From a3af3085750607bc20bd53579b2cf31d02a154f9 Mon Sep 17 00:00:00 2001 From: InvalidArgument3 Date: Sun, 16 Jun 2024 18:55:04 -0500 Subject: [PATCH] simplify config spawnablearea to just a sphere at 0/0/0 for now --- .../DynamicAsteroids/AsteroidSettings.cs | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Dynamic Asteroids/Data/Scripts/DynamicAsteroids/AsteroidSettings.cs b/Dynamic Asteroids/Data/Scripts/DynamicAsteroids/AsteroidSettings.cs index 19d7efe1..5a3d4394 100644 --- a/Dynamic Asteroids/Data/Scripts/DynamicAsteroids/AsteroidSettings.cs +++ b/Dynamic Asteroids/Data/Scripts/DynamicAsteroids/AsteroidSettings.cs @@ -64,10 +64,7 @@ public static class AsteroidSettings new SpawnableArea { CenterPosition = new Vector3D(148001024.50, 1024.50, 1024.50), - Normal = new Vector3D(1, 10, 0.5).Normalized(), - Radius = 60268000 * 2.5, - InnerRadius = 60268000 * 1.2, - HeightFromCenter = 1000, + Radius = 60268000 * 2.5 } }; @@ -199,6 +196,11 @@ public static void SaveSettings() WriteIntArray(writer, "GoldDropRange", GoldDropRange); WriteIntArray(writer, "PlatinumDropRange", PlatinumDropRange); WriteIntArray(writer, "UraniniteDropRange", UraniniteDropRange); + + writer.WriteLine("[SpawnableArea]"); + var spawnLocation = ValidSpawnLocations[0]; + writer.WriteLine($"CenterPosition={spawnLocation.CenterPosition.X},{spawnLocation.CenterPosition.Y},{spawnLocation.CenterPosition.Z}"); + writer.WriteLine($"Radius={spawnLocation.Radius}"); } } catch (Exception ex) @@ -380,6 +382,13 @@ public static void LoadSettings() case "UraniniteDropRange": UraniniteDropRange = ReadIntArray(value); break; + case "CenterPosition": + var coords = value.Split(','); + ValidSpawnLocations[0].CenterPosition = new Vector3D(double.Parse(coords[0]), double.Parse(coords[1]), double.Parse(coords[2])); + break; + case "Radius": + ValidSpawnLocations[0].Radius = double.Parse(value); + break; } } } @@ -411,25 +420,17 @@ private static int[] ReadIntArray(string value) public class SpawnableArea { public Vector3D CenterPosition; - public Vector3D Normal; public double Radius; - public double InnerRadius; - public double HeightFromCenter; public bool ContainsPoint(Vector3D point) { - point -= CenterPosition; - double pointDistanceSq = point.LengthSquared(); - if (pointDistanceSq > Radius * Radius || pointDistanceSq < InnerRadius * InnerRadius) - return false; - if (Math.Abs(Vector3D.Dot(point, Normal)) > HeightFromCenter) - return false; - return true; + double distanceSquared = (point - CenterPosition).LengthSquared(); + return distanceSquared <= Radius * Radius; } public Vector3D VelocityAtPoint(Vector3D point) { - return -(point - CenterPosition).Cross(Normal).Normalized() * AsteroidSettings.AsteroidVelocityBase; + return (point - CenterPosition).Normalized() * AsteroidSettings.AsteroidVelocityBase; } } }