From 7886aa6041d41f3aa0302d2846a8252509fbddf9 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 18 Oct 2023 18:45:50 -0500 Subject: [PATCH] building and region lookup completed --- src/engine/devcmd/cmds/RegionCmd.java | 14 +++++++++----- src/engine/gameManager/BuildingManager.java | 6 ++++-- src/engine/objects/AbstractCharacter.java | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index dbda7ae7..74da48fc 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -26,11 +26,13 @@ public class RegionCmd extends AbstractDevCmd { protected void _doCmd(PlayerCharacter pc, String[] words, AbstractGameObject target) { + String newline = "\r\n "; + String output; + output = "Target Region Information:" + newline; + Building building = BuildingManager.getBuildingAtLocation(((AbstractCharacter) target).loc); if(building == null){ this.throwbackInfo(pc, "No Building At This Location.") ; - } else{ - this.throwbackInfo(pc, "Building At Location: " + building.getName()); } Regions region = ((AbstractCharacter)target).region; if (region == null) { @@ -39,9 +41,11 @@ public class RegionCmd extends AbstractDevCmd { } if(region != null) { - this.throwbackInfo(pc, "Region Info: " + ((AbstractCharacter) target).getName()); - this.throwbackInfo(pc, "Region Name: " + region); - this.throwbackInfo(pc, "Region Height: " + region.lerpY((AbstractCharacter)target)); + output += "Player Info: " + ((AbstractCharacter) target).getName() + newline; + output += "Region Building: " + building.getName() + newline; + output += "Region Height: " + region.lerpY((AbstractCharacter)target) + newline; + output += "is Stairs: " + region.stairs + newline; + this.throwbackInfo(pc, output); } } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index ca32184d..787917dc 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -949,7 +949,7 @@ public enum BuildingManager { building.isDeranking.compareAndSet(true, false); } public static Building getBuildingAtLocation(Vector3fImmutable loc){ - for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc,128,MBServerStatics.MASK_BUILDING)){ + for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc,64,MBServerStatics.MASK_BUILDING)){ Building building = (Building)awo; if(building == null) continue; @@ -958,7 +958,9 @@ public enum BuildingManager { float minZ = building.loc.z - building.getBounds().getHalfExtents().y; float maxZ = building.loc.z + building.getBounds().getHalfExtents().y; - if(loc.x > minX && loc.x < maxX && loc.z > minZ && loc.x < maxZ) + boolean meetsX = loc.x > minX && loc.x < maxX; + boolean meetsY = loc.z > minZ && loc.z < maxZ; + if(meetsX && meetsY) return building; } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index c8ab7b60..41169b0b 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -991,7 +991,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { if(building != null){ //look for region in the building we are in for(Regions regionCycle : building.getBounds().getRegions()) - if(regionCycle.isPointInPolygon(value)) + if(regionCycle.isPointInPolygon(value) && Math.abs(regionCycle.highLerp.y - value.y) < 10) region = regionCycle; } float regionHeightOffset = 0;