1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use std::time::Duration;

use super::events::Events;
use crate::render::{
  command::RenderCommand,
  RenderContext,
};

/// The Component Interface for allowing Component based data structures
/// like the ComponentStack to store components with various purposes
/// and implementations to work together.
pub trait Component {
  fn on_attach(&mut self, render_context: &mut RenderContext);
  fn on_detach(&mut self, render_context: &mut RenderContext);
  fn on_event(&mut self, event: Events);

  /// The update function is called every frame and is used to update
  /// the state of the component.
  fn on_update(&mut self, last_frame: &Duration);

  fn on_render(
    &mut self,
    render_context: &mut RenderContext,
  ) -> Vec<RenderCommand>;
}