module

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package module runs independent minimum systems composed by project scene plans.

Index

Constants

View Source
const InputTopic = "input"
View Source
const SceneTarget = ""

SceneTarget addresses the sender's scene. All other targets are instance IDs in that scene. Receivers need no declaration or subscription.

Variables

View Source
var (
	ErrInvalid        = errors.New("module: invalid argument")
	ErrDisposed       = errors.New("module: instance disposed")
	ErrBusy           = errors.New("module: structural operation requires a tick boundary")
	ErrQueueFull      = errors.New("module: event queue capacity reached")
	ErrPendingFull    = errors.New("module: pending request capacity reached")
	ErrCommandFull    = errors.New("module: structural command capacity reached")
	ErrType           = errors.New("module: protocol type mismatch")
	ErrOwnership      = errors.New("module: entity belongs to another instance")
	ErrReadOnly       = errors.New("module: slot does not allow external writes")
	ErrTimeout        = errors.New("module: request timed out")
	ErrCanceled       = errors.New("module: request canceled")
	ErrAlreadyReplied = errors.New("module: request already replied")
	ErrUnavailable    = errors.New("module: request receiver unavailable")
	ErrStaleRevision  = errors.New("module: request slot revision changed")
)
View Source
var ErrStartupLimit = errors.New("module: scene startup did not settle within its batch/event budget")

Functions

func OnSlotsChange

func OnSlotsChange(c *Context, names []string, handler func(*Context) error) error

OnSlotsChange coalesces writes to the named slots into one next-batch callback. Binding is cold Install work; stable slot changes do not allocate or poll.

Types

type AnimationsContent

type AnimationsContent struct{}

type Collision2D

type Collision2D struct {
	Element         string
	Phase           physics.CollisionPhase
	Type, OtherType uint32
	Normal, Point   [2]float32
	Penetration     float32
}

Geometry uses solver world coordinates. Element is the sender's private name; OtherType is the collider's authored category, never an external entity handle.

type Collision3D

type Collision3D struct {
	Element         string
	Phase           physics.CollisionPhase
	Type, OtherType uint32
	Normal, Point   [3]float32
	Penetration     float32
}

type Content

type Content struct {
	// contains filtered or unexported fields
}

Content confines procedural UI and model operations to one module. ECS IDs returned by UI libraries are checked against ownership at every access.

func (*Content) BindControl

func (c *Content) BindControl[T any](id string, v T) error

func (*Content) ControlTextTabWidth

func (c *Content) ControlTextTabWidth(e ecs.Entity, text *scene.Text2D) (float32, bool)

func (*Content) Define

func (c *Content) Define[P, S any](template html.Template, css string, b ContentBehavior[P, S]) (*html.Definition[P, S], error)

func (*Content) Despawn

func (c *Content) Despawn(e ecs.Entity) bool

func (*Content) Element

func (c *Content) Element(id string) (ecs.Entity, error)

func (*Content) FindPart

func (c *Content) FindPart[P, T any](e ecs.Entity) (ecs.Entity, bool)

func (*Content) Focus

func (c *Content) Focus(e ecs.Entity) bool

func (*Content) FocusedControl

func (c *Content) FocusedControl() ecs.Entity

FocusedControl returns this module's keyboard focus, or zero if focus is outside.

func (*Content) Font

func (c *Content) Font(name string) (*text.Font, error)

func (*Content) Get

func (c *Content) Get[T any](e ecs.Entity) (T, bool)

func (*Content) HTMLControl

func (c *Content) HTMLControl(e ecs.Entity, id string) (ecs.Entity, bool)

func (*Content) HTMLNode

func (c *Content) HTMLNode(e ecs.Entity, id string) (html.Node, bool)

func (*Content) HTMLRoot

func (c *Content) HTMLRoot(e ecs.Entity) (html.Node, error)

func (*Content) HTMLScrollStyle

func (c *Content) HTMLScrollStyle(e ecs.Entity, id string) (html.ScrollStyle, bool)

func (*Content) HTMLSet

func (c *Content) HTMLSet(e ecs.Entity, source string)

func (*Content) HTMLSetCSS

func (c *Content) HTMLSetCSS(e ecs.Entity, cssText string) bool

func (*Content) HTMLSetOffset

func (c *Content) HTMLSetOffset(e ecs.Entity, id string, x, y float32) bool

func (*Content) HTMLSetScroll

func (c *Content) HTMLSetScroll(e ecs.Entity, id string, area ecs.Entity, x, y float32) bool

func (*Content) Has

func (c *Content) Has[T any](e ecs.Entity) bool

func (*Content) Insert

func (c *Content) Insert[T any](e ecs.Entity, value T) error

func (*Content) IsAlive

func (c *Content) IsAlive(e ecs.Entity) bool

func (*Content) ModelRig

func (c *Content) ModelRig(name string) (*project.ModelRig, error)

func (*Content) Mount

func (c *Content) Mount[P, S any](e ecs.Entity, d *html.Definition[P, S], p P, s S, key uint64) (ecs.Entity, error)

func (*Content) MustElement

func (c *Content) MustElement(id string) ecs.Entity

func (*Content) MustMut

func (c *Content) MustMut[T any](e ecs.Entity) *T

func (*Content) Mut

func (c *Content) Mut[T any](e ecs.Entity) *T

func (*Content) Query

func (c *Content) Query[T any]() iter.Seq2[ecs.Entity, ecs.ComponentAccess[T]]

func (*Content) Query2

func (c *Content) Query2[A, B any]() iter.Seq2[ecs.Entity, ecs.Components2[A, B]]

func (*Content) ReadFile

func (c *Content) ReadFile(name string) ([]byte, error)

func (*Content) Ref

func (c *Content) Ref[T any](e ecs.Entity) *T

func (*Content) RefreshTransforms

func (c *Content) RefreshTransforms() error

func (*Content) ReleaseHTML

func (c *Content) ReleaseHTML(e ecs.Entity)

func (*Content) RemoveResource

func (c *Content) RemoveResource[T any]() (T, bool)

func (*Content) Resource

func (c *Content) Resource[T any]() (T, bool)

func (*Content) ResourceMut

func (c *Content) ResourceMut[T any]() (*T, bool)

func (*Content) Root

func (c *Content) Root() ecs.Entity

func (*Content) ScrollOffset

func (c *Content) ScrollOffset(e ecs.Entity) (mgl32.Vec2, bool)

func (*Content) SetControlValue

func (c *Content) SetControlValue(e ecs.Entity, v string) bool

func (*Content) SetDisabled

func (c *Content) SetDisabled(e ecs.Entity, v bool)

func (*Content) SetIfChanged

func (c *Content) SetIfChanged[T comparable](e ecs.Entity, v T) bool

func (*Content) SetScrollOffset

func (c *Content) SetScrollOffset(e ecs.Entity, v mgl32.Vec2) bool

func (*Content) SetSelected

func (c *Content) SetSelected(e ecs.Entity, v bool)

func (*Content) Spawn

func (c *Content) Spawn(bundle ecs.Bundle) ecs.Entity

func (*Content) SpawnNode

func (c *Content) SpawnNode[T any](o ui.NodeOptions, v T) ecs.Entity

func (*Content) SpawnNode2

func (c *Content) SpawnNode2[A, B any](o ui.NodeOptions, a A, b B) ecs.Entity

func (*Content) SpawnScrollArea

func (c *Content) SpawnScrollArea(o ui.ScrollAreaOptions) ecs.Entity

func (*Content) Store

func (c *Content) Store[T any](value T)

func (*Content) SurfaceFonts

func (c *Content) SurfaceFonts(e ecs.Entity, font, bold *text.Font)

ImageProvider and fonts are installed on owned surfaces rather than globally.

func (*Content) SyncHTML

func (c *Content) SyncHTML() error

func (*Content) SyncUI

func (c *Content) SyncUI() error

func (*Content) Unmount

func (c *Content) Unmount(e ecs.Entity) bool

func (*Content) UpdateState

func (c *Content) UpdateState[P, S any](e ecs.Entity, update func(*S)) bool

type ContentBehavior

type ContentBehavior[P, S any] struct {
	Render      func(ContentRenderContext[P, S], *html.View)
	Unmount     func(*ContentComponentContext[P, S])
	HandleEvent func(*ContentEventContext[P, S])
}

type ContentComponentContext

type ContentComponentContext[P, S any] = ContentRenderContext[P, S]

type ContentEventContext

type ContentEventContext[P, S any] struct {
	World   *Content
	Pointer *html.PointerEvent
	Props   *P
	State   *S

	Ref       string
	Event     html.Event
	Component ecs.Entity
	// contains filtered or unexported fields
}

func (*ContentEventContext[P, S]) PreventDefault

func (c *ContentEventContext[P, S]) PreventDefault()

func (*ContentEventContext[P, S]) StopPropagation

func (c *ContentEventContext[P, S]) StopPropagation()

func (*ContentEventContext[P, S]) UpdateState

func (c *ContentEventContext[P, S]) UpdateState(update func(*S)) bool

type ContentFeature

type ContentFeature interface {
	// contains filtered or unexported methods
}

type ContentMessages

type ContentMessages[T any] struct {
	// contains filtered or unexported fields
}

ContentMessages filters engine control messages to their owning module.

func (*ContentMessages[T]) All

func (r *ContentMessages[T]) All(c *Content) iter.Seq[*T]

type ContentProfile

type ContentProfile interface {
	// contains filtered or unexported methods
}

ContentProfile selects component construction and its entire lifecycle at compile time. It must cover both authored content and content created by code.

type ContentRenderContext

type ContentRenderContext[P, S any] struct {
	World     *Content
	Props     *P
	State     *S
	Component ecs.Entity
}

ContentRenderContext is passed by value; Props and State refer to the component.

type ContentSystemContext

type ContentSystemContext struct{ World *Content }

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context deliberately exposes neither the global World nor foreign entities. One stable context is allocated at mount and reused for every callback.

func (*Context) Active

func (c *Context) Active() bool

func (*Context) Alive

func (c *Context) Alive() bool

func (*Context) BindEmitter

func (c *Context) BindEmitter[T any](topic string) (Emitter[T], error)

func (*Context) BindRequester

func (c *Context) BindRequester[Q, R any](topic string) (Requester[Q, R], error)

func (*Context) Content

func (c *Context) Content() *Content

func (*Context) Despawn

func (c *Context) Despawn(e Entity) error

func (*Context) Disown

func (c *Context) Disown[T ownedResource](resource T)

Disown removes an explicitly closed resource from lifecycle bookkeeping.

func (*Context) Dispose

func (c *Context) Dispose() error

func (*Context) Each

func (c *Context) Each[T any](visit func(Entity, T) bool) (err error)

Each visits this module's private entity list only. Values are read copies; returning false stops iteration. Entities spawned during traversal wait until the boundary before becoming visible to queries.

func (*Context) Element

func (c *Context) Element(name string) (Entity, error)

Element resolves only authored private content inside this module.

func (*Context) Forward

func (c *Context) Forward(target string, m Message) error

Forward preserves the sender and payload. Scenes relay to modules within the current delivery; module relays enter the next batch. Sends always enqueue. Requests have one destination per delivery.

func (*Context) ForwardAs

func (c *Context) ForwardAs(target, topic string, m Message) error

func (*Context) Generation

func (c *Context) Generation() uint64

func (*Context) Get

func (c *Context) Get[T any](e Entity) (T, bool)

func (*Context) Host

func (c *Context) Host() *Host

func (*Context) InstallMaterial3D

func (c *Context) InstallMaterial3D[T graphics.Material3D](entity Entity, material *T) error

InstallMaterial3D replaces the built-in material during this instance's installation and registers its concrete renderer without exposing the World.

func (*Context) Name

func (c *Context) Name() string

func (*Context) OpenFile

func (c *Context) OpenFile(name string) (fs.File, error)

OpenFile serves inline component paths and other module-private files. Resolution uses the same ownership boundary as the project compiler.

func (*Context) OpenResource

func (c *Context) OpenResource(name string) (fs.File, error)

OpenResource accepts a declared private resource name, not an arbitrary path. The module chooses its file layout; no resources/ directory is imposed.

func (*Context) Own

func (c *Context) Own[T ownedResource](resource T) error

func (*Context) Remove

func (c *Context) Remove[T any](e Entity) error

func (*Context) Reparent

func (c *Context) Reparent(child, parent Entity) error

func (*Context) Resource

func (c *Context) Resource[T any](kind, name string) (T, error)

Resource returns a typed, privately declared resource installed by a feature.

func (*Context) Root

func (c *Context) Root() Entity

func (*Context) Send

func (c *Context) Send[T any](target, topic string, value T) error

Send is convenient for occasional messages. BindEmitter avoids even the type lookup on frequently used send paths.

func (*Context) Set

func (c *Context) Set[T any](e Entity, value T) error

Set replaces existing components immediately; archetype changes are commands applied after the batch/update traversal. Transform writes affect local content.

func (*Context) Slot

func (c *Context) Slot(name string) (Slot, error)

func (*Context) Spawn

func (c *Context) Spawn(parent Entity) (Entity, error)

func (*Context) Switch

func (c *Context) Switch(request SceneSwitchRequest) error

type Emitter

type Emitter[T any] struct {
	// contains filtered or unexported fields
}

BindEmitter reserves typed buffers during Install. Emit sends to the scene; EmitTo addresses any scene module without a declared receive port.

func (Emitter[T]) Emit

func (e Emitter[T]) Emit(value T) error

func (Emitter[T]) EmitTo

func (e Emitter[T]) EmitTo(target string, value T) error

type Entity

type Entity struct {
	// contains filtered or unexported fields
}

Entity is an ownership-bound handle; it cannot be converted into an ECS ID.

type FontService

type FontService struct {
	// contains filtered or unexported fields
}

FontService reads only its module's declared resource. Identical font bytes share layout/output caches within the Runtime; provider state stays private.

func (*FontService) Destroy

func (f *FontService) Destroy() error

func (*FontService) Load

func (f *FontService) Load(c *Context, resource string) error

func (*FontService) Render

type FullContent

type FullContent struct{}

FullContent supports every authored component, including HTML and 3D.

type HTMLContent

type HTMLContent struct{}

type HTMLNode

type HTMLNode struct {
	// contains filtered or unexported fields
}

HTMLNode permits document edits inside an owned surface without exposing a World, ECS identity or callbacks with access to foreign input targets.

func HTML

func HTML(c *Context, surface Entity) (HTMLNode, error)

func (HTMLNode) Append

func (n HTMLNode) Append(child HTMLNode) bool

func (HTMLNode) Bounds

func (n HTMLNode) Bounds() (Rect, bool)

Bounds returns the node's last synchronized layout border box in the HTML surface's coordinates. Hidden or detached nodes have no box; runtime scroll and animation offsets are not included.

func (HTMLNode) Clear

func (n HTMLNode) Clear() bool

func (HTMLNode) Clone

func (n HTMLNode) Clone() HTMLNode

func (HTMLNode) FindByID

func (n HTMLNode) FindByID(id string) (HTMLNode, bool)

func (HTMLNode) Remove

func (n HTMLNode) Remove() bool

func (HTMLNode) RemoveAttribute

func (n HTMLNode) RemoveAttribute(name string) bool

func (HTMLNode) SetAttribute

func (n HTMLNode) SetAttribute(name, value string) bool

func (HTMLNode) SetHidden

func (n HTMLNode) SetHidden(hidden bool) bool

func (HTMLNode) SetSelectedIndex

func (n HTMLNode) SetSelectedIndex(selected int) bool

func (HTMLNode) SetText

func (n HTMLNode) SetText(value string) bool

type Host

type Host struct {
	Context              *window.Context
	RequestRender        func()
	WakeAt               func(time.Time)
	RequestClose         func()
	Minimize             func()
	ToggleMaximize       func()
	ToggleFullscreen     func()
	SetWindowTitle       func(string)
	SetViewport          func(int, int)
	GetViewport          func() (int, int)
	SetWindowDragRegion  func(func(float64, float64) bool)
	SetWindowInputRegion func([]window.InputRegionRect)
	OnCloseRequested     func(func() bool)
	OpenFolder           func(window.FileDialogOptions) (string, error)
	OpenFile             func(window.FileDialogOptions) (string, error)
	OpenFiles            func(window.FileDialogOptions) ([]string, error)
	SetClipboardText     func(string) bool
	SetMouseCaptured     func(bool) bool
	MouseCaptured        func() bool
	TakeMouseDelta       func() (float64, float64)
}

Host provides platform capabilities without exposing the application world.

type Input

type Input struct {
	Target   Entity
	Element  string
	HTMLID   string
	HTMLKind htmlui.EventKind
	Value    string
	Event    scene.InputEvent
}

Input removes raw cross-module ECS identities from the engine input event.

type LayoutContent

type LayoutContent struct{}

type Lifecycle

type Lifecycle[T any] struct {
	Install func(*Context, *T) error
	Enter   func(*Context, *T, SceneStartup) error
	Exit    func(*Context, *T) error
	Suspend func(*Context, *T) error
	Resume  func(*Context, *T, SceneStartup) error
	Update  func(*Context, *T, Tick) error
	// FrameUpdate runs once per awake frame before UI synchronization. Unlike
	// fixed Update, it does not keep an on-demand application awake.
	FrameUpdate func(*Context, *T, Tick) error
	OnMessage   func(*Context, *T, Message) error
	Destroy     func(*Context, *T) error
}

Lifecycle creates private state for every instance. Install and scene.startup run once during loading. Enter/Resume prepare activation before its commit; errors preserve the current foreground. Exit/Suspend leave the foreground, and Destroy releases the instance. Nil hooks have no schedule cost.

type ManagedResource

type ManagedResource interface {
	Activate(bool) error
	Close() error
}

ManagedResource belongs to one module and changes activity only at committed scene transitions. Heavy platform backends live in opt-in adapter packages.

type Message

type Message struct {
	Err   error
	Topic string
	From  string

	ID RequestID
	// contains filtered or unexported fields
}

Message is borrowed for the duration of OnMessage. Payloads remain typed in preallocated buffers. Use Value, RequestValue or ResultValue to inspect them.

func (Message) IsReply

func (m Message) IsReply() bool

func (Message) IsRequest

func (m Message) IsRequest() bool

func (Message) RequestValue

func (m Message) RequestValue[Q, R any]() (Request[Q, R], bool)

func (Message) ResultValue

func (m Message) ResultValue[T any]() (Result[T], bool)

func (Message) Value

func (m Message) Value[T any]() (T, bool)

type Options

type Options struct {
	Source            fs.FS
	Resources         project.ResourceFeature
	Host              *Host
	Wake              func()
	CommandCapacity   int
	OutputCapacity    int
	TextCacheCapacity int
	StartupBatches    int
	StartupEvents     int
	TimeoutTicks      uint64
	EventCapacity     int
	RequestCapacity   int
	// PayloadCapacity is the initial capacity per payload type and bank.
	// Zero selects min(8, EventCapacity); storage grows on demand while
	// EventCapacity continues to bound the total event queue.
	PayloadCapacity int
}

type ParticlesContent

type ParticlesContent struct{}

type Physics2DContent

type Physics2DContent struct{}

type Rect

type Rect struct{ X, Y, Width, Height float32 }

Rect is an element's border box in its HTML surface's coordinates.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry contains cold registration only. A Runtime snapshots it at creation.

func (*Registry) RegisterMod

func (r *Registry) RegisterMod[T any](id project.ModID, create func() T, hooks Lifecycle[T]) error

func (*Registry) RegisterScene

func (r *Registry) RegisterScene[T any](id project.SceneID, create func() T, hooks Lifecycle[T]) error

func (*Registry) RegisterValue

func (r *Registry) RegisterValue[T any](name project.ValueType, decode func(project.SlotValue) (T, error)) error

RegisterValue connects a JSON protocol name to a concrete Go type. Decode is used only for slot reads, never to encode message payloads. Slice/pointer fields in event values are immutable until delivery completes.

type Render2D

type Render2D struct{}

Render2D supports sprites, text, cameras, materials and pointer input.

type RenderOutputHandle

type RenderOutputHandle = scene.RenderOutputHandle

type Request

type Request[Q, R any] struct {
	Value Q

	ID RequestID
	// contains filtered or unexported fields
}

Request carries an opaque reply address, never the requester's Context/entity. Retaining it for deferred work is safe; Reply validates its identity again.

func (Request[Q, R]) Fail

func (q Request[Q, R]) Fail(c *Context, err error) error

Fail reports a service failure through Result, with the same reply-address validation as Reply. The callback is delivered at the next batch boundary.

func (Request[Q, R]) Reply

func (q Request[Q, R]) Reply(c *Context, value R) error

type RequestID

type RequestID uint64

type RequestOptions

type RequestOptions struct {
	Revision SlotRevision
	// Zero selects the Runtime default; timeouts count fixed logic ticks.
	TimeoutTicks uint64
}

type Requester

type Requester[Q, R any] struct {
	// contains filtered or unexported fields
}

func (Requester[Q, R]) Cancel

func (p Requester[Q, R]) Cancel(id RequestID) error

func (Requester[Q, R]) Send

func (p Requester[Q, R]) Send(value Q, options RequestOptions) (RequestID, error)

func (Requester[Q, R]) SendTo

func (p Requester[Q, R]) SendTo(target string, value Q, options RequestOptions) (RequestID, error)

type Result

type Result[T any] struct {
	// Output leases in Value are borrowed until the callback returns. Retain or
	// install them in a slot to keep them. Reply transfers its lease to the queue
	// only on success; on error the provider still owns it.
	Value T
	Err   error
	ID    RequestID
}

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

Runtime is single-threaded. Plans and registration are immutable for its life.

func New

func New[P ContentProfile](world *ecs.World, plan *project.ProjectPlan, registry Registry, options Options) (*Runtime, error)

New creates a runtime with statically selected content capabilities.

func (*Runtime) Cancel

func (r *Runtime) Cancel(id RequestID) error

func (*Runtime) Close

func (r *Runtime) Close() error

func (*Runtime) Dispatch

func (r *Runtime) Dispatch() error

Dispatch freezes exactly one batch per logic tick. Replies/actions emitted by callbacks are in the other buffer and cannot recurse into this batch.

func (*Runtime) HandleHTMLEvent

func (r *Runtime) HandleHTMLEvent(event htmlui.Event) error

HandleHTMLEvent gives semantic form/control input to the owning scene. Surface and generated target identities never enter the behavior callback.

func (*Runtime) HandleInput

func (r *Runtime) HandleInput(event scene.InputEvent) error

func (*Runtime) Manager

func (r *Runtime) Manager() *SceneManager

func (*Runtime) Mount

func (r *Runtime) Mount(id project.SceneID) (*Scene, error)

Mount is a loading operation; event callbacks enqueue disposal, never mount new scenes while a frozen batch is being traversed.

func (*Runtime) MountEntry

func (r *Runtime) MountEntry() (*Scene, error)

func (*Runtime) NeedsTick

func (r *Runtime) NeedsTick() bool

func (*Runtime) Pending

func (r *Runtime) Pending() int

func (*Runtime) PublishCollisions

func (r *Runtime) PublishCollisions() error

PublishCollisions runs after physics. It queues the next module batch, so a collision callback cannot mutate the solver or recurse into this simulation.

func (*Runtime) Queued

func (r *Runtime) Queued() int

func (*Runtime) RenderScope

func (r *Runtime) RenderScope() *ecs.QueryScope

RenderScope contains visible scenes, including retained overlay backgrounds.

func (*Runtime) SyncScopes

func (r *Runtime) SyncScopes()

SyncScopes rebuilds cached execution lists only after scene transitions, hierarchy edits, ownership changes or entity lifetimes. Unowned engine entities are shared; unrelated component migrations preserve scope versions.

func (*Runtime) Update

func (r *Runtime) Update(delta float32) error

Update visits only instances with an Update hook, using fixed-tick time.

func (*Runtime) UpdateFrame

func (r *Runtime) UpdateFrame(delta float32) error

UpdateFrame runs UI/application hooks once per awake frame, independently of fixed-tick accumulation. Callers must dispatch pending events first.

type Scene

type Scene struct {
	// contains filtered or unexported fields
}

func (*Scene) AdvanceGPUFor

func (s *Scene) AdvanceGPUFor(device *render.Device, budget graphics.UploadBudget) (bool, error)

func (*Scene) Alive

func (s *Scene) Alive() bool

func (*Scene) Dispose

func (s *Scene) Dispose() error

func (*Scene) Emitter

func (s *Scene) Emitter[T any](name string) (Emitter[T], error)

Emitter sends messages to a scene from the application orchestrator. A module never receives this Scene object through Context.

func (*Scene) GPUReadyFor

func (s *Scene) GPUReadyFor(device *render.Device) bool

func (*Scene) Generation

func (s *Scene) Generation() uint64

func (*Scene) ID

func (s *Scene) ID() project.SceneID

func (*Scene) SlotWriter

func (s *Scene) SlotWriter(instance, name string) (SlotWriter, error)

func (*Scene) State

func (s *Scene) State() SceneState

type SceneActivationOptions

type SceneActivationOptions struct {
	Startup         project.SlotValue
	Retain, Overlay bool
}

type SceneManager

type SceneManager struct {
	// contains filtered or unexported fields
}

func (*SceneManager) Activate

func (m *SceneManager) Activate(target *Scene, options SceneActivationOptions) error

Activate queues the exact prepared instance. Disposal before the commit produces a failed switch instead of silently loading another instance.

func (*SceneManager) Active

func (m *SceneManager) Active() *Scene

func (*SceneManager) BeginPreload

func (m *SceneManager) BeginPreload(request ScenePreloadRequest) (*ScenePreloader, error)

func (*SceneManager) Preload

func (m *SceneManager) Preload(request ScenePreloadRequest) (*Scene, error)

Preload is the synchronous convenience form of BeginPreload and Advance. Interactive loaders use BeginPreload to budget main-thread work per frame.

func (*SceneManager) StartEntry

func (m *SceneManager) StartEntry() (*Scene, error)

func (*SceneManager) Switch

func (m *SceneManager) Switch(request SceneSwitchRequest) error

Switch commits at the next event/update structural boundary. A ready target activates without repeating installation or startup resource loading.

type ScenePreloadRequest

type ScenePreloadRequest struct {
	Scene   project.SceneID
	Startup project.SlotValue
}

type ScenePreloader

type ScenePreloader struct {
	// contains filtered or unexported fields
}

ScenePreloader prepares CPU content on a worker, then commits startup and budgets GPU uploads on the owning render thread. Lifecycle callbacks always run on the caller's thread and remain indivisible work units.

func (*ScenePreloader) Advance

func (p *ScenePreloader) Advance(budget time.Duration) (bool, error)

func (*ScenePreloader) AdvanceFor

func (p *ScenePreloader) AdvanceFor(device *render.Device, budget graphics.UploadBudget) (ready bool, err error)

func (*ScenePreloader) CPUReady

func (p *ScenePreloader) CPUReady() bool

func (*ScenePreloader) Discard

func (p *ScenePreloader) Discard()

func (*ScenePreloader) GPUReadyFor

func (p *ScenePreloader) GPUReadyFor(device *render.Device) bool

func (*ScenePreloader) Ready

func (p *ScenePreloader) Ready() bool

func (*ScenePreloader) ReadyFor

func (p *ScenePreloader) ReadyFor(device *render.Device) bool

func (*ScenePreloader) Scene

func (p *ScenePreloader) Scene() *Scene

type SceneStartup

type SceneStartup struct {
	From  project.SceneID
	Value project.SlotValue
}

type SceneState

type SceneState uint8
const (
	SceneLoading SceneState = iota
	SceneReady
	SceneActive
	SceneSuspended
	SceneDisposed
)

type SceneSwitchRequest

type SceneSwitchRequest struct {
	Scene   project.SceneID
	Startup project.SlotValue
	// Retain applies when the departing scene has no explicit ExitPolicy.
	Retain bool
	// Overlay keeps retained scenes visible beneath the new foreground scene.
	// The background scenes are paused and cannot receive input.
	Overlay bool
}

type SceneSwitchResult

type SceneSwitchResult struct {
	Err      error
	From, To project.SceneID
}

type Signal

type Signal struct{}

type Slot

type Slot struct {
	// contains filtered or unexported fields
}

func (Slot) Read

func (s Slot) Read[T any]() (T, error)

func (Slot) Revision

func (s Slot) Revision() SlotRevision

func (Slot) Root

func (s Slot) Root() Entity

func (Slot) Set

func (s Slot) Set(value project.SlotValue) error

Set is an internal write. External writes must enter the buffered event channel.

func (Slot) SetVisual

func (s Slot) SetVisual(handle RenderOutputHandle) error

SetVisual borrows a handle and retains a separate lease for this slot. A reply value is borrowed only until its callback returns. Empty clears it.

func (Slot) Value

func (s Slot) Value() (project.SlotValue, bool)

Value is a borrowed read-only view until the next write. Fields storage belongs to the instance; use Read[T] for a concrete scalar/contract value.

func (Slot) Visual

func (s Slot) Visual() (RenderOutputHandle, bool)

Visual is a borrowed view of the slot's lease, not ownership of that lease.

type SlotRevision

type SlotRevision struct {
	// contains filtered or unexported fields
}

func (SlotRevision) With

func (v SlotRevision) With(other SlotRevision) SlotRevision

With guards a request against changes to up to four slots of its source.

type SlotWriter

type SlotWriter struct {
	// contains filtered or unexported fields
}

SlotWriter is resolved by the application/scene orchestrator. Modules obtain no other instance handles; their external slot changes use messages.

func (SlotWriter) Write

func (w SlotWriter) Write(value project.SlotValue) error

type SpatialContent

type SpatialContent struct{}

type SpineContent

type SpineContent struct{}

type TextRenderRequest

type TextRenderRequest struct {
	Text          string
	Size          float64
	Color         [4]float32
	Width, Height float32
	Alignment     scene.TextAlignment
}

Engine protocols contain data only; consumers need no provider imports.

type TextRenderResult

type TextRenderResult struct {
	Output        RenderOutputHandle
	Width, Height float32
}

type Tick

type Tick struct {
	Number uint64
	Delta  float32
}

type TilemapsContent

type TilemapsContent struct{}

type TrailsContent

type TrailsContent struct{}

type WithContent

type WithContent[P ContentProfile, F ContentFeature] struct{}

WithContent adds one statically selected capability. The runtime and node traversal remain shared; writers append into the same destination bundle.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL