Update Production's Faction when its owner changes
This commit is contained in:
@@ -23,14 +23,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("e.g. Infantry, Vehicles, Aircraft, Buildings")]
|
[Desc("e.g. Infantry, Vehicles, Aircraft, Buildings")]
|
||||||
public readonly string[] Produces = Array.Empty<string>();
|
public readonly string[] Produces = Array.Empty<string>();
|
||||||
|
|
||||||
|
[Desc("When owner is changed, should the Faction be updated to the new owner's faction?")]
|
||||||
|
public readonly bool UpdateFactionOnOwnerChange = false;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new Production(init, this); }
|
public override object Create(ActorInitializer init) { return new Production(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Production : PausableConditionalTrait<ProductionInfo>
|
public class Production : PausableConditionalTrait<ProductionInfo>, INotifyOwnerChanged
|
||||||
{
|
{
|
||||||
RallyPoint rp;
|
RallyPoint rp;
|
||||||
|
|
||||||
public string Faction { get; }
|
public string Faction { get; private set; }
|
||||||
|
|
||||||
public Production(ActorInitializer init, ProductionInfo info)
|
public Production(ActorInitializer init, ProductionInfo info)
|
||||||
: base(info)
|
: base(info)
|
||||||
@@ -138,6 +141,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return mobileInfo == null ||
|
return mobileInfo == null ||
|
||||||
mobileInfo.CanEnterCell(self.World, self, self.Location + s.ExitCell, ignoreActor: self);
|
mobileInfo.CanEnterCell(self.World, self, self.Location + s.ExitCell, ignoreActor: self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
|
{
|
||||||
|
if (Info.UpdateFactionOnOwnerChange)
|
||||||
|
Faction = self.Owner.Faction.InternalName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RallyPointInit : ValueActorInit<CPos[]>, ISingleInstanceInit
|
public class RallyPointInit : ValueActorInit<CPos[]>, ISingleInstanceInit
|
||||||
|
|||||||
Reference in New Issue
Block a user