I am working on a city building game where all buildings are axis aligned rectangles. Currently I am using spatial hashing to detect if the insertion of a building intersects a building in the board.
Now I am implementing an effect system where every building placed has some effects that they can give to other buildings within a specific range. This happens during placement of a new building into the board.
Basically how it should work is, if I place a building within the range of another building in the board, the building in the board should receive the effects that the building I just placed has, and the building that I am placing should also receive the effects that the building in the board has. Basically like a handshake. This should happen with every building that is in the range of another building and will only take place and be calculated when a new building is inserted into the board.
Another thing to keep in mind is that if a building is already in the board and a new building is placed within its range, that new building should receive the effects of the building already in the board even if the other building does not have this building in its range. Thus this would be a one way transfer of effects and not a "handshake".
I currently have the exchange of effects working as it should, but its slow because I am checking every building range against every building. Thus the more buildings you place, the slower it gets.
I am looking for a way to make this faster whether it means changing from spatial hashing to some other spatial partitioning. I am currently reading Hierarchical Hash Grids but I don't know if this will benefit me at all.