当前位置: 首页>>代码示例>>C#>>正文


C# ArgumentList.TryPopOne方法代码示例

本文整理汇总了C#中ArgumentList.TryPopOne方法的典型用法代码示例。如果您正苦于以下问题:C# ArgumentList.TryPopOne方法的具体用法?C# ArgumentList.TryPopOne怎么用?C# ArgumentList.TryPopOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArgumentList的用法示例。


在下文中一共展示了ArgumentList.TryPopOne方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Heal

        /// <summary>
        /// Heals one or all players.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="message">Message to send</param>
        public void Heal(ISender sender, ArgumentList args)
        {
            Player subject;

            if (args.TryPopOne(out subject))
            {
                subject = sender as Player;
                if (subject == null)
                {
                    sender.Message("Need a heal target");
                    return;
                }

                NetMessage.SendData((int)Packet.HEAL_PLAYER, -1, -1, String.Empty, subject.whoAmI, (float)subject.statLifeMax);
                subject.Message("You have been healed!", Color.Green);
            }
            else if (args.TryPop("-all"))
            {
                foreach (var plr in Main.player)
                {
                    if (plr.active)
                    {
                        NetMessage.SendData((int)Packet.HEAL_PLAYER, -1, -1, String.Empty, plr.whoAmI, (float)plr.statLifeMax);
                        plr.Message("You have been healed!", Color.Green);
                    }
                }
            }
            else if (sender is Player)
            {
                var plr = sender as Player;
                NetMessage.SendData((int)Packet.HEAL_PLAYER, -1, -1, String.Empty, plr.whoAmI, (float)plr.statLifeMax);
                plr.Message("You have been healed!", Color.Green);
            }
            else throw new CommandError("Nobody specified to heal");
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:40,代码来源:HealCommand.cs

示例2: TeleportHere

        /// <summary>
        /// Teleports specified player to sending player's location.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void TeleportHere(ISender sender, ArgumentList args)
        {
            if (sender is Player)
            {
                Player player = ((Player)sender);
                Player subject;

                if (args.TryPopOne(out subject))
                {
                    if (subject == null)
                    {
                        sender.Message("Cannot find player");
                        return;
                    }

                    subject.Teleport(player);

                    Utils.NotifyAllOps("Teleported " + subject.name + " to " +
                        player.name + " [" + sender.SenderName + "]", true);
                }
            }
            else
            {
                throw new CommandError("This command is for players only");
            }
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:31,代码来源:TeleportHereCommand.cs

示例3: Teleport

        /// <summary>
        /// Teleports player1 to a second specified player's location.
        /// </summary>
        /// <param name="server">Current Server instance</param>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public static void Teleport(Server server, ISender sender, ArgumentList args)
        {
            Player subject;
            Player target;

            if (! args.TryPopOne (out subject))
            {
                subject = sender as Player;
                if (subject == null)
                {
                    sender.sendMessage ("Need specify who to teleport.");
                    return;
                }

                if (args.Count == 0)
                {
                    if (subject.Teleport (Main.spawnTileX, Main.spawnTileY))
                    {
                        Program.server.notifyOps (string.Concat ("Teleported ", subject.Name, " to spawn."), true);
                    }
                    else
                        sender.sendMessage ("Teleportation failed.");
                    return;
                }
            }
            else if (args.Count == 0)
            {
                target = subject;

                subject = sender as Player;
                if (subject == null)
                {
                    sender.sendMessage ("Need specify who to teleport.");
                    return;
                }

                if (subject.Teleport (target))
                {

                    Program.server.notifyOps (string.Concat ("Teleported ", subject.Name, " to ",
                        target.Name, ". {", sender.Name, "}"), true);
                }
                else
                    sender.sendMessage ("Teleportation failed.");
                return;
            }

            int x;
            int y;

            if (args.Count == 1)
            {
                if (args.TryParseOne (out target))
                {
                    if (subject.Teleport (target))
                    {
                        Program.server.notifyOps (string.Concat ("Teleported ", subject.Name, " to ",
                            target.Name, ". {", sender.Name, "}"), true);
                    }
                    else
                        sender.sendMessage ("Teleportation failed.");
                }
                else
                    sender.sendMessage ("Target player not found.");
                return;
            }
            else if (args.Count == 2)
            {
                if (args.TryParseTwo (out x, out y))
                {
                    if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
                    {
                        sender.sendMessage (string.Format ("Coordinates out of range of (0, {0}); (0, {1}).", Main.maxTilesX, Main.maxTilesY));
                        return;
                    }

                    if (subject.Teleport (x, y))
                    {
                        Program.server.notifyOps (string.Concat ("Teleported ", subject.Name, " to ",
                            x, ":", y, ". {", sender.Name, "}"), true);
                    }
                    else
                        sender.sendMessage ("Teleportation failed.");
                }
                else
                    throw new CommandError ("Invalid coordinates.");
                return;
            }

            throw new CommandError ("");
        }
开发者ID:Dyrian,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:97,代码来源:Commands.cs

示例4: TeleportHere

        /// <summary>
        /// Teleports specified player to sending player's location.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public static void TeleportHere(ISender sender, ArgumentList args)
        {
            if (sender is Player)
            {
                Player player = ((Player)sender);
                Player subject;

                if (args.TryPopOne(out subject))
                {
                    if (subject == null)
                    {
                        sender.sendMessage("Could not find a Player on the Server");
                        return;
                    }

                    subject.Teleport(player);

                    Server.notifyOps("Teleported " + subject.Name + " to " +
                        player.Name + " {" + sender.Name + "}", true);
                }
            }
            else
            {
                throw new CommandError("Only a player can call this command!");
            }
        }
开发者ID:rakiru,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:31,代码来源:Commands.cs

示例5: TeleportHere

        /// <summary>
        /// Teleports specified player to sending player's location.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public static void TeleportHere(ISender sender, ArgumentList args)
        {
            if (sender is Player)
            {
                Player player = ((Player)sender);
                Player subject;

                if (args.TryPopOne(out subject))
                {
                    if (subject == null)
                    {
                        sender.sendMessage(Languages.CouldNotFindPlayer);
                        return;
                    }

                    subject.Teleport(player);

                    Server.notifyOps("Teleported " + subject.Name + " to " +
                        player.Name + " [" + sender.Name + "]", true);
                }
            }
            else
            {
                throw new CommandError(Languages.OnlyPlayerCanUseCommand);
            }
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:31,代码来源:Commands.cs

示例6: Teleport

        /// <summary>
        /// Teleports player1 to a second specified player's location.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public static void Teleport(ISender sender, ArgumentList args)
        {
            Player subject;
            Player target;

            if (!args.TryPopOne(out subject))
            {
                subject = sender as Player;
                if (subject == null)
                {
                    sender.sendMessage(Languages.NeedTeleportTarget);
                    return;
                }

                if (args.Count == 0)
                {
                    if (subject.Teleport(Main.spawnTileX, Main.spawnTileY))
                    {
                        Server.notifyOps(String.Format(Languages.TeleportedToSpawn, subject.Name), true);
                    }
                    else
                        sender.sendMessage(Languages.TeleportFailed);
                    return;
                }
            }
            else if (args.Count == 0)
            {
                target = subject;

                subject = sender as Player;
                if (subject == null)
                {
                    sender.sendMessage(Languages.NeedTeleportTarget);
                    return;
                }

                if (subject.Teleport(target))
                {

                    Server.notifyOps(string.Concat("Teleported ", subject.Name, " to ",
                        target.Name, ". [", sender.Name, "]"), true);
                }
                else
                    sender.sendMessage(Languages.TeleportFailed);
                return;
            }

            int x;
            int y;

            if (args.Count == 1)
            {
                if (args.TryParseOne(out target))
                {
                    if (subject.Teleport(target))
                    {
                        Server.notifyOps(string.Concat("Teleported ", subject.Name, " to ",
                            target.Name, ". [", sender.Name, "]"), true);
                    }
                    else
                        sender.sendMessage(Languages.TeleportFailed);
                }
                else
                    sender.sendMessage(Languages.PlayerNotFound);
                return;
            }
            else if (args.Count == 2)
            {
                if (args.TryParseTwo(out x, out y))
                {
                    if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
                    {
                        sender.sendMessage(String.Format("Coordinates out of range of (0, {0}); (0, {1}).", Main.maxTilesX - 1, Main.maxTilesY - 1));
                        return;
                    }

                    if (subject.Teleport(x, y))
                    {
                        Server.notifyOps(string.Concat("Teleported ", subject.Name, " to ",
                            x, ":", y, ". [", sender.Name, "]"), true);
                    }
                    else
                        sender.sendMessage(Languages.TeleportFailed);
                }
                else
                    throw new CommandError(Languages.InvalidCoords);
                return;
            }

            throw new CommandError("");
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:96,代码来源:Commands.cs

示例7: WorldEvent

        /// <summary>
        /// Starts an event
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void WorldEvent(ISender sender, ArgumentList args)
        {
            string first;
            args.TryPopOne(out first);
            switch (first)
            {
                case "eclipse":
                    if (!Main.eclipse)
                    {
                        _disableActiveEvents(sender);

                        World.SetTime(0);
                        //OTA.Callbacks.MainCallback.StartEclipse = true;
                        Main.eclipse = true;

                        NetMessage.SendData(25, -1, -1, Lang.misc[20], 255, 50f, 255f, 130f, 0);
                        NetMessage.SendData((int)Packet.WORLD_DATA);

                        ProgramLog.Admin.Log(Lang.misc[20]);
                    }
                    else
                    {
                        Main.eclipse = false;
                        sender.Message("The eclipse was disabled.");
                    }
                    break;
                case "snowmoon":
                    if (!Main.snowMoon)
                    {
                        _disableActiveEvents(sender);
                        World.SetTime(16200.0, false);
                        NetMessage.SendData(25, -1, -1, Lang.misc[34], 255, 50f, 255f, 130f, 0);
                        Main.startSnowMoon();
                        NetMessage.SendData((int)Packet.WORLD_DATA);

                        ProgramLog.Admin.Log(Lang.misc[34]);
                        ProgramLog.Admin.Log("First Wave: Zombie Elf and Gingerbread Man");
                    }
                    else
                    {
                        Main.stopMoonEvent();
                        sender.Message("The snow moon was disabled.");
                    }
                    break;
                case "pumpkinmoon":
                    if (!Main.pumpkinMoon)
                    {
                        _disableActiveEvents(sender);
                        World.SetTime(16200.0, false);
                        NetMessage.SendData(25, -1, -1, Lang.misc[31], 255, 50f, 255f, 130f, 0);
                        Main.startPumpkinMoon();
                        NetMessage.SendData((int)Packet.WORLD_DATA);

                        ProgramLog.Admin.Log(Lang.misc[31]);
                        ProgramLog.Admin.Log("First Wave: " + Main.npcName[305]);
                    }
                    else
                    {
                        Main.stopMoonEvent();
                        sender.Message("The pumpkin moon was disabled.");
                    }
                    break;
                case "bloodmoon":
                    if (!Main.bloodMoon)
                    {
                        _disableActiveEvents(sender);
                        World.SetTime(0, false);
                        //OTA.Callbacks.MainCallback.StartEclipse = true;
                        Main.bloodMoon = true;
                        NetMessage.SendData((int)Packet.WORLD_DATA);
                        NetMessage.SendData(25, -1, -1, Lang.misc[8], 255, 50f, 255f, 130f, 0);

                        ProgramLog.Admin.Log(Lang.misc[8]);
                    }
                    else
                    {
                        Main.bloodMoon = false;
                        sender.Message("The blood moon was disabled.");
                    }
                    break;
                case "slimerain":
                    if (!Main.slimeRain)
                    {
                        _disableActiveEvents(sender);
                        Main.slimeRain = true;
                        NetMessage.SendData((int)Packet.WORLD_DATA);
                        Main.StartSlimeRain();

                        sender.Message("Slime rain was enabled.");
                    }
                    else
                    {
                        Main.slimeRain = false;
                        NetMessage.SendData((int)Packet.WORLD_DATA);
                        sender.Message("The slime rain was disabled.");
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:WorldEventCommand.cs

示例8: ServerList

 /// <summary>
 /// Manages the server list
 /// </summary>
 /// <param name="sender">Sending player</param>
 /// <param name="args">Arguments sent with command</param>
 public void ServerList(ISender sender, ArgumentList args)
 {
     string first;
     args.TryPopOne(out first);
     switch (first)
     {
         case "enable":
             Heartbeat.Begin(CoreBuild);
             sender.SendMessage("Heartbeat enabled to the TDSM server.");
             break;
         case "disable":
             Heartbeat.End();
             sender.SendMessage("Heartbeat disabled to the TDSM server.");
             break;
         case "public":
             Heartbeat.PublishToList = args.GetBool(1);
             sender.SendMessage("Server list is now " + (Heartbeat.PublishToList ? "public" : "private"));
             break;
         case "desc":
             string d;
             if (args.TryPopOne(out d))
             {
                 Heartbeat.ServerDescription = d;
                 sender.SendMessage("Description set to: " + Heartbeat.ServerDescription);
             }
             else sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
             break;
         case "name":
             string n;
             if (args.TryPopOne(out n))
             {
                 Heartbeat.ServerName = n;
                 sender.SendMessage("Name set to: " + Heartbeat.ServerName);
             }
             else sender.SendMessage("Current name: " + Heartbeat.ServerName);
             break;
         case "domain":
             string h;
             if (args.TryPopOne(out h))
             {
                 Heartbeat.ServerDomain = h;
                 sender.SendMessage("Domain set to: " + Heartbeat.ServerDomain);
             }
             else sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
             break;
         case "?":
         case "print":
             sender.SendMessage("Heartbeat is " + (Heartbeat.Enabled ? "enabled" : "disabled"));
             sender.SendMessage("Server list " + (Heartbeat.PublishToList ? "public" : "private"));
             sender.SendMessage("Current name: " + Heartbeat.ServerName);
             sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
             sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
             break;
         default:
             throw new CommandError("Not a supported serverlist command " + first);
     }
 }
开发者ID:Stickiler,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:62,代码来源:Commands.cs

示例9: Heal

        /// <summary>
        /// Heals one or all players.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="message">Message to send</param>
        public void Heal(ISender sender, ArgumentList args)
        {
            Player subject;

            if (args.TryPopOne(out subject))
            {
                subject = sender as Player;
                if (subject == null)
                {
                    sender.Message("Need a heal target");
                    return;
                }

                //subject.HealEffect(subject.statLifeMax, true);
                NetMessage.SendData(35, -1, -1, String.Empty, subject.whoAmI, (float)subject.statLifeMax, 0f, 0f, 0);
            }
            else if (args.TryPop("-all"))
            {
                foreach (var plr in Main.player)
                {
                    if (plr.active)
                    {
                        NetMessage.SendData(35, -1, -1, String.Empty, plr.whoAmI, (float)plr.statLifeMax, 0f, 0f, 0);
                    }
                }
            }
            else throw new CommandError("No player or options were specified");
        }
开发者ID:Stickiler,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:33,代码来源:Commands.cs

示例10: Teleport

        /// <summary>
        /// Teleports player1 to a second specified player's location.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void Teleport(ISender sender, ArgumentList args)
        {
            Player subject;
            Player target;

            if (!args.TryPopOne(out subject))
            {
                subject = sender as Player;
                if (subject == null)
                {
                    sender.Message("Need a teleport target");
                    return;
                }

                if (args.Count == 0)
                {
                    /*if (*/
                    subject.Teleport(Main.spawnTileX * 16f, Main.spawnTileY * 16f - subject.height);//)
                    {
                        Tools.NotifyAllOps(String.Format("{0} has teleported to spawn", subject.Name), true);
                    }
                    //else
                    //    sender.Message(Languages.TeleportFailed);
                    return;
                }
            }
            else if (args.Count == 0)
            {
                target = subject;

                subject = sender as Player;
                if (subject == null)
                {
                    sender.Message("Need a teleport target");
                    return;
                }

                /*if (*/
                subject.Teleport(target); //)
                {

                    Tools.NotifyAllOps(string.Concat("Teleported ", subject.Name, " to ",
                        target.Name, ". [", sender.SenderName, "]"), true);
                }
                //else
                //    sender.Message(Languages.TeleportFailed);
                return;
            }

            int x;
            int y;

            if (args.Count == 1)
            {
                if (args.TryParseOne(out target))
                {
                    /*if (*/
                    subject.Teleport(target); //)
                    {
                        Tools.NotifyAllOps(string.Concat("Teleported ", subject.Name, " to ",
                            target.Name, ". [", sender.SenderName, "]"), true);
                    }
                    //else
                    //    sender.Message(Languages.TeleportFailed);
                }
                else
                    sender.Message("Cannot find player");
                return;
            }
            else if (args.Count == 2)
            {
                if (args.TryParseTwo(out x, out y))
                {
                    if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
                    {
                        sender.Message(String.Format("Coordinates out of range of (0, {0}); (0, {1}).", Main.maxTilesX - 1, Main.maxTilesY - 1));
                        return;
                    }
                    const Int32 OutOfBoundsPadding = 0; // 41;

                    /*if (*/
                    subject.Teleport((x - OutOfBoundsPadding) * 16f, (y - OutOfBoundsPadding) * 16f); //)
                    {
                        Tools.NotifyAllOps(string.Concat("Teleported ", subject.Name, " to ",
                            x, ":", y, ". [", sender.SenderName, "]"), true);
                    }
                    //else
                    //    sender.Message(Languages.TeleportFailed);
                }
                else
                    throw new CommandError("Invalid coordinates");
                return;
            }

            throw new CommandError(String.Empty);
//.........这里部分代码省略.........
开发者ID:Stickiler,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:Commands.cs

示例11: ServerList

 /// <summary>
 /// Manages the server list
 /// </summary>
 /// <param name="sender">Sending player</param>
 /// <param name="args">Arguments sent with command</param>
 public void ServerList(ISender sender, ArgumentList args)
 {
     string first;
     args.TryPopOne(out first);
     switch (first)
     {
         case "enable":
             if (!Heartbeat.Enabled)
             {
                 Heartbeat.Begin(Entry.CoreBuild);
                 sender.SendMessage("Heartbeat enabled to the TDSM server.");
             }
             else
             {
                 sender.SendMessage("Heartbeat is already enabled.");
             }
             break;
         case "disable":
             if (Heartbeat.Enabled)
             {
                 Heartbeat.End();
                 sender.SendMessage("Heartbeat disabled to the TDSM server.");
             }
             else
             {
                 sender.SendMessage("Heartbeat is not enabled.");
             }
             break;
         case "public":
             Heartbeat.PublishToList = args.GetBool(0);
             if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list", Heartbeat.PublishToList))
                 sender.SendMessage("Server list is now " + (Heartbeat.PublishToList ? "public" : "private"));
             else sender.Message("Failed to update visibility");
             break;
         case "desc":
             string d;
             if (args.TryPopOne(out d))
             {
                 Heartbeat.ServerDescription = d;
                 if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list-desc", d))
                     sender.SendMessage("Description set to: " + Heartbeat.ServerDescription);
                 else sender.Message("Failed to update description");
             }
             else
                 sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
             break;
         case "name":
             string n;
             if (args.TryPopOne(out n))
             {
                 Heartbeat.ServerName = n;
                 if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list-name", n))
                     sender.SendMessage("Name set to: " + Heartbeat.ServerName);
                 else sender.Message("Failed to update name");
             }
             else
                 sender.SendMessage("Current name: " + Heartbeat.ServerName);
             break;
         case "domain":
             string h;
             if (args.TryPopOne(out h))
             {
                 Heartbeat.ServerDomain = h;
                 if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list-domain", h))
                     sender.SendMessage("Domain set to: " + Heartbeat.ServerDomain);
                 else sender.Message("Failed to update domain");
             }
             else
                 sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
             break;
         case "?":
         case "print":
             sender.SendMessage("Heartbeat is " + (Heartbeat.Enabled ? "enabled" : "disabled"));
             if (Heartbeat.LastBeat.HasValue)
                 sender.SendMessage("Last beat: " + Heartbeat.LastBeat);
             else
                 sender.SendMessage("Last beat: n/a");
             sender.SendMessage("Server list is " + (Heartbeat.PublishToList ? "public" : "private"));
             sender.SendMessage("Current name: " + Heartbeat.ServerName);
             sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
             sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
             break;
         default:
             throw new CommandError("Not a supported serverlist command " + first);
     }
 }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:91,代码来源:ServerListCommand.cs


注:本文中的ArgumentList.TryPopOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。