Skip to content

Companion Powerup Inventory

saakshigupta2002 edited this page Oct 5, 2023 · 1 revision

Overview

The CompanionInventoryComponent is a vital component in the game responsible for managing the inventory of powerups and weapons for the companion. This wiki page provides an in-depth understanding of the structure, functionality, and usage of the CompanionInventoryComponent class.

Class Structure

Inventory Management The class incorporates a versatile inventory management system that handles both powerups and weapons. It contains methods to add, retrieve, and utilize powerups seamlessly during gameplay. The inventory size is limited to ensure a balanced gaming experience.

Weapon Handling

The CompanionInventoryComponent also manages the companion's equipped weapons. It allows for easy switching between weapon types and provides essential information such as ammo count, cooldowns, and maximum ammo capacity.

Equipped Weapons Map

A crucial feature is the use of a LinkedHashMap to manage equipped weapons. This preserves the order of insertion, facilitating efficient traversal and retrieval of equipped weapons.

Powerup Queue

The class maintains a queue for powerups, ensuring a first-in, first-out order when using or adding new powerups. This design choice contributes to a fair distribution of powerups during gameplay.

Usage

Powerup Handling Adding Powerups Developers can add powerups to the companion's inventory using the addPowerup(Entity item) method. This method ensures that the inventory does not exceed its specified size and updates the powerup count accordingly.

Using Powerups

To use the next powerup in the inventory, developers can employ the useNextPowerup() method. This method retrieves the next powerup in the queue, applies its effect, and updates the inventory accordingly.

Powerup Count

Developers can query the count of a specific powerup type using the getPowerupCount(PowerupType type) method. This allows for dynamic updates to UI elements reflecting the current state of the companion's powerup inventory.

Weapon Handling

Equipping Weapons Developers can change the equipped weapon type using the changeEquipped(CompanionWeaponType type) method. This method updates the equipped weapon based on the provided weapon type.

Retrieving Equipped Weapons

The getEquippedWeapons() method returns a list of all equipped weapons, providing developers with a convenient way to gather information about the current weapon setup.

Ammo and Cooldown

The class provides methods to retrieve current ammo count, maximum ammo capacity, cooldown duration, and change ammo count for the actively equipped weapon.

Conclusion

The CompanionInventoryComponent plays a central role in managing the companion's powerup inventory and equipped weapons. Its versatile design allows for efficient handling of diverse game scenarios, making it an essential component for developers aiming to create engaging and dynamic gameplay experiences. Developers are encouraged to leverage the provided methods for effective integration and utilization of the CompanionInventoryComponent in their game projects.

Clone this wiki locally