This commit is contained in:
2026-03-22 00:03:57 +00:00
parent ff149117ca
commit 458068fb87
3 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -3,4 +3,4 @@ pub mod systems;
pub use crate::world::tiles::tilemap::CargoPlaceError; pub use crate::world::tiles::tilemap::CargoPlaceError;
pub use components::{Cargo, CarryVisualState, HaulSlot, Haulable}; pub use components::{Cargo, CarryVisualState, HaulSlot, Haulable};
pub use systems::{carry_visual_system, haul_encumbrance_system}; pub use systems::{any_hauling, carry_visual_system, haul_encumbrance_system};
+7
View File
@@ -7,10 +7,17 @@ use crate::entities::item::inventory::constants::ENCUMBERED_SPEED_MULTIPLIER;
use crate::entities::item::inventory::InventoryChangedEvent; use crate::entities::item::inventory::InventoryChangedEvent;
use crate::entities::shared_components::Ambulatory; use crate::entities::shared_components::Ambulatory;
/// Returns true if any entity has an occupied HaulSlot.
/// Used to gate carry_visual_system — skips entire system when no one is hauling.
pub fn any_hauling(query: Query<&HaulSlot>) -> bool {
query.iter().any(|slot| slot.is_occupied())
}
/// Cycle the carry visual sprite while the entity's HaulSlot is occupied. /// Cycle the carry visual sprite while the entity's HaulSlot is occupied.
/// When empty, ensure the normal sprite is restored. /// When empty, ensure the normal sprite is restored.
/// ///
/// Runs in Update (visual only, no game state change). /// Runs in Update (visual only, no game state change).
/// Only runs when at least one entity has an occupied HaulSlot.
pub fn carry_visual_system( pub fn carry_visual_system(
time: Res<Time>, time: Res<Time>,
mut query: Query<(&HaulSlot, &mut CarryVisualState, &mut Sprite)>, mut query: Query<(&HaulSlot, &mut CarryVisualState, &mut Sprite)>,
+2 -1
View File
@@ -3,6 +3,7 @@ use bevy_rand::prelude::*;
use crate::entities::{ use crate::entities::{
cargo::carry_visual_system, cargo::carry_visual_system,
cargo::any_hauling,
item::{initialize_item_rotation_state, item_tile_management_system, ItemRotationTimer}, item::{initialize_item_rotation_state, item_tile_management_system, ItemRotationTimer},
shared_systems::digging::dig_system, shared_systems::digging::dig_system,
}; };
@@ -71,6 +72,6 @@ fn main() {
item_tile_management_system.after(initialize_item_rotation_state), item_tile_management_system.after(initialize_item_rotation_state),
) )
.add_systems(Update, debug::entity_dump::dump_entity_positions) .add_systems(Update, debug::entity_dump::dump_entity_positions)
.add_systems(Update, carry_visual_system) .add_systems(Update, carry_visual_system.run_if(any_hauling))
.run(); .run();
} }