From dbf74e38d13791b52fbb623773aceef5b07dfc6b Mon Sep 17 00:00:00 2001 From: ryankopf Date: Sun, 20 Aug 2023 02:16:05 -0500 Subject: [PATCH] Updates --- src/components.rs | 8 ++++++-- src/interface/game_ui.rs | 33 ++++++++++++++------------------ src/prelude.rs | 2 +- src/selection_systems.rs | 40 +++++++++++++++++++++++++++++++++++++++ src/task_system/forage.rs | 1 + 5 files changed, 62 insertions(+), 22 deletions(-) diff --git a/src/components.rs b/src/components.rs index f00642a..2112c8d 100644 --- a/src/components.rs +++ b/src/components.rs @@ -39,7 +39,7 @@ pub enum GameState { #[derive(PartialEq)] pub enum MenuStates { // Sorted in order of display. - Home, Tasks, Farm, Zone, Build, Craft + Home, Tasks, Farm, Build, Zone } impl MenuStates { @@ -50,7 +50,6 @@ impl MenuStates { MenuStates::Farm => 2, MenuStates::Zone => 3, MenuStates::Build => 4, - MenuStates::Craft => 5, } } } @@ -587,6 +586,10 @@ pub struct Foragable; #[derive(Component)] pub struct Choppable; +#[derive(Component)] +pub struct Huntable; +#[derive(Component)] +pub struct Mineable; #[derive(Component)] pub struct SetNest; @@ -734,6 +737,7 @@ pub enum SelectableType { Foragable, Gatherable, Harvestable, + Huntable, Mineable, Nothing, Unselecting, diff --git a/src/interface/game_ui.rs b/src/interface/game_ui.rs index 8dd82e8..83c5923 100644 --- a/src/interface/game_ui.rs +++ b/src/interface/game_ui.rs @@ -84,15 +84,14 @@ pub fn start_game_ui( let buttons = [vec![ "TASKS", "FARM", - "ZONE", "BUILD", - "CRAFT", + "ZONE", ],vec![ // tasks "BACK", "CLEAR", "CHOP", "FORAGE", - "GATHER", + "COLLECT", "HUNT", "MINE", ],vec![ // farm @@ -172,9 +171,8 @@ pub fn game_ui_click( match button_index { 0 => { menu_state.state = MenuStates::Tasks }, 1 => { menu_state.state = MenuStates::Farm }, - 2 => { menu_state.state = MenuStates::Zone }, - 3 => { menu_state.state = MenuStates::Build }, - 4 => { menu_state.state = MenuStates::Craft }, + 2 => { menu_state.state = MenuStates::Build }, + 3 => { menu_state.state = MenuStates::Zone }, _ => { }, } } @@ -233,11 +231,15 @@ pub fn game_ui_click( _ => { }, } } - MenuStates::Zone => { + MenuStates::Build => { match button_index { - 5 => { + 1 => { + dragging.looking_for = SelectableType::Unzoning; + }, + 2 => { dragging.looking_for = SelectableType::Zoning; - dragging.zone_type = ZoneType::Avoid; + dragging.zone_type = ZoneType::Construction; + dragging.item_type = ItemType::WallWood; }, _ => { dragging.looking_for = SelectableType::Nothing; @@ -245,15 +247,11 @@ pub fn game_ui_click( }, } } - MenuStates::Build => { + MenuStates::Zone => { match button_index { - 1 => { - dragging.looking_for = SelectableType::Unzoning; - }, - 2 => { + 5 => { dragging.looking_for = SelectableType::Zoning; - dragging.zone_type = ZoneType::Construction; - dragging.item_type = ItemType::WallWood; + dragging.zone_type = ZoneType::Avoid; }, _ => { dragging.looking_for = SelectableType::Nothing; @@ -261,9 +259,6 @@ pub fn game_ui_click( }, } } - MenuStates::Craft => { - menu_state.state = MenuStates::Home; - } } start_game_ui(commands, font, menu_state, game_buttons); } diff --git a/src/prelude.rs b/src/prelude.rs index 6f8d041..144276e 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1,7 +1,7 @@ pub use super::components::{ ActorType, Affliction, AfflictionType, AfflictionLocation, Attackable, Attacked, Attributeset, Bed, Brain, Choppable, ClickedOn, Danger, DangerType, Dying, Food, Foragable, ForageType, GameState, GeneratedBy, - GiveMeAName, HasName, HasNameShown, HighlightBox, Highlighted, HoverNote, InfoPanel, InGameButton, IsName, + GiveMeAName, HasName, HasNameShown, HighlightBox, Highlighted, HoverNote, Huntable, InfoPanel, InGameButton, IsName, Logs, MainMenuOverlay, MapTile, MenuStates, MonsterGenerator, Motivation, MoveRandom, MoveTowardsNearestAttackable, MoveTowardsTarget, NearestEntity, Need, Nest, Order, Pathing, PauseOverlay, PersonalityTrait, PhysicalBody, Plant, Position, diff --git a/src/selection_systems.rs b/src/selection_systems.rs index e1ff608..723da6e 100644 --- a/src/selection_systems.rs +++ b/src/selection_systems.rs @@ -43,12 +43,23 @@ pub fn select_foragables( highlightboxes: Query>, event: EventReader, dragging: Res, + font: Res, ) { if event.is_empty() { return; } if dragging.looking_for != SelectableType::Foragable { return; } for (entity, foragable) in query.iter_mut() { if foragable.is_some() { commands.entity(entity).insert(WorkTarget); + let child = commands.spawn(( + Text2dBundle { + text: Text::from_section("X", TextStyle { font: font.0.clone(), ..default() }) + .with_alignment(TextAlignment::Center), + ..default() + }, + WorkMarker + )) + .insert(Transform::from_xyz(10.0, 20.0, 100.0)).id(); + commands.entity(entity).push_children(&[child]); } } unhighlight(commands, highlighteds, highlightboxes); @@ -83,6 +94,35 @@ pub fn select_choppables( unhighlight(commands, highlighteds, highlightboxes); } +pub fn select_huntables( + mut commands: Commands, + mut query: Query<(Entity, Option<&Huntable>), With>, + highlighteds: Query>, + highlightboxes: Query>, + event: EventReader, + dragging: Res, + font: Res, +) { + if event.is_empty() { return; } + if dragging.looking_for != SelectableType::Huntable { return; } + for (entity, selection_reason) in query.iter_mut() { + if selection_reason.is_some() { + commands.entity(entity).insert(WorkTarget); + let child = commands.spawn(( + Text2dBundle { + text: Text::from_section("X", TextStyle { font: font.0.clone(), ..default() }) + .with_alignment(TextAlignment::Center), + ..default() + }, + WorkMarker + )) + .insert(Transform::from_xyz(10.0, 20.0, 100.0)).id(); + commands.entity(entity).push_children(&[child]); + } + } + unhighlight(commands, highlighteds, highlightboxes); +} + pub fn select_zoning( mut commands: Commands, query: Query<(Entity, Option<&MapTile>), With>, diff --git a/src/task_system/forage.rs b/src/task_system/forage.rs index 94d55f9..61dc388 100644 --- a/src/task_system/forage.rs +++ b/src/task_system/forage.rs @@ -18,6 +18,7 @@ pub fn task_system_forage( if distance <= 1 && targeting.is_some() && targeting.unwrap().target == foragable_entity { commands.entity(entity).remove::(); spawn_food(&mut commands, foragable_entity, foragable_position, &sprite_sheet, &mut plant); + commands.entity(entity).remove::(); did_foraging = true; nearest_entity = None; break;