/// <inheritdoc /> /// <summary>Initialize the mod.</summary> /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param> public override void Entry(IModHelper helper) { // Load configs this.Config = helper.ReadConfig <ConfigMain>(); this.TreasureConfig = helper.ReadJsonFile <ConfigTreasure>("treasure.json") ?? new ConfigTreasure(); this.FishConfig = helper.ReadJsonFile <ConfigFish>("fish.json") ?? new ConfigFish(); // Make sure the extra configs are generated helper.WriteJsonFile("treasure.json", this.TreasureConfig); helper.WriteJsonFile("fish.json", this.FishConfig); this.Config.AdditionalLootChance = (float)Math.Min(this.Config.AdditionalLootChance, 0.99); helper.WriteConfig(this.Config); this.OnLanguageChange(LocalizedContentManager.CurrentLanguageCode); // Stop here if the mod is disabled if (!this.Config.ModEnabled) { return; } // Events GameEvents.UpdateTick += this.UpdateTick; ControlEvents.KeyPressed += this.KeyPressed; LocalizedContentManager.OnLanguageChange += this.OnLanguageChange; }
private void LoadConfigs() { IJsonApi jsonApi = this.GetCoreApi().GetJsonApi(); // Load configs this.MainConfig = jsonApi.ReadOrCreate <ConfigMain>("config.json"); this.TreasureConfig = jsonApi.ReadOrCreate <ConfigTreasure>("treasure.json", this.MainConfig.MinifyConfigs); this.FishConfig = jsonApi.ReadOrCreate("fish.json", () => { // Populate fish data ConfigFish config = new ConfigFish(); config.PopulateData(); return(config); }, this.MainConfig.MinifyConfigs); this.FishTraitsConfig = jsonApi.ReadOrCreate("fishTraits.json", () => { // Populate fish traits data ConfigFishTraits config = new ConfigFishTraits(); config.PopulateData(); return(config); }, this.MainConfig.MinifyConfigs); // Load config values FishingRod.maxTackleUses = ModFishing.Instance.MainConfig.DifficultySettings.MaxTackleUses; }