From 3ce8df35dc517ace6ea70f53c89cf8d2a37f44c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Wed, 3 Nov 2021 17:48:56 +0100 Subject: [PATCH] don't build over collidable/essential inner blocks --- code/game/src/items.c | 6 +++++- code/game/src/world/blocks.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/code/game/src/items.c b/code/game/src/items.c index c96ebd6..02be5c4 100644 --- a/code/game/src/items.c +++ b/code/game/src/items.c @@ -65,7 +65,11 @@ void item_use(ecs_world_t *ecs, ItemDrop *it, Position p, uint64_t udata) { } else { 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)); it->quantity--; }break; diff --git a/code/game/src/world/blocks.h b/code/game/src/world/blocks.h index 3bb836f..2e1c077 100644 --- a/code/game/src/world/blocks.h +++ b/code/game/src/world/blocks.h @@ -5,6 +5,7 @@ typedef enum { BLOCK_FLAG_COLLISION = (1 << 1), BLOCK_FLAG_HAZARD = (1 << 2), + BLOCK_FLAG_ESSENTIAL = (1 << 3), } block_flags; int32_t blocks_setup(void);