EntityInstance
Namespace: Murder.Prefabs
Assembly: Murder.dll
public class EntityInstance : IEntity
Represents an entity as an instance placed on the map. This map may be relative to the world or another entity.
Implements: IEntity
⭐ Constructors
public EntityInstance()
public EntityInstance(string name, Guid guid)
Parameters
name string
guid Guid
public EntityInstance(string name, T? guid)
Parameters
name string
guid T?
⭐ Properties
_children
protected Dictionary<TKey, TValue> _children;
Returns
Dictionary<TKey, TValue>
_components
protected readonly Dictionary<TKey, TValue> _components;
List of custom components that difer from the parent entity.
Returns
Dictionary<TKey, TValue>
ActivateWithParent
public bool ActivateWithParent;
Whether this instance must have its activation propagated according to the parent.
TODO: We might need to revisit on whether this is okay/actually scales well.
Returns
bool
Children
public virtual ImmutableArray<T> Children { get; }
Returns
ImmutableArray<T>
Components
public virtual ImmutableArray<T> Components { get; }
Returns
ImmutableArray<T>
Guid
public virtual Guid Guid { get; }
Returns
Guid
Id
public T? Id;
Entity id, if any. This will be persisted across save files. This only exists for instances in the world.
Returns
T?
IsDeactivated
public bool IsDeactivated;
Returns whether the entity is currently deactivated once instantiated in the map.
Returns
bool
IsEmpty
public virtual bool IsEmpty { get; }
Returns
bool
Name
public virtual string Name { get; }
Returns
string
PrefabRefName
public virtual string PrefabRefName { get; }
By default, this is not based on any prefab. Return null.
Returns
string
⭐ Methods
AddOrReplaceComponentForChild(Guid, IComponent)
public virtual bool AddOrReplaceComponentForChild(Guid childGuid, IComponent component)
Parameters
childGuid Guid
component IComponent
Returns
bool
CanRemoveChild(Guid)
public virtual bool CanRemoveChild(Guid instanceGuid)
Parameters
instanceGuid Guid
Returns
bool
CanRevertComponent(Type)
public virtual bool CanRevertComponent(Type t)
Parameters
t Type
Returns
bool
HasComponent(Type)
public virtual bool HasComponent(Type type)
Returns whether an instance of
Parameters
type Type
Returns
bool
HasComponentAtChild(Guid, Type)
public virtual bool HasComponentAtChild(Guid childGuid, Type type)
Parameters
childGuid Guid
type Type
Returns
bool
IsComponentInAsset(IComponent)
public virtual bool IsComponentInAsset(IComponent c)
Returns whether a component is present in the entity asset.
Parameters
c IComponent
Returns
bool
RemoveAllComponents()
public virtual bool RemoveAllComponents()
Returns
bool
RemoveChild(Guid)
public virtual bool RemoveChild(Guid instanceGuid)
Parameters
instanceGuid Guid
Returns
bool
RemoveComponent(Type)
public virtual bool RemoveComponent(Type t)
Parameters
t Type
Returns
bool
RevertComponent(Type)
public virtual bool RevertComponent(Type t)
Parameters
t Type
Returns
bool
RevertComponentForChild(Guid, Type)
public virtual bool RevertComponentForChild(Guid childGuid, Type t)
Parameters
childGuid Guid
t Type
Returns
bool
TryGetChild(Guid, out EntityInstance&)
public virtual bool TryGetChild(Guid guid, EntityInstance& instance)
Parameters
guid Guid
instance EntityInstance&
Returns
bool
GetChild(Guid)
public virtual EntityInstance GetChild(Guid instanceGuid)
Parameters
instanceGuid Guid
Returns
EntityInstance
GetComponent(Type)
public virtual IComponent GetComponent(Type componentType)
Parameters
componentType Type
Returns
IComponent
TryGetComponentForChild(Guid, Type)
public virtual IComponent TryGetComponentForChild(Guid guid, Type t)
Returns
IComponent
FetchChildren()
public virtual ImmutableArray<T> FetchChildren()
Returns
ImmutableArray<T>
GetChildComponents(Guid)
public virtual ImmutableArray<T> GetChildComponents(Guid guid)
Try to get the components for a child. TODO: Do not expose the instance children directly...? Is this only necessary for prefabs? Are we limiting the amount of children recursive to two?
Parameters
guid Guid
Returns
ImmutableArray<T>
Create(World, IEntity)
public virtual int Create(World world, IEntity parent)
Create the instance entity in the world with a specified parent.
Parameters
world World
parent IEntity
Returns
int
Create(World)
public virtual int Create(World world)
Create the instance entity in the world.
Parameters
world World
Returns
int
AddChild(EntityInstance)
public virtual void AddChild(EntityInstance asset)
Parameters
asset EntityInstance
AddOrReplaceComponent(IComponent)
public virtual void AddOrReplaceComponent(IComponent c)
Parameters
c IComponent
RemoveComponentForChild(Guid, Type)
public virtual void RemoveComponentForChild(Guid childGuid, Type t)
Parameters
childGuid Guid
t Type
SetName(string)
public virtual void SetName(string name)
Set the name of the entity instance.
Parameters
name string
UpdateGuid(Guid)
public void UpdateGuid(Guid newGuid)
Parameters
newGuid Guid
⚡