For example Godot has a class Called MeshInterface which inherits
GeometryInstance which inherits VisualInstance which.... Spatial....Node...Object etc.
when I have a MeshInstance object it should be possible to call the getNode function from Node directly on the mesh instance like this:
const tween = self.base.getNode(godot.Tween, godot.NodePath.fromString("Tween"));
tween.interpolateProperty(...);
this could be achieved by recursively adding all parent functions (unless it was already added, child functions should have priority...) to the current object (and then adding all functions of that parent as well...)
This is currently implemented in this file via the callUp function
|
pub fn callUp(comptime T: type, obj: *T, comptime function_name: []const u8, args: anytype) !void { |
|
if (!@hasDecl(T, "BaseClass")) { |
|
@compileError("call can only be used with Godot objects"); |
|
} |
|
|
|
if (!@hasDecl(T, function_name)) { |
|
try callUp(T.BaseClass, obj.base, function_name, args); |
|
return; |
|
} |
|
|
|
_ = try @call(.{}, @field(obj, function_name), args); |
|
} |
Obvious downside however that you can't do this with your current class.
For example Godot has a class Called MeshInterface which inherits
GeometryInstance which inherits VisualInstance which.... Spatial....Node...Object etc.
when I have a MeshInstance object it should be possible to call the getNode function from Node directly on the mesh instance like this:
this could be achieved by recursively adding all parent functions (unless it was already added, child functions should have priority...) to the current object (and then adding all functions of that parent as well...)
This is currently implemented in this file via the callUp function
godot-zig/src/main.zig
Lines 15 to 26 in 30ffc92
Obvious downside however that you can't do this with your current class.