Fix FreeActorWithDelivery not being properly conditional
This commit is contained in:
committed by
Matthias Mailänder
parent
eb007fc43c
commit
a7d5b7b8b0
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public class FreeActor : ConditionalTrait<FreeActorInfo>
|
public class FreeActor : ConditionalTrait<FreeActorInfo>
|
||||||
{
|
{
|
||||||
bool allowSpawn;
|
protected bool allowSpawn;
|
||||||
|
|
||||||
public FreeActor(ActorInitializer init, FreeActorInfo info)
|
public FreeActor(ActorInitializer init, FreeActorInfo info)
|
||||||
: base(info)
|
: base(info)
|
||||||
|
|||||||
@@ -36,18 +36,26 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override object Create(ActorInitializer init) { return new FreeActorWithDelivery(init, this); }
|
public override object Create(ActorInitializer init) { return new FreeActorWithDelivery(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FreeActorWithDelivery
|
public class FreeActorWithDelivery : FreeActor
|
||||||
{
|
{
|
||||||
public readonly FreeActorWithDeliveryInfo Info;
|
readonly FreeActorWithDeliveryInfo info;
|
||||||
|
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
|
||||||
public FreeActorWithDelivery(ActorInitializer init, FreeActorWithDeliveryInfo info)
|
public FreeActorWithDelivery(ActorInitializer init, FreeActorWithDeliveryInfo info)
|
||||||
|
: base(init, info)
|
||||||
{
|
{
|
||||||
self = init.Self;
|
self = init.Self;
|
||||||
Info = info;
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
DoDelivery(self.Location + info.DeliveryOffset, info.Actor, info.DeliveringActor);
|
protected override void TraitEnabled(Actor self)
|
||||||
|
{
|
||||||
|
if (!allowSpawn)
|
||||||
|
return;
|
||||||
|
|
||||||
|
allowSpawn = info.AllowRespawn;
|
||||||
|
|
||||||
|
DoDelivery(self.Location + info.DeliveryOffset, Info.Actor, info.DeliveringActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoDelivery(CPos location, string actorName, string carrierActorName)
|
public void DoDelivery(CPos location, string actorName, string carrierActorName)
|
||||||
@@ -61,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
carryable.Reserve(cargo, carrier);
|
carryable.Reserve(cargo, carrier);
|
||||||
|
|
||||||
carrier.Trait<Carryall>().AttachCarryable(carrier, cargo);
|
carrier.Trait<Carryall>().AttachCarryable(carrier, cargo);
|
||||||
carrier.QueueActivity(new DeliverUnit(carrier, Target.FromCell(self.World, location), Info.DeliveryRange));
|
carrier.QueueActivity(new DeliverUnit(carrier, Target.FromCell(self.World, location), info.DeliveryRange));
|
||||||
carrier.QueueActivity(new Fly(carrier, Target.FromCell(self.World, self.World.Map.ChooseRandomEdgeCell(self.World.SharedRandom))));
|
carrier.QueueActivity(new Fly(carrier, Target.FromCell(self.World, self.World.Map.ChooseRandomEdgeCell(self.World.SharedRandom))));
|
||||||
carrier.QueueActivity(new RemoveSelf());
|
carrier.QueueActivity(new RemoveSelf());
|
||||||
|
|
||||||
@@ -71,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
void CreateActors(string actorName, string deliveringActorName, out Actor cargo, out Actor carrier)
|
void CreateActors(string actorName, string deliveringActorName, out Actor cargo, out Actor carrier)
|
||||||
{
|
{
|
||||||
// Get a carryall spawn location
|
// Get a carryall spawn location
|
||||||
var location = Info.SpawnLocation;
|
var location = info.SpawnLocation;
|
||||||
if (location == CPos.Zero)
|
if (location == CPos.Zero)
|
||||||
location = self.World.Map.ChooseClosestEdgeCell(self.Location);
|
location = self.World.Map.ChooseClosestEdgeCell(self.Location);
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var delivery = refinery.Trait<FreeActorWithDelivery>();
|
var delivery = refinery.Trait<FreeActorWithDelivery>();
|
||||||
delivery.DoDelivery(refinery.Location + delivery.Info.DeliveryOffset, delivery.Info.Actor, delivery.Info.DeliveringActor);
|
var deliveryInfo = delivery.Info as FreeActorWithDeliveryInfo;
|
||||||
|
delivery.DoDelivery(refinery.Location + deliveryInfo.DeliveryOffset, deliveryInfo.Actor, deliveryInfo.DeliveringActor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user