inv: render held items on top
parent
a2810b2a18
commit
ca2ded9554
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
|
@ -31,6 +31,9 @@ pkt_desc pkt_entity_view_desc[] = {
|
||||||
{ PKT_UINT(entity_view, asset) },
|
{ PKT_UINT(entity_view, asset) },
|
||||||
{ PKT_UINT(entity_view, quantity) },
|
{ PKT_UINT(entity_view, quantity) },
|
||||||
|
|
||||||
|
{ PKT_KEEP_IF(entity_view, kind, EKIND_DEVICE, 1) },
|
||||||
|
{ PKT_UINT(entity_view, asset) },
|
||||||
|
|
||||||
{ PKT_KEEP_IF(entity_view, has_items, true, 3) },
|
{ PKT_KEEP_IF(entity_view, has_items, true, 3) },
|
||||||
{ PKT_UINT(entity_view, has_items) },
|
{ PKT_UINT(entity_view, has_items) },
|
||||||
{ PKT_UINT(entity_view, selected_item) },
|
{ PKT_UINT(entity_view, selected_item) },
|
||||||
|
|
|
@ -68,6 +68,9 @@ Texture2D texgen_build_sprite(asset_id id) {
|
||||||
case ASSET_BELT_UP: return LoadTexEco("belt_up");
|
case ASSET_BELT_UP: return LoadTexEco("belt_up");
|
||||||
case ASSET_BELT_DOWN: return LoadTexEco("belt_down");
|
case ASSET_BELT_DOWN: return LoadTexEco("belt_down");
|
||||||
|
|
||||||
|
// NOTE(zaklaus): devices
|
||||||
|
case ASSET_CHEST: return LoadTexEco("chest");
|
||||||
|
|
||||||
default: return GenColorEco(PINK); break;
|
default: return GenColorEco(PINK); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,15 @@ void inventory_draw_panel(entity_view *e, bool is_player, float sx, float sy){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(zaklaus): switch it off if is_player
|
||||||
|
if (is_player)
|
||||||
|
inv_is_storage_action = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void inventory_render_held_item(bool is_player){
|
||||||
|
inv_keystate *inv = (!is_player) ? &storage_inv : &player_inv;
|
||||||
|
inv_keystate *inv2 = (is_player) ? &storage_inv : &player_inv;
|
||||||
|
|
||||||
if (inv->item_is_held) {
|
if (inv->item_is_held) {
|
||||||
Vector2 mpos = GetMousePosition();
|
Vector2 mpos = GetMousePosition();
|
||||||
mpos.x -= 32;
|
mpos.x -= 32;
|
||||||
|
@ -108,10 +117,6 @@ void inventory_draw_panel(entity_view *e, bool is_player, float sx, float sy){
|
||||||
inv_is_storage_action = true;
|
inv_is_storage_action = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(zaklaus): switch it off if is_player
|
|
||||||
if (is_player)
|
|
||||||
inv_is_storage_action = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void inventory_reset_states(inv_keystate *ik) {
|
void inventory_reset_states(inv_keystate *ik) {
|
||||||
|
@ -140,4 +145,7 @@ void inventory_draw() {
|
||||||
|
|
||||||
inventory_draw_panel(e, true, screenWidth/2.0f + 128, screenHeight/2.0f - 96);
|
inventory_draw_panel(e, true, screenWidth/2.0f + 128, screenHeight/2.0f - 96);
|
||||||
inventory_draw_panel(e, false, screenWidth/2.0f - 384, screenHeight/2.0f - 128);
|
inventory_draw_panel(e, false, screenWidth/2.0f - 384, screenHeight/2.0f - 128);
|
||||||
|
|
||||||
|
inventory_render_held_item(true);
|
||||||
|
inventory_render_held_item(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
uint64_t storage_spawn(void) {
|
uint64_t storage_spawn(void) {
|
||||||
ecs_entity_t e = entity_spawn(EKIND_DEVICE);
|
ecs_entity_t e = entity_spawn(EKIND_DEVICE);
|
||||||
|
|
||||||
|
Device *dev = ecs_get_mut(world_ecs(), e, Device);
|
||||||
|
dev->asset = ASSET_CHEST;
|
||||||
|
|
||||||
ItemContainer *storage = ecs_get_mut(world_ecs(), e, ItemContainer);
|
ItemContainer *storage = ecs_get_mut(world_ecs(), e, ItemContainer);
|
||||||
*storage = (ItemContainer){0};
|
*storage = (ItemContainer){0};
|
||||||
return (uint64_t)e;
|
return (uint64_t)e;
|
||||||
|
|
|
@ -60,6 +60,11 @@ entity_view world_build_entity_view(int64_t e) {
|
||||||
view.quantity = dr->quantity;
|
view.quantity = dr->quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ecs_get(world_ecs(), e, Device)) {
|
||||||
|
Device const* dev = ecs_get(world_ecs(), e, Device);
|
||||||
|
view.asset = dev->asset;
|
||||||
|
}
|
||||||
|
|
||||||
view.inside_vehicle = ecs_get(world_ecs(), e, IsInVehicle) != 0 ? true : false;
|
view.inside_vehicle = ecs_get(world_ecs(), e, IsInVehicle) != 0 ? true : false;
|
||||||
|
|
||||||
Inventory *inv = 0;
|
Inventory *inv = 0;
|
||||||
|
|
|
@ -14,6 +14,7 @@ ECS_COMPONENT_DECLARE(IsInVehicle);
|
||||||
ECS_COMPONENT_DECLARE(ItemDrop);
|
ECS_COMPONENT_DECLARE(ItemDrop);
|
||||||
ECS_COMPONENT_DECLARE(Inventory);
|
ECS_COMPONENT_DECLARE(Inventory);
|
||||||
ECS_COMPONENT_DECLARE(ItemContainer);
|
ECS_COMPONENT_DECLARE(ItemContainer);
|
||||||
|
ECS_COMPONENT_DECLARE(Device);
|
||||||
ECS_COMPONENT_DECLARE(DemoNPC);
|
ECS_COMPONENT_DECLARE(DemoNPC);
|
||||||
ECS_COMPONENT_DECLARE(StreamInfo);
|
ECS_COMPONENT_DECLARE(StreamInfo);
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ void ComponentsImport(ecs_world_t *ecs) {
|
||||||
ECS_COMPONENT_DEFINE(ecs, ItemDrop);
|
ECS_COMPONENT_DEFINE(ecs, ItemDrop);
|
||||||
ECS_COMPONENT_DEFINE(ecs, Inventory);
|
ECS_COMPONENT_DEFINE(ecs, Inventory);
|
||||||
ECS_COMPONENT_DEFINE(ecs, ItemContainer);
|
ECS_COMPONENT_DEFINE(ecs, ItemContainer);
|
||||||
|
ECS_COMPONENT_DEFINE(ecs, Device);
|
||||||
ECS_COMPONENT_DEFINE(ecs, DemoNPC);
|
ECS_COMPONENT_DEFINE(ecs, DemoNPC);
|
||||||
ECS_COMPONENT_DEFINE(ecs, StreamInfo);
|
ECS_COMPONENT_DEFINE(ecs, StreamInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,10 @@ typedef struct {
|
||||||
ItemDrop items[ITEMS_CONTAINER_SIZE];
|
ItemDrop items[ITEMS_CONTAINER_SIZE];
|
||||||
} ItemContainer;
|
} ItemContainer;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t asset;
|
||||||
|
} Device;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double last_update;
|
double last_update;
|
||||||
double tick_delay;
|
double tick_delay;
|
||||||
|
@ -131,6 +135,7 @@ extern ECS_COMPONENT_DECLARE(IsInVehicle);
|
||||||
extern ECS_COMPONENT_DECLARE(ItemDrop);
|
extern ECS_COMPONENT_DECLARE(ItemDrop);
|
||||||
extern ECS_COMPONENT_DECLARE(Inventory);
|
extern ECS_COMPONENT_DECLARE(Inventory);
|
||||||
extern ECS_COMPONENT_DECLARE(ItemContainer);
|
extern ECS_COMPONENT_DECLARE(ItemContainer);
|
||||||
|
extern ECS_COMPONENT_DECLARE(Device);
|
||||||
extern ECS_COMPONENT_DECLARE(DemoNPC);
|
extern ECS_COMPONENT_DECLARE(DemoNPC);
|
||||||
extern ECS_COMPONENT_DECLARE(StreamInfo);
|
extern ECS_COMPONENT_DECLARE(StreamInfo);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue