swiftlys2/docs/api/ai/
API Reference EntitySystem

IEntitySystemService

Interface
Namespace: SwiftlyS2.Shared.EntitySystem · Assembly: SwiftlyS2.CS2.dll
public interface IEntitySystemService
View source

Methods

CreateEntity<T>()

Create an entity by class.

T CreateEntity<T>() where T : class, ISchemaClass<T>
Returns
T
Created entity.
Exceptions

CreateEntity<T>(int)

Create an entity by class.

T CreateEntity<T>(int forcedIndex) where T : class, ISchemaClass<T>
Parameters
  • forcedIndexintForced entity index.
Returns
T
Created entity.
Exceptions

CreateEntityByDesignerName<T>(string)

Create an entity by designer name.

T CreateEntityByDesignerName<T>(string designerName) where T : class, ISchemaClass<T>
Parameters
  • designerNamestringDesigner name.
Returns
T
Created entity.
Exceptions

CreateEntityByDesignerName<T>(string, int)

Create an entity by designer name.

T CreateEntityByDesignerName<T>(string designerName, int forcedIndex) where T : class, ISchemaClass<T>
Parameters
  • designerNamestringDesigner name.
  • forcedIndexintForced entity index.
Returns
T
Created entity.
Exceptions

GetAllEntities()

Get all entities.

IEnumerable<CEntityInstance> GetAllEntities()
Returns
All entities.
Exceptions

GetAllEntitiesByClass<T>()

Get all entities by class.

IEnumerable<T> GetAllEntitiesByClass<T>() where T : class, ISchemaClass<T>
Returns
All entities by class.
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
  • designerNamestringDesigner name.
Returns
All entities by designer name.
Exceptions

GetEntityByAddress<T>(nint)

Get an entity by address.

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

GetEntityByAddress(nint)

Get an entity by address.

CEntityInstance? GetEntityByAddress(nint address)
Parameters
  • addressnintEntity address.
Returns
Entity by address. Nullable.
Exceptions

GetEntityByIndex<T>(uint)

Get an entity by index.

T? GetEntityByIndex<T>(uint index) where T : class, ISchemaClass<T>
Parameters
  • indexuintEntity index.
Returns
T?
Entity by index. Nullable.
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
  • indexuintEntity index.
Returns
Entity by index. Nullable.
Exceptions

GetGameRules()

Get the game rules entity.

CCSGameRules? GetGameRules()
Returns
Game rules entity. Nullable.
Exceptions

GetRefEHandle<T>(T)

Get a reference handle to the entity.

CHandle<T> GetRefEHandle<T>(T entity) where T : class, ISchemaClass<T>
Parameters
  • entityTEntity instance.
Returns
CHandle<T>
Reference entity handle to the entity.
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
A Guid that uniquely identifies the hook. This identifier can be used to remove the hook.

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
  • designerNamestringThe designer name of the entity to hook. This value cannot be null or empty.
  • inputNamestringThe name of the input to hook. This value cannot be null or empty.
  • callbackIEntitySystemService.EntityInputEventHandlerThe callback function to invoke when the input is accepted. This value cannot be null .
Returns
A Guid that uniquely identifies the hook. This identifier can be used to remove the hook.

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
A Guid that uniquely identifies the hook. This identifier can be used to remove the hook.

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
  • designerNamestringThe designer name of the entity to hook. This value cannot be null or empty.
  • outputNamestringThe name of the output to hook. This value cannot be null or empty.
  • callbackIEntitySystemService.EntityOutputEventHandlerThe callback function to invoke when the output is triggered. This value cannot be null .
Returns
A Guid that uniquely identifies the hook. This identifier can be used to remove the hook.

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
  • guidGuidThe unique identifier of the entity input to unhook.
Returns
true 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
  • guidGuidThe unique identifier of the entity output to unhook.
Returns
true if the hook was successfully removed; otherwise, false .