Ejemplo n.º 1
0
        static void LoadNpcData(BinBuffer bb, int v)
        {
            if (v < 1) // was borked in v0
            {
                return;
            }

            int i = 0;

            while (bb.ReadBoolean())
            {
                NPC n = Main.npc[i++];

                if (n.P_BHandler == null)
                {
                    n.P_BHandler = new NpcBHandler();
                }

                ((NpcBHandler)n.P_BHandler).Load(bb);
            }
            //while (bb.ReadBoolean())
            //{
            //    NPC n = Main.npc[i++];

            //    if (n.P_BHandler == null)
            //        n.P_BHandler = new NpcBHandler();

            //    ((NpcBHandler)n.P_BHandler).Load(bb);
            //}
        }
Ejemplo n.º 2
0
        static void LoadBehaviours(BinBuffer bb, int v)
        {
            if (v != 3) // TileBehaviour data introduced in v3
            {
                return;
            }

            while (bb.ReadBoolean())
            {
                bb.ReadInt16();
                bb.ReadInt16();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load <paramref name="slots" /> items to <paramref name="inventory" /> from the <paramref name="bb" />.
        /// </summary>
        /// <param name="bb">The reader for loading data</param>
        /// <param name="inventory">The array of items</param>
        /// <param name="slots">The amount of items in the inventory to load</param>
        /// <param name="stack">Whether or not the stack size should be loaded</param>
        /// <param name="favourited">Whether or not the favourited state should be loaded</param>
        static void LoadItemSlots(BinBuffer bb, Item[] inventory, int slots, bool stack, bool favourited)
        {
            for (int i = 0; i < slots; i++)
            {
                // Load basic item data
                string mod = bb.ReadString();
                if (!String.IsNullOrEmpty(mod) && mod != PrismApi.VanillaString)
                {
                    string item = bb.ReadString();

                    if (!ModData.modsFromInternalName.ContainsKey(mod) || !ModData.modsFromInternalName[mod].ItemDefs.ContainsKey(item))
                    {
                        inventory[i].SetDefaults(ItemDefHandler.UnknownItemID);

                        inventory[i].toolTip  = mod;
                        inventory[i].toolTip2 = item;
                    }
                    else
                    {
                        inventory[i].SetDefaults(ModData.modsFromInternalName[mod].ItemDefs[item].Type);
                    }

                    if (stack)
                    {
                        inventory[i].stack = bb.ReadInt32();
                    }
                    inventory[i].prefix = bb.ReadByte();
                    if (favourited)
                    {
                        inventory[i].favorited = bb.ReadBoolean();
                    }
                }

                // Load Mod Data
                if (inventory[i].P_BHandler == null)
                {
                    inventory[i].P_BHandler = new ItemBHandler();

                    ((ItemBHandler)inventory[i].P_BHandler).Create();
                }

                ((ItemBHandler)inventory[i].P_BHandler).Load(bb);
            }
        }