Hi guys!
I cannot think a way to make my game scalable as I add game logic that is heavy dependent of other things. I’ll try to create a simplified example.
There is 3 object/entities. Product, factory and country. For sake of simplicity, let’s assume that there is only wood (resource), lumberjack (factory) and Kuni (country). Kuni has a quantity of available wood, and also a number of lumberjacks that produce wood and is stored in the country store.
The easy way to make this work is that the country has an array of factories (lumberjacks) and a dictionary of products (key: “wood”; value: quantity available). This is easy to manage but when I try to add other things like product consumption from factory to be able to produce others, or employees that the factory has and population available in the country, the things start to be a little messy, as every one need to know about others. The factory needs to know everything from country, stored products, available population, etc… and the country needs to know about every factory it has
I extracted logic from the entities itself, making them a simple data object (kinda like components or resource) and I created Systems that have shared logic to manage it, but I feel like everything is tied up and I need double references. The factory need a reference to the country and navigate through it to get the population or products. The country needs a reference to the factories, products… (this is easy since they’re children nodes, but even then feels off…)
I came from Web Develop, using DDD and heavy event driven APIs and now I’m having a hard time trying to adapt to game develop. To avoid hard dependencies, I’m used to solve this using a database and access to the info that the current object needs to solve it and nothing more. For example, the a table will have the reference (uuid) of the country and the factory relation and, via repositories, access to that data (the factory will access the country population/available products and the country could list all factories). Repositories also give me more versatility since I can access from other parts of the code without knowing the country it belongs to.
I cannot make this work in Godot in an scalable way. Even tho I have something that works, I feel like changes affects every thing and other code needs to be changed every time.
How this relations are intended to be managed? Should I create another type that store all relations and then access this node/object to get the data I need for every action?
Sorry if is the question is confusing, but I’m really confused and lost. I’ll try to clarify anything
Thank you!