Move duplicate Tick() code from Plane and Helicopter to Aircraft.
This commit is contained in:
@@ -77,6 +77,29 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
|
Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool firstTick = true;
|
||||||
|
public virtual void Tick(Actor self)
|
||||||
|
{
|
||||||
|
if (firstTick)
|
||||||
|
{
|
||||||
|
firstTick = false;
|
||||||
|
|
||||||
|
// TODO: Aircraft husks don't properly unreserve.
|
||||||
|
if (self.HasTrait<FallsToEarth>())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ReserveSpawnBuilding();
|
||||||
|
|
||||||
|
var host = GetActorBelow();
|
||||||
|
if (host == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
self.QueueActivity(new TakeOff(self));
|
||||||
|
}
|
||||||
|
|
||||||
|
Repulse();
|
||||||
|
}
|
||||||
|
|
||||||
public void Repulse()
|
public void Repulse()
|
||||||
{
|
{
|
||||||
var repulsionForce = GetRepulsionForce();
|
var repulsionForce = GetRepulsionForce();
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
public readonly HelicopterInfo Info;
|
public readonly HelicopterInfo Info;
|
||||||
Actor self;
|
Actor self;
|
||||||
bool firstTick = true;
|
|
||||||
public bool IsMoving { get { return self.CenterPosition.Z > 0; } set { } }
|
public bool IsMoving { get { return self.CenterPosition.Z > 0; } set { } }
|
||||||
|
|
||||||
public Helicopter(ActorInitializer init, HelicopterInfo info)
|
public Helicopter(ActorInitializer init, HelicopterInfo info)
|
||||||
@@ -121,26 +120,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
|
||||||
{
|
|
||||||
if (firstTick)
|
|
||||||
{
|
|
||||||
firstTick = false;
|
|
||||||
if (self.HasTrait<FallsToEarth>()) // TODO: Aircraft husks don't properly unreserve.
|
|
||||||
return;
|
|
||||||
|
|
||||||
ReserveSpawnBuilding();
|
|
||||||
|
|
||||||
var host = GetActorBelow();
|
|
||||||
if (host == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
self.QueueActivity(new TakeOff(self));
|
|
||||||
}
|
|
||||||
|
|
||||||
Repulse();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Activity MoveTo(CPos cell, int nearEnough) { return new HeliFly(self, Target.FromCell(self.World, cell)); }
|
public Activity MoveTo(CPos cell, int nearEnough) { return new HeliFly(self, Target.FromCell(self.World, cell)); }
|
||||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(self, Target.FromCell(self.World, cell)); }
|
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(self, Target.FromCell(self.World, cell)); }
|
||||||
public Activity MoveWithinRange(Target target, WDist range) { return new HeliFly(self, target, WDist.Zero, range); }
|
public Activity MoveWithinRange(Target target, WDist range) { return new HeliFly(self, target, WDist.Zero, range); }
|
||||||
|
|||||||
@@ -37,27 +37,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Info = info;
|
Info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool firstTick = true;
|
|
||||||
public void Tick(Actor self)
|
|
||||||
{
|
|
||||||
if (firstTick)
|
|
||||||
{
|
|
||||||
firstTick = false;
|
|
||||||
if (self.HasTrait<FallsToEarth>()) // TODO: Aircraft husks don't properly unreserve.
|
|
||||||
return;
|
|
||||||
|
|
||||||
ReserveSpawnBuilding();
|
|
||||||
|
|
||||||
var host = GetActorBelow();
|
|
||||||
if (host == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
self.QueueActivity(new TakeOff(self));
|
|
||||||
}
|
|
||||||
|
|
||||||
Repulse();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override WVec GetRepulsionForce()
|
public override WVec GetRepulsionForce()
|
||||||
{
|
{
|
||||||
var repulsionForce = base.GetRepulsionForce();
|
var repulsionForce = base.GetRepulsionForce();
|
||||||
|
|||||||
Reference in New Issue
Block a user