예제 #1
0
        public static void OnGalaxyDataReset_Prefix(UIVirtualStarmap __instance)
        {
            __instance.clickText = ""; // reset to vanilla

            foreach (UIVirtualStarmap.ConnNode connNode in __instance.connPool)
            {
                connNode.lineRenderer.positionCount = 2;
            }
        }
예제 #2
0
 public static void Postfix(UIVirtualStarmap __instance)
 {
     UnityEngine.Debug.Log("In UIVirtualStarmap::_OnCreate()");
     UnityEngine.Debug.Log("neutronStarColor = " + __instance.neutronStarColor);
     UnityEngine.Debug.Log("whiteDwarfColor = " + __instance.whiteDwarfColor);
     UnityEngine.Debug.Log("blackholeColor = " + __instance.blackholeColor);
     for (int i = 0; i < __instance.starColors.colorKeys.Length; i++)
     {
         UnityEngine.Debug.Log("colorKey[" + i + "]: " + __instance.starColors.colorKeys[i].color + " @ " + __instance.starColors.colorKeys[i].time);
     }
     for (int i = 0; i < __instance.starColors.alphaKeys.Length; i++)
     {
         UnityEngine.Debug.Log("alphaKey[" + i + "]: " + __instance.starColors.alphaKeys[i].alpha + " @ " + __instance.starColors.alphaKeys[i].time);
     }
 }
        private static void ClearStarmap(UIVirtualStarmap starmap)
        {
            starmap.starPointBirth.gameObject.SetActive(false);

            foreach (UIVirtualStarmap.StarNode starNode in starmap.starPool)
            {
                starNode.active   = false;
                starNode.starData = null;
                starNode.pointRenderer.gameObject.SetActive(false);
                starNode.nameText.gameObject.SetActive(false);
            }
            foreach (UIVirtualStarmap.ConnNode connNode in starmap.connPool)
            {
                connNode.active = false;
                connNode.starA  = null;
                connNode.starB  = null;
                connNode.lineRenderer.gameObject.SetActive(false);
            }
        }
예제 #4
0
파일: TEST.cs 프로젝트: zealyahweh/DSPMOD
        public static void Postfix(UIVirtualStarmap __instance)
        {
            if (__instance.galaxyData == null)
            {
            }
            else
            {
                //System.Console.WriteLine("Refreshed");
                bool       TideLockFound  = false;
                bool       CloseMagFound  = false;
                bool       SuperStarFound = false;
                string     sTideLock      = "潮汐锁定";
                var        vResourceType  = new string[] { "无", "铁矿", "铜矿", "硅矿", "钛矿", "石矿", "煤矿", "石油", "可燃冰", "金伯利", "分形硅", "有机晶", "光栅石", "刺笋", "磁石" };
                var        vPlanetType    = new string[] { "None", "Vocano", "Ocean", "Desert", "Ice", "Gas", };
                var        vPlanetTheme   = new string[] { "无", "地中海", "气态巨星", "气态巨星", "冰巨星", "冰巨星", "干旱荒漠", "灰烬冻土", "海洋丛林", "熔岩", "冰原冻土", "贫瘠荒漠", "戈壁", "火山灰", "红石", "草原", "水世界" };
                StarData[] StarList       = __instance.galaxyData.stars;
                StarData   BirthStar      = StarList[0];
                string     BirthStarName  = BirthStar.name;
                int        Seed           = __instance.galaxyData.seed;

                var sPlanetData = new string[4];
                for (int PlanetIndex = 0; PlanetIndex < BirthStar.planetCount; PlanetIndex++)
                {
                    string pTheme = vPlanetTheme[BirthStar.planets[PlanetIndex].theme];
                    string sSin   = BirthStar.planets[PlanetIndex].singularityString;
                    if (sSin.Contains(sTideLock))
                    {
                        TideLockFound = true;
                    }
                    sPlanetData[PlanetIndex] = "[" + (PlanetIndex + 1).ToString() + "]" + pTheme + "\t" + sSin;
                }

                int    StarCount           = 0;
                int    NearStar            = 0;
                int    BlackHoleMagCount   = 0;
                int    NeutronStarMagCount = 0;
                double BlackHoleDistance   = 0;
                double NeutronStarDistance = 0;
                int    AcidCount           = 0;
                var    vRareCount          = new int[15];
                Array.Clear(vRareCount, 0, vRareCount.Length);

                for (int StarIndex = 0; StarIndex < StarList.Length; StarIndex++)
                {
                    StarCount++;
                    PlanetData[] PlanetList = StarList[StarIndex].planets;

                    if (StarList[StarIndex].type == EStarType.BlackHole)
                    {
                        BlackHoleDistance  = StarList[StarIndex].position.magnitude;
                        BlackHoleMagCount += PlanetList[0].veinSpotsSketch[14];
                        if (BlackHoleDistance < 6)
                        {
                            CloseMagFound = true;
                        }
                    }

                    if (StarList[StarIndex].type == EStarType.NeutronStar)
                    {
                        NeutronStarDistance  = StarList[StarIndex].position.magnitude;
                        NeutronStarMagCount += PlanetList[0].veinSpotsSketch[14];
                        if (NeutronStarDistance < 6)
                        {
                            CloseMagFound = true;
                        }
                    }

                    if (StarList[StarIndex].position.magnitude < 6 && StarIndex != 0)
                    {
                        NearStar++;
                        bool IsSuperStar = true;
                        var  vLocalRare  = new int[16];
                        foreach (PlanetData oPlanet in PlanetList)
                        {
                            if (oPlanet.type != EPlanetType.Gas)
                            {
                                for (int RareIndex = 0; RareIndex < vRareCount.Length; RareIndex++)
                                {
                                    vLocalRare[RareIndex] += oPlanet.veinSpotsSketch[RareIndex];
                                    vRareCount[RareIndex] += oPlanet.veinSpotsSketch[RareIndex];
                                }
                            }
                            if (oPlanet.theme == 13)
                            {
                                AcidCount      += 1;
                                vLocalRare[15] += 1;
                            }
                        }


                        for (int index3 = 1; index3 < vLocalRare.Length; index3++)
                        {
                            if (vLocalRare[index3] == 0 && index3 != 14)
                            {
                                IsSuperStar = false;
                            }
                        }

                        if (IsSuperStar)
                        {
                            SuperStarFound = true;
                        }
                    }
                }

                string sRareName = "六光年内\t";
                for (int i = 8; i < 15; i++)
                {
                    sRareName += vResourceType[i] + "\t";
                }
                sRareName += "硫酸";


                string sRareCount = "数量:\t";
                for (int i = 8; i < 15; i++)
                {
                    sRareCount += vRareCount[i] + "\t";
                }
                sRareCount += AcidCount;


                //if (TideLockFound && CloseMagFound)
                if (SuperStarFound && TideLockFound && CloseMagFound)
                {
                    System.Console.WriteLine("种子: " + Seed);
                    //System.Console.WriteLine("初始恒星: " + BirthStarName);
                    foreach (string sLine in sPlanetData)
                    {
                        System.Console.WriteLine(sLine);
                    }
                    System.Console.WriteLine(sRareName);
                    System.Console.WriteLine(sRareCount);
                    System.Console.WriteLine("恒星数目\t" + NearStar + "/" + StarCount);
                    System.Console.WriteLine("黑洞距离\t" + BlackHoleDistance.ToString("0.##") + "\t磁石数目:\t" + BlackHoleMagCount);
                    System.Console.WriteLine("中子距离\t" + NeutronStarDistance.ToString("0.##") + "\t磁石数目:\t" + NeutronStarMagCount);
                    System.Console.WriteLine("");
                }
            }
        }
        // probably reverse patch this if there is time
        private static void AddStarToStarmap(UIVirtualStarmap starmap, StarData starData)
        {
            Color color = starmap.starColors.Evaluate(starData.color);

            if (starData.type == EStarType.NeutronStar)
            {
                color = starmap.neutronStarColor;
            }
            else if (starData.type == EStarType.WhiteDwarf)
            {
                color = starmap.whiteDwarfColor;
            }
            else if (starData.type == EStarType.BlackHole)
            {
                color = starmap.blackholeColor;
            }
            float num2 = 1.2f;

            if (starData.type == EStarType.GiantStar)
            {
                num2 = 3f;
            }
            else if (starData.type == EStarType.WhiteDwarf)
            {
                num2 = 0.6f;
            }
            else if (starData.type == EStarType.NeutronStar)
            {
                num2 = 0.6f;
            }
            else if (starData.type == EStarType.BlackHole)
            {
                num2 = 0.8f;
            }
            string text = starData.displayName + "  ";

            if (starData.type == EStarType.GiantStar)
            {
                if (starData.spectr <= ESpectrType.K)
                {
                    text += "红巨星".Translate();
                }
                else if (starData.spectr <= ESpectrType.F)
                {
                    text += "黄巨星".Translate();
                }
                else if (starData.spectr == ESpectrType.A)
                {
                    text += "白巨星".Translate();
                }
                else
                {
                    text += "蓝巨星".Translate();
                }
            }
            else if (starData.type == EStarType.WhiteDwarf)
            {
                text += "白矮星".Translate();
            }
            else if (starData.type == EStarType.NeutronStar)
            {
                text += "中子星".Translate();
            }
            else if (starData.type == EStarType.BlackHole)
            {
                text += "黑洞".Translate();
            }
            else if (starData.type == EStarType.MainSeqStar)
            {
                text = text + starData.spectr.ToString() + "型恒星".Translate();
            }
            if (starData.index == ((customBirthStar != -1) ? customBirthStar - 1 : starmap._galaxyData.birthStarId - 1))
            {
                text = "即将登陆".Translate() + "\r\n" + text;
            }
            starmap.starPool[0].active   = true;
            starmap.starPool[0].starData = starData;
            starmap.starPool[0].pointRenderer.material.SetColor("_TintColor", color);
            starmap.starPool[0].pointRenderer.transform.localPosition = starData.position;
            starmap.starPool[0].pointRenderer.transform.localScale    = 2 * num2 * Vector3.one;
            starmap.starPool[0].pointRenderer.gameObject.SetActive(true);
            starmap.starPool[0].nameText.text  = text;
            starmap.starPool[0].nameText.color = Color.Lerp(color, Color.white, 0.5f);
            starmap.starPool[0].nameText.rectTransform.sizeDelta        = new Vector2(starmap.starPool[0].nameText.preferredWidth, starmap.starPool[0].nameText.preferredHeight);
            starmap.starPool[0].nameText.rectTransform.anchoredPosition = new Vector2(-2000f, -2000f);
            starmap.starPool[0].textContent = text;

            starmap.starPool[0].nameText.gameObject.SetActive(true);
        }
        private static void ShowSolarSystem(UIVirtualStarmap starmap, int starIndex)
        {
            // start planet compute thread if not done already
            PlanetModelingManager.StartPlanetComputeThread();

            // add star
            StarData starData = starmap._galaxyData.StarById(starIndex + 1); // because StarById() decrements by 1

            AddStarToStarmap(starmap, starData);

            starmap.clickText = starData.id.ToString();
            Debug.Log("Setting it to " + starmap.clickText + " " + starData.id);

            for (int i = 0; i < starData.planetCount; i++)
            {
                // add planets
                PlanetData pData       = starData.planets[i];
                Color      color       = starmap.neutronStarColor;
                float      scaleFactor = 0.6f;
                bool       isMoon      = false;

                VectorLF3 pPos = GetRelativeRotatedPlanetPos(starData, pData, ref isMoon);

                // request generation of planet surface data to display its details when clicked and if not already loaded
                if (!pData.loaded)
                {
                    PlanetModelingManager.RequestLoadPlanet(pData);
                }

                // create fake StarData to pass _OnLateUpdate()
                StarData dummyStarData = new StarData
                {
                    position = pPos,
                    color    = starData.color,
                    id       = pData.id
                };

                Vector3 scale = (pData.realRadius / 100) * scaleFactor * Vector3.one;
                if (scale.x > 3 || scale.y > 3 || scale.z > 3)
                {
                    scale = new Vector3(3, 3, 3);
                }

                starmap.starPool[i + 1].active   = true;
                starmap.starPool[i + 1].starData = dummyStarData;
                starmap.starPool[i + 1].pointRenderer.material.SetColor("_TintColor", color);
                starmap.starPool[i + 1].pointRenderer.transform.localPosition = pPos;
                starmap.starPool[i + 1].pointRenderer.transform.localScale    = scale;
                starmap.starPool[i + 1].pointRenderer.gameObject.SetActive(true);
                starmap.starPool[i + 1].nameText.text  = pData.displayName + " (" + pData.typeString + ")";
                starmap.starPool[i + 1].nameText.color = Color.Lerp(color, Color.white, 0.5f);
                starmap.starPool[i + 1].nameText.rectTransform.sizeDelta        = new Vector2(starmap.starPool[i + 1].nameText.preferredWidth, starmap.starPool[i + 1].nameText.preferredHeight);
                starmap.starPool[i + 1].nameText.rectTransform.anchoredPosition = new Vector2(-2000f, -2000f);
                starmap.starPool[i + 1].textContent = pData.displayName + " (" + pData.typeString + ")";

                starmap.starPool[i + 1].nameText.gameObject.SetActive(true);

                // add orbit renderer
                starmap.connPool[i].active = true;
                starmap.connPool[i].lineRenderer.material.SetColor("_LineColorA", Color.Lerp(color, Color.white, 0.65f));

                if (starmap.connPool[i].lineRenderer.positionCount != 61)
                {
                    starmap.connPool[i].lineRenderer.positionCount = 61;
                }
                for (int j = 0; j < 61; j++)
                {
                    float   f    = (float)j * 0.017453292f * 6f; // ty dsp devs :D
                    Vector3 cPos = GetCenterOfOrbit(starData, pData, ref isMoon);
                    Vector3 position;
                    if (isMoon)
                    {
                        position = new Vector3(Mathf.Cos(f) * pData.orbitRadius * orbitScaler * 8 + (float)cPos.x, cPos.y, Mathf.Sin(f) * pData.orbitRadius * orbitScaler * 8 + (float)cPos.z);
                    }
                    else
                    {
                        position = new Vector3(Mathf.Cos(f) * pData.orbitRadius * orbitScaler + (float)cPos.x, cPos.y, Mathf.Sin(f) * pData.orbitRadius * orbitScaler + (float)cPos.z);
                    }

                    // rotate position around center by orbit angle
                    Quaternion quaternion = Quaternion.Euler(pData.orbitInclination, pData.orbitInclination, pData.orbitInclination);
                    Vector3    dir        = quaternion * (position - cPos);
                    position = dir + cPos;

                    starmap.connPool[i].lineRenderer.SetPosition(j, position);
                }
                starmap.connPool[i].lineRenderer.gameObject.SetActive(true);
            }
        }