Class ServerEntityManager
- Namespace
- LiteEntitySystem
- Assembly
- LiteEntitySystem.dll
Server entity manager
public sealed class ServerEntityManager : EntityManager
- Inheritance
-
objectServerEntityManager
- 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
typesMapEntityTypesMapEntityTypesMap with registered entity types
packetHeaderbyteHeader byte that will be used for packets (to distinguish entity system packets)
framesPerSecondbyteFixed framerate of game logic
sendRateServerSendRateSend rate of server (depends on fps)
maxHistorySizeMaxHistorySizeMaximum size of lag compensation history in ticks
Fields
MaxStoredInputs
public const int MaxStoredInputs = 30
Field Value
SafeEntityUpdate
Add try catch to entity updates
public bool SafeEntityUpdate
Field Value
SendRate
Rate at which server will make and send packets
public readonly ServerSendRate SendRate
Field Value
Properties
PlayersCount
Network players count
public int PlayersCount { get; }
Property Value
Methods
AddAIController<T>(Action<T>)
Add new AI controller entity
public T AddAIController<T>(Action<T> initMethod = null) where T : AiControllerLogic
Parameters
initMethodAction<T>Method that will be called after entity construction
Returns
- T
Created entity or null in case of limit
Type Parameters
TEntity 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
ownerNetPlayerPlayer that owns this controller
entityToControlPawnLogicpawn that will be controlled
initMethodAction<T>Method that will be called after entity construction
Returns
- T
Created entity or null in case of limit
Type Parameters
TEntity 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
ownerNetPlayerPlayer that owns this controller
initMethodAction<T>Method that will be called after entity construction
Returns
- T
Created entity or null in case of limit
Type Parameters
TEntity 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
parentEntityLogicParent entity
initMethodAction<T>Method that will be called after entity construction
Returns
- T
Created entity or null in case of limit
Type Parameters
TEntity type
AddEntity<T>(Action<T>)
Add new entity
public T AddEntity<T>(Action<T> initMethod = null) where T : EntityLogic
Parameters
initMethodAction<T>Method that will be called after entity construction
Returns
- T
Created entity or null in case of limit
Type Parameters
TEntity type
AddPlayer(AbstractNetPeer)
Create and add new player
public NetPlayer AddPlayer(AbstractNetPeer peer)
Parameters
peerAbstractNetPeerAbstractPeer 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
initMethodAction<T>Method that will be called after entity construction
Returns
- T
Created entity or null in case of limit
Type Parameters
TEntity type
Deserialize(NetPlayer, ReadOnlySpan<byte>)
Read data from NetPlayer
public DeserializeResult Deserialize(NetPlayer player, ReadOnlySpan<byte> inData)
Parameters
playerNetPlayerPlayer that sent input
inDataReadOnlySpan<byte>incoming data with header
Returns
Deserialize(AbstractNetPeer, ReadOnlySpan<byte>)
Read data for player linked to AbstractNetPeer
public DeserializeResult Deserialize(AbstractNetPeer peer, ReadOnlySpan<byte> inData)
Parameters
peerAbstractNetPeerPlayer that sent input
inDataReadOnlySpan<byte>incoming data with header
Returns
GetCurrentFrameDebugInfo(DebugFrameModes)
Get information about current update frame
public override string GetCurrentFrameDebugInfo(DebugFrameModes modes)
Parameters
modesDebugFrameModes
Returns
- string
debug formatted string
GetPlayer(byte)
Get player by owner id
public NetPlayer GetPlayer(byte ownerId)
Parameters
ownerIdbyteid of player owner (Entity.OwnerId)
Returns
GetPlayerController(NetPlayer)
Returns controller owned by the player
public HumanControllerLogic GetPlayerController(NetPlayer player)
Parameters
playerNetPlayerplayer to remove
Returns
- HumanControllerLogic
Instance if found, null if not
GetPlayerController(AbstractNetPeer)
Returns controller owned by the player
public HumanControllerLogic GetPlayerController(AbstractNetPeer player)
Parameters
playerAbstractNetPeerplayer
Returns
- HumanControllerLogic
Instance if found, null if not
GetPlayerController(byte)
Returns controller owned by the player
public HumanControllerLogic GetPlayerController(byte playerId)
Parameters
playerIdbyteplayer
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
playerNetPlayerplayer 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
playerAbstractNetPeerplayer 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
forPlayerNetPlayerFor which player
entityEntityLogicentity
syncGroupSyncGroupsyncGroup to enable/disable
enablebooltrue - 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
forPlayerbyteFor which player
entityEntityLogicentity
syncGroupSyncGroupsyncGroup to enable/disable
enablebooltrue - enable sync (if was disabled), disable otherwise