improve feature resolution, robustness of currency settings, and initialization logic
This commit is contained in:
parent
8975a13f99
commit
e12ac35855
3 changed files with 72 additions and 18 deletions
|
|
@ -43,6 +43,15 @@ export async function loadIkonisFeatures() {
|
|||
console.log(`DH-Ikonis | Cache size: ${_featureCache.size}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Robust feature fetching. Tries cache first, then async fromUuid.
|
||||
*/
|
||||
export async function getAttachedFeature(uuid) {
|
||||
if (!uuid) return null;
|
||||
if (_featureCache.has(uuid)) return _featureCache.get(uuid);
|
||||
return await fromUuid(uuid);
|
||||
}
|
||||
|
||||
export function getSlotCount(item) {
|
||||
const flags = item.getFlag('dh-ikonis') || {};
|
||||
if (typeof flags.slotOverride === "number") return flags.slotOverride;
|
||||
|
|
@ -121,15 +130,27 @@ export function patchDhCharacter(DhCharacter) {
|
|||
|
||||
if (!this.parent) return lists;
|
||||
|
||||
for (const item of this.parent.items) {
|
||||
if (item.type !== 'weapon' || !item.system.equipped) continue;
|
||||
const weapons = this.parent.items.filter(i => i.type === 'weapon');
|
||||
if (weapons.length > 0) {
|
||||
console.log(`DH-Ikonis | Checking ${weapons.length} weapons on ${this.parent.name} for augments...`);
|
||||
}
|
||||
|
||||
for (const item of weapons) {
|
||||
if (!item.system.equipped) continue;
|
||||
|
||||
const installedIds = item.getFlag('dh-ikonis', 'installedAugments') || [];
|
||||
const bondedUuid = item.getFlag('dh-ikonis', 'bondedFeatureUuid');
|
||||
|
||||
if (bondedUuid) {
|
||||
const feature = _featureCache.get(bondedUuid) || fromUuidSync(bondedUuid);
|
||||
if (feature) ikonisFeatures.push(feature);
|
||||
if (feature) {
|
||||
ikonisFeatures.push(feature);
|
||||
console.log(`DH-Ikonis | Resolved bonded feature: ${feature.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (installedIds.length > 0) {
|
||||
console.log(`DH-Ikonis | Found ${installedIds.length} installed augments on ${item.name}`);
|
||||
}
|
||||
|
||||
const allAugs = getAugments();
|
||||
|
|
@ -138,7 +159,10 @@ export function patchDhCharacter(DhCharacter) {
|
|||
if (!aug?.featureUuid) continue;
|
||||
|
||||
const feature = _featureCache.get(aug.featureUuid) || fromUuidSync(aug.featureUuid);
|
||||
if (feature) ikonisFeatures.push(feature);
|
||||
if (feature) {
|
||||
ikonisFeatures.push(feature);
|
||||
console.log(`DH-Ikonis | Resolved augment feature: ${feature.name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue