Please excuse the long post. I was initially just going to ask about deriving from PackedScene, but I figured that including my other options and the surrounding context would make things clearer. I have some questions, but I’m also looking for thoughts and feedback in general.
Godot Version
4.2.1
Background
In my game, attack definitions (called GameActions) are defined as trees of nodes, which are then saved as Scenes. This will hopefully allow me to easily build modular attack systems with multiple parts.
For example, an attack that applies an effect to nearby enemies and heals the user might look like this:
RootNode (GameActionRoot)
├AOE (GameActionNode)
│└ApplyEffect (GameActionNode)
└HealPlayer (GameActionNode)
Each node within that structure has its own properties – AOE might include a parameter for range and damage, for example.
AOE (GameActionNode):
Range: 10
Shape: Circle
Damage: 0
HitsTeam: Enemy
The problem
As well as the behaviors provided by the branch and leaf nodes, each attack definition also needs to include some information about the whole thing. Things like its icon, its tooltip, its name, etc. I initially simply put these in the RootNode.
Those parameters have to be accessed far before the complicated tree is relevant. The tree isn’t necessary until the attack is initialized, but the icon, name, and tooltip all need to be accessible to the UI.
But when I store the trees as a PackedScene, these variables are no longer accessible at all, until I unpack the entire thing. I’m not really sure what the best way around this is.
I’ve listed a few options below, and I’d like to hear other people’s thoughts.