Example #1
0
        /// <summary>The mod entry point, called after the mod is first loaded</summary>
        /// <param name="helper">Provides simplified APIs for writing mods</param>
        public override void Entry(IModHelper helper)
        {
            _helper        = helper;
            Globals.ModRef = this;
            Globals.Config = Helper.ReadConfig <ModConfig>();

            ImageBuilder.CleanUpReplacementFiles();

            this._modAssetLoader = new AssetLoader(this);
            this._modAssetEditor = new AssetEditor(this);
            helper.Content.AssetLoaders.Add(this._modAssetLoader);
            helper.Content.AssetEditors.Add(this._modAssetEditor);

            this.PreLoadReplacments();
            helper.Events.GameLoop.SaveLoaded         += (sender, args) => this.CalculateAllReplacements();
            helper.Events.Display.RenderingActiveMenu += (sender, args) => _modAssetLoader.TryReplaceTitleScreen();
            helper.Events.GameLoop.ReturnedToTitle    += (sender, args) => _modAssetLoader.ReplaceTitleScreenAfterReturning();

            if (Globals.Config.Music.Randomize)
            {
                helper.Events.GameLoop.UpdateTicked += (sender, args) => MusicRandomizer.TryReplaceSong();
            }
            if (Globals.Config.RandomizeRain)
            {
                helper.Events.GameLoop.DayEnding += _modAssetLoader.ReplaceRain;
            }

            if (Globals.Config.Crops.Randomize)
            {
                helper.Events.Multiplayer.PeerContextReceived += (sender, args) => FixParsnipSeedBox();
            }

            if (Globals.Config.Crops.Randomize || Globals.Config.Fish.Randomize)
            {
                helper.Events.Display.RenderingActiveMenu += (sender, args) => CraftingRecipeAdjustments.HandleCraftingMenus();

                // Fix for the Special Orders causing crashes
                // Re-instate the object info when the save is first loaded for the session, and when saving so that the
                // items have the correct names on the items sold summary screen
                helper.Events.GameLoop.DayEnding  += (sender, args) => _modAssetEditor.UndoObjectInformationReplacements();
                helper.Events.GameLoop.SaveLoaded += (sender, args) => _modAssetEditor.RedoObjectInformationReplacements();
                helper.Events.GameLoop.Saving     += (sender, args) => _modAssetEditor.RedoObjectInformationReplacements();
            }

            if (Globals.Config.RandomizeForagables)
            {
                helper.Events.GameLoop.GameLaunched += (sender, args) => WildSeedAdjustments.ReplaceGetRandomWildCropForSeason();
            }

            if (Globals.Config.Fish.Randomize)
            {
                helper.Events.GameLoop.DayStarted += (sender, args) => OverriddenSubmarine.UseOverriddenSubmarine();
                helper.Events.GameLoop.DayEnding  += (sender, args) => OverriddenSubmarine.RestoreSubmarineLocation();
            }

            if (Globals.Config.Bundles.Randomize)
            {
                helper.Events.Display.MenuChanged         += BundleMenuAdjustments.FixRingSelection;
                helper.Events.Display.RenderingActiveMenu += (sender, args) => BundleMenuAdjustments.FixRingDeposits();

                if (Globals.Config.Bundles.ShowDescriptionsInBundleTooltips)
                {
                    helper.Events.Display.RenderedActiveMenu += (sender, args) => BundleMenuAdjustments.AddDescriptionsToBundleTooltips();
                }
            }
        }