예제 #1
0
        public void UpdateAtmosphereStatus()
        {
            if (m_character != null && (m_localPlayer == false || (MySession.Static != null && m_character == MySession.Static.LocalCharacter)))
            {
                AtmosphereStatus original = m_atmosphereStatus;
                Vector3D         pos      = m_character.PositionComp.GetPosition();
                Vector3          gravity  = MyGravityProviderSystem.CalculateNaturalGravityInPoint(pos);
                if (gravity.LengthSquared() > 0f)
                {
                    MyPlanet planet = MyGamePruningStructure.GetClosestPlanet(pos);
                    if (planet != null && planet.HasAtmosphere && planet.GetAirDensity(pos) > 0.5f)
                    {
                        m_atmosphereStatus = AtmosphereStatus.Atmosphere;//in atmosphere
                    }
                    else
                    {
                        m_atmosphereStatus = AtmosphereStatus.Space;
                    }
                }
                else
                {
                    m_atmosphereStatus = AtmosphereStatus.Space;
                }

                if (m_atmosphereStatus == AtmosphereStatus.Space)
                {
                    float oxygen = 0f;
                    if (m_character.OxygenComponent != null)
                    {
                        if (m_localPlayer)
                        {
                            if (MySession.Static.ControlledEntity is MyCharacter)
                            {
                                //in suit
                                oxygen = m_character.OxygenComponent.EnvironmentOxygenLevel;
                            }
                            else
                            {
                                //in cockpit
                                oxygen = m_character.OxygenComponent.OxygenLevelAtCharacterLocation;
                            }
                        }
                        else
                        {
                            oxygen = m_character.OxygenComponent.EnvironmentOxygenLevel;
                        }
                    }
                    if (oxygen > 0.1f)
                    {
                        m_atmosphereStatus = AtmosphereStatus.ShipOrStation;//in pressurized environment
                    }
                }

                if (MyFakes.ENABLE_REALISTIC_LIMITER && MyFakes.ENABLE_NEW_SOUNDS && original != m_atmosphereStatus && MySession.Static != null && MySession.Static.Settings.RealisticSound)
                {
                    MyAudio.Static.EnableMasterLimiter(!(InAtmosphere || InShipOrStation));
                }
            }
        }
예제 #2
0
        public void UpdateAtmosphereStatus()
        {
            if (m_character != null && (m_localPlayer == false || (MySession.Static != null && m_character == MySession.Static.LocalCharacter)))
            {
                Vector3D pos     = m_character.PositionComp.GetPosition();
                Vector3  gravity = MyGravityProviderSystem.CalculateNaturalGravityInPoint(pos);
                if (gravity.LengthSquared() > 0f)
                {
                    MyPlanet planet = MyGravityProviderSystem.GetNearestPlanet(pos);
                    if (planet != null && planet.HasAtmosphere && planet.GetAirDensity(pos) > 0.5f)
                    {
                        m_atmosphereStatus = AtmosphereStatus.Atmosphere;//in atmosphere
                    }
                    else
                    {
                        m_atmosphereStatus = AtmosphereStatus.Space;
                    }
                }
                else
                {
                    m_atmosphereStatus = AtmosphereStatus.Space;
                }

                if (m_atmosphereStatus == AtmosphereStatus.Space)
                {
                    float oxygen = 0f;
                    if (m_character.OxygenComponent != null)
                    {
                        if (m_localPlayer)
                        {
                            if (MySession.Static.ControlledEntity is MyCharacter)
                            {
                                //in suit
                                oxygen = m_character.OxygenComponent.EnvironmentOxygenLevel;
                            }
                            else
                            {
                                //in cockpit
                                oxygen = m_character.OxygenComponent.OxygenLevelAtCharacterLocation;
                            }
                        }
                        else
                        {
                            oxygen = m_character.OxygenComponent.EnvironmentOxygenLevel;
                        }
                    }
                    if (oxygen > 0.1f)
                    {
                        m_atmosphereStatus = AtmosphereStatus.ShipOrStation;//in pressurized environment
                    }
                }
            }
        }
예제 #3
0
        private float PlanetaryInfluence()
        {
            BoundingBoxD box           = _thisEntity.PositionComp.WorldAABB;
            MyPlanet     closestPlanet = MyGamePruningStructure.GetClosestPlanet(ref box);

            if (closestPlanet == null)
            {
                return(0);
            }
            MyGravityProviderComponent myGravityProviderComponent = closestPlanet.Components.Get <MyGravityProviderComponent>();

            return(closestPlanet.GetAirDensity(box.Center) * myGravityProviderComponent.GetGravityMultiplier(box.Center));
        }
예제 #4
0
        public static float PlanetaryInfluence(IMyEntity block)
        {
            BoundingBoxD box           = block.PositionComp.WorldAABB;
            MyPlanet     closestPlanet = MyGamePruningStructure.GetClosestPlanet(ref box);

            if (closestPlanet == null)
            {
                return(0);
            }
            MyGravityProviderComponent myGravityProviderComponent = closestPlanet.Components.Get <MyGravityProviderComponent>();

            return(closestPlanet.GetAirDensity(box.Center) * myGravityProviderComponent.GetGravityMultiplier(box.Center));
            //MySimpleObjectDraw
            //billboa
        }
예제 #5
0
파일: AeroEffects.cs 프로젝트: zrisher/ARMS
        private void FillAirDensity()
        {
#if DEBUG_IN_SPACE
            m_airDensity = 1f;
#else
            Vector3D gridCentre    = m_grid.GetCentre();
            MyPlanet closestPlanet = MyPlanetExtensions.GetClosestPlanet(gridCentre);
            if (closestPlanet == null)
            {
                m_airDensity = 0f;
            }
            else
            {
                m_airDensity = closestPlanet.GetAirDensity(gridCentre);
            }
#endif
        }
예제 #6
0
        private void Update10()
        {
            MyPlayer player = MySession.Static.LocalHumanPlayer;

            if (player == null)
            {
                return;
            }

            MyCubeBlock block = player.Controller.ControlledEntity as MyCubeBlock;

            if (block == null || block != m_cockpit)
            {
                return;
            }

            bool skipInput = MyGuiScreenGamePlay.ActiveGameplayScreen != null || MyAPIGateway.Input.IsGameControlPressed(MyControlsSpace.LOOKAROUND);

            Log.DebugLog("active screen: " + MyGuiScreenGamePlay.ActiveGameplayScreen, condition: MyGuiScreenGamePlay.ActiveGameplayScreen != null);
            Log.DebugLog("Lookaround", condition: MyAPIGateway.Input.IsGameControlPressed(MyControlsSpace.LOOKAROUND));

            Vector3D gridCentre = m_grid.GetCentre();
            MyPlanet closest    = MyPlanetExtensions.GetClosestPlanet(gridCentre);

            if (closest.GetAirDensity(gridCentre) == 0f)
            {
                return;
            }
            Vector3 gravityDirection = closest.GetWorldGravityNormalized(ref gridCentre);

            if (m_aileron != null)
            {
                AileronHelper(ref gravityDirection, skipInput);
            }
            if (m_elevator != null)
            {
                ElevatorHelper(skipInput);
            }
            if (m_rudder != null)
            {
                RudderHelper(skipInput);
            }
        }
예제 #7
0
        private void refresh_real_max_forces()
        {
            BoundingBoxD grid_bounding_box = _grid.PositionComp.WorldAABB;
            MyPlanet     closest_planetoid = MyGamePruningStructure.GetClosestPlanet(ref grid_bounding_box);
            bool         atmosphere_present;
            float        air_density;

            if (closest_planetoid == null)
            {
                atmosphere_present = false;
                air_density        = 0.0f;
            }
            else
            {
                atmosphere_present = closest_planetoid.HasAtmosphere;
                air_density        = closest_planetoid.GetAirDensity(grid_bounding_box.Center);
            }

            for (int dir_index = 0; dir_index < 6; ++dir_index)
            {
                refresh_real_max_forces_for_single_direction(dir_index, atmosphere_present, air_density);
            }
        }
        public static bool CalculateAtmoTravelPath(ImprovedSpawnGroup spawnGroup, Vector3D startCoords, MyPlanet planet, out Vector3D startPathCoords, out Vector3D endPathCoords, out MatrixD startMatrix)
        {
            startPathCoords = Vector3D.Zero;
            endPathCoords   = Vector3D.Zero;
            startMatrix     = MatrixD.CreateWorld(Vector3D.Zero, Vector3D.Forward, Vector3D.Up);
            SpawnResources.RefreshEntityLists();

            if (planet == null)
            {
                return(false);
            }

            var planetEntity = planet as IMyEntity;

            for (int i = 0; i < Settings.PlanetaryCargoShips.MaxSpawnAttempts; i++)
            {
                //Get Starting Point
                var randDirFromPlayer = SpawnResources.GetRandomCompassDirection(startCoords, planet);
                var pathDist          = SpawnResources.GetRandomPathDist(Settings.PlanetaryCargoShips.MinPathDistanceFromPlayer, Settings.PlanetaryCargoShips.MaxPathDistanceFromPlayer);
                var midPointSurface   = SpawnResources.GetNearestSurfacePoint(randDirFromPlayer * pathDist + startCoords, planet);
                var upDir             = Vector3D.Normalize(midPointSurface - planetEntity.GetPosition());
                var altitudeFromMid   = SpawnResources.GetRandomPathDist(Settings.PlanetaryCargoShips.MinSpawningAltitude, Settings.PlanetaryCargoShips.MaxSpawningAltitude);
                var tempStartPath     = upDir * altitudeFromMid + midPointSurface;

                if (spawnGroup.PlanetRequiresAtmo == true && planet.GetAirDensity(tempStartPath) < Settings.PlanetaryCargoShips.MinAirDensity)
                {
                    tempStartPath = upDir * Settings.PlanetaryCargoShips.MinSpawningAltitude + midPointSurface;

                    if (spawnGroup.PlanetRequiresAtmo == true && planet.GetAirDensity(tempStartPath) < Settings.PlanetaryCargoShips.MinAirDensity)
                    {
                        continue;
                    }
                }

                if (SpawnResources.IsPositionNearEntities(tempStartPath, Settings.PlanetaryCargoShips.MinSpawnFromGrids) == true)
                {
                    continue;
                }

                var startCoordsDistFromCenter = Vector3D.Distance(planetEntity.GetPosition(), tempStartPath);

                //Get Ending Point
                var randPathDir  = SpawnResources.GetRandomCompassDirection(tempStartPath, planet);
                var randPathDist = SpawnResources.GetRandomPathDist(Settings.PlanetaryCargoShips.MinPathDistance, Settings.PlanetaryCargoShips.MaxPathDistance);
                var endPathA     = randPathDir * randPathDist + tempStartPath;
                var endPathB     = -randPathDir * randPathDist + tempStartPath;
                var tempEndPath  = Vector3D.Zero;

                if (Vector3D.Distance(endPathA, startCoords) < Vector3D.Distance(endPathB, startCoords))
                {
                    tempEndPath = endPathA;
                }
                else
                {
                    tempEndPath  = endPathB;
                    randPathDir *= -1;
                }

                //TODO: Set At Same Height From Sealevel As Start
                var endUpDir = Vector3D.Normalize(tempEndPath - planetEntity.GetPosition());
                tempEndPath = endUpDir * startCoordsDistFromCenter + planetEntity.GetPosition();

                //Check Path
                var  tempMatrix  = MatrixD.CreateWorld(tempStartPath, randPathDir, upDir);
                var  truePathDir = Vector3D.Normalize(tempEndPath - tempStartPath);
                bool badPath     = false;

                foreach (var prefab in spawnGroup.SpawnGroup.Prefabs)
                {
                    var    modifiedStart = Vector3D.Transform((Vector3D)prefab.Position, tempMatrix);
                    double totalSteps    = 0;

                    while (totalSteps < randPathDist)
                    {
                        var testPath = totalSteps * truePathDir + modifiedStart;

                        if (SpawnResources.IsPositionInSafeZone(testPath) == true)
                        {
                            badPath = true;
                            break;
                        }

                        if (SpawnResources.GetDistanceFromSurface(testPath, planet) < Settings.PlanetaryCargoShips.MinPathAltitude)
                        {
                            badPath = true;
                            break;
                        }

                        totalSteps += Settings.PlanetaryCargoShips.PathStepCheckDistance;
                    }

                    if (badPath == true)
                    {
                        break;
                    }
                }

                if (badPath == true)
                {
                    continue;
                }

                startPathCoords = tempStartPath;
                endPathCoords   = tempEndPath;
                startMatrix     = tempMatrix;
                return(true);
            }

            return(false);
        }
        private void SolarPanel_MaxOutputChanged(MyDefinitionId changedResourceId, float oldOutput, MyResourceSourceComponent source)
        {
            //is this possible?
            if (source?.Entity == null)
            {
                return;
            }

            //shouldn't happen, should always exist from the OnEntityCreate
            if (solarPanelData.ContainsKey(source.Entity.EntityId) == false)
            {
                return;
            }

            var data = solarPanelData[source.Entity.EntityId];

            //if the max output matches our current max output, or our original max output don't do anything
            if (data.CurrentMaxOutput == source.MaxOutput || data.OriginalMaxOutput == source.MaxOutput)
            {
                return;
            }

            IMyTerminalBlock terminalEntity = source.Entity as IMyTerminalBlock;

            if (terminalEntity == null)
            {
                return;
            }

            //set our new original max output then recalculate
            solarPanelData[source.Entity.EntityId].OriginalMaxOutput = source.MaxOutput;


            //did we change grids?
            if (terminalEntity.CubeGrid.EntityId != data.GridEntityId)
            {
                //check if we're static again
                data.IsStatic = terminalEntity.CubeGrid.IsStatic;

                //force a re-calculation of air density
                data.CurrentAirDensity = null;
            }

            if (data.CurrentAirDensity == null || data.IsStatic == false)
            {
                var      entityPosition = terminalEntity.GetPosition();
                float    airDensity     = 0f;
                MyPlanet closestPlanet  = MyGamePruningStructure.GetClosestPlanet(entityPosition);
                if (closestPlanet == null || closestPlanet.PositionComp.WorldAABB.Contains(entityPosition) == ContainmentType.Disjoint)
                {
                    airDensity = 0f;
                }
                else
                {
                    airDensity = closestPlanet.GetAirDensity(entityPosition);
                }

                if (data.CurrentAirDensity != airDensity)
                {
                    data.CurrentAirDensity = airDensity;
                    terminalEntity.RefreshCustomInfo();
                }
            }

            //update
            UpdatePower(source.Entity as IMySolarPanel, data);
        }
        public EnvironmentEvaluation(Vector3D coords) : base()
        {
            //Non Planet Checks
            DistanceFromWorldCenter  = Vector3D.Distance(Vector3D.Zero, coords);
            DirectionFromWorldCenter = Vector3D.Normalize(coords);

            InsideTerritories       = new List <string>();
            InsideStrictTerritories = new List <string>();

            //Planet Checks
            NearestPlanet = SpawnResources.GetNearestPlanet(coords, true);

            if (NearestPlanet == null || !MyAPIGateway.Entities.Exist(NearestPlanet))
            {
                return;
            }

            AltitudeAtPosition = Vector3D.Distance(NearestPlanet.GetClosestSurfacePointGlobal(coords), coords);
            NearestPlanetName  = NearestPlanet.Generator.Id.SubtypeName;
            PlanetDiameter     = NearestPlanet.AverageRadius * 2;

            var planetEntity    = NearestPlanet as IMyEntity;
            var gravityProvider = planetEntity.Components.Get <MyGravityProviderComponent>();

            if (gravityProvider != null)
            {
                if (gravityProvider.IsPositionInRange(coords) == true)
                {
                    IsOnPlanet = true;
                }
            }

            if (!IsOnPlanet)
            {
                return;
            }

            //On Planet Checks
            GravityAtPosition    = gravityProvider.GetGravityMultiplier(coords);
            AtmosphereAtPosition = NearestPlanet.GetAirDensity(coords);
            OxygenAtPosition     = NearestPlanet.GetOxygenForPosition(coords);
            IsNight           = MyVisualScriptLogicProvider.IsOnDarkSide(NearestPlanet, coords);
            WeatherAtPosition = MyVisualScriptLogicProvider.GetWeather(coords) ?? "";

            //Terrain Material Checks
            var upDir         = Vector3D.Normalize(coords - NearestPlanet.PositionComp.WorldAABB.Center);
            var downDir       = upDir * -1;
            var forward       = Vector3D.CalculatePerpendicularVector(upDir);
            var matrix        = MatrixD.CreateWorld(coords, forward, upDir);
            var directionList = new List <Vector3D>();

            directionList.Add(matrix.Forward);
            directionList.Add(matrix.Backward);
            directionList.Add(matrix.Left);
            directionList.Add(matrix.Right);

            var terrainTypes = new Dictionary <string, int>();

            for (int i = 1; i < 12; i++)
            {
                foreach (var direction in directionList)
                {
                    try {
                        var checkCoordsRough   = direction * (i * 15) + coords;
                        var checkSurfaceCoords = NearestPlanet.GetClosestSurfacePointGlobal(checkCoordsRough);
                        var checkMaterial      = NearestPlanet.GetMaterialAt(ref checkSurfaceCoords);

                        if (checkMaterial == null)
                        {
                            continue;
                        }

                        if (terrainTypes.ContainsKey(checkMaterial.MaterialTypeName))
                        {
                            terrainTypes[checkMaterial.MaterialTypeName]++;
                        }
                        else
                        {
                            terrainTypes.Add(checkMaterial.MaterialTypeName, 1);
                        }
                    } catch (Exception e) {
                        Logger.AddMsg("Caught Exception Trying To Determine Terrain Material", true);
                        Logger.AddMsg(e.ToString(), true);
                    }
                }
            }

            string highestCountName   = "";
            int    highestCountNumber = 0;

            foreach (var material in terrainTypes.Keys)
            {
                if (string.IsNullOrWhiteSpace(highestCountName) || terrainTypes[material] > highestCountNumber)
                {
                    highestCountName   = material;
                    highestCountNumber = terrainTypes[material];
                }
            }

            if (!string.IsNullOrWhiteSpace(highestCountName))
            {
                CommonTerrainAtPosition = highestCountName;
            }
        }
        public static bool GetInitialSpawnCoords(Vector3D startCoords, out Vector3D spawnCoords)
        {
            spawnCoords = Vector3D.Zero;
            MyPlanet planet    = SpawnResources.GetNearestPlanet(startCoords);
            var      inGravity = SpawnResources.IsPositionInGravity(startCoords, planet);

            for (int i = 0; i < Settings.BossEncounters.PathCalculationAttempts; i++)
            {
                var testCoords = Vector3D.Zero;

                if (inGravity == false)
                {
                    var randDir  = Vector3D.Normalize(MyUtils.GetRandomVector3D());
                    var randDist = (double)SpawnResources.rnd.Next((int)Settings.BossEncounters.MinCoordsDistanceSpace, (int)Settings.BossEncounters.MaxCoordsDistanceSpace);
                    spawnCoords = randDir * randDist + startCoords;

                    if (SpawnResources.IsPositionInGravity(spawnCoords, planet) == true)
                    {
                        randDir    *= -1;
                        spawnCoords = randDir * randDist + startCoords;

                        if (SpawnResources.IsPositionInGravity(spawnCoords, planet) == true)
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    var planetEntity  = planet as IMyEntity;
                    var upDir         = Vector3D.Normalize(startCoords - planetEntity.GetPosition());
                    var randDir       = SpawnResources.GetRandomCompassDirection(startCoords, planet);
                    var randDist      = (double)SpawnResources.rnd.Next((int)Settings.BossEncounters.MinCoordsDistancePlanet, (int)Settings.BossEncounters.MaxCoordsDistancePlanet);
                    var roughCoords   = randDir * randDist + startCoords;
                    var surfaceCoords = SpawnResources.GetNearestSurfacePoint(roughCoords, planet);
                    spawnCoords = upDir * Settings.BossEncounters.MinPlanetAltitude + surfaceCoords;

                    if (planet.GetAirDensity(spawnCoords) < Settings.BossEncounters.MinAirDensity)
                    {
                        spawnCoords = Vector3D.Zero;
                        continue;
                    }
                }

                if (spawnCoords == Vector3D.Zero)
                {
                    continue;
                }

                bool badCoords = false;

                foreach (var entity in SpawnResources.EntityList)
                {
                    if (Vector3D.Distance(spawnCoords, entity.GetPosition()) < Settings.BossEncounters.MinSignalDistFromOtherEntities)
                    {
                        badCoords = true;
                        break;
                    }
                }

                if (badCoords == false)
                {
                    if (SpawnResources.IsPositionInSafeZone(spawnCoords) == true)
                    {
                        badCoords = true;
                    }
                }

                if (badCoords == false)
                {
                    return(true);
                }
            }

            spawnCoords = Vector3D.Zero;
            return(false);
        }
        public static List <ImprovedSpawnGroup> GetBossEncounters(Vector3D playerCoords, Vector3D spawnCoords)
        {
            MyPlanet planet             = SpawnResources.GetNearestPlanet(playerCoords);
            bool     spaceSpawn         = false;
            bool     planetSpawn        = false;
            string   specificGroup      = "";
            var      planetRestrictions = new List <string>(Settings.General.PlanetSpawnsDisableList.ToList());

            SpawnGroupSublists.Clear();
            EligibleSpawnsByModId.Clear();

            if (planet != null)
            {
                if (planetRestrictions.Contains(planet.Generator.Id.SubtypeName) == true)
                {
                    return(new List <ImprovedSpawnGroup>());
                }
            }

            bool specificSpawnRequest = false;

            if (SpawnGroupManager.AdminSpawnGroup != "")
            {
                specificGroup = SpawnGroupManager.AdminSpawnGroup;
                SpawnGroupManager.AdminSpawnGroup = "";
                specificSpawnRequest = true;
            }

            if (SpawnResources.IsPositionInGravity(spawnCoords, planet) == true)
            {
                if (planet.GetAirDensity(spawnCoords) > Settings.BossEncounters.MinAirDensity)
                {
                    planetSpawn = true;
                }
            }
            else
            {
                spaceSpawn = true;
            }

            var eligibleGroups = new List <ImprovedSpawnGroup>();

            //Filter Eligible Groups To List
            foreach (var spawnGroup in SpawnGroupManager.SpawnGroups)
            {
                if (specificGroup != "" && spawnGroup.SpawnGroup.Id.SubtypeName != specificGroup)
                {
                    continue;
                }

                if (specificGroup == "" && spawnGroup.AdminSpawnOnly == true)
                {
                    continue;
                }

                bool eligibleGroup = false;

                if (spawnGroup.BossEncounterSpace == true && spaceSpawn == true)
                {
                    eligibleGroup = true;
                }

                if (spawnGroup.BossEncounterAtmo == true && planetSpawn == true)
                {
                    eligibleGroup = true;
                }

                if (spawnGroup.BossEncounterAny == true)
                {
                    eligibleGroup = true;
                }

                if (eligibleGroup == false)
                {
                    continue;
                }

                if (SpawnResources.CheckCommonConditions(spawnGroup, playerCoords, planet, specificSpawnRequest) == false)
                {
                    continue;
                }

                if (spawnGroup.Frequency > 0)
                {
                    string modID = spawnGroup.SpawnGroup.Context.ModId;

                    if (string.IsNullOrEmpty(modID) == true)
                    {
                        modID = "KeenSWH";
                    }

                    if (SpawnGroupSublists.ContainsKey(modID) == false)
                    {
                        SpawnGroupSublists.Add(modID, new List <ImprovedSpawnGroup>());
                    }

                    if (EligibleSpawnsByModId.ContainsKey(modID) == false)
                    {
                        EligibleSpawnsByModId.Add(modID, 1);
                    }
                    else
                    {
                        EligibleSpawnsByModId[modID] += 1;
                    }

                    if (Settings.BossEncounters.UseMaxSpawnGroupFrequency == true && spawnGroup.Frequency > Settings.BossEncounters.MaxSpawnGroupFrequency * 10)
                    {
                        spawnGroup.Frequency = (int)Math.Round((double)Settings.BossEncounters.MaxSpawnGroupFrequency * 10);
                    }

                    for (int i = 0; i < spawnGroup.Frequency; i++)
                    {
                        eligibleGroups.Add(spawnGroup);
                        SpawnGroupSublists[modID].Add(spawnGroup);
                    }
                }
            }

            return(eligibleGroups);
        }
        public static List <ImprovedSpawnGroup> GetSpawnGroups(List <string> spawnGroups, Vector3D coords, out Dictionary <string, List <string> > validFactions)
        {
            MyPlanet planet             = SpawnResources.GetNearestPlanet(coords);
            var      planetRestrictions = new List <string>(Settings.General.PlanetSpawnsDisableList.ToList());

            validFactions = new Dictionary <string, List <string> >();

            if (planet != null)
            {
                if (planetRestrictions.Contains(planet.Generator.Id.SubtypeName) == true)
                {
                    return(new List <ImprovedSpawnGroup>());
                }
            }

            string planetName = "";

            if (planet != null)
            {
                planetName = planet.Generator.Id.SubtypeId.ToString();
            }

            var eligibleGroups = new List <ImprovedSpawnGroup>();

            //Filter Eligible Groups To List
            foreach (var spawnGroup in SpawnGroupManager.SpawnGroups)
            {
                if (!spawnGroups.Contains(spawnGroup.SpawnGroupName))
                {
                    continue;
                }

                if (spawnGroup.RivalAiAnySpawn == false)
                {
                    if (planet == null && spawnGroup.RivalAiSpaceSpawn == false)
                    {
                        continue;
                    }

                    if (planet != null)
                    {
                        var airDensity = planet.GetAirDensity(coords);

                        if (spawnGroup.RivalAiAtmosphericSpawn == false || planet.HasAtmosphere == false || airDensity < 0.4f)
                        {
                            continue;
                        }
                    }
                }

                if (SpawnResources.CheckCommonConditions(spawnGroup, coords, planet, false) == false)
                {
                    continue;
                }

                var validFactionsList = SpawnResources.ValidNpcFactions(spawnGroup, coords);

                if (validFactionsList.Count == 0)
                {
                    continue;
                }

                if (validFactions.ContainsKey(spawnGroup.SpawnGroupName) == false)
                {
                    validFactions.Add(spawnGroup.SpawnGroupName, validFactionsList);
                }

                if (spawnGroup.Frequency > 0)
                {
                    if (Settings.SpaceCargoShips.UseMaxSpawnGroupFrequency == true && spawnGroup.Frequency > Settings.SpaceCargoShips.MaxSpawnGroupFrequency * 10)
                    {
                        spawnGroup.Frequency = (int)Math.Round((double)Settings.SpaceCargoShips.MaxSpawnGroupFrequency * 10);
                    }

                    for (int i = 0; i < spawnGroup.Frequency; i++)
                    {
                        eligibleGroups.Add(spawnGroup);
                    }
                }
            }

            return(eligibleGroups);
        }