mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added reset system for unused persisted blocks
This commit is contained in:
parent
ee12924124
commit
22f95edf32
@ -156,8 +156,19 @@ impl<'a> System<'a> for Sys {
|
||||
},
|
||||
};
|
||||
|
||||
for (key, block) in terrain_persistence.load_chunk(key).blocks() {
|
||||
chunk.set(key, block);
|
||||
// Terrain persistence
|
||||
let mut resets = Vec::new();
|
||||
for (rpos, new_block) in terrain_persistence.load_chunk(key).blocks() {
|
||||
chunk.map(rpos, |block| {
|
||||
if block == new_block {
|
||||
resets.push(rpos);
|
||||
}
|
||||
new_block
|
||||
});
|
||||
}
|
||||
// Reset any unchanged blocks
|
||||
for rpos in resets {
|
||||
terrain_persistence.reset_block(key, rpos);
|
||||
}
|
||||
|
||||
// Arcify the chunk
|
||||
|
@ -103,6 +103,10 @@ impl TerrainPersistence {
|
||||
let key = pos.xy().map2(TerrainChunk::RECT_SIZE, |e, sz| e.div_euclid(sz as i32));
|
||||
self.load_chunk(key).blocks.insert(pos - key * TerrainChunk::RECT_SIZE.map(|e| e as i32), block);
|
||||
}
|
||||
|
||||
pub fn reset_block(&mut self, key: Vec2<i32>, rpos: Vec3<i32>) {
|
||||
self.load_chunk(key).blocks.remove(&rpos);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
|
Loading…
Reference in New Issue
Block a user