Support Forum

How to use data of GridGraph areas for rooms?

I am making a game similar to RimWorld, where if an area is walled off, I want that interior to be considered a room so it can have properties (does it have a roof, cleanliness, luxury etc).

I’ve written an entire system for this but its very dirty, however, I noticed A*PP already does rooms but calls it "areas".

Is there any way I could access the data of these areas and use it for my own purposes (e.g. defining "rooms")?

The only problem is other than knowing the information about the areas, I might have to slightly modify it - I have a tile which is a Door, and a Door is walkable however it should be treated by the flood-fill algorithm as a wall, so the algorithm can create rooms, however agents should still be able to walk through a Door.

How can I access the area data, and how can I achieve the Door functionality I mentioned? I assume I’d have to write a custom GridGraphRule, or is there a simpler way?

Thank you!


You can access the data using the node.Area property. However, I strongly advise not to modify this behavior. The pathfinding algorithms might break if the meaning of it changes.