diff options
Diffstat (limited to 'features')
-rw-r--r-- | features/dungeonSolvers/index.js | 2 | ||||
-rw-r--r-- | features/waypoints/index.js | 39 |
2 files changed, 24 insertions, 17 deletions
diff --git a/features/dungeonSolvers/index.js b/features/dungeonSolvers/index.js index 5088e75..f7d8e49 100644 --- a/features/dungeonSolvers/index.js +++ b/features/dungeonSolvers/index.js @@ -67,7 +67,7 @@ class DungeonSolvers extends Feature { .setLocationSetting(new LocationSetting("Run speed and exp rates location", "Allows you to edit the location of the information", "run_speed_rates_location", this, [10, 100, 1, 1]).requires(this.runSpeedRates).editTempText("&6Run speed&7> &f4:30\n&6Exp/hour&7> &f1,234,567\n&6Runs/hour&7> &f17")); this.scoreCalculation = new ToggleSetting("Show score calculation", "NOTE: doesent include mimic or spirit pet yet", true, "run_score_calc", this); - this.scoreElement = new HudTextElement().setToggleSetting(this.scoreCalculation).setLocationSetting(new LocationSetting("Score calculation location", "Allows you to edit the location of the score calc", "score_calc_location", this, [10, 130, 1, 1]).requires(this.scoreCalculation).editTempText("Editing temp text here")); + this.scoreElement = new HudTextElement().setToggleSetting(this.scoreCalculation).setLocationSetting(new LocationSetting("Score calculation location", "Allows you to edit the location of the score calc", "score_calc_location", this, [10, 130, 1, 1]).requires(this.scoreCalculation).editTempText("&dScore: 120\n&aS+ ??\n&aS ??")); this.hudElements.push(this.runSpeedRatesElement); this.hudElements.push(this.scoreElement); diff --git a/features/waypoints/index.js b/features/waypoints/index.js index 47806ec..d0d526d 100644 --- a/features/waypoints/index.js +++ b/features/waypoints/index.js @@ -21,8 +21,10 @@ class Waypoints extends Feature { new SettingBase("/savewaypoints", "Copys the waypoints to your clipboard", undefined, "save_waypoints", this) new SettingBase("/loadwaypoints", "Loads waypoints from your clipboard", undefined, "load_waypoints", this) - this.waypoints = [] this.userWaypoints = JSON.parse(FileLib.read("soopyAddonsData", "soopyv2userwaypoints.json") || "{}") + this.userWaypointsHash = {} + this.userWaypointsAll = [] + this.updateWaypointsHashes() this.userWaypointsArr = Object.values(this.userWaypoints) this.waypointsChanged = false @@ -57,6 +59,7 @@ class Waypoints extends Feature { this.userWaypointsArr = Object.values(this.userWaypoints) this.waypointsChanged = true + this.updateWaypointsHashes() ChatLib.chat(this.FeatureManager.messagePrefix + "Added waypoint " + name + "!") }) @@ -64,12 +67,14 @@ class Waypoints extends Feature { delete this.userWaypoints[name] this.userWaypointsArr = Object.values(this.userWaypoints) this.waypointsChanged = true + this.updateWaypointsHashes() ChatLib.chat(this.FeatureManager.messagePrefix + "Deleted waypoint " + name + "!") }) this.registerCommand("clearwaypoints", () => { this.userWaypoints = {} this.userWaypointsArr = [] this.waypointsChanged = true + this.updateWaypointsHashes() ChatLib.chat(this.FeatureManager.messagePrefix + "Cleared waypoints!") }) this.registerCommand("savewaypoints", () => { @@ -82,6 +87,7 @@ class Waypoints extends Feature { this.userWaypointsArr = Object.values(this.userWaypoints) this.waypointsChanged = true + this.updateWaypointsHashes() ChatLib.chat(this.FeatureManager.messagePrefix + "Loaded waypoints from clipboard!") } catch (e) { ChatLib.chat(this.FeatureManager.messagePrefix + "Error loading from clipboard!") @@ -89,31 +95,32 @@ class Waypoints extends Feature { }) } - addWaypoint(x, y, z, r, g, b, options) { - this.waypoints.push({ - x: x, - y: y, - z: z, - r: r, - g: g, - b: b, - options: options - }) + updateWaypointsHashes() { + this.userWaypointsAll = [] + this.userWaypointsHash = {} + for (let waypoint of this.userWaypointsArr) { + if (!waypoint.area) { + this.userWaypointsAll.push(waypoint) + } else { + if (!this.userWaypointsHash[waypoint.area]) this.userWaypointsHash[waypoint.area] = [] + this.userWaypointsHash[waypoint.area].push(waypoint) + } + } } renderWorldLast() { - for (let waypoint of this.waypoints) { + for (let waypoint of this.userWaypointsAll) { drawCoolWaypoint(waypoint.x, waypoint.y, waypoint.z, waypoint.r, waypoint.g, waypoint.b, waypoint.options) } - for (let waypoint of this.userWaypointsArr) { //TODO: Performance optimisation: Make hash from waypoint.area -> waypoints[] - if (!waypoint.area || this.FeatureManager.features["dataLoader"].class.area === waypoint.area) { - drawCoolWaypoint(waypoint.x, waypoint.y, waypoint.z, waypoint.r, waypoint.g, waypoint.b, { ...waypoint.options }) + if (this.userWaypointsHash[this.FeatureManager.features["dataLoader"].class.area]) { + for (let waypoint of this.userWaypointsHash[this.FeatureManager.features["dataLoader"].class.area]) { + drawCoolWaypoint(waypoint.x, waypoint.y, waypoint.z, waypoint.r, waypoint.g, waypoint.b, waypoint.options) } } } initVariables() { - this.waypoints = undefined + } onDisable() { |