specs_transform 0.1.2

transform 2d and 3d component for specs
Documentation
use core::sync::atomic::{AtomicBool, Ordering};

use specs::{Entity, VecStorage, Component};


pub struct Child {
    parent: Entity,
    dirty: AtomicBool,
}

impl Component for Child {
    type Storage = VecStorage<Child>;
}

impl Child {

    #[inline(always)]
    pub fn new(entity: Entity) -> Child {
        Child {
            parent: entity,
            dirty: AtomicBool::new(true),
        }
    }

    #[inline(always)]
    pub fn parent(&self) -> Entity {
        self.parent
    }

    #[inline]
    pub fn set_parent(&mut self, entity: Entity) {
        self.parent = entity;
        self.flag(true);
    }

    #[inline(always)]
    pub fn flag(&self, dirty: bool) {
        self.dirty.store(dirty, Ordering::SeqCst);
    }

    #[inline(always)]
    pub fn is_dirty(&self) -> bool {
        self.dirty.load(Ordering::SeqCst)
    }
}