.            ★.        . blessfrey.me ..          ☆        .

blessfrey gdd - item

description

Items are objects that may be picked up, purchased, used, equipped, dropped, or sold. They include currency, quest items, equipment, consumables, readables, upgrades, keys, and trinkets.


four representations

An item changes its form depending on its context.


Base items are the purest form of an item, maintaining its continuity and containing its essential data. Other items hold the base item as a child or generates one if one doesn't already exist.


Floor items are the representation of an item that spawns in the environment, drops from opponents, and can be picked up. They are technically tangible entities.


Inventory items appear in the inventory window. They are technically control nodes.


Merchandise appears in store windows.


move to pick up item

Items can only be picked up by the player. They can be picked up via item targeting or through selecting 'pick up' on the inspect menu.


Item pickup is triggered when a floor item is targeted, that is, a 'target' (left-click) triggers a $Item/Body/Sprite/Sprite.gd/_on_input_event. If 'no_move_to_target' (shift) is held while targeting, the floor item will be targeted without initiating pickup. Otherwise, floor_item.gd/target_event(viewport,event,shape_idx) is called to set the target and handle the input before prompting the player to consider pickup.


Item pickup is also an option on the floor items' inspect menu. Choosing it triggers that floor item's id_pressed(id), which calls the associated method from its inspect_options dictionary: floor_item.gd/move_player_then_pickup(), prompting the player to consider pickup.


Character.gd/consider_pickup(item) passes to UserControl/pickup(item). The next branch depends on a distance check.


If the floor item is within the player's intimate distance, the character will be prompted to pick up the floor item.


Otherwise, pathfinding begins towards the floor item. Upon arrival, it calls floor_item.pick_up().pick_up(). The floor item's pick_up removes itself from the room and returns the base item, then the inventory system takes care of the rest.


drop item

Items can be dropped from the inventory app when the player selects 'drop' on the inspect menu.


Choosing 'drop' triggers that inventory item's id_pressed(id), which calls the associated method from its inspect_options dictionary: inventory_item.gd/drop. It, in turn, calls the drop method off its base item.


The base item's drop() emits the 'dropped' signal, which triggers the inventory item to queue_free then the inventory app to be refreshed. (connected @ InvContainer.gd/make_inventory_items(base_item).

challenges/known issues

pick up in range puts a floor item in the programmatic inventory. out of range puts a proper base item. STOP at line 309 on character.gd.


works for...