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));
|
init.Add(new HealthInit(newHP));
|
||||||
}
|
}
|
||||||
|
|
||||||
var cargo = self.TraitOrDefault<Cargo>();
|
foreach (var modifier in self.TraitsImplementing<ITransformActorInitModifier>())
|
||||||
if (cargo != null)
|
modifier.ModifyTransformActorInit(self, init);
|
||||||
init.Add(new RuntimeCargoInit(cargo.Passengers.ToArray()));
|
|
||||||
|
|
||||||
var a = w.CreateActor(ToActor, init);
|
var a = w.CreateActor(ToActor, init);
|
||||||
foreach (var nt in self.TraitsImplementing<INotifyTransform>())
|
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,
|
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;
|
public readonly CargoInfo Info;
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
@@ -469,6 +470,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
CurrentAdjacentCells = GetAdjacentCells();
|
CurrentAdjacentCells = GetAdjacentCells();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ITransformActorInitModifier.ModifyTransformActorInit(Actor self, TypeDictionary init)
|
||||||
|
{
|
||||||
|
init.Add(new RuntimeCargoInit(Passengers.ToArray()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RuntimeCargoInit : IActorInit<Actor[]>, ISuppressInitExport
|
public class RuntimeCargoInit : IActorInit<Actor[]>, ISuppressInitExport
|
||||||
|
|||||||
@@ -280,6 +280,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
void ModifyDeathActorInit(Actor self, TypeDictionary init);
|
void ModifyDeathActorInit(Actor self, TypeDictionary init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface ITransformActorInitModifier
|
||||||
|
{
|
||||||
|
void ModifyTransformActorInit(Actor self, TypeDictionary init);
|
||||||
|
}
|
||||||
|
|
||||||
public interface IPreventsAutoTarget
|
public interface IPreventsAutoTarget
|
||||||
{
|
{
|
||||||
bool PreventsAutoTarget(Actor self, Actor attacker);
|
bool PreventsAutoTarget(Actor self, Actor attacker);
|
||||||
|
|||||||
Reference in New Issue
Block a user