region work
This commit is contained in:
@@ -993,7 +993,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
float regionHeightOffset = 0;
|
||||
if(region != null){
|
||||
this.region = region;
|
||||
regionHeightOffset = region.lerpY(this);
|
||||
regionHeightOffset = region.lerpY(this.loc);
|
||||
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;
|
||||
|
||||
@@ -179,7 +179,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
if (region.center.y == region.highLerp.y)
|
||||
worldObject.loc = worldObject.loc.setY(region.center.y + worldObject.getAltitude());
|
||||
else
|
||||
worldObject.loc = worldObject.loc.setY(region.lerpY(worldObject) + worldObject.getAltitude());
|
||||
worldObject.loc = worldObject.loc.setY(region.lerpY(worldObject.loc) + worldObject.getAltitude());
|
||||
|
||||
return region;
|
||||
}
|
||||
@@ -504,7 +504,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
this.loc = loc;
|
||||
|
||||
if(this instanceof AbstractCharacter && this.region != null){
|
||||
this.loc = this.loc.setY(this.region.lerpY(this) + this.getAltitude());
|
||||
this.loc = this.loc.setY(this.region.lerpY(this.loc) + this.getAltitude());
|
||||
} else{
|
||||
this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude());
|
||||
}
|
||||
|
||||
@@ -4828,7 +4828,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
if (this.landingRegion != null) {
|
||||
this.altitude = 0;
|
||||
this.region = this.landingRegion;
|
||||
this.loc = this.loc.setY(this.landingRegion.lerpY(this));
|
||||
this.loc = this.loc.setY(this.landingRegion.lerpY(this.loc));
|
||||
} else
|
||||
this.altitude = this.getDesiredAltitude();
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ public class Regions {
|
||||
boolean movingUp = false;
|
||||
|
||||
boolean movingDown = false;
|
||||
float yLerp = worldObject.region.lerpY(worldObject);
|
||||
float yLerp = worldObject.region.lerpY(worldObject.loc);
|
||||
|
||||
if (yLerp == (worldObject.region.highLerp.y))
|
||||
movingUp = true;
|
||||
@@ -338,10 +338,10 @@ public class Regions {
|
||||
return inside;
|
||||
}
|
||||
|
||||
public float lerpY(AbstractWorldObject lerper) {
|
||||
public float lerpY(Vector3fImmutable lerper) {
|
||||
|
||||
Vector3fImmutable lengthVector = this.highLerp.subtract2D(this.lowLerp);
|
||||
Vector3fImmutable characterVector = lerper.getLoc().subtract2D(this.lowLerp);
|
||||
Vector3fImmutable characterVector = lerper.subtract2D(this.lowLerp);
|
||||
float lengthVectorMagnitude = lengthVector.magnitude();
|
||||
float characterVectorMagnitude = characterVector.magnitude();
|
||||
float percentDistance = characterVectorMagnitude / lengthVectorMagnitude;
|
||||
|
||||
Reference in New Issue
Block a user