From d0c5ab0ca3ecbddb9a3c504de9b8dd5c35f33f82 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 25 Oct 2013 20:09:07 +1300 Subject: [PATCH 1/4] Clean up style nits in RenderInfantry. --- OpenRA.Mods.RA/Render/RenderInfantry.cs | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/OpenRA.Mods.RA/Render/RenderInfantry.cs b/OpenRA.Mods.RA/Render/RenderInfantry.cs index 529d93c3bb..c81e2f4ee6 100644 --- a/OpenRA.Mods.RA/Render/RenderInfantry.cs +++ b/OpenRA.Mods.RA/Render/RenderInfantry.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2013 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, @@ -8,10 +8,10 @@ */ #endregion -using OpenRA.Mods.RA.Effects; -using OpenRA.Traits; using OpenRA.Mods.RA.Activities; +using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Move; +using OpenRA.Traits; namespace OpenRA.Mods.RA.Render { @@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Render { public readonly int MinIdleWaitTicks = 30; public readonly int MaxIdleWaitTicks = 110; - public readonly string[] IdleAnimations = {}; + public readonly string[] IdleAnimations = { }; public override object Create(ActorInitializer init) { return new RenderInfantry(init.self, this); } } @@ -33,11 +33,11 @@ namespace OpenRA.Mods.RA.Render Moving, Waiting, IdleAnimating - }; + } protected bool dirty = false; - RenderInfantryInfo Info; + RenderInfantryInfo info; string idleSequence; int idleDelay; Mobile mobile; @@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Render protected virtual bool AllowIdleAnimation(Actor self) { - return Info.IdleAnimations.Length > 0; + return info.IdleAnimations.Length > 0; } public AnimationState State { get; private set; } @@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA.Render public RenderInfantry(Actor self, RenderInfantryInfo info) : base(self, MakeFacingFunc(self)) { - Info = info; + this.info = info; anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0); State = AnimationState.Waiting; mobile = self.Trait(); @@ -93,6 +93,7 @@ namespace OpenRA.Mods.RA.Render State = AnimationState.Moving; anim.PlayRepeating(NormalizeInfantrySequence(self, "run")); } + dirty = false; } @@ -103,10 +104,10 @@ namespace OpenRA.Mods.RA.Render anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0); State = AnimationState.Idle; - if (Info.IdleAnimations.Length > 0) + if (info.IdleAnimations.Length > 0) { - idleSequence = Info.IdleAnimations.Random(self.World.SharedRandom); - idleDelay = self.World.SharedRandom.Next(Info.MinIdleWaitTicks, Info.MaxIdleWaitTicks); + idleSequence = info.IdleAnimations.Random(self.World.SharedRandom); + idleDelay = self.World.SharedRandom.Next(info.MinIdleWaitTicks, info.MaxIdleWaitTicks); } } else if (AllowIdleAnimation(self) && idleDelay > 0 && --idleDelay == 0) @@ -114,12 +115,11 @@ namespace OpenRA.Mods.RA.Render if (anim.HasSequence(idleSequence)) { State = AnimationState.IdleAnimating; - anim.PlayThen(idleSequence, - () => - { - anim.PlayRepeating(NormalizeInfantrySequence(self, "stand")); - State = AnimationState.Waiting; - }); + anim.PlayThen(idleSequence, () => + { + anim.PlayRepeating(NormalizeInfantrySequence(self, "stand")); + State = AnimationState.Waiting; + }); } } } @@ -140,7 +140,7 @@ namespace OpenRA.Mods.RA.Render { if (!self.Destroyed) w.Add(new Corpse(w, self.CenterPosition, GetImage(self), - sequence, Info.PlayerPalette+self.Owner.InternalName)); + sequence, info.PlayerPalette + self.Owner.InternalName)); }); } } From ae86e20bc7e6ade65c7ceae3f08ffa88bf80ff11 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 25 Oct 2013 20:11:55 +1300 Subject: [PATCH 2/4] Add support for multiple stand animations. --- OpenRA.Mods.RA/Render/RenderInfantry.cs | 9 +++++---- OpenRA.Mods.RA/Render/RenderSpy.cs | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.RA/Render/RenderInfantry.cs b/OpenRA.Mods.RA/Render/RenderInfantry.cs index c81e2f4ee6..b0e62d8b7a 100644 --- a/OpenRA.Mods.RA/Render/RenderInfantry.cs +++ b/OpenRA.Mods.RA/Render/RenderInfantry.cs @@ -20,6 +20,7 @@ namespace OpenRA.Mods.RA.Render public readonly int MinIdleWaitTicks = 30; public readonly int MaxIdleWaitTicks = 110; public readonly string[] IdleAnimations = { }; + public readonly string[] StandAnimations = { "stand" }; public override object Create(ActorInitializer init) { return new RenderInfantry(init.self, this); } } @@ -58,7 +59,7 @@ namespace OpenRA.Mods.RA.Render : base(self, MakeFacingFunc(self)) { this.info = info; - anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0); + anim.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0); State = AnimationState.Waiting; mobile = self.Trait(); @@ -86,7 +87,7 @@ namespace OpenRA.Mods.RA.Render if ((State == AnimationState.Moving || dirty) && !mobile.IsMoving) { State = AnimationState.Waiting; - anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0); + anim.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0); } else if ((State != AnimationState.Moving || dirty) && mobile.IsMoving) { @@ -101,7 +102,7 @@ namespace OpenRA.Mods.RA.Render { if (State != AnimationState.Idle && State != AnimationState.IdleAnimating) { - anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0); + anim.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0); State = AnimationState.Idle; if (info.IdleAnimations.Length > 0) @@ -117,7 +118,7 @@ namespace OpenRA.Mods.RA.Render State = AnimationState.IdleAnimating; anim.PlayThen(idleSequence, () => { - anim.PlayRepeating(NormalizeInfantrySequence(self, "stand")); + anim.PlayRepeating(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom))); State = AnimationState.Waiting; }); } diff --git a/OpenRA.Mods.RA/Render/RenderSpy.cs b/OpenRA.Mods.RA/Render/RenderSpy.cs index 966401cd68..87be22b060 100755 --- a/OpenRA.Mods.RA/Render/RenderSpy.cs +++ b/OpenRA.Mods.RA/Render/RenderSpy.cs @@ -46,9 +46,9 @@ namespace OpenRA.Mods.RA.Render { disguisedAsSprite = spy.disguisedAsSprite; if (disguisedAsSprite != null) - anim.ChangeImage(disguisedAsSprite, "stand"); + anim.ChangeImage(disguisedAsSprite, info.StandAnimations.Random(Game.CosmeticRandom)); else - anim.ChangeImage(GetImage(self), "stand"); + anim.ChangeImage(GetImage(self), info.StandAnimations.Random(Game.CosmeticRandom)); UpdatePalette(); } base.Tick(self); From 7f0922b0342f0d77af3fa62de468d2600cb395b6 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 25 Oct 2013 20:14:08 +1300 Subject: [PATCH 3/4] Hook up C&C infantry. --- mods/cnc/rules/infantry.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mods/cnc/rules/infantry.yaml b/mods/cnc/rules/infantry.yaml index de45d06684..e70638735c 100644 --- a/mods/cnc/rules/infantry.yaml +++ b/mods/cnc/rules/infantry.yaml @@ -19,6 +19,7 @@ E1: AttackFrontal: RenderInfantryProne: IdleAnimations: idle1,idle2,idle3,idle4 + StandAnimations: stand, stand2 DetectCloaked: Range: 2 @@ -46,6 +47,7 @@ E2: AttackFrontal: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand, stand2 Explodes: Weapon: GrenadierExplode EmptyWeapon: GrenadierExplode @@ -76,6 +78,7 @@ E3: AttackFrontal: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand, stand2 DetectCloaked: Range: 2 @@ -104,6 +107,7 @@ E4: WithMuzzleFlash: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand, stand2 DetectCloaked: Range: 2 @@ -138,6 +142,7 @@ E5: -PoisonedByTiberium: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand, stand2 DetectCloaked: Range: 2 @@ -168,6 +173,7 @@ E6: JustMove: true RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand, stand2 -GainsExperience: RMBO: @@ -201,6 +207,7 @@ RMBO: AttackFrontal: RenderInfantryProne: IdleAnimations: idle1,idle2,idle3 + StandAnimations: stand, stand2 AnnounceOnBuild: AnnounceOnKill: DetectCloaked: From 11b131e70b04d6e150a8cf044773947f76bfe927 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 26 Oct 2013 10:56:33 +1300 Subject: [PATCH 4/4] Hook up RA infantry. --- mods/ra/rules/infantry.yaml | 8 ++++++++ mods/ra/sequences/infantry.yaml | 12 ++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/mods/ra/rules/infantry.yaml b/mods/ra/rules/infantry.yaml index 1a981a05d9..dd23c051b7 100644 --- a/mods/ra/rules/infantry.yaml +++ b/mods/ra/rules/infantry.yaml @@ -53,6 +53,7 @@ E1: -RenderInfantry: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand,stand2 E2: Inherits: ^Infantry @@ -82,6 +83,7 @@ E2: -RenderInfantry: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand,stand2 Explodes: Weapon: UnitExplodeSmall Chance: 50 @@ -115,6 +117,7 @@ E3: -RenderInfantry: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand,stand2 E4: Inherits: ^Infantry @@ -144,6 +147,7 @@ E4: -RenderInfantry: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand,stand2 E6: Inherits: ^Infantry @@ -176,6 +180,7 @@ E6: -RenderInfantry: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand,stand2 SPY: Inherits: ^Infantry @@ -211,6 +216,7 @@ SPY: -RenderInfantry: RenderSpy: IdleAnimations: idle1,idle2 + StandAnimations: stand,stand2 Armament: Weapon: SilencedPPK AttackFrontal: @@ -441,6 +447,7 @@ SHOK: -RenderInfantry: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand,stand2 -CrushableInfantry: SNIPER: @@ -475,6 +482,7 @@ SNIPER: -RenderInfantry: RenderInfantryProne: IdleAnimations: idle1,idle2 + StandAnimations: stand,stand2 Cloak: InitialDelay: 250 CloakDelay: 120 diff --git a/mods/ra/sequences/infantry.yaml b/mods/ra/sequences/infantry.yaml index 7693f1ac37..f84513df2f 100644 --- a/mods/ra/sequences/infantry.yaml +++ b/mods/ra/sequences/infantry.yaml @@ -4,7 +4,7 @@ e1: Facings: 8 stand2: Start: 8 - Length: 8 + Facings: 8 stand3: Start: 128 Length: 16 @@ -141,7 +141,7 @@ e3: Facings: 8 stand2: Start: 8 - Length: 8 + Facings: 8 run: Start: 16 Length: 6 @@ -203,7 +203,7 @@ e6: Facings: 8 stand2: Start: 8 - Length: 8 + Facings: 8 run: Start: 16 Length: 6 @@ -373,7 +373,7 @@ e2: Facings: 8 stand2: Start: 8 - Length: 8 + Facings: 8 run: Start: 16 Length: 6 @@ -481,7 +481,7 @@ spy: Facings: 8 stand2: Start: 8 - Length: 8 + Facings: 8 run: Start: 16 Length: 6 @@ -636,7 +636,7 @@ e4: Facings: 8 stand2: Start: 8 - Length: 8 + Facings: 8 run: Start: 16 Length: 6