Decompiled source of Portal Gun v1.0.0
PortalGun.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using DarkMachine.AI; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [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("PortalGun")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+fe2a2a0b313cfebb37cb3042edaa0d98684f7d56")] [assembly: AssemblyProduct("PortalGun")] [assembly: AssemblyTitle("PortalGun")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 PortalGun { public class DropTint : MonoBehaviour { private readonly List<Material> mats = new List<Material>(); private readonly List<Texture2D> originals = new List<Texture2D>(); private int shown = -1; private void Start() { Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (val is ParticleSystemRenderer || val is SpriteRenderer || val is TrailRenderer || val is LineRenderer) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { Texture mainTexture = val2.mainTexture; Texture2D val3 = (Texture2D)(object)((mainTexture is Texture2D) ? mainTexture : null); if (val3 != null) { mats.Add(val2); originals.Add(val3); } } } if (mats.Count == 0) { PortalGunPlugin.Log.LogWarning((object)("Drop tint: no textured mesh on " + ((Object)this).name)); } Update(); } private void Update() { int next = PortalGunPlugin.Next; if (next == shown) { return; } shown = next; for (int i = 0; i < mats.Count; i++) { if ((Object)(object)mats[i] != (Object)null) { mats[i].mainTexture = (Texture)(object)GunTint.RecolouredTexture(originals[i], next); } } } } public class GunTint : MonoBehaviour { [CompilerGenerated] private static class <>O { public static CameraCallback <0>__PreCull; } private const float MinSaturation = 0.25f; private static readonly float[] Hues = new float[2] { 0.58f, 0.14f }; private static readonly Dictionary<Texture2D, Texture2D>[] texCache = new Dictionary<Texture2D, Texture2D>[2] { new Dictionary<Texture2D, Texture2D>(), new Dictionary<Texture2D, Texture2D>() }; private static readonly Dictionary<Sprite, Sprite>[] spriteCache = new Dictionary<Sprite, Sprite>[2] { new Dictionary<Sprite, Sprite>(), new Dictionary<Sprite, Sprite>() }; private static readonly Dictionary<Sprite, Sprite> original = new Dictionary<Sprite, Sprite>(); private static bool hooked; private static readonly List<GunTint> live = new List<GunTint>(); private SpriteRenderer[] sprites; private bool logged; private void OnEnable() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0027: 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_0032: Expected O, but got Unknown live.Add(this); if (!hooked) { CameraCallback onPreCull = Camera.onPreCull; object obj = <>O.<0>__PreCull; if (obj == null) { CameraCallback val = PreCull; <>O.<0>__PreCull = val; obj = (object)val; } Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)onPreCull, (Delegate?)obj); hooked = true; } } private void OnDisable() { live.Remove(this); } private static void PreCull(Camera c) { for (int num = live.Count - 1; num >= 0; num--) { if ((Object)(object)live[num] == (Object)null) { live.RemoveAt(num); } else { live[num].Apply(); } } } private void Apply() { if (sprites == null) { sprites = ((Component)this).GetComponentsInChildren<SpriteRenderer>(true); } int next = PortalGunPlugin.Next; SpriteRenderer[] array = sprites; foreach (SpriteRenderer val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.sprite == (Object)null)) { Sprite val2 = val.sprite; if (original.TryGetValue(val2, out var value)) { val2 = value; } Sprite val3 = Recoloured(val2, next); if ((Object)(object)val3 != (Object)null && (Object)(object)val.sprite != (Object)(object)val3) { val.sprite = val3; } } } if (!logged) { logged = true; if (sprites.Length == 0) { PortalGunPlugin.Log.LogWarning((object)"Gun tint: no sprite renderer on the flare gun"); } array = sprites; foreach (SpriteRenderer val4 in array) { PortalGunPlugin.Log.LogInfo((object)("Gun tint: sprite renderer " + ((Object)val4).name + " (" + (((Object)(object)val4.sprite != (Object)null) ? ((Object)val4.sprite).name : "none") + ")")); } } } private static Sprite Recoloured(Sprite s, int colour) { //IL_0022: 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) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) if (spriteCache[colour].TryGetValue(s, out var value)) { return value; } Sprite val = null; try { Texture2D obj = RecolouredTexture(s.texture, colour); Rect textureRect = s.textureRect; float x = s.pivot.x; float x2 = ((Rect)(ref textureRect)).x; Rect rect = s.rect; float num = (x - (x2 - ((Rect)(ref rect)).x)) / ((Rect)(ref textureRect)).width; float y = s.pivot.y; float y2 = ((Rect)(ref textureRect)).y; rect = s.rect; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(num, (y - (y2 - ((Rect)(ref rect)).y)) / ((Rect)(ref textureRect)).height); val = Sprite.Create(obj, textureRect, val2, s.pixelsPerUnit, 0u, (SpriteMeshType)0, s.border); ((Object)val).name = ((Object)s).name + "_portal" + colour; original[val] = s; } catch (Exception ex) { PortalGunPlugin.Log.LogWarning((object)("Gun tint: can't recolour " + ((Object)s).name + ": " + ex.Message)); } spriteCache[colour][s] = val; return val; } internal static Texture2D RecolouredTexture(Texture2D src, int colour) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00a3: 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_0150: 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_00ae: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) if (texCache[colour].TryGetValue(src, out var value)) { return value; } RenderTexture temporary = RenderTexture.GetTemporary(((Texture)src).width, ((Texture)src).height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2); RenderTexture active = RenderTexture.active; Graphics.Blit((Texture)(object)src, temporary); RenderTexture.active = temporary; Texture2D val = new Texture2D(((Texture)src).width, ((Texture)src).height, (TextureFormat)4, false); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)src).width, (float)((Texture)src).height), 0, 0); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color32[] pixels = val.GetPixels32(); float num = Hues[colour]; int num2 = 0; float num3 = default(float); float num4 = default(float); float num5 = default(float); for (int i = 0; i < pixels.Length; i++) { Color32 val2 = pixels[i]; if (val2.a != 0) { Color.RGBToHSV(Color32.op_Implicit(val2), ref num3, ref num4, ref num5); if (!(num4 < 0.25f) && !(num5 < 0.12f)) { Color val3 = Color.HSVToRGB(num, Mathf.Max(num4, 0.6f), num5); pixels[i] = new Color32((byte)(val3.r * 255f), (byte)(val3.g * 255f), (byte)(val3.b * 255f), val2.a); num2++; } } } val.SetPixels32(pixels); ((Texture)val).filterMode = ((Texture)src).filterMode; ((Texture)val).wrapMode = ((Texture)src).wrapMode; val.Apply(false, false); ((Object)val).name = ((Object)src).name + "_portal" + colour; texCache[colour][src] = val; PortalGunPlugin.Log.LogInfo((object)string.Format("Gun tint: recoloured {0} ({1}x{2}) {3}, {4} pixels", ((Object)src).name, ((Texture)src).width, ((Texture)src).height, (colour == 0) ? "blue" : "yellow", num2)); return val; } } public class Portal : MonoBehaviour { public const float HalfWidth = 0.95f; public const float HalfHeight = 1.55f; internal static readonly Portal[] Open = new Portal[2]; public int colour; internal PortalView view; internal readonly List<Collider> surface = new List<Collider>(); private const int RingPieces = 32; private const float RingScale = 1.06f; internal const float RingDepth = 2.5f; private Transform anchor; private Vector3 localPos; private Quaternion localRot; private static readonly Vector2[] Nudges = (Vector2[])(object)new Vector2[13] { Vector2.zero, new Vector2(0f, 0.4f), new Vector2(0f, -0.4f), new Vector2(0.3f, 0f), new Vector2(-0.3f, 0f), new Vector2(0f, 0.8f), new Vector2(0f, -0.8f), new Vector2(0.55f, 0f), new Vector2(-0.55f, 0f), new Vector2(0.3f, 0.4f), new Vector2(-0.3f, 0.4f), new Vector2(0.3f, -0.4f), new Vector2(-0.3f, -0.4f) }; private Renderer[] parts; public Vector3 Normal => ((Component)this).transform.forward; public Portal Other => Open[1 - colour]; internal static void ClearAll() { for (int i = 0; i < 2; i++) { if ((Object)(object)Open[i] != (Object)null) { Object.Destroy((Object)(object)((Component)Open[i]).gameObject); Open[i] = null; } } } internal static bool TryPlace(int colour, RaycastHit hit) { //IL_003e: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b1: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_015d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null) { return false; } Rigidbody attachedRigidbody = ((RaycastHit)(ref hit)).collider.attachedRigidbody; if ((Object)(object)attachedRigidbody != (Object)null && !attachedRigidbody.isKinematic) { return Fizzle(colour, hit, "loose object"); } Vector3 normal = ((RaycastHit)(ref hit)).normal; Vector3 val; if (Mathf.Abs(normal.y) > 0.7f) { ENT_Player player = ENT_Player.GetPlayer(); val = Vector3.ProjectOnPlane(((Object)(object)player != (Object)null) ? ((Component)player).transform.forward : Vector3.forward, normal); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.ProjectOnPlane(Vector3.forward, normal); } } else { val = Vector3.ProjectOnPlane(Vector3.up, normal); } Quaternion val2 = Quaternion.LookRotation(normal, ((Vector3)(ref val)).normalized); int mask = (1 << ((Component)((RaycastHit)(ref hit)).collider).gameObject.layer) | 1; Vector2[] nudges = Nudges; foreach (Vector2 val3 in nudges) { Vector3 pos = ((RaycastHit)(ref hit)).point + val2 * new Vector3(val3.x, val3.y, 0f); List<Collider> list = new List<Collider>(); if (Fits(pos, val2, mask, colour, list)) { pos = DownToFloor(pos, val2, mask, colour, list); if (!list.Contains(((RaycastHit)(ref hit)).collider)) { list.Add(((RaycastHit)(ref hit)).collider); } Create(colour, pos, val2, ((Component)((RaycastHit)(ref hit)).collider).transform, list); return true; } } return Fizzle(colour, hit, "no room"); } private static Vector3 DownToFloor(Vector3 pos, Quaternion rot, int mask, int colour, List<Collider> found) { //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) //IL_0006: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0063: 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_008d: 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_0094: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00b3: Unknown result type (might be due to invalid IL or missing references) Vector3 val = rot * Vector3.forward; if (Mathf.Abs(val.y) > 0.3f) { return pos; } RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(pos + val * 0.3f, Vector3.down, ref val2, 2.55f, mask, (QueryTriggerInteraction)1) || ((RaycastHit)(ref val2)).normal.y < 0.7f) { return pos; } float num = pos.y - ((RaycastHit)(ref val2)).point.y - 1.55f - 0.02f; if (num <= 0.01f || num > 0.9f) { return pos; } Vector3 val3 = pos + Vector3.down * num; List<Collider> list = new List<Collider>(); if (!Fits(val3, rot, mask, colour, list)) { return pos; } found.Clear(); found.AddRange(list); return val3; } private static bool Fits(Vector3 pos, Quaternion rot, int mask, int colour, List<Collider> found) { //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) //IL_0006: 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_0025: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_013e: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) Vector3 val = rot * Vector3.forward; Portal portal = Open[1 - colour]; if ((Object)(object)portal != (Object)null && Vector3.Distance(((Component)portal).transform.position, pos) < 3.1f && Vector3.Dot(portal.Normal, val) > 0.9f) { return false; } int num = 0; int num2 = 0; RaycastHit val3 = default(RaycastHit); for (int i = 0; i < 12; i++) { float num3 = (float)i * MathF.PI * 2f / 12f; Vector3 val2 = pos + rot * new Vector3(Mathf.Cos(num3) * 0.95f * 0.9f, Mathf.Sin(num3) * 1.55f * 0.9f, 0f); num2++; if (Physics.Raycast(val2 + val * 0.25f, -val, ref val3, 0.5f, mask, (QueryTriggerInteraction)1) && Mathf.Abs(((RaycastHit)(ref val3)).distance - 0.25f) < 0.12f) { num++; if (!found.Contains(((RaycastHit)(ref val3)).collider)) { found.Add(((RaycastHit)(ref val3)).collider); } } } if (num < num2 - 1) { return false; } Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(0.76f, 1.24f, 0.2f); return !Physics.CheckBox(pos + val * 0.3f, val4, rot, mask, (QueryTriggerInteraction)1); } private static bool Fizzle(int colour, RaycastHit hit, string why) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) PortalGunPlugin.Log.LogInfo((object)string.Format("Portal {0} fizzled at {1}: {2}", (colour == 0) ? "blue" : "yellow", ((RaycastHit)(ref hit)).point, why)); return false; } private static void Create(int colour, Vector3 pos, Quaternion rot, Transform anchor, List<Collider> surface) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_003b: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Open[colour] != (Object)null) { Object.Destroy((Object)(object)((Component)Open[colour]).gameObject); } GameObject val = new GameObject((colour == 0) ? "Portal_Blue" : "Portal_Yellow"); val.transform.SetPositionAndRotation(pos, rot); val.layer = 2; Portal portal = val.AddComponent<Portal>(); portal.colour = colour; portal.anchor = anchor; portal.localPos = anchor.InverseTransformPoint(pos); portal.localRot = Quaternion.Inverse(anchor.rotation) * rot; portal.surface.AddRange(surface); portal.BuildRing(((Component)anchor).gameObject.layer); portal.BuildFloorPatches(((Component)anchor).gameObject.layer); Color val2 = ((colour == 0) ? PortalGunPlugin.Blue : PortalGunPlugin.Yellow); Disc(val.transform, 1f, 0.02f, val2); GameObject dark = Disc(val.transform, 0.88f, 0.03f, Color.Lerp(val2, Color.black, 0.7f)); portal.view = val.AddComponent<PortalView>(); portal.view.Init(portal, dark); Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.color = val2; obj.range = 2.5f; obj.intensity = 0.5f; Open[colour] = portal; PortalGunPlugin.Log.LogInfo((object)string.Format("Portal {0} opened at {1} facing {2}", (colour == 0) ? "blue" : "yellow", pos, rot * Vector3.forward)); } private void BuildRing(int layer) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Ring"); val.layer = layer; val.transform.SetParent(((Component)this).transform, false); Vector3 val2 = default(Vector3); Vector3 val3 = default(Vector3); for (int i = 0; i < 32; i++) { float num = (float)i * MathF.PI * 2f / 32f; float num2 = (float)(i + 1) * MathF.PI * 2f / 32f; ((Vector3)(ref val2))..ctor(Mathf.Cos(num) * 0.95f * 1.06f, Mathf.Sin(num) * 1.55f * 1.06f, 0f); ((Vector3)(ref val3))..ctor(Mathf.Cos(num2) * 0.95f * 1.06f, Mathf.Sin(num2) * 1.55f * 1.06f, 0f); Vector3 val4 = val3 - val2; Vector3 val5 = new Vector3(val4.y, 0f - val4.x, 0f); Vector3 normalized = ((Vector3)(ref val5)).normalized; GameObject val6 = new GameObject("Piece" + i) { layer = layer }; val6.transform.SetParent(val.transform, false); val6.transform.localPosition = (val2 + val3) * 0.5f + normalized * 0.1f + new Vector3(0f, 0f, -1.27f); val6.transform.localRotation = Quaternion.LookRotation(Vector3.forward, normalized); val6.AddComponent<BoxCollider>().size = new Vector3(((Vector3)(ref val4)).magnitude * 1.15f, 0.2f, 2.5f); } } private void BuildFloorPatches(int layer) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00ff: 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_010e: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) Vector3 normal = Normal; if (Mathf.Abs(normal.y) > 0.7f) { return; } GameObject val = new GameObject("FloorPatches"); val.layer = layer; val.transform.SetParent(((Component)this).transform, false); Vector3 right = ((Component)this).transform.right; int num = 0; for (float num2 = -1.15f; num2 <= 1.16f; num2 += 0.35f) { for (float num3 = 0.15f; num3 <= 1.6f; num3 += 0.35f) { RaycastHit[] array = Physics.RaycastAll(((Component)this).transform.position + right * num2 + normal * num3, Vector3.down, 3.05f, -1, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if (surface.Contains(((RaycastHit)(ref val2)).collider) && !(((RaycastHit)(ref val2)).normal.y < 0.6f)) { GameObject val3 = new GameObject("Patch") { layer = layer }; val3.transform.SetParent(val.transform, true); val3.transform.SetPositionAndRotation(((RaycastHit)(ref val2)).point - ((RaycastHit)(ref val2)).normal * 0.05f, Quaternion.FromToRotation(Vector3.up, ((RaycastHit)(ref val2)).normal)); val3.AddComponent<BoxCollider>().size = new Vector3(0.45f, 0.1f, 0.45f); num++; break; } } } } if (num > 0) { PortalGunPlugin.Log.LogInfo((object)$"Portal: {num} floor patches in front (floor is part of the wall's collider)"); } } private static GameObject Disc(Transform parent, float size, float lift, Color c) { //IL_0036: 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_0078: 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_009a: 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) //IL_00a6: Expected O, but got Unknown GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2); Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>()); obj.layer = 2; obj.transform.SetParent(parent, false); obj.transform.localPosition = new Vector3(0f, 0f, lift); obj.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); obj.transform.localScale = new Vector3(1.9f * size, 0.005f, 3.1f * size); MeshRenderer component = obj.GetComponent<MeshRenderer>(); Shader val = Shader.Find("Sprites/Default"); ((Renderer)component).sharedMaterial = new Material(val) { color = c }; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; return obj; } internal void SetHidden(bool hidden) { if (parts == null) { parts = ((Component)this).GetComponentsInChildren<Renderer>(true); } Renderer[] array = parts; for (int i = 0; i < array.Length; i++) { array[i].forceRenderingOff = hidden; } Light component = ((Component)this).GetComponent<Light>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = !hidden; } } private void LateUpdate() { //IL_0027: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)anchor == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { ((Component)this).transform.SetPositionAndRotation(anchor.TransformPoint(localPos), anchor.rotation * localRot); } } private void OnDestroy() { if ((Object)(object)Open[colour] == (Object)(object)this) { Open[colour] = null; } PortalTravel.Forget(this); } } internal static class PortalBarnacle { private class Link { public Portal near; public Portal far; public bool grabbed; } private static readonly Dictionary<Barnacle_Tongue_Basic, Link> links = new Dictionary<Barnacle_Tongue_Basic, Link>(); private static readonly HashSet<Barnacle_Tongue_Basic> holding = new HashSet<Barnacle_Tongue_Basic>(); private static Barnacle_Tongue_Basic updating; private static readonly FieldRef<Barnacle_Tongue_Core, Barnacle_Tongue_Interface_Module_Basic> Iface = AccessTools.FieldRefAccess<Barnacle_Tongue_Core, Barnacle_Tongue_Interface_Module_Basic>("barnacleInterface"); private static readonly FieldRef<Barnacle_Tongue_Basic, Vector3> AimPoint = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, Vector3>("aimPoint"); private static readonly FieldRef<Barnacle_Tongue_Basic, Vector3> AimTarget = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, Vector3>("aimTarget"); private static readonly FieldRef<Barnacle_Tongue_Basic, Vector3> TargetPoint = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, Vector3>("targetPoint"); private static readonly FieldRef<Barnacle_Tongue_Basic, Vector3> ReachPoint = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, Vector3>("reachPoint"); private static readonly FieldRef<Barnacle_Tongue_Basic, bool> TargetFound = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, bool>("targetFound"); private static readonly FieldRef<Barnacle_Tongue_Basic, bool> CanBite = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, bool>("canBite"); private static readonly FieldRef<Barnacle_Tongue_Basic, TongueState> State = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, TongueState>("state"); private static readonly FieldRef<Barnacle_Tongue_Basic, GameEntity> Grabbed = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, GameEntity>("grabbedEntity"); private static readonly FieldRef<Barnacle_Tongue_Basic, Vector3> GrabbedLocal = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, Vector3>("grabbedLocalPosition"); private static readonly FieldRef<Barnacle_Tongue_Basic, float> PullStrength = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, float>("pullStrength"); private static readonly FieldRef<Barnacle_Tongue_Basic, float> ReelTimer = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, float>("reelTimer"); private static readonly FieldRef<Barnacle_Tongue_Basic, Transform> Visual = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, Transform>("visualObject"); private static readonly FieldRef<Barnacle_Tongue_Basic, Material> TongueMat = AccessTools.FieldRefAccess<Barnacle_Tongue_Basic, Material>("tongueMaterial"); internal static void Patch(Harmony h) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00a5: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown Type typeFromHandle = typeof(Barnacle_Tongue_Basic); h.Patch((MethodBase)AccessTools.Method(typeFromHandle, "FindTarget", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PortalBarnacle), "FindTargetPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeFromHandle, "ScanForHitEntity", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PortalBarnacle), "ScanPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeFromHandle, "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PortalBarnacle), "UpdatePrefix", (Type[])null), new HarmonyMethod(typeof(PortalBarnacle), "UpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeFromHandle, "Retract", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PortalBarnacle), "RetractPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeFromHandle, "PullTarget", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PortalBarnacle), "PullPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool Current(Link l) { if (l != null && (Object)(object)l.near != (Object)null && (Object)(object)l.far != (Object)null && (Object)(object)Portal.Open[l.near.colour] == (Object)(object)l.near) { return (Object)(object)Portal.Open[l.far.colour] == (Object)(object)l.far; } return false; } private static bool CrossesFace(Portal p, Vector3 a, Vector3 b, out Vector3 x) { //IL_0001: 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_000d: 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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) //IL_0021: 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_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_005b: Unknown result type (might be due to invalid IL or missing references) x = default(Vector3); Vector3 normal = p.Normal; Vector3 position = ((Component)p).transform.position; float num = Vector3.Dot(a - position, normal); float num2 = Vector3.Dot(b - position, normal); if (num <= 0f || num2 >= 0f) { return false; } x = Vector3.Lerp(a, b, num / (num - num2)); return (Object)(object)PortalPass.OnFace(x, 0.05f) == (Object)(object)p; } private static void FindTargetPostfix(Barnacle_Tongue_Basic __instance) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0171: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) Barnacle_Tongue_Interface_Module_Basic val = Iface.Invoke((Barnacle_Tongue_Core)(object)__instance); ENT_Player playerObject = ENT_Player.playerObject; if (val == null || (Object)(object)playerObject == (Object)null || (Object)(object)Portal.Open[0] == (Object)null || (Object)(object)Portal.Open[1] == (Object)null) { return; } Vector3 position = __instance.tongue.position; if (TargetFound.Invoke(__instance)) { Portal portal = PortalPass.OnFace(AimPoint.Invoke(__instance), 0.15f); if ((Object)(object)portal != (Object)null) { links[__instance] = new Link { near = portal, far = portal.Other }; return; } } DEN_Barnacle barnacle = ((Barnacle_Tongue_Interface_Module)val).GetBarnacle(); if (((!CL_GameManager.IsHardmode() || !__instance.hardModeAdjustsDifficulty) && !__instance.aimForPlayer) || (Object)(object)barnacle == (Object)null || ((AIGameEntity)barnacle).sight == null || ((AIGameEntity)barnacle).sight.CanSeeTarget(((Component)playerObject).transform, false)) { return; } Transform val2 = (((Object)(object)__instance.aimEye != (Object)null) ? __instance.aimEye : __instance.tongue); RaycastHit val5 = default(RaycastHit); for (int i = 0; i < 2; i++) { Portal portal2 = Portal.Open[i]; Portal other = portal2.Other; Vector3 val3 = PortalHold.Through(other, portal2, ((Component)playerObject).transform.position); Vector3 val4 = val3 - position; if (!(((Vector3)(ref val4)).magnitude > val.scanDistance) && !(Vector3.Angle(val2.forward, val4) > 60f) && CrossesFace(portal2, position, val3, out var x) && !Physics.Linecast(position, x - ((Vector3)(ref val4)).normalized * 0.05f, LayerMask.op_Implicit(val.hitMask), (QueryTriggerInteraction)1) && (!Physics.Linecast(PortalHold.Through(portal2, other, x) + other.Normal * 0.05f, ((Component)playerObject).transform.position, ref val5, LayerMask.op_Implicit(val.hitMask), (QueryTriggerInteraction)1) || !((Object)(object)((Component)((RaycastHit)(ref val5)).collider).GetComponentInParent<ENT_Player>() == (Object)null))) { AimTarget.Invoke(__instance) = val3; AimPoint.Invoke(__instance) = x; TargetFound.Invoke(__instance) = true; links[__instance] = new Link { near = portal2, far = other }; break; } } } private static void ScanPostfix(Barnacle_Tongue_Basic __instance) { //IL_0080: 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_0096: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0108: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_0138: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null) { return; } if ((Object)(object)Grabbed.Invoke(__instance) == (Object)(object)playerObject) { holding.Add(__instance); } else { if ((Object)(object)Grabbed.Invoke(__instance) != (Object)null || (int)State.Invoke(__instance) != 1 || !links.TryGetValue(__instance, out var value) || !Current(value) || value.grabbed) { return; } Vector3 val = ReachPoint.Invoke(__instance); Vector3 val2 = TargetPoint.Invoke(__instance); if (Vector3.Distance(val, val2) > 0.35f || (Object)(object)PortalPass.OnFace(val2, 0.15f) != (Object)(object)value.near) { return; } Barnacle_Tongue_Interface_Module_Basic val3 = Iface.Invoke((Barnacle_Tongue_Core)(object)__instance); Quaternion val4 = PortalHold.Turn(value.near, value.far); Vector3 val5 = val2 - __instance.tongue.position; Vector3 val6 = val4 * ((Vector3)(ref val5)).normalized; RaycastHit val7 = default(RaycastHit); if (!Physics.Raycast(PortalHold.Through(value.near, value.far, val2) + value.far.Normal * 0.05f, val6, ref val7, val3.scanDistance * 1.5f, LayerMask.op_Implicit(val3.playerMask), (QueryTriggerInteraction)1) || (Object)(object)((Component)((RaycastHit)(ref val7)).collider).GetComponentInParent<ENT_Player>() != (Object)(object)playerObject) { return; } Grabbed.Invoke(__instance) = (GameEntity)(object)playerObject; GrabbedLocal.Invoke(__instance) = ((Component)((RaycastHit)(ref val7)).collider).transform.InverseTransformPoint(((RaycastHit)(ref val7)).point); State.Invoke(__instance) = (TongueState)3; PullStrength.Invoke(__instance) = 0f; value.grabbed = true; holding.Add(__instance); DEN_Barnacle barnacle = ((Barnacle_Tongue_Interface_Module)val3).GetBarnacle(); DamageInfo val8 = DamageInfo.CreateDamageInfo(__instance.hitDamage, __instance.hitDamageSource); val8.intensity = __instance.hitIntensity; val8.position = ((RaycastHit)(ref val7)).point; val8.sourceEntity = (GameEntity)(object)barnacle; ((GameEntity)playerObject).Damage(val8); ((AIGameEntity)barnacle).clipHandler.PlaySound("barnacle:grabbed-object"); barnacle.OnGrab(); if (!__instance.grabOnHit) { Grabbed.Invoke(__instance) = null; value.grabbed = false; ((Barnacle_Tongue_Core)__instance).Retract(); return; } if (__instance.dropPlayerOnHit) { playerObject.DropHang(0.4f, 1f, false, "drop", true); } PortalGunPlugin.Log.LogInfo((object)"Portal: barnacle grabbed you through a portal"); } } private static bool HeldThrough(Barnacle_Tongue_Basic t, out Link l) { l = null; if (links.TryGetValue(t, out l) && l.grabbed && Current(l) && (Object)(object)Grabbed.Invoke(t) != (Object)null) { return (Object)(object)Grabbed.Invoke(t) == (Object)(object)ENT_Player.playerObject; } return false; } private static void UpdatePrefix(Barnacle_Tongue_Basic __instance) { updating = __instance; } private static void UpdatePostfix(Barnacle_Tongue_Basic __instance) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) updating = null; if ((int)State.Invoke(__instance) == 0 || (links.TryGetValue(__instance, out var value) && !Current(value))) { links.Remove(__instance); } if ((Object)(object)Grabbed.Invoke(__instance) != (Object)(object)ENT_Player.playerObject) { holding.Remove(__instance); } if (!HeldThrough(__instance, out var l)) { return; } ENT_Player playerObject = ENT_Player.playerObject; Vector3 position = __instance.tongue.position; Portal far = l.far; Portal near = l.near; Bounds bounds = ((Collider)playerObject.cCon).bounds; Vector3 b = PortalHold.Through(far, near, ((Bounds)(ref bounds)).center); Vector3 x; Vector3 val = (CrossesFace(l.near, position, b, out x) ? x : ((Component)l.near).transform.position); ReachPoint.Invoke(__instance) = val; Transform val2 = Visual.Invoke(__instance); if ((Object)(object)val2 != (Object)null && val != val2.position) { val2.rotation = Quaternion.LookRotation(val - val2.position); val2.localScale = new Vector3(1f, 1f, Vector3.Distance(val2.position, val)); Material obj = TongueMat.Invoke(__instance); if (obj != null) { obj.SetFloat("_Length", val2.localScale.z); } } CanBite.Invoke(__instance) = false; } private static bool RetractPrefix(Barnacle_Tongue_Basic __instance) { //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_0047: Unknown result type (might be due to invalid IL or missing references) if (updating != __instance || !HeldThrough(__instance, out var l)) { return true; } Barnacle_Tongue_Interface_Module_Basic val = Iface.Invoke((Barnacle_Tongue_Core)(object)__instance); return Vector3.Distance(PortalHold.Through(l.far, l.near, ((Component)ENT_Player.playerObject).transform.position), __instance.tongue.position) > val.scanDistance * 2f; } private static bool PullPrefix(Barnacle_Tongue_Basic __instance) { //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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_011b: 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_0136: 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) if (!HeldThrough(__instance, out var l)) { return true; } Barnacle_Tongue_Interface_Module_Basic val = Iface.Invoke((Barnacle_Tongue_Core)(object)__instance); ENT_Player playerObject = ENT_Player.playerObject; float num = (CL_GameManager.IsHardmode() ? 0.8f : 0.3f); float num2 = val.pullStrength * (CL_GameManager.IsHardmode() ? 1.5f : 1f); PullStrength.Invoke(__instance) = Mathf.Lerp(PullStrength.Invoke(__instance), num2, Time.deltaTime * num * val.tongueReelIncreaseRate); if (ReelTimer.Invoke(__instance) > 0f) { PullStrength.Invoke(__instance) = 0f; ReelTimer.Invoke(__instance) -= Time.deltaTime; } Vector3 val2 = PortalHold.Through(l.near, l.far, __instance.tongue.position); float num3 = Mathf.Max(Vector3.Distance(val2, ((Component)playerObject).transform.position) / val.scanDistance, 1f); ((GameEntity)playerObject).SetGrappled(true, (Grappler)(object)((Barnacle_Tongue_Interface_Module)val).GetBarnacle()); Vector3 val3 = val2 - ((Component)playerObject).transform.position; ((GameEntity)playerObject).TonguePull(((Vector3)(ref val3)).normalized * Time.deltaTime * PullStrength.Invoke(__instance) * num3); return false; } internal static void Crossed(ENT_Player p, Portal from, Portal to) { holding.RemoveWhere((Barnacle_Tongue_Basic t) => t == null || (Object)(object)Grabbed.Invoke(t) != (Object)(object)p); foreach (Barnacle_Tongue_Basic item in holding) { if (links.TryGetValue(item, out var value) && value.grabbed) { links.Remove(item); continue; } links[item] = new Link { near = from, far = to, grabbed = true }; } } } internal static class PortalBlink { private struct State { public Portal from; public Portal to; public int hops; public Vector3 target; } private static readonly FieldRef<HandItem_BlinkEye, Vector3> Target = AccessTools.FieldRefAccess<HandItem_BlinkEye, Vector3>("blinkTargetPosition"); private static readonly FieldRef<ENT_Player, Vector3> Vel = AccessTools.FieldRefAccess<ENT_Player, Vector3>("vel"); private static Portal aimFrom; private static Portal aimTo; private static int aimHops; internal static void Patch(Harmony h) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_005d: 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_007f: Expected O, but got Unknown //IL_007f: Expected O, but got Unknown h.Patch((MethodBase)AccessTools.Method(typeof(HandItem_BlinkEye), "LateUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PortalBlink), "LateUpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(HandItem_BlinkEye), "StopUse", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PortalBlink), "StopUsePrefix", (Type[])null), new HarmonyMethod(typeof(PortalBlink), "StopUsePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void LateUpdatePostfix(HandItem_BlinkEye __instance) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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) //IL_009e: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00e5: 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_010a: 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_0118: 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) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (!((HandItem)__instance).used) { return; } aimFrom = (aimTo = null); ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null || (Object)(object)Portal.Open[0] == (Object)null || (Object)(object)Portal.Open[1] == (Object)null) { return; } Vector3 position = ((Component)playerObject.cam).transform.position; Vector3 forward = ((Component)__instance).transform.forward; if (PortalPass.AimChain(position, forward, __instance.blinkDistance, __instance.blinkMask, "blink", out var aim)) { Portal portal = aim.from; Portal to = aim.to; float radius = playerObject.cCon.radius; Vector3 dir = aim.dir; Vector3 val = PortalHold.ClearOfWall(aim.point, dir, to.Normal, radius + 0.02f); float left = aim.left; Vector3 val2 = val; if (left > 0f) { bool queriesHitBackfaces = Physics.queriesHitBackfaces; Physics.queriesHitBackfaces = true; RaycastHit val3 = default(RaycastHit); val2 = (Physics.SphereCast(val, radius, dir, ref val3, left, LayerMask.op_Implicit(__instance.blinkMask)) ? (val + dir * ((RaycastHit)(ref val3)).distance) : (val + dir * left)); Physics.queriesHitBackfaces = queriesHitBackfaces; } Target.Invoke(__instance) = val2; ((Component)__instance.blinkTargetEffect).transform.position = val2; aimFrom = portal; aimTo = to; aimHops = aim.hops; } } private static void StopUsePrefix(HandItem_BlinkEye __instance, out State __state) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) __state = new State { from = aimFrom, to = aimTo, hops = aimHops, target = Target.Invoke(__instance) }; } private static void StopUsePostfix(State __state) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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) if ((Object)(object)__state.from == (Object)null || (Object)(object)__state.to == (Object)null) { return; } ENT_Player playerObject = ENT_Player.playerObject; if (!((Object)(object)playerObject == (Object)null) && !(Vector3.Distance(((Component)playerObject).transform.position, __state.target) > 0.5f)) { Quaternion val = PortalHold.Turn(__state.from, __state.to, Mathf.Max(1, __state.hops)); PortalTravel.TurnedView(playerObject, val, out var yaw, out var pitch); playerObject.SetPlayerRotation(new Vector3(pitch, yaw, 0f)); PortalRighting.ApplyNow(playerObject); Vel.Invoke(playerObject) = val * Vel.Invoke(playerObject); for (int i = 0; i < Mathf.Max(1, __state.hops); i++) { PortalTravel.Crossed(playerObject, __state.from, __state.to); } aimFrom = (aimTo = null); PortalGunPlugin.Log.LogInfo((object)("Portal: blinked through " + ((__state.from.colour == 0) ? "blue>yellow" : "yellow>blue"))); } } } internal static class PortalFling { private const float DragMult = 0.2f; private const float Duration = 2f; private const float MinSpeed = 6f; private const float VelScale = 175f; private static readonly FieldRef<ENT_Player, float> TempFriction = AccessTools.FieldRefAccess<ENT_Player, float>("tempFrictionMult"); private static readonly FieldRef<ENT_Player, Vector3> Vel = AccessTools.FieldRefAccess<ENT_Player, Vector3>("vel"); private static float until; private static float started; internal static void Patch(Harmony h) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown h.Patch((MethodBase)AccessTools.Method(typeof(ENT_Player), "Movement", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PortalFling), "MovementPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } internal static void Start(float speed) { if (speed >= 6f) { until = Time.time + 2f; started = Time.time; } } private static void MovementPrefix(ENT_Player __instance) { if (!(Time.time >= until)) { if ((Time.time - started > 0.1f && (__instance.IsGrounded(false) || __instance.IsHanging())) || Vel.Invoke(__instance).y * 175f < -2f) { until = 0f; } else { TempFriction.Invoke(__instance) *= 0.2f; } } } } internal static class PortalGrapple { private class Link { public Portal near; public Portal far; public int hops; public Transform stub; } private struct State { public Projectile_Grapple hook; public Link link; public Vector3 pos; public Quaternion rot; public Quaternion back; } private static readonly Dictionary<Projectile_Grapple, Link> links = new Dictionary<Projectile_Grapple, Link>(); private static readonly FieldRef<HandItem_Shoot_Grapple, Projectile_Grapple> Hook = AccessTools.FieldRefAccess<HandItem_Shoot_Grapple, Projectile_Grapple>("grappleProjectile"); private static readonly FieldRef<Projectile, Vector3> Vel = AccessTools.FieldRefAccess<Projectile, Vector3>("velocity"); internal static void Patch(Harmony h) { //IL_0027: 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_0049: Expected O, but got Unknown //IL_0049: Expected O, but got Unknown h.Patch((MethodBase)AccessTools.Method(typeof(HandItem_Shoot_Grapple), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PortalGrapple), "UpdatePrefix", (Type[])null), new HarmonyMethod(typeof(PortalGrapple), "UpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool Valid(Link l) { if (l != null && l.hops > 0 && (Object)(object)l.near != (Object)null && (Object)(object)l.far != (Object)null && (Object)(object)Portal.Open[l.near.colour] == (Object)(object)l.near) { return (Object)(object)Portal.Open[l.far.colour] == (Object)(object)l.far; } return false; } private static Link Get(Projectile_Grapple g) { links.TryGetValue(g, out var value); return value; } private static void Drop(Projectile_Grapple g) { if ((Object)(object)g != (Object)null && links.TryGetValue(g, out var value) && (Object)(object)value.stub != (Object)null) { Object.Destroy((Object)(object)((Component)value.stub).gameObject); } links.Remove(g); } internal static void Carried(Projectile pr, Portal from, Portal to) { Projectile_Grapple val = (Projectile_Grapple)(object)((pr is Projectile_Grapple) ? pr : null); if (val == null) { return; } Link value = Get(val); if (Valid(value) && (Object)(object)value.far == (Object)(object)from && (Object)(object)value.near == (Object)(object)to) { value.hops--; } else if (Valid(value) && (Object)(object)value.near == (Object)(object)from && (Object)(object)value.far == (Object)(object)to) { value.hops++; } else { if (value != null && (Object)(object)value.stub != (Object)null) { Object.Destroy((Object)(object)((Component)value.stub).gameObject); } links[val] = new Link { near = from, far = to, hops = 1 }; } if (links.TryGetValue(val, out value) && value.hops <= 0) { Drop(val); } } internal static void Crossed(Portal from, Portal to) { List<Projectile_Grapple> list = new List<Projectile_Grapple>(); foreach (KeyValuePair<Projectile_Grapple, Link> link in links) { Link value = link.Value; if ((Object)(object)link.Key == (Object)null || !Valid(value)) { list.Add(link.Key); continue; } if ((Object)(object)value.near == (Object)(object)from && (Object)(object)value.far == (Object)(object)to) { value.hops--; } else if ((Object)(object)value.near == (Object)(object)to && (Object)(object)value.far == (Object)(object)from) { value.hops++; } if (value.hops <= 0) { list.Add(link.Key); } } foreach (Projectile_Grapple item in list) { Drop(item); } } private static void UpdatePrefix(HandItem_Shoot_Grapple __instance, out State __state) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0087: 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_008f: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) __state = default(State); Projectile_Grapple val = Hook.Invoke(__instance); if ((Object)(object)val == (Object)null) { return; } Link link = Get(val); if (!Valid(link)) { if (link != null) { Drop(val); } return; } Quaternion val2 = PortalHold.Turn(link.far, link.near, link.hops); __state = new State { hook = val, link = link, pos = ((Component)val).transform.position, rot = ((Component)val).transform.rotation, back = val2 }; ((Component)val).transform.SetPositionAndRotation(PortalHold.Through(link.far, link.near, ((Component)val).transform.position, link.hops), val2 * ((Component)val).transform.rotation); Vel.Invoke((Projectile)(object)val) = val2 * Vel.Invoke((Projectile)(object)val); } private static void UpdatePostfix(HandItem_Shoot_Grapple __instance, State __state) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) Projectile_Grapple hook = __state.hook; if ((Object)(object)hook == (Object)null) { return; } Link link = __state.link; Vector3 position = ((Component)hook).transform.position; ((Component)hook).transform.SetPositionAndRotation(__state.pos, __state.rot); Vel.Invoke((Projectile)(object)hook) = Quaternion.Inverse(__state.back) * Vel.Invoke((Projectile)(object)hook); CL_Handhold val = default(CL_Handhold); if ((Object)(object)Hook.Invoke(__instance) == (Object)null && ((Component)hook).TryGetComponent<CL_Handhold>(ref val)) { ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player != (Object)null) { Hand[] hands = player.hands; foreach (Hand val2 in hands) { if ((Object)(object)val2.handhold == (Object)(object)val) { Vector3 val3 = position - __state.back * ((Component)hook).transform.forward * 0.15f; PortalHold portalHold = PortalHold.Make(val, link.far, link.near, link.hops); val2.GrabHold(((Component)portalHold).transform, val3, (InteractionInfo)null); } } } Drop(hook); } else { Rope(__instance, hook, link); } } private static void Rope(HandItem_Shoot_Grapple gun, Projectile_Grapple g, Link l) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_010a: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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) //IL_00c0: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)g.hookMesh != (Object)null) ? ((Component)g.hookMesh).transform : null); if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeSelf || (Object)(object)gun.tetherPosition == (Object)null) { if ((Object)(object)l.stub != (Object)null) { ((Component)l.stub).gameObject.SetActive(false); } return; } Vector3 position = gun.tetherPosition.position; Vector3 b = PortalHold.Through(l.near, l.far, position, l.hops); float num = Mathf.Max(((Component)g).transform.lossyScale.y, 0.0001f); if (Cut(l.far, ((Component)g).transform.position, b, out var x)) { val.rotation = Quaternion.LookRotation(x - val.position); val.localScale = new Vector3(1f, 1f, Vector3.Distance(val.position, x) / num); } Vector3 b2 = PortalHold.Through(l.far, l.near, ((Component)g).transform.position, l.hops); if (!Cut(l.near, position, b2, out var x2)) { if ((Object)(object)l.stub != (Object)null) { ((Component)l.stub).gameObject.SetActive(false); } return; } if ((Object)(object)l.stub == (Object)null) { l.stub = Object.Instantiate<GameObject>(((Component)val).gameObject, val.parent).transform; ((Object)l.stub).name = "PortalRope"; } ((Component)l.stub).gameObject.SetActive(true); l.stub.SetPositionAndRotation(x2, Quaternion.LookRotation(position - x2)); l.stub.localScale = new Vector3(1f, 1f, Vector3.Distance(x2, position) / num); } private static bool Cut(Portal p, Vector3 a, Vector3 b, out Vector3 x) { //IL_0001: 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_000d: 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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) //IL_0021: 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_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) x = default(Vector3); Vector3 normal = p.Normal; Vector3 position = ((Component)p).transform.position; float num = Vector3.Dot(a - position, normal); float num2 = Vector3.Dot(b - position, normal); if (Mathf.Abs(num - num2) < 0.0001f || num * num2 > 0f) { return false; } x = Vector3.Lerp(a, b, num / (num - num2)); return true; } } [BepInPlugin("lakisa.portalgun", "Portal Gun", "1.0.0")] public class PortalGunPlugin : BaseUnityPlugin { internal static ManualLogSource Log; internal const string GunId = "Item_Flaregun"; internal static readonly Color Blue = new Color(0.15f, 0.55f, 1f); internal static readonly Color Yellow = new Color(1f, 0.78f, 0.1f); internal static int Next; private void Awake() { //IL_0010: 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) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("lakisa.portalgun"); val.Patch((MethodBase)AccessTools.Method(typeof(HandItem_Shoot), "CreateProjectile", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PortalGunPlugin), "CreateProjectilePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(HandItem_Shoot), "Initialize", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PortalGunPlugin), "InitializePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Projectile), "OnCollisionHit", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PortalGunPlugin), "CollisionHitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); PortalRighting.Patch(val); PortalPass.Patch(val); PortalHold.Patch(val); PortalBlink.Patch(val); PortalHook.Patch(val); PortalBarnacle.Patch(val); PortalSight.Patch(val); PortalSpear.Patch(val); PortalRewind.Patch(val); PortalFling.Patch(val); PortalTools.Patch(val); PortalGrapple.Patch(val); val.Patch((MethodBase)AccessTools.Method(typeof(Item_Object), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PortalGunPlugin), "ItemObjectStartPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); SceneManager.sceneLoaded += delegate { Portal.ClearAll(); Next = 0; }; GameObject val2 = new GameObject("PortalGun_Travel"); Object.DontDestroyOnLoad((Object)val2); val2.AddComponent<PortalTravel>(); val2.AddComponent<PortalSight>(); PortalView.Hook(); } internal static bool IsGun(HandItem h) { if ((Object)(object)h != (Object)null && h.item != null) { return h.item.prefabName == "Item_Flaregun"; } return false; } private static void CreateProjectilePostfix(HandItem_Shoot __instance, Projectile __result) { if (IsGun((HandItem)(object)__instance) && !((Object)(object)__result == (Object)null)) { ((Component)__result).gameObject.AddComponent<PortalShot>().colour = Next; Next = 1 - Next; Tint((HandItem)(object)__instance); } } private static void CollisionHitPostfix(Projectile __instance, RaycastHit hit, ObjectTagger tagger) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) PortalShot component = ((Component)__instance).GetComponent<PortalShot>(); if (!((Object)(object)component == (Object)null) && !component.done) { component.done = true; if (!((Object)(object)tagger != (Object)null) || (!tagger.HasTag("Creature") && !tagger.HasTag("Hitbox"))) { Portal.TryPlace(component.colour, hit); } } } private static void InitializePostfix(HandItem_Shoot __instance) { if (IsGun((HandItem)(object)__instance)) { Tint((HandItem)(object)__instance); Item_Object dropObject = ((HandItem)__instance).item.GetDropObject(true); if ((Object)(object)dropObject != (Object)null && (Object)(object)((Component)dropObject).GetComponent<DropTint>() == (Object)null) { ((Component)dropObject).gameObject.AddComponent<DropTint>(); } } } private static void ItemObjectStartPostfix(Item_Object __instance) { if (__instance.itemData != null && __instance.itemData.prefabName == "Item_Flaregun" && (Object)(object)((Component)__instance).GetComponent<DropTint>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<DropTint>(); } } internal static void Tint(HandItem h) { if ((Object)(object)((Component)h).GetComponent<GunTint>() == (Object)null) { ((Component)h).gameObject.AddComponent<GunTint>(); } } } public class PortalShot : MonoBehaviour { public int colour; public bool done; } public class PortalHold : MonoBehaviour { internal struct Grip { public Hand hand; public CL_Handhold hold; public Vector3 point; } private struct CamState { public Transform t; public Vector3 pos; public Quaternion rot; public ENT_Player p; public float reach; } private static readonly FieldRef<Hand, ENT_Player> HandPlayer = AccessTools.FieldRefAccess<Hand, ENT_Player>("player"); public CL_Handhold real; public Portal entry; public Portal exit; public int hops = 1; private CL_Handhold standIn; private float born; private static bool regrabbing; private static Portal castFrom; private static Portal castTo; private static int castHops = 1; private static float castTime = -10f; private bool Valid { get { if ((Object)(object)real != (Object)null && real.active && (Object)(object)entry != (Object)null && (Object)(object)exit != (Object)null && (Object)(object)Portal.Open[entry.colour] == (Object)(object)entry) { return (Object)(object)Portal.Open[exit.colour] == (Object)(object)exit; } return false; } } internal static void Patch(Harmony h) { //IL_0027: 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_0049: Expected O, but got Unknown //IL_0049: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown h.Patch((MethodBase)AccessTools.Method(typeof(Hand), "EnqueueInteractCast", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PortalHold), "CastPrefix", (Type[])null), new HarmonyMethod(typeof(PortalHold), "CastPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Hand), "GrabHold", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PortalHold), "GrabHoldPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } internal static Quaternion Turn(Portal from, Portal to) { //IL_0006: 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) //IL_001f: 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_002f: 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) return ((Component)to).transform.rotation * Quaternion.Euler(0f, 180f, 0f) * Quaternion.Inverse(((Component)from).transform.rotation); } internal static Vector3 Through(Portal from, Portal to, Vector3 point) { //IL_0006: 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) //IL_0012: 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) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) return ((Component)to).transform.position + Turn(from, to) * (point - ((Component)from).transform.position); } internal static Vector3 Through(Portal from, Portal to, Vector3 point, int n) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < n; i++) { point = Through(from, to, point); } return point; } internal static Quaternion Turn(Portal from, Portal to, int n) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.identity; Quaternion val2 = Turn(from, to); for (int i = 0; i < n; i++) { val = val2 * val; } return val; } internal static PortalHold Make(CL_Handhold real, Portal entry, Portal exit, int hops = 1) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PortalHold_" + ((Object)real).name); val.SetActive(false); PortalHold portalHold = val.AddComponent<PortalHold>(); portalHold.real = real; portalHold.entry = entry; portalHold.exit = exit; portalHold.hops = Mathf.Max(1, hops); portalHold.born = Time.time; CL_Handhold val2 = val.AddComponent<CL_Handhold>(); val2.activeEvent = new UnityEvent(); val2.stopEvent = new UnityEvent(); val2.hammerEvent = new UnityEvent(); val2.modules = null; val2.useSharedHandholdMaterial = false; val2.secure = true; val2.canHammer = false; val2.handholdColorType = real.handholdColorType; val2.dragMult = real.dragMult; val2.velocityMult = real.velocityMult; val2.climbMult = real.climbMult; val2.climbGrav = real.climbGrav; val2.strainRate = real.strainRate; val2.jumpMult = real.jumpMult; val2.jumpStrainMult = real.jumpStrainMult; val2.speedMult = real.speedMult; val2.hangVelAdjust = real.hangVelAdjust; val2.dropOnJump = real.dropOnJump; val2.allowAirbornJump = real.allowAirbornJump; portalHold.standIn = val2; portalHold.Follow(); val.SetActive(true); return portalHold; } private void Follow() { //IL_001d: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.SetPositionAndRotation(Through(entry, exit, ((Component)real).transform.position, hops), Turn(entry, exit, hops) * ((Component)real).transform.rotation); } private void FixedUpdate() { Tick(); } private void LateUpdate() { Tick(); } private void Tick() { if (!Valid) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Follow(); if (Time.time - born > 0.5f && !Held(standIn)) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private static bool Held(CL_Handhold hh) { ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player == (Object)null) { return false; } Hand[] hands = player.hands; foreach (Hand val in hands) { if (val.IsHanging() && (Object)(object)val.handhold == (Object)(object)hh) { return true; } } return false; } internal static List<Grip> Before(ENT_Player p) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) List<Grip> list = new List<Grip>(); Hand[] hands = p.hands; foreach (Hand val in hands) { if (val.IsHanging() && (Object)(object)val.handhold != (Object)null) { list.Add(new Grip { hand = val