Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Create a Struct

The first thing to define when creating a component is to create the structs that define the component.

All components should contain an Entity which is used to configure the logging and also to give a unique location within the model hierarchy. The Entity will be wrapped in std::rc::Rc so that it can be shared.

use std::marker::PhantomData;
use std::rc::Rc;
use gwr_engine::traits::SimObject;
use gwr_model_builder::{EntityGet, EntityDisplay};
use gwr_track::entity::Entity;
#[allow(dead_code)]

#[derive(EntityGet, EntityDisplay)]
struct MyComponent<T>
where
    T: SimObject
{
    entity: Rc<Entity>,

    // Any component-specific state
  phantom: PhantomData<T>
}
fn main() {}