forked from MagicBane/Server
new region lookup
This commit is contained in:
@@ -18,6 +18,7 @@ import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.UpgradeBuildingJob;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
@@ -26,7 +27,9 @@ import engine.net.client.msg.PlaceAssetMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
import org.w3c.dom.css.Rect;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
@@ -945,4 +948,20 @@ public enum BuildingManager {
|
||||
|
||||
building.isDeranking.compareAndSet(true, false);
|
||||
}
|
||||
public static Building getBuildingAtLocation(Vector3fImmutable loc){
|
||||
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc,128,MBServerStatics.MASK_BUILDING)){
|
||||
Building building = (Building)awo;
|
||||
if(building == null)
|
||||
continue;
|
||||
float minX = building.loc.x - building.getBounds().getHalfExtents().x;
|
||||
float maxX = building.loc.x + building.getBounds().getHalfExtents().x;
|
||||
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)
|
||||
return building;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user