using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
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: AssemblyCompany("NGA")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Persistent player progression! Raid, stash loot, and deploy with seemless scene/loadout saving.")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("NGA.OutdoorPanelPlus")]
[assembly: AssemblyTitle("BepInEx Plugin Title")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace NGA
{
[BepInPlugin("NGA.OutdoorPanelPlus", "OutdoorPanelPlus", "2.0.0")]
[BepInDependency("nrgill28.Sodalite", "1.4.1")]
[BepInProcess("h3vr.exe")]
public class OutdoorPanelPlus : BaseUnityPlugin
{
[HarmonyPatch(typeof(SosigOutdoorAssaultPanel))]
[HarmonyPatch("Start")]
private class SosigOutdoorPatchPlus
{
private static void Prefix(SosigOutdoorAssaultPanel __instance)
{
LogMessage("[OutdoorPanelPlus] Postfix.");
IM instance = ManagerSingleton<IM>.Instance;
if ((Object)(object)instance == (Object)null || instance.olistSosigCats == null)
{
LogError("[OutdoorPanelPlus] IM manager or olistSosigCats is null in SosigOutdoorAssaultPanel.Start postfix - not overwriting EnemyCategories");
return;
}
__instance.EnemyCategories = new List<SosigEnemyCategory>(instance.olistSosigCats);
List<Text> sosigTypeButtons = __instance.SosigTypeButtons;
if (sosigTypeButtons == null || sosigTypeButtons.Count == 0)
{
LogError("[OutdoorPanelPlus] SosigTypeButtons list is null or empty - cannot extend UI.");
return;
}
int count = __instance.EnemyCategories.Count;
int count2 = sosigTypeButtons.Count;
if (count2 < count)
{
AddUptoNeededButtons(__instance, count);
}
}
}
[HarmonyPatch(typeof(SosigOutdoorAssaultPanel))]
[HarmonyPatch("RedrawTypeIDList")]
private class SosigOutdoorPatchPlusRedraw
{
private static void Prefix(SosigOutdoorAssaultPanel __instance)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
List<SosigEnemyID> list = ManagerSingleton<IM>.Instance.odicSosigIDsByCategory[__instance.m_displayedCategory];
List<Text> sosigTypeButtons = __instance.SosigTypeButtons;
int count = list.Count;
int count2 = sosigTypeButtons.Count;
if (count2 < count)
{
AddUptoNeededButtons(__instance, count);
}
}
}
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("NGA.OutdoorPanelPlus");
SetUpConfigFields();
val.PatchAll();
Logger.LogMessage((object)"Hello, world! Sent from NGA.OutdoorPanelPlus 2.0.0");
}
private void SetUpConfigFields()
{
}
private static void AddUptoNeededButtons(SosigOutdoorAssaultPanel __instance, int needAmount)
{
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Expected O, but got Unknown
List<Text> sosigTypeButtons = __instance.SosigTypeButtons;
if (sosigTypeButtons == null || sosigTypeButtons.Count == 0)
{
LogError("[OutdoorPanelPlus] SosigTypeButtons list is null or empty - cannot extend UI.");
return;
}
int count = sosigTypeButtons.Count;
if (count >= needAmount)
{
return;
}
Text val = sosigTypeButtons[count - 1];
RectTransform component = ((Component)val).GetComponent<RectTransform>();
if ((Object)(object)component == (Object)null)
{
LogError("[OutdoorPanelPlus] Last SosigTypeButton button has no RectTransform.");
return;
}
Button component2 = ((Component)val).GetComponent<Button>();
RectTransform val2 = (Object.op_Implicit((Object)(object)component2) ? ((Component)component2).GetComponent<RectTransform>() : component);
Transform parent = ((Transform)val2).parent;
if ((Object)(object)parent == (Object)null)
{
LogError("[OutdoorPanelPlus] Buttons parent is null - cannot clone.");
return;
}
Vector2 val5 = default(Vector2);
if (count >= 2)
{
Button obj = ((Component)sosigTypeButtons[count - 2]).GetComponent<Button>() ?? ((Component)sosigTypeButtons[count - 2]).GetComponentInParent<Button>();
RectTransform val3 = ((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null) ?? ((Component)sosigTypeButtons[count - 2]).GetComponent<RectTransform>();
Vector2 val4 = (Object.op_Implicit((Object)(object)val3) ? val3.anchoredPosition : (val2.anchoredPosition + new Vector2(0f, -30f)));
val5 = val2.anchoredPosition - val4;
if (val5 == Vector2.zero)
{
((Vector2)(ref val5))..ctor(0f, -30f);
}
}
else
{
((Vector2)(ref val5))..ctor(0f, -30f);
}
float num = -18.2964f;
float z = ((Transform)val2).localPosition.z;
int num2 = count - 1;
int num3 = 23;
int num4 = num3 - num2;
int num5 = needAmount - count;
for (int i = 0; i < num5; i++)
{
int num6 = count + i;
GameObject val6 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent);
((Object)val6).name = $"BTN_0 ({num6})";
Text val7 = val6.GetComponent<Text>() ?? val6.GetComponentInChildren<Text>(true);
if ((Object)(object)val7 == (Object)null)
{
LogError($"[OutdoorPanelPlus] Clone BTN_0 ({num6}) has no Text component.");
continue;
}
RectTransform component3 = val6.GetComponent<RectTransform>();
component3.anchoredPosition = val2.anchoredPosition + val5 * (float)(i + 1);
float z2;
if (num4 > 0 && num6 <= num3)
{
float num7 = (float)(num6 - num2) / (float)num4;
z2 = Mathf.Lerp(z, num, num7);
}
else
{
z2 = num;
}
Vector3 localPosition = ((Transform)component3).localPosition;
localPosition.z = z2;
((Transform)component3).localPosition = localPosition;
Button component4 = val6.GetComponent<Button>();
if ((Object)(object)component4 != (Object)null)
{
component4.onClick = new ButtonClickedEvent();
configureButton(__instance, component4, num6);
}
else
{
LogError($"[OutdoorPanelPlus] Clone BTN_0 ({num6}) has no Button; click will not work.");
}
val6.SetActive(false);
val7.text = string.Empty;
val6.transform.SetAsLastSibling();
sosigTypeButtons.Add(val7);
}
LogMessage($"[OutdoorPanelPlus] Added {num5} new SosigTypeButtons (now {sosigTypeButtons.Count} total).");
}
private static void configureButton(SosigOutdoorAssaultPanel __instance, Button cloneBtn, int idx)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
((UnityEvent)cloneBtn.onClick).AddListener((UnityAction)delegate
{
__instance.SelectSosigTypeID(idx);
});
}
internal static void LogMessage(string message)
{
ManualLogSource logger = Logger;
if (logger != null)
{
logger.LogInfo((object)message);
}
}
internal static void LogError(string message)
{
ManualLogSource logger = Logger;
if (logger != null)
{
logger.LogError((object)message);
}
}
}
}