Exemple #1
0
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param>
        public override void Entry(IModHelper helper)
        {
            // toggle mod compatibility
            bool hasBetterJunimos     = helper.ModRegistry.IsLoaded("hawkfalcon.BetterJunimos");
            bool hasDeluxeAutoGrabber = helper.ModRegistry.IsLoaded("stokastic.DeluxeGrabber");

            // init
            this.Config  = helper.ReadConfig <ModConfig>();
            this.Factory = new MachineGroupFactory();
            this.Factory.Add(new AutomationFactory(this.Config.Connectors, this.Config.AutomateShippingBin, this.Monitor, helper.Reflection, hasBetterJunimos, hasDeluxeAutoGrabber));

            // hook events
            helper.Events.GameLoop.SaveLoaded       += this.OnSaveLoaded;
            helper.Events.Player.Warped             += this.OnWarped;
            helper.Events.World.LocationListChanged += this.World_LocationListChanged;
            helper.Events.World.ObjectListChanged   += this.World_ObjectListChanged;
            helper.Events.GameLoop.UpdateTicked     += this.OnUpdateTicked;
            helper.Events.Input.ButtonPressed       += this.OnButtonPressed;

            if (this.Config.Connectors.Any(p => p.Type == ObjectType.Floor))
            {
                helper.Events.World.TerrainFeatureListChanged += this.World_TerrainFeatureListChanged;
            }

            // log info
            this.Monitor.VerboseLog($"Initialised with automation every {this.Config.AutomationInterval} ticks.");
        }
Exemple #2
0
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param>
        public override void Entry(IModHelper helper)
        {
            // init
            this.Config  = helper.ReadConfig <ModConfig>();
            this.Keys    = this.Config.Controls.ParseControls(this.Monitor);
            this.Factory = new MachineGroupFactory();
            this.Factory.Add(new AutomationFactory(
                                 connectors: this.Config.ConnectorNames,
                                 automateShippingBin: this.Config.AutomateShippingBin,
                                 monitor: this.Monitor,
                                 reflection: helper.Reflection,
                                 data: this.Helper.Data.ReadJsonFile <DataModel>("data.json"),
                                 betterJunimosCompat: this.Config.ModCompatibility.BetterJunimos && helper.ModRegistry.IsLoaded("hawkfalcon.BetterJunimos"),
                                 autoGrabberModCompat: this.Config.ModCompatibility.AutoGrabberMod && helper.ModRegistry.IsLoaded("Jotser.AutoGrabberMod")
                                 ));

            // hook events
            helper.Events.GameLoop.SaveLoaded             += this.OnSaveLoaded;
            helper.Events.Player.Warped                   += this.OnWarped;
            helper.Events.World.BuildingListChanged       += this.OnBuildingListChanged;
            helper.Events.World.LocationListChanged       += this.OnLocationListChanged;
            helper.Events.World.ObjectListChanged         += this.OnObjectListChanged;
            helper.Events.World.TerrainFeatureListChanged += this.OnTerrainFeatureListChanged;
            helper.Events.GameLoop.UpdateTicked           += this.OnUpdateTicked;
            helper.Events.Input.ButtonPressed             += this.OnButtonPressed;

            // log info
            this.Monitor.VerboseLog($"Initialised with automation every {this.Config.AutomationInterval} ticks.");
        }
Exemple #3
0
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param>
        public override void Entry(IModHelper helper)
        {
            // read data file
            const string dataPath = "assets/data.json";
            DataModel    data     = null;

            try
            {
                data = this.Helper.Data.ReadJsonFile <DataModel>(dataPath);
                if (data?.FloorNames == null)
                {
                    this.Monitor.Log($"The {dataPath} file seems to be missing or invalid. Floor connectors will be disabled.", LogLevel.Error);
                }
            }
            catch (Exception ex)
            {
                this.Monitor.Log($"The {dataPath} file seems to be invalid. Floor connectors will be disabled.\n{ex}", LogLevel.Error);
            }

            // read config
            this.Config = this.LoadConfig();

            // init
            this.Keys    = this.Config.Controls.ParseControls(helper.Input, this.Monitor);
            this.Factory = new MachineGroupFactory(this.Config);
            this.Factory.Add(new AutomationFactory(
                                 connectors: this.Config.ConnectorNames,
                                 monitor: this.Monitor,
                                 reflection: helper.Reflection,
                                 data: data,
                                 betterJunimosCompat: this.Config.ModCompatibility.BetterJunimos && helper.ModRegistry.IsLoaded("hawkfalcon.BetterJunimos"),
                                 autoGrabberModCompat: this.Config.ModCompatibility.AutoGrabberMod && helper.ModRegistry.IsLoaded("Jotser.AutoGrabberMod"),
                                 pullGemstonesFromJunimoHuts: this.Config.PullGemstonesFromJunimoHuts
                                 ));
            this.CommandHandler = new CommandHandler(this.Monitor, this.Config, this.Factory, this.ActiveMachineGroups);

            // hook events
            helper.Events.GameLoop.SaveLoaded             += this.OnSaveLoaded;
            helper.Events.Player.Warped                   += this.OnWarped;
            helper.Events.World.BuildingListChanged       += this.OnBuildingListChanged;
            helper.Events.World.LocationListChanged       += this.OnLocationListChanged;
            helper.Events.World.ObjectListChanged         += this.OnObjectListChanged;
            helper.Events.World.TerrainFeatureListChanged += this.OnTerrainFeatureListChanged;
            helper.Events.GameLoop.UpdateTicked           += this.OnUpdateTicked;
            helper.Events.Input.ButtonPressed             += this.OnButtonPressed;
            helper.Events.Multiplayer.ModMessageReceived  += this.OnModMessageReceived;

            // hook commands
            helper.ConsoleCommands.Add("automate", "Run commands from the Automate mod. Enter 'automate help' for more info.", this.CommandHandler.HandleCommand);

            // log info
            this.Monitor.VerboseLog($"Initialized with automation every {this.Config.AutomationInterval} ticks.");
            if (this.Config.ModCompatibility.WarnForMissingBridgeMod)
            {
                this.ReportMissingBridgeMods(data?.SuggestedIntegrations);
            }
        }
Exemple #4
0
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param>
        public override void Entry(IModHelper helper)
        {
            // read data file
            const string dataPath = "assets/data.json";
            DataModel    data     = null;

            try
            {
                data = this.Helper.Data.ReadJsonFile <DataModel>(dataPath);
                if (data?.FloorNames == null)
                {
                    this.Monitor.Log($"The {dataPath} file seems to be missing or invalid. Floor connectors will be disabled.", LogLevel.Error);
                }
            }
            catch (Exception ex)
            {
                this.Monitor.Log($"The {dataPath} file seems to be invalid. Floor connectors will be disabled.\n{ex}", LogLevel.Error);
            }

            // read config
            this.Config = helper.ReadConfig <ModConfig>();
            this.Config.MachinePriority = new Dictionary <string, int>(this.Config.MachinePriority, StringComparer.OrdinalIgnoreCase);

            // init
            this.Keys    = this.Config.Controls.ParseControls(helper.Input, this.Monitor);
            this.Factory = new MachineGroupFactory(this.Config);
            this.Factory.Add(new AutomationFactory(
                                 connectors: this.Config.ConnectorNames,
                                 automateShippingBin: this.Config.AutomateShippingBin,
                                 monitor: this.Monitor,
                                 reflection: helper.Reflection,
                                 data: data,
                                 betterJunimosCompat: this.Config.ModCompatibility.BetterJunimos && helper.ModRegistry.IsLoaded("hawkfalcon.BetterJunimos"),
                                 autoGrabberModCompat: this.Config.ModCompatibility.AutoGrabberMod && helper.ModRegistry.IsLoaded("Jotser.AutoGrabberMod"),
                                 pullGemstonesFromJunimoHuts: this.Config.PullGemstonesFromJunimoHuts
                                 ));

            // hook events
            helper.Events.GameLoop.SaveLoaded             += this.OnSaveLoaded;
            helper.Events.Player.Warped                   += this.OnWarped;
            helper.Events.World.BuildingListChanged       += this.OnBuildingListChanged;
            helper.Events.World.LocationListChanged       += this.OnLocationListChanged;
            helper.Events.World.ObjectListChanged         += this.OnObjectListChanged;
            helper.Events.World.TerrainFeatureListChanged += this.OnTerrainFeatureListChanged;
            helper.Events.GameLoop.UpdateTicked           += this.OnUpdateTicked;
            helper.Events.Input.ButtonPressed             += this.OnButtonPressed;
            helper.Events.Multiplayer.ModMessageReceived  += this.OnModMessageReceived;

            // log info
            this.Monitor.VerboseLog($"Initialized with automation every {this.Config.AutomationInterval} ticks.");
        }
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param>
        public override void Entry(IModHelper helper)
        {
            // init
            this.Config  = helper.ReadConfig <ModConfig>();
            this.Factory = new MachineGroupFactory();
            this.Factory.Add(new AutomationFactory(this.Config.Connectors, this.Config.AutomateShippingBin, this.Monitor, helper.Reflection));

            // hook events
            helper.Events.GameLoop.SaveLoaded       += this.OnSaveLoaded;
            helper.Events.Player.Warped             += this.OnWarped;
            helper.Events.World.LocationListChanged += this.World_LocationListChanged;
            helper.Events.World.ObjectListChanged   += this.World_ObjectListChanged;
            helper.Events.GameLoop.UpdateTicked     += this.OnUpdateTicked;
            helper.Events.Input.ButtonPressed       += this.OnButtonPressed;

            if (this.Config.Connectors.Any(p => p.Type == ObjectType.Floor))
            {
                helper.Events.World.TerrainFeatureListChanged += this.World_TerrainFeatureListChanged;
            }

            // log info
            this.Monitor.VerboseLog($"Initialised with automation every {this.Config.AutomationInterval} ticks.");
        }