Item Pickup Component - UQcsse3200/2023-studio-1 GitHub Wiki
Item Pickup Component
Overview
Items exist as entities in the game, this means items can exist within the map alike the player, animals, and other entities. The ItemPickupComponent is a component that works alongside other components to allow items within the map to be added to an entity's inventory upon collision.
For a full description of entities and components, see ECS.
Dependencies
For this component to function, the calling entity (usually player) and the desired (item) entity need the following components:
- HitboxComponent (player and item)
- inventory component (player)
Details
This component relies on collision, this means both host entities must have a HitboxComponent (or ColliderComponent with sensor = true). Once collision is detected this component checks if the collision was with an item, if not - the function returns and nothing happens, otherwise the entity is retrieved and added to the players inventory through the inventory component interface. The item entity is then removed from the map through the service locator pattern.
NOTE: Since inventory component does not currently have a capacity implemented, this component is unable the account for the possible future case where the inventory is full, resulting in the item not being added to the players inventory and the item being deleted from the map (complete loss of refence to that item).