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:
Paul Chote
2020-05-30 16:48:35 +01:00
committed by reaperrr
parent 86305879cb
commit b856613194
45 changed files with 169 additions and 95 deletions

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits.Render
{
var sequenceProvider = init.World.Map.Rules.Sequences;
var faction = init.GetValue<FactionInit, string>(this);
var ownerName = init.Get<OwnerInit>(this).InternalName;
var ownerName = init.Get<OwnerInit>().InternalName;
var image = GetImage(init.Actor, sequenceProvider, faction);
var palette = init.WorldRenderer.Palette(Palette ?? PlayerPalette + ownerName);
@@ -169,7 +169,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
{
Info = info;
faction = init.GetValue<FactionInit, string>(info, init.Self.Owner.Faction.InternalName);
faction = init.GetValue<FactionInit, string>(init.Self.Owner.Faction.InternalName);
}
public string GetImage(Actor self)