Sites

Menu

EntityTemplate Class

Namespace: Improbable.Gdk.Core
GDK package: Core
Source

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<TSnapshot> Source
void AddComponent<TSnapshot>(TSnapshot snapshot, string writeAccess)

Adds a SpatialOS component to the EntityTemplate.

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

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

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

Exceptions:
  • InvalidOperationException : Thrown if the EntityTemplate already contains a component snapshot of type TSnapshot.
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.
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<TSnapshot> Source
void SetComponent<TSnapshot>(TSnapshot snapshot)

Sets a component snapshot in the EntityTemplate.

Parameters
  • TSnapshot snapshot : The component snapshot that will be inserted into the EntityTemplate.

Notes:
  • This will override a snapshot of type TSnapshot in the EntityTemplate if one already exists.

Type parameters:
  • TSnapshot : The type of the component snapshot.
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.
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.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums