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
typesMap
EntityTypesMapEntityTypesMap with registered entity types
packetHeader
byteHeader byte that will be used for packets (to distinguish entity system packets)
framesPerSecond
byteFixed framerate of game logic
sendRate
ServerSendRateSend rate of server (depends on fps)
maxHistorySize
MaxHistorySizeMaximum 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
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
NetPlayerPlayer that owns this controller
entityToControl
PawnLogicpawn 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
NetPlayerPlayer 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
EntityLogicParent 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
AbstractNetPeerAbstractPeer 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
NetPlayerPlayer that sent input
inData
ReadOnlySpan<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
peer
AbstractNetPeerPlayer that sent input
inData
ReadOnlySpan<byte>incoming data with header
Returns
GetPlayer(byte)
Get player by owner id
public NetPlayer GetPlayer(byte ownerId)
Parameters
ownerId
byteid of player owner (Entity.OwnerId)
Returns
GetPlayerController(NetPlayer)
Returns controller owned by the player
public HumanControllerLogic GetPlayerController(NetPlayer player)
Parameters
player
NetPlayerplayer 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
AbstractNetPeerplayer
Returns
- HumanControllerLogic
Instance if found, null if not
GetPlayerController(byte)
Returns controller owned by the player
public HumanControllerLogic GetPlayerController(byte playerId)
Parameters
playerId
byteplayer
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
NetPlayerplayer 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
AbstractNetPeerplayer 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
NetPlayerFor which player
entity
EntityLogicentity
syncGroup
SyncGroupsyncGroup to enable/disable
enable
booltrue - 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
byteFor which player
entity
EntityLogicentity
syncGroup
SyncGroupsyncGroup to enable/disable
enable
booltrue - enable sync (if was disabled), disable otherwise