Improve variable names
This commit is contained in:
parent
34b9d318a3
commit
cdb5baac4b
@ -159,25 +159,26 @@ export class BotWeaponGeneratorHelper
|
|||||||
* TODO - move into BotGeneratorHelper, this is not the class for it
|
* TODO - move into BotGeneratorHelper, this is not the class for it
|
||||||
* Adds an item with all its children into specified equipmentSlots, wherever it fits.
|
* Adds an item with all its children into specified equipmentSlots, wherever it fits.
|
||||||
* @param equipmentSlots Slot to add item+children into
|
* @param equipmentSlots Slot to add item+children into
|
||||||
* @param parentId
|
* @param rootItemId Root item id to use as mod items parentid
|
||||||
* @param parentTpl
|
* @param rootItemTplId Root itms tpl id
|
||||||
* @param itemWithChildren Item to add
|
* @param itemWithChildren Item to add
|
||||||
* @param inventory Inventory to add item+children into
|
* @param inventory Inventory to add item+children into
|
||||||
* @returns a `boolean` indicating item was added
|
* @returns ItemAddedResult result object
|
||||||
*/
|
*/
|
||||||
public addItemWithChildrenToEquipmentSlot(
|
public addItemWithChildrenToEquipmentSlot(
|
||||||
equipmentSlots: string[],
|
equipmentSlots: string[],
|
||||||
parentId: string,
|
rootItemId: string,
|
||||||
parentTpl: string,
|
rootItemTplId: string,
|
||||||
itemWithChildren: Item[],
|
itemWithChildren: Item[],
|
||||||
inventory: Inventory,
|
inventory: Inventory,
|
||||||
): ItemAddedResult
|
): ItemAddedResult
|
||||||
{
|
{
|
||||||
|
/** Track how many containers are unable to be found */
|
||||||
let missingContainerCount = 0;
|
let missingContainerCount = 0;
|
||||||
for (const slot of equipmentSlots)
|
for (const equipmentSlotId of equipmentSlots)
|
||||||
{
|
{
|
||||||
// Get container to put item into
|
// Get container to put item into
|
||||||
const container = inventory.items.find((item) => item.slotId === slot);
|
const container = inventory.items.find((item) => item.slotId === equipmentSlotId);
|
||||||
if (!container)
|
if (!container)
|
||||||
{
|
{
|
||||||
missingContainerCount++;
|
missingContainerCount++;
|
||||||
@ -214,7 +215,7 @@ export class BotWeaponGeneratorHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get x/y grid size of item
|
// Get x/y grid size of item
|
||||||
const itemSize = this.inventoryHelper.getItemSize(parentTpl, parentId, itemWithChildren);
|
const itemSize = this.inventoryHelper.getItemSize(rootItemTplId, rootItemId, itemWithChildren);
|
||||||
|
|
||||||
// Iterate over each grid in the container and look for a big enough space for the item to be placed in
|
// Iterate over each grid in the container and look for a big enough space for the item to be placed in
|
||||||
let currentGridCount = 1;
|
let currentGridCount = 1;
|
||||||
@ -228,7 +229,7 @@ export class BotWeaponGeneratorHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Can't put item type in grid, skip all grids as we're assuming they have the same rules
|
// Can't put item type in grid, skip all grids as we're assuming they have the same rules
|
||||||
if (!this.itemAllowedInContainer(slotGrid, parentTpl))
|
if (!this.itemAllowedInContainer(slotGrid, rootItemTplId))
|
||||||
{
|
{
|
||||||
// Only one possible slot and item is incompatible, exit function and inform caller
|
// Only one possible slot and item is incompatible, exit function and inform caller
|
||||||
if (equipmentSlots.length === 1)
|
if (equipmentSlots.length === 1)
|
||||||
@ -272,7 +273,7 @@ export class BotWeaponGeneratorHelper
|
|||||||
// Open slot found, add item to inventory
|
// Open slot found, add item to inventory
|
||||||
if (findSlotResult.success)
|
if (findSlotResult.success)
|
||||||
{
|
{
|
||||||
const parentItem = itemWithChildren.find((i) => i._id === parentId);
|
const parentItem = itemWithChildren.find((i) => i._id === rootItemId);
|
||||||
|
|
||||||
// Set items parent to container id
|
// Set items parent to container id
|
||||||
parentItem.parentId = container._id;
|
parentItem.parentId = container._id;
|
||||||
|
Loading…
Reference in New Issue
Block a user