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;
import engine.Enum; import engine.Enum;
import engine.Enum.*; import engine.Enum.*;
import engine.InterestManagement.InterestManager; import engine.InterestManagement.InterestManager;
import engine.InterestManagement.Terrain;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.exception.SerializationException; import engine.exception.SerializationException;
import engine.gameManager.*; import engine.gameManager.*;
@ -985,11 +986,22 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
@Override @Override
public final void setLoc(final Vector3fImmutable value) { public final void setLoc(final Vector3fImmutable value) {
Regions region = Regions.GetRegionForTeleport(value); Regions region = Regions.GetRegionForTeleport(value);
float regionHeightOffset = 0;
if(region != null){ if(region != null){
this.region = region; this.region = region;
} regionHeightOffset = region.lerpY(this);
this.inBuilding = region.level; // -1 not in building 0 on ground floor, 1 on first floor etc
super.setLoc(value); // set the location in the world 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(); this.resetLastSetLocUpdate();
} }

Loading…
Cancel
Save