Exemplo n.º 1
0
        public void OnTablesLoaded(Dictionary <string, LootSpawnList> Tables)
        {
            if (!Directory.Exists(ModuleFolder + "\\Tables"))
            {
                Directory.CreateDirectory(ModuleFolder + "\\Tables");
            }
            ExtractTables(Tables);

            foreach (var name in Tables.Keys)
            {
                IniParser     table     = new IniParser(ModuleFolder + "\\Tables\\" + name + ".ini");
                LootSpawnList realTable = Tables[name];
                try
                {
                    realTable.minPackagesToSpawn = int.Parse(table.GetSetting("TableSettings", "MinToSpawn"));
                    realTable.maxPackagesToSpawn = int.Parse(table.GetSetting("TableSettings", "MaxToSpawn"));
                    realTable.spawnOneOfEach     = bool.Parse(table.GetSetting("TableSettings", "OneOfEach"));
                    realTable.noDuplicates       = bool.Parse(table.GetSetting("TableSettings", "DuplicatesAllowed"));
                    realTable.noDuplicates       = !realTable.noDuplicates;
                }
                catch (Exception ex)
                {
                    Logger.LogError("[DropPP] Failed to convert values from the ini file! (0x1) " + ex);
                }

                var c     = table.Count() - 1;
                var packs = new LootSpawnList.LootWeightedEntry[c];

                for (var i = 1; i <= c; i++)
                {
                    try
                    {
                        var pack = new LootSpawnList.LootWeightedEntry();
                        pack.weight    = float.Parse(table.GetSetting("Entry" + i, "Weight"));
                        pack.amountMin = int.Parse(table.GetSetting("Entry" + i, "Min"));
                        pack.amountMax = int.Parse(table.GetSetting("Entry" + i, "Max"));

                        var objName = table.GetSetting("Entry" + i, "Name");

                        if (Tables.ContainsKey(objName))
                        {
                            pack.obj = Tables[objName];
                        }
                        else
                        {
                            pack.obj = Server.GetServer().Items.Find(objName);
                        }

                        packs[i - 1] = pack;
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("[DropPP] Failed to convert values from the ini file! (0x2) " + ex);
                    }
                }

                realTable.LootPackages = packs;
            }
        }
Exemplo n.º 2
0
        private void AddLootEntry(string list, LootSpawnList.LootWeightedEntry entry)
        {
            var lootList = DatablockDictionary._lootSpawnLists[list];

            var lootWeightedEntries = lootList.LootPackages.ToList();

            lootWeightedEntries.Add(entry);

            lootList.LootPackages = lootWeightedEntries.ToArray();

            Logger.Log("[CustomItems] Added loot entry \"" + entry.obj.name + "\" to LootTable " + list);
        }
Exemplo n.º 3
0
        void PatchNewSpawnlists()
        {
            int cnt = 0;
            var spawnlistobjects = new Dictionary <string, LootSpawnList>();

            foreach (KeyValuePair <string, object> pair in SpawnLists)
            {
                var currentspawnlist = pair.Value as Dictionary <string, object>;
                var obj = UnityEngine.ScriptableObject.CreateInstance <LootSpawnList>();
                obj.minPackagesToSpawn = Convert.ToInt32(currentspawnlist["min"]);
                obj.maxPackagesToSpawn = Convert.ToInt32(currentspawnlist["max"]);
                obj.noDuplicates       = Convert.ToBoolean(currentspawnlist["nodupes"]);
                obj.spawnOneOfEach     = Convert.ToBoolean(currentspawnlist["oneofeach"]);
                obj.name = pair.Key;
                spawnlistobjects.Add(pair.Key, obj);
                cnt++;
            }
            foreach (KeyValuePair <string, object> pair in SpawnLists)
            {
                var entrylist        = new List <LootSpawnList.LootWeightedEntry>();
                var currentspawnlist = pair.Value as Dictionary <string, object>;
                var packages         = currentspawnlist["packages"] as List <object>;
                foreach (Dictionary <string, object> entry in packages)
                {
                    var entryobj = new LootSpawnList.LootWeightedEntry();
                    entryobj.amountMin = Convert.ToInt32(entry["min"]);
                    entryobj.amountMax = Convert.ToInt32(entry["max"]);
                    entryobj.weight    = Convert.ToSingle(entry["weight"]);
                    if (spawnlistobjects.ContainsKey(entry["object"].ToString()))
                    {
                        entryobj.obj = spawnlistobjects[entry["object"].ToString()];
                    }
                    else
                    {
                        entryobj.obj = DatablockDictionary.GetByName(entry["object"].ToString());
                    }
                    entrylist.Add(entryobj);
                }
                spawnlistobjects[pair.Key].LootPackages = entrylist.ToArray();
            }
            var spawnlists = DatablockDictionary._lootSpawnLists;

            spawnlists.Clear();
            foreach (KeyValuePair <string, object> pair in SpawnLists)
            {
                spawnlists.Add(pair.Key, spawnlistobjects[pair.Key]);
            }
            Puts(string.Format("{0} custom loot tables were loaded!", cnt.ToString()));
        }
Exemplo n.º 4
0
 public void Lists()
 {
     foreach (LootSpawnList current in DatablockDictionary._lootSpawnLists.Values)
     {
         File.AppendAllText(Util.GetAbsoluteFilePath("Lists.txt"), "Name : " + current.name + "\n");
         File.AppendAllText(Util.GetAbsoluteFilePath("Lists.txt"), "Min Spawn : " + current.minPackagesToSpawn + "\n");
         File.AppendAllText(Util.GetAbsoluteFilePath("Lists.txt"), "Max Spawn : " + current.maxPackagesToSpawn + "\n");
         File.AppendAllText(Util.GetAbsoluteFilePath("Lists.txt"), "NoDuplicate : " + current.noDuplicates + "\n");
         File.AppendAllText(Util.GetAbsoluteFilePath("Lists.txt"), "OneOfEach : " + current.spawnOneOfEach + "\n");
         File.AppendAllText(Util.GetAbsoluteFilePath("Lists.txt"), "Entries :\n");
         LootSpawnList.LootWeightedEntry[] lootPackages = current.LootPackages;
         for (int i = 0; i < lootPackages.Length; i++)
         {
             LootSpawnList.LootWeightedEntry lootWeightedEntry = lootPackages[i];
             File.AppendAllText(Util.GetAbsoluteFilePath("Lists.txt"), "Amount Min : " + lootWeightedEntry.amountMin + "\n");
             File.AppendAllText(Util.GetAbsoluteFilePath("Lists.txt"), "Amount Max : " + lootWeightedEntry.amountMax + "\n");
             File.AppendAllText(Util.GetAbsoluteFilePath("Lists.txt"), "Weight : " + lootWeightedEntry.weight + "\n");
             File.AppendAllText(Util.GetAbsoluteFilePath("Lists.txt"), "Object : " + lootWeightedEntry.obj.ToString() + "\n\n");
         }
     }
 }
Exemplo n.º 5
0
    private void PopulateInventory_Recurse(ref LootSpawnList.RecursiveInventoryPopulateArgs args)
    {
        if (this.maxPackagesToSpawn > (int)this.LootPackages.Length)
        {
            this.maxPackagesToSpawn = (int)this.LootPackages.Length;
        }
        int num = 0;

        num = (!this.spawnOneOfEach ? UnityEngine.Random.Range(this.minPackagesToSpawn, this.maxPackagesToSpawn) : (int)this.LootPackages.Length);
        for (int i = 0; !args.inventoryExausted && i < num; i++)
        {
            LootSpawnList.LootWeightedEntry lootWeightedEntry = null;
            lootWeightedEntry = (!this.spawnOneOfEach ? WeightSelection.RandomPickEntry(this.LootPackages) as LootSpawnList.LootWeightedEntry : this.LootPackages[i]);
            if (lootWeightedEntry == null)
            {
                Debug.Log("Massive fuckup...");
                return;
            }
            UnityEngine.Object obj = lootWeightedEntry.obj;
            if (obj)
            {
                if (obj is ItemDataBlock)
                {
                    if (!object.ReferenceEquals(args.inventory.AddItem(obj as ItemDataBlock, Inventory.Slot.Preference.Define(args.spawnCount, false, Inventory.Slot.KindFlags.Default | Inventory.Slot.KindFlags.Belt), UnityEngine.Random.Range(lootWeightedEntry.amountMin, lootWeightedEntry.amountMax + 1)), null))
                    {
                        args.spawnCount = args.spawnCount + 1;
                        if (args.inventory.noVacantSlots)
                        {
                            args.inventoryExausted = true;
                        }
                    }
                }
                else if (obj is LootSpawnList)
                {
                    ((LootSpawnList)obj).PopulateInventory_Recurse(ref args);
                }
            }
        }
    }
Exemplo n.º 6
0
        public void loadTables()
        {
            try
            {
                string currentSection = "";
                bool isSkipping = false;

                if (!Directory.Exists(Vars.tablesDir))
                    Directory.CreateDirectory(Vars.tablesDir);

                List<string> tables = Directory.GetFiles(Vars.tablesDir, "*.ini").ToList();
                List<string> removeQueue = new List<string>();
                foreach (string table in tables)
                {
                    string tableName = Path.GetFileNameWithoutExtension(table);
                    if (!Vars.originalLootTables.ContainsKey(tableName))
                        removeQueue.Add(table);
                }
                foreach (string table in removeQueue)
                {
                    tables.Remove(table);
                }

                if (tables.Count < Vars.originalLootTables.Count)
                {
                    foreach (KeyValuePair<string, LootSpawnList> lootTable in Vars.originalLootTables)
                    {
                        string tableName = lootTable.Key;
                        string filePath = Path.Combine(Vars.tablesDir, tableName + ".ini");

                        if (!File.Exists(filePath))
                        {
                            using (StreamWriter sw = new StreamWriter(filePath))
                            {
                                sw.WriteLine("[Settings]");
                                sw.WriteLine("# Minimum number of items/tables that can be selected.");
                                sw.WriteLine("minimumSelections=" + lootTable.Value.minPackagesToSpawn);
                                sw.WriteLine("# Maximum number of items/tables that can be selected.");
                                sw.WriteLine("maximumSelections=" + lootTable.Value.maxPackagesToSpawn);
                                sw.WriteLine("# If true, the same item/table can be randomly selected multiple times for spawning.");
                                sw.WriteLine("allowDuplicates=" + (!lootTable.Value.noDuplicates).ToString().ToLower());
                                sw.WriteLine("# If true, all items and tables will be used regardless of probability - there will be no random selection.");
                                sw.WriteLine("useAll=" + lootTable.Value.spawnOneOfEach.ToString().ToLower());
                                sw.WriteLine("");
                                foreach (LootSpawnList.LootWeightedEntry entry in lootTable.Value.LootPackages)
                                {
                                    try
                                    {
                                        if (entry.obj is LootSpawnList)
                                        {
                                            LootSpawnList entryTable = (LootSpawnList)entry.obj;
                                            string entryName = Array.Find(Vars.originalLootTables.ToArray(), (KeyValuePair<string, LootSpawnList> kv) => kv.Value == entryTable).Key;
                                            if (entryName != null)
                                            {
                                                sw.WriteLine("[" + entryName + ".Table]");
                                                sw.WriteLine("probability=" + entry.weight);
                                                sw.WriteLine("minimumAmount=" + entry.amountMin);
                                                sw.WriteLine("maximumAmount=" + entry.amountMax);
                                                sw.WriteLine("");
                                            }
                                        }
                                        else if (entry.obj is ItemDataBlock)
                                        {
                                            ItemDataBlock entryItem = (ItemDataBlock)entry.obj;
                                            string entryName = entryItem.name;

                                            sw.WriteLine("[" + entryName + ".Item]");
                                            sw.WriteLine("probability=" + entry.weight);
                                            sw.WriteLine("minimumAmount=" + entry.amountMin);
                                            sw.WriteLine("maximumAmount=" + entry.amountMax);
                                            sw.WriteLine("");
                                        }
                                    }
                                    catch (Exception ex) { Vars.conLog.Error("Something went wrong when uncovering a loot package: " + ex.ToString()); }
                                }
                            }
                        }
                    }
                }

                tables.Clear();
                removeQueue.Clear();
                tables = Directory.GetFiles(Vars.tablesDir, "*.ini").ToList();
                removeQueue = new List<string>();
                foreach (string table in tables)
                {
                    string tableName = Path.GetFileNameWithoutExtension(table);
                    if (!Vars.originalLootTables.ContainsKey(tableName))
                        removeQueue.Add(table);
                }
                foreach (string table in removeQueue)
                {
                    tables.Remove(table);
                }

                List<LootSpawnList.LootWeightedEntry> newLootPackages = new List<LootSpawnList.LootWeightedEntry>();
                LootSpawnList.LootWeightedEntry lootPackage = new LootSpawnList.LootWeightedEntry();
                int overridedPackages = 0;
                foreach (string tablePath in tables)
                {
                    string fileName = Path.GetFileName(tablePath);
                    string tableName = Path.GetFileNameWithoutExtension(tablePath);
                    if (File.Exists(tablePath))
                    {
                        using (StreamReader sr = new StreamReader(tablePath))
                        {
                            string line;
                            while ((line = sr.ReadLine()) != null)
                            {
                                if (!line.StartsWith("#"))
                                {
                                    if (line.IndexOf("#") > -1)
                                    {
                                        line = line.Substring(0, line.IndexOf("#"));
                                    }

                                    line = line.Trim();

                                    if (line.StartsWith("[") && line.EndsWith("]"))
                                    {
                                        currentSection = line.Trim();
                                        isSkipping = false;
                                        lootPackage = new LootSpawnList.LootWeightedEntry();
                                        if (currentSection == "[Settings]")
                                        {
                                        }
                                        else if (currentSection.EndsWith(".Item]"))
                                        {
                                            try
                                            {
                                                string itemName = currentSection.Substring(1, currentSection.LastIndexOf(".Item]") - 1);
                                                if (Vars.itemIDs.ContainsValue(itemName))
                                                {
                                                    ItemDataBlock item = DatablockDictionary.GetByName(itemName);
                                                    lootPackage.obj = item;
                                                }
                                                else
                                                {
                                                    Vars.conLog.Error("Invalid item name [" + itemName + "] in " + fileName + "!");
                                                    isSkipping = true;
                                                }
                                            }
                                            catch { Vars.conLog.Error("Invalid item section name " + currentSection + " in " + fileName + "!"); isSkipping = true; }
                                        }
                                        else if (currentSection.EndsWith(".Table]"))
                                        {
                                            try
                                            {
                                                string tableSectionName = currentSection.Substring(1, currentSection.LastIndexOf(".Table]") - 1);
                                                if (Vars.originalLootTables.ContainsKey(tableSectionName))
                                                {
                                                    LootSpawnList table = DatablockDictionary.GetLootSpawnListByName(tableSectionName);
                                                    lootPackage.obj = table;
                                                }
                                                else
                                                {
                                                    Vars.conLog.Error("Invalid table name [" + tableSectionName + "] in " + fileName + "!");
                                                    isSkipping = true;
                                                }
                                            }
                                            catch { Vars.conLog.Error("Invalid table section name " + currentSection + " in " + fileName + "!"); isSkipping = true; }
                                        }
                                        else
                                        {
                                            Vars.conLog.Error("Invalid table/item section name " + currentSection + " in " + fileName + "!");
                                            isSkipping = true;
                                        }
                                    }
                                    else
                                    {
                                        if (!isSkipping)
                                        {
                                            if (currentSection == "[Settings]")
                                            {
                                                if (line.Length > 0 && line.Contains("="))
                                                {
                                                    string variableName = line.Split('=')[0];
                                                    string variableValue = line.Split('=')[1];
                                                    if (variableName.Length > 0 && variableValue.Length > 0)
                                                    {
                                                        switch (variableName)
                                                        {
                                                            case "minimumSelections":
                                                                int minimumLoot = Vars.originalLootTables[tableName].minPackagesToSpawn;
                                                                if (int.TryParse(variableValue, out minimumLoot))
                                                                {
                                                                    if (minimumLoot >= 0)
                                                                        DatablockDictionary._lootSpawnLists[tableName].minPackagesToSpawn = minimumLoot;
                                                                    else
                                                                        Vars.conLog.Error("Variable \"minimumLoot\" must be above 0 in " + fileName + "!");
                                                                }
                                                                else
                                                                {
                                                                    Vars.conLog.Error("Could not parse \"minimumLoot\" as an integer in " + fileName + "!");
                                                                }
                                                                break;
                                                            case "maximumSelections":
                                                                int maximumLoot = Vars.originalLootTables[tableName].maxPackagesToSpawn;
                                                                if (int.TryParse(variableValue, out maximumLoot))
                                                                {
                                                                    if (maximumLoot >= 0)
                                                                        DatablockDictionary._lootSpawnLists[tableName].maxPackagesToSpawn = maximumLoot;
                                                                    else
                                                                        Vars.conLog.Error("Variable \"maximumLoot\" must be above 0 in " + fileName + "!");
                                                                }
                                                                else
                                                                {
                                                                    Vars.conLog.Error("Could not parse \"maximumLoot\" as an integer in " + fileName + "!");
                                                                }
                                                                break;
                                                            case "allowDuplicates":
                                                                bool allowDuplicates = !Vars.originalLootTables[tableName].noDuplicates;
                                                                if (bool.TryParse(variableValue, out allowDuplicates))
                                                                {
                                                                    DatablockDictionary._lootSpawnLists[tableName].noDuplicates = !allowDuplicates;
                                                                }
                                                                else
                                                                {
                                                                    Vars.conLog.Error("Could not parse \"allowDuplicates\" as a boolean in " + fileName + "!");
                                                                }
                                                                break;
                                                            case "useAll":
                                                                bool useAll = !Vars.originalLootTables[tableName].spawnOneOfEach;
                                                                if (bool.TryParse(variableValue, out useAll))
                                                                {
                                                                    DatablockDictionary._lootSpawnLists[tableName].spawnOneOfEach = useAll;
                                                                }
                                                                else
                                                                {
                                                                    Vars.conLog.Error("Could not parse \"useAll\" as a boolean in " + fileName + "!");
                                                                }
                                                                break;
                                                            default:
                                                                Vars.conLog.Error("Unfamiliar variable name \"" + variableName + "\" in " + fileName + "!");
                                                                break;
                                                        }
                                                    }
                                                }
                                            }
                                            else if (currentSection.EndsWith(".Item]") || currentSection.EndsWith(".Table]"))
                                            {
                                                if (line.Length > 0 && line.Contains("="))
                                                {
                                                    string variableName = line.Split('=')[0];
                                                    string variableValue = line.Split('=')[1];
                                                    if (variableName.Length > 0 && variableValue.Length > 0)
                                                    {
                                                        switch (variableName)
                                                        {
                                                            case "probability":
                                                                float probability;
                                                                if (float.TryParse(variableValue, out probability))
                                                                {
                                                                    if (probability >= 0)
                                                                        lootPackage.weight = probability;
                                                                    else
                                                                        Vars.conLog.Error("Variable \"probability\" must be above 0 in " + fileName + "!");
                                                                }
                                                                else
                                                                {
                                                                    Vars.conLog.Error("Could not parse \"probability\" as a float in " + fileName + "!");
                                                                }
                                                                break;
                                                            case "minimumAmount":
                                                                int minimum;
                                                                if (int.TryParse(variableValue, out minimum))
                                                                {
                                                                    if (minimum >= 0)
                                                                        lootPackage.amountMin = minimum;
                                                                    else
                                                                        Vars.conLog.Error("Variable \"minimum\" must be above 0 in " + fileName + "!");
                                                                }
                                                                else
                                                                {
                                                                    Vars.conLog.Error("Could not parse \"minimum\" as an integer in " + fileName + "!");
                                                                }
                                                                break;
                                                            case "maximumAmount":
                                                                int maximum;
                                                                if (int.TryParse(variableValue, out maximum))
                                                                {
                                                                    if (maximum >= 0)
                                                                        lootPackage.amountMax = maximum;
                                                                    else
                                                                        Vars.conLog.Error("Variable \"maximum\" must be above 0 in " + fileName + "!");
                                                                }
                                                                else
                                                                {
                                                                    Vars.conLog.Error("Could not parse \"maximum\" as an integer in " + fileName + "!");
                                                                }
                                                                newLootPackages.Add(lootPackage);
                                                                break;
                                                            default:
                                                                Vars.conLog.Error("Unfamiliar variable name \"" + variableName + "\" in " + fileName + "!");
                                                                break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (newLootPackages.Count > 0)
                        {
                            overridedPackages++;
                            DatablockDictionary._lootSpawnLists[tableName].LootPackages = newLootPackages.ToArray();
                        }
                        newLootPackages.Clear();
                    }
                }
                Vars.conLog.Info(overridedPackages + "/" + DatablockDictionary._lootSpawnLists.Count + " loot tables successfully overrided!");
            }
            catch (Exception ex) { Vars.conLog.Error(ex.ToString()); }
        }
Exemplo n.º 7
0
        private static bool smethod_0()
        {
            System.Collections.Generic.List <string> list = File.ReadAllLines(LootsFile).ToList <string>();
            if (predicate_0 == null)
            {
                predicate_0 = new Predicate <string>(Override.smethod_6);
            }
            if (!list.Exists(predicate_0))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"AILootList\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            if (predicate_1 == null)
            {
                predicate_1 = new Predicate <string>(Override.smethod_7);
            }
            if (!list.Exists(predicate_1))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"AmmoSpawnList\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            if (predicate_2 == null)
            {
                predicate_2 = new Predicate <string>(Override.smethod_8);
            }
            if (!list.Exists(predicate_2))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"JunkSpawnList\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            if (predicate_3 == null)
            {
                predicate_3 = new Predicate <string>(Override.smethod_9);
            }
            if (!list.Exists(predicate_3))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"MedicalSpawnList\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            if (predicate_4 == null)
            {
                predicate_4 = new Predicate <string>(Override.smethod_10);
            }
            if (!list.Exists(predicate_4))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"WeaponSpawnList\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            if (predicate_5 == null)
            {
                predicate_5 = new Predicate <string>(Override.smethod_11);
            }
            if (!list.Exists(predicate_5))
            {
                ConsoleSystem.PrintError("ERROR: Spawn list for \"SupplyDropSpawnListMaster\" not found in \"lootslist.cfg\".", false);
                return(false);
            }
            DatablockDictionary._lootSpawnLists.Clear();
            Dictionary <string, LootSpawnList> dictionary = new Dictionary <string, LootSpawnList>();

            foreach (string str in list)
            {
                string str2 = str.Trim();
                if (!string.IsNullOrEmpty(str2) && !str2.StartsWith("//"))
                {
                    if (str2.Contains("//"))
                    {
                        str2 = str2.Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                    }
                    if ((!string.IsNullOrEmpty(str2) && str2.StartsWith("[")) && str2.EndsWith("]"))
                    {
                        str2             = str2.Substring(1, str2.Length - 2);
                        dictionary[str2] = ScriptableObject.CreateInstance <LootSpawnList>();
                    }
                }
            }
            LootSpawnList list2 = null;

            LootSpawnList.LootWeightedEntry item = null;
            System.Collections.Generic.List <LootSpawnList.LootWeightedEntry> list3 = null;
            foreach (string str3 in list)
            {
                string str4 = str3.Trim();
                if (!string.IsNullOrEmpty(str4) && !str4.StartsWith("//"))
                {
                    if (str4.Contains("//"))
                    {
                        str4 = str4.Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                    }
                    if (!string.IsNullOrEmpty(str4))
                    {
                        if (str4.StartsWith("[") && str4.EndsWith("]"))
                        {
                            string str5 = str4.Substring(1, str4.Length - 2);
                            list2      = dictionary[str5];
                            list2.name = str5;
                            DatablockDictionary._lootSpawnLists.Add(list2.name, list2);
                            list3 = new System.Collections.Generic.List <LootSpawnList.LootWeightedEntry>();
                        }
                        else if (str4.Contains("=") && (list2 != null))
                        {
                            string   str6;
                            string[] strArray = str4.Split(new char[] { '=' });
                            if ((strArray.Length >= 2) && ((str6 = strArray[0].ToUpper()) != null))
                            {
                                if (str6 == "PACKAGESTOSPAWN")
                                {
                                    if (strArray[1].Contains(","))
                                    {
                                        strArray = strArray[1].Split(new char[] { ',' });
                                    }
                                    else
                                    {
                                        strArray = new string[] { strArray[1], strArray[1] };
                                    }
                                    int.TryParse(strArray[0], out list2.minPackagesToSpawn);
                                    int.TryParse(strArray[1], out list2.maxPackagesToSpawn);
                                }
                                else if (str6 == "SPAWNONEOFEACH")
                                {
                                    bool.TryParse(strArray[1], out list2.spawnOneOfEach);
                                }
                                else if (str6 == "NODUPLICATES")
                                {
                                    bool.TryParse(strArray[1], out list2.noDuplicates);
                                }
                                else if (str6 == "PACKAGELIST")
                                {
                                    strArray = strArray[1].Split(new string[] { "\t" }, StringSplitOptions.RemoveEmptyEntries);
                                    item     = new LootSpawnList.LootWeightedEntry();
                                    if (!dictionary.ContainsKey(strArray[1]))
                                    {
                                        ConsoleSystem.LogError(string.Format("Package {0} has a reference to an spawn list named {1}, but it not exist.", list2.name, strArray[1]));
                                    }
                                    else
                                    {
                                        item.obj = dictionary[strArray[1]];
                                        float.TryParse(strArray[0], out item.weight);
                                        int.TryParse(strArray[2], out item.amountMin);
                                        int.TryParse(strArray[3], out item.amountMax);
                                        list3.Add(item);
                                        list2.LootPackages = list3.ToArray();
                                    }
                                }
                                else if (str6 == "PACKAGEITEM")
                                {
                                    strArray = strArray[1].Split(new string[] { "\t" }, StringSplitOptions.RemoveEmptyEntries);
                                    item     = new LootSpawnList.LootWeightedEntry {
                                        obj = DatablockDictionary.GetByName(strArray[1])
                                    };
                                    if (item.obj == null)
                                    {
                                        ConsoleSystem.LogError(string.Format("Package {0} has a reference to an item named {1}, but it not exist.", list2.name, strArray[1]));
                                    }
                                    else
                                    {
                                        float.TryParse(strArray[0], out item.weight);
                                        int.TryParse(strArray[2], out item.amountMin);
                                        int.TryParse(strArray[3], out item.amountMax);
                                        list3.Add(item);
                                        list2.LootPackages = list3.ToArray();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }