EntityTemplate Class

Namespace: Improbable.Gdk.CoreSource

Utility class to help build SpatialOS entities. An EntityTemplate can be mutated be used multiple times.


Static Methods

GetWorkerAccessAttribute Source
string GetWorkerAccessAttribute(string workerId)

Constructs a worker access attribute, given a worker ID.

Returns:
A string representing the worker access attribute.

Parameters
  • string workerId : An ID of a worker.


Methods

AddComponent Source
void AddComponent(ISpatialComponentSnapshot snapshot)

Adds a SpatialOS component to the Entity Template.

Parameters

Notes:
  • EntityACL is handled automatically by the EntityTemplate, so a EntityACL snapshot will be ignored.

Exceptions:
  • InvalidOperationException : Thrown if the EntityTemplate already contains a component snapshot with the same component ID.

AddComponent Source
void AddComponent(ISpatialComponentSnapshot snapshot, string writeAccess)

Adds a SpatialOS component to the EntityTemplate with write permissions specified.

Parameters
  • ISpatialComponentSnapshot snapshot : The component snapshot to add.
  • string writeAccess : The worker attribute that should be granted write access over the given component.

Notes:
  • EntityACL is handled automatically by the EntityTemplate, so a EntityACL snapshot will be ignored.

Exceptions:
  • InvalidOperationException : Thrown if the EntityTemplate already contains a component snapshot with the same component ID.

GetComponent<TSnapshot> Source
TSnapshot? GetComponent<TSnapshot>()

Attempts to get a component snapshot stored in the EntityTemplate.

Returns:
The component snapshot, if the component snapshot exists, null otherwise.

Type parameters:
  • TSnapshot : The type of the component snapshot.

GetComponent Source
ISpatialComponentSnapshot GetComponent(uint componentId)

Attempts to get a component snapshot stored in the EntityTemplate.

Returns:
The component snapshot, if the component snapshot exists, null otherwise.

Parameters
  • uint componentId : The ID of the component to fetch.

TryGetComponent<TSnapshot> Source
bool TryGetComponent<TSnapshot>(out TSnapshot component)

Gets the component of the associated type.

Returns:
True if this contains a component of type TSnapshot; otherwise, false.

Parameters
  • out TSnapshot component : When this method returns, contains the component, if the component is found; otherwise, the default value TSnapshot. This parameter is passed uninitialized.

Type parameters:
  • TSnapshot : The type of the component snapshot.

TryGetComponent Source
bool TryGetComponent(uint componentId, out ISpatialComponentSnapshot component)

Gets the component with the associated component ID.

Returns:
True if this contains a component with the associated component ID; otherwise, false.

Parameters
  • uint componentId : The ID of the component to get.
  • out ISpatialComponentSnapshot component : When this method returns, contains the component, if the component is found; otherwise null. This parameter is passed uninitialized.

HasComponent Source
bool HasComponent(uint componentId)

Checks if a component snapshot is stored in the EntityTemplate.

Returns:
True, if the component snapshot exists, false otherwise.

Parameters
  • uint componentId : The component id to check.

HasComponent<TSnapshot> Source
bool HasComponent<TSnapshot>()

Checks if a component snapshot is stored in the EntityTemplate.

Returns:
True, if the component snapshot exists, false otherwise.

Type parameters:
  • TSnapshot : The type of the component snapshot.

SetComponent Source
void SetComponent(ISpatialComponentSnapshot snapshot)

Sets a component snapshot in the EntityTemplate.

Parameters

Notes:
  • This will override the component snapshot in the EntityTemplate if one already exists.

RemoveComponent<TSnapshot> Source
void RemoveComponent<TSnapshot>()

Removes a component snapshot from the EntityTemplate, if it exists.

Type parameters:
  • TSnapshot : The type of the component snapshot.

RemoveComponent Source
void RemoveComponent(uint componentId)

Removes a component snapshot from the EntityTemplate, if it exists.

Parameters
  • uint componentId : The component that will be removed from the EntityTemplate.

GetComponentWriteAccess Source
string GetComponentWriteAccess(uint componentId)

Retrieves the write access worker attribute for a given component.

Returns:
The write access worker attribute, if it exists, null otherwise.

Parameters
  • uint componentId : The component id for that component.

GetComponentWriteAccess<TSnapshot> Source
string GetComponentWriteAccess<TSnapshot>()

Retrieves the write access worker attribute for a given component.

Returns:
The write access worker attribute, if it exists, null otherwise.

Type parameters:
  • TSnapshot : The type of the component.

SetComponentWriteAccess Source
void SetComponentWriteAccess(uint componentId, string writeAccess)

Sets the write access worker attribute for a given component.

Parameters
  • uint componentId : The component id for that component.
  • string writeAccess : The write access worker attribute.

SetComponentWriteAccess<TSnapshot> Source
void SetComponentWriteAccess<TSnapshot>(string writeAccess)

Sets the write access worker attribute for a given component.

Parameters
  • string writeAccess : The write access worker attribute.

Type parameters:
  • TSnapshot : The type of the component.

SetReadAccess Source
void SetReadAccess(params string[] attributes)

Sets the worker attributes which should have read access over this entity.

Parameters
  • params string[] attributes : The worker attributes which should have read access.

GetEntity Source
Entity GetEntity()

Creates an Entity instance from this template.

Returns:
The Entity object.

Notes:
  • This function allocates native memory. The Entity returned from this function should be handed to a GDK API, which will take ownership, or otherwise must be disposed of manually.

GetEntitySnapshot Source
EntitySnapshot GetEntitySnapshot()

Creates an EntitySnapshot from this template.

Returns:
The EntitySnapshot object.

Updated about a year ago


EntityTemplate Class


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.