Table of Contents

Class BaseAspect<T>

Namespace
RisingV.Shared.Aspects
Assembly
RisingV.Shared.dll

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
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 bool

If 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 T

Target object to apply the aspect to.

strict bool

If true, throws an exception if the target does not qualify for the aspect.

Properties

DumpUnqualifiedTargets

public static bool DumpUnqualifiedTargets { get; }

Property Value

bool

EntityManager

protected EntityManager EntityManager { get; }

Property Value

EntityManager

IsEntity

Indicates whether this aspect is an entity aspect.

public virtual bool IsEntity { get; }

Property Value

bool

IsEquipment

Indicates whether this aspect is an equipment aspect.

public virtual bool IsEquipment { get; }

Property Value

bool

Log

protected virtual Logger Log { get; }

Property Value

Logger

MetaSerializer

Serializer for metadata associated with this aspect.

public IMetaSerializer MetaSerializer { get; set; }

Property Value

IMetaSerializer

Strict

public bool Strict { get; set; }

Property Value

bool

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

strict bool
args object[]

Returns

TX

Type Parameters

TX

Exceptions

InvalidOperationException

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 T

Target object to apply the aspect to.

strict bool

If 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

string

DisplayName(T)

Returns a display name for the target object.

protected virtual string DisplayName(T obj)

Parameters

obj T

Returns

string

DumpUnqualifiedTarget(T, string)

protected virtual void DumpUnqualifiedTarget(T obj, string errorMessage)

Parameters

obj T
errorMessage 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

string

GetRawMetadata()

Gets the raw metadata for this aspect, must be overridden to add support.

protected virtual string GetRawMetadata()

Returns

string

Exceptions

NotImplementedException

Initialize(T)

Initializes the aspect with the target object.

protected void Initialize(T obj)

Parameters

obj T

Exceptions

Exception

OnUnqualifiedTarget(T, string)

Called when the target object does not qualify for this aspect.

protected virtual void OnUnqualifiedTarget(T obj, string errorMessage)

Parameters

obj T
errorMessage string

Qualifies(T)

Determines if the target object qualifies for this aspect.

public abstract bool Qualifies(T obj)

Parameters

obj T

Returns

bool

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

NotImplementedException

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 T
message string

Returns

Exception

Exceptions

UnqualifiedTargetException

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

string

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

string

Type Parameters

TData