use crate::interaction::selection::NodeId;
use super::context::RuntimeStepContext;
pub mod phase {
pub const PREPARE: i32 = 100;
pub const PICK: i32 = 200;
pub const SELECT: i32 = 300;
pub const MANIPULATE: i32 = 400;
pub const ANIMATE: i32 = 500;
pub const SIMULATE: i32 = 600;
pub const POST_SIM: i32 = 700;
pub const WRITEBACK: i32 = 800;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum RuntimePhase {
Prepare,
Pick,
Select,
Manipulate,
Animate,
Simulate,
PostSimulate,
Writeback,
}
impl RuntimePhase {
pub fn to_priority(&self) -> i32 {
match self {
RuntimePhase::Prepare => phase::PREPARE,
RuntimePhase::Pick => phase::PICK,
RuntimePhase::Select => phase::SELECT,
RuntimePhase::Manipulate => phase::MANIPULATE,
RuntimePhase::Animate => phase::ANIMATE,
RuntimePhase::Simulate => phase::SIMULATE,
RuntimePhase::PostSimulate => phase::POST_SIM,
RuntimePhase::Writeback => phase::WRITEBACK,
}
}
}
#[derive(Debug, Clone)]
pub enum RuntimeEvent {
NodeAdded(NodeId),
NodeRemoved(NodeId),
}
pub trait RuntimePlugin: Send + 'static {
fn priority(&self) -> i32;
fn submit(&mut self, _ctx: &RuntimeStepContext<'_>) {}
fn collect(&mut self, _ctx: &mut RuntimeStepContext<'_>) {}
fn on_event(&mut self, _event: &RuntimeEvent, _ctx: &mut RuntimeStepContext<'_>) {}
fn step(&mut self, ctx: &mut RuntimeStepContext<'_>);
}