Table of Contents

Class ServerEntityManager

Namespace
LiteEntitySystem
Assembly
LiteEntitySystem.dll

Server entity manager

public sealed class ServerEntityManager : EntityManager
Inheritance
object
ServerEntityManager
Inherited Members

Constructors

ServerEntityManager(EntityTypesMap, byte, byte, ServerSendRate, MaxHistorySize)

Constructor

public ServerEntityManager(EntityTypesMap typesMap, byte packetHeader, byte framesPerSecond, ServerSendRate sendRate, MaxHistorySize maxHistorySize = MaxHistorySize.Size32)

Parameters

typesMap EntityTypesMap

EntityTypesMap with registered entity types

packetHeader byte

Header byte that will be used for packets (to distinguish entity system packets)

framesPerSecond byte

Fixed framerate of game logic

sendRate ServerSendRate

Send rate of server (depends on fps)

maxHistorySize MaxHistorySize

Maximum size of lag compensation history in ticks

Fields

MaxStoredInputs

public const int MaxStoredInputs = 30

Field Value

int

SafeEntityUpdate

Add try catch to entity updates

public bool SafeEntityUpdate

Field Value

bool

SendRate

Rate at which server will make and send packets

public readonly ServerSendRate SendRate

Field Value

ServerSendRate

Properties

PlayersCount

Network players count

public int PlayersCount { get; }

Property Value

int

Methods

AddAIController<T>(Action<T>)

Add new AI controller entity

public T AddAIController<T>(Action<T> initMethod = null) where T : AiControllerLogic

Parameters

initMethod Action<T>

Method that will be called after entity construction

Returns

T

Created entity or null in case of limit

Type Parameters

T

Entity type

AddController<T>(NetPlayer, PawnLogic, Action<T>)

Add new player controller entity and start controlling entityToControl

public T AddController<T>(NetPlayer owner, PawnLogic entityToControl, Action<T> initMethod = null) where T : HumanControllerLogic

Parameters

owner NetPlayer

Player that owns this controller

entityToControl PawnLogic

pawn that will be controlled

initMethod Action<T>

Method that will be called after entity construction

Returns

T

Created entity or null in case of limit

Type Parameters

T

Entity type

AddController<T>(NetPlayer, Action<T>)

Add new player controller entity

public T AddController<T>(NetPlayer owner, Action<T> initMethod = null) where T : HumanControllerLogic

Parameters

owner NetPlayer

Player that owns this controller

initMethod Action<T>

Method that will be called after entity construction

Returns

T

Created entity or null in case of limit

Type Parameters

T

Entity type

AddEntity<T>(EntityLogic, Action<T>)

Add new entity and set parent entity

public T AddEntity<T>(EntityLogic parent, Action<T> initMethod = null) where T : EntityLogic

Parameters

parent EntityLogic

Parent entity

initMethod Action<T>

Method that will be called after entity construction

Returns

T

Created entity or null in case of limit

Type Parameters

T

Entity type

AddEntity<T>(Action<T>)

Add new entity

public T AddEntity<T>(Action<T> initMethod = null) where T : EntityLogic

Parameters

initMethod Action<T>

Method that will be called after entity construction

Returns

T

Created entity or null in case of limit

Type Parameters

T

Entity type

AddPlayer(AbstractNetPeer)

Create and add new player

public NetPlayer AddPlayer(AbstractNetPeer peer)

Parameters

peer AbstractNetPeer

AbstractPeer to use

Returns

NetPlayer

Newly created player, null if players count is maximum

AddSingleton<T>(Action<T>)

Add new entity

public T AddSingleton<T>(Action<T> initMethod = null) where T : SingletonEntityLogic

Parameters

initMethod Action<T>

Method that will be called after entity construction

Returns

T

Created entity or null in case of limit

Type Parameters

T

Entity type

Deserialize(NetPlayer, ReadOnlySpan<byte>)

Read data from NetPlayer

public DeserializeResult Deserialize(NetPlayer player, ReadOnlySpan<byte> inData)

Parameters

player NetPlayer

Player that sent input

inData ReadOnlySpan<byte>

incoming data with header

Returns

DeserializeResult

Deserialize(AbstractNetPeer, ReadOnlySpan<byte>)

Read data for player linked to AbstractNetPeer

public DeserializeResult Deserialize(AbstractNetPeer peer, ReadOnlySpan<byte> inData)

Parameters

peer AbstractNetPeer

Player that sent input

inData ReadOnlySpan<byte>

incoming data with header

Returns

DeserializeResult

GetPlayer(byte)

Get player by owner id

public NetPlayer GetPlayer(byte ownerId)

Parameters

ownerId byte

id of player owner (Entity.OwnerId)

Returns

NetPlayer

GetPlayerController(NetPlayer)

Returns controller owned by the player

public HumanControllerLogic GetPlayerController(NetPlayer player)

Parameters

player NetPlayer

player to remove

Returns

HumanControllerLogic

Instance if found, null if not

GetPlayerController(AbstractNetPeer)

Returns controller owned by the player

public HumanControllerLogic GetPlayerController(AbstractNetPeer player)

Parameters

player AbstractNetPeer

player

Returns

HumanControllerLogic

Instance if found, null if not

GetPlayerController(byte)

Returns controller owned by the player

public HumanControllerLogic GetPlayerController(byte playerId)

Parameters

playerId byte

player

Returns

HumanControllerLogic

Instance if found, null if not

OnLogicTick()

protected override void OnLogicTick()

RemovePlayer(NetPlayer)

Remove player and it's owned entities

public bool RemovePlayer(NetPlayer player)

Parameters

player NetPlayer

player to remove

Returns

bool

true if player removed successfully, false if player not found

RemovePlayer(AbstractNetPeer)

Remove player using NetPeer.Tag (is you assigned it or used AddPlayer(AbstractNetPeer) with assignToTag)

public bool RemovePlayer(AbstractNetPeer player)

Parameters

player AbstractNetPeer

player to remove

Returns

bool

true if player removed successfully, false if player not found

Reset()

Remove all entities and reset all counters and timers

public override void Reset()

ToggleSyncGroup(NetPlayer, EntityLogic, SyncGroup, bool)

Change SyncVar and RPC synchronization by SyncGroup for player constructor and destruction will be synchronized anyways works only on server

public void ToggleSyncGroup(NetPlayer forPlayer, EntityLogic entity, SyncGroup syncGroup, bool enable)

Parameters

forPlayer NetPlayer

For which player

entity EntityLogic

entity

syncGroup SyncGroup

syncGroup to enable/disable

enable bool

true - enable sync (if was disabled), disable otherwise

ToggleSyncGroup(byte, EntityLogic, SyncGroup, bool)

Change SyncVar and RPC synchronization by SyncGroup for player constructor and destruction will be synchronized anyways works only on server

public void ToggleSyncGroup(byte forPlayer, EntityLogic entity, SyncGroup syncGroup, bool enable)

Parameters

forPlayer byte

For which player

entity EntityLogic

entity

syncGroup SyncGroup

syncGroup to enable/disable

enable bool

true - enable sync (if was disabled), disable otherwise