Adventure Creator  1.55b
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2016
AC.RuntimeInventory Class Reference
Inheritance diagram for AC.RuntimeInventory:

Public Member Functions

void OnStart ()
 
void AfterLoad ()
 
void SetNull ()
 
void SelectItemByID (int _id, SelectItemMode _mode=SelectItemMode.Use)
 Selects an inventory item (InvItem) by referencing its ID number. More...
 
void SelectItem (InvItem item, SelectItemMode _mode=SelectItemMode.Use)
 Selects an inventory item (InvItem) More...
 
bool IsGivingItem ()
 Checks if the currently-selected item is in "give" mode, as opposed to "use". More...
 
void Replace (int _addID, int _removeID, int addAmount=1)
 Replaces one inventory item carried by the player with another, retaining its position in its MenuInventoryBox element. More...
 
void Add (int _id, int amount=1, bool selectAfter=false, int playerID=0)
 Adds an inventory item to the player's inventory. More...
 
List< InvItemAdd (int _id, int amount, List< InvItem > itemList, bool selectAfter)
 Adds an inventory item to a generic inventory. More...
 
void Remove (int _id, int amount, bool setAmount, int playerID=0)
 Removes an inventory item from the player's inventory. More...
 
void Remove (InvItem _item)
 Removes an inventory item from the player's inventory. More...
 
string GetHotspotPrefixLabel (InvItem item, string itemName, int languageNumber, bool canGive=false)
 Gets the full prefix to a Hotpsot label when an item is selected, e.g. "Use X on " / "Give X to ". More...
 
string GetLabel (InvItem item, int languageNumber)
 Gets an inventory item's display name. More...
 
int GetCount (int _invID)
 Gets the amount of a particular inventory item within the player's inventory. More...
 
int GetCount (int _invID, int _playerID)
 Gets the amount of a particular inventory item within any player's inventory, if multiple Player prefabs are supported. More...
 
InvItem GetCraftingItem (int _id)
 Gets an inventory item within the current Recipe being crafted. More...
 
InvItem GetItem (int _id)
 Gets an inventory item within the player's current inventory. More...
 
bool IsCarryingItem (int _id)
 Checks if an inventory item is within the player's current inventory. More...
 
void Look (InvItem item)
 Runs an inventory item's "Examine" interaction. More...
 
void Use (InvItem item)
 Runs an inventory item's "Use" interaction. More...
 
void RunInteraction (InvItem invItem, int iconID)
 Runs an inventory item's interaction, when multiple "use" interactions are defined. More...
 
void RunInteraction (int iconID, InvItem clickedItem=null)
 Runs an interaction on the "hoverItem" inventory item, when multiple "use" interactions are defined. More...
 
void ShowInteractions (InvItem item)
 Sets up all "Interaction" menus according to a specific inventory item. More...
 
void SetHoverItem (InvItem item, MenuInventoryBox menuInventoryBox)
 Sets the item currently being hovered over by the mouse cursor. More...
 
void SetHoverItem (InvItem item, MenuCrafting menuCrafting)
 Sets the item currently being hovered over by the mouse cursor. More...
 
void Combine (InvItem item1, int item2ID)
 Combines two inventory items. More...
 
void Combine (InvItem item1, InvItem item2)
 Combines two inventory items. More...
 
List< InvItemGetSelected ()
 Gets the currently selected inventory item as a List with a single entry. More...
 
bool IsItemCarried (InvItem _item)
 Checks if a particular inventory item is currently held by the player. More...
 
void RemoveRecipes ()
 
void TransferCraftingToLocal (int _recipeSlot, bool selectAfter)
 Moves an ingredient from a crafting recipe back into the player's inventory. More...
 
void TransferLocalToCrafting (InvItem _item, int _slot)
 Moves an ingredient from the player's inventory into a crafting recipe as an ingredient. More...
 
List< InvItemMatchInteractions ()
 Gets a list of inventory items associated with the interactions of the current Hotspot or item being hovered over. More...
 
Recipe CalculateRecipe (bool autoCreateMatch)
 Works out which Recipe, if any, for which all ingredients have been correctly arranged. More...
 
void PerformCrafting (Recipe recipe, bool selectAfter)
 Crafts a new inventory item, and removes the relevent ingredients, according to a Recipe. More...
 
List< InvItemMoveItemToIndex (InvItem item, List< InvItem > items, int index)
 Moves an item already in an inventory to a different slot. More...
 
void SetFont (Font font, int size, Color color, TextEffects textEffects)
 Sets the font style of the "amount" numbers displayed over an inventory item in OnGUI menus More...
 
void DrawHighlighted (Rect _rect)
 Draws the currently-highlight item across a set region of the screen. More...
 
void HighlightItemOnInstant (int _id)
 Fully highlights an inventory item instantly. More...
 
void HighlightItemOffInstant ()
 
void HighlightItem (int _id, HighlightType _type)
 Highlights an inventory item. More...
 
void DrawInventoryCount (Vector2 cursorPosition, float cursorSize, int count)
 Draws a number at the cursor position. This should be called within an OnGUI function. More...
 
void ProcessInventoryBoxClick (AC.Menu _menu, MenuInventoryBox inventoryBox, int _slot, MouseState _mouseState)
 Processes the clicking of an inventory item within a MenuInventoryBox element More...
 
int GetTotalIntProperty (int ID)
 Gets the total value of all instances of an Integer inventory property (e.g. currency) within the player's inventory. More...
 
int GetTotalIntProperty (InvItem[] items, int ID)
 Gets the total value of all instances of an Integer inventory property (e.g. currency) within a set of inventory items. More...
 
float GetTotalFloatProperty (int ID)
 Gets the total value of all instances of an Float inventory property (e.g. weight) within the player's inventory. More...
 
float GetTotalFloatProperty (InvItem[] items, int ID)
 Gets the total value of all instances of an Float inventory property (e.g. weight) within a set of inventory items. More...
 
MainData SaveMainData (MainData mainData)
 Updates a MainData class with its own variables that need saving. More...
 
InvVar GetPropertyTotals (int ID)
 

Public Attributes

List< InvItemlocalItems = new List<InvItem>()
 
List< InvItemcraftingItems = new List<InvItem>()
 
ActionListAsset unhandledCombine
 
ActionListAsset unhandledHotspot
 
ActionListAsset unhandledGive
 
InvItem selectedItem = null
 
InvItem hoverItem = null
 
InvItem highlightItem = null
 
bool showHoverLabel = true
 
List< int > matchingInvInteractions = new List<int>()
 
InvItem lastClickedItem
 

Detailed Description

This component is where inventory items (see InvItem) are stored at runtime. When the player aquires an item, it is transferred here (into localItems) from the InventoryManager asset. It should be placed on the PersistentEngine prefab.

Member Function Documentation

void AC.RuntimeInventory.Add ( int  _id,
int  amount = 1,
bool  selectAfter = false,
int  playerID = 0 
)

Adds an inventory item to the player's inventory.

Parameters
_idThe ID number of the inventory item (InvItem) to add
amountThe amount if the inventory item to add, if the InvItem's canCarryMultiple = True
selectAfterIf True, then the inventory item will be automatically selected
playerIDThe ID number of the Player to receive the item, if multiple Player prefabs are supported. If playerID = 0, the current player will receive the item
List<InvItem> AC.RuntimeInventory.Add ( int  _id,
int  amount,
List< InvItem itemList,
bool  selectAfter 
)

Adds an inventory item to a generic inventory.

Parameters
_idThe ID number of the inventory item (InvItem) to add
amountThe amount if the inventory item to add, if the InvItem's canCarryMultiple = True
itemListThe list of inventory items to add the new item to
selectAfterIf True, then the inventory item will be automatically selected
Returns
The modified List of inventory items
void AC.RuntimeInventory.AfterLoad ( )

Initialises the inventory after a scene change. This is called manually by SaveSystem so that the order is correct.

Recipe AC.RuntimeInventory.CalculateRecipe ( bool  autoCreateMatch)

Works out which Recipe, if any, for which all ingredients have been correctly arranged.

Parameters
autoCreateMatchIf True, then any Recipes with autoCreateMatch = False will be ignored
Returns
The Recipe, if any, for which all ingredients have been correctly arranged
void AC.RuntimeInventory.Combine ( InvItem  item1,
int  item2ID 
)

Combines two inventory items.

Parameters
item1The first inventory item to combine
item2IDThe ID number of the second inventory item to combine
void AC.RuntimeInventory.Combine ( InvItem  item1,
InvItem  item2 
)

Combines two inventory items.

Parameters
item1The first inventory item to combine
item2IDThe second inventory item to combine
void AC.RuntimeInventory.DrawHighlighted ( Rect  _rect)

Draws the currently-highlight item across a set region of the screen.

Parameters
_rectThe Screen-Space co-ordinates at which to draw the highlight item
void AC.RuntimeInventory.DrawInventoryCount ( Vector2  cursorPosition,
float  cursorSize,
int  count 
)

Draws a number at the cursor position. This should be called within an OnGUI function.

Parameters
cursorPositionThe position of the cursor
cursorSizeThe size to draw the number<param>
Parameters
countThe number to display
int AC.RuntimeInventory.GetCount ( int  _invID)

Gets the amount of a particular inventory item within the player's inventory.

Parameters
_invIDThe ID number of the inventory item (InvItem) in question
Returns
The amount of the inventory item within the player's inventory.
int AC.RuntimeInventory.GetCount ( int  _invID,
int  _playerID 
)

Gets the amount of a particular inventory item within any player's inventory, if multiple Player prefabs are supported.

Parameters
_invIDThe ID number of the inventory item (InvItem) in question
playerIDThe ID number of the Player to refer to
Returns
The amount of the inventory item within the player's inventory.
InvItem AC.RuntimeInventory.GetCraftingItem ( int  _id)

Gets an inventory item within the current Recipe being crafted.

<param name "_id">The ID number of the inventory item

Returns
The inventory item, if it is within the current Recipe being crafted
string AC.RuntimeInventory.GetHotspotPrefixLabel ( InvItem  item,
string  itemName,
int  languageNumber,
bool  canGive = false 
)

Gets the full prefix to a Hotpsot label when an item is selected, e.g. "Use X on " / "Give X to ".

Parameters
itemThe inventory item that is selected
itemNameThe display name of the inventory item, in the current language
languageNumberThe index of the current language, as set in SpeechManager
canGiveIf True, the the item is assumed to be in "give" mode, as opposed to "use".
Returns
The full prefix to a Hotspot label when the item is selected
InvItem AC.RuntimeInventory.GetItem ( int  _id)

Gets an inventory item within the player's current inventory.

Parameters
_idThe ID number of the inventory item
Returns
The inventory item, if it is held by the player
string AC.RuntimeInventory.GetLabel ( InvItem  item,
int  languageNumber 
)

Gets an inventory item's display name.

Parameters
itemThe inventory item to get the display name of
languageNumberThe index of the current language, as set in SpeechManager
Returns
The inventory item's display name
List<InvItem> AC.RuntimeInventory.GetSelected ( )

Gets the currently selected inventory item as a List with a single entry.

Returns
The currently selected inventory item as a List with a single entry.
float AC.RuntimeInventory.GetTotalFloatProperty ( int  ID)

Gets the total value of all instances of an Float inventory property (e.g. weight) within the player's inventory.

Parameters
IDThe ID number of the Inventory Float (see InvVar) to get the total value of
Returns
The total value of all instances of the Float inventory property within the player's inventory
float AC.RuntimeInventory.GetTotalFloatProperty ( InvItem[]  items,
int  ID 
)

Gets the total value of all instances of an Float inventory property (e.g. weight) within a set of inventory items.

Parameters
itemsThe inventory items to get the total value from
IDThe ID number of the Inventory property (see InvVar) to get the total value of
Returns
The total value of all instances of the Float inventory property within the set of inventory items
int AC.RuntimeInventory.GetTotalIntProperty ( int  ID)

Gets the total value of all instances of an Integer inventory property (e.g. currency) within the player's inventory.

Parameters
IDThe ID number of the Inventory property (see InvVar) to get the total value of
Returns
The total value of all instances of the Integer inventory property within the player's inventory
int AC.RuntimeInventory.GetTotalIntProperty ( InvItem[]  items,
int  ID 
)

Gets the total value of all instances of an Integer inventory property (e.g. currency) within a set of inventory items.

Parameters
itemsThe inventory items to get the total value from
IDThe ID number of the Inventory property (see InvVar) to get the total value of
Returns
The total value of all instances of the Integer inventory property within the set of inventory items
void AC.RuntimeInventory.HighlightItem ( int  _id,
HighlightType  _type 
)

Highlights an inventory item.

Parameters
_idThe ID number of the inventory item (see InvItem) to highlight
_typeThe type of highlighting effect to perform (Enable, Disable, PulseOnce, PulseContinuously)
void AC.RuntimeInventory.HighlightItemOffInstant ( )

Removes all highlighting from the inventory item curently being highlighted.

void AC.RuntimeInventory.HighlightItemOnInstant ( int  _id)

Fully highlights an inventory item instantly.

Parameters
_idThe ID number of the inventory item (see InvItem) to highlight
bool AC.RuntimeInventory.IsCarryingItem ( int  _id)

Checks if an inventory item is within the player's current inventory.

Parameters
_idThe ID number of the inventory item
Returns
True if the inventory item is within the player's current inventory
bool AC.RuntimeInventory.IsGivingItem ( )

Checks if the currently-selected item is in "give" mode, as opposed to "use".

Returns
True if the currently-selected item is in "give" mode, as opposed to "use"
bool AC.RuntimeInventory.IsItemCarried ( InvItem  _item)

Checks if a particular inventory item is currently held by the player.

Parameters
_itemThe inventory item to check for
Returns
True if the inventory item is currently held by the player
void AC.RuntimeInventory.Look ( InvItem  item)

Runs an inventory item's "Examine" interaction.

Parameters
itemThe inventory item to examine
List<InvItem> AC.RuntimeInventory.MatchInteractions ( )

Gets a list of inventory items associated with the interactions of the current Hotspot or item being hovered over.

Returns
A list of inventory items associated with the interactions of the current Hotspot or item being hovered over
List<InvItem> AC.RuntimeInventory.MoveItemToIndex ( InvItem  item,
List< InvItem items,
int  index 
)

Moves an item already in an inventory to a different slot.

Parameters
itemThe inventory item to move
itemsThe List of inventory items that the item is to be moved within
indexThe index number of the MenuInventoryBox slot to move the item to
Returns
The re-ordered List of inventory items
void AC.RuntimeInventory.OnStart ( )

Transfers any relevant data from InventoryManager when the game begins or restarts.

void AC.RuntimeInventory.PerformCrafting ( Recipe  recipe,
bool  selectAfter 
)

Crafts a new inventory item, and removes the relevent ingredients, according to a Recipe.

Parameters
recipeThe Recipe to perform
selectAfterIf True, then the resulting inventory item will be selected once the crafting is complete
void AC.RuntimeInventory.ProcessInventoryBoxClick ( AC.Menu  _menu,
MenuInventoryBox  inventoryBox,
int  _slot,
MouseState  _mouseState 
)

Processes the clicking of an inventory item within a MenuInventoryBox element

Parameters
_menuThe Menu that contains the MenuInventoryBox element
inventoryBoxThe MenuInventoryBox element that was clicked on
_slotThe index number of the MenuInventoryBox slot that was clicked on
_mouseStateThe state of the mouse when the click occured (Normal, SingleClick, RightClick, DoubleClick, HeldDown, LetGo)
void AC.RuntimeInventory.Remove ( int  _id,
int  amount,
bool  setAmount,
int  playerID = 0 
)

Removes an inventory item from the player's inventory.

Parameters
_idThe ID number of the inventory item (InvItem) to remove
amountThe amount if the inventory item to remove, if the InvItem's canCarryMultiple = True
setAmountIf False, then all instances of the inventory item will be removed, even if the InvItem's canCarryMultiple = True
playerIDThe ID number of the Player to lose the item, if multiple Player prefabs are supported. If playerID = 0, the current player will lose the item
void AC.RuntimeInventory.Remove ( InvItem  _item)

Removes an inventory item from the player's inventory.

Parameters
_itemThe inventory item (InvItem) to remove
void AC.RuntimeInventory.RemoveRecipes ( )

Resets any active recipe, and clears all MenuCrafting elements.

void AC.RuntimeInventory.Replace ( int  _addID,
int  _removeID,
int  addAmount = 1 
)

Replaces one inventory item carried by the player with another, retaining its position in its MenuInventoryBox element.

Parameters
_addIDThe ID number of the inventory item (InvItem) to add
_removeIDThe ID number of the inventory item (InvItem) to remove
addAmountThe amount if the new inventory item to add, if the InvItem's canCarryMultiple = True
void AC.RuntimeInventory.RunInteraction ( InvItem  invItem,
int  iconID 
)

Runs an inventory item's interaction, when multiple "use" interactions are defined.

Parameters
invItemThe relevant inventory item
iconIDThe ID number of the interaction's icon, defined in CursorManager
void AC.RuntimeInventory.RunInteraction ( int  iconID,
InvItem  clickedItem = null 
)

Runs an interaction on the "hoverItem" inventory item, when multiple "use" interactions are defined.

Parameters
iconIDThe ID number of the interaction's icon, defined in CursorManager
clickedItemIf assigned, hoverItem will be become this before the interaction is run
MainData AC.RuntimeInventory.SaveMainData ( MainData  mainData)

Updates a MainData class with its own variables that need saving.

Parameters
mainDataThe original MainData class
Returns
The updated MainData class
void AC.RuntimeInventory.SelectItem ( InvItem  item,
SelectItemMode  _mode = SelectItemMode.Use 
)

Selects an inventory item (InvItem)

Parameters
_idThe inventory item to selet
_modeWhat mode the item is selected in (Use, Give)
void AC.RuntimeInventory.SelectItemByID ( int  _id,
SelectItemMode  _mode = SelectItemMode.Use 
)

Selects an inventory item (InvItem) by referencing its ID number.

Parameters
_idThe inventory item's ID number
_modeWhat mode the item is selected in (Use, Give)
void AC.RuntimeInventory.SetFont ( Font  font,
int  size,
Color  color,
TextEffects  textEffects 
)

Sets the font style of the "amount" numbers displayed over an inventory item in OnGUI menus

Parameters
fontThe font to use<param>
Parameters
sizeThe font's size
colorThe colour to set the font
textEffectsWhat text effect to apply (Outline, Shadow, OutlineAndShadow)
void AC.RuntimeInventory.SetHoverItem ( InvItem  item,
MenuInventoryBox  menuInventoryBox 
)

Sets the item currently being hovered over by the mouse cursor.

Parameters
itemThe item to set
menuInventoryBoxThe MenuInventoryBox that the item is displayed within
void AC.RuntimeInventory.SetHoverItem ( InvItem  item,
MenuCrafting  menuCrafting 
)

Sets the item currently being hovered over by the mouse cursor.

Parameters
itemThe item to set
menuCraftingThe MenuInventoryBox that the item is displayed within
void AC.RuntimeInventory.SetNull ( )

De-selects the active inventory item.

void AC.RuntimeInventory.ShowInteractions ( InvItem  item)

Sets up all "Interaction" menus according to a specific inventory item.

Parameters
itemThe relevant inventory item
void AC.RuntimeInventory.TransferCraftingToLocal ( int  _recipeSlot,
bool  selectAfter 
)

Moves an ingredient from a crafting recipe back into the player's inventory.

Parameters
_recipeSlotThe index number of the MenuCrafting slot that the ingredient was placed in
selectAfterIf True, the inventory item will be selected once the transfer is complete
void AC.RuntimeInventory.TransferLocalToCrafting ( InvItem  _item,
int  _slot 
)

Moves an ingredient from the player's inventory into a crafting recipe as an ingredient.

Parameters
_itemThe inventory item to transfer
_slotThe index number of the MenuCrafting slot to place the item in
void AC.RuntimeInventory.Use ( InvItem  item)

Runs an inventory item's "Use" interaction.

Parameters
itemThe inventory item to use

Member Data Documentation

List<InvItem> AC.RuntimeInventory.craftingItems = new List<InvItem>()

A List of inventory items (InvItem) being used in the current Recipe being crafted

InvItem AC.RuntimeInventory.highlightItem = null

The inventory item that is currently being highlighted within an MenuInventoryBox element

InvItem AC.RuntimeInventory.hoverItem = null

The inventory item that is currently being hovered over by the cursor

InvItem AC.RuntimeInventory.lastClickedItem

The last inventory item that the player clicked on, in any MenuInventoryBox element type

List<InvItem> AC.RuntimeInventory.localItems = new List<InvItem>()

A List of inventory items (InvItem) carried by the player

List<int> AC.RuntimeInventory.matchingInvInteractions = new List<int>()

A List of index numbers within a Button's invButtons List that represent inventory interactions currently available to the player

InvItem AC.RuntimeInventory.selectedItem = null

The inventory item that is currently selected

bool AC.RuntimeInventory.showHoverLabel = true

If True, then the Hotspot label will show the name of the inventory item that the mouse is hovering over

ActionListAsset AC.RuntimeInventory.unhandledCombine

The default ActionListAsset to run if an inventory combination is unhandled

ActionListAsset AC.RuntimeInventory.unhandledGive

The default ActionListAsset to run if giving an inventory item to an NPC is unhandled

ActionListAsset AC.RuntimeInventory.unhandledHotspot

The default ActionListAsset to run if using an inventory item on a Hotspot is unhandled