Beispiel #1
0
        private void LoadVariables()
        {
            // Reset configuration on developer mode
            if (Dev)
            {
                Config.Clear();
            }

            // General Settings
            string GS = "General Settings";

            AdvertsInterval         = GetConfig <int>(GS, "Adverts Interval (In Minutes)", 15);
            PluginPrefix            = GetConfig <string>(GS, "Plugin Prefix", "<white>[ <cyan>NOTIFIER<end> ]<end>");
            IconProfile             = GetConfig <string>(GS, "Icon Profile", "76561198235146288");
            RulesLanguage           = GetConfig <string>(GS, "Rules Default Language", "auto").ToUpper();
            TimeFormat              = GetConfig <string>(GS, "Time Format", "{hour}:{minute}:{second}");
            DateFormat              = GetConfig <string>(GS, "Date Format", "{day}/{month}/{year}");
            EnablePluginPrefix      = GetConfig <bool>(GS, "Enable Plugin Prefix", true);
            BroadcastToConsole      = GetConfig <bool>(GS, "Broadcast To Console", true);
            EnablePluginIcon        = GetConfig <bool>(GS, "Enable Plugin Icon", false);
            EnableJoinMessage       = GetConfig <bool>(GS, "Enable Join Message", true);
            EnableLeaveMessage      = GetConfig <bool>(GS, "Enable Leave Message", true);
            EnableAdvertMessages    = GetConfig <bool>(GS, "Enable Advert Messages", true);
            EnableScheduledMessages = GetConfig <bool>(GS, "Enable Scheduled Messages", false);
            EnableWelcomeMessage    = GetConfig <bool>(GS, "Enable Welcome Message", true);
            EnableLineSperators     = GetConfig <bool>(GS, "Enable Line Separators", true);
            NotifyHelicopter        = GetConfig <bool>(GS, "Notify Incoming Helicopter", true);
            NotifyAirdrop           = GetConfig <bool>(GS, "Notify Incoming Airdrop", false);
            HideAdmins              = GetConfig <bool>(GS, "Hide Admins", false);
            EnableBetterChatSupport = GetConfig <bool>(GS, "Enable BetterChat Support", false);
            EnableHelpTextSupport   = GetConfig <bool>(GS, "Enable HelpText Support", true);

            // Welcome Message
            SetConfig("Welcome Messages", new List <object>
            {
                "<size=20>Welcome <lightblue>{player.name}<end></size> (Level: {player.level})",
                "<orange><size=20>•</size><end> Type <orange>help<end> or <orange>/notifier help<end> for all available commands",
                "<orange><size=20>•</size><end> Please respect the server <orange>/rules<end>",
                "<orange><size=20>•</size><end> Check our live map at <lime>http://{server.ip}:{server.port}<end>"
            }
                      );

            // Advert Messages
            SetConfig("Advert Messages", new List <object>
            {
                "Please be respectful with all the other players",
                "Cheating or abusing of game exploits may result in a <red>permanent<end> ban.",
                "You are playing on: <orange>{server.hostname}<end>",
                "There are <orange>{players.active}<silver>/<end>{server.maxplayers} <silver>players playing in the server, and<end> {players.sleepers}<end> sleepers.",
                "Check <cyan>Notifier's<end> commands with <orange>/notifier help<end> command."
            }
                      );

            // Scheduled Messages
            SetConfig("Schedule Messages", new Dictionary <string, object>
            {
                {
                    "00:46", new List <object> {
                        "It is now <orange>{localtime.now}<end> (Server local time)"
                    }
                },
                {
                    "00:47", new List <object> {
                        "It is now <orange>{localtime.date} {localtime.now}<end> (Server local time)"
                    }
                }
            }
                      );

            // Server Rules
            SetConfig("Rules", "EN", new List <object> {
                "Cheating is strictly prohibited",
                "Respect all players",
                "Don't spam the chat",
                "Do not abuse of bugs or exploits"
            }
                      );
            SetConfig("Rules", "PT", new List <object> {
                "Usar cheats é estritamente proibido",
                "Respeita todos os jogadores",
                "Não spames o chat",
                "Não abuses de bugs ou exploits"
            }
                      );
            SetConfig("Rules", "FR", new List <object> {
                "Tricher est strictement interdit.",
                "Respectez tous les joueurs.",
                "Évitez le spam dans le chat.",
                "Jouer juste et ne pas abuser des bugs / exploits."
            }
                      );
            SetConfig("Rules", "ES", new List <object> {
                "Los trucos están terminantemente prohibidos.",
                "Respeta a todos los jugadores.",
                "Evita el Spam en el chat.",
                "Juega limpio y no abuses de bugs/exploits."
            }
                      );
            SetConfig("Rules", "DE", new List <object> {
                "Cheaten ist verboten!",
                "Respektiere alle Spieler",
                "Spam im Chat zu vermeiden.",
                "Spiel fair und missbrauche keine Bugs oder Exploits."
            }
                      );
            SetConfig("Rules", "TR", new List <object> {
                "Hile kesinlikle yasaktır.",
                "Tüm oyuncular Saygı.",
                "Sohbet Spam kaçının.",
                "Adil oynayın ve böcek / açıkları kötüye yok."
            }
                      );
            SetConfig("Rules", "IT", new List <object> {
                "Cheating è severamente proibito.",
                "Rispettare tutti i giocatori.",
                "Evitare lo spam in chat.",
                "Fair Play e non abusare di bug / exploit."
            }
                      );
            SetConfig("Rules", "DK", new List <object> {
                "Snyd er strengt forbudt.",
                "Respekter alle spillere.",
                "Undgå spam i chatten.",
                "Spil fair og misbrug ikke bugs / exploits."
            }
                      );
            SetConfig("Rules", "RU", new List <object> {
                "Запрещено использовать читы.",
                "Запрещено спамить и материться.",
                "Уважайте других игроков.",
                "Играйте честно и не используйте баги и лазейки."
            }
                      );
            SetConfig("Rules", "UA", new List <object> {
                "Обман суворо заборонено.",
                "Поважайте всіх гравців",
                "Щоб уникнути спаму в чаті.",
                "Грати чесно і не зловживати помилки / подвиги."
            }
                      );
            SetConfig("Rules", "NL", new List <object> {
                "Vals spelen is ten strengste verboden.",
                "Respecteer alle spelers",
                "Vermijd spam in de chat.",
                "Speel eerlijk en maak geen misbruik van bugs / exploits."
            }
                      );
            SetConfig("Rules", "RO", new List <object> {
                "Cheaturile sunt strict interzise!",
                "Respectați toți jucătorii!",
                "Evitați spamul în chat!",
                "Jucați corect și nu abuzați de bug-uri/exploituri!"
            }
                      );
            SetConfig("Rules", "HU", new List <object> {
                "Csalás szigorúan tilos.",
                "Tiszteld minden játékostársad.",
                "Kerüld a spammolást a chaten.",
                "Játssz tisztességesen és nem élj vissza a hibákkal."
            }
                      );
            SetConfig("Rules", "JP", new List <object> {
                "チート行為は固く禁じております。",
                "全てのプレイヤーに敬意を払って下さい。",
                "チャットでスパム行為はしないで下さい。",
                "バグの悪用行為や公平なプレイはしないで下さい"
            }
                      );
            SetConfig("Rules", "CZ", new List <object> {
                "Cheatování je přísně zakázáno.",
                "Respektuj a neurážej ostatní hráče.",
                "Nespamuj chat zbytečně.",
                "Hraj fair play a nezneužívej bugy/exploity."
            }
                      );

            Rules = (Dictionary <string, object>)Config.Get("Rules");

            // Commands Section
            string cmds = "Commands";

            SetConfig(cmds, "Triggers", "Players List", new List <string> {
                "/players"
            });
            SetConfig(cmds, "Triggers", "Plugins List", new List <string> {
                "/plugins"
            });
            SetConfig(cmds, "Triggers", "Admins List", new List <string> {
                "/admins"
            });
            SetConfig(cmds, "Triggers", "Players Count", new List <string> {
                "/online"
            });
            SetConfig(cmds, "Triggers", "Server Map", new List <string> {
                "/map"
            });
            SetConfig(cmds, "Triggers", "Server Rules", new List <string> {
                "/rules"
            });

            SetConfig(cmds, "Settings", "Players List", true);
            SetConfig(cmds, "Settings", "Plugins List", false);
            SetConfig(cmds, "Settings", "Admins List", false);
            SetConfig(cmds, "Settings", "Server Rules", true);
            SetConfig(cmds, "Settings", "Server Map", false);
            SetConfig(cmds, "Settings", "Players Count", false);

            // Save file
            SaveConfig();
        }
Beispiel #2
0
 protected override void LoadDefaultConfig()
 {
     Config.Clear();
     LoadVariables();
 }
Beispiel #3
0
        protected override void LoadDefaultConfig()
        {
            // -- [ RESET ] ---
            Config.Clear();
            Puts("No configuration file found, generating...");
            // -- [ SETTINGS ] ---
            Config["_Settings", "Multiplier"]         = VANILLA_MULTIPLIER;
            Config["_Settings", "ItemListMultiplier"] = VANILLA_MULTIPLIER;

            Config["_Settings", "MultiplyOnlyItemList"]             = false;
            Config["_Settings", "RandomWorkshopSkins"]              = true;
            Config["_Settings", "ForceRefreshDisabledCratesOnLoad"] = false;
            Config["_Settings", "ReportMissingConfigCrates"]        = true;
            Config["_Settings", "DisableBlueprintDropMultiplier"]   = true;
            Config["_Settings", "DisableBlueprintDrops"]            = false;

            Config["ExtraLoot", "Enabled"] = false;
            Config["ExtraLoot", "VanillaLootTablesOnly"] = true;
            Config["ExtraLoot", "ExtraItemsMin"]         = 1;
            Config["ExtraLoot", "ExtraItemsMax"]         = 3;
            Config["ExtraLoot", "ItemStackSizeMin"]      = 1;
            Config["ExtraLoot", "PreventDuplicates"]     = false;


            Config["DeveloperDebug", "_EnableLogs"]  = false;
            Config["DeveloperDebug", "Skins"]        = false;
            Config["DeveloperDebug", "AmountChange"] = false;
            Config["DeveloperDebug", "ExtraItem"]    = false;
            Config["DeveloperDebug", "LootRefresh"]  = false;


            //Exclude.list.Add("supply.signal");
            Exclude.list.Add("ammo.rocket.smoke");
            Config["Exclude"] = Exclude;

            ExcludeFromMultiplication.list.Add("crude.oil");
            Config["ExcludeFromMultiplication"] = ExcludeFromMultiplication;

            if (INIT)
            {
                foreach (ItemDefinition q in ItemManager.itemList.Where(p => p.category == ItemCategory.Component))
                {
                    Components.list.Add(q.shortname, 1.0);
                }
                Components.list.Add("antiradpills", 1.0);
                Components.list.Add("wood", 1.0);
                Components.list.Add("apple", 1.0);
                Components.list.Add("chocholate", 1.0);
                Components.list.Add("granolabar", 1.0);
                Components.list.Add("can.beans", 1.0);
                Components.list.Add("can.tuna", 1.0);
                Components.list.Add("metal.fragments", 1.0);
                Components.list.Add("lowgradefuel", 1.0);
                Components.list.Add("largemedkit", 1.0);
                Components.list.Add("syringe.medical", 1.0);
                Components.list.Add("black.raspberries", 1.0);
                Components.list.Add("blueberries", 1.0);
                Components.list.Add("bandage", 1.0);
                Components.list.Add("metal.refined", 1.0);
                Components.list.Add("scrap", 1.0);
            }
            else
            {
                LoadedDefaultConfig = true;
            }



            Puts("Added " + Components.list.Count.ToString() + " components to configuration file.");
            Config["ItemList"] = Components;

            //foreach (var container in UnityEngine.Resources.FindObjectsOfTypeAll<LootContainer>().Where(c => c.isActiveAndEnabled).Cast<BaseEntity>().GroupBy(c => c.ShortPrefabName))
            if (INIT)
            {
                foreach (var container in UnityEngine.Resources.FindObjectsOfTypeAll <LootContainer>().Where(c => c.enabled).Cast <BaseEntity>().GroupBy(c => c.ShortPrefabName).OrderBy(c => c.Key))
                {
                    Crates.list.Add(container.Key.ToString(), new CrateData());
                }
            }
            else
            {
                LoadedDefaultConfig = true;
            }

            //if (!Crates.list.ContainsKey("crate_elite")) Crates.list.Add("crate_elite", true);
            //if (!Crates.list.ContainsKey("bradley_crate")) Crates.list.Add("bradley_crate", false);
            //if (!Crates.list.ContainsKey("heli_crate")) Crates.list.Add("heli_crate", false);
            //if (!Crates.list.ContainsKey("supply_drop")) Crates.list.Add("supply_drop", false);
            Config["LootContainersEnabled"] = Crates;
        }
Beispiel #4
0
 void LoadDefaultConfig()
 {
     Puts("Event Deathmatch: Creating a new config file");
     Config.Clear();
     LoadVariables();
 }
 void LoadDefaultConfig()
 {
     Puts("Creating a new config file");
     Config.Clear();
     LoadVariables();
 }
Beispiel #6
0
 protected override void LoadDefaultConfig()
 {
     Puts("RemoverTool: Creating a new config file");
     Config.Clear();
     LoadVariables();
 }
Beispiel #7
0
        protected override void LoadDefaultConfig()
        {
            if (Config.Exists())
            {
                Config.Clear();
            }

            Config["Version"] = this.Version.ToString();

            #region paper
            // just took required blueprint.fragment * 1.5 / 10 for standard, because we are all bad blueprint-drawers and it will already take a lot of wood with this
            // (1)paper = 100 wood (if not changed by other plugin) ; Common = 300 wood ; Uncommon = 4.5k wood ; Rare = 9k wood ; VeryRare = 18k wood

            Config["Paper", "Common"] = 3;

            Config["Paper", "Uncommon"] = 45;

            Config["Paper", "Rare"] = 90;

            Config["Paper", "VeryRare"] = 180;

            Config["Paper", "None"] = 1;
            #endregion
            #region blueprintparts
            Config["BlueprintParts", "Common"] = 2;

            //Config["BlueprintParts", "CommonType"] = "blueprint_fragment";

            Config["BlueprintParts", "Uncommon"] = 4;

            //Config["BlueprintParts", "UncommonType"] = "blueprint_page";

            Config["BlueprintParts", "Rare"] = 8;

            //Config["BlueprintParts", "RareType"] = "blueprint_book";

            Config["BlueprintParts", "VeryRare"] = 16;

            // Config["BlueprintParts", "VeryRareType"] = "blueprint_library";

            Config["BlueprintParts", "None"] = 1;

            //Config["BlueprintParts", "NoneType"] = "blueprint_fragment";
            #endregion
            #region drawtime
            Config["DrawTime", "Common"] = 10;

            Config["DrawTime", "Uncommon"] = 30;

            Config["DrawTime", "Rare"] = 60;

            Config["DrawTime", "VeryRare"] = 120;

            Config["DrawTime", "None"] = 0;
            #endregion
            #region drawtimemodifier
            Config["DrawTimeModifierMultiuse", "Common"] = 5;

            Config["DrawTimeModifierMultiuse", "Uncommon"] = 15;

            Config["DrawTimeModifierMultiuse", "Rare"] = 30;

            Config["DrawTimeModifierMultiuse", "VeryRare"] = 60;

            Config["DrawTimeModifierMultiuse", "None"] = 0;
            #endregion
            #region settings
            Config["Settings", "CancelBPWhenDead"] = true;

            Config["Settings", "PaperUsageAllowed"] = true;

            Config["Settings", "BlueprintPartsUsageAllowed"] = false;

            Config["Settings", "EnablePopups"] = false;

            Config["Settings", "EnableDrawTimeModifier"] = false;

            Config["Settings", "AllowMultiUseBPs"] = true;
            #endregion
            #region localization
            Config["Localization", "NotEnoughPaper"] = "The required ammount of paper to create this blueprint is {0} and you only have {1}.";

            Config["Localization", "NotEnoughBluePrintParts"] = "The required ammount of research paper to create this blueprint is {0} and you only have {1}.";

            Config["Localization", "BPNotLearned"] = "You don't know the blueprint for this item, learn it yourself first.";

            Config["Localization", "BPIsDrawing"] = "Blueprint is drawing now, please wait {0} seconds.";

            Config["Localization", "BPDelivery"] = "You finished drawing a blueprint for {0}.";

            Config["Localization", "BPRemovedFromQueue"] = "You are dead and can't finish drawing the blueprint for {0}.";

            Config["Localization", "AlreadyDrawing"] = "You are already drawing a blueprint, please wait until this is finished.";

            Config["Localization", "ItemNotFound"] = "An item with the name \"{0}\" was not found.";

            Config["Localization", "NoBP"] = "No blueprint for this item possible.";

            Config["Localization", "Help"] = "Use /blueprinter [ITEM] to create a blueprint from your known items.";

            Config["Localization", "NoPermission"] = "You have no permission to use this command.";
            #endregion
            #region itemalias
            foreach (ItemDefinition itemDef in ItemManager.itemList)
            {
                if (ItemManager.FindBlueprint(itemDef) != null &&
                    !ItemManager.FindBlueprint(itemDef).defaultBlueprint)
                {
                    Config["ZItemAlias", itemDef.shortname] = itemDef.displayName.english; // only putting the Z here so it won't show before the other things in the config
                }
            }
            //Config["ZItemAlias", "blueprint_fragment"] = "Blueprint Fragment";
            //
            //Config["ZItemAlias", "blueprint_page"] = "Blueprint Page";
            //
            //Config["ZItemAlias", "blueprint_book"] = "Blueprint Book";
            //
            //Config["ZItemAlias", "blueprint_library"] = "Blueprint Library";

            Config["ZItemAlias", "researchpaper"] = "Research Paper";
            #endregion
            #region permission
            if (!permission.PermissionExists("blueprinter.canuse"))
            {
                permission.RegisterPermission("blueprinter.canuse", this);
            }

            if (!permission.GroupHasPermission("player", "blueprinter.canuse"))
            {
                permission.GrantGroupPermission("player", "blueprinter.canuse", this);
            }

            if (!permission.GroupHasPermission("moderator", "blueprinter.canuse"))
            {
                permission.GrantGroupPermission("moderator", "blueprinter.canuse", this);
            }

            if (!permission.GroupHasPermission("admin", "blueprinter.canuse"))
            {
                permission.GrantGroupPermission("admin", "blueprinter.canuse", this);
            }
            #endregion

            SaveConfig();

            PrintWarning("Blueprinter created new config.");
        }
        /*private static void StripObject(JSONObject obj)
         * {
         *  if (obj == null) return;
         *  var keys = obj.Select(entry => entry.Key).ToList();
         *  foreach (var key in keys)
         *  {
         *      if (!key.Equals("shortname") && !key.Equals("itemid"))
         *          obj.Remove(key);
         *  }
         * }
         *
         * private static void StripArray(JSONArray arr, string key)
         * {
         *  if (arr == null) return;
         *  foreach (var obj in arr)
         *  {
         *      StripObject(obj.Obj[key].Obj);
         *  }
         * }*/

        private bool CreateDefaultConfig()
        {
            Config.Clear();
            Config["Version"]       = Protocol.network;
            Config["VersionConfig"] = VersionConfig;
            var constructions = new Dictionary <string, object>();

            Config["Constructions"] = constructions;
            var deployables = new Dictionary <string, object>();

            Config["Deployables"] = deployables;
            var protectionProperties = new HashSet <ProtectionProperties>();
            var constructionPrefabs  = PrefabAttribute.server.GetAll <Construction>();

            foreach (var construct in constructionPrefabs)
            {
                if (construct.deployable != null)
                {
                    var entity     = GameManager.server.FindPrefab(StringPool.Get(construct.deployable.prefabID)).GetComponent <BaseCombatEntity>();
                    var deployable = new Dictionary <string, object>();
                    deployable["health"] = entity.startHealth;
                    if (entity.baseProtection != null)
                    {
                        protectionProperties.Add(entity.baseProtection);
                        deployable["protection"] = entity.baseProtection.name;
                    }
                    deployables[construct.fullName] = deployable;
                    continue;
                }
                var construction = new Dictionary <string, object>();
                var grades       = new Dictionary <string, object>();
                construction["costMultiplier"]   = construct.costMultiplier;
                construction["healthMultiplier"] = construct.healthMultiplier;
                for (var g = 0; g < construct.grades.Length; g++)
                {
                    var grade = construct.grades[g];
                    if (grade == null)
                    {
                        continue;
                    }
                    var dict = new Dictionary <string, object>();
                    dict["baseHealth"] = grade.gradeBase.baseHealth;
                    var costToBuild = ToJsonArray(grade.gradeBase.baseCost);
                    foreach (var cost in costToBuild)
                    {
                        cost.Obj["shortname"] = cost.Obj.GetObject("itemDef").GetString("shortname", "unnamed");
                        cost.Obj.Remove("itemid");
                        cost.Obj.Remove("itemDef");
                    }
                    dict["baseCost"] = JsonObjectToObject(costToBuild);
                    if (grade.gradeBase.damageProtecton != null)
                    {
                        protectionProperties.Add(grade.gradeBase.damageProtecton);
                    }
                    grades[((BuildingGrade.Enum)g).ToString()] = dict;
                }
                construction["grades"]            = grades;
                constructions[construct.fullName] = construction;
            }
            var protections = new Dictionary <string, object>();

            Config["DamageProtections"] = protections;
            foreach (var protectionProperty in protectionProperties)
            {
                var damageProtection = new Dictionary <string, object>();
                for (var i = 0; i < protectionProperty.amounts.Length; i++)
                {
                    damageProtection[Enum.GetName(typeof(DamageType), i)] = protectionProperty.amounts[i];
                }
                protections[protectionProperty.name] = damageProtection;
            }
            var directionProperties = PrefabAttribute.server.GetAll <DirectionProperties>();

            if (directionProperties != null)
            {
                var directions = new Dictionary <string, object>();
                Config["DirectionProperties"] = directions;
                foreach (var directionProperty in directionProperties)
                {
                    //Puts("DirectionProperty: {0} Radius: {1} Dupe: {2}", directionProperty.fullName, directionProperty.radius, directions.ContainsKey(directionProperty.fullName));
                    var direction = new Dictionary <string, object>();
                    direction["center"] = Vector3ToString(directionProperty.bounds.center);
                    direction["size"]   = Vector3ToString(directionProperty.bounds.size);
                    if (directionProperty.extraProtection?.amounts != null)
                    {
                        var damageProtection = new Dictionary <string, object>();
                        for (var i = 0; i < directionProperty.extraProtection.amounts.Length; i++)
                        {
                            damageProtection[Enum.GetName(typeof(DamageType), i)] = directionProperty.extraProtection.amounts[i];
                        }
                        direction["extraProtection"] = damageProtection;
                    }
                    directions[directionProperty.fullName] = direction;
                }
            }
            try
            {
                Config.Save(_configpath);
            }
            catch (Exception e)
            {
                Puts(e.Message);
                return(false);
            }
            Puts("Created new config");
            return(LoadConfig());
        }
        protected override void LoadDefaultConfig()
        {
            Puts("Creating a new config file");
            Config.Clear();

            SetConfig("Storage Container", "refinery_small_deployed", new List <object>
            {
                "wood",
                "crude.oil",
                "lowgradefuel"
            });

            SetConfig("Storage Container", "furnace", new List <object> {
                "wood",
                "charcoal",
                "sulfur.ore",
                "sulfur",
                "metal.ore",
                "metal.fragments",
                "hq.metal.ore",
                "metal.refined"
            });
            SetConfig("Storage Container", "furnace.large", new List <object>
            {
                "wood",
                "charcoal",
                "sulfur.ore",
                "sulfur",
                "metal.ore",
                "metal.fragments",
                "hq.metal.ore",
                "metal.refined"
            });
            SetConfig("Storage Container", "campfire", new List <object>
            {
                "wood",
                "charcoal",
                "bearmeat",
                "bearmeat.burned",
                "bearmeat.cooked",
                "humanmeat.burned",
                "humanmeat.cooked",
                "humanmeat.raw",
                "humanmeat.spoiled",
                "meat.boar",
                "meat.pork.burned",
                "meat.pork.cooked",
                "wolfmeat.burned",
                "wolfmeat.cooked",
                "wolfmeat.raw",
                "wolfmeat.spoiled",
                "chicken.burned",
                "chicken.cooked",
                "chicken.raw",
                "chicken.spoiled",
                "fish.raw",
                "fish.cooked"
            });
            SetConfig("Storage Container", "fuelstorage", new List <object>
            {
                "lowgradefuel"
            });
            SetConfig("Storage Container", "hopperoutput", new List <object>
            {
                "sulfur.ore",
                "metal.ore",
                "metal.fragments",
                "hq.metal.ore",
                "stones"
            });
            SetConfig("Storage Container", "crudeoutput", new List <object>
            {
                "crude.oil"
            });
            SaveConfig();
            LoadVariables();
        }
Beispiel #10
0
 protected override void LoadDefaultConfig() => Config.Clear();
Beispiel #11
0
 void LoadDefaultConfig()
 {
     Puts("No configuration file found, generating...");
     Config.Clear();
     LoadVariables();
 }
Beispiel #12
0
 void LoadDefaultConfig()
 {
     Puts("Event Battlefield: Creating a new config file");
     Config.Clear();
     LoadVariables();
 }
Beispiel #13
0
 void LoadDefaultConfig()
 {
     Config.Clear();
     LoadVariables();
 }
Beispiel #14
0
 void LoadDefaultConfig()
 {
     Puts("Airdrop Control: Creating a new config file");
     Config.Clear(); // force clean new config
     LoadVariables();
 }
Beispiel #15
0
 protected override void LoadDefaultConfig()
 {
     PrintWarning("Creating a configuration file.");
     Config.Clear();
 }
        private bool CreateDefaultConfig()
        {
            Config.Clear();
            Config["Version"] = Protocol.network;
            var constructions = new Dictionary <string, object>();

            Config["Constructions"] = constructions;
            var protectionProperties = new HashSet <ProtectionProperties>();
            var constructionPrefabs  = PrefabAttribute.server.GetAll <Construction>();

            foreach (var construct in constructionPrefabs)
            {
                var construction = new Dictionary <string, object>();
                var grades       = new Dictionary <string, object>();
                construction["costMultiplier"]   = construct.costMultiplier;
                construction["healthMultiplier"] = construct.healthMultiplier;
                for (var g = 0; g < construct.grades.Length; g++)
                {
                    var grade = construct.grades[g];
                    if (grade == null)
                    {
                        continue;
                    }
                    var dict = new Dictionary <string, object>();
                    dict["baseHealth"] = grade.gradeBase.baseHealth;
                    var costToBuild = ToJsonArray(grade.gradeBase.baseCost);
                    foreach (var cost in costToBuild)
                    {
                        cost.Obj["itemDef"] = cost.Obj.GetObject("itemDef").GetString("shortname", "unnamed");
                    }
                    dict["baseCost"] = JsonObjectToObject(costToBuild);
                    if (grade.gradeBase.damageProtecton != null)
                    {
                        protectionProperties.Add(grade.gradeBase.damageProtecton);
                    }
                    grades[((BuildingGrade.Enum)g).ToString()] = dict;
                }
                construction["grades"] = grades;
                constructions[construct.hierachyName] = construction;
            }
            var protections = new Dictionary <string, object>();

            Config["DamageProtections"] = protections;
            foreach (var protectionProperty in protectionProperties)
            {
                var damageProtection = new Dictionary <string, object>();
                for (var i = 0; i < protectionProperty.amounts.Length; i++)
                {
                    damageProtection[Enum.GetName(typeof(DamageType), i)] = protectionProperty.amounts[i];
                }
                protections[protectionProperty.name] = damageProtection;
            }
            try
            {
                Config.Save(_configpath);
            }
            catch (Exception e)
            {
                LocalPuts(e.Message);
                return(false);
            }
            LocalPuts("Created new config");
            return(LoadConfig());
        }
Beispiel #17
0
        void LoadConfigData()
        {
            var version = (string)Config["Version"];

            //Load config
            rustServersKey = (string)ReadConfig("Rust-Servers - Api Key", rustServersKey);
            rustServersID  = (string)ReadConfig("Rust-Servers - Server ID", rustServersID);
            topRustKey     = (string)ReadConfig("TopRustServers - Api Key", topRustKey);
            topRustID      = (string)ReadConfig("TopRustServers - Server ID", topRustID);
            beancanKey     = (string)ReadConfig("BeancanIO - Api Key", beancanKey);
            beancanID      = (string)ReadConfig("BeancanIO - Server ID", beancanID);
            voteType       = (string)ReadConfig("Vote Type", voteType);
            voteInterval   = Convert.ToInt16(ReadConfig("Vote Interval", voteInterval));
            useRP          = Convert.ToBoolean(ReadConfig("Use RP", useRP));
            useEconomics   = Convert.ToBoolean(ReadConfig("Use Economics", useEconomics));
            useKits        = Convert.ToBoolean(ReadConfig("Use Kits", useKits));
            prefix         = (string)ReadConfig("Prefix", prefix);

            var oldMoney = "";
            var oldRP    = "";
            var oldKit   = "";

            if (version == null || version == "0.1.0")
            {
                oldMoney = (string)ReadConfig("Money", oldMoney);
                oldRP    = (string)ReadConfig("RP", oldRP);
                oldKit   = (string)ReadConfig("Kit", oldKit);
            }
            else
            {
                money = ConvertToDictionary(ReadConfig("Money", money), money);
                rp    = ConvertToDictionary(ReadConfig("RP", rp), rp);
                kits  = ConvertToDictionary(ReadConfig("Kits", kits), kits);
            }

            if (version == null || version != configVersion)
            {
                PrintWarning("Configuration is outdate. Update in progress...");
                Config.Clear();

                SetConfig("Rust-Servers - Api Key", rustServersKey);
                SetConfig("Rust-Servers - Server ID", rustServersID);
                SetConfig("TopRustServers - Api Key", topRustKey);
                SetConfig("TopRustServers - Server ID", topRustID);
                SetConfig("BeancanIO - Api Key", beancanKey);
                SetConfig("BeancanIO - Server ID", beancanID);
                SetConfig("Vote Type", voteType);
                SetConfig("Vote Interval", voteInterval);
                SetConfig("Use Economics", useEconomics);
                SetConfig("Use RP", useRP);
                SetConfig("Use Kits", useKits);
                SetConfig("Prefix", prefix);

                if (version == null || version == "0.1.0")
                {
                    money = new Dictionary <string, string> {
                        { "default", oldMoney }
                    };
                    SetConfig("Money", money);
                    rp = new Dictionary <string, string> {
                        { "default", oldRP }
                    };
                    SetConfig("RP", rp);
                    kits = new Dictionary <string, string> {
                        { "default", oldKit }
                    };
                    SetConfig("Kits", kits);
                }
                else
                {
                    SetConfig("Money", money);
                    SetConfig("RP", rp);
                    SetConfig("Kits", kits);
                }

                SetConfig("Version", configVersion);
            }
        }
Beispiel #18
0
        private bool CreateDefaultConfig()
        {
            Config.Clear();
            _config = new ConfigData
            {
                Version       = Protocol.network,
                VersionConfig = VersionConfig,
                WorldSize     = World.Size,
                WorldSeed     = World.Seed
            };
            var AllSpawnPopulations = (SpawnPopulation[])AllSpawnPopulationsField.GetValue(SpawnHandler.Instance);

            foreach (var population in AllSpawnPopulations)
            {
                var data = ToJsonString(population);
                //if ((int)population.Filter.BiomeType < 0)
                //    Puts("Bits: {0} Inv: {1}", Convert.ToString((int)population.Filter.BiomeType, 2), Convert.ToString((int)ToObject<TerrainBiomeEnum>("\"EVERYTHING, "+ToJsonString((TerrainBiomeEnum)~(int)population.Filter.BiomeType).Substring(1)), 2));
                var populationData = ToObject <SpawnPopulationData>(data);
                var prefabs        = (Prefab <Spawnable>[])PrefabsField.GetValue(population);
                if (prefabs == null || prefabs.Length == 0)
                {
                    if (!string.IsNullOrEmpty(population.ResourceFolder))
                    {
                        PrefabsField.SetValue(population, Prefab.Load <Spawnable>(string.Concat("assets/bundled/prefabs/autospawn/", population.ResourceFolder), GameManager.server, PrefabAttribute.server));
                    }
                    if (population.ResourceList != null && population.ResourceList.Length > 0)
                    {
                        PrefabsField.SetValue(population, Prefab.Load <Spawnable>(population.ResourceList.Select(x => x.resourcePath).ToArray(), GameManager.server, PrefabAttribute.server));
                    }
                }
                //if (population.ResourceList != null) populationData.ResourceList.AddRange(population.ResourceList.Select(r => r.resourcePath));
                prefabs = (Prefab <Spawnable>[])PrefabsField.GetValue(population);
                var counts = prefabs.GroupBy(x => x.Name).ToDictionary(g => g.Key, g => g.Count());
                foreach (var prefab in counts)
                {
                    populationData.Prefabs.Add(new PrefabData {
                        Prefab = prefab.Key, Weight = prefab.Value
                    });
                }
                if (_config.SpawnPopulations.ContainsKey(population.name))
                {
                    Puts("SpawnPopulation key already exists: {0}", population.name);
                }
                _config.SpawnPopulations[population.name] = populationData;
            }

            var monuments   = Resources.FindObjectsOfTypeAll <MonumentInfo>();
            var spawnGroups = (List <SpawnGroup>)SpawnGroupsField.GetValue(SpawnHandler.Instance);
            var indexes     = GetSpawnGroupIndexes(spawnGroups, monuments);

            foreach (var spawnGroup in spawnGroups)
            {
                var data           = ToJsonString(spawnGroup);
                var spawnGroupData = ToObject <SpawnGroupData>(data);
                foreach (var spawnEntry in spawnGroup.prefabs)
                {
                    var baseNetworkable = spawnEntry.prefab?.Get()?.GetComponent <BaseNetworkable>();
                    if (baseNetworkable == null)
                    {
                        continue;
                    }
                    spawnGroupData.Prefabs.Add(new SpawnEntryData {
                        Prefab = baseNetworkable.PrefabName, Weight = spawnEntry.weight, Mobile = spawnEntry.mobile
                    });
                }
                var spawnPoints = (BaseSpawnPoint[])SpawnPointsField.GetValue(spawnGroup);
                foreach (var spawnPoint in spawnPoints)
                {
                    var spawnPointData = new SpawnPointData {
                        Position = $"{spawnPoint.transform.position.x} {spawnPoint.transform.position.y} {spawnPoint.transform.position.z}"
                    };
                    if (spawnPoint is GenericSpawnPoint)
                    {
                        spawnPointData.DropToGround = ((GenericSpawnPoint)spawnPoint).dropToGround;
                        spawnPointData.RandomRot    = ((GenericSpawnPoint)spawnPoint).randomRot;
                    }
                    else if (spawnPoint is RadialSpawnPoint)
                    {
                        spawnPointData.Radius = ((RadialSpawnPoint)spawnPoint).radius;
                    }
                    spawnGroupData.SpawnPoints[spawnPoint.name] = spawnPointData;
                }
                var key = GetSpawnGroupKey(spawnGroup, monuments, indexes);
                if (_config.SpawnGroups.ContainsKey(key))
                {
                    Puts("SpawnGroup key already exists: {0}", key);
                }
                _config.SpawnGroups[key] = spawnGroupData;
            }

            try
            {
                Config.WriteObject(_config);
            }
            catch (Exception e)
            {
                Puts("Config save failed: {0}{1}{2}", e.Message, Environment.NewLine, e.StackTrace);
                return(false);
            }
            Puts("Created new config");
            return(LoadConfig());
        }
Beispiel #19
0
        private bool CreateDefaultConfig()
        {
            Config.Clear();
            Config["Version"] = Protocol.network;
            var itemList = Resources.LoadAll <ItemDefinition>("items/").ToList();
            var bpList   = Resources.LoadAll <ItemBlueprint>("items/").ToList();
            var items    = new JSONArray();

            foreach (var definition in itemList)
            {
                var obj      = ToJsonObject(definition);
                var mods     = definition.GetComponentsInChildren <ItemMod>(true);
                var modArray = new JSONArray();
                foreach (var itemMod in mods)
                {
                    if (itemMod.GetType() == typeof(ItemModMenuOption))
                    {
                        continue;
                    }
                    var mod = ToJsonObject(itemMod);
                    if (itemMod.GetType() == typeof(ItemModBurnable))
                    {
                        StripObject(mod["byproductItem"].Obj);
                    }
                    else if (itemMod.GetType() == typeof(ItemModCookable))
                    {
                        StripObject(mod["becomeOnCooked"].Obj);
                    }
                    else if (itemMod.GetType() == typeof(ItemModConsume))
                    {
                        mod["effects"] = ToJsonArray(itemMod.GetComponent <ItemModConsumable>().effects);
                    }
                    else if (itemMod.GetType() == typeof(ItemModSwap))
                    {
                        var becomeItems = mod["becomeItem"].Array;
                        foreach (var entry in becomeItems)
                        {
                            entry.Obj["itemDef"] = entry.Obj.GetObject("itemDef").GetString("shortname", "unnamed");
                        }
                    }
                    if (!mod.Any())
                    {
                        continue;
                    }
                    mod["type"] = itemMod.GetType().FullName;
                    modArray.Add(mod);
                }
                var modProjectile = definition.GetComponent <ItemModProjectile>();
                if (modProjectile != null)
                {
                    var projectile = modProjectile.projectileObject.targetObject.GetComponent <Projectile>();
                    var mod        = ToJsonObject(projectile);
                    mod.Remove("sourceWeapon");
                    mod.Remove("projectileID");
                    mod.Remove("seed");
                    mod.Remove("velocityScalar");
                    mod["type"] = modProjectile.GetType().FullName;
                    modArray.Add(mod);
                }
                obj["modules"] = modArray;

                items.Add(obj);
            }
            Config["Items"] = JsonObjectToObject(items);
            var bps = ToJsonArray(bpList);

            foreach (var bp in bps)
            {
                StripObject(bp.Obj["targetItem"].Obj);
                foreach (var ing in bp.Obj.GetArray("ingredients"))
                {
                    ing.Obj["itemDef"] = ing.Obj.GetObject("itemDef").GetString("shortname", "unnamed");
                }
            }
            Config["Blueprints"] = JsonObjectToObject(bps);

            /*var constructions = new Dictionary<string, object>();
             * Config["Constructions"] = constructions;
             * var protectionProperties = new HashSet<ProtectionProperties>();
             * var constructionSkinArray = Resources.LoadAll<ConstructionSkin>("Prefabs/build/skins");
             * var constructionArray = Resources.LoadAll<Construction>("Prefabs/build/");
             * foreach (var construct in constructionArray)
             * {
             *  var common = new Construction.Common(construct, constructionSkinArray);
             *  var construction = new Dictionary<string, object>();
             *  var grades = new Dictionary<string, object>();
             *  for (var g = 0; g < common.grades.Length; g++)
             *  {
             *      var grade = common.grades[g];
             *      if (grade == null) continue;
             *      var dict = new Dictionary<string, object>();
             *      dict["maxHealth"] = grade.maxHealth;
             *      var costToBuild = ToJsonArray(grade.costToBuild);
             *      foreach (var cost in costToBuild)
             *      {
             *          cost.Obj["itemDef"] = cost.Obj.GetObject("itemDef").GetString("shortname", "unnamed");
             *      }
             *      dict["costToBuild"] = JsonObjectToObject(costToBuild);
             *      if (grade.damageProtecton != null)
             *      {
             *          protectionProperties.Add(grade.damageProtecton);
             *      }
             *      grades[((BuildingGrade.Enum)g).ToString()] = dict;
             *  }
             *  construction["grades"] = grades;
             *  constructions[common.name] = construction;
             * }
             * var protections = new Dictionary<string, object>();
             * Config["DamageProtections"] = protections;
             * foreach (var protectionProperty in protectionProperties)
             * {
             *  var damageProtection = new Dictionary<string, object>();
             *  for (var i = 0; i < protectionProperty.amounts.Length; i++)
             *  {
             *      damageProtection[Enum.GetName(typeof(DamageType), i)] = protectionProperty.amounts[i];
             *  }
             *  protections[protectionProperty.name] = damageProtection;
             * }*/
            try
            {
                Config.Save(_configpath);
            }
            catch (Exception e)
            {
                LocalPuts(e.Message);
                return(false);
            }
            LocalPuts("Created new config");
            return(LoadConfig());
        }
 protected override void LoadDefaultConfig()
 {
     Log("Created a new default configuration file.");
     Config.Clear();
     LoadVariables();
 }
Beispiel #21
0
 void LoadDefaultConfig()
 {
     Puts(string.Format(lang.GetMessage("noConfig", this)));
     Config.Clear();
     LoadVariables();
 }
Beispiel #22
0
 protected override void LoadDefaultConfig()
 {
     PrintWarning("No configuration file found, generating...");
     Config.Clear();
     LoadVariables();
 }
Beispiel #23
0
 void LoadDefaultConfig()
 {
     Config.Clear();
     Config["Enabled"] = false;
     Config.Save();
 }
 protected override void LoadDefaultConfig()
 {
     PrintWarning("New configuration file created");
     Config.Clear();
     LoadVariables();
 }
Beispiel #25
0
 protected override void LoadDefaultConfig()
 {
     Puts("Creating a new configuration file!");
     Config.Clear();
     LoadVariables();
 }
Beispiel #26
0
        void cmdChatJailSet(Player player, string command, string[] args)
        {
            if (!HasPermission(player, ConfigPermission))
            {
                PrintToChat(player, "[" + MessagePrefixColor + "]" + MessagePrefix + " [" + MessageTextColor + "]: " + ConfigPermissionRequired); return;
            }
            if (args.Length < 1)
            {
                ShowJailHelp(player);
            }
            switch (args[0].ToLower())
            {
            case "cell":
                JailX = (int)player.Entity.Position.x;
                JailY = (int)player.Entity.Position.y + 1;
                JailZ = (int)player.Entity.Position.z;
                PrintToChat(player, "Center of Jail Cell has been set.");
                if (ConsoleSpam)
                {
                    Puts("Center of Jail Cell has been set.");
                }
                break;

            case "radius":
                JailRadius = Int32.Parse(args[1]);
                PrintToChat(player, "Jail Cell Radius has been set to " + JailRadius + ".");
                if (ConsoleSpam)
                {
                    Puts("Jail Cell Radius has been set to " + JailRadius + ".");
                }
                break;

            case "rollcall":
                RollCallInterval = Int32.Parse(args[1]);
                PrintToChat(player, "Roll Calls will occur every " + RollCallInterval + " seconds.");
                if (ConsoleSpam)
                {
                    Puts("Roll Calls will occur every " + RollCallInterval + " seconds.");
                }
                break;

            case "release":
                if (!player.HasPermission("admin"))
                {
                    PrintToChat(player, ConfigPermissionRequired); return;
                }
                ReleaseX = (int)player.Entity.Position.x;
                ReleaseY = (int)player.Entity.Position.y + 1;
                ReleaseZ = (int)player.Entity.Position.z;
                PrintToChat(player, "Inmate release point has been set.");
                if (ConsoleSpam)
                {
                    Puts("Inmate release point has been set.");
                }
                break;

            case "spam":
                switch (args[1].ToLower())
                {
                case "on":
                    ConsoleSpam = true;
                    PrintToChat(player, "Console Spam has been turned on.");
                    if (ConsoleSpam)
                    {
                        Puts("Console Spam has been turned on.");
                    }
                    break;

                case "off":
                    ConsoleSpam = false;
                    PrintToChat(player, "Console Spam has been turned off.");
                    if (ConsoleSpam)
                    {
                        Puts("Console Spam has been turned off.");
                    }
                    break;

                default:
                    PrintToChat(player, SyntaxErrorMsg);
                    if (ConsoleSpam)
                    {
                        Puts(SyntaxErrorMsg);
                    }
                    break;
                }
                break;

            case "nicknames":
                switch (args[1].ToLower())
                {
                case "on":
                    DisplayInmateNickname = true;
                    PrintToChat(player, "Inmate Nicknames have been turned on.");
                    if (ConsoleSpam)
                    {
                        Puts("Inmate Nicknames have been turned on.");
                    }
                    break;

                case "off":
                    DisplayInmateNickname = false;
                    PrintToChat(player, "Inmate Nicknames have been turned off.");
                    if (ConsoleSpam)
                    {
                        Puts("Inmate Nicknames have been turned off.");
                    }
                    break;

                default:
                    PrintToChat(player, SyntaxErrorMsg);
                    if (ConsoleSpam)
                    {
                        Puts(SyntaxErrorMsg);
                    }
                    break;
                }
                break;

            case "nickname":
                switch (args[1].ToLower())
                {
                case "inmate":
                    if (args[2] != "")
                    {
                        InmateNickname = args[2];
                        PrintToChat(player, "Inmate Nickname has been changed to " + InmateNickname + ".");
                        if (ConsoleSpam)
                        {
                            Puts("Inmate Nickname has been changed to " + InmateNickname + ".");
                        }
                    }
                    else
                    {
                        PrintToChat(player, SyntaxErrorMsg);
                        if (ConsoleSpam)
                        {
                            Puts(SyntaxErrorMsg);
                        }
                    }
                    break;

                default:
                    PrintToChat(player, SyntaxErrorMsg);
                    if (ConsoleSpam)
                    {
                        Puts(SyntaxErrorMsg);
                    }
                    break;
                }
                break;

            case "restore":
                Config.Clear();
                LoadConfigData();
                PrintToChat(player, "Jail Defaults have been restored.");
                if (ConsoleSpam)
                {
                    Puts("Jail Defaults have been restored.");
                }
                break;

            default:
                PrintToChat(player, SyntaxErrorMsg);
                if (ConsoleSpam)
                {
                    Puts(SyntaxErrorMsg);
                }
                return;

                break;
            }
            UpdateConfig();
        }
Beispiel #27
0
        private void Init()
        {
            lang.RegisterMessages(new Dictionary <string, string>
            {
                { "ChatName", "[Economy]" },
                { "NoPermission", "No Permission!" },
                { "NoPlayer", "No Player Found!" },
                { "New_Player_Balance", "New player balance: {0:C}" },
                { "Syntax_Error", "Syntax Error! /{0} <name/steamid> <money>" },
                { "Withdraw_Error", "'{0}' has not enough money!" },
                { "My_Balance", "Your Balance: {0:C}" },
                { "Received", "You received: {0:C}" },
                { "Lost", "You lost: {0:C}" },
                { "Balance", "Player Balance: {0:C}" },
                { "Transfer_Money_Error", "You do not have enough money!" },
                { "Transfer_Negative_Error", "Money can not be negative!" },
                { "Transfer_Error", "You can not transfer money yourself!" },
                { "Transfer_Success", "You have successfully transferred {1} money to '{0}'!" },
                { "Transfer_Success_To", "'{0}' has transferred {1} money to you! Check your balance '/balance'!" },
                { "Save_Success", "Economics data saved!" },
                { "Help1", "/balance - check your balance" },
                { "Help2", "/transfer <name> <money> - transfer [money] to [name] player for small fee" }
            }, this);

            data = Interface.Oxide.DataFileSystem.GetFile(nameof(Economics));
            data.Settings.Converters = new List <JsonConverter> {
                new RoundingJsonConverter(4)
            };

            try
            {
                configData = Config.ReadObject <ConfigData>();
                if (Config["Messages"] != null)
                {
                    Config.WriteObject(configData, true);
                }
            }
            catch
            {
                Config.Clear();
                LoadDefaultConfig();
                configData = Config.ReadObject <ConfigData>();
            }
            try
            {
                economicsData = data.ReadObject <Dictionary <ulong, double> >();
            }
            catch
            {
                economicsData = new Dictionary <ulong, double>();
                try
                {
                    var temp = data.ReadObject <Dictionary <ulong, int[]> >();
                    foreach (var intse in temp)
                    {
                        if (intse.Value.Length > 0 && !economicsData.ContainsKey(intse.Key))
                        {
                            economicsData.Add(intse.Key, intse.Value[0]);
                        }
                    }
                    changed = true;
                } catch { }
            }
            if (configData.CleanBase)
            {
                var players = economicsData.Keys.ToArray();
                foreach (var p in players)
                {
                    if (economicsData[p] == configData.StartMoney)
                    {
                        economicsData.Remove(p);
                    }
                }
                if (players.Length != economicsData.Count)
                {
                    changed = true;
                }
            }
            SaveEconomics();
            cmd.AddChatCommand(configData.Commands["Balance"], this, cmdBalance);
            cmd.AddChatCommand(configData.Commands["Deposit"], this, cmdDeposit);
            cmd.AddChatCommand(configData.Commands["SetMoney"], this, cmdSetMoney);
            cmd.AddChatCommand(configData.Commands["Transfer"], this, cmdTransfer);
            cmd.AddChatCommand(configData.Commands["Withdraw"], this, cmdWithdraw);
        }
Beispiel #28
0
        private bool CreateDefaultConfig()
        {
            Config.Clear();
            var loot          = Resources.FindObjectsOfTypeAll <LootSpawn>();
            var itemModReveal = Resources.FindObjectsOfTypeAll <ItemModReveal>();
            var itemModUnwrap = Resources.FindObjectsOfTypeAll <ItemModUnwrap>();

#if DEBUG
            var sb = new StringBuilder();
            foreach (var reveal in itemModReveal)
            {
                var items = new List <ItemAmount>();
                var stack = new Stack <LootSpawn>();
                stack.Push(reveal.revealList);
                while (stack.Count > 0)
                {
                    var lootSpawn = stack.Pop();
                    if (lootSpawn.subSpawn != null && lootSpawn.subSpawn.Length > 0)
                    {
                        foreach (var entry in lootSpawn.subSpawn)
                        {
                            stack.Push(entry.category);
                        }
                        continue;
                    }
                    if (lootSpawn.items != null)
                    {
                        items.AddRange(lootSpawn.items);
                    }
                }
                sb.Clear();
                sb.AppendLine(reveal.name);
                sb.AppendLine("Items:");
                foreach (var item in items)
                {
                    sb.AppendLine($"\t{item.itemDef.shortname}: {item.amount}");
                }
                Puts(sb.ToString());
            }
            Puts("LootContainer: {0} LootSpawn: {1} ItemModReveal: {2}", Resources.FindObjectsOfTypeAll <LootContainer>().Length, loot.Length, itemModReveal.Length);
#endif
            var caseInsensitiveComparer = new CaseInsensitiveComparer();
            Array.Sort(loot, (a, b) => caseInsensitiveComparer.Compare(a.name, b.name));
            Array.Sort(itemModReveal, (a, b) => caseInsensitiveComparer.Compare(a.name, b.name));
            Array.Sort(itemModUnwrap, (a, b) => caseInsensitiveComparer.Compare(a.name, b.name));
            var spawnGroupsData = new Dictionary <string, Dictionary <string, LootContainer> >();
            var spawnGroups     = (List <SpawnGroup>)SpawnGroupsField.GetValue(SpawnHandler.Instance);
            var monuments       = Resources.FindObjectsOfTypeAll <MonumentInfo>();
            var indexes         = GetSpawnGroupIndexes(spawnGroups, monuments);
            foreach (var spawnGroup in spawnGroups)
            {
                var spawnGroupKey = GetSpawnGroupKey(spawnGroup, monuments, indexes);
                if (spawnGroup.prefabs == null)
                {
                    continue;
                }
                foreach (var entry in spawnGroup.prefabs)
                {
                    var container = entry.prefab?.Get()?.GetComponent <LootContainer>();
                    if (container?.lootDefinition == null)
                    {
                        continue;
                    }
                    Dictionary <string, LootContainer> spawnGroupData;
                    if (!spawnGroupsData.TryGetValue(spawnGroupKey, out spawnGroupData))
                    {
                        spawnGroupsData[spawnGroupKey] = spawnGroupData = new Dictionary <string, LootContainer>();
                    }
                    spawnGroupData[container.PrefabName] = container;
                }
            }
            var containerData = new Dictionary <string, LootContainer>();
            var allPrefabs    = GameManifest.Get().pooledStrings.ToList().ConvertAll(p => p.str).Where(p => _findLoot.IsMatch(p)).ToArray();
            Array.Sort(allPrefabs, (a, b) => caseInsensitiveComparer.Compare(a, b));
            foreach (var strPrefab in allPrefabs)
            {
                var container = GameManager.server.FindPrefab(strPrefab)?.GetComponent <LootContainer>();
                if (container?.lootDefinition == null)
                {
                    continue;
                }
                containerData[strPrefab] = container;
            }

            /*foreach (var container in containers)
             * {
             *  if (container.gameObject.activeInHierarchy || container.GetComponent<SpawnPointInstance>() != null) continue; //skip spawned & spawn groups
             *  containerData[container.PrefabName] = container;
             * }*/
            try
            {
                Config.Settings = new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                    Converters            = new List <JsonConverter>
                    {
                        new ItemAmountRangedConverter(),
                        new LootSpawnEntryConverter(),
                        new LootContainerConverter(),
                        new LootSpawnConverter(),
                        new ItemModRevealConverter(),
                        new ItemModUnwrapConverter()
                    }
                };
                Config.WriteObject(new ExportData
                {
                    Version        = Protocol.network,
                    VersionConfig  = VersionConfig,
                    WorldSize      = World.Size,
                    WorldSeed      = World.Seed,
                    LootContainers = containerData,
                    SpawnGroups    = spawnGroupsData.OrderBy(l => l.Key).ToDictionary(l => l.Key, l => l.Value),
                    ItemModReveals = itemModReveal.ToDictionary(l => l.name),
                    ItemModUnwraps = itemModUnwrap.Where(l => l.revealList != null).ToDictionary(l => l.name),
                    Categories     = loot.ToDictionary(l => l.name)
                });
            }
            catch (Exception e)
            {
                Puts("Config save failed: {0}{1}{2}", e.Message, Environment.NewLine, e.StackTrace);
                return(false);
            }
            Puts("Created new config");
            return(LoadConfig());
        }
Beispiel #29
0
 protected override void LoadDefaultConfig()
 {
     Warn("Creating a new config file");
     Config.Clear();
     LoadVariables();
 }
Beispiel #30
0
 protected override void LoadDefaultConfig()
 {
     Config.Clear();
     LoadVariables();
     DoStartupItemNames();
 }