本文整理汇总了C#中Terraria.Item.Prefix方法的典型用法代码示例。如果您正苦于以下问题:C# Item.Prefix方法的具体用法?C# Item.Prefix怎么用?C# Item.Prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terraria.Item
的用法示例。
在下文中一共展示了Item.Prefix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadExtraData
public override void ReadExtraData(BinaryReader reader)
{
item = new Item();
item.netDefaults((int)reader.ReadInt16());
item.Prefix((int)reader.ReadByte());
item.stack = (int)reader.ReadInt16();
}
示例2: entry_OnClick
void entry_OnClick(Terraria.UI.UIMouseEvent evt, Terraria.UI.UIElement listeningElement)
{
var entry = (PrefixEntry)listeningElement;
var baseItem = new Item();
baseItem.SetDefaults(entry.Item.type);
baseItem.Prefix(entry.Item.prefix);
_itemSlot.Item = baseItem;
}
示例3: SetupStartInventory
public static IList<Item> SetupStartInventory(Player player)
{
IList<Item> items = new List<Item>();
Item item = new Item();
item.SetDefaults("Copper Shortsword");
item.Prefix(-1);
items.Add(item);
item = new Item();
item.SetDefaults("Copper Pickaxe");
item.Prefix(-1);
items.Add(item);
item = new Item();
item.SetDefaults("Copper Axe");
item.Prefix(-1);
items.Add(item);
foreach (ModPlayer modPlayer in player.modPlayers)
{
modPlayer.SetupStartInventory(items);
}
IDictionary<int, int> counts = new Dictionary<int, int>();
foreach (Item item0 in items)
{
if (item0.maxStack > 1)
{
if (!counts.ContainsKey(item0.netID))
{
counts[item0.netID] = 0;
}
counts[item0.netID] += item0.stack;
}
}
int k = 0;
while (k < items.Count)
{
bool flag = true;
int id = items[k].netID;
if (counts.ContainsKey(id))
{
items[k].stack = counts[id];
if (items[k].stack > items[k].maxStack)
{
items[k].stack = items[k].maxStack;
}
counts[id] -= items[k].stack;
if (items[k].stack <= 0)
{
items.RemoveAt(k);
flag = false;
}
}
if (flag)
{
k++;
}
}
return items;
}
示例4: Item
TextSnippet ITagHandler.Parse(string text, Color baseColor, string options)
{
Item obj = new Item();
int result1;
if (int.TryParse(text, out result1))
obj.netDefaults(result1);
else
obj.SetDefaults(text);
if (obj.itemId <= 0)
return new TextSnippet(text);
obj.stack = 1;
if (options != null)
{
string[] strArray = options.Split(',');
for (int index = 0; index < strArray.Length; ++index)
{
if (strArray[index].Length != 0)
{
switch (strArray[index][0])
{
case 'p':
int result2;
if (int.TryParse(strArray[index].Substring(1), out result2))
{
obj.Prefix(Utils.Clamp<int>(result2, 0, 84));
continue;
}
continue;
case 's':
case 'x':
int result3;
if (int.TryParse(strArray[index].Substring(1), out result3))
{
obj.stack = Utils.Clamp<int>(result3, 1, obj.maxStack);
continue;
}
continue;
default:
continue;
}
}
}
}
string str = "";
if (obj.stack > 1)
str = " (" + obj.stack + ")";
ItemSnippet itemSnippet = new ItemSnippet(obj);
itemSnippet.Text = "[" + obj.AffixName() + str + "]";
itemSnippet.CheckForHover = true;
itemSnippet.DeleteWhole = true;
return itemSnippet;
}
示例5: ReadModItem
internal static void ReadModItem(Item item, BinaryReader reader)
{
string modName = reader.ReadString();
string itemName = reader.ReadString();
Mod mod = ModLoader.GetMod(modName);
int type = mod == null ? 0 : mod.ItemType(itemName);
if (type != 0)
{
item.netDefaults(type);
int dataLength = reader.ReadUInt16();
if (dataLength > 0)
{
byte[] data = reader.ReadBytes(dataLength);
using (MemoryStream memoryStream = new MemoryStream(data))
{
using (BinaryReader customReader = new BinaryReader(memoryStream))
{
item.modItem.LoadCustomData(customReader);
}
}
}
if (type == ModLoader.GetMod("ModLoader").ItemType("MysteryItem"))
{
MysteryItem mystery = item.modItem as MysteryItem;
modName = mystery.GetModName();
itemName = mystery.GetItemName();
mod = ModLoader.GetMod(modName);
type = mod == null ? 0 : mod.ItemType(itemName);
if (type != 0)
{
item.netDefaults(type);
}
}
}
else
{
item.netDefaults(ModLoader.GetMod("ModLoader").ItemType("MysteryItem"));
MysteryItem mystery = item.modItem as MysteryItem;
mystery.SetModName(modName);
mystery.SetItemName(itemName);
reader.ReadBytes(reader.ReadUInt16());
}
item.Prefix(reader.ReadByte());
}
示例6: LoadChests
private static void LoadChests(BinaryReader reader)
{
short num;
int i;
int j;
int num1;
int num2;
Chest chest = null;
int num3 = reader.ReadInt16();
int num4 = reader.ReadInt16();
if (num4 >= 40)
{
num1 = 40;
num2 = num4 - 40;
}
else
{
num1 = num4;
num2 = 0;
}
for (i = 0; i < num3; i++)
{
chest = new Chest(false)
{
x = reader.ReadInt32(),
y = reader.ReadInt32(),
name = reader.ReadString()
};
for (j = 0; j < num1; j++)
{
num = reader.ReadInt16();
Item item = new Item();
if (num > 0)
{
item.netDefaults(reader.ReadInt32());
item.stack = num;
item.Prefix((int)reader.ReadByte());
}
else if (num < 0)
{
item.netDefaults(reader.ReadInt32());
item.Prefix((int)reader.ReadByte());
item.stack = 1;
}
chest.item[j] = item;
}
for (j = 0; j < num2; j++)
{
num = reader.ReadInt16();
if (num > 0)
{
reader.ReadInt32();
reader.ReadByte();
}
}
Main.chest[i] = chest;
}
while (i < 1000)
{
Main.chest[i] = null;
i++;
}
if (WorldFile.versionNumber < 115)
{
WorldFile.FixDresserChests();
}
}
示例7: ReadChest
public static Chest ReadChest(this BinaryReader reader)
{
Chest chest = new Chest(false);
chest.x = reader.ReadInt32();
chest.y = reader.ReadInt32();
chest.name = "World Chest";
for (int l = 0; l < 40; l++)
{
Item item = new Item();
int stack = reader.ReadInt16();
if (stack > 0)
{
int netID = reader.ReadInt32();
byte prefix = reader.ReadByte();
item.netDefaults(netID);
item.stack = stack;
item.Prefix(prefix);
}
chest.item[l] = item;
}
return chest;
}
示例8: NetHooks_GetData
//.........这里部分代码省略.........
if (player.GetState() != SettingState.None)
//if player is still setting something - end his setting
player.SetState(SettingState.None);
}
break;
case PacketTypes.TileKill:
case PacketTypes.Tile:
using (var data = new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))
try
{
var reader = new BinaryReader(data);
if (e.MsgID == PacketTypes.Tile)
{
byte type = reader.ReadByte();
if (!(type == 0 || type == 4))
return;
}
int x = reader.ReadInt32();
int y = reader.ReadInt32();
reader.Close();
if (Chest.TileIsChest(x, y)) //if is Chest
{
int id = Terraria.Chest.FindChest(x, y);
CPlayer player = Players[e.Msg.whoAmI];
TPPlayer tplayer = tPulse.Players[e.Msg.whoAmI];
//dirty fix for finding chest, try to find chest point around
if (id == -1)
try
{
id = Terraria.Chest.FindChest(x - 1, y); //search one tile left
if (id == -1)
{
id = Terraria.Chest.FindChest(x - 1, y - 1);
//search one tile left and one tile up
if (id == -1)
id = Terraria.Chest.FindChest(x, y - 1); //search one tile up
}
}
catch (Exception ex)
{
Log.Write(ex.ToString(), LogLevel.Error);
}
if (id != -1) //if have found chest
{
Chest chest = ChestManager.GetChest(id);
if (chest.HasOwner()) //if owned stop removing
{
if (tplayer.Group.HasPermission("removechestprotection") ||
chest.IsOwnerConvert(player))
//display more verbose info to player who has permission to remove protection on this chest
player.SendMessage(
"This chest is protected. To remove it, first remove protection using \"/cunset\" command.",
Color.Red);
else
player.SendMessage("This chest is protected!", Color.Red);
player.SendTileSquare(x, y);
e.Handled = true;
}
}
}
}
catch (Exception ex)
{
Log.Write(ex.ToString(), LogLevel.Error);
}
break;
case PacketTypes.ChestItem:
using (var data = new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))
{
var reader = new BinaryReader(data);
short id = reader.ReadInt16();
byte slot = reader.ReadByte();
byte stack = reader.ReadByte();
byte prefix = reader.ReadByte();
short type = reader.ReadByte();
if (id != -1)
{
Chest chest = ChestManager.GetChest(id);
if (chest.IsRefill())
e.Handled = true;
if (!e.Handled)
{
var item = Main.chest[id].item[slot];
var newitem = new Item();
newitem.netDefaults(type);
newitem.Prefix(prefix);
newitem.AffixName();
Log.Write(string.Format("{0}({1}) in slot {2} in chest at {3}x{4} was modified to {5}({6}) by {7}",
item.name, item.stack, slot, Main.chest[id].x, Main.chest[id].y, newitem.name, stack, tPulse.Players[e.Msg.whoAmI].UserAccountName),
LogLevel.Info, false);
}
}
}
break;
}
}
示例9: LoadChests
private static void LoadChests(BinaryReader reader)
{
int num = (int)reader.ReadInt16();
int num2 = (int)reader.ReadInt16();
int num3;
int num4;
if (num2 < Chest.maxItems)
{
num3 = num2;
num4 = 0;
}
else
{
num3 = Chest.maxItems;
num4 = num2 - Chest.maxItems;
}
int i;
for (i = 0; i < num; i++)
{
Chest chest = new Chest(false);
chest.x = reader.ReadInt32();
chest.y = reader.ReadInt32();
chest.name = reader.ReadString();
for (int j = 0; j < num3; j++)
{
short num5 = reader.ReadInt16();
Item item = new Item();
if (num5 > 0)
{
item.netDefaults(reader.ReadInt32());
item.stack = (int)num5;
item.Prefix((int)reader.ReadByte());
}
else if (num5 < 0)
{
item.netDefaults(reader.ReadInt32());
item.Prefix((int)reader.ReadByte());
item.stack = 1;
}
chest.item[j] = item;
}
for (int j = 0; j < num4; j++)
{
short num5 = reader.ReadInt16();
if (num5 > 0)
{
reader.ReadInt32();
reader.ReadByte();
}
}
Main.chest[i] = chest;
}
while (i < 1000)
{
Main.chest[i] = null;
i++;
}
}
示例10: HandlePlayerSlot
private static bool HandlePlayerSlot(GetDataHandlerArgs args)
{
byte plr = args.Data.ReadInt8();
byte slot = args.Data.ReadInt8();
short stack = args.Data.ReadInt16();
byte prefix = args.Data.ReadInt8();
short type = args.Data.ReadInt16();
// Players send a slot update packet for each inventory slot right after they've joined.
bool bypassTrashCanCheck = false;
if (plr == args.Player.Index && !args.Player.HasSentInventory && slot == NetItem.MaxInventory)
{
args.Player.HasSentInventory = true;
bypassTrashCanCheck = true;
}
if (OnPlayerSlot(plr, slot, stack, prefix, type) || plr != args.Player.Index || slot < 0 ||
slot > NetItem.MaxInventory)
return true;
if (args.Player.IgnoreSSCPackets)
{
args.Player.SendData(PacketTypes.PlayerSlot, "", args.Player.Index, slot, prefix);
return true;
}
// Garabage? Or will it cause some internal initialization or whatever?
var item = new Item();
item.netDefaults(type);
item.Prefix(prefix);
if (args.Player.IsLoggedIn)
{
args.Player.PlayerData.StoreSlot(slot, type, prefix, stack);
}
else if (Main.ServerSideCharacter && TShock.Config.DisableLoginBeforeJoin && !bypassTrashCanCheck &&
args.Player.HasSentInventory && !args.Player.Group.HasPermission(Permissions.bypassssc))
{
// The player might have moved an item to their trash can before they performed a single login attempt yet.
args.Player.IgnoreActionsForClearingTrashCan = true;
}
if (slot == 58) //this is the hand
{
item.stack = stack;
args.Player.ItemInHand = item;
}
return false;
}
示例11: PickItemMovementAction
public static int PickItemMovementAction(Item[] inv, int context, int slot, Item checkItem)
{
Player player = Main.player[Main.myPlayer];
int num = -1;
if (context == 0)
num = 0;
else if (context == 1)
{
if (checkItem.itemId == 0 || checkItem.itemId == 71 || (checkItem.itemId == 72 || checkItem.itemId == 73) || checkItem.itemId == 74)
num = 0;
}
else if (context == 2)
{
if ((checkItem.itemId == 0 || checkItem.ammo > 0 || checkItem.bait > 0) && !checkItem.notAmmo || checkItem.itemId == 530)
num = 0;
}
else if (context == 3)
num = 0;
else if (context == 4)
num = 0;
else if (context == 5)
{
if (checkItem.Prefix(-3) || checkItem.itemId == 0)
num = 0;
}
else if (context == 6)
num = 0;
else if (context == 7)
{
if (checkItem.material || checkItem.itemId == 0)
num = 0;
}
else if (context == 8)
{
if (checkItem.itemId == 0 || checkItem.headSlot > -1 && slot == 0 || (checkItem.bodySlot > -1 && slot == 1 || checkItem.legSlot > -1 && slot == 2))
num = 1;
}
else if (context == 9)
{
if (checkItem.itemId == 0 || checkItem.headSlot > -1 && slot == 10 || (checkItem.bodySlot > -1 && slot == 11 || checkItem.legSlot > -1 && slot == 12))
num = 1;
}
else if (context == 10)
{
if (checkItem.itemId == 0 || checkItem.accessory && !ItemSlot.AccCheck(checkItem, slot))
num = 1;
}
else if (context == 11)
{
if (checkItem.itemId == 0 || checkItem.accessory && !ItemSlot.AccCheck(checkItem, slot))
num = 1;
}
else if (context == 12)
num = 2;
else if (context == 15)
{
if (checkItem.itemId == 0 && inv[slot].itemId > 0)
{
if (player.BuyItem(inv[slot].value))
num = 3;
}
else if (inv[slot].itemId == 0 && checkItem.itemId > 0 && (checkItem.itemId < 71 || checkItem.itemId > 74))
num = 4;
}
else if (context == 16)
{
if (checkItem.itemId == 0 || Main.projHook[checkItem.shoot])
num = 1;
}
else if (context == 17)
{
if (checkItem.itemId == 0 || checkItem.mountType != -1 && !MountID.Sets.Cart[checkItem.mountType])
num = 1;
}
else if (context == 19)
{
if (checkItem.itemId == 0 || checkItem.buffType > 0 && Main.vanityPet[checkItem.buffType] && !Main.lightPet[checkItem.buffType])
num = 1;
}
else if (context == 18)
{
if (checkItem.itemId == 0 || checkItem.mountType != -1 && MountID.Sets.Cart[checkItem.mountType])
num = 1;
}
else if (context == 20 && (checkItem.itemId == 0 || checkItem.buffType > 0 && Main.lightPet[checkItem.buffType]))
num = 1;
return num;
}
示例12: HackedInventory
public static bool HackedInventory(TSPlayer player)
{
bool check = false;
Item[] inventory = player.TPlayer.inventory;
Item[] armor = player.TPlayer.armor;
for (int i = 0; i < NetItem.maxNetInventory; i++)
{
if (i < 49)
{
Item item = new Item();
if (inventory[i] != null && inventory[i].netID != 0)
{
item.netDefaults(inventory[i].netID);
item.Prefix(inventory[i].prefix);
item.AffixName();
if (inventory[i].stack > item.maxStack)
{
check = true;
player.SendMessage(
String.Format("Stack cheat detected. Remove item {0} ({1}) and then rejoin", item.name, inventory[i].stack),
Color.Cyan);
}
}
}
else
{
Item item = new Item();
if (armor[i - 48] != null && armor[i - 48].netID != 0)
{
item.netDefaults(armor[i - 48].netID);
item.Prefix(armor[i - 48].prefix);
item.AffixName();
if (armor[i - 48].stack > item.maxStack)
{
check = true;
player.SendMessage(
String.Format("Stack cheat detected. Remove armor {0} ({1}) and then rejoin", item.name, armor[i - 48].stack),
Color.Cyan);
}
}
}
}
return check;
}
示例13: LoadChests
private static void LoadChests(BinaryReader reader)
{
Chest chest = null;
int num6;
int num7;
int num4 = reader.ReadInt16();
int num5 = reader.ReadInt16();
if (num5 < 40)
{
num6 = num5;
num7 = 0;
}
else
{
num6 = 40;
num7 = num5 - 40;
}
int index = 0;
while (index < num4)
{
chest = new Chest(false)
{
x = reader.ReadInt32(),
y = reader.ReadInt32(),
name = reader.ReadString()
};
int num3 = 0;
while (num3 < num6)
{
short num = reader.ReadInt16();
Item item = new Item();
if (num > 0)
{
item.netDefaults(reader.ReadInt32());
item.stack = num;
item.Prefix(reader.ReadByte());
}
else if (num < 0)
{
item.netDefaults(reader.ReadInt32());
item.Prefix(reader.ReadByte());
item.stack = 1;
}
chest.item[num3] = item;
num3++;
}
for (num3 = 0; num3 < num7; num3++)
{
if (reader.ReadInt16() > 0)
{
reader.ReadInt32();
reader.ReadByte();
}
}
Main.chest[index] = chest;
index++;
}
while (index < 0x3e8)
{
Main.chest[index] = null;
index++;
}
if (versionNumber < 0x73)
{
FixDresserChests();
}
}
示例14: KillTile
//.........这里部分代码省略.........
}
if (num7 != 0)
{
num6 = (num7 - 1) * 18;
}
num6 %= 54;
if (num6 == 18)
{
n = (int)Main.tile[i - 1, j].frameX;
num5--;
}
if (num6 == 36)
{
n = (int)Main.tile[i - 2, j].frameX;
num5 -= 2;
}
if (n >= 5000)
{
int num8 = n % 5000;
num8 -= 100;
int num9 = (int)Main.tile[num5 + 1, j].frameX;
if (num9 >= 25000)
{
num9 -= 25000;
}
else
{
num9 -= 10000;
}
if (Main.netMode != 1)
{
Item item = new Item();
item.netDefaults(num8);
item.Prefix(num9);
int num10 = Item.NewItem(i * 16, j * 16, 16, 16, num8, 1, true, 0, false, false);
item.position = Main.item[num10].position;
Main.item[num10] = item;
NetMessage.SendData((int)PacketTypes.ItemDrop, -1, -1, "", num10, 0f, 0f, 0f, 0, 0, 0);
}
n = (int)Main.tile[num5, j].frameX;
int num11 = 0;
while (n >= 5000)
{
n -= 5000;
num11++;
}
if (num11 != 0)
{
n = (num11 - 1) * 18;
}
Main.tile[num5, j].frameX = (short)n;
Main.tile[num5 + 1, j].frameX = (short)(n + 18);
}
}
if (tile.type == TileID.ItemFrame)
{
int num12 = TEItemFrame.Find(i - (int)(tile.frameX % 36 / 18), j - (int)(tile.frameY % 36 / 18));
if (num12 != -1 && ((TEItemFrame)TileEntity.ByID[num12]).item.stack > 0)
{
((TEItemFrame)TileEntity.ByID[num12]).DropItem();
if (Main.netMode != 2)
{
Main.blockMouse = true;
}
return;
}
示例15: DrawTiles
//.........这里部分代码省略.........
else
{
if (num264 == 2)
{
this.LoadArmorLegs(num266);
Main.spriteBatch.Draw(Main.armorLegTexture[num266], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X + num267), (float)(num263 * 16 - (int)Main.screenPosition.Y - 44)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 54)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, effects3, 0f);
}
}
}
}
if (type3 == 334 && tile7.frameX >= 5000)
{
short arg_B6AA_0 = tile7.frameY / 18;
int num269 = (int)tile7.frameX;
int num270 = 0;
int num271 = num269 % 5000;
num271 -= 100;
while (num269 >= 5000)
{
num270++;
num269 -= 5000;
}
int num272 = (int)Main.tile[num262 + 1, num263].frameX;
if (num272 >= 25000)
{
num272 -= 25000;
}
else
{
num272 -= 10000;
}
Item item = new Item();
item.netDefaults(num271);
item.Prefix(num272);
Texture2D texture2D = Main.itemTexture[item.type];
int width2 = texture2D.Width;
int height6 = texture2D.Height;
float num273 = 1f;
if (width2 > 40 || height6 > 40)
{
if (width2 > height6)
{
num273 = 40f / (float)width2;
}
else
{
num273 = 40f / (float)height6;
}
}
num273 *= item.scale;
SpriteEffects effects4 = SpriteEffects.None;
if (num270 >= 3)
{
effects4 = SpriteEffects.FlipHorizontally;
}
Color color11 = Lighting.GetColor(num262, num263);
Main.spriteBatch.Draw(texture2D, new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X + 24), (float)(num263 * 16 - (int)Main.screenPosition.Y + 8)) + zero, new Rectangle?(new Rectangle(0, 0, width2, height6)), Lighting.GetColor(num262, num263), 0f, new Vector2((float)(width2 / 2), (float)(height6 / 2)), num273, effects4, 0f);
if (item.color != default(Color))
{
Main.spriteBatch.Draw(texture2D, new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X + 24), (float)(num263 * 16 - (int)Main.screenPosition.Y + 8)) + zero, new Rectangle?(new Rectangle(0, 0, width2, height6)), item.GetColor(color11), 0f, new Vector2((float)(width2 / 2), (float)(height6 / 2)), num273, effects4, 0f);
}
}
try
{
if (type3 == 5 && tile7.frameY >= 198 && tile7.frameX >= 22)
{