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


C# TSPlayer.?.SendWarningMessage方法代码示例

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


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

示例1: TrySwapChestData

        public bool TrySwapChestData(TSPlayer player, DPoint anyChestTileLocation, out IChest newChest)
        {
            newChest = null;

              if (TerrariaUtils.Tiles[anyChestTileLocation].type != TileID.Containers && TerrariaUtils.Tiles[anyChestTileLocation].type != TileID.Dressers) {
            player.SendErrorMessage("The selected tile is not a chest or dresser.");
            return false;
              }

              DPoint chestLocation = TerrariaUtils.Tiles.MeasureObject(anyChestTileLocation).OriginTileLocation;
              IChest chest = this.ChestManager.ChestFromLocation(chestLocation, player);
              if (chest == null)
            return false;

              ItemData[] content = new ItemData[Chest.maxItems];
              for (int i = 0; i < Chest.maxItems; i++)
            content[i] = chest.Items[i];

              if (chest.IsWorldChest) {
            lock (this.WorldMetadata.ProtectorChests) {
              bool isChestAvailable = this.WorldMetadata.ProtectorChests.Count < this.Config.MaxProtectorChests;
              if (!isChestAvailable) {
            player?.SendErrorMessage("The maximum of possible Protector chests has been reached.");
            return false;
              }

              int playerUsingChestIndex = Chest.UsingChest(chest.Index);
              if (playerUsingChestIndex != -1)
            Main.player[playerUsingChestIndex].chest = -1;

              Main.chest[chest.Index] = null;
              newChest = new ProtectorChestData(chestLocation, content);

              this.WorldMetadata.ProtectorChests.Add(chestLocation, (ProtectorChestData)newChest);

              //TSPlayer.All.SendData(PacketTypes.ChestName, string.Empty, chest.Index, chestLocation.X, chestLocation.Y);

              // Tell the client to remove the chest with the given index from its own chest array.
              TSPlayer.All.SendData(PacketTypes.TileKill, string.Empty, 1, chestLocation.X, chestLocation.Y, 0, chest.Index);
              TSPlayer.All.SendTileSquare(chestLocation.X, chestLocation.Y, 2);
              player?.SendWarningMessage("This chest is now a Protector chest.");
            }
              } else {
            int availableUnnamedChestIndex = -1;
            int availableEmptyChestIndex = -1;
            for (int i = 0; i < Main.chest.Length; i++) {
              if (i == ChestManager.DummyChestIndex)
            continue;

              Chest tChest = Main.chest[i];
              if (tChest == null) {
            availableEmptyChestIndex = i;
            break;
              } else if (availableUnnamedChestIndex == -1 && string.IsNullOrWhiteSpace(tChest.name)) {
            availableUnnamedChestIndex = i;
              }
            }

            // Prefer unset chests over unnamed chests.
            int availableChestIndex = availableEmptyChestIndex;
            if (availableChestIndex == -1)
              availableChestIndex = availableUnnamedChestIndex;

            bool isChestAvailable = (availableChestIndex != -1);
            if (!isChestAvailable) {
              player?.SendErrorMessage("The maximum of possible world chests has been reached.");
              return false;
            }

            lock (this.WorldMetadata.ProtectorChests)
              this.WorldMetadata.ProtectorChests.Remove(chestLocation);

            Chest availableChest = Main.chest[availableChestIndex];
            bool isExistingButUnnamedChest = (availableChest != null);
            if (isExistingButUnnamedChest) {
              if (!this.TrySwapChestData(null, new DPoint(availableChest.x, availableChest.y), out newChest))
            return false;
            }

            availableChest = Main.chest[availableChestIndex] = new Chest();
            availableChest.x = chestLocation.X;
            availableChest.y = chestLocation.Y;
            availableChest.item = content.Select(i => i.ToItem()).ToArray();

            newChest = new ChestAdapter(availableChestIndex, availableChest);
            player?.SendWarningMessage("This chest is now a world chest.");
              }

              return true;
        }
开发者ID:CoderCow,项目名称:Protector-Plugin,代码行数:90,代码来源:UserInteractionHandler.cs


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