mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Refactored mergeCamoraPool()
This commit is contained in:
parent
8a46d2c33d
commit
416ef74902
@ -1352,7 +1352,7 @@ export class BotEquipmentModGenerator
|
|||||||
{
|
{
|
||||||
modSlot = camoraFirstSlot;
|
modSlot = camoraFirstSlot;
|
||||||
exhaustableModPool = new ExhaustableArray(
|
exhaustableModPool = new ExhaustableArray(
|
||||||
this.mergeCamoraPoolsTogether(itemModPool),
|
this.mergeCamoraPools(itemModPool),
|
||||||
this.randomUtil,
|
this.randomUtil,
|
||||||
this.cloner,
|
this.cloner,
|
||||||
);
|
);
|
||||||
@ -1383,36 +1383,29 @@ export class BotEquipmentModGenerator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const slot of parentTemplate._props.Slots)
|
for (const slot of cylinderMagTemplate._props.Slots)
|
||||||
{
|
{
|
||||||
const modSlotId = slot._name;
|
const modSlotId = slot._name;
|
||||||
const modId = this.hashUtil.generate();
|
const modId = this.hashUtil.generate();
|
||||||
items.push({ _id: modId, _tpl: modTpl, parentId: parentId, slotId: modSlotId });
|
items.push({ _id: modId, _tpl: modTpl, parentId: cylinderMagParentId, slotId: modSlotId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take a record of camoras and merge the compatible shells into one array
|
* Take a record of camoras and merge the compatible shells into one array
|
||||||
* @param camorasWithShells camoras we want to merge into one array
|
* @param camorasWithShells Dictionary of camoras we want to merge into one array
|
||||||
* @returns string array of shells for multiple camora sources
|
* @returns String array of shells for multiple camora sources
|
||||||
*/
|
*/
|
||||||
protected mergeCamoraPoolsTogether(camorasWithShells: Record<string, string[]>): string[]
|
protected mergeCamoraPools(camorasWithShells: Record<string, string[]>): string[]
|
||||||
{
|
{
|
||||||
const poolResult: string[] = [];
|
const uniqueShells = new Set<string>();
|
||||||
for (const camoraKey in camorasWithShells)
|
for (const shells of Object.values(camorasWithShells))
|
||||||
{
|
{
|
||||||
const shells = camorasWithShells[camoraKey];
|
// Add all shells to the set.
|
||||||
for (const shell of shells)
|
shells.forEach((shell) => uniqueShells.add(shell));
|
||||||
{
|
|
||||||
// Only add distinct shells
|
|
||||||
if (!poolResult.includes(shell))
|
|
||||||
{
|
|
||||||
poolResult.push(shell);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return poolResult;
|
return Array.from(uniqueShells);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user