本文整理汇总了C#中TShockAPI.TSPlayer.?.SendErrorMessage方法的典型用法代码示例。如果您正苦于以下问题:C# TSPlayer.?.SendErrorMessage方法的具体用法?C# TSPlayer.?.SendErrorMessage怎么用?C# TSPlayer.?.SendErrorMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TShockAPI.TSPlayer
的用法示例。
在下文中一共展示了TSPlayer.?.SendErrorMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: ChestFromLocation
public IChest ChestFromLocation(DPoint chestLocation, TSPlayer reportToPlayer = null)
{
Tile tile = TerrariaUtils.Tiles[chestLocation];
if (!tile.active() || (tile.type != (int)BlockType.Chest && tile.type != (int)BlockType.Dresser)) {
reportToPlayer?.SendErrorMessage("There is no chest at this position.");
return null;
}
IChest chest = null;
int chestIndex = Chest.FindChest(chestLocation.X, chestLocation.Y);
bool isWorldDataChest = (chestIndex != -1 && chestIndex != ChestManager.DummyChestIndex);
if (isWorldDataChest) {
Chest tChest = Main.chest[chestIndex];
if (tChest != null)
chest = new ChestAdapter(chestIndex, Main.chest[chestIndex]);
else
reportToPlayer?.SendErrorMessage($"World data for this chest (id {chestIndex}) were expected, but was not present.");
} else {
lock (this.WorldMetadata.ProtectorChests) {
ProtectorChestData protectorChest;
if (this.WorldMetadata.ProtectorChests.TryGetValue(chestLocation, out protectorChest))
chest = protectorChest;
else
reportToPlayer?.SendErrorMessage("The data record of this chest is missing in both world data and Protector's data.");
}
}
return chest;
}