From 6027ccd68bdb54c1de17655b3c246fc4d5532973 Mon Sep 17 00:00:00 2001 From: Jonah Jeleniewski Date: Mon, 15 Jan 2024 18:57:27 +1100 Subject: [PATCH] Fix incorrect map coordinates for copy-pasted NPC & item spawns --- CHANGELOG.md | 4 ++++ src/core/state/entity-state.js | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4351f59..6efb217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Copy-pasted NPC and item spawns had incorrect map coordinates. + ## [1.2.0] - 2024-01-11 ### Added diff --git a/src/core/state/entity-state.js b/src/core/state/entity-state.js index 8f8f748..96fc6c1 100644 --- a/src/core/state/entity-state.js +++ b/src/core/state/entity-state.js @@ -45,12 +45,24 @@ export class EntityState { withX(x) { let copy = this.copy(); copy.x = x; + for (let npc of copy.npcs) { + npc.x = x; + } + for (let item of copy.items) { + item.x = x; + } return copy; } withY(y) { let copy = this.copy(); copy.y = y; + for (let npc of copy.npcs) { + npc.y = y; + } + for (let item of copy.items) { + item.y = y; + } return copy; }