Skip to main content

EngineCore

Struct EngineCore 

Source
pub struct EngineCore<A: EngineApp> { /* private fields */ }
Expand description

The core engine state, independent of any windowing backend.

Created by the windowing driver (e.g. WinitAppRunner), then driven frame-by-frame via EngineCore::tick.

Implementations§

Source§

impl<A: EngineApp> EngineCore<A>

Source

pub fn new() -> Self

Creates a new, uninitialized engine core.

Source

pub fn bootstrap(&mut self, app: A, runtime: Runtime)

Bootstraps the engine: creates DCC, telemetry, scheduler, registers agents, calls app.setup(), and initializes agents.

This method takes ownership of the runtime populated by the windowing driver’s bootstrap closure. It wraps the runtime in an Arc once all built-in entries have been inserted.

Source

pub fn feed_input(&mut self, event: InputEvent)

Queues an input event to be processed on the next tick.

Source

pub fn tick(&mut self)

Executes one frame: app update, ECS maintenance, scheduler.

This method is called by the windowing driver (e.g. winit) each time a redraw is requested.

Source

pub fn tick_with_runtime(&mut self, frame_runtime_arc: Arc<Runtime>)

Executes one frame with a custom per-frame Runtime overlay.

Used by the winit runner to inject a FrameContext into the per-frame Resources for cross-agent synchronization.

This is a convenience wrapper that calls the staged methods in order without invoking any EngineApp lifecycle hooks. Drivers that need to interleave hooks (e.g., the editor’s overlay/shell) should call the staged methods directly via the winit runner.

Source

pub fn run_maintenance(&mut self)

Stage 6 — runs the end-of-tick Maintenance-phase DataSystems against the scheduler’s per-frame [OutputDeck].

The engine is subsystem-agnostic here: it threads the deck through the substrate dispatcher and lets each DataSystem drain whatever typed slot belongs to its domain (audio writeback, physics writeback, future subsystems …). No subsystem-specific code lives in this method.

Source

pub fn drain_inputs(&mut self) -> Vec<InputEvent>

Stage 1 — drain queued input events. Also marks simulation started (emits the "simulation" phase change on the first call), ticks the telemetry service, and feeds the events into the engine-wide [khora_core::platform::InputMap] so app code can query actions (is_pressed, just_pressed) from the same frame’s inputs.

Source

pub fn run_app_update(&mut self, inputs: &[InputEvent])

Stage 2 — run app.update, ECS maintenance, mesh sync, and scene/UI extractions. Called between drain_inputs and begin_render_frame.

Source

pub fn begin_render_frame(&mut self, frame_runtime_arc: &Arc<Runtime>) -> bool

Stage 3 — acquire the swapchain via RenderSystem::begin_frame and populate the per-frame [FrameContext] with ColorTarget, DepthTarget, and ClearColor.

Returns true when a renderer is present and begin_frame succeeded (driver should later call present_frame). Returns false only when no renderer is registered or the swapchain could not be acquired.

Source

pub fn run_scheduler(&mut self, frame_runtime_arc: &Arc<Runtime>)

Stage 4 — dispatch the scheduler so all registered agents execute their phases for this frame.

Source

pub fn submit_passes(&mut self, presents: bool)

Stage 5a — submit recorded passes from the [FrameGraph] to the GPU. When presents is false (render-to-viewport mode), the frame graph is discarded instead.

Source

pub fn present_frame(&mut self, presents: bool)

Stage 5b — call RenderSystem::end_frame to present the swapchain. No-op when presents is false.

Source

pub fn end_render_frame(&mut self, presents: bool)

Convenience: runs both submit_passes and present_frame in order. Used by the default tick path; drivers that need to interleave hooks should call the staged methods directly.

Source

pub fn app_mut(&mut self) -> Option<&mut A>

Mutable accessor for the application instance. Used by the winit runner to invoke EngineApp lifecycle hooks between staged frame methods.

Source

pub fn with_app_and_world<F>(&mut self, f: F)
where F: FnOnce(&mut A, &mut GameWorld),

Invokes a closure with mutable access to BOTH the application and the game world simultaneously. Used by the winit runner to call lifecycle hooks that need to read/write components (e.g., gizmo collection) without re-borrowing EngineCore twice.

The closure is skipped silently if either is uninitialized.

Source

pub fn set_runtime(&mut self, runtime: Arc<Runtime>)

Stores the runtime Arc. Used by the winit runner after bootstrap.

Source

pub fn runtime(&self) -> &Arc<Runtime>

Returns a reference to the engine-level runtime.

Source

pub fn game_world_mut(&mut self) -> Option<&mut GameWorld>

Returns a mutable reference to the game world, if initialized.

Source

pub fn dcc(&self) -> Option<&DccService>

Returns the DCC service, if initialized.

Source

pub fn set_engine_hint(&self, hint: EngineHint)

Applies a developer EngineHint biasing GORNA arbitration (Cap a per-frame budget, Prioritize an agent) without changing game semantics. No-op if the DCC isn’t running. Thread-safe; takes effect on the next arbitration tick.

Source

pub fn clear_agent_hints(&self, agent_id: AgentId)

Clears all developer hints for an agent, restoring engine defaults.

Source

pub fn engine_hints(&self) -> HashMap<AgentId, AgentHints>

Read-only snapshot of the accumulated per-agent hints (glass-box), or an empty map if the DCC isn’t running.

Source

pub fn shutdown(&mut self)

Shuts down the engine, calling app.on_shutdown().

Note: renderer shutdown is the responsibility of the application, since the renderer was created and registered by the app’s bootstrap closure.

Trait Implementations§

Source§

impl<A: EngineApp> Default for EngineCore<A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<A> !Freeze for EngineCore<A>

§

impl<A> !RefUnwindSafe for EngineCore<A>

§

impl<A> Send for EngineCore<A>

§

impl<A> !Sync for EngineCore<A>

§

impl<A> Unpin for EngineCore<A>
where A: Unpin,

§

impl<A> UnsafeUnpin for EngineCore<A>
where A: UnsafeUnpin,

§

impl<A> !UnwindSafe for EngineCore<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AppLifecycle for T
where T: ?Sized,

§

fn on_start(&mut self, ctx: &mut dyn AppContext)

Called once after the backend is up but before the first update. Apps install their theme / fonts here.
§

fn on_exit(&mut self)

Called once when the window is closing. Persist state here.
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to the inner value as &dyn Any.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(value: T, _simd: S) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,