Table of Contents

Class Entity

Namespace
AO
Assembly
CoreAssembly.dll

Entities are the base object we work with. They can have components attached to them and can be parented to other entities.

public class Entity
Inheritance
Entity
Inherited Members
Extension Methods

Fields

MarkedForDestroy

Is the entity itself destroyed.

public bool MarkedForDestroy

Field Value

bool

Properties

Children

All children directly under this entity

public Entity.ChildEnumerator Children { get; }

Property Value

Entity.ChildEnumerator

Id

The unique generational ID of this entity.

public ulong Id { get; }

Property Value

ulong

IdGeneration

The generation part of the entity ID.

public int IdGeneration { get; }

Property Value

int

IdIndex

The index part of the entity ID.

public int IdIndex { get; }

Property Value

int

LocalEnabled

Is the entity itself enabled.

public bool LocalEnabled { get; set; }

Property Value

bool

LocalPosition

The local position of the entity.

public Vector2 LocalPosition { get; set; }

Property Value

Vector2

LocalRotation

The local rotation of the entity in degrees.

public float LocalRotation { get; set; }

Property Value

float

LocalRotationTurns

The world rotation of the entity in turns

public float LocalRotationTurns { get; set; }

Property Value

float

LocalScale

The local scale of the entity.

public Vector2 LocalScale { get; set; }

Property Value

Vector2

LocalScaleX

Utility to grab the entity's local X scale

public float LocalScaleX { get; set; }

Property Value

float

LocalScaleY

Utility to grab the entity's lcoal Y scale

public float LocalScaleY { get; set; }

Property Value

float

LocalX

Utility to get/set the entity's local X position

public float LocalX { get; set; }

Property Value

float

LocalY

Utility to get/set the entity's local Y position

public float LocalY { get; set; }

Property Value

float

Name

Entity name

public string Name { get; set; }

Property Value

string

NetSyncDataFrameNumber

public uint NetSyncDataFrameNumber { get; }

Property Value

uint

NetSyncFlags

public Entity.NetSyncOptions NetSyncFlags { get; set; }

Property Value

Entity.NetSyncOptions

NetSyncReceiveFrameNumber

public uint NetSyncReceiveFrameNumber { get; }

Property Value

uint

NetworkId

The unique network id of the entity. Can be used to describe entities across the network

public ulong NetworkId { get; }

Property Value

ulong

Parent

Gets the parent of the entity. Null if this entity is at root level in the scene.

public Entity Parent { get; }

Property Value

Entity

Position

The world position of the entity. Takes into account all the parent enties transform matrix.

public Vector2 Position { get; set; }

Property Value

Vector2

Rotation

The world rotaiton of the entity in degrees. Takes into account all the parent enties transform matrix.

public float Rotation { get; set; }

Property Value

float

RotationTurns

The world rotation of the entity in turns

public float RotationTurns { get; set; }

Property Value

float

Scale

The world scale of the entity. Takes into account all the parent enties transform matrix.

public Vector2 Scale { get; set; }

Property Value

Vector2

ServerPosition

public Vector2 ServerPosition { get; }

Property Value

Vector2

WorldEnabled

Is the entity and all its parents enabled.

public bool WorldEnabled { get; }

Property Value

bool

X

Utility to get/set the entity's X position

public float X { get; set; }

Property Value

float

Y

Utility to get/set the entity's Y position

public float Y { get; set; }

Property Value

float

Methods

AddComponent(Type, Action<Component>)

public Component AddComponent(Type type, Action<Component> onBeforeAwake = null)

Parameters

type Type
onBeforeAwake Action<Component>

Returns

Component

AddComponent<T>(Action<T>)

Add a component of type T to this entity

public T AddComponent<T>(Action<T> onBeforeAwake = null) where T : Component

Parameters

onBeforeAwake Action<T>

Returns

T

Type Parameters

T

CalculateWorldMatrix()

The world matrix of the entity. Takes into account all the parent enties transform matrix.

public Matrix4 CalculateWorldMatrix()

Returns

Matrix4

Clone()

Clone this entity

public Entity Clone()

Returns

Entity

Create()

Create a new empty entity

public static extern Entity Create()

Returns

Entity

The new entity

Destroy()

Mark this entity for destruction

public void Destroy()

FindByName(string)

Find an entity by its name

public static extern Entity FindByName(string name)

Parameters

name string

Returns

Entity

The entity matching the name

FindByNetworkId(ulong)

Find an entity by its network id

public static extern Entity FindByNetworkId(ulong network_id)

Parameters

network_id ulong

Returns

Entity

The entity matching the network id

FindComponentByNetworkId(ulong, ulong, out Entity, out Component)

Find an entity and component by its network id and component id

public static extern void FindComponentByNetworkId(ulong network_id, ulong component_id, out Entity e, out Component c)

Parameters

network_id ulong
component_id ulong
e Entity
c Component

GetAllComponents(List<Component>)

Populate the given list with references to all components attached to this entity.

public void GetAllComponents(List<Component> outComponents)

Parameters

outComponents List<Component>

GetChildCount()

Gets how many children this entity has

public int GetChildCount()

Returns

int

GetComponentById(ulong)

Get the component with the given ID attached to this entity.

public Component GetComponentById(ulong componentId)

Parameters

componentId ulong

Returns

Component

GetComponent<T>(ulong)

Get the first component of type T attached to this entity

public T GetComponent<T>(ulong componentId = 0) where T : Component

Parameters

componentId ulong

Returns

T

Type Parameters

T

GetSceneHierarchyPath()

public string GetSceneHierarchyPath()

Returns

string

Instantiate(Prefab, Action<Entity>)

Instantiate a prefab into the scene

public static Entity Instantiate(Prefab prefab, Action<Entity> onBeforeAwake = null)

Parameters

prefab Prefab
onBeforeAwake Action<Entity>

Returns

Entity

RemoveComponent(Component)

Remove the specified component from this entity.

public void RemoveComponent(Component component)

Parameters

component Component

RemoveComponent<T>()

Remove the first component found of type T from this entity.

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

Type Parameters

T

SetParent(Entity, bool)

Set the parent of the entity.

public void SetParent(Entity newParent, bool keepWorldPosition)

Parameters

newParent Entity
keepWorldPosition bool

Should we stay in the same spot.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryGetChildByIndex(int)

Gets a child of this entity by index. Returns null if index is negative or if index is greater than or equal to the number of children.

public Entity TryGetChildByIndex(int index)

Parameters

index int

Returns

Entity

TryGetChildByName(string)

Gets a child of this entity with matching name. Returns null if none match.

public Entity TryGetChildByName(string name)

Parameters

name string

Returns

Entity

TryGetComponent<T>(out T)

public bool TryGetComponent<T>(out T t) where T : Component

Parameters

t T

Returns

bool

Type Parameters

T

Unsafe_NetworkEntity(ulong)

Networks the entity, setting its network ID to the one passed in. This is a dangerous function and can break things if not used properly. Usually used in tandem with Scene.Unsafe_ServerGetNextNetworkId.

public void Unsafe_NetworkEntity(ulong networkId)

Parameters

networkId ulong