mirror of
https://bitbucket.org/projectswg/pswgcommon.git
synced 2026-01-16 23:04:32 -05:00
Minor optimizations to location
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
plugins {
|
||||
id 'idea'
|
||||
id 'java'
|
||||
id "org.javamodularity.moduleplugin"
|
||||
}
|
||||
@@ -6,6 +7,12 @@ plugins {
|
||||
sourceCompatibility = 11
|
||||
targetCompatibility = 11
|
||||
|
||||
idea {
|
||||
module {
|
||||
inheritOutputDirs = true
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
@@ -127,7 +127,11 @@ public class Location implements Encodable, Persistable {
|
||||
}
|
||||
|
||||
public boolean isWithinFlatDistance(Point3D target, double radius) {
|
||||
return square(getX() - target.getX()) + square(getZ() - target.getZ()) <= square(radius);
|
||||
double mX = getX(), mZ = getZ();
|
||||
double tX = target.getX(), tZ = target.getZ();
|
||||
if (Math.abs(mX - tX) >= radius || Math.abs(mZ - tZ) >= radius)
|
||||
return false;
|
||||
return square(mX - tX) + square(mZ - tZ) <= square(radius);
|
||||
}
|
||||
|
||||
public double getSpeed(Location l, double deltaTime) {
|
||||
|
||||
@@ -102,8 +102,8 @@ public enum Terrain {
|
||||
WATERTABLETEST ("terrain/watertabletest.trn"),
|
||||
YAVIN4 ("terrain/yavin4.trn");
|
||||
|
||||
private static final EnumLookup<Integer, Terrain> CRC_LOOKUP = new EnumLookup<>(Terrain.class, t -> t.getCrc());
|
||||
private static final EnumLookup<String, Terrain> NAME_LOOKUP = new EnumLookup<>(Terrain.class, t -> t.getName());
|
||||
private static final EnumLookup<Integer, Terrain> CRC_LOOKUP = new EnumLookup<>(Terrain.class, Terrain::getCrc);
|
||||
private static final EnumLookup<String, Terrain> NAME_LOOKUP = new EnumLookup<>(Terrain.class, Terrain::getName);
|
||||
|
||||
private String file;
|
||||
private String name;
|
||||
|
||||
Reference in New Issue
Block a user