Asking for some clearance on a design subject.
Context, It’s a game about throwing bombs, I have some bombs with side effects, properties are a range of damage, a time for the cloud to dissapear and a reference to the effect.
I want for each bomb a bomb+.
So I made some resources with those values for each one. Bomb and bomb+ are exactly the same scene when I need to throw them.
To be able to make bomb+ I need an upgrade of equipement. And to produce a bomb+ I only will use the values on the bomb+ resource to create a bomb scene with higher values.
Is a decorator an overkill? I’m totally sure it is, and this game is only a prototype that will never see the light before a rework. Then, when it stops being an overkill?
I’m a bit extensive with this, but what if we take the other dimension? not between bomb and bomb+ but the multiple special effects? there is a place for decorator in there? Not sure yet how I will apply the effects, but maybe it’s a good example.
It depends on your data structure and systems design (as you said about bombs potentially gaining new overclock abilities).
The upgrade from Bomb to Bomb+ in terms of properties sounds linear and deterministic, therefore you can hardcode the upgrade method which is triggered when the game detects the equipment upgrade.
You could also save the Bomb properties inside of an Array instead of flat variables. This way your Bombs have an actual level that can go beyond Bomb+. dmg[0] for Bomb, dmg[1] for Bomb+, etc
Lastly, you could create a BaseBomb, which all bombs inherit from.
Then you inherit from each bomb to create a Bomb+ which have altered properties AND may have new effects that are not found in the unupgraded Bombs. With such a system, you could override existing methods so that your code becomes more manageable and structured.
As for the overclocks, I would assume you would have to go with Components.
Every Bomb has a number of component slots that can be filled with modular overclocks. One overclock could be that it doubles the amount of cloud onscreen time, or explodes the cloud when in contact, or allows you to throw two bombs at once.
Yes, using a decorator pattern for the bomb+ functionality in your game seems like overkill for a prototype. The primary goal of a decorator is to dynamically add new behaviors to objects without modifying their existing code. In your case, the bomb+ is essentially just a variation of the bomb with enhanced properties. Creating a new bomb object with the desired values would be a more straightforward and efficient approach.