diff --git a/Dynamic Asteroids/Data/Scripts/DynamicAsteroids/AsteroidEntities/AsteroidSpawner.cs b/Dynamic Asteroids/Data/Scripts/DynamicAsteroids/AsteroidEntities/AsteroidSpawner.cs index a2764523..4fe90ced 100644 --- a/Dynamic Asteroids/Data/Scripts/DynamicAsteroids/AsteroidEntities/AsteroidSpawner.cs +++ b/Dynamic Asteroids/Data/Scripts/DynamicAsteroids/AsteroidEntities/AsteroidSpawner.cs @@ -572,11 +572,7 @@ private void UpdatePlayerMovementData() }; } } - } - - private Dictionary gravityCache = new Dictionary(); - private const int gravityCheckInterval = 10; // Check every 10 spawns - private int spawnCounter = 0; + } private bool IsValidSpawnPosition(Vector3D position, List zones) { @@ -598,21 +594,9 @@ private bool IsValidSpawnPosition(Vector3D position, List zones) private bool IsNearPlanet(Vector3D position) { - bool isNearPlanet; - if (gravityCache.TryGetValue(position, out isNearPlanet)) - { - return isNearPlanet; - } - - if (spawnCounter++ % gravityCheckInterval == 0) - { - float naturalGravityInterference; - MyAPIGateway.Physics.CalculateNaturalGravityAt(position, out naturalGravityInterference); - isNearPlanet = naturalGravityInterference > 0; - gravityCache[position] = isNearPlanet; - } - - return isNearPlanet; + float interference; + Vector3D gravity = MyAPIGateway.Physics.CalculateNaturalGravityAt(position, out interference); + return gravity.LengthSquared() > 0; } public void SendNetworkMessages()