示例#1
0
        public override void Entry(IModHelper helper)
        {
            // Read Config
            this.Config = helper.ReadConfig <ModConfig>();

            // Starting Localisation
            I18n.Init(helper.Translation);

            // Starting Harmony
            UpgradePatches.SetUp(Monitor, helper, Config.MoveFruitTrees);
            var harmony = HarmonyInstance.Create(this.ModManifest.UniqueID);

            harmony.Patch(
                original: AccessTools.Method(typeof(Building), nameof(Building.dayUpdate)),
                prefix: new HarmonyMethod(typeof(UpgradePatches), nameof(UpgradePatches.Upgrade_Prefix))
                );

            FruitTreeMover.SetUp(Monitor);

            // Adding console comand for tree moving.
            helper.ConsoleCommands.Add("move_trees",
                                       "Move greenhouse fruit trees to the given upgrade level.\n" +
                                       "\nUsage: move_trees <level>\n- level: the upgrade level to perform the move.",
                                       this.DoMoveTrees);

            // Events Hooks
            helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;
            helper.Events.GameLoop.DayStarted   += this.OnDayStarted;
            helper.Events.Display.MenuChanged   += this.OnMenuChanged;
        }
示例#2
0
 /// <summary>Forces the fruit tree move process for the given upgrade level.</summary>
 /// <param name="command">The name of the command invoked</param>
 /// <param name="args">The arguments received by the command. Each word after the command name is a separate argument.</param>
 private void DoMoveTrees(string command, string[] args)
 {
     if (Context.IsWorldReady)
     {
         FruitTreeMover.Upgraded();
         FruitTreeMover.MoveTrees(int.Parse(args[0]));
         Monitor.Log($"Trees moved as if greenhouse upgrade {args[0]} has been completed now.", LogLevel.Info);
     }
 }
示例#3
0
        /// <summary>The event called when a new day begins.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnDayStarted(object sender, DayStartedEventArgs e)
        {
            var greenhouse   = Game1.getFarm().buildings.OfType <GreenhouseBuilding>().FirstOrDefault();
            int currentLevel = GetUpgradeLevel(greenhouse);

            FruitTreeMover.MoveTrees(currentLevel);

            if (currentLevel == 2)
            {
                this.WaterGreenhouse();
            }
        }