Remove RenderSimple

All traits inheriting from it have been removed, and WithSpriteBody can
now take its place.
This commit is contained in:
reaperrr
2015-07-15 07:28:18 +02:00
parent 7c7506fafb
commit c272e790e5
5 changed files with 33 additions and 77 deletions

View File

@@ -404,7 +404,6 @@
<Compile Include="Traits\Render\RenderSpritesEditorOnly.cs" /> <Compile Include="Traits\Render\RenderSpritesEditorOnly.cs" />
<Compile Include="Traits\Render\WithTurretedSpriteBody.cs" /> <Compile Include="Traits\Render\WithTurretedSpriteBody.cs" />
<Compile Include="Traits\Render\RenderNameTag.cs" /> <Compile Include="Traits\Render\RenderNameTag.cs" />
<Compile Include="Traits\Render\RenderSimple.cs" />
<Compile Include="Traits\Render\RenderSprites.cs" /> <Compile Include="Traits\Render\RenderSprites.cs" />
<Compile Include="Traits\Render\WithWallSpriteBody.cs" /> <Compile Include="Traits\Render\WithWallSpriteBody.cs" />
<Compile Include="Traits\Render\RenderDetectionCircle.cs" /> <Compile Include="Traits\Render\RenderDetectionCircle.cs" />

View File

@@ -1,73 +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 System.Collections.Generic;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Basic render trait for immobile actors. Deprecated, use RenderSprites + WithSpriteBody instead.")]
public class RenderSimpleInfo : RenderSpritesInfo, IRenderActorPreviewSpritesInfo, Requires<IBodyOrientationInfo>
{
[SequenceReference] public readonly string Sequence = "idle";
public override object Create(ActorInitializer init) { return new RenderSimple(init, this); }
public virtual IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
{
var ifacing = init.Actor.Traits.GetOrDefault<IFacingInfo>();
var facing = ifacing != null ? init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : ifacing.GetInitialFacing() : 0;
var anim = new Animation(init.World, image, () => facing);
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence));
yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
}
}
public class RenderSimple : RenderSprites, IAutoSelectionSize
{
public readonly Animation DefaultAnimation;
readonly RenderSimpleInfo info;
public RenderSimple(ActorInitializer init, RenderSimpleInfo info, Func<int> baseFacing)
: base(init, info)
{
this.info = info;
DefaultAnimation = new Animation(init.World, GetImage(init.Self), baseFacing);
Add(DefaultAnimation);
}
public RenderSimple(ActorInitializer init, RenderSimpleInfo info)
: this(init, info, MakeFacingFunc(init.Self))
{
DefaultAnimation.PlayRepeating(NormalizeSequence(init.Self, info.Sequence));
}
public int2 SelectionSize(Actor self) { return AutoSelectionSize(self); }
public string NormalizeSequence(Actor self, string sequence)
{
return NormalizeSequence(DefaultAnimation, self.GetDamageState(), sequence);
}
public void PlayCustomAnim(Actor self, string name)
{
if (DefaultAnimation.HasSequence(name))
DefaultAnimation.PlayThen(NormalizeSequence(self, name),
() => DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence)));
}
}
}

View File

@@ -222,7 +222,7 @@ namespace OpenRA.Mods.Common.Traits
return sequence; return sequence;
} }
// Required by RenderSimple, WithSpriteBody and WithInfantryBody // Required by WithSpriteBody and WithInfantryBody
public int2 AutoSelectionSize(Actor self) public int2 AutoSelectionSize(Actor self)
{ {
return anims.Where(b => b.IsVisible return anims.Where(b => b.IsVisible

View File

@@ -2058,6 +2058,32 @@ namespace OpenRA.Mods.Common.UtilityCommands
node.Key = "RotationPaletteEffect"; node.Key = "RotationPaletteEffect";
} }
// Replace RenderSimple with RenderSprites + WithSpriteBody + AutoSelectionSize
if (engineVersion < 20150909)
{
if (depth == 0)
{
var rs = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderSimple"));
if (rs != null)
{
rs.Key = "RenderSprites";
var wsbNodes = rs.Value.Nodes.Where(n => n.Key == "Sequence").ToList();
if (wsbNodes.Any())
node.Value.Nodes.Add(new MiniYamlNode("WithSpriteBody", new MiniYaml("", wsbNodes)));
else
node.Value.Nodes.Add(new MiniYamlNode("WithSpriteBody", ""));
node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", ""));
rs.Value.Nodes.RemoveAll(n => wsbNodes.Contains(n));
}
var rrs = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderSimple"));
if (rrs != null)
rrs.Key = "-WithSpriteBody";
}
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
} }
} }

View File

@@ -12,7 +12,9 @@ MINP:
NotifyAppliedDamage: false NotifyAppliedDamage: false
Armor: Armor:
Type: Light Type: Light
RenderSimple: RenderSprites:
WithSpriteBody:
AutoSelectionSize:
Cloak: Cloak:
CloakSound: CloakSound:
UncloakSound: UncloakSound:
@@ -43,7 +45,9 @@ MINV:
NotifyAppliedDamage: false NotifyAppliedDamage: false
Armor: Armor:
Type: Light Type: Light
RenderSimple: RenderSprites:
WithSpriteBody:
AutoSelectionSize:
Cloak: Cloak:
CloakSound: CloakSound:
UncloakSound: UncloakSound: