I'm currently developing a resource-management game and require a "collection manager" to streamline interactions between states and objects in Typescript.
Let's imagine the game revolves around nurturing cats. In one state, players advance time by a year and I need to pair certain cats for breeding. In another state, players feed 10 cats which affects their hunger levels. Consequently, I must update the collection of cats during these different states.
Initially, I managed the cat collection within each state using localStorage or Phaser Cache, resulting in messy code.
To simplify this process, I aim to establish an abstraction layer to handle tasks such as updating cats, generating new ones, and retrieving specific subsets based on criteria without passing it between states. Ideally, this static layer should allow me to call functions like:
catManager.generateNewCats(10);
catManager.getCats({minAge:2, maxAge:5});
catManager.incrementAges();
What would be your approach to organizing this system?