Native bindings
Project Go code in native/ exposes functions, constants and component members through the SDK.
Functions
m := r.ScriptModule("mygame/combat")
sdk.Proc2(m, "Damage", func(c *sdk.ScriptCtx, target sdk.NodeHandle, amount int64) {
if h, ok := sdk.Get[Health](c.Scene, target); ok {
h.Current -= float32(amount)
}
}, sdk.ScriptDoc("deals damage to a node with Health"))
Scripts import "mygame/combat" and call combat.Damage(target, 5). Use Func0..Func3 for functions with a result, Proc0..Proc3 without, Const and Enum for constants and host enums. Allowed parameter and result types: bool, Go integer types, float32/float64, string, mathx.Vec2/Vec3/Color/Quat/Rect, scene.Transform2D/Transform3D, scene.NodeHandle (a NodeRef), asset.Ref[…], and integer types registered with Enum. Structs and slices cannot cross the boundary. c.Fail(msg) stops the calling instance with AES6010; a Go panic becomes AES6002.
Component fields and methods
A component registered through sdk.Component[T] exposes every field marked with the script schema flag by default. The builder narrows or extends that:
b := sdk.Component[Health](r, schema.Category("Gameplay"))
b.Script("Current", "Max")
sdk.Method1[Health, int64, bool](b, "Damage", func(c *sdk.ScriptCtx, h *Health, amount int64) bool {
h.Current -= float32(amount)
return h.Current <= 0
})
sdk.Proc0[Health](b, "Heal", func(c *sdk.ScriptCtx, h *Health) { h.Current = h.Max })
Script(names...) lists the visible fields, ScriptNone() hides the component from scripts entirely. Method0..Method3 and Proc0..Proc3 on a builder take the same parameter types as module functions plus the component pointer; they are compiled to typed adapters and allocate nothing per call. ScriptMethod(name, fn any) accepts an arbitrary Go function through reflection: it is for prototyping, logs a warning at registration and is rejected in aego_runtime builds.
The binding registry's hash covers every module, name and signature and is part of the compile cache key, so changing a native signature recompiles the scripts that use it. Changes in native/ are never swapped in-process (§19).