RpgGame
Console Based RPG game in C#
Loading...
Searching...
No Matches
RpgGame.Core.Inventory Class Reference

Manages the player's inventory system, storing and organizing equippable items. More...

Collaboration diagram for RpgGame.Core.Inventory:

Public Member Functions

 Inventory (Player player, int size)
 Initializes a new instance of the Inventory class.
 
bool AddToInventory (IEquippable item)
 Adds an item to the inventory at the selected index if empty, otherwise finds the nearest empty slot.
 
IEquippableGetSelectedItem ()
 Gets the currently selected item without removing it.
 
IEquippableGetNItem (int n)
 Gets the nth item in the inventory without removing it.
 
int GetCount ()
 Gets the current number of items in the inventory.
 
bool TakeToRight ()
 Equips the selected item in the inventory to the player's right hand and removes it from inventory.
 
bool TakeToLeft ()
 Equips the selected item in the inventory to the player's left hand and removes it from inventory.
 

Properties

int SelectedIndex = 0 [get, set]
 The currently selected inventory slot index (0-9).
 
int Size [get]
 Gets the maximum size of the inventory.
 

Detailed Description

Manages the player's inventory system, storing and organizing equippable items.

The inventory has a fixed capacity and maintains a LIFO (Last In, First Out) structure. Items are added to the inventory and can be equipped directly to either hand.

Constructor & Destructor Documentation

◆ Inventory()

RpgGame.Core.Inventory.Inventory ( Player  player,
int  size 
)
inline

Initializes a new instance of the Inventory class.

Parameters
playerThe player who owns the inventory.
sizeThe maximum capacity of the inventory (ignored, forced to 10).

Member Function Documentation

◆ AddToInventory()

bool RpgGame.Core.Inventory.AddToInventory ( IEquippable  item)
inline

Adds an item to the inventory at the selected index if empty, otherwise finds the nearest empty slot.

Parameters
itemThe equippable item to add.
Returns
True if the item was successfully added; false if the inventory is full.
Here is the caller graph for this function:

◆ GetCount()

int RpgGame.Core.Inventory.GetCount ( )
inline

Gets the current number of items in the inventory.

Returns
The number of items currently stored in the inventory.

◆ GetNItem()

IEquippable? RpgGame.Core.Inventory.GetNItem ( int  n)
inline

Gets the nth item in the inventory without removing it.

Parameters
nThe 0-based index of the item to retrieve.
Returns
The nth item in the inventory, or null if n is out of bounds or slot is empty.

◆ GetSelectedItem()

IEquippable? RpgGame.Core.Inventory.GetSelectedItem ( )
inline

Gets the currently selected item without removing it.

Returns
The selected item, or null if the slot is empty.

◆ TakeToLeft()

bool RpgGame.Core.Inventory.TakeToLeft ( )
inline

Equips the selected item in the inventory to the player's left hand and removes it from inventory.

Returns
True if an item was successfully equipped; false if the slot is empty or equip failed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TakeToRight()

bool RpgGame.Core.Inventory.TakeToRight ( )
inline

Equips the selected item in the inventory to the player's right hand and removes it from inventory.

Returns
True if an item was successfully equipped; false if the slot is empty or equip failed.
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: