Beispiel #1
0
        /*********
        ** Public methods
        *********/
        /// <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)
        {
            //config file read in
            string[] config = System.IO.File.ReadAllLines("Mods/Randomizer/RandomizerSettings.txt");
            configDict = new Dictionary <string, bool>();

            foreach (string line in config)
            {
                string[] tokens = line.Split('=');
                if (tokens.Length != 2)
                {
                    continue;
                }
                configDict.Add(tokens[0].Trim().ToLower(), string.Equals(tokens[1].Trim(), "true", StringComparison.OrdinalIgnoreCase));
            }


            this._modAssetLoader = new AssetLoader(this);
            this._modAssetEditor = new AssetEditor(this);

            //SaveEvents.AfterCreate += this.OnCreateOrLoad;
            //SaveEvents.AfterLoad += this.OnCreateOrLoad;

            helper.Content.AssetLoaders.Add(this._modAssetLoader);
            helper.Content.AssetEditors.Add(this._modAssetEditor);



            //Changes made before game loads
            this.PreLoadReplacments();

            // Calculate on creation replacements
            Helper.Events.GameLoop.SaveCreated += (sender, args) => this.CalculateOneTimeReplacements();

            // Calculate all replacements when the save is loaded
            Helper.Events.GameLoop.SaveLoaded += (sender, args) => this.CalculateAllReplacements();

            //PlayerEvents.Warped += (sender, args) => this.PlayerChangedLocations();

            Helper.Events.GameLoop.UpdateTicked += (sender, args) => this.CheckSong();
        }
Beispiel #2
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)
        {
            ImageBuilder.CleanUpReplacementFiles();

            _helper        = helper;
            Globals.ModRef = this;
            Globals.Config = Helper.ReadConfig <ModConfig>();

            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.Multiplayer.PeerContextReceived += (sender, args) => FixParsnipSeedBox();

            helper.Events.Display.RenderingActiveMenu += (sender, args) => _modAssetLoader.TryReplaceTitleScreen();
            helper.Events.Display.MenuChanged         += BundleMenuAdjustments.FixRingSelection;
            helper.Events.Display.RenderingActiveMenu += (sender, args) => BundleMenuAdjustments.FixRingDeposits();
            helper.Events.GameLoop.ReturnedToTitle    += (sender, args) => _modAssetLoader.ReplaceTitleScreenAfterReturning();
            helper.Events.GameLoop.ReturnedToTitle    += (sender, args) => ImageBuilder.CleanUpReplacementFiles();

            if (Globals.Config.RandomizeMusic)
            {
                helper.Events.GameLoop.UpdateTicked += (sender, args) => this.TryReplaceSong();
            }
            if (Globals.Config.RandomizeRain)
            {
                helper.Events.GameLoop.DayEnding += _modAssetLoader.ReplaceRain;
            }
            if (Globals.Config.RandomizeCrops || Globals.Config.RandomizeFish)
            {
                helper.Events.Display.RenderingActiveMenu += (sender, args) => CraftingRecipeAdjustments.HandleCraftingMenus();
            }

            helper.Events.GameLoop.DayStarted += (sender, args) => UseOverriddenSubmarine();
            helper.Events.GameLoop.DayEnding  += (sender, args) => RestoreSubmarineLocation();
        }
Beispiel #3
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)
        {
            ImageBuilder.CleanUpReplacementFiles();

            _helper        = helper;
            Globals.ModRef = this;
            Globals.Config = Helper.ReadConfig <ModConfig>();

            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.RandomizeMusic)
            {
                helper.Events.GameLoop.UpdateTicked += (sender, args) => this.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();
                }
            }
        }