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 BepInEx;
using BepInEx.Configuration;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DSP_DarkFogInfo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DSP_DarkFogInfo")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c9a0c519-dee7-4750-8058-f1f8c765021c")]
[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 DSP_DarkFogInfo;
public class TinderInfo
{
public DFTinderComponent tinder;
public double ETA;
public StarData originStar;
public StarData targetStar;
public VectorLF3 pos;
public double lastUpdateDistance;
public double EliminationPriority => Math.Max(1.0, 60.0 / (ETA + 1.0)) * (2400000.0 / lastUpdateDistance);
public static int EliminationPriorityDescComparer(TinderInfo a, TinderInfo b)
{
if (!(a.EliminationPriority < b.EliminationPriority))
{
return -1;
}
return 1;
}
}
[BepInPlugin("cn.chewei.dsp.darkfoginfo", "Dark For Infomation", "1.0.2")]
[BepInProcess("DSPGAME.exe")]
public class DarkFogInfoPlugin : BaseUnityPlugin
{
private enum EGUITab
{
HiveInfoTab = 1,
TinderTab,
AAConfigTab
}
public const string GUID = "cn.chewei.dsp.darkfoginfo";
public const string NAME = "Dark For Infomation";
public const string VERSION = "1.0.2";
public const string GAME_PROCESS = "DSPGAME.exe";
public int TinderTotalCount;
public int TinderIdleCount;
public int TinderInTransitCount;
public List<TinderInfo> TinderInTransit = new List<TinderInfo>();
public int NaviLineTargetEnemyId;
public LineGizmo NaviLine;
public UIHiveInfo HiveInfoPanel;
private StarData _focusStar;
private static readonly string[] hivecodes = new string[12]
{
"α", "β", "γ", "δ", "ε", "ζ", "η", "θ", "ι", "κ",
"λ", "μ"
};
private Rect _windowRect = new Rect((float)Screen.width * 0.05f, (float)Screen.height * 0.35f, (float)Screen.width * 0.3f, (float)Screen.height * 0.3f);
private bool _isWindowActive;
private List<string> _focusSystemHiveInfo;
private bool _showTinderList = true;
private ConfigEntry<bool> configAutoTinderNaviAssist;
private Vector2 _tinderListScrollPos;
public double UpdateTimeMax;
public double UpdateTimeMin;
private EGUITab activeTab = EGUITab.HiveInfoTab;
public bool AutoTinderNaviAssist
{
get
{
return configAutoTinderNaviAssist.Value;
}
set
{
configAutoTinderNaviAssist.Value = value;
}
}
public void Start()
{
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
configAutoTinderNaviAssist = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AutoTinderNaviAssist", false, "Whether automatically add navigation to the nearest tinder, this can work as an alert also");
}
public void Update()
{
if (DSPGame.IsMenuDemo)
{
return;
}
if (Input.GetKey((KeyCode)306) && Input.GetKeyUp((KeyCode)120))
{
_isWindowActive = !_isWindowActive;
}
if (GameMain.data != null && GameMain.data.spaceSector != null)
{
if (GameMain.gameTick % 30 == 0L && _isWindowActive)
{
UpdateFocusedHiveInfo();
}
if (GameMain.gameTick % 30 == 15)
{
UpdateGlobalTinderInfo();
}
if (AutoTinderNaviAssist)
{
UpdateAutoTinderTarget();
TinderHuntWarpSpeedControl();
}
else
{
NaviLineTargetEnemyId = 0;
}
}
}
public void OnGUI()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
if (!DSPGame.IsMenuDemo && !GameMain.isPaused)
{
if (_isWindowActive)
{
_windowRect = GUILayout.Window(100, _windowRect, new WindowFunction(DrawInfoWindow), "Dark Fog Information", Array.Empty<GUILayoutOption>());
}
if ((Object)(object)HiveInfoPanel == (Object)null)
{
HiveInfoPanel = UIHiveInfo.Create();
}
HiveInfoPanel.OnGUI();
}
}
public void OpenNaviLine(VectorLF3 targetUpos)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = GameMain.mainPlayer.position;
Vector3 position2 = GameMain.mainPlayer.position;
Vector3 val = position + ((Vector3)(ref position2)).normalized * 4f;
Vector3 val2 = TransformUposToPos(targetUpos);
NaviLine = LineGizmo.Create(1, val, val2);
NaviLine.autoRefresh = false;
NaviLine.multiplier = 5f;
NaviLine.alphaMultiplier = 0.6f;
NaviLine.width = 3f;
NaviLine.color = Configs.builtin.gizmoColors[4];
NaviLine.spherical = false;
((GizmoBase)NaviLine).Open();
}
public void CloseNaviLine()
{
NaviLineTargetEnemyId = 0;
LineGizmo naviLine = NaviLine;
if (naviLine != null)
{
((GizmoBase)naviLine).Close();
}
NaviLine = null;
}
public void RefreshNaviLine(VectorLF3 targetUpos)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)NaviLine == (Object)null))
{
LineGizmo naviLine = NaviLine;
Vector3 position = GameMain.mainPlayer.position;
Vector3 position2 = GameMain.mainPlayer.position;
naviLine.startPoint = position + ((Vector3)(ref position2)).normalized * 4f;
NaviLine.endPoint = TransformUposToPos(targetUpos);
NaviLine.ManualRefresh();
}
}
[Obsolete]
private void UpdateNaviLine()
{
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)NaviLine == (Object)null)
{
if (TinderInTransit.Count <= 0)
{
return;
}
for (int i = 0; i < TinderInTransit.Count; i++)
{
if (GameMain.spaceSector.enemyPool[TinderInTransit[i].tinder.enemyId].dfTinderId != 0)
{
NaviLineTargetEnemyId = TinderInTransit[i].tinder.enemyId;
break;
}
}
OpenNaviLine(GameMain.spaceSector.enemyPool[NaviLineTargetEnemyId].pos);
}
else if (NaviLineTargetEnemyId > 0 && GameMain.spaceSector.enemyPool[NaviLineTargetEnemyId].dfTinderId != 0)
{
RefreshNaviLine(GameMain.spaceSector.enemyPool[NaviLineTargetEnemyId].pos);
}
else
{
CloseNaviLine();
}
}
private void UpdateAutoTinderTarget()
{
Player mainPlayer = GameMain.mainPlayer;
PlayerNavigation val = ((mainPlayer != null) ? mainPlayer.navigation : null);
if (val != null && !val.hasTask)
{
if (TinderInTransit.Count <= 0)
{
return;
}
for (int i = 0; i < TinderInTransit.Count; i++)
{
if (GameMain.spaceSector.enemyPool[TinderInTransit[i].tinder.enemyId].dfTinderId != 0)
{
NaviLineTargetEnemyId = TinderInTransit[i].tinder.enemyId;
break;
}
}
val.indicatorEnemyId = NaviLineTargetEnemyId;
}
else if (NaviLineTargetEnemyId > 0 && GameMain.spaceSector.enemyPool[NaviLineTargetEnemyId].dfTinderId == 0)
{
NaviLineTargetEnemyId = 0;
}
}
private void DrawNaviLinePanel()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
double distance = ((VectorLF3)(ref GameMain.mainPlayer.uPosition)).Distance(GameMain.spaceSector.enemyPool[NaviLineTargetEnemyId].pos);
string text = "Distance " + DistanceToString(distance);
GUIStyle val = new GUIStyle(GUI.skin.label)
{
fontStyle = (FontStyle)1,
fontSize = GUI.skin.label.fontSize * 2
};
GUILayout.BeginArea(new Rect((float)Screen.width * 0.6f, (float)Screen.height * 0.6f, (float)Screen.width * 0.16f, (float)Screen.height * 0.1f));
GUILayout.Label(text, val, Array.Empty<GUILayoutOption>());
GUILayout.EndArea();
}
private double ConvertSpeedRatioToWarpSpeedControl(double speedRatio)
{
return Math.Log(speedRatio * 1000.0 + 1.0) / Math.Log(1001.0);
}
private void TinderHuntWarpSpeedControl()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
Player mainPlayer = GameMain.mainPlayer;
if (mainPlayer.warping && mainPlayer.navigation.indicatorEnemyId != 0)
{
VectorLF3 pos = GameMain.spaceSector.enemyPool[mainPlayer.navigation.indicatorEnemyId].pos;
double num = ((VectorLF3)(ref mainPlayer.uPosition)).Distance(pos);
double num2 = 1.0 / ((double)mainPlayer.mecha.maxWarpSpeed * 1.0);
double speedRatio = Math.Max(0.003, Math.Min(num * num2, 1.0));
double num3 = ConvertSpeedRatioToWarpSpeedControl(speedRatio);
double warpSpeedControl = mainPlayer.controller.actionSail.warpSpeedControl;
double val = num3 - warpSpeedControl;
val = Math.Max(-0.008, Math.Min(val, 0.008));
PlayerMove_Sail actionSail = mainPlayer.controller.actionSail;
actionSail.warpSpeedControl += val;
VectorLF3 normalized = ((VectorLF3)(ref mainPlayer.uVelocity)).normalized;
VectorLF3 val2 = pos - mainPlayer.uPosition;
double num4 = 2.0 - VectorLF3.Dot(normalized, ((VectorLF3)(ref val2)).normalized);
if (num < 10000.0 * num4)
{
mainPlayer.warpCommand = false;
}
}
}
public void UpdateGlobalTinderInfo()
{
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
SpaceSector val = GameMain.data?.spaceSector;
int num = 0;
int num2 = 0;
int num3 = 0;
TinderInTransit.Clear();
StarData[] stars = val.galaxy.stars;
foreach (StarData val2 in stars)
{
for (EnemyDFHiveSystem val3 = val.dfHives[val2.index]; val3 != null; val3 = val3.nextSibling)
{
num += val3.tinderCount;
num2 += val3.idleTinderCount;
num3 += val3.tindersInTransit;
int cursor = val3.tinders.cursor;
DFTinderComponent[] buffer = val3.tinders.buffer;
for (int j = 1; j < cursor; j++)
{
if (buffer[j].id == j && buffer[j].stage == 0)
{
DFTinderComponent val4 = buffer[j];
VectorLF3 pos = val.enemyPool[val4.enemyId].pos;
VectorLF3 val5 = val.astros[val4.targetHiveAstroId - 1000000].uPos - pos;
double eTA = ((VectorLF3)(ref val5)).magnitude / (double)val4.uSpeed / 60.0;
TinderInfo item = new TinderInfo
{
tinder = val4,
originStar = val.GetHiveByAstroId(val4.originHiveAstroId).starData,
targetStar = val.GetHiveByAstroId(val4.targetHiveAstroId).starData,
ETA = eTA,
pos = pos,
lastUpdateDistance = ((VectorLF3)(ref GameMain.mainPlayer.uPosition)).Distance(pos)
};
TinderInTransit.Add(item);
}
}
}
}
if (TinderInTransit.Count > 1)
{
TinderInTransit.Sort(TinderInfo.EliminationPriorityDescComparer);
}
TinderTotalCount = num;
TinderIdleCount = num2;
TinderInTransitCount = num3;
}
public void UpdateFocusedHiveInfo()
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
if (GameMain.data.starmapViewStar != null)
{
_focusStar = GameMain.data.starmapViewStar;
_focusSystemHiveInfo = GetSystemHivesInfo(GameMain.data.spaceSector, _focusStar);
}
else if (GameMain.data.localStar != null)
{
_focusStar = GameMain.data.localStar;
_focusSystemHiveInfo = GetSystemHivesInfo(GameMain.data.spaceSector, _focusStar);
}
else if (_focusStar == null)
{
PlanetData val = default(PlanetData);
GameMain.data.QueryNearestStarPlanet(GameMain.mainPlayer.uPosition, ref _focusStar, ref val);
}
}
public int SetPlanetTurretAntiAir(ref PlanetFactory planetFactory, VSLayerMask vsOrbitAndSpaceSettings)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Invalid comparison between Unknown and I4
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Invalid comparison between Unknown and I4
DataPool<TurretComponent> turrets = planetFactory.defenseSystem.turrets;
TurretComponent[] buffer = planetFactory.defenseSystem.turrets.buffer;
int num = 0;
for (int i = 1; i < turrets.cursor; i++)
{
if (buffer[i].id == i && ((int)buffer[i].type == 5 || (int)buffer[i].type == 4))
{
VSLayerMask vsSettings = buffer[i].vsSettings;
vsSettings = (VSLayerMask)(vsSettings & 0xF);
vsSettings = (VSLayerMask)(vsSettings | (vsOrbitAndSpaceSettings & 0xF0));
buffer[i].vsSettings = vsSettings;
num++;
}
}
return num;
}
public void DrawInfoWindow(int id)
{
if (GameMain.spaceSector != null)
{
DrawTapSelection();
GUILayout.Space(5f);
switch (activeTab)
{
case EGUITab.TinderTab:
DrawTinderInfoTab();
break;
case EGUITab.HiveInfoTab:
DrawHiveInfoTab();
break;
case EGUITab.AAConfigTab:
DrawPlanetAABulkConfigUI();
break;
}
GUI.DragWindow();
}
}
private void DrawHiveInfoTab()
{
int num = 0;
if (_focusSystemHiveInfo == null)
{
return;
}
StarData focusStar = _focusStar;
GUILayout.Label("Focus Star System:" + ((focusStar != null) ? focusStar.displayName : null) + "\n", Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
foreach (string item in _focusSystemHiveInfo)
{
GUILayout.Label(item, Array.Empty<GUILayoutOption>());
num++;
if (num == 3 && _focusSystemHiveInfo.Count >= 3)
{
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
}
}
GUILayout.EndHorizontal();
}
private void DrawTapSelection()
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (GUILayout.Button("Space Hives", Array.Empty<GUILayoutOption>()))
{
activeTab = EGUITab.HiveInfoTab;
}
if (GUILayout.Button("Tinder", Array.Empty<GUILayoutOption>()))
{
activeTab = EGUITab.TinderTab;
}
if (GUILayout.Button("Anti-air Bulk Config", Array.Empty<GUILayoutOption>()))
{
activeTab = EGUITab.AAConfigTab;
}
GUILayout.EndHorizontal();
}
private void DrawPlanetAABulkConfigUI()
{
if (GameMain.localPlanet != null && GameMain.localPlanet.factory != null)
{
DrawTurretAAButtons();
}
else
{
GUILayout.Label("Not available outside planet", Array.Empty<GUILayoutOption>());
}
}
private void DrawTinderInfoTab()
{
_showTinderList = GUILayout.Toggle(_showTinderList, "Show tinders in space list", Array.Empty<GUILayoutOption>());
AutoTinderNaviAssist = GUILayout.Toggle(AutoTinderNaviAssist, "Enable tinder guide line", Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label($"Total: {TinderTotalCount}", Array.Empty<GUILayoutOption>());
GUILayout.Label($"Idle: {TinderIdleCount}", Array.Empty<GUILayoutOption>());
GUILayout.Label($"In transit: {TinderInTransitCount}", Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
if (_showTinderList)
{
DrawTinderList();
}
}
public void DrawTurretAAButtons()
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (GUILayout.Button(Localization.Translate("设置行星对空"), Array.Empty<GUILayoutOption>()))
{
int num = SetPlanetTurretAntiAir(ref GameMain.localPlanet.factory, (VSLayerMask)176);
UIRealtimeTip.Popup(Localization.Translate("设置行星对空") + $"{num} Turrets", true, 0);
}
if (GUILayout.Button(Localization.Translate("设置行星对空(不攻击中继站)"), Array.Empty<GUILayoutOption>()))
{
int num2 = SetPlanetTurretAntiAir(ref GameMain.localPlanet.factory, (VSLayerMask)192);
UIRealtimeTip.Popup(Localization.Translate("设置行星对空(不攻击中继站)") + $"{num2} Turrets", true, 0);
}
if (GUILayout.Button(Localization.Translate("取消行星对空"), Array.Empty<GUILayoutOption>()))
{
int num3 = SetPlanetTurretAntiAir(ref GameMain.localPlanet.factory, (VSLayerMask)0);
UIRealtimeTip.Popup(Localization.Translate("取消行星对空") + $"{num3} Turrets", true, 0);
}
GUILayout.EndHorizontal();
}
public void DrawTinderList()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
_tinderListScrollPos = GUILayout.BeginScrollView(_tinderListScrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height((float)((double)((Rect)(ref _windowRect)).height * 0.5)) });
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Label("From", Array.Empty<GUILayoutOption>());
foreach (TinderInfo item in TinderInTransit)
{
GUILayout.Label(item.originStar.displayName, Array.Empty<GUILayoutOption>());
}
GUILayout.EndVertical();
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Label("To", Array.Empty<GUILayoutOption>());
foreach (TinderInfo item2 in TinderInTransit)
{
GUILayout.Label(item2.targetStar.displayName, Array.Empty<GUILayoutOption>());
}
GUILayout.EndVertical();
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Label("ETA[min]", Array.Empty<GUILayoutOption>());
foreach (TinderInfo item3 in TinderInTransit)
{
GUILayout.Label(Math.Round(item3.ETA, 1).ToString(), Array.Empty<GUILayoutOption>());
}
GUILayout.EndVertical();
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Label("Distance", Array.Empty<GUILayoutOption>());
foreach (TinderInfo item4 in TinderInTransit)
{
VectorLF3 val = GameMain.data.mainPlayer.uPosition - item4.pos;
double magnitude = ((VectorLF3)(ref val)).magnitude;
GUILayout.Label(DistanceToString(magnitude), Array.Empty<GUILayoutOption>());
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUILayout.EndScrollView();
}
public string DistanceToString(double distance)
{
if (distance >= 240000.0)
{
return Math.Round(distance / 2400000.0, 2) + "LY";
}
if (distance >= 10000.0)
{
return Math.Round(distance / 40000.0, 2) + "AU";
}
return Math.Round(distance) + "m";
}
public Vector3 TransformUposToPos(VectorLF3 uPos)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
VectorLF3 relativePos = GameMain.data.relativePos;
return VectorLF3.op_Implicit(Maths.QInvRotateLF(GameMain.data.relativeRot, uPos - relativePos));
}
private static List<string> GetSystemHivesInfo(SpaceSector spaceSector, StarData star)
{
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Expected O, but got Unknown
int num = 0;
List<string> list = new List<string>();
for (EnemyDFHiveSystem val = spaceSector.dfHives[star.index]; val != null; val = val.nextSibling)
{
if (val.isAlive)
{
num++;
string text = "";
string text2 = hivecodes[val.hiveOrbitIndex % hivecodes.Length];
string text3 = val.evolve.level.ToString();
string text4 = "太空巢穴" + text2 + "(Level " + text3 + ")\r\n";
text += text4;
text += $"Tick={val.ticks}\r\n";
int hiveAstroId = val.hiveAstroId;
int enemyId = val.cores.buffer[1].enemyId;
int num2 = val.units.count;
for (int i = 0; i < val.forms.Length; i++)
{
num2 += val.forms[i].unitCount;
}
text = text + "敌人数量:" + num2 + "\r\n";
EnemyBriefInfo val2 = new EnemyBriefInfo();
val2.SetBriefInfo(spaceSector, hiveAstroId, enemyId, 0, 0, 0, 0);
string text5 = GenerateHiveCoreInfoString(val, val2);
text = text + text5 + "\r\n";
list.Add(text);
}
}
return list;
}
private static string GenerateHiveCoreInfoString(EnemyDFHiveSystem enemyDfHiveSystem, EnemyBriefInfo enemyInfo)
{
float num = 1E+09f;
string text = $"Matter: {enemyInfo.matter}/{enemyInfo.matterMax}\r\n";
string text2 = $"Energy: {Math.Round((float)enemyInfo.energy / num, 3)}GJ/{(float)enemyInfo.energyMax / num}GJ\r\n";
string text3 = Localization.Translate("中继站") + enemyInfo.relayCount + $"(idle:{enemyDfHiveSystem.idleRelayCount})" + "\r\n";
string text4 = Localization.Translate("火种") + enemyInfo.tinderCount + $"(idle:{enemyDfHiveSystem.idleTinderCount})" + "\r\n";
string text5 = "";
Localization.Translate("制造中");
string text6 = "";
if (enemyInfo.buildRelaySp > 0 || enemyInfo.buildTinderSp > 0)
{
if (enemyInfo.buildRelaySp > 0 && enemyInfo.buildTinderSp > 0)
{
float num2 = (float)enemyInfo.buildRelaySp / (float)enemyInfo.buildRelaySpMax;
text5 = text5 + "(" + Localization.Translate("中继站") + ") " + (num2 * 100f).ToString("0.0") + "\u2006%";
float num3 = (float)enemyInfo.buildTinderSp / (float)enemyInfo.buildTinderSpMax;
text6 = text6 + "(" + Localization.Translate("火种") + ") " + (num3 * 100f).ToString("0.0") + "\u2006%";
text5 = text6;
}
else if (enemyInfo.buildRelaySp > 0)
{
float num2 = (float)enemyInfo.buildRelaySp / (float)enemyInfo.buildRelaySpMax;
text5 = text5 + "(" + Localization.Translate("中继站") + ") " + (num2 * 100f).ToString("0.0") + "\u2006%";
}
else if (enemyInfo.buildTinderSp > 0)
{
float num2 = (float)enemyInfo.buildTinderSp / (float)enemyInfo.buildTinderSpMax;
text5 = text5 + "(" + Localization.Translate("火种") + ") " + (num2 * 100f).ToString("0.0") + "\u2006%";
}
}
return text + text2 + text3 + text4 + text5;
}
}
public class Constants
{
public static readonly string[] HiveCodes = new string[12]
{
"α", "β", "γ", "δ", "ε", "ζ", "η", "θ", "ι", "κ",
"λ", "μ"
};
}
public class DFILocalize
{
private static readonly Dictionary<string, string> DFIDictionary = new Dictionary<string, string>
{
{ "行星仇恨值", "Planet Hatred" },
{ "被消灭", "Neutralized" },
{ "出发概率", "Dispatch Possibility" },
{ "巢穴构成", "Hive Composition" },
{ "防御塔", "Defence Turrets" },
{ "制造港", "Replicator Ports" },
{ "电力偷取比例", "Energy Steal Fraction" }
};
public static string Translate(string text)
{
if (Localization.isZHCN)
{
return text;
}
if (Localization.CanTranslate(text))
{
return Localization.Translate(text);
}
if (DFIDictionary.ContainsKey(text))
{
return DFIDictionary[text];
}
return text;
}
}
public class UIHiveInfo : MonoBehaviour
{
private GUIStyle LabelStyleInfoTitle;
private GUIStyle LabelStyleHeader;
private GUIStyle LabelStyleContent;
private Rect RectStarMapHiveInfo;
private string InfoTitleText;
private readonly List<string> Headers = new List<string>();
private readonly List<string> Contents = new List<string>();
private EnemyDFHiveSystem LastUpdateHive;
private double NextUpdateTime;
public static UIHiveInfo Create()
{
//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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Expected O, but got Unknown
UIHiveInfo uIHiveInfo = new UIHiveInfo();
float num = (float)Screen.height * 0.4f;
float num2 = (float)Screen.height * 0.6f;
float num3 = (float)Screen.width / 3980f;
uIHiveInfo.RectStarMapHiveInfo = new Rect((float)Screen.width - num, (float)Screen.height * 0.2f, num, num2);
uIHiveInfo.LabelStyleInfoTitle = new GUIStyle(GUI.skin.label)
{
fontStyle = (FontStyle)1,
fontSize = (int)(34.0 * (double)num3)
};
uIHiveInfo.LabelStyleHeader = new GUIStyle(GUI.skin.label)
{
fontSize = (int)(24.0 * (double)num3)
};
uIHiveInfo.LabelStyleContent = new GUIStyle(GUI.skin.label)
{
fontSize = (int)(24.0 * (double)num3)
};
return uIHiveInfo;
}
public void OnGUI()
{
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
UIStarmap starmap = UIRoot.instance.uiGame.starmap;
if (!((Object)(object)starmap.focusHive != (Object)null) && starmap.viewHive == null)
{
return;
}
EnemyDFHiveSystem val = ((!((Object)(object)starmap.focusHive != (Object)null)) ? starmap.viewHive : starmap.focusHive.hive);
if (val?.hiveAstroId != LastUpdateHive?.hiveAstroId || NextUpdateTime < (double)Time.time)
{
LastUpdateHive = val;
UpdateHiveInfoPanel(val);
NextUpdateTime = (double)Time.time + 1.0;
}
GUILayout.BeginArea(RectStarMapHiveInfo);
GUILayout.Label(InfoTitleText, LabelStyleInfoTitle, Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.BeginVertical(LabelStyleHeader, Array.Empty<GUILayoutOption>());
foreach (string header in Headers)
{
GUILayout.Label(header, LabelStyleHeader, Array.Empty<GUILayoutOption>());
}
GUILayout.EndVertical();
GUILayout.BeginVertical(LabelStyleHeader, Array.Empty<GUILayoutOption>());
foreach (string content in Contents)
{
GUILayout.Label(content, LabelStyleContent, Array.Empty<GUILayoutOption>());
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
private void AddInfo(string header, string contents = "")
{
Headers.Add(header);
Contents.Add(contents);
}
private string GetHiveName(EnemyDFHiveSystem hive)
{
return Constants.HiveCodes[hive.hiveOrbitIndex % Constants.HiveCodes.Length].ToString() + " " + Localization.Translate("巢穴简称");
}
public static void CountByProductName(ref Dictionary<string, int> dictCounter, int productId, int addNumber = 1)
{
EnemyProto val = ((ProtoSet<EnemyProto>)(object)LDB.enemies).Select(productId);
string name = ((Proto)val).Name;
if (!dictCounter.ContainsKey(name))
{
dictCounter.Add(name, addNumber);
}
else
{
dictCounter[((Proto)val).Name] += addNumber;
}
}
public static int CountAvailableDataPoolItems<T>(DataPool<T> dataPool) where T : struct, IPoolElement
{
int num = 0;
for (int i = 1; i < dataPool.cursor; i++)
{
T val = dataPool.buffer[i];
if (((IPoolElement)val).ID == i)
{
num++;
}
}
return num;
}
public static int StatReplicator(EnemyDFHiveSystem hive, ref Dictionary<string, int> dictCounter)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
DataPool<DFSReplicatorComponent> replicators = hive.replicators;
for (int i = 1; i < replicators.cursor; i++)
{
DFSReplicatorComponent val = replicators.buffer[i];
if (val.id == i)
{
num++;
EnemyData val2 = GameMain.data.spaceSector.enemyPool[val.enemyId];
EnemyProto val3 = ((ProtoSet<EnemyProto>)(object)LDB.enemies).Select((int)val2.protoId);
string name = ((Proto)val3).Name;
if (!dictCounter.ContainsKey(name))
{
dictCounter.Add(name, 1);
}
else
{
dictCounter[((Proto)val3).Name]++;
}
}
}
return num;
}
public static int StatTurret(EnemyDFHiveSystem hive, ref Dictionary<string, int> dictCounter)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Invalid comparison between Unknown and I4
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Invalid comparison between Unknown and I4
int num = 0;
DataPool<DFSTurretComponent> turrets = hive.turrets;
for (int i = 1; i < turrets.cursor; i++)
{
DFSTurretComponent val = turrets.buffer[i];
if (val.id != i)
{
continue;
}
num++;
string key = "Unknown Type";
EDFTurretType type = val.type;
if ((int)type != 1)
{
if ((int)type == 2)
{
key = Localization.Translate("等离子发生塔");
}
}
else
{
key = Localization.Translate("相位激光塔");
}
if (!dictCounter.ContainsKey(key))
{
dictCounter.Add(key, 1);
}
else
{
dictCounter[key]++;
}
}
return num;
}
public void UpdateHiveInfoPanel(EnemyDFHiveSystem hive)
{
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Expected O, but got Unknown
//IL_0575: Unknown result type (might be due to invalid IL or missing references)
//IL_057a: Unknown result type (might be due to invalid IL or missing references)
//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
Headers.Clear();
Contents.Clear();
if (!hive.isAlive)
{
return;
}
InfoTitleText = GetHiveName(hive) + string.Format("({0}:{1})", Localization.Translate("等级全称"), hive.evolve.level);
int hiveAstroId = hive.hiveAstroId;
int enemyId = hive.cores.buffer[1].enemyId;
AddInfo("Hive Enemy ID", hive.cores.buffer[1].enemyId.ToString());
AddInfo("Hive Astro ID", hive.hiveAstroId.ToString());
int num = 0;
Dictionary<string, int> dictCounter = new Dictionary<string, int>();
for (int i = 0; i < hive.forms.Length; i++)
{
num += hive.forms[i].unitCount;
int productId = 8113 - i;
CountByProductName(ref dictCounter, productId, hive.forms[i].unitCount);
}
AddInfo(Localization.Translate("黑雾单位"), num.ToString());
foreach (string key in dictCounter.Keys)
{
AddInfo(" " + Localization.Translate(key), dictCounter[key].ToString());
}
Dictionary<string, int> dictCounter2 = new Dictionary<string, int>();
Dictionary<string, int> dictCounter3 = new Dictionary<string, int>();
AddInfo(DFILocalize.Translate("巢穴构成"));
int num2 = UIHiveInfo.CountAvailableDataPoolItems<DFSGammaComponent>(hive.gammas);
AddInfo(" " + Localization.Translate("光能接收站"), num2.ToString());
AddInfo(" " + DFILocalize.Translate("电力偷取比例"), $"{0.0003 * (double)num2:P} - {0.0007 * (double)num2:P}");
int num3 = StatReplicator(hive, ref dictCounter2);
AddInfo(" " + DFILocalize.Translate("制造港"), num3.ToString());
foreach (string key2 in dictCounter2.Keys)
{
AddInfo(" " + Localization.Translate(key2), dictCounter2[key2].ToString());
}
int num4 = StatTurret(hive, ref dictCounter3);
AddInfo(" " + DFILocalize.Translate("防御塔"), num4.ToString());
foreach (string key3 in dictCounter3.Keys)
{
AddInfo(" " + Localization.Translate(key3), dictCounter3[key3].ToString());
}
EnemyBriefInfo val = new EnemyBriefInfo();
val.SetBriefInfo(GameMain.spaceSector, hiveAstroId, enemyId, 0, 0, 0, 0);
AddInfo(Localization.Translate("物质"), val.matter.ToString());
AddInfo(Localization.Translate("能量"), $"{(double)val.energy / 1000000000.0:N2}GJ");
AddInfo(Localization.Translate("中继站"), val.relayCount.ToString());
AddInfo(" " + Localization.Translate("待机"), hive.idleRelayCount.ToString());
AddInfo(" " + DFILocalize.Translate("被消灭"), hive.relayNeutralizedCounter.ToString());
float num5 = ((hive.relayNeutralizedCounter <= 6) ? 1f : ((float)(3.0 / ((double)hive.relayNeutralizedCounter - 3.0))));
AddInfo(" " + DFILocalize.Translate("出发概率"), $"{num5:P}/10Seconds");
AddInfo(" MTTH", string.Format("{0:N1} " + Localization.Translate("空格分钟"), 1f / 6f / num5));
if (val.buildRelaySp > 0)
{
double num6 = (double)val.buildRelaySp / (double)val.buildRelaySpMax;
AddInfo(" " + Localization.Translate("制造中"), $"{num6:P}");
}
AddInfo(Localization.Translate("火种"), val.tinderCount.ToString());
AddInfo(" " + Localization.Translate("待机"), hive.idleTinderCount.ToString());
if (val.buildTinderSp > 0)
{
double num7 = (double)val.buildTinderSp / (double)val.buildTinderSpMax;
AddInfo(" " + Localization.Translate("制造中"), $"{num7:P}");
}
if (GetHatretList(hive).Count <= 0)
{
return;
}
AddInfo(DFILocalize.Translate("行星仇恨值"));
foreach (HatredTarget hatret in GetHatretList(hive))
{
HatredTarget current4 = hatret;
PlanetData val2 = GameMain.data.spaceSector.galaxy.PlanetById(((HatredTarget)(ref current4)).objectId);
string header = " " + val2.displayName;
int value = current4.value;
AddInfo(header, value.ToString());
}
}
private static List<HatredTarget> GetHatretList(EnemyDFHiveSystem hive)
{
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Invalid comparison between Unknown and I4
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
ref HatredTarget max = ref hive.hatredAstros.max;
List<HatredTarget> list = new List<HatredTarget>();
for (int i = 0; i < 8; i++)
{
max = i switch
{
0 => ref hive.hatredAstros.max,
1 => ref hive.hatredAstros.h1,
2 => ref hive.hatredAstros.h2,
3 => ref hive.hatredAstros.h3,
4 => ref hive.hatredAstros.h4,
5 => ref hive.hatredAstros.h5,
6 => ref hive.hatredAstros.h6,
7 => ref hive.hatredAstros.min,
_ => ref hive.hatredAstros.max,
};
if (!((HatredTarget)(ref max)).isNull)
{
PlanetData val = GameMain.data.spaceSector.galaxy.PlanetById(((HatredTarget)(ref max)).objectId);
if (val != null && (int)val.type != 5)
{
list.Add(max);
}
}
list.Sort((HatredTarget a, HatredTarget b) => b.value - a.value);
}
return list;
}
}