public void Run(ManagerLogger managerLogger, Server server, NetIncomingMessage inc,
                        PlayerAndConnection playerAndConnection, List <PlayerAndConnection> players, List <AbilityOutline> abilities)
        {
            //managerLogger.AddLogMessage("Server", "Recieved new input");
            var name = inc.ReadString();

            playerAndConnection = players.FirstOrDefault(p => p.Player.Username == name);
            if (playerAndConnection == null)
            {
                managerLogger.AddLogMessage("Server", string.Format("Didn't find player with name {0}", name));
                return;
            }
            playerAndConnection.Player.XPosition         = inc.ReadInt16();
            playerAndConnection.Player.YPosition         = inc.ReadInt16();
            playerAndConnection.Player.Animation.XRecPos = inc.ReadInt16();
            playerAndConnection.Player.Animation.YRecPos = inc.ReadInt16();
            playerAndConnection.Player.Animation.Height  = inc.ReadInt16();
            playerAndConnection.Player.Animation.Width   = inc.ReadInt16();
            playerAndConnection.Player.Health            = inc.ReadSByte();
            playerAndConnection.Player.IntersectingLava  = inc.ReadBoolean();
            playerAndConnection.Player.OrbiterRotation   = inc.ReadDouble();



            var command = new PlayerPositionCommand();

            command.Run(managerLogger, server, inc, playerAndConnection, players, abilities);
        }
예제 #2
0
        private void UserDisconnected(NetIncomingMessage inc)
        {
            NetConnectionStatus status = inc.SenderConnection.Status;

            switch (status)
            {
            case NetConnectionStatus.Disconnecting:
                managerLogger.AddLogMessage("Disconnecting", "Player is disconnecting");
                break;

            case NetConnectionStatus.Disconnected:
                managerLogger.AddLogMessage("Disconnection", "Removing player");
                NetConnection       playerConnection    = inc.SenderConnection;
                PlayerAndConnection playerAndConnection = players.Find(p => p.Connection == playerConnection);

                var outmsg = NetServer.CreateMessage();
                outmsg.Write((byte)PacketType.Kick);
                outmsg.Write(playerAndConnection.Player.Username);
                NetServer.SendToAll(outmsg, NetDeliveryMethod.ReliableOrdered);

                players.Remove(playerAndConnection);
                break;
            }
        }