I’m working through a menu/text heavy game like Coffee Talk, Strange Horticulture, Potion Craft, etc where you interact with customers in a store setting. I’ve run into a problem where I’m modifying data, and I need it updated in multiple components. What is a good approach on how to handle modifying data that’s being used in many different components?
For example, the game has store in which different characters come into it. I can assign these characters tasks that take “X minutes”. I have multiple different menu screens that need to reference the time remaining on the task and character data across all the characters that have tasks. Should that be done with a static data manager, some sort of data warehouse, or store it on the characters themselves?
Hard to visualise what you’re doing here exactly, but have you tried looking into Scriptable Objects for data management, I’ve recently implemented a system using a main data store class that then references Scriptable Objects (SO) as a List, then within that SO I have another array of SOs, check this out - might be what you’re after
Yes, I looked into Scriptable Objects, but I wasn’t sure how to handle the same data across multiple components. The problem is the data is constantly changing (timers, calculations based on changing stats) and those changes need to passed to each component so everything is up to date.
I uploaded a generic layout. The character is assigned 4 tasks, and those tasks are time based where they would be completed after “X time”. There could be 50 characters all with tasks, and I need a way to track that data. There could be X number of tabs all referencing that same data collection. I figured a singleton that controlled all the data as the source of truth would become cumbersome.
These things (character customization, inventories, shop systems) are fairly tricky hairy beasts, definitely deep in advanced coding territory. They contain elements of:
a database of items that you may possibly possess / equip
a database of the items that you actually possess / equip currently
perhaps another database of your “storage” area at home base?
persistence of this information to storage between game runs
presentation of the inventory to the user (may have to scale and grow, overlay parts, clothing, etc)
interaction with items in the inventory or on the character or in the home base storage area
interaction with the world to get items in and out
dependence on asset definition (images, etc.) for presentation
Just the design choices of an inventory system can have a lot of complicating confounding issues, such as:
can you have multiple items? Is there a limit?
are those items shown individually or do they stack?
are coins / gems stacked but other stuff isn’t stacked?
do items have detailed data shown (durability, rarity, damage, etc.)?
can users combine items to make new items? How? Limits? Results? Messages of success/failure?
can users substantially modify items with other things like spells, gems, sockets, etc.?
does a worn-out item (shovel) become something else (like a stick) when the item wears out fully?
etc.
Your best bet is probably to write down exactly what you want feature-wise. It may be useful to get very familiar with an existing game so you have an actual example of each feature in action.
Once you have decided a baseline design, fully work through two or three different inventory tutorials on Youtube, perhaps even for the game example you have chosen above.
Or… do like I like to do: just jump in and make it up as you go. It is SOFT-ware after all… evolve it as you go!