@@ -30,40 +30,34 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public class RenderSimple : RenderSprites, IAutoSelectionSize
|
public class RenderSimple : RenderSprites, IAutoSelectionSize
|
||||||
{
|
{
|
||||||
RenderSimpleInfo Info;
|
public readonly Animation DefaultAnimation;
|
||||||
|
|
||||||
public RenderSimple(Actor self, Func<int> baseFacing)
|
public RenderSimple(Actor self, Func<int> baseFacing)
|
||||||
: base(self)
|
: base(self)
|
||||||
{
|
{
|
||||||
Add("", new Animation(self.World, GetImage(self), baseFacing));
|
DefaultAnimation = new Animation(self.World, GetImage(self), baseFacing);
|
||||||
Info = self.Info.Traits.Get<RenderSimpleInfo>();
|
Add("", DefaultAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderSimple(Actor self)
|
public RenderSimple(Actor self)
|
||||||
: this(self, MakeFacingFunc(self))
|
: this(self, MakeFacingFunc(self))
|
||||||
{
|
{
|
||||||
anim.PlayRepeating("idle");
|
DefaultAnimation.PlayRepeating("idle");
|
||||||
self.Trait<IBodyOrientation>().SetAutodetectedFacings(anim.CurrentSequence.Facings);
|
self.Trait<IBodyOrientation>().SetAutodetectedFacings(DefaultAnimation.CurrentSequence.Facings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int2 SelectionSize(Actor self)
|
public int2 SelectionSize(Actor self) { return AutoSelectionSize(self); }
|
||||||
{
|
|
||||||
return anims.Values.Where(b => (b.DisableFunc == null || !b.DisableFunc())
|
|
||||||
&& b.Animation.CurrentSequence != null)
|
|
||||||
.Select(a => (a.Animation.Image.size*Info.Scale).ToInt2())
|
|
||||||
.FirstOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string NormalizeSequence(Actor self, string baseSequence)
|
public string NormalizeSequence(Actor self, string baseSequence)
|
||||||
{
|
{
|
||||||
return NormalizeSequence(anim, self.GetDamageState(), baseSequence);
|
return NormalizeSequence(DefaultAnimation, self.GetDamageState(), baseSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayCustomAnim(Actor self, string name)
|
public void PlayCustomAnim(Actor self, string name)
|
||||||
{
|
{
|
||||||
if (anim.HasSequence(name))
|
if (DefaultAnimation.HasSequence(name))
|
||||||
anim.PlayThen(NormalizeSequence(self, name),
|
DefaultAnimation.PlayThen(NormalizeSequence(self, name),
|
||||||
() => anim.PlayRepeating(NormalizeSequence(self, "idle")));
|
() => DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
@@ -33,7 +34,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public class RenderSprites : IRender, ITick, INotifyOwnerChanged
|
public class RenderSprites : IRender, ITick, INotifyOwnerChanged
|
||||||
{
|
{
|
||||||
public Dictionary<string, AnimationWithOffset> anims = new Dictionary<string, AnimationWithOffset>();
|
Dictionary<string, AnimationWithOffset> anims = new Dictionary<string, AnimationWithOffset>();
|
||||||
|
|
||||||
public static Func<int> MakeFacingFunc(Actor self)
|
public static Func<int> MakeFacingFunc(Actor self)
|
||||||
{
|
{
|
||||||
@@ -42,13 +43,6 @@ namespace OpenRA.Traits
|
|||||||
return () => facing.Facing;
|
return () => facing.Facing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Animation anim
|
|
||||||
{
|
|
||||||
get { return anims[""].Animation; }
|
|
||||||
protected set { anims[""] = new AnimationWithOffset(value,
|
|
||||||
anims[""].OffsetFunc, anims[""].DisableFunc, anims[""].Paused, anims[""].ZOffset); }
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderSpritesInfo Info;
|
RenderSpritesInfo Info;
|
||||||
string cachedImage = null;
|
string cachedImage = null;
|
||||||
bool initializePalette = true;
|
bool initializePalette = true;
|
||||||
@@ -131,5 +125,14 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
return baseSequence;
|
return baseSequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Required by RenderSimple
|
||||||
|
protected int2 AutoSelectionSize(Actor self)
|
||||||
|
{
|
||||||
|
return anims.Values.Where(b => (b.DisableFunc == null || !b.DisableFunc())
|
||||||
|
&& b.Animation.CurrentSequence != null)
|
||||||
|
.Select(a => (a.Animation.Image.size*Info.Scale).ToInt2())
|
||||||
|
.FirstOrDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (started)
|
if (started)
|
||||||
{
|
{
|
||||||
// Don't break the actor if someone has overriden the animation prematurely
|
// Don't break the actor if someone has overriden the animation prematurely
|
||||||
if (rb.anim.CurrentSequence.Name != "make")
|
if (rb.DefaultAnimation.CurrentSequence.Name != "make")
|
||||||
{
|
{
|
||||||
complete = true;
|
complete = true;
|
||||||
OnComplete();
|
OnComplete();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Cnc
|
namespace OpenRA.Mods.Cnc
|
||||||
{
|
{
|
||||||
class DeadBuildingStateInfo : ITraitInfo, Requires<HealthInfo>, Requires<RenderSpritesInfo>
|
class DeadBuildingStateInfo : ITraitInfo, Requires<HealthInfo>, Requires<RenderSimpleInfo>
|
||||||
{
|
{
|
||||||
public readonly int LingerTime = 20;
|
public readonly int LingerTime = 20;
|
||||||
|
|
||||||
@@ -23,23 +23,23 @@ namespace OpenRA.Mods.Cnc
|
|||||||
class DeadBuildingState : INotifyKilled
|
class DeadBuildingState : INotifyKilled
|
||||||
{
|
{
|
||||||
DeadBuildingStateInfo info;
|
DeadBuildingStateInfo info;
|
||||||
RenderSprites rs;
|
RenderSimple rs;
|
||||||
|
|
||||||
public DeadBuildingState(Actor self, DeadBuildingStateInfo info)
|
public DeadBuildingState(Actor self, DeadBuildingStateInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
rs = self.Trait<RenderSprites>();
|
rs = self.Trait<RenderSimple>();
|
||||||
self.Trait<Health>().RemoveOnDeath = !rs.anim.HasSequence("dead");
|
self.Trait<Health>().RemoveOnDeath = !rs.DefaultAnimation.HasSequence("dead");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Killed(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (!rs.anim.HasSequence("dead")) return;
|
if (!rs.DefaultAnimation.HasSequence("dead")) return;
|
||||||
|
|
||||||
if (rs.anim.GetSequence("dead").Length > 1)
|
if (rs.DefaultAnimation.GetSequence("dead").Length > 1)
|
||||||
rs.anim.Play("dead");
|
rs.DefaultAnimation.Play("dead");
|
||||||
else
|
else
|
||||||
rs.anim.PlayRepeating("dead");
|
rs.DefaultAnimation.PlayRepeating("dead");
|
||||||
|
|
||||||
self.World.AddFrameEndTask(
|
self.World.AddFrameEndTask(
|
||||||
w => w.Add(
|
w => w.Add(
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
|
|
||||||
// Work around a bogus crash
|
// Work around a bogus crash
|
||||||
anim.PlayRepeating(NormalizeSequence(self, "idle"));
|
DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle"));
|
||||||
self.Trait<IBodyOrientation>().SetAutodetectedFacings(anim.CurrentSequence.Facings);
|
self.Trait<IBodyOrientation>().SetAutodetectedFacings(DefaultAnimation.CurrentSequence.Facings);
|
||||||
|
|
||||||
// Can't call Complete() directly from ctor because other traits haven't been inited yet
|
// Can't call Complete() directly from ctor because other traits haven't been inited yet
|
||||||
if (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation && !init.Contains<SkipMakeAnimsInit>())
|
if (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation && !init.Contains<SkipMakeAnimsInit>())
|
||||||
@@ -61,45 +61,45 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
void Complete(Actor self)
|
void Complete(Actor self)
|
||||||
{
|
{
|
||||||
anim.PlayRepeating(NormalizeSequence(self, "idle"));
|
DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle"));
|
||||||
foreach (var x in self.TraitsImplementing<INotifyBuildComplete>())
|
foreach (var x in self.TraitsImplementing<INotifyBuildComplete>())
|
||||||
x.BuildingComplete(self);
|
x.BuildingComplete(self);
|
||||||
|
|
||||||
if (info.PauseOnLowPower)
|
if (info.PauseOnLowPower)
|
||||||
{
|
{
|
||||||
var disabled = self.TraitsImplementing<IDisable>();
|
var disabled = self.TraitsImplementing<IDisable>();
|
||||||
anim.Paused = () => disabled.Any(d => d.Disabled)
|
DefaultAnimation.Paused = () => disabled.Any(d => d.Disabled)
|
||||||
&& anim.CurrentSequence.Name == NormalizeSequence(self, "idle");
|
&& DefaultAnimation.CurrentSequence.Name == NormalizeSequence(self, "idle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayCustomAnimThen(Actor self, string name, Action a)
|
public void PlayCustomAnimThen(Actor self, string name, Action a)
|
||||||
{
|
{
|
||||||
anim.PlayThen(NormalizeSequence(self, name),
|
DefaultAnimation.PlayThen(NormalizeSequence(self, name),
|
||||||
() => { anim.PlayRepeating(NormalizeSequence(self, "idle")); a(); });
|
() => { DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle")); a(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayCustomAnimRepeating(Actor self, string name)
|
public void PlayCustomAnimRepeating(Actor self, string name)
|
||||||
{
|
{
|
||||||
anim.PlayThen(NormalizeSequence(self, name),
|
DefaultAnimation.PlayThen(NormalizeSequence(self, name),
|
||||||
() => PlayCustomAnimRepeating(self, name));
|
() => PlayCustomAnimRepeating(self, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayCustomAnimBackwards(Actor self, string name, Action a)
|
public void PlayCustomAnimBackwards(Actor self, string name, Action a)
|
||||||
{
|
{
|
||||||
anim.PlayBackwardsThen(NormalizeSequence(self, name),
|
DefaultAnimation.PlayBackwardsThen(NormalizeSequence(self, name),
|
||||||
() => { anim.PlayRepeating(NormalizeSequence(self, "idle")); a(); });
|
() => { DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle")); a(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CancelCustomAnim(Actor self)
|
public void CancelCustomAnim(Actor self)
|
||||||
{
|
{
|
||||||
anim.PlayRepeating(NormalizeSequence(self, "idle"));
|
DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DamageStateChanged(Actor self, AttackInfo e)
|
public virtual void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (anim.CurrentSequence != null)
|
if (DefaultAnimation.CurrentSequence != null)
|
||||||
anim.ReplaceAnim(NormalizeSequence(self, "idle"));
|
DefaultAnimation.ReplaceAnim(NormalizeSequence(self, "idle"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
public void PlayCharge(Actor self)
|
public void PlayCharge(Actor self)
|
||||||
{
|
{
|
||||||
Sound.Play(info.ChargeAudio, self.CenterPosition);
|
Sound.Play(info.ChargeAudio, self.CenterPosition);
|
||||||
anim.PlayThen(NormalizeSequence(self, info.ChargeSequence),
|
DefaultAnimation.PlayThen(NormalizeSequence(self, info.ChargeSequence),
|
||||||
() => anim.PlayRepeating(NormalizeSequence(self, "idle")));
|
() => DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
public void BuildingComplete(Actor self)
|
public void BuildingComplete(Actor self)
|
||||||
{
|
{
|
||||||
var animation = (self.GetDamageState() >= DamageState.Heavy) ? "damaged-idle" : "idle";
|
var animation = (self.GetDamageState() >= DamageState.Heavy) ? "damaged-idle" : "idle";
|
||||||
anim.PlayFetchIndex(animation,
|
DefaultAnimation.PlayFetchIndex(animation,
|
||||||
() => playerResources.OreCapacity != 0
|
() => playerResources.OreCapacity != 0
|
||||||
? ((10 * anim.CurrentSequence.Length - 1) * playerResources.Ore) / (10 * playerResources.OreCapacity)
|
? ((10 * DefaultAnimation.CurrentSequence.Length - 1) * playerResources.Ore) / (10 * playerResources.OreCapacity)
|
||||||
: 0);
|
: 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
: base(init, info, MakeTurretFacingFunc(init.self))
|
: base(init, info, MakeTurretFacingFunc(init.self))
|
||||||
{
|
{
|
||||||
t = init.self.TraitsImplementing<Turreted>().FirstOrDefault();
|
t = init.self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||||
t.QuantizedFacings = anim.CurrentSequence.Facings;
|
t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DamageStateChanged(Actor self, AttackInfo e)
|
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
base.DamageStateChanged(self, e);
|
base.DamageStateChanged(self, e);
|
||||||
t.QuantizedFacings = anim.CurrentSequence.Facings;
|
t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
public void BuildingComplete(Actor self)
|
public void BuildingComplete(Actor self)
|
||||||
{
|
{
|
||||||
anim.PlayFetchIndex(info.Sequence, () => adjacent);
|
DefaultAnimation.PlayFetchIndex(info.Sequence, () => adjacent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DamageStateChanged(Actor self, AttackInfo e)
|
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
anim.PlayFetchIndex(NormalizeSequence(anim, e.DamageState, info.Sequence), () => adjacent);
|
DefaultAnimation.PlayFetchIndex(NormalizeSequence(DefaultAnimation, e.DamageState, info.Sequence), () => adjacent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Tick(Actor self)
|
public override void Tick(Actor self)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
if (disguise.AsSprite != intendedSprite)
|
if (disguise.AsSprite != intendedSprite)
|
||||||
{
|
{
|
||||||
intendedSprite = disguise.AsSprite;
|
intendedSprite = disguise.AsSprite;
|
||||||
anim.ChangeImage(intendedSprite ?? GetImage(self), info.StandAnimations.Random(Game.CosmeticRandom));
|
DefaultAnimation.ChangeImage(intendedSprite ?? GetImage(self), info.StandAnimations.Random(Game.CosmeticRandom));
|
||||||
UpdatePalette();
|
UpdatePalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
public RenderFlare(Actor self)
|
public RenderFlare(Actor self)
|
||||||
: base(self, () => 0)
|
: base(self, () => 0)
|
||||||
{
|
{
|
||||||
anim.PlayThen("open", () => anim.PlayRepeating("idle"));
|
DefaultAnimation.PlayThen("open", () => DefaultAnimation.PlayRepeating("idle"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,15 +40,15 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
var desiredState = harv.Fullness * (info.ImagesByFullness.Length - 1) / 100;
|
var desiredState = harv.Fullness * (info.ImagesByFullness.Length - 1) / 100;
|
||||||
var desiredImage = info.ImagesByFullness[desiredState];
|
var desiredImage = info.ImagesByFullness[desiredState];
|
||||||
|
|
||||||
if (anim.Name != desiredImage)
|
if (DefaultAnimation.Name != desiredImage)
|
||||||
anim.ChangeImage(desiredImage, "idle");
|
DefaultAnimation.ChangeImage(desiredImage, "idle");
|
||||||
|
|
||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Harvested(Actor self, ResourceType resource)
|
public void Harvested(Actor self, ResourceType resource)
|
||||||
{
|
{
|
||||||
if (anim.CurrentSequence.Name != "harvest")
|
if (DefaultAnimation.CurrentSequence.Name != "harvest")
|
||||||
PlayCustomAnim(self, "harvest");
|
PlayCustomAnim(self, "harvest");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,20 +59,20 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
: base(self, MakeFacingFunc(self))
|
: base(self, MakeFacingFunc(self))
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
anim.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
|
DefaultAnimation.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
|
||||||
State = AnimationState.Waiting;
|
State = AnimationState.Waiting;
|
||||||
move = self.Trait<IMove>();
|
move = self.Trait<IMove>();
|
||||||
|
|
||||||
self.Trait<IBodyOrientation>().SetAutodetectedFacings(anim.CurrentSequence.Facings);
|
self.Trait<IBodyOrientation>().SetAutodetectedFacings(DefaultAnimation.CurrentSequence.Facings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Attacking(Actor self, Target target)
|
public void Attacking(Actor self, Target target)
|
||||||
{
|
{
|
||||||
State = AnimationState.Attacking;
|
State = AnimationState.Attacking;
|
||||||
if (anim.HasSequence(NormalizeInfantrySequence(self, "shoot")))
|
if (DefaultAnimation.HasSequence(NormalizeInfantrySequence(self, "shoot")))
|
||||||
anim.PlayThen(NormalizeInfantrySequence(self, "shoot"), () => State = AnimationState.Idle);
|
DefaultAnimation.PlayThen(NormalizeInfantrySequence(self, "shoot"), () => State = AnimationState.Idle);
|
||||||
else if (anim.HasSequence(NormalizeInfantrySequence(self, "heal")))
|
else if (DefaultAnimation.HasSequence(NormalizeInfantrySequence(self, "heal")))
|
||||||
anim.PlayThen(NormalizeInfantrySequence(self, "heal"), () => State = AnimationState.Idle);
|
DefaultAnimation.PlayThen(NormalizeInfantrySequence(self, "heal"), () => State = AnimationState.Idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
public void Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||||
@@ -87,12 +87,12 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
if ((State == AnimationState.Moving || dirty) && !move.IsMoving)
|
if ((State == AnimationState.Moving || dirty) && !move.IsMoving)
|
||||||
{
|
{
|
||||||
State = AnimationState.Waiting;
|
State = AnimationState.Waiting;
|
||||||
anim.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
|
DefaultAnimation.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
|
||||||
}
|
}
|
||||||
else if ((State != AnimationState.Moving || dirty) && move.IsMoving)
|
else if ((State != AnimationState.Moving || dirty) && move.IsMoving)
|
||||||
{
|
{
|
||||||
State = AnimationState.Moving;
|
State = AnimationState.Moving;
|
||||||
anim.PlayRepeating(NormalizeInfantrySequence(self, "run"));
|
DefaultAnimation.PlayRepeating(NormalizeInfantrySequence(self, "run"));
|
||||||
}
|
}
|
||||||
|
|
||||||
dirty = false;
|
dirty = false;
|
||||||
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
{
|
{
|
||||||
if (State != AnimationState.Idle && State != AnimationState.IdleAnimating)
|
if (State != AnimationState.Idle && State != AnimationState.IdleAnimating)
|
||||||
{
|
{
|
||||||
anim.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
|
DefaultAnimation.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
|
||||||
State = AnimationState.Idle;
|
State = AnimationState.Idle;
|
||||||
|
|
||||||
if (info.IdleAnimations.Length > 0)
|
if (info.IdleAnimations.Length > 0)
|
||||||
@@ -113,12 +113,12 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
}
|
}
|
||||||
else if (AllowIdleAnimation(self) && idleDelay > 0 && --idleDelay == 0)
|
else if (AllowIdleAnimation(self) && idleDelay > 0 && --idleDelay == 0)
|
||||||
{
|
{
|
||||||
if (anim.HasSequence(idleSequence))
|
if (DefaultAnimation.HasSequence(idleSequence))
|
||||||
{
|
{
|
||||||
State = AnimationState.IdleAnimating;
|
State = AnimationState.IdleAnimating;
|
||||||
anim.PlayThen(idleSequence, () =>
|
DefaultAnimation.PlayThen(idleSequence, () =>
|
||||||
{
|
{
|
||||||
anim.PlayRepeating(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)));
|
DefaultAnimation.PlayRepeating(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)));
|
||||||
State = AnimationState.Waiting;
|
State = AnimationState.Waiting;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
{
|
{
|
||||||
var prefix = sc != null && sc.Panicking ? "panic-" : "";
|
var prefix = sc != null && sc.Panicking ? "panic-" : "";
|
||||||
|
|
||||||
if (anim.HasSequence(prefix + baseSequence))
|
if (DefaultAnimation.HasSequence(prefix + baseSequence))
|
||||||
return prefix + baseSequence;
|
return prefix + baseSequence;
|
||||||
else
|
else
|
||||||
return baseSequence;
|
return baseSequence;
|
||||||
|
|||||||
@@ -51,20 +51,20 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
void Open()
|
void Open()
|
||||||
{
|
{
|
||||||
if (open || !anim.HasSequence(info.OpenAnim))
|
if (open || !DefaultAnimation.HasSequence(info.OpenAnim))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
open = true;
|
open = true;
|
||||||
PlayCustomAnimation(self, info.OpenAnim, () =>
|
PlayCustomAnimation(self, info.OpenAnim, () =>
|
||||||
{
|
{
|
||||||
if (anim.HasSequence(info.UnloadAnim))
|
if (DefaultAnimation.HasSequence(info.UnloadAnim))
|
||||||
PlayCustomAnimRepeating(self, info.UnloadAnim);
|
PlayCustomAnimRepeating(self, info.UnloadAnim);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close()
|
void Close()
|
||||||
{
|
{
|
||||||
if (!open || !anim.HasSequence(info.OpenAnim))
|
if (!open || !DefaultAnimation.HasSequence(info.OpenAnim))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
open = false;
|
open = false;
|
||||||
|
|||||||
@@ -25,19 +25,19 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
public void PlayCustomAnimation(Actor self, string newAnim, Action after)
|
public void PlayCustomAnimation(Actor self, string newAnim, Action after)
|
||||||
{
|
{
|
||||||
anim.PlayThen(newAnim, () => { anim.Play("idle"); if (after != null) after(); });
|
DefaultAnimation.PlayThen(newAnim, () => { DefaultAnimation.Play("idle"); if (after != null) after(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayCustomAnimRepeating(Actor self, string name)
|
public void PlayCustomAnimRepeating(Actor self, string name)
|
||||||
{
|
{
|
||||||
anim.PlayThen(name,
|
DefaultAnimation.PlayThen(name,
|
||||||
() => { PlayCustomAnimRepeating(self, name); });
|
() => { PlayCustomAnimRepeating(self, name); });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayCustomAnimBackwards(Actor self, string name, Action after)
|
public void PlayCustomAnimBackwards(Actor self, string name, Action after)
|
||||||
{
|
{
|
||||||
anim.PlayBackwardsThen(name,
|
DefaultAnimation.PlayBackwardsThen(name,
|
||||||
() => { anim.PlayRepeating("idle"); if (after != null) after(); });
|
() => { DefaultAnimation.PlayRepeating("idle"); if (after != null) after(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
public override void Tick(Actor self)
|
public override void Tick(Actor self)
|
||||||
{
|
{
|
||||||
var sequence = (armament.IsReloading ? "empty-" : "") + (attack.IsAttacking ? "aim" : "idle");
|
var sequence = (armament.IsReloading ? "empty-" : "") + (attack.IsAttacking ? "aim" : "idle");
|
||||||
if (sequence != anim.CurrentSequence.Name)
|
if (sequence != DefaultAnimation.CurrentSequence.Name)
|
||||||
anim.ReplaceAnim(sequence);
|
DefaultAnimation.ReplaceAnim(sequence);
|
||||||
|
|
||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var prefix = tc != null && tc.IsProne ? "prone-" : "";
|
var prefix = tc != null && tc.IsProne ? "prone-" : "";
|
||||||
|
|
||||||
if (anim.HasSequence(prefix + baseSequence))
|
if (DefaultAnimation.HasSequence(prefix + baseSequence))
|
||||||
return prefix + baseSequence;
|
return prefix + baseSequence;
|
||||||
else
|
else
|
||||||
return baseSequence;
|
return baseSequence;
|
||||||
|
|||||||
Reference in New Issue
Block a user