Managing Inventory
Items don’t always sit passively on the map, hoping someone will walk onto them. Unless you’re making a Pac-Man style game, it also doesn’t make sense to have items activate when the player walks into them. Instead, let’s allow players to pick up items and carry them in their inventory until they’re needed. This adds strategy to the game, letting players decide when they want to use their precious items.
Items are entities, and they exist on the map because they have a Point component indicating their location. The entity rendering system query requires a Point to draw an item or display its tooltip. You can take advantage of the render system’s query structure by removing the Point component from an item when it’s picked ...
Get Hands-on Rust now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.