Documentation ¶
Index ¶
- Variables
- func Attach(parent Object, child Component)
- func Builder[K Object](object K) *builder[K]
- func Children(object Component) iter.Seq[Component]
- func Copy[T Component](pool Pool, obj T) T
- func Deserialize[T Component](pool Pool, decoder Decoder) (T, error)
- func Destroy(object Component)
- func Detach(child Component)
- func Disable(object Component)
- func Enable(object Component)
- func Get[K Component](self Component) K
- func GetAll[K Component](self Component) []K
- func GetAllInChildren[K Component](self Component) []K
- func GetAllInParents[K Component](self Component) []K
- func GetInChildren[K Component](self Component) K
- func GetInParents[K Component](self Component) K
- func ID() uint
- func Is[K any](c Component) bool
- func Key(prefix string, object Component) string
- func Load[T Component](pool Pool, assets fs.Filesystem, key string) (T, error)
- func NewComponent[K Component](pool Pool, cmp K) K
- func NewObject[K Object](pool Pool, name string, obj K) K
- func Register[T any](info Type)
- func Save(assets fs.Filesystem, key string, obj Component) error
- func Serialize(enc Encoder, obj Component) error
- func Toggle(object Component, enabled bool)
- type Array
- func (a *Array[T]) Append(value T)
- func (a *Array[T]) AppendAny(value any)
- func (a *Array[T]) Delete(index int)
- func (a *Array[T]) Deserialize(dec Decoder) error
- func (a *Array[T]) Get(index int) T
- func (a *Array[T]) GetAny(index int) any
- func (a *Array[T]) Length() int
- func (a *Array[T]) Serialize(enc Encoder) error
- func (a *Array[T]) Set(index int, value T)
- func (a *Array[T]) SetAny(index int, value any)
- type Component
- type CreateFn
- type Decoder
- type Dict
- func (d *Dict[K, V]) Delete(key K)
- func (d *Dict[K, V]) Deserialize(dec Decoder) error
- func (d *Dict[K, V]) Get(key K) (V, bool)
- func (d *Dict[K, V]) GetAny(key K) (any, bool)
- func (d *Dict[K, V]) Serialize(enc Encoder) error
- func (d *Dict[K, V]) Set(key K, value V)
- func (d *Dict[K, V]) SetAny(key K, value any)
- type DisableHandler
- type EnableHandler
- type EncodedProp
- type Encoder
- type GenericProp
- type Handle
- type MemorySerializer
- type Object
- type Pool
- type PropInfo
- type PropValue
- type Property
- func (p *Property[T]) Deserialize(pool Pool, dec Decoder) error
- func (p *Property[T]) Get() T
- func (p *Property[T]) GetAny() any
- func (p *Property[T]) Serialize(enc Encoder) error
- func (p *Property[T]) Set(value T)
- func (p *Property[T]) SetAny(value any)
- func (p *Property[T]) String() string
- func (p *Property[T]) Type() reflect.Type
- type Query
- func (q *Query[K]) Collect(roots ...Component) []K
- func (q *Query[K]) CollectObjects(roots ...Component) []Component
- func (q *Query[K]) First(root Component) (K, bool)
- func (q *Query[K]) Reset() *Query[K]
- func (q *Query[K]) Sort(sorter func(a, b K) bool) *Query[K]
- func (q *Query[K]) Where(predicate func(K) bool) *Query[K]
- type Ref
- type Registry
- type SceneFunc
- type Serializable
- type Type
Constants ¶
This section is empty.
Variables ¶
var ErrSerialize = errors.New("serialization error")
var GlobalPool = NewPool()
Functions ¶
func Attach ¶
Attach a child component/object to a parent object If the object already has a parent, it will be detached first.
func Builder ¶
func Builder[K Object](object K) *builder[K]
Builder instantiates a new group builder.
func Children ¶
Returns all the children of an object. Returns the empty slice if the object is a component.
func Deserialize ¶
deserialization
func Detach ¶
func Detach(child Component)
Detach a child component/object from its parent object Does nothing if the given object has no parent.
func Get ¶
Gets a reference to a component of type K on the same object as the component/object specified.
func GetAll ¶
Gets references to all components of type K on the same object as the component/object specified.
func GetAllInChildren ¶
Gets references to all components of type K on the same object as the component/object specified, or any child of the object.
func GetAllInParents ¶
Gets references to all components of type K in any parent of the object/component. For component targets, sibling components will be returned.
func GetInChildren ¶
Gets a reference to a component of type K on the same object as the component/object specified, or any child of the object.
func GetInParents ¶
Gets the first reference to a component of type K in any parent of the object/component. For component targets, sibling components will be returned.
func NewComponent ¶
Types ¶
type Array ¶
type Array[T PropValue] struct { // contains filtered or unexported fields }
func (*Array[T]) Deserialize ¶
type Component ¶
type Component interface { // ID returns a unique identifier for this object. ID() Handle // Pool returns the object pool this object belongs to. Pool() Pool // Name is used to identify the object within the scene. Name() string // Parent returns the parent of this object, or nil Parent() Object // Transform returns the object transform Transform() transform.T // Active indicates whether the object is active in the scene or not. // E.g. the object/component and all its parents are enabled and active. Active() bool // Enabled indicates whether the object is currently enabled or not. // Note that the object can still be inactive if an ancestor is disabled. Enabled() bool // Update the component. Called on every frame. Update(Component, float32) // contains filtered or unexported methods }
func Components ¶
Returns the components attached to an object
type Dict ¶
type Dict[K comparable, V any] struct { // contains filtered or unexported fields }
func NewDict ¶
func NewDict[K comparable, V any]() Dict[K, V]
func (*Dict[K, V]) Deserialize ¶
type DisableHandler ¶
type DisableHandler interface { Component OnDisable() }
type EnableHandler ¶
type EnableHandler interface { Component OnEnable() }
type EncodedProp ¶
type MemorySerializer ¶
type MemorySerializer struct { Stream []any // contains filtered or unexported fields }
func (*MemorySerializer) Decode ¶
func (m *MemorySerializer) Decode(target any) error
func (*MemorySerializer) Encode ¶
func (m *MemorySerializer) Encode(data any) error
type Object ¶
type Object interface { Component input.Handler // Children iterates over the objects children. Children() iter.Seq[Component] // Child returns the child at the given index. Child(index int) Component // Len returns the number of children attached to the object. Len() int // contains filtered or unexported methods }
type Pool ¶
type Property ¶
type Property[T PropValue] struct { // OnChange executes callbacks every time the property value is changed. // The callback is called with the new value. // Only the propertys owner object should subscribe to this event. OnChange events.Event[T] // contains filtered or unexported fields }
func NewProperty ¶
type Query ¶
type Query[K Component] struct { // contains filtered or unexported fields }