Table of Contents

Class Component

Namespace
SampSharp.Entities
Assembly
SampSharp.OpenMp.Entities.dll

Represents a component which can be attached to an entity.

public abstract class Component
Inheritance
Component
Derived
Inherited Members

Constructors

Component()

protected Component()

Properties

Entity

Gets the entity to which this component has been attached.

public virtual EntityId Entity { get; }

Property Value

EntityId

IsComponentAlive

Gets a value indicating whether this component is alive (has not been destroyed).

public bool IsComponentAlive { get; }

Property Value

bool

IsDestroying

Gets a value indicating whether this component is being destroyed. This property is set to true when the destruction of this component has been initiated.

public bool IsDestroying { get; }

Property Value

bool

Manager

Gets the manager of the entity of this component.

protected virtual IEntityManager Manager { get; }

Property Value

IEntityManager

Parent

Gets the parent entity of the entity to which this component has been attached.

public EntityId Parent { get; }

Property Value

EntityId

Methods

AddComponent<T>()

Adds a component of the specified type T to the entity.

public T AddComponent<T>() where T : Component

Returns

T

The created component.

Type Parameters

T

The type of the component to add.

AddComponent<T>(params object[])

Adds a component of the specified type T to the entity with the specified constructor args.

public T AddComponent<T>(params object[] args) where T : Component

Parameters

args object[]

The arguments of the constructor of the component.

Returns

T

The created component.

Type Parameters

T

The type of the component to add.

AddComponent<T>(T)

Adds a component of the specified type T to the entity.

public void AddComponent<T>(T component) where T : Component

Parameters

component T

The instance of component to be added.

Type Parameters

T

The type of the component to add.

Destroy()

Destroys this component.

public void Destroy()

DestroyComponents<T>()

Destroys the components of the specified type T attached to the entity.

public void DestroyComponents<T>() where T : Component

Type Parameters

T

The type of the components to destroy.

DestroyEntity()

Destroys the entity.

public void DestroyEntity()

GetComponentInChildren<T>()

Gets a component of the specified type T attached to a child entity of the entity using a depth first search.

public T? GetComponentInChildren<T>() where T : Component

Returns

T

The found component or null if no component of the specified type could be found.

Type Parameters

T

The type of the component to find.

GetComponentInParent<T>()

Gets a component of the specified type T attached to a parent entity of the entity.

public T? GetComponentInParent<T>() where T : Component

Returns

T

The found component or null if no component of the specified type could be found.

Type Parameters

T

The type of the component to find.

GetComponent<T>()

Gets a component of the specified type T attached to the entity.

public T? GetComponent<T>() where T : Component

Returns

T

The found component or null if no component of the specified type could be found.

Type Parameters

T

The type of the component to find.

GetComponentsInChildren<T>()

Gets all components of the specified type T attached to a child entity of the entity.

public T[] GetComponentsInChildren<T>() where T : Component

Returns

T[]

A collection of the found components.

Type Parameters

T

The type of the components to find.

GetComponentsInParent<T>()

Gets all components of the specified type T attached to a parent entity of the entity.

public T[] GetComponentsInParent<T>() where T : Component

Returns

T[]

A collection of the found components.

Type Parameters

T

The type of the components to find.

GetComponents<T>()

Gets all components of the specified type T attached to the entity.

public T[] GetComponents<T>() where T : Component

Returns

T[]

A collection of the found components.

Type Parameters

T

The type of the components to find.

OnDestroyComponent()

This method is invoked before this component is destroyed and removed from its entity.

protected virtual void OnDestroyComponent()

OnInitializeComponent()

This method is invoked after this component has been attached the an entity.

protected virtual void OnInitializeComponent()

Operators

operator false(Component?)

Implements the operator false. Returns true if the specified component is not alive.

public static bool operator false(Component? component)

Parameters

component Component

The component.

Returns

bool

true if the specified component is not alive; false otherwise.

operator !(Component?)

Implements the operator !. Returns true if the specified component is not alive.

public static bool operator !(Component? component)

Parameters

component Component

The component.

Returns

bool

true if the specified component is not alive; otherwise false.

operator true(Component?)

Implements the operator true. Returns true if the specified component is alive.

public static bool operator true(Component? component)

Parameters

component Component

The component.

Returns

bool

true if the specified component is alive; false otherwise.