Helis return to nearest base like Planes
This commit is contained in:
@@ -31,11 +31,13 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
this.dest = dest;
|
this.dest = dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Actor ChooseHelipad(Actor self)
|
public Actor ChooseHelipad(Actor self, bool unreservedOnly)
|
||||||
{
|
{
|
||||||
var rearmBuildings = heli.Info.RearmBuildings;
|
var rearmBuildings = heli.Info.RearmBuildings;
|
||||||
return self.World.Actors.Where(a => a.Owner == self.Owner).FirstOrDefault(
|
return self.World.Actors.Where(a => a.Owner == self.Owner
|
||||||
a => rearmBuildings.Contains(a.Info.Name) && !Reservable.IsReserved(a));
|
&& rearmBuildings.Contains(a.Info.Name)
|
||||||
|
&& (!unreservedOnly || !Reservable.IsReserved(a)))
|
||||||
|
.ClosestTo(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
@@ -44,16 +46,13 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
if (dest == null || dest.IsDead || Reservable.IsReserved(dest))
|
if (dest == null || dest.IsDead || Reservable.IsReserved(dest))
|
||||||
dest = ChooseHelipad(self);
|
dest = ChooseHelipad(self, true);
|
||||||
|
|
||||||
var initialFacing = heli.Info.InitialFacing;
|
var initialFacing = heli.Info.InitialFacing;
|
||||||
|
|
||||||
if (dest == null || dest.IsDead)
|
if (dest == null || dest.IsDead)
|
||||||
{
|
{
|
||||||
var rearmBuildings = heli.Info.RearmBuildings;
|
var nearestHpad = ChooseHelipad(self, false);
|
||||||
var nearestHpad = self.World.ActorsHavingTrait<Reservable>()
|
|
||||||
.Where(a => a.Owner == self.Owner && rearmBuildings.Contains(a.Info.Name))
|
|
||||||
.ClosestTo(self);
|
|
||||||
|
|
||||||
if (nearestHpad == null)
|
if (nearestHpad == null)
|
||||||
return ActivityUtils.SequenceActivities(new Turn(self, initialFacing), new HeliLand(self, true), NextActivity);
|
return ActivityUtils.SequenceActivities(new Turn(self, initialFacing), new HeliLand(self, true), NextActivity);
|
||||||
|
|||||||
Reference in New Issue
Block a user