private static void SetupFootprintPrefab()
            {
                footprintPrefab       = new GameObject("KerbalEVAFootprint");
                footprintPrefab.layer = GameLayers.LOCAL_SPACE;
                footprintPrefab.SetActive(false);

                MeshFilter   mf = footprintPrefab.AddComponent <MeshFilter>();
                MeshRenderer mr = footprintPrefab.AddComponent <MeshRenderer>();

                mf.mesh = new Quad(0.15f, 0.3f, true);

                Material        material      = new Material(ShaderLoader.GetShader("KopernicusExpansion/Footprint"));
                Texture2DParser footprintMask = new Texture2DParser();

                footprintMask.SetFromString("KopernicusExpansion/Textures/KerbalEVAFootprintMask");
                material.SetTexture("_MainTex", footprintMask);
                material.SetFloat("_Opacity", 0.8f);
                material.SetColor("_Color", Color.black);
                mr.material          = material;
                mr.shadowCastingMode = ShadowCastingMode.Off;
                footprintPrefab.AddComponent <EVAFootprint>();
                Debug.Log("[KopernicusExpansion] Footprint prefab created");
            }
Beispiel #2
0
                void IParserEventSubscriber.PostApply(ConfigNode node)
                {
                    if (node.HasNode("Watermain"))
                    {
                        // Parse the watermain textures
                        ConfigNode watermain = node.GetNode("Watermain");

                        // Set the Watermain length
                        _mod.waterMainLength = watermain.values.Count;

                        // If the count doesn't matches, recreate the array
                        if (_mod.watermain.Length != _mod.waterMainLength)
                        {
                            _mod.watermain = new Texture2D[(int)_mod.waterMainLength];
                        }

                        // Load the textures
                        int i = 0;
                        foreach (string s in watermain.GetValuesStartsWith("waterTex-"))
                        {
                            Texture2DParser texParser = new Texture2DParser();
                            texParser.SetFromString(s);
                            _mod.watermain[i] = texParser.value;
                            i++;
                        }
                    }
                }
Beispiel #3
0
        void IParserEventSubscriber.PostApply(ConfigNode node)
        {
            // Apply changes to the Material
            Material material = generatedBody.scaledVersion.GetComponent <Renderer>()?.sharedMaterial;

            if (material != null)
            {
                if (emitColor0?.value != null)
                {
                    Color color = Pick(emitColor0);

                    material.SetColor("_EmitColor0", color);

                    if (emitColorMult != null)
                    {
                        material.SetColor("_EmitColor1", color * emitColorMult);
                    }

                    if (rimColorMult != null)
                    {
                        material.SetColor("_RimColor", color * rimColorMult);
                    }
                }

                if (emitColor1 != null)
                {
                    material.SetColor("_EmitColor1", Pick(emitColor1));
                }

                if (sunspotColor == null)
                {
                    sunspotColor = emitColor0;
                }

                if (sunspotTemp == null)
                {
                    sunspotTemp = temperature;
                }

                material.SetColor("_SunspotColor", Pick(sunspotColor, sunspotTemp) * sunspotColorMult);

                if (type == StarType.WhiteDwarf)
                {
                    material.SetColor("_EmitColor0", new Color(0.9f, 0.9f, 0.9f, 1));
                    material.SetColor("_EmitColor1", material.GetColor("_EmitColor1") * 0.925f);
                }
            }


            // Apply changes to the LightShifter
            LightShifter light = generatedBody.scaledVersion.GetComponentInChildren <LightShifter>();

            if (light != null)
            {
                if (lightColors == null)
                {
                    lightColors = emitColor0;
                }

                Color color = Pick(lightColors) * lightColorMult;

                light.ambientLightColor   = new Color(0, 0, 0, 1);
                light.IVASunColor         = color;
                light.scaledSunlightColor = color;
                light.sunlightColor       = color;
            }


            // Set Orbit Color
            if (setOrbit.value && emitColor0 != null)
            {
                generatedBody.orbitRenderer.SetColor(Pick(emitColor0));
            }
        }
        // Post apply event
        void IParserEventSubscriber.PostApply(ConfigNode node)
        {
            Logger.Active.Log("============= Scaled Version Dump ===================");
            Utility.GameObjectWalk(Value.scaledBody);
            Logger.Active.Log("===========================================");

            // If we are a star, we need to generate the coronas
            if (Type.Value == BodyType.Star)
            {
                // Restore backed up coronas if no custom ones were specified
                if (!Coronas.Any())
                {
                    foreach (SunCoronas corona in Utility.Deactivator.GetComponentsInChildren <SunCoronas>(true)
                             .Where(c => c.transform.parent == Utility.Deactivator))
                    {
                        corona.transform.parent = Value.scaledBody.transform;
                    }
                }
                else
                {
                    foreach (SunCoronas corona in Utility.Deactivator.GetComponentsInChildren <SunCoronas>(true)
                             .Where(c => c.transform.parent == Utility.Deactivator))
                    {
                        corona.transform.parent = null;
                        Object.Destroy(corona.gameObject);
                    }
                }
            }

            // If we use OnDemand, we need to delete the original textures and reload them
            if (Type.Value != BodyType.Star && OnDemandTextures != null)
            {
                if (OnDemandStorage.UseOnDemand)
                {
                    ScaledSpaceOnDemand onDemand = Value.scaledBody.AddComponent <ScaledSpaceOnDemand>();
                    onDemand.texture = OnDemandTextures.Texture;
                    onDemand.normals = OnDemandTextures.Normals;

                    // Delete the original scaled space textures
                    if (OnDemandTextures.Texture != null)
                    {
                        Texture2D texture = new Texture2D(1, 1);
                        texture.Apply();
                        Material.SetTexture(MainTex, texture);
                    }

                    if (OnDemandTextures.Normals != null)
                    {
                        Texture2D texture = new Texture2D(1, 1);
                        texture.Apply();
                        Material.SetTexture(BumpMap, texture);
                    }
                }
                else
                {
                    // If OD isn't enabled, load the textures, assign them and don't care anymore
                    Texture2DParser parser = new Texture2DParser();

                    if (OnDemandTextures.Texture != null)
                    {
                        parser.SetFromString(OnDemandTextures.Texture);
                        Material.SetTexture(MainTex, parser);
                    }

                    if (OnDemandTextures.Normals != null)
                    {
                        parser.SetFromString(OnDemandTextures.Normals);
                        Material.SetTexture(BumpMap, parser);
                    }
                }
            }

            // Event
            Events.OnScaledVersionLoaderPostApply.Fire(this, node);
        }