Skip to content

Commit

Permalink
Update unit generation. Add screenshot to readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankopf committed Aug 4, 2023
1 parent f74a575 commit 8aec1b9
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 29 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added assets/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,32 @@ impl InfoPanel for Status {
}


#[derive(Component, PartialEq)]
#[derive(Default)]
#[derive(Component, Default)]
pub struct Brain {
pub motivation: Option<Motivation>,
pub task: Option<Task>,
pub order: Option<String>,
pub personality: Vec<PersonalityTrait>,
}
impl Brain {
pub fn remotivate(&mut self) {
self.motivation = None;
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;
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use crate::task_system::{HALF_SECOND, TWO_SECOND};
task_system,
text_system,
thinking_system,
unitgenerator_system,
window_system
)]

Expand Down
56 changes: 29 additions & 27 deletions src/startup.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 };
Expand Down
47 changes: 47 additions & 0 deletions src/unitgenerator_system.rs
Original file line number Diff line number Diff line change
@@ -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<SpriteSheet>,
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() } )
;
}

0 comments on commit 8aec1b9

Please sign in to comment.