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

@@ -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()
})
};