Wrap TileMap HashMaps in Arc for async pathfinding access
- Add Arc<AHashMap> wrapper around floor_tiles, fixture_tiles, item_tiles - Copy-on-write semantics: Arc::make_mut clones only if other Arcs exist - Add insert_floor, insert_fixture, insert_item, remove_item methods - Add get_floor_mut, get_fixture_mut for visibility updates - Update all mutation sites to use new TileMap methods - Enables cheap Arc::clone for async pathfinding workers - Single-threaded pathfinding: no clone, direct access - Multi-threaded pathfinding: clone Arc, read without locks
This commit is contained in:
@@ -116,13 +116,13 @@ pub fn item_tile_management_system(
|
||||
|
||||
for position in positions {
|
||||
let items = match tilemap.item_tiles.get(&position) {
|
||||
Some(i) => i,
|
||||
Some(i) => i.clone(),
|
||||
None => continue,
|
||||
};
|
||||
|
||||
// Clean up empty tiles
|
||||
if items.is_empty() {
|
||||
tilemap.item_tiles.remove(&position);
|
||||
tilemap.remove_item(&position);
|
||||
rotation_timer.current_indices.remove(&position);
|
||||
continue;
|
||||
}
|
||||
@@ -146,8 +146,8 @@ pub fn item_tile_management_system(
|
||||
.copied()
|
||||
.unwrap_or(0);
|
||||
|
||||
for &entity_id in items {
|
||||
if let Some(entity) = Entity::from_raw_u32(entity_id) {
|
||||
for entity_id in &items {
|
||||
if let Some(entity) = Entity::from_raw_u32(*entity_id) {
|
||||
if let Ok(mut rotation_state) = item_query.get_mut(entity) {
|
||||
rotation_state.should_be_visible = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user