Let autocarryall switch destination when carryable switches destination.
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Activities;
|
using OpenRA.Mods.Common.Activities;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -42,8 +43,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
if (ReserveCarryable(self, carryable))
|
if (ReserveCarryable(self, carryable))
|
||||||
{
|
{
|
||||||
self.QueueActivity(false, new PickupUnit(self, carryable, 0));
|
self.QueueActivity(false, new FerryUnit(self, carryable));
|
||||||
self.QueueActivity(true, new DeliverUnit(self, Target.FromCell(self.World, destination), Info.DropRange));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,11 +96,35 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (IsBestAutoCarryallForCargo(self, p.Actor) && ReserveCarryable(self, p.Actor))
|
if (IsBestAutoCarryallForCargo(self, p.Actor) && ReserveCarryable(self, p.Actor))
|
||||||
{
|
{
|
||||||
busy = true;
|
busy = true;
|
||||||
self.QueueActivity(false, new PickupUnit(self, p.Actor, 0));
|
self.QueueActivity(false, new FerryUnit(self, p.Actor));
|
||||||
self.QueueActivity(true, new DeliverUnit(self, Target.FromCell(self.World, p.Trait.Destination.Value), Info.DropRange));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FerryUnit : Activity
|
||||||
|
{
|
||||||
|
readonly Actor cargo;
|
||||||
|
|
||||||
|
public FerryUnit(Actor self, Actor cargo)
|
||||||
|
{
|
||||||
|
this.cargo = cargo;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnFirstRun(Actor self)
|
||||||
|
{
|
||||||
|
QueueChild(new PickupUnit(self, cargo, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Tick(Actor self)
|
||||||
|
{
|
||||||
|
var dropRange = self.Trait<Carryall>().Info.DropRange;
|
||||||
|
var destination = cargo.Trait<Carryable>().Destination;
|
||||||
|
if (destination != null)
|
||||||
|
self.QueueActivity(true, new DeliverUnit(self, Target.FromCell(self.World, destination.Value), dropRange));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user