using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BetterUniverseInfo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterUniverseInfo")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e99a75d4-ff8a-4453-b827-ec4060684088")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterUniverseInfo;
public class BetterUniverseInfoAuxiliary
{
public enum ResourceType
{
None,
Iron,
Copper,
Silicium,
Titanium,
Stone,
Coal,
Oil,
Fireice,
Diamond,
Fractal,
Crysrub,
Grat,
Bamboo,
Mag,
Max,
H,
HeavyH,
Acid,
RealMax
}
private static HashSet<int> tempids = new HashSet<int>();
public static StringBuilder stringBuilder = new StringBuilder();
public static Dictionary<ResourceType, string> vein_name = new Dictionary<ResourceType, string>
{
{
ResourceType.Max,
""
},
{
ResourceType.None,
""
},
{
ResourceType.Acid,
"硫酸"
},
{
ResourceType.Bamboo,
"刺笋结晶"
},
{
ResourceType.Coal,
"煤矿"
},
{
ResourceType.Copper,
"铜矿"
},
{
ResourceType.Crysrub,
"有机晶体"
},
{
ResourceType.Diamond,
"金伯利"
},
{
ResourceType.Fireice,
"可燃冰"
},
{
ResourceType.Fractal,
"分形硅石"
},
{
ResourceType.Grat,
"光栅石"
},
{
ResourceType.H,
"氢"
},
{
ResourceType.HeavyH,
"重氢"
},
{
ResourceType.Iron,
"铁矿"
},
{
ResourceType.Mag,
"单极磁石"
},
{
ResourceType.Oil,
"原油"
},
{
ResourceType.Silicium,
"硅石"
},
{
ResourceType.Stone,
"石矿"
},
{
ResourceType.Titanium,
"钛石"
}
};
public static int[] all_res = new int[32];
public static void resetResource()
{
all_res = new int[32];
}
public static string galaxySpecialVeinSketch2String(StarData star, string padding)
{
stringBuilder.Length = 0;
stringBuilder.Append(padding);
for (int i = 8; i < 19; i++)
{
if (all_res[i] > 0 && i != 16)
{
stringBuilder.Append(vein_name[(ResourceType)i]);
stringBuilder.Append(" ");
}
}
return stringBuilder.ToString();
}
public static string planetVeinSketch2String(PlanetData planet, string padding)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
stringBuilder.Length = 0;
stringBuilder.Append(padding);
if ((int)planet.type == 5 && planet.gasItems != null)
{
int[] gasItems = planet.gasItems;
for (int i = 0; i < gasItems.Length; i++)
{
switch (gasItems[i])
{
case 1121:
stringBuilder.Append("重氢 ");
all_res[17] = 1;
break;
case 1120:
all_res[16] = 1;
break;
case 1011:
stringBuilder.Append("可燃冰 ");
all_res[8] = 1;
break;
}
}
}
else
{
if (planet.waterItemId == 1116)
{
stringBuilder.Append("硫酸 ");
all_res[18] = 1;
}
int[] array = veinSpotsSketch(planet);
if (array != null)
{
for (int j = 0; j < 15; j++)
{
if (array[j] != 0)
{
all_res[j] = 1;
if (j == 3 || j == 4 || (j >= 8 && j != 16))
{
stringBuilder.Append(vein_name[(ResourceType)j]);
stringBuilder.Append(" ");
}
}
}
}
}
return stringBuilder.ToString();
}
public static string planetDataWithVein2String(PlanetData planet, string padding)
{
long[] array = new long[32];
planet.SummarizeVeinAmountsByFilter(ref array, tempids, UIRoot.instance.uiGame.veinAmountDisplayFilter);
stringBuilder.Length = 0;
stringBuilder.AppendFormat("{0}{1} {2}\n", padding, planet.typeString, planet.singularityString);
for (int i = 1; i < 15; i++)
{
if (array[i] > 0)
{
stringBuilder.AppendFormat(" {0}{1}:{2}\n", padding, vein_name[(ResourceType)i], array[i]);
}
}
return stringBuilder.ToString();
}
public static int[] veinSpotsSketch(PlanetData planet)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Invalid comparison between Unknown and I4
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Invalid comparison between Unknown and I4
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Invalid comparison between Unknown and I4
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Invalid comparison between Unknown and I4
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Invalid comparison between Unknown and I4
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Invalid comparison between Unknown and I4
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Invalid comparison between Unknown and I4
//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Invalid comparison between Unknown and I4
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Invalid comparison between Unknown and I4
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Invalid comparison between Unknown and I4
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Invalid comparison between Unknown and I4
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Invalid comparison between Unknown and I4
ThemeProto val = ((ProtoSet<ThemeProto>)(object)LDB.themes).Select(planet.theme);
if (val != null)
{
DotNet35Random val2 = new DotNet35Random(planet.seed);
val2.Next();
val2.Next();
val2.Next();
val2.Next();
val2.Next();
val2.Next();
VeinProto[] veinProtos = PlanetModelingManager.veinProtos;
int[] array = new int[veinProtos.Length];
if (val.VeinSpot != null)
{
Array.Copy(val.VeinSpot, 0, array, 1, Math.Min(val.VeinSpot.Length, array.Length - 1));
}
float num = 1f;
ESpectrType spectr = planet.star.spectr;
EStarType type = planet.star.type;
if ((int)type == 0)
{
if ((int)spectr == 0)
{
num = 2.5f;
}
else if ((int)spectr == 1)
{
num = 1f;
}
else if ((int)spectr == 2)
{
num = 0.7f;
}
else if ((int)spectr == 3)
{
num = 0.6f;
}
else if ((int)spectr == 4)
{
num = 1f;
}
else if ((int)spectr == 5)
{
num = 0.4f;
}
else if ((int)spectr == 6)
{
num = 1.6f;
}
}
else if ((int)type == 1)
{
num = 2.5f;
}
else if ((int)type == 2)
{
num = 3.5f;
array[9] += 2;
for (int i = 1; i < 12; i++)
{
if (!(val2.NextDouble() < 0.44999998807907104))
{
break;
}
array[9]++;
}
array[10] += 2;
for (int j = 1; j < 12; j++)
{
if (!(val2.NextDouble() < 0.44999998807907104))
{
break;
}
array[10]++;
}
array[12]++;
for (int k = 1; k < 12; k++)
{
if (!(val2.NextDouble() < 0.5))
{
break;
}
array[12]++;
}
}
else if ((int)type == 3)
{
num = 4.5f;
array[14]++;
for (int l = 1; l < 12; l++)
{
if (!(val2.NextDouble() < 0.6499999761581421))
{
break;
}
array[14]++;
}
}
else if ((int)type == 4)
{
num = 5f;
array[14]++;
for (int m = 1; m < 12; m++)
{
if (!(val2.NextDouble() < 0.6499999761581421))
{
break;
}
array[14]++;
}
}
for (int n = 0; n < val.RareVeins.Length; n++)
{
int num2 = val.RareVeins[n];
float num3 = ((planet.star.index == 0) ? val.RareSettings[n * 4] : val.RareSettings[n * 4 + 1]);
num3 = 1f - Mathf.Pow(1f - num3, num);
if (!(val2.NextDouble() < (double)num3))
{
continue;
}
array[num2]++;
for (int num4 = 1; num4 < 12; num4++)
{
if (!(val2.NextDouble() < (double)val.RareSettings[n * 4 + 2]))
{
break;
}
array[num2]++;
}
}
return array;
}
return null;
}
}
[BepInPlugin("org.fat32andntfs.GalaxyVeinEarlyView", "Galaxy Vein Early View", "1.0.4")]
public class GalaxyVeinEarlyView : BaseUnityPlugin
{
[HarmonyPatch(typeof(UIVirtualStarmap), "OnGalaxyDataReset")]
private class Patch
{
public static void Postfix(UIVirtualStarmap __instance)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0476: Unknown result type (might be due to invalid IL or missing references)
if (__instance.galaxyData == null)
{
msg = "";
return;
}
Traverse val = Traverse.Create((object)__instance);
List<StarNode> value = val.Field("starPool").GetValue<List<StarNode>>();
VectorLF3 position = __instance.galaxyData.stars[0].position;
if (__instance.galaxyData.stars.Length > 1 && !value[1].nameText.text.Contains("星体:"))
{
BetterUniverseInfoAuxiliary.resetResource();
sb.Length = 0;
sb.AppendFormat("起始星系: {0} {1}", value[0].starData.displayName, value[0].starData.typeString);
sb.AppendFormat("\n光度:{0:N2}L", value[0].starData.dysonLumino);
sb.Append("\n星体:");
PlanetData[] planets = value[0].starData.planets;
foreach (PlanetData val2 in planets)
{
sb.AppendFormat("\n {0} {1}:{2}", val2.typeString, val2.singularityString, BetterUniverseInfoAuxiliary.planetVeinSketch2String(val2, ""));
sb.AppendFormat("\n 风 {0:P} 光 {1:P}", val2.windStrength, val2.luminosity);
}
sb.Append("\n\n");
for (int j = 1; j < __instance.galaxyData.stars.Length; j++)
{
StarData val3 = __instance.galaxyData.stars[j];
if ((double)val3.dysonLumino > 2.0 || val3.planetCount > 5)
{
sb.Append('\n');
if ((double)val3.dysonLumino > 2.0)
{
sb.AppendFormat("高光度 {0}L ", val3.dysonLumino);
}
if (val3.planetCount > 5)
{
sb.AppendFormat("较多行星 {0}个 ", val3.planetCount);
}
sb.AppendFormat("{0} {1} {2:N2}LY ", val3.displayName, val3.typeString, ((VectorLF3)(ref val3.position)).Distance(position));
}
}
msg = sb.ToString();
for (int k = 1; k < __instance.galaxyData.stars.Length; k++)
{
if (!value[k].nameText.text.Contains("星体:"))
{
BetterUniverseInfoAuxiliary.resetResource();
sb.Length = 0;
sb.Append(value[k].nameText.text);
sb.AppendFormat("\n距离:{0:N2}LY", ((VectorLF3)(ref value[k].starData.position)).Distance(position));
sb.AppendFormat("\n光度:{0:N2}L", value[k].starData.dysonLumino);
sb.Append("\n星体:");
PlanetData[] planets2 = value[k].starData.planets;
foreach (PlanetData val4 in planets2)
{
sb.AppendFormat("\n {0} {1}:{2}", val4.typeString, val4.singularityString, BetterUniverseInfoAuxiliary.planetVeinSketch2String(val4, ""));
sb.AppendFormat("\n 风 {0:P} 光 {1:P}", val4.windStrength, val4.luminosity);
}
sb.Append(BetterUniverseInfoAuxiliary.galaxySpecialVeinSketch2String(value[k].starData, "\n珍奇:"));
string text = sb.ToString();
value[k].nameText.text = text;
value[k].textContent = text;
((Graphic)value[k].nameText).rectTransform.sizeDelta = new Vector2(value[k].nameText.preferredWidth, value[k].nameText.preferredHeight);
}
}
}
val.Field("starPool").SetValue((object)value);
}
}
private static StringBuilder sb = new StringBuilder();
private static string msg = "";
private static string[] themeTy = new string[14]
{
"地中海", "气巨星", "冰巨星", "干旱荒漠", "灰烬冻土", "海洋丛林", "熔岩", "冰原冻土", "贫瘠荒漠", "戈壁",
"火山灰", "红石", "草原", "水世界"
};
private static Rect rect = new Rect(30f, 30f, 200f, 400f);
private static Rect windowRect = new Rect(30f, 450f, 200f, 400f);
private static GUIStyle style = new GUIStyle();
private static bool hide = false;
private void Start()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
style.fontSize = 16;
style.normal.textColor = new Color(255f, 255f, 255f);
new Harmony("org.fat32andntfs.GalaxyVeinEarlyView").PatchAll();
}
private void Update()
{
if ((Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) && Input.GetKeyDown((KeyCode)104))
{
hide = !hide;
}
}
private void OnGUI()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
GUI.Label(rect, hide ? "" : msg, style);
}
}
[BepInPlugin("org.fat32andntfs.VeinDetailView", "Vein Detail View", "1.0.0.2")]
public class VeinDetailView : BaseUnityPlugin
{
[HarmonyPatch(typeof(UIStarmap), "UpdateCursorView")]
private class Patch
{
public static void Postfix(UIStarmap __instance)
{
if ((Object)(object)__instance.mouseHoverStar == (Object)null || !__instance.mouseHoverStar.projected)
{
msg = "";
return;
}
StarData star = __instance.mouseHoverStar.star;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("星系:\n");
PlanetData[] planets = star.planets;
foreach (PlanetData planet in planets)
{
stringBuilder.Append(BetterUniverseInfoAuxiliary.planetDataWithVein2String(planet, " "));
}
msg = stringBuilder.ToString();
}
}
private static string msg = "";
private static Rect rect = new Rect(30f, 30f, 200f, 400f);
private static GUIStyle style = new GUIStyle();
private static bool hide = false;
private void Start()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
style.fontSize = 16;
style.normal.textColor = new Color(255f, 255f, 255f);
new Harmony("org.fat32andntfs.VeinDetailView").PatchAll();
}
private void Update()
{
if ((Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) && Input.GetKeyDown((KeyCode)104))
{
hide = !hide;
}
}
private void OnGUI()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
GUI.Label(rect, hide ? "" : msg, style);
}
}