Astra Unity 2.6.6
Astra Unity Plugin
Astra.Serialization.ItemDict Class Reference

Dictionary used to manage Astra Items by key/value. More...

Inheritance diagram for Astra.Serialization.ItemDict:

Public Member Functions

 ItemDict ()
 Constructor for an ItemDict, creates an empty one
 
void Add (string _gid, ItemBase _item, bool replace=false)
 Adds an item to the dictionary More...
 
void Remove (string _gid, bool refreshIndexes=true)
 Removes the item with the given id More...
 
bool ContainsKey (string _gid)
 Whether the dictionary contains an item of this id More...
 
bool ContainsValue (ItemBase _val)
 Whether the dictionary contains this item More...
 
ItemBase Get (string _gid)
 Gets the item of the given id More...
 
Get< T > (string _gid, bool warnIfMissing=false)
 Templated get for an item More...
 
Pop< T > (string _gid, bool refreshIndexes=true)
 Gets the item from the dictionary and removes it in the same call More...
 
int GetIndex (string _gid)
 Finds the index for the item with the given id More...
 
GetItemAtIndex< T > (int _indx)
 Retrieves the item at the given index More...
 
void Clear ()
 Clears the dictionary
 
void RebuildIndexes ()
 Sets up indexes for keys in dictionary for quick lookup
 
void OnBeforeSerialize ()
 Implementation of method in Unity's ISerializationCallbackReceiver
 
void OnAfterDeserialize ()
 Implementation of method in Unity's ISerializationCallbackReceiver
 

Public Attributes

List< string > Keys
 List of keys
 
List< ItemBaseValues
 List of values
 

Protected Member Functions

void UpdateRefreshKeysToSlotAfterSlot (int slot)
 

Properties

int Count [get]
 Number of items in the dictionary
 
ItemBase this[string _gid] [getset]
 Sets or gets the item using this id More...
 

Detailed Description

Dictionary used to manage Astra Items by key/value.

Member Function Documentation

◆ Add()

void Astra.Serialization.ItemDict.Add ( string  _gid,
ItemBase  _item,
bool  replace = false 
)
inline

Adds an item to the dictionary

Parameters
_gidId of the item
_itemItem instance
replaceWhether the item should replace an existing item

◆ ContainsKey()

bool Astra.Serialization.ItemDict.ContainsKey ( string  _gid)
inline

Whether the dictionary contains an item of this id

Parameters
_gidId of item to look for

◆ ContainsValue()

bool Astra.Serialization.ItemDict.ContainsValue ( ItemBase  _val)
inline

Whether the dictionary contains this item

Parameters
_valItem to look for

◆ Get()

ItemBase Astra.Serialization.ItemDict.Get ( string  _gid)
inline

Gets the item of the given id

Parameters
_gidId of item to retrieve

◆ Get< T >()

T Astra.Serialization.ItemDict.Get< T > ( string  _gid,
bool  warnIfMissing = false 
)
inline

Templated get for an item

Template Parameters
TType of item to be retrieved. Must derive from ItemBase
Parameters
_gidId of the item to retrieve
warnIfMissingWhether a log statement should be made if the item is not there
Type Constraints
T :ItemBase 

◆ GetIndex()

int Astra.Serialization.ItemDict.GetIndex ( string  _gid)
inline

Finds the index for the item with the given id

Parameters
_gidId of item
Returns

◆ GetItemAtIndex< T >()

T Astra.Serialization.ItemDict.GetItemAtIndex< T > ( int  _indx)
inline

Retrieves the item at the given index

Template Parameters
TType of item to be retrieved. Must derive from ItemBase
Parameters
_indxIndex of the item
Type Constraints
T :ItemBase 

◆ Pop< T >()

T Astra.Serialization.ItemDict.Pop< T > ( string  _gid,
bool  refreshIndexes = true 
)
inline

Gets the item from the dictionary and removes it in the same call

Template Parameters
TType of item to be retrieved. Must derive from ItemBase
Parameters
_gidId of the item to retrieve
refreshIndexesWhether indexes should be refreshed after pop action
Type Constraints
T :ItemBase 

◆ Remove()

void Astra.Serialization.ItemDict.Remove ( string  _gid,
bool  refreshIndexes = true 
)
inline

Removes the item with the given id

Parameters
_gidId of item to remove
refreshIndexesWhether index list should be refreshed after removal

Property Documentation

◆ this[string _gid]

ItemBase Astra.Serialization.ItemDict.this[string _gid]
getset

Sets or gets the item using this id

Parameters
_gidId of the item

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