Example #1
0
        public override void ProcessPacket(TrashSystemNewTrashCreatedPacket packet, NebulaConnection conn)
        {
            bool valid = true;

            if (IsHost)
            {
                Player player = playerManager.GetPlayer(conn);
                if (player != null)
                {
                    playerManager.SendPacketToOtherPlayers(packet, player);
                }
                else
                {
                    valid = false;
                }
            }

            if (valid)
            {
                int myId = SimulatedWorld.GenerateTrashOnPlayer(packet);

                //Check if myID is same as the ID from the host
                if (myId != packet.TrashId)
                {
                    TrashManager.SwitchTrashWithIds(myId, packet.TrashId);
                }
            }
        }
Example #2
0
        public void ProcessPacket(TrashSystemNewTrashCreatedPacket packet, NebulaConnection conn)
        {
            int myId = SimulatedWorld.GenerateTrashOnPlayer(packet);

            //Check if myID is same as the ID from the host
            if (myId != packet.TrashId)
            {
                TrashManager.SwitchTrashWithIds(myId, packet.TrashId);
            }
        }
        public void ProcessPacket(TrashSystemNewTrashCreatedPacket packet, NebulaConnection conn)
        {
            Player player = playerManager.GetPlayer(conn);

            if (player != null)
            {
                int myId = SimulatedWorld.GenerateTrashOnPlayer(packet);

                //Send to other players trash with valid ID
                playerManager.SendPacketToOtherPlayers(packet, player);

                //Send correction packet to the creator with authotaritive ID if the ID does not match
                if (myId != packet.TrashId)
                {
                    player.SendPacket(new TrashSystemCorrectionIdPacket(packet.TrashId, myId));
                }
            }
        }