Skip to main content

pite_core/
lifecycle.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! Node lifecycle dispatch trait (`_ready`, `_process`).
3
4use crate::node::NodeId;
5
6/// Lifecycle dispatch interface through which engine systems invoke script lifecycle hooks.
7///
8/// Missing lifecycle callbacks are treated as no-ops rather than errors.
9pub trait LifecycleSink {
10    /// Invoked once when a node and its children have entered the active scene tree.
11    fn on_ready(&mut self, _node: &NodeId) {}
12
13    /// Invoked every frame during the main update tick with the elapsed frame delta time in seconds.
14    fn on_process(&mut self, _node: &NodeId, _delta: f32) {}
15}
16
17/// No-op lifecycle sink used in headless simulation, tests, or before a scripting host is attached.
18#[allow(dead_code)]
19#[derive(Debug, Default)]
20pub struct NoopSink;
21
22impl LifecycleSink for NoopSink {}