diff --git a/OpenRA.Mods.Cnc/UtilityCommands/LegacyRulesImporter.cs b/OpenRA.Mods.Cnc/UtilityCommands/LegacyRulesImporter.cs
index 93200bfcf1..947dec7d89 100644
--- a/OpenRA.Mods.Cnc/UtilityCommands/LegacyRulesImporter.cs
+++ b/OpenRA.Mods.Cnc/UtilityCommands/LegacyRulesImporter.cs
@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
var crewed = rulesSection.GetValue("Crewed", string.Empty);
if (!string.IsNullOrEmpty(crewed) && crewed == "yes")
- Console.WriteLine("\tEmitInfantryOnSell:");
+ Console.WriteLine("\tSpawnActorsOnSell:");
var deploysInto = rulesSection.GetValue("DeploysInto", string.Empty);
if (!string.IsNullOrEmpty(deploysInto))
diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
index 4051d37f47..aae092c0bc 100644
--- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
+++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
@@ -353,7 +353,7 @@
-
+
@@ -881,6 +881,7 @@
+
diff --git a/OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs b/OpenRA.Mods.Common/Traits/SpawnActorsOnSell.cs
similarity index 85%
rename from OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs
rename to OpenRA.Mods.Common/Traits/SpawnActorsOnSell.cs
index 92aa921b15..1591712fc6 100644
--- a/OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs
+++ b/OpenRA.Mods.Common/Traits/SpawnActorsOnSell.cs
@@ -17,28 +17,28 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Spawn new actors when sold.")]
- public class EmitInfantryOnSellInfo : ITraitInfo
+ public class SpawnActorsOnSellInfo : ITraitInfo
{
public readonly int ValuePercent = 40;
public readonly int MinHpPercent = 30;
- [ActorReference]
- [Desc("Be sure to use lowercase.")]
- public readonly string[] ActorTypes;
+ [ActorReference, FieldLoader.Require]
+ [Desc("Actor types to spawn on sell. Be sure to use lowercase.")]
+ public readonly string[] ActorTypes = null;
[Desc("Spawns actors only if the selling player's faction is in this list. " +
"Leave empty to allow all factions by default.")]
public readonly HashSet Factions = new HashSet();
- public object Create(ActorInitializer init) { return new EmitInfantryOnSell(init.Self, this); }
+ public object Create(ActorInitializer init) { return new SpawnActorsOnSell(init.Self, this); }
}
- public class EmitInfantryOnSell : INotifySold
+ public class SpawnActorsOnSell : INotifySold
{
- readonly EmitInfantryOnSellInfo info;
+ readonly SpawnActorsOnSellInfo info;
readonly bool correctFaction;
- public EmitInfantryOnSell(Actor self, EmitInfantryOnSellInfo info)
+ public SpawnActorsOnSell(Actor self, SpawnActorsOnSellInfo info)
{
this.info = info;
var factionsList = info.Factions;
diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/RenameEmitInfantryOnSell.cs b/OpenRA.Mods.Common/UpdateRules/Rules/RenameEmitInfantryOnSell.cs
new file mode 100644
index 0000000000..e79abc91d8
--- /dev/null
+++ b/OpenRA.Mods.Common/UpdateRules/Rules/RenameEmitInfantryOnSell.cs
@@ -0,0 +1,45 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007-2018 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;
+
+namespace OpenRA.Mods.Common.UpdateRules.Rules
+{
+ public class RenameEmitInfantryOnSell : UpdateRule
+ {
+ public override string Name { get { return "EmitInfantryOnSell renamed to SpawnActorsOnSell"; } }
+ public override string Description
+ {
+ get
+ {
+ return "The EmitInfantryOnSell trait was renamed to SpawnActorsOnSell and the default\n" +
+ "actor type to spawn was removed. Uses of the old traits and defaults are updated\n" +
+ "to account for this.";
+ }
+ }
+
+ public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode)
+ {
+ foreach (var uneios in actorNode.ChildrenMatching("-EmitInfantryOnSell"))
+ uneios.RenameKeyPreservingSuffix("-SpawnActorsOnSell");
+
+ foreach (var eios in actorNode.ChildrenMatching("EmitInfantryOnSell"))
+ {
+ eios.RenameKeyPreservingSuffix("SpawnActorsOnSell");
+ var actortypes = eios.LastChildMatching("ActorTypes");
+ if (actortypes == null)
+ eios.AddNode("ActorTypes", "e1");
+ }
+
+ yield break;
+ }
+ }
+}
diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs
index 3e7de09e52..cf766216dd 100644
--- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs
+++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs
@@ -52,7 +52,8 @@ namespace OpenRA.Mods.Common.UpdateRules
new AddEditorPlayer(),
new RemovePaletteFromCurrentTileset(),
new DefineLocomotors(),
- new DefineOwnerLostAction()
+ new DefineOwnerLostAction(),
+ new RenameEmitInfantryOnSell()
})
};
diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml
index 24ae8aefa4..7a1e94f2ff 100644
--- a/mods/cnc/rules/defaults.yaml
+++ b/mods/cnc/rules/defaults.yaml
@@ -689,7 +689,7 @@
UseDeathTypeSuffix: false
GivesBuildableArea:
AreaTypes: building
- EmitInfantryOnSell:
+ SpawnActorsOnSell:
ActorTypes: e6,e1,e1,e1
EngineerRepairable:
Sellable:
diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml
index e78712f563..277c3be73f 100644
--- a/mods/cnc/rules/structures.yaml
+++ b/mods/cnc/rules/structures.yaml
@@ -243,7 +243,7 @@ SILO:
PipCount: 10
PipColor: Green
Capacity: 3000
- -EmitInfantryOnSell:
+ -SpawnActorsOnSell:
Power:
Amount: -10
MustBeDestroyed:
@@ -865,7 +865,7 @@ OBLI:
RequiresCondition: charging
SoundFiles: obelpowr.aud
Interval: 30, 40
- -EmitInfantryOnSell:
+ -SpawnActorsOnSell:
DetectCloaked:
Range: 5c0
RequiresCondition: !lowpower
diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml
index 5b1cf4f953..9dea8d40bb 100644
--- a/mods/d2k/rules/defaults.yaml
+++ b/mods/d2k/rules/defaults.yaml
@@ -398,7 +398,7 @@
RepairableBuilding:
RepairStep: 500
PlayerExperience: 25
- EmitInfantryOnSell:
+ SpawnActorsOnSell:
ActorTypes: light_inf
MustBeDestroyed:
RequiredForShortGame: true
diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml
index 7805630845..34523cc3e3 100644
--- a/mods/d2k/rules/structures.yaml
+++ b/mods/d2k/rules/structures.yaml
@@ -85,7 +85,7 @@ construction_yard:
Name: Construction Yard
CustomSellValue:
Value: 2000
- EmitInfantryOnSell:
+ SpawnActorsOnSell:
ActorTypes: light_inf, light_inf, engineer
BaseBuilding:
ProductionBar:
@@ -351,7 +351,7 @@ silo:
PipColor: green
PipCount: 5
Capacity: 2000
- -EmitInfantryOnSell:
+ -SpawnActorsOnSell:
Power:
Amount: -15
MustBeDestroyed:
diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml
index 05453af4cf..0960da8a79 100644
--- a/mods/ra/rules/defaults.yaml
+++ b/mods/ra/rules/defaults.yaml
@@ -614,7 +614,7 @@
WithMakeAnimation:
ExternalCapturable:
ExternalCapturableBar:
- EmitInfantryOnSell:
+ SpawnActorsOnSell:
ActorTypes: e1,e1,e1,tecn,tecn
MustBeDestroyed:
RequiredForShortGame: true
@@ -625,7 +625,7 @@
^ScienceBuilding:
Inherits: ^Building
- EmitInfantryOnSell:
+ SpawnActorsOnSell:
ActorTypes: e1,e1,e1,e1,tecn,tecn,tecn,tecn,tecn,tecn,tecn,tecn,tecn,tecn,e6,e6,e6,e6,e6,chan,chan,chan,chan
^Defense:
@@ -720,7 +720,7 @@
Sequence: tag-fake
ReferencePoint: Top
ZOffset: 256
- -EmitInfantryOnSell:
+ -SpawnActorsOnSell:
-MustBeDestroyed:
EditorTilesetFilter:
Categories: Fake
diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml
index 257012ff52..46bea19461 100644
--- a/mods/ra/rules/structures.yaml
+++ b/mods/ra/rules/structures.yaml
@@ -183,7 +183,7 @@ SPEN:
Produces: Ship, Submarine
PrimaryBuilding:
PrimaryCondition: primary
- -EmitInfantryOnSell:
+ -SpawnActorsOnSell:
RepairsUnits:
HpPerStep: 1000
FinishRepairingNotification: UnitRepaired
@@ -296,7 +296,7 @@ SYRD:
Produces: Ship, Boat
PrimaryBuilding:
PrimaryCondition: primary
- -EmitInfantryOnSell:
+ -SpawnActorsOnSell:
RepairsUnits:
HpPerStep: 1000
FinishRepairingNotification: UnitRepaired
@@ -672,7 +672,7 @@ PBOX:
MaxWeight: 1
PipCount: 1
InitialUnits: e1
- -EmitInfantryOnSell:
+ -SpawnActorsOnSell:
AttackGarrisoned:
Armaments: garrisoned
PortOffsets: 384,0,128, 224,-341,128, -224,-341,128, -384,0,128, -224,341,128, 224,341,128
@@ -727,7 +727,7 @@ HBOX:
MaxWeight: 1
PipCount: 1
InitialUnits: e1
- -EmitInfantryOnSell:
+ -SpawnActorsOnSell:
DetectCloaked:
Range: 6c0
RenderRangeCircle:
@@ -1084,7 +1084,7 @@ FACT:
Name: Construction Yard
CustomSellValue:
Value: 2500
- EmitInfantryOnSell:
+ SpawnActorsOnSell:
ActorTypes: e1,e1,e1,tecn,tecn,e6
BaseBuilding:
Transforms:
@@ -1211,7 +1211,7 @@ SILO:
StoresResources:
PipCount: 5
Capacity: 3000
- -EmitInfantryOnSell:
+ -SpawnActorsOnSell:
Power:
Amount: -10
Explodes:
@@ -1685,7 +1685,7 @@ KENN:
PrimaryBuilding:
PrimaryCondition: primary
ProductionBar:
- -EmitInfantryOnSell:
+ -SpawnActorsOnSell:
Power:
Amount: -10
ProvidesPrerequisite@buildingname:
diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml
index 0bcf499edf..ac2f75484a 100644
--- a/mods/ts/rules/defaults.yaml
+++ b/mods/ts/rules/defaults.yaml
@@ -349,10 +349,10 @@
WithDeathAnimation:
DeathSequence: dead
UseDeathTypeSuffix: false
- EmitInfantryOnSell@gdi:
+ SpawnActorsOnSell@gdi:
ActorTypes: e1, e1, e2, medic
Factions: gdi
- EmitInfantryOnSell@nod:
+ SpawnActorsOnSell@nod:
ActorTypes: e1, e1, e1, e3, e3
Factions: nod
MustBeDestroyed: