diff --git a/OpenRA.Game/Traits/Mobile.cs b/OpenRA.Game/Traits/Mobile.cs index 3e940c5092..9a38d4121b 100644 --- a/OpenRA.Game/Traits/Mobile.cs +++ b/OpenRA.Game/Traits/Mobile.cs @@ -157,6 +157,7 @@ namespace OpenRA.Traits // Couldn't find a cell return target; } + public void ResolveOrder(Actor self, Order order) { if (order.OrderString == "Move") diff --git a/OpenRA.Mods.RA/Activities/IdleAnimation.cs b/OpenRA.Mods.RA/Activities/IdleAnimation.cs new file mode 100644 index 0000000000..8dd01f17c2 --- /dev/null +++ b/OpenRA.Mods.RA/Activities/IdleAnimation.cs @@ -0,0 +1,47 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 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 LICENSE. + */ +#endregion + +using System; +using OpenRA.Traits; +using OpenRA.Mods.RA.Render; + +namespace OpenRA.Mods.RA.Activities +{ + public class IdleAnimation : IActivity + { + string sequence; + int delay; + + public IdleAnimation(string sequence, int delay) + { + this.sequence = sequence; + this.delay = delay; + } + + public IActivity NextActivity { get; set; } + + bool active = true; + public IActivity Tick(Actor self) + { + if (!active) return NextActivity; + + if (delay > 0 && --delay == 0) + self.Trait().anim.PlayThen(sequence, () => active = false); + + return this; + } + + public void Cancel(Actor self) + { + active = false; + NextActivity = null; + } + } +} diff --git a/OpenRA.Mods.RA/IdleAnimation.cs b/OpenRA.Mods.RA/IdleAnimation.cs new file mode 100644 index 0000000000..c4b2ee9704 --- /dev/null +++ b/OpenRA.Mods.RA/IdleAnimation.cs @@ -0,0 +1,44 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 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 LICENSE. + */ +#endregion + +using OpenRA.GameRules; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class IdleAnimationInfo : ITraitInfo + { + public readonly int IdleWaitTicks = 50; + public readonly string[] Animations = {}; + public object Create(ActorInitializer init) { return new IdleAnimation(this); } + } + + // infantry prone behavior + class IdleAnimation : INotifyDamage, INotifyIdle + { + IdleAnimationInfo Info; + public IdleAnimation(IdleAnimationInfo info) + { + Info = info; + } + + public void Damaged(Actor self, AttackInfo e) + { + if (self.GetCurrentActivity() is IdleAnimation) + self.CancelActivity(); + } + + public void Idle(Actor self) + { + self.QueueActivity(new Activities.IdleAnimation(Info.Animations.Random(Game.CosmeticRandom), + Info.IdleWaitTicks)); + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 9e543b728f..bbf5d0a108 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -1,4 +1,4 @@ - + Debug @@ -239,6 +239,8 @@ + + diff --git a/OpenRA.Mods.RA/Render/RenderInfantry.cs b/OpenRA.Mods.RA/Render/RenderInfantry.cs index 2681b50c72..ff2edb4880 100644 --- a/OpenRA.Mods.RA/Render/RenderInfantry.cs +++ b/OpenRA.Mods.RA/Render/RenderInfantry.cs @@ -11,6 +11,7 @@ using OpenRA.Mods.RA.Effects; using OpenRA.Traits; using OpenRA.Traits.Activities; +using OpenRA.Mods.RA.Activities; namespace OpenRA.Mods.RA.Render { @@ -66,10 +67,9 @@ namespace OpenRA.Mods.RA.Render { base.Tick(self); if (inAttack) return; + if (self.GetCurrentActivity() is Activities.IdleAnimation) return; if (ChooseMoveAnim(self)) return; - /* todo: idle anims, etc */ - if (IsProne(self)) anim.PlayFetchIndex("crawl", () => 0); /* what a hack. */ else diff --git a/mods/cnc/infantry.yaml b/mods/cnc/infantry.yaml index 54bb2765e8..dc7c3fcab6 100644 --- a/mods/cnc/infantry.yaml +++ b/mods/cnc/infantry.yaml @@ -65,6 +65,8 @@ E3: PrimaryOffset: 0,0,0,-10 FireDelay: 5 TakeCover: + IdleAnimation: + Animations: idle1,idle2 E4: Inherits: ^Infantry diff --git a/mods/cnc/sequences-infantry.xml b/mods/cnc/sequences-infantry.xml index c04229ff91..58f46010e9 100644 --- a/mods/cnc/sequences-infantry.xml +++ b/mods/cnc/sequences-infantry.xml @@ -38,6 +38,8 @@ + +