From 6f990d488f339b89b549cf1cf8a4b2643a21e8e0 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 13:41:18 -0500 Subject: [PATCH] region assignment in AbstractCharacter.setLoc --- src/engine/objects/AbstractCharacter.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 7834b0cb..f778755a 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -12,6 +12,7 @@ package engine.objects; import engine.Enum; import engine.Enum.*; import engine.InterestManagement.InterestManager; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.exception.SerializationException; import engine.gameManager.*; @@ -985,11 +986,22 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @Override public final void setLoc(final Vector3fImmutable value) { Regions region = Regions.GetRegionForTeleport(value); + float regionHeightOffset = 0; if(region != null){ this.region = region; - } - - super.setLoc(value); // set the location in the world + regionHeightOffset = region.lerpY(this); + this.inBuilding = region.level; // -1 not in building 0 on ground floor, 1 on first floor etc + this.inBuildingID = region.parentBuildingID; + this.inFloorID = region.room; + } else { + this.region = null; + this.inBuilding = -1; + this.inBuildingID = 0; + this.inFloorID = -1; + } + float terrainHeight = Terrain.getWorldHeight(value); + Vector3fImmutable finalLocation = new Vector3fImmutable(value.x,terrainHeight + regionHeightOffset, value.z); + super.setLoc(finalLocation); // set the location in the world this.resetLastSetLocUpdate(); }