Aego Playground

Nodes, components and references

NodeRef

Method
IsAlive() bool, Name() string, Parent() NodeRef, Child(name string) NodeRef, Find(path string) NodeRef, Destroy() hierarchy; Find accepts Weapon/Gun, ../Sibling, /Root/Player
Enabled() bool, SetEnabled(bool), Space() int state; Space is 0 for 2D, 1 for 3D
Transform2D() Transform2D, SetTransform2D(t), Position() Vec2, SetPosition(Vec2), WorldPosition() Vec2, Rotation() float, SetRotation(float), Scale() Vec2, SetScale(Vec2) 2D nodes
Transform3D() Transform3D, SetTransform3D(t), Position3() Vec3, SetPosition3(Vec3), Rotation3() Quat, SetRotation3(Quat) 3D nodes
Get<T>() ComponentRef<T>, Has<T>() bool components
GetScript<T>() ScriptRef<T>, HasScript<T>() bool scripts (§18)

Transforms are read and written by value: t := node.Transform2D(); t.Position.X += 1; node.SetTransform2D(t). A 2D method on a 3D node (and the reverse) faults. Destroy takes effect at the end of the phase; IsAlive is false immediately. Get<T>() and GetScript<T>() on a destroyed node return nil; on a nil reference they fault with AES6004.

Components

node.Get<SpriteRenderer>() returns a ComponentRef<SpriteRenderer> or nil. Field names are the schema names with an upper-cased first letter (sr.FlipX, hp.Current); read-only fields cannot be assigned. A short component name works when it is unique among registered components; otherwise write the full name (render2d.SpriteRenderer). An enum field of a Go component is exposed as int.

Components may also expose methods: hp.Damage(5), body.ApplyImpulse(Vec2{0, -300}). Which fields and methods are visible is decided by the component's owner when it registers the component (§11); the generated library stubs (Ctrl+Click on a component name in the editor) show exactly what is available.

A ComponentRef is safe to keep in a field: it is re-validated on every access and faults with AES6004 as soon as the component or its node is destroyed, even before the end of the phase.

AssetRef

IsNil() bool, Name() string. Assets are assigned in the Inspector; scripts pass them to engine functions (scene.Instantiate).