summaryrefslogtreecommitdiff
path: root/engine-ecs/src/phase.rs
blob: f78912087982adbe9316c38f75b9bbdb1635c3e7 (plain)
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
26
27
28
29
30
31
32
33
34
use crate::{declare_entity, Component, World};

#[derive(Debug, Default, Clone, Copy, Component)]
pub struct Phase;

declare_entity! {
/// Initialization phase that only occurs the first tick, before [`START`].
/// Should not be used for game logic
pub INIT: (Phase,);

/// Phase that only occurs the first tick, after [`INIT`].
pub START: (Phase,);

/// Phase that occurs every tick, before [`UPDATE`].
pub PRE_UPDATE: (Phase,);

/// Phase that occurs every tick, after [`PRE_UPDATE`].
pub UPDATE: (Phase,);

/// Phase that occurs every tick, after [`UPDATE`].
pub POST_UPDATE: (Phase,);
}

pub(crate) fn spawn_standard_phases(world: &mut World)
{
    world.spawn_declared_entity(&INIT);
    world.spawn_declared_entity(&START);
    world.spawn_declared_entity(&PRE_UPDATE);
    world.spawn_declared_entity(&UPDATE);
    world.spawn_declared_entity(&POST_UPDATE);
}

#[derive(Debug, Component)]
pub(crate) struct HasSystem;