Exemplo 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();
        }
Exemplo n.º 2
0
 private static void onDraggedChanceSlider(SleekSlider slider, float state)
 {
     if ((int)EditorSpawns.selectedItem < LevelItems.tables.Count)
     {
         int num = (slider.parent.positionOffset_Y - 170) / 70;
         LevelItems.tables[(int)EditorSpawns.selectedItem].updateChance(num, state);
         for (int i = 0; i < LevelItems.tables[(int)EditorSpawns.selectedItem].tiers.Count; i++)
         {
             ItemTier    itemTier    = LevelItems.tables[(int)EditorSpawns.selectedItem].tiers[i];
             SleekSlider sleekSlider = (SleekSlider)EditorSpawnsItemsUI.tierButtons[i].children[0];
             if (i != num)
             {
                 sleekSlider.state = itemTier.chance;
             }
             sleekSlider.updateLabel(Mathf.RoundToInt(itemTier.chance * 100f) + "%");
         }
     }
 }
Exemplo n.º 3
0
        public ushort getItem()
        {
            if (this.tableID != 0)
            {
                return(SpawnTableTool.resolve(this.tableID));
            }
            float value = Random.value;

            if (this.tiers.Count == 0)
            {
                return(0);
            }
            int i = 0;

            while (i < this.tiers.Count)
            {
                if (value < this.tiers[i].chance)
                {
                    ItemTier itemTier = this.tiers[i];
                    if (itemTier.table.Count > 0)
                    {
                        return(itemTier.table[Random.Range(0, itemTier.table.Count)].item);
                    }
                    return(0);
                }
                else
                {
                    i++;
                }
            }
            ItemTier itemTier2 = this.tiers[Random.Range(0, this.tiers.Count)];

            if (itemTier2.table.Count > 0)
            {
                return(itemTier2.table[Random.Range(0, itemTier2.table.Count)].item);
            }
            return(0);
        }
        // Token: 0x06003476 RID: 13430 RVA: 0x00157B34 File Offset: 0x00155F34
        private static bool isVariantItemTier(ItemTier tier)
        {
            if (tier.table.Count < 6)
            {
                return(false);
            }
            ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, tier.table[0].item);

            if (itemAsset == null)
            {
                return(false);
            }
            int num = itemAsset.itemName.IndexOf(" ");

            if (num <= 0)
            {
                return(false);
            }
            string text = itemAsset.itemName.Substring(num + 1);

            if (text.Length <= 1)
            {
                Debug.LogError(itemAsset.itemName + " name has a trailing space!");
                return(false);
            }
            for (int i = 1; i < tier.table.Count; i++)
            {
                ItemAsset itemAsset2 = (ItemAsset)Assets.find(EAssetType.ITEM, tier.table[i].item);
                if (!itemAsset2.itemName.Contains(text))
                {
                    return(false);
                }
            }
            tier.name = text;
            return(true);
        }
Exemplo n.º 5
0
 public static void updateSelection()
 {
     if ((int)EditorSpawns.selectedItem < LevelItems.tables.Count)
     {
         ItemTable itemTable = LevelItems.tables[(int)EditorSpawns.selectedItem];
         EditorSpawnsItemsUI.selectedBox.text       = itemTable.name;
         EditorSpawnsItemsUI.tableNameField.text    = itemTable.name;
         EditorSpawnsItemsUI.tableIDField.state     = itemTable.tableID;
         EditorSpawnsItemsUI.tableColorPicker.state = itemTable.color;
         if (EditorSpawnsItemsUI.tierButtons != null)
         {
             for (int i = 0; i < EditorSpawnsItemsUI.tierButtons.Length; i++)
             {
                 EditorSpawnsItemsUI.spawnsScrollBox.remove(EditorSpawnsItemsUI.tierButtons[i]);
             }
         }
         EditorSpawnsItemsUI.tierButtons = new SleekButton[itemTable.tiers.Count];
         for (int j = 0; j < EditorSpawnsItemsUI.tierButtons.Length; j++)
         {
             ItemTier    itemTier    = itemTable.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             = itemTier.name;
             SleekButton sleekButton2 = sleekButton;
             if (EditorSpawnsItemsUI.< > f__mg$cache1 == null)
             {
                 EditorSpawnsItemsUI.< > f__mg$cache1 = new ClickedButton(EditorSpawnsItemsUI.onClickedTierButton);
             }
             sleekButton2.onClickedButton = EditorSpawnsItemsUI.< > f__mg$cache1;
             EditorSpawnsItemsUI.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            = itemTier.chance;
             sleekSlider.addLabel(Mathf.RoundToInt(itemTier.chance * 100f) + "%", ESleekSide.LEFT);
             SleekSlider sleekSlider2 = sleekSlider;
             if (EditorSpawnsItemsUI.< > f__mg$cache2 == null)
             {
                 EditorSpawnsItemsUI.< > f__mg$cache2 = new Dragged(EditorSpawnsItemsUI.onDraggedChanceSlider);
             }
             sleekSlider2.onDragged = EditorSpawnsItemsUI.< > f__mg$cache2;
             sleekButton.add(sleekSlider);
             EditorSpawnsItemsUI.tierButtons[j] = sleekButton;
         }
         EditorSpawnsItemsUI.tierNameField.positionOffset_Y    = 170 + EditorSpawnsItemsUI.tierButtons.Length * 70;
         EditorSpawnsItemsUI.addTierButton.positionOffset_Y    = 170 + EditorSpawnsItemsUI.tierButtons.Length * 70 + 40;
         EditorSpawnsItemsUI.removeTierButton.positionOffset_Y = 170 + EditorSpawnsItemsUI.tierButtons.Length * 70 + 40;
         if (EditorSpawnsItemsUI.itemButtons != null)
         {
             for (int k = 0; k < EditorSpawnsItemsUI.itemButtons.Length; k++)
             {
                 EditorSpawnsItemsUI.spawnsScrollBox.remove(EditorSpawnsItemsUI.itemButtons[k]);
             }
         }
         if ((int)EditorSpawnsItemsUI.selectedTier < itemTable.tiers.Count)
         {
             EditorSpawnsItemsUI.tierNameField.text = itemTable.tiers[(int)EditorSpawnsItemsUI.selectedTier].name;
             EditorSpawnsItemsUI.itemButtons        = new SleekButton[itemTable.tiers[(int)EditorSpawnsItemsUI.selectedTier].table.Count];
             for (int l = 0; l < EditorSpawnsItemsUI.itemButtons.Length; l++)
             {
                 SleekButton sleekButton3 = new SleekButton();
                 sleekButton3.positionOffset_X = 240;
                 sleekButton3.positionOffset_Y = 170 + EditorSpawnsItemsUI.tierButtons.Length * 70 + 80 + l * 40;
                 sleekButton3.sizeOffset_X     = 200;
                 sleekButton3.sizeOffset_Y     = 30;
                 ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, itemTable.tiers[(int)EditorSpawnsItemsUI.selectedTier].table[l].item);
                 string    str       = "?";
                 if (itemAsset != null)
                 {
                     if (string.IsNullOrEmpty(itemAsset.itemName))
                     {
                         str = itemAsset.name;
                     }
                     else
                     {
                         str = itemAsset.itemName;
                     }
                 }
                 sleekButton3.text = itemTable.tiers[(int)EditorSpawnsItemsUI.selectedTier].table[l].item.ToString() + " " + str;
                 SleekButton sleekButton4 = sleekButton3;
                 if (EditorSpawnsItemsUI.< > f__mg$cache3 == null)
                 {
                     EditorSpawnsItemsUI.< > f__mg$cache3 = new ClickedButton(EditorSpawnsItemsUI.onClickItemButton);
                 }
                 sleekButton4.onClickedButton = EditorSpawnsItemsUI.< > f__mg$cache3;
                 EditorSpawnsItemsUI.spawnsScrollBox.add(sleekButton3);
                 EditorSpawnsItemsUI.itemButtons[l] = sleekButton3;
             }
         }
         else
         {
             EditorSpawnsItemsUI.tierNameField.text = string.Empty;
             EditorSpawnsItemsUI.itemButtons        = new SleekButton[0];
         }
         EditorSpawnsItemsUI.itemIDField.positionOffset_Y      = 170 + EditorSpawnsItemsUI.tierButtons.Length * 70 + 80 + EditorSpawnsItemsUI.itemButtons.Length * 40;
         EditorSpawnsItemsUI.addItemButton.positionOffset_Y    = 170 + EditorSpawnsItemsUI.tierButtons.Length * 70 + 80 + EditorSpawnsItemsUI.itemButtons.Length * 40 + 40;
         EditorSpawnsItemsUI.removeItemButton.positionOffset_Y = 170 + EditorSpawnsItemsUI.tierButtons.Length * 70 + 80 + EditorSpawnsItemsUI.itemButtons.Length * 40 + 40;
         EditorSpawnsItemsUI.spawnsScrollBox.area = new Rect(0f, 0f, 5f, (float)(170 + EditorSpawnsItemsUI.tierButtons.Length * 70 + 80 + EditorSpawnsItemsUI.itemButtons.Length * 40 + 70));
     }
     else
     {
         EditorSpawnsItemsUI.selectedBox.text       = string.Empty;
         EditorSpawnsItemsUI.tableNameField.text    = string.Empty;
         EditorSpawnsItemsUI.tableIDField.state     = 0;
         EditorSpawnsItemsUI.tableColorPicker.state = Color.white;
         if (EditorSpawnsItemsUI.tierButtons != null)
         {
             for (int m = 0; m < EditorSpawnsItemsUI.tierButtons.Length; m++)
             {
                 EditorSpawnsItemsUI.spawnsScrollBox.remove(EditorSpawnsItemsUI.tierButtons[m]);
             }
         }
         EditorSpawnsItemsUI.tierButtons                       = null;
         EditorSpawnsItemsUI.tierNameField.text                = string.Empty;
         EditorSpawnsItemsUI.tierNameField.positionOffset_Y    = 170;
         EditorSpawnsItemsUI.addTierButton.positionOffset_Y    = 210;
         EditorSpawnsItemsUI.removeTierButton.positionOffset_Y = 210;
         if (EditorSpawnsItemsUI.itemButtons != null)
         {
             for (int n = 0; n < EditorSpawnsItemsUI.itemButtons.Length; n++)
             {
                 EditorSpawnsItemsUI.spawnsScrollBox.remove(EditorSpawnsItemsUI.itemButtons[n]);
             }
         }
         EditorSpawnsItemsUI.itemButtons = null;
         EditorSpawnsItemsUI.itemIDField.positionOffset_Y      = 250;
         EditorSpawnsItemsUI.addItemButton.positionOffset_Y    = 290;
         EditorSpawnsItemsUI.removeItemButton.positionOffset_Y = 290;
         EditorSpawnsItemsUI.spawnsScrollBox.area = new Rect(0f, 0f, 5f, 320f);
     }
 }
 // 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);
         }
     }
 }