using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using GTFO.API;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PingConsumables")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PingConsumables")]
[assembly: AssemblyTitle("PingConsumables")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace PingConsumables
{
[BepInPlugin("PingConsumables", "PingConsumables", "0.0.8")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public class PingConsumables : MonoBehaviour
{
[CompilerGenerated]
private sealed class <MovePickups>d__5 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <MovePickups>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//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_004e: Invalid comparison between Unknown and I4
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
}
else
{
<>1__state = -1;
}
bool flag = default(bool);
foreach (ResourcePackPickup item in packlist)
{
if (!((Object)(object)item != (Object)null) || (int)item.m_sync.GetCurrentState().status == 1)
{
continue;
}
iTerminalItem component = ((Component)item).GetComponent<iTerminalItem>();
if (component == null)
{
continue;
}
AIG_CourseNode courseNode = ((ItemInLevel)item).m_courseNode;
if (courseNode != null && component.SpawnNode != courseNode)
{
ManualLogSource l = L;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("setting ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(component.TerminalItemKey);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" spawnnode and locatorbeacon position..");
}
l.LogInfo(val);
component.SpawnNode = courseNode;
component.FloorItemLocation = courseNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7);
component.LocatorBeaconPosition = ((Component)item).transform.position;
}
}
<>2__current = (object)new WaitForSeconds(10f);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <RemoveConsumablesFromTerminal>d__4 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
private List<ConsumablePickup_Core> <poista>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RemoveConsumablesFromTerminal>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<poista>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Invalid comparison between Unknown and I4
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Expected O, but got Unknown
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Expected O, but got Unknown
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
}
else
{
<>1__state = -1;
<poista>5__2 = new List<ConsumablePickup_Core>();
}
foreach (ConsumablePickup_Core item in <poista>5__2)
{
_consumables.Remove(item);
}
<poista>5__2.Clear();
bool flag = default(bool);
foreach (ConsumablePickup_Core consumable in _consumables)
{
if (!((Object)(object)consumable != (Object)null))
{
continue;
}
iTerminalItem component = ((Component)consumable).GetComponent<iTerminalItem>();
if ((int)consumable.m_sync.GetCurrentState().status == 1)
{
if (LG_LevelInteractionManager.Current.m_terminalItems.ContainsKey(component.TerminalItemId))
{
LG_LevelInteractionManager.Current.m_terminalItems.Remove(component.TerminalItemId);
}
if (LG_LevelInteractionManager.Current.m_terminalItemsByKeyString.ContainsKey(component.TerminalItemKey))
{
LG_LevelInteractionManager.Current.m_terminalItemsByKeyString.Remove(component.TerminalItemKey);
}
<poista>5__2.Add(consumable);
ManualLogSource l = L;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("item ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(component.TerminalItemKey);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" removed from terminals as it was picked up.");
}
l.LogInfo(val);
}
}
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 1;
return true;
}
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 Coroutine mover;
private static Coroutine remover;
public static void OnLevelCleanup()
{
L.LogInfo((object)"all coroutines stop");
CoroutineManager.StopCoroutine(mover);
CoroutineManager.StopCoroutine(remover);
}
public static void Initialize()
{
//IL_0109: 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_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Expected O, but got Unknown
//IL_01a2: 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)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Expected O, but got Unknown
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Expected O, but got Unknown
_consumables.Clear();
bool flag = default(bool);
AIG_CourseNode val5 = default(AIG_CourseNode);
foreach (ConsumablePickup_Core item in Object.FindObjectsOfType<ConsumablePickup_Core>())
{
if (!((Item)item).ItemDataBlock.registerInTerminalSystem || !_consumePing)
{
continue;
}
_consumables.Add(item);
LG_GenericTerminalItem val = ((Component)item).gameObject.AddComponent<LG_GenericTerminalItem>();
if (!((Object)(object)val != (Object)null))
{
continue;
}
int num = Random.Range(101, 999);
string text = "";
String val2 = String.op_Implicit(((Item)item).ItemDataBlock.publicName.Replace(" ", "_").Replace("-", "").ToUpper());
if (!string.IsNullOrEmpty(((Item)item).ItemDataBlock.terminalItemShortName))
{
val2 = String.op_Implicit(((Item)item).ItemDataBlock.terminalItemShortName);
}
if (((Item)item).ItemDataBlock.publicName == "Long Range Flashlight")
{
val2 = String.op_Implicit("LRF");
}
text = String.op_Implicit(val2) + "_" + ((Item)item).pItemData.custom.ammo + "_" + num;
ManualLogSource l = L;
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("setting up consumable item ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ..");
}
l.LogInfo(val3);
AIG_CourseNode val4 = null;
Enumerator<Dimension> enumerator2 = Builder.CurrentFloor.m_dimensions.GetEnumerator();
while (enumerator2.MoveNext())
{
Dimension current2 = enumerator2.Current;
if (!current2.IsArenaDimension)
{
AIG_CourseNode.TryGetCourseNode(current2.DimensionIndex, ((Component)item).gameObject.transform.position, 1f, ref val5);
if (val5 != null)
{
val4 = val5;
}
}
}
if (val4 == null)
{
ManualLogSource l2 = L;
val3 = new BepInExInfoLogInterpolatedStringHandler(64, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("ERROR ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" location wasnt within a valid courseNode, not setting up!");
}
l2.LogInfo(val3);
return;
}
val.SpawnNode = val4;
iTerminalItem component = ((Component)val).GetComponent<iTerminalItem>();
component.FloorItemType = (eFloorInventoryObjectType)0;
component.FloorItemStatus = (eFloorInventoryObjectStatus)0;
component.ShowInFloorInventory = true;
component.LocatorBeaconPosition = ((Component)item).transform.position;
((ItemInLevel)item).CourseNode = val4;
component.SpawnNode = val4;
component.OverrideCode = "URPO";
val.m_detailedInfo.Add("Location: " + component.FloorItemLocation);
val.m_detailedInfo.Add($"Capacity: {((Item)item).pItemData.custom.ammo} uses");
val.FloorItemLocation = ((ItemInLevel)item).m_courseNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7);
component.FloorItemLocation = ((ItemInLevel)item).m_courseNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7);
component.Setup(text, ((ItemInLevel)item).CourseNode);
ManualLogSource l3 = L;
val3 = new BepInExInfoLogInterpolatedStringHandler(25, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" in zone ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(val4.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7));
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" has been added.");
}
l3.LogInfo(val3);
packlist = Object.FindObjectsOfType<ResourcePackPickup>();
}
mover = CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(MovePickups()), (Action)null);
remover = CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(RemoveConsumablesFromTerminal()), (Action)null);
}
[IteratorStateMachine(typeof(<RemoveConsumablesFromTerminal>d__4))]
public static IEnumerator RemoveConsumablesFromTerminal()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RemoveConsumablesFromTerminal>d__4(0);
}
[IteratorStateMachine(typeof(<MovePickups>d__5))]
public static IEnumerator MovePickups()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MovePickups>d__5(0);
}
}
[HarmonyPatch]
private class PingConsumables_patches
{
[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "Query")]
[HarmonyPrefix]
private static bool Prefix(LG_ComputerTerminalCommandInterpreter __instance, string param1, string param2)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
iTerminalItem val = default(iTerminalItem);
if (LG_LevelInteractionManager.TryGetTerminalInterface(param1.ToUpper(), __instance.m_terminal.SpawnNode.m_dimension.DimensionIndex, ref val) && val.OverrideCode == "URPO")
{
__instance.AddOutput((TerminalLineType)2, "Querying " + param1.ToUpper(), 3f, (TerminalSoundType)0, (TerminalSoundType)0);
string pingStatus = __instance.GetPingStatus(val);
foreach (string item in new List<string>
{
"----------------------------------------------------------------",
"CONSUMABLE ITEM",
"----------------------------------------------------------------",
"",
"ID: " + val.TerminalItemKey,
"LOCATION: " + val.FloorItemLocation,
"PING STATUS: " + pingStatus,
""
})
{
__instance.AddOutput(item, false);
}
return false;
}
return true;
}
}
internal static ManualLogSource L;
public static List<ConsumablePickup_Core> _consumables = new List<ConsumablePickup_Core>();
public static Il2CppArrayBase<ResourcePackPickup> packlist;
public static bool _consumePing = true;
public override void Load()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_005e: Expected O, but got Unknown
L = ((BasePlugin)this).Log;
_consumables.Clear();
new Harmony("pingconsumables").PatchAll();
_consumePing = new ConfigFile(Path.Combine(Paths.ConfigPath, "PingConsumables.cfg"), true).Bind<bool>(new ConfigDefinition("General", "Consumables_On_Terminal"), true, new ConfigDescription("consumables on terminals? if false, just the resource position fix active.", (AcceptableValueBase)null, Array.Empty<object>())).Value;
LG_Factory.OnFactoryBuildDone += Action.op_Implicit((Action)PingConsumables.Initialize);
LevelAPI.OnLevelCleanup += PingConsumables.OnLevelCleanup;
}
}
[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
[CompilerGenerated]
internal static class VersionInfo
{
public const string RootNamespace = "PingConsumables";
public const string Version = "1.0.0";
public const string VersionPrerelease = null;
public const string VersionMetadata = null;
public const string SemVer = "1.0.0";
public const string GitRevShort = null;
public const string GitRevLong = null;
public const string GitBranch = null;
public const string GitTag = null;
public const bool GitIsDirty = false;
}
}