using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
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("KroesTerminal")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KroesTerminal")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("de3d7b90-7d06-4938-9b2f-b7c9e2f82888")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace KroesTerminal
{
[BepInPlugin("com.kroes.kroesterminal", "KroesTerminal", "1.0.0")]
public class KroesTerminal : BaseUnityPlugin
{
private const string GUID = "com.kroes.kroesterminal";
private const string NAME = "KroesTerminal";
private const string VERSION = "1.0.0";
internal static ManualLogSource Log;
private Harmony harmony = new Harmony("com.kroes.kroesterminal");
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"Loaded succesfully!");
harmony.PatchAll();
}
}
internal class TextJumpAnimation : MonoBehaviour
{
private TextMeshProUGUI text;
private float jumpTime;
private const float jumpDuration = 0.2f;
private const float jumpScale = 1.5f;
private readonly Vector3 originalScale = new Vector3(1f, 1f, 1f);
public void StartJump(TextMeshProUGUI target)
{
text = target;
jumpTime = 0.2f;
}
private void Update()
{
//IL_0063: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)text == (Object)null) && jumpTime > 0f)
{
float num = 1f - jumpTime / 0.2f;
float num2 = Mathf.Sin(num * (float)Math.PI) * 0.5f + 1f;
((TMP_Text)text).transform.localScale = originalScale * num2;
jumpTime -= Time.deltaTime;
if (jumpTime <= 0f)
{
((TMP_Text)text).transform.localScale = originalScale;
Object.Destroy((Object)(object)this);
}
}
}
}
internal class Utilities
{
public static TextMeshProUGUI QuotaText;
public static GameObject ship;
public static int totalShipLoot;
internal static TerminalNode CreateTerminalNode(string name)
{
TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
val.displayText = "[" + name + "]";
val.terminalEvent = "";
val.clearPreviousText = true;
val.maxCharactersToType = 35;
val.buyItemIndex = -1;
val.buyVehicleIndex = -1;
val.isConfirmationNode = false;
val.buyRerouteToMoon = -1;
val.displayPlanetInfo = -1;
val.shipUnlockableID = -1;
val.buyUnlockable = false;
val.returnFromStorage = false;
val.itemCost = 0;
val.creatureFileID = -1;
val.creatureName = "";
val.storyLogFileID = -1;
val.overrideOptions = false;
val.acceptAnything = false;
val.terminalOptions = Array.Empty<CompatibleNoun>();
val.playSyncedClip = -1;
val.loadImageSlowly = false;
val.persistentImage = false;
return val;
}
internal static void OnSubmitEnd(Terminal terminal)
{
terminal.screenText.ActivateInputField();
((Selectable)terminal.screenText).Select();
}
internal static string KScanDisplayText()
{
string text = "";
int num = 0;
GrabbableObject[] source = Object.FindObjectsOfType<GrabbableObject>();
GrabbableObject[] array = (from obj in source
where obj.itemProperties.isScrap && !obj.isInShipRoom && !obj.isInElevator
orderby obj.itemProperties.itemName
select obj).ToArray();
if (array.Length == 0)
{
return "\n\n\nNo objects were found.\n\n";
}
GrabbableObject[] array2 = array;
foreach (GrabbableObject val in array2)
{
text += $"\n* {val.itemProperties.itemName} // ${val.scrapValue}";
num += val.scrapValue;
}
return $"\n\n\nThere are {array.Length} objects outside the ship, totalling a value of ${num}.\n{text}\n\n";
}
internal static string KItemsDisplayText()
{
int num = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
GrabbableObject[] array2 = array;
foreach (GrabbableObject val in array2)
{
if (val.itemProperties.isScrap)
{
if (val.isInShipRoom)
{
num3++;
num4 += val.scrapValue;
}
else if (!val.isInElevator)
{
num++;
num2 += val.scrapValue;
}
}
}
return $"\n\n\nItems on moon: {num} : ${num2}\nItems in ship: {num3} : ${num4}\n\n";
}
internal static int ShipLootTotal()
{
List<GrabbableObject> source = (from obj in ship.GetComponentsInChildren<GrabbableObject>()
where obj.itemProperties.isScrap && !(obj is RagdollGrabbableObject)
select obj).ToList();
return source.Sum((GrabbableObject scrap) => scrap.scrapValue);
}
public static void TriggerJump()
{
TextMeshProUGUI quotaText = QuotaText;
if (!((Object)(object)quotaText == (Object)null))
{
TextJumpAnimation textJumpAnimation = ((Component)quotaText).gameObject.AddComponent<TextJumpAnimation>();
textJumpAnimation.StartJump(quotaText);
}
}
}
}
namespace KroesTerminal.Patches
{
[HarmonyPatch(typeof(HUDManager))]
internal class HUDManagerPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void AwakePostfix(HUDManager __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0036: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("myHotbarUI");
val.transform.SetParent(__instance.HUDContainer.transform, false);
RectTransform val2 = val.AddComponent<RectTransform>();
val2.anchorMin = new Vector2(0f, 1f);
val2.anchorMax = new Vector2(0f, 1f);
val2.pivot = new Vector2(0f, 1f);
val2.anchoredPosition = new Vector2(60f, -10f);
GameObject val3 = new GameObject("QuotaText");
val3.transform.SetParent(val.transform, false);
TextMeshProUGUI val4 = val3.AddComponent<TextMeshProUGUI>();
RectTransform component = val3.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.5f, 0.5f);
component.anchorMax = new Vector2(0.5f, 0.5f);
component.pivot = new Vector2(0.5f, 0.5f);
component.anchoredPosition = new Vector2(50f, 20f);
component.sizeDelta = new Vector2(300f, 50f);
((TMP_Text)val4).font = ((TMP_Text)__instance.controlTipLines[0]).font;
((TMP_Text)val4).fontSize = 20f;
((TMP_Text)val4).fontStyle = (FontStyles)1;
((TMP_Text)val4).text = "-placeholder-";
((Graphic)val4).color = Color.white;
((TMP_Text)val4).alignment = (TextAlignmentOptions)513;
((TMP_Text)val4).enableWordWrapping = true;
((TMP_Text)val4).overflowMode = (TextOverflowModes)0;
Utilities.QuotaText = val4;
Utilities.ship = GameObject.Find("/Environment/HangarShip");
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePostfix(HUDManager __instance)
{
int num = Utilities.ShipLootTotal();
if (num != Utilities.totalShipLoot)
{
Utilities.totalShipLoot = num;
Utilities.TriggerJump();
}
((TMP_Text)Utilities.QuotaText).text = $"[QUOTA] {Utilities.totalShipLoot} : {TimeOfDay.Instance.profitQuota}";
}
}
[HarmonyPatch(typeof(Terminal))]
internal class TerminalPatch
{
[HarmonyPatch("OnSubmit")]
[HarmonyPrefix]
private static bool OnSubmitPrefix(Terminal __instance)
{
string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
string text2 = text.ToLower();
if (text2 == "kscan")
{
KroesTerminal.Log.LogInfo((object)"Custom Command: kscan");
TerminalNode val = Utilities.CreateTerminalNode("kscan");
__instance.LoadNewNode(val);
return false;
}
if (text2 == "kitems")
{
KroesTerminal.Log.LogInfo((object)"Custom Command: kitems");
TerminalNode val2 = Utilities.CreateTerminalNode("kitems");
__instance.LoadNewNode(val2);
return false;
}
return true;
}
[HarmonyPatch("TextPostProcess")]
[HarmonyPrefix]
private static bool TextPostProcessPrefix(ref string modifiedDisplayText, TerminalNode node, ref string __result, Terminal __instance)
{
string text = modifiedDisplayText.Trim();
if (text.Contains("[kscan]"))
{
KroesTerminal.Log.LogInfo((object)"Processing [kscan]...");
__result = Utilities.KScanDisplayText();
Utilities.OnSubmitEnd(__instance);
return false;
}
if (text.Contains("[kitems]"))
{
KroesTerminal.Log.LogInfo((object)"Processing [kitems]...");
__result = Utilities.KItemsDisplayText();
Utilities.OnSubmitEnd(__instance);
return false;
}
return true;
}
}
}