Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of InfinityStones v0.2.0
plugins/InfinityStones.dll
Decompiled 30 minutes agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("InfinityStones")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0")] [assembly: AssemblyProduct("InfinityStones")] [assembly: AssemblyTitle("InfinityStones")] [assembly: AssemblyVersion("0.2.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } [CompilerGenerated] [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 InfinityStones { internal static class Content { internal const string GauntletId = "Item Infinity Gauntlet"; internal static Item ShopItem { get; private set; } internal static void Register() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)ShopItem)) { return; } GameObject val = Resources.Load<GameObject>("Items/Item Health Pack Medium"); GameObject stoneSource = Resources.Load<GameObject>("Valuables/01 Tiny/Valuable Wizard Small Gem"); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)stoneSource)) { throw new InvalidOperationException($"Infinity Stones templates are unavailable (shop item: {val}, valuable: {stoneSource})."); } GameObject templates = new GameObject("Infinity Stones prefab templates"); templates.SetActive(false); Object.DontDestroyOnLoad((Object)(object)templates); try { Models models = new Models(val); ItemAttributes val2 = CreateGauntlet(val, templates.transform, models); ValuableObject[] array = StoneDefinition.All.Select((StoneDefinition stone) => CreateStone(stoneSource, templates.transform, models, stone)).ToArray(); if (Items.RegisterItem(val2) == null) { throw new InvalidOperationException("REPOLib rejected the Infinity Gauntlet."); } ValuableObject[] array2 = array; foreach (ValuableObject val3 in array2) { if (Valuables.RegisterValuable(val3, new List<string> { "Valuables - Generic" }) == null) { InfinityStonesPlugin.Log.LogError((object)("REPOLib rejected " + ((Object)val3).name + ".")); } } ShopItem = val2.item; InfinityStonesPlugin.Log.LogInfo((object)"Registered the Infinity Gauntlet and six Infinity Stones."); } catch { Object.Destroy((Object)(object)templates); throw; } } private static ItemAttributes CreateGauntlet(GameObject source, Transform parent, Models models) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate<GameObject>(source, parent, false); ((Object)obj).name = "Item Infinity Gauntlet"; obj.SetActive(true); Object.DestroyImmediate((Object)(object)obj.GetComponent<ItemHealthPack>()); Object.DestroyImmediate((Object)(object)obj.GetComponent<ItemToggle>()); ConfigureGauntletBody(obj); Transform root = CreateVisualRoot(obj); MeshRenderer[] gemSlots = models.Gauntlet(root); obj.AddComponent<Gauntlet>().Configure(gemSlots, models.Crystals); ItemAttributes component = obj.GetComponent<ItemAttributes>(); Item val = Object.Instantiate<Item>(component.item); ((Object)val).name = "Item Infinity Gauntlet"; val.itemName = "Infinity Gauntlet"; val.itemNameLocalized = null; val.description = "Hold a stone next to the gauntlet. Insert it, select a stone and use Interact to cast."; val.itemType = (itemType)13; val.itemVolume = (itemVolume)0; val.itemSecretShopType = (itemSecretShopType)0; val.status = (Status)1; val.disabled = false; val.maxAmount = 1; val.maxAmountInShop = 1; val.maxPurchase = false; val.minPlayerCount = 1; val.physicalItem = true; val.value = ScriptableObject.CreateInstance<Value>(); val.value.valueMin = 25000f; val.value.valueMax = 25000f; component.item = val; component.icon = null; return component; } private static void ConfigureGauntletBody(GameObject template) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) NotValuableObject component = template.GetComponent<NotValuableObject>(); component.physAttributePreset = ScriptableObject.CreateInstance<PhysAttribute>(); component.physAttributePreset.mass = 3.2f; template.GetComponent<Rigidbody>().mass = component.physAttributePreset.mass; component.durabilityPreset = ScriptableObject.CreateInstance<Durability>(); component.durabilityPreset.fragility = 22f; component.durabilityPreset.durability = 100f; component.healthDestroy = false; BoxCollider[] componentsInChildren = template.GetComponentsInChildren<BoxCollider>(true); foreach (BoxCollider val in componentsInChildren) { if (!((Collider)val).isTrigger && Object.op_Implicit((Object)(object)((Component)val).GetComponent<PhysGrabObjectBoxCollider>())) { val.size = Vector3.Scale(val.size, new Vector3(1.08f, 1.28f, 1.85f)); } } } private static ValuableObject CreateStone(GameObject source, Transform parent, Models models, StoneDefinition stone) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(source, parent, false); ((Object)val).name = "Valuable " + stone.Name; val.SetActive(true); models.LooseStone(CreateVisualRoot(val), stone); val.AddComponent<InfinityStone>().Configure(stone.Kind); ValuableObject component = val.GetComponent<ValuableObject>(); component.status = (Status)1; component.valuePreset = ScriptableObject.CreateInstance<Value>(); component.valuePreset.valueMin = stone.Value; component.valuePreset.valueMax = stone.Value; component.particleColors = new Gradient(); component.particleColors.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(stone.Color, 0f), new GradientColorKey(stone.Color * 0.4f, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 1f) }); return component; } private static Transform CreateVisualRoot(GameObject template) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = template.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if ((val is MeshRenderer || val is SkinnedMeshRenderer) ? true : false) { val.enabled = false; } } Bounds val2 = default(Bounds); bool flag = false; BoxCollider[] componentsInChildren2 = template.GetComponentsInChildren<BoxCollider>(true); Vector3 val6 = default(Vector3); foreach (BoxCollider val3 in componentsInChildren2) { if (!((Collider)val3).enabled || ((Collider)val3).isTrigger) { continue; } Matrix4x4 val4 = template.transform.worldToLocalMatrix * ((Component)val3).transform.localToWorldMatrix; Vector3 val5 = val3.size * 0.5f; for (int j = 0; j < 8; j++) { ((Vector3)(ref val6))..ctor(((j & 1) == 0) ? val5.x : (0f - val5.x), ((j & 2) == 0) ? val5.y : (0f - val5.y), ((j & 4) == 0) ? val5.z : (0f - val5.z)); Vector3 val7 = ((Matrix4x4)(ref val4)).MultiplyPoint3x4(val3.center + val6); if (flag) { ((Bounds)(ref val2)).Encapsulate(val7); } else { ((Bounds)(ref val2))..ctor(val7, Vector3.zero); } flag = true; } } Transform transform = new GameObject("Infinity Stones model").transform; transform.SetParent(template.transform, false); ((Component)transform).gameObject.layer = template.layer; transform.localPosition = ((Bounds)(ref val2)).center; transform.localScale = (flag ? Vector3.Max(((Bounds)(ref val2)).size, Vector3.one * 0.07f) : (Vector3.one * 0.26f)); return transform; } } internal sealed class InfinityStone : MonoBehaviour { [SerializeField] private StoneKind kind; internal StoneDefinition Definition => StoneDefinition.All[(int)kind]; internal void Configure(StoneKind stone) { kind = stone; } } internal sealed class Gauntlet : MonoBehaviour { private const float SocketRange = 1.35f; private const int StoneMask = 63; private static readonly FieldRef<RoomVolumeCheck, bool> InExtraction = AccessTools.FieldRefAccess<RoomVolumeCheck, bool>("inExtractionPoint"); [SerializeField] private MeshRenderer[] sockets; [SerializeField] private Material[] installedMaterials; private ItemAttributes attributes; private PhysGrabObject physicsObject; private PhotonView view; private Material emptyMaterial; private int installed; private int displayedMask; private int selection = -1; private double nextCast; private string InstanceName => InfinityStonesPlugin.ItemInstanceName.Invoke(attributes); internal void Configure(MeshRenderer[] gemSlots, Material[] materials) { sockets = gemSlots; installedMaterials = materials; } private void Awake() { attributes = ((Component)this).GetComponent<ItemAttributes>(); physicsObject = ((Component)this).GetComponent<PhysGrabObject>(); view = ((Component)this).GetComponent<PhotonView>(); emptyMaterial = ((Renderer)sockets[0]).sharedMaterial; } private void LateUpdate() { int num = installed; if (displayedMask != num) { for (int i = 0; i < sockets.Length; i++) { ((Renderer)sockets[i]).sharedMaterial = (((num & (1 << i)) != 0) ? installedMaterials[i] : emptyMaterial); } displayedMask = num; } } private int SelectedStone() { int mask = installed; if (selection >= 0 && (mask & (1 << selection)) != 0) { return selection; } selection = Array.FindIndex(StoneDefinition.All, (StoneDefinition stone) => (mask & stone.Bit) != 0); return selection; } internal string GetPrompt() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) int num = SelectedStone(); string text = $"[{InfinityStonesPlugin.InsertKey.Value}] Insert"; if (num < 0) { return "Infinity Gauntlet | " + text; } string text2 = SemiFunc.InputDisplayReplaceTags("[interact]", "<u><b>", "</b></u>"); StoneDefinition stoneDefinition = StoneDefinition.All[num]; return "<color=#" + ColorUtility.ToHtmlStringRGB(stoneDefinition.Color) + ">" + stoneDefinition.Name + "</color> | [" + text2 + "] Cast " + $"[{InfinityStonesPlugin.CycleKey.Value}] Cycle {text}"; } internal void Cycle() { int num = SelectedStone(); if (num < 0) { return; } int num2 = installed; for (int i = 1; i <= StoneDefinition.All.Length; i++) { int num3 = (num + i) % StoneDefinition.All.Length; if ((num2 & (1 << num3)) != 0) { selection = num3; break; } } } internal void RequestInsert(InfinityStone? stone) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) PhotonView val = default(PhotonView); if (!Object.op_Implicit((Object)(object)stone)) { Notify("Bring an Infinity Stone next to the gauntlet.", Color.white); } else if (SemiFunc.IsMasterClientOrSingleplayer()) { TryInsert(SemiFunc.PlayerAvatarLocal(), stone, null); } else if (view.ViewID != 0 && ((Component)stone).TryGetComponent<PhotonView>(ref val) && val.ViewID != 0) { view.RPC("InsertStoneRPC", (RpcTarget)2, new object[1] { val.ViewID }); } } internal void RequestCast() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) int num = SelectedStone(); if (num < 0) { Notify("Insert an Infinity Stone first.", Color.white); } else if (SemiFunc.IsMasterClientOrSingleplayer()) { TryCast(SemiFunc.PlayerAvatarLocal(), num, null); } else if (view.ViewID != 0) { view.RPC("CastStoneRPC", (RpcTarget)2, new object[1] { num }); } } [PunRPC] private void InsertStoneRPC(int stoneViewId, PhotonMessageInfo info) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (PhotonNetwork.IsMasterClient && info.Sender != null) { PhotonView val = PhotonView.Find(stoneViewId); InfinityStone stone = default(InfinityStone); if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<InfinityStone>(ref stone)) { TryInsert(SemiFunc.PlayerAvatarGetFromPhotonPlayer(info.Sender), stone, info.Sender); } } } [PunRPC] private void CastStoneRPC(int index, PhotonMessageInfo info) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (PhotonNetwork.IsMasterClient && info.Sender != null) { TryCast(SemiFunc.PlayerAvatarGetFromPhotonPlayer(info.Sender), index, info.Sender); } } [PunRPC] private void SyncSocketsRPC(int mask, PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { installed = mask & 0x3F; } } private bool CanAct(PlayerAvatar player) { if (InfinityStonesPlugin.GameplayActive() && Object.op_Implicit((Object)(object)player) && !InfinityStonesPlugin.IsDisabled.Invoke(player) && !physicsObject.dead && !string.IsNullOrEmpty(InstanceName)) { return StatsManager.instance.item.ContainsKey(InstanceName); } return false; } private static bool IsHeldBy(PhysGrabObject item, PlayerAvatar player) { if (!((Object)(object)InfinityStonesPlugin.HeldObject(player) == (Object)(object)item)) { return SemiFunc.PhysGrabObjectGetPhysGrabbersGrabbing(item).Contains(player.physGrabber); } return true; } private void TryInsert(PlayerAvatar player, InfinityStone stone, Player? recipient) { PhysGrabObject component = ((Component)stone).GetComponent<PhysGrabObject>(); ValuableObject component2 = ((Component)stone).GetComponent<ValuableObject>(); if (!CanAct(player) || !Object.op_Implicit((Object)(object)component) || component.dead || InfinityStonesPlugin.CommittedToExtraction.Invoke(component2) || !AreClose(((Component)this).transform, ((Component)stone).transform) || (!IsHeldBy(physicsObject, player) && !IsHeldBy(component, player))) { return; } RoomVolumeCheck component3 = ((Component)stone).GetComponent<RoomVolumeCheck>(); component3.CheckSet(); if (InExtraction.Invoke(component3)) { Reply(recipient, "Move the stone away from extraction first."); return; } StoneDefinition definition = stone.Definition; int num = installed; if ((num & definition.Bit) != 0) { Reply(recipient, definition.Name + " is already installed."); return; } installed = num | definition.Bit; if (SemiFunc.IsMultiplayer() && view.ViewID != 0) { view.RPC("SyncSocketsRPC", (RpcTarget)4, new object[1] { installed }); } component.dead = true; ValuableDirector.instance.valuableList.Remove(component2); component.DestroyPhysGrabObject(); Reply(recipient, definition.Name + " installed.", (int)definition.Kind); } private void TryCast(PlayerAvatar player, int index, Player? recipient) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if ((uint)index >= StoneDefinition.All.Length || !CanAct(player) || !IsHeldBy(physicsObject, player)) { return; } StoneDefinition stoneDefinition = StoneDefinition.All[index]; if ((installed & stoneDefinition.Bit) == 0) { return; } double timeAsDouble = Time.timeAsDouble; if (timeAsDouble < nextCast) { Reply(recipient, $"Gauntlet recharging ({Math.Ceiling(nextCast - timeAsDouble)} s)."); return; } Vector3 centerPoint = physicsObject.centerPoint; if (!StonePowers.Cast(stoneDefinition, centerPoint, player, (MonoBehaviour)(object)this)) { Reply(recipient, "No target in range."); return; } nextCast = timeAsDouble + (double)stoneDefinition.Cooldown; PlayCastPulse(centerPoint, index); if (SemiFunc.IsMultiplayer() && view.ViewID != 0) { view.RPC("ShowCastPulseRPC", (RpcTarget)1, new object[2] { centerPoint, index }); } Reply(recipient, stoneDefinition.Name + " activated.", index); } [PunRPC] private void ShowCastPulseRPC(Vector3 center, int index, PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info) && (uint)index < StoneDefinition.All.Length) { PlayCastPulse(center, index); } } private void PlayCastPulse(Vector3 center, int index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) StonePulse.Spawn(center, StoneDefinition.All[index], installedMaterials[index]); if (Object.op_Implicit((Object)(object)AssetManager.instance) && AssetManager.instance.soundDeviceTurnOn != null) { AssetManager.instance.soundDeviceTurnOn.Play(center, 1f, 1f, 1f, 1f); } } private void Reply(Player? player, string message, int colorIndex = -1) { if (player != null) { view.RPC("ShowFeedbackRPC", player, new object[2] { message, colorIndex }); } else { ShowFeedback(message, colorIndex); } } [PunRPC] private void ShowFeedbackRPC(string message, int colorIndex, PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { ShowFeedback(message, colorIndex); } } private static void ShowFeedback(string message, int colorIndex) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Notify(message, ((uint)colorIndex < StoneDefinition.All.Length) ? StoneDefinition.All[colorIndex].Color : Color.white); } internal static void Notify(string message, Color color) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)MissionUI.instance)) { SemiFunc.UIFocusText(message, color, Color.white, 2.2f); } } internal static InfinityStone? FindNearbyStone(Gauntlet gauntlet) { return FindNearby<InfinityStone>(((Component)gauntlet).transform); } internal static Gauntlet? FindNearbyGauntlet(InfinityStone stone) { return FindNearby<Gauntlet>(((Component)stone).transform); } private static T? FindNearby<T>(Transform around) where T : Component { //IL_0023: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) T result = default(T); float num = 1.8225001f; T[] array = Object.FindObjectsByType<T>((FindObjectsSortMode)0); PhysGrabObject val3 = default(PhysGrabObject); foreach (T val in array) { Vector3 val2 = around.position - ((Component)val).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num && AreClose(around, ((Component)val).transform) && ((Component)val).TryGetComponent<PhysGrabObject>(ref val3) && !val3.dead) { result = val; num = sqrMagnitude; } } return result; } private static bool AreClose(Transform first, Transform second) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Vector3 val = first.position - second.position; if (((Vector3)(ref val)).sqrMagnitude <= 1.8225001f) { return InfinityStonesPlugin.CanSee(first.position, second.position); } return false; } } [BepInPlugin("petop.repo.infinitystones", "Infinity Stones", "0.2.0")] [BepInDependency("REPOLib", "4.5.0")] [HarmonyPatch] public sealed class InfinityStonesPlugin : BaseUnityPlugin { internal const string Id = "petop.repo.infinitystones"; private static readonly FieldRef<PhysGrabber, PhysGrabObject> GrabbedObject = AccessTools.FieldRefAccess<PhysGrabber, PhysGrabObject>("grabbedPhysGrabObject"); internal static readonly FieldRef<PlayerAvatar, bool> IsDisabled = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isDisabled"); internal static readonly FieldRef<ItemAttributes, string> ItemInstanceName = AccessTools.FieldRefAccess<ItemAttributes, string>("instanceName"); internal static readonly FieldRef<ValuableObject, bool> CommittedToExtraction = AccessTools.FieldRefAccess<ValuableObject, bool>("committedToExtraction"); private static readonly FieldRef<ItemAttributes, string> ItemPrompt = AccessTools.FieldRefAccess<ItemAttributes, string>("promptName"); private static readonly FieldRef<PlayerController, float> InputDisabled = AccessTools.FieldRefAccess<PlayerController, float>("InputDisableTimer"); internal static ManualLogSource Log { get; private set; } = null; internal static ConfigEntry<Key> InsertKey { get; private set; } = null; internal static ConfigEntry<Key> CycleKey { get; private set; } = null; private void Awake() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; InsertKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Controls", "InsertStone", (Key)32, "Insert the nearby Infinity Stone."); CycleKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Controls", "CycleStone", (Key)21, "Select the next stone in the gauntlet."); new Harmony("petop.repo.infinitystones").PatchAll(); } private void Update() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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) if (!GameplayActive() || !Object.op_Implicit((Object)(object)PlayerController.instance) || InputDisabled.Invoke(PlayerController.instance) > 0f || !SemiFunc.NoTextInputsActive()) { return; } PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); if (!Object.op_Implicit((Object)(object)val) || IsDisabled.Invoke(val)) { return; } PhysGrabObject val2 = HeldObject(val); if (!Object.op_Implicit((Object)(object)val2)) { return; } bool flag = IsPressed(InsertKey.Value); Gauntlet gauntlet = default(Gauntlet); InfinityStone stone = default(InfinityStone); if (((Component)val2).TryGetComponent<Gauntlet>(ref gauntlet)) { if (flag) { gauntlet.RequestInsert(Gauntlet.FindNearbyStone(gauntlet)); } else if (IsPressed(CycleKey.Value)) { gauntlet.Cycle(); } else if (SemiFunc.InputDown((InputKey)2)) { gauntlet.RequestCast(); } } else if (flag && ((Component)val2).TryGetComponent<InfinityStone>(ref stone)) { Gauntlet gauntlet2 = Gauntlet.FindNearbyGauntlet(stone); if (Object.op_Implicit((Object)(object)gauntlet2)) { gauntlet2.RequestInsert(stone); } else { Gauntlet.Notify("Bring the stone next to an Infinity Gauntlet.", Color.white); } } } [HarmonyPatch(typeof(ItemAttributes), "ShowingInfo")] [HarmonyPostfix] private static void ShowGauntletControls(ItemAttributes __instance) { if (!((Object)(object)__instance.item != (Object)(object)Content.ShopItem) && GameplayActive() && Object.op_Implicit((Object)(object)PlayerController.instance)) { PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); if (Object.op_Implicit((Object)(object)val) && (Object)(object)HeldObject(val) == (Object)(object)((Component)__instance).GetComponent<PhysGrabObject>()) { ItemPrompt.Invoke(__instance) = ((Component)__instance).GetComponent<Gauntlet>().GetPrompt(); } } } private static bool IsPressed(Key key) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //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) //IL_001c: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current != null && (int)key > 0 && (int)key <= current.allKeys.Count) { return ((ButtonControl)current[key]).wasPressedThisFrame; } return false; } [HarmonyPatch(typeof(RunManager), "Awake")] [HarmonyPostfix] [HarmonyBefore(new string[] { "REPOLib" })] private static void RegisterContent(RunManager __instance) { if ((Object)(object)RunManager.instance != (Object)(object)__instance) { return; } try { Content.Register(); } catch (Exception ex) { Log.LogError((object)ex); } } [HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")] [HarmonyPostfix] private static void PrioritizeGauntlet(ShopManager __instance) { Item shopItem = Content.ShopItem; if (Object.op_Implicit((Object)(object)shopItem) && SemiFunc.IsMasterClientOrSingleplayer() && StatsManager.instance.GetItemPurchased(shopItem) < shopItem.maxAmountInShop) { __instance.potentialItems.Remove(shopItem); __instance.potentialItems.Add(shopItem); } } internal static bool GameplayActive() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated && Object.op_Implicit((Object)(object)RunManager.instance) && (Object)(object)LevelGenerator.Instance.Level == (Object)(object)RunManager.instance.levelCurrent && Object.op_Implicit((Object)(object)GameDirector.instance) && (int)GameDirector.instance.currentState == 2) { return SemiFunc.RunIsLevel(); } return false; } internal static PhysGrabObject? HeldObject(PlayerAvatar player) { PhysGrabber physGrabber = player.physGrabber; if (!Object.op_Implicit((Object)(object)physGrabber) || !SemiFunc.PhysGrabberIsGrabbing(physGrabber)) { return null; } return GrabbedObject.Invoke(physGrabber); } internal static bool CanSee(Vector3 from, Vector3 to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !Physics.Linecast(from, to, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1); } } internal enum StoneKind { Power, Space, Reality, Soul, Time, Mind } internal sealed class StoneDefinition { internal static readonly StoneDefinition[] All = new StoneDefinition[6] { new StoneDefinition(StoneKind.Power, Color32.op_Implicit(new Color32((byte)188, (byte)65, byte.MaxValue, byte.MaxValue)), 2200, 16f, 9f, 6, 0.79f), new StoneDefinition(StoneKind.Space, Color32.op_Implicit(new Color32((byte)40, (byte)153, byte.MaxValue, byte.MaxValue)), 1800, 15f, 12f, 5, 0.97f), new StoneDefinition(StoneKind.Reality, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)58, (byte)68, byte.MaxValue)), 1900, 24f, 10f, 6, 0.71f), new StoneDefinition(StoneKind.Soul, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)141, (byte)37, byte.MaxValue)), 2400, 30f, 9f, 7, 0.77f), new StoneDefinition(StoneKind.Time, Color32.op_Implicit(new Color32((byte)63, (byte)232, (byte)100, byte.MaxValue)), 2300, 23f, 9f, 6, 0.9f), new StoneDefinition(StoneKind.Mind, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)226, (byte)57, byte.MaxValue)), 2000, 20f, 8f, 5, 0.81f) }; internal StoneKind Kind { get; } internal Color Color { get; } internal int Value { get; } internal float Cooldown { get; } internal float Radius { get; } internal int Sides { get; } internal float Width { get; } internal string Name => Kind.ToString() + " Stone"; internal int Bit => 1 << (int)Kind; internal StoneDefinition(StoneKind kind, Color color, int value, float cooldown, float radius, int sides, float width) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Kind = kind; Color = color; Value = value; Cooldown = cooldown; Radius = radius; Sides = sides; Width = width; } } internal sealed class Models { private readonly Material gold; private readonly Material brass; private readonly Material leather; private readonly Material empty; private readonly Mesh bevel; private readonly Mesh[] crystals; internal Material[] Crystals { get; } internal Models(GameObject source) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) Shader shader = Shader.Find("Standard") ?? ((Renderer)source.GetComponentsInChildren<MeshRenderer>(true).First((MeshRenderer renderer) => Object.op_Implicit((Object)(object)((Renderer)renderer).sharedMaterial))).sharedMaterial.shader; gold = Material(shader, Color32.op_Implicit(new Color32((byte)223, (byte)165, (byte)70, byte.MaxValue)), 0.66f); brass = Material(shader, Color32.op_Implicit(new Color32((byte)125, (byte)75, (byte)29, byte.MaxValue)), 0.7f); leather = Material(shader, Color32.op_Implicit(new Color32((byte)48, (byte)31, (byte)34, byte.MaxValue)), 0f); empty = Material(shader, Color32.op_Implicit(new Color32((byte)28, (byte)23, (byte)37, byte.MaxValue)), 0.15f); Crystals = StoneDefinition.All.Select((StoneDefinition s) => Material(shader, s.Color, 0.24f, glowing: true)).ToArray(); bevel = CutMesh(8, 1f, armor: true); crystals = StoneDefinition.All.Select((StoneDefinition s) => CutMesh(s.Sides, s.Width, armor: false)).ToArray(); } internal void LooseStone(Transform root, StoneDefinition stone) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) int kind = (int)stone.Kind; AddPart(root, stone.Name, crystals[kind], Crystals[kind], Vector3.zero, new Vector3(0.9f, 0.91f, 0.92f), Quaternion.Euler(0f, (float)(19 * kind), 0f)); } internal MeshRenderer[] Gauntlet(Transform root) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0326: 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_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: 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_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) AddArmor(root, "Leather glove", leather, new Vector3(0f, -0.1f, 0.02f), new Vector3(0.74f, 0.68f, 0.73f)); AddArmor(root, "Cuff", brass, new Vector3(0f, -0.035f, -0.34f), new Vector3(0.82f, 0.91f, 0.31f)); AddArmor(root, "Cuff rim", gold, new Vector3(0f, -0.035f, -0.44f), new Vector3(0.9f, 0.96f, 0.12f)); AddArmor(root, "Cuff collar", gold, new Vector3(0f, -0.025f, -0.23f), new Vector3(0.79f, 0.86f, 0.075f)); AddArmor(root, "Palm armor", gold, new Vector3(0f, 0.17f, -0.015f), new Vector3(0.79f, 0.6f, 0.54f)); AddArmor(root, "Palm ridge", brass, new Vector3(0f, 0.42f, -0.08f), new Vector3(0.53f, 0.16f, 0.32f)); AddArmor(root, "Thumb joint", brass, new Vector3(-0.38f, 0.027f, -0.085f), new Vector3(0.22f, 0.7f, 0.3f), -27f); AddArmor(root, "Thumb plate", gold, new Vector3(-0.425f, 0.13f, 0.035f), new Vector3(0.15f, 0.61f, 0.24f), -30f); for (int i = 0; i < 4; i++) { float num = -0.27f + (float)i * 0.18f; bool flag = ((i == 0 || i == 3) ? true : false); float num2 = (flag ? 0.39f : 0.44f); AddArmor(root, $"Finger {i + 1}", brass, new Vector3(num, -0.05f, 0.3f), new Vector3(0.173f, 0.7f, 0.27f)); AddArmor(root, $"Knuckle {i + 1}", gold, new Vector3(num, 0.25f, 0.27f), new Vector3(0.166f, 0.37f, 0.18f)); AddArmor(root, $"Finger cap {i + 1}", gold, new Vector3(num, -0.08f, num2), new Vector3(0.151f, 0.55f, 0.13f)); } Vector3[] array = (Vector3[])(object)new Vector3[6] { new Vector3(-0.43f, 0.45f, 0.015f), new Vector3(-0.27f, 0.45f, 0.27f), new Vector3(-0.09f, 0.45f, 0.27f), new Vector3(0.09f, 0.45f, 0.27f), new Vector3(0.27f, 0.45f, 0.27f), new Vector3(0f, 0.52f, -0.07f) }; MeshRenderer[] array2 = (MeshRenderer[])(object)new MeshRenderer[array.Length]; for (int j = 0; j < array2.Length; j++) { float num3 = ((j == 5) ? 0.21f : 0.144f); AddArmor(root, "Socket bezel", brass, array[j] - Vector3.up * 0.04f, new Vector3(num3 * 1.15f, 0.12f, num3 * 1.15f)); array2[j] = AddPart(root, StoneDefinition.All[j].Name, crystals[j], empty, array[j], new Vector3(num3, 0.17f, num3), Quaternion.identity); } return array2; } private void AddArmor(Transform root, string name, Material material, Vector3 position, Vector3 size, float yaw = 0f) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) AddPart(root, name, bevel, material, position, size, Quaternion.Euler(0f, yaw, 0f)); } private static MeshRenderer AddPart(Transform root, string name, Mesh mesh, Material material, Vector3 position, Vector3 size, Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name) { layer = ((Component)root).gameObject.layer }; val.transform.SetParent(root, false); val.transform.SetLocalPositionAndRotation(position, rotation); val.transform.localScale = size; val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = material; return obj; } private static Material Material(Shader shader, Color color, float metallic, bool glowing = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0065: 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) Material val = new Material(shader) { color = color }; if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.32f); } if (glowing && val.HasProperty("_EmissionColor")) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", color * 0.78f); } return val; } private static Mesh CutMesh(int sides, float width, bool armor) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0262: 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) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown List<Vector3> vertices = new List<Vector3>(); List<int> indices = new List<int>(); float[] heights = ((!armor) ? new float[4] { -0.5f, -0.22f, 0.24f, 0.5f } : new float[4] { -0.5f, -0.39f, 0.39f, 0.5f }); float[] radii = ((!armor) ? new float[4] { 0.24f, 0.88f, 1f, 0.52f } : new float[4] { 0.83f, 1f, 1f, 0.83f }); Vector2[] edges = (Vector2[])((!armor) ? ((Array)Enumerable.Range(0, sides).Select((Func<int, Vector2>)delegate(int num5) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) float num4 = (float)num5 * MathF.PI * 2f / (float)sides; return new Vector2(Mathf.Sin(num4) * width * 0.5f, Mathf.Cos(num4) * 0.5f); }).ToArray()) : ((Array)new Vector2[8] { new Vector2(0.35f, 0.5f), new Vector2(0.5f, 0.35f), new Vector2(0.5f, -0.35f), new Vector2(0.35f, -0.5f), new Vector2(-0.35f, -0.5f), new Vector2(-0.5f, -0.35f), new Vector2(-0.5f, 0.35f), new Vector2(-0.35f, 0.5f) })); for (int num = 0; num < sides; num++) { int i = (num + 1) % sides; for (int num2 = 0; num2 < heights.Length - 1; num2++) { Triangle(Point(num2, num), Point(num2, i), Point(num2 + 1, i)); Triangle(Point(num2, num), Point(num2 + 1, i), Point(num2 + 1, num)); } Triangle(Vector3.up * heights[0], Point(0, i), Point(0, num)); int num3 = heights.Length - 1; Triangle(Vector3.up * heights[num3], Point(num3, num), Point(num3, i)); } Mesh val = new Mesh { name = (armor ? "Beveled gauntlet segment" : "Faceted Infinity Stone") }; val.SetVertices(vertices); val.SetTriangles(indices, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; Vector3 Point(int ring, int num4) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) return new Vector3(edges[num4].x * radii[ring], heights[ring], edges[num4].y * radii[ring]); } void Triangle(Vector3 a, Vector3 b, Vector3 c) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) indices.Add(vertices.Count); indices.Add(vertices.Count + 1); indices.Add(vertices.Count + 2); vertices.Add(a); vertices.Add(b); vertices.Add(c); } } } internal static class StonePowers { private static readonly FieldRef<EnemyParent, Enemy> EnemyOf = AccessTools.FieldRefAccess<EnemyParent, Enemy>("Enemy"); private static readonly FieldRef<EnemyParent, bool> EnemySpawned = AccessTools.FieldRefAccess<EnemyParent, bool>("Spawned"); private static readonly FieldRef<EnemyHealth, bool> EnemyDead = AccessTools.FieldRefAccess<EnemyHealth, bool>("dead"); private static readonly FieldRef<PlayerHealth, int> Health = AccessTools.FieldRefAccess<PlayerHealth, int>("health"); private static readonly FieldRef<PlayerHealth, int> MaxHealth = AccessTools.FieldRefAccess<PlayerHealth, int>("maxHealth"); internal static bool Cast(StoneDefinition stone, Vector3 center, PlayerAvatar caster, MonoBehaviour source) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) return stone.Kind switch { StoneKind.Power => Damage(center, stone.Radius), StoneKind.Space => PullLoot(center, stone.Radius, source), StoneKind.Reality => ProtectLoot(center, stone.Radius), StoneKind.Soul => Heal(center, stone.Radius, caster), StoneKind.Time => Stun(center, stone.Radius), StoneKind.Mind => Conceal(center, stone.Radius, caster), _ => false, }; } private static bool Damage(Vector3 center, float range) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) bool result = false; EnemyHealth val = default(EnemyHealth); foreach (Enemy item in NearbyEnemies(center, range)) { if (((Component)item).TryGetComponent<EnemyHealth>(ref val)) { Vector3 val2 = item.CenterTransform.position - center; Vector3 normalized = ((Vector3)(ref val2)).normalized; val.Hurt(140, normalized); result = true; } } return result; } private static bool PullLoot(Vector3 center, float range, MonoBehaviour source) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) List<PhysGrabObject> list = NearbyLoot(center, range).Where(delegate(PhysGrabObject loot) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (AvailableForPull(loot)) { Vector3 val = center - loot.centerPoint; return ((Vector3)(ref val)).sqrMagnitude > 2.25f; } return false; }).Take(5).ToList(); if (list.Count == 0) { return false; } source.StartCoroutine(GuideLoot(list, center, 1.5f)); return true; } private static IEnumerator GuideLoot(List<PhysGrabObject> targets, Vector3 center, float arrivalRadius) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) WaitForFixedUpdate physicsStep = new WaitForFixedUpdate(); for (float elapsed = 0f; elapsed < 2.7f; elapsed += Time.fixedDeltaTime) { if (targets.Count == 0) { break; } if (!InfinityStonesPlugin.GameplayActive()) { break; } for (int num = targets.Count - 1; num >= 0; num--) { PhysGrabObject val = targets[num]; if (!AvailableForPull(val) || !InfinityStonesPlugin.CanSee(center, val.centerPoint)) { targets.RemoveAt(num); } else { Vector3 val2 = center - val.centerPoint; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude <= arrivalRadius) { val.rb.linearVelocity = Vector3.zero; targets.RemoveAt(num); } else { float num2 = Mathf.Min(6f, (magnitude - arrivalRadius + 0.1f) * 4f); val.OverrideZeroGravity(0.18f); val.rb.linearVelocity = val2 * (num2 / magnitude); } } } yield return physicsStep; } } private static bool AvailableForPull(PhysGrabObject loot) { if (Object.op_Implicit((Object)(object)loot) && !loot.dead && Object.op_Implicit((Object)(object)loot.rb) && !loot.rb.isKinematic) { return !SemiFunc.PhysGrabObjectIsGrabbed(loot); } return false; } private static bool ProtectLoot(Vector3 center, float range) { //IL_0002: 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) bool result = false; PhysGrabObjectImpactDetector val = default(PhysGrabObjectImpactDetector); foreach (PhysGrabObject item in NearbyLoot(center, range)) { item.OverrideIndestructible(25f); if (((Component)item).TryGetComponent<PhysGrabObjectImpactDetector>(ref val)) { val.Heal(0.3f, item.centerPoint); } result = true; } return result; } private static bool Heal(Vector3 center, float range, PlayerAvatar caster) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) bool result = false; foreach (PlayerAvatar item in NearbyPlayers(center, range, caster)) { if (Object.op_Implicit((Object)(object)item.playerHealth) && Health.Invoke(item.playerHealth) < MaxHealth.Invoke(item.playerHealth)) { item.playerHealth.HealOther(60, true); result = true; } } return result; } private static bool Stun(Vector3 center, float range) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) bool result = false; EnemyStateStunned val = default(EnemyStateStunned); foreach (Enemy item in NearbyEnemies(center, range)) { if (((Component)item).TryGetComponent<EnemyStateStunned>(ref val)) { val.Set(8f); } item.Freeze(8f); result = true; } return result; } private static bool Conceal(Vector3 center, float range, PlayerAvatar caster) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerAvatar item in NearbyPlayers(center, range, caster)) { item.EnemyVisionFreezeTimerSet(16f); item.OverrideDisableEnemyInvestigate(16f); } return true; } private static IEnumerable<PlayerAvatar> NearbyPlayers(Vector3 center, float range, PlayerAvatar caster) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) yield return caster; foreach (PlayerAvatar item in SemiFunc.PlayerGetAllPlayerAvatarWithinRange(range, center, false, default(LayerMask))) { if (Object.op_Implicit((Object)(object)item) && (Object)(object)item != (Object)(object)caster && !InfinityStonesPlugin.IsDisabled.Invoke(item) && InfinityStonesPlugin.CanSee(center, ((Component)item).transform.position + Vector3.up * 0.5f)) { yield return item; } } } private static IEnumerable<Enemy> NearbyEnemies(Vector3 center, float range) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return (from parent in EnemyDirector.instance.enemiesSpawned where Object.op_Implicit((Object)(object)parent) && EnemySpawned.Invoke(parent) select EnemyOf.Invoke(parent)).Where(delegate(Enemy enemy) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) EnemyHealth val = default(EnemyHealth); if (Object.op_Implicit((Object)(object)enemy) && ((Behaviour)enemy).isActiveAndEnabled && Object.op_Implicit((Object)(object)enemy.CenterTransform) && (!((Component)enemy).TryGetComponent<EnemyHealth>(ref val) || !EnemyDead.Invoke(val))) { Vector3 val2 = enemy.CenterTransform.position - center; if (((Vector3)(ref val2)).sqrMagnitude <= range * range) { return InfinityStonesPlugin.CanSee(center, enemy.CenterTransform.position); } } return false; }); } private static IEnumerable<PhysGrabObject> NearbyLoot(Vector3 center, float range) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); return (from loot in SemiFunc.PhysGrabObjectAllValuablesWithinRange(range, center, false, default(LayerMask)) where Object.op_Implicit((Object)(object)loot) && !loot.dead && ((Component)loot).TryGetComponent<ValuableObject>(ref val) && !InfinityStonesPlugin.CommittedToExtraction.Invoke(val) && InfinityStonesPlugin.CanSee(center, loot.centerPoint) select loot).Distinct().OrderBy(delegate(PhysGrabObject loot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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) val = loot.centerPoint - center; return ((Vector3)(ref val)).sqrMagnitude; }); } } internal sealed class StonePulse : MonoBehaviour { private const int Segments = 64; private const float Duration = 0.7f; private static readonly Vector3[] UnitCircle = MakeUnitCircle(); private LineRenderer ring; private Light flash; private float radius; private float age; internal static void Spawn(Vector3 center, StoneDefinition stone, Material material) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(stone.Name + " pulse"); val.transform.position = center; StonePulse stonePulse = val.AddComponent<StonePulse>(); stonePulse.radius = stone.Radius; stonePulse.ring = val.AddComponent<LineRenderer>(); stonePulse.ring.useWorldSpace = false; stonePulse.ring.loop = true; stonePulse.ring.positionCount = UnitCircle.Length; stonePulse.ring.SetPositions(UnitCircle); ((Renderer)stonePulse.ring).sharedMaterial = material; ((Renderer)stonePulse.ring).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)stonePulse.ring).receiveShadows = false; stonePulse.flash = val.AddComponent<Light>(); stonePulse.flash.type = (LightType)2; stonePulse.flash.color = stone.Color; stonePulse.flash.range = 5f; stonePulse.flash.intensity = 2.4f; stonePulse.Draw(0f); } private void Update() { age += Time.deltaTime; if (age >= 0.7f) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Draw(age / 0.7f); } } private void Draw(float progress) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) float num = 1f - progress; float num2 = Mathf.Lerp(0.25f, radius, 1f - num * num); ((Component)this).transform.localScale = new Vector3(num2, 1f, num2); ring.widthMultiplier = 0.15f * num; flash.intensity = 2.4f * num * num; } private static Vector3[] MakeUnitCircle() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[64]; for (int i = 0; i < array.Length; i++) { float num = (float)i * (MathF.PI / 32f); array[i] = new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)); } return array; } } }