Exemplo n.º 1
0
        private static void Go_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            if (e.Length == 0)
            {
                GoGump.DisplayTo(from);
                return;
            }

            if (e.Length == 1)
            {
                try
                {
                    int ser = e.GetInt32(0);

                    IEntity ent = World.FindEntity(ser);

                    if (ent is Item)
                    {
                        Item item = (Item)ent;

                        Map     map = item.Map;
                        Point3D loc = item.GetWorldLocation();

                        Mobile owner = item.RootParent as Mobile;

                        if (owner != null && (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible(from, owner) /* !from.CanSee( owner )*/)
                        {
                            from.SendMessage("You can not go to what you can not see.");
                            return;
                        }
                        else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= from.AccessLevel)
                        {
                            from.SendMessage("You can not go to what you can not see.");
                            return;
                        }
                        else if (!FixMap(ref map, ref loc, item))
                        {
                            from.SendMessage("That is an internal item and you cannot go to it.");
                            return;
                        }

                        from.MoveToWorld(loc, map);

                        return;
                    }
                    else if (ent is Mobile)
                    {
                        Mobile m = (Mobile)ent;

                        Map     map = m.Map;
                        Point3D loc = m.Location;

                        Mobile owner = m;

                        if (owner != null && (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible(from, owner) /* !from.CanSee( owner )*/)
                        {
                            from.SendMessage("You can not go to what you can not see.");
                            return;
                        }
                        else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= from.AccessLevel)
                        {
                            from.SendMessage("You can not go to what you can not see.");
                            return;
                        }
                        else if (!FixMap(ref map, ref loc, m))
                        {
                            from.SendMessage("That is an internal mobile and you cannot go to it.");
                            return;
                        }

                        from.MoveToWorld(loc, map);

                        return;
                    }
                    else
                    {
                        string name = e.GetString(0);
                        Map    map;

                        for (int i = 0; i < Map.AllMaps.Count; ++i)
                        {
                            map = Map.AllMaps[i];

                            if (map.MapIndex == 0x7F || map.MapIndex == 0xFF)
                            {
                                continue;
                            }

                            if (Insensitive.Equals(name, map.Name))
                            {
                                from.Map = map;
                                return;
                            }
                        }

                        Dictionary <string, Region> list = from.Map.Regions;

                        foreach (KeyValuePair <string, Region> kvp in list)
                        {
                            Region r = kvp.Value;

                            if (Insensitive.Equals(r.Name, name))
                            {
                                from.Location = new Point3D(r.GoLocation);
                                return;
                            }
                        }

                        for (int i = 0; i < Map.AllMaps.Count; ++i)
                        {
                            Map m = Map.AllMaps[i];

                            if (m.MapIndex == 0x7F || m.MapIndex == 0xFF || from.Map == m)
                            {
                                continue;
                            }

                            foreach (Region r in m.Regions.Values)
                            {
                                if (Insensitive.Equals(r.Name, name))
                                {
                                    from.MoveToWorld(r.GoLocation, m);
                                    return;
                                }
                            }
                        }

                        if (ser != 0)
                        {
                            from.SendMessage("No object with that serial was found.");
                        }
                        else
                        {
                            from.SendMessage("No region with that name was found.");
                        }

                        return;
                    }
                }
                catch
                {
                }

                from.SendMessage("Region name not found");
            }
            else if (e.Length == 2 || e.Length == 3)
            {
                Map map = from.Map;

                if (map != null)
                {
                    try
                    {
                        /*
                         * This to avoid being teleported to (0,0) if trying to teleport
                         * to a region with spaces in its name.
                         */
                        int x = int.Parse(e.GetString(0));
                        int y = int.Parse(e.GetString(1));
                        int z = (e.Length == 3) ? int.Parse(e.GetString(2)) : map.GetAverageZ(x, y);

                        from.Location = new Point3D(x, y, z);
                    }
                    catch
                    {
                        from.SendMessage("Region name not found.");
                    }
                }
            }
            else if (e.Length == 6)
            {
                Map map = from.Map;

                if (map != null)
                {
                    Point3D p = Sextant.ReverseLookup(map, e.GetInt32(3), e.GetInt32(0), e.GetInt32(4), e.GetInt32(1), Insensitive.Equals(e.GetString(5), "E"), Insensitive.Equals(e.GetString(2), "S"));

                    if (p != Point3D.Zero)
                    {
                        from.Location = p;
                    }
                    else
                    {
                        from.SendMessage("Sextant reverse lookup failed.");
                    }
                }
            }
            else
            {
                from.SendMessage("Format: Go [name | serial | (x y [z]) | (deg min (N | S) deg min (E | W)]");
            }
        }
Exemplo n.º 2
0
        public override void ExecuteList(CommandEventArgs e, ArrayList list)
        {
            if (list.Count == 0)
            {
                LogFailure("Nothing was found to use this command on.");
                return;
            }

            try
            {
                BaseCommand[]      commands  = new BaseCommand[m_BatchCommands.Count];
                CommandEventArgs[] eventArgs = new CommandEventArgs[m_BatchCommands.Count];

                for (int i = 0; i < m_BatchCommands.Count; ++i)
                {
                    BatchCommand bc = (BatchCommand)m_BatchCommands[i];

                    string   commandString, argString;
                    string[] args;

                    bc.GetDetails(out commandString, out argString, out args);

                    BaseCommand command = m_Scope.Commands[commandString];

                    commands[i]  = command;
                    eventArgs[i] = new CommandEventArgs(e.Mobile, commandString, argString, args);

                    if (command == null)
                    {
                        e.Mobile.SendMessage("That is either an invalid command name or one that does not support this modifier: {0}.", commandString);
                        return;
                    }
                    else if (e.Mobile.AccessLevel < command.AccessLevel)
                    {
                        e.Mobile.SendMessage("You do not have access to that command: {0}.", commandString);
                        return;
                    }
                    else if (!command.ValidateArgs(m_Scope, eventArgs[i]))
                    {
                        return;
                    }
                }

                for (int i = 0; i < commands.Length; ++i)
                {
                    BaseCommand  command = commands[i];
                    BatchCommand bc      = (BatchCommand)m_BatchCommands[i];

                    if (list.Count > 20)
                    {
                        CommandLogging.Enabled = false;
                    }

                    ArrayList usedList;

                    if (Utility.InsensitiveCompare(bc.Object, "Current") == 0)
                    {
                        usedList = list;
                    }
                    else
                    {
                        Hashtable propertyChains = new Hashtable();

                        usedList = new ArrayList(list.Count);

                        for (int j = 0; j < list.Count; ++j)
                        {
                            object obj = list[j];

                            if (obj == null)
                            {
                                continue;
                            }

                            Type type = obj.GetType();

                            PropertyInfo[] chain = (PropertyInfo[])propertyChains[type];

                            string failReason = "";

                            if (chain == null && !propertyChains.Contains(type))
                            {
                                propertyChains[type] = chain = Properties.GetPropertyInfoChain(e.Mobile, type, bc.Object, PropertyAccess.Read, ref failReason);
                            }

                            if (chain == null)
                            {
                                continue;
                            }

                            PropertyInfo endProp = Properties.GetPropertyInfo(ref obj, chain, ref failReason);

                            if (endProp == null)
                            {
                                continue;
                            }

                            try
                            {
                                obj = endProp.GetValue(obj, null);

                                if (obj != null)
                                {
                                    usedList.Add(obj);
                                }
                            }
                            catch
                            {
                            }
                        }
                    }

                    command.ExecuteList(eventArgs[i], usedList);

                    if (list.Count > 20)
                    {
                        CommandLogging.Enabled = true;
                    }

                    command.Flush(e.Mobile, list.Count > 20);
                }
            }
            catch (Exception ex)
            {
                e.Mobile.SendMessage(ex.Message);
            }
        }
Exemplo n.º 3
0
        public void OnTarget(Mobile from, object targeted, object state)
        {
            if (!BaseCommand.IsAccessible(from, targeted))
            {
                from.SendMessage("That is not accessible.");
                return;
            }

            object[]    states  = (object[])state;
            BaseCommand command = (BaseCommand)states[0];

            string[] args = (string[])states[1];

            if (command.ObjectTypes == ObjectTypes.Mobiles)
            {
                return;                 // sanity check
            }
            if (!(targeted is Container))
            {
                from.SendMessage("That is not a container.");
            }
            else
            {
                try
                {
                    ObjectConditional cond = ObjectConditional.Parse(from, ref args);

                    bool items, mobiles;

                    if (!CheckObjectTypes(command, cond, out items, out mobiles))
                    {
                        return;
                    }

                    if (!items)
                    {
                        from.SendMessage("This command only works on items.");
                        return;
                    }

                    Container cont = (Container)targeted;

                    Item[] found;

                    if (cond.Type == null)
                    {
                        found = cont.FindItemsByType(typeof(Item), true);
                    }
                    else
                    {
                        found = cont.FindItemsByType(cond.Type, true);
                    }

                    ArrayList list = new ArrayList();

                    for (int i = 0; i < found.Length; ++i)
                    {
                        if (cond.CheckCondition(found[i]))
                        {
                            list.Add(found[i]);
                        }
                    }

                    RunCommand(from, list, command, args);
                }
                catch (Exception e)
                {
                    LogHelper.LogException(e);
                    from.SendMessage(e.Message);
                }
            }
        }
Exemplo n.º 4
0
        public static void FillTable()
        {
            List <CommandEntry> commands = new List <CommandEntry>(CommandSystem.Entries.Values);
            List <CommandInfo>  list     = new List <CommandInfo>();

            commands.Sort();
            commands.Reverse();
            Docs.Clean(commands);

            for (int i = 0; i < commands.Count; ++i)
            {
                CommandEntry e = commands[i];

                MethodInfo mi = e.Handler.Method;

                object[] attrs = mi.GetCustomAttributes(typeof(UsageAttribute), false);

                if (attrs.Length == 0)
                {
                    continue;
                }

                UsageAttribute usage = attrs[0] as UsageAttribute;

                attrs = mi.GetCustomAttributes(typeof(DescriptionAttribute), false);

                if (attrs.Length == 0)
                {
                    continue;
                }

                DescriptionAttribute desc = attrs[0] as DescriptionAttribute;

                if (usage == null || desc == null)
                {
                    continue;
                }

                attrs = mi.GetCustomAttributes(typeof(AliasesAttribute), false);

                AliasesAttribute aliases = (attrs.Length == 0 ? null : attrs[0] as AliasesAttribute);

                string descString = desc.Description.Replace("<", "(").Replace(">", ")");

                if (aliases == null)
                {
                    list.Add(new CommandInfo(e.AccessLevel, e.Command, null, usage.Usage, descString));
                }
                else
                {
                    list.Add(new CommandInfo(e.AccessLevel, e.Command, aliases.Aliases, usage.Usage, descString));

                    for (int j = 0; j < aliases.Aliases.Length; j++)
                    {
                        string[] newAliases = new string[aliases.Aliases.Length];

                        aliases.Aliases.CopyTo(newAliases, 0);

                        newAliases[j] = e.Command;

                        list.Add(new CommandInfo(e.AccessLevel, aliases.Aliases[j], newAliases, usage.Usage, descString));
                    }
                }
            }


            for (int i = 0; i < TargetCommands.AllCommands.Count; ++i)
            {
                BaseCommand command = TargetCommands.AllCommands[i];

                string usage = command.Usage;
                string desc  = command.Description;

                if (usage == null || desc == null)
                {
                    continue;
                }

                string[] cmds    = command.Commands;
                string   cmd     = cmds[0];
                string[] aliases = new string[cmds.Length - 1];

                for (int j = 0; j < aliases.Length; ++j)
                {
                    aliases[j] = cmds[j + 1];
                }

                desc = desc.Replace("<", "(").Replace(">", ")");

                if (command.Supports != CommandSupport.Single)
                {
                    StringBuilder sb = new StringBuilder(50 + desc.Length);

                    sb.Append("Modifiers: ");

                    if ((command.Supports & CommandSupport.Global) != 0)
                    {
                        sb.Append("<i>Global</i>, ");
                    }

                    if ((command.Supports & CommandSupport.Online) != 0)
                    {
                        sb.Append("<i>Online</i>, ");
                    }

                    if ((command.Supports & CommandSupport.Region) != 0)
                    {
                        sb.Append("<i>Region</i>, ");
                    }

                    if ((command.Supports & CommandSupport.Contained) != 0)
                    {
                        sb.Append("<i>Contained</i>, ");
                    }

                    if ((command.Supports & CommandSupport.Multi) != 0)
                    {
                        sb.Append("<i>Multi</i>, ");
                    }

                    if ((command.Supports & CommandSupport.Area) != 0)
                    {
                        sb.Append("<i>Area</i>, ");
                    }

                    if ((command.Supports & CommandSupport.Self) != 0)
                    {
                        sb.Append("<i>Self</i>, ");
                    }

                    sb.Remove(sb.Length - 2, 2);
                    sb.Append("<br>");
                    sb.Append(desc);

                    desc = sb.ToString();
                }

                list.Add(new CommandInfo(command.AccessLevel, cmd, aliases, usage, desc));

                for (int j = 0; j < aliases.Length; j++)
                {
                    string[] newAliases = new string[aliases.Length];

                    aliases.CopyTo(newAliases, 0);

                    newAliases[j] = cmd;

                    list.Add(new CommandInfo(command.AccessLevel, aliases[j], newAliases, usage, desc));
                }
            }

            List <BaseCommandImplementor> commandImpls = BaseCommandImplementor.Implementors;

            for (int i = 0; i < commandImpls.Count; ++i)
            {
                BaseCommandImplementor command = commandImpls[i];

                string usage = command.Usage;
                string desc  = command.Description;

                if (usage == null || desc == null)
                {
                    continue;
                }

                string[] cmds    = command.Accessors;
                string   cmd     = cmds[0];
                string[] aliases = new string[cmds.Length - 1];

                for (int j = 0; j < aliases.Length; ++j)
                {
                    aliases[j] = cmds[j + 1];
                }

                desc = desc.Replace("<", ")").Replace(">", ")");

                list.Add(new CommandInfo(command.AccessLevel, cmd, aliases, usage, desc));

                for (int j = 0; j < aliases.Length; j++)
                {
                    string[] newAliases = new string[aliases.Length];

                    aliases.CopyTo(newAliases, 0);

                    newAliases[j] = cmd;

                    list.Add(new CommandInfo(command.AccessLevel, aliases[j], newAliases, usage, desc));
                }
            }

            list.Sort(new CommandInfoSorter());

            m_SortedHelpInfo = list;

            foreach (CommandInfo c in m_SortedHelpInfo)
            {
                if (!m_HelpInfos.ContainsKey(c.Name.ToLower()))
                {
                    m_HelpInfos.Add(c.Name.ToLower(), c);
                }
            }
        }
        public void RunCommand(Mobile from, object obj, BaseCommand command, string[] args)
        {
            try
            {
                CommandEventArgs e = new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args);

                if (!command.ValidateArgs(this, e))
                {
                    return;
                }

                bool flushToLog = false;

                if (obj is ArrayList)
                {
                    ArrayList list = (ArrayList)obj;

                    if (list.Count > 20)
                    {
                        CommandLogging.Enabled = false;
                    }
                    else if (list.Count == 0)
                    {
                        command.LogFailure("Nothing was found to use this command on.");
                    }

                    command.Begin(e);
                    command.ExecuteList(e, list);
                    command.End(e);

                    if (list.Count > 20)
                    {
                        flushToLog             = true;
                        CommandLogging.Enabled = true;
                    }
                }
                else if (obj != null)
                {
                    if (command.ListOptimized)
                    {
                        ArrayList list = new ArrayList();
                        list.Add(obj);
                        command.Begin(e);
                        command.ExecuteList(e, list);
                        command.End(e);
                    }
                    else
                    {
                        command.Begin(e);
                        command.Execute(e, obj);
                        command.End(e);
                    }
                }

                command.Flush(from, flushToLog);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                from.SendMessage(ex.Message);
            }
        }
 public virtual void Process(Mobile from, object target, BaseCommand command, string[] args)
 {
     RunCommand(from, command, args);
 }
 public virtual void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
 {
     obj = null;
 }
Exemplo n.º 8
0
        public override void ExecuteList(CommandEventArgs e, List <object> list)
        {
            if (list.Count == 0)
            {
                LogFailure("Nothing was found to use this command on.");
                return;
            }

            try
            {
                var commands  = new BaseCommand[BatchCommands.Count];
                var eventArgs = new CommandEventArgs[BatchCommands.Count];

                for (var i = 0; i < BatchCommands.Count; ++i)
                {
                    var bc = BatchCommands[i];

                    bc.GetDetails(out var commandString, out var argString, out var args);

                    var command = Scope.Commands[commandString];

                    commands[i]  = command;
                    eventArgs[i] = new CommandEventArgs(e.Mobile, commandString, argString, args);

                    if (command == null)
                    {
                        e.Mobile.SendMessage(
                            "That is either an invalid command name or one that does not support this modifier: {0}.",
                            commandString
                            );
                        return;
                    }

                    if (e.Mobile.AccessLevel < command.AccessLevel)
                    {
                        e.Mobile.SendMessage("You do not have access to that command: {0}.", commandString);
                        return;
                    }

                    if (!command.ValidateArgs(Scope, eventArgs[i]))
                    {
                        return;
                    }
                }

                for (var i = 0; i < commands.Length; ++i)
                {
                    var command = commands[i];
                    var bc      = BatchCommands[i];

                    if (list.Count > 20)
                    {
                        CommandLogging.Enabled = false;
                    }

                    List <object> usedList;

                    if (Utility.InsensitiveCompare(bc.Object, "Current") == 0)
                    {
                        usedList = list;
                    }
                    else
                    {
                        var propertyChains = new Dictionary <Type, PropertyInfo[]>();

                        usedList = new List <object>(list.Count);

                        for (var j = 0; j < list.Count; ++j)
                        {
                            var obj = list[j];

                            if (obj == null)
                            {
                                continue;
                            }

                            var type       = obj.GetType();
                            var failReason = "";

                            if (!propertyChains.TryGetValue(type, out var chain))
                            {
                                propertyChains[type] = chain = Properties.GetPropertyInfoChain(
                                    e.Mobile,
                                    type,
                                    bc.Object,
                                    PropertyAccess.Read,
                                    ref failReason
                                    );
                            }

                            if (chain == null)
                            {
                                continue;
                            }

                            var endProp = Properties.GetPropertyInfo(ref obj, chain, ref failReason);

                            if (endProp == null)
                            {
                                continue;
                            }

                            try
                            {
                                obj = endProp.GetValue(obj, null);

                                if (obj != null)
                                {
                                    usedList.Add(obj);
                                }
                            }
                            catch
                            {
                                // ignored
                            }
                        }
                    }

                    command.ExecuteList(eventArgs[i], usedList);

                    if (list.Count > 20)
                    {
                        CommandLogging.Enabled = true;
                    }

                    command.Flush(e.Mobile, list.Count > 20);
                }
            }
            catch (Exception ex)
            {
                e.Mobile.SendMessage(ex.Message);
            }
        }
Exemplo n.º 9
0
        public override void ExecuteList(CommandEventArgs e, List <object> list)
        {
            if (list.Count == 0)
            {
                LogFailure("Nothing was found to use this command on.");
                return;
            }

            try
            {
                BaseCommand[]      commands  = new BaseCommand[BatchCommands.Count];
                CommandEventArgs[] eventArgs = new CommandEventArgs[BatchCommands.Count];

                for (int i = 0; i < BatchCommands.Count; ++i)
                {
                    BatchCommand bc = BatchCommands[i];

                    bc.GetDetails(out string commandString, out string argString, out string[] args);

                    BaseCommand command = Scope.Commands[commandString];

                    commands[i]  = command;
                    eventArgs[i] = new CommandEventArgs(e.Mobile, commandString, argString, args);

                    if (command == null)
                    {
                        e.Mobile.SendMessage(
                            "That is either an invalid command name or one that does not support this modifier: {0}.",
                            commandString);
                        return;
                    }

                    if (e.Mobile.AccessLevel < command.AccessLevel)
                    {
                        e.Mobile.SendMessage("You do not have access to that command: {0}.", commandString);
                        return;
                    }

                    if (!command.ValidateArgs(Scope, eventArgs[i]))
                    {
                        return;
                    }
                }

                for (int i = 0; i < commands.Length; ++i)
                {
                    BaseCommand  command = commands[i];
                    BatchCommand bc      = BatchCommands[i];

                    if (list.Count > 20)
                    {
                        CommandLogging.Enabled = false;
                    }

                    List <object> usedList;

                    if (Utility.InsensitiveCompare(bc.Object, "Current") == 0)
                    {
                        usedList = list;
                    }
                    else
                    {
                        Dictionary <Type, PropertyInfo[]> propertyChains = new Dictionary <Type, PropertyInfo[]>();

                        usedList = new List <object>(list.Count);

                        for (int j = 0; j < list.Count; ++j)
                        {
                            object obj = list[j];

                            if (obj == null)
                            {
                                continue;
                            }

                            Type   type       = obj.GetType();
                            string failReason = "";

                            if (!propertyChains.TryGetValue(type, out PropertyInfo[] chain))
Exemplo n.º 10
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Mobile.Deleted)
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }
            else if (!BaseCommand.IsAccessible(m_From, m_Mobile))
            {
                m_From.SendMessage("That is no longer accessible.");
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            case 1:
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                break;
            }

            case 2:                     // Properties
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                m_From.SendGump(new PropertiesGump(m_From, m_Mobile));
                break;
            }

            case 3:                     // Delete
            {
                if (!m_Mobile.Player)
                {
                    CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, CommandLogging.Format(m_From), CommandLogging.Format(m_Mobile));
                    m_Mobile.Delete();
                    m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                }

                break;
            }

            case 4:                     // Go there
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                InvokeCommand(String.Format("Go {0}", m_Mobile.Serial.Value));
                break;
            }

            case 5:                     // Bring them here
            {
                if (m_From.Map == null || m_From.Map == Map.Internal)
                {
                    m_From.SendMessage("You cannot bring that person here.");
                }
                else
                {
                    m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                    m_Mobile.MoveToWorld(m_From.Location, m_From.Map);
                }

                break;
            }

            case 6:                     // Move to target
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                m_From.Target = new MoveTarget(m_Mobile);
                break;
            }

            case 7:                     // Kill
            {
                if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
                {
                    m_Mobile.Kill();
                }

                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));

                break;
            }

            case 8:                     // Res
            {
                if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
                {
                    m_Mobile.PlaySound(0x214);
                    m_Mobile.FixedEffect(0x376A, 10, 16);

                    m_Mobile.Resurrect();
                }

                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));

                break;
            }

            case 9:                     // Client
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));

                if (m_Mobile.NetState != null)
                {
                    m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState));
                }

                break;
            }
            }
        }
Exemplo n.º 11
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Item.Deleted)
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }
            else if (!BaseCommand.IsAccessible(m_From, m_Item))
            {
                m_From.SendMessage("That is no longer accessible.");
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            case 1:
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                break;
            }

            case 2:                     // Properties
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                m_From.SendGump(new PropertiesGump(m_From, m_Item));
                break;
            }

            case 3:                     // Delete
            {
                CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, CommandLogging.Format(m_From), CommandLogging.Format(m_Item));
                m_Item.Delete();
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                break;
            }

            case 4:                     // Go there
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                InvokeCommand(String.Format("Go {0}", m_Item.Serial.Value));
                break;
            }

            case 5:                     // Move to target
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                m_From.Target = new MoveTarget(m_Item);
                break;
            }

            case 6:                     // Bring to pack
            {
                Mobile owner = m_Item.RootParent as Mobile;

                if (owner != null && (owner.Map != null && owner.Map != Map.Internal) && !m_From.CanSee(owner))
                {
                    m_From.SendMessage("You can not get what you can not see.");
                }
                else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= m_From.AccessLevel)
                {
                    m_From.SendMessage("You can not get what you can not see.");
                }
                else
                {
                    m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                    m_From.AddToBackpack(m_Item);
                }

                break;
            }
            }
        }