コード例 #1
0
        public static void UIStarDetail__OnOpen_Prefix(UIStarDetail __instance)
        {
            if (!starInfos.ContainsKey("star-details-min-radius"))
            {
                AddStarInfo("star-details-min-radius", "Dyson sphere min radius");
            }
            if (!starInfos.ContainsKey("star-details-max-radius"))
            {
                AddStarInfo("star-details-max-radius", "Dyson sphere max radius");
            }

            var minSphereRadius = Mathf.Max(4000f, __instance.star.physicsRadius * 1.5f);

            if (__instance.star.type == EStarType.GiantStar)
            {
                minSphereRadius *= 0.6f;
            }
            minSphereRadius = Mathf.Ceil(minSphereRadius / 100f) * 100f;
            starInfos["star-details-min-radius"].value.text = minSphereRadius.ToString("0");

            var maxSphereRadius = Mathf.Round((float)((double)__instance.star.dysonRadius * 40000.0) * 2f / 100f) * 100f;

            starInfos["star-details-max-radius"].value.text = maxSphereRadius.ToString("0");

            Debug.Log(JsonUtility.ToJson(GameMain.data.galacticTransport.stationPool, true));
        }
コード例 #2
0
ファイル: UIStarDetail_Patch.cs プロジェクト: Mushroom/nebula
 public static void OnNameInputEndEdit_Postfix(UIStarDetail __instance)
 {
     if (SimulatedWorld.Initialized && !FactoryManager.IsIncomingRequest)
     {
         if (__instance.star != null && !string.IsNullOrEmpty(__instance.star.overrideName))
         {
             // Send packet with new star name
             LocalPlayer.SendPacket(new NameInputPacket(__instance.star.overrideName, __instance.star.id, FactoryManager.PLANET_NONE, LocalPlayer.PlayerId));
         }
     }
 }
コード例 #3
0
 public static void OnNameInputEndEdit_Postfix(UIStarDetail __instance)
 {
     if (Multiplayer.IsActive && !Multiplayer.Session.Factories.IsIncomingRequest.Value)
     {
         if (__instance.star != null && !string.IsNullOrEmpty(__instance.star.overrideName))
         {
             // Send packet with new star name
             Multiplayer.Session.Network.SendPacket(new NameInputPacket(__instance.star.overrideName, __instance.star.id, NebulaModAPI.PLANET_NONE, Multiplayer.Session.LocalPlayer.Id));
         }
     }
 }
コード例 #4
0
        private static bool OnStarDataSet(
            StarData ____star,
            Text ___nameText,
            Text ___typeText,
            RectTransform ___paramGroup,
            Text ___massValueText,
            Text ___spectrValueText,
            Text ___radiusValueText,
            Text ___luminoValueText,
            Text ___temperatureValueText,
            Text ___ageValueText,
            Sprite ___unknownResIcon,
            GameObject ___trslBg,
            GameObject ___imgBg,
            UIResAmountEntry ___tipEntry,
            UIResAmountEntry ___entryPrafab,
            ref UIStarDetail __instance
            )
        {
            for (int index = 0; index < __instance.entries.Count; ++index)
            {
                UIResAmountEntry entry = __instance.entries[index];
                entry.SetEmpty();
                __instance.pool.Add(entry);
            }
            __instance.entries.Clear();
            if (__instance.star == null)
            {
                return(false);
            }
            double magnitude = (__instance.star.uPosition - GameMain.mainPlayer.uPosition).magnitude;
            bool   _observed = GameMain.history.universeObserveLevel >= (__instance.star != GameMain.localStar ? (magnitude >= 14400000.0 ? 4 : 3) : 2);

            ___nameText.text             = __instance.star.displayName;
            ___typeText.text             = (__instance.star.typeString);
            ___massValueText.text        = (__instance.star.mass.ToString("0.000") + " M    ");
            ___spectrValueText.text      = (__instance.star.spectr.ToString());
            ___radiusValueText.text      = (__instance.star.radius.ToString("0.00") + " R    ");
            ___luminoValueText.text      = (((double)__instance.star.dysonLumino).ToString("0.000") + " L    ");
            ___temperatureValueText.text = (__instance.star.temperature.ToString("#,##0") + " K");
            if (Localization.isKMG)
            {
                ___ageValueText.text = ((__instance.star.age * __instance.star.lifetime).ToString("#,##0 ") + "百万亿年".Translate());
            }
            else
            {
                ___ageValueText.text = (((float)(__instance.star.age * (double)__instance.star.lifetime * 0.00999999977648258)).ToString("#,##0.00 ") + "百万亿年".Translate());
            }
            int num = 0;

            for (int type = 1; type < 15; ++type)
            {
                int       id        = type;
                VeinProto veinProto = LDB.veins.Select(id);
                ItemProto itemProto = LDB.items.Select(veinProto.MiningItem);
                if (_observed || type < 7)
                {
                    bool flag = (!__instance.star.loaded ? __instance.star.GetResourceSpots(type) > 0 : __instance.star.GetResourceAmount(type) > 0L) || type < 7;
                    if (veinProto != null && itemProto != null && flag)
                    {
                        UIResAmountEntry entry = Object.Instantiate(___entryPrafab, ___entryPrafab.transform.parent);;
                        __instance.entries.Add(entry);
                        entry.SetInfo(num, itemProto.name, veinProto.iconSprite, veinProto.description, type >= 7, false, type != 7 ? "                " : "         /s");
                        entry.refId = id;
                        ++num;
                    }
                }
            }
            if (_observed)
            {
                for (int index = 0; index < __instance.star.planetCount; ++index)
                {
                    int waterItemId = __instance.star.planets[index].waterItemId;
                    "无".Translate();
                    if (waterItemId > 0)
                    {
                        ItemProto itemProto = LDB.items.Select(waterItemId);
                        if (itemProto != null)
                        {
                            Sprite           iconSprite = itemProto.iconSprite;
                            string           name       = itemProto.name;
                            UIResAmountEntry entry      = Object.Instantiate(___entryPrafab, ___entryPrafab.transform.parent);;
                            __instance.entries.Add(entry);
                            entry.SetInfo(num, name, iconSprite, itemProto.description, itemProto != null && waterItemId != 1000, false, string.Empty);
                            entry.valueString = "海洋".Translate();
                            ++num;
                        }
                    }
                }
            }

            //*
            Dictionary <int, float> ressources = new Dictionary <int, float>();

            for (int index1 = 0; index1 < __instance.star.planetCount; ++index1)
            {
                PlanetData planet = __instance.star.planets[index1];
                if (planet.type == EPlanetType.Gas && planet.gasItems != null)
                {
                    for (var i = 0; i < planet.gasItems.Length; i++)
                    {
                        if (ressources.ContainsKey(planet.gasItems[i]))
                        {
                            ressources[planet.gasItems[i]] += planet.gasSpeeds[i];
                        }
                        else
                        {
                            ressources[planet.gasItems[i]] = planet.gasSpeeds[i];
                        }
                    }
                }
            }


            foreach (var keyValuePair in ressources)
            {
                ItemProto itemProto = LDB.items.Select(keyValuePair.Key);

                UIResAmountEntry entry = Object.Instantiate(___entryPrafab, ___entryPrafab.transform.parent);
                __instance.entries.Add(entry);
                if (_observed)
                {
                    entry.SetInfo(num, itemProto.name, itemProto.iconSprite, itemProto.description, false, false, "        /s");
                    if (__instance.star.loaded)
                    {
                        StringBuilderUtility.WritePositiveFloat(entry.sb, 0, 7, keyValuePair.Value);
                        entry.DisplayStringBuilder();
                    }
                    else
                    {
                        entry.valueString = "探测到信号".Translate();
                    }
                }
                else
                {
                    entry.SetInfo(num, "未知".Translate(), ___unknownResIcon, string.Empty, false, false, "        /s");
                    entry.valueString = "未知".Translate();
                }
                entry.SetObserved(_observed);
                ++num;
            }

            if (!_observed)
            {
                UIResAmountEntry entry = Object.Instantiate(___entryPrafab, ___entryPrafab.transform.parent);;;
                __instance.entries.Add(entry);
                entry.SetInfo(num, string.Empty, null, string.Empty, false, false, string.Empty);
                ___tipEntry = entry;
                int  num1 = ____star != GameMain.localStar ? (magnitude >= 14400000.0 ? 4 : 3) : 2;
                bool flag = GameMain.history.universeObserveLevel >= num1;
                ___tipEntry.valueString = flag ? string.Empty : "宇宙探索等级".Translate() + num1.ToString();
                ++num;
            }
            __instance.SetResCount(num);
            __instance.RefreshDynamicProperties();

            return(false);
        }
コード例 #5
0
 public static void UIStarDetail__OnUpdate_Prefix(UIStarDetail __instance)
 {
 }