From a38958dd12d309263a6ec551207b141cd935ddd6 Mon Sep 17 00:00:00 2001 From: Trevor Settles Date: Wed, 13 Dec 2023 23:52:50 -0700 Subject: [PATCH] feat: added user commands --- src/lib.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index e3bc6d4..942376a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,6 +18,7 @@ fn spawn_units(mut creations: EventReader, mut commands: Commands) { #[derive(Bundle)] struct MyBundle { transform: Transform, + commands: UserCommandComponent, } #[derive(Component)] @@ -26,13 +27,24 @@ enum UnitComponents { Villager, } +#[derive(Component, Debug, Default, PartialEq, Eq)] +struct UserCommandComponent { + command: Option, +} + +#[derive(Debug, PartialEq, Eq)] +enum UserCommand {} + fn create_unit_bundles(spawn: &SpawnUnitData) -> MyBundle { let transform = Transform { translation: Vec3::new(spawn.pos.x, spawn.pos.y, 0.0), ..Default::default() }; - MyBundle { transform } + MyBundle { + transform, + commands: UserCommandComponent::default(), + } } #[derive(Debug, Event)] @@ -82,6 +94,16 @@ mod test { assert_eq!(Vec3::new(3.0, 4.0, 0.0), actual.transform.translation); } + + #[test] + fn user_commands_get_created() { + let actual = create_unit_bundles(&SpawnUnitData { + pos: Vec2::default(), + unit: Unit::Villager, + }); + + assert_eq!(UserCommandComponent::default(), actual.commands); + } } mod acceptance {