diff --git a/README.md b/README.md index 61b9178..04e60ba 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ What are the various systems? * You can give Orders > Chop to chop down trees * Units automatically sleep when they're tired. +![Screenshot](./assets/screenshot.png) + ## Next Steps 1. Some kind of UI box should show up when you click one of your units, displaying their health/hunger/sleepiness/stats/etc diff --git a/assets/screenshot.png b/assets/screenshot.png new file mode 100644 index 0000000..74e8f2c Binary files /dev/null and b/assets/screenshot.png differ diff --git a/src/components.rs b/src/components.rs index 94939d9..fec9487 100644 --- a/src/components.rs +++ b/src/components.rs @@ -222,12 +222,12 @@ impl InfoPanel for Status { } -#[derive(Component, PartialEq)] -#[derive(Default)] +#[derive(Component, Default)] pub struct Brain { pub motivation: Option, pub task: Option, pub order: Option, + pub personality: Vec, } impl Brain { pub fn remotivate(&mut self) { @@ -235,8 +235,19 @@ impl Brain { self.task = None; self.order = None; } + pub fn add_personality_trait(&mut self, trait_: PersonalityTrait) { + self.personality.push(trait_); + } } +#[derive(Component)] +pub enum PersonalityTrait { + Adventurous, Ambitious, Analytical, Airheaded, Artistic, Brave, Calm, Charismatic, Confident, Cowardly, + Creative, Curious, Charitable, Cynical, Dumb, Eccentric, Energetic, Empath, Empathetic, Enthusiastic, + Fearless, Friendly, Greedy, Impulsive, Jinxed, Loyal, Logical, Lucky, Mean, Mischievous, + Nice, Optimistic, Patient, Pessimistic, Rebellious, Reliable, Sensitive, Shy, Smart, Stupid, + Technophile, Timid, Tolerant, Trusting, Violent, Weak, Workaholic, Witty, Outgoing, +} #[derive(Component)] pub struct Foragable; diff --git a/src/main.rs b/src/main.rs index 1a1c916..4cbb206 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,7 @@ use crate::task_system::{HALF_SECOND, TWO_SECOND}; task_system, text_system, thinking_system, + unitgenerator_system, window_system )] diff --git a/src/startup.rs b/src/startup.rs index b7297a1..65172da 100644 --- a/src/startup.rs +++ b/src/startup.rs @@ -1,6 +1,7 @@ use bevy::prelude::*; use super::components::{Position, SizeXYZ}; use super::prelude::*; +use crate::spawn_unit; // Make Startup Plugin pub struct StartupPlugin; @@ -29,34 +30,35 @@ pub fn startup( 2 => ActorType::Dwarf, _ => ActorType::Man }; - let sprite = TextureAtlasSprite::new(actor_type.sprite_index()); + // let sprite = TextureAtlasSprite::new(actor_type.sprite_index()); + spawn_unit(&mut commands, position, &sprite_sheet, actor_type, 21.0, 21.0, 21.0); - commands.spawn(SpriteSheetBundle { - sprite, - texture_atlas: sprite_sheet.0.clone(), - transform: Transform::from_xyz( - position.x as f32 * TILE_SIZE, - position.y as f32 * TILE_SIZE, - position.z as f32 * TILE_SIZE, - ), - ..Default::default() - }) - .insert(position) - .insert(position.to_transform_layer(1.0)) - .insert(Attackable) - // .insert(NeedsFood { current: 100.0, max: 100.0, rate: 0.1 }) - .insert( GiveMeAName ) - .insert( Status { - needs_food: Some(NeedsFood { current: 25.1, max: 100.0, rate: 0.1 }), - needs_entertainment: Some(NeedsEntertainment { current: 100.0, max: 100.0, rate: 0.1 }), - needs_sleep: Some(NeedsSleep { current: 15.2, max: 100.0, rate: 0.1 }), - index: 0, - crisis: None, - danger: None, - injured: false - } ) - .insert( Brain { ..Default::default() } ) - ; + // commands.spawn(SpriteSheetBundle { + // sprite, + // texture_atlas: sprite_sheet.0.clone(), + // transform: Transform::from_xyz( + // position.x as f32 * TILE_SIZE, + // position.y as f32 * TILE_SIZE, + // position.z as f32 * TILE_SIZE, + // ), + // ..default() + // }) + // .insert(position) + // .insert(position.to_transform_layer(1.0)) + // .insert(Attackable) + // // .insert(NeedsFood { current: 100.0, max: 100.0, rate: 0.1 }) + // .insert( GiveMeAName ) + // .insert( Status { + // needs_food: Some(NeedsFood { current: 25.1, max: 100.0, rate: 0.1 }), + // needs_entertainment: Some(NeedsEntertainment { current: 100.0, max: 100.0, rate: 0.1 }), + // needs_sleep: Some(NeedsSleep { current: 15.2, max: 100.0, rate: 0.1 }), + // index: 0, + // crisis: None, + // danger: None, + // injured: false + // } ) + // .insert( Brain { ..Default::default() } ) + // ; } let position = Position { x: 10, y: 10, z: 0 }; diff --git a/src/unitgenerator_system.rs b/src/unitgenerator_system.rs new file mode 100644 index 0000000..1deb9a2 --- /dev/null +++ b/src/unitgenerator_system.rs @@ -0,0 +1,47 @@ +use crate::prelude::*; + +// Make plugin +pub struct UnitGeneratorPlugin; + +impl Plugin for UnitGeneratorPlugin { + fn build(&self, app: &mut App) { + // app.add_system_set( + // SystemSet::new() + // .with_run_criteria(FixedTimestep::step(1.0)) + // .with_system(unit_generator), + // ); + } +} + +pub fn spawn_unit( + commands: &mut Commands, + position: Position, + sprite_sheet: &Res, + actor_type: ActorType, + food_need: f32, + entertainment_need: f32, + sleep_need: f32, +) { + let sprite = TextureAtlasSprite::new(actor_type.sprite_index()); // TO DO + commands + .spawn(SpriteSheetBundle { + sprite, + texture_atlas: sprite_sheet.0.clone(), + ..default() + }) + .insert(position) + .insert(position.to_transform_layer(1.0)) + .insert(Attackable) + .insert( GiveMeAName ) + .insert( Status { + needs_food: Some(NeedsFood { current: food_need, max: 100.0, rate: 0.1 }), + needs_entertainment: Some(NeedsEntertainment { current: entertainment_need, max: 100.0, rate: 0.1 }), + needs_sleep: Some(NeedsSleep { current: sleep_need, max: 100.0, rate: 0.1 }), + index: 0, + crisis: None, + danger: None, + injured: false + } ) + .insert( Brain { ..Default::default() } ) + ; +} \ No newline at end of file