using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Agents;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem.Collections.Generic;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PacksHelper")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PacksHelper")]
[assembly: AssemblyTitle("PacksHelper")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PacksHelper
{
[BepInPlugin("Localia.PacksHelper", "PacksHelper", "3.1.4")]
public class EntryPoint : BasePlugin
{
private Harmony m_Harmony;
public override void Load()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
m_Harmony = new Harmony("Localia.PacksHelper");
m_Harmony.PatchAll();
Logs.Info("OK");
}
}
internal static class Logs
{
private static readonly ManualLogSource _logger;
static Logs()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
_logger = new ManualLogSource("Localia.PacksHelper");
Logger.Sources.Add((ILogSource)(object)_logger);
}
private static string Format(object msg)
{
return msg.ToString();
}
public static void Info(object data)
{
_logger.LogMessage((object)Format(data));
}
public static void Verbose(object data)
{
_logger.LogDebug((object)Format(data));
}
public static void Debug(object data)
{
_logger.LogDebug((object)Format(data));
}
public static void Error(object data)
{
_logger.LogError((object)Format(data));
}
}
internal static class PH_Manager
{
public static bool canCheckTar = false;
public static bool canCheckInter = false;
public static bool canCheckInputCondition = false;
public static float forceUpateHUDTIme = 0f;
public static int pack_type = 0;
public static int last_pack_type = 0;
public static string[] health = new string[4];
public static string[] standard = new string[4];
public static string[] special = new string[4];
public static string[] tool = new string[4];
public static string[] ori_all_info = new string[4];
public static string[] now_show_info = new string[4];
public static void checkPackType(string name)
{
if (name == "AmmoPackWeaponFirstPerson(Clone)")
{
pack_type = 1;
}
else if (name == "MediPackFirstPerson(Clone)" || name == "DisinfectonPackFirstPerson(Clone)")
{
pack_type = 2;
}
else if (name == "AmmoPackToolFirstPerson(Clone)")
{
pack_type = 3;
}
else
{
pack_type = 0;
}
if (pack_type > 0)
{
showAll();
}
if (pack_type > 0 || (last_pack_type > 0 && pack_type != last_pack_type))
{
forceUpdateHUDAll();
}
last_pack_type = pack_type;
}
public static void showAll()
{
List<PlayerAgent> playerAgentsInLevel = PlayerManager.PlayerAgentsInLevel;
for (int i = 0; i < playerAgentsInLevel.Count; i++)
{
if ((Object)(object)playerAgentsInLevel[i] != (Object)null && !((Agent)playerAgentsInLevel[i]).IsLocallyOwned && pack_type > 0 && !playerAgentsInLevel[i].NavMarker.ExtraInfoVisible)
{
playerAgentsInLevel[i].NavMarker.SetExtraInfoVisible(true);
}
}
}
public static void forceUpdateHUDAll()
{
forceUpateHUDTIme = Clock.Time + 0.1f;
for (int i = 0; i < PlayerManager.PlayerAgentsInLevel.Count; i++)
{
PlayerAgent val = PlayerManager.PlayerAgentsInLevel[i];
if ((Object)(object)val != (Object)null && !((Agent)val).IsLocallyOwned)
{
val.NavMarker.m_isInfoDirty = true;
val.NavMarker.UpdateExtraInfo();
}
}
}
public static string get_ext_changed(PlaceNavMarkerOnGO marker, int slot)
{
if (pack_type == 1)
{
now_show_info[slot] = "<color=#CCCCCCFF><size=140%>" + standard[slot] + "\n" + special[slot] + "</size></color>";
}
else if (pack_type == 2)
{
now_show_info[slot] = "<color=#CCCCCCFF><size=140%>" + health[slot] + "</size></color>";
}
else if (pack_type == 3)
{
now_show_info[slot] = "<color=#CCCCCCFF><size=140%>" + tool[slot] + "</size></color>";
}
else
{
now_show_info[slot] = ori_all_info[slot];
}
return now_show_info[slot];
}
public static void update_ori_hud_info(PlaceNavMarkerOnGO marker, int slot)
{
string extraInfo = marker.m_extraInfo;
ori_all_info[slot] = extraInfo;
now_show_info[slot] = "";
health[slot] = "";
standard[slot] = "";
special[slot] = "";
tool[slot] = "";
string[] array = extraInfo.Split("\n");
int num = 0;
if (array.Length > 3)
{
health[slot] = array[num];
num++;
if (array[num].IndexOf("<color=#00FFA8>", 0) != -1)
{
health[slot] = health[slot] + "\n" + array[num];
num++;
}
health[slot] = health[slot].Replace("<color=#CCCCCC66><size=70%>", "").Replace("66>", "FF>").Replace("A8>", "FF>");
standard[slot] = array[num].Replace("66>", "FF>");
num++;
special[slot] = array[num].Replace("66>", "FF>");
num++;
tool[slot] = array[num].Replace("66>", "FF>").Replace("</size></color>", "");
num++;
}
}
}
[HarmonyPatch(typeof(ResourcePackFirstPerson))]
internal static class patch_ResourcePackFirstPersonUpdate
{
[HarmonyPatch("UpdateInteraction")]
[HarmonyPrefix]
[HarmonyPriority(100)]
[HarmonyWrapSafe]
public static void UpdateInteraction_pre(ResourcePackFirstPerson __instance)
{
if (!((Interact_Timed)__instance.m_interactApplyResource).TimerIsActive)
{
__instance.m_lastActionReceiver = null;
PH_Manager.canCheckTar = true;
PH_Manager.canCheckInter = false;
PH_Manager.canCheckInputCondition = false;
}
}
[HarmonyPatch("UpdateInteraction")]
[HarmonyPostfix]
[HarmonyWrapSafe]
public static void UpdateInteraction_post(ResourcePackFirstPerson __instance)
{
PH_Manager.canCheckTar = false;
PH_Manager.canCheckInter = false;
PH_Manager.canCheckInputCondition = false;
if (Clock.Time > PH_Manager.forceUpateHUDTIme)
{
PH_Manager.forceUpdateHUDAll();
}
}
[HarmonyPatch("UpdateInteractionActionName")]
[HarmonyPrefix]
[HarmonyWrapSafe]
public static bool UpdateInteractionActionName(ResourcePackFirstPerson __instance)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
if (!PH_Manager.canCheckTar)
{
return true;
}
PH_Manager.canCheckTar = false;
PH_Manager.canCheckInputCondition = false;
bool flag = false;
if (InputMapper.GetButtonDown.Invoke((InputAction)6, ((Item)__instance).Owner.InputFilter))
{
__instance.m_actionReceiver = ((Component)((Item)__instance).Owner).GetComponentInChildren<iResourcePackReceiver>();
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(((Item)__instance).Owner.FPSCamera.Position, ((Item)__instance).Owner.FPSCamera.Forward, ref val, 2.4f, LayerManager.MASK_GIVE_RESOURCE_PACK))
{
iResourcePackReceiver componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<iResourcePackReceiver>();
if (componentInParent != null)
{
__instance.m_actionReceiver = componentInParent;
}
}
}
else if (InputMapper.GetButton.Invoke((InputAction)8, ((Item)__instance).Owner.InputFilter))
{
__instance.m_actionReceiver = ((Component)((Item)__instance).Owner).GetComponentInChildren<iResourcePackReceiver>();
flag = true;
}
else
{
__instance.m_actionReceiver = ((Component)((Item)__instance).Owner).GetComponentInChildren<iResourcePackReceiver>();
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(((Item)__instance).Owner.FPSCamera.Position, ((Item)__instance).Owner.FPSCamera.Forward, ref val2, 2.4f, LayerManager.MASK_GIVE_RESOURCE_PACK))
{
iResourcePackReceiver componentInParent2 = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<iResourcePackReceiver>();
if (componentInParent2 != null)
{
__instance.m_actionReceiver = componentInParent2;
}
}
}
__instance.m_interactApplyResource.m_input = (InputAction)6;
if (__instance.m_actionReceiver.IsLocallyOwned)
{
__instance.UpdateInteractionActionName(Text.Get(856u), true);
if (!InputMapper.GetButtonDown.Invoke((InputAction)6, ((Item)__instance).Owner.InputFilter))
{
__instance.m_interactApplyResource.m_input = (InputAction)8;
}
}
else
{
__instance.UpdateInteractionActionName(__instance.m_actionReceiver.InteractionName, true);
PlayerAgent val3 = ((Il2CppObjectBase)__instance.m_actionReceiver).TryCast<PlayerAgent>();
if ((Object)(object)val3 != (Object)null)
{
int num = val3.Owner.PlayerSlotIndex();
Interact_ManualTimedWithCallback interactApplyResource = __instance.m_interactApplyResource;
((Interact_Timed)interactApplyResource).InteractionMessage = ((Interact_Timed)interactApplyResource).InteractionMessage + "\n" + PH_Manager.now_show_info[num];
}
if (!InputMapper.GetButtonDown.Invoke((InputAction)6, ((Item)__instance).Owner.InputFilter))
{
__instance.m_interactApplyResource.m_input = (InputAction)7;
}
}
PH_Manager.canCheckInter = true;
if (flag)
{
PH_Manager.canCheckInputCondition = true;
}
return false;
}
}
[HarmonyPatch(typeof(Interact_ManualTimedWithCallback))]
internal static class patch_Interact_ManualTimedWithCallback
{
[HarmonyPatch("ManualUpdateWithCondition")]
[HarmonyPrefix]
[HarmonyWrapSafe]
public static void ManualUpdateWithCondition_Pre(Interact_ManualTimedWithCallback __instance, bool __0, PlayerAgent __1, ref bool __2)
{
if (PH_Manager.canCheckInputCondition)
{
PH_Manager.canCheckInputCondition = false;
__2 = true;
}
}
}
[HarmonyPatch(typeof(Interact_Timed))]
internal static class patch_Interact_Timed
{
[HarmonyPatch("PlayerCheckInput")]
[HarmonyPrefix]
[HarmonyWrapSafe]
public static bool PlayerCheckInput(Interact_Timed __instance, bool __result, PlayerAgent agent)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
if (!PH_Manager.canCheckInter)
{
return true;
}
PH_Manager.canCheckInter = false;
if (!__instance.InternalAllowInput)
{
return true;
}
if (__instance.m_localPlayerInteractInfo == null && InputMapper.GetButton.Invoke(((Interact_Base)__instance).InputAction, agent.InputFilter))
{
__instance.OnInteractorStateChanged(agent, true);
return false;
}
return true;
}
}
[HarmonyPatch(typeof(PlayerInventoryLocal), "SyncWieldItem")]
internal static class Patch_onChangeGear
{
public static void Postfix(PlayerInventoryLocal __instance, ItemEquippable item)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
if ((int)GameStateManager.Current.m_currentStateName == 10 && ((PlayerInventoryBase)__instance).AllowedToWieldItem && ((PlayerInventoryBase)__instance).m_playerEnabled)
{
PH_Manager.checkPackType(((Object)item).name);
}
}
}
[HarmonyPatch(typeof(PlaceNavMarkerOnGO))]
internal static class Patch_PlaceNavMarkerOnGO
{
[HarmonyPatch("UpdateExtraInfo")]
[HarmonyPostfix]
[HarmonyWrapSafe]
public static void UpdateExtraInfo(PlaceNavMarkerOnGO __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
if ((int)GameStateManager.Current.m_currentStateName == 10)
{
int num = __instance.m_player.Owner.PlayerSlotIndex();
if (__instance.m_extraInfo != PH_Manager.ori_all_info[num] && __instance.m_extraInfo != PH_Manager.now_show_info[num])
{
PH_Manager.update_ori_hud_info(__instance, num);
}
__instance.m_extraInfo = PH_Manager.get_ext_changed(__instance, num);
if (__instance.m_extraInfoVisible)
{
__instance.UpdateName(__instance.Player.Owner.NickName, PH_Manager.now_show_info[num]);
}
}
}
[HarmonyPatch("SetExtraInfoVisible")]
[HarmonyPrefix]
[HarmonyWrapSafe]
public static bool SetExtraInfoVisible(PlaceNavMarkerOnGO __instance, bool visible)
{
if (PH_Manager.pack_type > 0 && !visible)
{
return false;
}
return true;
}
}
}