Class EcsApi
Namespace: ReadyM.Relay.Server.Sdk.Ecs
Assembly: ReadyM.Relay.Server.Sdk.dll
Mod-side ECS API. Wraps the function pointers exposed by the AOT server.
All component types - whether defined in the server binary or in this mod - are
identified by int component IDs assigned at registration time.
public class EcsApi
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Methods
CreateAreaEntity(ArchetypeId, AreaId)
Creates a networked entity in the Area scope. When the area entity is destroyed, this entity is destroyed too. The entity is owned by the server.
public Entity CreateAreaEntity(ArchetypeId archetypeId, AreaId areaId)
Parameters
archetypeId ArchetypeId
The entity Archetype.
areaId AreaId
The Area in whose scope the entity is created.
Returns
The created entity.
CreateAreaEntity(ArchetypeId, AreaId, PlayerId)
Creates a networked entity in the Area scope, with an owner override. When the area entity is destroyed, this entity is destroyed too.
public Entity CreateAreaEntity(ArchetypeId archetypeId, AreaId areaId, PlayerId owner)
Parameters
archetypeId ArchetypeId
The entity Archetype.
areaId AreaId
The Area in whose scope the entity is created.
owner PlayerId
The owner of the entity.
Returns
The created entity.
CreateCellEntity(ArchetypeId, FullCellId)
Creates a networked entity in the Cell scope. When the cell entity is destroyed, this entity is destroyed too.
public Entity CreateCellEntity(ArchetypeId archetypeId, FullCellId cellId)
Parameters
archetypeId ArchetypeId
The entity Archetype.
cellId FullCellId
The Cell in whose scope the entity is created.
Returns
The created entity.
CreateCellEntity(ArchetypeId, FullCellId, PlayerId)
Creates a networked entity in the Cell scope, with an owner override. When the cell entity is destroyed, this entity is destroyed too.
public Entity CreateCellEntity(ArchetypeId archetypeId, FullCellId cellId, PlayerId owner)
Parameters
archetypeId ArchetypeId
The entity Archetype.
cellId FullCellId
The Cell in whose scope the entity is created.
owner PlayerId
The owner of the entity.
Returns
The created entity.
CreateCellEntity(ArchetypeId, AreaId, CellId)
Creates a networked entity in the Cell scope. When the cell entity is destroyed, this entity is destroyed too. The entity is owned by the server.
public Entity CreateCellEntity(ArchetypeId archetypeId, AreaId areaId, CellId cellId)
Parameters
archetypeId ArchetypeId
The entity Archetype.
areaId AreaId
The Cell's area.
cellId CellId
The Cell in whose scope the entity is created.
Returns
The created entity.
CreateCellEntity(ArchetypeId, AreaId, CellId, PlayerId)
Creates a networked entity in the Cell scope, with an owner override. When the cell entity is destroyed, this entity is destroyed too.
public Entity CreateCellEntity(ArchetypeId archetypeId, AreaId areaId, CellId cellId, PlayerId ownerOverride)
Parameters
archetypeId ArchetypeId
The entity Archetype.
areaId AreaId
The Cell's area.
cellId CellId
The Cell in whose scope the entity is created.
ownerOverride PlayerId
The owner of the entity.
Returns
The created entity.
CreateEntity(ArchetypeId)
Create a server-owned networked entity in no particular scope.
public Entity CreateEntity(ArchetypeId archetypeId)
Parameters
archetypeId ArchetypeId
The entity Archetype.
Returns
The created entity.
CreateEntity(ArchetypeId, PlayerId)
Create a networked entity in no particular scope, with an owner override. The owner override is used to determine which client can modify it.
public Entity CreateEntity(ArchetypeId archetypeId, PlayerId owner)
Parameters
archetypeId ArchetypeId
The entity Archetype.
owner PlayerId
The owner of the entity.
Returns
The created entity.
CreateGlobalEntity(ArchetypeId)
Creates a networked entity in the Global scope. The entity is owned by the server.
public Entity CreateGlobalEntity(ArchetypeId archetypeId)
Parameters
archetypeId ArchetypeId
The entity Archetype.
Returns
The created entity.
CreateGlobalEntity(ArchetypeId, PlayerId)
Creates a networked entity in the Global scope, with an owner override.
public Entity CreateGlobalEntity(ArchetypeId archetypeId, PlayerId owner)
Parameters
archetypeId ArchetypeId
The entity Archetype.
owner PlayerId
The owner of the entity.
Returns
The created entity.
CreateLocalEntity(ArchetypeId)
Creates a server-only entity: never replicated, invisible to clients.
public Entity CreateLocalEntity(ArchetypeId archetypeId)
Parameters
archetypeId ArchetypeId
The entity Archetype.
Returns
The created entity.
CreateLocalEntity(ArchetypeId, int)
Creates a server-only entity: never replicated, invisible to clients.
public Entity CreateLocalEntity(ArchetypeId archetypeId, int parentId)
Parameters
archetypeId ArchetypeId
The entity Archetype.
parentId int
The entity that owns the new one. Deleting it with Int32) deletes the new one too.
Returns
The created entity.
CreatePlayerEntity(ArchetypeId, PlayerId)
Creates a networked entity in the Player scope. When the associated player entity is destroyed, this entity is destroyed too. The entity is owned by the server (the player can only read it, not modify it).
public Entity CreatePlayerEntity(ArchetypeId archetypeId, PlayerId playerId)
Parameters
archetypeId ArchetypeId
The entity Archetype.
playerId PlayerId
The player in whose scope the entity is created.
Returns
The created entity.
CreatePlayerEntity(ArchetypeId, PlayerId, PlayerId)
Creates a networked entity in the Player scope, with an owner override. Usually, the player in whose scope the entity is created should be the owner.
public Entity CreatePlayerEntity(ArchetypeId archetypeId, PlayerId playerId, PlayerId owner)
Parameters
archetypeId ArchetypeId
The entity Archetype.
playerId PlayerId
The player in whose scope the entity is created.
owner PlayerId
The owner of the entity.
Returns
The created entity.
DeleteEntity(in Entity)
Deletes a networked entity.
public bool DeleteEntity(in Entity entity)
Parameters
entity Entity
The entity to delete.
Returns
Whether the entity was deleted (true) or already gone (false).
DeleteEntity(int)
Deletes a networked entity.
public bool DeleteEntity(int entityId)
Parameters
entityId int
The ID of the entity to delete.
Returns
Whether the entity was deleted (true) or already gone (false).
DeleteEntityTree(int)
Deletes an entity together with everything below it. Deleting a parent on its own leaves its children behind without one, so this is the call to use for anything that owns other entities.
public int DeleteEntityTree(int entityId)
Parameters
entityId int
The ID of the entity to delete along with its children.
Returns
How many entities were deleted.
GetChildren(int)
The children of an entity. This one allocates, so call it outside a query callback, where a no-GC region is held over raw component pointers.
public int[] GetChildren(int parentId)
Parameters
parentId int
Returns
int[]
GetComponentRef<T>(int)
public ref T GetComponentRef<T>(int entityId) where T : struct
Parameters
entityId int
Returns
T
Type Parameters
T
GetParent(int)
0 when the entity has no parent.
public int GetParent(int childId)
Parameters
childId int
The ID of the child entity.
Returns
The ID of the parent entity, or 0 if there is no parent.
HasComponent<T>(int)
public bool HasComponent<T>(int entityId) where T : struct
Parameters
entityId int
Returns
Type Parameters
T
Query<T>(EmbedForEach<T>)
public void Query<T>(EcsApi.EmbedForEach<T> callback) where T : struct
Parameters
callback EcsApi.EmbedForEach<T>
Type Parameters
T
Query<T, TState>(TState, EmbedForEachStateManaged<T, TState>)
public void Query<T, TState>(TState state, EcsApi.EmbedForEachStateManaged<T, TState> callback) where T : struct where TState : class
Parameters
state TState
callback EcsApi.EmbedForEachStateManaged<T, TState>
Type Parameters
T
TState
Query<T, TState>(ref TState, EmbedForEachState<T, TState>)
public void Query<T, TState>(ref TState state, EcsApi.EmbedForEachState<T, TState> callback) where T : struct where TState : unmanaged
Parameters
state TState
callback EcsApi.EmbedForEachState<T, TState>
Type Parameters
T
TState
Query<T1, T2>(EmbedForEach<T1, T2>)
public void Query<T1, T2>(EcsApi.EmbedForEach<T1, T2> callback) where T1 : struct where T2 : struct
Parameters
callback EcsApi.EmbedForEach<T1, T2>
Type Parameters
T1
T2
Query<T1, T2, TState>(TState, EmbedForEachStateManaged<T1, T2, TState>)
public void Query<T1, T2, TState>(TState state, EcsApi.EmbedForEachStateManaged<T1, T2, TState> callback) where T1 : struct where T2 : struct where TState : class
Parameters
state TState
callback EcsApi.EmbedForEachStateManaged<T1, T2, TState>
Type Parameters
T1
T2
TState
Query<T1, T2, TState>(ref TState, EmbedForEachState<T1, T2, TState>)
public void Query<T1, T2, TState>(ref TState state, EcsApi.EmbedForEachState<T1, T2, TState> callback) where T1 : struct where T2 : struct where TState : unmanaged
Parameters
state TState
callback EcsApi.EmbedForEachState<T1, T2, TState>
Type Parameters
T1
T2
TState
Query<T1, T2, T3>(EmbedForEach<T1, T2, T3>)
public void Query<T1, T2, T3>(EcsApi.EmbedForEach<T1, T2, T3> callback) where T1 : struct where T2 : struct where T3 : struct
Parameters
callback EcsApi.EmbedForEach<T1, T2, T3>
Type Parameters
T1
T2
T3
Query<T1, T2, T3, TState>(TState, EmbedForEachStateManaged<T1, T2, T3, TState>)
public void Query<T1, T2, T3, TState>(TState state, EcsApi.EmbedForEachStateManaged<T1, T2, T3, TState> callback) where T1 : struct where T2 : struct where T3 : struct where TState : class
Parameters
state TState
callback EcsApi.EmbedForEachStateManaged<T1, T2, T3, TState>
Type Parameters
T1
T2
T3
TState
Query<T1, T2, T3, TState>(ref TState, EmbedForEachState<T1, T2, T3, TState>)
public void Query<T1, T2, T3, TState>(ref TState state, EcsApi.EmbedForEachState<T1, T2, T3, TState> callback) where T1 : struct where T2 : struct where T3 : struct where TState : unmanaged
Parameters
state TState
callback EcsApi.EmbedForEachState<T1, T2, T3, TState>
Type Parameters
T1
T2
T3
TState
Query<T1, T2, T3, T4>(EmbedForEach<T1, T2, T3, T4>)
public void Query<T1, T2, T3, T4>(EcsApi.EmbedForEach<T1, T2, T3, T4> callback) where T1 : struct where T2 : struct where T3 : struct where T4 : struct
Parameters
callback EcsApi.EmbedForEach<T1, T2, T3, T4>
Type Parameters
T1
T2
T3
T4
Query<T1, T2, T3, T4, TState>(TState, EmbedForEachStateManaged<T1, T2, T3, T4, TState>)
public void Query<T1, T2, T3, T4, TState>(TState state, EcsApi.EmbedForEachStateManaged<T1, T2, T3, T4, TState> callback) where T1 : struct where T2 : struct where T3 : struct where T4 : struct where TState : class
Parameters
state TState
callback EcsApi.EmbedForEachStateManaged<T1, T2, T3, T4, TState>
Type Parameters
T1
T2
T3
T4
TState
Query<T1, T2, T3, T4, TState>(ref TState, EmbedForEachState<T1, T2, T3, T4, TState>)
public void Query<T1, T2, T3, T4, TState>(ref TState state, EcsApi.EmbedForEachState<T1, T2, T3, T4, TState> callback) where T1 : struct where T2 : struct where T3 : struct where T4 : struct where TState : unmanaged
Parameters
state TState
callback EcsApi.EmbedForEachState<T1, T2, T3, T4, TState>
Type Parameters
T1
T2
T3
T4
TState
Query<T1, T2, T3, T4, T5>(EmbedForEach<T1, T2, T3, T4, T5>)
public void Query<T1, T2, T3, T4, T5>(EcsApi.EmbedForEach<T1, T2, T3, T4, T5> callback) where T1 : struct where T2 : struct where T3 : struct where T4 : struct where T5 : struct
Parameters
callback EcsApi.EmbedForEach<T1, T2, T3, T4, T5>
Type Parameters
T1
T2
T3
T4
T5
Query<T1, T2, T3, T4, T5, TState>(TState, EmbedForEachStateManaged<T1, T2, T3, T4, T5, TState>)
public void Query<T1, T2, T3, T4, T5, TState>(TState state, EcsApi.EmbedForEachStateManaged<T1, T2, T3, T4, T5, TState> callback) where T1 : struct where T2 : struct where T3 : struct where T4 : struct where T5 : struct where TState : class
Parameters
state TState
callback EcsApi.EmbedForEachStateManaged<T1, T2, T3, T4, T5, TState>
Type Parameters
T1
T2
T3
T4
T5
TState
Query<T1, T2, T3, T4, T5, TState>(ref TState, EmbedForEachState<T1, T2, T3, T4, T5, TState>)
public void Query<T1, T2, T3, T4, T5, TState>(ref TState state, EcsApi.EmbedForEachState<T1, T2, T3, T4, T5, TState> callback) where T1 : struct where T2 : struct where T3 : struct where T4 : struct where T5 : struct where TState : unmanaged
Parameters
state TState
callback EcsApi.EmbedForEachState<T1, T2, T3, T4, T5, TState>
Type Parameters
T1
T2
T3
T4
T5
TState
Query<T1, T2, T3, T4, T5, T6>(EmbedForEach<T1, T2, T3, T4, T5, T6>)
public void Query<T1, T2, T3, T4, T5, T6>(EcsApi.EmbedForEach<T1, T2, T3, T4, T5, T6> callback) where T1 : struct where T2 : struct where T3 : struct where T4 : struct where T5 : struct where T6 : struct
Parameters
callback EcsApi.EmbedForEach<T1, T2, T3, T4, T5, T6>
Type Parameters
T1
T2
T3
T4
T5
T6
Query<T1, T2, T3, T4, T5, T6, TState>(TState, EmbedForEachStateManaged<T1, T2, T3, T4, T5, T6, TState>)
public void Query<T1, T2, T3, T4, T5, T6, TState>(TState state, EcsApi.EmbedForEachStateManaged<T1, T2, T3, T4, T5, T6, TState> callback) where T1 : struct where T2 : struct where T3 : struct where T4 : struct where T5 : struct where T6 : struct where TState : class
Parameters
state TState
callback EcsApi.EmbedForEachStateManaged<T1, T2, T3, T4, T5, T6, TState>
Type Parameters
T1
T2
T3
T4
T5
T6
TState
Query<T1, T2, T3, T4, T5, T6, TState>(ref TState, EmbedForEachState<T1, T2, T3, T4, T5, T6, TState>)
public void Query<T1, T2, T3, T4, T5, T6, TState>(ref TState state, EcsApi.EmbedForEachState<T1, T2, T3, T4, T5, T6, TState> callback) where T1 : struct where T2 : struct where T3 : struct where T4 : struct where T5 : struct where T6 : struct where TState : unmanaged
Parameters
state TState
callback EcsApi.EmbedForEachState<T1, T2, T3, T4, T5, T6, TState>
Type Parameters
T1
T2
T3
T4
T5
T6
TState
QueryWithEntity<T>(EmbedForEachEntity<T>)
Iterates a component along with the entity id it belongs to.
public void QueryWithEntity<T>(EcsApi.EmbedForEachEntity<T> callback) where T : struct
Parameters
callback EcsApi.EmbedForEachEntity<T>
Type Parameters
T
QueryWithEntity<T1, T2>(EmbedForEachEntity<T1, T2>)
Iterates a component along with the entity id it belongs to.
public void QueryWithEntity<T1, T2>(EcsApi.EmbedForEachEntity<T1, T2> callback) where T1 : struct where T2 : struct
Parameters
callback EcsApi.EmbedForEachEntity<T1, T2>
Type Parameters
T1
T2
SetComponent<T>(int, in T)
Writes a component by entity id.
public void SetComponent<T>(int entityId, in T component) where T : struct
Parameters
entityId int
component T
Type Parameters
T
SetParent(int, int)
Makes the child belong to the parent, replacing whatever parent it had.
public int SetParent(int childId, int parentId)
Parameters
childId int
parentId int
Returns
The index the child took among the parent's children, or -1 if it already was one.
TryGetComponent<T>(int, out T)
False when the entity is gone or does not carry the component.
public bool TryGetComponent<T>(int entityId, out T component) where T : struct
Parameters
entityId int
component T
Returns
Type Parameters
T