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);
if (!string.IsNullOrEmpty(crewed) && crewed == "yes")
Console.WriteLine("\tEmitInfantryOnSell:");
Console.WriteLine("\tSpawnActorsOnSell:");
var deploysInto = rulesSection.GetValue("DeploysInto", string.Empty);
if (!string.IsNullOrEmpty(deploysInto))

View File

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

View File

@@ -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<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;
public EmitInfantryOnSell(Actor self, EmitInfantryOnSellInfo info)
public SpawnActorsOnSell(Actor self, SpawnActorsOnSellInfo info)
{
this.info = info;
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 RemovePaletteFromCurrentTileset(),
new DefineLocomotors(),
new DefineOwnerLostAction()
new DefineOwnerLostAction(),
new RenameEmitInfantryOnSell()
})
};

View File

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

View File

@@ -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

View File

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

View File

@@ -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:

View File

@@ -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

View File

@@ -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:

View File

@@ -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: