예제 #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();
        }
예제 #2
0
 public static void updateSelection()
 {
     if ((int)EditorSpawns.selectedAnimal < LevelAnimals.tables.Count)
     {
         AnimalTable animalTable = LevelAnimals.tables[(int)EditorSpawns.selectedAnimal];
         EditorSpawnsAnimalsUI.selectedBox.text       = animalTable.name;
         EditorSpawnsAnimalsUI.tableNameField.text    = animalTable.name;
         EditorSpawnsAnimalsUI.tableIDField.state     = animalTable.tableID;
         EditorSpawnsAnimalsUI.tableColorPicker.state = animalTable.color;
         if (EditorSpawnsAnimalsUI.tierButtons != null)
         {
             for (int i = 0; i < EditorSpawnsAnimalsUI.tierButtons.Length; i++)
             {
                 EditorSpawnsAnimalsUI.spawnsScrollBox.remove(EditorSpawnsAnimalsUI.tierButtons[i]);
             }
         }
         EditorSpawnsAnimalsUI.tierButtons = new SleekButton[animalTable.tiers.Count];
         for (int j = 0; j < EditorSpawnsAnimalsUI.tierButtons.Length; j++)
         {
             AnimalTier  animalTier  = animalTable.tiers[j];
             SleekButton sleekButton = new SleekButton();
             sleekButton.positionOffset_X = 240;
             sleekButton.positionOffset_Y = 170 + j * 70;
             sleekButton.sizeOffset_X     = 200;
             sleekButton.sizeOffset_Y     = 30;
             sleekButton.text             = animalTier.name;
             SleekButton sleekButton2 = sleekButton;
             if (EditorSpawnsAnimalsUI.< > f__mg$cache1 == null)
             {
                 EditorSpawnsAnimalsUI.< > f__mg$cache1 = new ClickedButton(EditorSpawnsAnimalsUI.onClickedTierButton);
             }
             sleekButton2.onClickedButton = EditorSpawnsAnimalsUI.< > f__mg$cache1;
             EditorSpawnsAnimalsUI.spawnsScrollBox.add(sleekButton);
             SleekSlider sleekSlider = new SleekSlider();
             sleekSlider.positionOffset_Y = 40;
             sleekSlider.sizeOffset_X     = 200;
             sleekSlider.sizeOffset_Y     = 20;
             sleekSlider.orientation      = ESleekOrientation.HORIZONTAL;
             sleekSlider.state            = animalTier.chance;
             sleekSlider.addLabel(Mathf.RoundToInt(animalTier.chance * 100f) + "%", ESleekSide.LEFT);
             SleekSlider sleekSlider2 = sleekSlider;
             if (EditorSpawnsAnimalsUI.< > f__mg$cache2 == null)
             {
                 EditorSpawnsAnimalsUI.< > f__mg$cache2 = new Dragged(EditorSpawnsAnimalsUI.onDraggedChanceSlider);
             }
             sleekSlider2.onDragged = EditorSpawnsAnimalsUI.< > f__mg$cache2;
             sleekButton.add(sleekSlider);
             EditorSpawnsAnimalsUI.tierButtons[j] = sleekButton;
         }
         EditorSpawnsAnimalsUI.tierNameField.positionOffset_Y    = 170 + EditorSpawnsAnimalsUI.tierButtons.Length * 70;
         EditorSpawnsAnimalsUI.addTierButton.positionOffset_Y    = 170 + EditorSpawnsAnimalsUI.tierButtons.Length * 70 + 40;
         EditorSpawnsAnimalsUI.removeTierButton.positionOffset_Y = 170 + EditorSpawnsAnimalsUI.tierButtons.Length * 70 + 40;
         if (EditorSpawnsAnimalsUI.animalButtons != null)
         {
             for (int k = 0; k < EditorSpawnsAnimalsUI.animalButtons.Length; k++)
             {
                 EditorSpawnsAnimalsUI.spawnsScrollBox.remove(EditorSpawnsAnimalsUI.animalButtons[k]);
             }
         }
         if ((int)EditorSpawnsAnimalsUI.selectedTier < animalTable.tiers.Count)
         {
             EditorSpawnsAnimalsUI.tierNameField.text = animalTable.tiers[(int)EditorSpawnsAnimalsUI.selectedTier].name;
             EditorSpawnsAnimalsUI.animalButtons      = new SleekButton[animalTable.tiers[(int)EditorSpawnsAnimalsUI.selectedTier].table.Count];
             for (int l = 0; l < EditorSpawnsAnimalsUI.animalButtons.Length; l++)
             {
                 SleekButton sleekButton3 = new SleekButton();
                 sleekButton3.positionOffset_X = 240;
                 sleekButton3.positionOffset_Y = 170 + EditorSpawnsAnimalsUI.tierButtons.Length * 70 + 80 + l * 40;
                 sleekButton3.sizeOffset_X     = 200;
                 sleekButton3.sizeOffset_Y     = 30;
                 AnimalAsset animalAsset = (AnimalAsset)Assets.find(EAssetType.ANIMAL, animalTable.tiers[(int)EditorSpawnsAnimalsUI.selectedTier].table[l].animal);
                 string      str         = "?";
                 if (animalAsset != null)
                 {
                     if (string.IsNullOrEmpty(animalAsset.animalName))
                     {
                         str = animalAsset.name;
                     }
                     else
                     {
                         str = animalAsset.animalName;
                     }
                 }
                 sleekButton3.text = animalTable.tiers[(int)EditorSpawnsAnimalsUI.selectedTier].table[l].animal.ToString() + " " + str;
                 SleekButton sleekButton4 = sleekButton3;
                 if (EditorSpawnsAnimalsUI.< > f__mg$cache3 == null)
                 {
                     EditorSpawnsAnimalsUI.< > f__mg$cache3 = new ClickedButton(EditorSpawnsAnimalsUI.onClickAnimalButton);
                 }
                 sleekButton4.onClickedButton = EditorSpawnsAnimalsUI.< > f__mg$cache3;
                 EditorSpawnsAnimalsUI.spawnsScrollBox.add(sleekButton3);
                 EditorSpawnsAnimalsUI.animalButtons[l] = sleekButton3;
             }
         }
         else
         {
             EditorSpawnsAnimalsUI.tierNameField.text = string.Empty;
             EditorSpawnsAnimalsUI.animalButtons      = new SleekButton[0];
         }
         EditorSpawnsAnimalsUI.animalIDField.positionOffset_Y      = 170 + EditorSpawnsAnimalsUI.tierButtons.Length * 70 + 80 + EditorSpawnsAnimalsUI.animalButtons.Length * 40;
         EditorSpawnsAnimalsUI.addAnimalButton.positionOffset_Y    = 170 + EditorSpawnsAnimalsUI.tierButtons.Length * 70 + 80 + EditorSpawnsAnimalsUI.animalButtons.Length * 40 + 40;
         EditorSpawnsAnimalsUI.removeAnimalButton.positionOffset_Y = 170 + EditorSpawnsAnimalsUI.tierButtons.Length * 70 + 80 + EditorSpawnsAnimalsUI.animalButtons.Length * 40 + 40;
         EditorSpawnsAnimalsUI.spawnsScrollBox.area = new Rect(0f, 0f, 5f, (float)(170 + EditorSpawnsAnimalsUI.tierButtons.Length * 70 + 80 + EditorSpawnsAnimalsUI.animalButtons.Length * 40 + 70));
     }
     else
     {
         EditorSpawnsAnimalsUI.selectedBox.text       = string.Empty;
         EditorSpawnsAnimalsUI.tableNameField.text    = string.Empty;
         EditorSpawnsAnimalsUI.tableIDField.state     = 0;
         EditorSpawnsAnimalsUI.tableColorPicker.state = Color.white;
         if (EditorSpawnsAnimalsUI.tierButtons != null)
         {
             for (int m = 0; m < EditorSpawnsAnimalsUI.tierButtons.Length; m++)
             {
                 EditorSpawnsAnimalsUI.spawnsScrollBox.remove(EditorSpawnsAnimalsUI.tierButtons[m]);
             }
         }
         EditorSpawnsAnimalsUI.tierButtons                       = null;
         EditorSpawnsAnimalsUI.tierNameField.text                = string.Empty;
         EditorSpawnsAnimalsUI.tierNameField.positionOffset_Y    = 170;
         EditorSpawnsAnimalsUI.addTierButton.positionOffset_Y    = 210;
         EditorSpawnsAnimalsUI.removeTierButton.positionOffset_Y = 210;
         if (EditorSpawnsAnimalsUI.animalButtons != null)
         {
             for (int n = 0; n < EditorSpawnsAnimalsUI.animalButtons.Length; n++)
             {
                 EditorSpawnsAnimalsUI.spawnsScrollBox.remove(EditorSpawnsAnimalsUI.animalButtons[n]);
             }
         }
         EditorSpawnsAnimalsUI.animalButtons = null;
         EditorSpawnsAnimalsUI.animalIDField.positionOffset_Y      = 250;
         EditorSpawnsAnimalsUI.addAnimalButton.positionOffset_Y    = 290;
         EditorSpawnsAnimalsUI.removeAnimalButton.positionOffset_Y = 290;
         EditorSpawnsAnimalsUI.spawnsScrollBox.area = new Rect(0f, 0f, 5f, 320f);
     }
 }
 // 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);
         }
     }
 }