From 32ed63727dfe87e2a3755d0517f4c5c6ff4f70fb Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Fri, 3 Apr 2015 23:42:35 +0200 Subject: [PATCH] Revert "Expose Plane turn-to-attack delay to yaml." This reverts commit 02da41e5c5c47b6f2ecbca241790699631f57462. --- .../Traits/Buildings/ProductionAirdrop.cs | 5 ++-- OpenRA.Mods.Common/Activities/Air/Fly.cs | 8 +++--- .../Activities/Air/FlyAttack.cs | 11 +++----- .../Activities/Air/FlyFollow.cs | 6 ++--- .../Activities/Air/ReturnToBase.cs | 14 +++++------ .../Scripting/Properties/PlaneProperties.cs | 6 ++--- OpenRA.Mods.Common/Traits/Air/AttackPlane.cs | 11 +++----- OpenRA.Mods.Common/Traits/Air/Plane.cs | 25 ++++++++----------- OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs | 4 +-- .../Traits/SupportPowers/AirstrikePower.cs | 6 ++--- .../Traits/World/CrateSpawner.cs | 2 +- .../Properties/ParadropProperties.cs | 2 +- .../Traits/SupportPowers/ParatroopersPower.cs | 5 ++-- 13 files changed, 45 insertions(+), 60 deletions(-) diff --git a/OpenRA.Mods.Cnc/Traits/Buildings/ProductionAirdrop.cs b/OpenRA.Mods.Cnc/Traits/Buildings/ProductionAirdrop.cs index 08196adb6e..e44633e7d9 100644 --- a/OpenRA.Mods.Cnc/Traits/Buildings/ProductionAirdrop.cs +++ b/OpenRA.Mods.Cnc/Traits/Buildings/ProductionAirdrop.cs @@ -63,8 +63,7 @@ namespace OpenRA.Mods.Cnc.Traits new FacingInit(64) }); - var plane = actor.Trait(); - actor.QueueActivity(new Fly(actor, Target.FromCell(w, self.Location + new CVec(9, 0)), plane)); + actor.QueueActivity(new Fly(actor, Target.FromCell(w, self.Location + new CVec(9, 0)))); actor.QueueActivity(new Land(actor, Target.FromActor(self))); actor.QueueActivity(new CallFunc(() => { @@ -78,7 +77,7 @@ namespace OpenRA.Mods.Cnc.Traits Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.ReadyAudio, self.Owner.Country.Race); })); - actor.QueueActivity(new Fly(actor, Target.FromCell(w, endPos), plane)); + actor.QueueActivity(new Fly(actor, Target.FromCell(w, endPos))); actor.QueueActivity(new RemoveSelf()); }); diff --git a/OpenRA.Mods.Common/Activities/Air/Fly.cs b/OpenRA.Mods.Common/Activities/Air/Fly.cs index 2d1edd0266..a8460e1c08 100644 --- a/OpenRA.Mods.Common/Activities/Air/Fly.cs +++ b/OpenRA.Mods.Common/Activities/Air/Fly.cs @@ -22,14 +22,14 @@ namespace OpenRA.Mods.Common.Activities readonly WRange maxRange; readonly WRange minRange; - public Fly(Actor self, Target t, Plane plane) + public Fly(Actor self, Target t) { + plane = self.Trait(); target = t; - this.plane = plane; } - public Fly(Actor self, Target t, Plane plane, WRange minRange, WRange maxRange) - : this(self, t, plane) + public Fly(Actor self, Target t, WRange minRange, WRange maxRange) + : this(self, t) { this.maxRange = maxRange; this.minRange = minRange; diff --git a/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs b/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs index 1332aa25c7..ade6867341 100644 --- a/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs +++ b/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs @@ -21,16 +21,13 @@ namespace OpenRA.Mods.Common.Activities { readonly Target target; readonly AttackPlane attackPlane; - readonly Plane plane; readonly IEnumerable ammoPools; Activity inner; - int ticksUntilTurn; + int ticksUntilTurn = 50; - public FlyAttack(Actor self, Target target, Plane plane) + public FlyAttack(Actor self, Target target) { this.target = target; - this.plane = plane; - ticksUntilTurn = plane.Info.AttackTurnDelay; attackPlane = self.TraitOrDefault(); ammoPools = self.TraitsImplementing(); } @@ -55,9 +52,9 @@ namespace OpenRA.Mods.Common.Activities // TODO: This should fire each weapon at its maximum range if (target.IsInRange(self.CenterPosition, attackPlane.Armaments.Select(a => a.Weapon.MinRange).Min())) - inner = Util.SequenceActivities(new FlyTimed(ticksUntilTurn, self), new Fly(self, target, plane), new FlyTimed(ticksUntilTurn, self)); + inner = Util.SequenceActivities(new FlyTimed(ticksUntilTurn, self), new Fly(self, target), new FlyTimed(ticksUntilTurn, self)); else - inner = Util.SequenceActivities(new Fly(self, target, plane), new FlyTimed(ticksUntilTurn, self)); + inner = Util.SequenceActivities(new Fly(self, target), new FlyTimed(ticksUntilTurn, self)); } inner = Util.RunActivity(self, inner); diff --git a/OpenRA.Mods.Common/Activities/Air/FlyFollow.cs b/OpenRA.Mods.Common/Activities/Air/FlyFollow.cs index f760cb55ed..7da1c5c1dc 100644 --- a/OpenRA.Mods.Common/Activities/Air/FlyFollow.cs +++ b/OpenRA.Mods.Common/Activities/Air/FlyFollow.cs @@ -21,10 +21,10 @@ namespace OpenRA.Mods.Common.Activities WRange minRange; WRange maxRange; - public FlyFollow(Actor self, Target target, Plane plane, WRange minRange, WRange maxRange) + public FlyFollow(Actor self, Target target, WRange minRange, WRange maxRange) { this.target = target; - this.plane = plane; + plane = self.Trait(); this.minRange = minRange; this.maxRange = maxRange; } @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Activities return this; } - return Util.SequenceActivities(new Fly(self, target, plane, minRange, maxRange), this); + return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), this); } } } diff --git a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs index a6e69998a1..d342661e34 100644 --- a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs +++ b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs @@ -24,11 +24,11 @@ namespace OpenRA.Mods.Common.Activities Actor dest; WPos w1, w2, w3; - public ReturnToBase(Actor self, Actor dest, Plane plane) + public ReturnToBase(Actor self, Actor dest) { this.dest = dest; - this.plane = plane; - planeInfo = plane.Info; + plane = self.Trait(); + planeInfo = self.Info.Traits.Get(); } public static Actor ChooseAirfield(Actor self, bool unreservedOnly) @@ -113,15 +113,15 @@ namespace OpenRA.Mods.Common.Activities self.CancelActivity(); if (nearestAfld != null) - return Util.SequenceActivities(new Fly(self, Target.FromActor(nearestAfld), plane), new FlyCircle(self)); + return Util.SequenceActivities(new Fly(self, Target.FromActor(nearestAfld)), new FlyCircle(self)); else return new FlyCircle(self); } return Util.SequenceActivities( - new Fly(self, Target.FromPos(w1), plane), - new Fly(self, Target.FromPos(w2), plane), - new Fly(self, Target.FromPos(w3), plane), + new Fly(self, Target.FromPos(w1)), + new Fly(self, Target.FromPos(w2)), + new Fly(self, Target.FromPos(w3)), new Land(self, Target.FromActor(dest)), NextActivity); } diff --git a/OpenRA.Mods.Common/Scripting/Properties/PlaneProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/PlaneProperties.cs index 713f9ea0e4..919c5149f9 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/PlaneProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/PlaneProperties.cs @@ -25,14 +25,14 @@ namespace OpenRA.Mods.Common.Scripting [Desc("Fly within the cell grid.")] public void Move(CPos cell) { - Self.QueueActivity(new Fly(Self, Target.FromCell(Self.World, cell), Self.Trait())); + Self.QueueActivity(new Fly(Self, Target.FromCell(Self.World, cell))); } [ScriptActorPropertyActivity] [Desc("Return to the base, which is either the airfield given, or an auto-selected one otherwise.")] public void ReturnToBase(Actor airfield = null) { - Self.QueueActivity(new ReturnToBase(Self, airfield, Self.Trait())); + Self.QueueActivity(new ReturnToBase(Self, airfield)); } } @@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Scripting [Desc("Fly an attack against the target actor.")] public void Attack(Actor target) { - Self.QueueActivity(new FlyAttack(Self, Target.FromActor(target), Self.Trait())); + Self.QueueActivity(new FlyAttack(Self, Target.FromActor(target))); } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/Air/AttackPlane.cs b/OpenRA.Mods.Common/Traits/Air/AttackPlane.cs index a9b7cde7fd..26f89f4df6 100644 --- a/OpenRA.Mods.Common/Traits/Air/AttackPlane.cs +++ b/OpenRA.Mods.Common/Traits/Air/AttackPlane.cs @@ -14,24 +14,19 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public class AttackPlaneInfo : AttackFrontalInfo, Requires + public class AttackPlaneInfo : AttackFrontalInfo { public override object Create(ActorInitializer init) { return new AttackPlane(init.Self, this); } } public class AttackPlane : AttackFrontal { - readonly Plane plane; - public AttackPlane(Actor self, AttackPlaneInfo info) - : base(self, info) - { - plane = self.Trait(); - } + : base(self, info) { } public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove) { - return new FlyAttack(self, newTarget, plane); + return new FlyAttack(self, newTarget); } protected override bool CanAttack(Actor self, Target target) diff --git a/OpenRA.Mods.Common/Traits/Air/Plane.cs b/OpenRA.Mods.Common/Traits/Air/Plane.cs index 3a69284681..8e18c49e9d 100644 --- a/OpenRA.Mods.Common/Traits/Air/Plane.cs +++ b/OpenRA.Mods.Common/Traits/Air/Plane.cs @@ -20,9 +20,6 @@ namespace OpenRA.Mods.Common.Traits { public readonly WAngle MaximumPitch = WAngle.FromDegrees(10); - [Desc("Delay, in game ticks, before turning to attack.")] - public readonly int AttackTurnDelay = 50; - public override object Create(ActorInitializer init) { return new Plane(init, this); } } @@ -91,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits var target = Target.FromCell(self.World, cell); self.SetTargetLine(target, Color.Green); self.CancelActivity(); - self.QueueActivity(new Fly(self, target, this)); + self.QueueActivity(new Fly(self, target)); self.QueueActivity(new FlyCircle(self)); } else if (order.OrderString == "Enter") @@ -103,7 +100,7 @@ namespace OpenRA.Mods.Common.Traits self.SetTargetLine(Target.FromOrder(self.World, order), Color.Green); self.CancelActivity(); - self.QueueActivity(new ReturnToBase(self, order.TargetActor, this)); + self.QueueActivity(new ReturnToBase(self, order.TargetActor)); self.QueueActivity(new ResupplyAircraft(self)); } else if (order.OrderString == "Stop") @@ -119,7 +116,7 @@ namespace OpenRA.Mods.Common.Traits UnReserve(); self.CancelActivity(); self.SetTargetLine(Target.FromActor(airfield), Color.Green); - self.QueueActivity(new ReturnToBase(self, airfield, this)); + self.QueueActivity(new ReturnToBase(self, airfield)); self.QueueActivity(new ResupplyAircraft(self)); } else @@ -129,24 +126,24 @@ namespace OpenRA.Mods.Common.Traits } } - public Activity MoveTo(CPos cell, int nearEnough) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell), this), new FlyCircle(self)); } - public Activity MoveTo(CPos cell, Actor ignoredActor) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell), this), new FlyCircle(self)); } - public Activity MoveWithinRange(Target target, WRange range) { return Util.SequenceActivities(new Fly(self, target, this, WRange.Zero, range), new FlyCircle(self)); } + public Activity MoveTo(CPos cell, int nearEnough) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell)), new FlyCircle(self)); } + public Activity MoveTo(CPos cell, Actor ignoredActor) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell)), new FlyCircle(self)); } + public Activity MoveWithinRange(Target target, WRange range) { return Util.SequenceActivities(new Fly(self, target, WRange.Zero, range), new FlyCircle(self)); } public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { - return Util.SequenceActivities(new Fly(self, target, this, minRange, maxRange), new FlyCircle(self)); + return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), new FlyCircle(self)); } - public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new FlyFollow(self, target, this, minRange, maxRange); } + public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new FlyFollow(self, target, minRange, maxRange); } public CPos NearestMoveableCell(CPos cell) { return cell; } - public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) { return new Fly(self, Target.FromCell(self.World, cell), this); } + public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) { return new Fly(self, Target.FromCell(self.World, cell)); } public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { - return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new Fly(self, Target.FromPos(toPos), this)); + return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new Fly(self, Target.FromPos(toPos))); } - public Activity MoveToTarget(Actor self, Target target) { return new Fly(self, target, this, WRange.FromCells(3), WRange.FromCells(5)); } + public Activity MoveToTarget(Actor self, Target target) { return new Fly(self, target, WRange.FromCells(3), WRange.FromCells(5)); } public Activity MoveIntoTarget(Actor self, Target target) { return new Land(self, target); } } } diff --git a/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs b/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs index 6a402f84ec..64c8de885b 100644 --- a/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs +++ b/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits var airfield = ReturnToBase.ChooseAirfield(self, true); if (airfield != null) { - self.QueueActivity(new ReturnToBase(self, airfield, self.Trait())); + self.QueueActivity(new ReturnToBase(self, airfield)); self.QueueActivity(new ResupplyAircraft(self)); } else @@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits return; } - self.QueueActivity(new Fly(self, Target.FromActor(someBuilding), self.Trait())); + self.QueueActivity(new Fly(self, Target.FromActor(someBuilding))); self.QueueActivity(new FlyCircle(self)); } } diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs index 9eb267ba9d..f75d831fa3 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs @@ -155,10 +155,8 @@ namespace OpenRA.Mods.Common.Traits attack.OnExitedAttackRange += onExitRange; attack.OnRemovedFromWorld += onExitRange; - var plane = a.Trait(); - a.QueueActivity(new Fly(a, Target.FromPos(target + spawnOffset), plane)); - a.QueueActivity(new Fly(a, Target.FromPos(finishEdge + spawnOffset), plane)); - + a.QueueActivity(new Fly(a, Target.FromPos(target + spawnOffset))); + a.QueueActivity(new Fly(a, Target.FromPos(finishEdge + spawnOffset))); a.QueueActivity(new RemoveSelf()); aircraftInRange.Add(a, false); distanceTestActor = a; diff --git a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs index de6adf7779..bb8fae99cf 100644 --- a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs +++ b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs @@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Traits plane.Trait().Load(plane, crate); plane.CancelActivity(); - plane.QueueActivity(new Fly(plane, Target.FromPos(finishEdge), plane.Trait())); + plane.QueueActivity(new Fly(plane, Target.FromPos(finishEdge))); plane.QueueActivity(new RemoveSelf()); } else diff --git a/OpenRA.Mods.RA/Scripting/Properties/ParadropProperties.cs b/OpenRA.Mods.RA/Scripting/Properties/ParadropProperties.cs index 5b797f0532..4f0b488e3b 100644 --- a/OpenRA.Mods.RA/Scripting/Properties/ParadropProperties.cs +++ b/OpenRA.Mods.RA/Scripting/Properties/ParadropProperties.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Scripting public void Paradrop(CPos cell) { paradrop.SetLZ(cell, true); - Self.QueueActivity(new Fly(Self, Target.FromCell(Self.World, cell), Self.Trait())); + Self.QueueActivity(new Fly(Self, Target.FromCell(Self.World, cell))); Self.QueueActivity(new FlyOffMap(Self)); Self.QueueActivity(new RemoveSelf()); } diff --git a/OpenRA.Mods.RA/Traits/SupportPowers/ParatroopersPower.cs b/OpenRA.Mods.RA/Traits/SupportPowers/ParatroopersPower.cs index 3c211de0a3..6820aee695 100644 --- a/OpenRA.Mods.RA/Traits/SupportPowers/ParatroopersPower.cs +++ b/OpenRA.Mods.RA/Traits/SupportPowers/ParatroopersPower.cs @@ -184,9 +184,8 @@ namespace OpenRA.Mods.RA.Traits foreach (var p in passengers) cargo.Load(a, p); - var plane = a.Trait(); - a.QueueActivity(new Fly(a, Target.FromPos(target + spawnOffset), plane)); - a.QueueActivity(new Fly(a, Target.FromPos(finishEdge + spawnOffset), plane)); + a.QueueActivity(new Fly(a, Target.FromPos(target + spawnOffset))); + a.QueueActivity(new Fly(a, Target.FromPos(finishEdge + spawnOffset))); a.QueueActivity(new RemoveSelf()); aircraftInRange.Add(a, false); distanceTestActor = a;