Repository navigation
Item System
Current Room/item spawning contract: Spawning items from a room documents remote
items@1ec91e64for draft PR #198. The oldercreateDrop,TypedItem, and drop-policy examples below describe the dated baseline stated in this page and should not be used as the currentitemsintegration API.
Updated 17 September 2026 against remote items@9eb2186. The generic Item abstraction also exists on main, but the Team 5 integration described here is not a claim of a completed items-to-main merge.
Item is the shared abstract model with name, description, texture, pickUp(Entity) and drop(Entity). ItemComponent attaches an Item to a world entity. ItemPickupComponent detects nearby ITEM-layer entities and invokes pickup on E; collision alone does not collect them.
Team 5 uses ItemType to identify Health Potion, Shield, Speed Potion, Strength Potion, Gold Coin and Strength Charm. TypedItem carries a consumable/currency type and positive quantity from ItemDropSpec. Strength Charm retains its dedicated implementation: +10 raw attack per distinct picked-up object, with a same-object duplicate-application guard. Charm.drop reverses its effect; removing a list entry directly does not.
The existing InventoryComponent stores Gold, a Charm list and a separate consumable-count map. It does not expose a generic addItem method or maintain a universal List for every item category.
The following is the routing used by a TypedItem after the generic pickup component provides the player:
InventoryComponent inventory = player.getComponent(InventoryComponent.class);
if (itemType.isConsumable()) {
inventory.addConsumable(itemType, quantity);
} else if (itemType.isCurrency()) {
inventory.addGold(quantity);
}Pickup stores consumables; it does not immediately apply their effects. The fixed-key use flow validates inventory and applies the effect later. See controls and contracts.
Callers must load the corresponding textures and provide the normal physics/resource services before using ItemFactory.
ItemDropSpec reward = new ItemDropSpec(ItemType.HEALTH_POTION, 2);
Entity potionDrop = ItemFactory.createDrop(reward, position);The entity is positioned and pickup-ready, but not registered by the factory. Its caller owns registration and disposal. EnemyManager defers construction/registration outside the active physics callback and tracks room-owned drops.
For an existing Item object, ItemFactory.createItem(item) constructs its world entity. Set its position and register it through the owning system. For example, construct a weapon descriptor with WeaponItem.createWeaponItem(WeaponItem.WeaponType.SWORD), not a nonexistent zero-argument constructor. The descriptor/factory interface does not establish that weapon unlock-on-pickup is implemented; weapon pickup currently logs the interaction.
Item.drop(Entity) is a model hook, not proof that the complete inventory UI supplies a drop button or creates a world entity for the player.
EnemyDropPolicy selects Gold and optional consumable ItemDropSpec values; ItemFactory creates them; EnemyManager owns deferred registration and cleanup. createRandomDrop remains a separate Charm-pool API. See Sprint 2 rules for the normal enemy policy and boss tracking limits.
classDiagram
Item <|-- TypedItem
Item <|-- Charm
Charm <|-- StrengthCharm
Item <|-- WeaponItem
ItemComponent --> Item
ItemPickupComponent --> Item : pickUp(player)
TypedItem --> ItemDropSpec : type and quantity
TypedItem --> InventoryComponent : add consumable or Gold
StrengthCharm --> InventoryComponent : add Charm
EnemyDropPolicy --> ItemDropSpec
ItemFactory --> ItemComponent : constructs world entity
EnemyManagerComponent --> ItemFactory : registers and owns drops
InventoryComponent : int gold
InventoryComponent : List charms
InventoryComponent : Map consumableCounts
This page preserves the shared Item abstraction and documents Team 5's concrete integration. Team 4 owns the complete inventory UI and other teams retain their item subclasses. Original contributions remain in repository history; this revision was prepared with Codex assistance under Yuezhou's direction.