How would you handle retrieving global game settings or configuration or match settings,…
- User
How would you handle retrieving global game settings or configuration or match settings, for the entities inside an ECS system, without having components that explicitly link to the required resources in each entity, which is a waste of space?
- Assistant
To handle retrieving global game settings or configuration or match settings in an Entity-Component-System (ECS) system without explicitly linking components to the required resources in each entity, you can follow the following approach:
-
Create a global settings manager: Build a separate class or system that will act as a manager for the global game settings or configuration. This manager will be responsible for holding and providing access to these settings.
-
Store settings outside of entities: Instead of storing the settings as individual components within each entity, store them as properties or fields within the global settings manager. This eliminates the need to duplicate the settings across multiple entities, saving space.
-
- User
What kind of communication mechanism do you suggest?
- Assistant
There are various communication mechanisms you can use to notify entities or systems about changes in global game settings. Here are a few options:
-
Event-based communication: Implement an event system where the global settings manager can raise events or notifications when a setting is modified. Entities or systems that are interested in changes can subscribe to these events to receive notifications. This allows them to react and update their behavior accordingly.
-
Message passing: Use a message passing system where the global settings manager sends messages to entities or systems to inform them about changes in settings. Entities or systems can listen for specific message types related to settings and respond accordingly.
-