Is dynamic casting Entities A good design?
- by Milo
For my game,
Everything inherits from Entity, then other things like Player, PhysicsObject, etc, inherit from Entity. The physics engine sends collision callbacks which has an Entity* to the B that A collided on. Then, lets say A is a Bullet, A tries to cast the entity as a player, if it succeeds, it reduces the player's health.
Is this a good design?
The problem I have with a message system is that I'd need messages for everything, like:
entity.sendMessage(SET_PLAYER_HEALTH,16);
So that's why I think casting is cleaner.