for (neighbor_in_set, neighbor_on_map) in neighbors {
match (neighbor_in_set, neighbor_on_map) {
(None, None) => { /* nop */ }
(None, Some(on_map)) => {
// in this case, we have to check the new neighbor is the same or not
if block.reg_name == blocks[&on_map].reg_name {
// if they are, we merge
self.merge_polymer(entity, on_map);
}
}
(Some(in_set), None) => {
// in this case, we have to check our old neighbor
if in_set.0 {
// if our old neighbor and entity are the same, it means we lost a neighbor
// we will request a deep refresh for this entity and it's connected blocks
deep_refresh_list.push(entity);
}
}
(Some(in_set), Some(on_map)) => {
// in this case, we have to consider our old neighbor is the same with us or not
if in_set.0 {
// if they were and it's not now
if blocks[&on_map].reg_name != block.reg_name {
// we lost a neighbor
deep_refresh_list.push(entity);
deep_refresh_list.push(on_map);
}
} else {
// if they were not but they are now
if blocks[&on_map].reg_name == block.reg_name {
// we have a new neighbor
deep_refresh_list.push(entity);
deep_refresh_list.push(on_map);
}
}
}
}
}
评论区
共 2 条评论热门最新