Class InventoryComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.inventory.InventoryComponent

public class InventoryComponent extends Component
Data class to store the player's inventory separately from the display components. All other objects which do not explicitly need to use the display but need to access the inventory should access this component only.
  • Constructor Details

    • InventoryComponent

      public InventoryComponent(int capacity)
  • Method Details

    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class Component
    • getInventory

      public Inventory getInventory()
      Returns the player's current inventory from this attached InventoryComponent.
      Returns:
      The player's current inventory.
    • loadInventoryFromSave

      public void loadInventoryFromSave()
      Loads the inventory attached to the player from a save.