The Lost Archives #12: Even more complexity
Hello all, surprisingly I still haven’t finished the multi-floor system. The more I work on it the more complications arise! However I think this is the last unexpected feature I need to code. What is this feature you ask? Well it’s structural integrity. We realised it isn’t very realistic to be able to build floating rooms believe it or not, so to combat this I figured we need walls to require support or they cannot be placed. Furthermore if a wall loses its support/s then it should structurally fail, and this failure should propagate throughout a whole building. Quite a cool system!
As I pondered over how I was going to implement this, I was coming up with overly complex models by taking from real world physics when I figured that it is actually surprisingly easy to implement with very basic behaviours, that can combine and manifest into complex structural interactions. The method I came up with is to have every wall flood fill through other walls, up to a certain distance. If the wall didn’t find a supporting structure, then it isn’t structurally support and either breaks, or is not allowed to be placed, depending on what the circumstances are. In the case of removing a supporting wall, we can just tell all the blocks in the chunk to perform the flood-fill to check if they are supported. If they are not well, they break of course, and the opposite is self explanatory.
I believe this system should work for N amount of floors, but optimisations and performance remain unclear. I am about to start implementing it now, replacing it with the old system, which just checked how far a supporting wall was on the lower floor and if it was next to a tile on the same floor. It worked, but was very janky and the player could still make some weird structures.
Sorry for a highly technical post, hopefully by next week structural integrity is finished and I can move on to multi floor path-finding.( ‾ʖ̫‾)
Til the next one! **
**The Team,
Plasmarc Studios