コード例 #1
0
            // Parser post apply event
            void IParserEventSubscriber.PostApply(ConfigNode node)
            {
                // Recalculate with the new values and store
                CalculatedMembers(Value);
                AFGInfo.StoreAFG(Value);

                // Fire event
                Events.OnAFGLoaderPostApply.Fire(this, node);
            }
コード例 #2
0
            public AtmosphereFromGroundLoader(CelestialBody body)
            {
                // Is this a spawned body?
                if (body?.scaledBody == null)
                {
                    throw new InvalidOperationException("The body must be already spawned by the PSystemManager.");
                }

                // Store values
                Value = body.afg;

                if (Value == null)
                {
                    // Add the material light direction behavior
                    MaterialSetDirection materialLightDirection = body.scaledBody.AddComponent <MaterialSetDirection>();
                    materialLightDirection.valueName = "_localLightDirection";

                    // Create the atmosphere shell game object
                    GameObject scaledAtmosphere = new GameObject("Atmosphere");
                    scaledAtmosphere.transform.parent = body.scaledBody.transform;
                    scaledAtmosphere.layer            = Constants.GameLayers.ScaledSpaceAtmosphere;
                    MeshRenderer renderer = scaledAtmosphere.AddComponent <MeshRenderer>();
                    renderer.sharedMaterial = new MaterialWrapper.AtmosphereFromGround();
                    MeshFilter meshFilter = scaledAtmosphere.AddComponent <MeshFilter>();
                    meshFilter.sharedMesh = Templates.ReferenceGeosphere;
                    Value            = body.afg = scaledAtmosphere.AddComponent <AtmosphereFromGround>();
                    Value.planet     = body;
                    Value.sunLight   = Sun.Instance.gameObject;
                    Value.mainCamera = ScaledCamera.Instance.transform;
                    AFGInfo.StoreAFG(Value);
                    AFGInfo.PatchAFG(Value);

                    // Set defaults
                    SetDefaultValues();
                }

                Value.planet = body;
            }