Skip to main content

pite_core/nodes/
timer.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! Timer: fires its engine-owned `timeout` signal every `wait_time` seconds
3//! (looping; non-positive never fires). `current_elapsed` is the rolling
4//! clock advanced by `PyTimer::_process`; exposed as a normal prop so
5//! scripts can inspect or reset it.
6
7use crate::schema::{DefaultPropVal, NodeTypeSchema, PropHint, PropSchema};
8
9pub static SCHEMA: NodeTypeSchema = NodeTypeSchema {
10    type_name: "Timer",
11    description: "Fires the engine-owned `timeout` signal every `wait_time` seconds.",
12    inherits: Some("Node"),
13    abstract_class: false,
14    props: PROPS,
15};
16
17pub static PROPS: &[PropSchema] = &[
18    PropSchema {
19        key: "wait_time",
20        label: "Wait Time",
21        doc: "Seconds between `timeout` emissions. Non-positive disables the timer.",
22        default_value: DefaultPropVal::Num(1.0),
23        hint: PropHint::Num {
24            speed: 0.1,
25            min: 0.01,
26            max: 3600.0,
27        },
28        read_only: false,
29    },
30    PropSchema {
31        key: "current_elapsed",
32        label: "Current Elapsed",
33        doc: "Seconds accumulated toward the next fire. Reset to 0 on fire; scripts can reset it manually.",
34        default_value: DefaultPropVal::Num(0.0),
35        hint: PropHint::Num {
36            speed: 0.01,
37            min: 0.0,
38            max: 3600.0,
39        },
40        read_only: false,
41    },
42];