Merge pull request #8044 from penev92/bleed_withSpriteBody
Retire RenderFlare and WithFire traits
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -372,7 +372,6 @@
|
||||
<Compile Include="Traits\Render\RenderBuildingCharge.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingTurreted.cs" />
|
||||
<Compile Include="Traits\Render\RenderEditorOnly.cs" />
|
||||
<Compile Include="Traits\Render\RenderFlare.cs" />
|
||||
<Compile Include="Traits\Render\RenderHarvester.cs" />
|
||||
<Compile Include="Traits\Render\RenderNameTag.cs" />
|
||||
<Compile Include="Traits\Render\RenderSimple.cs" />
|
||||
@@ -402,8 +401,8 @@
|
||||
<Compile Include="Traits\Render\WithRotor.cs" />
|
||||
<Compile Include="Traits\Render\WithShadow.cs" />
|
||||
<Compile Include="Traits\Render\WithSmoke.cs" />
|
||||
<Compile Include="Traits\Render\WithSpriteBody.cs" />
|
||||
<Compile Include="Traits\Render\WithTurret.cs" />
|
||||
<Compile Include="Traits\Render\WithFire.cs" />
|
||||
<Compile Include="Traits\Render\WithBuildingPlacedOverlay.cs" />
|
||||
<Compile Include="Traits\Render\WithProductionDoorOverlay.cs" />
|
||||
<Compile Include="Traits\Render\WithProductionOverlay.cs" />
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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(); });
|
||||
|
||||
@@ -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<RenderSpritesInfo>
|
||||
{
|
||||
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<RenderSprites>();
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
70
OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs
Normal file
70
OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs
Normal file
@@ -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<RenderSpritesInfo>
|
||||
{
|
||||
[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<WithSpriteBodyInfo>, ISpriteBody
|
||||
{
|
||||
readonly Animation body;
|
||||
readonly WithSpriteBodyInfo info;
|
||||
|
||||
public WithSpriteBody(ActorInitializer init, WithSpriteBodyInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.info = info;
|
||||
|
||||
var rs = init.Self.Trait<RenderSprites>();
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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<MiniYamlNode>
|
||||
{
|
||||
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<MiniYamlNode>
|
||||
{
|
||||
new MiniYamlNode("StartSequence", "fire-start"),
|
||||
new MiniYamlNode("Sequence", "fire-loop")
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -11,7 +11,10 @@ V19:
|
||||
|
||||
V19.Husk:
|
||||
Inherits: ^CivBuildingHusk
|
||||
WithFire:
|
||||
RenderSprites:
|
||||
WithSpriteBody:
|
||||
StartSequence: fire-start
|
||||
Sequence: fire-loop
|
||||
Building:
|
||||
Footprint: x
|
||||
Dimensions: 1,1
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user