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)
|
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;
|
dockingState = State.Loop;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity OnStateUndock(Actor self)
|
public override Activity OnStateUndock(Actor self)
|
||||||
{
|
{
|
||||||
ru.PlayCustomAnimBackwards(self, "dock", () => dockingState = State.Complete);
|
ru.PlayCustomAnimationBackwards(self, "dock", () => dockingState = State.Complete);
|
||||||
dockingState = State.Wait;
|
dockingState = State.Wait;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -372,7 +372,6 @@
|
|||||||
<Compile Include="Traits\Render\RenderBuildingCharge.cs" />
|
<Compile Include="Traits\Render\RenderBuildingCharge.cs" />
|
||||||
<Compile Include="Traits\Render\RenderBuildingTurreted.cs" />
|
<Compile Include="Traits\Render\RenderBuildingTurreted.cs" />
|
||||||
<Compile Include="Traits\Render\RenderEditorOnly.cs" />
|
<Compile Include="Traits\Render\RenderEditorOnly.cs" />
|
||||||
<Compile Include="Traits\Render\RenderFlare.cs" />
|
|
||||||
<Compile Include="Traits\Render\RenderHarvester.cs" />
|
<Compile Include="Traits\Render\RenderHarvester.cs" />
|
||||||
<Compile Include="Traits\Render\RenderNameTag.cs" />
|
<Compile Include="Traits\Render\RenderNameTag.cs" />
|
||||||
<Compile Include="Traits\Render\RenderSimple.cs" />
|
<Compile Include="Traits\Render\RenderSimple.cs" />
|
||||||
@@ -402,8 +401,8 @@
|
|||||||
<Compile Include="Traits\Render\WithRotor.cs" />
|
<Compile Include="Traits\Render\WithRotor.cs" />
|
||||||
<Compile Include="Traits\Render\WithShadow.cs" />
|
<Compile Include="Traits\Render\WithShadow.cs" />
|
||||||
<Compile Include="Traits\Render\WithSmoke.cs" />
|
<Compile Include="Traits\Render\WithSmoke.cs" />
|
||||||
|
<Compile Include="Traits\Render\WithSpriteBody.cs" />
|
||||||
<Compile Include="Traits\Render\WithTurret.cs" />
|
<Compile Include="Traits\Render\WithTurret.cs" />
|
||||||
<Compile Include="Traits\Render\WithFire.cs" />
|
|
||||||
<Compile Include="Traits\Render\WithBuildingPlacedOverlay.cs" />
|
<Compile Include="Traits\Render\WithBuildingPlacedOverlay.cs" />
|
||||||
<Compile Include="Traits\Render\WithProductionDoorOverlay.cs" />
|
<Compile Include="Traits\Render\WithProductionDoorOverlay.cs" />
|
||||||
<Compile Include="Traits\Render\WithProductionOverlay.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 override object Create(ActorInitializer init) { return new RenderUnit(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RenderUnit : RenderSimple
|
public class RenderUnit : RenderSimple, ISpriteBody
|
||||||
{
|
{
|
||||||
readonly RenderUnitInfo info;
|
readonly RenderUnitInfo info;
|
||||||
|
|
||||||
@@ -28,18 +28,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
this.info = info;
|
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,
|
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.PlayBackwardsThen(name,
|
||||||
() => { DefaultAnimation.PlayRepeating(info.Sequence); if (after != null) after(); });
|
() => { 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
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
@@ -17,6 +18,13 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.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
|
public interface INotifyResourceClaimLost
|
||||||
{
|
{
|
||||||
void OnNotifyResourceClaimLost(Actor self, ResourceClaim claim, Actor claimer);
|
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);
|
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
self.World.AddFrameEndTask(w => EjectDriver());
|
self.World.AddFrameEndTask(w => EjectDriver());
|
||||||
if (info.ThumpSequence != null)
|
if (info.ThumpSequence != null)
|
||||||
renderUnit.PlayCustomAnimRepeating(self, info.ThumpSequence);
|
renderUnit.PlayCustomAnimationRepeating(self, info.ThumpSequence);
|
||||||
deployed = true;
|
deployed = true;
|
||||||
self.QueueActivity(new Wait(info.ChargeDelay, false));
|
self.QueueActivity(new Wait(info.ChargeDelay, false));
|
||||||
self.QueueActivity(new CallFunc(() => Sound.Play(info.ChargeSound, self.CenterPosition)));
|
self.QueueActivity(new CallFunc(() => Sound.Play(info.ChargeSound, self.CenterPosition)));
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
PlayCustomAnimation(self, info.OpenAnim, () =>
|
PlayCustomAnimation(self, info.OpenAnim, () =>
|
||||||
{
|
{
|
||||||
if (DefaultAnimation.HasSequence(info.UnloadAnim))
|
if (DefaultAnimation.HasSequence(info.UnloadAnim))
|
||||||
PlayCustomAnimRepeating(self, info.UnloadAnim);
|
PlayCustomAnimationRepeating(self, info.UnloadAnim);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
open = false;
|
open = false;
|
||||||
PlayCustomAnimBackwards(self, info.OpenAnim, null);
|
PlayCustomAnimationBackwards(self, info.OpenAnim, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Tick(Actor self)
|
public override void Tick(Actor self)
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ V19:
|
|||||||
|
|
||||||
V19.Husk:
|
V19.Husk:
|
||||||
Inherits: ^CivBuildingHusk
|
Inherits: ^CivBuildingHusk
|
||||||
WithFire:
|
RenderSprites:
|
||||||
|
WithSpriteBody:
|
||||||
|
StartSequence: fire-start
|
||||||
|
Sequence: fire-loop
|
||||||
Building:
|
Building:
|
||||||
Footprint: x
|
Footprint: x
|
||||||
Dimensions: 1,1
|
Dimensions: 1,1
|
||||||
|
|||||||
@@ -233,7 +233,10 @@ V19.Husk:
|
|||||||
ExcludeTilesets: DESERT
|
ExcludeTilesets: DESERT
|
||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Husk (Oil Pump)
|
Name: Husk (Oil Pump)
|
||||||
WithFire:
|
RenderSprites:
|
||||||
|
WithSpriteBody:
|
||||||
|
StartSequence: fire-start
|
||||||
|
Sequence: fire-loop
|
||||||
-Health:
|
-Health:
|
||||||
-Selectable:
|
-Selectable:
|
||||||
-TargetableBuilding:
|
-TargetableBuilding:
|
||||||
|
|||||||
@@ -210,8 +210,10 @@ FLARE:
|
|||||||
HP: 1000
|
HP: 1000
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 3c0
|
Range: 3c0
|
||||||
RenderFlare:
|
RenderSprites:
|
||||||
Image: smokland
|
Image: smokland
|
||||||
|
WithSpriteBody:
|
||||||
|
StartSequence: open
|
||||||
HiddenUnderFog:
|
HiddenUnderFog:
|
||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Flare
|
Name: Flare
|
||||||
@@ -388,3 +390,4 @@ CTFLAG:
|
|||||||
Invulnerable:
|
Invulnerable:
|
||||||
-Selectable:
|
-Selectable:
|
||||||
-TargetableBuilding:
|
-TargetableBuilding:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user