pub const onCastFn = ?*const fn (self: *Spell, entity: *Entity) void;
pub const Spell = struct {
name: []const u8,
onCast: onCastFn,
isActive: bool,
pub fn init(name: []const u8, onCast: onCastFn) @This() {
return @This(){
.name = name,
.onCast = onCast,
.isActive = false,
};
}
pub fn cast(self: @This(), args: anytype) void {
if (self.onCast) |onCast| {
onCast(args[0], args[1]);
}
}
};
pub const SpellBook = struct {
spells: std.ArrayList(Spell),
...
Is it possible / workaround for me to use anytime for my onCastFn?
I cant use anytype because the ArrayList requires that the parameter to be known in comptime
note: argument to function being called at comptime must be comptime-known