Small optimisations applied to reateRandomLoot()
This commit is contained in:
parent
80fdaf65e6
commit
13ce200f80
@ -106,11 +106,14 @@ export class LootGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
const globalDefaultPresets = Object.values(this.presetHelper.getDefaultPresets());
|
const globalDefaultPresets = Object.values(this.presetHelper.getDefaultPresets());
|
||||||
|
const itemBlacklistArray = Array.from(itemBlacklist);
|
||||||
|
|
||||||
// Filter default presets to just weapons
|
// Filter default presets to just weapons
|
||||||
const weaponDefaultPresets = globalDefaultPresets.filter(preset => this.itemHelper.isOfBaseclass(preset._encyclopedia, BaseClasses.WEAPON));
|
|
||||||
const randomisedWeaponPresetCount = this.randomUtil.getInt(options.weaponPresetCount.min, options.weaponPresetCount.max);
|
const randomisedWeaponPresetCount = this.randomUtil.getInt(options.weaponPresetCount.min, options.weaponPresetCount.max);
|
||||||
const itemBlacklistArray = Array.from(itemBlacklist);
|
if (randomisedWeaponPresetCount > 0)
|
||||||
|
{
|
||||||
|
const weaponDefaultPresets = globalDefaultPresets.filter(preset => this.itemHelper.isOfBaseclass(preset._encyclopedia, BaseClasses.WEAPON));
|
||||||
|
|
||||||
for (let index = 0; index < randomisedWeaponPresetCount; index++)
|
for (let index = 0; index < randomisedWeaponPresetCount; index++)
|
||||||
{
|
{
|
||||||
if (!this.findAndAddRandomPresetToLoot(weaponDefaultPresets, itemTypeCounts, itemBlacklistArray, result))
|
if (!this.findAndAddRandomPresetToLoot(weaponDefaultPresets, itemTypeCounts, itemBlacklistArray, result))
|
||||||
@ -118,11 +121,15 @@ export class LootGenerator
|
|||||||
index--;
|
index--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Filter default presets to just armors and then filter again by protection level
|
// Filter default presets to just armors and then filter again by protection level
|
||||||
|
const randomisedArmorPresetCount = this.randomUtil.getInt(options.armorPresetCount.min, options.armorPresetCount.max);
|
||||||
|
if (randomisedArmorPresetCount > 0)
|
||||||
|
{
|
||||||
const armorDefaultPresets = globalDefaultPresets.filter(preset => this.itemHelper.armorItemCanHoldMods(preset._encyclopedia));
|
const armorDefaultPresets = globalDefaultPresets.filter(preset => this.itemHelper.armorItemCanHoldMods(preset._encyclopedia));
|
||||||
const levelFilteredArmorPresets = armorDefaultPresets.filter(armor => this.armorIsDesiredProtectionLevel(armor, options));
|
const levelFilteredArmorPresets = armorDefaultPresets.filter(armor => this.armorIsDesiredProtectionLevel(armor, options));
|
||||||
const randomisedArmorPresetCount = this.randomUtil.getInt(options.armorPresetCount.min, options.armorPresetCount.max);
|
|
||||||
for (let index = 0; index < randomisedArmorPresetCount; index++)
|
for (let index = 0; index < randomisedArmorPresetCount; index++)
|
||||||
{
|
{
|
||||||
if (!this.findAndAddRandomPresetToLoot(levelFilteredArmorPresets, itemTypeCounts, itemBlacklistArray, result))
|
if (!this.findAndAddRandomPresetToLoot(levelFilteredArmorPresets, itemTypeCounts, itemBlacklistArray, result))
|
||||||
@ -130,6 +137,7 @@ export class LootGenerator
|
|||||||
index--;
|
index--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user