-
Notifications
You must be signed in to change notification settings - Fork 9
Companion Powerup Inventory
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.
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.
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.
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.
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.
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.
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.
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.
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.
The getEquippedWeapons() method returns a list of all equipped weapons, providing developers with a convenient way to gather information about the current weapon setup.
The class provides methods to retrieve current ammo count, maximum ammo capacity, cooldown duration, and change ammo count for the actively equipped weapon.
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.
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files