Skip to content

Commit

Permalink
Revert "Update AsteroidSpawner.cs"
Browse files Browse the repository at this point in the history
This reverts commit 703c22b.
  • Loading branch information
InvalidArgument3 committed Jun 17, 2024
1 parent 703c22b commit 2d5c357
Showing 1 changed file with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,7 @@ private void UpdatePlayerMovementData()
};
}
}
}

private Dictionary<Vector3D, bool> gravityCache = new Dictionary<Vector3D, bool>();
private const int gravityCheckInterval = 10; // Check every 10 spawns
private int spawnCounter = 0;
}

private bool IsValidSpawnPosition(Vector3D position, List<AsteroidZone> zones)
{
Expand All @@ -598,21 +594,9 @@ private bool IsValidSpawnPosition(Vector3D position, List<AsteroidZone> 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()
Expand Down

0 comments on commit 2d5c357

Please sign in to comment.