Example #1
0
        public static void NewEntityDetected(IMyEntity entity)
        {
            var cubeGrid = entity as IMyCubeGrid;

            if (cubeGrid != null)
            {
                lock (GridManager.Grids) {
                    var gridEntity = new GridEntity(entity);
                    UnloadEntities += gridEntity.Unload;
                    GridManager.Grids.Add(gridEntity);
                }

                return;
            }

            var planet = entity as MyPlanet;

            if (planet != null)
            {
                var planetEntity = new PlanetEntity(entity);
                UnloadEntities += planetEntity.Unload;
                Planets.Add(planetEntity);
                return;
            }

            var safezone = entity as MySafeZone;

            if (safezone != null)
            {
                var safezoneEntity = new SafeZoneEntity(entity);
                UnloadEntities += safezoneEntity.Unload;
                SafeZones.Add(safezoneEntity);
                return;
            }
        }
Example #2
0
        public static double AltitudeAtPosition(Vector3D coords, PlanetEntity planet)
        {
            if (planet.Closed)
            {
                return(-1000000);
            }

            var surfaceCoords     = planet.Planet.GetClosestSurfacePointGlobal(coords);
            var myDistToCore      = Vector3D.Distance(coords, planet.GetPosition());
            var surfaceDistToCore = Vector3D.Distance(surfaceCoords, planet.GetPosition());

            return(myDistToCore - surfaceDistToCore);
        }
Example #3
0
 public static double GravityAtPosition(Vector3D coords, PlanetEntity planet)
 {
     return(planet.Gravity.GetGravityMultiplier(coords));
 }