Documentation ¶
Index ¶
- Variables
- func Attach(parent Object, child Component)
- func Builder[K Object](object K) *builder[K]
- 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 New[K Object](name string, obj K) K
- func NewComponent[K Component](cmp K) K
- func Register[T Serializable](info TypeInfo)
- func Save(writer io.Writer, obj Component) error
- func Serialize(enc Encoder, obj Component) error
- func Toggle(object Component, enabled bool)
- type Component
- func Children(object Component) []Component
- func Components(object Component) []Component
- func Copy(obj Component) Component
- func Deserialize(decoder Decoder) (Component, error)
- func DeserializeObject(dec Decoder) (Component, error)
- func Load(reader io.Reader) (Component, error)
- func Root(obj Component) Component
- type ComponentState
- type CreateFn
- type Decoder
- type DeserializeFn
- type DisableHandler
- type EnableHandler
- type Encoder
- type GenericProp
- type MemorySerializer
- type Object
- type ObjectState
- type PropInfo
- type PropValue
- type Property
- 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 Registry
- type Serializable
- type TypeInfo
Constants ¶
This section is empty.
Variables ¶
var ErrSerialize = errors.New("serialization error")
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 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 ¶
func NewComponent[K Component](cmp K) K
func Register ¶
func Register[T Serializable](info TypeInfo)
Types ¶
type Component ¶
type Component interface { // ID returns a unique identifier for this object. ID() uint // 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 object. Called on every frame. Update(Component, float32) // Destroy the object Destroy() // contains filtered or unexported methods }
func Children ¶
Returns all the children of an object. Returns the empty slice if the object is a component.
func Components ¶
Returns the components attached to an object
func Deserialize ¶
func DeserializeObject ¶
type ComponentState ¶
func NewComponentState ¶
func NewComponentState(c Component) ComponentState
func (ComponentState) New ¶
func (c ComponentState) New() Component
type DeserializeFn ¶
type DisableHandler ¶
type DisableHandler interface { Component OnDisable() }
type EnableHandler ¶
type EnableHandler interface { Component OnEnable() }
type MemorySerializer ¶
type MemorySerializer struct {
// 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 returns a slice containing the objects children. Children() []Component // contains filtered or unexported methods }
type ObjectState ¶
type Property ¶
type Property[T PropValue] struct { OnChange events.Event[T] // contains filtered or unexported fields }
func NewProperty ¶
type Query ¶
type Query[K Component] struct { // contains filtered or unexported fields }