Beispiel #1
0
            /// <summary>
            /// Renders the Window
            /// </summary>
            protected override void Render(Int32 id)
            {
                // Call base
                base.Render(id);

                // Scroll
                BeginScrollView(250, Utils.GetScrollSize <AtmosphereFromGround>() + distance * 3, 20);

                // Index
                index = 0;

                // Check for existing AFG
                if (Current.afg == null)
                {
                    Button(Localization.LOC_KITTOPIATECH_AFGEDITOR_ADD + " " + Current.displayName.Replace("^N", ""), () =>
                    {
                        // Create the atmosphere shell game object
                        GameObject scaledAtmosphere       = new GameObject("Atmosphere");
                        scaledAtmosphere.transform.parent = Current.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;
                        Current.afg = scaledAtmosphere.AddComponent <AtmosphereFromGround>();

                        // Register the AFG for updates
                        AFGInfo.StoreAFG(Current.afg);
                    });
                    return;
                }

                // Render AFG
                RenderObject(Current.afg);
                index++;

                // Updates
                Button(Localization.LOC_KITTOPIATECH_AFGEDITOR_UPDATE, () => { AtmosphereFromGroundLoader.CalculatedMembers(Current.afg); AFGInfo.PatchAFG(Current.afg); });

                // End Scroll
                EndScrollView();
            }
        private void Apply(AtmosphereFromGround afg)
        {
            Transform transform = afg.transform;

            afg.DEBUG_alwaysUpdateAll = _debugAlwaysUpdateAll;
            afg.doScale          = _doScale;
            afg.ESun             = _eSun;
            afg.Kr               = _kr;
            afg.Km               = _km;
            transform.localScale = _transformScale;
            afg.scaleDepth       = _scaleDepth;
            afg.samples          = _samples;
            afg.g                   = _g;
            afg.waveLength          = _waveLength;
            afg.invWaveLength       = _invWaveLength;
            afg.outerRadius         = _outerRadius;
            afg.innerRadius         = _innerRadius;
            transform.localPosition = Vector3.zero;

            AtmosphereFromGroundLoader.CalculatedMembers(afg);
            afg.SetMaterial(true);

            Events.OnRuntimeUtilityPatchAFG.Fire(afg);
        }
            // Parser apply event
            void IParserEventSubscriber.Apply(ConfigNode node)
            {
                // If we don't want an atmosphere, ignore this step
                if(!celestialBody.atmosphere || !addAFG)
                    return;

                // If we don't already have an atmospheric shell generated
                if (scaledVersion.GetComponentsInChildren<AtmosphereFromGround> (true).Length == 0)
                {
                    // Add the material light direction behavior
                    MaterialSetDirection materialLightDirection = scaledVersion.AddComponent<MaterialSetDirection>();
                    materialLightDirection.valueName            = "_localLightDirection";

                    // Create the atmosphere shell game object
                    GameObject scaledAtmosphere       = new GameObject("Atmosphere");
                    scaledAtmosphere.transform.parent = scaledVersion.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;
                    scaledAtmosphere.AddComponent<AtmosphereFromGround>();

                    // Store the AFG
                    atmosphereFromGround = new AtmosphereFromGroundLoader();

                    // Setup known defaults
                    celestialBody.atmospherePressureSeaLevel = 1.0f;
                }
            }