bahrmichael / factorio-tycoon

GNU General Public License v3.0
10 stars 7 forks source link

feat: multi surface support #295

Closed bahrmichael closed 8 months ago

bahrmichael commented 8 months ago

Closes https://github.com/bahrmichael/factorio-tycoon/issues/297

This PR updates the code so that it can work with multiple surfaces.

Urban planning centers (to be removed soon) only work with the starting surface, and towns only spawn on the starting surface.

winex commented 8 months ago

hmm, didn't test it yet, but looks cool. my latest rbgen commits should almost support multi-surface, too... as i knew that you mentioned it many times.

note: some events has event.surface, which can be used directly like this diff, but some others only event.surface_index (see docs). i added WARNs about this in my latest rbgen code somewhere. and yes, this is weird!

btw, Factorissimo 2 -notnotmelon may have only single factory-floor-1 surface, which we must skip in generation, but i thought about player-configurable whitelisting, because it's very hard to know what names ppl may use. then we may keep blacklist as simple as this:

+make dict of blacklisted surface.id's for cheap check on each callback

bahrmichael commented 8 months ago

btw, Factorissimo 2 -notnotmelon may have only single factory-floor-1 surface, which we must skip in generation, but i thought about player-configurable whitelisting, because it's very hard to know what names ppl may use. then we may keep blacklist as simple as this:

  • surface.name starts with _
  • surface.name contains -
  • ...

+make dict of blacklisted surface.id's for cheap check on each callback

Looking at https://mods.factorio.com/mod/Factorissimo2 it seems that all their buildings have an artificial floor. Instead of restricting surfaces we could change our code to only generate primary industries on natural floor (grass, dirt, ...). As for town generation, I'm leaning towards only automatically spawning towns on surfaces where there already is a town somewhere. That means players have to place a town on a new surface to get started there. With Factorissimo2 that means they have to make the decision to put towns into Factories if they want that.

bahrmichael commented 8 months ago

note: some events has event.surface, which can be used directly like this diff, but some others only event.surface_index (see docs). i added WARNs about this in my latest rbgen code somewhere. and yes, this is weird!

Yeah, it's a bit annoying that it's not consistent. I'm leaning towards just using the ID if that's all I need.

bahrmichael commented 8 months ago

This seems to be working well. There is a case with residential -> highrise upgrades that I didn't test yet, but I'm not too concerned about that one. Just in case it breaks ;)

winex commented 8 months ago

ok, then i'm going to rebase my winex:rbgen onto this branch, not old main anymore, so we can cleanly "merge" afterwards. just stuck fixing few other bugs...

bahrmichael commented 8 months ago

I'll merge this into main soon, so you can rebase off that :)