Add ITransformActorInitModifier.
Remove hardcoded Cargo reference from Transform.
This commit is contained in:
@@ -127,9 +127,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
init.Add(new HealthInit(newHP));
|
||||
}
|
||||
|
||||
var cargo = self.TraitOrDefault<Cargo>();
|
||||
if (cargo != null)
|
||||
init.Add(new RuntimeCargoInit(cargo.Passengers.ToArray()));
|
||||
foreach (var modifier in self.TraitsImplementing<ITransformActorInitModifier>())
|
||||
modifier.ModifyTransformActorInit(self, init);
|
||||
|
||||
var a = w.CreateActor(ToActor, init);
|
||||
foreach (var nt in self.TraitsImplementing<INotifyTransform>())
|
||||
|
||||
@@ -75,7 +75,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated, INotifyKilled,
|
||||
INotifyOwnerChanged, INotifyAddedToWorld, ITick, INotifySold, INotifyActorDisposing, IIssueDeployOrder
|
||||
INotifyOwnerChanged, INotifyAddedToWorld, ITick, INotifySold, INotifyActorDisposing, IIssueDeployOrder,
|
||||
ITransformActorInitModifier
|
||||
{
|
||||
public readonly CargoInfo Info;
|
||||
readonly Actor self;
|
||||
@@ -469,6 +470,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
CurrentAdjacentCells = GetAdjacentCells();
|
||||
}
|
||||
}
|
||||
|
||||
void ITransformActorInitModifier.ModifyTransformActorInit(Actor self, TypeDictionary init)
|
||||
{
|
||||
init.Add(new RuntimeCargoInit(Passengers.ToArray()));
|
||||
}
|
||||
}
|
||||
|
||||
public class RuntimeCargoInit : IActorInit<Actor[]>, ISuppressInitExport
|
||||
|
||||
@@ -280,6 +280,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void ModifyDeathActorInit(Actor self, TypeDictionary init);
|
||||
}
|
||||
|
||||
public interface ITransformActorInitModifier
|
||||
{
|
||||
void ModifyTransformActorInit(Actor self, TypeDictionary init);
|
||||
}
|
||||
|
||||
public interface IPreventsAutoTarget
|
||||
{
|
||||
bool PreventsAutoTarget(Actor self, Actor attacker);
|
||||
|
||||
Reference in New Issue
Block a user