Overhaul and rename WithActiveAnimation -> WithIdleAnimation.
This commit is contained in:
@@ -421,7 +421,6 @@
|
||||
<Compile Include="Traits\Render\TimedUpgradeBar.cs" />
|
||||
<Compile Include="Traits\Render\WithSpriteBarrel.cs" />
|
||||
<Compile Include="Traits\Render\WithBuildingExplosion.cs" />
|
||||
<Compile Include="Traits\Render\WithActiveAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithAttackAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithMoveAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithSiloAnimation.cs" />
|
||||
@@ -718,6 +717,7 @@
|
||||
<Compile Include="EditorBrushes\EditorCopyPasteBrush.cs" />
|
||||
<Compile Include="Traits\World\EditorSelectionLayer.cs" />
|
||||
<Compile Include="Graphics\DetectionCircleRenderable.cs" />
|
||||
<Compile Include="Traits\Render\WithIdleAnimation.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -1,70 +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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Replaces the idle animation of a building.")]
|
||||
public class WithActiveAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
[SequenceReference] public readonly string Sequence = "active";
|
||||
|
||||
public readonly int Interval = 750;
|
||||
|
||||
public readonly bool PauseOnLowPower = false;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithActiveAnimation(init.Self, this); }
|
||||
}
|
||||
|
||||
public class WithActiveAnimation : ITick, INotifyBuildComplete, INotifySold
|
||||
{
|
||||
readonly WithActiveAnimationInfo info;
|
||||
readonly WithSpriteBody wsb;
|
||||
|
||||
public WithActiveAnimation(Actor self, WithActiveAnimationInfo info)
|
||||
{
|
||||
wsb = self.Trait<WithSpriteBody>();
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
int ticks;
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (!buildComplete)
|
||||
return;
|
||||
|
||||
if (--ticks <= 0)
|
||||
{
|
||||
if (!(info.PauseOnLowPower && self.IsDisabled()))
|
||||
wsb.PlayCustomAnimation(self, info.Sequence, () => wsb.CancelCustomAnimation(self));
|
||||
ticks = info.Interval;
|
||||
}
|
||||
}
|
||||
|
||||
bool buildComplete = false;
|
||||
|
||||
public void BuildingComplete(Actor self)
|
||||
{
|
||||
buildComplete = true;
|
||||
}
|
||||
|
||||
public void Selling(Actor self)
|
||||
{
|
||||
buildComplete = false;
|
||||
}
|
||||
|
||||
public void Sold(Actor self) { }
|
||||
}
|
||||
}
|
||||
71
OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs
Normal file
71
OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
#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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Periodically plays an idle animation, replacing the default body animation.")]
|
||||
public class WithIdleAnimationInfo : UpgradableTraitInfo, Requires<WithSpriteBodyInfo>
|
||||
{
|
||||
[SequenceReference, Desc("Sequence names to use.")]
|
||||
public readonly string[] Sequences = { "active" };
|
||||
|
||||
public readonly int Interval = 750;
|
||||
|
||||
[Desc("Pause when the actor is disabled. Deprecated. Use upgrades instead.")]
|
||||
public readonly bool PauseOnLowPower = false;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new WithIdleAnimation(init.Self, this); }
|
||||
}
|
||||
|
||||
public class WithIdleAnimation : UpgradableTrait<WithIdleAnimationInfo>, ITick, INotifyBuildComplete, INotifySold
|
||||
{
|
||||
readonly WithSpriteBody wsb;
|
||||
bool buildComplete;
|
||||
int ticks;
|
||||
|
||||
public WithIdleAnimation(Actor self, WithIdleAnimationInfo info)
|
||||
: base(info)
|
||||
{
|
||||
wsb = self.Trait<WithSpriteBody>();
|
||||
buildComplete = !self.Info.HasTraitInfo<BuildingInfo>(); // always render instantly for units
|
||||
ticks = info.Interval;
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (!buildComplete || IsTraitDisabled)
|
||||
return;
|
||||
|
||||
if (--ticks <= 0)
|
||||
{
|
||||
if (!(Info.PauseOnLowPower && self.IsDisabled()))
|
||||
wsb.PlayCustomAnimation(self, Info.Sequences.Random(Game.CosmeticRandom), () => wsb.CancelCustomAnimation(self));
|
||||
ticks = Info.Interval;
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildingComplete(Actor self)
|
||||
{
|
||||
buildComplete = true;
|
||||
}
|
||||
|
||||
public void Selling(Actor self)
|
||||
{
|
||||
buildComplete = false;
|
||||
}
|
||||
|
||||
public void Sold(Actor self) { }
|
||||
}
|
||||
}
|
||||
@@ -2818,6 +2818,18 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
}
|
||||
|
||||
if (engineVersion < 20160103)
|
||||
{
|
||||
// Overhauled WithActiveAnimation -> WithIdleAnimation
|
||||
if (node.Key == "WithActiveAnimation")
|
||||
{
|
||||
node.Key = "WithIdleAnimation";
|
||||
foreach (var n in node.Value.Nodes)
|
||||
if (n.Key == "Sequence")
|
||||
n.Key = "Sequences";
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ SPLIT2:
|
||||
SeedsResource:
|
||||
ResourceType: Tiberium
|
||||
Interval: 55
|
||||
WithActiveAnimation:
|
||||
WithIdleAnimation:
|
||||
|
||||
SPLIT3:
|
||||
Inherits: ^TibTree
|
||||
@@ -12,7 +12,7 @@ SPLIT3:
|
||||
SeedsResource:
|
||||
ResourceType: Tiberium
|
||||
Interval: 55
|
||||
WithActiveAnimation:
|
||||
WithIdleAnimation:
|
||||
|
||||
SPLITBLUE:
|
||||
Inherits: ^TibTree
|
||||
@@ -21,7 +21,7 @@ SPLITBLUE:
|
||||
SeedsResource:
|
||||
ResourceType: BlueTiberium
|
||||
Interval: 110
|
||||
WithActiveAnimation:
|
||||
WithIdleAnimation:
|
||||
Tooltip:
|
||||
Name: Blossom Tree (blue)
|
||||
RadarColorFromTerrain:
|
||||
|
||||
@@ -571,7 +571,7 @@
|
||||
SeedsResource:
|
||||
ResourceType: Tiberium
|
||||
Interval: 55
|
||||
WithActiveAnimation:
|
||||
WithIdleAnimation:
|
||||
|
||||
^Tree:
|
||||
Inherits@1: ^SpriteActor
|
||||
|
||||
Reference in New Issue
Block a user