Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.Utils.QuickUseManager Class Reference

Set of quick use slots holding elements to quickly use if activated. More...

Inheritance diagram for Dragengine.Utils.QuickUseManager:

Public Member Functions

void forEachNonEmptySlot (Block ablock)
 Visit non-empty slots with block.
void forEachSlot (Block ablock)
 Visit slots with block.
Element getItem (int index)
 Item from indexed slot.
int getSlotCount ()
 Count of slots.
int indexOfNextFreeSlot ()
 Index of next free slot or -1 if all are full.
int indexOfSlotWith (Element item)
 Index of slot item is located in or -1 if absent.
QuickUseManager new (int slotCount)
 Create quick use manager.
void readFromFile (PersistencyEnvironment env, FileReader reader, ElementResolver elementResolver)
 Read slots from file.
void removeItemIfPresent (Element item)
 Remove item if present in any slots.
void setItem (int index, Element item)
 Set item in slot.
void setSlotCount (int count)
 Set count of slots.
void writeToFile (PersistencyEnvironment env, FileWriter writer)
 Write slots to file.

Detailed Description

Set of quick use slots holding elements to quickly use if activated.

Member Function Documentation

◆ forEachNonEmptySlot()

void Dragengine.Utils.QuickUseManager.forEachNonEmptySlot ( Block ablock)

Visit non-empty slots with block.

Block is called for each slot with arguments "int slot" and "Element element".

Referenced by writeToFile().

◆ forEachSlot()

void Dragengine.Utils.QuickUseManager.forEachSlot ( Block ablock)

Visit slots with block.

Block is called for each slot with arguments "int slot" and "Element element". Element can be null if slot is empty.

References indexOfNextFreeSlot().

Referenced by writeToFile().

◆ getItem()

Element Dragengine.Utils.QuickUseManager.getItem ( int index)

Item from indexed slot.

References setSlotCount().

Referenced by indexOfNextFreeSlot().

◆ getSlotCount()

int Dragengine.Utils.QuickUseManager.getSlotCount ( )

Count of slots.

Referenced by setSlotCount().

◆ indexOfNextFreeSlot()

int Dragengine.Utils.QuickUseManager.indexOfNextFreeSlot ( )

Index of next free slot or -1 if all are full.

References getItem(), and removeItemIfPresent().

Referenced by forEachSlot().

◆ indexOfSlotWith()

int Dragengine.Utils.QuickUseManager.indexOfSlotWith ( Element item)

Index of slot item is located in or -1 if absent.

Referenced by setItem().

◆ new()

QuickUseManager Dragengine.Utils.QuickUseManager.new ( int slotCount)

Create quick use manager.

References new(), and setSlotCount().

Referenced by new().

◆ readFromFile()

void Dragengine.Utils.QuickUseManager.readFromFile ( PersistencyEnvironment env,
FileReader reader,
ElementResolver elementResolver )

Read slots from file.

The number of slots is not saved. If you need variable slot count you have to restore the correct slot number before calling readFromFile() yourself.

References setItem().

Referenced by writeToFile().

◆ removeItemIfPresent()

void Dragengine.Utils.QuickUseManager.removeItemIfPresent ( Element item)

Remove item if present in any slots.

Referenced by indexOfNextFreeSlot().

◆ setItem()

void Dragengine.Utils.QuickUseManager.setItem ( int index,
Element item )

Set item in slot.

Can be null to clear the slot. If item is not null and it is already in another slot it is moved.

References indexOfSlotWith().

Referenced by readFromFile().

◆ setSlotCount()

void Dragengine.Utils.QuickUseManager.setSlotCount ( int count)

Set count of slots.

References getSlotCount().

Referenced by getItem(), and new().

◆ writeToFile()

void Dragengine.Utils.QuickUseManager.writeToFile ( PersistencyEnvironment env,
FileWriter writer )

Write slots to file.

The number of slots is not saved. If you need variable slot count you have to restore the correct slot number before calling readFromFile() yourself.

References forEachNonEmptySlot(), forEachSlot(), readFromFile(), and writeToFile().

Referenced by writeToFile().


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