I wanted to figure out how should the objects in a game environment like these
- A reward Chest
- A mana depleting/replenishing zone
- sudden stormy winds in a certain direction
can affect Other entities (player) properties like
- Health/mana values
- add a force on the entity in a certain direction.
whenever the above interaction occurs, I’ve been thinking of using an event bus in the following manner.
- The player interacts with a script on the chest and an event is
raised containing the chest content via the environment manager. The
player Manager (entity manager) should subscribe to this event and
- In the case of mana zones, these zones can communicate the
interaction to the environment manager which can raise the event
which is already subscribed by the player manager.
- similarly, force magnitude and direction can be communicated.
some important points I’m keeping in mind,
- These event types can be reused in most cases. for eg. All
health-related interactions can be communicated via a single event
type, all physics (rigid body) related interactions can be another
type. This will probably keep the number of events type low.
- The environment entities can choose to raise or player entities can
choose to respond to an event.
- This would be a local event bus that is open to the Core game system
only. Trying to keep these events away from other systems.
I wanted to know what is generally used for this purpose in the game industry. Will this be overkill? Is there a better approach that handles all such interactions keeping the code entities decoupled from each other?