don't build over collidable/essential inner blocks

isolation_bkp/dynres
Dominik Madarász 2021-11-03 17:48:56 +01:00
parent 797c23e8c5
commit 3ce8df35dc
2 changed files with 6 additions and 1 deletions

View File

@ -65,7 +65,11 @@ void item_use(ecs_world_t *ecs, ItemDrop *it, Position p, uint64_t udata) {
} else { } else {
return; return;
} }
} }
// NOTE(zaklaus): This is an inner layer block, we can't build over it if it has a collision!
else if (l.block_id > 0 && blocks_get_flags(l.block_id) & (BLOCK_FLAG_COLLISION|BLOCK_FLAG_ESSENTIAL)) {
return;
}
world_chunk_replace_block(l.chunk_id, l.id, blocks_find(desc->place.kind + (asset_id)udata)); world_chunk_replace_block(l.chunk_id, l.id, blocks_find(desc->place.kind + (asset_id)udata));
it->quantity--; it->quantity--;
}break; }break;

View File

@ -5,6 +5,7 @@
typedef enum { typedef enum {
BLOCK_FLAG_COLLISION = (1 << 1), BLOCK_FLAG_COLLISION = (1 << 1),
BLOCK_FLAG_HAZARD = (1 << 2), BLOCK_FLAG_HAZARD = (1 << 2),
BLOCK_FLAG_ESSENTIAL = (1 << 3),
} block_flags; } block_flags;
int32_t blocks_setup(void); int32_t blocks_setup(void);