Godot Version
4.2.2
Question
I’m rebuilding something I made in Unity. My game has a bunch of different objects like Rock, Tree, Sheep, Merchant, Bandit, etc. They’re basically all just tokens with data fields and some functions. In Unity, I used derived classes to build all of these off a base object, adding new fields to children to flesh out their game info.
All objects have a base class CoreObject. This contains basic data such as the object’s name, owner, visibility, etc.
TerrainObjects are children of CoreObject. They contain data for stuff like trees or rocks, stuff that just sits there. They hold fields like toughness, destructibility, scavenge value, etc.
ActiveObjects are also children of CoreObject. I used them for merchants, bandits, sheep—anything that moves or does things with its own decision making process. It contains data like the object’s speed, bravery, sight range, aggression, etc.
Finally, I have specific classes for things like Merchant, Enemy, Animal, etc, which are all children of the ActiveObject class. Merchants can buy and sell resources. Enemies will attack and fight back. Animals will run away if you attack them.
This all works pretty smoothly in Unity, but now I’m trying to adapt it over to the node structures in Godot. Pic below to help explain. Questions:
Would it be better to use the derived class approach:
CoreObject >> ActiveObject >> Merchant
Or would it be better to make each of these classes its own node:
A Sheep scene has a CoreObject node and an ActiveObject node and an Animal node, each with the fields and code needed for those components.
A Rock would have a CoreObect node and a Terrain node.
Or is there just a better way to do this and I’m way off base?
Pic for examples: