Skip to content

Companion Inventory

saakshigupta2002 edited this page Oct 9, 2023 · 2 revisions

CompanionInventoryComponent Class

The CompanionInventoryComponent class is responsible for managing inventory and weapons for a companion in a game.

Class Overview

  • Package: com.csse3200.game.components.Companion
  • Inherits From: Component
  • Dependencies: CompanionWeapons.CompanionWeaponType, PowerupComponent, PowerupType, Entity, CompanionWeaponConfigs

Class Members

Fields

  • CompanionWeaponType weaponType: The currently equipped weapon type.
  • int ammoCount: The current ammunition count for the equipped weapon.
  • int maxAmmo: The maximum ammunition capacity.
  • int attackCooldown: The cooldown time for the companion's attack.

Constructors

  • CompanionInventoryComponent(CompanionWeaponType weaponType, int ammo, int maxAmmo): Constructor to initialize the companion's inventory with a specified weapon type, ammo, and max ammo capacity.

Methods

  • CompanionWeaponType getItem(): Get the currently equipped weapon type.
  • int getAmmo(): Get the current ammunition count.
  • void changeItem(CompanionWeaponType weaponType): Change the equipped weapon type.
  • void changeAmmo(int change): Change the ammunition count.
  • int getMaxAmmo(): Get the maximum ammunition capacity.
  • void setAttackCooldown(int cooldown): Set the attack cooldown.
  • int getAttackCooldown(): Get the attack cooldown.
  • void decCoolDown(): Decrease the attack cooldown timer.

Inventory Management

  • Deque<Entity> powerupQueue: A queue to store power-up items.
  • int[] itemQuantity: An array to store the quantity of each item.
  • HashMap<PowerupType, Integer> powerupCounts: A map to store counts for each power-up type.

Power-Up Handling

  • void addPowerup(Entity item): Add a power-up item to the companion's inventory.
  • boolean useNextPowerup(): Retrieve and use the next power-up from the inventory.

Weapon Configuration

  • String equipped: The currently equipped weapon slot.
  • LinkedHashMap<String, CompanionInventoryComponent> equippedWMap: A map to represent equipped weapons.
  • CompanionWeaponConfigs config: Configuration for weapons.

Weapon Management

  • void create(): Create the initial weapon configuration.
  • void update(): Update the equipped weapon's cooldown timer.
  • CompanionWeaponConfigs getConfigs(): Get the weapon configuration.
  • String getEquipped(): Get the currently equipped weapon slot.
  • void setEquipped(String slot): Change the active inventory slot to a specific slot.
  • ArrayList<CompanionWeaponType> getEquippedWeapons(): Get a list of currently equipped weapons.
  • void changeEquipped(CompanionWeaponType type): Update the weapon of the active inventory slot.
  • CompanionWeaponType getEquippedType(): Get the equipped weapon type.
  • int GetCurrentAmmo(): Get the current ammunition for the equipped weapon.
  • int GetCurrentMaxAmmo(): Get the maximum ammunition for the equipped weapon.
  • void changeEquippedAmmo(int ammoChange): Change the ammunition count for the equipped weapon.
  • int getEquippedCooldown(): Get the cooldown for the equipped weapon.
  • void setEquippedCooldown(int coolDown): Set the cooldown for the equipped weapon.
Screenshot 2023-10-10 at 9 57 48 AM
Clone this wiki locally