Wouldnt this only allow to hook into an already started building generation?
One could still account for somehow clone-marked factories and create the cloned interior machines at this point.
But this narrows the possible features. you only get the factory at building/placing time. so for example, you cant determine the worth of the interior and create a dynamic recipe passed on that.
EDIT: you dont have the source factory in this scenario. cant imagine a way to make it work like this.
I would prefer a remote call to create a copy. Or even simpler just one to create a factory spot. So you dont have to place the factory as you create it.
In my proof of concept i created a single method to clone a factory within the mod. This creates the factory spot, saves it in the mods data structure , creates the inner building and recursive factories and returns the root-factorys entity.
At first for testing i triggered this at mining time. So you just got 2 factories for mining one.
But now i am setting up an external mod to call the particular function via remote and create the copy by clicking on it with an item. Only problem, i couldnt yet figure out how to hook on the leftclick of a non-placable entity. If i get this to work, i will probably be satisfied for my own playthrough. :)
LAST EDIT: Got it working for me. But its quite buggy. for example: in inner factories, one needs to rebuild the connection belt tiles, because the teleportation-thing gets thrown off if the factory is cloned. - items on belts get cloned too etc. etc. - But thats good enough for me.
Thanks for this amazing mod. All the best.