improve item dragging

isolation_bkp/dynres
Dominik Madarász 2022-08-09 18:11:02 +02:00
parent 079819e8d1
commit 2c3110b63e
3 changed files with 6 additions and 7 deletions

View File

@ -58,24 +58,24 @@ void inventory_draw_panel(entity_view *e, bool is_player, float sx, float sy){
inv->swap = true; inv->swap = true;
inv->swap_from = inv2->held_item_idx; inv->swap_from = inv2->held_item_idx;
inv->swap_to = i; inv->swap_to = i;
} else if (area == DAREA_PRESS && !inv->item_is_held) { } else if (area == DAREA_PRESS && !inv->item_is_held && !inv2->item_is_held) {
color = VIOLET; color = VIOLET;
inv->selected_item = i;
inv_is_storage_action = true; inv_is_storage_action = true;
inv->selected_item = i;
} else if (area == DAREA_PRESS && inv->item_is_held) { } else if (area == DAREA_PRESS && inv->item_is_held) {
color = VIOLET; color = VIOLET;
inv_is_storage_action = true;
inv->selected_item = i; inv->selected_item = i;
inv->item_is_held = false; inv->item_is_held = false;
inv->swap = true; inv->swap = true;
inv->swap_from = inv->held_item_idx; inv->swap_from = inv->held_item_idx;
inv->swap_to = i; inv->swap_to = i;
} else if (area == DAREA_HELD && item->quantity > 0 && !inv->item_is_held && !inv2->item_is_held) {
inv_is_storage_action = true; inv_is_storage_action = true;
} else if (area == DAREA_HELD && item->quantity > 0 && !inv->item_is_held) {
inv->selected_item = i; inv->selected_item = i;
inv->item_is_held = true; inv->item_is_held = true;
inv->held_item = *item; inv->held_item = *item;
inv->held_item_idx = i; inv->held_item_idx = i;
inv_is_storage_action = true;
} else if (i == inv->selected_item) { } else if (i == inv->selected_item) {
color = RED; color = RED;
} }

View File

@ -221,7 +221,7 @@ void SystemsImport(ecs_world_t *ecs) {
//ECS_SYSTEM(ecs, MergeItems, EcsPostUpdate, components.Position, components.ItemDrop); //ECS_SYSTEM(ecs, MergeItems, EcsPostUpdate, components.Position, components.ItemDrop);
ECS_SYSTEM(ecs, UseItem, EcsPostUpdate, components.Input, components.Position, components.Inventory, !components.IsInVehicle); ECS_SYSTEM(ecs, UseItem, EcsPostUpdate, components.Input, components.Position, components.Inventory, !components.IsInVehicle);
ECS_SYSTEM(ecs, InspectContainers, EcsPostUpdate, components.Input, !components.IsInVehicle); ECS_SYSTEM(ecs, InspectContainers, EcsPostUpdate, components.Input, !components.IsInVehicle);
//ECS_SYSTEM(ecs, HarvestIntoContainers, EcsPostUpdate, components.ItemContainer, components.Position); ECS_SYSTEM(ecs, HarvestIntoContainers, EcsPostUpdate, components.ItemContainer, components.Position);
ECS_SYSTEM(ecs, ResetActivators, EcsPostUpdate, components.Input); ECS_SYSTEM(ecs, ResetActivators, EcsPostUpdate, components.Input);

View File

@ -310,7 +310,7 @@ void HarvestIntoContainers(ecs_iter_t *it) {
for (int i = 0; i < it->count; ++i) { for (int i = 0; i < it->count; ++i) {
// NOTE(zaklaus): find any item // NOTE(zaklaus): find any item
size_t ents_count; size_t ents_count;
int64_t *ents = world_chunk_query_entities(it->entities[i], &ents_count, 2); int64_t *ents = world_chunk_query_entities(it->entities[i], &ents_count, 0);
for (size_t j = 0; j < ents_count; j++) { for (size_t j = 0; j < ents_count; j++) {
ItemDrop *drop = 0; ItemDrop *drop = 0;
@ -336,7 +336,6 @@ void HarvestIntoContainers(ecs_iter_t *it) {
if (drop->quantity == 0) if (drop->quantity == 0)
item_despawn(ents[j]); item_despawn(ents[j]);
break;
} }
} }
} }