five-on-it / packages/sim/src/items
packages/sim/src/items
Items (GAME_DESIGN §7.4): data, held in slots. An item is a definition (ItemDef: an id, a name, tags, how many stack in one slot, what may be done with it); the room's items are a table the world carries (SimWorld.items: the COMMON_ITEMS, then the game's own), and a stack names an item by its index in that table, so the simulation never handles a string on its hot path. Missions check tags, not names: an item answers to each of its tags and to its id (itemMatches).
Weapons are items too (GAME_DESIGN §7.4): an item with a weapon arms whoever holds it in the selected slot (weapons.ts), and its ammunition is items of their own, spent from the inventory a shot at a time. A character keeps its ammunition in a pouch beyond its slots (AMMO_POUCH more, where nothing else goes): the strip shows a weapon once, with its rounds, and never a separate stack of them.
What holds items is an entity with slots (SimWorld.slots, created empty when first asked for): a character's inventory (INVENTORY_SLOTS: the weapons and what else it carries, then the pouch), a crate's or a locker's (CONTAINER_SLOTS) and a car's trunk (TRUNK_SLOTS; a two-wheeler has none, a class may have its own: a pickup's bed, a delivery scooter's top box). Items lie on the ground as pickups: entities with a pose and a stack and no collider at all, so nothing (a wheel, a shot, the cover probe) ever touches one; the interaction key finds them by distance. A container (a crate, a locker) stands on a fixed body of its own, a box that blocks and gives cover like a wall. A level, a mission or a drop puts them in the world; the server spawns them and the snapshots carry them to the clients.
Interfaces
Type Aliases
Variables
- AMMO_POUCH
- COMMON_ITEMS
- CONTAINER_KINDS
- CONTAINER_SIZE
- CONTAINER_SLOTS
- DEFAULT_PRICE
- INVENTORY_SLOTS
- NO_ITEM
- PHONE_ITEM
- TRUNK_SLOTS