Merge pull request #9786 from RoosterDragon/reserve-fixes
Reserve fixes
This commit is contained in:
@@ -52,13 +52,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
return Util.SequenceActivities(new HeliFly(self, Target.FromActor(nearestHpad)));
|
return Util.SequenceActivities(new HeliFly(self, Target.FromActor(nearestHpad)));
|
||||||
}
|
}
|
||||||
|
|
||||||
var res = dest.TraitOrDefault<Reservable>();
|
heli.MakeReservation(dest);
|
||||||
|
|
||||||
if (res != null)
|
|
||||||
{
|
|
||||||
heli.UnReserve();
|
|
||||||
heli.Reservation = res.Reserve(dest, self, heli);
|
|
||||||
}
|
|
||||||
|
|
||||||
var exit = dest.Info.TraitInfos<ExitInfo>().FirstOrDefault();
|
var exit = dest.Info.TraitInfos<ExitInfo>().FirstOrDefault();
|
||||||
var offset = (exit != null) ? exit.SpawnOffset : WVec.Zero;
|
var offset = (exit != null) ? exit.SpawnOffset : WVec.Zero;
|
||||||
|
|||||||
@@ -49,12 +49,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (dest == null)
|
if (dest == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var res = dest.TraitOrDefault<Reservable>();
|
plane.MakeReservation(dest);
|
||||||
if (res != null)
|
|
||||||
{
|
|
||||||
plane.UnReserve();
|
|
||||||
plane.Reservation = res.Reserve(dest, self, plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
var landPos = dest.CenterPosition;
|
var landPos = dest.CenterPosition;
|
||||||
var altitude = planeInfo.CruiseAltitude.Length;
|
var altitude = planeInfo.CruiseAltitude.Length;
|
||||||
|
|||||||
@@ -30,12 +30,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (NextActivity == null)
|
if (NextActivity == null)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
var reservation = aircraft.Reservation;
|
aircraft.UnReserve();
|
||||||
if (reservation != null)
|
|
||||||
{
|
|
||||||
reservation.Dispose();
|
|
||||||
reservation = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var host = aircraft.GetActorBelow();
|
var host = aircraft.GetActorBelow();
|
||||||
var hasHost = host != null;
|
var hasHost = host != null;
|
||||||
|
|||||||
@@ -92,11 +92,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
|
||||||
UpgradeManager um;
|
UpgradeManager um;
|
||||||
|
IDisposable reservation;
|
||||||
|
|
||||||
[Sync] public int Facing { get; set; }
|
[Sync] public int Facing { get; set; }
|
||||||
[Sync] public WPos CenterPosition { get; private set; }
|
[Sync] public WPos CenterPosition { get; private set; }
|
||||||
public CPos TopLeft { get { return self.World.Map.CellContaining(CenterPosition); } }
|
public CPos TopLeft { get { return self.World.Map.CellContaining(CenterPosition); } }
|
||||||
public IDisposable Reservation;
|
|
||||||
public int ROT { get { return Info.ROT; } }
|
public int ROT { get { return Info.ROT; } }
|
||||||
|
|
||||||
bool airborne;
|
bool airborne;
|
||||||
@@ -257,22 +257,24 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (afld == null)
|
if (afld == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var res = afld.TraitOrDefault<Reservable>();
|
MakeReservation(afld);
|
||||||
|
}
|
||||||
|
|
||||||
if (res != null)
|
public void MakeReservation(Actor target)
|
||||||
{
|
{
|
||||||
UnReserve();
|
UnReserve();
|
||||||
Reservation = res.Reserve(afld, self, this);
|
var reservable = target.TraitOrDefault<Reservable>();
|
||||||
}
|
if (reservable != null)
|
||||||
|
reservation = reservable.Reserve(target, self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnReserve()
|
public void UnReserve()
|
||||||
{
|
{
|
||||||
if (Reservation != null)
|
if (reservation == null)
|
||||||
{
|
return;
|
||||||
Reservation.Dispose();
|
|
||||||
Reservation = null;
|
reservation.Dispose();
|
||||||
}
|
reservation = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AircraftCanEnter(Actor a)
|
public bool AircraftCanEnter(Actor a)
|
||||||
@@ -453,12 +455,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (target.Positions.Any(p => self.World.ActorMap.GetActorsAt(self.World.Map.CellContaining(p)).Any(a => a != self && a != target.Actor)))
|
if (target.Positions.Any(p => self.World.ActorMap.GetActorsAt(self.World.Map.CellContaining(p)).Any(a => a != self && a != target.Actor)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var res = target.Actor.TraitOrDefault<Reservable>();
|
MakeReservation(target.Actor);
|
||||||
if (res == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
UnReserve();
|
|
||||||
Reservation = res.Reserve(target.Actor, self, this);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,9 +543,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var res = order.TargetActor.TraitOrDefault<Reservable>();
|
MakeReservation(order.TargetActor);
|
||||||
if (res != null)
|
|
||||||
Reservation = res.Reserve(order.TargetActor, self, this);
|
|
||||||
|
|
||||||
Action enter = () =>
|
Action enter = () =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user