internal void Load(TagCompound tag) { for (int i = 0; i < item.Length; i += 1) { item[i] = ItemIO.Load(tag.GetCompound($"item{i}")); } }
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); }
/// <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) { Tervania.instance.ui.Refresh(); SetESoul(ItemIO.Load(tag.GetCompound(EnchantedSoulTag))); SetBSoul(ItemIO.Load(tag.GetCompound(BulletSoulTag))); SetGSoul(ItemIO.Load(tag.GetCompound(GuardianSoulTag))); }
public override void Load(TagCompound tag) { amuletSlotItem = ItemIO.Load(tag.GetCompound("amuletSlotItem")); // Load to slot Decimation.amuletSlotState.LoadItem(amuletSlotItem); }
/// <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 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 Load(TagCompound tag) { if (tag.ContainsKey("stck")) { stock = ItemIO.Load((TagCompound)tag["stck"]); } base.Load(tag); }
public static void DrawItemInPipe(ItemNetworkPath path, SpriteBatch spriteBatch) { //We need to emulate drawing items in the world, but shrinked into the bounds of a pipe Item item = ItemIO.Load(path.itemData); var offset = MiscUtils.GetLightingDrawOffset(); spriteBatch.DrawItemInWorld(item, path.worldCenter - Main.screenPosition + offset, new Vector2(3.85f * 2)); }
public override void Load(TagCompound tag) { IList <TagCompound> listStations = tag.GetList <TagCompound>("Stations"); if (listStations != null && listStations.Any()) { stations = listStations.Select(item => ItemIO.Load(item)).ToArray(); } }
public override void Load(TagCompound tag) { if (tag.ContainsKey("Item")) { item = ItemIO.Load((TagCompound)tag["Item"]); } else if (tag.ContainsKey("ID")) { item.SetDefaults((int)tag["ID"]); } }
public override void Load(TagCompound tag) { IList <TagCompound> listStations = tag.GetList <TagCompound>("Stations"); if (listStations != null && listStations.Count > 0) { for (int k = 0; k < stations.Length; k++) { stations[k] = ItemIO.Load(listStations[k]); } } }
public void InputItemFromNetwork(ItemNetworkPath incoming, out bool sendBack) { Item data = ItemIO.Load(incoming.itemData); sendBack = true; if (!CanBeInput(data)) { return; } int[] inputSlots = GetInputSlots(); foreach (int slot in inputSlots) { Item slotItem = this.RetrieveItem(slot); if (slotItem.IsAir || slotItem.type == data.type) { if (slotItem.IsAir) { slots[slot] = data.Clone(); if (ParentState?.Active ?? false) { ParentState.LoadToSlots(slots); } slotItem = this.RetrieveItem(slot); slotItem.stack = 0; } if (slotItem.stack + data.stack > slotItem.maxStack) { data.stack -= slotItem.maxStack - slotItem.stack; slotItem.stack = slotItem.maxStack; } else { slotItem.stack += data.stack; data.stack = 0; sendBack = false; break; } } } if (sendBack) { incoming.itemData = ItemIO.Save(data); } }
public override void Load(TagCompound tag) { // legacy load int type = tag.GetInt("extraSlotItem_Type"); if (type != 0) { extraSlotItem.SetDefaults(type); } if (tag.GetCompound("extraSlotItem") is TagCompound item && item != new TagCompound()) { extraSlotItem = ItemIO.Load(item); } }
public override void Load(TagCompound tag) { base.Load(tag); ClearItemsData(); foreach (TagCompound tagItem in tag.GetList <TagCompound>("Items")) { Item item = ItemIO.Load(tagItem); items.Add(item); ItemData data = new ItemData(item); if (item.stack < item.maxStack) { hasSpaceInStack.Add(data); } hasItem.Add(data); } }
public void Load(TagCompound tag) { SetSize(tag.ContainsKey("Count") ? tag.GetInt("Count") : Slots); foreach (TagCompound compound in tag.GetList <TagCompound>("Items")) { Item item = ItemIO.Load(compound.GetCompound("Item")); int slot = compound.GetInt("Slot"); SlotMode mode = (SlotMode)compound.GetByte("Mode"); if (slot >= 0 && slot < Slots) { Items[slot] = item; Modes[slot] = mode; } } }
// Returns -1 for missing recipe, index of recipe otherwise public static int Load(TagCompound tag) { Item createItem = ItemIO.Load(tag.Get <TagCompound>("createItem")); List <Item> requiredItems = tag.GetList <TagCompound>("requiredItem").Select(ItemIO.Load).ToList(); for (int i = 0; i < Recipe.numRecipes; i++) { Recipe recipe = Main.recipe[i]; if (recipe.createItem.type == createItem.type) { HashSet <int> tagIngredients = new HashSet <int>(requiredItems.Where(x => !x.IsAir).Select(x => x.type)); HashSet <int> recipeIngredients = new HashSet <int>(recipe.requiredItem.Where(x => !x.IsAir).Select(x => x.type)); if (tagIngredients.SetEquals(recipeIngredients)) { return(i); } } } return(-1); }
public override void Load(TagCompound tag) { base.Load(tag); ClearItemsData(); foreach (TagCompound tagItem in tag.GetList <TagCompound>("Items")) { Item item = ItemIO.Load(tagItem); items.Add(item); ItemData data = new ItemData(item); if (item.stack < item.maxStack) { hasSpaceInStack.Add(data); } hasItem.Add(data); } if (Main.netMode == NetmodeID.Server) { netQueue.Enqueue(UnitOperation.FullSync.Create()); } }
public override void Load(TagCompound tag) { //PathOfModifiers.Log($"Load{Main.netMode}"); timeLeft = tag.GetInt("timeLeft"); bool isBoundsNull = tag.GetBool("isBoundsNull"); bounds = isBoundsNull ? null : (Rectangle?)tag.Get <Rectangle>("bounds"); if (timeLeft > 0 && bounds.HasValue) { MapBorder.AddActiveBounds(bounds.Value); } mapItem = ItemIO.Load(tag.GetCompound("map")); if (Main.netMode != 2) { MapDeviceUI.Instance.UpdateText(); } }
public sealed override void Load(TagCompound tag) { TagCompound info = tag.GetCompound("machineInfo"); ReactionSpeed = info.GetFloat(nameof(ReactionSpeed)); ReactionProgress = info.GetFloat(nameof(ReactionProgress)); ReactionInProgress = info.GetBool(nameof(ReactionInProgress)); TagCompound tagSlots = tag.GetCompound("slots"); List <TagCompound> items = tagSlots.GetList <TagCompound>("items") as List <TagCompound> ?? new List <TagCompound>(); foreach (var c in items) { slots.Add(ItemIO.Load(c)); } TagCompound extra = tag.GetCompound("extra"); if (extra != null) { ExtraLoad(extra); } }
public override void Load(TagCompound tag) => item = ItemIO.Load(tag.GetCompound("item"));
public void Load(string lowercaseBookName, TagCompound tags) { string prefix; if (lowercaseBookName == "default") { prefix = ""; } else { prefix = lowercaseBookName + "_"; } if (ExtensibleInventoryMod.Instance.Config.DebugModeReset) { return; } if (!tags.ContainsKey(prefix + "page_count") || !tags.ContainsKey(prefix + "curr_page")) { return; } this.Pages.Clear(); //bool foundSharing = false; int pages = tags.GetInt(prefix + "page_count"); int currPage = tags.GetInt(prefix + "curr_page"); for (int i = 0; i < pages; i++) { InventoryPage page = new InventoryPage(); this.Pages.Add(page); string pageNumKey = prefix + "page_" + i; //foundSharing = tags.ContainsKey( pageNumKey + "_s" ); // //if( foundSharing ) { // page.IsSharing = tags.GetBool( pageNumKey + "_s" ); //} if (i == currPage) { continue; } for (int j = 0; j < InventoryPage.BasePageCapacity; j++) { string pageNumItemNumKey = pageNumKey + "_" + j; if (tags.ContainsKey(pageNumItemNumKey)) { try { page.Items[j] = ItemIO.Load(tags.GetCompound(pageNumItemNumKey)); } catch (Exception e) { string err = "Could not load item for book " + lowercaseBookName + " on page " + i + " at position " + j + "; please report this issue in the forum thread with your .tplr file."; if (ExtensibleInventoryMod.Instance.Config.DebugModeSkipLoadErrors) { LogHelpers.Warn(err); } else { throw new ModHelpersException(err, e); } } } else { page.Items[j] = new Item(); } //if( !foundSharing && tags.ContainsKey( pageNumItemNumKey+"_s" ) ) { // Oops! // foundSharing = true; // page.IsSharing = tags.GetBool( pageNumItemNumKey + "_s" ); //} } } this.CurrentPageIdx = currPage; }
public override void Load(TagCompound tag) { //PathOfModifiers.Log($"Load{Main.netMode}"); modifiedItem = ItemIO.Load(tag.GetCompound("modifiedItem")); modifierItem = ItemIO.Load(tag.GetCompound("modifierItem")); }
/// <summary> /// Attempts to move the item in this object along the <seealso cref="itemNetwork"/> /// </summary> public void Update() { oldCenter = worldCenter; var newTilePos = worldCenter.ToTileCoordinates16(); if (delayPathCalc && itemNetwork.HasEntryAt(newTilePos)) { delayPathCalc = false; } CalculatePath(); MoveAlongNetwork(); newTilePos = worldCenter.ToTileCoordinates16(); Tile sourceTile = Framing.GetTileSafely(newTilePos); if (ModContent.GetModTile(sourceTile.type) is ItemPumpTile pump) { //Force the move direction to be away from the pump moveDir = -(pump.GetBackwardsOffset(newTilePos) - newTilePos).ToVector2(); } if (!delayPathCalc && (!sourceTile.active() || !itemNetwork.HasEntryAt(newTilePos))) { Item data = ItemIO.Load(itemData); //If the tile is a machine or chest, try to put this item in there Chest chest = null; MachineEntity entity = null; bool sendBack = true; if ((entity = FindConnectedMachine(itemNetwork, newTilePos, data)) != null || (chest = FindConnectedChest(itemNetwork, newTilePos, data, out _)) != null) { if (chest is Chest) { sendBack = !chest.TryInsertItems(data); if (sendBack) { itemData = ItemIO.Save(data); } } else { entity.InputItemFromNetwork(this, out sendBack); } if (!sendBack) { itemNetwork.RemovePath(this.id); } else { //Send the item back into the network and force it to create a new path needsPathRefresh = true; moveDir *= -1; delayPathCalc = true; } } else { if (FindConnectedChest(itemNetwork, newTilePos, data, out _) is null && !(TileEntityUtils.TryFindMachineEntity(newTilePos + new Point16(0, -1), out _) || TileEntityUtils.TryFindMachineEntity(newTilePos + new Point16(-1, 0), out _) || TileEntityUtils.TryFindMachineEntity(newTilePos + new Point16(0, 1), out _) || TileEntityUtils.TryFindMachineEntity(newTilePos + new Point16(1, 0), out _))) { SpawnInWorld(); } else { wander = true; moveDir *= -1; delayPathCalc = true; needsPathRefresh = true; worldCenter = itemNetwork.GetEntries().Select(pipe => pipe.Position).OrderBy(p => Vector2.DistanceSquared(p.ToWorldCoordinates(), worldCenter)).First().ToWorldCoordinates(); } }
public override void Load(TagCompound tag) { CustomizerMod.mod.customizerUI.itemSlot.item = ItemIO.Load(tag.GetCompound("ItemSlot")); CustomizerMod.mod.customizerUI.dyeSlot.item = ItemIO.Load(tag.GetCompound("DyeSlot")); }
public override void ExtraLoad(TagCompound tag) { base.ExtraLoad(tag); fuelLeft = tag.GetFloat("fuelLeft"); cachedFuelItem = tag.GetCompound("cache") is TagCompound cache?ItemIO.Load(cache) : null; }