Skip to content

Commit

Permalink
Updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankopf committed Aug 5, 2023
1 parent 7532947 commit 04944b1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/combat_system/melee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn do_melee_damage(
body2.attributes.health -= 50;
println!("Health: {}", body2.attributes.health);
if body2.attributes.health <= 0 {
//CRASHES: commands.entity(entity).despawn_recursive();
commands.entity(entity).despawn_recursive();
}
}
pub fn attacked_entities_system(
Expand Down
8 changes: 0 additions & 8 deletions src/statusdisplay_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,5 @@ pub fn status_display_system (
.id()
;
commands.entity(entity).push_children(&[child]);


// let e = parent.get();
//commands.entity(nametext).insert(Transform::from_xyz(300.0, 0.0, 100.0));
// println!("{:?}", text.sections);
// text.sections[0].value = "FIRE".to_string();
// text.set_changed();
//println!("{}", text.sections[0].value);
}
}
78 changes: 41 additions & 37 deletions src/unitgenerator_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,41 @@ impl Plugin for UnitGeneratorPlugin {
}
}

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());
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( PhysicalBody {
needs_food: Some(Need { current: food_need, max: 100.0, rate: 0.1, low: 10.0, normal: 25.0, high: 80.0 }),
needs_entertainment: Some(Need { current: entertainment_need, max: 100.0, rate: 0.1, low: 10.0, normal: 25.0, high: 80.0 }),
needs_sleep: Some(Need { current: sleep_need, max: 100.0, rate: 0.1, low: 10.0, normal: 25.0, high: 80.0 }),
index: 0,
crisis: None,
danger: None,
injured: false,
afflictions: Vec::new(),
skillset: Skillset::default(),
attributes: Attributeset::default(),
} )
.insert( Brain { ..default() } )
;
}
// 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());
// 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( PhysicalBody {
// needs_food: Some(Need { current: food_need, max: 100.0, rate: 0.1, low: 10.0, normal: 25.0, high: 80.0 }),
// needs_entertainment: Some(Need { current: entertainment_need, max: 100.0, rate: 0.1, low: 10.0, normal: 25.0, high: 80.0 }),
// needs_sleep: Some(Need { current: sleep_need, max: 100.0, rate: 0.1, low: 10.0, normal: 25.0, high: 80.0 }),
// index: 0,
// crisis: None,
// danger: None,
// injured: false,
// afflictions: Vec::new(),
// skillset: Skillset::default(),
// attributes: Attributeset::default(),
// } )
// .insert( Brain { ..default() } )
// ;
// }

pub fn spawn_unit_from_template(
commands: &mut Commands,
Expand Down Expand Up @@ -75,8 +75,8 @@ pub fn spawn_unit_from_template(
danger: None,
injured: false,
afflictions: template.afflictions.clone(),//Vec::new(),
skillset: Skillset::default(),
attributes: Attributeset::default(),
skillset: template.skillset.clone(),
attributes: template.attributes.clone(),
} )
.insert( Brain { ..default() } )
;
Expand All @@ -88,6 +88,8 @@ pub struct UnitTemplate {
pub entertainment_need: NeedExample,
pub sleep_need: NeedExample,
pub afflictions: Vec<Affliction>,
pub skillset: Skillset,
pub attributes: Attributeset,
}
#[derive(Copy, Clone)]
pub struct NeedExample {
Expand Down Expand Up @@ -134,6 +136,8 @@ impl UnitTemplate {
entertainment_need: NeedExample { current: 90.0, max: 100.0, rate: 0.1, low: 10.0, normal: 25.0, high: 80.0, variance: 5.0 },
sleep_need: NeedExample { current: 90.0, max: 100.0, rate: 0.1, low: 10.0, normal: 25.0, high: 80.0, variance: 5.0 },
afflictions: random_afflictions.to_vec(),
skillset: Self::random_skillset_humanoid(),
attributes: Self::random_attributeset_humanoid(),
}
}
pub fn random_afflictions_humanoid() -> Vec<Affliction> {
Expand Down

0 comments on commit 04944b1

Please sign in to comment.