Пример #1
0
        public void PlayerDisconnected(NebulaConnection conn)
        {
            if (connectedPlayers.TryGetValue(conn, out Player player))
            {
                SendPacketToOtherPlayers(new PlayerDisconnected(player.Id), player);
                connectedPlayers.Remove(conn);
                availablePlayerIds.Enqueue(player.Id);
                SimulatedWorld.DestroyRemotePlayerModel(player.Id);
            }

            // TODO: Should probably also handle playing that disconnect during "pending" or "syncing" steps.
        }
Пример #2
0
        public void PlayerDisconnected(NebulaConnection conn)
        {
            if (connectedPlayers.TryGetValue(conn, out Player player))
            {
                SendPacketToOtherPlayers(new PlayerDisconnected(player.Id), player);
                SimulatedWorld.DestroyRemotePlayerModel(player.Id);
                connectedPlayers.Remove(conn);
                availablePlayerIds.Enqueue(player.Id);
                StatisticsManager.instance.UnRegisterPlayer(player.Id);
            }
            else
            {
                Log.Warn($"PlayerDisconnected NOT CALLED!");
            }

            // TODO: Should probably also handle playing that disconnect during "pending" or "syncing" steps.
        }
Пример #3
0
        public void PlayerDisconnected(NebulaConnection conn)
        {
            using (GetConnectedPlayers(out var connectedPlayers))
            {
                if (connectedPlayers.TryGetValue(conn, out Player player))
                {
                    SendPacketToOtherPlayers(new PlayerDisconnected(player.Id), player);
                    SimulatedWorld.DestroyRemotePlayerModel(player.Id);
                    connectedPlayers.Remove(conn);
                    using (threadSafe.availablePlayerIds.GetLocked(out var availablePlayerIds))
                    {
                        availablePlayerIds.Enqueue(player.Id);
                    }
                    StatisticsManager.instance.UnRegisterPlayer(player.Id);

                    //Notify players about queued building plans for drones
                    int[] DronePlans = DroneManager.GetPlayerDronePlans(player.Id);
                    if (DronePlans != null && DronePlans.Length > 0 && player.Data.LocalPlanetId > 0)
                    {
                        LocalPlayer.SendPacketToPlanet(new RemoveDroneOrdersPacket(DronePlans), player.Data.LocalPlanetId);
                        //Remove it also from host queue, if host is on the same planet
                        if (GameMain.mainPlayer.planetId == player.Data.LocalPlanetId)
                        {
                            for (int i = 0; i < DronePlans.Length; i++)
                            {
                                GameMain.mainPlayer.mecha.droneLogic.serving.Remove(DronePlans[i]);
                            }
                        }
                    }
                }
                else
                {
                    Log.Warn($"PlayerDisconnected NOT CALLED!");
                }

                // TODO: Should probably also handle playing that disconnect during "pending" or "syncing" steps.
            }
        }
Пример #4
0
 public void ProcessPacket(PlayerDisconnected packet, NebulaConnection conn)
 {
     SimulatedWorld.DestroyRemotePlayerModel(packet.PlayerId);
 }