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)
        {
            // read config
            this.Config = helper.ReadConfig <ModConfig>();

            // hook events
            helper.Events.Player.Warped      += this.OnWarped;
            helper.Events.GameLoop.DayEnding += this.DayEnding;

            // hook Harmony patch
            HarmonyInstance harmony = HarmonyInstance.Create(this.ModManifest.UniqueID);

            FarmPatcher.Hook(harmony, this.Monitor, this.Config.UseBeachMusic, isSmallBeachFarm: location => this.IsSmallBeachFarm(location, out _), isOceanTile: this.IsOceanTile);
        }
Beispiel #2
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)
        {
            // read data
            this.Data = this.Helper.Data.ReadJsonFile <ModData>("assets/data.json");
            {
                string dataPath = Path.Combine(this.Helper.DirectoryPath, "assets", "data.json");
                if (this.Data == null || !File.Exists(dataPath))
                {
                    this.Monitor.Log("The mod's 'assets/data.json' file is missing, so this mod can't work correctly. Please reinstall the mod to fix this.", LogLevel.Error);
                    return;
                }
                if (CommonHelper.GetFileHash(dataPath) != ModEntry.DataFileHash)
                {
                    this.Monitor.Log("Found edits to 'assets/data.json'.");
                }
            }

            // read config
            this.Config           = this.Helper.ReadConfig <ModConfig>();
            this.FarmMapAssetName = this.Data.FarmMaps.FirstOrDefault(p => p.ID == this.Config.ReplaceFarmID)?.Map;
            if (this.FarmMapAssetName == null)
            {
                this.Monitor.Log("You have an invalid farm ID in the 'config.json' file. You can delete the file to reset it. This mod will be disabled.", LogLevel.Error);
                return;
            }

            // hook events
            helper.Events.Player.Warped         += this.OnWarped;
            helper.Events.GameLoop.DayEnding    += this.DayEnding;
            helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;

            // hook Harmony patch
            var harmony = HarmonyInstance.Create(this.ModManifest.UniqueID);

            FarmPatcher.Hook(
                harmony,
                this.Monitor,
                addCampfire: this.Config.AddCampfire,
                useBeachMusic: this.Config.UseBeachMusic,
                isSmallBeachFarm: location => this.IsSmallBeachFarm(location, out _),
                getFishType: this.GetFishType
                );
        }
Beispiel #3
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)
        {
            // read config
            this.Config = helper.ReadConfig <ModConfig>();
            this.Data   = helper.Data.ReadJsonFile <ModData>("assets/data.json") ?? new ModData();

            // hook events
            helper.Events.Player.Warped      += this.OnWarped;
            helper.Events.GameLoop.DayEnding += this.DayEnding;

            // hook Harmony patch
            var harmony = HarmonyInstance.Create(this.ModManifest.UniqueID);

            FarmPatcher.Hook(
                harmony,
                this.Monitor,
                addCampfire: this.Config.AddCampfire,
                useBeachMusic: this.Config.UseBeachMusic,
                isSmallBeachFarm: location => this.IsSmallBeachFarm(location, out _),
                getFishType: this.GetFishType
                );
        }