예제 #1
0
파일: DropPP.cs 프로젝트: dretax/DropPP
        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;
            }
        }