room.structureCacheKey



  • Can we have a room property, structureCacheKey, with some value that's guaranteed to change if, and only if, a structure has been added to or removed from a room between the current tick and the previous?



  • Or perhaps an EVENT_STRUCTURE_COMPLETED event in the room event log? (EVENT_BUILD is a crude tool for identifying freshly-built structures. It's hard to distinguish a constructionSite that was completed from one that was stepped on or removed)



  • I have dreamed a lot about this to make an efficient room rebuilder.

    I currently I check the structure count, construction site count, and RCL every tick (which is very efficient). Then I only run my room builder when those values change.

    But there is a loop hole with construction sites completing and being placed in the same tick as a structure is destroyed.

    Ruins closes that loop hole.

    In short, every tick count the number of structures, number of construction sites, number of ruins, and RCL. If any of those change you need to look through the room for changes.

    I think now that Ruins are here you could probably get a way with only checking every couple hundred ticks (unless you have hostiles in the room).



  • @deft-code said in room.structureCacheKey:

    Ruins closes that loop hole.

    Nukes don't leave behind ruins



  • EVENT_BUILD could be used to distinguish a completed build from a stomped/removed construction site if its info had a property that indicated success. A boolean that's true if the job were completed, maybe. Or the id of the completed structure. Or the amount of work yet to be done to complete the job. Or the position and structureType of the targeted thing.