Class ServerEntityManager (original) (raw)
Namespace
Assembly
LiteEntitySystem.dll
Server entity manager
public sealed class ServerEntityManager : EntityManagerInheritance
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 = 30Field Value
SafeEntityUpdate
Add try catch to entity updates
public bool SafeEntityUpdateField Value
SendRate
Rate at which server will make and send packets
public readonly ServerSendRate SendRateField Value
Properties
PlayersCount
Network players count
public int PlayersCount { get; }Property Value
Methods
AddAIController(Action)
Add new AI controller entity
public T AddAIController<T>(Action<T> initMethod = null) where T : AiControllerLogicParameters
initMethod Action
Method that will be called after entity construction
Returns
T
Created entity or null in case of limit
Type Parameters
T
Entity type
AddController(NetPlayer, PawnLogic, Action)
Add new player controller entity and start controlling entityToControl
public T AddController<T>(NetPlayer owner, PawnLogic entityToControl, Action<T> initMethod = null) where T : HumanControllerLogicParameters
owner NetPlayer
Player that owns this controller
entityToControl PawnLogic
pawn that will be controlled
initMethod Action
Method that will be called after entity construction
Returns
T
Created entity or null in case of limit
Type Parameters
T
Entity type
AddController(NetPlayer, Action)
Add new player controller entity
public T AddController<T>(NetPlayer owner, Action<T> initMethod = null) where T : HumanControllerLogicParameters
owner NetPlayer
Player that owns this controller
initMethod Action
Method that will be called after entity construction
Returns
T
Created entity or null in case of limit
Type Parameters
T
Entity type
AddEntity(EntityLogic, Action)
Add new entity and set parent entity
public T AddEntity<T>(EntityLogic parent, Action<T> initMethod = null) where T : EntityLogicParameters
parent EntityLogic
Parent entity
initMethod Action
Method that will be called after entity construction
Returns
T
Created entity or null in case of limit
Type Parameters
T
Entity type
AddEntity(Action)
Add new entity
public T AddEntity<T>(Action<T> initMethod = null) where T : EntityLogicParameters
initMethod Action
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
Newly created player, null if players count is maximum
AddSingleton(Action)
Add new entity
public T AddSingleton<T>(Action<T> initMethod = null) where T : SingletonEntityLogicParameters
initMethod Action
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)
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
Deserialize(AbstractNetPeer, ReadOnlySpan)
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
GetCurrentFrameDebugInfo(DebugFrameModes)
Get information about current update frame
public override string GetCurrentFrameDebugInfo(DebugFrameModes modes)Parameters
modes DebugFrameModes
Returns
debug formatted string
GetPlayer(byte)
Get player by owner id
public NetPlayer GetPlayer(byte ownerId)Parameters
ownerId byte
id of player owner (Entity.OwnerId)
Returns
GetPlayerController(NetPlayer)
Returns controller owned by the player
public HumanControllerLogic GetPlayerController(NetPlayer player)Parameters
player NetPlayer
player to remove
Returns
Instance if found, null if not
GetPlayerController(AbstractNetPeer)
Returns controller owned by the player
public HumanControllerLogic GetPlayerController(AbstractNetPeer player)Parameters
player AbstractNetPeer
player
Returns
Instance if found, null if not
GetPlayerController(byte)
Returns controller owned by the player
public HumanControllerLogic GetPlayerController(byte playerId)Parameters
playerId byte
player
Returns
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
true if player removed successfully, false if player not found
RemovePlayer(AbstractNetPeer)
public bool RemovePlayer(AbstractNetPeer player)Parameters
player AbstractNetPeer
player to remove
Returns
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