public override TagCompound Save()
 {
     return(new TagCompound()
     {
         { "Item", ItemIO.Save(item) }
     });
 }
Пример #2
0
 public override TagCompound Save()
 {
     return(new TagCompound {
         { "ItemSlot", ItemIO.Save(CustomizerMod.mod.customizerUI.itemSlot.item) },
         { "DyeSlot", ItemIO.Save(CustomizerMod.mod.customizerUI.dyeSlot.item) }
     });
 }
Пример #3
0
 public override TagCompound Save()
 {
     return(new TagCompound()
     {
         { "amuletSlotItem", ItemIO.Save(amuletSlotItem) }
     });
 }
Пример #4
0
        /// <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);
        }
Пример #5
0
 public override TagCompound Save()
 {
     return(new TagCompound
     {
         ["extraSlotItem"] = ItemIO.Save(extraSlotItem)
     });
 }
        public override TagCompound Save()
        {
            TagCompound tags = base.Save();

            tags.Add("stck", ItemIO.Save(stock));
            return(tags);
        }
Пример #7
0
        public override TagCompound ExtraSave()
        {
            var tag = base.ExtraSave();

            tag.Add("fuelLeft", fuelLeft);
            tag.Add("cache", cachedFuelItem is null ? null : ItemIO.Save(cachedFuelItem));
            return(tag);
        }
Пример #8
0
        // 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(),
            });
        }
Пример #9
0
        public override TagCompound Save()
        {
            TagCompound tag = new TagCompound();

            tag["Stations"] = stations.Select(item => ItemIO.Save(item)).ToList();

            return(tag);
        }
 /// <summary>
 /// Save the mod settings.
 /// </summary>
 public override TagCompound Save()
 {
     return(new TagCompound {
         { HIDDEN_TAG, EquipWingSlot.ItemVisible },
         { WINGS_TAG, ItemIO.Save(EquipWingSlot.Item) },
         { VANITY_WINGS_TAG, ItemIO.Save(VanityWingSlot.Item) },
         { WING_DYE_TAG, ItemIO.Save(WingDyeSlot.Item) }
     });
 }
 /// <summary>
 /// Save the mod settings.
 /// </summary>
 public override TagCompound Save()
 {
     return(new TagCompound {
         { HiddenTag, EquipSlot.ItemVisible },
         { WingsTag, ItemIO.Save(EquipSlot.Item) },
         { VanityWingsTag, ItemIO.Save(VanitySlot.Item) },
         { WingDyeTag, ItemIO.Save(DyeSlot.Item) }
     });
 }
Пример #12
0
        public override TagCompound Save()
        {
            //PathOfModifiers.Log($"Save{Main.netMode}");
            TagCompound tag = new TagCompound();

            tag.Set("modifiedItem", ItemIO.Save(modifiedItem));
            tag.Set("modifierItem", ItemIO.Save(modifierItem));
            return(tag);
        }
Пример #13
0
 /// <summary>
 /// Save the mod settings.
 /// </summary>
 public override TagCompound Save()
 {
     return(new TagCompound {
         { HiddenTag, EquipShoeSlot.ItemVisible },
         { ShoesTag, ItemIO.Save(EquipShoeSlot.Item) },
         { VanityshoesTag, ItemIO.Save(VanityShoeSlot.Item) },
         { ShoeDyeTag, ItemIO.Save(ShoeDyeSlot.Item) }
     });
 }
Пример #14
0
        internal TagCompound Save()
        {
            var tag = new TagCompound();

            for (int i = 0; i < item.Length; i += 1)
            {
                tag.Add($"item{i}", ItemIO.Save(item[i]));
            }
            return(tag);
        }
Пример #15
0
        public override TagCompound Save()
        {
            TagCompound tag = new TagCompound();

            for (int i = 0; i < ballMods.Length; ++i)
            {
                tag.Add("ballItem" + i, ItemIO.Save(ballMods[i]));
            }
            return(tag);
        }
Пример #16
0
        public override TagCompound Save()
        {
            TagCompound tags = base.Save();

            if (stock.stack > 0)
            {
                tags.Add("stck", ItemIO.Save(stock));
            }
            return(tags);
        }
Пример #17
0
        /*public static EntModItem New(int type = 0, int id = 0, int level = 0){
         *  EntModItem output;
         *  switch(type){
         *      default:
         *      output = new EntModItemMod(id, level);
         *      break;
         *  }
         *  return output;
         * }
         * public void ModEffect(EntModItemMod Mod){
         *
         * }*/
        #region THXJopoIdidntthinkofLinqorknowofItemIO
        public override TagCompound Save()
        {
            TagCompound o = new TagCompound()
            {
                ["mods"] = mods.Select((i) => { return(i == null?ItemIO.Save(new Item()):ItemIO.Save(i)); }).ToList()
            };

            //for(int i = 0; i < 8; i++)o.Add("mod"+i,mods[i]);
            return(o);
        }
Пример #18
0
        public override TagCompound Save()
        {
            TagCompound         tag          = new TagCompound();
            IList <TagCompound> listStations = new List <TagCompound>();

            foreach (Item item in stations)
            {
                listStations.Add(ItemIO.Save(item));
            }
            tag["Stations"] = listStations;
            return(tag);
        }
Пример #19
0
        public override TagCompound Save()
        {
            TagCompound        tag      = base.Save();
            List <TagCompound> tagItems = new List <TagCompound>();

            foreach (Item item in items)
            {
                tagItems.Add(ItemIO.Save(item));
            }
            tag.Set("Items", tagItems);
            return(tag);
        }
Пример #20
0
        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);
            }
        }
Пример #21
0
        public TagCompound Save()
        {
            List <TagCompound> items = Items.Select((item, slot) => new TagCompound
            {
                ["Slot"] = slot,
                ["Item"] = ItemIO.Save(item),
                ["Mode"] = (byte)Modes[slot]
            }).ToList();

            return(new TagCompound
            {
                ["Items"] = items,
                ["Count"] = Slots
            });
        }
Пример #22
0
        public void TestItemSerializerCompatibility()
        {
            var item = new Item();

            item.SetDefaults(ItemID.Meowmere, true);
            item.prefix    = 4;
            item.stack     = 25;
            item.favorited = true;

            var tag = new TagCompound {
                ["item"] = ItemIO.Save(item)
            };

            AssertEqual(item, tag.Get <Item>("item"));
        }
Пример #23
0
        public override TagCompound Save()
        {
            TagCompound tag = new TagCompound();

            for (int i = 0; i < missileMods.Length; ++i)
            {
                tag.Add("missileItem" + i, ItemIO.Save(missileMods[i]));
            }

            MGlobalItem mi = item.GetGlobalItem <MGlobalItem>();

            tag.Add("statMissiles", mi.statMissiles);
            tag.Add("maxMissiles", mi.maxMissiles);

            return(tag);
        }
Пример #24
0
        public override TagCompound Save()
        {
            TagCompound s = new TagCompound();

            if (research == null || research.Count <= 0)
            {
                return(s);
            }
            if (destroyingItem == null)
            {
                destroyingItem = new Item();
            }
            research["0.research"] = ItemIO.Save(destroyingItem);
            research["0.prefix"]   = ItemIO.Save(((ResearchFrom14)ModLoader.GetMod("ResearchFrom14")).preUI.itemSlot.item);
            return(research);
        }
Пример #25
0
 public sealed override TagCompound Save()
 => new TagCompound()
 {
     ["machineInfo"] = new TagCompound()
     {
         [nameof(ReactionSpeed)]      = ReactionSpeed,
         [nameof(ReactionProgress)]   = ReactionProgress,
         [nameof(ReactionInProgress)] = ReactionInProgress
     },
     ["slots"] = new TagCompound()
     {
         //Lots of unnecessary data is saved, but that's fine due to the small amount of extra bytes used
         // TODO: refactor ItemIO.Save/ItemIO.Load to get rid of this extra info
         ["items"] = slots.Count == 0 ? null : slots.Select(i => ItemIO.Save(i)).ToList()
     },
     ["extra"] = ExtraSave()
 };
Пример #26
0
        public override TagCompound Save()
        {
            //PathOfModifiers.Log($"Save{Main.netMode}");
            TagCompound tag = new TagCompound();

            tag.Set("timeLeft", timeLeft);
            bool isBoundsNull = bounds == null;

            tag.Set("isBoundsNull", isBoundsNull);
            if (!isBoundsNull)
            {
                tag.Set("bounds", bounds);
            }

            tag.Set("map", ItemIO.Save(mapItem));

            return(tag);
        }
Пример #27
0
        public TagCompound Save(string lowercaseBookName, TagCompound tags)
        {
            string prefix;

            if (lowercaseBookName == "default")
            {
                prefix = "";
            }
            else
            {
                prefix = lowercaseBookName + "_";
            }

            tags[prefix + "page_count"] = this.Pages.Count;
            tags[prefix + "curr_page"]  = this.CurrentPageIdx;

            for (int i = 0; i < this.Pages.Count; i++)
            {
                string pageNumKey = prefix + "page_" + i;
                tags[pageNumKey + "_s"] = (bool)this.Pages[i].IsSharing;

                if (i == this.CurrentPageIdx)
                {
                    continue;
                }

                for (int j = 0; j < InventoryPage.BasePageCapacity; j++)
                {
                    string pageNumItemNumKey = pageNumKey + "_" + j;

                    try {
                        tags[pageNumItemNumKey] = ItemIO.Save(this.Pages[i].Items[j]);
                    } catch {
                        LogHelpers.Warn("Could not save item for book " + lowercaseBookName + " on page " + i + " at position " + j);
                        continue;
                    }
                }
            }

            return(tags);
        }
Пример #28
0
 public void FromItem(Item item)
 {
     this.modData = new Dictionary <string, object>();
     if (item.type > Main.maxItemTypes || item.modItem != null)
     {
         this.IsMod = true;
         this.ID    = 0;
         ToDict(ItemIO.Save(item));
     }
     else
     {
         this.IsMod = false;
         this.ID    = item.type;
     }
     this.Prefix   = item.prefix;
     this.Stack    = item.stack;
     this.Favorite = item.favorited;
     if (item.stack > item.maxStack)
     {
         item.stack = item.maxStack;
     }
 }
Пример #29
0
 public override TagCompound Save() => new TagCompound
 {
     { "item", ItemIO.Save(item) }
 };
Пример #30
0
 public TagCompound SerializeData()
 {
     return(ItemIO.Save(this));
 }