using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using ShowLootOnPlanet.Patches;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
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("ShowLootOnPlanet")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShowLootOnPlanet")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("725ec4c1-a00b-4c16-99cc-16d676583120")]
[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 ShowLootOnPlanet
{
public enum ColorType
{
White,
Red,
Orange,
Yellow,
Green,
Blue,
Purple,
Pink
}
public enum OffsetGUI
{
Original,
Lowered,
Lowered2,
Uppered,
Uppered2
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("funfoxrr.PlanetLoot", "Show Planet Loot", "1.0.0.0")]
public class PlanetModBase : BaseUnityPlugin
{
private const string GUID = "funfoxrr.PlanetLoot";
private const string NAME = "Show Planet Loot";
private const string VERSION = "1.0.0.0";
private readonly Harmony harmony = new Harmony("funfoxrr.PlanetLoot");
public static PlanetModBase Instance;
internal static ManualLogSource log;
public static ConfigEntry<ColorType> color;
public static ConfigEntry<OffsetGUI> offset;
public static ConfigEntry<float> fontSize;
public static ConfigEntry<float> lifetime;
public static ConfigEntry<bool> logging;
public static ColorType colorValue;
private void Awake()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_00ad: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
//IL_00e3: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Expected O, but got Unknown
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Expected O, but got Unknown
//IL_0185: Expected O, but got Unknown
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Expected O, but got Unknown
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Expected O, but got Unknown
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
log = Logger.CreateLogSource("funfoxrr.PlanetLoot");
log.LogInfo((object)"The mod has awakened!");
color = ((BaseUnityPlugin)this).Config.Bind<ColorType>("Customize", "Color", ColorType.Green, "Change the color of the text!");
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<ColorType>(color, new EnumDropDownOptions
{
RequiresRestart = false
}));
color.Value = colorValue;
lifetime = ((BaseUnityPlugin)this).Config.Bind<float>("Customize", "Lifetime", 3f, "How long does it last? ShipLoot: 5");
ConfigEntry<float> obj = lifetime;
FloatStepSliderOptions val = new FloatStepSliderOptions
{
RequiresRestart = false,
Step = 0.25f
};
((BaseRangeOptions<float>)val).Min = 1f;
((BaseRangeOptions<float>)val).Max = 6f;
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatStepSliderConfigItem(obj, val));
offset = ((BaseUnityPlugin)this).Config.Bind<OffsetGUI>("Support", "Offset", OffsetGUI.Original, "Just in case for other mods intersect. (If needed, may turn into a slider)");
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<OffsetGUI>(offset, new EnumDropDownOptions
{
RequiresRestart = false
}));
fontSize = ((BaseUnityPlugin)this).Config.Bind<float>("Customize", "Font Size", 19f, "Change the size of the text.");
ConfigEntry<float> obj2 = fontSize;
FloatStepSliderOptions val2 = new FloatStepSliderOptions
{
RequiresRestart = false,
Step = 0.25f
};
((BaseRangeOptions<float>)val2).Min = 6f;
((BaseRangeOptions<float>)val2).Max = 24f;
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatStepSliderConfigItem(obj2, val2));
logging = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Logging", false, "Should log into the console? Should be off in most cases.");
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(logging, new BoolCheckBoxOptions
{
RequiresRestart = false
}));
color.SettingChanged += Color_SettingChanged;
harmony.PatchAll(typeof(PlanetModBase));
harmony.PatchAll(typeof(ScanPatch));
}
private void Color_SettingChanged(object sender, EventArgs e)
{
colorValue = color.Value;
}
}
}
namespace ShowLootOnPlanet.Patches
{
[HarmonyPatch]
internal class ScanPatch
{
private static GameObject counter;
private static TextMeshProUGUI textMesh;
private static float displayLeft;
private static float DisplayTime = 3f;
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
private static void OnScan(HUDManager __instance, CallbackContext context)
{
if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
{
return;
}
if (PlanetModBase.logging.Value)
{
PlanetModBase.log.LogInfo((object)"SCAN!");
}
if (!Object.op_Implicit((Object)(object)counter))
{
CopyValueCounter();
}
GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
int num = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
for (int i = 0; i < array.Length; i++)
{
if (array[i].itemProperties.isScrap && !array[i].isInShipRoom && !array[i].isInElevator && !array[i].scrapPersistedThroughRounds)
{
num++;
num2 += array[i].scrapValue;
}
else if (array[i].itemProperties.isScrap && array[i].isInShipRoom && array[i].isInElevator)
{
num3++;
num4 += array[i].scrapValue;
}
}
if (num > 0)
{
DisplayTime = PlanetModBase.lifetime.Value;
StyleText();
((TMP_Text)textMesh).text = $"MOON: ${num2:F0} (" + num + ")";
displayLeft = DisplayTime;
if (!counter.activeSelf)
{
((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(PlanetLoot());
}
}
}
private static IEnumerator PlanetLoot()
{
counter.SetActive(true);
while (displayLeft > 0f)
{
float time = displayLeft;
displayLeft = 0f;
yield return (object)new WaitForSeconds(time);
}
counter.SetActive(false);
Object.Destroy((Object)(object)counter);
}
private static void StyleText()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
((TMP_Text)textMesh).fontSize = PlanetModBase.fontSize.Value;
switch (PlanetModBase.colorValue)
{
case ColorType.White:
((Graphic)textMesh).color = new Color(0.9056604f, 0.9056604f, 0.9056604f);
break;
case ColorType.Red:
((Graphic)textMesh).color = new Color(1f, 0.3820755f, 0.3820755f);
break;
case ColorType.Orange:
((Graphic)textMesh).color = new Color(1f, 0.7653924f, 0.3803922f);
break;
case ColorType.Yellow:
((Graphic)textMesh).color = new Color(0.9899307f, 1f, 0.3803922f);
break;
case ColorType.Green:
((Graphic)textMesh).color = new Color(0.3803922f, 1f, 0.6797408f);
break;
case ColorType.Blue:
((Graphic)textMesh).color = new Color(0.3803922f, 0.8848869f, 1f);
break;
case ColorType.Purple:
((Graphic)textMesh).color = new Color(0.6813213f, 0.3803922f, 1f);
break;
case ColorType.Pink:
((Graphic)textMesh).color = new Color(0.9750692f, 0.3803922f, 1f);
break;
}
}
private static void CopyValueCounter()
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/ValueCounter");
if (!Object.op_Implicit((Object)(object)counter) && PlanetModBase.logging.Value)
{
PlanetModBase.log.LogWarning((object)"Failed to find ValueCounter object to copy!");
}
counter = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false);
counter.transform.Translate(0f, 1f, 0f);
Vector3 localPosition = counter.transform.localPosition;
counter.transform.localPosition = new Vector3(localPosition.x + 50f, -50f, localPosition.z);
textMesh = counter.GetComponentInChildren<TextMeshProUGUI>();
switch (PlanetModBase.offset.Value)
{
case OffsetGUI.Original:
break;
case OffsetGUI.Lowered:
counter.transform.Translate(0f, -0.18f, 0f);
break;
case OffsetGUI.Lowered2:
counter.transform.Translate(0f, -0.3f, 0f);
break;
case OffsetGUI.Uppered:
counter.transform.Translate(0f, 0.18f, 0f);
break;
case OffsetGUI.Uppered2:
counter.transform.Translate(0f, 0.3f, 0f);
break;
}
}
}
}