using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Dawn;
using Dawn.Internal;
using Dawn.Utils;
using Dusk;
using GameNetcodeStuff;
using Microsoft.CodeAnalysis;
using On;
using On.Dusk;
using On.GameNetcodeStuff;
using ScannableLuck.Patches;
using TMPro;
using UnityEngine;
using com.github.xuuxiaolan.scannableluck.NetcodePatcher;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("com.github.xuuxiaolan.scannableluck")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("ScannableLuck")]
[assembly: AssemblyTitle("com.github.xuuxiaolan.scannableluck")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ScannableLuck
{
[BepInPlugin("com.github.xuuxiaolan.scannableluck", "ScannableLuck", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ScannableLuck : BaseUnityPlugin
{
internal static ManualLogSource Logger { get; private set; }
internal static PersistentDataContainer PersistentData { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
UnlockableItemPatches.Init();
PersistentData = BepInPluginExtensions.GetPersistentDataContainer((BaseUnityPlugin)(object)this);
((DataContainer)PersistentData).Set<string>(ScannableLuckKeys.LastVersion, "1.0.1");
Logger.LogInfo((object)"com.github.xuuxiaolan.scannableluck v1.0.1 has loaded!");
}
}
public static class ScannableLuckKeys
{
public const string Namespace = "scannable_luck";
internal static NamespacedKey LastVersion = NamespacedKey.From("scannable_luck", "last_version");
}
public class ValueTextChecker : MonoBehaviour
{
private static readonly int display = Animator.StringToHash("display");
public void Update()
{
if (UnlockableItemPatches.totalLuckScanned == 0f || !HUDManager.Instance.scanInfoAnimator.GetBool(display))
{
((Behaviour)UnlockableItemPatches.totalTextLuckText).enabled = false;
((Behaviour)UnlockableItemPatches.totalNumLuckText).enabled = false;
}
else
{
((Behaviour)UnlockableItemPatches.totalTextLuckText).enabled = true;
((Behaviour)UnlockableItemPatches.totalNumLuckText).enabled = true;
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.github.xuuxiaolan.scannableluck";
public const string PLUGIN_NAME = "ScannableLuck";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace ScannableLuck.Patches
{
internal static class UnlockableItemPatches
{
[CompilerGenerated]
private static class <>O
{
public static hook_Start <0>__PlayerControllerStart;
public static hook_Start <1>__UnlockableItemAwake;
public static hook_AssignNodeToUIElement <2>__HUDManagerAssignNodeToUIElement;
public static hook_DisableAllScanElements <3>__HUDManagerDisableAllScanElements;
public static hook_NodeIsNotVisible <4>__HUDManagerNodeIsNotVisible;
}
private static GameObject totalNumLuck;
internal static TextMeshProUGUI totalNumLuckText;
private static GameObject totalTextLuck;
internal static TextMeshProUGUI totalTextLuckText;
internal static float totalLuckScanned;
private static List<ScanNodeProperties> scanNodesAlreadyAdded = new List<ScanNodeProperties>();
internal static void Init()
{
//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_001b: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
object obj = <>O.<0>__PlayerControllerStart;
if (obj == null)
{
hook_Start val = PlayerControllerStart;
<>O.<0>__PlayerControllerStart = val;
obj = (object)val;
}
PlayerControllerB.Start += (hook_Start)obj;
object obj2 = <>O.<1>__UnlockableItemAwake;
if (obj2 == null)
{
hook_Start val2 = UnlockableItemAwake;
<>O.<1>__UnlockableItemAwake = val2;
obj2 = (object)val2;
}
DuskUnlockable.Start += (hook_Start)obj2;
object obj3 = <>O.<2>__HUDManagerAssignNodeToUIElement;
if (obj3 == null)
{
hook_AssignNodeToUIElement val3 = HUDManagerAssignNodeToUIElement;
<>O.<2>__HUDManagerAssignNodeToUIElement = val3;
obj3 = (object)val3;
}
HUDManager.AssignNodeToUIElement += (hook_AssignNodeToUIElement)obj3;
object obj4 = <>O.<3>__HUDManagerDisableAllScanElements;
if (obj4 == null)
{
hook_DisableAllScanElements val4 = HUDManagerDisableAllScanElements;
<>O.<3>__HUDManagerDisableAllScanElements = val4;
obj4 = (object)val4;
}
HUDManager.DisableAllScanElements += (hook_DisableAllScanElements)obj4;
object obj5 = <>O.<4>__HUDManagerNodeIsNotVisible;
if (obj5 == null)
{
hook_NodeIsNotVisible val5 = HUDManagerNodeIsNotVisible;
<>O.<4>__HUDManagerNodeIsNotVisible = val5;
obj5 = (object)val5;
}
HUDManager.NodeIsNotVisible += (hook_NodeIsNotVisible)obj5;
}
private static bool HUDManagerNodeIsNotVisible(orig_NodeIsNotVisible orig, HUDManager self, ScanNodeProperties node, int elementIndex)
{
if (self.nodesOnScreen.Contains(node))
{
return orig.Invoke(self, node, elementIndex);
}
if (!scanNodesAlreadyAdded.Contains(node))
{
return orig.Invoke(self, node, elementIndex);
}
totalLuckScanned -= float.Parse(node.subText.Split(" ")[2], CultureInfo.InvariantCulture);
((TMP_Text)totalNumLuckText).text = $"${totalLuckScanned}";
ScannableLuck.Logger.LogInfo((object)$"{totalLuckScanned} total luck scanned!");
scanNodesAlreadyAdded.Remove(node);
return orig.Invoke(self, node, elementIndex);
}
private static void HUDManagerDisableAllScanElements(orig_DisableAllScanElements orig, HUDManager self)
{
orig.Invoke(self);
totalLuckScanned = 0f;
((TMP_Text)totalNumLuckText).text = "$0";
scanNodesAlreadyAdded.Clear();
}
private static void HUDManagerAssignNodeToUIElement(orig_AssignNodeToUIElement orig, HUDManager self, ScanNodeProperties node)
{
orig.Invoke(self, node);
if (!scanNodesAlreadyAdded.Contains(node) && node.nodeType == 2 && node.subText.StartsWith("Luck Value: "))
{
totalLuckScanned += float.Parse(node.subText.Split(" ")[2], CultureInfo.InvariantCulture);
((TMP_Text)totalNumLuckText).text = $"${totalLuckScanned}";
scanNodesAlreadyAdded.Add(node);
ScannableLuck.Logger.LogInfo((object)$"{totalLuckScanned} total luck scanned!");
}
}
private static void PlayerControllerStart(orig_Start orig, PlayerControllerB self)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (!((Object)(object)totalNumLuck != (Object)null))
{
GameObject val = GameObject.Find("Systems/UI/Canvas/ObjectScanner/GlobalScanInfo/AnimContainer/Image/TotalNum");
GameObject val2 = GameObject.Find("Systems/UI/Canvas/ObjectScanner/GlobalScanInfo/AnimContainer/Image/TotalText");
totalNumLuck = Object.Instantiate<GameObject>(val, val.transform.parent);
totalNumLuck.AddComponent<ValueTextChecker>();
((Object)totalNumLuck).name = "TotalNumLuck";
((RectTransform)totalNumLuck.transform).anchoredPosition = Vector2.op_Implicit(new Vector3(-20.8f, -26.3f, -4.7f));
totalNumLuckText = totalNumLuck.GetComponent<TextMeshProUGUI>();
((TMP_Text)totalNumLuckText).text = "$0";
((TMP_Text)totalNumLuckText).fontSize = 16.48f;
((TMP_Text)totalNumLuckText).margin = new Vector4(0f, 0f, -21.95649f, 34.61575f);
((Behaviour)totalNumLuckText).enabled = true;
totalTextLuck = Object.Instantiate<GameObject>(val2, val2.transform.parent);
((Object)totalTextLuck).name = "TotalTextLuck";
((RectTransform)totalTextLuck.transform).anchoredPosition = Vector2.op_Implicit(new Vector3(-24.62507f, -27.8f, 0f));
totalTextLuckText = totalTextLuck.GetComponent<TextMeshProUGUI>();
((TMP_Text)totalTextLuckText).text = "TOTAL:";
((TMP_Text)totalTextLuckText).fontSize = 9.48f;
((TMP_Text)totalTextLuckText).margin = new Vector4(0f, 0f, 82.79764f, 36.80792f);
((Behaviour)totalTextLuckText).enabled = true;
}
}
private static void UnlockableItemAwake(orig_Start orig, DuskUnlockable self)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
UnlockableItem val = StartOfRoundRefs.Instance.unlockablesList.unlockables[self.PlaceableShipObject.unlockableID];
if (val.luckValue != 0f)
{
Collider val2 = default(Collider);
((Component)self).TryGetComponent<Collider>(ref val2);
GameObject val3 = new GameObject("ScanNode");
val3.transform.SetParent(((Component)self).transform);
val3.transform.localPosition = new Vector3(0f, 0.5f, 0f);
val3.transform.localRotation = Quaternion.identity;
val3.transform.localScale = Vector3.one;
val3.layer = LayerMask.NameToLayer("ScanNode");
BoxCollider val4 = val3.AddComponent<BoxCollider>();
val4.size = Vector3.one;
((Collider)val4).isTrigger = true;
ScanNodeProperties val5 = val3.AddComponent<ScanNodeProperties>();
val5.maxRange = 13;
val5.minRange = 0;
val5.requiresLineOfSight = true;
val5.headerText = val.unlockableName ?? "";
val5.subText = $"Luck Value: {val.luckValue}";
val5.nodeType = 2;
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace __GEN
{
internal class NetworkVariableSerializationHelper
{
[RuntimeInitializeOnLoadMethod]
internal static void InitializeSerialization()
{
}
}
}
namespace com.github.xuuxiaolan.scannableluck.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}