Make aircraft occupy cells when landed.
This commit is contained in:
@@ -105,6 +105,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
soundPlayed = true;
|
||||
}
|
||||
|
||||
if (self.IsAtGroundLevel())
|
||||
aircraft.RemoveInfluence();
|
||||
|
||||
// Inside the target annulus, so we're done
|
||||
var insideMaxRange = maxRange.Length > 0 && checkTarget.IsInRange(aircraft.CenterPosition, maxRange);
|
||||
var insideMinRange = minRange.Length > 0 && checkTarget.IsInRange(aircraft.CenterPosition, minRange);
|
||||
|
||||
@@ -98,6 +98,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
soundPlayed = true;
|
||||
}
|
||||
|
||||
if (self.IsAtGroundLevel())
|
||||
aircraft.RemoveInfluence();
|
||||
|
||||
if (AdjustAltitude(self, aircraft, aircraft.Info.CruiseAltitude))
|
||||
return this;
|
||||
|
||||
|
||||
@@ -19,26 +19,42 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly Aircraft aircraft;
|
||||
readonly WDist landAltitude;
|
||||
readonly bool requireSpace;
|
||||
readonly Actor ignoreActor;
|
||||
|
||||
bool soundPlayed;
|
||||
bool landingInitiated;
|
||||
|
||||
public HeliLand(Actor self, bool requireSpace)
|
||||
: this(self, requireSpace, self.Info.TraitInfo<AircraftInfo>().LandAltitude) { }
|
||||
public HeliLand(Actor self, bool requireSpace, Actor ignoreActor = null)
|
||||
: this(self, requireSpace, self.Info.TraitInfo<AircraftInfo>().LandAltitude, ignoreActor) { }
|
||||
|
||||
public HeliLand(Actor self, bool requireSpace, WDist landAltitude)
|
||||
public HeliLand(Actor self, bool requireSpace, WDist landAltitude, Actor ignoreActor = null)
|
||||
{
|
||||
this.requireSpace = requireSpace;
|
||||
this.landAltitude = landAltitude;
|
||||
this.ignoreActor = ignoreActor;
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceling)
|
||||
{
|
||||
aircraft.RemoveInfluence();
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
if (requireSpace && !aircraft.CanLand(self.Location))
|
||||
return this;
|
||||
if (requireSpace && !landingInitiated)
|
||||
{
|
||||
var landingCell = self.Location;
|
||||
if (!aircraft.CanLand(landingCell, ignoreActor))
|
||||
{
|
||||
self.NotifyBlocker(landingCell);
|
||||
return this;
|
||||
}
|
||||
|
||||
aircraft.AddInfluence(landingCell);
|
||||
landingInitiated = true;
|
||||
}
|
||||
|
||||
if (!soundPlayed && aircraft.Info.LandingSounds.Length > 0 && !self.IsAtGroundLevel())
|
||||
{
|
||||
|
||||
@@ -19,22 +19,52 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
readonly Target target;
|
||||
readonly Aircraft aircraft;
|
||||
readonly bool requireSpace;
|
||||
readonly Actor ignoreActor;
|
||||
|
||||
bool landingInitiated;
|
||||
bool soundPlayed;
|
||||
|
||||
public Land(Actor self, Target t)
|
||||
public Land(Actor self, Target t, bool requireSpace, Actor ignoreActor = null)
|
||||
{
|
||||
target = t;
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
this.requireSpace = requireSpace;
|
||||
this.ignoreActor = ignoreActor;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!target.IsValidFor(self))
|
||||
Cancel(self);
|
||||
return NextActivity;
|
||||
|
||||
if (IsCanceling)
|
||||
{
|
||||
aircraft.RemoveInfluence();
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
if (requireSpace && !landingInitiated)
|
||||
{
|
||||
var landingCell = self.World.Map.CellContaining(target.CenterPosition);
|
||||
if (!aircraft.CanLand(landingCell, ignoreActor))
|
||||
{
|
||||
// Maintain holding pattern.
|
||||
QueueChild(self, new FlyCircle(self, 25), true);
|
||||
self.NotifyBlocker(landingCell);
|
||||
return this;
|
||||
}
|
||||
|
||||
aircraft.AddInfluence(landingCell);
|
||||
landingInitiated = true;
|
||||
}
|
||||
|
||||
if (!soundPlayed && aircraft.Info.LandingSounds.Length > 0 && !self.IsAtGroundLevel())
|
||||
{
|
||||
|
||||
@@ -230,10 +230,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (aircraft.Info.TurnToDock)
|
||||
QueueChild(self, new Turn(self, aircraft.Info.InitialFacing), true);
|
||||
|
||||
QueueChild(self, new HeliLand(self, false), true);
|
||||
QueueChild(self, new HeliLand(self, true, dest), true);
|
||||
}
|
||||
else
|
||||
QueueChild(self, new Land(self, Target.FromPos(dest.CenterPosition + offset)), true);
|
||||
QueueChild(self, new Land(self, Target.FromPos(dest.CenterPosition + offset), true, dest), true);
|
||||
|
||||
QueueChild(self, new ResupplyAircraft(self), true);
|
||||
resupplied = true;
|
||||
|
||||
Reference in New Issue
Block a user