I'm wondering whether an object asking a question to another object that indirectly holds it is "bad" design. For example...
Requirements: Character (an object) moves on a grid. When it tries to move to another spot, it needs to know whether that spot is already occupied by something that blocks it, or if that part of the grid is completely inaccessible. (Note that the character itself needs to know).
In the application, a state holds a tilemanager and a charactermanager. The tilemanager knows what tiles are accessible and which aren't. The charactermanager knows the characters' tile locations.
Would it be reasonable for the character to call a function from the state, say AuthorizeMovement
, which determines whether movement is possible via its TileManager and CharacterManager, and returns true if so, false if not?
Is this violating any important principles, leading to trouble down the road?
Obviously this is generalized and stripped down to what is necessary to understand the problem.