Removed RenderUnit
Used this opportunity to unhardcode several sandworm-related sequences.
This commit is contained in:
@@ -400,7 +400,6 @@
|
||||
<Compile Include="Traits\Render\RenderNameTag.cs" />
|
||||
<Compile Include="Traits\Render\RenderSimple.cs" />
|
||||
<Compile Include="Traits\Render\RenderSprites.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnit.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingSilo.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingWall.cs" />
|
||||
<Compile Include="Traits\Render\RenderDetectionCircle.cs" />
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 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. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Render trait for non-animated actors that have sprites facing into each direction.",
|
||||
"Deprecated. This will soon be removed, use RenderSprites + WithFacingSpriteBody instead.")]
|
||||
public class RenderUnitInfo : RenderSimpleInfo, Requires<IFacingInfo>
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderUnit(init, this); }
|
||||
}
|
||||
|
||||
public class RenderUnit : RenderSimple, ISpriteBody
|
||||
{
|
||||
readonly RenderUnitInfo info;
|
||||
|
||||
public RenderUnit(ActorInitializer init, RenderUnitInfo info)
|
||||
: base(init, info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void PlayCustomAnimation(Actor self, string newAnimation, Action after)
|
||||
{
|
||||
DefaultAnimation.PlayThen(newAnimation, () => { DefaultAnimation.Play(info.Sequence); if (after != null) after(); });
|
||||
}
|
||||
|
||||
public void PlayCustomAnimationRepeating(Actor self, string name)
|
||||
{
|
||||
DefaultAnimation.PlayThen(name,
|
||||
() => PlayCustomAnimationRepeating(self, name));
|
||||
}
|
||||
|
||||
public void PlayCustomAnimationBackwards(Actor self, string name, Action after)
|
||||
{
|
||||
DefaultAnimation.PlayBackwardsThen(name,
|
||||
() => { DefaultAnimation.PlayRepeating(info.Sequence); if (after != null) after(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1317,6 +1317,38 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (rrh != null)
|
||||
rrh.Key = "-WithHarvestAnimation";
|
||||
}
|
||||
|
||||
// Replace RenderUnit with RenderSprites + WithFacingSpriteBody + AutoSelectionSize.
|
||||
// Normally this should have been removed by previous upgrade rules, but let's run this again
|
||||
// to make sure to get rid of potential left-over cases like D2k sandworms and harvesters.
|
||||
if (depth == 0)
|
||||
{
|
||||
var childKeys = new[] { "Sequence" };
|
||||
|
||||
var ru = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderUnit"));
|
||||
if (ru != null)
|
||||
{
|
||||
ru.Key = "WithFacingSpriteBody";
|
||||
|
||||
var rsNodes = ru.Value.Nodes.Where(n => !childKeys.Contains(n.Key)).ToList();
|
||||
|
||||
if (rsNodes.Any())
|
||||
node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", new MiniYaml("", rsNodes)));
|
||||
else
|
||||
node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", ""));
|
||||
|
||||
node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", ""));
|
||||
|
||||
ru.Value.Nodes.RemoveAll(n => rsNodes.Contains(n));
|
||||
|
||||
Console.WriteLine("RenderUnit has now been removed from code.");
|
||||
Console.WriteLine("Use RenderSprites + WithFacingSpriteBody (+ AutoSelectionSize, if necessary) instead.");
|
||||
}
|
||||
|
||||
var rru = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderUnit"));
|
||||
if (rru != null)
|
||||
rru.Key = "-WithFacingSpriteBody";
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
|
||||
Reference in New Issue
Block a user