using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CountCruiserLoot;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HitsujiSauce.CountCruiserLoot")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CountCruiserLoot")]
[assembly: AssemblyTitle("HitsujiSauce.CountCruiserLoot")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
}
}
}
public class ShipLootExternalConfig
{
private readonly ConfigFile _configFile;
private ConfigEntry<float> DisplayTimeConf;
public float DisplayTime;
public ShipLootExternalConfig()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
string text = Path.Combine(Paths.ConfigPath, "com.github.tinyhoot.ShipLoot.cfg");
if (!File.Exists(text))
{
DisplayTime = 5f;
return;
}
_configFile = new ConfigFile(text, true);
DisplayTimeConf = _configFile.Bind<float>("General", "DisplayTime", 5f, new ConfigDescription("How long to display the total scrap value for, counted in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>()));
DisplayTime = DisplayTimeConf.Value;
}
}
[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
public static class CruiserScanPatch
{
[CompilerGenerated]
private sealed class <CruiserLootCoroutine>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private float <time>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CruiserLootCoroutine>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
_totalCounter.SetActive(true);
break;
case 1:
<>1__state = -1;
break;
}
if (_displayTimeLeft > 0f)
{
<time>5__1 = _displayTimeLeft;
_displayTimeLeft = 0f;
<>2__current = (object)new WaitForSeconds(<time>5__1);
<>1__state = 1;
return true;
}
_totalCounter.SetActive(false);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static GameObject _totalCounter;
private static TextMeshProUGUI _textMesh;
private static float _displayTimeLeft;
private static ShipLootExternalConfig config;
public static void Postfix(HUDManager __instance)
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
if ((Object)(object)localPlayerController == (Object)null || localPlayerController.isInsideFactory || localPlayerController.isInHangarShipRoom)
{
return;
}
VehicleController cruiser = Object.FindObjectOfType<VehicleController>();
if ((Object)(object)cruiser != (Object)null)
{
List<GrabbableObject> list = (from obj in Object.FindObjectsOfType<GrabbableObject>()
where ((Component)obj).transform.IsChildOf(((Component)cruiser).transform) && !(obj is RagdollGrabbableObject) && obj.itemProperties.isScrap
select obj).ToList();
int count = list.Count;
int num = list.Sum((GrabbableObject o) => o.scrapValue);
if (!Object.op_Implicit((Object)(object)_totalCounter))
{
CopyValueCounter();
}
((TMP_Text)_textMesh).text = $"Cruiser:${num}({count})";
_displayTimeLeft = GetDisplayTimeLeft();
if (!_totalCounter.activeSelf)
{
((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(CruiserLootCoroutine());
}
}
}
[IteratorStateMachine(typeof(<CruiserLootCoroutine>d__5))]
private static IEnumerator CruiserLootCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CruiserLootCoroutine>d__5(0);
}
private static void CopyValueCounter()
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: 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_008f: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: 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)val))
{
global::CountCruiserLoot.CountCruiserLoot.Logger.LogError((object)"Failed to find ValueCounter object to copy!");
}
_totalCounter = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false);
_totalCounter.transform.Translate(0f, 1f, 0f);
Vector3 localPosition = _totalCounter.transform.localPosition;
_totalCounter.transform.localPosition = new Vector3(localPosition.x + 50f, -30f, localPosition.z);
_textMesh = _totalCounter.GetComponentInChildren<TextMeshProUGUI>();
RectTransform rectTransform = ((TMP_Text)_textMesh).rectTransform;
rectTransform.anchoredPosition += new Vector2(200f, 0f);
rectTransform.sizeDelta = new Vector2(600f, rectTransform.sizeDelta.y);
}
public static void SetInactive()
{
if ((Object)(object)_totalCounter != (Object)null && _totalCounter.activeSelf)
{
_totalCounter.SetActive(false);
}
}
private static float GetDisplayTimeLeft()
{
if (config == null)
{
config = new ShipLootExternalConfig();
}
float displayTime = config.DisplayTime;
if (displayTime > 0f)
{
return displayTime;
}
return 5f;
}
}
namespace CountCruiserLoot
{
[BepInPlugin("HitsujiSauce.CountCruiserLoot", "CountCruiserLoot", "1.0.0")]
public class CountCruiserLoot : BaseUnityPlugin
{
public static CountCruiserLoot Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Patch();
Logger.LogInfo((object)"HitsujiSauce.CountCruiserLoot v1.0.0 has loaded!");
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("HitsujiSauce.CountCruiserLoot");
}
Harmony.PatchAll();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "HitsujiSauce.CountCruiserLoot";
public const string PLUGIN_NAME = "CountCruiserLoot";
public const string PLUGIN_VERSION = "1.0.0";
}
}