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:
@@ -78,12 +78,12 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
p = init.WorldRenderer.Palette(Palette);
|
||||
|
||||
Func<int> facing;
|
||||
var dynamicfacingInit = init.GetOrDefault<DynamicFacingInit>(this);
|
||||
var dynamicfacingInit = init.GetOrDefault<DynamicFacingInit>();
|
||||
if (dynamicfacingInit != null)
|
||||
facing = dynamicfacingInit.Value;
|
||||
else
|
||||
{
|
||||
var f = init.GetValue<FacingInit, int>(this, 0);
|
||||
var f = init.GetValue<FacingInit, int>(0);
|
||||
facing = () => f;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user