Decompiled source of PortalGun v0.1.1
plugins/PortalGun.dll
Decompiled 2 days 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.Globalization; using System.IO; using System.Numerics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DarkMachine.AI; using DarkMachine.Collections; using HarmonyLib; using Microsoft.CodeAnalysis; using PortalGun.Core; using PortalGun.Game; using PortalGun.Game.Art; using PortalGun.Game.Audio; using PortalGun.Game.Items; using PortalGun.Game.Portals; using PortalGun.Game.UI; using PortalGun.Input; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Experimental.Rendering; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.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 { [BepInPlugin("com.perch.whiteknuckle.portalgun", "Portal Gun", "0.1.0")] public class Plugin : BaseUnityPlugin { private ConfigEntry<string> _probeKey; private ConfigEntry<bool> _enableProbe; private ConfigEntry<bool> _disableLeaderboards; private ConfigEntry<string> _donorItem; private ConfigEntry<float> _itemRange; private ConfigEntry<string> _giveKey; private ConfigEntry<bool> _enableGiveKey; private ConfigEntry<float> _sizeScale; private ConfigEntry<string> _placeBKey; private ConfigEntry<float> _maxAngleDeg; private ConfigEntry<float> _depthTolerance; private ConfigEntry<float> _nudgeFraction; private ConfigEntry<string> _clearPortalsKey; private ConfigEntry<bool> _indicatorEnabled; private ConfigEntry<bool> _transitEnabled; private ConfigEntry<bool> _transitWalkThrough; private ConfigEntry<bool> _transitDebugLog; private ConfigEntry<float> _transitCooldown; private ConfigEntry<float> _transitContactEpsilon; private ConfigEntry<float> _transitExitClearance; private ConfigEntry<bool> _renderEnabled; private ConfigEntry<float> _renderScale; private ConfigEntry<int> _renderGrid; private ConfigEntry<float> _renderClipOffset; private ConfigEntry<bool> _portalFx; private ConfigEntry<bool> _phase6Probe; private ConfigEntry<float> _floorSnap; private ConfigEntry<bool> _grabbableEdges; private IPortalInput _portalInput; private float _nextGuard; private float _nextRegister; private static Plugin _instance; private ConfigEntry<bool> _renderOblique; private ConfigEntry<float> _obliqueFarScale; private ConfigEntry<int> _recursionDepth; private ConfigEntry<RecursionFallback> _recursionFallback; public static ManualLogSource Log { get; private set; } public static float FloorSnap { get { if (!((Object)(object)_instance != (Object)null)) { return 0.5f; } return _instance._floorSnap.Value; } } public static bool GrabbableEdges { get { if (!((Object)(object)_instance == (Object)null)) { return _instance._grabbableEdges.Value; } return true; } } public static string DonorItem { get { if (!((Object)(object)_instance != (Object)null)) { return "Item_GrapplePiton"; } return _instance._donorItem.Value; } } public static float PortalScale { get { if (!((Object)(object)_instance != (Object)null)) { return 1f; } return _instance._sizeScale.Value; } } public static bool RenderEnabled { get { if (!((Object)(object)_instance == (Object)null)) { return _instance._renderEnabled.Value; } return true; } } public static float ResolutionScale { get { if (!((Object)(object)_instance != (Object)null)) { return 1f; } return _instance._renderScale.Value; } } public static int GridResolution { get { if (!((Object)(object)_instance != (Object)null)) { return 24; } return Mathf.Clamp(_instance._renderGrid.Value, 1, 128); } } public static bool PortalFxEnabled { get { if (!((Object)(object)_instance == (Object)null)) { return _instance._portalFx.Value; } return true; } } public static float ClipOffset { get { if (!((Object)(object)_instance != (Object)null)) { return -0.012f; } return _instance._renderClipOffset.Value; } } public static bool ObliqueClip { get { if (!((Object)(object)_instance == (Object)null)) { return _instance._renderOblique.Value; } return true; } } public static float ObliqueFarScale { get { if (!((Object)(object)_instance != (Object)null)) { return 10f; } return Mathf.Max(1f, _instance._obliqueFarScale.Value); } } public static int RecursionDepth { get { if (!((Object)(object)_instance != (Object)null)) { return 2; } return Mathf.Clamp(_instance._recursionDepth.Value, 1, 6); } } public static RecursionFallback RecursionFallbackMode { get { if (!((Object)(object)_instance != (Object)null)) { return RecursionFallback.Black; } return _instance._recursionFallback.Value; } } public static float ItemRange { get { if (!((Object)(object)_instance != (Object)null)) { return 100f; } return _instance._itemRange.Value; } } public static PlacementSettings BuildPlacementSettings() { PlacementSettings placementSettings = new PlacementSettings(); if ((Object)(object)_instance == (Object)null) { return placementSettings; } placementSettings.MaxAngleDeg = _instance._maxAngleDeg.Value; placementSettings.DepthTolerance = _instance._depthTolerance.Value; placementSettings.NudgeFraction = _instance._nudgeFraction.Value; return placementSettings; } private void Awake() { //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Expected O, but got Unknown //IL_16bb: Unknown result type (might be due to invalid IL or missing references) //IL_16c5: Expected O, but got Unknown //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Expected O, but got Unknown //IL_07b7: Unknown result type (might be due to invalid IL or missing references) //IL_07c6: Expected O, but got Unknown //IL_092a: Unknown result type (might be due to invalid IL or missing references) //IL_0939: Expected O, but got Unknown //IL_09c9: Unknown result type (might be due to invalid IL or missing references) //IL_09d8: Expected O, but got Unknown //IL_0c16: Unknown result type (might be due to invalid IL or missing references) //IL_0c25: Expected O, but got Unknown //IL_0f1c: Unknown result type (might be due to invalid IL or missing references) //IL_0f2b: Expected O, but got Unknown //IL_0f53: Unknown result type (might be due to invalid IL or missing references) //IL_0f62: Expected O, but got Unknown //IL_0f84: Unknown result type (might be due to invalid IL or missing references) //IL_0f93: Expected O, but got Unknown //IL_0fb5: Unknown result type (might be due to invalid IL or missing references) //IL_0fc4: Expected O, but got Unknown //IL_0fe6: Unknown result type (might be due to invalid IL or missing references) //IL_0ff5: Expected O, but got Unknown //IL_1267: Unknown result type (might be due to invalid IL or missing references) //IL_1276: Expected O, but got Unknown //IL_129e: Unknown result type (might be due to invalid IL or missing references) //IL_12ad: Expected O, but got Unknown //IL_12d5: Unknown result type (might be due to invalid IL or missing references) //IL_12e4: Expected O, but got Unknown //IL_130c: Unknown result type (might be due to invalid IL or missing references) //IL_131b: Expected O, but got Unknown //IL_1343: Unknown result type (might be due to invalid IL or missing references) //IL_1352: Expected O, but got Unknown //IL_137a: Unknown result type (might be due to invalid IL or missing references) //IL_1389: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _instance = this; Log.LogInfo((object)("Portal Gun 0.1.0 loading. Unity " + Application.unityVersion + ", game build " + Application.version)); _probeKey = ((BaseUnityPlugin)this).Config.Bind<string>("Debug", "ProbeKey", "F8", "Key that runs the recon probe and logs the result."); PortalTunnel.ConfiguredLayer = ((BaseUnityPlugin)this).Config.Bind<int>("Debug", "TunnelLayer", -1, "Physics layer for the invisible portal tunnel colliders (only the player collides with it). -1 = first unnamed layer from 8 to 31.").Value; PortalGunArt.BindConfig(((BaseUnityPlugin)this).Config); PortalShot.BindConfig(((BaseUnityPlugin)this).Config); PortalEffects.BindConfig(((BaseUnityPlugin)this).Config); PortalSfx.BindConfig(((BaseUnityPlugin)this).Config); PortalSfx.Load(); _enableProbe = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableProbe", true, "Enable the recon probe key."); _donorItem = ((BaseUnityPlugin)this).Config.Bind<string>("Item", "DonorItem", "Item_GrapplePiton", "Existing item whose prefabs are cloned for the portal gun"); _itemRange = ((BaseUnityPlugin)this).Config.Bind<float>("Item", "Range", 100f, "Maximum raycast range of the portal gun, in meters."); _giveKey = ((BaseUnityPlugin)this).Config.Bind<string>("Debug", "GiveKey", "F9", "Key that spawns a portal gun into the inventory."); _enableGiveKey = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableGiveKey", true, "Enable the give key."); _sizeScale = ((BaseUnityPlugin)this).Config.Bind<float>("Portal", "SizeScale", 1f, "Portal size multiplier (1 = Portal 2 proportions relative to the player)."); _placeBKey = ((BaseUnityPlugin)this).Config.Bind<string>("Portal", "PlaceBKey", "R", "Key that places portal B while holding the portal gun (fire places portal A)."); _maxAngleDeg = ((BaseUnityPlugin)this).Config.Bind<float>("Portal", "FlatAngleDeg", 2f, "Max angle between the surface normal at any sample and the portal normal, in degrees. Portals only go on flat surfaces."); _depthTolerance = ((BaseUnityPlugin)this).Config.Bind<float>("Portal", "FlatDepthTolerance", 0.02f, "Max gap or penetration of the surface at any sample, in meters."); _nudgeFraction = ((BaseUnityPlugin)this).Config.Bind<float>("Portal", "NudgeFraction", 1f, "How far a portal may slide to fit, as a fraction of its half size (1 keeps the aimed point inside the portal)."); _clearPortalsKey = ((BaseUnityPlugin)this).Config.Bind<string>("Debug", "ClearPortalsKey", "F10", "Key that closes both portals."); _indicatorEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Indicator", "Enabled", true, "Replace the held hand's interact icon with the portal indicator while holding the portal gun."); _transitEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Transit", "Enabled", true, "Move the player through the portals on contact. Disable to turn off all portal gameplay effects."); _transitWalkThrough = ((BaseUnityPlugin)this).Config.Bind<bool>("Transit", "WalkThrough", true, "Walk into portals: the player passes into the portal hole and is moved when their centre crosses the plane. Off = Phase 4 contact teleport."); PortalTransit.WalkThrough = _transitWalkThrough.Value; _transitWalkThrough.SettingChanged += delegate { PortalTransit.WalkThrough = _transitWalkThrough.Value; }; _transitCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Transit", "Cooldown", 0.15f, "Seconds after a transit before another is allowed."); _transitContactEpsilon = ((BaseUnityPlugin)this).Config.Bind<float>("Transit", "ContactEpsilon", 0.05f, "Gap in meters between the player capsule and the portal plane that still counts as contact."); _transitExitClearance = ((BaseUnityPlugin)this).Config.Bind<float>("Transit", "ExitClearance", 0.05f, "Extra distance in meters the player is placed in front of the exit portal."); _transitDebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Transit", "DebugLog", true, "Log transit near-misses (with contact info), at most twice a second."); PortalTransit.DebugLog = _transitDebugLog.Value; _transitDebugLog.SettingChanged += delegate { PortalTransit.DebugLog = _transitDebugLog.Value; }; ConfigEntry<bool> ff = ((BaseUnityPlugin)this).Config.Bind<bool>("Funnel", "FloorFunnel", true, "Portal 2 style: steer a falling player toward the centre of a floor portal."); ConfigEntry<float> fh = ((BaseUnityPlugin)this).Config.Bind<float>("Funnel", "FloorFunnelHeight", 2.44f, "Funnel only within this height (m) above the floor portal (Portal 2: 128 u)."); ConfigEntry<float> fg = ((BaseUnityPlugin)this).Config.Bind<float>("Funnel", "FloorFunnelGimmeDot", 0.9f, "Heading gate: dot(velocity direction, down into the portal) must be at least this."); ConfigEntry<float> fm = ((BaseUnityPlugin)this).Config.Bind<float>("Funnel", "FloorFunnelCaptureMargin", 0.6f, "Funnel only when the predicted landing point is within this margin (m) of the portal rectangle."); ConfigEntry<float> fa = ((BaseUnityPlugin)this).Config.Bind<float>("Funnel", "FloorFunnelMaxAccel", 15f, "Max sideways acceleration (m/s^2) of the floor funnel. Tuned by feel."); ConfigEntry<float> fs = ((BaseUnityPlugin)this).Config.Bind<float>("Funnel", "SnapThreshold", 0.19f, "Within this lateral distance (m) of a floor portal centre, snap to the centre (Portal 2: 10 u)."); ConfigEntry<bool> wl = ((BaseUnityPlugin)this).Config.Bind<bool>("Funnel", "WallLips", true, "Angled collision lips around wall portal holes so the player slides into the hole instead of catching on the frame."); ConfigEntry<float> wd = ((BaseUnityPlugin)this).Config.Bind<float>("Funnel", "WallLipDepth", 0.4f, "Depth (m) of the wall portal lips (45 degree ramps)."); ConfigEntry<bool> cx = ((BaseUnityPlugin)this).Config.Bind<bool>("Transit", "CameraCrossing", true, "Phase 6.3: transit on the frame the rendered camera crosses the portal plane (seamless view). Off = transit when the body centre crosses."); ConfigEntry<bool> ev = ((BaseUnityPlugin)this).Config.Bind<bool>("Transit", "EaseView", true, "Keep the roll and out-of-range pitch a portal pair gives the view and ease it upright (Portal 2 style). Off = snap upright."); ConfigEntry<float> er = ((BaseUnityPlugin)this).Config.Bind<float>("Transit", "EaseRate", 8f, "View easing: exponential return rate (1/s)."); ConfigEntry<float> em = ((BaseUnityPlugin)this).Config.Bind<float>("Transit", "EaseMinSpeed", 45f, "View easing: minimum return speed (deg/s), so it finishes."); ConfigEntry<bool> ws = ((BaseUnityPlugin)this).Config.Bind<bool>("Funnel", "WallSlide", false, "Scripted sideways slide into wall portals (older approach, for comparison with WallLips)."); ApplyFunnel(); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { ApplyFunnel(); }; PortalTransit.Enabled = _transitEnabled.Value; PortalTransit.Cooldown = _transitCooldown.Value; PortalTransit.ContactEpsilon = _transitContactEpsilon.Value; PortalTransit.ExitClearance = _transitExitClearance.Value; _transitEnabled.SettingChanged += delegate { PortalTransit.Enabled = _transitEnabled.Value; }; _transitCooldown.SettingChanged += delegate { PortalTransit.Cooldown = _transitCooldown.Value; }; _transitContactEpsilon.SettingChanged += delegate { PortalTransit.ContactEpsilon = _transitContactEpsilon.Value; }; _transitExitClearance.SettingChanged += delegate { PortalTransit.ExitClearance = _transitExitClearance.Value; }; try { PortalTransit.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg) { Log.LogError((object)$"PortalTransit install failed: {arg}"); } ConfigEntry<bool> keepGrip = ((BaseUnityPlugin)this).Config.Bind<bool>("Transit", "KeepGrip", true, "Keep handhold grips when passing through a portal."); PortalGrip.Enabled = keepGrip.Value; keepGrip.SettingChanged += delegate { PortalGrip.Enabled = keepGrip.Value; }; ConfigEntry<bool> pullClamp = ((BaseUnityPlugin)this).Config.Bind<bool>("Transit", "GripPullClamp", true, "Aim the hang pull at a point on the player's side of a portal when hanging through it (fixes shaking against the portal surface); also disables the grip return guard. Off = old guard behaviour."); PortalGrip.PullClamp = pullClamp.Value; pullClamp.SettingChanged += delegate { PortalGrip.PullClamp = pullClamp.Value; }; ConfigEntry<float> grs = ((BaseUnityPlugin)this).Config.Bind<float>("Transit", "GripReturnSpeed", 1f, "No longer used: while hanging through a portal every crossing straight back through the portal just exited is ignored (the hang pull settling); the guard disarms the moment the grip is released."); PortalGrip.ReturnSpeed = grs.Value; grs.SettingChanged += delegate { PortalGrip.ReturnSpeed = grs.Value; }; ((BaseUnityPlugin)this).Config.Bind<float>("Transit", "GripReturnWindow", 0.5f, "No longer used: the return guard now disarms immediately when the grip ends (kept for config compatibility)."); try { PortalGrip.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg2) { Log.LogError((object)$"PortalGrip install failed: {arg2}"); } ConfigEntry<bool> grabThrough = ((BaseUnityPlugin)this).Config.Bind<bool>("Transit", "GrabThrough", true, "Grab handholds seen through a portal within reach (reach is measured along the path through the portal). Needs KeepGrip."); PortalGrabThrough.Enabled = grabThrough.Value; grabThrough.SettingChanged += delegate { PortalGrabThrough.Enabled = grabThrough.Value; }; try { PortalGrabThrough.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg3) { Log.LogError((object)$"PortalGrabThrough install failed: {arg3}"); } ConfigEntry<bool> propsOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Props", "Enabled", true, "Move physics props through portals (6.8)."); PropTransit.Enabled = propsOn.Value; propsOn.SettingChanged += delegate { PropTransit.Enabled = propsOn.Value; }; ConfigEntry<bool> propsLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Props", "DebugLog", true, "Log prop tracking, tunnel enter/exit and prop transits."); PropTransit.DebugLog = propsLog.Value; propsLog.SettingChanged += delegate { PropTransit.DebugLog = propsLog.Value; }; PropTunnel.ConfiguredLayer = ((BaseUnityPlugin)this).Config.Bind<int>("Debug", "PropTunnelLayer", -1, "Physics layer for the invisible prop tunnel colliders (collide with everything except the player). -1 = next unnamed layer from 8 to 31 after the player tunnel layer. Read once at first use.").Value; ConfigEntry<bool> straddle = ((BaseUnityPlugin)this).Config.Bind<bool>("Props", "StraddleCopy", true, "Draw a copy of a prop on the other side while it straddles a portal"); PropClone.Enabled = straddle.Value; straddle.SettingChanged += delegate { PropClone.Enabled = straddle.Value; }; ConfigEntry<bool> entStraddle = ((BaseUnityPlugin)this).Config.Bind<bool>("Entities", "StraddleCopy", true, "Draw the part of a creature that is behind a portal at the other portal"); PropClone.EntitiesEnabled = entStraddle.Value; entStraddle.SettingChanged += delegate { PropClone.EntitiesEnabled = entStraddle.Value; }; try { PropTransit.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg4) { Log.LogError((object)$"PropTransit install failed: {arg4}"); } ConfigEntry<bool> holdThrough = ((BaseUnityPlugin)this).Config.Bind<bool>("Props", "HoldThrough", true, "Keep holding a prop when it and the player are on opposite sides of a portal; grab props through portals (6.9)"); PropHold.Enabled = holdThrough.Value; holdThrough.SettingChanged += delegate { PropHold.Enabled = holdThrough.Value; if (!holdThrough.Value) { PropHold.ReleaseAll("HoldThrough turned off"); } }; PropHold.DebugLog = propsLog.Value; propsLog.SettingChanged += delegate { PropHold.DebugLog = propsLog.Value; }; try { PropHold.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg5) { Log.LogError((object)$"PropHold install failed: {arg5}"); } ConfigEntry<bool> entOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Entities", "Enabled", true, "Move entities (roaches, bloodbugs, other non-prop game entities) through portals (6.11a)."); EntityTransit.Enabled = entOn.Value; entOn.SettingChanged += delegate { EntityTransit.Enabled = entOn.Value; if (!entOn.Value) { EntityTransit.ReleaseAll(); } }; ConfigEntry<bool> entHole = ((BaseUnityPlugin)this).Config.Bind<bool>("Entities", "HoleRaycasts", true, "Entity floor and wall raycasts pass through portal openings instead of hitting the wall behind them."); PortalHoleCast.Enabled = entHole.Value; entHole.SettingChanged += delegate { PortalHoleCast.Enabled = entHole.Value; }; PortalGunItemRegistry.ArtifactTag = ((BaseUnityPlugin)this).Config.Bind<bool>("Item", "ArtifactTag", true, "Give the portal gun the \"Artifact\" item tag (Phantom limb can hold it; kept through checkpoint respawns). Read at registration, so restart to apply.").Value; ConfigEntry<bool> decalProbe = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DecalProbe", false, "At each portal placement, log renderers overlapping the portal rect near the wall (finds decals drawing over the portal)."); DecalProbe.Enabled = decalProbe.Value; decalProbe.SettingChanged += delegate { DecalProbe.Enabled = decalProbe.Value; }; ConfigEntry<bool> entPerf = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EntityPerf", false, "Log a one-line per-second summary of entity-through-portal cost (ms per second and call counts per subsystem)."); EntityPerf.Enabled = entPerf.Value; entPerf.SettingChanged += delegate { EntityPerf.Enabled = entPerf.Value; }; ConfigEntry<bool> entLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Entities", "DebugLog", false, "Log each entity transit (name, type, portal ids)."); EntityTransit.DebugLog = entLog.Value; entLog.SettingChanged += delegate { EntityTransit.DebugLog = entLog.Value; }; ConfigEntry<bool> seeThrough = ((BaseUnityPlugin)this).Config.Bind<bool>("Entities", "SeeThroughPortals", true, "Creatures (denizens, fliers, navigators, bloodbugs, drones, turrets) see, acquire and chase the player through portals (6.11b). Does not apply to barnacles or always-aware chasers."); PortalSightPatch.Enabled = seeThrough.Value; seeThrough.SettingChanged += delegate { PortalSightPatch.Enabled = seeThrough.Value; if (!seeThrough.Value) { PortalSightPatch.ClearAll("SeeThroughPortals turned off"); } }; ConfigEntry<bool> roachFix = ((BaseUnityPlugin)this).Config.Bind<bool>("Entities", "RoachFallFix", true, "Cap roach fall speed so they cannot tunnel through floors, and stop the 10 m fall despawn from removing roaches that went through a portal."); EntityTransit.RoachFallFix = roachFix.Value; roachFix.SettingChanged += delegate { EntityTransit.RoachFallFix = roachFix.Value; }; try { EntityTransit.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg6) { Log.LogError((object)$"EntityTransit install failed: {arg6}"); } ConfigEntry<bool> projOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "ProjectilesThrough", true, "Projectiles (rebar, boomerang, homing, ...) fly through portals; returning ones steer toward the player through portals (6.12a). Grapple hooks are covered by GrapplesThrough."); ProjectileTransit.Enabled = projOn.Value; projOn.SettingChanged += delegate { ProjectileTransit.Enabled = projOn.Value; }; ConfigEntry<bool> projLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "DebugLog", false, "Log each projectile transit."); ProjectileTransit.DebugLog = projLog.Value; projLog.SettingChanged += delegate { ProjectileTransit.DebugLog = projLog.Value; }; PortalThroughCast.DebugLog = projLog.Value; projLog.SettingChanged += delegate { PortalThroughCast.DebugLog = projLog.Value; }; ConfigEntry<bool> hitOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "HitscanThrough", true, "Hitscan guns and turrets shoot through portals; turret tracers go into the portal on the turret's side (6.12b)."); PortalThroughCast.HitscanEnabled = hitOn.Value; hitOn.SettingChanged += delegate { PortalThroughCast.HitscanEnabled = hitOn.Value; }; ConfigEntry<bool> meleeOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "MeleeThrough", true, "Melee swings reach through portals (6.12b)."); PortalThroughCast.MeleeEnabled = meleeOn.Value; meleeOn.SettingChanged += delegate { PortalThroughCast.MeleeEnabled = meleeOn.Value; }; ConfigEntry<bool> grapOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "GrapplesThrough", true, "Grapple piton and grappling hook work through portals: hooks fly through, latch beyond a portal and pull the player toward the exit (6.12c)."); GrappleThrough.Enabled = grapOn.Value; grapOn.SettingChanged += delegate { GrappleThrough.Enabled = grapOn.Value; }; ConfigEntry<bool> cutOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "GrappleCutAtPortalEdge", true, "A grappling hook connected through a portal lets go when its rope no longer passes through a portal opening (6.12c)."); GrappleThrough.CutAtEdge = cutOn.Value; cutOn.SettingChanged += delegate { GrappleThrough.CutAtEdge = cutOn.Value; }; ConfigEntry<bool> aimImg = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "PitonAimImage", false, "Testing only: draw the piton aim icon at the image point (behind the portal wall) instead of the real hit."); PortalThroughCast.PitonAimImage = aimImg.Value; aimImg.SettingChanged += delegate { PortalThroughCast.PitonAimImage = aimImg.Value; }; ConfigEntry<bool> pitonOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "PitonsThrough", true, "Pitons can be placed (and strike) through portals (6.12c)."); PortalThroughCast.PitonEnabled = pitonOn.Value; pitonOn.SettingChanged += delegate { PortalThroughCast.PitonEnabled = pitonOn.Value; }; ConfigEntry<bool> trailsOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Render", "PortalTrails", true, "Draw projectile trails in portal views: layers drawn by another (non-hands, non-UI) camera are added to the portal cameras' culling mask."); PortalTrails.Enabled = trailsOn.Value; trailsOn.SettingChanged += delegate { PortalTrails.Enabled = trailsOn.Value; }; PortalTrails.DebugLog = projLog.Value; projLog.SettingChanged += delegate { PortalTrails.DebugLog = projLog.Value; }; try { ProjectileTransit.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg7) { Log.LogError((object)$"ProjectileTransit install failed: {arg7}"); } try { WeaponsThrough.Install(((BaseUnityPlugin)this).Config, new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg8) { Log.LogError((object)$"WeaponsThrough install failed: {arg8}"); } try { PortalThroughCast.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg9) { Log.LogError((object)$"PortalThroughCast install failed: {arg9}"); } try { GrappleThrough.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg10) { Log.LogError((object)$"GrappleThrough install failed: {arg10}"); } try { PortalCameraTransit.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg11) { Log.LogError((object)$"PortalCameraTransit install failed: {arg11}"); } ConfigEntry<bool> sndOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "Enabled", true, "Sounds near a portal are also heard coming out of the other portal (6.13): a mirror audio source at the mapped position."); PortalSound.Enabled = sndOn.Value; sndOn.SettingChanged += delegate { PortalSound.Enabled = sndOn.Value; }; ConfigEntry<float> sndReach = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "Reach", 25f, "A sound source is mirrored through a portal only when it is within this distance (m) of the portal."); PortalSound.Reach = sndReach.Value; sndReach.SettingChanged += delegate { PortalSound.Reach = sndReach.Value; }; ConfigEntry<int> sndMax = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "MaxProxies", 24, "Maximum number of mirror audio sources alive at once; further sounds are not mirrored. Applies to newly created proxies."); PortalSound.MaxProxies = sndMax.Value; sndMax.SettingChanged += delegate { PortalSound.MaxProxies = sndMax.Value; }; ConfigEntry<float> sndVol = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "VolumeScale", 1f, "Volume multiplier for sound heard through portals (the source's own volume is clamped to 1 after scaling)."); PortalSound.VolumeScale = sndVol.Value; sndVol.SettingChanged += delegate { PortalSound.VolumeScale = sndVol.Value; }; ConfigEntry<float> sndScan = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "ScanInterval", 0.25f, "Seconds between scans for looping and owned audio sources near a portal."); PortalSound.ScanInterval = sndScan.Value; sndScan.SettingChanged += delegate { PortalSound.ScanInterval = sndScan.Value; }; ConfigEntry<float> sndFull = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "FullScanInterval", 2f, "Seconds between full refreshes of the list of audio sources (the expensive scene search). New looping sources are noticed within this time; the cheap distance filter over the list runs every ScanInterval."); PortalSound.FullScanInterval = sndFull.Value; sndFull.SettingChanged += delegate { PortalSound.FullScanInterval = sndFull.Value; }; ConfigEntry<bool> sndHear = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "HearingThrough", true, "Creature hearing (noise events) also passes through portals, with the radius shortened by the distance to the portal."); PortalSound.HearingThrough = sndHear.Value; sndHear.SettingChanged += delegate { PortalSound.HearingThrough = sndHear.Value; }; ConfigEntry<bool> sndLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "DebugLog", false, "Log mirror start/stop (clip, source path, portal, distance) and the audio listener object."); PortalSound.DebugLog = sndLog.Value; sndLog.SettingChanged += delegate { PortalSound.DebugLog = sndLog.Value; }; try { PortalSound.Install(new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg12) { Log.LogError((object)$"PortalSound install failed: {arg12}"); } try { PortalTerminalThrough.Install(((BaseUnityPlugin)this).Config, new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg13) { Log.LogError((object)$"PortalTerminalThrough install failed: {arg13}"); } try { PlayerItemsThrough.Install(((BaseUnityPlugin)this).Config, new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg14) { Log.LogError((object)$"PlayerItemsThrough install failed: {arg14}"); } try { MovingSurfaces.Install(((BaseUnityPlugin)this).Config, new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg15) { Log.LogError((object)$"MovingSurfaces install failed: {arg15}"); } try { CraftCubeThrough.Install(((BaseUnityPlugin)this).Config, new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg16) { Log.LogError((object)$"CraftCubeThrough install failed: {arg16}"); } try { PortalLights.Install(((BaseUnityPlugin)this).Config, new Harmony("com.perch.whiteknuckle.portalgun"), Log); } catch (Exception arg17) { Log.LogError((object)$"PortalLights install failed: {arg17}"); } _renderEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Render", "Enabled", true, "See through portals (camera per portal rendered to a texture). false = flat colored portals."); ConfigEntry<bool> nb = ((BaseUnityPlugin)this).Config.Bind<bool>("Render", "NearBox", true, "Phase 6.4: shallow box behind the portal surface with the same image, so the camera's near plane never shows the wall when pressed against a portal."); ConfigEntry<float> nd = ((BaseUnityPlugin)this).Config.Bind<float>("Render", "NearBoxDepth", 0.3f, "Near box depth (m) behind the surface; must exceed the camera near-clip distance. Applies to newly placed portals."); ConfigEntry<float> nr = ((BaseUnityPlugin)this).Config.Bind<float>("Render", "NearBoxRange", 1f, "Show the near box while the camera is within this distance (m) of the portal."); ApplyNearBox(); ConfigEntry<bool> ss = ((BaseUnityPlugin)this).Config.Bind<bool>("Render", "ScreenShader", true, "Use the embedded screen-space portal shader (exact up close). false or missing bundle = per-vertex UVs. Applies to newly placed portals."); ConfigEntry<bool> sf = ((BaseUnityPlugin)this).Config.Bind<bool>("Render", "ScreenShaderFlipY", false, "Flip the portal image vertically in the screen-space shader (applied live)."); ApplyScreenShader(); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { ApplyScreenShader(); }; ((BaseUnityPlugin)this).Config.SettingChanged += delegate { ApplyNearBox(); }; ConfigEntry<PortalShape> vShape = ((BaseUnityPlugin)this).Config.Bind<PortalShape>("Visual", "Shape", PortalShape.Oval, "Portal shape: Oval (animated border, open/close animation) or Rectangle (the plain rim). Applies at the next placement. Collision, transit and placement stay rectangular either way."); ConfigEntry<float> vBw = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "BorderWidth", 0.06f, "Oval border width in meters. Applies at the next placement."); ConfigEntry<float> vGlow = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "BorderGlow", 2f, "Oval border brightness multiplier (above 1 is HDR, so the game's bloom picks it up). Applied live."); ConfigEntry<float> vWob = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "BorderWobble", 0.012f, "Oval border outer-edge wobble amplitude in meters. Applied live."); ConfigEntry<float> vOpen = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "OpenTime", 0.215f, "Oval portal open animation time in seconds (0 = off)."); ConfigEntry<float> vClose = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "CloseTime", 0.15f, "Oval portal close animation time in seconds (0 = off)."); ConfigEntry<int> vEdge = ((BaseUnityPlugin)this).Config.Bind<int>("Visual", "EdgeSegments", 8, "Oval floor/ceiling portals: number of straight grabbable segments in the chamfered ring around the oval (minimum 4; 8 = octagon). Applies at the next placement."); ApplyVisual(); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { ApplyVisual(); }; _renderScale = ((BaseUnityPlugin)this).Config.Bind<float>("Render", "ResolutionScale", 1f, "Portal render texture size relative to the screen (0.1 to 2)."); _renderGrid = ((BaseUnityPlugin)this).Config.Bind<int>("Render", "GridResolution", 24, "Portal surface tessellation (cells per side, 1 to 128). Higher is more exact under perspective; applies to newly placed portals."); _renderClipOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Render", "ClipOffset", -0.012f, "Oblique near plane offset in front of the exit portal, in meters. Negative values move the clip plane behind the exit surface so straddling props have no seam (wall surfaces there are back-facing to the portal camera and culled); must exceed the portal surface offset (0.01)."); _renderOblique = ((BaseUnityPlugin)this).Config.Bind<bool>("Render", "ObliqueNearClip", true, "true: clip everything behind the exit portal's surface with an oblique near plane (exact). false: plain near plane at the exit's nearest corner (leaves geometry behind the exit wall visible at an angle: black wedges, extra fog planes)."); _obliqueFarScale = ((BaseUnityPlugin)this).Config.Bind<float>("Render", "ObliqueFarScale", 10f, "Far plane multiplier used when building the oblique projection, so its tilted far plane does not cut into the view."); _portalFx = ((BaseUnityPlugin)this).Config.Bind<bool>("Render", "PortalFX", true, "Run the game's fog/FX and lamp-lighting setup for the portal cameras so the view through a portal matches the world. Costs extra frame time per visible portal."); _recursionDepth = ((BaseUnityPlugin)this).Config.Bind<int>("Render", "RecursionDepth", 2, new ConfigDescription("Phase 6.5: portals seen through portals. Number of cameras per portal chain (1 = no recursion, the portal is hidden in its own view; 2 = one level of recursion then the fallback). Levels whose inner portal is off-screen are skipped. Needs the screen shader.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 6), Array.Empty<object>())); _recursionFallback = ((BaseUnityPlugin)this).Config.Bind<RecursionFallback>("Render", "RecursionFallback", RecursionFallback.Black, "What the portal shows at the deepest recursion level: Black = solid black, LastFrame = its own image from the previous frame (smears when moving), Color = flat portal color."); _floorSnap = ((BaseUnityPlugin)this).Config.Bind<float>("Placement", "FloorSnap", 0.5f, "Wall portals within this distance (m) above a floor are moved down so their bottom edge sits on the floor. 0 = off."); _grabbableEdges = ((BaseUnityPlugin)this).Config.Bind<bool>("Portals", "GrabbableEdges", true, "Wall portals: the bottom edge can be grabbed. Floor and ceiling portals: all four edges."); _phase6Probe = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Phase6Probe", false, "Log Phase 6 probe data (prefix 'P6 probe:'): collider meshes, shader properties, camera target, frame times, contact offsets."); Phase6Probe.Enabled = _phase6Probe.Value; _phase6Probe.SettingChanged += delegate { Phase6Probe.Enabled = _phase6Probe.Value; }; PortalRenderer.Instance.Install(Log); PortalIndicator.EnabledProvider = () => _indicatorEnabled.Value; PortalIndicator.Subscribe(); _portalInput = new ConfigKeyPortalInput(() => _placeBKey.Value); _disableLeaderboards = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableLeaderboards", true, "Required while the mod is loaded; runs with the mod are not leaderboard-eligible."); if (_disableLeaderboards.Value) { LeaderboardGuard.Apply(Log); } void ApplyFunnel() { PortalCameraTransit.Enabled = cx.Value; PortalCameraTransit.EaseView = ev.Value; PortalCameraTransit.EaseRate = er.Value; PortalCameraTransit.EaseMinSpeed = em.Value; PortalTunnel.WallLips = wl.Value; PortalTunnel.WallLipDepth = wd.Value; PortalTransit.WallSlide = ws.Value; PortalTransit.FloorFunnel = ff.Value; PortalTransit.FloorFunnelHeight = fh.Value; PortalTransit.FloorFunnelGimmeDot = fg.Value; PortalTransit.FloorFunnelCaptureMargin = fm.Value; PortalTransit.FloorFunnelMaxAccel = fa.Value; PortalTransit.SnapThreshold = fs.Value; } void ApplyNearBox() { PortalView.NearBox = nb.Value; PortalView.NearBoxDepth = Mathf.Max(0.02f, nd.Value); PortalView.NearBoxRange = nr.Value; } void ApplyScreenShader() { PortalView.UseScreenShader = ss.Value; PortalView.ScreenShaderFlipY = sf.Value; } void ApplyVisual() { PortalView.EdgeSegments = Mathf.Max(4, vEdge.Value); PortalView.Oval = vShape.Value == PortalShape.Oval; PortalView.BorderWidth = Mathf.Max(0.005f, vBw.Value); PortalView.BorderGlow = Mathf.Max(0f, vGlow.Value); PortalView.BorderWobble = Mathf.Max(0f, vWob.Value); PortalView.OpenTime = Mathf.Max(0f, vOpen.Value); PortalView.CloseTime = Mathf.Max(0f, vClose.Value); } } private static bool PortalGunHeld() { ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null || playerObject.hands == null) { return false; } for (int i = 0; i < playerObject.hands.Length; i++) { if (playerObject.hands[i]?.inventoryHand?.currentItem?.prefabName == "Item_PortalGun") { return true; } } return false; } private void OnDestroy() { PortalTunnel.ReleaseAll(); PropTransit.ReleaseAll(); EntityTransit.ReleaseAll(); PropClone.Shutdown(); PortalSound.Shutdown(); PortalLights.Shutdown(); PortalRenderer.Instance.Uninstall(); } private void LateUpdate() { long t = EntityPerf.Begin(); try { EntityTransit.LateTick(); EntityPerf.Flush(Log); long t2 = EntityPerf.Begin(); try { PropClone.Draw(Log); } catch (Exception arg) { Log.LogError((object)$"PropClone failed: {arg}"); } EntityPerf.End(EntityPerf.Sys.PropDraw, t2); try { PortalSound.LateTick(); } catch (Exception arg2) { Log.LogError((object)$"PortalSound failed: {arg2}"); } try { PortalLights.LateTick(); } catch (Exception arg3) { Log.LogError((object)$"PortalLights failed: {arg3}"); } } finally { EntityPerf.End(EntityPerf.Sys.PluginLate, t); } } private void Update() { long t = EntityPerf.Begin(); try { UpdateInner(); } finally { EntityPerf.End(EntityPerf.Sys.PluginUpdate, t); } } private void UpdateInner() { //IL_00ec: 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) Phase6Probe.Update(Log); if (Time.unscaledTime >= _nextGuard) { _nextGuard = Time.unscaledTime + 1f; if (_disableLeaderboards.Value) { LeaderboardGuard.Apply(null); } } if (!PortalGunItemRegistry.Registered && Time.unscaledTime >= _nextRegister) { _nextRegister = Time.unscaledTime + 1f; PortalGunItemRegistry.TryRegister(Log); } if (_enableGiveKey.Value && KeyReader.WasPressedThisFrame(_giveKey.Value)) { PortalGunItemRegistry.TryGive(Log); } if (KeyReader.WasPressedThisFrame(_clearPortalsKey.Value)) { PortalManager.Clear(); } if (_portalInput.PlaceBPressed() && PortalGunHeld()) { Camera main = Camera.main; PortalGunArt.OnFire(PortalId.B); if (PortalShot.Enabled) { PortalShot.Fire(PortalId.B, null); } else if ((Object)(object)main != (Object)null) { try { PortalManager.TryPlace(PortalId.B, new Ray(((Component)main).transform.position, ((Component)main).transform.forward), Log); } catch (Exception arg) { Log.LogError((object)$"Portal B placement failed: {arg}"); } } } if (_enableProbe.Value && KeyReader.WasPressedThisFrame(_probeKey.Value)) { ReconProbe.Run(Log); } } } internal static class PluginInfo { public const string Guid = "com.perch.whiteknuckle.portalgun"; public const string Name = "Portal Gun"; public const string Version = "0.1.0"; } } namespace PortalGun.Input { internal interface IPortalInput { bool PlaceBPressed(); } internal sealed class ConfigKeyPortalInput : IPortalInput { private readonly Func<string> _keyName; public ConfigKeyPortalInput(Func<string> keyName) { _keyName = keyName; } public bool PlaceBPressed() { return KeyReader.WasPressedThisFrame(_keyName()); } } internal static class KeyReader { public static bool WasPressedThisFrame(string keyName) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) if (string.IsNullOrWhiteSpace(keyName)) { return false; } keyName = keyName.Trim(); try { Keyboard current = Keyboard.current; if (current != null && Enum.TryParse<Key>(keyName, ignoreCase: true, out Key result) && (int)result != 0) { return ((ButtonControl)current[result]).wasPressedThisFrame; } } catch (Exception) { } try { if (Enum.TryParse<KeyCode>(keyName, ignoreCase: true, out KeyCode result2)) { return Input.GetKeyDown(result2); } } catch (Exception) { } return false; } } } namespace PortalGun.Game { internal static class GameDebug { public static string Path(Transform t) { if ((Object)(object)t == (Object)null) { return "<null>"; } StringBuilder stringBuilder = new StringBuilder(((Object)t).name); Transform parent = t.parent; while ((Object)(object)parent != (Object)null) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } public static string MaskNames(int mask) { List<string> list = new List<string>(); for (int i = 0; i < 32; i++) { if ((mask & (1 << i)) != 0) { string text = LayerMask.LayerToName(i); list.Add(string.IsNullOrEmpty(text) ? i.ToString() : text); } } if (list.Count != 0) { return string.Join(",", list); } return "(none)"; } } internal static class LeaderboardGuard { public static void Apply(ManualLogSource log) { try { if (!WK_Leaderboard_Core.disableLeaderboards) { WK_Leaderboard_Core.disableLeaderboards = true; ManualLogSource obj = log ?? Plugin.Log; if (obj != null) { obj.LogInfo((object)"Leaderboards disabled (disableLeaderboards = true)."); } } } catch (Exception ex) { ManualLogSource obj2 = log ?? Plugin.Log; if (obj2 != null) { obj2.LogError((object)("LeaderboardGuard failed: " + ex)); } } } } public static class Phase6Probe { private const string P = "P6 probe: "; public static bool Enabled = true; public static long RunTicks; public static long FxTicks; public static long RenderTicks; public static int PortalRenders; private static ManualLogSource _log; private static bool _firstRenderDone; private static float _windowStart = -1f; private static int _frames; private static float _sumDt; private static float _maxDt; private static readonly Dictionary<int, List<string>> MeshLevels = new Dictionary<int, List<string>>(); private const int MaxContactLines = 10; private static int _contactLines; private static double Ms(long ticks) { return (double)ticks * 1000.0 / (double)Stopwatch.Frequency; } public static void OnPlaced(PortalId id, Collider host, string levelName, ManualLogSource log) { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) if (!Enabled || (Object)(object)host == (Object)null) { return; } try { MeshCollider val = (MeshCollider)(object)((host is MeshCollider) ? host : null); if ((Object)(object)val == (Object)null) { if (log != null) { log.LogInfo((object)string.Format("{0}placement {1}: host collider {2} is {3} (not a MeshCollider), layer {4}, level={5}", "P6 probe: ", id, ((Object)host).name, ((object)host).GetType().Name, LayerMask.LayerToName(((Component)host).gameObject.layer), levelName)); } return; } Mesh sharedMesh = val.sharedMesh; if ((Object)(object)sharedMesh == (Object)null) { if (log != null) { log.LogInfo((object)string.Format("{0}placement {1}: MeshCollider {2} has no sharedMesh, level={3}", "P6 probe: ", id, ((Object)host).name, levelName)); } return; } long num = 0L; int num2 = 0; bool flag = true; for (int i = 0; i < sharedMesh.subMeshCount; i++) { long num3 = sharedMesh.GetIndexCount(i); num += num3; if ((int)sharedMesh.GetTopology(i) == 0) { num2 += (int)(num3 / 3); } else { flag = false; } } int instanceID = ((Object)sharedMesh).GetInstanceID(); if (!MeshLevels.TryGetValue(instanceID, out var value)) { value = (MeshLevels[instanceID] = new List<string>()); } if (!value.Contains(levelName)) { value.Add(levelName); } string text = ((value.Count > 1) ? string.Format("SHARED across {0} levels [{1}]", value.Count, string.Join(", ", value)) : "seen in one level so far"); if (log != null) { string text2 = string.Format("{0}placement {1}: mesh '{2}' id={3} isReadable={4} verts={5} ", "P6 probe: ", id, ((Object)sharedMesh).name, instanceID, sharedMesh.isReadable, sharedMesh.vertexCount); string text3 = string.Format("tris={0}{1} indices={2} submeshes={3} ", num2, flag ? "" : " (+non-triangle submeshes)", num, sharedMesh.subMeshCount); object[] array = new object[5]; Bounds bounds = sharedMesh.bounds; array[0] = ((Bounds)(ref bounds)).size; array[1] = val.convex; array[2] = ((Object)host).name; array[3] = levelName; array[4] = text; log.LogInfo((object)(text2 + text3 + string.Format("boundsSize={0} convex={1} collider='{2}' level={3}; {4}", array))); } } catch (Exception ex) { if (log != null) { log.LogWarning((object)("P6 probe: OnPlaced failed: " + ex.GetType().Name + ": " + ex.Message)); } } } public static void OnFirstRender(Camera main, ManualLogSource log) { if (!Enabled || _firstRenderDone) { return; } _firstRenderDone = true; _log = log; try { LogShaders(log); } catch (Exception ex) { if (log != null) { log.LogWarning((object)("P6 probe: shader dump failed: " + ex.Message)); } } try { LogStencil(main, log); } catch (Exception ex2) { if (log != null) { log.LogWarning((object)("P6 probe: stencil probe failed: " + ex2.Message)); } } } private static void LogShaders(ManualLogSource log) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) string[] array = new string[5] { "UI/Default", "Particles/Standard Unlit", "Dark Machine/Effect/Projection", "Unlit/SHDR_OverlayFull", "Hidden/BlitCopy" }; foreach (string text in array) { Shader val = Shader.Find(text); if ((Object)(object)val == (Object)null) { if (log != null) { log.LogInfo((object)("P6 probe: shader '" + text + "': not found")); } continue; } StringBuilder stringBuilder = new StringBuilder(); int propertyCount = val.GetPropertyCount(); for (int j = 0; j < propertyCount; j++) { if (j > 0) { stringBuilder.Append(", "); } stringBuilder.Append(val.GetPropertyName(j)).Append(':').Append(val.GetPropertyType(j)); } if (log != null) { log.LogInfo((object)string.Format("{0}shader '{1}': supported={2} queue={3} props({4})=[{5}]", "P6 probe: ", text, val.isSupported, val.renderQueue, propertyCount, stringBuilder)); } } } private static void LogStencil(Camera main, ManualLogSource log) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_0138: 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_00bd: 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) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append($"main camera: path={main.actualRenderingPath} allowHDR={main.allowHDR} allowMSAA={main.allowMSAA} " + "targetTexture=" + (((Object)(object)main.targetTexture != (Object)null) ? ((Object)main.targetTexture).name : "none") + " " + $"depthTextureMode={main.depthTextureMode} clearFlags={main.clearFlags} qualityAA={QualitySettings.antiAliasing}"); try { RenderTexture targetTexture = main.targetTexture; if ((Object)(object)targetTexture != (Object)null) { stringBuilder.Append($" targetRT[depthStencilFormat={targetTexture.depthStencilFormat} graphicsFormat={targetTexture.graphicsFormat} depthBits={targetTexture.depth}]"); } } catch (Exception ex) { stringBuilder.Append(" targetRT[err " + ex.GetType().Name + "]"); } try { RenderTexture active = RenderTexture.active; stringBuilder.Append(((Object)(object)active != (Object)null) ? $" RenderTexture.active='{((Object)active).name}'[depthStencilFormat={active.depthStencilFormat} graphicsFormat={active.graphicsFormat}]" : " RenderTexture.active=null (back buffer; its stencil cannot be read from script)"); } catch (Exception ex2) { stringBuilder.Append(" RenderTexture.active[err " + ex2.GetType().Name + "]"); } try { stringBuilder.Append($" defaultDepthStencilFormat={SystemInfo.GetGraphicsFormat((DefaultFormat)2)} gfxApi={SystemInfo.graphicsDeviceType}"); } catch (Exception ex3) { stringBuilder.Append(" defaultDepthStencil[err " + ex3.GetType().Name + "]"); } Component[] components = ((Component)main).GetComponents<Component>(); List<string> list = new List<string>(); bool flag = false; Component[] array = components; foreach (Component val in array) { if (!((Object)(object)val == (Object)null)) { string name = ((object)val).GetType().Name; list.Add(name); if (name == "PostProcessLayer") { flag = true; } } } stringBuilder.Append(" PostProcessLayer=" + (flag ? "present" : "absent") + " components=[" + string.Join(", ", list) + "]"); if (log != null) { log.LogInfo((object)("P6 probe: " + stringBuilder)); } } public static void Update(ManualLogSource log) { if (!Enabled) { return; } _log = log; float unscaledTime = Time.unscaledTime; float unscaledDeltaTime = Time.unscaledDeltaTime; if (_windowStart < 0f) { _windowStart = unscaledTime; return; } _frames++; _sumDt += unscaledDeltaTime; if (unscaledDeltaTime > _maxDt) { _maxDt = unscaledDeltaTime; } if (!(unscaledTime - _windowStart < 5f)) { int num = Math.Max(1, _frames); double num2 = Ms(RunTicks) / (double)num; double num3 = Ms(FxTicks) / (double)num; double num4 = Ms(RenderTicks) / (double)num; int num5 = (PortalManager.IsActive(PortalId.A) ? 1 : 0) + (PortalManager.IsActive(PortalId.B) ? 1 : 0); if (log != null) { log.LogInfo((object)(string.Format("{0}frame window {1:F1}s frames={2} avg={3:F2}ms max={4:F2}ms ", "P6 probe: ", unscaledTime - _windowStart, _frames, _sumDt / (float)num * 1000f, _maxDt * 1000f) + $"portalsActive={num5} portalCamsPerFrame={(double)PortalRenders / (double)num:F2} " + $"portalPathPerFrame={num2:F3}ms (fxSetup={num3:F3}ms, Render()excludingFx={num4 - num3:F3}ms, Render()total={num4:F3}ms)")); } _windowStart = unscaledTime; _frames = 0; _sumDt = 0f; _maxDt = 0f; RunTicks = 0L; FxTicks = 0L; RenderTicks = 0L; PortalRenders = 0; } } public static void OnControllerHit(ControllerColliderHit hit) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) if (!Enabled || hit == null || _contactLines >= 10) { return; } try { ENT_Player playerObject = ENT_Player.playerObject; for (int i = 0; i < 2; i++) { PortalId portalId = ((i != 0) ? PortalId.B : PortalId.A); if (!PortalManager.TryGet(portalId, out var frame, out var size, out var _)) { continue; } Vector3 vector = hit.point.ToN() - frame.Position; float num = Vector3.Dot(vector, frame.Forward); float num2 = Vector3.Dot(vector, frame.Right); float num3 = Vector3.Dot(vector, frame.Up); if (!(Mathf.Abs(num) > 0.6f) && !(Mathf.Abs(num2) > size.Width * 0.5f + 0.6f) && !(Mathf.Abs(num3) > size.Height * 0.5f + 0.6f)) { Collider collider = hit.collider; string text = (((Object)(object)collider == (Object)null) ? "null" : (((Object)collider).name + "(" + ((object)collider).GetType().Name + ", layer " + LayerMask.LayerToName(((Component)collider).gameObject.layer) + ")")); string text2 = ""; if ((Object)(object)playerObject != (Object)null && (Object)(object)playerObject.cCon != (Object)null) { CharacterController cCon = playerObject.cCon; text2 = $" skinWidth={cCon.skinWidth:F3} radius={cCon.radius:F3} height={cCon.height:F3} center={cCon.center} lossyScale={((Component)playerObject).transform.lossyScale}"; } _contactLines++; ManualLogSource log = _log; if (log != null) { log.LogInfo((object)(string.Format("{0}contact {1}/{2} portal {3}: collider={4} planeDist={5:F3} (hit.point to portal plane, + = in front) ", "P6 probe: ", _contactLines, 10, portalId, text, num) + $"lateral=({num2:F2},{num3:F2}) normal={hit.normal}{text2}")); } break; } } } catch (Exception ex) { ManualLogSource log2 = _log; if (log2 != null) { log2.LogWarning((object)("P6 probe: contact probe failed: " + ex.GetType().Name + ": " + ex.Message)); } _contactLines = 10; } } public static void SetLog(ManualLogSource log) { _log = log; } } internal static class ReconProbe { public static void Run(ManualLogSource log) { log.LogInfo((object)"=== PortalGun probe ==="); Section(log, "versions", delegate { log.LogInfo((object)("Application.version=" + Application.version + " unity=" + Application.unityVersion)); }); Section(log, "layers", delegate { Layers(log); }); Section(log, "cameras", delegate { Cameras(log); }); Section(log, "player", delegate { Player(log); }); Section(log, "aim raycast", delegate { Aim(log); }); Section(log, "held items", delegate { Held(log); }); Section(log, "perks", delegate { Perks(log); }); log.LogInfo((object)"=== end probe ==="); } private static string J(List<string> l) { if (l != null) { return string.Join(",", l); } return "null"; } private static void Try(ManualLogSource log, string what, Action a) { try { a(); } catch (Exception ex) { log.LogError((object)("perks: '" + what + "' failed: " + ex.Message)); } } private static void DumpItem(ManualLogSource log, string label, Item_Object io) { if ((Object)(object)io == (Object)null) { log.LogInfo((object)("item[" + label + "]: prefab not found")); return; } Try(log, label + " itemData", delegate { Item itemData = io.itemData; log.LogInfo((object)((itemData == null) ? ("item[" + label + "]: itemData null") : ("item[" + label + "]: itemName=" + itemData.itemName + " prefabName=" + itemData.prefabName + " itemTags=" + J(itemData.itemTags)))); }); Try(log, label + " taggers", delegate { ObjectTagger[] componentsInChildren = ((Component)io).GetComponentsInChildren<ObjectTagger>(true); foreach (ObjectTagger val in componentsInChildren) { log.LogInfo((object)("item[" + label + "]: tagger " + GameDebug.Path(((Component)val).transform) + " tags=" + string.Join(",", val.tags ?? new List<string>()))); } }); } private static void Perks(ManualLogSource log) { ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player == (Object)null) { log.LogInfo((object)"perk: no player"); return; } List<string> wl = new List<string>(); Try(log, "perk list", delegate { if (player.perks == null) { log.LogInfo((object)"perk: perks null"); return; } log.LogInfo((object)$"perk: count={player.perks.Count}"); foreach (Perk p in player.perks) { if ((Object)(object)p == (Object)null) { log.LogInfo((object)"perk: <null>"); } else { Try(log, "perk " + p.title, delegate { log.LogInfo((object)$"perk: title={p.title} id={p.id} modules={p.modules?.Count ?? (-1)}"); if (p.modules == null) { return; } foreach (PerkModule module in p.modules) { if (module == null) { log.LogInfo((object)("perk[" + p.id + "]: module <null>")); } else { log.LogInfo((object)("perk[" + p.id + "]: module " + ((object)module).GetType().Name)); PerkModule_InteractionWhitelist val = (PerkModule_InteractionWhitelist)(object)((module is PerkModule_InteractionWhitelist) ? module : null); if (val != null) { log.LogInfo((object)$"perk[{p.id}]: whitelistmodule hands={val.hands} whitelist={J(val.whitelist)} blacklist={J(val.blacklist)} itemWhitelist={J(val.itemWhitelist)} itemBlacklist={J(val.itemBlacklist)}"); if (val.itemWhitelist != null) { wl.AddRange(val.itemWhitelist); } } } } }); } } }); Item_Object gun = null; Item_Object donor = null; Try(log, "gun prefab", delegate { gun = CL_AssetManager.GetItemObjectPrefab("Item_PortalGun", ""); DumpItem(log, "portalgun", gun); }); Try(log, "donor prefab", delegate { donor = CL_AssetManager.GetItemObjectPrefab(Plugin.DonorItem, ""); DumpItem(log, "donor " + Plugin.DonorItem, donor); }); Try(log, "hands", delegate { MethodInfo canHold = AccessTools.Method(typeof(Hand), "CanHoldItem", (Type[])null, (Type[])null); log.LogInfo((object)$"hand: CanHoldItem method found={canHold != null}"); for (int i = 0; i < player.hands.Length; i++) { Hand hand = player.hands[i]; int idx = i; if (hand == null) { log.LogInfo((object)$"hand {idx}: null"); } else { Try(log, "hand " + idx, delegate { Item val = hand.inventoryHand?.currentItem; log.LogInfo((object)((val == null) ? $"hand {idx}: empty" : $"hand {idx}: held itemName={val.itemName} prefabName={val.prefabName} itemTags={J(val.itemTags)}")); if (canHold != null) { if (val != null) { log.LogInfo((object)$"hand {idx}: CanHoldItem(held)={canHold.Invoke(hand, new object[1] { val })}"); } if ((Object)(object)gun != (Object)null) { log.LogInfo((object)$"hand {idx}: CanHoldItem(portalgun)={canHold.Invoke(hand, new object[1] { gun.itemData })}"); } } if ((Object)(object)gun != (Object)null && player.perks != null) { foreach (Perk perk in player.perks) { if ((Object)(object)perk != (Object)null) { log.LogInfo((object)$"hand {idx}: perk '{perk.title}' AllowItemInHand(portalgun)={perk.AllowItemInHand(gun.itemData, hand)}"); } } } }); } } }); Try(log, "live items", delegate { Inventory instance = Inventory.instance; if ((Object)(object)instance == (Object)null) { log.LogInfo((object)"item: no Inventory.instance"); } else { int num = 0; foreach (Item item in instance.GetItems(true, true, true)) { if (item != null && !(item.prefabName != "Item_PortalGun")) { num++; log.LogInfo((object)$"item: live portalgun sameAsPrefabData={(Object)(object)gun != (Object)null && item == gun.itemData} itemTags={J(item.itemTags)}"); } } log.LogInfo((object)$"item: live portalgun instances={num}"); } }); Try(log, "whitelist reference", delegate { if (wl.Count == 0) { log.LogInfo((object)"item: no perk itemWhitelist tags; skipping reference list"); } else if (!(AccessTools.Field(typeof(CL_AssetManager), "databases")?.GetValue(null) is List<WKDatabaseHolder> list)) { log.LogInfo((object)"item: databases not accessible"); } else { int num = 0; foreach (WKDatabaseHolder item2 in list) { if (item2?.database?.itemPrefabs != null) { foreach (GameObject itemPrefab in item2.database.itemPrefabs) { Item val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<Item_Object>() : null)?.itemData; if (val?.itemTags != null && val.itemTags.Exists((string t) => wl.Contains(t))) { if (num++ >= 30) { return; } log.LogInfo((object)("item: whitelisted-ref prefabName=" + val.prefabName + " tags=" + J(val.itemTags))); } } } } log.LogInfo((object)$"item: whitelisted-ref shown={num}"); } }); } private static void Section(ManualLogSource log, string name, Action a) { try { a(); } catch (Exception arg) { log.LogError((object)$"probe section '{name}' failed: {arg}"); } } private static string Mask(LayerMask m) { return $"{((LayerMask)(ref m)).value} [{GameDebug.MaskNames(((LayerMask)(ref m)).value)}]"; } private static void Layers(ManualLogSource log) { for (int i = 0; i < 32; i++) { string text = LayerMask.LayerToName(i); if (!string.IsNullOrEmpty(text)) { log.LogInfo((object)$"layer {i}: {text}"); } } } private static void Cameras(ManualLogSource log) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) HashSet<Camera> hashSet = new HashSet<Camera>(); List<Camera> list = new List<Camera>(Camera.allCameras); foreach (Camera item in list) { hashSet.Add(item); } Camera[] array = Resources.FindObjectsOfTypeAll<Camera>(); foreach (Camera val in array) { if ((Object)(object)val != (Object)null) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && hashSet.Add(val)) { list.Add(val); } } } ENT_Player playerObject = ENT_Player.playerObject; foreach (Camera item2 in list) { List<string> list2 = new List<string>(); if ((Object)(object)item2 == (Object)(object)Camera.main) { list2.Add("Camera.main"); } if ((Object)(object)playerObject != (Object)null) { if ((Object)(object)item2 == (Object)(object)playerObject.cam) { list2.Add("player.cam"); } if ((Object)(object)item2 == (Object)(object)playerObject.overlayCam) { list2.Add("player.overlayCam"); } if ((Object)(object)item2 == (Object)(object)playerObject.inventoryCam) { list2.Add("player.inventoryCam"); } } string text = (((Object)(object)item2.targetTexture != (Object)null) ? $"{((Object)item2.targetTexture).name} {((Texture)item2.targetTexture).width}x{((Texture)item2.targetTexture).height}" : "screen"); log.LogInfo((object)($"camera {GameDebug.Path(((Component)item2).transform)} enabled={((Behaviour)item2).enabled} activeInHierarchy={((Component)item2).gameObject.activeInHierarchy} depth={item2.depth} tag={((Component)item2).tag} " + $"cull={item2.cullingMask} [{GameDebug.MaskNames(item2.cullingMask)}] clear={item2.clearFlags} target={text} fov={item2.fieldOfView} " + string.Format("near={0} far={1} is=[{2}]", item2.nearClipPlane, item2.farClipPlane, string.Join(",", list2)))); } } private static void Player(ManualLogSource log) { //IL_0027: 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_0087: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player == (Object)null) { log.LogInfo((object)"player: null"); return; } log.LogInfo((object)$"player position={((Component)player).transform.position}"); CL_GameManager gMan = CL_GameManager.gMan; if ((Object)(object)gMan != (Object)null) { log.LogInfo((object)$"corrected height={gMan.GetPlayerCorrectedHeight()}"); } log.LogInfo((object)("interactMask=" + Mask(player.interactMask))); log.LogInfo((object)("inventoryItemMask=" + Mask(player.inventoryItemMask))); log.LogInfo((object)("jumpMask=" + Mask(player.jumpMask))); log.LogInfo((object)("parentMask=" + Mask(player.parentMask))); log.LogInfo((object)("stepMask=" + Mask(player.stepMask))); } private static void Aim(ManualLogSource log) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if ((Object)(object)main == (Object)null) { log.LogInfo((object)"aim: no Camera.main"); return; } Ray val = default(Ray); ((Ray)(ref val))..ctor(((Component)main).transform.position, ((Component)main).transform.forward); RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(val, ref val2, 50f, -1, (QueryTriggerInteraction)1)) { log.LogInfo((object)"aim: no hit within 50 m"); return; } Collider collider = ((RaycastHit)(ref val2)).collider; log.LogInfo((object)($"aim hit: {((Object)collider).name} path={GameDebug.Path(((Component)collider).transform)} layer={LayerMask.LayerToName(((Component)collider).gameObject.layer)}({((Component)collider).gameObject.layer}) " + $"normal={((RaycastHit)(ref val2)).normal} dist={((RaycastHit)(ref val2)).distance} colliderType={((object)collider).GetType().Name} rigidbody={(Object)(object)collider.attachedRigidbody != (Object)null}")); ObjectTagger[] componentsInParent = ((Component)collider).GetComponentsInParent<ObjectTagger>(); if (componentsInParent.Length == 0) { log.LogInfo((object)"tags: no ObjectTagger in parents"); } ObjectTagger[] array = componentsInParent; foreach (ObjectTagger val3 in array) { log.LogInfo((object)("tagger " + GameDebug.Path(((Component)val3).transform) + ": [" + string.Join(",", val3.tags) + "]")); } M_Level componentInParent = ((Component)collider).GetComponentInParent<M_Level>(); log.LogInfo((object)("host M_Level: " + (((Object)(object)componentInParent != (Object)null) ? ((Object)((Component)componentInParent).gameObject).name : "none"))); ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject != (Object)null) { RaycastHit val4 = default(RaycastHit); bool flag = Physics.Raycast(val, ref val4, 50f, LayerMask.op_Implicit(playerObject.jumpMask), (QueryTriggerInteraction)1); log.LogInfo((object)(flag ? $"jumpMask cast hit {((Object)((RaycastHit)(ref val4)).collider).name}, same collider={(Object)(object)((RaycastHit)(ref val4)).collider == (Object)(object)collider}" : "jumpMask cast: no hit")); } } private static void Held(ManualLogSource log) { ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null) { log.LogInfo((object)"held: no player"); return; } for (int i = 0; i < playerObject.hands.Length; i++) { Item val = playerObject.hands[i]?.inventoryHand?.currentItem; log.LogInfo((object)((val == null) ? $"hand {i}: empty" : $"hand {i}: prefabName={val.prefabName}")); } } } } namespace PortalGun.Game.UI { public static class PortalIndicator { [CompilerGenerated] private static class <>O { public static WillRenderCanvases <0>__OnWillRender; } private static readonly Color BlueColor = new Color(0.1f, 0.5f, 1f, 1f); private static readonly Color OrangeColor = new Color(1f, 0.5f, 0.1f, 1f); private const float OutlineAlpha = 0.45f; private const float CrosshairSize = 64f; private static Transform _root; private static GameObject _container; private static Image _left; private static Image _right; private static readonly HashSet<string> LoggedErrors = new HashSet<string>(); private static bool _subscribed; public static Func<bool> EnabledProvider = () => true; public static void Subscribe() { //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_0029: Expected O, but got Unknown if (!_subscribed) { _subscribed = true; object obj = <>O.<0>__OnWillRender; if (obj == null) { WillRenderCanvases val = OnWillRender; <>O.<0>__OnWillRender = val; obj = (object)val; } Canvas.willRenderCanvases += (WillRenderCanvases)obj; } } private static void LogOnce(string msg) { if (LoggedErrors.Add(msg)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("PortalIndicator: " + msg)); } } } private static void OnWillRender() { //IL_00a6: 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) try { CL_UIManager instance = CL_UIManager.instance; Transform val = (((Object)(object)instance != (Object)null && (Object)(object)instance.crosshairController != (Object)null) ? instance.crosshairController.crosshairRoot : null); if ((Object)(object)val == (Object)null) { Hide(); return; } if (!EnabledProvider() || !HoldingPortalGun()) { Hide(); return; } if ((Object)(object)_container == (Object)null || (Object)(object)_root != (Object)(object)val) { _container = null; Create(val); } if (!_container.activeSelf) { _container.SetActive(true); } Set(_left, left: true, PortalManager.IsActive(PortalId.A), PortalId.A, BlueColor); Set(_right, left: false, PortalManager.IsActive(PortalId.B), PortalId.B, OrangeColor); } catch (Exception ex) { LogOnce(ex.GetType().Name + ": " + ex.Message); } } private static bool HoldingPortalGun() { ENT_Player playerObject = ENT_Player.playerObject; if ((Object)(object)playerObject == (Object)null || playerObject.hands == null) { return false; } for (int i = 0; i < playerObject.hands.Length; i++) { Hand val = playerObject.hands[i]; if (val != null && val.inventoryHand?.currentItem?.prefabName == "Item_PortalGun") { return true; } } return false; } private static void Hide() { if ((Object)(object)_container != (Object)null && _container.activeSelf) { _container.SetActive(false); } } private static void Set(Image img, bool left, bool active, PortalId id, Color c) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) Sprite val = PortalIndicatorSprites.Get(left, active); if ((Object)(object)img.sprite != (Object)(object)val) { img.sprite = val; } c.a = (active ? 1f : 0.45f); c = PortalEffects.IndicatorTint(id, c); if (((Graphic)img).color != c) { ((Graphic)img).color = c; } } private static void Create(Transform root) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0030: 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_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_0046: 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_0051: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown GameObject val = new GameObject("PortalGun_Indicator", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(root, false); ((Transform)val2).localPosition = Vector3.zero; ((Transform)val2).localScale = Vector3.one * 64f; val2.sizeDelta = Vector2.one; ((Transform)val2).SetAsLastSibling(); _left = MakeSide(val.transform, "Left"); _right = MakeSide(val.transform, "Right"); _container = val; _root = root; } private static Image MakeSide(Transform parent, string name) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0051: 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_005c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(parent, false); ((Transform)val2).localPosition = Vector3.zero; ((Transform)val2).localScale = Vector3.one; val2.sizeDelta = Vector2.one; Image component = val.GetComponent<Image>(); ((Graphic)component).raycastTarget = false; component.preserveAspect = false; return component; } } public static class PortalIndicatorSprites { private static readonly Dictionary<int, Sprite> Cache = new Dictionary<int, Sprite>(); public static Sprite Get(bool left, bool filled) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //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) //IL_00a7: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00e3: 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) int key = (left ? 1 : 0) | (filled ? 2 : 0); if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } IndicatorRaster.SideAngles(left, out var startDeg, out var endDeg); int num = 128; float[] array = IndicatorRaster.Compose(filled, num, startDeg, endDeg); Color32[] array2 = (Color32[])(object)new Color32[num * num]; for (int i = 0; i < array2.Length; i++) { array2[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(array[i] * 255f)); } Texture2D val = new Texture2D(num, num, (TextureFormat)4, false) { name = "PortalGun_Indicator", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; val.SetPixels32(array2); val.Apply(false, true); value = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f); ((Object)value).name = ((Object)val).name; ((Object)value).hideFlags = (HideFlags)61; Cache[key] = value; return value; } } } namespace PortalGun.Game.Portals { internal static class CraftCubeThrough { private sealed class Entry { public GripMapping M; public GripMapping Inv; } public static bool Enabled = true; private static ManualLogSource _log; private static readonly Dictionary<GameEntity, Entry> Maps = new Dictionary<GameEntity, Entry>(); private static readonly Dictionary<GameEntity, GripMapping> Pending = new Dictionary<GameEntity, GripMapping>(); private static readonly List<GameEntity> VanillaEnts = new List<GameEntity>(); private static readonly List<RaycastHit> Extras = new List<RaycastHit>(); private static readonly List<GameEntity> Scratch = new List<GameEntity>(); private static FieldRef<HandItem_Crafter, List<GameEntity>> _picked; private static HandItem_Crafter _crafter; private static readonly List<HandItem_Crafter> Crafters = new List<HandItem_Crafter>(); private static int _castN; private static int _posN; private static int _velN; private static int _forceN; private static int _tossN; public static void Install(ConfigFile cfg, Harmony harmony, ManualLogSource log) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_00f8: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown _log = log; if (cfg != null) { Enabled = cfg.Bind<bool>("Items", "CraftCubeThrough", true, "The craft cube (amalgamator) picks up and holds items through portals.").Value; } if (!Enabled) { return; } try { _picked = AccessTools.FieldRefAccess<HandItem_Crafter, List<GameEntity>>("pickedupEntities"); MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(HandItem_Crafter), "Update", Type.EmptyTypes, (Type[])null); MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(HandItem_Crafter), "OnTryDrop", Type.EmptyTypes, (Type[])null); MethodInfo methodInfo3 = AccessTools.DeclaredMethod(typeof(HandItem_Crafter), "StopUse", Type.EmptyTypes, (Type[])null); if (_picked == null || methodInfo == null || methodInfo2 == null || methodInfo3 == null) { log.LogWarning((object)"CraftCubeThrough: HandItem_Crafter members not found; disabled"); return; } harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(CraftCubeThrough), "UpdatePrefix", (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(CraftCubeThrough), "UpdateTranspiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); log.LogInfo((object)$"CraftCubeThrough: patched Update: {_castN} SphereCastAll (expected 1), {_posN} entity position read(s) (expected 1), {_velN} linearVelocity set(s) (expected 1), {_forceN} SetForce call(s) (expected 1)"); if (_castN != 1 || _posN != 1 || _velN != 1 || _forceN != 1) { log.LogWarning((object)"CraftCubeThrough: an Update pattern count is off; held items may misbehave (turn Items/CraftCubeThrough off)"); } harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(CraftCubeThrough), "TossTranspiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); log.LogInfo((object)$"CraftCubeThrough: patched OnTryDrop: {_tossN} linearVelocity set(s) (expected 1)"); harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(CraftCubeThrough), "StopPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo4 = AccessTools.DeclaredMethod(typeof(PropHold), "OnPlayerTransit", (Type[])null, (Type[])null); if (methodInfo4 != null) { harmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(typeof(CraftCubeThrough), "PlayerTransitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { log.LogWarning((object)"CraftCubeThrough: PropHold.OnPlayerTransit not found; held items lose their mapping when the player transits"); } MethodInfo methodInfo5 = AccessTools.DeclaredMethod(typeof(PropHold), "OnPropTransit", (Type[])null, (Type[])null); if (methodInfo5 != null) { harmony.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, new HarmonyMethod(typeof(CraftCubeThrough), "PropTransitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { log.LogWarning((object)"CraftCubeThrough: PropHold.OnPropTransit not found; props transiting while held keep a stale mapping"); } MethodInfo methodInfo6 = AccessTools.DeclaredMethod(typeof(EntityTransit), "Transit", (Type[])null, (Type[])null); if (methodInfo6 != null) { harmony.Patch((MethodBase)methodInfo6, (HarmonyMethod)null, new HarmonyMethod(typeof(CraftCubeThrough), "EntityTransitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { log.LogWarning((object)"CraftCubeThrough: EntityTransit.Transit not found; non-prop entities transiting while held keep a stale mapping"); } } catch (Exception ex) { log.LogWarning((object)("CraftCubeThrough: install failed (" + ex.Message + ")")); } } private static void Set(GameEntity e, GripMapping m, string why) { if (m.IsIdentity()) { if (Maps.Remove(e) && PortalTransit.DebugLog) { ManualLogSource log = _log; if (log != null) { log.LogInfo((object)("CraftCubeThrough: " + ((Object)e).name + " mapping cleared (" + why + ")")); } } return; } Maps[e] = new Entry { M = m, Inv = m.Inverse() }; if (PortalTransit.DebugLog) { ManualLogSource log2 = _log; if (log2 != null) { log2.LogInfo((object)("CraftCubeThrough: " + ((Object)e).name + " mapping set (" + why + ")")); } } } private static bool IsHeld(GameEntity e) { if ((Object)(object)e == (Object)null || _picked == null) { return false; } for (int num = Crafters.Count - 1; num >= 0; num--) { HandItem_Crafter val = Crafters[num]; if ((Object)(object)val == (Object)null) { Crafters.RemoveAt(num); } else { List<GameEntity> list = _picked.Invoke(val); if (list != null && list.Contains(e)) { return true; } } } return false; } private static GripMapping CurrentMapping(GameEntity e) { if (!Maps.TryGetValue(e, out var value)) { return GripMapping.Identity; } return value.M; } private static void PlayerTransitPostfix(PortalTransform t) { Scratch.Clear(); foreach (GameEntity key in Maps.Keys) { Scratch.Add(key); } if (_picked != null) { for (int num = Crafters.Count - 1; num >= 0; num--) { HandItem_Crafter val = Crafters[num]; if ((Object)(object)val == (Object)null) { Crafters.RemoveAt(num); } else { List<GameEntity> list = _picked.Invoke(val); if (list != null) { foreach (GameEntity item in list) { if ((Object)(object)item != (Object)null && !Scratch.Contains(item)) { Scratch.Add(item); } } } } } } foreach (GameEntity item2 in Scratch) { if ((Object)(object)item2 != (Object)null) { Set(item2, CurrentMapping(item2).Then(t), "player transit"); } } } private static void PropTransitPostfix(CL_Prop prop, PortalFrame entry, PortalFrame exit) { EntityTransited((GameEntity)(object)prop, entry, exit); } private static void EntityTransitPostfix(EntityTransit.State s, PortalFrame entry, PortalFrame exit) { if (s != null) { EntityTransited(s.Ent, entry, exit); } } private static void EntityTransited(GameEntity e, PortalFrame entry, PortalFrame exit) { if (!((Object)(object)e == (Object)null) && Crafters.Count != 0) { bool flag = Maps.ContainsKey(e); if (flag || IsHeld(e)) { Set(e, CurrentMapping(e).After(new PortalTransform(exit, entry)), flag ? "entity transit" : "held item transited"); } } } private static void StopPostfix() { Maps.Clear(); Pending.Clear(); } public static void UpdatePrefix(HandItem_Crafter __instance) { _crafter = __instance; if (!Crafters.Contains(__instance)) { Crafters.Add(__instance); } if (Maps.Count == 0) { return; } List<GameEntity> list = _picked.Invoke(__instance); Scratch.Clear(); foreach (GameEntity key in Maps.Keys) { if ((Object)(object)key == (Object)null || !list.Contains(key)) { Scratch.Add(key); } } foreach (GameEntity item in Scratch) { Maps.Remove(item); } } public static RaycastHit[] CastAll(Vector3 origin, float radius, Vector3 direction, float maxDistance, int layerMask) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_000d: Unknown result type (might be due to invalid IL or missing references) return CastAllImpl(Physics.SphereCastAll(origin, radius, direction, maxDistance, layerMask), origin, radius, direction, maxDistance, layerMask); } public static RaycastHit[] CastAll(Vector3 origin, float radius, Vector3 direction, float maxDistance, int layerMask, QueryTriggerInteraction qti) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return CastAllImpl(Physics.SphereCastAll(origin, radius, direction, maxDistance, layerMask, qti), origin, radius, direction, maxDistance, layerMask); } private static RaycastHit[] CastAllImpl(RaycastHit[] vanilla, Vector3 origin, float radius, Vector3 direction, float maxDistance, int layerMask) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00c3: 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_0118: 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_018d: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: 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_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) Pending.Clear(); if (!Enabled) { return vanilla; } PortalPairCache.Refresh(); float magnitude = ((Vector3)(ref direction)).magnitude; if (!PortalPairCache.Both || magnitude < 1E-06f) { return vanilla; } List<GameEntity> list = (((Object)(object)_crafter != (Object)null && _picked != null) ? _picked.Invoke(_crafter) : null); VanillaEnts.Clear(); RaycastHit[] array = vanilla; for (int i = 0; i < array.Length; i++) { RaycastHit val = array[i]; if ((Object)(object)((RaycastHit)(ref val)).collider != (Object)null) { GameEntity componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<GameEntity>(); if ((Object)(object)componentInParent != (Object)null) { VanillaEnts.Add(componentInParent); } } } Extras.Clear(); Vector3 val2 = origin; Vector3 val3 = direction / magnitude; float num = maxDistance; float num2 = 0f; GripMapping gripMapping = GripMapping.Identity; for (int j = 0; j < 3; j++) { int num3 = -1; float num4 = 0f; for (int k = 0; k < 2; k++) { PortalFrame frame = ((k == 0) ? PortalPairCache.FrameA : PortalPairCache.FrameB); PortalSize size = ((k == 0) ? PortalPairCache.SizeA : PortalPairCache.SizeB); if (PortalRay.TryHitFront(val2.ToN(), val3.ToN(), num, frame, size, out var distance) && (num3 < 0 || distance < num4)) { num3 = k; num4 = distance; } } if (num3 < 0) { break; } PortalFrame entry = ((num3 == 0) ? PortalPairCache.FrameA : PortalPairCache.FrameB); PortalFrame exit = ((num3 == 0) ? PortalPairCache.FrameB : PortalPairCache.FrameA); PortalTransform t = new PortalTransform(entry, exit); Vector3 v = val2 + val3 * num4; Vector3 val4 = t.TransformDirection(val3.ToN()).ToU(); val3 = ((Vector3)(ref val4)).normalized; val2 = t.TransformPoint(v.ToN()).ToU() + val3 * 0.001f; num2 += num4 + 0.001f; num -= num4 + 0.001f; gripMapping = gripMapping.Then(t); if (num <= 0f) { break; } array = Physics.SphereCastAll(val2, radius, val3, num, layerMask); for (int i = 0; i < array.Length; i++) { RaycastHit val5 = array[i]; if (!((Object)(object)((RaycastHit)(ref val5)).collider == (Object)null) && !ProjectileTransit.Skippable(val5, radius)) { GameEntity componentInParent2 = ((Component)((RaycastHit)(ref val5)).collider).GetComponentInParent<GameEntity>(); if (!((Object)(object)componentInParent2 == (Object)null) && !VanillaEnts.Contains(componentInParent2) && !Pending.ContainsKey(componentInParent2) && (list == null || !list.Contains(componentInParent2))) { Pending[componentInParent2] = gripMapping.Inverse(); RaycastHit item = val5; ((RaycastHit)(ref item)).distance = ((RaycastHit)(ref item)).distance + num2; Extras.Add(item); } } } } if (Extras.Count == 0) { return vanilla; } RaycastHit[] array2 = (RaycastHit[])(object)new RaycastHit[vanilla.Length + Extras.Count]; vanilla.CopyTo(array2, 0); Extras.CopyTo(array2, vanilla.Length); return array2; } public static Vector3 SeenPosition(Component c) { //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_001d: 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_0085: 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_0072: Unknown result type (might be due to invalid IL or missing references) Vector3 position = c.transform.position; if (Enabled) { GameEntity val = (GameEntity)(object)((c is GameEntity) ? c : null); if (val != null) { if (!Maps.TryGetValue(val, out var value)) { if (Pending.Count == 0 || !Pending.TryGetValue(val, out var value2)) { return position; } Pending.Remove(val); Set(val, value2, "picked up through a portal"); if (!Maps.TryGetValue(val, out value)) { return position; } } return value.M.TransformPoint(position.ToN()).ToU(); } } return position; } private static Vector3 ToReal(GameEntity e, Vector3 v) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)e != (Object)null) || Maps.Count <= 0 || !Maps.TryGetValue(e, out var value)) { return v; } retur