diff --git a/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs b/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs index 19ab697eb8..f26480cb19 100644 --- a/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs +++ b/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs @@ -28,13 +28,13 @@ namespace OpenRA.Mods.Cnc.Effects int weaponDelay; bool impacted = false; - public IonCannon(Player firedBy, WeaponInfo weapon, World world, WPos launchPos, CPos location, string effect, string sequence, string palette, int delay) + public IonCannon(Player firedBy, WeaponInfo weapon, World world, WPos launchPos, Target target, string effect, string sequence, string palette, int delay) { + this.target = target; this.firedBy = firedBy; this.weapon = weapon; this.palette = palette; weaponDelay = delay; - target = Target.FromCell(world, location); anim = new Animation(world, effect); anim.PlayThen(sequence, () => Finish(world)); diff --git a/OpenRA.Mods.Cnc/Scripting/Properties/IonCannonProperties.cs b/OpenRA.Mods.Cnc/Scripting/Properties/IonCannonProperties.cs index f16b335a2b..eddbddb412 100644 --- a/OpenRA.Mods.Cnc/Scripting/Properties/IonCannonProperties.cs +++ b/OpenRA.Mods.Cnc/Scripting/Properties/IonCannonProperties.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.CnC.Scripting [Desc("Activate the actor's IonCannonPower.")] public void ActivateIonCannon(CPos target) { - icp.Activate(Self, target); + icp.Activate(Self, Target.FromCell(Self.World, target)); } } } diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs index f057a76d6c..999673b97c 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs @@ -44,7 +44,8 @@ namespace OpenRA.Mods.Cnc.Traits public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); - attack.AttackTarget(Target.FromCell(self.World, order.TargetLocation), false, false, true); + + attack.AttackTarget(order.Target, false, false, true); } protected override void Created(Actor self) diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs index de829a12a4..f285e08fd6 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs @@ -50,7 +50,8 @@ namespace OpenRA.Mods.Cnc.Traits class ChronoshiftPower : SupportPower { - public ChronoshiftPower(Actor self, ChronoshiftPowerInfo info) : base(self, info) { } + public ChronoshiftPower(Actor self, ChronoshiftPowerInfo info) + : base(self, info) { } public override void SelectTarget(Actor self, string order, SupportPowerManager manager) { @@ -62,6 +63,8 @@ namespace OpenRA.Mods.Cnc.Traits { base.Activate(self, order, manager); + var info = (ChronoshiftPowerInfo)Info; + var targetDelta = self.World.Map.CellContaining(order.Target.CenterPosition) - order.ExtraLocation; foreach (var target in UnitsInRange(order.ExtraLocation)) { var cs = target.TraitsImplementing() @@ -70,11 +73,10 @@ namespace OpenRA.Mods.Cnc.Traits if (cs == null) continue; - var targetCell = target.Location + (order.TargetLocation - order.ExtraLocation); - var cpi = Info as ChronoshiftPowerInfo; + var targetCell = target.Location + targetDelta; if (self.Owner.Shroud.IsExplored(targetCell) && cs.CanChronoshiftTo(target, targetCell)) - cs.Teleport(target, targetCell, cpi.Duration, cpi.KillCargo, self); + cs.Teleport(target, targetCell, info.Duration, info.KillCargo, self); } } diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs index 28182b39ca..5904d9789e 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs @@ -74,16 +74,16 @@ namespace OpenRA.Mods.Cnc.Traits { base.Activate(self, order, manager); - Activate(self, order.TargetLocation); + Activate(self, order.Target); } - public void Activate(Actor self, CPos targetLocation) + public void Activate(Actor self, Target target) { self.World.AddFrameEndTask(w => { PlayLaunchSounds(); - Game.Sound.Play(SoundType.World, info.OnFireSound, self.World.Map.CenterOfCell(targetLocation)); - w.Add(new IonCannon(self.Owner, info.WeaponInfo, w, self.CenterPosition, targetLocation, + Game.Sound.Play(SoundType.World, info.OnFireSound, target.CenterPosition); + w.Add(new IonCannon(self.Owner, info.WeaponInfo, w, self.CenterPosition, target, info.Effect, info.EffectSequence, info.EffectPalette, info.WeaponDelay)); if (info.CameraActor == null) @@ -91,7 +91,7 @@ namespace OpenRA.Mods.Cnc.Traits var camera = w.CreateActor(info.CameraActor, new TypeDictionary { - new LocationInit(targetLocation), + new LocationInit(self.World.Map.CellContaining(target.CenterPosition)), new OwnerInit(self.Owner), }); diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs index 0b8a4e1d96..b14e09947f 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits { base.Activate(self, order, manager); - SendAirstrike(self, self.World.Map.CenterOfCell(order.TargetLocation)); + SendAirstrike(self, order.Target.CenterPosition); } public void SendAirstrike(Actor self, WPos target, bool randomize = true, int attackFacing = 0) diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs index e0af3b02f7..2a5d0820da 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs @@ -71,9 +71,9 @@ namespace OpenRA.Mods.Common.Traits if (wsb != null && wsb.DefaultAnimation.HasSequence(info.Sequence)) wsb.PlayCustomAnimation(self, info.Sequence); - Game.Sound.Play(SoundType.World, info.OnFireSound, self.World.Map.CenterOfCell(order.TargetLocation)); + Game.Sound.Play(SoundType.World, info.OnFireSound, order.Target.CenterPosition); - foreach (var a in UnitsInRange(order.TargetLocation)) + foreach (var a in UnitsInRange(self.World.Map.CellContaining(order.Target.CenterPosition))) { var external = a.TraitsImplementing() .FirstOrDefault(t => t.Info.Condition == info.Condition && t.CanGrantCondition(a, self)); diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs index cf723d9109..0253e3872b 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs @@ -104,7 +104,7 @@ namespace OpenRA.Mods.Common.Traits base.Activate(self, order, manager); PlayLaunchSounds(); - Activate(self, self.World.Map.CenterOfCell(order.TargetLocation)); + Activate(self, order.Target.CenterPosition); } public void Activate(Actor self, WPos targetPosition) diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs index f25258303f..ff95650d7c 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs @@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits { base.Activate(self, order, manager); - SendParatroopers(self, self.World.Map.CenterOfCell(order.TargetLocation)); + SendParatroopers(self, order.Target.CenterPosition); } public Actor[] SendParatroopers(Actor self, WPos target, bool randomize = true, int dropFacing = 0) diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs index 9dd1fa756d..7e1eb701e4 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs @@ -48,17 +48,15 @@ namespace OpenRA.Mods.Common.Traits { self.World.AddFrameEndTask(w => { - var location = self.World.Map.CenterOfCell(order.TargetLocation); - PlayLaunchSounds(); - Game.Sound.Play(SoundType.World, info.DeploySound, location); + Game.Sound.Play(SoundType.World, info.DeploySound, order.Target.CenterPosition); if (!string.IsNullOrEmpty(info.EffectSequence) && !string.IsNullOrEmpty(info.EffectPalette)) - w.Add(new SpriteEffect(location, w, info.EffectImage, info.EffectSequence, info.EffectPalette)); + w.Add(new SpriteEffect(order.Target.CenterPosition, w, info.EffectImage, info.EffectSequence, info.EffectPalette)); var actor = w.CreateActor(info.Actor, new TypeDictionary { - new LocationInit(order.TargetLocation), + new LocationInit(self.World.Map.CellContaining(order.Target.CenterPosition)), new OwnerInit(self.Owner), }); diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs index a7680398a7..7526257ccc 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs @@ -134,7 +134,7 @@ namespace OpenRA.Mods.Common.Traits { ping = manager.RadarPings.Value.Add( () => order.Player.IsAlliedWith(self.World.RenderPlayer), - self.World.Map.CenterOfCell(order.TargetLocation), + order.Target.CenterPosition, order.Player.Color.RGB, Info.RadarPingDuration); } diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs index 2abf12414a..6a407916cc 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs @@ -239,7 +239,7 @@ namespace OpenRA.Mods.Common.Traits if (a.Self.OccupiesSpace == null) return 0; - return (a.Self.CenterPosition - a.Self.World.Map.CenterOfCell(order.TargetLocation)).HorizontalLengthSquared; + return (a.Self.CenterPosition - order.Target.CenterPosition).HorizontalLengthSquared; }); if (power == null)