Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds missing spawn events for items #74

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ class Inventory extends Map {
newItem.hydrate(state, def);
this.set(uuid, newItem);
state.ItemManager.add(newItem);
/**
* @event Item#spawn
*/
newItem.emit('spawn');
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ class Item extends GameEntity {
newItem.hydrate(state);
state.ItemManager.add(newItem);
this.addItem(newItem);
/**
* @event Item#spawn
*/
newItem.emit('spawn');
});
}

Expand Down
10 changes: 9 additions & 1 deletion src/Npc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Npc extends Scriptable(Character) {
this.defaultEquipment = data.equipment || {};
this.defaultItems = data.items || [];
this.description = data.description;
this.entityReference = data.entityReference;
this.entityReference = data.entityReference;
this.id = data.id;
this.keywords = data.keywords;
this.quests = data.quests || [];
Expand Down Expand Up @@ -89,6 +89,10 @@ class Npc extends Scriptable(Character) {
newItem.hydrate(state);
state.ItemManager.add(newItem);
this.addItem(newItem);
/**
* @event Item#spawn
*/
newItem.emit('spawn');
}

for (let [slot, defaultEqId] of Object.entries(this.defaultEquipment)) {
Expand All @@ -97,6 +101,10 @@ class Npc extends Scriptable(Character) {
newItem.hydrate(state);
state.ItemManager.add(newItem);
this.equip(newItem, slot);
/**
* @event Item#spawn
*/
newItem.emit('spawn');
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ class Player extends Character {
newItem.hydrate(state, itemDef);
state.ItemManager.add(newItem);
this.equip(newItem, slot);
/**
* @event Item#spawn
*/
newItem.emit('spawn');
} catch (e) {
Logger.error(e.message);
}
Expand Down