Ejemplo n.º 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);
            }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
            // Sun

            // Parser Apply Event
            public void Apply(ConfigNode node)
            {
                // If we have a template, generatedBody *is* the template body
                if (template != null)
                {
                    generatedBody = template.body;

                    // Patch the game object names in the template
                    generatedBody.name = name;
                    generatedBody.celestialBody.bodyName = name;
                    generatedBody.scaledVersion.name     = name;
                    if (generatedBody.pqsVersion != null)
                    {
                        foreach (PQS p in generatedBody.pqsVersion.GetComponentsInChildren(typeof(PQS), true))
                        {
                            p.name = p.name.Replace(template.body.celestialBody.bodyName, name);
                        }
                    }

                    // If this body has an orbit, create editor/loader
                    if (generatedBody.orbitDriver != null)
                    {
                        orbit = new OrbitLoader(generatedBody);
                    }

                    // If this body has a PQS, create editor/loader
                    if (generatedBody.pqsVersion != null)
                    {
                        pqs = new PQSLoader(generatedBody.pqsVersion);
                    }

                    // Create the scaled version editor/loader
                    scaledVersion = new ScaledVersion(generatedBody.scaledVersion, generatedBody.celestialBody, template.type);
                }

                // Otherwise we have to generate all the things for this body
                else
                {
                    // Create the PSystemBody object
                    GameObject generatedBodyGameObject = new GameObject(name);
                    generatedBodyGameObject.transform.parent = Utility.Deactivator;
                    generatedBody = generatedBodyGameObject.AddComponent <PSystemBody> ();
                    generatedBody.flightGlobalsIndex = 0;

                    // Create the celestial body
                    GameObject generatedBodyProperties = new GameObject(name);
                    generatedBodyProperties.transform.parent = generatedBodyGameObject.transform;
                    generatedBody.celestialBody = generatedBodyProperties.AddComponent <CelestialBody> ();
                    generatedBody.resources     = generatedBodyProperties.AddComponent <PResource> ();

                    // Sensible defaults
                    generatedBody.celestialBody.bodyName   = name;
                    generatedBody.celestialBody.atmosphere = false;
                    generatedBody.celestialBody.ocean      = false;

                    // Create the scaled version
                    generatedBody.scaledVersion                  = new GameObject(name);
                    generatedBody.scaledVersion.layer            = Constants.GameLayers.ScaledSpace;
                    generatedBody.scaledVersion.transform.parent = Utility.Deactivator;

                    // Create the scaled version editor/loader
                    scaledVersion = new ScaledVersion(generatedBody.scaledVersion, generatedBody.celestialBody, BodyType.Atmospheric);
                }

                // Create property editor/loader objects
                properties = new Properties(generatedBody.celestialBody);

                // Atmospheric settings
                atmosphere = new Atmosphere(generatedBody.celestialBody, generatedBody.scaledVersion);
            }