Show / Hide Table of Contents

Class EntityManager

Base class for client and server manager

Inheritance
object
EntityManager
ClientEntityManager
ServerEntityManager
Namespace: LiteEntitySystem
Assembly: LiteEntitySystem.dll
Syntax
public abstract class EntityManager

Constructors

EntityManager(EntityTypesMap, InputProcessor, NetworkMode, byte, byte)

Declaration
protected EntityManager(EntityTypesMap typesMap, InputProcessor inputProcessor, NetworkMode mode, byte framesPerSecond, byte headerByte)
Parameters
Type Name Description
EntityTypesMap typesMap
InputProcessor inputProcessor
NetworkMode mode
byte framesPerSecond
byte headerByte

Fields

AliveEntities

Declaration
protected readonly AVLTree<InternalEntity> AliveEntities
Field Value
Type Description
AVLTree<InternalEntity>

AllEntities

Declaration
protected readonly AVLTree<InternalEntity> AllEntities
Field Value
Type Description
AVLTree<InternalEntity>

DeltaTime

Fixed delta time

Declaration
public readonly double DeltaTime
Field Value
Type Description
double

DeltaTimeF

Fixed delta time (float for less precision)

Declaration
public readonly float DeltaTimeF
Field Value
Type Description
float

FramesPerSecond

FPS of game logic

Declaration
public readonly int FramesPerSecond
Field Value
Type Description
int

HeaderByte

Declaration
public readonly byte HeaderByte
Field Value
Type Description
byte

InputProcessor

Declaration
protected readonly InputProcessor InputProcessor
Field Value
Type Description
InputProcessor

InvalidEntityId

Invalid entity id

Declaration
public const ushort InvalidEntityId = 0
Field Value
Type Description
ushort

IsClient

Is client

Declaration
public readonly bool IsClient
Field Value
Type Description
bool

IsServer

Is server

Declaration
public readonly bool IsServer
Field Value
Type Description
bool

LagCompensatedEntities

Declaration
protected readonly AVLTree<EntityLogic> LagCompensatedEntities
Field Value
Type Description
AVLTree<EntityLogic>

MaxEntityCount

Declaration
public const int MaxEntityCount = 16384
Field Value
Type Description
int

MaxHistorySize

Size of history (in ticks) for lag compensation. Tune for your game fps

Declaration
public MaxHistorySize MaxHistorySize
Field Value
Type Description
MaxHistorySize

MaxPlayers

Declaration
public const int MaxPlayers = 254
Field Value
Type Description
int

MaxSavedStateDiff

Declaration
protected const int MaxSavedStateDiff = 30
Field Value
Type Description
int

MaxSyncedEntityCount

Maximum synchronized (without LocalOnly) entities

Declaration
public const int MaxSyncedEntityCount = 8192
Field Value
Type Description
int

Mode

Current mode (Server or Client)

Declaration
public readonly NetworkMode Mode
Field Value
Type Description
NetworkMode

ServerPlayerId

Declaration
public const byte ServerPlayerId = 0
Field Value
Type Description
byte

SpeedMultiplier

Declaration
protected float SpeedMultiplier
Field Value
Type Description
float

TimeSpeedChangeCoef

Declaration
protected const float TimeSpeedChangeCoef = 0.1
Field Value
Type Description
float

_tick

Declaration
protected ushort _tick
Field Value
Type Description
ushort

Properties

EntitiesCount

Total entities count (including local)

Declaration
public ushort EntitiesCount { get; }
Property Value
Type Description
ushort

InNormalState

Declaration
public bool InNormalState { get; }
Property Value
Type Description
bool

InRollBackState

Declaration
public bool InRollBackState { get; }
Property Value
Type Description
bool

IsRunning

Is entity manager running IsRunning - true after first update IsRunning - sets to false after Reset() call

Declaration
public bool IsRunning { get; }
Property Value
Type Description
bool

LerpFactor

Interpolation time between logic and render

Declaration
public float LerpFactor { get; }
Property Value
Type Description
float

PlayerId

Local player id (0 on server)

Declaration
public byte PlayerId { get; }
Property Value
Type Description
byte

Tick

Current tick

Declaration
public ushort Tick { get; }
Property Value
Type Description
ushort

UpdateMode

Current update mode (can be used inside entities to separate logic for rollbacks)

Declaration
public UpdateMode UpdateMode { get; protected set; }
Property Value
Type Description
UpdateMode

VisualDeltaTime

Declaration
public double VisualDeltaTime { get; }
Property Value
Type Description
double

Methods

AddEntity(EntityParams)

Declaration
protected InternalEntity AddEntity(EntityParams entityParams)
Parameters
Type Name Description
EntityParams entityParams
Returns
Type Description
InternalEntity

AddLocalSingleton<T>(T)

Add local (not synchronized) singleton.

Declaration
public void AddLocalSingleton<T>(T singleton) where T : ILocalSingleton
Parameters
Type Name Description
T singleton

Signleton to add

Type Parameters
Name Description
T

ConstructEntity(InternalEntity)

Declaration
protected void ConstructEntity(InternalEntity e)
Parameters
Type Name Description
InternalEntity e

DisableLagCompensation()

Declaration
public void DisableLagCompensation()

EnableLagCompensation(NetPlayer)

Declaration
public void EnableLagCompensation(NetPlayer player)
Parameters
Type Name Description
NetPlayer player

GetControllers<T>()

Get all controller entities with type

Declaration
public EntityFilter<T> GetControllers<T>() where T : ControllerLogic
Returns
Type Description
EntityFilter<T>

Entity filter that can be used in foreach

Type Parameters
Name Description
T

Entity type

GetEntities<T>()

Get all entities with type

Declaration
public EntityFilter<T> GetEntities<T>() where T : EntityLogic
Returns
Type Description
EntityFilter<T>

Entity filter that can be used in foreach

Type Parameters
Name Description
T

Entity type

GetEntityById<T>(EntitySharedReference)

Get entity by id

Declaration
public T GetEntityById<T>(EntitySharedReference id) where T : InternalEntity
Parameters
Type Name Description
EntitySharedReference id

Id of entity

Returns
Type Description
T

Entity if it exists, null if id == InvalidEntityId or entity is another type or version

Type Parameters
Name Description
T

GetLocalSingleton<T>()

Get local (not synchronized) singleton.

Declaration
public T GetLocalSingleton<T>() where T : ILocalSingleton
Returns
Type Description
T
Type Parameters
Name Description
T

GetSingleton<T>()

Get existing singleton entity

Declaration
public T GetSingleton<T>() where T : SingletonEntityLogic
Returns
Type Description
T

Singleton entity, can throw exceptions on invalid type

Type Parameters
Name Description
T

Singleton entity type

HasSingleton<T>()

Is singleton exists and has correct type

Declaration
public bool HasSingleton<T>() where T : SingletonEntityLogic
Returns
Type Description
bool
Type Parameters
Name Description
T

OnAliveEntityAdded(InternalEntity)

Declaration
protected virtual void OnAliveEntityAdded(InternalEntity e)
Parameters
Type Name Description
InternalEntity e

OnLogicTick()

Declaration
protected abstract void OnLogicTick()

RegisterFieldType<T>()

Register custom field type

Declaration
public static void RegisterFieldType<T>() where T : unmanaged
Type Parameters
Name Description
T

RegisterFieldType<T>(InterpolatorDelegateWithReturn<T>)

Register custom field type with interpolation

Declaration
public static void RegisterFieldType<T>(InterpolatorDelegateWithReturn<T> interpolationDelegate) where T : unmanaged
Parameters
Type Name Description
InterpolatorDelegateWithReturn<T> interpolationDelegate

interpolation function

Type Parameters
Name Description
T

RemoveEntity(InternalEntity)

Declaration
protected void RemoveEntity(InternalEntity e)
Parameters
Type Name Description
InternalEntity e

Reset()

Remove all entities and reset all counters and timers

Declaration
public virtual void Reset()

TryGetEntityById<T>(EntitySharedReference, out T)

Try get entity by id throws exception if entity is null or invalid type

Declaration
public bool TryGetEntityById<T>(EntitySharedReference id, out T entity) where T : InternalEntity
Parameters
Type Name Description
EntitySharedReference id

Id of entity

T entity

out entity if exists otherwise null

Returns
Type Description
bool

true if it exists, false if id == InvalidEntityId or entity is another type or version

Type Parameters
Name Description
T

TryGetLocalSingleton<T>(out T)

TryGet local (not synchronized) singleton.

Declaration
public bool TryGetLocalSingleton<T>(out T result) where T : ILocalSingleton
Parameters
Type Name Description
T result
Returns
Type Description
bool
Type Parameters
Name Description
T

TryGetSingleton<T>(out T)

Try get singleton entity

Declaration
public bool TryGetSingleton<T>(out T singleton) where T : SingletonEntityLogic
Parameters
Type Name Description
T singleton

result singleton entity

Returns
Type Description
bool

true if entity exists

Type Parameters
Name Description
T

Singleton type

Update()

Main update method, updates internal fixed timer and do all other stuff

Declaration
public virtual void Update()
In this article
Back to top Generated by DocFX