Class/Object

net.psforever.objects.inventory

GridInventory

Related Docs: object GridInventory | package inventory

Permalink

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
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new GridInventory()

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from GridInventory to any2stringadd[GridInventory] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def +=(kv: (Int, Equipment)): Boolean

    Permalink
  5. def -=(guid: PlanetSideGUID): Boolean

    Permalink
  6. def -=(index: Int): Boolean

    Permalink
  7. def ->[B](y: B): (GridInventory, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from GridInventory to ArrowAssoc[GridInventory] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  8. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def Capacity: Int

    Permalink

    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

  10. def CheckCollisions(start: Int, w: Int, h: Int): Try[List[Int]]

    Permalink

    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

  11. def CheckCollisions(start: Int, item: Equipment): Try[List[Int]]

    Permalink

    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 gridkeeps 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

  12. def CheckCollisionsAsGrid(start: Int, w: Int, h: Int): Try[List[InventoryItem]]

    Permalink

    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

  13. def CheckCollisionsAsList(start: Int, w: Int, h: Int): Try[List[InventoryItem]]

    Permalink

    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

  14. def CheckCollisionsVar(start: Int, w: Int, h: Int): Try[List[InventoryItem]]

    Permalink

    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

  15. def Clear(): List[InventoryItem]

    Permalink

    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

  16. def Collisions(index: Int, width: Int, height: Int): Try[List[InventoryItem]]

    Permalink

    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

  17. def Find(guid: PlanetSideGUID): Option[Int]

    Permalink

    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]

    Permalink

    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]

    Permalink

    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]

    Permalink
    Definition Classes
    Container
  21. def Height: Int

    Permalink
  22. def Insert(start: Int, obj: Equipment): Boolean

    Permalink
  23. def InsertQuickly(start: Int, obj: Equipment): Boolean

    Permalink
  24. def Insertion_CheckCollisions(start: Int, obj: Equipment, key: Int): Boolean

    Permalink
  25. def Inventory: GridInventory

    Permalink

    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]

    Permalink
  27. def LastIndex: Int

    Permalink

    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

    Permalink
  29. def Offset_=(fset: Int): Int

    Permalink

    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

    Permalink
  31. def Remove(index: Int): Boolean

    Permalink
  32. def Resize(w: Int, h: Int): Unit

    Permalink

    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

    Permalink

    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")

  34. def SetCellsOffset(start: Int, w: Int, h: Int, value: Int = 1): Unit

    Permalink

    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, 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")

    Exceptions thrown

    IndexOutOfBoundsException if the region extends outside of the grid boundaries

  35. def Size: Int

    Permalink
  36. def Slot(slot: Int): EquipmentSlot

    Permalink

    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 TotalCapacity: Int

    Permalink

    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)

  38. def VisibleSlots: Set[Int]

    Permalink

    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

  39. def Width: Int

    Permalink
  40. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  41. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. def ensuring(cond: (GridInventory) ⇒ Boolean, msg: ⇒ Any): GridInventory

    Permalink
    Implicit information
    This member is added by an implicit conversion from GridInventory to Ensuring[GridInventory] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  43. def ensuring(cond: (GridInventory) ⇒ Boolean): GridInventory

    Permalink
    Implicit information
    This member is added by an implicit conversion from GridInventory to Ensuring[GridInventory] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  44. def ensuring(cond: Boolean, msg: ⇒ Any): GridInventory

    Permalink
    Implicit information
    This member is added by an implicit conversion from GridInventory to Ensuring[GridInventory] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  45. def ensuring(cond: Boolean): GridInventory

    Permalink
    Implicit information
    This member is added by an implicit conversion from GridInventory to Ensuring[GridInventory] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  46. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  47. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  48. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  49. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from GridInventory to StringFormat[GridInventory] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  50. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  51. def hasItem(guid: PlanetSideGUID): Option[Equipment]

    Permalink

    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

  52. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  53. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  54. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  55. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  56. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  57. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  58. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  59. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  60. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  61. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  62. def [B](y: B): (GridInventory, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from GridInventory to ArrowAssoc[GridInventory] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from Container

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from GridInventory to any2stringadd[GridInventory]

Inherited by implicit conversion StringFormat from GridInventory to StringFormat[GridInventory]

Inherited by implicit conversion Ensuring from GridInventory to Ensuring[GridInventory]

Inherited by implicit conversion ArrowAssoc from GridInventory to ArrowAssoc[GridInventory]

Ungrouped