Fix InitialActor in Carryall not initialized correctly

This commit is contained in:
dnqbob
2023-11-24 18:59:53 +08:00
committed by Gustas
parent 65361ed8dc
commit deacc7ad65
3 changed files with 6 additions and 5 deletions

View File

@@ -166,7 +166,7 @@ namespace OpenRA.Mods.Common.Activities
self.World.AddFrameEndTask(w =>
{
cargo.World.Remove(cargo);
carryable.Attached(cargo);
carryable.Attached(cargo, self);
carryall.AttachCarryable(self, cargo);
});
}

View File

@@ -69,12 +69,13 @@ namespace OpenRA.Mods.Common.Traits
base.Created(self);
}
public virtual void Attached(Actor self)
public virtual void Attached(Actor self, Actor carrier)
{
if (attached)
return;
attached = true;
Carrier = carrier;
if (carriedToken == Actor.InvalidConditionToken)
carriedToken = self.GrantCondition(Info.CarriedCondition);

View File

@@ -128,14 +128,14 @@ namespace OpenRA.Mods.Common.Traits
if (!string.IsNullOrEmpty(info.InitialActor))
{
var unit = self.World.CreateActor(false, info.InitialActor.ToLowerInvariant(), new TypeDictionary
var cargo = self.World.CreateActor(false, info.InitialActor.ToLowerInvariant(), new TypeDictionary
{
new ParentActorInit(self),
new OwnerInit(self.Owner)
});
unit.Trait<Carryable>().Attached(unit);
AttachCarryable(self, unit);
cargo.Trait<Carryable>().Attached(cargo, self);
AttachCarryable(self, cargo);
}
}