Exemplo n.º 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 {}
        }
Exemplo n.º 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);
        }