Wall Damage and Patching, Pathfinding Improved
Hey Folks! Pretty productive day, today, as I spruced-up pathfinding a bit, as well as added damaged/patched walls.
The pathfinding fixes and improvements were a big chunk of the day, since there were several edge cases to sort out with all the recent changes. First, I had to add code to abort the current interaction if the goal became unreachable. Also, AI was getting caught in pathfinding loops when the target tile was unwalkable (such as when fixing a broken floor). I had to do some special handling for path calculations when that situation occurs.
I also added some code so that non-pathfinding items can still succeed on interactions that can be done remotely. Previously, they would always fail if not currently sitting in the destination tile. But now, they can succeed if they are within the interaction's prescribed tile range. And finally, I realized my pathfinding was ignoring diagonal tile directions, so I enabled those. And that seems to not only work, but really smooth out the walking experience.
Once that was done, I turned back to damage/repair game loop stuff, and added damaged walls. Since 90% of the ship's tiles are floors or walls, this makes a good chunk of the ship damageable. And with patching kits, they can be quickly jury-rigged to stop leaking precious atmo into space. Patched floors and walls won't stand much abuse, however, so it's best to get them fully repaired asap. And I'm not sure yet how that's going to work. It'd likely require moving heavy ship hull pieces around, and potentially prohibitive tools/processes. So for now, that might be only available in docks, until I get more game systems to support such heavy-lifting and rebuilding.
As it turns out, repairs aren't the only tricky question raised by this game feature. I also started encountering damage in hard-to-reach places, where even a handheld patching kit would be hard to install.
The first one was just crowded tiles. Like the HVAC or conduit tiles, where there is a wall, floor, and potentially other items all stacked up. Right-clicking such a tile didn't guarantee you got the context menu for the item you wanted. Usually, just whatever one was on top and had a valid interaction.
This, fortunately, turned out to be not too hard to solve. I just changed the context menu code to show all available options for all items in the tile. Let the player choose, and done.
But the next problem was a doozy: tiles far away from walkable areas.
For example, looking at today's image, there are two damaged wall sections around the fridge by Noah. And for the most part, those can be reached. But what if the damaged wall was in the corner behind the fridge? Or worse, a breached floor tile under the middle of a giant reactor? How does one reach something that far away from walkable tiles?
In the case of the fridge, you could probably move it if it weren't attached. But on the opposite wall, the toilet is a good example of something that wouldn't be movable (or, you know, same for a giant reactor). So there has to be some other way. And at first, I figured maybe the solution is to just make it possible to repair things, say, 3 tiles away.
However, that doesn't solve the reactor example, where the tile could be a dozen or more units away from the nearest accessible point. And besides, it looks a little hokey to wave one's arms and have a wall repaired far away.
Another solution that comes to mind is making access corridors. If you need access to a wall that's blocked by something, that should be designed into the ship's layout. Like a narrow mechanical corridor between rooms. Or even make that double as an air duct. I really like this idea, as it's an interesting design/planning challenge, fairly realistic, and it's reminiscent of Alien. Unfortunately, this also doesn't solve the reactor problem.
A third option is to allow for spacewalking (or a drone) to go outside and repair from the exterior. This one is a cool idea, realistic, and solves the reactor problem. But is likely a ton of work for me to build. It may also be work I need to do anyway, though.
A fourth option is to allow multi-floor ships. But this has pretty much the same pros and cons as the spacewalk option.
And finally, maybe there just isn't damage to unreachable tiles until I have systems to do that. This might be the preferred route for now. I can still do the access corridor thing without any other development effort, and just limit damage areas for now to places the AI can reach. And some day later, make systems to support unreachable fixes later.
Despite that hang-up, though, not a bad day! Some serious improvements to core systems, plus a new feature!