Class BaseAspect<T>
Base class for aspects that operate on a specific type of entity. See IAspect for more details on aspects.
public abstract class BaseAspect<T> : IAspect<T>, IAspect
Type Parameters
T
- Inheritance
-
BaseAspect<T>
- Implements
-
IAspect<T>
- Inherited Members
- Extension Methods
Constructors
BaseAspect(IAspect<T>, bool)
Initializes a new instance of the BaseAspect<T> class with another aspect as the base.
protected BaseAspect(IAspect<T> aspect, bool strict = true)
Parameters
aspect
IAspect<T>The aspect to base this instance on.
strict
boolIf true, throws an exception if the target does not qualify for the aspect.
BaseAspect(T, bool)
Initializes a new instance of the BaseAspect<T> class with the specified target object.
protected BaseAspect(T obj, bool strict = true)
Parameters
obj
TTarget object to apply the aspect to.
strict
boolIf true, throws an exception if the target does not qualify for the aspect.
Properties
DumpUnqualifiedTargets
public static bool DumpUnqualifiedTargets { get; }
Property Value
EntityManager
protected EntityManager EntityManager { get; }
Property Value
- EntityManager
IsEntity
Indicates whether this aspect is an entity aspect.
public virtual bool IsEntity { get; }
Property Value
IsEquipment
Indicates whether this aspect is an equipment aspect.
public virtual bool IsEquipment { get; }
Property Value
Log
protected virtual Logger Log { get; }
Property Value
MetaSerializer
Serializer for metadata associated with this aspect.
public IMetaSerializer MetaSerializer { get; set; }
Property Value
Strict
public bool Strict { get; set; }
Property Value
Target
The wrapped object this aspect operates on.
public T Target { get; }
Property Value
- T
World
public World World { get; }
Property Value
- World
Methods
As<TX>(bool, params object?[]?)
Converts this aspect to a specific type TX
if it qualifies.
public TX As<TX>(bool strict = true, params object?[]? args) where TX : IAspect
Parameters
Returns
- TX
Type Parameters
TX
Exceptions
Create<TX>(T, bool, params object?[]?)
Creates an instance of the aspect for the specified target object.
public static TX Create<TX>(T target, bool strict = true, params object?[]? args) where TX : class, IAspect
Parameters
target
TTarget object to apply the aspect to.
strict
boolIf true, throws an exception if the target does not qualify for the aspect.
args
object[]Optional additional arguments to pass to the aspect constructor.
Returns
- TX
An instance of the aspect type
TX
.
Type Parameters
TX
Type of the aspect to create, must implement IAspect.
DisplayName()
Returns a display name for the target object.
public virtual string DisplayName()
Returns
DisplayName(T)
Returns a display name for the target object.
protected virtual string DisplayName(T obj)
Parameters
obj
T
Returns
DumpUnqualifiedTarget(T, string)
protected virtual void DumpUnqualifiedTarget(T obj, string errorMessage)
Parameters
obj
TerrorMessage
string
ExtraDetails(T)
Returns additional details about the target object, which can be used in logging or error messages.
protected virtual string ExtraDetails(T obj)
Parameters
obj
T
Returns
GetRawMetadata()
Gets the raw metadata for this aspect, must be overridden to add support.
protected virtual string GetRawMetadata()
Returns
Exceptions
Initialize(T)
Initializes the aspect with the target object.
protected void Initialize(T obj)
Parameters
obj
T
Exceptions
OnUnqualifiedTarget(T, string)
Called when the target object does not qualify for this aspect.
protected virtual void OnUnqualifiedTarget(T obj, string errorMessage)
Parameters
obj
TerrorMessage
string
Qualifies(T)
Determines if the target object qualifies for this aspect.
public abstract bool Qualifies(T obj)
Parameters
obj
T
Returns
ReadMetadata<TData>()
Reads metadata of type TData
from the aspect's raw metadata.
public virtual TData? ReadMetadata<TData>() where TData : struct
Returns
- TData?
Type Parameters
TData
SetRawMetadata(string)
Sets the raw metadata for this aspect, must be overridden to add support.
protected virtual void SetRawMetadata(string json)
Parameters
json
string
Exceptions
UnqualifiedTargetError(T, string?)
Throws an exception indicating that the target object does not qualify for this aspect.
protected Exception UnqualifiedTargetError(T obj, string? message = null)
Parameters
obj
Tmessage
string
Returns
Exceptions
UnqualifiedTargetMessage(T)
Generates a default error message when the target object does not qualify for this aspect.
protected virtual string UnqualifiedTargetMessage(T obj)
Parameters
obj
T
Returns
WriteMetadata<TData>(TData)
Writes metadata of type TData
to the aspect's raw metadata.
public virtual string WriteMetadata<TData>(TData data) where TData : struct
Parameters
data
TData
Returns
Type Parameters
TData