GetPlayer() public static method

Gets a Player according to the entity pointer. Needed most of the time for internal engine calls, since the entity pointer is used a lot.
public static GetPlayer ( IntPtr entity ) : Player
entity System.IntPtr /// A pointer to the entity class ///
return Player
コード例 #1
0
        unsafe internal static void OnCommand(IntPtr entity)
        {
            MetaModEngine.SetResult(MetaResult.Handled);
            Player  player = Player.GetPlayer(entity);
            Command cmd    = CommandManager.CreateCommandFromGameEngine(CommandType.Player);

            switch (cmd.Arguments[0])
            {
            case "menuselect":
                player.SelectMenu(Convert.ToInt32(cmd.Arguments[1]) - 1);
                break;

            default:
                CommandManager.Execute(player, cmd);
                break;
            }

            clientCommandEventArgs = new CommandEventArgs(player, cmd);
            OnCommand(clientCommandEventArgs);
            player.OnPlayerCommand(clientCommandEventArgs);

            if (clientCommandEventArgs.Override)
            {
                MetaModEngine.SetResult(MetaResult.Supercede);
            }
            else
            {
                MetaModEngine.SetResult(MetaResult.Handled);
            }
        }
コード例 #2
0
        internal static void OnPutInServer(IntPtr entity)
        {
            Player player             = Player.GetPlayer(entity);
            PutInServerEventArgs args = new PutInServerEventArgs(player);

            OnPutInServer(args);
            player.OnPlayerPutInServer(args);
        }
コード例 #3
0
        internal static void OnDisconnect(IntPtr entity)
        {
            MetaModEngine.SetResult(MetaResult.Handled);
            Player player            = Player.GetPlayer(entity);
            DisconnectEventArgs args = new DisconnectEventArgs(player);

            OnDisconnect(args);
            player.OnPlayerClientDisconnect(args);
            player.Release();
        }
コード例 #4
0
        internal static bool OnConnect(IntPtr entity, string name, string address, string reject_reason)
        {
            Player player = Player.GetPlayer(entity);

            player.Name = name;
            string[] addressinformation = address.Split(':');
            player.IPAddress = IPAddress.Parse(addressinformation[0]);
            player.Port      = Convert.ToInt32(addressinformation[1]);

            if (player.PendingAuth)
            {
                pendingAuthPlayers.Add(player);
            }
            else
            {
                Player.OnAuthorize(player);
            }

            ConnectEventArgs connectEventArgs = new ConnectEventArgs(player, reject_reason);

            OnConnect(connectEventArgs);
            player.OnPlayerConnect(connectEventArgs);
            return(true);
        }