Browse Source

region assignment in AbstractCharacter.setLoc

magicbox-1.5.2
FatBoy-DOTC 1 year ago
parent
commit
6f990d488f
  1. 18
      src/engine/objects/AbstractCharacter.java

18
src/engine/objects/AbstractCharacter.java

@ -12,6 +12,7 @@ package engine.objects; @@ -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 { @@ -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();
}

Loading…
Cancel
Save