class GridInventory extends Container
An inventory are used to stow Equipment
when it does not exist visually in the game world.
Visually, an inventory is understood as a rectangular region divided into cellular units.
The Equipment
that is placed into the inventory can also be represented as smaller rectangles, also composed of cells.
The same number of cells of the item must overlap with the same number of cells of the inventory.
No two items may have cells that overlap.
This "grid" maintains a spatial distinction between items when they get stowed.
It is not necessary to actually have a structural representation of the "grid."
Adhering to such a data structure does speed up the actions upon the inventory and its contents in certain cases (where noted).
The HashMap
of items is used for quick object lookup.
Use of the HashMap
only is hitherto referred as "using the inventory as a List
."
The Array
of spatial GUIDs is used for quick collision lookup.
Use of the Array
only is hitherto referred as "using the inventory as a grid."
- Source
- GridInventory.scala
- Alphabetic
- By Inheritance
- GridInventory
- Container
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new GridInventory()
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +=(kv: (Int, Equipment)): Boolean
- def -=(guid: PlanetSideGUID): Boolean
- def -=(index: Int): Boolean
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def Capacity: Int
Capacity is a measure how many squares in the grid inventory are unused (value of -1).
Capacity is a measure how many squares in the grid inventory are unused (value of -1). It does not guarantee the cells are distributed in any configuration conductive to item stowing.
- returns
the number of free cells
- def CheckCollisions(start: Int, w: Int, h: Int): Try[List[Int]]
Test whether a given piece of
Equipment
would collide with any stowed content in the inventory.Test whether a given piece of
Equipment
would collide with any stowed content in the inventory.- start
the cell index to test this
Equipment
for insertion- w
the width of the
Equipment
to be tested- h
the height of the
Equipment
to be tested- returns
a
List
of GUID values for all existing contents that this item would overlap if inserted
- def CheckCollisions(start: Int, item: Equipment): Try[List[Int]]
Test whether a given piece of
Equipment
would collide with any stowed content in the inventory.
A "collision" is considered a situation where the stowed placards of two items would overlap in some way.Test whether a given piece of
Equipment
would collide with any stowed content in the inventory.
A "collision" is considered a situation where the stowed placards of two items would overlap in some way. The grid keeps track of the location of items by storing the primitive of their GUID in one or more cells. Two primitives can not be stored in the same cell. If placing two items into the same inventory leads to a situation where two primitive values might be in the same cell, that is a collision.- start
the cell index to test this
Equipment
for insertion- item
the
Equipment
to be tested- returns
a
List
of GUID values for all existing contents that this item would overlap if inserted
- def CheckCollisionsAsGrid(start: Int, w: Int, h: Int): Try[List[InventoryItem]]
Test whether a given piece of
Equipment
would collide with any stowed content in the inventory.
Iterate over all cells that would be occupied by a new value and check each one whether or not that cell has an existing value.Test whether a given piece of
Equipment
would collide with any stowed content in the inventory.
Iterate over all cells that would be occupied by a new value and check each one whether or not that cell has an existing value. This is a "using the inventory as a grid" method.- start
the cell index to test this
Equipment
for insertion- w
the width of the
Equipment
to be tested- h
the height of the
Equipment
to be tested- returns
a
List
of existing items that an item of this scale would overlap if inserted
- Exceptions thrown
IndexOutOfBoundsException
if the region extends outside of the grid boundaries
- def CheckCollisionsAsList(start: Int, w: Int, h: Int): Try[List[InventoryItem]]
Test whether a given piece of
Equipment
would collide with any stowed content in the inventory.
Iterate over all stowed items and check each one whether or not it overlaps with the given region.Test whether a given piece of
Equipment
would collide with any stowed content in the inventory.
Iterate over all stowed items and check each one whether or not it overlaps with the given region. This is a "using the inventory as aList
" method.- start
the cell index to test this
Equipment
for insertion- w
the width of the
Equipment
to be tested- h
the height of the
Equipment
to be tested- returns
a
List
of existing items that an item of this scale would overlap if inserted
- Exceptions thrown
IndexOutOfBoundsException
if the region extends outside of the grid boundaries
- def CheckCollisionsVar(start: Int, w: Int, h: Int): Try[List[InventoryItem]]
Test whether a given piece of
Equipment
would collide with any stowed content in the inventory.
If there are fewer items stored in the inventory than there are cells required to represent the testing item, test the collision by iterating through the list of items.Test whether a given piece of
Equipment
would collide with any stowed content in the inventory.
If there are fewer items stored in the inventory than there are cells required to represent the testing item, test the collision by iterating through the list of items. If there are more items, check that each cell that would be used for the testing items tile does not collide. The "testing item" in this case has already been transformed into its tile dimensions.- start
the cell index to test this
Equipment
for insertion- w
the width of the
Equipment
to be tested- h
the height of the
Equipment
to be tested- returns
a
List
of existing items that an item of this scale would overlap if inserted
- def Clear(): List[InventoryItem]
Clear the inventory by removing all of its items.
Clear the inventory by removing all of its items.
- returns
a
List
of the previous items in the inventory as theirInventoryItemData
tiles
- def Collisions(index: Int, width: Int, height: Int): Try[List[InventoryItem]]
Given a region of "searchable unit positions" considered as stowable, determine if any previously stowed items are contained within that region.
Default usage, and recommended the continued inclusion of that use, is defined in terms ofEquipment
being stowed in aGridInventory
.Given a region of "searchable unit positions" considered as stowable, determine if any previously stowed items are contained within that region.
Default usage, and recommended the continued inclusion of that use, is defined in terms ofEquipment
being stowed in aGridInventory
. Where theEquipment
object is defined by the dimensionswidth
andheight
, starting a search atindex
will search all positions within a grid-like range of numbers. Under certain searching conditions, this range may be meaningless, such as is the case when searching individual positions that are normalEquipmentSlot
objects. Regardless, the value collected indicates the potential of multiple objects being discovered and maintains a reference to the object itself and the slot position where the object is located. (As any object can be discovered within the range, that is important.)- index
the position to start searching
- width
the width of the searchable space
- height
the height of the serachable space
- returns
a list of objects that have been encountered within the searchable space
- Definition Classes
- Container
- See also
GridInventory.CheckCollisionsVar
- def ElementsInListCollideInGrid(): List[List[InventoryItem]]
Check whether any items in the "inventory as a list" datastructure would overlap in the "inventory as a grid".
Check whether any items in the "inventory as a list" datastructure would overlap in the "inventory as a grid". Most likely, if an overlap is discovered, the grid-space is already compromised by having lost a section of some item's
Tile
. The inventory system actually lacks mechanics to properly resolve any discovered issues. For that reason, it will return a list of overlap issues that need to be resolved by a higher authority.- returns
a list of item overlap collision combinations
- See also
InventoryDisarrayException
recursiveRelatedListCollisions
- def ElementsOnGridMatchList(): Int
Align the "inventory as a grid" with the "inventory as a list." The grid is a faux-two-dimensional map of object identifiers that should point to items in the list.
Align the "inventory as a grid" with the "inventory as a list." The grid is a faux-two-dimensional map of object identifiers that should point to items in the list. (Not the same as the global unique identifier number.) The objects in the list are considered actually being in the inventory. Only the references to those objects in grid-space can be considered out of alignment by not pointing to objects in the list. The inventory as a grid can be repaired but only a higher authority can perform inventory synchronization.
- returns
the number of stale object references found and corrected
- See also
InventoryDisarrayException
- def Find(guid: PlanetSideGUID): Option[Int]
Given globally unique identifier, if the object using it is stowed, attempt to locate its slot.
Given globally unique identifier, if the object using it is stowed, attempt to locate its slot. All positions,
VisibleSlot
andInventory
, and wherever else, should be searchable.- guid
the GUID of the
Equipment
- returns
the index of the
EquipmentSlot
, orNone
- Definition Classes
- GridInventory → Container
- def Find(obj: Equipment): Option[Int]
Given an object, attempt to locate its slot.
Given an object, attempt to locate its slot. All positions,
VisibleSlot
andInventory
, and wherever else, should be searchable.- obj
the
Equipment
object- returns
the index of the
EquipmentSlot
, orNone
- Definition Classes
- Container
- def Fit(tile: InventoryTile): Option[Int]
Find a blank space in the current inventory where a
tile
of given dimensions can be cleanly inserted.Find a blank space in the current inventory where a
tile
of given dimensions can be cleanly inserted. Brute-force method.- tile
the dimensions of the blank space
- returns
the grid index of the upper left corner where equipment to which the
tile
belongs should be placed
- Definition Classes
- GridInventory → Container
- def Fit(obj: Equipment): Option[Int]
- Definition Classes
- Container
- def Height: Int
- def Insert(start: Int, obj: Equipment): Boolean
- def InsertQuickly(start: Int, obj: Equipment): Boolean
Just insert an item into the inventory without checking for item collisions.
Just insert an item into the inventory without checking for item collisions.
- start
the starting slot
- obj
the
Equipment
item to be inserted- returns
whether the insertion succeeded
- def Insertion_CheckCollisions(start: Int, obj: Equipment, key: Int): Boolean
Perform a collisions check and, if it passes, perform the insertion.
Perform a collisions check and, if it passes, perform the insertion.
- start
the starting slot
- obj
the
Equipment
item to be inserted- key
the internal numeric identifier for this item
- returns
the success or the failure of the insertion process
- def Inventory: GridInventory
A(n imperfect) reference to a generalized pool of the contained objects.
A(n imperfect) reference to a generalized pool of the contained objects. Having access to all of the available positions is not required. The entries in this reference should definitely include all unseen positions. The
GridInventory
returned by this accessor is also an implementation ofContainer
.- Definition Classes
- GridInventory → Container
- See also
VisibleSlots
- def Items: List[InventoryItem]
- def LastIndex: Int
The index of the last cell in this inventory.
The index of the last cell in this inventory.
- returns
same as
Offset
plus the total number of cells in this inventory minus 1
- def Offset: Int
- def Offset_=(fset: Int): Int
Change the grid index offset value.
Change the grid index offset value.
- fset
the new offset value
- returns
the current offset value
- Exceptions thrown
IndexOutOfBoundsException
if the index is negative
- def Remove(guid: PlanetSideGUID): Boolean
- def Remove(index: Int): Boolean
- def Resize(w: Int, h: Int): Unit
Change the size of the inventory, without regard for its current contents.
Change the size of the inventory, without regard for its current contents. This method replaces mutators for
Width
andHeight
.- w
the new width
- h
the new height
- Exceptions thrown
IllegalArgumentException
if the new size to be set is zero or less
- def SetCells(start: Int, w: Int, h: Int, value: Int = -1): Unit
Define a region of inventory grid cells and set them to a given value.
Define a region of inventory grid cells and set them to a given value.
- start
the initial inventory index
- w
the width of the region
- h
the height of the region
- value
the value to set all the cells in the defined region; defaults to -1 (which is "nothing")
- See also
SetCellsNoOffset
- def SetCellsNoOffset(start: Int, w: Int, h: Int, value: Int = -1): Array[Int]
Define a region of inventory grid cells and set them to a given value.
Define a region of inventory grid cells and set them to a given value. Perform basic boundary checking for the current inventory dimensions.
- start
the initial inventory index, without the inventory offset (required)
- w
the width of the region
- h
the height of the region
- value
the value to set all the cells in the defined region; defaults to -1 (which is "nothing")
- returns
a copy of the inventory as a grid, with the anticipated modifications
- Exceptions thrown
IndexOutOfBoundsException
if the region extends outside of the grid boundaries- See also
SetCellsOnlyNoOffset
- def Size: Int
- def Slot(slot: Int): EquipmentSlot
Get whatever is stowed in the inventory at the given index.
Get whatever is stowed in the inventory at the given index.
- slot
the cell index
- returns
an
EquipmentSlot
that contains whateverEquipment
was stored inslot
- Definition Classes
- GridInventory → Container
- def SlotMapResolution(slot: Int): Int
When the slot reported is not the slot requested, change the slot.
When the slot reported is not the slot requested, change the slot.
- slot
the original slot index
- returns
the modified slot index
- Definition Classes
- Container
- def TotalCapacity: Int
The total number of cells in this inventory.
The total number of cells in this inventory.
- returns
the width multiplied by the height (
grid.length
, which is the same thing)
- def VisibleSlots: Set[Int]
A(n imperfect) reference to a generalized pool of the contained objects.
Having access to all of the available positions is not required.A(n imperfect) reference to a generalized pool of the contained objects.
Having access to all of the available positions is not required. Only the positions that can be actively viewed by other clients are listed.- returns
all of the affected slot indices
- Definition Classes
- GridInventory → Container
- See also
Inventory
- def Width: Int
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hasItem(guid: PlanetSideGUID): Option[Equipment]
Does this inventory contain an object with the given GUID?
Does this inventory contain an object with the given GUID?
- guid
the GUID
- returns
the discovered object, or
None
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()