public Item ToItem() { Item item = new Item(); if (IsMod) { TagCompound tag = new TagCompound(); foreach (var pair in modData) { tag.Add(pair.Key, pair.Value); } item = ItemIO.Load(tag); } else { item.netDefaults(ID); } item.Prefix(Prefix); item.stack = Stack; item.favorited = Favorite; if (item.stack < 0) { item.stack = 0; } else if (item.stack > item.maxStack) { item.stack = item.maxStack; } return(item); }
public override void NetReceive(BinaryReader reader, bool lightReceive) { //PathOfModifiers.Instance.Logger.Info($"NetReceive: {Main.netMode}"); var newTimeLeft = reader.ReadInt32(); bool isBoundsNull = reader.ReadBoolean(); var newBounds = isBoundsNull ? null : (Rectangle?)reader.ReadRectangle(); mapItem = ItemIO.Receive(reader, true); if (timeLeft == 0 && newTimeLeft != 0) { MapBorder.AddActiveBounds(newBounds.Value); } else if (timeLeft != 0 && newTimeLeft == 0) { MapBorder.RemoveActiveBounds(bounds.Value); } timeLeft = newTimeLeft; bounds = newBounds; if (Main.netMode == NetmodeID.MultiplayerClient) { if (MapDevice.activeMD?.Position == Position) { MapDeviceUI.ShowUI(this); } } }
/// <summary> /// Load the mod settings. /// </summary> public override void Load(TagCompound tag) { Tervania.instance.ui.Refresh(); SetESoul(ItemIO.Load(tag.GetCompound(EnchantedSoulTag))); SetBSoul(ItemIO.Load(tag.GetCompound(BulletSoulTag))); SetGSoul(ItemIO.Load(tag.GetCompound(GuardianSoulTag))); }
internal void Load(TagCompound tag) { for (int i = 0; i < item.Length; i += 1) { item[i] = ItemIO.Load(tag.GetCompound($"item{i}")); } }
public override TagCompound Save() { return(new TagCompound() { { "Item", ItemIO.Save(item) } }); }
public override TagCompound Save() { return(new TagCompound { { "ItemSlot", ItemIO.Save(CustomizerMod.mod.customizerUI.itemSlot.item) }, { "DyeSlot", ItemIO.Save(CustomizerMod.mod.customizerUI.dyeSlot.item) } }); }
public override void Load(TagCompound tag) { amuletSlotItem = ItemIO.Load(tag.GetCompound("amuletSlotItem")); // Load to slot Decimation.amuletSlotState.LoadItem(amuletSlotItem); }
public void Save() { if (!isServer) { return; } // Save all tile layers to file. TileMap.SaveAll(); // Save the player inventory: // This will only save the host's inventory. TODO support other clients saving inventory data. InventoryIO.SaveInventory(RealityName); // Save current gear held and worn by local player. TODO see above. InventoryIO.SaveGear(RealityName, Player.Local); // Save currently held item. TODO see above. InventoryIO.SaveHolding(RealityName, Player.Local); // Save player state (position, health, etc.) PlayerIO.SavePlayerState(RealityName, Player.Local); // Save all world items to file. ItemIO.ItemsToFile(RealityName, GameObject.FindObjectsOfType <Item>()); // Save placed furniture... FurnitureIO.SaveFurniture(RealityName, Furniture.GetAllFurniture()); // Save the building inventory... BuildingIO.SaveBuildingInventory(RealityName, Player.Local); // Save the world state to file. WorldIO.SaveWorldState(this); }
public override TagCompound Save() { return(new TagCompound() { { "amuletSlotItem", ItemIO.Save(amuletSlotItem) } }); }
public override void HandleCommand(BinaryReader reader, int playerNumber) { if (Main.netMode == 2) { string name = reader.ReadString(); var id = reader.ReadByte(); var nettype = reader.ReadInt16(); var prefix = reader.ReadByte(); var stack = reader.ReadInt16(); var player = ServerSideCharacter2.PlayerCollection.Get(name); var sender = Main.player[playerNumber].GetServerPlayer(); Item item = new Item(); item.SetDefaults(nettype); item.Prefix(prefix); item.stack = stack; ItemIO.ReceiveModData(item, reader); if (player == null) { sender.SendInfoMessage("玩家不存在", Color.Red); return; } lock (player) { if (stack < 0) { stack = 0; } player.SetInventory(id, item); } } }
public override void HandleCommand(BinaryReader reader, int playerNumber) { if (Main.netMode == 2) { int plr = reader.ReadByte(); var id = reader.ReadInt16(); var nettype = reader.ReadInt16(); var prefix = reader.ReadByte(); var stack = reader.ReadInt16(); var player = Main.player[plr]; Item item = new Item(); item.SetDefaults(nettype); item.Prefix(prefix); item.stack = stack; ItemIO.ReceiveModData(item, reader); if (!player.active) { return; } var splayer = player.GetServerPlayer(); lock (player) { if (stack < 0) { stack = 0; } int k = setItem(player, id, item); NetMessage.SendData(5, -1, -1, null, plr, k, (float)prefix, 0f, 0, 0, 0); } } }
public void Drag() { if (!slot.isSlots()) { return; } if (!isDrag && Vector2.Distance((Vector2)Input.mousePosition, firMousePos) >= min) { // 처음에 드래그 일정 거리 이상 했을 경우 isDrag = true; ObjManager.objManager.inventory.RenewInfo(); img.gameObject.SetActive(true); emptyImg.sprite = slot.ItemReturn().sprite; slot.UpdateInfo(true, slot.DefaultImg); gameObject.transform.GetChild(0).gameObject.GetComponent <Image>().color = Color.white; if (!ItemIO.isItemGot(slot.item.ID)) { emptyImg.color = Color.black; } else { emptyImg.color = Color.white; } } if (img.gameObject.activeInHierarchy) { img.transform.position = Input.mousePosition; } }
public override void NetSend(BinaryWriter writer, bool lightSend) { foreach (Item item in stations) { ItemIO.Send(item, writer, true, false); } }
/// <summary> /// Creates a new <seealso cref="ItemNetworkPath"/> object /// </summary> /// <param name="item">The item to be sent into the network</param> /// <param name="network">The network the item is being sent into</param> /// <param name="pumpSource">The tile location of the item pump</param> public static ItemNetworkPath CreateObject(Item item, ItemNetwork network, Point16 pumpSource, List <Point16> pathOverride = null) { if (!network.HasEntryAt(pumpSource)) { return(null); } if (item.IsAir) { return(null); } ItemNetworkPath path = new ItemNetworkPath() { itemData = ItemIO.Save(item), itemNetwork = network, worldCenter = pumpSource.ToWorldCoordinates() }; if (pathOverride?.Count > 0) { path.currentPath = new Queue <Point16>(pathOverride); path.needsPathRefresh = false; path.dequeuedPoint = path.currentPath.Dequeue(); } return(path); }
public static void GetGuardianEquippedItem(BinaryReader reader, int WhoAmI) { byte PlayerID = reader.ReadByte(); int MyGuardianPosID = reader.ReadInt32(); int Slot = reader.ReadInt32(); int NetId = reader.ReadInt32(); byte Prefix = (byte)(NetId == 0 ? 0 : reader.ReadByte()); int Stack = (NetId == 0 ? 0 : reader.ReadInt32()); Item i = new Item(); i.netDefaults(NetId); i.Prefix(Prefix); i.stack = Stack; ItemIO.ReceiveModData(i, reader); Player player = Main.player[PlayerID]; if (PlayerID == Main.myPlayer) { return; } PlayerMod pm = player.GetModPlayer <PlayerMod>(); if (!pm.MyGuardians.ContainsKey(MyGuardianPosID)) { return; } pm.MyGuardians[MyGuardianPosID].Equipments[Slot] = i; if (Main.netMode == 2) { SendGuardianEquippedItem(pm, MyGuardianPosID, Slot, -1, WhoAmI); } }
public const int InvenMax = 6; // 애기 당 최대 인벤토리 슬롯 수 /* 슬롯 번호 * 0 ~ 5 0번 애기 * 6 ~ 11 1번 애기 * 12 ~ 17 2번 애기 */ private void Start() // 인벤토리 상황 불러와서 UI 설정하기 { /* 설명 슬롯 버튼 가져오기 */ checkBtn = InfoSlot.Find("BtnCheck").GetComponent <Button>(); useBtn = InfoSlot.Find("BtnUse").GetComponent <Button>(); trashBtn = InfoSlot.Find("BtnThrow").GetComponent <Button>(); /* 슬롯들 리스트에 저장하기 */ for (int i = 0; i < SlotsParent.transform.childCount; i++) { slots.Add(SlotsParent.transform.GetChild(i).gameObject); slots[i].GetComponent <Slot>().SetChildNum(i / 6); } /* xml에서 아이템 데이터 가져오기 */ Item[] items = ItemIO.LoadData(); if (items != null) { for (int i = 0; i < items.Length; i++) { Slot slot = slots[i].GetComponent <Slot>(); try { slot.AddItem(items[i]); } catch (Exception ex) { } } RenewInventory(); } }
/// <summary> /// Load the mod settings. /// </summary> public override void Load(TagCompound tag) { SetWings(false, ItemIO.Load(tag.GetCompound(WINGS_TAG))); SetWings(true, ItemIO.Load(tag.GetCompound(VANITY_WINGS_TAG))); SetDye(ItemIO.Load(tag.GetCompound(WING_DYE_TAG))); EquipWingSlot.ItemVisible = tag.GetBool(HIDDEN_TAG); }
/// <summary> /// Load the mod settings. /// </summary> public override void Load(TagCompound tag) { SetWings(false, ItemIO.Load(tag.GetCompound(WingsTag))); SetWings(true, ItemIO.Load(tag.GetCompound(VanityWingsTag))); SetDye(ItemIO.Load(tag.GetCompound(WingDyeTag))); EquipSlot.ItemVisible = tag.GetBool(HiddenTag); }
public override TagCompound Save() { return(new TagCompound { ["extraSlotItem"] = ItemIO.Save(extraSlotItem) }); }
public override void NetSend(BinaryWriter writer) { writer.Write(BitsByte.ComposeBitsBytesChain(false, _items.Select(i => !i.IsAir).ToArray())[0]); writer.Write(BitsByte.ComposeBitsBytesChain(false, _dyes.Select(i => !i.IsAir).ToArray())[0]); for (int i = 0; i < 8; i++) { var item = _items[i]; if (!item.IsAir) { ItemIO.Send(item, writer, true); } } for (int i = 0; i < 8; i++) { var dye = _dyes[i]; if (!dye.IsAir) { ItemIO.Send(dye, writer, true); } } }
public static void ReceiveStationResult(BinaryReader reader) { if (Main.netMode != 1) { return; } Player player = Main.player[Main.myPlayer]; byte op = reader.ReadByte(); Item item = ItemIO.Receive(reader, true); if (op == 2 && Main.playerInventory && Main.mouseItem.IsAir) { Main.mouseItem = item; item = new Item(); } else if (op == 2 && Main.playerInventory && Main.mouseItem.type == item.type) { int total = Main.mouseItem.stack + item.stack; if (total > Main.mouseItem.maxStack) { total = Main.mouseItem.maxStack; } int difference = total - Main.mouseItem.stack; Main.mouseItem.stack = total; item.stack -= total; } if (item.stack > 0) { item = player.GetItem(Main.myPlayer, item, false, true); if (!item.IsAir) { player.QuickSpawnClonedItem(item, item.stack); } } }
internal static bool WriteHotbar(List <UIItemSlot> itemSlots, BinaryWriter writer, bool writeStack = false, bool writeFavorite = false) { ushort count = 0; byte[] data; using (MemoryStream stream = new MemoryStream()) { using (BinaryWriter w = new BinaryWriter(stream)) { for (int i = 0; i < itemSlots.Count; i++) { w.Write((ushort)i); ItemIO.WriteItem(itemSlots[i].item, w, writeStack, writeFavorite); count++; } } data = stream.ToArray(); } if (count > 0) { writer.Write(count); writer.Write(data); return(true); } return(false); }
public override TagCompound Save() { TagCompound tags = base.Save(); tags.Add("stck", ItemIO.Save(stock)); return(tags); }
public override void Load(TagCompound tag) { research = tag; if (research == null) { research = new TagCompound(); } if (research.ContainsKey("0.research")) { destroyingItem = ItemIO.Load(research.GetCompound("0.research")); research.Remove("0.research"); } if (research.ContainsKey("0.prefix")) { ((ResearchFrom14)ModLoader.GetMod("ResearchFrom14")).preUI.itemSlot.item = ItemIO.Load(research.GetCompound("0.prefix")); ((ResearchFrom14)ModLoader.GetMod("ResearchFrom14")).preUI.itemSlot.realItem = ((ResearchFrom14)ModLoader.GetMod("ResearchFrom14")).preUI.itemSlot.item; research.Remove("0.prefix"); } if (!research.ContainsKey(ResearchFrom14.ItemIDToTag(ModContent.ItemType <ResearchSharingBook>())) || !research.ContainsKey(ResearchFrom14.ItemIDToTag(ModContent.ItemType <ResearchErasingBook>()))) { research[ResearchFrom14.ItemIDToTag(ModContent.ItemType <ResearchSharingBook>())] = Int32.MaxValue - 1000; research[ResearchFrom14.ItemIDToTag(ModContent.ItemType <ResearchErasingBook>())] = Int32.MaxValue - 1000; } researchedCache = new List <int>(); researchedTileCache = new List <int>(); researchedTileAdj = new bool[TileLoader.TileCount]; mod.Logger.Info("Player " + player.name + " knows " + research.Count + " Items"); populateCache = Task.Run(actualRebuildCache); }
public override void NetReceive(BinaryReader reader, bool lightReceive) { for (int k = 0; k < stations.Length; k++) { stations[k] = ItemIO.Receive(reader, true, false); } }
protected override bool PreReceive(BinaryReader reader, int fromWho) { bool result = base.PreReceive(reader, fromWho); if (!ModPlayer.Initialized) { ModPlayer.Init(); } for (int i = 1; i < ModPlayer.Inventory.Page.Length; i += 1) { for (int j = 0; j < ModPlayer.Inventory.Page[i].item.Length; j += 1) { ModPlayer.Inventory.Page[i].item[j] = ItemIO.Receive(reader, true, true); } } foreach (AlignmentStat stat in ModPlayer.Character.AlignmentStats.Values) { if (stat.DoSave) { stat.BaseAmount = reader.ReadInt32(); } } foreach (MinorStat stat in ModPlayer.Character.MinorStats.Values) { if (stat.DoSave) { stat.BaseAmount = reader.ReadSingle(); } } return(result); }
protected override void SendData(BinaryWriter writer, TEStorageUnit unit) { writer.Write(unit.items.Count); foreach (Item item in unit.items) { ItemIO.Send(item, writer, true, false); } }
public override void Load(TagCompound tag) { if (tag.ContainsKey("stck")) { stock = ItemIO.Load((TagCompound)tag["stck"]); } base.Load(tag); }
// Unused slim TagCompound for just the definition of an item. //public static TagCompound SaveItemDefinition(Item item) //{ // var tag = new TagCompound(); // if (item.type <= 0) // return tag; // if (item.modItem == null) // { // tag.Set("mod", "Terraria"); // tag.Set("id", item.netID); // } // else // { // tag.Set("mod", item.modItem.mod.Name); // tag.Set("name", item.modItem.Name); // tag.Set("data", item.modItem.Save()); // } // return tag; //} // Necessary? Tile needed? public static TagCompound Save(Recipe recipe) { return(new TagCompound { ["createItem"] = ItemIO.Save(recipe.createItem), ["requiredItem"] = recipe.requiredItem.Where(x => !x.IsAir).Select(ItemIO.Save).ToList(), }); }
public override void SaveCustomData(BinaryWriter writer) { writer.Write((ushort)items.Count); foreach (Item item in items) { ItemIO.WriteItem(item, writer, true); } }