Exemple #1
0
        public void AddStar(string Name, CustomStar CStar)
        {
            Stars.Add(Name, new FixedStar(Name, CStar));

            try
            {
                CStar.Enabled = false;
                CStar.SunlightEnabled(false);

                Sun.Instance.SunlightEnabled(true);
            }catch {}
        }
Exemple #2
0
        //Reslah fix ported for multiuse
        public static CustomStar FixStar(string starName)
        {
            //Get defualt stuff
            GameObject Scenery     = GameObject.Find("Scenery");
            Sun        DefualtStar = Scenery.GetComponentInChildren <Sun>();

            //Create a new instance of "scenery star"
            GameObject newSceneryStar = new GameObject(starName + "_scenery");

            newSceneryStar.name             = starName + "_scenery";
            newSceneryStar.transform.parent = Scenery.transform;

            //Create a new lense flare, and dump the existing suns data to it.
            LensFlare NewLenseFlare = newSceneryStar.AddComponent <LensFlare>();

            NewLenseFlare.color = GameObject.Find("SunLight").GetComponentInChildren <LensFlare>().color;
            NewLenseFlare.flare = GameObject.Find("SunLight").GetComponentInChildren <LensFlare>().flare;

            //Add the "light"
            Light newLight = newSceneryStar.AddComponent <Light>();

            //Create a new instance of "CustomStar"
            CustomStar newStar = newSceneryStar.AddComponent <CustomStar>();

            newStar.name            = starName + "Sun";
            newStar.target          = DefualtStar.target;
            newStar.brightnessCurve = DefualtStar.brightnessCurve;
            newStar.AU        = DefualtStar.AU;
            newStar.sun       = Utils.FindCB(starName);
            newStar.sunFlare  = NewLenseFlare;
            newStar.localTime = DefualtStar.localTime;
            newStar.fadeStart = DefualtStar.fadeStart;
            newStar.fadeEnd   = DefualtStar.fadeEnd;

            newLight.type      = DefualtStar.light.type;
            newLight.intensity = DefualtStar.light.intensity;
            newLight.color     = DefualtStar.light.color;
            newLight.enabled   = false;

            newLight.transform.position = Utils.FindCB(starName).transform.position;
            newLight.transform.parent   = Utils.FindCB(starName).transform.parent;

            newStar.MYLight = newLight;

            newSceneryStar.transform.position = Utils.FindScaled(starName).transform.position;
            newSceneryStar.transform.parent   = Utils.FindScaled(starName).transform;
            newSceneryStar.layer = Utils.FindScaled(starName).layer;

            //Sun Shader:
            //SunShaderController Hack_SSS = Utils.FindScaled(starName).GetComponentInChildren<SunShaderController>();
            try
            {
                RecursiveFixAtmo(Utils.FindCB(starName), starName);

                GameObject DetectorGOB;

                if (GameObject.FindObjectOfType <StarDetector>( ) == null)                 //spawn a new detector
                {
                    DetectorGOB = new GameObject("StarDetector");
                    DetectorGOB.AddComponent <StarDetector>();
                    GameObject.DontDestroyOnLoad(DetectorGOB);
                }
                else
                {
                    DetectorGOB = GameObject.FindObjectOfType <StarDetector>().gameObject;
                }

                StarDetector StarFixer = DetectorGOB.GetComponent <StarDetector>( );
                StarFixer.AddStar(starName, newStar);

                newStar.Enabled = false;
                newStar.SunlightEnabled(false);
            }catch (Exception e) { Debug.Log("PLANETUI: Exeption thrown in StarFix: " + e + "\n"); }
            //If all else fails, at least return the star
            return(newStar);
        }
        private void StarEditorUI()
        {
            int yoffset = 280;

            if( TemplateName == "" )
            {
                GUI.Label( new Rect( 20 , yoffset, 200, 20), "NO PLANET SELECTED" );
                return;
            }

            if( PlanetarySettings[ TemplateName ].HasStarFix == true )
            {
                StarToEdit = PlanetarySettings[ TemplateName ].Star;

                GUI.Label( new Rect( 20, yoffset, 200, 20 ), "Flare Colour" );
                if( GUI.Button( new Rect( 150 , yoffset, 50, 20), "Edit" ) )
                {
                    Color getColour = StarToEdit.sunFlare.color;
                    rVal = getColour.r;
                    gVal = getColour.g;
                    bVal = getColour.b;
                    aVal = getColour.a;

                    objToEdit = (System.Object)this;
                    KeyToEdit = this.GetType().GetField("FlareColour");

                    isshowingColourEditor = true;
                }
                yoffset += 30;

                GUI.Label( new Rect( 20, yoffset, 200, 20 ), "Light Colour" );
                if( GUI.Button( new Rect( 150 , yoffset, 50, 20), "Edit" ) )
                {
                    Color getColour = StarToEdit.sunFlare.color;
                    rVal = getColour.r;
                    gVal = getColour.g;
                    bVal = getColour.b;
                    aVal = getColour.a;

                    objToEdit = (System.Object)this;
                    KeyToEdit = this.GetType().GetField("LightColour");

                    isshowingColourEditor = true;
                }
                yoffset += 30;

                GUI.Label( new Rect( 20, yoffset, 200, 20 ), "Rim Colour" );
                if( GUI.Button( new Rect( 150 , yoffset, 50, 20), "Edit" ) )
                {
                    Color getColour = RimColour = Utils.FindScaled( TemplateName ).renderer.material.GetColor( "_RimColor" );
                    rVal = getColour.r;
                    gVal = getColour.g;
                    bVal = getColour.b;
                    aVal = getColour.a;

                    objToEdit = (System.Object)this;
                    KeyToEdit = this.GetType().GetField("RimColour");

                    isshowingColourEditor = true;
                }
                yoffset += 30;

                GUI.Label( new Rect( 20, yoffset, 200, 20 ), "Spot Colour" );
                if( GUI.Button( new Rect( 150 , yoffset, 50, 20), "Edit" ) )
                {
                    Color getColour = SpotColour = Utils.FindScaled( TemplateName ).renderer.material.GetColor( "_SunspotColor" );
                    rVal = getColour.r;
                    gVal = getColour.g;
                    bVal = getColour.b;
                    aVal = getColour.a;

                    objToEdit = (System.Object)this;
                    KeyToEdit = this.GetType().GetField("SpotColour");

                    isshowingColourEditor = true;
                }
                yoffset += 30;

                GUI.Label( new Rect( 20, yoffset, 200, 20 ), "Emit Colour" );
                if( GUI.Button( new Rect( 150 , yoffset, 50, 20), "Edit" ) )
                {
                    Color getColour = EmitColour = Utils.FindScaled( TemplateName ).renderer.material.GetColor( "_SunspotColor" );
                    rVal = getColour.r;
                    gVal = getColour.g;
                    bVal = getColour.b;
                    aVal = getColour.a;

                    objToEdit = (System.Object)this;
                    KeyToEdit = this.GetType().GetField("EmitColour");

                    isshowingColourEditor = true;
                }
                yoffset += 30;

                StarToEdit.sunFlare.color = FlareColour;
                StarToEdit.MYLight.color = LightColour;
                Utils.FindScaled( TemplateName ).renderer.material.SetColor( "_RimColor", RimColour );
                Utils.FindScaled( TemplateName ).renderer.material.SetColor( "_SunspotColor", SpotColour );
                Utils.FindScaled( TemplateName ).renderer.material.SetColor( "_EmitColor0", EmitColour );
                Utils.FindScaled( TemplateName ).renderer.material.SetColor( "_EmitColor1", EmitColour );

                foreach( SunCoronas corona in Utils.FindScaled( TemplateName ).GetComponentsInChildren<SunCoronas>() )
                {
                    corona.gameObject.GetComponentInChildren<MeshRenderer>().material.color = FlareColour;
                }

                PlanetarySettings[ TemplateName ].FlareLight = StarToEdit.sunFlare.color;
                PlanetarySettings[ TemplateName ].LightColour = StarToEdit.MYLight.color;
                PlanetarySettings[ TemplateName ].RimColour = RimColour;
                PlanetarySettings[ TemplateName ].SpotColour = SpotColour;
                PlanetarySettings[ TemplateName ].EmitColour = EmitColour;
            }
            else if( PlanetarySettings[ TemplateName ].HasStarFix == false )
            {
                if( GUI.Button( new Rect( 20 , yoffset, 200, 20), "Add StarFix to: " +TemplateName ) )
                {
                    PlanetarySettings[ TemplateName ].HasStarFix = true;
                    PlanetarySettings[ TemplateName ].Star = PlanetUtils.FixStar( TemplateName );

                    FlareColour = PlanetarySettings[ TemplateName ].Star.sunFlare.color;
                    LightColour = PlanetarySettings[ TemplateName ].Star.MYLight.color;
                }
            }
        }
Exemple #4
0
 public FixedStar(string IName, CustomStar ICStar)
 {
     Name  = IName;
     CStar = ICStar;
 }