diff --git a/OpenRA.Game/Traits/Render/RenderSimple.cs b/OpenRA.Game/Traits/Render/RenderSimple.cs index 4cad396ad6..2f091ad5bd 100755 --- a/OpenRA.Game/Traits/Render/RenderSimple.cs +++ b/OpenRA.Game/Traits/Render/RenderSimple.cs @@ -16,7 +16,7 @@ using OpenRA.FileFormats; namespace OpenRA.Traits { - public class RenderSimpleInfo : RenderSpritesInfo, LocalCoordinatesModelInfo + public class RenderSimpleInfo : RenderSpritesInfo, IBodyOrientationInfo { [Desc("Number of facings for gameplay calculations. -1 indiciates auto-detection from sequence")] public readonly int QuantizedFacings = -1; @@ -34,7 +34,7 @@ namespace OpenRA.Traits } } - public class RenderSimple : RenderSprites, ILocalCoordinatesModel, IAutoSelectionSize + public class RenderSimple : RenderSprites, IBodyOrientation, IAutoSelectionSize { RenderSimpleInfo Info; diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 5b59961b38..8138b6a872 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -187,12 +187,12 @@ namespace OpenRA.Traits public interface IPostRenderSelection { void RenderAfterWorld(WorldRenderer wr); } public interface IPreRenderSelection { void RenderBeforeWorld(WorldRenderer wr, Actor self); } public interface IRenderAsTerrain { IEnumerable RenderAsTerrain(WorldRenderer wr, Actor self); } - public interface ILocalCoordinatesModel + public interface IBodyOrientation { WVec LocalToWorld(WVec vec); WRot QuantizeOrientation(Actor self, WRot orientation); } - public interface LocalCoordinatesModelInfo {} + public interface IBodyOrientationInfo {} public interface ITargetable { diff --git a/OpenRA.Mods.Cnc/WithCargo.cs b/OpenRA.Mods.Cnc/WithCargo.cs index 906e00db52..9fdd3258ba 100644 --- a/OpenRA.Mods.Cnc/WithCargo.cs +++ b/OpenRA.Mods.Cnc/WithCargo.cs @@ -18,7 +18,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Cnc { - public class WithCargoInfo : ITraitInfo, Requires, Requires + public class WithCargoInfo : ITraitInfo, Requires, Requires { [Desc("Cargo position relative to turret or body. (forward, right, up) triples")] public readonly WRange[] LocalOffset = {}; @@ -33,7 +33,7 @@ namespace OpenRA.Mods.Cnc IFacing facing; WithCargoInfo Info; WVec[] positions; - ILocalCoordinatesModel coords; + IBodyOrientation body; public WithCargo(Actor self, WithCargoInfo info) { @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Cnc facing = self.TraitOrDefault(); Info = info; - coords = self.Trait(); + body = self.Trait(); if (info.LocalOffset.Length % 3 != 0) throw new InvalidOperationException("Invalid LocalOffset array length"); @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Cnc foreach (var rr in r) yield return rr; - var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation); + var bodyOrientation = body.QuantizeOrientation(self, self.Orientation); var pos = self.CenterPosition; int i = 0; foreach (var c in cargo.Passengers) @@ -68,7 +68,7 @@ namespace OpenRA.Mods.Cnc var cargoPassenger = c.Trait(); if (Info.DisplayTypes.Contains(cargoPassenger.info.CargoType)) { - var offset = pos - c.CenterPosition + coords.LocalToWorld(positions[i++ % positions.Length].Rotate(bodyOrientation)); + var offset = pos - c.CenterPosition + body.LocalToWorld(positions[i++ % positions.Length].Rotate(bodyOrientation)); foreach (var cr in c.Render(wr)) yield return cr.WithPos(cr.Pos + offset).WithZOffset(1); } diff --git a/OpenRA.Mods.RA/Armament.cs b/OpenRA.Mods.RA/Armament.cs index f73727bab5..95482d0bf9 100755 --- a/OpenRA.Mods.RA/Armament.cs +++ b/OpenRA.Mods.RA/Armament.cs @@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA public readonly WeaponInfo Weapon; public readonly Barrel[] Barrels; Lazy Turret; - Lazy Coords; + Lazy Coords; public WRange Recoil; public int FireDelay { get; private set; } @@ -66,7 +66,7 @@ namespace OpenRA.Mods.RA // We can't resolve these until runtime Turret = Lazy.New(() => self.TraitsImplementing().FirstOrDefault(t => t.Name == info.Turret)); - Coords = Lazy.New(() => self.Trait()); + Coords = Lazy.New(() => self.Trait()); Weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()]; Burst = Weapon.Burst; diff --git a/OpenRA.Mods.RA/Effects/Contrail.cs b/OpenRA.Mods.RA/Effects/Contrail.cs index aad81bd457..17f15b49e2 100755 --- a/OpenRA.Mods.RA/Effects/Contrail.cs +++ b/OpenRA.Mods.RA/Effects/Contrail.cs @@ -16,7 +16,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class ContrailInfo : ITraitInfo, Requires + class ContrailInfo : ITraitInfo, Requires { [Desc("Position relative to body")] public readonly WVec Offset = WVec.Zero; @@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA { ContrailInfo info; ContrailHistory history; - ILocalCoordinatesModel coords; + IBodyOrientation body; public Contrail(Actor self, ContrailInfo info) { @@ -40,13 +40,13 @@ namespace OpenRA.Mods.RA history = new ContrailHistory(info.TrailLength, info.UsePlayerColor ? ContrailHistory.ChooseColor(self) : info.Color); - coords = self.Trait(); + body = self.Trait(); } public void Tick(Actor self) { - var local = info.Offset.Rotate(coords.QuantizeOrientation(self, self.Orientation)); - history.Tick(self.CenterPosition + coords.LocalToWorld(local)); + var local = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation)); + history.Tick(self.CenterPosition + body.LocalToWorld(local)); } public void RenderAfterWorld(WorldRenderer wr, Actor self) { history.Render(wr, self); } diff --git a/OpenRA.Mods.RA/Render/WithRotor.cs b/OpenRA.Mods.RA/Render/WithRotor.cs index 72be2a1511..2da92ea359 100755 --- a/OpenRA.Mods.RA/Render/WithRotor.cs +++ b/OpenRA.Mods.RA/Render/WithRotor.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Render { - public class WithRotorInfo : ITraitInfo, Requires, Requires + public class WithRotorInfo : ITraitInfo, Requires, Requires { [Desc("Position relative to body")] public readonly WVec Offset = WVec.Zero; @@ -29,12 +29,12 @@ namespace OpenRA.Mods.RA.Render public WithRotor(Actor self, WithRotorInfo info) { var rs = self.Trait(); - var coords = self.Trait(); + var body = self.Trait(); rotorAnim = new Animation(rs.GetImage(self)); rotorAnim.PlayRepeating("rotor"); rs.anims.Add(info.Id, new AnimationWithOffset(rotorAnim, - () => coords.LocalToWorld(info.Offset.Rotate(coords.QuantizeOrientation(self, self.Orientation))), + () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), null, p => WithTurret.ZOffsetFromCenter(self, p, 1))); } diff --git a/OpenRA.Mods.RA/Render/WithSpinner.cs b/OpenRA.Mods.RA/Render/WithSpinner.cs index 939474cde0..68e003d42b 100755 --- a/OpenRA.Mods.RA/Render/WithSpinner.cs +++ b/OpenRA.Mods.RA/Render/WithSpinner.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Render { - class WithSpinnerInfo : ITraitInfo, Requires, Requires + class WithSpinnerInfo : ITraitInfo, Requires, Requires { [Desc("Sequence name to use")] public readonly string Sequence = "spinner"; @@ -30,12 +30,12 @@ namespace OpenRA.Mods.RA.Render public WithSpinner(Actor self, WithSpinnerInfo info) { var rs = self.Trait(); - var coords = self.Trait(); + var body = self.Trait(); var spinner = new Animation(rs.GetImage(self)); spinner.PlayRepeating(info.Sequence); rs.anims.Add("spinner_{0}".F(info.Sequence), new AnimationWithOffset(spinner, - () => coords.LocalToWorld(info.Offset.Rotate(coords.QuantizeOrientation(self, self.Orientation))), + () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), null, p => WithTurret.ZOffsetFromCenter(self, p, 1))); } } diff --git a/OpenRA.Mods.RA/Render/WithTurret.cs b/OpenRA.Mods.RA/Render/WithTurret.cs index 3c5f68f3ac..fdca26d491 100755 --- a/OpenRA.Mods.RA/Render/WithTurret.cs +++ b/OpenRA.Mods.RA/Render/WithTurret.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made @@ -17,7 +17,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Render { - class WithTurretInfo : ITraitInfo, Requires, Requires, Requires + class WithTurretInfo : ITraitInfo, Requires, Requires, Requires { [Desc("Sequence name to use")] public readonly string Sequence = "turret"; @@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Render { WithTurretInfo info; RenderSprites rs; - ILocalCoordinatesModel coords; + IBodyOrientation body; AttackBase ab; Turreted t; IEnumerable arms; @@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Render { this.info = info; rs = self.Trait(); - coords = self.Trait(); + body = self.Trait(); ab = self.TraitOrDefault(); t = self.TraitsImplementing() @@ -72,9 +72,9 @@ namespace OpenRA.Mods.RA.Render var recoil = arms.Aggregate(WRange.Zero, (a,b) => a + b.Recoil); var localOffset = new WVec(-recoil, WRange.Zero, WRange.Zero); - var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation); - var turretOrientation = coords.QuantizeOrientation(self, t.LocalOrientation(self)); - return t.Position(self) + coords.LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation)); + var bodyOrientation = body.QuantizeOrientation(self, self.Orientation); + var turretOrientation = body.QuantizeOrientation(self, t.LocalOrientation(self)); + return t.Position(self) + body.LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation)); } public void Tick(Actor self) diff --git a/OpenRA.Mods.RA/SmokeTrailWhenDamaged.cs b/OpenRA.Mods.RA/SmokeTrailWhenDamaged.cs index fcb5c871fc..787d1249a5 100644 --- a/OpenRA.Mods.RA/SmokeTrailWhenDamaged.cs +++ b/OpenRA.Mods.RA/SmokeTrailWhenDamaged.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class SmokeTrailWhenDamagedInfo : ITraitInfo, Requires + class SmokeTrailWhenDamagedInfo : ITraitInfo, Requires { [Desc("Position relative to body")] public readonly WVec Offset = WVec.Zero; @@ -26,14 +26,14 @@ namespace OpenRA.Mods.RA class SmokeTrailWhenDamaged : ITick { - ILocalCoordinatesModel coords; + IBodyOrientation body; SmokeTrailWhenDamagedInfo info; int ticks; public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info) { this.info = info; - coords = self.Trait(); + body = self.Trait(); } public void Tick(Actor self) @@ -44,8 +44,8 @@ namespace OpenRA.Mods.RA if (position.Z > 0 && self.GetDamageState() >= DamageState.Heavy && !self.World.FogObscures(new CPos(position))) { - var offset = info.Offset.Rotate(coords.QuantizeOrientation(self, self.Orientation)); - var pos = position + coords.LocalToWorld(offset); + var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation)); + var pos = position + body.LocalToWorld(offset); self.World.AddFrameEndTask(w => w.Add(new Smoke(w, pos, info.Sprite))); } diff --git a/OpenRA.Mods.RA/SupportPowers/NukePower.cs b/OpenRA.Mods.RA/SupportPowers/NukePower.cs index 08f9448b73..5e7d88b5fc 100755 --- a/OpenRA.Mods.RA/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/NukePower.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class NukePowerInfo : SupportPowerInfo, Requires + class NukePowerInfo : SupportPowerInfo, Requires { [WeaponReference] public readonly string MissileWeapon = ""; @@ -25,12 +25,12 @@ namespace OpenRA.Mods.RA class NukePower : SupportPower { - ILocalCoordinatesModel coords; + IBodyOrientation body; public NukePower(Actor self, NukePowerInfo info) : base(self, info) { - coords = self.Trait(); + body = self.Trait(); } public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager) @@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA var rb = self.Trait(); rb.PlayCustomAnim(self, "active"); self.World.AddFrameEndTask(w => w.Add( - new NukeLaunch(self.Owner, self, npi.MissileWeapon, self.CenterPosition + coords.LocalToWorld(npi.SpawnOffset), order.TargetLocation))); + new NukeLaunch(self.Owner, self, npi.MissileWeapon, self.CenterPosition + body.LocalToWorld(npi.SpawnOffset), order.TargetLocation))); } } } diff --git a/OpenRA.Mods.RA/ThrowsParticle.cs b/OpenRA.Mods.RA/ThrowsParticle.cs index 7e9248f1ba..076000e37f 100644 --- a/OpenRA.Mods.RA/ThrowsParticle.cs +++ b/OpenRA.Mods.RA/ThrowsParticle.cs @@ -15,7 +15,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class ThrowsParticleInfo : ITraitInfo, Requires, Requires + class ThrowsParticleInfo : ITraitInfo, Requires, Requires { public readonly string Anim = null; @@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA var self = init.self; var rs = self.Trait(); - var coords = self.Trait(); + var body = self.Trait(); // TODO: Carry orientation over from the parent instead of just facing var bodyFacing = init.Contains() ? init.Get() : 0; @@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA var throwRotation = WRot.FromFacing(Game.CosmeticRandom.Next(1024)); var throwOffset = new WVec((int)(Game.CosmeticRandom.Gauss1D(1)*info.ThrowRange.Range), 0, 0).Rotate(throwRotation); - initialPos = pos = info.Offset.Rotate(coords.QuantizeOrientation(self, WRot.FromFacing(bodyFacing))); + initialPos = pos = info.Offset.Rotate(body.QuantizeOrientation(self, WRot.FromFacing(bodyFacing))); finalPos = initialPos + throwOffset; // Facing rotation diff --git a/OpenRA.Mods.RA/Turreted.cs b/OpenRA.Mods.RA/Turreted.cs index e3ffeb7662..02f9c03c1b 100755 --- a/OpenRA.Mods.RA/Turreted.cs +++ b/OpenRA.Mods.RA/Turreted.cs @@ -84,9 +84,9 @@ namespace OpenRA.Mods.RA // Turret offset in world-space public WVec Position(Actor self) { - var coords = self.Trait(); - var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation); - return coords.LocalToWorld(Offset.Rotate(bodyOrientation)); + var body = self.Trait(); + var bodyOrientation = body.QuantizeOrientation(self, self.Orientation); + return body.LocalToWorld(Offset.Rotate(bodyOrientation)); } // Orientation in unit-space