示例#1
0
        public void ReadDictionary(BinBuffer bb)
        {
            int modAmt = bb.ReadByte();

            for (int i = 0; i < modAmt; i++)
            {
                Mods.Add(bb.ReadString(), bb.ReadByte());
            }

            for (int i = 0; i < modAmt; i++)
            {
                ModID mid = bb.ReadByte();

                var modObjs = new BiDictionary <ObjName, ObjID>();

                short objAmt = bb.ReadInt16();

                for (int j = 0; j < objAmt; j++)
                {
                    modObjs.Add(bb.ReadString(), bb.ReadUInt16());
                }

                ModObjects.Add(mid, modObjs);
            }
        }
示例#2
0
 public void Write(BinBuffer bb, int count)
 {
     for (int i = 0; i < count; i++)
     {
         Write(bb.ReadByte());
     }
 }
示例#3
0
        static void LoadChestItems(BinBuffer bb, int v)
        {
            int chestAmt = bb.ReadInt16();
            int items    = bb.ReadByte();

            for (int i = 0; i < chestAmt; i++)
            {
                LoadItemSlots(bb, Main.chest[i].item, items, true, false);
            }
        }
示例#4
0
        static int  LoadPrismData(BinBuffer bb)
        {
            var v = bb.ReadByte();

            if (v > WORLD_VERSION)
            {
                throw new FileFormatException("Tried to load world file from a future version of Prism.");
            }
            if (v < MIN_WORLD_SUPPORT_VER)
            {
                throw new FileFormatException("This world is saved in a format that is too old and unsupported.");
            }

            return(v);
        }
示例#5
0
        static void LoadTileData(BinBuffer bb, int v)
        {
            if (v < 4)
            {
                return;
            }

            TileDataEntryFlags fl;

            while ((fl = (TileDataEntryFlags)bb.ReadByte()) != TileDataEntryFlags.Finished)
            {
                var x = bb.ReadInt16();
                var y = bb.ReadInt16();
                var p = new Point16(x, y);
                var t = Main.tile[x, y].type;

                var bs = TileHooks.CreateBHandler(p);

                if ((fl & TileDataEntryFlags.Tile) != 0)
                {
                    var bh = bs.Item1;

                    foreach (var b in bh.behaviours)
                    {
                        b.HasTile  = true;
                        b.Position = p;
                    }

                    bh.Load(bb);
                }
                if ((fl & TileDataEntryFlags.Type) != 0)
                {
                    var bh = bs.Item2;

                    foreach (var b in bh.behaviours)
                    {
                        b.HasTile  = true;
                        b.Position = p;
                    }

                    bh.Load(bb);
                }
            }
        }
示例#6
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);
            }
        }