Server.Network.PacketHandlers.TextCommand C# (CSharp) Méthode

TextCommand() public static méthode

public static TextCommand ( NetState state, PacketReader pvSrc ) : void
state NetState
pvSrc PacketReader
Résultat void
        public static void TextCommand( NetState state, PacketReader pvSrc )
        {
            int type = pvSrc.ReadByte();
            string command = pvSrc.ReadString();

            Mobile m = state.Mobile;

            switch ( type )
            {
                case 0x00: // Go
                {
                    if ( VerifyGC( state ) )
                    {
                        try
                        {
                            string[] split = command.Split( ' ' );

                            int x = Utility.ToInt32( split[0] );
                            int y = Utility.ToInt32( split[1] );

                            int z;

                            if ( split.Length >= 3 )
                                z = Utility.ToInt32( split[2] );
                            else if ( m.Map != null )
                                z = m.Map.GetAverageZ( x, y );
                            else
                                z = 0;

                            m.Location = new Point3D( x, y, z );
                        }
                        catch
                        {
                        }
                    }

                    break;
                }
                case 0xC7: // Animate
                {
                    EventSink.InvokeAnimateRequest( new AnimateRequestEventArgs( m, command ) );

                    break;
                }
                case 0x24: // Use skill
                {
                    int skillIndex;

                    if ( !int.TryParse( command.Split( ' ' )[0], out skillIndex ) )
                        break;

                    Skills.UseSkill( m, skillIndex );

                    break;
                }
                case 0x43: // Open spellbook
                {
                    int booktype;

                    if ( !int.TryParse( command, out booktype ) )
                        booktype = 1;

                    EventSink.InvokeOpenSpellbookRequest( new OpenSpellbookRequestEventArgs( m, booktype ) );

                    break;
                }
                case 0x27: // Cast spell from book
                {
                    string[] split = command.Split( ' ' );

                    if ( split.Length > 0 )
                    {
                        int spellID = Utility.ToInt32( split[0] ) - 1;
                        int serial = split.Length > 1 ? Utility.ToInt32( split[1] ) : -1;

                        EventSink.InvokeCastSpellRequest( new CastSpellRequestEventArgs( m, spellID, World.FindItem( serial ) ) );
                    }

                    break;
                }
                case 0x58: // Open door
                {
                    EventSink.InvokeOpenDoorMacroUsed( new OpenDoorMacroEventArgs( m ) );

                    break;
                }
                case 0x56: // Cast spell from macro
                {
                    int spellID = Utility.ToInt32( command ) - 1;

                    EventSink.InvokeCastSpellRequest( new CastSpellRequestEventArgs( m, spellID, null ) );

                    break;
                }
                case 0xF4: // Invoke virtues from macro
                {
                    int virtueID = Utility.ToInt32( command ) - 1;

                    EventSink.InvokeVirtueMacroRequest( new VirtueMacroRequestEventArgs( m, virtueID ) );

                    break;
                }
                case 0x2F: // Old scroll double click
                {
                    /*
                     * This command is still sent for items 0xEF3 - 0xEF9
                     *
                     * Command is one of three, depending on the item ID of the scroll:
                     * - [scroll serial]
                     * - [scroll serial] [target serial]
                     * - [scroll serial] [x] [y] [z]
                     */
                    break;
                }
                default:
                {
                    Console.WriteLine( "Client: {0}: Unknown text-command type 0x{1:X2}: {2}", state, type, command );
                    break;
                }
            }
        }
PacketHandlers