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.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
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.7")]
public class Plugin : BasePlugin
{
public class PingConsumables : MonoBehaviour
{
private static Coroutine mover;
private static Coroutine remover;
private void OnLevelCleanup()
{
Debug.Log(Object.op_Implicit("pingconsumables - 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_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
_consumables.Clear();
AIG_CourseNode val4 = 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;
Debug.Log(Object.op_Implicit("PingConsumables - setting up consumable item " + text + " .."));
AIG_CourseNode val3 = 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 val4);
if (val4 != null)
{
val3 = val4;
}
}
}
if (val3 == null)
{
Debug.Log(Object.op_Implicit("PingConsumables - ERROR " + text + " location wasnt within a valid courseNode, not setting up!"));
return;
}
val.SpawnNode = val3;
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 = val3;
component.SpawnNode = val3;
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);
Debug.Log(Object.op_Implicit($"PingConsumables - {text} in zone {val3.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7)} has been added."));
packlist = Object.FindObjectsOfType<ResourcePackPickup>();
}
mover = CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(MovePickups()), (Action)null);
remover = CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(RemoveConsumablesFromTerminal()), (Action)null);
}
public static IEnumerator RemoveConsumablesFromTerminal()
{
List<ConsumablePickup_Core> poista = new List<ConsumablePickup_Core>();
while (true)
{
foreach (ConsumablePickup_Core item in poista)
{
_consumables.Remove(item);
}
poista.Clear();
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.Add(consumable);
Debug.Log(Object.op_Implicit("PingConsumables - item " + component.TerminalItemKey + " removed from terminals as it was picked up."));
}
}
yield return (object)new WaitForSeconds(2f);
}
}
public static IEnumerator MovePickups()
{
while (true)
{
foreach (ResourcePackPickup item in packlist)
{
if (!((Object)(object)item != (Object)null))
{
continue;
}
iTerminalItem component = ((Component)item).GetComponent<iTerminalItem>();
if (component == null)
{
continue;
}
LG_ResourceContainer_Storage container = ((ItemInLevel)item).container;
if ((Object)(object)container != (Object)null)
{
AIG_CourseNode componentInParent = ((Component)container).GetComponentInParent<AIG_CourseNode>();
if (componentInParent != null && component.SpawnNode != componentInParent)
{
component.SpawnNode = componentInParent;
component.FloorItemLocation = componentInParent.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7);
component.LocatorBeaconPosition = ((Component)item).transform.position;
}
}
}
yield return (object)new WaitForSeconds(10f);
}
}
}
[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;
}
}
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_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_0053: Expected O, but got Unknown
_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);
}
}
[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;
}
}