public static void AddCurrentLocalGameLoopState(ref GameLoopMessage toGameloop, bool deletePreviousInstance = false) { if (deletePreviousInstance) { toGameloop = new GameLoopMessage(); } toGameloop = toGameloop == null || toGameloop.playerInfos == null || toGameloop.playerInfos.Length != config.playerCount ? new GameLoopMessage { playerInfos = new GameLoopMessage.PlayerInfo[config.playerCount] } : toGameloop; foreach (var player in PlayerConfigurationManager.Instance.Players) { if (player.config.NetworkPlayerIndex < 0 || player.config.NetworkPlayerIndex >= config.playerCount) { Client_RegisterPlayer(player); } toGameloop.playerInfos[player.config.NetworkPlayerIndex] = new GameLoopMessage.PlayerInfo { position = player.transform.position, rotation = player.transform.rotation, ammunitionReserve = player.playerStats.ammunitionLeft, animationState = (int)player.currentStatus }; } }
public static void Server_AddClientMessageToLoop(GameLoopMessage clientMessage) { currentServerGameLoop = currentServerGameLoop == null ? currentServerGameLoop : new GameLoopMessage(); for (int i = 0; i < clientMessage.playerInfos.Length; i++) { if (clientMessage.playerInfos[i] == null) { continue; } currentServerGameLoop.playerInfos[i] = clientMessage.playerInfos[i]; } }