From b8e3decc96a68e0a0f5ff80bcd2a6e419639e3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Wed, 28 Sep 2022 05:53:52 +0000 Subject: [PATCH] add some impl comments --- code/foundation/src/ecs/components.h | 12 +++++------- code/foundation/src/ents/items.h | 5 +++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/code/foundation/src/ecs/components.h b/code/foundation/src/ecs/components.h index 1e26f85..346bd13 100644 --- a/code/foundation/src/ecs/components.h +++ b/code/foundation/src/ecs/components.h @@ -103,20 +103,18 @@ typedef struct { } Item; typedef struct { - uint64_t ent; -} ItemSlot; - -typedef struct { - ItemSlot items[ITEMS_CONTAINER_SIZE]; + // TODO: we now hold a ref to an item, instead of representing an item slot, + // so that we can let the item entity keep its own components and also handle merging ops on its own. + ecs_entity_t items[ITEMS_CONTAINER_SIZE]; float pickup_time; } Inventory; typedef struct { - ItemSlot items[ITEMS_CONTAINER_SIZE]; + ecs_entity_t items[ITEMS_CONTAINER_SIZE]; } ItemContainer; typedef struct { - ItemSlot processed_item; + ecs_entity_t processed_item; float cook_time; float burn_time; } Furnace; diff --git a/code/foundation/src/ents/items.h b/code/foundation/src/ents/items.h index 14dbbe3..0b2aece 100644 --- a/code/foundation/src/ents/items.h +++ b/code/foundation/src/ents/items.h @@ -48,6 +48,11 @@ void item_show(uint64_t ent, bool show); uint64_t item_spawn(asset_id kind, uint32_t qty); void item_despawn(uint64_t id); +// NOTE: item ops +void item_pickup(uint64_t ent, uint64_t item); +void item_drop(uint64_t ent, uint64_t item); +void item_merge(uint64_t item1, uint64_t item2); + // NOTE(zaklaus): items item_id item_find(asset_id kind); void item_use(ecs_world_t *ecs, ItemSlot *it, Position p, uint64_t udata);