Class EntityManager
Base class for client and server manager
Inheritance
EntityManager
Assembly: LiteEntitySystem.dll
Syntax
public abstract class EntityManager
Constructors
Declaration
protected EntityManager(EntityTypesMap typesMap, InputProcessor inputProcessor, NetworkMode mode, byte framesPerSecond, byte headerByte)
Parameters
Fields
AliveEntities
Declaration
protected readonly EntityFilter<InternalEntity> AliveEntities
Field Value
DeltaTime
Declaration
public readonly double DeltaTime
Field Value
DeltaTimeF
Fixed delta time (float for less precision)
Declaration
public readonly float DeltaTimeF
Field Value
FirstEntityId
Declaration
protected const ushort FirstEntityId = 1
Field Value
FramesPerSecond
Declaration
public readonly int FramesPerSecond
Field Value
Declaration
public readonly byte HeaderByte
Field Value
Declaration
protected readonly InputProcessor InputProcessor
Field Value
InvalidEntityId
Declaration
public const ushort InvalidEntityId = 0
Field Value
IsClient
Declaration
public readonly bool IsClient
Field Value
IsServer
Declaration
public readonly bool IsServer
Field Value
LagCompensatedEntities
Declaration
protected readonly EntityFilter<EntityLogic> LagCompensatedEntities
Field Value
MaxEntityCount
Declaration
public const int MaxEntityCount = 16384
Field Value
MaxHistorySize
Size of history (in ticks) for lag compensation. Tune for your game fps
Declaration
public MaxHistorySize MaxHistorySize
Field Value
MaxLocalEntityId
Declaration
protected int MaxLocalEntityId
Field Value
MaxPlayers
Declaration
public const int MaxPlayers = 254
Field Value
MaxSavedStateDiff
Declaration
protected const int MaxSavedStateDiff = 30
Field Value
MaxSyncedEntityCount
Maximum synchronized (without LocalOnly) entities
Declaration
public const int MaxSyncedEntityCount = 8192
Field Value
MaxSyncedEntityId
Declaration
protected int MaxSyncedEntityId
Field Value
Mode
Current mode (Server or Client)
Declaration
public readonly NetworkMode Mode
Field Value
ServerPlayerId
Declaration
public const byte ServerPlayerId = 0
Field Value
SpeedMultiplier
Declaration
protected int SpeedMultiplier
Field Value
_tick
Declaration
Field Value
Properties
EntitiesCount
Total entities count (including local)
Declaration
public ushort EntitiesCount { get; }
Property Value
GameSpeedMultiplier
Declaration
public int GameSpeedMultiplier { get; }
Property Value
InNormalState
Declaration
public bool InNormalState { get; }
Property Value
InRollBackState
Declaration
public bool InRollBackState { get; }
Property Value
LerpFactor
Interpolation time between logic and render
Declaration
public float LerpFactor { get; }
Property Value
PlayerId
Local player id (0 on server)
Declaration
public byte PlayerId { get; }
Property Value
Tick
Declaration
public ushort Tick { get; }
Property Value
UpdateMode
Current update mode (can be used inside entities to separate logic for rollbacks)
Declaration
public UpdateMode UpdateMode { get; protected set; }
Property Value
VisualDeltaTime
Declaration
public double VisualDeltaTime { get; }
Property Value
Methods
AddEntity(EntityParams)
Declaration
protected InternalEntity AddEntity(EntityParams entityParams)
Parameters
Returns
AddLocalEntity<T>(Action<T>)
Add local entity that will be not synchronized
Declaration
public T AddLocalEntity<T>(Action<T> initMethod = null) where T : InternalEntity
Parameters
Type |
Name |
Description |
Action<T> |
initMethod |
|
Returns
Type |
Description |
T |
Created entity or null if entities limit is reached (65535 - MaxSyncedEntityCount)
|
Type Parameters
Name |
Description |
T |
Entity type
|
ConstructEntity(InternalEntity)
Declaration
protected void ConstructEntity(InternalEntity e)
Parameters
DisableLagCompensation()
Declaration
public void DisableLagCompensation()
EnableLagCompensation(NetPlayer)
Declaration
public void EnableLagCompensation(NetPlayer player)
Parameters
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)
Declaration
public T GetEntityById<T>(EntitySharedReference id) where T : InternalEntity
Parameters
Returns
Type |
Description |
T |
Entity if it exists, null if id == InvalidEntityId or entity is another type or version
|
Type Parameters
GetSingletonSafe<T>()
Declaration
public T GetSingletonSafe<T>() where T : SingletonEntityLogic
Returns
Type |
Description |
T |
Singleton entity or null if it didn't exists
|
Type Parameters
Name |
Description |
T |
Singleton entity type
|
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 Parameters
OnLogicTick()
Declaration
protected abstract void OnLogicTick()
RegisterFieldType<T>()
Declaration
public static void RegisterFieldType<T>() where T : unmanaged
Type Parameters
RegisterFieldType<T>(InterpolatorDelegateWithReturn<T>)
Declaration
public static void RegisterFieldType<T>(InterpolatorDelegateWithReturn<T> interpolationDelegate) where T : unmanaged
Parameters
Type Parameters
Reset()
Remove all entities and reset all counters and timers
Declaration
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
Returns
Type |
Description |
bool |
true if it exists, false if id == InvalidEntityId or entity is another type or version
|
Type Parameters
TryGetSingleton<T>(out T)
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()