using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using IL.RoR2.UI;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.Hologram;
using RoR2.UI;
using RoR2BepInExPack.Utilities;
using UnityEngine;
using UnityEngine.Networking;
[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("ChestPickupDisplay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ChestPickupDisplay")]
[assembly: AssemblyTitle("ChestPickupDisplay")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 ChestPickupDisplay
{
[Serializable]
[BepInPlugin("com.brynzananas.chestpickupdisplay", "Chest Pickup Display", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ChestPickupDisplayPlugin : BaseUnityPlugin
{
public const string ModGuid = "com.brynzananas.chestpickupdisplay";
public const string ModName = "Chest Pickup Display";
public const string ModVer = "1.0.0";
private static FixedConditionalWeakTable<ChestBehavior, ChestPickupDisplayController> keyValuePairs = new FixedConditionalWeakTable<ChestBehavior, ChestPickupDisplayController>();
private static bool _hooksSet;
public void Awake()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
NetworkingAPI.RegisterMessageType<SyncPickupMessage>();
if (!_hooksSet)
{
_hooksSet = true;
ChestBehavior.Awake += new hook_Awake(ChestBehavior_Awake);
ChestBehavior.Roll += new hook_Roll(ChestBehavior_Roll);
PingIndicator.RebuildPing += new Manipulator(PingIndicator_RebuildPing);
}
}
public void OnDestroy()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
if (_hooksSet)
{
_hooksSet = false;
ChestBehavior.Awake -= new hook_Awake(ChestBehavior_Awake);
ChestBehavior.Roll -= new hook_Roll(ChestBehavior_Roll);
PingIndicator.RebuildPing -= new Manipulator(PingIndicator_RebuildPing);
}
}
private void PingIndicator_RebuildPing(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Expected O, but got Unknown
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
ILLabel iLLabel = null;
ILLabel iLLabel2 = null;
int num4 = default(int);
int num3 = default(int);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[6]
{
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num4),
(Instruction x) => ILPatternMatchingExt.MatchCall<Object>(x, "op_Implicit"),
(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref iLLabel2),
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num3),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<ShopTerminalBehavior>(x, "ignorePingFormatting"),
(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref iLLabel)
}))
{
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<PingIndicator>(x, "interactablePingGameObjects")
}))
{
Instruction next = val.Next;
val = new ILCursor(il);
int num2 = default(int);
int num = default(int);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[6]
{
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2),
(Instruction x) => ILPatternMatchingExt.MatchCall<Object>(x, "op_Implicit"),
(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref iLLabel2),
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<ShopTerminalBehavior>(x, "ignorePingFormatting"),
(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref iLLabel)
}))
{
val.GotoLabel(iLLabel, (MoveType)0, false);
Instruction next2 = val.Next;
iLLabel.Target = val.Emit(OpCodes.Ldarg_0).Prev;
iLLabel2.Target = iLLabel.Target;
val.Emit(OpCodes.Call, (MethodBase)AccessTools.PropertyGetter(typeof(PingIndicator), "pingTarget"));
val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.Method(typeof(GameObject), "GetComponent", (Type[])null, new Type[1] { typeof(ChestPickupDisplayController) }));
val.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(Object), "op_Implicit", (Type[])null, (Type[])null));
val.Emit(OpCodes.Brfalse_S, next2);
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldloc, 4);
val.EmitDelegate<Func<PingIndicator, string, string>>((Func<PingIndicator, string, string>)HandlePing);
val.Emit(OpCodes.Stloc, 4);
val.Emit(OpCodes.Br_S, next);
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 3 failed!"));
}
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 2 failed!"));
}
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 1 failed!"));
}
((BaseUnityPlugin)this).Logger.LogWarning((object)((object)il).ToString());
}
private string HandlePing(PingIndicator pingIndicator, string text)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
ChestPickupDisplayController component = pingIndicator.pingTarget.GetComponent<ChestPickupDisplayController>();
PickupIndex pickupIndex = component.uniquePickup.pickupIndex;
return PingIndicator.GetFormattedTargetString(text, pickupIndex, component.show && Object.op_Implicit((Object)(object)component.pickupDisplay));
}
private void ChestBehavior_Roll(orig_Roll orig, ChestBehavior self)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (Object.op_Implicit((Object)(object)self) && NetworkServer.active)
{
NetMessageExtensions.Send((INetMessage)(object)new SyncPickupMessage(((NetworkBehaviour)self).netIdentity, self.currentPickup), (NetworkDestination)1);
}
}
public static void HandleRoll(ChestBehavior self, UniquePickup uniquePickup)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
ChestPickupDisplayController chestPickupDisplayController = GetChestPickupDisplayController(self);
chestPickupDisplayController.uniquePickup = uniquePickup;
if (!((Object)(object)chestPickupDisplayController == (Object)null) && Object.op_Implicit((Object)(object)chestPickupDisplayController.pickupDisplay))
{
chestPickupDisplayController.pickupDisplay.SetPickup(ref chestPickupDisplayController.uniquePickup, false);
}
}
private void ChestBehavior_Awake(orig_Awake orig, ChestBehavior self)
{
orig.Invoke(self);
GetChestPickupDisplayController(self);
}
public static ChestPickupDisplayController GetChestPickupDisplayController(ChestBehavior chestBehavior)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: 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_009f: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: 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_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
ChestPickupDisplayController chestPickupDisplayController = default(ChestPickupDisplayController);
if (!keyValuePairs.TryGetValue(chestBehavior, ref chestPickupDisplayController))
{
chestPickupDisplayController = ((Component)chestBehavior).gameObject.AddComponent<ChestPickupDisplayController>();
chestPickupDisplayController.chestBehavior = chestBehavior;
GenericInspectInfoProvider component = ((Component)chestBehavior).GetComponent<GenericInspectInfoProvider>();
if (Object.op_Implicit((Object)(object)component))
{
chestPickupDisplayController.inspectDef = component.InspectInfo;
Object.DestroyImmediate((Object)(object)component);
}
chestPickupDisplayController.pickupTransform = new GameObject("PickupDisplay").transform;
chestPickupDisplayController.pickupTransform.SetParent(((Component)chestBehavior).transform, false);
HologramProjector component2 = ((Component)chestBehavior).gameObject.GetComponent<HologramProjector>();
Vector3 val = (Vector3)(Object.op_Implicit((Object)(object)component2) ? (component2.hologramPivot.localPosition * 1.5f * component2.hologramPivot.lossyScale.y) : new Vector3(0f, 3f, 0f));
Transform pickupTransform = chestPickupDisplayController.pickupTransform;
pickupTransform.localPosition += val;
chestPickupDisplayController.pickupDisplay = ((Component)chestPickupDisplayController.pickupTransform).gameObject.AddComponent<PickupDisplay>();
chestPickupDisplayController.pickupDisplay.coloredParticleSystems = (ParticleSystem[])(object)new ParticleSystem[0];
chestPickupDisplayController.pickupDisplay.highlight = ((Component)chestPickupDisplayController.pickupTransform).gameObject.AddComponent<Highlight>();
chestPickupDisplayController.pickupDisplay.highlight.highlightColor = (HighlightColor)2;
chestPickupDisplayController.pickupDisplay.verticalWave = new Wave
{
amplitude = 0.2f,
cycleOffset = 0f,
frequency = 0.25f
};
if (((Object)((Component)chestBehavior).gameObject).name.StartsWith("Chest1StealthedVariant"))
{
((Component)chestPickupDisplayController.pickupTransform).gameObject.SetActive(false);
chestPickupDisplayController.stealth = true;
}
keyValuePairs.Add(chestBehavior, chestPickupDisplayController);
}
return chestPickupDisplayController;
}
}
public class ChestPickupDisplayController : MonoBehaviour, IInspectInfoProvider
{
public ChestBehavior chestBehavior;
public PickupDisplay pickupDisplay;
public Transform pickupTransform;
public InspectDef inspectDef;
public UniquePickup uniquePickup;
public bool show;
public bool stealth;
public bool CanBeInspected()
{
return true;
}
public void FixedUpdate()
{
if (!Object.op_Implicit((Object)(object)chestBehavior) || show == !chestBehavior.NetworkisChestOpened)
{
return;
}
show = !chestBehavior.NetworkisChestOpened;
if (Object.op_Implicit((Object)(object)pickupTransform) && !stealth)
{
if (show)
{
((Component)pickupTransform).gameObject.SetActive(true);
}
else
{
((Component)pickupTransform).gameObject.SetActive(false);
}
}
}
public InspectInfo GetInfo()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (!show && Object.op_Implicit((Object)(object)inspectDef))
{
return InspectInfo.op_Implicit(inspectDef);
}
PickupDef pickupDef = PickupCatalog.GetPickupDef(uniquePickup.pickupIndex);
if (pickupDef == null)
{
throw new InvalidOperationException("67");
}
return InspectInfo.op_Implicit(pickupDef);
}
}
public class SyncPickupMessage : INetMessage, ISerializableObject
{
public NetworkIdentity networkIdentity;
public UniquePickup uniquePickup;
public SyncPickupMessage()
{
}
public SyncPickupMessage(NetworkIdentity networkIdentity, UniquePickup uniquePickup)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
this.networkIdentity = networkIdentity;
this.uniquePickup = uniquePickup;
}
public void Deserialize(NetworkReader reader)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
networkIdentity = reader.ReadNetworkIdentity();
uniquePickup = NetworkExtensions.ReadUniquePickup(reader);
}
public void OnReceived()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)networkIdentity))
{
ChestBehavior component = ((Component)networkIdentity).GetComponent<ChestBehavior>();
if (Object.op_Implicit((Object)(object)component))
{
ChestPickupDisplayPlugin.HandleRoll(component, uniquePickup);
}
}
}
public void Serialize(NetworkWriter writer)
{
writer.Write(networkIdentity);
NetworkExtensions.Write(writer, ref uniquePickup);
}
}
}