Packages

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
Linear Supertypes
Container, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. GridInventory
  2. Container
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new GridInventory()

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +=(kv: (Int, Equipment)): Boolean
  4. def -=(guid: PlanetSideGUID): Boolean
  5. def -=(index: Int): Boolean
  6. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  7. 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

  8. 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

  9. 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

  10. 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

  11. 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 a List" 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

  12. 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

  13. 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 their InventoryItemData tiles

  14. 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 of Equipment being stowed in a GridInventory.

    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 of Equipment being stowed in a GridInventory. Where the Equipment object is defined by the dimensions width and height, starting a search at index 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 normal EquipmentSlot 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

  15. 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

  16. 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

  17. 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 and Inventory, and wherever else, should be searchable.

    guid

    the GUID of the Equipment

    returns

    the index of the EquipmentSlot, or None

    Definition Classes
    GridInventoryContainer
  18. 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 and Inventory, and wherever else, should be searchable.

    obj

    the Equipment object

    returns

    the index of the EquipmentSlot, or None

    Definition Classes
    Container
  19. 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
    GridInventoryContainer
  20. def Fit(obj: Equipment): Option[Int]
    Definition Classes
    Container
  21. def Height: Int
  22. def Insert(start: Int, obj: Equipment): Boolean
  23. 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

  24. 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

  25. 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 of Container.

    Definition Classes
    GridInventoryContainer
    See also

    VisibleSlots

  26. def Items: List[InventoryItem]
  27. 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

  28. def Offset: Int
  29. 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

  30. def Remove(guid: PlanetSideGUID): Boolean
  31. def Remove(index: Int): Boolean
  32. 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 and Height.

    w

    the new width

    h

    the new height

    Exceptions thrown

    IllegalArgumentException if the new size to be set is zero or less

  33. 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

  34. 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

  35. def Size: Int
  36. 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 whatever Equipment was stored in slot

    Definition Classes
    GridInventoryContainer
  37. 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
  38. 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)

  39. 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
    GridInventoryContainer
    See also

    Inventory

  40. def Width: Int
  41. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  42. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  43. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  44. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  45. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  46. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  47. 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

  48. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  49. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  50. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  51. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  52. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  53. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  54. def toString(): String
    Definition Classes
    AnyRef → Any
  55. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  56. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  57. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Container

Inherited from AnyRef

Inherited from Any

Ungrouped