Example #1
0
            /// <summary>
            /// Creates a new Body from a spawned CelestialBody.
            /// </summary>
            public Body(CelestialBody celestialBody)
            {
                this.celestialBody = celestialBody;

                // Create the accessors
                properties = new PropertiesLoader(celestialBody);
                if (celestialBody.orbitDriver != null)
                {
                    orbit = new OrbitLoader(celestialBody);
                }
                scaledVersion = new ScaledVersionLoader(celestialBody);
                if (celestialBody.atmosphere)
                {
                    atmosphere = new AtmosphereLoader(celestialBody);
                }
                pqs   = new PQSLoader(celestialBody);
                ocean = new OceanLoader(celestialBody);
                rings = new List <RingLoader>();
                foreach (Ring ring in celestialBody.scaledBody.GetComponentsInChildren <Ring>(true))
                {
                    rings.Add(new RingLoader(ring));
                }
                particles = new List <ParticleLoader>();
                foreach (PlanetParticleEmitter particle in celestialBody.scaledBody
                         .GetComponentsInChildren <PlanetParticleEmitter>(true))
                {
                    particles.Add(new ParticleLoader(particle));
                }
                if (celestialBody.isHomeWorld)
                {
                    spaceCenter = new SpaceCenterLoader(celestialBody);
                }
                debug = new DebugLoader(celestialBody);
            }
Example #2
0
        /// <summary>
        /// Creates a new Body from a spawned CelestialBody.
        /// </summary>
        public Body(CelestialBody celestialBody)
        {
            CelestialBody = celestialBody;
            Name          = celestialBody.transform.name;

            // Create the accessors
            Properties = new PropertiesLoader(celestialBody);
            if (celestialBody.orbitDriver != null)
            {
                Orbit = new OrbitLoader(celestialBody);
            }

            ScaledVersion = new ScaledVersionLoader(celestialBody);
            if (celestialBody.atmosphere)
            {
                Atmosphere = new AtmosphereLoader(celestialBody);
            }

            if (celestialBody.pqsController != null)
            {
                Pqs = new PQSLoader(celestialBody);
                if (celestialBody.pqsController.GetComponentsInChildren <PQS>(true)
                    .Any(p => p.name.EndsWith("Ocean")))
                {
                    Ocean = new OceanLoader(celestialBody);
                }
            }

            Rings = new List <RingLoader>();
            foreach (Ring ring in celestialBody.scaledBody.GetComponentsInChildren <Ring>(true))
            {
                Rings.Add(new RingLoader(ring));
            }

            Particles = new List <ParticleLoader>();
            foreach (PlanetParticleEmitter particle in celestialBody.scaledBody
                     .GetComponentsInChildren <PlanetParticleEmitter>(true))
            {
                Particles.Add(new ParticleLoader(particle));
            }

            HazardousBody = new List <HazardousBodyLoader>();
            foreach (HazardousBody body in celestialBody.GetComponents <HazardousBody>())
            {
                HazardousBody.Add(new HazardousBodyLoader(body));
            }

            if (celestialBody.isHomeWorld)
            {
                SpaceCenter = new SpaceCenterLoader(celestialBody);
            }

            Debug = new DebugLoader(celestialBody);
        }