In many languages, traits are just sharable pieces of code. But in Godot, it may also be a Node. Why not share a hitbox as an Area2D as a trait ?
If a trait is a Node (it extends Node or a sub-class of Node), it should be added as a child of the receiver, to allow the trait to use methods like _process and all. It allows it to access the scene tree too.
Second thing is, only objects and ref counted are traits. By doing this feature, if a Node script becomes a trait, if it has an associated scene (a scene where the root element has this script attached), the scene should be instantiated as the trait instead of the script itself.
In many languages, traits are just sharable pieces of code. But in Godot, it may also be a
Node
. Why not share a hitbox as anArea2D
as a trait ?If a trait is a Node (it extends
Node
or a sub-class ofNode
), it should be added as a child of the receiver, to allow the trait to use methods like_process
and all. It allows it to access the scene tree too.Second thing is, only objects and ref counted are traits. By doing this feature, if a
Node
script becomes a trait, if it has an associated scene (a scene where the root element has this script attached), the scene should be instantiated as the trait instead of the script itself.