Rename EmitInfantryOnSell and remove default actor type.

This commit is contained in:
lawando
2018-06-01 10:15:11 +02:00
committed by reaperrr
parent 3d79541148
commit 7dd64445fc
12 changed files with 76 additions and 29 deletions

View File

@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
var crewed = rulesSection.GetValue("Crewed", string.Empty); var crewed = rulesSection.GetValue("Crewed", string.Empty);
if (!string.IsNullOrEmpty(crewed) && crewed == "yes") if (!string.IsNullOrEmpty(crewed) && crewed == "yes")
Console.WriteLine("\tEmitInfantryOnSell:"); Console.WriteLine("\tSpawnActorsOnSell:");
var deploysInto = rulesSection.GetValue("DeploysInto", string.Empty); var deploysInto = rulesSection.GetValue("DeploysInto", string.Empty);
if (!string.IsNullOrEmpty(deploysInto)) if (!string.IsNullOrEmpty(deploysInto))

View File

@@ -353,7 +353,7 @@
<Compile Include="Traits\DetectCloaked.cs" /> <Compile Include="Traits\DetectCloaked.cs" />
<Compile Include="Traits\EditorTilesetFilter.cs" /> <Compile Include="Traits\EditorTilesetFilter.cs" />
<Compile Include="Traits\EjectOnDeath.cs" /> <Compile Include="Traits\EjectOnDeath.cs" />
<Compile Include="Traits\EmitInfantryOnSell.cs" /> <Compile Include="Traits\SpawnActorsOnSell.cs" />
<Compile Include="Traits\EngineerRepair.cs" /> <Compile Include="Traits\EngineerRepair.cs" />
<Compile Include="Traits\Explodes.cs" /> <Compile Include="Traits\Explodes.cs" />
<Compile Include="Traits\ExplosionOnDamageTransition.cs" /> <Compile Include="Traits\ExplosionOnDamageTransition.cs" />
@@ -881,6 +881,7 @@
<Compile Include="UtilityCommands\DumpSequenceSheetsCommand.cs" /> <Compile Include="UtilityCommands\DumpSequenceSheetsCommand.cs" />
<Compile Include="UpdateRules\Rules\DefineLocomotors.cs" /> <Compile Include="UpdateRules\Rules\DefineLocomotors.cs" />
<Compile Include="UpdateRules\Rules\DefineOwnerLostAction.cs" /> <Compile Include="UpdateRules\Rules\DefineOwnerLostAction.cs" />
<Compile Include="UpdateRules\Rules\RenameEmitInfantryOnSell.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild"> <Target Name="AfterBuild">

View File

@@ -17,28 +17,28 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Spawn new actors when sold.")] [Desc("Spawn new actors when sold.")]
public class EmitInfantryOnSellInfo : ITraitInfo public class SpawnActorsOnSellInfo : ITraitInfo
{ {
public readonly int ValuePercent = 40; public readonly int ValuePercent = 40;
public readonly int MinHpPercent = 30; public readonly int MinHpPercent = 30;
[ActorReference] [ActorReference, FieldLoader.Require]
[Desc("Be sure to use lowercase.")] [Desc("Actor types to spawn on sell. Be sure to use lowercase.")]
public readonly string[] ActorTypes; public readonly string[] ActorTypes = null;
[Desc("Spawns actors only if the selling player's faction is in this list. " + [Desc("Spawns actors only if the selling player's faction is in this list. " +
"Leave empty to allow all factions by default.")] "Leave empty to allow all factions by default.")]
public readonly HashSet<string> Factions = new HashSet<string>(); public readonly HashSet<string> Factions = new HashSet<string>();
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; readonly bool correctFaction;
public EmitInfantryOnSell(Actor self, EmitInfantryOnSellInfo info) public SpawnActorsOnSell(Actor self, SpawnActorsOnSellInfo info)
{ {
this.info = info; this.info = info;
var factionsList = info.Factions; var factionsList = info.Factions;

View File

@@ -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<string> 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;
}
}
}

View File

@@ -52,7 +52,8 @@ namespace OpenRA.Mods.Common.UpdateRules
new AddEditorPlayer(), new AddEditorPlayer(),
new RemovePaletteFromCurrentTileset(), new RemovePaletteFromCurrentTileset(),
new DefineLocomotors(), new DefineLocomotors(),
new DefineOwnerLostAction() new DefineOwnerLostAction(),
new RenameEmitInfantryOnSell()
}) })
}; };

View File

@@ -689,7 +689,7 @@
UseDeathTypeSuffix: false UseDeathTypeSuffix: false
GivesBuildableArea: GivesBuildableArea:
AreaTypes: building AreaTypes: building
EmitInfantryOnSell: SpawnActorsOnSell:
ActorTypes: e6,e1,e1,e1 ActorTypes: e6,e1,e1,e1
EngineerRepairable: EngineerRepairable:
Sellable: Sellable:

View File

@@ -243,7 +243,7 @@ SILO:
PipCount: 10 PipCount: 10
PipColor: Green PipColor: Green
Capacity: 3000 Capacity: 3000
-EmitInfantryOnSell: -SpawnActorsOnSell:
Power: Power:
Amount: -10 Amount: -10
MustBeDestroyed: MustBeDestroyed:
@@ -865,7 +865,7 @@ OBLI:
RequiresCondition: charging RequiresCondition: charging
SoundFiles: obelpowr.aud SoundFiles: obelpowr.aud
Interval: 30, 40 Interval: 30, 40
-EmitInfantryOnSell: -SpawnActorsOnSell:
DetectCloaked: DetectCloaked:
Range: 5c0 Range: 5c0
RequiresCondition: !lowpower RequiresCondition: !lowpower

View File

@@ -398,7 +398,7 @@
RepairableBuilding: RepairableBuilding:
RepairStep: 500 RepairStep: 500
PlayerExperience: 25 PlayerExperience: 25
EmitInfantryOnSell: SpawnActorsOnSell:
ActorTypes: light_inf ActorTypes: light_inf
MustBeDestroyed: MustBeDestroyed:
RequiredForShortGame: true RequiredForShortGame: true

View File

@@ -85,7 +85,7 @@ construction_yard:
Name: Construction Yard Name: Construction Yard
CustomSellValue: CustomSellValue:
Value: 2000 Value: 2000
EmitInfantryOnSell: SpawnActorsOnSell:
ActorTypes: light_inf, light_inf, engineer ActorTypes: light_inf, light_inf, engineer
BaseBuilding: BaseBuilding:
ProductionBar: ProductionBar:
@@ -351,7 +351,7 @@ silo:
PipColor: green PipColor: green
PipCount: 5 PipCount: 5
Capacity: 2000 Capacity: 2000
-EmitInfantryOnSell: -SpawnActorsOnSell:
Power: Power:
Amount: -15 Amount: -15
MustBeDestroyed: MustBeDestroyed:

View File

@@ -614,7 +614,7 @@
WithMakeAnimation: WithMakeAnimation:
ExternalCapturable: ExternalCapturable:
ExternalCapturableBar: ExternalCapturableBar:
EmitInfantryOnSell: SpawnActorsOnSell:
ActorTypes: e1,e1,e1,tecn,tecn ActorTypes: e1,e1,e1,tecn,tecn
MustBeDestroyed: MustBeDestroyed:
RequiredForShortGame: true RequiredForShortGame: true
@@ -625,7 +625,7 @@
^ScienceBuilding: ^ScienceBuilding:
Inherits: ^Building 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 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: ^Defense:
@@ -720,7 +720,7 @@
Sequence: tag-fake Sequence: tag-fake
ReferencePoint: Top ReferencePoint: Top
ZOffset: 256 ZOffset: 256
-EmitInfantryOnSell: -SpawnActorsOnSell:
-MustBeDestroyed: -MustBeDestroyed:
EditorTilesetFilter: EditorTilesetFilter:
Categories: Fake Categories: Fake

View File

@@ -183,7 +183,7 @@ SPEN:
Produces: Ship, Submarine Produces: Ship, Submarine
PrimaryBuilding: PrimaryBuilding:
PrimaryCondition: primary PrimaryCondition: primary
-EmitInfantryOnSell: -SpawnActorsOnSell:
RepairsUnits: RepairsUnits:
HpPerStep: 1000 HpPerStep: 1000
FinishRepairingNotification: UnitRepaired FinishRepairingNotification: UnitRepaired
@@ -296,7 +296,7 @@ SYRD:
Produces: Ship, Boat Produces: Ship, Boat
PrimaryBuilding: PrimaryBuilding:
PrimaryCondition: primary PrimaryCondition: primary
-EmitInfantryOnSell: -SpawnActorsOnSell:
RepairsUnits: RepairsUnits:
HpPerStep: 1000 HpPerStep: 1000
FinishRepairingNotification: UnitRepaired FinishRepairingNotification: UnitRepaired
@@ -672,7 +672,7 @@ PBOX:
MaxWeight: 1 MaxWeight: 1
PipCount: 1 PipCount: 1
InitialUnits: e1 InitialUnits: e1
-EmitInfantryOnSell: -SpawnActorsOnSell:
AttackGarrisoned: AttackGarrisoned:
Armaments: garrisoned Armaments: garrisoned
PortOffsets: 384,0,128, 224,-341,128, -224,-341,128, -384,0,128, -224,341,128, 224,341,128 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 MaxWeight: 1
PipCount: 1 PipCount: 1
InitialUnits: e1 InitialUnits: e1
-EmitInfantryOnSell: -SpawnActorsOnSell:
DetectCloaked: DetectCloaked:
Range: 6c0 Range: 6c0
RenderRangeCircle: RenderRangeCircle:
@@ -1084,7 +1084,7 @@ FACT:
Name: Construction Yard Name: Construction Yard
CustomSellValue: CustomSellValue:
Value: 2500 Value: 2500
EmitInfantryOnSell: SpawnActorsOnSell:
ActorTypes: e1,e1,e1,tecn,tecn,e6 ActorTypes: e1,e1,e1,tecn,tecn,e6
BaseBuilding: BaseBuilding:
Transforms: Transforms:
@@ -1211,7 +1211,7 @@ SILO:
StoresResources: StoresResources:
PipCount: 5 PipCount: 5
Capacity: 3000 Capacity: 3000
-EmitInfantryOnSell: -SpawnActorsOnSell:
Power: Power:
Amount: -10 Amount: -10
Explodes: Explodes:
@@ -1685,7 +1685,7 @@ KENN:
PrimaryBuilding: PrimaryBuilding:
PrimaryCondition: primary PrimaryCondition: primary
ProductionBar: ProductionBar:
-EmitInfantryOnSell: -SpawnActorsOnSell:
Power: Power:
Amount: -10 Amount: -10
ProvidesPrerequisite@buildingname: ProvidesPrerequisite@buildingname:

View File

@@ -349,10 +349,10 @@
WithDeathAnimation: WithDeathAnimation:
DeathSequence: dead DeathSequence: dead
UseDeathTypeSuffix: false UseDeathTypeSuffix: false
EmitInfantryOnSell@gdi: SpawnActorsOnSell@gdi:
ActorTypes: e1, e1, e2, medic ActorTypes: e1, e1, e2, medic
Factions: gdi Factions: gdi
EmitInfantryOnSell@nod: SpawnActorsOnSell@nod:
ActorTypes: e1, e1, e1, e3, e3 ActorTypes: e1, e1, e1, e3, e3
Factions: nod Factions: nod
MustBeDestroyed: MustBeDestroyed: