Esempio n. 1
0
        public override void UpdateAfterSimulation()
        {
            if (Tick % 5 == 0)
            {
                if (Camera == null)
                {
                    return;
                }
                rainImpactEntities.Clear();

                MyGamePruningStructure.GetTopMostEntitiesInBox(ref frustumBBox, rainImpactEntities);
                //MyAPIGateway.Parallel.Start(CalculateLines);
                CalculateLines();
            }

            if (Tick % 60 == 0 && closestPlanet != null)
            {
                cameraDistanceFromSurface = closestPlanet.GetClosestSurfacePointGlobal(Camera.Position);
                cameraAltitude            = (Camera.Position - cameraDistanceFromSurface).Length();
            }

            if (Tick % 301 == 0)
            {
                closestPlanet = MyGamePruningStructure.GetClosestPlanet(Camera.Position);
                if (closestPlanet != null)
                {
                    planetCentre = closestPlanet.PositionComp.WorldAABB.Center;
                }
            }

            lines.Clear();
        }
Esempio n. 2
0
        public static MatrixD GetPlanetRandomSpawnMatrix(Vector3D coords, double minDist, double maxDist, double minAltitude, double maxAltitude, bool inheritAltitude = false)
        {
            MatrixD result = MatrixD.Identity;
            var     planet = MyGamePruningStructure.GetClosestPlanet(coords);
            var     upDir  = GetPlanetUpDirection(coords);

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

            double inheritedAltitude = 0;

            if (inheritAltitude)
            {
                var npcSurface = GetPlanetSurfaceCoordsAtPosition(coords, planet);
                inheritedAltitude = Vector3D.Distance(npcSurface, coords);
            }

            var perpDir        = RandomPerpendicular(upDir);
            var roughArea      = perpDir * RandomDistance(minDist, maxDist) + coords;
            var surfaceCoords  = GetPlanetSurfaceCoordsAtPosition(roughArea, planet);
            var upAtSurface    = Vector3D.Normalize(surfaceCoords - planet.PositionComp.WorldAABB.Center);
            var spawnCoords    = upAtSurface * (RandomDistance(minAltitude, maxAltitude) + inheritedAltitude) + surfaceCoords;
            var perpSurfaceDir = RandomPerpendicular(upAtSurface);

            result = MatrixD.CreateWorld(spawnCoords, perpSurfaceDir, upAtSurface);
            return(result);
        }
Esempio n. 3
0
        public static bool IsInSpace(Vector3D pos)
        {
            var closestPlanet = MyGamePruningStructure.GetClosestPlanet(pos);

            return(closestPlanet == null || !closestPlanet.HasAtmosphere ||
                   closestPlanet.GetAirDensity(pos) <= 0.5);
        }
        /// <summary>
        /// Returns the planet closest to the given position
        /// </summary>
        /// <param name="position">3D Point from where the search is started</param>
        /// <returns>The closest planet</returns>
        private MyPlanet GetPlanet(Vector3D position)
        {
            int          voxelDistance = 200;
            BoundingBoxD box           = new BoundingBoxD(position - voxelDistance * 0.5f, position + voxelDistance * 0.5f);

            return(MyGamePruningStructure.GetClosestPlanet(ref box));
        }
        //alter position based on altitude
        private void HoverMechanic(ref Vector3D pos)
        {
            m_hoverMin = 5;
            m_hoverMax = 25;

            Vector3 gravity = MyGravityProviderSystem.CalculateNaturalGravityInPoint(pos);

            if (gravity.LengthSquared() > 0f)
            {
                MyPlanet planet = MyGamePruningStructure.GetClosestPlanet(pos);
                if (planet != null)
                {
                    Vector3D closestPoint = planet.GetClosestSurfacePointGlobal(ref pos);
                    float    altitude     = (float)Vector3D.Distance(closestPoint, pos);
                    if (Vector3D.DistanceSquared(planet.PositionComp.GetPosition(), closestPoint) > Vector3D.DistanceSquared(planet.PositionComp.GetPosition(), pos))
                    {
                        altitude *= -1;
                    }
                    if (altitude < m_hoverMin)
                    {
                        pos = closestPoint - Vector3D.Normalize(gravity) * m_hoverMin;
                    }
                    else if (altitude > m_hoverMax)
                    {
                        pos = closestPoint - Vector3D.Normalize(gravity) * m_hoverMax;
                    }
                }
            }
        }
Esempio n. 6
0
        public static void ScorePlanetFlatness(Vector3D startPos, double radius, out double score, out Vector3D groundPos)
        {
            var planet = MyGamePruningStructure.GetClosestPlanet(startPos);

            groundPos = planet.GetClosestSurfacePointGlobal(ref startPos);
            var center = planet.PositionComp.WorldVolume.Center;

            var normal = groundPos - center;

            normal.Normalize();
            // Sample two points _radius_ away perp. to normal
            var otherDir = Vector3D.CalculatePerpendicularVector(normal);

            otherDir.Normalize();
            var otherWorld = groundPos + otherDir * radius;
            var other1Surf = planet.GetClosestSurfacePointGlobal(ref otherWorld);

            Vector3D.Cross(ref normal, ref otherDir, out otherDir);
            otherDir.Normalize();
            otherWorld = groundPos + otherDir * radius;
            var other2Surf = planet.GetClosestSurfacePointGlobal(ref otherWorld);

            var surfNorm = Vector3D.Cross(other2Surf - groundPos, other1Surf - groundPos);

            surfNorm.Normalize();
            score = Math.Abs(Vector3D.Dot(surfNorm, normal));
        }
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            m_waitForUpdate--;
            if (m_waitForUpdate > 0)
            {
                return;
            }
            m_waitForUpdate = UPDATE_DELAY;


            Vector3D position = MySector.MainCamera.Position;


            MyPlanet planet = MyGamePruningStructure.GetClosestPlanet(position);

            if (planet != null)
            {
                var distanceFromPlanet = Vector3D.Distance(planet.PositionComp.GetPosition(), position);
                if (distanceFromPlanet > planet.MaximumRadius + Math.Max(100, planet.MaximumRadius))
                {
                    ;
                }
                planet = null; //too far planet
            }

            if (m_closestPlanet != planet)
            {
                m_closestPlanet = planet;

                if (m_closestPlanet != null)
                {
                    MyStringId category   = MyStringId.GetOrCompute(m_closestPlanet.Generator.Id.SubtypeId.ToString());
                    MyStringId transition = MyStringId.GetOrCompute(m_closestPlanet.Generator.Id.SubtypeId.ToString());

                    if (!MyAudio.Static.IsValidTransitionCategory(transition, category))
                    {
                        category   = MyStringId.GetOrCompute("OtherPlanet");
                        transition = MyStringId.GetOrCompute("OtherPlanet");
                    }

                    MyMusicTrack mt = new MyMusicTrack()
                    {
                        MusicCategory      = category,
                        TransitionCategory = transition
                    };

                    MyAudio.Static.PlayMusic(mt);
                }
                else
                {
                    //random
                    MyMusicTrack mt = new MyMusicTrack()
                    {
                    };
                    MyAudio.Static.PlayMusic(mt, 1);
                }
            }
        }
Esempio n. 8
0
        public static Vector3D GetRandomDespawnCoords(Vector3D coords, double distance = 8000, double altitude = 1500)
        {
            Vector3D result = Vector3D.Zero;

            var planet          = MyGamePruningStructure.GetClosestPlanet(coords);
            var planetEntity    = planet as IMyEntity;
            var gravityProvider = planetEntity?.Components?.Get <MyGravityProviderComponent>();

            if (gravityProvider != null && gravityProvider.IsPositionInRange(coords))
            {
                var      up            = Vector3D.Normalize(coords - planetEntity.GetPosition());
                Vector3D randDirection = MyUtils.GetRandomPerpendicularVector(up);
                var      surfaceCoords = planet.GetClosestSurfacePointGlobal(randDirection * distance + coords);
                result = Vector3D.Normalize(surfaceCoords - planetEntity.GetPosition()) * altitude + surfaceCoords;
            }
            else if (planet != null)
            {
                var      up            = Vector3D.Normalize(coords - planetEntity.GetPosition());
                Vector3D randDirection = MyUtils.GetRandomPerpendicularVector(up);
                result = randDirection * distance + coords;
            }
            else
            {
                Vector3D randDirection = Vector3D.Normalize(MyUtils.GetRandomVector3D());
                return(randDirection * distance + coords);
            }

            return(result);
        }
Esempio n. 9
0
        private MyPlanet GetPlanet(Vector3D position)
        {
            int          num = 100;
            BoundingBoxD box = new BoundingBoxD(position - (num * 0.5f), position + (num * 0.5f));

            return(MyGamePruningStructure.GetClosestPlanet(ref box));
        }
Esempio n. 10
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));
                }
            }
        }
 public SpawnInfo(MyObjectBuilder_SpaceFaunaComponent.SpawnInfo info, int currentTime)
 {
     SpawnTime   = currentTime + info.SpawnTime;
     AbandonTime = currentTime + info.SpawnTime;
     Position    = new Vector3D(info.X, info.Y, info.Z);
     Planet      = MyGamePruningStructure.GetClosestPlanet(Position);
     SpawnDone   = false;
 }
Esempio n. 12
0
        /// <summary>
        /// Returns the planet closest to the given position
        /// </summary>
        /// <param name="position">3D Point from where the search is centered</param>
        /// <returns>The closest planet</returns>
        private MyPlanet GetPlanet(Vector3D position)
        {
            //TODO: what value to put here??? Warning - Also defined in other places
            int          voxelDistance = 500;
            BoundingBoxD box           = new BoundingBoxD(position - voxelDistance * 0.5f, position + voxelDistance * 0.5f);

            return(MyGamePruningStructure.GetClosestPlanet(ref box));
        }
Esempio n. 13
0
        private void FinalizeTargetDb()
        {
            MyPlanetTmp = MyGamePruningStructure.GetClosestPlanet(ScanVolume.Center);
            ObstructionsTmp.Clear();
            StaticsInRangeTmp.Clear();
            for (int i = 0; i < NearByEntitiesTmp; i++)
            {
                var ent = _possibleTargets[i];
                if (Session.ShieldApiLoaded && ent.DefinitionId?.SubtypeId == Session.ShieldHash && ent.Render.Visible)
                {
                    var shieldblock = Session.SApi.MatchEntToShieldFast(ent, false);
                    if (shieldblock != null)
                    {
                        NearByShieldsTmp.Add(new Shields {
                            Id = ent.Hierarchy.ChildId, ShieldEnt = ent, ShieldBlock = (MyCubeBlock)shieldblock
                        });
                    }
                }
                var voxel    = ent as MyVoxelBase;
                var grid     = ent as MyCubeGrid;
                var safeZone = ent as MySafeZone;

                var blockingThings = safeZone != null || ent.Physics != null && grid != null || voxel != null && voxel == voxel.RootVoxel;
                if (!blockingThings || voxel != null && (voxel.RootVoxel is MyPlanet || voxel.PositionComp.LocalVolume.Radius < 15))
                {
                    continue;
                }

                if (voxel != null || safeZone != null || ent.Physics.IsStatic)
                {
                    StaticsInRangeTmp.Add(ent);
                }

                GridMap map;
                if (grid != null && (PrevSubGrids.Contains(grid) || ValidGrids.Contains(ent) || grid.PositionComp.LocalVolume.Radius < 10 || Session.GridToInfoMap.TryGetValue(grid, out map) && map.Trash || grid.BigOwners.Count == 0))
                {
                    continue;
                }

                ObstructionsTmp.Add(ent);
            }


            foreach (var pair in NoTargetLos)
            {
                if (Session.Tick - pair.Value > 120)
                {
                    uint lastLosTick;
                    NoTargetLos.TryRemove(pair.Key, out lastLosTick);
                }
            }

            ValidGrids.Clear();
            _possibleTargets.Clear();
        }
Esempio n. 14
0
        public static Vector3D GetPlanetSurfaceCoordsAtPosition(Vector3D coords)
        {
            var planet = MyGamePruningStructure.GetClosestPlanet(coords);

            if (planet == null)
            {
                return(Vector3D.Zero);
            }

            return(GetPlanetSurfaceCoordsAtPosition(coords, planet));
        }
        private static MyPlanet FindNearestPlanet(Vector3D worldPosition)
        {
            BoundingBoxD bb          = new BoundingBoxD(worldPosition, worldPosition);
            MyPlanet     foundPlanet = MyGamePruningStructure.GetClosestPlanet(ref bb);

            if (foundPlanet != null && foundPlanet.AtmosphereAltitude > Vector3D.Distance(worldPosition, foundPlanet.PositionComp.GetPosition()))
            {
                foundPlanet = null;
            }

            return(foundPlanet);
        }
Esempio n. 16
0
        /// <summary>
        /// Computes the temperature at a given point in space.
        /// </summary>
        /// <param name="pos">Position</param>
        /// <returns>Background temperature (K)</returns>
        public static float TemperatureAtPoint(Vector3D pos)
        {
            var planet = MyGamePruningStructure.GetClosestPlanet(pos);

            if (planet != null)
            {
                var density = planet.GetAirDensity(pos);
                return(MathHelper.Lerp(TemperatureSpace, TemperatureSurface, MathHelper.Clamp(density * density, 0, 1)));
            }

            return(TemperatureSpace);
        }
            public SpawnTimeoutInfo(MyObjectBuilder_SpaceFaunaComponent.TimeoutInfo info, int currentTime)
            {
                TimeoutTime = currentTime + info.Timeout;
                Position    = new Vector3D(info.X, info.Y, info.Z);
                var planet = MyGamePruningStructure.GetClosestPlanet(Position);

                AnimalSpawnInfo = MySpaceBotFactory.GetDayOrNightAnimalSpawnInfo(planet, Position);
                if (AnimalSpawnInfo == null)
                {
                    TimeoutTime = currentTime;
                }
            }
Esempio n. 18
0
        /// <summary>
        /// Returns a position that should be safe to spawn at given the radius and position.
        /// </summary>
        /// <param name="collisionRadius">The radius of the object that is trying to spawn.</param>
        /// <param name="position">The position the object would like to spawn at.</param>
        /// <param name="forward">(Out) The forward vector the object should spawn with.</param>
        /// <param name="up">(Out) The up vector the object should spawn with.</param>
        /// <param name="planetSpawnHeightRatio">The ratio within the planet's max radius and atmosphere radius you are positioned in.</param>
        /// <param name="randomRangeMin">The minimum randomized distance that is added.</param>
        /// <param name="randomRangeMax">The minimum randomized distance that is added.</param>
        public static void GetSpawnPosition(float collisionRadius, ref Vector3D position, out Vector3D forward, out Vector3D up, float planetSpawnHeightRatio = 0.3f, float randomRangeMin = 500, float randomRangeMax = 650)
        {
            // Are we spawning near a planet?
            MyPlanet planet = MyGamePruningStructure.GetClosestPlanet(position);

            if (planet != null)
            {
                GetSpawnPositionNearPlanet(planet, collisionRadius, ref position, out forward, out up, planetSpawnHeightRatio, randomRangeMin, randomRangeMax);
                return;
            }

            // Old logic, testing for asteroids and other objects
            double distance = 0;

            foreach (var entity in MyEntities.GetEntities())
            {
                MyVoxelMap voxelMap = entity as MyVoxelMap;

                // Only test against voxels
                if (entity == null)
                {
                    continue;
                }

                distance = MathHelper.Max(distance, entity.PositionComp.WorldVolume.Center.Length() + entity.PositionComp.WorldVolume.Radius);
            }

            // Random range from last voxel
            distance += MyUtils.GetRandomFloat(randomRangeMin, randomRangeMax);

            if (MyEntities.IsWorldLimited())
            {
                distance = Math.Min(distance, MyEntities.WorldSafeHalfExtent());
            }
            else
            {
                distance = Math.Min(distance, 20000); // limited spawn area in infinite worlds
            }
            // Compute random position
            forward = MyUtils.GetRandomVector3Normalized();
            up      = Vector3D.CalculatePerpendicularVector(forward);
            Vector3D randomizedPosition = position + (forward * distance);

            // Test if we can spawn here
            Vector3D?searchPosition = MyEntities.FindFreePlace(randomizedPosition, collisionRadius);

            if (searchPosition.HasValue)
            {
                randomizedPosition = searchPosition.Value;
            }

            position = randomizedPosition;
        }
Esempio n. 19
0
        public static bool IsNight(Vector3D coords)
        {
            //Get Planet
            MyPlanet myPlanet = MyGamePruningStructure.GetClosestPlanet(coords);

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

            //Sun Rotation Axis
            var BaseSunDirectionNormalized = new Vector3(0.339467347f, 0.709795356f, -0.617213368f);

            var checkpoint = MyAPIGateway.Session.GetCheckpoint("null");

            foreach (var component in checkpoint.SessionComponents)
            {
                var weather = component as MyObjectBuilder_SectorWeatherComponent;

                if (weather != null)
                {
                    BaseSunDirectionNormalized.X = weather.BaseSunDirection.X;
                    BaseSunDirectionNormalized.Y = weather.BaseSunDirection.Y;
                    BaseSunDirectionNormalized.Z = weather.BaseSunDirection.Z;
                    break;
                }
            }


            Vector3 axis = (!(Math.Abs(Vector3.Dot(BaseSunDirectionNormalized, Vector3.Up)) > 0.95f)) ? Vector3.Cross(Vector3.Cross(BaseSunDirectionNormalized, Vector3.Up), BaseSunDirectionNormalized) : Vector3.Cross(Vector3.Cross(BaseSunDirectionNormalized, Vector3.Left), BaseSunDirectionNormalized);

            axis.Normalize();

            //Sun Direction
            var     speed        = 60f * MyAPIGateway.Session.SessionSettings.SunRotationIntervalMinutes;
            var     gameTime     = MyAPIGateway.Session.GameDateTime - new DateTime(2081, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            float   angle        = 6.283186f * (float)(gameTime.TotalSeconds / (double)speed);
            Vector3 sunDirection = Vector3.Transform(BaseSunDirectionNormalized, Matrix.CreateFromAxisAngle(axis, angle));

            sunDirection.Normalize();

            Vector3D result = coords - myPlanet.PositionComp.GetPosition();

            if ((float)result.Length() > myPlanet.MaximumRadius * 1.1f)
            {
                return(false);
            }

            Vector3 vector = Vector3.Normalize(result);

            return(Vector3.Dot(sunDirection, vector) < -0.1f);
        }
            public SpawnTimeoutInfo(Vector3D position, int currentTime)
            {
                TimeoutTime = currentTime;
                Position    = position;
                var planet = MyGamePruningStructure.GetClosestPlanet(Position);

                Debug.Assert(planet != null);
                AnimalSpawnInfo = MySpaceBotFactory.GetDayOrNightAnimalSpawnInfo(planet, Position);
                if (AnimalSpawnInfo == null)
                {
                    TimeoutTime = currentTime;
                }
            }
Esempio n. 21
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));
        }
Esempio n. 22
0
        private bool ElevationThreshold(Vector3D location)
        {
            var planet = MyGamePruningStructure.GetClosestPlanet(location);

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

            Vector3D surfaceLocation = planet.GetClosestSurfacePointGlobal(location);

            return(Vector3D.Distance(surfaceLocation, location) <= MaxHeight);
        }
Esempio n. 23
0
        public static double GetAltitudeAtPosition(Vector3D coords, MyPlanet planet = null)
        {
            if (planet == null)
            {
                planet = MyGamePruningStructure.GetClosestPlanet(coords);

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

            return(Vector3D.Distance(coords, GetPlanetSurfaceCoordsAtPosition(coords, planet)));
        }
Esempio n. 24
0
        public static float CalculateRequiredLift(MyCubeBlock block)
        {
            BoundingBoxD box           = block.PositionComp.WorldAABB;
            MyPlanet     closestPlanet = MyGamePruningStructure.GetClosestPlanet(ref box);

            if (closestPlanet == null)
            {
                return(0);
            }
            MyGravityProviderComponent myGravityProviderComponent = closestPlanet.Components.Get <MyGravityProviderComponent>();
            MatrixD worldMatrixRef = block.PositionComp.WorldMatrixRef;

            return(block.CubeGrid.Mass * myGravityProviderComponent.GetGravityMultiplier(worldMatrixRef.Translation) * GravityConstant);
        }
Esempio n. 25
0
        //GetDirectionAwayFromTarget
        public static Vector3D GetDirectionAwayFromTarget(Vector3D myPosition, Vector3D targetPosition)
        {
            var planet = MyGamePruningStructure.GetClosestPlanet(myPosition);

            if (planet == null)
            {
                return(Vector3D.Normalize(myPosition - targetPosition));
            }
            else
            {
                var mySealevel     = GetPlanetSealevelAtPosition(myPosition, planet);
                var targetSealevel = GetPlanetSealevelAtPosition(targetPosition, planet);
                return(Vector3D.Normalize(mySealevel - targetSealevel));
            }
        }
Esempio n. 26
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
        }
Esempio n. 27
0
        public void DrawLineFromPlayerToPlanetCentre()
        {
            var player         = MyAPIGateway.Session.Player;
            var playerPosition = player.Character.PositionComp.GetPosition();
            var lineColor      = Color.White.ToVector4();
            var closestPlanet  = MyGamePruningStructure.GetClosestPlanet(playerPosition);

            if (closestPlanet != null)
            {
                var planetCentre   = closestPlanet.PositionComp.GetPosition();
                var lineStartPoint = playerPosition;
                var lineEndPoint   = planetCentre;
                var lineCheck      = new LineD(lineStartPoint, lineEndPoint);
                DrawLine(lineColor, lineStartPoint, lineEndPoint);
            }
        }
        public override void Draw()
        {
            if (DebugDrawEnvironmentProviders)
            {
                foreach (var provider in m_environmentProviders)
                {
                    provider.DebugDraw();
                }
            }

            var closest = MyGamePruningStructure.GetClosestPlanet(MySector.MainCamera.Position);

            if (DebugDrawSectors && closest != null)
            {
                ActiveSector = closest.Components.Get <MyPlanetEnvironmentComponent>().GetSectorForPosition(MySector.MainCamera.Position);
            }
        }
        public float GetAirDensity(IMyCubeGrid grid)
        {
            Vector3D pos     = grid.PositionComp.GetPosition();
            Vector3  gravity = MyGravityProviderSystem.CalculateNaturalGravityInPoint(pos);

            if (gravity.LengthSquared() > 0f)
            {
                var planet = MyGamePruningStructure.GetClosestPlanet(pos);
                if (planet != null && planet.HasAtmosphere)
                {
                    return(-(planet.GetAirDensity(pos)));
                }
            }

            // Probably in space.
            return(0);
        }
Esempio n. 30
0
        public static MyPlanetNamesData GetPlanetNames(Vector3D position)
        {
            MyPlanetNamesData returnData = new MyPlanetNamesData();

            var planet = MyGamePruningStructure.GetClosestPlanet(position);

            if (planet != null)
            {
                returnData.planetName = planet.StorageName;
                returnData.planetType = planet.Generator.FolderName;
            }
            else
            {
                returnData.planetName = "";
                returnData.planetType = "";
            }
            return(returnData);
        }