Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Fix for meteors spawning underground, partial #532

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Sources/Sandbox.Game/Game/Entities/MyMeteorShower.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Sandbox.Engine.Utils;
using Sandbox.Game.Audio;
using Sandbox.Game.Entities.Character;
using Sandbox.Game.GameSystems;
using Sandbox.Game.Multiplayer;
using Sandbox.Game.SessionComponents;
using Sandbox.Game.World;
Expand Down Expand Up @@ -166,6 +167,21 @@ private static void StartWave()

var sunDir = MySector.DirectionToSunNormalized;
var waveMeteorCount = MyUtils.GetRandomFloat(Math.Min(2, m_meteorcount - 3), m_meteorcount + 3);
var planet = MyGravityProviderSystem.GetStrongestGravityWell(m_currentTarget.Value.Center);
if (planet != null)
{
var planetVector = m_currentTarget.Value.Center - planet.PositionComp.GetPosition();
if (planetVector.Length() <= planet.GravityLimit)
{
planetVector.Normalize();
planetVector = planetVector * -1;
if (planetVector.Dot(sunDir) >= 0)
{
sunDir = sunDir * -1;

}
}
}
for (int i = 0; i < waveMeteorCount; i++)
{
var randCircle = MyUtils.GetRandomVector3CircleNormalized();
Expand Down