Class ServerEntityManager
Server entity manager
Inherited Members
Namespace: LiteEntitySystem
Assembly: LiteEntitySystem.dll
Syntax
public sealed class ServerEntityManager : EntityManager
Constructors
ServerEntityManager(EntityTypesMap, byte, byte, ServerSendRate, MaxHistorySize)
Constructor
Declaration
public ServerEntityManager(EntityTypesMap typesMap, byte packetHeader, byte framesPerSecond, ServerSendRate sendRate, MaxHistorySize maxHistorySize = MaxHistorySize.Size32)
Parameters
Type | Name | Description |
---|---|---|
EntityTypesMap | typesMap | EntityTypesMap with registered entity types |
byte | packetHeader | Header byte that will be used for packets (to distinguish entity system packets) |
byte | framesPerSecond | Fixed framerate of game logic |
ServerSendRate | sendRate | Send rate of server (depends on fps) |
MaxHistorySize | maxHistorySize | Maximum size of lag compensation history in ticks |
Fields
MaxStoredInputs
Declaration
public const int MaxStoredInputs = 30
Field Value
Type | Description |
---|---|
int |
SafeEntityUpdate
Add try catch to entity updates
Declaration
public bool SafeEntityUpdate
Field Value
Type | Description |
---|---|
bool |
SendRate
Rate at which server will make and send packets
Declaration
public readonly ServerSendRate SendRate
Field Value
Type | Description |
---|---|
ServerSendRate |
Properties
PlayersCount
Network players count
Declaration
public int PlayersCount { get; }
Property Value
Type | Description |
---|---|
int |
Methods
AddAIController<T>(Action<T>)
Add new AI controller entity
Declaration
public T AddAIController<T>(Action<T> initMethod = null) where T : AiControllerLogic
Parameters
Type | Name | Description |
---|---|---|
Action<T> | initMethod | Method that will be called after entity construction |
Returns
Type | Description |
---|---|
T | Created entity or null in case of limit |
Type Parameters
Name | Description |
---|---|
T | Entity type |
AddController<T>(NetPlayer, PawnLogic, Action<T>)
Add new player controller entity and start controlling entityToControl
Declaration
public T AddController<T>(NetPlayer owner, PawnLogic entityToControl, Action<T> initMethod = null) where T : HumanControllerLogic
Parameters
Type | Name | Description |
---|---|---|
NetPlayer | owner | Player that owns this controller |
PawnLogic | entityToControl | pawn that will be controlled |
Action<T> | initMethod | Method that will be called after entity construction |
Returns
Type | Description |
---|---|
T | Created entity or null in case of limit |
Type Parameters
Name | Description |
---|---|
T | Entity type |
AddController<T>(NetPlayer, Action<T>)
Add new player controller entity
Declaration
public T AddController<T>(NetPlayer owner, Action<T> initMethod = null) where T : HumanControllerLogic
Parameters
Type | Name | Description |
---|---|---|
NetPlayer | owner | Player that owns this controller |
Action<T> | initMethod | Method that will be called after entity construction |
Returns
Type | Description |
---|---|
T | Created entity or null in case of limit |
Type Parameters
Name | Description |
---|---|
T | Entity type |
AddEntity<T>(EntityLogic, Action<T>)
Add new entity and set parent entity
Declaration
public T AddEntity<T>(EntityLogic parent, Action<T> initMethod = null) where T : EntityLogic
Parameters
Type | Name | Description |
---|---|---|
EntityLogic | parent | Parent entity |
Action<T> | initMethod | Method that will be called after entity construction |
Returns
Type | Description |
---|---|
T | Created entity or null in case of limit |
Type Parameters
Name | Description |
---|---|
T | Entity type |
AddEntity<T>(Action<T>)
Add new entity
Declaration
public T AddEntity<T>(Action<T> initMethod = null) where T : EntityLogic
Parameters
Type | Name | Description |
---|---|---|
Action<T> | initMethod | Method that will be called after entity construction |
Returns
Type | Description |
---|---|
T | Created entity or null in case of limit |
Type Parameters
Name | Description |
---|---|
T | Entity type |
AddPlayer(AbstractNetPeer)
Create and add new player
Declaration
public NetPlayer AddPlayer(AbstractNetPeer peer)
Parameters
Type | Name | Description |
---|---|---|
AbstractNetPeer | peer | AbstractPeer to use |
Returns
Type | Description |
---|---|
NetPlayer | Newly created player, null if players count is maximum |
AddSingleton<T>(Action<T>)
Add new entity
Declaration
public T AddSingleton<T>(Action<T> initMethod = null) where T : SingletonEntityLogic
Parameters
Type | Name | Description |
---|---|---|
Action<T> | initMethod | Method that will be called after entity construction |
Returns
Type | Description |
---|---|
T | Created entity or null in case of limit |
Type Parameters
Name | Description |
---|---|
T | Entity type |
Deserialize(NetPlayer, ReadOnlySpan<byte>)
Read data from NetPlayer
Declaration
public DeserializeResult Deserialize(NetPlayer player, ReadOnlySpan<byte> inData)
Parameters
Type | Name | Description |
---|---|---|
NetPlayer | player | Player that sent input |
ReadOnlySpan<byte> | inData | incoming data with header |
Returns
Type | Description |
---|---|
DeserializeResult |
Deserialize(AbstractNetPeer, ReadOnlySpan<byte>)
Read data for player linked to AbstractNetPeer
Declaration
public DeserializeResult Deserialize(AbstractNetPeer peer, ReadOnlySpan<byte> inData)
Parameters
Type | Name | Description |
---|---|---|
AbstractNetPeer | peer | Player that sent input |
ReadOnlySpan<byte> | inData | incoming data with header |
Returns
Type | Description |
---|---|
DeserializeResult |
GetPlayer(byte)
Get player by owner id
Declaration
public NetPlayer GetPlayer(byte ownerId)
Parameters
Type | Name | Description |
---|---|---|
byte | ownerId | id of player owner (Entity.OwnerId) |
Returns
Type | Description |
---|---|
NetPlayer |
GetPlayerController(NetPlayer)
Returns controller owned by the player
Declaration
public HumanControllerLogic GetPlayerController(NetPlayer player)
Parameters
Type | Name | Description |
---|---|---|
NetPlayer | player | player to remove |
Returns
Type | Description |
---|---|
HumanControllerLogic | Instance if found, null if not |
GetPlayerController(AbstractNetPeer)
Returns controller owned by the player
Declaration
public HumanControllerLogic GetPlayerController(AbstractNetPeer player)
Parameters
Type | Name | Description |
---|---|---|
AbstractNetPeer | player | player |
Returns
Type | Description |
---|---|
HumanControllerLogic | Instance if found, null if not |
GetPlayerController(byte)
Returns controller owned by the player
Declaration
public HumanControllerLogic GetPlayerController(byte playerId)
Parameters
Type | Name | Description |
---|---|---|
byte | playerId | player |
Returns
Type | Description |
---|---|
HumanControllerLogic | Instance if found, null if not |
OnLogicTick()
Declaration
protected override void OnLogicTick()
Overrides
RemovePlayer(NetPlayer)
Remove player and it's owned entities
Declaration
public bool RemovePlayer(NetPlayer player)
Parameters
Type | Name | Description |
---|---|---|
NetPlayer | player | player to remove |
Returns
Type | Description |
---|---|
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)
Declaration
public bool RemovePlayer(AbstractNetPeer player)
Parameters
Type | Name | Description |
---|---|---|
AbstractNetPeer | player | player to remove |
Returns
Type | Description |
---|---|
bool | true if player removed successfully, false if player not found |
Reset()
Remove all entities and reset all counters and timers
Declaration
public override void Reset()
Overrides
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
Declaration
public void ToggleSyncGroup(NetPlayer forPlayer, EntityLogic entity, SyncGroup syncGroup, bool enable)
Parameters
Type | Name | Description |
---|---|---|
NetPlayer | forPlayer | For which player |
EntityLogic | entity | entity |
SyncGroup | syncGroup | syncGroup to enable/disable |
bool | enable | 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
Declaration
public void ToggleSyncGroup(byte forPlayer, EntityLogic entity, SyncGroup syncGroup, bool enable)
Parameters
Type | Name | Description |
---|---|---|
byte | forPlayer | For which player |
EntityLogic | entity | entity |
SyncGroup | syncGroup | syncGroup to enable/disable |
bool | enable | true - enable sync (if was disabled), disable otherwise |