High level
At a high level, I'm looking to create a galaxy exploration-style game.
A number of points of interest will be selectable on the map (I'd like to aim for several hundred, but flexible and needs testing).
A POI can be something story-related or a source of one of 4 resources.
Players start with a ship, head to a resource node, harvest resources and can move on.
So far so good, I've got a small number of resources, so can just group them together as a single ResourceStockpile
component and hide empty resources in the UI.
The POI that produce resources will have a service that increments their stockpile over time, and ships will have a "cargo bay" of ResourceStockpile
.
The player can use [some resources] to create factories at a POI.
Factories convert resources to goods (both finished products and components/parts).
Complexity
I want to be able to ship goods. Unlike resources, I'm expecting to have several dozen types of finished good (and many more intermediate parts and components), with an eye to expanding over time.
Storing a few zeroes for resources seemed like a small overhead to maintain a consistent ResourceStockpile
I could reuse.
As the number of items/fields grows, the design feels less and less desirable.
To make things more interesting, I'd ideally like to be able to ship pretty much anything (including the factories, if the ship is large enough).
Do I switch to a HasX
component for every possible resource/good? If so, it seems like I'm going to spend an awful lot of time swapping between archetypes.
It also seems like a lot of duplicated code, unless there's some way to treat it as a generic Has<X>
instead, but I believe that's quite complex to implement, and may negate some of the memory management benefits of ECS (?)
Or do I create a ResourceStockpile
with -say- 100 integers, one per possible resource/good and just swallow the overhead?
What's the right™ way to break this down?