SwiftlyS2

Interface IEntitySystemService

Interface IEntitySystemService

Namespace: SwiftlyS2.Shared.EntitySystem

Assembly: SwiftlyS2.CS2.dll

public interface IEntitySystemService

Methods

CreateEntity<T>()

Create an entity by class.

T CreateEntity<T>() where T : class, ISchemaClass<T>
Returns
  • T — Created entity.
Type Parameters
  • T — Entity type.
Exceptions
  • ArgumentException — Thrown when failed to create entity by class or class doesn't have a designer name.
  • InvalidOperationException — Thrown when called too early that entity system is not valid at this moment.

CreateEntityByDesignerName<T>(string)

Create an entity by designer name.

T CreateEntityByDesignerName<T>(string designerName) where T : class, ISchemaClass<T>
Parameters
  • designerName string — Designer name.
Returns
  • T — Created entity.
Type Parameters
  • T — Entity type.
Exceptions
  • ArgumentException — Thrown when failed to create entity by designer name or designer name is invalid.
  • InvalidOperationException — Thrown when called too early that entity system is not valid at this moment.

GetAllEntities()

Get all entities.

IEnumerable<CEntityInstance> GetAllEntities()
Returns
Exceptions

GetAllEntitiesByClass<T>()

Get all entities by class.

IEnumerable<T> GetAllEntitiesByClass<T>() where T : class, ISchemaClass<T>
Returns
Type Parameters
  • T — Entity type.
Exceptions

GetAllEntitiesByDesignerName<T>(string)

Get all entities by designer name, and cast to type T.

IEnumerable<T> GetAllEntitiesByDesignerName<T>(string designerName) where T : class, ISchemaClass<T>
Parameters
  • designerName string — Designer name.
Returns
Type Parameters
  • T — Entity type.
Exceptions

GetEntityByAddress<T>(nint)

Get an entity by address.

T? GetEntityByAddress<T>(nint address) where T : class, ISchemaClass<T>
Parameters
  • address nint — Entity address.
Returns
  • T? — Entity by address. Nullable.
Type Parameters
  • T — Entity type.
Exceptions

GetEntityByAddress(nint)

Get an entity by address.

CEntityInstance? GetEntityByAddress(nint address)
Parameters
  • address nint — Entity address.
Returns
Exceptions

GetEntityByIndex<T>(uint)

Get an entity by index.

T? GetEntityByIndex<T>(uint index) where T : class, ISchemaClass<T>
Parameters
  • index uint — Entity index.
Returns
  • T? — Entity by index. Nullable.
Type Parameters
  • T — Entity type.
Exceptions

GetEntityByIndex(uint)

Get an entity by index. The object return will have the actual type of the entity. You can cast it to the actual type.

CEntityInstance? GetEntityByIndex(uint index)
Parameters
  • index uint — Entity index.
Returns
Exceptions

GetGameRules()

Get the game rules entity.

CCSGameRules? GetGameRules()
Returns
Exceptions

GetRefEHandle<T>(T)

Get a reference handle to the entity.

CHandle<T> GetRefEHandle<T>(T entity) where T : class, ISchemaClass<T>
Parameters
  • entity T — Entity instance.
Returns
  • CHandle<T> — Reference entity handle to the entity.
Type Parameters
  • T — Entity type.
Exceptions

HookEntityInput<T>(string, EntityInputEventHandler)

Hooks an input of the specified entity type to a callback function.

Guid HookEntityInput<T>(string inputName, IEntitySystemService.EntityInputEventHandler callback) where T : class, ISchemaClass<T>
Parameters
Returns
  • Guid — A System.Guid that uniquely identifies the hook. This identifier can be used to remove the hook.
Type Parameters
  • T — The type of the entity, which must implement SwiftlyS2.Shared.Schemas.ISchemaClass%601.
Remarks

This method allows you to attach a handler to a specific input of an entity. The callback will be invoked whenever the input is accepted.

HookEntityInput(string, string, EntityInputEventHandler)

Hooks an input of the specified entity type to a callback function.

Guid HookEntityInput(string designerName, string inputName, IEntitySystemService.EntityInputEventHandler callback)
Parameters
Returns
  • Guid — A System.Guid that uniquely identifies the hook. This identifier can be used to remove the hook.
Remarks

This method allows you to attach a handler to a specific input of an entity. The callback will be invoked whenever the input is accepted.

HookEntityOutput<T>(string, EntityOutputEventHandler)

Hooks an output of the specified entity type to a callback function.

Guid HookEntityOutput<T>(string outputName, IEntitySystemService.EntityOutputEventHandler callback) where T : class, ISchemaClass<T>
Parameters
Returns
  • Guid — A System.Guid that uniquely identifies the hook. This identifier can be used to remove the hook.
Type Parameters
  • T — The type of the entity, which must implement SwiftlyS2.Shared.Schemas.ISchemaClass%601.
Remarks

This method allows you to attach a handler to a specific output of an entity. The callback will be invoked whenever the output is triggered.

HookEntityOutput(string, string, EntityOutputEventHandler)

Hooks an output of the specified entity type to a callback function.

Guid HookEntityOutput(string designerName, string outputName, IEntitySystemService.EntityOutputEventHandler callback)
Parameters
Returns
  • Guid — A System.Guid that uniquely identifies the hook. This identifier can be used to remove the hook.
Remarks

This method allows you to attach a handler to a specific output of an entity. The callback will be invoked whenever the output is triggered.

UnhookEntityInput(Guid)

Removes the association between the specified entity input and its handler.

bool UnhookEntityInput(Guid guid)
Parameters
  • guid Guid — The unique identifier of the entity input to unhook.
Returns
  • booltrue if the hook was successfully removed; otherwise, false.

UnhookEntityOutput(Guid)

Removes the association between the specified entity output and its handler.

bool UnhookEntityOutput(Guid guid)
Parameters
  • guid Guid — The unique identifier of the entity output to unhook.
Returns
  • booltrue if the hook was successfully removed; otherwise, false.

On this page