diff --git a/OpenRA.Mods.Common/Activities/SpriteHarvesterDockSequence.cs b/OpenRA.Mods.Common/Activities/SpriteHarvesterDockSequence.cs
index 680eb2135a..a5b78bdc92 100644
--- a/OpenRA.Mods.Common/Activities/SpriteHarvesterDockSequence.cs
+++ b/OpenRA.Mods.Common/Activities/SpriteHarvesterDockSequence.cs
@@ -25,14 +25,14 @@ namespace OpenRA.Mods.Common.Activities
public override Activity OnStateDock(Actor self)
{
- ru.PlayCustomAnimation(self, "dock", () => ru.PlayCustomAnimRepeating(self, "dock-loop"));
+ ru.PlayCustomAnimation(self, "dock", () => ru.PlayCustomAnimationRepeating(self, "dock-loop"));
dockingState = State.Loop;
return this;
}
public override Activity OnStateUndock(Actor self)
{
- ru.PlayCustomAnimBackwards(self, "dock", () => dockingState = State.Complete);
+ ru.PlayCustomAnimationBackwards(self, "dock", () => dockingState = State.Complete);
dockingState = State.Wait;
return this;
}
diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
index 2ea74f4762..341a16092b 100644
--- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
+++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
@@ -372,7 +372,6 @@
-
@@ -402,8 +401,8 @@
+
-
diff --git a/OpenRA.Mods.Common/Traits/Render/RenderFlare.cs b/OpenRA.Mods.Common/Traits/Render/RenderFlare.cs
deleted file mode 100644
index 92fc4f3269..0000000000
--- a/OpenRA.Mods.Common/Traits/Render/RenderFlare.cs
+++ /dev/null
@@ -1,28 +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
-
-namespace OpenRA.Mods.Common.Traits
-{
- class RenderFlareInfo : RenderSimpleInfo
- {
- public readonly string OpenSequence = "open";
-
- public override object Create(ActorInitializer init) { return new RenderFlare(init, this); }
- }
-
- class RenderFlare : RenderSimple
- {
- public RenderFlare(ActorInitializer init, RenderFlareInfo info)
- : base(init, info, () => 0)
- {
- DefaultAnimation.PlayThen(info.OpenSequence, () => DefaultAnimation.PlayRepeating(info.Sequence));
- }
- }
-}
diff --git a/OpenRA.Mods.Common/Traits/Render/RenderUnit.cs b/OpenRA.Mods.Common/Traits/Render/RenderUnit.cs
index 03105eb208..1abfc5fc05 100644
--- a/OpenRA.Mods.Common/Traits/Render/RenderUnit.cs
+++ b/OpenRA.Mods.Common/Traits/Render/RenderUnit.cs
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new RenderUnit(init, this); }
}
- public class RenderUnit : RenderSimple
+ public class RenderUnit : RenderSimple, ISpriteBody
{
readonly RenderUnitInfo info;
@@ -28,18 +28,18 @@ namespace OpenRA.Mods.Common.Traits
this.info = info;
}
- public void PlayCustomAnimation(Actor self, string newAnim, Action after)
+ public void PlayCustomAnimation(Actor self, string newAnimation, Action after)
{
- DefaultAnimation.PlayThen(newAnim, () => { DefaultAnimation.Play(info.Sequence); if (after != null) after(); });
+ DefaultAnimation.PlayThen(newAnimation, () => { DefaultAnimation.Play(info.Sequence); if (after != null) after(); });
}
- public void PlayCustomAnimRepeating(Actor self, string name)
+ public void PlayCustomAnimationRepeating(Actor self, string name)
{
DefaultAnimation.PlayThen(name,
- () => PlayCustomAnimRepeating(self, name));
+ () => PlayCustomAnimationRepeating(self, name));
}
- public void PlayCustomAnimBackwards(Actor self, string name, Action after)
+ public void PlayCustomAnimationBackwards(Actor self, string name, Action after)
{
DefaultAnimation.PlayBackwardsThen(name,
() => { DefaultAnimation.PlayRepeating(info.Sequence); if (after != null) after(); });
diff --git a/OpenRA.Mods.Common/Traits/Render/WithFire.cs b/OpenRA.Mods.Common/Traits/Render/WithFire.cs
deleted file mode 100644
index 8155717caa..0000000000
--- a/OpenRA.Mods.Common/Traits/Render/WithFire.cs
+++ /dev/null
@@ -1,35 +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 OpenRA.Graphics;
-using OpenRA.Traits;
-
-namespace OpenRA.Mods.Common.Traits
-{
- [Desc("Renders a flame sprite on top of the actor.")]
- class WithFireInfo : ITraitInfo, Requires
- {
- public readonly string StartSequence = "fire-start";
- public readonly string LoopSequence = "fire-loop";
-
- public object Create(ActorInitializer init) { return new WithFire(init.Self, this); }
- }
-
- class WithFire
- {
- public WithFire(Actor self, WithFireInfo info)
- {
- var rs = self.Trait();
- var fire = new Animation(self.World, rs.GetImage(self));
- fire.PlayThen(info.StartSequence, () => fire.PlayRepeating(info.LoopSequence));
- rs.Add(new AnimationWithOffset(fire, null, null, 1024));
- }
- }
-}
diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs
new file mode 100644
index 0000000000..d00cf49ae3
--- /dev/null
+++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs
@@ -0,0 +1,70 @@
+#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.Graphics;
+using OpenRA.Traits;
+
+namespace OpenRA.Mods.Common.Traits
+{
+ [Desc("Default trait for rendering sprite-based actors.")]
+ class WithSpriteBodyInfo : UpgradableTraitInfo, ITraitInfo, Requires
+ {
+ [Desc("Animation to play when the actor is created.")]
+ public readonly string StartSequence = null;
+
+ [Desc("Animation to play when the actor is idle.")]
+ public readonly string Sequence = "idle";
+
+ public object Create(ActorInitializer init) { return new WithSpriteBody(init, this); }
+ }
+
+ class WithSpriteBody : UpgradableTrait, ISpriteBody
+ {
+ readonly Animation body;
+ readonly WithSpriteBodyInfo info;
+
+ public WithSpriteBody(ActorInitializer init, WithSpriteBodyInfo info)
+ : base(info)
+ {
+ this.info = info;
+
+ var rs = init.Self.Trait();
+ body = new Animation(init.Self.World, rs.GetImage(init.Self));
+ PlayCustomAnimation(init.Self, info.StartSequence, () => body.PlayRepeating(info.Sequence));
+ rs.Add(new AnimationWithOffset(body, null, () => IsTraitDisabled));
+ }
+
+ public void PlayCustomAnimation(Actor self, string newAnimation, Action after)
+ {
+ body.PlayThen(newAnimation, () =>
+ {
+ body.Play(info.Sequence);
+ if (after != null)
+ after();
+ });
+ }
+
+ public void PlayCustomAnimationRepeating(Actor self, string name)
+ {
+ body.PlayThen(name, () => PlayCustomAnimationRepeating(self, name));
+ }
+
+ public void PlayCustomAnimationBackwards(Actor self, string name, Action after)
+ {
+ body.PlayBackwardsThen(name, () =>
+ {
+ body.PlayRepeating(info.Sequence);
+ if (after != null)
+ after();
+ });
+ }
+ }
+}
diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs
index 654b65021d..ec4ee7218f 100644
--- a/OpenRA.Mods.Common/TraitsInterfaces.cs
+++ b/OpenRA.Mods.Common/TraitsInterfaces.cs
@@ -8,6 +8,7 @@
*/
#endregion
+using System;
using System.Collections.Generic;
using OpenRA.Activities;
using OpenRA.Graphics;
@@ -17,6 +18,13 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
+ public interface ISpriteBody
+ {
+ void PlayCustomAnimation(Actor self, string newAnimation, Action after);
+ void PlayCustomAnimationRepeating(Actor self, string name);
+ void PlayCustomAnimationBackwards(Actor self, string name, Action after);
+ }
+
public interface INotifyResourceClaimLost
{
void OnNotifyResourceClaimLost(Actor self, ResourceClaim claim, Actor claimer);
diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs
index a9b2689e2f..b37cdaab7f 100644
--- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs
+++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs
@@ -905,6 +905,32 @@ namespace OpenRA.Mods.Common.UtilityCommands
}
}
+ if (engineVersion < 20150501)
+ {
+ // Change RenderFlare to RenderSprites + WithSpriteBody
+ var flares = node.Value.Nodes.Where(x => x.Key == "RenderFlare");
+ if (flares.Any())
+ {
+ flares.Do(x => x.Key = "RenderSprites");
+ node.Value.Nodes.Add(new MiniYamlNode("WithSpriteBody", "", new List
+ {
+ new MiniYamlNode("StartSequence", "open")
+ }));
+ }
+
+ // Change WithFire to RenderSprites + WithSpriteBody
+ var fire = node.Value.Nodes.Where(x => x.Key == "WithFire");
+ if (fire.Any())
+ {
+ fire.Do(x => x.Key = "RenderSprites");
+ node.Value.Nodes.Add(new MiniYamlNode("WithSpriteBody", "", new List
+ {
+ new MiniYamlNode("StartSequence", "fire-start"),
+ new MiniYamlNode("Sequence", "fire-loop")
+ }));
+ }
+ }
+
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}
diff --git a/OpenRA.Mods.RA/Traits/MadTank.cs b/OpenRA.Mods.RA/Traits/MadTank.cs
index 9ca8090e45..7082bb6052 100644
--- a/OpenRA.Mods.RA/Traits/MadTank.cs
+++ b/OpenRA.Mods.RA/Traits/MadTank.cs
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.RA.Traits
self.World.AddFrameEndTask(w => EjectDriver());
if (info.ThumpSequence != null)
- renderUnit.PlayCustomAnimRepeating(self, info.ThumpSequence);
+ renderUnit.PlayCustomAnimationRepeating(self, info.ThumpSequence);
deployed = true;
self.QueueActivity(new Wait(info.ChargeDelay, false));
self.QueueActivity(new CallFunc(() => Sound.Play(info.ChargeSound, self.CenterPosition)));
diff --git a/OpenRA.Mods.RA/Traits/Render/RenderLandingCraft.cs b/OpenRA.Mods.RA/Traits/Render/RenderLandingCraft.cs
index 66814e8402..b7ac4b2fc1 100644
--- a/OpenRA.Mods.RA/Traits/Render/RenderLandingCraft.cs
+++ b/OpenRA.Mods.RA/Traits/Render/RenderLandingCraft.cs
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA.Traits
PlayCustomAnimation(self, info.OpenAnim, () =>
{
if (DefaultAnimation.HasSequence(info.UnloadAnim))
- PlayCustomAnimRepeating(self, info.UnloadAnim);
+ PlayCustomAnimationRepeating(self, info.UnloadAnim);
});
}
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA.Traits
return;
open = false;
- PlayCustomAnimBackwards(self, info.OpenAnim, null);
+ PlayCustomAnimationBackwards(self, info.OpenAnim, null);
}
public override void Tick(Actor self)
diff --git a/mods/cnc/rules/tech.yaml b/mods/cnc/rules/tech.yaml
index 903a86ead1..216051e583 100644
--- a/mods/cnc/rules/tech.yaml
+++ b/mods/cnc/rules/tech.yaml
@@ -11,7 +11,10 @@ V19:
V19.Husk:
Inherits: ^CivBuildingHusk
- WithFire:
+ RenderSprites:
+ WithSpriteBody:
+ StartSequence: fire-start
+ Sequence: fire-loop
Building:
Footprint: x
Dimensions: 1,1
diff --git a/mods/ra/rules/civilian.yaml b/mods/ra/rules/civilian.yaml
index aac7b36659..d446c7a1e9 100644
--- a/mods/ra/rules/civilian.yaml
+++ b/mods/ra/rules/civilian.yaml
@@ -233,7 +233,10 @@ V19.Husk:
ExcludeTilesets: DESERT
Tooltip:
Name: Husk (Oil Pump)
- WithFire:
+ RenderSprites:
+ WithSpriteBody:
+ StartSequence: fire-start
+ Sequence: fire-loop
-Health:
-Selectable:
-TargetableBuilding:
diff --git a/mods/ra/rules/misc.yaml b/mods/ra/rules/misc.yaml
index f784026b2e..be67feffea 100644
--- a/mods/ra/rules/misc.yaml
+++ b/mods/ra/rules/misc.yaml
@@ -210,8 +210,10 @@ FLARE:
HP: 1000
RevealsShroud:
Range: 3c0
- RenderFlare:
+ RenderSprites:
Image: smokland
+ WithSpriteBody:
+ StartSequence: open
HiddenUnderFog:
Tooltip:
Name: Flare
@@ -388,3 +390,4 @@ CTFLAG:
Invulnerable:
-Selectable:
-TargetableBuilding:
+