Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unhardcode AI defensive targets and air units.
- Loading branch information
1 parent
9bcbbdd
commit 6b76ea6
Showing
11 changed files
with
105 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
OpenRA.Mods.Common/UpdateRules/Rules/UnhardcodeSquadManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#region Copyright & License Information | ||
/* | ||
* Copyright 2007-2021 The OpenRA Developers (see AUTHORS) | ||
* This file is part of OpenRA, which is free software. It is made | ||
* available to you under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation, either version 3 of | ||
* the License, or (at your option) any later version. For more | ||
* information, see COPYING. | ||
*/ | ||
#endregion | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using OpenRA.Mods.Common.Traits; | ||
|
||
namespace OpenRA.Mods.Common.UpdateRules.Rules | ||
{ | ||
public class UnhardcodeSquadManager : UpdateRule | ||
{ | ||
public override string Name => "SquadManagerBotModule got new fields to configure ground attacks and defensive actions."; | ||
|
||
public override string Description => "AirUnitsTypes and ProtectionTypes were added."; | ||
|
||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode) | ||
{ | ||
var addNodes = new List<MiniYamlNode>(); | ||
var squadManagers = new List<MiniYamlNode>(); | ||
|
||
foreach (var squadManager in actorNode.ChildrenMatching("SquadManagerBotModule")) | ||
squadManagers.Add(squadManager); | ||
|
||
var aircraft = modData.DefaultRules.Actors.Values.Where(a => a.HasTraitInfo<AircraftInfo>() && a.HasTraitInfo<AttackBaseInfo>()).Select(a => a.Name); | ||
var airUnits = new MiniYamlNode("AirUnitsTypes", FieldSaver.FormatValue(aircraft.ToList())); | ||
addNodes.Add(airUnits); | ||
|
||
var vips = modData.DefaultRules.Actors.Values.Where(a => a.HasTraitInfo<HarvesterInfo>() || a.HasTraitInfo<BaseBuildingInfo>()).Select(a => a.Name); | ||
var protection = new MiniYamlNode("ProtectionTypes", FieldSaver.FormatValue(vips.ToList())); | ||
addNodes.Add(protection); | ||
|
||
foreach (var squadManager in squadManagers) | ||
foreach (var addNode in addNodes) | ||
squadManager.AddNode(addNode); | ||
|
||
yield break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,3 @@ LST.Reinforcement: | |
powerproxy.parabombs: | ||
AirstrikePower: | ||
DisplayBeacon: False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ E3: | |
CA: | ||
Buildable: | ||
Prerequisites: ~syrd, dome | ||
|
||
HELI: | ||
Buildable: | ||
Prerequisites: ~hpad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ E3: | |
CA: | ||
Buildable: | ||
Prerequisites: ~syrd, dome | ||
|
||
HELI: | ||
Buildable: | ||
Prerequisites: ~hpad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters