use crate::runtime::context::RuntimeFrameContext;
use crate::runtime::output::RuntimeOutput;
use crate::runtime::output::SelectionOp;
pub struct SelectionSystem;
impl Default for SelectionSystem {
fn default() -> Self {
Self
}
}
impl SelectionSystem {
pub fn new() -> Self {
Self
}
pub(crate) fn step(&self, frame: &RuntimeFrameContext, output: &mut RuntimeOutput) {
if !frame.clicked {
return;
}
match &frame.pick_hit {
Some(hit) => {
if frame.shift_held {
output.selection_ops.push(SelectionOp::Toggle(hit.id));
} else {
output.selection_ops.push(SelectionOp::SelectOne(hit.id));
}
}
None => {
if !frame.shift_held {
output.selection_ops.push(SelectionOp::Clear);
}
}
}
}
}