mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-15 05:13:14 -04:00
some bug fixes + updated engine with networking fixes
This commit is contained in:
@@ -21,6 +21,10 @@
|
||||
******************************************************************************/
|
||||
package resources.common;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -79,5 +83,30 @@ public class SpawnPoint {
|
||||
public void setCellNumber(int cellNumber) {
|
||||
this.cellNumber = cellNumber;
|
||||
}
|
||||
|
||||
public Point3D getRandomPosition(float minDistance, float maxDistance) {
|
||||
|
||||
Random random = new Random();
|
||||
float distance = random.nextInt((int) (maxDistance - minDistance) + 1) + minDistance;
|
||||
float angle = (float) (random.nextInt(360) * (Math.PI / 180));
|
||||
float x = (float) (position.x + distance * Math.cos(angle));
|
||||
float z = (float) (position.z + distance * Math.sin(angle));
|
||||
|
||||
return new Point3D(x, 0, z);
|
||||
|
||||
}
|
||||
|
||||
public static Point3D getRandomPosition(Point3D position, float minDistance, float maxDistance, int planetId) {
|
||||
|
||||
Random random = new Random();
|
||||
float distance = random.nextInt((int) (maxDistance - minDistance) + 1) + minDistance;
|
||||
float angle = (float) (random.nextInt(360) * (Math.PI / 180));
|
||||
float x = (float) (position.x + distance * Math.cos(angle));
|
||||
float z = (float) (position.z + distance * Math.sin(angle));
|
||||
|
||||
return new Point3D(x, NGECore.getInstance().terrainService.getHeight(planetId, x, z), z);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user