Skip to content

Commit f799ebb

Browse files
committed
Adding an extra null check for the new API method
1 parent c23939b commit f799ebb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/game-engine/world/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,13 @@ export class World {
149149
* @param objectPosition The position of the copied object to find the template of.
150150
*/
151151
public findCustomMapObject(actor: Actor, objectId: number, objectPosition: Position): LandscapeObject | null {
152+
const map = actor?.metadata?.customMap as ConstructedMap || null;
153+
154+
if(!map) {
155+
return null;
156+
}
157+
152158
const objectChunk = this.chunkManager.getChunkForWorldPosition(objectPosition);
153-
const map = actor.metadata.customMap as ConstructedMap;
154159
const mapChunk = world.chunkManager.getChunkForWorldPosition(map.position);
155160

156161
const chunkIndexX = objectChunk.position.x - (mapChunk.position.x - 2);

0 commit comments

Comments
 (0)