Skip to content

Commit

Permalink
feat: Support dynamic NPCs in Map view.
Browse files Browse the repository at this point in the history
  • Loading branch information
elondaits committed Jul 2, 2024
1 parent c006a66 commit cfa59bb
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39956,6 +39956,35 @@ class MapApp {
});
}

ensureNpcHidden(id) {
const view = this.npcViews[id];
if (view && view.isVisible()) {
view.hide();
}
}

ensureNpcVisible(id) {
const view = this.npcViews[id];
if (view && !view.isVisible()) {
view.show();
}
}

updateNpcs() {
const storyline = this.config.storylines[this.storylineId];
Object.entries(storyline.npcs || {}).forEach(([id, props]) => {
// If the npc has a cond property, evaluate it
if (props.cond) {
const conditionMet = this.questTracker.isConditionMet(props.cond);
if (conditionMet) {
this.ensureNpcVisible(id);
} else {
this.ensureNpcHidden(id);
}
}
});
}

addMarker(character, icon) {
const marker = new MapMarker(
this.textures['map-markers'].textures['pin-marker'],
Expand Down Expand Up @@ -43608,6 +43637,7 @@ const MapApp = __webpack_require__(/*! ./lib/app/map-app */ "./src/js/lib/app/ma
});
if (flagsChanged) {
mapApp.updateQuestMarkers();
mapApp.updateNpcs();
}
}
});
Expand All @@ -43632,4 +43662,4 @@ const MapApp = __webpack_require__(/*! ./lib/app/map-app */ "./src/js/lib/app/ma

/******/ })()
;
//# sourceMappingURL=map.6cd3a6e36592efd8b8f2.js.map
//# sourceMappingURL=map.1149f43f94574738da24.js.map
1 change: 1 addition & 0 deletions assets/map.1149f43f94574738da24.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion assets/map.6cd3a6e36592efd8b8f2.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion map.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/><meta name="apple-mobile-web-app-title" content="CQ Map"/><title>Map | Citizen Quest</title><link rel="icon" type="image/png" href="static/ui/favicon.png"><link rel="stylesheet" href="vendor/bootstrap-v5.2.3/bootstrap.min.css"><script src="vendor/jquery-v3.6.4/jquery-3.6.4.min.js"></script><script src="vendor/bootstrap-v5.2.3/bootstrap.bundle.min.js"></script><script src="vendor/pixi-v7.2.4/pixi-legacy.min.js"></script><script src="vendor/tween.js-v20.0.0/tween.umd.js"></script><meta name="title" content="Map | Citizen Quest"><meta name="description" content="A game about the future of democracy"><script defer="defer" src="assets/map.6cd3a6e36592efd8b8f2.js"></script><link href="assets/map.8490b0dcb785b8f4be5a.css" rel="stylesheet"></head><body><div data-component="MapApp"></div></body>
<!doctype html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/><meta name="apple-mobile-web-app-title" content="CQ Map"/><title>Map | Citizen Quest</title><link rel="icon" type="image/png" href="static/ui/favicon.png"><link rel="stylesheet" href="vendor/bootstrap-v5.2.3/bootstrap.min.css"><script src="vendor/jquery-v3.6.4/jquery-3.6.4.min.js"></script><script src="vendor/bootstrap-v5.2.3/bootstrap.bundle.min.js"></script><script src="vendor/pixi-v7.2.4/pixi-legacy.min.js"></script><script src="vendor/tween.js-v20.0.0/tween.umd.js"></script><meta name="title" content="Map | Citizen Quest"><meta name="description" content="A game about the future of democracy"><script defer="defer" src="assets/map.1149f43f94574738da24.js"></script><link href="assets/map.8490b0dcb785b8f4be5a.css" rel="stylesheet"></head><body><div data-component="MapApp"></div></body>
29 changes: 29 additions & 0 deletions src/js/lib/app/map-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,35 @@ class MapApp {
});
}

ensureNpcHidden(id) {
const view = this.npcViews[id];
if (view && view.isVisible()) {
view.hide();
}
}

ensureNpcVisible(id) {
const view = this.npcViews[id];
if (view && !view.isVisible()) {
view.show();
}
}

updateNpcs() {
const storyline = this.config.storylines[this.storylineId];
Object.entries(storyline.npcs || {}).forEach(([id, props]) => {
// If the npc has a cond property, evaluate it
if (props.cond) {
const conditionMet = this.questTracker.isConditionMet(props.cond);
if (conditionMet) {
this.ensureNpcVisible(id);
} else {
this.ensureNpcHidden(id);
}
}
});
}

addMarker(character, icon) {
const marker = new MapMarker(
this.textures['map-markers'].textures['pin-marker'],
Expand Down
1 change: 1 addition & 0 deletions src/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const MapApp = require('./lib/app/map-app');
});
if (flagsChanged) {
mapApp.updateQuestMarkers();
mapApp.updateNpcs();
}
}
});
Expand Down

0 comments on commit cfa59bb

Please sign in to comment.