system enabled

This commit is contained in:
2023-10-26 20:04:11 -05:00
parent 7af63d1519
commit 136c8c4756
6 changed files with 153 additions and 45 deletions
+1 -12
View File
@@ -987,18 +987,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
@Override
public final void setLoc(final Vector3fImmutable value) {
Building building = BuildingManager.getBuildingAtLocation(this.loc);
Regions region = null;
if(building != null) {
//look for region in the building we are in
for (Regions regionCycle : building.getBounds().getRegions()) {
float regionHeight = regionCycle.highLerp.y - regionCycle.lowLerp.y;
if(regionHeight < 10)
regionHeight = 10;
if (regionCycle.isPointInPolygon(value) && Math.abs(regionCycle.highLerp.y - value.y) < regionHeight)
region = regionCycle;
}
}
Regions region = Regions.getRegionAtLocation(value);
float regionHeightOffset = 0;
if(region != null){
this.region = region;
+3
View File
@@ -20,6 +20,7 @@ import engine.jobs.DeferredPowerJob;
import engine.jobs.UpgradeNPCJob;
import engine.math.Bounds;
import engine.math.Vector3fImmutable;
import engine.mobileAI.utilities.MovementUtilities;
import engine.net.ByteBufferWriter;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
@@ -1899,4 +1900,6 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
public int compareTo(@NotNull Delayed o) {
return toIntExact(this.respawnTime - ((Mob) o).respawnTime);
}
public void setDestination(Vector3fImmutable destination) {MovementUtilities.pathfind(this,destination);}
}
+10 -24
View File
@@ -270,32 +270,18 @@ public class Regions {
return BuildingManager.getBuildingFromCache(region.parentBuildingID);
}
public static Regions GetRegionForTeleport(Vector3fImmutable location) {
public static Regions getRegionAtLocation(Vector3fImmutable location) {
Regions region = null;
//Find building
for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(location, 128, MBServerStatics.MASK_BUILDING)) {
Building building = (Building) awo;
if (!Bounds.collide(location, building.getBounds()))
continue;
if(building != null) {
region = BuildingManager.GetRegion(building, location.x, location.y, location.z);
Building building = BuildingManager.getBuildingAtLocation(location);
if(building != null) {
//look for region in the building we are in
for (Regions regionCycle : building.getBounds().getRegions()) {
float regionHeight = regionCycle.highLerp.y - regionCycle.lowLerp.y;
if(regionHeight < 10)
regionHeight = 10;
if (regionCycle.isPointInPolygon(location) && Math.abs(regionCycle.highLerp.y - location.y) < regionHeight)
region = regionCycle;
}
//find regions that intersect x and z, check if object can enter.
//for (Regions toEnter : building.getBounds().getRegions()) {
// if (toEnter.isPointInPolygon(location)) {
// if (region == null)
// region = toEnter;
// else // we're using a low level to high level tree structure, database not always in order low to high.
//check for highest level index.
// if (region != null && toEnter.highLerp.y > region.highLerp.y)
// region = toEnter;
// }
// }
}
return region;
}