Esempio n. 1
0
        // Token: 0x060024E7 RID: 9447 RVA: 0x000D38C0 File Offset: 0x000D1CC0
        public static void save()
        {
            Block block = new Block();

            block.writeByte(LevelItems.SAVEDATA_VERSION);
            block.writeByte((byte)LevelItems.tables.Count);
            byte b = 0;

            while ((int)b < LevelItems.tables.Count)
            {
                ItemTable itemTable = LevelItems.tables[(int)b];
                block.writeColor(itemTable.color);
                block.writeString(itemTable.name);
                block.writeUInt16(itemTable.tableID);
                block.write((byte)itemTable.tiers.Count);
                byte b2 = 0;
                while ((int)b2 < itemTable.tiers.Count)
                {
                    ItemTier itemTier = itemTable.tiers[(int)b2];
                    block.writeString(itemTier.name);
                    block.writeSingle(itemTier.chance);
                    block.writeByte((byte)itemTier.table.Count);
                    byte b3 = 0;
                    while ((int)b3 < itemTier.table.Count)
                    {
                        ItemSpawn itemSpawn = itemTier.table[(int)b3];
                        block.writeUInt16(itemSpawn.item);
                        b3 += 1;
                    }
                    b2 += 1;
                }
                b += 1;
            }
            ReadWrite.writeBlock(Level.info.path + "/Spawns/Items.dat", false, false, block);
            River river = new River(Level.info.path + "/Spawns/Jars.dat", false);

            river.writeByte(LevelItems.SAVEDATA_VERSION);
            for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1)
            {
                for (byte b5 = 0; b5 < Regions.WORLD_SIZE; b5 += 1)
                {
                    List <ItemSpawnpoint> list = LevelItems.spawns[(int)b4, (int)b5];
                    river.writeUInt16((ushort)list.Count);
                    ushort num = 0;
                    while ((int)num < list.Count)
                    {
                        ItemSpawnpoint itemSpawnpoint = list[(int)num];
                        river.writeByte(itemSpawnpoint.type);
                        river.writeSingleVector3(itemSpawnpoint.point);
                        num += 1;
                    }
                }
            }
            river.closeRiver();
        }
 // Token: 0x06003478 RID: 13432 RVA: 0x00157D04 File Offset: 0x00156104
 private static void exportItems(string path, Data spawnsData, ref ushort id, bool isLegacy)
 {
     for (int i = 0; i < LevelItems.tables.Count; i++)
     {
         ItemTable itemTable = LevelItems.tables[i];
         if (itemTable.tableID == 0)
         {
             itemTable.tableID = id;
             spawnsData.writeString(id.ToString(), Level.info.name + "_" + itemTable.name);
             Data data = new Data();
             data.writeString("Type", "Spawn");
             Data   data2 = data;
             string key   = "ID";
             ushort value;
             id = (value = id) + 1;
             data2.writeUInt16(key, value);
             if (ReadWrite.fileExists(string.Concat(new string[]
             {
                 "/Bundles/Spawns/Items/",
                 itemTable.name,
                 "/",
                 itemTable.name,
                 ".dat"
             }), false, true))
             {
                 Data data3 = ReadWrite.readData(string.Concat(new string[]
                 {
                     "/Bundles/Spawns/Items/",
                     itemTable.name,
                     "/",
                     itemTable.name,
                     ".dat"
                 }), false, true);
                 data.writeInt32("Tables", 1);
                 data.writeUInt16("Table_0_Spawn_ID", data3.readUInt16("ID"));
                 data.writeInt32("Table_0_Weight", 100);
             }
             else
             {
                 data.writeInt32("Tables", 1);
                 data.writeUInt16("Table_0_Spawn_ID", id);
                 data.writeInt32("Table_0_Weight", 100);
                 spawnsData.writeString(id.ToString(), itemTable.name);
                 Data data4 = new Data();
                 data4.writeString("Type", "Spawn");
                 Data   data5 = data4;
                 string key2  = "ID";
                 id = (value = id) + 1;
                 data5.writeUInt16(key2, value);
                 if (isLegacy)
                 {
                     if (itemTable.tiers.Count > 1)
                     {
                         float num = float.MaxValue;
                         for (int j = 0; j < itemTable.tiers.Count; j++)
                         {
                             ItemTier itemTier = itemTable.tiers[j];
                             if (itemTier.chance < num)
                             {
                                 num = itemTier.chance;
                             }
                         }
                         int num2 = Mathf.CeilToInt(10f / num);
                         data4.writeInt32("Tables", itemTable.tiers.Count);
                         for (int k = 0; k < itemTable.tiers.Count; k++)
                         {
                             ItemTier itemTier2 = itemTable.tiers[k];
                             bool     flag      = SpawnTableTool.isVariantItemTier(itemTier2);
                             if (flag && ReadWrite.fileExists(string.Concat(new string[]
                             {
                                 "/Bundles/Spawns/Items/",
                                 itemTier2.name,
                                 "/",
                                 itemTier2.name,
                                 ".dat"
                             }), false, true))
                             {
                                 Data data6 = ReadWrite.readData(string.Concat(new string[]
                                 {
                                     "/Bundles/Spawns/Items/",
                                     itemTier2.name,
                                     "/",
                                     itemTier2.name,
                                     ".dat"
                                 }), false, true);
                                 data4.writeUInt16("Table_" + k + "_Spawn_ID", data6.readUInt16("ID"));
                                 data4.writeInt32("Table_" + k + "_Weight", (int)(itemTier2.chance * (float)num2));
                             }
                             else if (flag && ReadWrite.fileExists(string.Concat(new string[]
                             {
                                 path,
                                 "/Items/",
                                 itemTier2.name,
                                 "/",
                                 itemTier2.name,
                                 ".dat"
                             }), false, false))
                             {
                                 Data data7 = ReadWrite.readData(string.Concat(new string[]
                                 {
                                     path,
                                     "/Items/",
                                     itemTier2.name,
                                     "/",
                                     itemTier2.name,
                                     ".dat"
                                 }), false, false);
                                 data4.writeUInt16("Table_" + k + "_Spawn_ID", data7.readUInt16("ID"));
                                 data4.writeInt32("Table_" + k + "_Weight", (int)(itemTier2.chance * (float)num2));
                             }
                             else
                             {
                                 data4.writeUInt16("Table_" + k + "_Spawn_ID", id);
                                 data4.writeInt32("Table_" + k + "_Weight", (int)(itemTier2.chance * (float)num2));
                                 if (flag)
                                 {
                                     spawnsData.writeString(id.ToString(), itemTier2.name);
                                 }
                                 else
                                 {
                                     spawnsData.writeString(id.ToString(), itemTable.name + "_" + itemTier2.name);
                                 }
                                 Data data8 = new Data();
                                 data8.writeString("Type", "Spawn");
                                 Data   data9 = data8;
                                 string key3  = "ID";
                                 id = (value = id) + 1;
                                 data9.writeUInt16(key3, value);
                                 data8.writeInt32("Tables", itemTier2.table.Count);
                                 for (int l = 0; l < itemTier2.table.Count; l++)
                                 {
                                     ItemSpawn itemSpawn = itemTier2.table[l];
                                     data8.writeUInt16("Table_" + l + "_Asset_ID", itemSpawn.item);
                                     data8.writeInt32("Table_" + l + "_Weight", 10);
                                 }
                                 if (flag)
                                 {
                                     ReadWrite.writeData(string.Concat(new string[]
                                     {
                                         path,
                                         "/Items/",
                                         itemTier2.name,
                                         "/",
                                         itemTier2.name,
                                         ".dat"
                                     }), false, false, data8);
                                 }
                                 else
                                 {
                                     ReadWrite.writeData(string.Concat(new string[]
                                     {
                                         path,
                                         "/Items/",
                                         itemTable.name,
                                         "_",
                                         itemTier2.name,
                                         "/",
                                         itemTable.name,
                                         "_",
                                         itemTier2.name,
                                         ".dat"
                                     }), false, false, data8);
                                 }
                             }
                         }
                     }
                     else
                     {
                         ItemTier itemTier3 = itemTable.tiers[0];
                         data4.writeInt32("Tables", itemTier3.table.Count);
                         for (int m = 0; m < itemTier3.table.Count; m++)
                         {
                             ItemSpawn itemSpawn2 = itemTier3.table[m];
                             data4.writeUInt16("Table_" + m + "_Asset_ID", itemSpawn2.item);
                             data4.writeInt32("Table_" + m + "_Weight", 10);
                         }
                     }
                 }
                 ReadWrite.writeData(string.Concat(new string[]
                 {
                     path,
                     "/Items/",
                     itemTable.name,
                     "/",
                     itemTable.name,
                     ".dat"
                 }), false, false, data4);
             }
             ReadWrite.writeData(string.Concat(new string[]
             {
                 path,
                 "/Items/",
                 Level.info.name,
                 "_",
                 itemTable.name,
                 "/",
                 Level.info.name,
                 "_",
                 itemTable.name,
                 ".dat"
             }), false, false, data);
         }
     }
 }