Maintenance Hub


Adds an Aquilo technology that unlocks a Fulgorian Maintenance Hub that uses power to create matter to repair bulidings

Content
4 months ago
2.0 - 2.1
91
Combat Environment

i performance improvements

13 days ago
(updated 13 days ago)

the way the code is set up makes the game check for a hub every time any entity is damaged, regardless of if there are any placed in the save or on that surface, id suggest adding a check like this:

script.on_event(
  defines.events.on_entity_damaged,
  function(event)
    if not (storage.maintenance_hubs and next(storage.maintenance_hubs)) then
      return
    end

to prevent it from causing performance problems before you even use it

another thing is that that lookup check is slow, a better way would be to mark all DAMAGE_CELL_SIZE cells within [hub.x - radius, hub.x + radius] in storage like this: storage.hub_covered_cells[surface_index][force_index][cell_key] = true., then in on_entity_damaged check that that is true before calling hub_can_reach_entity(entity), an entity outside hub coverage just performs a table lookup which is much more performant than calling find_entities_filtered

in my base this mod used 50ms during large attacks when i didn't even have the tech researched yet

if you're willing it would be helpful if you put this on github, id love to contribute to this mod

9 days ago

I shall try to implement this :)

New response