From c6691e881caa65c78e7f959be3f8e564f2f07196 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 4 Oct 2014 23:17:15 +1300 Subject: [PATCH] Fix Turreted style issues. --- OpenRA.Mods.Cnc/RenderGunboat.cs | 4 +-- OpenRA.Mods.RA/Attack/AttackPopupTurreted.cs | 8 +++--- OpenRA.Mods.RA/LeavesHusk.cs | 2 +- .../Render/RenderBuildingTurreted.cs | 2 +- OpenRA.Mods.RA/Render/WithBarrel.cs | 2 +- OpenRA.Mods.RA/Render/WithMuzzleFlash.cs | 2 +- OpenRA.Mods.RA/Render/WithTurret.cs | 2 +- OpenRA.Mods.RA/TakeCover.cs | 4 +-- OpenRA.Mods.RA/Turreted.cs | 27 +++++++++---------- 9 files changed, 26 insertions(+), 27 deletions(-) diff --git a/OpenRA.Mods.Cnc/RenderGunboat.cs b/OpenRA.Mods.Cnc/RenderGunboat.cs index 5bab1128cd..f76deb2d1c 100644 --- a/OpenRA.Mods.Cnc/RenderGunboat.cs +++ b/OpenRA.Mods.Cnc/RenderGunboat.cs @@ -44,11 +44,11 @@ namespace OpenRA.Mods.RA.Render var turret = self.TraitsImplementing() .First(t => t.Name == info.Turret); - left = new Animation(self.World, name, () => turret.turretFacing); + left = new Animation(self.World, name, () => turret.TurretFacing); left.Play(info.LeftSequence); Add(info.LeftSequence, new AnimationWithOffset(left, null, () => facing.Facing > 128, 0)); - right = new Animation(self.World, name, () => turret.turretFacing); + right = new Animation(self.World, name, () => turret.TurretFacing); right.Play(info.RightSequence); Add(info.RightSequence, new AnimationWithOffset(right, null, () => facing.Facing <= 128, 0)); diff --git a/OpenRA.Mods.RA/Attack/AttackPopupTurreted.cs b/OpenRA.Mods.RA/Attack/AttackPopupTurreted.cs index 85a36478fc..80c1e2af7c 100644 --- a/OpenRA.Mods.RA/Attack/AttackPopupTurreted.cs +++ b/OpenRA.Mods.RA/Attack/AttackPopupTurreted.cs @@ -80,17 +80,17 @@ namespace OpenRA.Mods.RA { if (state == PopupState.Open && idleTicks++ > info.CloseDelay) { - turret.desiredFacing = info.DefaultFacing; + turret.DesiredFacing = info.DefaultFacing; state = PopupState.Rotating; } - else if (state == PopupState.Rotating && turret.turretFacing == info.DefaultFacing) + else if (state == PopupState.Rotating && turret.TurretFacing == info.DefaultFacing) { state = PopupState.Transitioning; rb.PlayCustomAnimThen(self, "closing", () => { state = PopupState.Closed; rb.PlayCustomAnimRepeating(self, "closed-idle"); - turret.desiredFacing = null; + turret.DesiredFacing = null; }); } } @@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA { state = PopupState.Closed; rb.PlayCustomAnimRepeating(self, "closed-idle"); - turret.desiredFacing = null; + turret.DesiredFacing = null; } } diff --git a/OpenRA.Mods.RA/LeavesHusk.cs b/OpenRA.Mods.RA/LeavesHusk.cs index 03fe9d6548..a21b494a9b 100644 --- a/OpenRA.Mods.RA/LeavesHusk.cs +++ b/OpenRA.Mods.RA/LeavesHusk.cs @@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA // This isn't a problem with the current units, but may be a problem for mods var turreted = self.TraitsImplementing().FirstOrDefault(); if (turreted != null) - td.Add(new TurretFacingInit(turreted.turretFacing)); + td.Add(new TurretFacingInit(turreted.TurretFacing)); var chronoshiftable = self.TraitOrDefault(); if (chronoshiftable != null && chronoshiftable.ReturnTicks > 0) diff --git a/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs b/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs index c8965505a8..9f3d828180 100644 --- a/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Render { // Turret artwork is baked into the sprite, so only the first turret makes sense. var turreted = self.TraitsImplementing().FirstOrDefault(); - return () => turreted.turretFacing; + return () => turreted.TurretFacing; } public RenderBuildingTurreted(ActorInitializer init, RenderBuildingInfo info) diff --git a/OpenRA.Mods.RA/Render/WithBarrel.cs b/OpenRA.Mods.RA/Render/WithBarrel.cs index 6908f3e36f..5d4e6244dc 100644 --- a/OpenRA.Mods.RA/Render/WithBarrel.cs +++ b/OpenRA.Mods.RA/Render/WithBarrel.cs @@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA.Render .First(tt => tt.Name == armament.Info.Turret); var rs = self.Trait(); - anim = new Animation(self.World, rs.GetImage(self), () => turreted.turretFacing); + anim = new Animation(self.World, rs.GetImage(self), () => turreted.TurretFacing); anim.Play(info.Sequence); rs.Add("barrel_{0}".F(info.Barrel), new AnimationWithOffset( anim, () => BarrelOffset(), null, () => false, p => WithTurret.ZOffsetFromCenter(self, p, 0))); diff --git a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs index 0d6d785082..0621331604 100644 --- a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs +++ b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Render var turreted = self.TraitsImplementing() .FirstOrDefault(t => t.Name == arm.Info.Turret); - getFacing = turreted != null ? () => turreted.turretFacing : + getFacing = turreted != null ? () => turreted.TurretFacing : facing != null ? (Func)(() => facing.Facing) : () => 0; var muzzleFlash = new Animation(self.World, render.GetImage(self), getFacing); diff --git a/OpenRA.Mods.RA/Render/WithTurret.cs b/OpenRA.Mods.RA/Render/WithTurret.cs index a5b452bc61..31aa845000 100755 --- a/OpenRA.Mods.RA/Render/WithTurret.cs +++ b/OpenRA.Mods.RA/Render/WithTurret.cs @@ -70,7 +70,7 @@ namespace OpenRA.Mods.RA.Render arms = self.TraitsImplementing() .Where(w => w.Info.Turret == info.Turret); - anim = new Animation(self.World, rs.GetImage(self), () => t.turretFacing); + anim = new Animation(self.World, rs.GetImage(self), () => t.TurretFacing); anim.Play(info.Sequence); rs.Add("turret_{0}".F(info.Turret), new AnimationWithOffset( anim, () => TurretOffset(self), null, () => false, p => ZOffsetFromCenter(self, p, 1))); diff --git a/OpenRA.Mods.RA/TakeCover.cs b/OpenRA.Mods.RA/TakeCover.cs index ef1097c79f..8a92c09981 100644 --- a/OpenRA.Mods.RA/TakeCover.cs +++ b/OpenRA.Mods.RA/TakeCover.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA if (e.Damage > 0 && (e.Warhead == null || !e.Warhead.PreventProne)) /* Don't go prone when healed */ { if (!isProne) - LocalOffset = info.ProneOffset; + localOffset = info.ProneOffset; remainingProneTime = info.ProneTime; } @@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA base.Tick(self); if (isProne && --remainingProneTime == 0) - LocalOffset = WVec.Zero; + localOffset = WVec.Zero; } public int GetDamageModifier(Actor attacker, DamageWarhead warhead) diff --git a/OpenRA.Mods.RA/Turreted.cs b/OpenRA.Mods.RA/Turreted.cs index 42735f816c..9910c7b997 100755 --- a/OpenRA.Mods.RA/Turreted.cs +++ b/OpenRA.Mods.RA/Turreted.cs @@ -36,23 +36,23 @@ namespace OpenRA.Mods.RA IFacing facing; [Sync] public int QuantizedFacings = 0; - [Sync] public int turretFacing = 0; - public int? desiredFacing; + [Sync] public int TurretFacing = 0; + public int? DesiredFacing; int realignTick = 0; // For subclasses that want to move the turret relative to the body - protected WVec LocalOffset = WVec.Zero; + protected WVec localOffset = WVec.Zero; - public WVec Offset { get { return info.Offset + LocalOffset; } } + public WVec Offset { get { return info.Offset + localOffset; } } public string Name { get { return info.Turret; } } public static int GetInitialTurretFacing(ActorInitializer init, int def) { if (init.Contains()) - return init.Get(); + return init.Get(); if (init.Contains()) - return init.Get(); + return init.Get(); return def; } @@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA public Turreted(ActorInitializer init, TurretedInfo info) { this.info = info; - turretFacing = GetInitialTurretFacing(init, info.InitialFacing); + TurretFacing = GetInitialTurretFacing(init, info.InitialFacing); } public void Created(Actor self) @@ -76,19 +76,19 @@ namespace OpenRA.Mods.RA if (realignTick < info.RealignDelay) realignTick++; else if (info.RealignDelay > -1) - desiredFacing = null; + DesiredFacing = null; } else realignTick = 0; - var df = desiredFacing ?? ( facing != null ? facing.Facing : turretFacing ); - turretFacing = Util.TickFacing(turretFacing, df, info.ROT); + var df = DesiredFacing ?? (facing != null ? facing.Facing : TurretFacing); + TurretFacing = Util.TickFacing(TurretFacing, df, info.ROT); } public bool FaceTarget(Actor self, Target target) { - desiredFacing = Util.GetFacing(target.CenterPosition - self.CenterPosition, turretFacing); - return turretFacing == desiredFacing; + DesiredFacing = Util.GetFacing(target.CenterPosition - self.CenterPosition, TurretFacing); + return TurretFacing == DesiredFacing; } // Turret offset in world-space @@ -102,9 +102,8 @@ namespace OpenRA.Mods.RA // Orientation in unit-space public WRot LocalOrientation(Actor self) { - // Hack: turretFacing is relative to the world, so subtract the body yaw - var local = WRot.FromYaw(WAngle.FromFacing(turretFacing) - self.Orientation.Yaw); + var local = WRot.FromYaw(WAngle.FromFacing(TurretFacing) - self.Orientation.Yaw); if (QuantizedFacings == 0) return local;