Add ISingleInstanceInit interface.
Inits that are logically singletons (e.g. actor location or owner) should implement this interface to avoid runtime inconsistencies. Duplicate instances are rejected at init-time, allowing simpler queries when they are used.
This commit is contained in:
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Explore map-placed actors if the "Explore Map" option is enabled
|
||||
var shroudInfo = init.World.Map.Rules.Actors["player"].TraitInfo<ShroudInfo>();
|
||||
var exploredMap = init.World.LobbyInfo.GlobalSettings.OptionOrDefault("explored", shroudInfo.ExploredMapCheckboxEnabled);
|
||||
startsRevealed = exploredMap && init.Contains<SpawnedByMapInit>(info) && !init.Contains<HiddenUnderFogInit>(info);
|
||||
startsRevealed = exploredMap && init.Contains<SpawnedByMapInit>() && !init.Contains<HiddenUnderFogInit>();
|
||||
var buildingInfo = init.Self.Info.TraitInfoOrDefault<BuildingInfo>();
|
||||
var footprintCells = buildingInfo != null ? buildingInfo.FrozenUnderFogTiles(init.Self.Location).ToList() : new List<CPos>() { init.Self.Location };
|
||||
footprint = footprintCells.SelectMany(c => map.ProjectedCellsCovering(c.ToMPos(map))).ToArray();
|
||||
@@ -195,5 +195,5 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public class HiddenUnderFogInit : RuntimeFlagInit { }
|
||||
public class HiddenUnderFogInit : RuntimeFlagInit, ISingleInstanceInit { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user