in UnityProject/Assets/Scripts/Server/Server.cs [251:297]
void FixedUpdate()
{
// Don't run before Network server is created
if (this.server == null)
return;
// Update the Network server to check client status and get messages
server.Update();
// Process any messages we received
this.ProcessMessages();
// Move players based on latest input and update player states to clients
for (int i = 0; i < this.players.Count; i++)
{
var player = this.players[i];
// Move
player.Move();
// Send state if changed
var positionMessage = player.GetPositionMessage();
if (positionMessage != null)
{
positionMessage.clientId = player.GetPlayerId();
this.server.TransmitMessage(positionMessage, player.GetPlayerId());
//Send to the player him/herself
positionMessage.messageType = MessageType.PositionOwn;
this.server.SendMessage(player.GetPlayerId(), positionMessage);
}
}
// Update the server state to FleetIQ every 60. This will also get done when new clients connect
this.fleetIqUpdateCounter += Time.fixedDeltaTime;
if(this.fleetIqUpdateCounter > Server.fleetIqUpdateInterval && this.taskDataArnWithContainer != null)
{
this.UpdateFleetIQ();
this.fleetIqUpdateCounter = 0.0f;
}
// If a new player joined, update FleetIQ as well
if(this.server.GetPlayerCount() > this.lastPlayerCount)
{
Debug.Log("New player joined, update FleetIQ");
this.UpdateFleetIQ();
this.lastPlayerCount = this.server.GetPlayerCount();
}
}