eco2d/code/foundation/src/ents/items.h

59 lines
1.3 KiB
C
Raw Normal View History

2021-08-25 21:36:20 +00:00
#pragma once
#include "platform/system.h"
#include "gen/assets.h"
2021-08-30 15:50:05 +00:00
#include "world/blocks.h"
#include "ecs/components.h"
2021-08-30 15:50:05 +00:00
typedef enum {
2021-11-02 18:14:54 +00:00
// NOTE(zaklaus): hardcoded fields for placement ops
2022-08-11 10:41:36 +00:00
UKIND_DELETE,
2021-08-30 15:50:05 +00:00
UKIND_PLACE,
2021-11-01 17:35:33 +00:00
UKIND_PLACE_ITEM,
UKIND_END_PLACE,
2021-11-02 18:14:54 +00:00
// NOTE(zaklaus): the rest of possible actions
UKIND_HOLD,
UKIND_PROXY,
2021-08-30 15:50:05 +00:00
} item_usage;
typedef struct {
2021-11-02 10:48:32 +00:00
asset_id kind;
2021-08-30 15:50:05 +00:00
item_usage usage;
uint32_t max_quantity;
// NOTE(zaklaus): usage data
union {
struct {
2021-11-02 11:49:03 +00:00
asset_id kind;
2021-11-02 17:58:55 +00:00
bool directional; // NOTE(zaklaus): expects next 4 asset entries to be direction assets
2021-08-30 15:50:05 +00:00
} place;
2021-11-02 17:58:55 +00:00
struct {
asset_id id;
} proxy;
2022-08-09 14:46:23 +00:00
struct {
2022-08-13 06:43:15 +00:00
asset_id id;
2022-08-09 14:46:23 +00:00
} place_item;
2021-08-30 15:50:05 +00:00
};
} item_desc;
2021-11-03 18:09:19 +00:00
typedef uint16_t item_id;
2022-09-27 13:55:24 +00:00
void item_setup();
void item_cleanup();
void item_register(item_desc desc);
2021-08-30 15:50:05 +00:00
// NOTE(zaklaus): item drops
2021-11-02 10:48:32 +00:00
uint64_t item_spawn(asset_id kind, uint32_t qty);
2021-08-25 21:36:20 +00:00
void item_despawn(uint64_t id);
2021-08-30 15:50:05 +00:00
// NOTE(zaklaus): items
2021-11-03 18:09:19 +00:00
item_id item_find(asset_id kind);
2021-11-02 17:58:55 +00:00
void item_use(ecs_world_t *ecs, ItemDrop *it, Position p, uint64_t udata);
2021-08-30 15:50:05 +00:00
2021-11-03 18:09:19 +00:00
uint32_t item_max_quantity(item_id id);
item_usage item_get_usage(item_id id);
bool item_get_place_directional(item_id id);