示例#1
0
        /*********
        ** Private methods
        *********/
        /// <summary>Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialized at this point, so this is a good time to set up mod integrations.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            IAutomateAPI automate = Helper.ModRegistry.GetApi <IAutomateAPI>("Pathoschild.Automate");

            automate.AddFactory(new ProducerFrameworkAutomationFactory());

            var harmony = HarmonyInstance.Create("Digus.PFMAutomate");

            Assembly   automateAssembly   = AppDomain.CurrentDomain.GetAssemblies().First(a => a.FullName.StartsWith("Automate,"));
            MethodInfo automateMethodInfo = AccessTools.GetDeclaredMethods(automateAssembly.GetType("Pathoschild.Stardew.Automate.Framework.AutomationFactory")).Find(m => m.GetParameters().Any(p => p.ParameterType == typeof(SObject)));

            harmony.Patch(
                original: automateMethodInfo,
                postfix: new HarmonyMethod(typeof(AutomateOverrides), nameof(AutomateOverrides.GetFor))
                );

            Assembly ccrmAutomateAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName.StartsWith("CCRMAutomate,"));

            if (ccrmAutomateAssembly != null)
            {
                MethodInfo ccrmAutomateMethodInfo = AccessTools.GetDeclaredMethods(ccrmAutomateAssembly.GetType("CCRMAutomate.Automate.CustomCrystalariumAutomationFactory")).Find(m => m.GetParameters().Any(p => p.ParameterType == typeof(SObject)));
                harmony.Patch(
                    original: ccrmAutomateMethodInfo,
                    postfix: new HarmonyMethod(typeof(CCRMAutomateOverrides), nameof(CCRMAutomateOverrides.GetFor))
                    );
            }
        }
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            Monitor.Log("Attempting to hook into Pathoschild.Automate.", LogLevel.Debug);
            try
            {
                IAutomateAPI automateApi = Helper.ModRegistry.GetApi <IAutomateAPI>("Pathoschild.Automate");

                // Add the AutomationFactory for Harvest Statue
                automateApi.AddFactory(new HarvestStatueFactory());
            }
            catch (Exception ex)
            {
                Monitor.Log($"There was an issue with hooking into Pathoschild.Automate: {ex}", LogLevel.Error);
            }
        }
示例#3
0
        /// <summary>
        /// Patches game through Harmony and sets up mod integration.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnGameLaunched(object sender, GameLaunchedEventArgs args)
        {
            HarmonyInstance harmony = HarmonyInstance.Create("JacquePott.MassProduction");

            harmony.Patch(
                original: AccessTools.Method(typeof(SObject), nameof(SObject.performObjectDropInAction)),
                prefix: new HarmonyMethod(typeof(ObjectOverrides), nameof(ObjectOverrides.PerformObjectDropInAction))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(SObject), nameof(SObject.draw), new Type[] { typeof(SpriteBatch), typeof(int), typeof(int), typeof(float) }),
                postfix: new HarmonyMethod(typeof(ObjectOverrides), nameof(ObjectOverrides.Draw_Postfix))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(SObject), nameof(SObject.isPlaceable)),
                postfix: new HarmonyMethod(typeof(ObjectOverrides), nameof(ObjectOverrides.isPlaceable_Postfix))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(SObject), nameof(SObject.performDropDownAction)),
                prefix: new HarmonyMethod(typeof(ObjectOverrides), nameof(ObjectOverrides.performDropDownAction_Prefix))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(SObject), nameof(SObject.DayUpdate)),
                prefix: new HarmonyMethod(typeof(ObjectOverrides), nameof(ObjectOverrides.DayUpdate_Prefix))
                );

            //Automate integration
            if (Helper.ModRegistry.IsLoaded("Pathoschild.Automate"))
            {
                IAutomateAPI automate = Helper.ModRegistry.GetApi <IAutomateAPI>("Pathoschild.Automate");
                automate.AddFactory(new MPMAutomationFactory());

                Assembly   automateAssembly      = AppDomain.CurrentDomain.GetAssemblies().First(a => a.FullName.StartsWith("Automate,"));
                Type       automationFactoryType = automateAssembly.GetType("Pathoschild.Stardew.Automate.Framework.AutomationFactory");
                MethodInfo methodInfo            = AccessTools.GetDeclaredMethods(automationFactoryType).Find(m => m.GetParameters().Any(p => p.ParameterType == typeof(SObject)));
                harmony.Patch(
                    original: methodInfo,
                    postfix: new HarmonyMethod(typeof(AutomateOverrides), nameof(AutomateOverrides.GetFor))
                    );

                if (Helper.ModRegistry.IsLoaded("Digus.PFMAutomate"))
                {
                    Monitor.Log("Automate integration for Mass Production clashes with PFMAutomate. Please remove PFMAutomate " +
                                "to have this functionality work correctly.", LogLevel.Warn);
                }
            }
        }
示例#4
0
        /*********
        ** Private methods
        *********/
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            automate             = this.Helper.ModRegistry.GetApi <IAutomateAPI>("Pathoschild.Automate");
            industrialFurnaceAPI = this.Helper.ModRegistry.GetApi <IIndustrialFurnaceAPI>("Traktori.IndustrialFurnace");

            if (automate != null && industrialFurnaceAPI != null)
            {
                automate.AddFactory(new IndustrialFurnaceAutomationFactory(industrialFurnaceAPI));
            }
            else
            {
                if (automate is null)
                {
                    Monitor.Log("Could not detect Automate. Are you sure you have installed everything correctly?", LogLevel.Error);
                }
                if (industrialFurnaceAPI is null)
                {
                    Monitor.Log("Could not detect Industrial Furnace. Are you sure you have installed everything correctly?", LogLevel.Error);
                }
            }
        }
示例#5
0
        /*********
        ** Private methods
        *********/
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            automateApi = Helper.ModRegistry.GetApi <IAutomateAPI>(automateUniqueID);

            qualityScrubberApi = Helper.ModRegistry.GetApi <IQualityScrubberApi>(qualityScrubberUniqueID);

            if (automateApi != null && qualityScrubberApi != null)
            {
                automateApi.AddFactory(new QualityScrubberAutomationFactory(qualityScrubberApi.controller));
            }
            else
            {
                if (automateApi is null)
                {
                    Monitor.Log("Could not detect Automate. Are you sure you have installed everything correctly?", LogLevel.Error);
                }
                if (qualityScrubberApi is null)
                {
                    Monitor.Log("Could not detect Quality Scrubber. Are you sure you have installed everything correctly?", LogLevel.Error);
                }
            }
        }
示例#6
0
        /*********
        ** Private methods
        *********/
        /// <summary>Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialised at this point, so this is a good time to set up mod integrations.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            IAutomateAPI automate = Helper.ModRegistry.GetApi <IAutomateAPI>("Pathoschild.Automate");

            automate.AddFactory(new CustomCrystalariumAutomationFactory());
        }