Prepare MapCreeps code for trait-defined lobby options.
This commit is contained in:
@@ -52,17 +52,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly SpawnActorOnDeathInfo info;
|
||||
readonly string faction;
|
||||
readonly bool enabled;
|
||||
|
||||
public SpawnActorOnDeath(ActorInitializer init, SpawnActorOnDeathInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
|
||||
enabled = !info.RequiresLobbyCreeps || init.Self.World.WorldActor.Trait<MapCreeps>().Enabled;
|
||||
faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
|
||||
}
|
||||
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (info.RequiresLobbyCreeps && !self.World.LobbyInfo.GlobalSettings.Creeps)
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
if (!self.IsInWorld)
|
||||
|
||||
@@ -24,5 +24,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly bool Locked = false;
|
||||
}
|
||||
|
||||
public class MapCreeps { }
|
||||
public class MapCreeps : INotifyCreated
|
||||
{
|
||||
public bool Enabled { get; private set; }
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
Enabled = self.World.LobbyInfo.GlobalSettings.Creeps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user