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 => self.World.AddFrameEndTask(w =>
{ {
cargo.World.Remove(cargo); cargo.World.Remove(cargo);
carryable.Attached(cargo); carryable.Attached(cargo, self);
carryall.AttachCarryable(self, cargo); carryall.AttachCarryable(self, cargo);
}); });
} }

View File

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

View File

@@ -128,14 +128,14 @@ namespace OpenRA.Mods.Common.Traits
if (!string.IsNullOrEmpty(info.InitialActor)) 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 ParentActorInit(self),
new OwnerInit(self.Owner) new OwnerInit(self.Owner)
}); });
unit.Trait<Carryable>().Attached(unit); cargo.Trait<Carryable>().Attached(cargo, self);
AttachCarryable(self, unit); AttachCarryable(self, cargo);
} }
} }