Task fix attempt
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
//! Cargo systems: carry visual cycling and haul encumbrance.
|
||||
//! Cargo systems: carry visual cycling, position sync, and haul encumbrance.
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::entities::cargo::components::{CarryVisualState, HaulSlot};
|
||||
use crate::entities::cargo::components::{Cargo, CarryVisualState, HaulSlot};
|
||||
use crate::entities::item::constants::ITEM_Z_FIGHTING_OFFSET;
|
||||
use crate::entities::item::inventory::constants::ENCUMBERED_SPEED_MULTIPLIER;
|
||||
use crate::entities::item::inventory::InventoryChangedEvent;
|
||||
use crate::entities::shared_components::Ambulatory;
|
||||
@@ -60,3 +61,16 @@ pub fn haul_encumbrance_system(
|
||||
events.write(InventoryChangedEvent { carrier: entity });
|
||||
}
|
||||
}
|
||||
|
||||
/// Sync cargo visual position when tile_pos changes.
|
||||
/// When cargo is picked up or dropped, tile_pos updates but Transform doesn't.
|
||||
/// This system keeps Transform in sync with the logical position.
|
||||
pub fn cargo_position_sync_system(mut query: Query<(&Cargo, &mut Transform), Changed<Cargo>>) {
|
||||
for (cargo, mut transform) in query.iter_mut() {
|
||||
transform.translation = Vec3::new(
|
||||
cargo.tile_pos.x as f32,
|
||||
cargo.tile_pos.y as f32,
|
||||
cargo.tile_pos.z as f32 - ITEM_Z_FIGHTING_OFFSET,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user