From 847e62dd27c166afac788cecaed078dbc24a8682 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 19:51:39 -0500 Subject: [PATCH] setLoc now handles region assignment --- src/engine/objects/AbstractCharacter.java | 12 ++++++++++-- src/engine/objects/AbstractWorldObject.java | 3 --- src/engine/objects/Mob.java | 4 ---- src/engine/objects/PlayerCharacter.java | 3 --- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index cbbb88f3..9a60e116 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -983,8 +983,16 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @Override public final void setLoc(final Vector3fImmutable value) { - super.setLoc(value); // set the location in the world - this.resetLastSetLocUpdate(); + Regions region = Regions.GetRegionForTeleport(value); + if(region != null){ + this.region = region; + Vector3fImmutable newValue = new Vector3fImmutable(value.x,region.lerpY(this),value.z); + super.setLoc(newValue); // set the location in the world + this.resetLastSetLocUpdate(); + } else { + super.setLoc(value); // set the location in the world + this.resetLastSetLocUpdate(); + } } public Vector3fImmutable getMovementLoc() { diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index 4525dc65..0ea3c6b4 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -610,9 +610,6 @@ public abstract class AbstractWorldObject extends AbstractGameObject { this.movingUp = movingUp; } - public void setRegion(Regions region) { - this.region = region; - } //used for interestmanager loading and unloading objects to client. // if not in grid, unload from player. diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 97c08b4c..311839ea 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -841,13 +841,11 @@ public class Mob extends AbstractIntelligenceAgent { if (newLoc.equals(this.getEndLoc())) { this.stopMovement(newLoc); - this.region = AbstractWorldObject.GetRegionByWorldObject(this); return; //Next upda } setLoc(newLoc); - this.region = AbstractWorldObject.GetRegionByWorldObject(this); //Next update will be end Loc, lets stop him here. } @@ -971,8 +969,6 @@ public class Mob extends AbstractIntelligenceAgent { if (this.building == null && this.guardCaptain != null && ((Mob) this.guardCaptain).behaviourType.equals(MobBehaviourType.GuardCaptain)) this.building = this.guardCaptain.building; - else if (this.building != null) - this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); this.loadInventory(); diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index cc09fd56..cd24f990 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4888,12 +4888,10 @@ public class PlayerCharacter extends AbstractCharacter { if (this.isAlive() == false || this.getBonuses().getBool(ModType.Stunned, SourceType.None) || this.getBonuses().getBool(ModType.CannotMove, SourceType.None)) { //Target is stunned or rooted. Don't move this.stopMovement(newLoc); - this.region = AbstractWorldObject.GetRegionByWorldObject(this); return; } if (newLoc.equals(this.getEndLoc())) { this.stopMovement(newLoc); - this.region = AbstractWorldObject.GetRegionByWorldObject(this); if (this.getDebug(1)) ChatManager.chatSystemInfo(this, "Arrived at End location. " + this.getEndLoc()); @@ -4902,7 +4900,6 @@ public class PlayerCharacter extends AbstractCharacter { } setLoc(newLoc); - this.region = AbstractWorldObject.GetRegionByWorldObject(this); if (this.getDebug(1)) ChatManager.chatSystemInfo(this,