feat: Implemented Inventory.find_free_space

- Added tests for find_free_space
This commit is contained in:
Alexey 2026-03-07 22:00:00 +03:00
commit 5f59e02788
3 changed files with 120 additions and 1 deletions

View file

@ -1,3 +1,5 @@
use std::mem::swap;
use bevy::prelude::*;
#[derive(Component, Clone)]
@ -32,4 +34,16 @@ impl Item {
!rect.intersect(other_rect).is_empty()
}
/// Swap size.x with size.y
pub fn swap_size(&mut self) {
swap(&mut self.size.x, &mut self.size.y);
}
/// Get clone of item with swapped size
pub fn clone_swapped(&self) -> Self {
let mut new = self.clone();
new.swap_size();
new
}
}