Content Patcher

Content Patcher

378k Downloads

[Automate] provide public API for mod integrations

Pathoschild opened this issue ยท 4 comments

commented

Provide a public API other mods can use to integrate with Automate.

commented

Based on how commonly it's requested, having a public API for mod integrations is more valuable than transport pipes, so I'll focus on the API first with the understanding that it may break in a future Automate version which adds pipes.

The API would probably work something like this:

AutomateAPI
   .GetInstanceFor(this.ModManifest)
   .AddObjectMachine(this.GetObjectMachine);

private IMachine GetObjectMachine(StardewValley.Object obj, GameLocation location, Vector2 tile)
{
   if (obj.ParentSheetIndex == 999999)
      return new NineGeneratorMachine(location, tile);
   return null;
}
commented

Done in develop for the upcoming Automate 1.11 (see readme).

commented

Automate could allow mods to register methods containing signatures similar to MachineFactory.TryGetMachine, then Automate could loop through all the registered methods to see if that tile has a machine that a mod has registered. This would also require Automate to expose IMachine and all the types it uses. These types could be separated into their own assembly for mod authors to import if they want to add optional support for Automate.

commented

Yep. The main factor is that transport pipes will change those interfaces, so I don't want to expose them with a public API until that's done.