Exemple #1
0
        public static void save()
        {
            River river = new River(Level.info.path + "/Spawns/Fauna.dat", false);

            river.writeByte(LevelAnimals.SAVEDATA_VERSION);
            river.writeByte((byte)LevelAnimals.tables.Count);
            byte b = 0;

            while ((int)b < LevelAnimals.tables.Count)
            {
                AnimalTable animalTable = LevelAnimals.tables[(int)b];
                river.writeColor(animalTable.color);
                river.writeString(animalTable.name);
                river.writeUInt16(animalTable.tableID);
                river.writeByte((byte)animalTable.tiers.Count);
                byte b2 = 0;
                while ((int)b2 < animalTable.tiers.Count)
                {
                    AnimalTier animalTier = animalTable.tiers[(int)b2];
                    river.writeString(animalTier.name);
                    river.writeSingle(animalTier.chance);
                    river.writeByte((byte)animalTier.table.Count);
                    byte b3 = 0;
                    while ((int)b3 < animalTier.table.Count)
                    {
                        AnimalSpawn animalSpawn = animalTier.table[(int)b3];
                        river.writeUInt16(animalSpawn.animal);
                        b3 += 1;
                    }
                    b2 += 1;
                }
                b += 1;
            }
            river.writeUInt16((ushort)LevelAnimals.spawns.Count);
            for (int i = 0; i < LevelAnimals.spawns.Count; i++)
            {
                AnimalSpawnpoint animalSpawnpoint = LevelAnimals.spawns[i];
                river.writeByte(animalSpawnpoint.type);
                river.writeSingleVector3(animalSpawnpoint.point);
            }
            river.closeRiver();
        }
 // Token: 0x0600347B RID: 13435 RVA: 0x00158CC4 File Offset: 0x001570C4
 private static void exportAnimals(string path, Data spawnsData, ref ushort id, bool isLegacy)
 {
     for (int i = 0; i < LevelAnimals.tables.Count; i++)
     {
         AnimalTable animalTable = LevelAnimals.tables[i];
         if (animalTable.tableID == 0)
         {
             animalTable.tableID = id;
             spawnsData.writeString(id.ToString(), Level.info.name + "_" + animalTable.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/Animals/",
                 animalTable.name,
                 "/",
                 animalTable.name,
                 ".dat"
             }), false, true))
             {
                 Data data3 = ReadWrite.readData(string.Concat(new string[]
                 {
                     "/Bundles/Spawns/Animals/",
                     animalTable.name,
                     "/",
                     animalTable.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(), animalTable.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 (animalTable.tiers.Count > 1)
                     {
                         float num = float.MaxValue;
                         for (int j = 0; j < animalTable.tiers.Count; j++)
                         {
                             AnimalTier animalTier = animalTable.tiers[j];
                             if (animalTier.chance < num)
                             {
                                 num = animalTier.chance;
                             }
                         }
                         int num2 = Mathf.CeilToInt(10f / num);
                         data4.writeInt32("Tables", animalTable.tiers.Count);
                         for (int k = 0; k < animalTable.tiers.Count; k++)
                         {
                             AnimalTier animalTier2 = animalTable.tiers[k];
                             data4.writeUInt16("Table_" + k + "_Spawn_ID", id);
                             data4.writeInt32("Table_" + k + "_Weight", (int)(animalTier2.chance * (float)num2));
                             spawnsData.writeString(id.ToString(), animalTable.name + "_" + animalTier2.name);
                             Data data6 = new Data();
                             data6.writeString("Type", "Spawn");
                             Data   data7 = data6;
                             string key3  = "ID";
                             id = (value = id) + 1;
                             data7.writeUInt16(key3, value);
                             data6.writeInt32("Tables", animalTier2.table.Count);
                             for (int l = 0; l < animalTier2.table.Count; l++)
                             {
                                 AnimalSpawn animalSpawn = animalTier2.table[l];
                                 data6.writeUInt16("Table_" + l + "_Asset_ID", animalSpawn.animal);
                                 data6.writeInt32("Table_" + l + "_Weight", 10);
                             }
                             ReadWrite.writeData(string.Concat(new string[]
                             {
                                 path,
                                 "/Animals/",
                                 animalTable.name,
                                 "_",
                                 animalTier2.name,
                                 "/",
                                 animalTable.name,
                                 "_",
                                 animalTier2.name,
                                 ".dat"
                             }), false, false, data6);
                         }
                     }
                     else
                     {
                         AnimalTier animalTier3 = animalTable.tiers[0];
                         data4.writeInt32("Tables", animalTier3.table.Count);
                         for (int m = 0; m < animalTier3.table.Count; m++)
                         {
                             AnimalSpawn animalSpawn2 = animalTier3.table[m];
                             data4.writeUInt16("Table_" + m + "_Asset_ID", animalSpawn2.animal);
                             data4.writeInt32("Table_" + m + "_Weight", 10);
                         }
                     }
                 }
                 ReadWrite.writeData(string.Concat(new string[]
                 {
                     path,
                     "/Animals/",
                     animalTable.name,
                     "/",
                     animalTable.name,
                     ".dat"
                 }), false, false, data4);
             }
             ReadWrite.writeData(string.Concat(new string[]
             {
                 path,
                 "/Animals/",
                 Level.info.name,
                 "_",
                 animalTable.name,
                 "/",
                 Level.info.name,
                 "_",
                 animalTable.name,
                 ".dat"
             }), false, false, data);
         }
     }
 }