net.psforever.objects.inventory
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.
the number of free cells
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.
the cell index to test this Equipment
for insertion
the width of the Equipment
to be tested
the height of the Equipment
to be tested
a List
of GUID values for all existing contents that this item would overlap if inserted
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.
the cell index to test this Equipment
for insertion
the Equipment
to be tested
a List
of GUID values for all existing contents that this item would overlap if inserted
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.
the cell index to test this Equipment
for insertion
the width of the Equipment
to be tested
the height of the Equipment
to be tested
a List
of existing items that an item of this scale would overlap if inserted
IndexOutOfBoundsException
if the region extends outside of the grid boundaries
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.
the cell index to test this Equipment
for insertion
the width of the Equipment
to be tested
the height of the Equipment
to be tested
a List
of existing items that an item of this scale would overlap if inserted
IndexOutOfBoundsException
if the region extends outside of the grid boundaries
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.
the cell index to test this Equipment
for insertion
the width of the Equipment
to be tested
the height of the Equipment
to be tested
a List
of existing items that an item of this scale would overlap if inserted
Clear the inventory by removing all of its items.
Clear the inventory by removing all of its items.
a List
of the previous items in the inventory as their InventoryItemData
tiles
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.)
the position to start searching
the width of the searchable space
the height of the serachable space
a list of objects that have been encountered within the searchable space
GridInventory.CheckCollisionsVar
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.
the GUID of the Equipment
the index of the EquipmentSlot
, or None
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.
the Equipment
object
the index of the EquipmentSlot
, or None
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.
the dimensions of the blank space
the grid index of the upper left corner where equipment to which the tile
belongs should be placed
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
.
VisibleSlots
The index of the last cell in this inventory.
The index of the last cell in this inventory.
same as Offset
plus the total number of cells in this inventory minus 1
Change the grid index offset value.
Change the grid index offset value.
the new offset value
the current offset value
IndexOutOfBoundsException
if the index is negative
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
.
the new width
the new height
IllegalArgumentException
if the new size to be set is zero or less
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.
the initial inventory index
the width of the region
the height of the region
the value to set all the cells in the defined region; defaults to -1 (which is "nothing")
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.
the initial inventory index, without the inventory offset (required)
the width of the region
the height of the region
the value to set all the cells in the defined region; defaults to -1 (which is "nothing")
IndexOutOfBoundsException
if the region extends outside of the grid boundaries
Get whatever is stowed in the inventory at the given index.
Get whatever is stowed in the inventory at the given index.
the cell index
an EquipmentSlot
that contains whatever Equipment
was stored in slot
The total number of cells in this inventory.
The total number of cells in this inventory.
the width multiplied by the height (grid.length
, which is the same thing)
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.
all of the affected slot indices
Inventory
Does this inventory contain an object with the given GUID?
Does this inventory contain an object with the given GUID?
the GUID
the discovered object, or None
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 theHashMap
only is hitherto referred as "using the inventory as aList
." TheArray
of spatial GUIDs is used for quick collision lookup. Use of theArray
only is hitherto referred as "using the inventory as a grid."