I'm designing a system for a Unity game where each plant type is defined using a ScriptableObject. The ScriptableObject stores the plant’s base parameters such as growth speed, harvest value, and an associated attack type.
The attack-type itself is also defined as a ScriptableObject, since different plants can use different attack behaviours (for example: projectile, bomb, electric shock, etc.). Each attack-type has its own unique set of parameters. For instance, a projectile attack might have parameters like projectile speed and damage, while a bomb attack might have explosion radius and fuse time.
During gameplay, the player can purchase items or upgrades that modify these parameters at runtime (for example increasing damage, reducing cooldown, or changing projectile speed). Since these values change during the run, it would not be appropriate to modify the ScriptableObject assets directly, as they represent the base definitions. Instead, these parameters would need to exist as mutable runtime copies that can be safely modified without affecting the original assets.
If this were only for the plant’s own parameters, creating a mutable runtime copy of the plant stats would be straightforward. However, since the plant references an attack-type ScriptableObject hierarchy with multiple inherited attack types, each with different parameter sets, this would likely require creating separate mutable runtime copies for each attack-type as well?
The question is how to structure this cleanly. Is creating runtime copies for each attack type the correct approach in this situation, or is there a better way to organize this system while still keeping ScriptableObjects as immutable base definitions? Or is there a better architecture than this for implementing this.
Plus I plan to have other SO based paramaters similar to attack-type like Special-Powers etc.
Code structure I have in mind:
(Same as above discussed)
https://paste.ofcode.org/cweheC9sHkDx4usURGDgGj