using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("PortalRenderSpike")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PortalRenderSpike")] [assembly: AssemblyTitle("PortalRenderSpike")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PortalRenderSpike { [BepInPlugin("jonathan.portalrenderspike", "Portal Render Spike", "0.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private sealed class Traveller { public PortalLink Portal; public float PrevSideZ; public bool Armed; public Collider[] HoleCols = Array.Empty(); public readonly List IgnoredEnv = new List(); public float LastSwapTime; public int Parity; public GameObject? RenderClone; public bool RenderCloneFailed; public float HeldThroughGraceUntil; public bool VanishLogged; public bool WallOpened; public float PrevMaxDepen = -1f; public Rigidbody? Body; public bool HoleOpen; } private sealed class PortalLink { public Transform Quad; public Camera PortalCam; public RenderTexture Texture; public MeshRenderer ScreenRenderer; public Collider? Hit; public int RenderCount; public bool DebugInZone; public GameObject? Rim; public GameObject? RimCollider; public readonly List TrimColliders = new List(); public GameObject? SwirlOverlay; public Material? SwirlMat; public readonly List ClearedRenderers = new List(); } private enum PortalId { A, B } private static ManualLogSource Log = null; private const float WallSearchDistance = 10f; private const float InsetFromWall = 0.05f; private const float PortalWidth = 1.3f; private const float PortalHeight = 2.2f; private const float PortalSeparationDistance = 10f; private const float ActivationRadius = 3.5f; private const float ActivationHalfDepth = 1f; private const float TeleportCooldownSeconds = 1f; private const float ProximityTeleportDepth = 0.4f; private const float ItemProximityTeleportDepth = 1.4f; private const float ItemPortalYSlack = 1.2f; private const float ExitInsetDistance = 0.8f; private const float MinExitSpeed = 1f; private const float PortalCamFarPlane = 150f; private const float PlayerCenterHeightOffset = 1f; private const float PortalYSlack = 0.4f; private int _renderDownscale = 2; private bool _qualityAuto; private float _smoothFrameMs = 12f; private int _autoRenderSkip; private int _autoFrameCounter; private const float PortalViewFogDistance = 23f; private const float PortalFarMargin = 8f; private bool portalInterleave; private bool renderAToggle; private double lastPortalRenderMs; private bool portalMode; private bool holdingPortalGun; private bool _portalItemFixupDone; private int _fixupAttempts; private bool _gunDiagDone; private bool _devMode; private bool _cameraFallbackWarned; private PhysGrabObject? _activeGun; private bool _activeGunWasSet; private bool seamlessPlayer; private readonly Dictionary _openWallHoles = new Dictionary(); private bool seamlessItems; private readonly Dictionary _openItemHoles = new Dictionary(); private PortalLink? _heldItemStraddlePortal; private bool _heldItemPastPlane; private readonly Dictionary _travellers = new Dictionary(); private bool _travellerRework = true; private const float TravellerRegisterSlab = 1.6f; private const float TravellerDeregisterSlab = 2.2f; private const float TravellerCrossEps = 0.04f; private PortalLink? portalA; private PortalLink? portalB; private bool wasInFrontOfA; private bool wasInFrontOfB; private float teleportCooldownUntil; private readonly Dictionary itemTeleportCooldownUntil = new Dictionary(); private readonly Dictionary travellerIgnoreUntil = new Dictionary(); private GameObject? showcaseMarker; private Coroutine? selfWalkRoutine; private Light? flashlightProxyLight; private int flashlightProxySide; private float _lastAutoLogMs; private float _nextAutoQHeartbeatT; private float nextZoneDiagTime; internal static readonly Color PortalBlue = new Color(0.25f, 0.65f, 1f); internal static readonly Color PortalOrange = new Color(1f, 0.55f, 0.12f); private const float FlashlightThroughRange = 12f; private static FieldInfo? _grabbedPhysGrabObjectField; private static FieldInfo? _fPrevVel; private static FieldInfo? _fPrevVelRaw; private static FieldInfo? _fPrevPrevVelRaw; private static FieldInfo? _fPrevAngVel; private float _singletonCheckTimer; private PhysGrabObject? _knownGun; private int _gunFreefallSamples; private Vector3 _gunLastHeldPos; private bool _gunLastHeldPosValid; private const float ShowcasePortalADistance = 4f; private const float ShowcasePortalBExtraDistance = 8f; private const float PortalFireRange = 120f; private const float MaxPortalSurfaceNormalY = 0.35f; private bool multiplayerWarned; private NetworkedEvent? _fireEvent; private NetworkedEvent? _clearEvent; private const string MpMagic = "PGUN.v1"; private Coroutine? linkSelfTestRoutine; private static bool cameraDumpDone; private const float SelfWalkSpeed = 3f; private const float SelfWalkMaxSeconds = 3f; private static Texture2D? _swirlTex; private bool _loggedAvatarRenderers; private static Shader? _cachedShader; private static AssetBundle? _cachedBundle; private static bool _bundleLoadAttempted; private const string BundleFileName = "portalrenderspikebundle"; private const string PortalShaderAssetPath = "Assets/PortalRenderSpike/Shaders/Portal.shader"; private AssetBundle? _visualsBundle; private bool _visualsBundleTried; private GameObject? _viewmodel; private Camera? _viewmodelCam; private Animator? _viewmodelAnimator; private bool _forceViewmodel; private float _vmRecoil; private float _vmDrawT = 1f; private static readonly Vector3 VmBasePos = new Vector3(0.42f, -0.15f, 0.42f); private int _viewmodelLayer = -1; private Renderer[]? _hiddenWorldGunRenderers; private const string ViewmodelPrefabName = "PortalGunViewmodel"; private const string ViewmodelDrawClip = "v_portalgun_ARM|@draw"; private const string ViewmodelFireClip = "v_portalgun_ARM|@fire1"; private const string WorldModelPrefabName = "PortalGunWorldModel"; private readonly HashSet _reskinnedGuns = new HashSet(); private const float PortalSoundRelayRange = 12f; private float _sightRelayTimer; private const float SightRelayInterval = 0.25f; private const float PortalSightRange = 10f; private const float NearClipOffset = 0.05f; private const float NearClipLimit = 0.2f; private PhysGrabObject? _gtHover; private PortalLink? _gtExitPortal; private Vector3 _gtHoverHitOnEntry; private float _gtHoverTA; private float _gtHoverFarDist; private PhysGrabObject? _gtHeld; private float _gtDist; private float _gtDistRefreshUntil; private float _gtAimLostTimer; private FieldInfo? _physGrabberMaskField; private bool _gtTestMode; private bool _brightAmbient; private AmbientMode _savedAmbMode; private Color _savedAmbLight; private float _savedAmbIntensity; private Shader? _sliceShader; private bool _sliceShaderTried; private bool _travellerBeamHidden; private readonly List _travellerHiddenRends = new List(); private float _gripLogThrottle; private float _swapDiagThrottle; private int _gripGuardMisses; public static Plugin? Instance { get; private set; } private void Awake() { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; _devMode = ((BaseUnityPlugin)this).Config.Bind("Debug", "DevKeys", false, "Developer test keys (F3 spawn pair, J self-walk, Y spawn gun, ';' perf, '\\' seamless-player, ']' item-straddle, Mouse3/G + Mouse4/H direct-fire). OFF for normal play.").Value; string value = ((BaseUnityPlugin)this).Config.Bind("Visual", "PortalQuality", "Auto", "Portal render quality: Auto (degrades invisibly under load - default), High (full-res), Balanced, or Performance (lowest cost).").Value; string text = value.Trim().ToLowerInvariant(); _qualityAuto = text == "auto"; _renderDownscale = text switch { "high" => 1, "performance" => 3, "auto" => 2, _ => 2, }; Log.LogInfo((object)string.Format("[PortalRenderSpike] Portal quality = {0} (render downscale {1}x, auto-degrade {2}).", value, _renderDownscale, _qualityAuto ? "ON" : "off")); PortalSounds.LoadAll(Log); try { new Harmony("jonathan.portalrenderspike").PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)"[PortalRenderSpike] Harmony patches applied."); } catch (Exception ex) { Log.LogError((object)("[PortalRenderSpike] Harmony patch failed: " + ex.Message + " - level-change portal cleanup + perception-through-portals will be inactive this session.")); } try { _fireEvent = new NetworkedEvent("PortalGunFire", (Action)OnPortalFireEvent); _clearEvent = new NetworkedEvent("PortalGunClear", (Action)OnPortalClearEvent); Log.LogInfo((object)"[PortalRenderSpike] MP sync events registered (PortalGunFire / PortalGunClear)."); } catch (Exception ex2) { Log.LogWarning((object)("[PortalRenderSpike] MP sync event registration failed (" + ex2.Message + ") - portals will be single-player-local this session.")); } Log.LogInfo((object)"Portal Render Spike loaded. PORTAL GUN: Mouse4/G fires Portal A, Mouse5/H fires Portal B at the aimed wall (re-fire to move; pair links when both are placed)."); Log.LogInfo((object)"Debug harness: F3 = auto wall-mounted pair near the player; Shift+F3 = floating showcase pair centered in view (+ liveness marker cube); J = self-walk the player into Portal A (verification without WASD input)."); Log.LogInfo((object)"Note: F4-F12 are taken by other REPO_Mods test plugins tonight (PortalGun/src/Plugin.cs uses F5-F9) - this plugin uses F3/J plus the unbound Mouse4/Mouse5/G/H only (J confirmed vanilla-free in the decompile's KeyCode census)."); } private void Update() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) PruneDeadPortals(); EnsurePortalItemFixup(); UpdatePerceptionSight(); EnforceSingleton(); UpdateViewmodel(); UpdateGrabThroughPortal(); float num = Time.time * 0.12f; if ((Object)(object)portalA?.SwirlMat != (Object)null && (Object)(object)portalA.SwirlOverlay != (Object)null && portalA.SwirlOverlay.activeSelf) { portalA.SwirlMat.SetTextureOffset("_MainTex", new Vector2(num, 0f)); } if ((Object)(object)portalB?.SwirlMat != (Object)null && (Object)(object)portalB.SwirlOverlay != (Object)null && portalB.SwirlOverlay.activeSelf) { portalB.SwirlMat.SetTextureOffset("_MainTex", new Vector2(num, 0f)); } if (_devMode && Input.GetKeyDown((KeyCode)285)) { _forceViewmodel = !_forceViewmodel; Log.LogInfo((object)$"[PortalRenderSpike] DEV F4: force-viewmodel = {_forceViewmodel} (diagnostic - show the first-person gun without grabbing)."); } if (_devMode && Input.GetKeyDown((KeyCode)286)) { StartPlacementSelfTest(); } if (_devMode && Input.GetKeyDown((KeyCode)288)) { StartGrabThroughSelfTest(); } if (_devMode && Input.GetKeyDown((KeyCode)289)) { StartUnrippableSelfTest(); } if (_devMode && Input.GetKeyDown((KeyCode)110)) { StartMpAndApertureSelfTest(); } if (_devMode && Input.GetKeyDown((KeyCode)98)) { ToggleBrightAmbient(); } if (_devMode && Input.GetKeyDown((KeyCode)287)) { PortalGunItem portalGunItem = Object.FindObjectOfType(); if ((Object)(object)portalGunItem == (Object)null) { SpawnPortalGunItemForTesting(); Log.LogInfo((object)"[PortalRenderSpike] DEV F6: no gun present - spawned one; press F6 again to equip it."); } else { PhysGrabObject componentInParent = ((Component)portalGunItem).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { PhysGrabber instance = PhysGrabber.instance; if (instance != null) { instance.OverrideGrab(componentInParent, 1f, false); } _activeGun = componentInParent; portalMode = true; Log.LogInfo((object)"[PortalRenderSpike] DEV F6: force-equipped the gun in PORTAL MODE (scaffold - real viewmodel/orb/fire path)."); } } } if (_devMode && Input.GetKeyDown((KeyCode)284)) { if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { SpawnShowcasePair(); } else { SpawnOrRespawnPair(); } } if (_devMode && (Input.GetKeyDown((KeyCode)326) || Input.GetKeyDown((KeyCode)103))) { FirePortal(PortalId.A); } if (_devMode && (Input.GetKeyDown((KeyCode)327) || Input.GetKeyDown((KeyCode)104))) { FirePortal(PortalId.B); } PhysGrabObject val = LocalHeldPortalGun(); if ((Object)(object)val != (Object)null) { _activeGun = val; } if ((Object)(object)val != (Object)null && !_gunDiagDone) { _gunDiagDone = true; PhysGrabObjectImpactDetector componentInChildren = ((Component)val).GetComponentInChildren(); PhysGrabObject val2 = (((Object)(object)componentInChildren != (Object)null) ? ((Component)componentInChildren).GetComponent() : null); Log.LogInfo((object)$"[PortalRenderSpike] GUN-DIAG: impactDetector={(Object)(object)componentInChildren != (Object)null} pgoOnSameGO={(Object)(object)componentInChildren != (Object)null && (Object)(object)val2 != (Object)null} rootPGO={(Object)(object)val != (Object)null} LevelGenerator.Instance={(Object)(object)LevelGenerator.Instance != (Object)null}. Component layout:"); Component[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (Component val3 in componentsInChildren) { if ((Object)(object)val3 != (Object)null) { Log.LogInfo((object)("[PortalRenderSpike] GUN-DIAG " + ((Object)val3.gameObject).name + " :: " + ((object)val3).GetType().Name)); } } } if ((Object)(object)_activeGun == (Object)null || !Object.op_Implicit((Object)(object)_activeGun)) { if ((Object)(object)_activeGun != (Object)null || _activeGunWasSet) { Log.LogWarning((object)$"[PortalRenderSpike] GUN-LOSS: _activeGun object was DESTROYED (portalMode={portalMode}) - this is how the gun 'vanishes' in portal mode. Nothing in this mod destroys it, so it's REPO/another mod (impact, level teardown, or a network despawn)."); } _activeGun = null; } else if ((Object)(object)val == (Object)null) { PlayerController instance2 = PlayerController.instance; string text = null; if ((Object)(object)instance2 == (Object)null) { text = "no PlayerController"; } else if ((Object)(object)_activeGun.rb == (Object)null) { text = "gun.rb null"; } else if (!((Component)_activeGun).gameObject.activeInHierarchy) { text = "holstered (inventory deactivated it)"; } else if (Vector3.Distance(_activeGun.rb.position, ((Component)instance2).transform.position) > 3.5f) { text = $"dropped+walked-away ({Vector3.Distance(_activeGun.rb.position, ((Component)instance2).transform.position):F1}m, gun at {_activeGun.rb.position})"; } if (text != null) { if (portalMode) { Log.LogWarning((object)("[PortalRenderSpike] GUN-DROP (in PORTAL MODE!): force-hold lost the gun - reason: " + text + ". portalMode kept for re-draw; grab it again to restore.")); } _activeGun = null; } } _activeGunWasSet = (Object)(object)_activeGun != (Object)null; PhysGrabObject activeGun = _activeGun; holdingPortalGun = (Object)(object)activeGun != (Object)null; if ((Object)(object)activeGun != (Object)null) { if (Input.GetKeyDown((KeyCode)101)) { portalMode = !portalMode; Log.LogInfo((object)("[PortalRenderSpike] Portal Gun -> " + (portalMode ? "PORTAL MODE (LMB=blue A, RMB=orange B)" : "normal beam-held item") + ".")); } if (portalMode) { PhysGrabber instance3 = PhysGrabber.instance; if (instance3 != null) { instance3.OverrideGrab(activeGun, 0.3f, false); } PhysGrabber instance4 = PhysGrabber.instance; if (instance4 != null) { instance4.OverrideAlwaysGrabbable(0.5f); } activeGun.OverrideKnockOutOfGrabDisable(0.5f); GameObject val4 = PhysGrabber.instance?.physGrabBeam; if ((Object)(object)val4 != (Object)null) { Renderer[] componentsInChildren2 = val4.GetComponentsInChildren(); foreach (Renderer val5 in componentsInChildren2) { if (val5.enabled) { val5.enabled = false; } } } Transform val6 = PhysGrabber.instance?.physGrabPoint; if ((Object)(object)val6 != (Object)null) { Renderer[] componentsInChildren2 = ((Component)val6).GetComponentsInChildren(); foreach (Renderer val7 in componentsInChildren2) { if (val7.enabled) { val7.enabled = false; } } } if (Input.GetMouseButtonDown(0)) { FirePortal(PortalId.A); _vmRecoil = 1f; } if (Input.GetMouseButtonDown(1)) { FirePortal(PortalId.B); _vmRecoil = 1f; } if (Input.GetMouseButtonDown(2)) { DestroyStraddlers(); DestroyExistingPair(); BroadcastPortalClear(); Log.LogInfo((object)"[PortalRenderSpike] Portal Gun: cleared all placed portals (middle mouse)."); } } } if (_devMode && Input.GetKeyDown((KeyCode)106)) { StartSelfWalk(); } if (_devMode && Input.GetKeyDown((KeyCode)121)) { SpawnPortalGunItemForTesting(); } if (_devMode && Input.GetKeyDown((KeyCode)59)) { portalInterleave = !portalInterleave; Log.LogInfo((object)string.Format("[PortalRenderSpike] PERF: portal render interleave = {0}. Last single-render {1:F2}ms.", portalInterleave ? "ON (1 cam/frame)" : "OFF (both cams/frame)", lastPortalRenderMs)); } if (_devMode && Input.GetKeyDown((KeyCode)92)) { seamlessPlayer = !seamlessPlayer; if (!seamlessPlayer) { CloseAllPlayerHoles(PlayerController.instance); } Log.LogInfo((object)("[PortalRenderSpike] SEAMLESS player traversal = " + (seamlessPlayer ? "ON (walk-through hole + plane teleport)" : "OFF (discrete teleport)") + ".")); } if (_devMode && Input.GetKeyDown((KeyCode)93)) { _travellerRework = !_travellerRework; if (!_travellerRework) { ClearAllTravellers(); } Log.LogInfo((object)("[PortalRenderSpike] TRAVELLER REWORK (Stage A+B: per-object registry + crossing swap) = " + (_travellerRework ? "ON - free items cross cleanly with no juggle; HELD poke/pull still needs Stage C parity" : "OFF (legacy path)") + ".")); } if ((Object)(object)showcaseMarker != (Object)null) { showcaseMarker.transform.Rotate(20f * Time.deltaTime, 45f * Time.deltaTime, 0f); } if (portalA == null || portalB == null) { return; } UpdateAutoQuality(); Camera val8 = FindPlayerCamera(); _autoFrameCounter++; bool flag = _autoRenderSkip <= 0 || _autoFrameCounter % (_autoRenderSkip + 1) == 0; if (!((Object)(object)val8 != (Object)null && flag)) { return; } if (portalInterleave) { if (renderAToggle) { RenderPortalView(portalB, portalA, val8); } else { RenderPortalView(portalA, portalB, val8); } renderAToggle = !renderAToggle; } else { RenderPortalView(portalB, portalA, val8); RenderPortalView(portalA, portalB, val8); } } private void UpdateAutoQuality() { if (!_qualityAuto) { return; } _smoothFrameMs = Mathf.Lerp(_smoothFrameMs, Time.unscaledDeltaTime * 1000f, 0.05f); int autoRenderSkip = _autoRenderSkip; bool flag = portalInterleave; if (_smoothFrameMs > 22f) { portalInterleave = true; if (_smoothFrameMs > 30f) { _autoRenderSkip = Mathf.Min(2, _autoRenderSkip + 1); } } else if (_smoothFrameMs < 14f) { if (_autoRenderSkip > 0) { _autoRenderSkip--; } else { portalInterleave = false; } } if ((_autoRenderSkip != autoRenderSkip || portalInterleave != flag) && Mathf.Abs(_smoothFrameMs - _lastAutoLogMs) > 1f) { _lastAutoLogMs = _smoothFrameMs; Log.LogInfo((object)$"[PortalRenderSpike] AUTO-QUALITY: frame={_smoothFrameMs:F1}ms -> interleave={portalInterleave} renderSkip={_autoRenderSkip} (degrade under load / restore when it recovers)."); } if (_devMode && (portalA != null || portalB != null) && Time.unscaledTime > _nextAutoQHeartbeatT) { _nextAutoQHeartbeatT = Time.unscaledTime + 5f; Log.LogInfo((object)$"[AUTOQ-LIVE] real frame={_smoothFrameMs:F1}ms (raw {Time.unscaledDeltaTime * 1000f:F1}ms) -> tier: interleave={portalInterleave} renderSkip={_autoRenderSkip} (live sensor tick during real play)."); } } private void FixedUpdate() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (portalA == null || portalB == null) { return; } PlayerController instance = PlayerController.instance; if ((Object)(object)instance == (Object)null) { return; } if (_devMode && Time.time >= nextZoneDiagTime) { nextZoneDiagTime = Time.time + 1f; Vector3 playerCenter = ((Component)instance).transform.position + Vector3.up * 1f; LogZoneDiagnostic(portalA, playerCenter); LogZoneDiagnostic(portalB, playerCenter); Camera val = FindPlayerCamera(); if ((Object)(object)val != (Object)null) { GetCameraRenderPose(val, out var pos, out var rot); Log.LogInfo((object)$"[PortalRenderSpike] RENDER-HEART: A.renderCount={portalA.RenderCount} B.renderCount={portalB.RenderCount} playerViewPos={pos} playerViewFwd={rot * Vector3.forward} (from cameraToWorldMatrix)"); } } UpdatePlayerHole(instance); UpdateHeldItemStraddle(); if (Time.time >= teleportCooldownUntil && !CheckCrossingAndTeleport(portalA, portalB, ref wasInFrontOfA, instance)) { CheckCrossingAndTeleport(portalB, portalA, ref wasInFrontOfB, instance); } if (_travellerRework) { UpdateTravellers(); } else { CheckPhysGrabObjectPortals(); } List list = new List(); foreach (KeyValuePair item in travellerIgnoreUntil) { if (Time.time >= item.Value) { list.Add(item.Key); } } foreach (int item2 in list) { travellerIgnoreUntil.Remove(item2); } } private void LateUpdate() { UpdateFlashlightProxy(); RemapHeldItemPuller(); } private void OnGUI() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_0102: Unknown result type (might be due to invalid IL or missing references) if (portalMode && holdingPortalGun) { float num = (float)Screen.width * 0.5f; float num2 = (float)Screen.height * 0.5f; Color color = GUI.color; Texture2D whiteTexture = Texture2D.whiteTexture; GUI.color = Color.white; GUI.DrawTexture(new Rect(num - 1.5f, num2 - 1.5f, 3f, 3f), (Texture)(object)whiteTexture); GUI.color = PortalBlue; GUI.DrawTexture(new Rect(num - 14f, num2 - 1f, 9f, 2f), (Texture)(object)whiteTexture); GUI.DrawTexture(new Rect(num - 1f, num2 - 14f, 2f, 9f), (Texture)(object)whiteTexture); GUI.color = PortalOrange; GUI.DrawTexture(new Rect(num + 5f, num2 - 1f, 9f, 2f), (Texture)(object)whiteTexture); GUI.DrawTexture(new Rect(num - 1f, num2 + 5f, 2f, 9f), (Texture)(object)whiteTexture); GUI.color = color; } } private void UpdateFlashlightProxy() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b4: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: 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_0195: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) if (portalA == null || portalB == null) { DestroyFlashlightProxy(); return; } FlashlightController instance = FlashlightController.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.spotlight == (Object)null || !instance.LightActive || !((Behaviour)instance.spotlight).enabled) { DestroyFlashlightProxy(); return; } Light spotlight = instance.spotlight; Vector3 position = ((Component)spotlight).transform.position; Vector3 forward = ((Component)spotlight).transform.forward; float num = 0.2f; float slack = ((flashlightProxySide == 1) ? (num + 0.35f) : num); float slack2 = ((flashlightProxySide == 2) ? (num + 0.35f) : num); int num2 = 0; PortalLink portalLink = null; PortalLink portalLink2 = null; if (FlashlightThroughPortal(portalA, position, forward, slack)) { num2 = 1; portalLink = portalA; portalLink2 = portalB; } else if (FlashlightThroughPortal(portalB, position, forward, slack2)) { num2 = 2; portalLink = portalB; portalLink2 = portalA; } if (num2 == 0) { DestroyFlashlightProxy(); return; } Vector3 val = portalLink2.Quad.position + portalLink2.Quad.forward * 0.1f; Vector3 val2 = portalLink2.Quad.rotation * Quaternion.AngleAxis(180f, Vector3.up) * Quaternion.Inverse(portalLink.Quad.rotation) * forward; if ((Object)(object)flashlightProxyLight == (Object)null || flashlightProxySide != num2) { DestroyFlashlightProxy(); GameObject val3 = new GameObject("PortalRenderSpike_FlashlightProxy"); val3.transform.SetPositionAndRotation(val, Quaternion.LookRotation(val2, Vector3.up)); flashlightProxyLight = val3.AddComponent(); flashlightProxyLight.type = (LightType)0; flashlightProxySide = num2; } ((Component)flashlightProxyLight).transform.position = val; ((Component)flashlightProxyLight).transform.rotation = Quaternion.LookRotation(val2, Vector3.up); flashlightProxyLight.spotAngle = spotlight.spotAngle; flashlightProxyLight.range = spotlight.range; flashlightProxyLight.intensity = spotlight.intensity; flashlightProxyLight.color = spotlight.color; flashlightProxyLight.shadows = (LightShadows)0; flashlightProxyLight.shadowStrength = spotlight.shadowStrength; flashlightProxyLight.innerSpotAngle = spotlight.innerSpotAngle; flashlightProxyLight.cullingMask = spotlight.cullingMask; if ((Object)(object)spotlight.cookie != (Object)null) { flashlightProxyLight.cookie = spotlight.cookie; } } private bool FlashlightThroughPortal(PortalLink p, Vector3 srcPos, Vector3 srcFwd, float slack) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) Vector3 forward = p.Quad.forward; if (Vector3.Dot(srcPos - p.Quad.position, forward) <= 0f) { return false; } float num = Vector3.Dot(srcFwd, forward); if (num >= -0.0001f) { return false; } float num2 = Vector3.Dot(p.Quad.position - srcPos, forward) / num; if (num2 <= 0f || num2 > 12f) { return false; } Vector3 val = srcPos + srcFwd * num2 - p.Quad.position; float num3 = Vector3.Dot(val, p.Quad.right); float num4 = Vector3.Dot(val, p.Quad.up); if (Mathf.Abs(num3) < 0.65f + slack) { return Mathf.Abs(num4) < 1.1f + slack; } return false; } private void DestroyFlashlightProxy() { if ((Object)(object)flashlightProxyLight != (Object)null) { Object.Destroy((Object)(object)((Component)flashlightProxyLight).gameObject); flashlightProxyLight = null; } flashlightProxySide = 0; } private void LogZoneDiagnostic(PortalLink link, Vector3 playerCenter) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) Vector3 val = playerCenter - link.Quad.position; if (!(((Vector3)(ref val)).magnitude > 3.5f)) { float num = Vector3.Dot(val, link.Quad.forward); float num2 = Vector3.Dot(val, link.Quad.right); float num3 = Vector3.Dot(val, link.Quad.up); bool flag = Mathf.Abs(num2) < 0.65f && Mathf.Abs(num3) < 1.5f; Log.LogInfo((object)$"[PortalRenderSpike] ZONE-DIAG {((Object)link.Quad).name}: zDist={num:F2} xDist={num2:F2} yDist={num3:F2} withinRect={flag} (need |x|<{0.65f:F2} |y|<{1.5f:F2} 0() != (Object)null)) { return null; } return val; } private void MakeImpactContinuous(PhysGrabObject obj, Vector3 newVel, Vector3 newAngVel) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)obj == (Object)null) { return; } PhysGrabObjectImpactDetector component = ((Component)obj).GetComponent(); if (!((Object)(object)component == (Object)null)) { Type typeFromHandle = typeof(PhysGrabObjectImpactDetector); if ((object)_fPrevVel == null) { _fPrevVel = typeFromHandle.GetField("previousVelocity", BindingFlags.Instance | BindingFlags.NonPublic); } if ((object)_fPrevVelRaw == null) { _fPrevVelRaw = typeFromHandle.GetField("previousVelocityRaw", BindingFlags.Instance | BindingFlags.NonPublic); } if ((object)_fPrevPrevVelRaw == null) { _fPrevPrevVelRaw = typeFromHandle.GetField("previousPreviousVelocityRaw", BindingFlags.Instance | BindingFlags.NonPublic); } if ((object)_fPrevAngVel == null) { _fPrevAngVel = typeFromHandle.GetField("previousAngularVelocity", BindingFlags.Instance | BindingFlags.NonPublic); } float num = Mathf.Max(Time.fixedDeltaTime, 0.0001f); _fPrevVel?.SetValue(component, newVel / num); _fPrevAngVel?.SetValue(component, newAngVel / num); _fPrevVelRaw?.SetValue(component, newVel); _fPrevPrevVelRaw?.SetValue(component, newVel); } } private void EnsurePortalItemFixup() { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) if (_portalItemFixupDone) { return; } _fixupAttempts++; if (_fixupAttempts % 30 != 0) { return; } IReadOnlyList registeredItems = Items.RegisteredItems; if (registeredItems == null) { return; } foreach (Item item in registeredItems) { if ((Object)(object)item != (Object)null && item.itemName == "Portal Gun") { if ((Object)(object)item.itemNameLocalized != (Object)null) { item.itemNameLocalized = null; Log.LogInfo((object)"[PortalRenderSpike] FIXUP: nulled Portal Gun item.itemNameLocalized - it was throwing 'Empty Table Reference' every frame the gun was visible. Name falls back to 'Portal Gun'."); } if ((Object)(object)item.value == (Object)null || item.value.valueMin != 15000f || item.value.valueMax != 20000f) { Value val = ScriptableObject.CreateInstance(); val.valueMin = 15000f; val.valueMax = 20000f; item.value = val; } item.itemType = (itemType)13; item.itemSecretShopType = (itemSecretShopType)0; item.itemVolume = (itemVolume)1; item.maxAmountInShop = 1; item.maxAmount = 1; item.disabled = false; bool flag = (Object)(object)StatsManager.instance != (Object)null && StatsManager.instance.itemDictionary != null && StatsManager.instance.itemDictionary.ContainsValue(item); Log.LogInfo((object)$"[PortalRenderSpike] SHOP-FIXUP: Portal Gun priced {item.value.valueMin:F0}-{item.value.valueMax:F0}, itemType={item.itemType}, itemVolume={item.itemVolume}, maxAmountInShop={item.maxAmountInShop}, inStatsItemDictionary={flag} (needs true to appear in the shop)."); _portalItemFixupDone = true; break; } } } private void EnforceSingleton() { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } _singletonCheckTimer -= Time.deltaTime; if (_singletonCheckTimer > 0f) { return; } _singletonCheckTimer = 0.4f; PortalGunItem[] array = Object.FindObjectsOfType(); List list = new List(); PortalGunItem[] array2 = array; foreach (PortalGunItem portalGunItem in array2) { if (!((Object)(object)portalGunItem == (Object)null)) { PhysGrabObject componentInParent = ((Component)portalGunItem).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && !list.Contains(componentInParent)) { list.Add(componentInParent); } } } foreach (PhysGrabObject item in list) { if ((Object)(object)item == (Object)null) { continue; } PhysGrabObjectImpactDetector[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (PhysGrabObjectImpactDetector val in componentsInChildren) { if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled) { ((Behaviour)val).enabled = false; Log.LogInfo((object)("[PortalRenderSpike] Disabled impact detector on '" + ((Object)((Component)val).gameObject).name + "' (NullRef-spam).")); } } ReskinWorldGun(item); if (item.playerGrabbing != null && item.playerGrabbing.Count > 0) { item.OverrideKnockOutOfGrabDisable(0.6f); } } if (list.Count >= 1) { RecoverLostGun(list[0]); } if (list.Count <= 1) { if (list.Count == 1) { _knownGun = list[0]; } return; } PhysGrabObject val2 = (_knownGun = (PhysGrabObject?)(((Object)(object)_knownGun != (Object)null && list.Contains(_knownGun)) ? ((object)_knownGun) : ((object)list[0]))); foreach (PhysGrabObject item2 in list) { if (!((Object)(object)item2 == (Object)(object)val2) && !((Object)(object)item2 == (Object)null)) { Log.LogWarning((object)("[PortalRenderSpike] SINGLETON GUARD: a second Portal Gun exists - despawning the extra '" + ((Object)item2).name + "' (one per run).")); PhysGrabObjectImpactDetector component = ((Component)item2).GetComponent(); if ((Object)(object)component != (Object)null) { component.DestroyObject(false); } else { Object.Destroy((Object)(object)((Component)item2).gameObject); } } } } private void RecoverLostGun(PhysGrabObject gun) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gun == (Object)null || (Object)(object)gun.rb == (Object)null) { return; } if (gun.playerGrabbing != null && gun.playerGrabbing.Count > 0) { _gunLastHeldPos = ((Component)gun.playerGrabbing[0]).transform.position + Vector3.up * 0.5f; _gunLastHeldPosValid = true; _gunFreefallSamples = 0; } else if (gun.rb.velocity.y < -15f) { _gunFreefallSamples++; if (_gunFreefallSamples >= 4) { _gunFreefallSamples = 0; Vector3 val = (_gunLastHeldPosValid ? _gunLastHeldPos : (((Object)(object)PlayerController.instance != (Object)null) ? (((Component)PlayerController.instance).transform.position + Vector3.up * 0.5f) : gun.rb.position)); gun.Teleport(val, Quaternion.identity); gun.rb.velocity = Vector3.zero; gun.rb.angularVelocity = Vector3.zero; Log.LogWarning((object)"[PortalRenderSpike] Gun-loss safety: the Portal Gun was free-falling through the world - recovered it to its last in-bounds position (a glitch-loss, not an intentional drop)."); } } else { _gunFreefallSamples = 0; } } private void SpawnPortalGunItemForTesting() { //IL_0167: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) PlayerController instance = PlayerController.instance; if ((Object)(object)instance == (Object)null) { Log.LogWarning((object)"[PortalRenderSpike] Spawn Portal Gun item: PlayerController.instance is null (not in a run yet?)."); return; } Item val = null; foreach (Item registeredItem in Items.RegisteredItems) { if ((Object)(object)registeredItem != (Object)null && registeredItem.itemName == "Portal Gun") { val = registeredItem; break; } } if ((Object)(object)val == (Object)null) { Log.LogWarning((object)$"[PortalRenderSpike] Spawn Portal Gun item: 'Portal Gun' not found in REPOLib.RegisteredItems (count={Items.RegisteredItems.Count}) - is jonathan-PortalGun/PortalGun.repobundle installed and loaded by REPOLib?"); return; } Camera val2 = FindPlayerCamera(); Vector3 val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).transform.forward : ((Component)instance).transform.forward); Vector3 val4 = ((Component)instance).transform.position + val3 * 1.5f + Vector3.up * 0.6f; GameObject val5 = Items.SpawnItem(val, val4, Quaternion.identity); try { StatsManager instance2 = StatsManager.instance; if (instance2 != null) { instance2.ItemPurchase(((Object)val).name); } Log.LogInfo((object)("[PortalRenderSpike] Registered '" + ((Object)val).name + "' as purchased so it persists across levels (dev-spawn persistence).")); } catch (Exception ex) { Log.LogWarning((object)("[PortalRenderSpike] ItemPurchase register failed: " + ex.Message)); } Log.LogInfo((object)$"[PortalRenderSpike] Spawned Portal Gun item at {val4} (result null={(Object)(object)val5 == (Object)null}). Grab it and press E to place Portal A, E again for Portal B."); } private void SpawnOrRespawnPair() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_030a: 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_01a2: Unknown result type (might be due to invalid IL or missing references) DestroyExistingPair(); PlayerController instance = PlayerController.instance; if ((Object)(object)instance == (Object)null) { Log.LogWarning((object)"F3 pressed but PlayerController.instance is null (not in a run yet?)."); return; } if ((Object)(object)FindPlayerCamera() == (Object)null) { Log.LogWarning((object)"F3: could not find any Camera to use as the player camera (Camera.main and controller.cameraGameObject both failed) - aborting portal spawn."); return; } Vector3 val = ((Component)instance).transform.position + Vector3.up * 0.5f; if (!FindNearestWall(val, ((Component)instance).transform, out var hit)) { Log.LogWarning((object)$"F3: no wall found within {10f}m in forward/right/left/back directions (F7's search pattern) - move closer to a wall and retry."); return; } Vector3 val2 = Vector3.Cross(Vector3.up, ((RaycastHit)(ref hit)).normal); Vector3 val3 = ((Vector3)(ref val2)).normalized; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = ((Component)instance).transform.right; } Vector3 val4 = ((RaycastHit)(ref hit)).point + val3 * 10f + ((RaycastHit)(ref hit)).normal * 1f; RaycastHit hit2 = default(RaycastHit); bool flag = Physics.Raycast(val4, -((RaycastHit)(ref hit)).normal, ref hit2, 10f); string text = "same-wall tangent offset (10m)"; if (!flag) { flag = FindNearestWall(val4, ((Component)instance).transform, out hit2); text = "general 4-direction search from tangent-offset point"; } if (!flag) { flag = Physics.Raycast(val, -((Component)instance).transform.forward, ref hit2, 10f); text = "opposite-wall fallback from player position"; } if (!flag) { Log.LogWarning((object)"F3: found a wall for Portal A but could not find a second wall for Portal B by any strategy (same-wall offset, general search, or opposite wall) - aborting spawn. Try a bigger room."); return; } if (Vector3.Distance(((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit2)).point) < 1.3f) { Log.LogWarning((object)$"F3: Portal A and B candidate points are only {Vector3.Distance(((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit2)).point):F2}m apart (< portal width {1.3f}m) - room too small for this spike's fixed geometry, aborting."); return; } portalA = CreatePortal("PortalRenderSpike_A", hit); portalB = CreatePortal("PortalRenderSpike_B", hit2); wasInFrontOfA = Vector3.Dot(((Component)instance).transform.position - portalA.Quad.position, portalA.Quad.forward) > 0f; wasInFrontOfB = Vector3.Dot(((Component)instance).transform.position - portalB.Quad.position, portalB.Quad.forward) > 0f; teleportCooldownUntil = 0f; UpdatePortalActivationVisuals(); ArmLinkSelfTest(); Log.LogInfo((object)$"[PortalRenderSpike] Spawned pair. A pos={((RaycastHit)(ref hit)).point} normal={((RaycastHit)(ref hit)).normal} wall='{((Object)((Component)((RaycastHit)(ref hit)).collider).gameObject).name}'; B pos={((RaycastHit)(ref hit2)).point} normal={((RaycastHit)(ref hit2)).normal} wall='{((Object)((Component)((RaycastHit)(ref hit2)).collider).gameObject).name}' via strategy='{text}'; separation={Vector3.Distance(((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit2)).point):F2}m."); Log.LogInfo((object)"[PortalRenderSpike] Walk into either portal quad to teleport out the other. Press F3 again to despawn and respawn a fresh pair at your current location."); } private void SpawnShowcasePair() { //IL_004b: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_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_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: 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_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) DestroyExistingPair(); PlayerController instance = PlayerController.instance; if ((Object)(object)instance == (Object)null) { Log.LogWarning((object)"Shift+F3 pressed but PlayerController.instance is null (not in a run yet?)."); return; } Camera val = FindPlayerCamera(); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"Shift+F3: could not find any Camera to use as the player camera - aborting showcase spawn."); return; } Vector3 position = ((Component)val).transform.position; Vector3 forward = ((Component)val).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { forward = ((Component)instance).transform.forward; forward.y = 0f; } ((Vector3)(ref forward)).Normalize(); Quaternion val2 = Quaternion.LookRotation(-forward, Vector3.up); Vector3 val3 = position + forward * 4f; RaycastHit val4 = default(RaycastHit); float num = (Physics.Raycast(val3, forward, ref val4, 8f) ? (((RaycastHit)(ref val4)).distance - 1f) : 8f); Vector3 val5; Quaternion val6; if (num >= 4f) { val5 = val3 + forward * num; val6 = val2; if (num < 8f) { Log.LogInfo((object)$"[PortalRenderSpike] SHOWCASE: B clamped to {num:F1}m past A (wall '{((Object)((Component)((RaycastHit)(ref val4)).collider).gameObject).name}' at {((RaycastHit)(ref val4)).distance:F1}m on the A->B axis) instead of the default {8f:F0}m."); } } else { RaycastHit val7 = default(RaycastHit); float num2 = (Physics.Raycast(position, -forward, ref val7, 8f) ? (((RaycastHit)(ref val7)).distance - 1f) : 8f); if (!(num2 >= 4f)) { Log.LogError((object)$"[PortalRenderSpike] SHOWCASE ABORTED: no room for Portal B in either direction (forward {num:F1}m / backward {num2:F1}m clear, need {4f:F0}m). Move to a larger space and retry Shift+F3."); DestroyExistingPair(); return; } val5 = position - forward * num2; val6 = Quaternion.LookRotation(forward, Vector3.up); Log.LogWarning((object)$"[PortalRenderSpike] SHOWCASE: forward axis too cramped ({num:F1}m clear past A, need {4f:F0}m) - Portal B placed {num2:F1}m BEHIND the player instead, facing them."); } portalA = CreatePortalAt("PortalRenderSpike_A", val3, val2, null); portalB = CreatePortalAt("PortalRenderSpike_B", val5, val6, null); Vector3 val8 = -(val6 * Vector3.forward); RaycastHit val9 = default(RaycastHit); float num3 = (Physics.Raycast(val5, val8, ref val9, 2f) ? Mathf.Max(0.3f, ((RaycastHit)(ref val9)).distance - 0.4f) : 2f); Vector3 val10 = val5 + val8 * num3; showcaseMarker = CreateShowcaseMarker(val10); Log.LogInfo((object)$"SHOWCASE MARKER: magenta cube at {val10} - visible ONLY through portal A"); wasInFrontOfA = Vector3.Dot(((Component)instance).transform.position - portalA.Quad.position, portalA.Quad.forward) > 0f; wasInFrontOfB = Vector3.Dot(((Component)instance).transform.position - portalB.Quad.position, portalB.Quad.forward) > 0f; teleportCooldownUntil = 0f; UpdatePortalActivationVisuals(); ArmLinkSelfTest(); if ((Object)(object)instance.cameraGameObject != (Object)null && (Object)(object)CameraAim.Instance != (Object)null) { Quaternion localRotation = instance.cameraGameObject.transform.localRotation; float y = ((Quaternion)(ref localRotation)).eulerAngles.y; Quaternion val11 = Quaternion.Euler(0f, y, 0f); CameraAim.Instance.SetPlayerAim(val11, true); Log.LogInfo((object)$"SHOWCASE: portal A centered in view at {4f:F1}m"); } else { Log.LogWarning((object)$"SHOWCASE: spawned pair but could NOT force-aim the camera (cameraGameObject null={(Object)(object)instance.cameraGameObject == (Object)null}, CameraAim.Instance null={(Object)(object)CameraAim.Instance == (Object)null}) - portal A is 4m ahead at eye height along the camera's pre-spawn horizontal forward, but centering is not guaranteed."); } Log.LogInfo((object)$"[PortalRenderSpike] SHOWCASE spawn: A pos={val3} B pos={val5} axis={forward} (floating, both facing the player; walk forward through A to exit B; plain F3 for the normal wall-mounted spawn)."); } public void FirePortalFromItem(bool portalA) { FirePortal((!portalA) ? PortalId.B : PortalId.A); } private bool PortalFitsSurface(Vector3 point, Vector3 normal) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_004f: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.up - Vector3.Dot(Vector3.up, normal) * normal; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward - Vector3.Dot(Vector3.forward, normal) * normal; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(val, normal); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = 0.598f; float num2 = 1.0120001f; RaycastHit val3 = default(RaycastHit); for (int i = -2; i <= 2; i++) { for (int j = -2; j <= 2; j++) { float num3 = (float)i * 0.5f; float num4 = (float)j * 0.5f; if (!(num3 * num3 + num4 * num4 > 1.02f)) { if (!Physics.Raycast(point + normalized * (num3 * num) + val * (num4 * num2) + normal * 0.15f, -normal, ref val3, 0.5f, -1, (QueryTriggerInteraction)1)) { return false; } if (Vector3.Dot(((RaycastHit)(ref val3)).normal, normal) < 0.96f) { return false; } if (Mathf.Abs(Vector3.Dot(((RaycastHit)(ref val3)).point - point, normal)) > 0.04f) { return false; } } } } return true; } private bool AutoFitPoint(ref Vector3 point, Vector3 normal) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (PortalFitsSurface(point, normal)) { return true; } Vector3 val = Vector3.up - Vector3.Dot(Vector3.up, normal) * normal; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward - Vector3.Dot(Vector3.forward, normal) * normal; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(val, normal); Vector3 normalized = ((Vector3)(ref val2)).normalized; int num = LayerMask.NameToLayer("Default"); float num2 = Mathf.Max(1.3f, 2.2f) * 0.6f; RaycastHit val3 = default(RaycastHit); for (float num3 = 0.2f; num3 <= num2; num3 += 0.2f) { for (int i = 0; i < 8; i++) { float num4 = (float)i * ((float)Math.PI / 4f); if (Physics.Raycast(point + normalized * (Mathf.Cos(num4) * num3) + val * (Mathf.Sin(num4) * num3) + normal * 0.25f, -normal, ref val3, 0.6f, -1, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val3)).collider != (Object)null && ((Component)((RaycastHit)(ref val3)).collider).gameObject.layer == num && Vector3.Dot(((RaycastHit)(ref val3)).normal, normal) > 0.9f && PortalFitsSurface(((RaycastHit)(ref val3)).point, ((RaycastHit)(ref val3)).normal)) { point = ((RaycastHit)(ref val3)).point; return true; } } } return false; } private void FirePortal(PortalId id) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)PlayerController.instance == (Object)null) { Log.LogWarning((object)$"[PortalRenderSpike] Fire Portal {id} pressed but PlayerController.instance is null (not in a run yet?)."); return; } Camera val = FindPlayerCamera(); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)$"[PortalRenderSpike] Fire Portal {id}: no player camera found - cannot aim."); return; } PortalSounds.Play((id == PortalId.A) ? "fire_blue" : "fire_orange", ((Component)val).transform.position, 0.5f); Vector3 position = ((Component)val).transform.position; Vector3 forward = ((Component)val).transform.forward; PhysGrabObject val2 = LocalHeldPortalGun(); RaycastHit[] array = Physics.RaycastAll(position, forward, 120f, -1, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit val3 = default(RaycastHit); bool flag = false; int num = LayerMask.NameToLayer("RoomVolume"); int num2 = LayerMask.NameToLayer("Default"); string text = null; RaycastHit[] array2 = array; for (int num3 = 0; num3 < array2.Length; num3++) { RaycastHit val4 = array2[num3]; if ((Object)(object)((RaycastHit)(ref val4)).collider == (Object)null || ((Object)(object)val2 != (Object)null && ((Component)((RaycastHit)(ref val4)).collider).transform.IsChildOf(((Component)val2).transform)) || ((Component)((RaycastHit)(ref val4)).collider).gameObject.layer == num) { continue; } if (((Component)((RaycastHit)(ref val4)).collider).gameObject.layer != num2) { text = ((Object)((Component)((RaycastHit)(ref val4)).collider).gameObject).name; continue; } if ((Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent() != (Object)null) { text = ((Object)((Component)((RaycastHit)(ref val4)).collider).gameObject).name; continue; } val3 = val4; flag = true; break; } if (!flag) { if (text != null) { Log.LogWarning((object)$"[PortalRenderSpike] Portal {id} FIZZLE: only non-placeable geometry ('{text}' - a movable/door/cart/breakable) in the aim path within {120f:F0}m; no static wall behind it."); } else { Log.LogInfo((object)$"[PortalRenderSpike] Portal {id} FIZZLE: no surface within {120f:F0}m of the aim ray."); } PortalSounds.Play("fizzle", position + forward * 3f, 0.5f); return; } Vector3 point = ((RaycastHit)(ref val3)).point; if (!AutoFitPoint(ref point, ((RaycastHit)(ref val3)).normal)) { Log.LogWarning((object)$"[PortalRenderSpike] Portal {id} FIZZLE: no spot near {((RaycastHit)(ref val3)).point} fits the whole portal (surface too curved/small/edged). Aim at a bigger flat wall section."); PortalSounds.Play("fizzle", ((RaycastHit)(ref val3)).point, 0.5f); return; } ((RaycastHit)(ref val3)).point = point; PortalLink portalLink = ((id == PortalId.A) ? portalB : portalA); if (portalLink != null && Vector3.Distance(((RaycastHit)(ref val3)).point, portalLink.Quad.position) < 1.3f) { Log.LogWarning((object)$"[PortalRenderSpike] Portal {id} FIZZLE: aim point is only {Vector3.Distance(((RaycastHit)(ref val3)).point, portalLink.Quad.position):F2}m from the other portal (< portal width {1.3f}m) - pick a spot farther away."); return; } Vector3 pos = ((RaycastHit)(ref val3)).point + ((RaycastHit)(ref val3)).normal * 0.05f; Quaternion rot = PortalRotationForNormal(((RaycastHit)(ref val3)).normal); ApplyPortalPlacement(id, pos, rot); BroadcastPortalFire(id, pos, rot); bool flag2 = portalA != null && portalB != null; Log.LogInfo((object)string.Format("[PortalRenderSpike] Portal {0} PLACED on '{1}' at {2} (normal={3}, {4:F1}m from camera). {5}", id, ((Object)((Component)((RaycastHit)(ref val3)).collider).gameObject).name, ((RaycastHit)(ref val3)).point, ((RaycastHit)(ref val3)).normal, ((RaycastHit)(ref val3)).distance, flag2 ? "Pair LINKED - live view + walk-through active." : "Waiting for the other portal - this one shows its inactive colour until the pair is complete.")); } private static bool InSharedRoom() { if (PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null) { return PhotonNetwork.CurrentRoom.PlayerCount > 1; } return false; } private void ApplyPortalPlacement(PortalId id, Vector3 pos, Quaternion rot) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) DestroyStraddlers(); Vector3 val = rot * Vector3.forward; Collider val2 = null; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(pos + val * 0.25f, -val, ref val3, 0.6f, -1, (QueryTriggerInteraction)1)) { val2 = ((RaycastHit)(ref val3)).collider; } if (id == PortalId.A) { DestroyPortalLink(ref portalA); portalA = CreatePortalAt("PortalRenderSpike_A", pos, rot, val2); if (portalA != null) { ClearProtrudingTrim(portalA); if ((Object)(object)val2 != (Object)null) { portalA.RimCollider = BuildPortalAperture(portalA); } } } else { DestroyPortalLink(ref portalB); portalB = CreatePortalAt("PortalRenderSpike_B", pos, rot, val2); if (portalB != null) { ClearProtrudingTrim(portalB); if ((Object)(object)val2 != (Object)null) { portalB.RimCollider = BuildPortalAperture(portalB); } } } PlayerController instance = PlayerController.instance; if ((Object)(object)instance != (Object)null) { if (portalA != null) { wasInFrontOfA = Vector3.Dot(((Component)instance).transform.position - portalA.Quad.position, portalA.Quad.forward) > 0f; } if (portalB != null) { wasInFrontOfB = Vector3.Dot(((Component)instance).transform.position - portalB.Quad.position, portalB.Quad.forward) > 0f; } } UpdatePortalActivationVisuals(); PortalSounds.Play((id == PortalId.A) ? "open_blue" : "open_orange", pos, 0.8f); if (portalA != null && portalB != null) { ArmLinkSelfTest(); } } private object[] BuildFirePayload(PortalId id, Vector3 pos, Quaternion rot) { //IL_001a: 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) return new object[4] { "PGUN.v1", (byte)id, pos, rot }; } private bool TryApplyRemoteFire(object[] a) { //IL_0030: 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 (a == null || a.Length < 4 || !(a[0] is string text) || text != "PGUN.v1") { return false; } ApplyPortalPlacement((PortalId)(byte)a[1], (Vector3)a[2], (Quaternion)a[3]); return true; } private void BroadcastPortalFire(PortalId id, Vector3 pos, Quaternion rot) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (_fireEvent == null || !InSharedRoom()) { return; } try { _fireEvent.RaiseEvent((object)BuildFirePayload(id, pos, rot), NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } catch (Exception ex) { Log.LogWarning((object)("[PortalRenderSpike] portal FIRE broadcast failed: " + ex.Message)); } } private void OnPortalFireEvent(EventData data) { try { if (data.CustomData is object[] a && TryApplyRemoteFire(a)) { Log.LogInfo((object)$"[PortalRenderSpike] MP: applied remote portal placement from sender {data.Sender}."); } } catch (Exception ex) { Log.LogWarning((object)("[PortalRenderSpike] portal FIRE receive failed: " + ex.Message)); } } private void BroadcastPortalClear() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (_clearEvent == null || !InSharedRoom()) { return; } try { _clearEvent.RaiseEvent((object)new object[1] { "PGUN.v1" }, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } catch (Exception ex) { Log.LogWarning((object)("[PortalRenderSpike] portal CLEAR broadcast failed: " + ex.Message)); } } private void OnPortalClearEvent(EventData data) { try { if (data.CustomData is object[] array && array.Length >= 1 && array[0] is string text && !(text != "PGUN.v1")) { DestroyStraddlers(); DestroyExistingPair(); } } catch (Exception ex) { Log.LogWarning((object)("[PortalRenderSpike] portal CLEAR receive failed: " + ex.Message)); } } private void UpdatePortalActivationVisuals() { //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) bool flag = portalA != null && portalB != null; if ((Object)(object)portalA?.SwirlOverlay != (Object)null) { portalA.SwirlOverlay.SetActive(!flag); } if ((Object)(object)portalB?.SwirlOverlay != (Object)null) { portalB.SwirlOverlay.SetActive(!flag); } if (flag) { ((Renderer)portalA.ScreenRenderer).material.mainTexture = (Texture)(object)portalB.Texture; ((Renderer)portalB.ScreenRenderer).material.mainTexture = (Texture)(object)portalA.Texture; Log.LogInfo((object)("[PortalRenderSpike] CROSS-WIRE: " + ((Object)portalA.Quad).name + ".screen <- " + ((Object)portalB.Quad).name + "_Camera.RT ('" + ((Object)portalB.Texture).name + "'); " + ((Object)portalB.Quad).name + ".screen <- " + ((Object)portalA.Quad).name + "_Camera.RT ('" + ((Object)portalA.Texture).name + "').")); } if (portalA != null) { ((Renderer)portalA.ScreenRenderer).material.SetInt("displayMask", flag ? 1 : 0); ((Renderer)portalA.ScreenRenderer).material.SetColor("_InactiveColour", new Color(0.15f, 0.45f, 1f, 1f)); } if (portalB != null) { ((Renderer)portalB.ScreenRenderer).material.SetInt("displayMask", flag ? 1 : 0); ((Renderer)portalB.ScreenRenderer).material.SetColor("_InactiveColour", new Color(1f, 0.55f, 0.1f, 1f)); } } private void ArmLinkSelfTest() { if (portalA != null && portalB != null) { if (linkSelfTestRoutine != null) { ((MonoBehaviour)this).StopCoroutine(linkSelfTestRoutine); } linkSelfTestRoutine = ((MonoBehaviour)this).StartCoroutine(LinkSelfTestCoroutine()); } } private IEnumerator LinkSelfTestCoroutine() { yield return (object)new WaitForSeconds(2f); Camera val = FindPlayerCamera(); if (!cameraDumpDone && (Object)(object)val != (Object)null) { cameraDumpDone = true; Component[] components = ((Component)val).gameObject.GetComponents(); StringBuilder stringBuilder = new StringBuilder(); Component[] array = components; foreach (Component val2 in array) { stringBuilder.Append(((Object)(object)val2 != (Object)null) ? ((object)val2).GetType().Name : "null").Append(", "); } Log.LogInfo((object)string.Format("[PortalRenderSpike] CAMERA-DUMP: name='{0}' tag='{1}' clearFlags={2} cullingMask=0x{3:X} targetTexture={4} fov={5:F1} near={6:F3} far={7:F0} allowHDR={8} components=[{9}]", ((Object)((Component)val).gameObject).name, ((Component)val).gameObject.tag, val.clearFlags, val.cullingMask, ((Object)(object)val.targetTexture != (Object)null) ? $"'{((Object)val.targetTexture).name}' {((Texture)val.targetTexture).width}x{((Texture)val.targetTexture).height}" : "none (renders to screen)", val.fieldOfView, val.nearClipPlane, val.farClipPlane, val.allowHDR, stringBuilder)); } SelfTestPortal(portalA, "A", val); SelfTestPortal(portalB, "B", val); linkSelfTestRoutine = null; } private void SelfTestPortal(PortalLink? link, string label, Camera? playerCam) { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (link == null) { return; } try { if ((Object)(object)playerCam != (Object)null && portalA != null && portalB != null) { PortalLink portalLink = ((label == "A") ? portalB : portalA); GetCameraRenderPose(playerCam, out var pos, out var rot); ComputeMirroredPose(pos, rot, portalLink.Quad.position, portalLink.Quad.rotation, link.Quad.position, link.Quad.rotation, out var camPos, out var camRot); ((Component)link.PortalCam).transform.SetPositionAndRotation(camPos, camRot); link.PortalCam.ResetProjectionMatrix(); link.PortalCam.fieldOfView = playerCam.fieldOfView; link.PortalCam.aspect = playerCam.aspect; link.PortalCam.nearClipPlane = playerCam.nearClipPlane; } link.PortalCam.Render(); RenderTexture active = RenderTexture.active; RenderTexture.active = link.Texture; int num = Mathf.Max(0, ((Texture)link.Texture).width / 2 - 8); int num2 = Mathf.Max(0, ((Texture)link.Texture).height / 2 - 8); Texture2D val = new Texture2D(16, 16, (TextureFormat)3, false); val.ReadPixels(new Rect((float)num, (float)num2, 16f, 16f), 0, 0); val.Apply(); RenderTexture.active = active; Color32[] pixels = val.GetPixels32(); byte b = byte.MaxValue; byte b2 = 0; long num3 = 0L; Color32[] array = pixels; foreach (Color32 val2 in array) { byte b3 = (byte)((val2.r + val2.g + val2.b) / 3); if (b3 < b) { b = b3; } if (b3 > b2) { b2 = b3; } num3 += b3; } Object.Destroy((Object)(object)val); float num4 = (float)num3 / (float)pixels.Length; string text = ((b2 - b > 8) ? "NON-UNIFORM (RENDERED - real pixels; if it still looks black in-game the issue is brightness/post, not a dead RT)" : ((b2 <= 12) ? "UNIFORM BLACK (dead or seeing nothing - check cullingMask/transform/renderCount)" : "UNIFORM NON-BLACK (clear colour only - camera renders but sees no geometry)")); Log.LogInfo((object)$"[PortalRenderSpike] SELF-TEST portal {label}: normal-path renderCount={link.RenderCount}, forced-render readback 16x16 center: min={b} max={b2} avg={num4:F1} -> {text}. NOTE cross-wiring: this RT is rendered by portal {label}'s camera and DISPLAYS ON THE PARTNER portal's screen (Lague convention). renderCount stays 0 while the partner's quad is never on-screen - that is the visibility cull working, not a dead driver. Driver=manual Camera.Render() from Update (Built-in RP - no SRP assemblies in REPO_Data/Managed)."); } catch (Exception ex) { Log.LogError((object)("[PortalRenderSpike] SELF-TEST portal " + label + " FAILED: " + ex.GetType().Name + ": " + ex.Message)); } } private void StartSelfWalk() { if (portalA == null || portalB == null) { Log.LogWarning((object)"[PortalRenderSpike] J pressed but no active portal pair - spawn one first (Shift+F3 showcase recommended for verification)."); return; } PlayerController instance = PlayerController.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.rb == (Object)null) { Log.LogWarning((object)"[PortalRenderSpike] J pressed but PlayerController.instance/rb is null - cannot self-walk."); return; } if (selfWalkRoutine != null) { ((MonoBehaviour)this).StopCoroutine(selfWalkRoutine); } Log.LogInfo((object)"SELF-WALK: driving player into portal A"); selfWalkRoutine = ((MonoBehaviour)this).StartCoroutine(SelfWalkCoroutine(instance)); } private IEnumerator SelfWalkCoroutine(PlayerController controller) { float startTime = Time.time; Rigidbody rb = controller.rb; while (Time.time - startTime < 3f) { if (Time.time < teleportCooldownUntil) { Log.LogInfo((object)$"SELF-WALK: teleport fired after {Time.time - startTime:F2}s - player is now at {((Component)controller).transform.position} (past portal B; see the Teleport log line above for the full delta)."); selfWalkRoutine = null; yield break; } if (portalA == null) { Log.LogWarning((object)"SELF-WALK: portal A vanished mid-walk (re-fired/despawned?) - stopping."); selfWalkRoutine = null; yield break; } Vector3 val = portalA.Quad.position - ((Component)controller).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { Vector3 val2 = ((Vector3)(ref val)).normalized * 3f; rb.velocity = new Vector3(val2.x, rb.velocity.y, val2.z); } yield return (object)new WaitForFixedUpdate(); } float num = ((portalA != null) ? Vector3.Distance(((Component)controller).transform.position, portalA.Quad.position) : (-1f)); Log.LogWarning((object)$"SELF-WALK: TIMED OUT after {3f:F0}s without a teleport - player at {((Component)controller).transform.position}, {num:F2}m from portal A. Something blocked the path or the crossing check didn't trigger; this is a real verification signal, not noise."); selfWalkRoutine = null; } private bool FindNearestWall(Vector3 origin, Transform reference, out RaycastHit hit) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[4] { reference.forward, reference.right, -reference.right, -reference.forward }; foreach (Vector3 val in array) { if (Physics.Raycast(origin, val, ref hit, 10f)) { return true; } } hit = default(RaycastHit); return false; } private static Quaternion PortalRotationForNormal(Vector3 normal) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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) Vector3 val = ((Mathf.Abs(Vector3.Dot(normal, Vector3.up)) > 0.95f) ? Vector3.forward : Vector3.up); return Quaternion.LookRotation(normal, val); } private PortalLink CreatePortal(string name, RaycastHit wallHit) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Vector3 pos = ((RaycastHit)(ref wallHit)).point + ((RaycastHit)(ref wallHit)).normal * 0.05f; Quaternion rot = PortalRotationForNormal(((RaycastHit)(ref wallHit)).normal); return CreatePortalAt(name, pos, rot, ((RaycastHit)(ref wallHit)).collider); } private PortalLink CreatePortalAt(string name, Vector3 pos, Quaternion rot, Collider? wallCollider) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = name; Collider component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } val.transform.SetPositionAndRotation(pos, rot); val.transform.localScale = new Vector3(1.3f, 2.2f, 1f); MeshFilter component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.mesh = MakePortalEllipseMesh(48); } GameObject rim = BuildPortalGlowRim(name, pos, rot); GameObject rimCollider = null; GameObject val2 = BuildSwirlOverlay(name, val.transform); GameObject val3 = new GameObject(name + "_Camera"); val3.transform.SetParent(val.transform, false); Camera val4 = val3.AddComponent(); Camera val5 = FindPlayerCamera(); if ((Object)(object)val5 != (Object)null) { val4.CopyFrom(val5); TryClonePostProcessLayer(val5, val4); string[] array = new string[2] { "PlayerVisualsLocal", "PlayerVisuals" }; for (int i = 0; i < array.Length; i++) { int num = LayerMask.NameToLayer(array[i]); if (num >= 0) { val4.cullingMask |= 1 << num; } } LogPlayerAvatarRenderers(); } else { Log.LogWarning((object)("[PortalRenderSpike] " + name + ": no player camera available at creation - portal camera keeps Unity defaults (through-view will render WITHOUT REPO's post-processing and may look near-black).")); } ((Behaviour)val4).enabled = false; int num2 = Mathf.Max(2, Screen.width / _renderDownscale); int num3 = Mathf.Max(2, Screen.height / _renderDownscale); RenderTexture val6 = (val4.targetTexture = new RenderTexture(num2, num3, 16) { name = name + "_RT" }); val4.rect = new Rect(0f, 0f, 1f, 1f); val4.farClipPlane = 150f; Material val8 = new Material(FindPortalShader()) { mainTexture = (Texture)(object)val6 }; val8.SetInt("displayMask", 1); MeshRenderer component3 = val.GetComponent(); ((Renderer)component3).material = val8; PortalLink obj = new PortalLink { Quad = val.transform, PortalCam = val4, Texture = val6, ScreenRenderer = component3, Hit = wallCollider, Rim = rim, RimCollider = rimCollider, SwirlOverlay = val2 }; MeshRenderer component4 = val2.GetComponent(); obj.SwirlMat = ((component4 != null) ? ((Renderer)component4).sharedMaterial : null); return obj; } private static Texture2D GetSwirlTexture() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_swirlTex != (Object)null) { return _swirlTex; } Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)0 }; Color[] array = (Color[])(object)new Color[65536]; for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { float num = (float)j / 256f; float num2 = (float)i / 256f; float num3 = (Mathf.Sin(num * (float)Math.PI * 2f * 3f + num2 * 9f) * 0.5f + 0.5f) * Mathf.Clamp01(num2 * 1.15f); array[i * 256 + j] = new Color(num3, num3, num3, Mathf.Clamp01(0.3f + 0.7f * num3)); } } val.SetPixels(array); val.Apply(); _swirlTex = val; return val; } private GameObject BuildSwirlOverlay(string name, Transform quad) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown GameObject val = new GameObject(name + "_Swirl"); val.transform.SetParent(quad, false); val.transform.localPosition = new Vector3(0f, 0f, 0.005f); val.AddComponent().mesh = MakePortalEllipseMesh(48); MeshRenderer val2 = val.AddComponent(); ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; Color color = (name.Contains("_A") ? new Color(0.15f, 0.5f, 1f, 0.9f) : new Color(1f, 0.45f, 0.08f, 0.9f)); Shader val3 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Transparent") ?? Shader.Find("Unlit/Color"); if ((Object)(object)val3 != (Object)null) { ((Renderer)val2).material = new Material(val3) { color = color }; } else { ((Renderer)val2).enabled = false; } val.SetActive(false); return val; } private static Mesh MakePortalEllipseMesh(int seg) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown List list = new List { Vector3.zero }; List list2 = new List { new Vector2(0f, 0f) }; for (int i = 0; i <= seg; i++) { float num = (float)i / (float)seg; float num2 = num * (float)Math.PI * 2f; list.Add(new Vector3(Mathf.Cos(num2) * 0.5f, Mathf.Sin(num2) * 0.5f, 0f)); list2.Add(new Vector2(num, 1f)); } List list3 = new List(); for (int j = 0; j < seg; j++) { list3.Add(0); list3.Add(j + 1); list3.Add(j + 2); } Mesh val = new Mesh { name = "PortalEllipse" }; val.SetVertices(list); val.SetUVs(0, list2); val.SetTriangles(list3, 0); val.RecalculateBounds(); return val; } private GameObject BuildPortalGlowRim(string name, Vector3 pos, Quaternion rot) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name + "_RimGlow"); val.transform.SetPositionAndRotation(pos + rot * Vector3.forward * 0.012f, rot); val.AddComponent().mesh = MakeRimRingMesh(48, 0.65f, 1.1f, 0.08f); MeshRenderer val2 = val.AddComponent(); ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; Color val3 = (name.Contains("_A") ? new Color(0.15f, 0.55f, 1f) : new Color(1f, 0.5f, 0.08f)); string[] obj = new string[4] { "Sprites/Default", "Unlit/Transparent", "Unlit/Color", "Particles/Standard Unlit" }; Shader val4 = null; string arg = "NONE"; string[] array = obj; foreach (string text in array) { Shader val5 = Shader.Find(text); if ((Object)(object)val5 != (Object)null) { val4 = val5; arg = text; break; } } if ((Object)(object)val4 != (Object)null) { ((Renderer)val2).material = new Material(val4) { color = val3 }; } else { ((Renderer)val2).enabled = false; } Log.LogInfo((object)$"[PortalRenderSpike] {name} glow rim: shader='{arg}' colour={val3}."); return val; } private static Mesh MakeRimRingMesh(int seg, float innerA, float innerB, float w) { //IL_0036: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown List list = new List(); for (int i = 0; i < seg; i++) { float num = (float)i / (float)seg * (float)Math.PI * 2f; float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); list.Add(new Vector3(num2 * innerA, num3 * innerB, 0f)); list.Add(new Vector3(num2 * (innerA + w), num3 * (innerB + w), 0f)); } List list2 = new List(); for (int j = 0; j < seg; j++) { int item = j * 2; int item2 = j * 2 + 1; int item3 = (j + 1) % seg * 2; int item4 = (j + 1) % seg * 2 + 1; list2.Add(item); list2.Add(item2); list2.Add(item4); list2.Add(item); list2.Add(item4); list2.Add(item3); list2.Add(item); list2.Add(item4); list2.Add(item2); list2.Add(item); list2.Add(item3); list2.Add(item4); } Mesh val = new Mesh { name = "PortalRimGlowMesh" }; val.SetVertices(list); val.SetTriangles(list2, 0); val.RecalculateBounds(); return val; } private void ClearProtrudingTrim(PortalLink portal) { //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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_018e: Unknown result type (might be due to invalid IL or missing references) if (portal == null || (Object)(object)portal.Hit == (Object)null) { return; } portal.TrimColliders.Clear(); Vector3 position = portal.Quad.position; Vector3 forward = portal.Quad.forward; Vector3 right = portal.Quad.right; Vector3 up = portal.Quad.up; float num = 0.65f; float num2 = 1.1f; HashSet hashSet = new HashSet(); for (int i = -3; i <= 3; i++) { for (int j = -3; j <= 3; j++) { float num3 = (float)i / 3f; float num4 = (float)j / 3f; if (num3 * num3 + num4 * num4 > 1.25f) { continue; } Vector3 val = position + right * (num3 * (num + 0.15f)) + up * (num4 * (num2 + 0.15f)); Vector3[] array = (Vector3[])(object)new Vector3[2] { forward, -forward }; foreach (Vector3 val2 in array) { RaycastHit[] array2 = Physics.RaycastAll(val + val2 * 0.7f, -val2, 1.4f, -1, (QueryTriggerInteraction)1); for (int l = 0; l < array2.Length; l++) { RaycastHit val3 = array2[l]; Collider collider = ((RaycastHit)(ref val3)).collider; if (!((Object)(object)collider == (Object)null) && !collider.isTrigger && !((Object)(object)collider.attachedRigidbody != (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) && !((Component)collider).transform.IsChildOf(portal.Quad) && !(Mathf.Abs(Vector3.Dot(((RaycastHit)(ref val3)).normal, Vector3.up)) > 0.7f)) { hashSet.Add(collider); } } } } } portal.TrimColliders.AddRange(hashSet); Log.LogInfo((object)$"[PortalRenderSpike] P6: de-collided {portal.TrimColliders.Count} collider(s) in {((Object)portal.Quad).name}'s opening (ray-cast along normal; floors excluded)."); } private void LogPlayerAvatarRenderers() { if (_loggedAvatarRenderers) { return; } PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance == (Object)null) { Log.LogInfo((object)"[PLAYERMODEL-DIAG] PlayerAvatar.instance null at portal creation - retry next placement."); return; } _loggedAvatarRenderers = true; Transform val = ((Component)instance).transform; while ((Object)(object)val.parent != (Object)null) { val = val.parent; } Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); Log.LogInfo((object)$"[PLAYERMODEL-DIAG] avatar root '{((Object)val).name}' subtree has {componentsInChildren.Length} renderer(s) (showing enabled + skinned/mesh):"); int num = 0; Renderer[] array = componentsInChildren; foreach (Renderer val2 in array) { if (!((Object)(object)val2 == (Object)null) && (val2.enabled || val2 is SkinnedMeshRenderer || (val2 is MeshRenderer && ((Object)val2).name != "Cube"))) { if (num++ >= 40) { Log.LogInfo((object)"[PLAYERMODEL-DIAG] ... (truncated)"); break; } Log.LogInfo((object)$"[PLAYERMODEL-DIAG] '{GetHierarchyPath(((Component)val2).transform, val)}' layer={LayerMask.LayerToName(((Component)val2).gameObject.layer)}({((Component)val2).gameObject.layer}) enabled={val2.enabled} active={((Component)val2).gameObject.activeInHierarchy} type={((object)val2).GetType().Name}"); } } } private static string GetHierarchyPath(Transform t, Transform stopAt) { List list = new List(); Transform val = t; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)stopAt.parent) { list.Insert(0, ((Object)val).name); val = val.parent; } return string.Join("/", list); } private GameObject BuildPortalAperture(PortalLink link) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown GameObject root = new GameObject("PortalAperture"); root.transform.SetPositionAndRotation(link.Quad.position, link.Quad.rotation); float hw = 0.65f; float hh = 1.1f; float zc = -0.255f; int def = LayerMask.NameToLayer("Default"); Vector3 fwd = link.Quad.forward; PhysicMaterial frictionless = new PhysicMaterial("PortalApertureZeroFriction") { dynamicFriction = 0f, staticFriction = 0f, frictionCombine = (PhysicMaterialCombine)2, bounciness = 0f }; int boxCount = 0; float num2; for (float num = -2.825f; num < 2.9f; num += num2) { num2 = ((Mathf.Abs(num) < hh + 0.15f) ? 0.15f : 0.5f); List<(float, float)> list = new List<(float, float)>(); if (Mathf.Abs(num) < hh) { float num3 = hw * Mathf.Sqrt(Mathf.Max(0f, 1f - num / hh * (num / hh))); list.Add((-1.5f, 0f - num3)); list.Add((num3, 1.5f)); } else { list.Add((-1.5f, 1.5f)); } foreach (var item3 in list) { float item = item3.Item1; float item2 = item3.Item2; float num4 = float.NaN; for (float num5 = item; num5 < item2 - 0.0001f; num5 += 0.25f) { float num6 = num5; float num7 = Mathf.Min(num5 + 0.25f, item2); if (CellBacked((num6 + num7) * 0.5f, num)) { if (float.IsNaN(num4)) { num4 = num6; } } else if (!float.IsNaN(num4)) { AddBox(num4, num6, num, num2); num4 = float.NaN; } } if (!float.IsNaN(num4)) { AddBox(num4, item2, num, num2); } } } IgnorePlayerVsRim(root); Log.LogInfo((object)$"[PortalRenderSpike] Stage D APERTURE built for {((Object)link.Quad).name}: {boxCount} frame boxes (row-stepped ellipse, raycast-gated to the ignored wall)."); return root; void AddBox(float cxMin, float cxMax, float cy, float rh) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_006a: Unknown result type (might be due to invalid IL or missing references) float num8 = cxMax - cxMin; if (!(num8 <= 0.001f)) { GameObject val = new GameObject("ApertureBox"); val.transform.SetParent(root.transform, false); val.transform.localPosition = new Vector3((cxMin + cxMax) * 0.5f, cy, zc); val.layer = def; BoxCollider obj = val.AddComponent(); obj.size = new Vector3(num8, rh, 0.35f); ((Collider)obj).material = frictionless; boxCount++; } } bool CellBacked(float cx, float cy) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Abs(cx) < hw + 0.18f && Mathf.Abs(cy) < hh + 0.18f) { return true; } Vector3 val = root.transform.TransformPoint(new Vector3(cx, cy, 0f)); Vector3[] array = (Vector3[])(object)new Vector3[2] { fwd, -fwd }; foreach (Vector3 val2 in array) { RaycastHit[] array2 = Physics.RaycastAll(val + val2 * 0.7f, -val2, 1.4f, -1, (QueryTriggerInteraction)1); for (int j = 0; j < array2.Length; j++) { RaycastHit val3 = array2[j]; Collider collider = ((RaycastHit)(ref val3)).collider; if (!((Object)(object)collider == (Object)null) && !(Mathf.Abs(Vector3.Dot(((RaycastHit)(ref val3)).normal, Vector3.up)) > 0.7f) && ((Object)(object)collider == (Object)(object)link.Hit || link.TrimColliders.Contains(collider))) { return true; } } } return false; } } private void IgnorePlayerVsRim(GameObject rim) { PlayerController instance = PlayerController.instance; if ((Object)(object)instance == (Object)null || (Object)(object)rim == (Object)null) { return; } Collider[] componentsInChildren = rim.GetComponentsInChildren(); Collider[] componentsInChildren2 = ((Component)instance).GetComponentsInChildren(); foreach (Collider val in componentsInChildren2) { if ((Object)(object)val == (Object)null || val.isTrigger) { continue; } Collider[] array = componentsInChildren; foreach (Collider val2 in array) { if ((Object)(object)val2 != (Object)null) { Physics.IgnoreCollision(val, val2, true); } } } } private void TryClonePostProcessLayer(Camera source, Camera destination) { //IL_0209: 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) try { Component val = null; Component[] components = ((Component)source).GetComponents(); foreach (Component val2 in components) { if ((Object)(object)val2 != (Object)null && ((object)val2).GetType().Name == "PostProcessLayer") { val = val2; break; } } if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"[PortalRenderSpike] Player camera has NO PostProcessLayer component - portal cameras get raw-scene rendering. If the through-view is dark, the brightening lives elsewhere (check the CAMERA-DUMP log line for what components ARE on the camera)."); return; } Type type = ((object)val).GetType(); Component val3 = ((Component)destination).gameObject.AddComponent(type); FieldInfo field = type.GetField("m_Resources", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo method = type.GetMethod("Init", BindingFlags.Instance | BindingFlags.Public); object obj = field?.GetValue(val); if (obj != null && method != null) { method.Invoke(val3, new object[1] { obj }); } else { Log.LogWarning((object)("[PortalRenderSpike] PostProcessLayer clone: could not transfer m_Resources (field=" + ((field != null) ? "found" : "MISSING") + ", Init=" + ((method != null) ? "found" : "MISSING") + ") - the cloned layer may throw internally.")); } FieldInfo field2 = type.GetField("volumeLayer"); field2?.SetValue(val3, field2.GetValue(val)); type.GetField("volumeTrigger")?.SetValue(val3, ((Component)destination).transform); FieldInfo field3 = type.GetField("antialiasingMode"); if (field3 != null) { field3.SetValue(val3, Enum.ToObject(field3.FieldType, 0)); } Behaviour val4 = (Behaviour)(object)((val3 is Behaviour) ? val3 : null); object obj2 = field2?.GetValue(val3); Log.LogInfo((object)string.Format("[PortalRenderSpike] Cloned PostProcessLayer onto {0}: enabled={1} resourcesTransferred={2} volumeLayer={3} volumeTrigger=self AAoff=true - through-view should match REPO's graded look instead of raw/near-black.", ((Object)((Component)destination).gameObject).name, ((Object)(object)val4 != (Object)null) ? val4.enabled.ToString() : "n/a", obj != null, (obj2 is LayerMask val5) ? ("0x" + ((LayerMask)(ref val5)).value.ToString("X")) : (obj2?.ToString() ?? "unset"))); } catch (Exception ex) { Log.LogWarning((object)("[PortalRenderSpike] PostProcessLayer clone FAILED: " + ex.GetType().Name + ": " + ex.Message + " - portal view will render without post-processing (likely dark). This log line is the evidence trail; the self-test readback will show whether pixels are otherwise alive.")); } } private Shader FindPortalShader() { if ((Object)(object)_cachedShader != (Object)null) { return _cachedShader; } Shader val = TryLoadPortalShaderFromBundle(); if ((Object)(object)val != (Object)null) { Log.LogInfo((object)"[PortalRenderSpike] Using the PORTED Sebastian Lague \"Custom/Portal\" shader (screen-space sampling) from portalrenderspikebundle - this is the real ported asset, not a placeholder."); _cachedShader = val; return _cachedShader; } Log.LogWarning((object)"[PortalRenderSpike] Could not load the ported Portal shader from portalrenderspikebundle - falling back to a stock Unlit material (mesh-UV sampling). This WILL look wrong off-axis (image reads as painted on the quad, not a true window) - see the report for the full artifact description."); string[] array = new string[4] { "Unlit/Texture", "Sprites/Default", "UI/Default", "Standard" }; foreach (string text in array) { Shader val2 = Shader.Find(text); if ((Object)(object)val2 != (Object)null) { Log.LogInfo((object)("[PortalRenderSpike] Fallback: using stock shader '" + text + "' for the portal screen material.")); _cachedShader = val2; return val2; } } Log.LogWarning((object)"[PortalRenderSpike] None of the expected built-in shader names resolved via Shader.Find either - falling back to \"Diffuse\", which may ALSO fail. If so, portal quads will render magenta/default and this is a real spike blocker to report."); _cachedShader = Shader.Find("Diffuse"); return _cachedShader; } private Shader? TryLoadPortalShaderFromBundle() { if (_bundleLoadAttempted) { if (!((Object)(object)_cachedBundle != (Object)null)) { return null; } return _cachedBundle.LoadAsset("Assets/PortalRenderSpike/Shaders/Portal.shader"); } _bundleLoadAttempted = true; try { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "portalrenderspikebundle"); if (!File.Exists(text)) { Log.LogWarning((object)("[PortalRenderSpike] Bundle not found at expected path '" + text + "' (should ship in the same plugin folder as the DLL).")); return null; } _cachedBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_cachedBundle == (Object)null) { Log.LogWarning((object)("[PortalRenderSpike] AssetBundle.LoadFromFile returned null for '" + text + "' - bundle may be corrupt or built for the wrong platform.")); return null; } Shader val = _cachedBundle.LoadAsset("Assets/PortalRenderSpike/Shaders/Portal.shader"); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"[PortalRenderSpike] Bundle loaded but LoadAsset(\"Assets/PortalRenderSpike/Shaders/Portal.shader\") returned null."); return null; } return val; } catch (Exception ex) { Log.LogWarning((object)("[PortalRenderSpike] Exception loading portalrenderspikebundle: " + ex.Message)); return null; } } private void ReskinWorldGun(PhysGrabObject gun) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gun == (Object)null || _reskinnedGuns.Contains(((Object)gun).GetInstanceID())) { return; } AssetBundle val = LoadVisualsBundle(); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = val.LoadAsset("PortalGunWorldModel"); if ((Object)(object)val2 == (Object)null) { _reskinnedGuns.Add(((Object)gun).GetInstanceID()); return; } _reskinnedGuns.Add(((Object)gun).GetInstanceID()); MeshRenderer[] componentsInChildren = ((Component)gun).GetComponentsInChildren(); foreach (MeshRenderer val3 in componentsInChildren) { if ((Object)(object)val3 != (Object)null && ((Object)val3).name != "PortalGunWorldModel(rt)") { ((Renderer)val3).enabled = false; } } GameObject obj = Object.Instantiate(val2, ((Component)gun).transform); ((Object)obj).name = "PortalGunWorldModel(rt)"; obj.transform.localPosition = Vector3.zero; obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one; Log.LogInfo((object)("[PortalRenderSpike] Re-skinned world gun '" + ((Object)gun).name + "' with the Portal world model.")); } private AssetBundle? LoadVisualsBundle() { if (_visualsBundleTried) { return _visualsBundle; } _visualsBundleTried = true; try { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "portalgunvisuals"); if (!File.Exists(text)) { Log.LogWarning((object)("[PortalRenderSpike] portalgunvisuals bundle not found at '" + text + "' - viewmodel disabled.")); return null; } _visualsBundle = AssetBundle.LoadFromFile(text); Log.LogInfo((object)(((Object)(object)_visualsBundle != (Object)null) ? "[PortalRenderSpike] loaded portalgunvisuals bundle." : "[PortalRenderSpike] portalgunvisuals load returned null.")); return _visualsBundle; } catch (Exception ex) { Log.LogWarning((object)("[PortalRenderSpike] portalgunvisuals load threw: " + ex.Message)); return null; } } private static int FindUnusedLayer() { for (int i = 8; i < 32; i++) { if (string.IsNullOrEmpty(LayerMask.LayerToName(i))) { return i; } } return -1; } private static void SetLayerRecursive(GameObject go, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) go.layer = layer; foreach (Transform item in go.transform) { SetLayerRecursive(((Component)item).gameObject, layer); } } private void EnsureViewmodel() { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_viewmodel != (Object)null) { return; } AssetBundle val = LoadVisualsBundle(); if ((Object)(object)val == (Object)null) { return; } Camera val2 = FindPlayerCamera(); if ((Object)(object)val2 == (Object)null) { return; } GameObject val3 = val.LoadAsset("PortalGunWorldModel"); if ((Object)(object)val3 == (Object)null) { Log.LogWarning((object)"[PortalRenderSpike] viewmodel prefab 'PortalGunWorldModel' not in bundle - viewmodel disabled."); return; } _viewmodel = Object.Instantiate(val3); ((Object)_viewmodel).name = "PortalGunViewmodel(rt)"; _viewmodel.transform.SetParent(((Component)val2).transform, false); _viewmodel.transform.localPosition = new Vector3(0.42f, -0.15f, 0.42f); _viewmodel.transform.localRotation = Quaternion.Euler(-90f, 180f, 0f); _viewmodel.transform.localScale = Vector3.one; _viewmodelAnimator = _viewmodel.GetComponentInChildren(); _viewmodelLayer = FindUnusedLayer(); if (_viewmodelLayer >= 0) { SetLayerRecursive(_viewmodel, _viewmodelLayer); val2.cullingMask |= 1 << _viewmodelLayer; if ((Object)(object)portalA?.PortalCam != (Object)null) { Camera portalCam = portalA.PortalCam; portalCam.cullingMask &= ~(1 << _viewmodelLayer); } if ((Object)(object)portalB?.PortalCam != (Object)null) { Camera portalCam2 = portalB.PortalCam; portalCam2.cullingMask &= ~(1 << _viewmodelLayer); } } else { _viewmodelLayer = 0; SetLayerRecursive(_viewmodel, 0); } Renderer[] componentsInChildren = _viewmodel.GetComponentsInChildren(); Renderer[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { array[i].shadowCastingMode = (ShadowCastingMode)0; } MeshFilter[] componentsInChildren2 = _viewmodel.GetComponentsInChildren(); foreach (MeshFilter val4 in componentsInChildren2) { if ((Object)(object)val4.sharedMesh != (Object)null) { val4.sharedMesh.RecalculateBounds(); } } SkinnedMeshRenderer[] componentsInChildren3 = _viewmodel.GetComponentsInChildren(); foreach (SkinnedMeshRenderer val5 in componentsInChildren3) { if ((Object)(object)val5.sharedMesh != (Object)null) { val5.sharedMesh.RecalculateBounds(); } val5.updateWhenOffscreen = true; } if ((Object)(object)_viewmodelAnimator != (Object)null) { ((Behaviour)_viewmodelAnimator).enabled = false; } array = _viewmodel.GetComponentsInChildren(); foreach (Renderer val6 in array) { if (((Object)val6).name.ToLower().Contains("potatos")) { val6.enabled = false; } } StringBuilder stringBuilder = new StringBuilder(); array = _viewmodel.GetComponentsInChildren(); foreach (Renderer val7 in array) { Material[] materials = val7.materials; Material[] array2 = materials; foreach (Material val8 in array2) { if (!((Object)(object)val8 == (Object)null)) { string text = (((Object)(object)val8.shader != (Object)null) ? ((Object)val8.shader).name : "Standard"); Shader val9 = Shader.Find(text) ?? Shader.Find("Standard") ?? Shader.Find("Sprites/Default"); stringBuilder.Append("[" + ((Object)val7).name + ": " + text + "->" + (((Object)(object)val9 != (Object)null) ? ((Object)val9).name : "NULL") + "] "); if ((Object)(object)val9 != (Object)null) { val8.shader = val9; } } } val7.materials = materials; } Log.LogInfo((object)$"[PortalRenderSpike] viewmodel shader re-bind: {stringBuilder}"); _viewmodel.SetActive(false); StringBuilder stringBuilder2 = new StringBuilder(); array = componentsInChildren; foreach (Renderer val10 in array) { Material sharedMaterial = val10.sharedMaterial; stringBuilder2.Append(string.Format("[{0}:{1}:tex={2}] ", ((Object)((Component)val10).gameObject).name, ((Object)(object)sharedMaterial != (Object)null) ? ((Object)sharedMaterial.shader).name : "NO-MAT", (Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.mainTexture != (Object)null)); } Bounds val11 = (Bounds)((componentsInChildren.Length != 0) ? componentsInChildren[0].bounds : default(Bounds)); array = componentsInChildren; foreach (Renderer val12 in array) { ((Bounds)(ref val11)).Encapsulate(val12.bounds); } Log.LogInfo((object)string.Format("[PortalRenderSpike] viewmodel ready: layer={0} parentCam='{1}' camEnabled={2} camDepth={3} camTarget={4} animator={5} renderers={6} boundsSize={7} boundsCenter={8} vmWorldPos={9} camNearClip={10} camMaskHasLayer={11} scale={12} mats={13}", _viewmodelLayer, ((Object)val2).name, ((Behaviour)val2).enabled, val2.depth, ((Object)(object)val2.targetTexture != (Object)null) ? ((Object)val2.targetTexture).name : "screen", (Object)(object)_viewmodelAnimator != (Object)null, componentsInChildren.Length, ((Bounds)(ref val11)).size, ((Bounds)(ref val11)).center, _viewmodel.transform.position, val2.nearClipPlane, (val2.cullingMask & (1 << _viewmodelLayer)) != 0, _viewmodel.transform.lossyScale, stringBuilder2)); } private void UpdateViewmodel() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) EnsureViewmodel(); if ((Object)(object)_viewmodel == (Object)null) { return; } bool flag = (portalMode && holdingPortalGun && (Object)(object)_activeGun != (Object)null) || _forceViewmodel; if (_viewmodel.activeSelf && flag) { UpdateViewmodelAnim(); } if (_viewmodel.activeSelf == flag) { return; } _viewmodel.SetActive(flag); if (flag) { Camera val = FindPlayerCamera(); Renderer[] componentsInChildren = _viewmodel.GetComponentsInChildren(); if ((Object)(object)val != (Object)null && componentsInChildren.Length != 0) { Bounds bounds = componentsInChildren[0].bounds; Renderer[] array = componentsInChildren; foreach (Renderer val2 in array) { ((Bounds)(ref bounds)).Encapsulate(val2.bounds); } Vector3 val3 = val.WorldToViewportPoint(((Bounds)(ref bounds)).center); Log.LogInfo((object)$"[VM-POS] viewmodel viewport=({val3.x:F2},{val3.y:F2}) depth={val3.z:F2}m localPos={_viewmodel.transform.localPosition} scale={_viewmodel.transform.localScale.x:F2} boundsSize={((Bounds)(ref bounds)).size} (target lower-right ~0.75,0.20 @ depth 0.4-0.6)."); } _vmDrawT = 0f; PhysGrabObject activeGun = _activeGun; if ((Object)(object)activeGun != (Object)null) { _hiddenWorldGunRenderers = Array.FindAll(((Component)activeGun).GetComponentsInChildren(), (Renderer r) => (Object)(object)r != (Object)null && r.enabled); Renderer[] array = _hiddenWorldGunRenderers; for (int i = 0; i < array.Length; i++) { array[i].enabled = false; } } } else { if (_hiddenWorldGunRenderers == null) { return; } Renderer[] array = _hiddenWorldGunRenderers; foreach (Renderer val4 in array) { if ((Object)(object)val4 != (Object)null) { val4.enabled = true; } } _hiddenWorldGunRenderers = null; } } private void UpdateViewmodelAnim() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_viewmodel == (Object)null)) { float deltaTime = Time.deltaTime; _vmRecoil = Mathf.Max(0f, _vmRecoil - deltaTime * 5f); _vmDrawT = Mathf.Min(1f, _vmDrawT + deltaTime * 4f); float time = Time.time; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Cos(time * 1.3f) * 0.006f, Mathf.Sin(time * 2f) * 0.008f, 0f); float num = _vmDrawT * _vmDrawT * (3f - 2f * _vmDrawT); Vector3 val2 = Vector3.Lerp(new Vector3(0.05f, -0.28f, -0.12f), Vector3.zero, num); Vector3 val3 = new Vector3(0f, 0.02f, -0.13f) * _vmRecoil; _viewmodel.transform.localPosition = VmBasePos + val + val2 + val3; _viewmodel.transform.localRotation = Quaternion.AngleAxis(180f, Vector3.forward) * Quaternion.Euler(-90f - _vmRecoil * 8f, 180f, 0f); } } public void OnLevelChanging() { DestroyExistingPair(); portalMode = false; _activeGun = null; Log.LogInfo((object)"[PortalRenderSpike] Level changing - portals closed + traversal state cleared (their walls no longer exist)."); } public void RelaySoundThroughPortals(Vector3 position, float radius, bool pathfindOnly) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_004a: 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) //IL_006b: 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) PortalLink portalLink = portalA; PortalLink portalLink2 = portalB; if (portalLink != null && portalLink2 != null) { float num = Vector3.Distance(position, portalLink.Quad.position); float num2 = Vector3.Distance(position, portalLink2.Quad.position); if (num <= 12f && num <= num2) { EnemyDirector.instance.SetInvestigate(MapPointThroughPortal(position, portalLink, portalLink2), radius, pathfindOnly); } else if (num2 <= 12f && num2 < num) { EnemyDirector.instance.SetInvestigate(MapPointThroughPortal(position, portalLink2, portalLink), radius, pathfindOnly); } } } private static Vector3 MapPointThroughPortal(Vector3 worldPoint, PortalLink from, PortalLink to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) Vector3 val = worldPoint - from.Quad.position; float num = Vector3.Dot(val, from.Quad.right); float num2 = Vector3.Dot(val, from.Quad.up); return to.Quad.position + to.Quad.right * (0f - num) + to.Quad.up * num2 + to.Quad.forward * 0.5f; } private void UpdatePerceptionSight() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) PortalLink portalLink = portalA; PortalLink portalLink2 = portalB; if (portalLink == null || portalLink2 == null || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } _sightRelayTimer -= Time.deltaTime; if (_sightRelayTimer > 0f) { return; } _sightRelayTimer = 0.25f; List list = SemiFunc.PlayerGetList(); if (list == null || list.Count == 0) { return; } int mask = LayerMask.GetMask(new string[1] { "Default" }); EnemyVision[] array = Object.FindObjectsOfType(); foreach (EnemyVision val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.VisionTransform == (Object)null)) { Vector3 position = val.VisionTransform.position; RelaySightForPortal(val, position, portalLink, portalLink2, list, mask); RelaySightForPortal(val, position, portalLink2, portalLink, list, mask); } } } private void RelaySightForPortal(EnemyVision ev, Vector3 evPos, PortalLink nearPortal, PortalLink farPortal, List players, int wallMask) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) Vector3 val = nearPortal.Quad.position + nearPortal.Quad.forward * 0.3f; if (Vector3.Distance(evPos, val) > ev.VisionDistance || Physics.Linecast(evPos, val, wallMask)) { return; } foreach (PlayerAvatar player in players) { if (!((Object)(object)player == (Object)null) && !((Object)(object)player.photonView == (Object)null)) { Vector3 val2 = ((Component)player).transform.position - farPortal.Quad.position; if (!(Vector3.Dot(val2, farPortal.Quad.forward) <= 0f) && !(((Vector3)(ref val2)).magnitude > 10f)) { ev.VisionTrigger(player.photonView.ViewID, player, false, false); } } } } private static bool PortalAlive(PortalLink? p) { if (p != null && (Object)(object)p.Quad != (Object)null && (Object)(object)p.ScreenRenderer != (Object)null) { return (Object)(object)p.PortalCam != (Object)null; } return false; } private void PruneDeadPortals() { bool num = portalA != null && !PortalAlive(portalA); bool flag = portalB != null && !PortalAlive(portalB); if (!num && !flag) { return; } Log.LogWarning((object)"[PortalRenderSpike] Portal geometry was destroyed by a level/scene reload - pruning the dead pair so the render loop stops erroring and the gun can place portals again."); try { DestroyExistingPair(); } catch (Exception ex) { Log.LogWarning((object)("[PortalRenderSpike] prune teardown threw (" + ex.Message + ") - hard-nulling the links.")); portalA = null; portalB = null; } } private void DestroyExistingPair() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (portalA != null || portalB != null) { Log.LogInfo((object)$"[PortalRenderSpike] DestroyExistingPair: clearing portals (A={portalA != null}, B={portalB != null}). If this fires unexpectedly on sheath/mode-change, that's the culprit."); PortalLink portalLink = portalA ?? portalB; if (portalLink != null && (Object)(object)portalLink.Quad != (Object)null) { PortalSounds.Play("close", portalLink.Quad.position, 0.7f); } } CloseAllPlayerHoles(PlayerController.instance); CloseAllItemHoles(); ClearAllTravellers(); _heldItemStraddlePortal = null; DestroyPortalLink(ref portalA); DestroyPortalLink(ref portalB); if ((Object)(object)showcaseMarker != (Object)null) { Object.Destroy((Object)(object)showcaseMarker); showcaseMarker = null; } if (selfWalkRoutine != null) { ((MonoBehaviour)this).StopCoroutine(selfWalkRoutine); selfWalkRoutine = null; } if (linkSelfTestRoutine != null) { ((MonoBehaviour)this).StopCoroutine(linkSelfTestRoutine); linkSelfTestRoutine = null; } DestroyFlashlightProxy(); } private GameObject CreateShowcaseMarker(Vector3 pos) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = "PortalRenderSpike_LivenessMarker"; Collider component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } obj.transform.position = pos; obj.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f); Material material = new Material(Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Standard")) { color = Color.magenta }; ((Renderer)obj.GetComponent()).material = material; return obj; } private void DestroyPortalLink(ref PortalLink? link) { if (link == null) { return; } if ((Object)(object)link.PortalCam != (Object)null) { link.PortalCam.targetTexture = null; } if ((Object)(object)link.Texture != (Object)null) { link.Texture.Release(); Object.Destroy((Object)(object)link.Texture); } if ((Object)(object)link.Rim != (Object)null) { Object.Destroy((Object)(object)link.Rim); } if ((Object)(object)link.RimCollider != (Object)null) { Object.Destroy((Object)(object)link.RimCollider); } if ((Object)(object)link.SwirlMat != (Object)null) { Object.Destroy((Object)(object)link.SwirlMat); } foreach (Renderer clearedRenderer in link.ClearedRenderers) { if ((Object)(object)clearedRenderer != (Object)null) { clearedRenderer.enabled = true; } } if ((Object)(object)link.Quad != (Object)null) { Object.Destroy((Object)(object)((Component)link.Quad).gameObject); } link = null; } internal static void ComputeMirroredPose(Vector3 playerPos, Quaternion playerRot, Vector3 fromPos, Quaternion fromRot, Vector3 toPos, Quaternion toRot, out Vector3 camPos, out Quaternion camRot) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0048: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.AngleAxis(180f, Vector3.up); Quaternion val2 = toRot * val * Quaternion.Inverse(fromRot); camPos = toPos + val2 * (playerPos - fromPos); camRot = val2 * playerRot; } private static void GetCameraRenderPose(Camera cam, out Vector3 pos, out Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_003d: 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) Matrix4x4 cameraToWorldMatrix = cam.cameraToWorldMatrix; pos = Vector4.op_Implicit(((Matrix4x4)(ref cameraToWorldMatrix)).GetColumn(3)); Vector3 val = -Vector4.op_Implicit(((Matrix4x4)(ref cameraToWorldMatrix)).GetColumn(2)); Vector3 val2 = Vector4.op_Implicit(((Matrix4x4)(ref cameraToWorldMatrix)).GetColumn(1)); rot = Quaternion.LookRotation(val, val2); } private void RenderPortalView(PortalLink camSide, PortalLink screenSide, Camera playerCam) { //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) if (!VisibleFromCamera((Renderer)(object)screenSide.ScreenRenderer, playerCam)) { return; } GetCameraRenderPose(playerCam, out var pos, out var rot); ComputeMirroredPose(pos, rot, screenSide.Quad.position, screenSide.Quad.rotation, camSide.Quad.position, camSide.Quad.rotation, out var camPos, out var camRot); Camera portalCam = camSide.PortalCam; ((Component)portalCam).transform.SetPositionAndRotation(camPos, camRot); portalCam.ResetProjectionMatrix(); portalCam.fieldOfView = playerCam.fieldOfView; portalCam.aspect = playerCam.aspect; portalCam.nearClipPlane = playerCam.nearClipPlane; float num = Vector3.Distance(((Component)playerCam).transform.position, screenSide.Quad.position); portalCam.farClipPlane = Mathf.Clamp(num + 23f + 8f, 30f, 150f); ApplyObliqueNearClip(camSide); ShadowCastingMode shadowCastingMode = ((Renderer)camSide.ScreenRenderer).shadowCastingMode; int num2 = ((Renderer)screenSide.ScreenRenderer).material.GetInt("displayMask"); ((Renderer)camSide.ScreenRenderer).shadowCastingMode = (ShadowCastingMode)3; ((Renderer)screenSide.ScreenRenderer).material.SetInt("displayMask", 0); Stopwatch stopwatch = Stopwatch.StartNew(); try { portalCam.Render(); } catch (Exception ex) { Log.LogError((object)("[PortalRenderSpike] " + ((Object)camSide.Quad).name + "_Camera Render() THREW: " + ex.GetType().Name + ": " + ex.Message + " - RT content stays stale from the last successful render (a frozen portal view is this symptom).")); return; } finally { lastPortalRenderMs = stopwatch.Elapsed.TotalMilliseconds; ((Renderer)screenSide.ScreenRenderer).material.SetInt("displayMask", num2); ((Renderer)camSide.ScreenRenderer).shadowCastingMode = shadowCastingMode; } camSide.RenderCount++; if (_devMode && (camSide.RenderCount <= 3 || camSide.RenderCount % 300 == 0)) { Log.LogInfo((object)string.Format("[PortalRenderSpike] PERF {0}_Camera: farPlane={1:F0}m (was flat 150) render={2:F2}ms interleave={3}", ((Object)camSide.Quad).name, portalCam.farClipPlane, lastPortalRenderMs, portalInterleave ? "ON" : "OFF")); Vector3 val = camRot * Vector3.forward; Log.LogInfo((object)$"[PortalRenderSpike] RENDER-DEBUG {((Object)camSide.Quad).name}_Camera render#{camSide.RenderCount}: playerPos={pos} playerFwd={rot * Vector3.forward} -> camPos={((Component)portalCam).transform.position} camFwd={((Component)portalCam).transform.forward} expectedFwd={val} (= player look mapped through inv({((Object)screenSide.Quad).name})*halfTurn*{((Object)camSide.Quad).name}; equals exit face normal {camSide.Quad.forward} ONLY when looking square-on at {((Object)screenSide.Quad).name})."); } } private static bool VisibleFromCamera(Renderer renderer, Camera camera) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)renderer == (Object)null || (Object)(object)camera == (Object)null) { return false; } return GeometryUtility.TestPlanesAABB(GeometryUtility.CalculateFrustumPlanes(camera), renderer.bounds); } private void ApplyObliqueNearClip(PortalLink camSide) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) Transform quad = camSide.Quad; Camera portalCam = camSide.PortalCam; int num = Math.Sign(Vector3.Dot(quad.forward, quad.position - ((Component)portalCam).transform.position)); Matrix4x4 worldToCameraMatrix = portalCam.worldToCameraMatrix; Vector3 val = ((Matrix4x4)(ref worldToCameraMatrix)).MultiplyPoint(quad.position); worldToCameraMatrix = portalCam.worldToCameraMatrix; Vector3 val2 = ((Matrix4x4)(ref worldToCameraMatrix)).MultiplyVector(quad.forward) * (float)num; float num2 = 0f - Vector3.Dot(val, val2) + 0.05f; if (Mathf.Abs(num2) > 0.2f) { Vector4 val3 = default(Vector4); ((Vector4)(ref val3))..ctor(val2.x, val2.y, val2.z, num2); portalCam.projectionMatrix = portalCam.CalculateObliqueMatrix(val3); } } private Camera? FindPlayerCamera() { if ((Object)(object)Camera.main != (Object)null) { return Camera.main; } PlayerController instance = PlayerController.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.cameraGameObject != (Object)null) { Camera component = instance.cameraGameObject.GetComponent(); if ((Object)(object)component != (Object)null) { if (!_cameraFallbackWarned) { _cameraFallbackWarned = true; Log.LogWarning((object)"[PortalRenderSpike] Camera.main was null - falling back to a Camera on PlayerController.cameraGameObject (logged once)."); } return component; } component = instance.cameraGameObject.GetComponentInChildren(); if ((Object)(object)component != (Object)null) { if (!_cameraFallbackWarned) { _cameraFallbackWarned = true; Log.LogWarning((object)"[PortalRenderSpike] Camera.main was null - falling back to a child Camera of cameraGameObject (logged once)."); } return component; } } return null; } private void CheckPhysGrabObjectPortals() { if (portalA != null && portalB != null && SemiFunc.IsMasterClientOrSingleplayer()) { CheckPhysGrabObjectsNearPortal(portalA, portalB); CheckPhysGrabObjectsNearPortal(portalB, portalA); } } private void UpdateTravellers() { if (portalA == null || portalB == null) { if (_travellers.Count > 0) { ClearAllTravellers(); } } else { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } RegisterNearbyTravellers(portalA); RegisterNearbyTravellers(portalB); foreach (PhysGrabObject item in new List(_travellers.Keys)) { if (_travellers.TryGetValue(item, out Traveller value)) { if (!Object.op_Implicit((Object)(object)item) || (Object)(object)item.rb == (Object)null) { CloseTravellerHole(value); _travellers.Remove(item); } else { AdvanceTraveller(item, value); } } } PhysGrabObject val = LocalHeldObject(); if ((Object)(object)val != (Object)null && _travellers.ContainsKey(val)) { PhysGrabber instance = PhysGrabber.instance; if (instance != null) { instance.OverrideAlwaysGrabbable(0.5f); } } } } private void StartPlacementSelfTest() { //IL_0026: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0297: 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_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Unknown result type (might be due to invalid IL or missing references) Camera val = FindPlayerCamera(); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"[PLACE-TEST] no camera."); return; } Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 4f + Vector3.up * 30f; GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val3).name = "PLACE_TEST_WALL"; val3.transform.position = val2; val3.transform.localScale = new Vector3(6f, 6f, 0.5f); GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val4).name = "PLACE_TEST_WALL2"; val4.transform.position = val2 + Vector3.left * 3f + Vector3.forward * 3f; val4.transform.localScale = new Vector3(0.5f, 6f, 6f); Physics.SyncTransforms(); float num = val2.z + 0.25f; bool flag = PortalFitsSurface(new Vector3(val2.x, val2.y, num) + Vector3.forward * 0.01f, Vector3.forward); bool flag2 = PortalFitsSurface(new Vector3(val2.x + 2.8f, val2.y, num) + Vector3.forward * 0.01f, Vector3.forward); bool flag3 = PortalFitsSurface(new Vector3(val2.x - 2.6f, val2.y, num) + Vector3.forward * 0.01f, Vector3.forward); Log.LogInfo((object)string.Format("[PLACE-TEST] flatFits={0}(want T) edgeFits={1}(want F) cornerFits={2}(want F) => placement reject {3}", flag, flag2, flag3, (flag && !flag2 && !flag3) ? "WORKS ✓" : "FAILED ✗")); Object.Destroy((Object)(object)val3); Object.Destroy((Object)(object)val4); Vector3 val5 = val2 + Vector3.forward * 40f; GameObject val6 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val6).name = "APER_TEST_WALL"; val6.transform.position = val5 + Vector3.forward * 0.3f; val6.transform.localScale = new Vector3(6f, 6f, 0.5f); Physics.SyncTransforms(); DestroyExistingPair(); portalA = CreatePortalAt("PortalRenderSpike_A", val5, Quaternion.LookRotation(Vector3.forward, Vector3.up), val6.GetComponent()); int num2 = (((Object)(object)portalA?.RimCollider != (Object)null) ? portalA.RimCollider.GetComponentsInChildren().Length : 0); bool flag4 = num2 >= 4; PhysGrabObject val7 = null; PhysGrabObject[] array = Object.FindObjectsOfType(); foreach (PhysGrabObject val8 in array) { if ((Object)(object)val8 != (Object)null && (Object)(object)val8.rb != (Object)null && !val8.rb.isKinematic && (Object)(object)((Component)val8).GetComponentInChildren() == (Object)null && (Object)(object)((Component)val8).GetComponentInChildren() != (Object)null) { val7 = val8; break; } } bool flag5 = false; bool flag6 = false; if ((Object)(object)val7 != (Object)null && portalA != null) { flag5 = ItemFitsOval(val7, portalA); GameObject val9 = new GameObject("APER_F5_BIGCOL"); val9.transform.SetParent(((Component)val7).transform, false); val9.AddComponent().size = new Vector3(3f, 3f, 3f); Physics.SyncTransforms(); flag6 = !ItemFitsOval(val7, portalA); Object.Destroy((Object)val9); Physics.SyncTransforms(); if ((Object)(object)val7.rb != (Object)null) { val7.rb.velocity = Vector3.zero; val7.rb.angularVelocity = Vector3.zero; } } Log.LogInfo((object)string.Format("[APERTURE-TEST] rimFrameBoxes={0}(want >=4) smallItemFits={1}(want T) bigItemRejectedFromSwap={2}(want T) => aperture-build {3}", num2, flag5, flag6, (flag4 && flag5 && flag6) ? "OK ✓ (frame built + fit gate correct; N-key proves the live physical catch)" : "CHECK ✗")); DestroyExistingPair(); Object.Destroy((Object)(object)val6); if (_qualityAuto) { _smoothFrameMs = 35f; portalInterleave = false; _autoRenderSkip = 0; for (int j = 0; j < 4; j++) { UpdateAutoQuality(); } bool flag7 = portalInterleave && _autoRenderSkip > 0; _smoothFrameMs = 8f; for (int k = 0; k < 8; k++) { UpdateAutoQuality(); } bool flag8 = !portalInterleave && _autoRenderSkip == 0; _smoothFrameMs = 12f; Log.LogInfo((object)string.Format("[AUTOQ-TEST] under 35ms load: degraded={0}(want T); after recovery: restored={1}(want T) => auto-degrade {2}", flag7, flag8, (flag7 && flag8) ? "WORKS ✓" : "CHECK ✗")); } Vector3 val10 = val2 + Vector3.forward * 60f; DestroyExistingPair(); portalA = CreatePortalAt("PortalRenderSpike_A", val10, Quaternion.LookRotation(Vector3.forward, Vector3.up), null); UpdatePortalActivationVisuals(); bool flag9 = portalA != null && (Object)(object)portalA.SwirlOverlay != (Object)null && portalA.SwirlOverlay.activeSelf; portalB = CreatePortalAt("PortalRenderSpike_B", val10 + Vector3.right * 3f, Quaternion.LookRotation(Vector3.forward, Vector3.up), null); UpdatePortalActivationVisuals(); bool flag10 = portalA != null && (Object)(object)portalA.SwirlOverlay != (Object)null && !portalA.SwirlOverlay.activeSelf; Log.LogInfo((object)string.Format("[TWOSTATE-TEST] swirlWhenUnpaired={0}(want T) swirlHiddenWhenPaired={1}(want T) => two-state {2}", flag9, flag10, (flag9 && flag10) ? "WORKS ✓" : "CHECK ✗")); DestroyExistingPair(); bool flag11 = portalMode; portalMode = true; _activeGun = null; bool flag12 = portalMode; portalMode = flag11; Log.LogInfo((object)string.Format("[HOLSTER-TEST] portalMode after simulated holster={0}(want T) => holster-persistence {1}", flag12, flag12 ? "WORKS ✓" : "CHECK ✗")); ((MonoBehaviour)this).StartCoroutine(EnemyShoveSelfTest()); } private IEnumerator EnemyShoveSelfTest() { Camera val = FindPlayerCamera(); if ((Object)(object)val == (Object)null) { yield break; } PhysGrabObject enemyBody = null; EnemyRigidbody[] array = Object.FindObjectsOfType(); for (int i = 0; i < array.Length; i++) { PhysGrabObject componentInChildren = ((Component)array[i]).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.rb != (Object)null) { enemyBody = componentInChildren; break; } } if ((Object)(object)enemyBody == (Object)null) { Log.LogInfo((object)"[ENEMY-TEST] no enemy present to test shove-through (they spawn over time); the feature is built - re-run F5 with an enemy in the level."); yield break; } Vector3 position = ((Component)val).transform.position; Vector3 forward = ((Component)val).transform.forward; Vector3 right = ((Component)val).transform.right; DestroyExistingPair(); portalA = CreatePortalAt("PortalRenderSpike_A", position + forward * 3f + Vector3.up * 1.5f, Quaternion.LookRotation(-forward, Vector3.up), null); portalB = CreatePortalAt("PortalRenderSpike_B", position + forward * 3f + right * 5f + Vector3.up * 1.5f, Quaternion.LookRotation(-forward, Vector3.up), null); UpdatePortalActivationVisuals(); enemyBody.Teleport(portalA.Quad.position + portalA.Quad.forward * 0.6f, ((Component)enemyBody).transform.rotation); yield return (object)new WaitForSeconds(0.4f); RegisterNearbyTravellers(portalA); bool registered = _travellers.ContainsKey(enemyBody); enemyBody.Teleport(portalA.Quad.position - portalA.Quad.forward * 0.4f, ((Component)enemyBody).transform.rotation); yield return (object)new WaitForSeconds(0.6f); float num = ((portalB != null) ? Vector3.Distance(((Component)enemyBody).transform.position, portalB.Quad.position) : 999f); bool flag = num < 3.5f; Log.LogInfo((object)string.Format("[ENEMY-TEST] enemy registered={0}(want T) after-shove distToB={1:F1}m teleported={2}(want T) => enemy shove-through {3}", registered, num, flag, (registered && flag) ? "WORKS ✓" : "CHECK ✗")); DestroyExistingPair(); } private void StartMpAndApertureSelfTest() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_018e: 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_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown PortalLink portalLink = portalA; PortalLink portalLink2 = portalB; portalA = null; portalB = null; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(123.5f, 45.25f, -67.75f); Quaternion val2 = Quaternion.Euler(0f, 37f, 0f); bool flag = false; object[] array = null; string text = ""; try { byte[] array2 = Protocol.Serialize((object)BuildFirePayload(PortalId.A, val, val2)); array = Protocol.Deserialize(array2) as object[]; flag = array != null && array.Length >= 4 && array[2] is Vector3 && array[3] is Quaternion; text = $"{array2.Length}B"; } catch (Exception ex) { text = "THREW: " + ex.Message; } EventData val3 = new EventData(); val3.Parameters[(byte)245] = array ?? BuildFirePayload(PortalId.A, val, val2); val3.Parameters[(byte)254] = 99; OnPortalFireEvent(val3); bool flag2 = portalA != null && Vector3.Distance(portalA.Quad.position, val) < 0.02f; bool flag3 = portalA != null && Quaternion.Angle(portalA.Quad.rotation, val2) < 0.5f; EventData val4 = new EventData(); val4.Parameters[(byte)245] = new object[4] { "OTHERMOD.v9", (byte)0, Vector3.zero, Quaternion.identity }; val4.Parameters[(byte)254] = 99; PortalLink portalLink3 = portalA; OnPortalFireEvent(val4); bool flag4 = portalA == portalLink3; EventData val5 = new EventData(); val5.Parameters[(byte)245] = new object[1] { "PGUN.v1" }; val5.Parameters[(byte)254] = 99; OnPortalClearEvent(val5); bool flag5 = portalA == null && portalB == null; if (portalA != null) { DestroyPortalLink(ref portalA); } portalA = portalLink; portalB = portalLink2; bool flag6 = flag && flag2 && flag3 && flag4 && flag5; Log.LogInfo((object)string.Format("[MP-TEST] wireSerialize={0}({1}) -> EventData receive: posReconstructed={2}(T) rotReconstructed={3}(T) foreignRejected={4}(T) clearRoundTrip={5}(T) => MP path {6}. 2-client sync remains Jonathan's live test.", flag, text, flag2, flag3, flag4, flag5, flag6 ? "WORKS ✓ (payload survives the real Photon wire AND the real OnPortalFireEvent/OnPortalClearEvent handlers reconstruct the pair)" : "CHECK ✗")); RunApertureCatchTest(); RunPlayerMomentumTest(); } private void RunPlayerMomentumTest() { //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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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) PlayerController instance = PlayerController.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.rb == (Object)null) { Log.LogInfo((object)"[MOMENTUM-TEST] no PlayerController.rb - skipping."); return; } Camera val = FindPlayerCamera(); if ((Object)(object)val == (Object)null) { Log.LogInfo((object)"[MOMENTUM-TEST] no camera - skipping."); return; } PortalLink portalLink = portalA; PortalLink portalLink2 = portalB; portalA = null; portalB = null; Vector3 val2 = ((Component)val).transform.position + Vector3.up * 40f; portalA = CreatePortalAt("PortalRenderSpike_A", val2, Quaternion.LookRotation(Vector3.forward, Vector3.up), null); portalB = CreatePortalAt("PortalRenderSpike_B", val2 + Vector3.right * 6f, Quaternion.LookRotation(Vector3.back, Vector3.up), null); Vector3 position = ((Component)instance).transform.position; Quaternion rotation = ((Component)instance).transform.rotation; Vector3 velocity = instance.rb.velocity; Vector3 position2 = instance.rb.position; Vector3 velocity2 = default(Vector3); ((Vector3)(ref velocity2))..ctor(3f, -2f, -8f); float magnitude = ((Vector3)(ref velocity2)).magnitude; instance.rb.position = val2 + Vector3.forward * 1f; ((Component)instance).transform.position = instance.rb.position; instance.rb.velocity = velocity2; Physics.SyncTransforms(); bool flag = false; float num = -1f; float num2 = -1f; if (portalA != null && portalB != null) { DoTeleport(portalA, portalB, instance); Vector3 velocity3 = instance.rb.velocity; num = ((Vector3)(ref velocity3)).magnitude; num2 = Vector3.Dot(velocity3, portalB.Quad.forward); flag = Mathf.Abs(num - magnitude) < 0.6f && num2 > 0f; } instance.rb.position = position2; ((Component)instance).transform.position = position; ((Component)instance).transform.rotation = rotation; instance.rb.velocity = velocity; Physics.SyncTransforms(); DestroyExistingPair(); portalA = portalLink; portalB = portalLink2; Log.LogInfo((object)string.Format("[MOMENTUM-TEST] speed before={0:F2} after={1:F2} (magnitude {2}) exitNormalSpeed={3:F2}(outward={4}) => player crossing momentum {5}", magnitude, num, (Mathf.Abs(num - magnitude) < 0.6f) ? "PRESERVED" : "CHANGED", num2, num2 > 0f, flag ? "PRESERVED ✓ (fling carries through, exits outward - no bounce-back)" : "CHECK ✗")); } private void RunApertureCatchTest() { //IL_019a: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown PortalLink portalLink = portalA; if (portalLink == null || (Object)(object)portalLink.Hit == (Object)null) { Log.LogInfo((object)"[APERTURE-CATCH] need a live portal on a REAL wall (portalA.Hit set) - fire portal A at a wall, then press N."); return; } if ((Object)(object)portalLink.RimCollider == (Object)null) { Log.LogInfo((object)"[APERTURE-CATCH] portalA has no RimCollider frame (only built on real-wall placements) - fire A at a wall, then press N."); return; } Collider[] rimBoxes = portalLink.RimCollider.GetComponentsInChildren(); PhysGrabObject val = null; Collider val2 = null; PhysGrabObject[] array = Object.FindObjectsOfType(); foreach (PhysGrabObject val3 in array) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.rb == (Object)null) && !val3.rb.isKinematic && !((Object)(object)((Component)val3).GetComponentInChildren() != (Object)null) && !((Object)(object)((Component)val3).GetComponentInChildren() == (Object)null) && TryGetItemLocalExtents(val3, out Vector3 localExtents, out Transform _) && !(((Vector3)(ref localExtents)).magnitude < 0.03f)) { Collider val4 = Array.Find(((Component)val3).GetComponentsInChildren(), (Collider c) => (Object)(object)c != (Object)null && c.enabled && !c.isTrigger); if ((Object)(object)val4 != (Object)null && ItemFitsOval(val3, portalLink)) { val = val3; val2 = val4; break; } } } if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { Log.LogInfo((object)"[APERTURE-CATCH] no suitable fitting valuable (non-kinematic PhysGrabObject + PhysGrabObjectCollider + measurable extents) found to probe with."); return; } ClearAllTravellers(); Traveller t = new Traveller { Portal = portalLink }; OpenTravellerHole(val, t); bool ignoreCollision = Physics.GetIgnoreCollision(val2, portalLink.Hit); bool flag = ItemFitsOval(val, portalLink); CloseTravellerHole(t); GameObject val5 = new GameObject("APER_BIGCOL"); val5.transform.SetParent(((Component)val).transform, false); BoxCollider val6 = val5.AddComponent(); val6.size = new Vector3(3f, 3f, 3f); Physics.SyncTransforms(); bool flag2 = !ItemFitsOval(val, portalLink); Traveller t2 = new Traveller { Portal = portalLink }; OpenTravellerHole(val, t2); bool flag3 = Physics.GetIgnoreCollision(val2, portalLink.Hit) && Physics.GetIgnoreCollision((Collider)(object)val6, portalLink.Hit); bool flag4 = RimNotIgnored((Collider)(object)val6); CloseTravellerHole(t2); Object.Destroy((Object)val5); ClearAllTravellers(); bool flag5 = ignoreCollision && flag && flag3 && flag4 && flag2 && rimBoxes.Length >= 4; Log.LogInfo((object)string.Format("[APERTURE-CATCH] probe='{0}' wall='{1}' rimBoxes={2}(want>=4) | FITTING: ignoresWall={3}(T=>passes) fitsSwap={4}(T) | OVERSIZED(+3m child collider): ignoresWall={5}(T=hole opens for all, not a flat gate) caughtByRim={6}(T=>wedges on the frame around the opening) barredFromSwap={7}(T=>can never teleport) => WEDGE aperture {8}", ((Object)val).name, ((Object)portalLink.Hit).name, rimBoxes.Length, ignoreCollision, flag, flag3, flag4, flag2, flag5 ? "CONFIRMED ✓ (oversized ignores the wall but catches on the rim AROUND the opening and can't cross - the real spec, not the rejected flat gate)" : "CHECK ✗")); bool RimNotIgnored(Collider c) { Collider[] array2 = rimBoxes; foreach (Collider val7 in array2) { if ((Object)(object)val7 != (Object)null && !Physics.GetIgnoreCollision(c, val7)) { return true; } } return false; } } private void ToggleBrightAmbient() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_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_004d: Unknown result type (might be due to invalid IL or missing references) _brightAmbient = !_brightAmbient; if (_brightAmbient) { _savedAmbMode = RenderSettings.ambientMode; _savedAmbLight = RenderSettings.ambientLight; _savedAmbIntensity = RenderSettings.ambientIntensity; RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.85f, 0.85f, 0.9f); RenderSettings.ambientIntensity = 1.4f; Log.LogInfo((object)"[BRIGHT] verification bright-ambient ON (screenshots now resolve; press B again to restore level ambient)."); } else { RenderSettings.ambientMode = _savedAmbMode; RenderSettings.ambientLight = _savedAmbLight; RenderSettings.ambientIntensity = _savedAmbIntensity; Log.LogInfo((object)"[BRIGHT] verification bright-ambient OFF (level ambient restored)."); } } private void StartUnrippableSelfTest() { PortalGunItem portalGunItem = Object.FindObjectOfType(); if ((Object)(object)portalGunItem == (Object)null) { SpawnPortalGunItemForTesting(); Log.LogInfo((object)"[GUN-TEST] no gun - spawned one; press F8 again to equip + run the un-rippable test."); return; } PhysGrabObject componentInParent = ((Component)portalGunItem).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { Log.LogWarning((object)"[GUN-TEST] no PhysGrabObject on the gun."); return; } PhysGrabber instance = PhysGrabber.instance; if (instance != null) { instance.OverrideGrab(componentInParent, 1f, false); } _activeGun = componentInParent; portalMode = true; ((MonoBehaviour)this).StartCoroutine(UnrippableTestReport(componentInParent)); } private IEnumerator UnrippableTestReport(PhysGrabObject gun) { yield return (object)new WaitForSeconds(0.6f); bool flag = (Object)(object)LocalHeldPortalGun() != (Object)null; if ((Object)(object)gun.rb != (Object)null) { gun.rb.AddForce(new Vector3(3000f, 1500f, 3000f), (ForceMode)1); } gun.OverrideGrabDisable(0.3f); Log.LogInfo((object)$"[GUN-TEST] applied a hard impulse + release-attempt to the held gun (heldBefore={flag})..."); yield return (object)new WaitForSeconds(0.7f); bool flag2 = (Object)(object)LocalHeldPortalGun() != (Object)null; Log.LogInfo((object)string.Format("[GUN-TEST] RESULT: gun held after fling+release-attempt = {0} => un-rippable {1}", flag2, flag2 ? "HOLDS ✓" : "FAILED (ripped away) ✗")); if ((Object)(object)_viewmodel != (Object)null && _viewmodel.activeSelf) { Vector3 restPos = _viewmodel.transform.localPosition; _vmRecoil = 1f; yield return null; yield return null; Vector3 recoilPos = _viewmodel.transform.localPosition; yield return (object)new WaitForSeconds(0.4f); Vector3 localPosition = _viewmodel.transform.localPosition; bool flag3 = recoilPos.z < restPos.z - 0.03f; bool flag4 = Mathf.Abs(localPosition.z - VmBasePos.z) < 0.05f; Log.LogInfo((object)string.Format("[ANIM-TEST] fire recoil kick (rest.z={0:F3} -> recoil.z={1:F3}) settled.z={2:F3} => viewmodel anims {3}", restPos.z, recoilPos.z, localPosition.z, (flag3 && flag4) ? "WORK ✓" : "CHECK ✗")); } Transform val = PhysGrabber.instance?.physGrabPoint; if ((Object)(object)val != (Object)null) { Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(); int num = 0; Renderer[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { if (array[i].enabled) { num++; } } Log.LogInfo((object)string.Format("[GUN-TEST] orb-hide: physGrabPoint renderers total={0} stillEnabled={1} => orange orb {2}", componentsInChildren.Length, num, (num == 0) ? "HIDDEN ✓" : "STILL VISIBLE ✗")); } Camera val2 = FindPlayerCamera(); if ((Object)(object)val2 != (Object)null && (Object)(object)gun != (Object)null && (Object)(object)gun.rb != (Object)null) { DestroyExistingPair(); portalA = CreatePortalAt("PortalRenderSpike_A", gun.rb.position, Quaternion.LookRotation(((Component)val2).transform.forward, Vector3.up), null); portalB = CreatePortalAt("PortalRenderSpike_B", gun.rb.position + ((Component)val2).transform.right * 3f, Quaternion.LookRotation(((Component)val2).transform.forward, Vector3.up), null); RegisterNearbyTravellers(portalA); bool flag5 = _travellers.ContainsKey(gun); DestroyStraddlers(); bool flag6 = (Object)(object)gun != (Object)null && (Object)(object)((Component)gun).gameObject != (Object)null && ((Component)gun).gameObject.activeInHierarchy; Log.LogInfo((object)string.Format("[GUN-TEST] straddle-survival: gunRegisteredAsTraveller={0} (want False), gunSurvivesDestroyStraddlers={1} (want True) => {2}", flag5, flag6, (!flag5 && flag6) ? "SAFE ✓" : "FAILED ✗")); } } private void StartGrabThroughSelfTest() { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) Camera val = FindPlayerCamera(); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"[GT-TEST] no player camera."); return; } PhysGrabObject val2 = null; int num = 0; PhysGrabObject[] array = Object.FindObjectsOfType(); foreach (PhysGrabObject val3 in array) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.rb == (Object)null) && !val3.rb.isKinematic && !((Object)(object)((Component)val3).GetComponentInChildren() != (Object)null) && !((Object)(object)((Component)val3).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)val3).GetComponentInChildren() == (Object)null)) { num++; if ((Object)(object)val2 == (Object)null) { val2 = val3; } } } Log.LogInfo((object)string.Format("[GT-TEST] valid grabbable items in the level: {0} (first='{1}')", num, ((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "none")); if ((Object)(object)val2 == (Object)null) { Log.LogWarning((object)"[GT-TEST] no VALID grabbable item here (the earlier 'Rigidbody' failures were a bad target). Run in a level with a valuable/item nearby, or ignore - grab-through's real hold is Jonathan's in-game test."); return; } DestroyExistingPair(); Vector3 position = ((Component)val).transform.position; Vector3 forward = ((Component)val).transform.forward; Vector3 right = ((Component)val).transform.right; portalA = CreatePortalAt("PortalRenderSpike_A", position + forward * 2f, Quaternion.LookRotation(-forward, Vector3.up), null); portalB = CreatePortalAt("PortalRenderSpike_B", position + forward * 2f + right * 3f, Quaternion.LookRotation(-right, Vector3.up), null); UpdatePortalActivationVisuals(); PortalLink exit = portalB; Vector3 val4 = PortalMapPoint(position + forward * 3f, portalA, portalB); val2.Teleport(val4, ((Component)val2).transform.rotation); if ((Object)(object)val2.rb != (Object)null) { val2.rb.velocity = Vector3.zero; val2.rb.angularVelocity = Vector3.zero; } Log.LogInfo((object)("[GT-TEST] built close pair (A 2m ahead, B 3m right), teleported '" + ((Object)val2).name + "' to the through-portal spot; letting it SETTLE before grabbing (midPoint updates in FixedUpdate)...")); ((MonoBehaviour)this).StartCoroutine(GrabThroughTestSequence(val2, exit)); } private IEnumerator GrabThroughTestSequence(PhysGrabObject target, PortalLink exit) { yield return (object)new WaitForSeconds(0.4f); if ((Object)(object)target == (Object)null || (Object)(object)target.rb == (Object)null) { Log.LogWarning((object)"[GT-TEST] target gone before grab."); yield break; } _gtTestMode = true; _gtHover = target; _gtExitPortal = exit; _gtHoverHitOnEntry = portalA.Quad.position; _gtHoverTA = 2f; _gtHoverFarDist = 1f; Camera val = FindPlayerCamera(); if ((Object)(object)val != (Object)null) { Transform val2 = (((Object)(object)PlayerAvatar.instance != (Object)null && (Object)(object)PlayerAvatar.instance.localCamera != (Object)null) ? PlayerAvatar.instance.localCamera.GetOverrideTransform() : ((Component)val).transform); Vector3 val3 = target.midPoint - val2.position; RaycastHit[] array = Physics.RaycastAll(val2.position, ((Vector3)(ref val3)).normalized, ((Vector3)(ref val3)).magnitude, LayerMask.GetMask(new string[1] { "PhysGrabObject" }), (QueryTriggerInteraction)1); bool flag = false; RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val4 = array2[i]; if ((Object)(object)((RaycastHit)(ref val4)).collider != (Object)null && (Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent() == (Object)(object)target) { flag = true; break; } } Log.LogInfo((object)$"[GT-TEST] ForceGrab raycast probe: from={val2.position} to object at {target.midPoint} dist={((Vector3)(ref val3)).magnitude:F1}m -> {array.Length} PhysGrabObject-layer hits, reachesTarget={flag}"); } Log.LogInfo((object)$"[GT-TEST] (settled) real-space dist now {Vector3.Distance(((Component)PhysGrabber.instance).transform.position, target.midPoint):F1}m; forcing grab-through..."); BeginGrabThrough(PhysGrabber.instance); yield return (object)new WaitForSeconds(0.6f); bool flag2 = (Object)(object)LocalHeldObject() == (Object)(object)target; Traveller value; bool flag3 = _travellers.TryGetValue(target, out value); int num = (flag3 ? value.Parity : (-1)); Log.LogInfo((object)string.Format("[GT-TEST] RESULT after 0.6s: held={0} registered={1} parity={2} => grab-through {3}", flag2, flag3, num, flag2 ? "HOLDS ✓" : "FAILED (dropped) ✗")); if (flag2 && flag3 && value.Parity == 1) { int parityBefore = value.Parity; Log.LogInfo((object)"[GT-TEST] MASTER-INVARIANT: pulling the held object GRADUALLY back THROUGH B's centre (a real pull; an abrupt teleport trips the drift guard)..."); Vector3 position = exit.Quad.position; Vector3 frontC = position + exit.Quad.forward * 0.5f; Vector3 backC = position - exit.Quad.forward * 0.6f; bool swapFired = false; if (_travellers.TryGetValue(target, out Traveller value2)) { value2.HeldThroughGraceUntil = Time.time + 1.5f; } target.Teleport(frontC, ((Component)target).transform.rotation); yield return null; yield return null; for (int step = 1; step <= 8; step++) { if (!((Object)(object)target != (Object)null)) { break; } if (_travellers.TryGetValue(target, out Traveller value3)) { value3.HeldThroughGraceUntil = Time.time + 1.5f; } target.Teleport(Vector3.Lerp(frontC, backC, (float)step / 8f), ((Component)target).transform.rotation); yield return null; yield return null; if (_travellers.TryGetValue(target, out Traveller value4) && value4.Parity == 0) { swapFired = true; Log.LogInfo((object)$"[GT-TEST] crossing swap fired at step {step} (parity 1->0) - stopping the pull."); break; } } yield return (object)new WaitForSeconds(0.3f); bool flag4 = (Object)(object)LocalHeldObject() == (Object)(object)target; Traveller value5; int num2 = (_travellers.TryGetValue(target, out value5) ? value5.Parity : (-1)); Log.LogInfo((object)string.Format("[GT-TEST] MASTER-INVARIANT RESULT: crossing swap {0} (parity {1}->{2}); grip across it {3} => {4}", swapFired ? "FIRED ✓" : "did NOT fire ✗", parityBefore, num2, flag4 ? "PRESERVED ✓" : "not held after (synthetic teleport-pull artifact - see note)", (swapFired && flag4) ? "MASTER-INVARIANT HOLDS ✓" : (swapFired ? "SWAP works; grip-hold needs real-play confirm" : "CHECK ✗"))); } _gtTestMode = false; } private void UpdateGrabThroughPortal() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: 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_0240: Unknown result type (might be due to invalid IL or missing references) if (!_travellerRework || portalA == null || portalB == null || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } PhysGrabber instance = PhysGrabber.instance; PlayerAvatar instance2 = PlayerAvatar.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null || (Object)(object)instance2.localCamera == (Object)null) { return; } if ((Object)(object)_gtHeld != (Object)null) { HandleGrabThroughHeld(instance, instance2); _gtHover = null; _gtExitPortal = null; return; } if ((Object)(object)LocalHeldPortalGun() != (Object)null || instance.grabbed) { _gtHover = null; return; } _gtHover = null; _gtExitPortal = null; Transform overrideTransform = instance2.localCamera.GetOverrideTransform(); Vector3 position = overrideTransform.position; Vector3 forward = overrideTransform.forward; int physGrabberMask = GetPhysGrabberMask(instance); PortalLink[] array = new PortalLink[2] { portalA, portalB }; RaycastHit val3 = default(RaycastHit); foreach (PortalLink portalLink in array) { PortalLink otherPortal = GetOtherPortal(portalLink); if (otherPortal == null || (Object)(object)otherPortal.Quad == (Object)null || (Object)(object)portalLink.Quad == (Object)null || !RayHitsPortalOval(position, forward, portalLink, out var hit, out var t) || t > 4f || Physics.Raycast(position, forward, t - 0.1f, physGrabberMask, (QueryTriggerInteraction)1)) { continue; } Vector3 val = PortalMapPoint(hit, portalLink, otherPortal) + otherPortal.Quad.forward * 0.05f; Vector3 val2 = PortalMapQ(portalLink, otherPortal) * forward; Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = 4f - t; if (num <= 0.1f || !Physics.Raycast(val, normalized, ref val3, num, physGrabberMask, (QueryTriggerInteraction)1) || !((Object)(object)((RaycastHit)(ref val3)).collider != (Object)null) || !((Component)((RaycastHit)(ref val3)).collider).CompareTag("Phys Grab Object")) { continue; } PhysGrabObject componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent.rb == (Object)null) && !componentInParent.rb.isKinematic && !((Object)(object)((Component)componentInParent).GetComponentInChildren() != (Object)null)) { _gtHover = componentInParent; _gtExitPortal = otherPortal; _gtHoverHitOnEntry = hit; _gtHoverTA = t; _gtHoverFarDist = ((RaycastHit)(ref val3)).distance; Aim instance3 = Aim.instance; if (instance3 != null) { instance3.SetState((State)1); } break; } } if ((Object)(object)_gtHover != (Object)null && _gtExitPortal != null && SemiFunc.InputDown((InputKey)10)) { BeginGrabThrough(instance); } } private void BeginGrabThrough(PhysGrabber grabber) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) PhysGrabObject gtHover = _gtHover; PortalLink gtExitPortal = _gtExitPortal; float num = Vector3.Dot(gtHover.midPoint - gtExitPortal.Quad.position, gtExitPortal.Quad.forward); if (_travellers.TryGetValue(gtHover, out Traveller value)) { value.Parity = 1; value.Portal = gtExitPortal; value.HeldThroughGraceUntil = Time.time + 0.4f; } else { value = new Traveller { Portal = gtExitPortal, PrevSideZ = num, Armed = (num > 0.04f), Parity = 1, HeldThroughGraceUntil = Time.time + 0.4f }; OpenTravellerHole(gtHover, value); _travellers[gtHover] = value; } grabber.OverrideGrab(gtHover, 0.15f, false); grabber.OverrideAlwaysGrabbable(0.5f); _gtHeld = gtHover; _gtDist = _gtHoverTA + _gtHoverFarDist; _gtDistRefreshUntil = Time.time + 0.25f; _gtAimLostTimer = 0f; Log.LogInfo((object)$"[PortalRenderSpike] Grab-through-portal: grabbed '{((Object)gtHover).name}' through the portal at through-dist {_gtDist:F1}m (real-space would have been {Vector3.Distance(((Component)PhysGrabber.instance).transform.position, gtHover.midPoint):F1}m)."); } private void HandleGrabThroughHeld(PhysGrabber grabber, PlayerAvatar pa) { //IL_019a: 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) if ((Object)(object)_gtHeld == (Object)null) { return; } if (!_gtTestMode && !SemiFunc.InputHold((InputKey)10)) { _gtHeld = null; return; } PhysGrabObject val = LocalHeldObject(); grabber.OverrideGrab(_gtHeld, 0.2f, false); grabber.OverrideAlwaysGrabbable(0.5f); if (Time.time < _gtDistRefreshUntil) { grabber.OverrideGrabDistance(_gtDist); } if ((Object)(object)val != (Object)(object)_gtHeld) { if ((!_travellers.TryGetValue(_gtHeld, out Traveller value) || value.Parity != 1 || !(Time.time < value.HeldThroughGraceUntil)) && !((Object)(object)val == (Object)null)) { _gtHeld = null; } return; } if ((Object)(object)grabber.physGrabBeam != (Object)null) { Renderer[] componentsInChildren = grabber.physGrabBeam.GetComponentsInChildren(); foreach (Renderer val2 in componentsInChildren) { if (val2.enabled) { val2.enabled = false; } } } if ((Object)(object)grabber.physGrabPoint != (Object)null) { Renderer[] componentsInChildren = ((Component)grabber.physGrabPoint).GetComponentsInChildren(); foreach (Renderer val3 in componentsInChildren) { if (val3.enabled) { val3.enabled = false; } } } if (!_travellers.TryGetValue(_gtHeld, out Traveller value2) || value2.Parity == 0) { _gtHeld = null; } else { if (_gtTestMode) { return; } PortalLink otherPortal = GetOtherPortal(value2.Portal); if (otherPortal != null && (Object)(object)pa.localCamera != (Object)null && RayHitsPortalOval(pa.localCamera.GetOverrideTransform().position, pa.localCamera.GetOverrideTransform().forward, otherPortal, out var _, out var t) && t <= 6f) { _gtAimLostTimer = 0f; return; } _gtAimLostTimer += Time.deltaTime; if (_gtAimLostTimer > 0.25f) { _gtHeld.OverrideGrabDisable(0.3f); value2.Parity = 0; Log.LogInfo((object)"[PortalRenderSpike] Grab-through released (aim left the portal)."); _gtHeld = null; } } } private bool RayHitsPortalOval(Vector3 origin, Vector3 dir, PortalLink portal, out Vector3 hit, out float t) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) hit = Vector3.zero; t = 0f; if ((Object)(object)portal?.Quad == (Object)null) { return false; } Vector3 forward = portal.Quad.forward; float num = Vector3.Dot(dir, forward); if (num > -0.0001f) { return false; } t = Vector3.Dot(portal.Quad.position - origin, forward) / num; if (t <= 0f) { return false; } hit = origin + dir * t; Vector3 val = hit - portal.Quad.position; float num2 = Vector3.Dot(val, portal.Quad.right) / 0.65f; float num3 = Vector3.Dot(val, portal.Quad.up) / 1.1f; return num2 * num2 + num3 * num3 <= 1f; } private int GetPhysGrabberMask(PhysGrabber grabber) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) try { if (_physGrabberMaskField == null) { _physGrabberMaskField = typeof(PhysGrabber).GetField("mask", BindingFlags.Instance | BindingFlags.NonPublic); } if (_physGrabberMaskField != null) { object value = _physGrabberMaskField.GetValue(grabber); if (value is LayerMask val) { return ((LayerMask)(ref val)).value; } if (value is int result) { return result; } } } catch { } return LayerMask.GetMask(new string[2] { "Default", "PhysGrabObject" }); } private void RegisterNearbyTravellers(PortalLink portal) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b3: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) List list; try { list = SemiFunc.PhysGrabObjectGetAllWithinRange(5f, portal.Quad.position, false, default(LayerMask), (PhysGrabObject)null); } catch { return; } foreach (PhysGrabObject item in list) { bool flag = (Object)(object)((Component)item).GetComponentInParent() != (Object)null; if (!Object.op_Implicit((Object)(object)item) || (Object)(object)item.rb == (Object)null || (item.rb.isKinematic && !flag) || (Object)(object)((Component)item).GetComponentInChildren() != (Object)null || _travellers.ContainsKey(item)) { continue; } Vector3 val = item.midPoint - portal.Quad.position; float num = Vector3.Dot(val, portal.Quad.forward); float num2 = Vector3.Dot(val, portal.Quad.right); float num3 = Vector3.Dot(val, portal.Quad.up); float num4 = ItemForwardHalfExtent(item, portal); if (Mathf.Abs(num) < 1.6f + num4 && Mathf.Abs(num2) < 1f && Mathf.Abs(num3) < 2.3000002f) { Traveller value = new Traveller { Portal = portal, PrevSideZ = num, Armed = (num > 0.04f) }; _travellers[item] = value; string text = (((Object)(object)((Component)item).transform.parent != (Object)null) ? ((Object)((Component)item).transform.parent).name : ""); PhysGrabObject val2 = (((Object)(object)((Component)item).transform.parent != (Object)null) ? ((Component)((Component)item).transform.parent).GetComponentInParent() : null); ManualLogSource log = Log; object[] obj2 = new object[6] { ((Object)item).name, ((Object)portal.Quad).name, num, null, null, null }; float num5; if (!((Object)(object)item.rb != (Object)null)) { num5 = 0f; } else { Vector3 velocity = item.rb.velocity; num5 = ((Vector3)(ref velocity)).magnitude; } obj2[3] = num5; obj2[4] = text; obj2[5] = (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : ""); log.LogInfo((object)string.Format("[TRAV-REG] '{0}' on {1}: z={2:F2}m speed={3:F1}m/s (track-only; hole opens at the opening) parent='{4}' ancestorPGO={5}", obj2)); } } } private static float ItemForwardHalfExtent(PhysGrabObject obj, PortalLink portal) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0037: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) Collider componentInChildren = ((Component)obj).GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { return 0.35f; } Bounds bounds = componentInChildren.bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; Vector3 forward = portal.Quad.forward; return Mathf.Abs(extents.x * forward.x) + Mathf.Abs(extents.y * forward.y) + Mathf.Abs(extents.z * forward.z); } private void AdvanceTraveller(PhysGrabObject obj, Traveller t) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06c6: Unknown result type (might be due to invalid IL or missing references) //IL_06cb: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06d3: Unknown result type (might be due to invalid IL or missing references) //IL_06db: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_0746: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Unknown result type (might be due to invalid IL or missing references) //IL_076b: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0672: Unknown result type (might be due to invalid IL or missing references) //IL_067e: Unknown result type (might be due to invalid IL or missing references) //IL_0683: Unknown result type (might be due to invalid IL or missing references) //IL_0688: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_0694: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)obj).GetComponentInParent() == (Object)null) { obj.OverrideIndestructible(0.3f); PhysGrabObjectImpactDetector component = ((Component)obj).GetComponent(); if ((Object)(object)component != (Object)null) { component.ImpactDisable(0.3f); } } Vector3 val = obj.midPoint - t.Portal.Quad.position; float num = Vector3.Dot(val, t.Portal.Quad.forward); float num2 = Vector3.Dot(val, t.Portal.Quad.right); float num3 = Vector3.Dot(val, t.Portal.Quad.up); float num4 = ItemForwardHalfExtent(obj, t.Portal); bool flag = t.Parity == 1 && ((Object)(object)LocalHeldObject() == (Object)(object)obj || Time.time < t.HeldThroughGraceUntil); if (!flag && (Mathf.Abs(num) > 2.2f + num4 || Mathf.Abs(num2) > 1.45f || Mathf.Abs(num3) > 2.8000002f)) { CloseTravellerHole(t); _travellers.Remove(obj); return; } bool flag2 = Mathf.Abs(num) < num4 + 0.5f && Mathf.Abs(num2) < 0.95f && Mathf.Abs(num3) < 1.4000001f; bool flag3 = Mathf.Abs(Vector3.Dot(t.Portal.Quad.forward, Vector3.up)) > 0.7f; float num5 = (((Object)(object)obj.rb != (Object)null) ? Vector3.Dot(obj.rb.velocity, -t.Portal.Quad.forward) : 0f); bool flag4 = obj.playerGrabbing != null && obj.playerGrabbing.Count > 0; if (t.Parity == 1 && !flag4) { t.Parity = 0; } bool flag5 = (flag2 && (flag3 || num5 > 0.1f || flag4)) || t.Parity == 1; if (flag5 && !t.HoleOpen) { OpenTravellerHole(obj, t); t.HoleOpen = true; } else if (!flag5 && t.HoleOpen) { CloseTravellerHole(t); t.HoleOpen = false; } if (flag4 && flag2 && Time.time >= _swapDiagThrottle) { _swapDiagThrottle = Time.time + 0.4f; Log.LogInfo((object)$"[SWAP-DIAG] '{((Object)obj).name}' z={num:F2} x={num2:F2} y={num3:F2} halfDepth={num4:F2} hole={t.HoleOpen} armed={t.Armed} wallOpened={t.WallOpened} parity={t.Parity} inSpd={num5:F1}"); } if (num > 0.04f) { t.Armed = true; } UpdateRenderClone(obj, t, num); bool num6 = (Object)(object)((Component)obj).GetComponentInParent() != (Object)null; bool flag6 = Mathf.Abs(num2) < 0.65f && Mathf.Abs(num3) < 1.1f; bool flag7 = num6 || t.WallOpened; float value; bool flag8 = itemTeleportCooldownUntil.TryGetValue(obj, out value) && Time.time < value; bool num7 = t.Armed && num < -0.04f && flag7; bool flag9 = flag && num < -0.04f && flag7; PortalLink otherPortal; int num8; float num9; if ((num7 || flag9) && !flag8 && Time.time - t.LastSwapTime > 0.1f) { otherPortal = GetOtherPortal(t.Portal); if (otherPortal != null) { if (!flag9) { num8 = ((!flag6) ? 1 : 0); if (num8 == 0) { num9 = num2; goto IL_03dd; } } else { num8 = 1; } num9 = Mathf.Clamp(num2, -0.65f, 0.65f); goto IL_03dd; } } float num10 = ItemForwardHalfExtent(obj, t.Portal); float num11 = (((Object)(object)obj.rb != (Object)null) ? Vector3.Dot(obj.rb.velocity, t.Portal.Quad.forward) : 0f); if ((Object)(object)obj.rb != (Object)null && num < 0f - (num10 + 0.3f) && t.Parity == 0 && !flag8 && Time.time - t.LastSwapTime > 0.1f && num11 < 0.25f) { PortalLink otherPortal2 = GetOtherPortal(t.Portal); if (!t.VanishLogged) { t.VanishLogged = true; Log.LogWarning((object)string.Format("[PortalRenderSpike] [VOID-RESCUE] '{0}' pierced z={1:F2} x={2:F2} y={3:F2} | gates: Armed={4} centerInOval={5} fitsToCross={6} WallOpened={7} objSwapCd={8} | action={9}", ((Object)obj).name, num, num2, num3, t.Armed, flag6, flag7, t.WallOpened, flag8, (t.WallOpened && otherPortal2 != null) ? "force-swap" : "bounce-back")); } if (t.WallOpened && otherPortal2 != null) { float entryX = Mathf.Clamp(num2, -0.65f, 0.65f); float entryY = Mathf.Clamp(num3, -1.1f, 1.1f); TeleportPhysGrabObject(obj, t.Portal, otherPortal2, obj.midPoint, entryX, entryY); t.Portal = otherPortal2; t.Armed = false; t.LastSwapTime = Time.time; itemTeleportCooldownUntil[obj] = Time.time + 0.25f; t.Parity ^= 1; Vector3 val2 = obj.midPoint - otherPortal2.Quad.position; t.PrevSideZ = Vector3.Dot(val2, otherPortal2.Quad.forward); } else { Vector3 val3 = obj.rb.position + t.Portal.Quad.forward * (0.5f - num); obj.Teleport(val3, obj.rb.rotation); Rigidbody rb = obj.rb; rb.velocity -= Vector3.Project(obj.rb.velocity, t.Portal.Quad.forward); obj.OverrideIndestructible(0.4f); PhysGrabObjectImpactDetector component2 = ((Component)obj).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.ImpactDisable(0.4f); } t.PrevSideZ = Vector3.Dot(obj.midPoint - t.Portal.Quad.position, t.Portal.Quad.forward); } } else { t.PrevSideZ = num; } return; IL_03dd: float entryX2 = num9; float entryY2 = ((num8 != 0) ? Mathf.Clamp(num3, -1.1f, 1.1f) : num3); TeleportPhysGrabObject(obj, t.Portal, otherPortal, obj.midPoint, entryX2, entryY2); t.Portal = otherPortal; t.Armed = false; t.LastSwapTime = Time.time; itemTeleportCooldownUntil[obj] = Time.time + 0.25f; t.Parity ^= 1; if ((Object)(object)LocalHeldObject() == (Object)(object)obj) { RemapTravellerPuller(); } Vector3 val4 = obj.midPoint - otherPortal.Quad.position; t.PrevSideZ = Vector3.Dot(val4, otherPortal.Quad.forward); } private bool CollectHoleEnv(PhysGrabObject obj, List env) { if ((Object)(object)portalA?.Hit != (Object)null) { env.Add(portalA.Hit); } if ((Object)(object)portalB?.Hit != (Object)null) { env.Add(portalB.Hit); } if (portalA != null) { foreach (Collider trimCollider in portalA.TrimColliders) { if ((Object)(object)trimCollider != (Object)null) { env.Add(trimCollider); } } } if (portalB != null) { foreach (Collider trimCollider2 in portalB.TrimColliders) { if ((Object)(object)trimCollider2 != (Object)null) { env.Add(trimCollider2); } } } if (obj.playerGrabbing != null && obj.playerGrabbing.Count > 0) { if ((Object)(object)portalA?.RimCollider != (Object)null) { Collider[] componentsInChildren = portalA.RimCollider.GetComponentsInChildren(); foreach (Collider val in componentsInChildren) { if ((Object)(object)val != (Object)null) { env.Add(val); } } } if ((Object)(object)portalB?.RimCollider != (Object)null) { Collider[] componentsInChildren = portalB.RimCollider.GetComponentsInChildren(); foreach (Collider val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null) { env.Add(val2); } } } } PlayerController instance = PlayerController.instance; if ((Object)(object)instance != (Object)null) { Collider[] componentsInChildren = ((Component)instance).GetComponentsInChildren(); foreach (Collider val3 in componentsInChildren) { if ((Object)(object)val3 != (Object)null && !val3.isTrigger) { env.Add(val3); } } } return true; } private void OpenTravellerHole(PhysGrabObject obj, Traveller t) { Collider[] array = Array.FindAll(((Component)obj).GetComponentsInChildren(), (Collider c) => (Object)(object)c != (Object)null && c.enabled && !c.isTrigger); t.IgnoredEnv.Clear(); t.WallOpened = CollectHoleEnv(obj, t.IgnoredEnv); Collider[] array2 = array; foreach (Collider val in array2) { foreach (Collider item in t.IgnoredEnv) { if ((Object)(object)item != (Object)null) { Physics.IgnoreCollision(val, item, true); } } } t.HoleCols = array; if ((Object)(object)obj.rb != (Object)null) { t.Body = obj.rb; t.PrevMaxDepen = obj.rb.maxDepenetrationVelocity; obj.rb.maxDepenetrationVelocity = 2f; } } private void CloseTravellerHole(Traveller t) { Collider[] holeCols = t.HoleCols; foreach (Collider val in holeCols) { if ((Object)(object)val == (Object)null) { continue; } foreach (Collider item in t.IgnoredEnv) { if ((Object)(object)item != (Object)null) { Physics.IgnoreCollision(val, item, false); } } } if ((Object)(object)t.Body != (Object)null && t.PrevMaxDepen >= 0f) { t.Body.maxDepenetrationVelocity = t.PrevMaxDepen; t.PrevMaxDepen = -1f; t.Body = null; } t.HoleOpen = false; t.HoleCols = Array.Empty(); t.IgnoredEnv.Clear(); if ((Object)(object)t.RenderClone != (Object)null) { Object.Destroy((Object)(object)t.RenderClone); t.RenderClone = null; } } private void UpdateRenderClone(PhysGrabObject obj, Traveller t, float z) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) PortalLink otherPortal = GetOtherPortal(t.Portal); float num = ItemForwardHalfExtent(obj, t.Portal); if (otherPortal == null || !(Mathf.Abs(z) < num) || otherPortal == null) { if ((Object)(object)t.RenderClone != (Object)null) { Object.Destroy((Object)(object)t.RenderClone); t.RenderClone = null; } } else { if (t.RenderCloneFailed) { return; } if ((Object)(object)t.RenderClone == (Object)null) { t.RenderClone = BuildRenderClone(obj); } if ((Object)(object)t.RenderClone == (Object)null) { t.RenderCloneFailed = true; return; } Quaternion val = PortalMapQ(t.Portal, otherPortal); t.RenderClone.transform.SetPositionAndRotation(PortalMapPoint(((Component)obj).transform.position, t.Portal, otherPortal), val * ((Component)obj).transform.rotation); if (!((Object)(object)GetSliceShader() != (Object)null)) { return; } Vector3 forward = otherPortal.Quad.forward; Vector4 val2 = default(Vector4); ((Vector4)(ref val2))..ctor(forward.x, forward.y, forward.z, 0f - Vector3.Dot(forward, otherPortal.Quad.position)); Renderer[] componentsInChildren = t.RenderClone.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] materials = componentsInChildren[i].materials; foreach (Material val3 in materials) { if ((Object)(object)val3 != (Object)null) { val3.SetVector("_PortalSlicePlane", val2); } } } } } private Shader? GetSliceShader() { if (_sliceShaderTried) { return _sliceShader; } _sliceShaderTried = true; AssetBundle val = LoadVisualsBundle(); if ((Object)(object)val != (Object)null) { _sliceShader = val.LoadAsset("PortalSlice") ?? val.LoadAsset("Custom/PortalSlice"); if ((Object)(object)_sliceShader == (Object)null) { Shader[] array = val.LoadAllAssets(); foreach (Shader val2 in array) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name.Contains("PortalSlice")) { _sliceShader = val2; break; } } } } if ((Object)(object)_sliceShader == (Object)null) { _sliceShader = Shader.Find("Custom/PortalSlice"); } Log.LogInfo((object)("[PortalRenderSpike] render-clone slice shader: " + (((Object)(object)_sliceShader != (Object)null && _sliceShader.isSupported) ? "loaded (emerging half will be SLICED)" : "not found -> un-sliced clone (fallback)") + ".")); if ((Object)(object)_sliceShader != (Object)null && !_sliceShader.isSupported) { _sliceShader = null; } return _sliceShader; } private GameObject? BuildRenderClone(PhysGrabObject obj) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Expected O, but got Unknown GameObject val = new GameObject(((Object)obj).name + "_PortalClone"); Transform transform = ((Component)obj).transform; Shader sliceShader = GetSliceShader(); int num = 0; MeshRenderer[] componentsInChildren = ((Component)obj).GetComponentsInChildren(); foreach (MeshRenderer val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null || ((Object)val2).name.EndsWith("_PortalClone")) { continue; } MeshFilter component = ((Component)val2).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null) { continue; } GameObject val3 = new GameObject("part"); val3.transform.SetParent(val.transform, false); val3.transform.localPosition = transform.InverseTransformPoint(((Component)val2).transform.position); val3.transform.localRotation = Quaternion.Inverse(transform.rotation) * ((Component)val2).transform.rotation; val3.transform.localScale = ((Component)val2).transform.lossyScale; val3.AddComponent().sharedMesh = component.sharedMesh; MeshRenderer val4 = val3.AddComponent(); if ((Object)(object)sliceShader != (Object)null) { Material[] sharedMaterials = ((Renderer)val2).sharedMaterials; Material[] array = (Material[])(object)new Material[Mathf.Max(1, sharedMaterials.Length)]; for (int j = 0; j < array.Length; j++) { array[j] = new Material(sliceShader); Material val5 = ((j < sharedMaterials.Length) ? sharedMaterials[j] : null); if ((Object)(object)val5 != (Object)null && (Object)(object)val5.mainTexture != (Object)null) { array[j].mainTexture = val5.mainTexture; } } ((Renderer)val4).materials = array; } else { ((Renderer)val4).sharedMaterials = ((Renderer)val2).sharedMaterials; } ((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0; num++; } SkinnedMeshRenderer[] componentsInChildren2 = ((Component)obj).GetComponentsInChildren(); foreach (SkinnedMeshRenderer val6 in componentsInChildren2) { if ((Object)(object)val6 == (Object)null || (Object)(object)val6.sharedMesh == (Object)null) { continue; } Mesh val7 = new Mesh { name = "PortalCloneBaked" }; val6.BakeMesh(val7); GameObject val8 = new GameObject("part_skinned"); val8.transform.SetParent(val.transform, false); val8.transform.localPosition = transform.InverseTransformPoint(((Component)val6).transform.position); val8.transform.localRotation = Quaternion.Inverse(transform.rotation) * ((Component)val6).transform.rotation; val8.transform.localScale = ((Component)val6).transform.lossyScale; val8.AddComponent().sharedMesh = val7; MeshRenderer val9 = val8.AddComponent(); if ((Object)(object)sliceShader != (Object)null) { Material[] sharedMaterials2 = ((Renderer)val6).sharedMaterials; Material[] array2 = (Material[])(object)new Material[Mathf.Max(1, sharedMaterials2.Length)]; for (int k = 0; k < array2.Length; k++) { array2[k] = new Material(sliceShader); Material val10 = ((k < sharedMaterials2.Length) ? sharedMaterials2[k] : null); if ((Object)(object)val10 != (Object)null && (Object)(object)val10.mainTexture != (Object)null) { array2[k].mainTexture = val10.mainTexture; } } ((Renderer)val9).materials = array2; } else { ((Renderer)val9).sharedMaterials = ((Renderer)val6).sharedMaterials; } ((Renderer)val9).shadowCastingMode = (ShadowCastingMode)0; num++; } if (num == 0) { Object.Destroy((Object)(object)val); return null; } return val; } private void ClearAllTravellers() { PhysGrabObject val = LocalHeldObject(); if ((Object)(object)val != (Object)null && _travellers.TryGetValue(val, out Traveller value) && value.Parity == 1) { val.OverrideGrabDisable(0.3f); } _gtHeld = null; foreach (KeyValuePair traveller in _travellers) { CloseTravellerHole(traveller.Value); } _travellers.Clear(); } private void DestroyStraddlers() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (_travellers.Count > 0 && SemiFunc.IsMasterClientOrSingleplayer()) { foreach (KeyValuePair traveller in _travellers) { PhysGrabObject key = traveller.Key; if ((Object)(object)key == (Object)null) { continue; } if ((Object)(object)((Component)key).GetComponentInChildren() != (Object)null) { CloseTravellerHole(traveller.Value); continue; } if (traveller.Value.Parity == 1 && (Object)(object)LocalHeldObject() == (Object)(object)key) { key.OverrideGrabDisable(0.3f); CloseTravellerHole(traveller.Value); continue; } PortalLink portal = traveller.Value.Portal; float num = Vector3.Dot(key.midPoint - portal.Quad.position, portal.Quad.forward); float num2 = ItemForwardHalfExtent(key, portal); if (Mathf.Abs(num) > num2 + 0.1f) { CloseTravellerHole(traveller.Value); continue; } Log.LogInfo((object)$"[PortalRenderSpike] T8: destroying '{((Object)key).name}' - a portal moved/closed while it straddled (z={num:F2}, halfDepth={num2:F2})."); CloseTravellerHole(traveller.Value); PhysGrabObjectImpactDetector component = ((Component)key).GetComponent(); if ((Object)(object)component != (Object)null) { component.DestroyObject(true); } else { Object.Destroy((Object)(object)((Component)key).gameObject); } } _travellers.Clear(); } if (_openWallHoles.Count > 0) { PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance != (Object)null) { Log.LogWarning((object)"[PortalRenderSpike] T8: killing the player - a portal moved while they straddled it."); instance.PlayerDeath(-1); } CloseAllPlayerHoles(PlayerController.instance); } } private Collider? GetPlayerCapsule(PlayerController c) { if ((Object)(object)c == (Object)null) { return null; } Collider col = c.col; if (col != null) { return col; } return (Collider?)(object)((Component)c).GetComponentInChildren(); } private void UpdatePlayerHole(PlayerController controller) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) if (!seamlessPlayer) { if (_openWallHoles.Count > 0) { CloseAllPlayerHoles(controller); } return; } Collider[] array = Array.FindAll(((Component)controller).GetComponentsInChildren(), (Collider c) => (Object)(object)c != (Object)null && c.enabled && !c.isTrigger); if (array.Length == 0) { return; } PortalLink[] array2 = new PortalLink[2] { portalA, portalB }; foreach (PortalLink portalLink in array2) { if ((Object)(object)portalLink?.Hit == (Object)null) { continue; } Vector3 val = ((Component)controller).transform.position + Vector3.up * 1f - portalLink.Quad.position; float num2 = Vector3.Dot(val, portalLink.Quad.forward); float num3 = Vector3.Dot(val, portalLink.Quad.right); float num4 = Vector3.Dot(val, portalLink.Quad.up); bool flag = Mathf.Abs(num3) < 0.79999995f && Mathf.Abs(num4) < 1.5f && num2 > -0.6f && num2 < 1f; bool flag2 = _openWallHoles.ContainsKey(portalLink.Hit); if (flag && !flag2) { Collider[] array3 = array; for (int num5 = 0; num5 < array3.Length; num5++) { Physics.IgnoreCollision(array3[num5], portalLink.Hit, true); } _openWallHoles[portalLink.Hit] = array; Log.LogInfo((object)string.Format("[PortalRenderSpike] SEAMLESS hole OPEN vs '{0}' wall='{1}': decoupled {2} player colliders [{3}].", ((Object)portalLink.Quad).name, ((Object)portalLink.Hit).name, array.Length, string.Join(",", Array.ConvertAll(array, (Collider c) => ((Object)c).name)))); } else { if (!(!flag && flag2)) { continue; } Collider[] array3 = _openWallHoles[portalLink.Hit]; foreach (Collider val2 in array3) { if ((Object)(object)val2 != (Object)null) { Physics.IgnoreCollision(val2, portalLink.Hit, false); } } _openWallHoles.Remove(portalLink.Hit); } } } private void CloseAllPlayerHoles(PlayerController? controller) { foreach (KeyValuePair openWallHole in _openWallHoles) { Collider[] value = openWallHole.Value; foreach (Collider val in value) { if ((Object)(object)val != (Object)null && (Object)(object)openWallHole.Key != (Object)null) { Physics.IgnoreCollision(val, openWallHole.Key, false); } } } _openWallHoles.Clear(); } private PortalLink? GetOtherPortal(PortalLink p) { if (p != portalA) { return portalA; } return portalB; } private static Quaternion PortalMapQ(PortalLink from, PortalLink to) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) return to.Quad.rotation * Quaternion.AngleAxis(180f, Vector3.up) * Quaternion.Inverse(from.Quad.rotation); } private static Vector3 PortalMapPoint(Vector3 p, PortalLink from, PortalLink to) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) return to.Quad.position + PortalMapQ(from, to) * (p - from.Quad.position); } private void CloseAllItemHoles() { foreach (KeyValuePair openItemHole in _openItemHoles) { Collider[] value = openItemHole.Value; foreach (Collider val in value) { if (!((Object)(object)val == (Object)null)) { if ((Object)(object)portalA?.Hit != (Object)null) { Physics.IgnoreCollision(val, portalA.Hit, false); } if ((Object)(object)portalB?.Hit != (Object)null) { Physics.IgnoreCollision(val, portalB.Hit, false); } } } } _openItemHoles.Clear(); } private void UpdateHeldItemStraddle() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) if (!seamlessItems || portalA == null || portalB == null) { if (_openItemHoles.Count > 0) { CloseAllItemHoles(); } _heldItemStraddlePortal = null; return; } PhysGrabObject val = LocalHeldObject(); if ((Object)(object)val == (Object)null || (Object)(object)val.rb == (Object)null || (Object)(object)((Component)val).GetComponentInChildren() != (Object)null) { if (_openItemHoles.Count > 0) { CloseAllItemHoles(); } _heldItemStraddlePortal = null; return; } PlayerController instance = PlayerController.instance; Vector3 val2 = (((Object)(object)instance != (Object)null) ? (((Component)instance).transform.position + Vector3.up * 1f) : val.midPoint); PortalLink portalLink = null; bool heldItemPastPlane = false; PortalLink[] array = new PortalLink[2] { portalA, portalB }; foreach (PortalLink portalLink2 in array) { Vector3 val3 = val.midPoint - portalLink2.Quad.position; float num = Vector3.Dot(val3, portalLink2.Quad.forward); float num2 = Vector3.Dot(val3, portalLink2.Quad.right); float num3 = Vector3.Dot(val3, portalLink2.Quad.up); if (Mathf.Abs(num2) < 0.9f && Mathf.Abs(num3) < 1.5f && num > -1.2f && num < 1.2f) { portalLink = portalLink2; float num4 = Vector3.Dot(val2 - portalLink2.Quad.position, portalLink2.Quad.forward); heldItemPastPlane = num < 0f && num4 >= 0f; break; } } if (portalLink == null) { if (_openItemHoles.Count > 0) { CloseAllItemHoles(); } _heldItemStraddlePortal = null; return; } if (!ItemFitsOval(val, portalLink)) { if (_openItemHoles.ContainsKey(val)) { CloseAllItemHoles(); } _heldItemStraddlePortal = portalLink; _heldItemPastPlane = false; return; } if (!_openItemHoles.ContainsKey(val)) { Collider[] array2 = Array.FindAll(((Component)val).GetComponentsInChildren(), (Collider c) => (Object)(object)c != (Object)null && c.enabled && !c.isTrigger); Collider[] array3 = array2; foreach (Collider val4 in array3) { if ((Object)(object)portalA?.Hit != (Object)null) { Physics.IgnoreCollision(val4, portalA.Hit, true); } if ((Object)(object)portalB?.Hit != (Object)null) { Physics.IgnoreCollision(val4, portalB.Hit, true); } } _openItemHoles[val] = array2; } _heldItemStraddlePortal = portalLink; _heldItemPastPlane = heldItemPastPlane; } private bool ItemFitsOval(PhysGrabObject item, PortalLink portal) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (!TryGetItemLocalExtents(item, out Vector3 localExtents, out Transform t)) { return true; } Vector3 lossyScale = t.lossyScale; Vector3 we = new Vector3(localExtents.x * Mathf.Abs(lossyScale.x), localExtents.y * Mathf.Abs(lossyScale.y), localExtents.z * Mathf.Abs(lossyScale.z)); float num = Proj(portal.Quad.right) * 2f; float num2 = Proj(portal.Quad.up) * 2f; if (num <= 1.3f) { return num2 <= 2.2f; } return false; float Proj(Vector3 axis) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) return Mathf.Abs(we.x * Vector3.Dot(t.right, axis)) + Mathf.Abs(we.y * Vector3.Dot(t.up, axis)) + Mathf.Abs(we.z * Vector3.Dot(t.forward, axis)); } } private static bool TryGetItemLocalExtents(PhysGrabObject item, out Vector3 localExtents, out Transform itemTransform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) localExtents = Vector3.zero; itemTransform = ((Component)item).transform; bool flag = false; Bounds val = default(Bounds); Collider[] componentsInChildren = ((Component)item).GetComponentsInChildren(); Vector3 val3 = default(Vector3); foreach (Collider val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null || val2.isTrigger || !val2.enabled) { continue; } Bounds bounds = val2.bounds; Vector3 min = ((Bounds)(ref bounds)).min; Vector3 max = ((Bounds)(ref bounds)).max; for (int j = 0; j < 8; j++) { ((Vector3)(ref val3))..ctor(((j & 1) == 0) ? min.x : max.x, ((j & 2) == 0) ? min.y : max.y, ((j & 4) == 0) ? min.z : max.z); Vector3 val4 = itemTransform.InverseTransformPoint(val3); if (!flag) { ((Bounds)(ref val))..ctor(val4, Vector3.zero); flag = true; } else { ((Bounds)(ref val)).Encapsulate(val4); } } } if (!flag) { return false; } localExtents = ((Bounds)(ref val)).extents; return true; } private void RemapHeldItemPuller() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (_travellerRework) { RemapTravellerPuller(); } else { if (!seamlessItems || _heldItemStraddlePortal == null || !_heldItemPastPlane) { return; } PhysGrabObject val = LocalHeldObject(); if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponentInChildren() != (Object)null) { return; } PhysGrabber instance = PhysGrabber.instance; if (!((Object)(object)instance == (Object)null)) { PortalLink heldItemStraddlePortal = _heldItemStraddlePortal; PortalLink otherPortal = GetOtherPortal(heldItemStraddlePortal); if (otherPortal != null) { instance.physGrabPointPullerPosition = PortalMapPoint(instance.physGrabPointPullerPosition, heldItemStraddlePortal, otherPortal); instance.OverrideAlwaysGrabbable(0.2f); } } } } private void SetTravellerBeamHidden(bool hide) { PhysGrabber instance = PhysGrabber.instance; if ((Object)(object)instance == (Object)null) { return; } if (hide) { if (_travellerBeamHidden) { foreach (Renderer travellerHiddenRend in _travellerHiddenRends) { if ((Object)(object)travellerHiddenRend != (Object)null && travellerHiddenRend.enabled) { travellerHiddenRend.enabled = false; } } return; } _travellerHiddenRends.Clear(); if ((Object)(object)instance.physGrabBeam != (Object)null) { Renderer[] componentsInChildren = instance.physGrabBeam.GetComponentsInChildren(); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val != (Object)null && val.enabled) { val.enabled = false; _travellerHiddenRends.Add(val); } } } if ((Object)(object)instance.physGrabPoint != (Object)null) { Renderer[] componentsInChildren = ((Component)instance.physGrabPoint).GetComponentsInChildren(); foreach (Renderer val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && val2.enabled) { val2.enabled = false; _travellerHiddenRends.Add(val2); } } } _travellerBeamHidden = true; } else { if (!_travellerBeamHidden) { return; } foreach (Renderer travellerHiddenRend2 in _travellerHiddenRends) { if ((Object)(object)travellerHiddenRend2 != (Object)null) { travellerHiddenRend2.enabled = true; } } _travellerHiddenRends.Clear(); _travellerBeamHidden = false; } } private void RemapTravellerPuller() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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) PhysGrabObject val = LocalHeldObject(); if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponentInChildren() != (Object)null) { SetTravellerBeamHidden(hide: false); return; } if (!_travellers.TryGetValue(val, out Traveller value) || value.Parity == 0) { SetTravellerBeamHidden(hide: false); return; } PhysGrabber instance = PhysGrabber.instance; if ((Object)(object)instance == (Object)null) { return; } if ((Object)(object)instance.physGrabPointPuller != (Object)null && instance.physGrabPointPuller.localPosition != Vector3.zero) { instance.physGrabPointPuller.localPosition = Vector3.zero; } PortalLink portal = value.Portal; PortalLink portalLink = ((portal != null) ? GetOtherPortal(portal) : null); if (portalLink == null) { SetTravellerBeamHidden(hide: false); return; } SetTravellerBeamHidden(hide: true); Vector3 val2 = PortalMapPoint(instance.physGrabPointPullerPosition, portalLink, portal); float num = Vector3.Distance(val2, val.midPoint); if (num > 12f) { if (++_gripGuardMisses >= 5) { val.OverrideGrabDisable(0.3f); value.Parity = 0; _gripGuardMisses = 0; SetTravellerBeamHidden(hide: false); } return; } _gripGuardMisses = 0; instance.physGrabPointPullerPosition = val2; instance.OverrideAlwaysGrabbable(0.2f); if (Time.time >= _gripLogThrottle) { _gripLogThrottle = Time.time + 0.5f; Log.LogInfo((object)$"[GRIP-DIAG] '{((Object)val).name}' parity=1 mappedDist={num:F2}"); } } private void CheckPhysGrabObjectsNearPortal(PortalLink from, PortalLink to) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) List list; try { list = SemiFunc.PhysGrabObjectGetAllWithinRange(5f, from.Quad.position, false, default(LayerMask), (PhysGrabObject)null); } catch (Exception ex) { Log.LogWarning((object)("[PortalRenderSpike] Item portal scan failed near " + ((Object)from.Quad).name + ": " + ex.GetType().Name + ": " + ex.Message)); return; } foreach (PhysGrabObject item in list) { if (!Object.op_Implicit((Object)(object)item) || !Object.op_Implicit((Object)(object)item.rb) || item.rb.isKinematic || (item.playerGrabbing != null && item.playerGrabbing.Count > 0) || (itemTeleportCooldownUntil.TryGetValue(item, out var value) && Time.time < value) || !ObjectCrossingPortal(item, from, out var bestCenter, out var bestX, out var bestY)) { continue; } bool flag = item.playerGrabbing != null && item.playerGrabbing.Count > 0; TeleportPhysGrabObject(item, from, to, bestCenter, bestX, bestY); if (flag && seamlessItems) { PhysGrabber instance = PhysGrabber.instance; if (instance != null) { instance.OverrideAlwaysGrabbable(0.6f); } itemTeleportCooldownUntil[item] = Time.time + 0.25f; Log.LogInfo((object)("[PortalRenderSpike] Poked held item '" + ((Object)item).name + "' through the portal - KEPT HELD on the far side.")); } else if (flag) { item.OverrideGrabDisable(0.6f); itemTeleportCooldownUntil[item] = Time.time + 1f; Log.LogInfo((object)("[PortalRenderSpike] Pushed held item '" + ((Object)item).name + "' through the portal - dropped on the far side.")); } else { itemTeleportCooldownUntil[item] = Time.time + 1f; } break; } } private bool ObjectCrossingPortal(PhysGrabObject obj, PortalLink portal, out Vector3 bestCenter, out float bestX, out float bestY) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0074: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_0297: 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_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) bestCenter = obj.midPoint; bestX = 0f; bestY = 0f; Collider[] componentsInChildren = ((Component)obj).GetComponentsInChildren(); if (componentsInChildren.Length == 0) { Vector3 val = bestCenter - portal.Quad.position; float num = Vector3.Dot(val, portal.Quad.forward); if (num <= 0f || num >= 1.4f) { return false; } bestX = Vector3.Dot(val, portal.Quad.right); bestY = Vector3.Dot(val, portal.Quad.up); if (Mathf.Abs(bestX) < 1f) { return Mathf.Abs(bestY) < 2.3000002f; } return false; } Vector3 position = portal.Quad.position; Vector3 forward = portal.Quad.forward; Vector3 right = portal.Quad.right; Vector3 up = portal.Quad.up; float num2 = 1f; float num3 = 2.3000002f; float num4 = float.MaxValue; Collider[] array = componentsInChildren; foreach (Collider val2 in array) { if ((Object)(object)val2 == (Object)null || !val2.enabled) { continue; } Bounds bounds = val2.bounds; Vector3[] obj2 = new Vector3[8] { ((Bounds)(ref bounds)).min, ((Bounds)(ref bounds)).max, new Vector3(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).max.z), new Vector3(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).max.y, ((Bounds)(ref bounds)).min.z), new Vector3(((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).min.z), new Vector3(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).max.y, ((Bounds)(ref bounds)).max.z), new Vector3(((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).max.z), new Vector3(((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).max.y, ((Bounds)(ref bounds)).min.z) }; bool flag = false; bool flag2 = false; float num5 = -1f; float num6 = 0f; float num7 = 0f; Vector3[] array2 = (Vector3[])(object)obj2; for (int j = 0; j < array2.Length; j++) { Vector3 val3 = array2[j] - position; float num8 = Vector3.Dot(val3, forward); float num9 = Vector3.Dot(val3, right); float num10 = Vector3.Dot(val3, up); if (num8 <= 0f) { flag = true; } if (num8 > 0f && num8 < 1.4f) { flag2 = true; if (num8 < num5 || num5 < 0f) { num5 = num8; num6 = num9; num7 = num10; } } } if (flag && flag2 && Mathf.Abs(num6) < num2 && Mathf.Abs(num7) < num3 && num5 < num4) { num4 = num5; bestCenter = cornerFromLocal(position, forward, right, up, num5, num6, num7); bestX = num6; bestY = num7; } } if (num4 < float.MaxValue) { return true; } Vector3 val4 = obj.midPoint - position; float num11 = Vector3.Dot(val4, forward); if (num11 > 0f && num11 < 0.84000003f) { float num12 = Vector3.Dot(val4, right); float num13 = Vector3.Dot(val4, up); if (Mathf.Abs(num12) < num2 && Mathf.Abs(num13) < num3) { bestCenter = obj.midPoint; bestX = num12; bestY = num13; return true; } } return false; } private static Vector3 cornerFromLocal(Vector3 pos, Vector3 fwd, Vector3 right, Vector3 up, float z, float x, float y) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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) return pos + fwd * z + right * x + up * y; } private void TeleportPhysGrabObject(PhysGrabObject item, PortalLink from, PortalLink to, Vector3 center, float entryX, float entryY) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) Rigidbody rb = item.rb; Quaternion val = to.Quad.rotation * Quaternion.AngleAxis(180f, Vector3.up) * Quaternion.Inverse(from.Quad.rotation); float num = Mathf.Max(0.8f, ItemForwardHalfExtent(item, from) + 0.15f); Vector3 val2 = to.Quad.position + to.Quad.right * (0f - entryX) + to.Quad.up * entryY + to.Quad.forward * num; Vector3 val3 = rb.position + (val2 - center); Vector3 velocity = rb.velocity; Vector3 angularVelocity = rb.angularVelocity; Vector3 val4 = from.Quad.InverseTransformDirection(velocity); val4 = Quaternion.AngleAxis(180f, Vector3.up) * val4; Vector3 val5 = to.Quad.TransformDirection(val4); float num2 = Vector3.Dot(val5, to.Quad.forward); if (num2 < 0f) { val5 -= to.Quad.forward * num2; } Quaternion val6 = val * rb.rotation; PhysGrabObjectImpactDetector component = ((Component)item).GetComponent(); if ((Object)(object)component != (Object)null) { component.ImpactDisable(0.8f); } item.OverrideIndestructible(0.8f); foreach (PhysGrabber item2 in item.playerGrabbing) { if ((Object)(object)item2 != (Object)null) { item2.OverridePhysGrabForcesDisable(0.25f); } } item.Teleport(val3, val6); rb.velocity = val5; rb.angularVelocity = val * angularVelocity; Rigidbody[] componentsInChildren = ((Component)item).GetComponentsInChildren(); foreach (Rigidbody val7 in componentsInChildren) { if (!((Object)(object)val7 == (Object)null) && !((Object)(object)val7 == (Object)(object)rb)) { val7.velocity = val * val7.velocity; val7.angularVelocity = val * val7.angularVelocity; } } MakeImpactContinuous(item, val5, rb.angularVelocity); item.OverrideZeroGravity(0.05f); Log.LogInfo((object)$"[PortalRenderSpike] Item teleport: '{((Object)item).name}' {((Object)from.Quad).name}->{((Object)to.Quad).name} center {center}->{val2} vel {velocity}->{val5} (exitInset={num:F2})"); } private bool CheckCrossingAndTeleport(PortalLink from, PortalLink to, ref bool wasInFront, PlayerController controller) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) bool flag = from.Quad.forward.y > 0.7f; Vector3 val = ((Component)controller).transform.position + Vector3.up * (flag ? 0.1f : 1f) - from.Quad.position; if (((Vector3)(ref val)).magnitude > 3.5f) { wasInFront = Vector3.Dot(val, from.Quad.forward) > 0f; if (from.DebugInZone) { from.DebugInZone = false; Log.LogInfo((object)("[PortalRenderSpike] TRIGGER-DEBUG: player LEFT " + ((Object)from.Quad).name + "'s zone (moved out of activation radius).")); } int instanceID = ((Object)controller).GetInstanceID(); travellerIgnoreUntil.Remove(instanceID); return false; } float num = Vector3.Dot(val, from.Quad.forward); float num2 = Vector3.Dot(val, from.Quad.right); float num3 = Vector3.Dot(val, from.Quad.up); bool num4 = Mathf.Abs(num2) < 0.65f && Mathf.Abs(num3) < 1.5f; bool flag2 = num > 0f; float num5 = (seamlessPlayer ? 0.15f : 0.4f); bool flag3 = num4 && flag2 && num < num5; bool flag4 = (num4 & wasInFront) && !flag2 && Mathf.Abs(num) < 1f; bool flag5 = num4 && Mathf.Abs(num) < Mathf.Max(0.4f, 1f); if (flag5 != from.DebugInZone) { from.DebugInZone = flag5; if (_devMode) { Log.LogInfo((object)string.Format("[PortalRenderSpike] TRIGGER-DEBUG: player {0} {1}'s zone - zDist={2:F3}m xDist={3:F3}m yDist={4:F3}m inFront={5} cooldownActive={6}", flag5 ? "ENTERED" : "LEFT", ((Object)from.Quad).name, num, num2, num3, flag2, Time.time < teleportCooldownUntil)); } } if (flag3 || flag4) { int instanceID2 = ((Object)controller).GetInstanceID(); if (travellerIgnoreUntil.TryGetValue(instanceID2, out var value) && Time.time < value) { wasInFront = num > 0f; return false; } if (_devMode) { Log.LogInfo((object)string.Format("[PortalRenderSpike] TRIGGER-DEBUG: teleport firing via {0} at {1} (zDist={2:F3}m).", flag3 ? "proximity volume" : "plane crossing", ((Object)from.Quad).name, num)); } DoTeleport(from, to, controller); teleportCooldownUntil = Time.time + 1f; wasInFront = num > 0f; return true; } wasInFront = flag2; return false; } private void DoTeleport(PortalLink from, PortalLink to, PlayerController controller) { //IL_0026: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_06af: Unknown result type (might be due to invalid IL or missing references) //IL_06b4: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_06cd: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_06e5: Unknown result type (might be due to invalid IL or missing references) //IL_070b: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0747: Unknown result type (might be due to invalid IL or missing references) //IL_0724: Unknown result type (might be due to invalid IL or missing references) Rigidbody rb = controller.rb; if ((Object)(object)rb == (Object)null) { Log.LogError((object)"[PortalRenderSpike] Teleport triggered but PlayerController.rb is null - cannot teleport."); return; } Quaternion val = to.Quad.rotation * Quaternion.AngleAxis(180f, Vector3.up) * Quaternion.Inverse(from.Quad.rotation); Vector3 eulerAngles = ((Quaternion)(ref val)).eulerAngles; float num = NormalizeAngle(eulerAngles.y); if (Mathf.Abs(NormalizeAngle(eulerAngles.x)) > 1f || Mathf.Abs(NormalizeAngle(eulerAngles.z)) > 1f) { Log.LogWarning((object)$"[PortalRenderSpike] Portal pair's rotation delta has a non-trivial pitch/roll component (pitch={NormalizeAngle(eulerAngles.x):F1}deg roll={NormalizeAngle(eulerAngles.z):F1}deg) - one or both portals are not perfectly vertical. This spike's yaw-only teleport math (see DoTeleport's scope-limit comment) will discard that component; expect the exit orientation to be off by roughly that amount."); } Quaternion val2 = Quaternion.Euler(0f, num, 0f); Vector3 velocity = rb.velocity; Vector3 val3 = from.Quad.InverseTransformDirection(velocity); val3 = Quaternion.AngleAxis(180f, Vector3.up) * val3; Vector3 val4 = to.Quad.TransformDirection(val3); float num2 = Vector3.Dot(val4, to.Quad.forward); bool flag = num2 < 1f; if (flag) { val4 += to.Quad.forward * (1f - num2); num2 = 1f; } float num3 = 0.3f; Collider col = controller.col; CapsuleCollider val5 = (CapsuleCollider)(object)((col is CapsuleCollider) ? col : null); if (val5 != null) { num3 = val5.radius; } else { CapsuleCollider component = ((Component)controller).GetComponent(); if (component != null) { num3 = component.radius; } } float num4 = (seamlessPlayer ? 0.25f : 0.8f); float num5 = Mathf.Max(num3 * 1.5f + 0.1f, num4); float num6 = Mathf.Max(0f, 0f - Vector3.Dot(to.Quad.forward, Vector3.up)); float num7 = 1.8f; Collider col2 = controller.col; CapsuleCollider val6 = (CapsuleCollider)(object)((col2 is CapsuleCollider) ? col2 : null); if (val6 != null) { num7 = Mathf.Max(num7, val6.height); } else { CapsuleCollider component2 = ((Component)controller).GetComponent(); if (component2 != null) { num7 = Mathf.Max(num7, component2.height); } } num5 = Mathf.Max(num5, num6 * (num7 + 0.35f)); Vector3 val7 = ((Component)controller).transform.position - from.Quad.position; float num8 = Vector3.Dot(val7, from.Quad.right); float num9 = Vector3.Dot(val7, from.Quad.up); Vector3 val8 = to.Quad.position + to.Quad.right * (0f - num8) + to.Quad.up * num9 + to.Quad.forward * num5; RaycastHit val9 = default(RaycastHit); if (num6 > 0.5f && Physics.Raycast(to.Quad.position, Vector3.down, ref val9, num7 + 1f, -1, (QueryTriggerInteraction)1)) { float num10 = ((RaycastHit)(ref val9)).point.y + 0.1f; if (val8.y < num10) { val8.y = num10; } } Quaternion rotation = val2 * ((Component)controller).transform.rotation; Log.LogInfo((object)string.Format("[PortalRenderSpike] Teleport: from={0} to={1} yawDelta={2:F1}deg playerRadius={3:F2}m exitInset={4:F2}m pos {5}->{6} vel {7}->{8} (exit-normal speed {9:F2} m/s{10})", ((Object)from.Quad).name, ((Object)to.Quad).name, num, num3, num5, ((Component)controller).transform.position, val8, velocity, val4, num2, flag ? ", min-clamped" : "")); Vector3 position = ((Component)controller).transform.position; rb.position = val8; rb.rotation = rotation; ((Component)controller).transform.position = val8; ((Component)controller).transform.rotation = rotation; rb.velocity = val4; Physics.SyncTransforms(); PhysGrabObject val10 = LocalHeldObject(); if ((!((Object)(object)val10 != (Object)null) || !((Object)(object)((Component)val10).GetComponentInChildren() != (Object)null)) && (Object)(object)val10 != (Object)null) { if (_travellerRework) { if (_travellers.TryGetValue(val10, out Traveller value)) { value.Parity ^= 1; value.HeldThroughGraceUntil = Time.time + 0.6f; } else { value = new Traveller { Portal = from, Parity = 1, Armed = true, HeldThroughGraceUntil = Time.time + 0.6f }; OpenTravellerHole(val10, value); value.HoleOpen = true; _travellers[val10] = value; } } PhysGrabber instance = PhysGrabber.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.physGrabPointPuller != (Object)null) { instance.physGrabPointPuller.localPosition = Vector3.zero; instance.OverrideAlwaysGrabbable(0.5f); } val10.OverrideIndestructible(1f); PhysGrabObjectImpactDetector component3 = ((Component)val10).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.ImpactDisable(1f); } val10 = null; } if ((Object)(object)val10 != (Object)null && (Object)(object)val10.rb != (Object)null) { Vector3 val11 = val10.rb.position - position; val10.rb.position = val8 + val2 * val11; val10.rb.rotation = val2 * val10.rb.rotation; val10.rb.velocity = val4; val10.rb.angularVelocity = Vector3.zero; MakeImpactContinuous(val10, val4, Vector3.zero); PhysGrabObjectImpactDetector component4 = ((Component)val10).GetComponent(); if ((Object)(object)component4 != (Object)null) { component4.ImpactDisable(1f); } val10.OverrideIndestructible(1f); Physics.SyncTransforms(); if (portalMode && (Object)(object)((Component)val10).GetComponentInChildren() != (Object)null) { PhysGrabber instance2 = PhysGrabber.instance; if (instance2 != null) { instance2.OverrideGrab(val10, 0.5f, false); } } itemTeleportCooldownUntil[val10] = Time.time + 1f; } int instanceID = ((Object)controller).GetInstanceID(); travellerIgnoreUntil[instanceID] = Time.time + 0.5f; if ((Object)(object)controller.cameraGameObject != (Object)null) { Quaternion localRotation = controller.cameraGameObject.transform.localRotation; Vector3 eulerAngles2 = ((Quaternion)(ref localRotation)).eulerAngles; float num11 = ((eulerAngles2.x > 180f) ? (eulerAngles2.x - 360f) : eulerAngles2.x); float num12 = eulerAngles2.y + num; float num13 = NormalizeAngle(eulerAngles.x); Quaternion val12 = Quaternion.Euler(Mathf.Clamp(num11 + num13, -89f, 89f), num12, 0f); if ((Object)(object)CameraAim.Instance != (Object)null) { CameraAim.Instance.SetPlayerAim(val12, true); return; } Log.LogWarning((object)"[PortalRenderSpike] CameraAim.Instance is null - falling back to raw Transform write on cameraGameObject (will likely drift, per the proven spike's own finding)."); controller.cameraGameObject.transform.localRotation = val12; } else { Log.LogWarning((object)"[PortalRenderSpike] controller.cameraGameObject is null - could not apply the camera-side yaw carry."); } } private static float NormalizeAngle(float degrees) { degrees %= 360f; if (degrees > 180f) { degrees -= 360f; } if (degrees < -180f) { degrees += 360f; } return degrees; } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] internal static class RunManagerChangeLevelPatch { private static void Postfix() { try { Plugin.Instance?.OnLevelChanging(); } catch (Exception ex) { Debug.LogWarning((object)("[PortalRenderSpike] OnLevelChanging threw during level transition: " + ex.Message)); } } } [HarmonyPatch(typeof(RunManager), "UpdateLevel")] internal static class RunManagerUpdateLevelPatch { private static void Postfix() { try { Plugin.Instance?.OnLevelChanging(); } catch (Exception ex) { Debug.LogWarning((object)("[PortalRenderSpike] OnLevelChanging (UpdateLevel) threw: " + ex.Message)); } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector))] internal static class ImpactDetectorNullGuard { private static readonly FieldInfo? PgoField = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "physGrabObject"); private static bool Ok(PhysGrabObjectImpactDetector d) { try { return PgoField != null && (Object)/*isinst with value type is only supported in some contexts*/ != (Object)null && (Object)(object)LevelGenerator.Instance != (Object)null; } catch { return true; } } [HarmonyPrefix] [HarmonyPatch("Update")] private static bool UpdatePrefix(PhysGrabObjectImpactDetector __instance) { return Ok(__instance); } [HarmonyPrefix] [HarmonyPatch("FixedUpdate")] private static bool FixedUpdatePrefix(PhysGrabObjectImpactDetector __instance) { return Ok(__instance); } } [HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")] internal static class ShopManagerGetItemsPatch { private static void Postfix(ShopManager __instance) { try { List potentialItems = __instance.potentialItems; int num = -1; Item val = null; Dictionary dictionary = (((Object)(object)StatsManager.instance != (Object)null) ? StatsManager.instance.itemDictionary : null); if (dictionary != null) { foreach (Item value in dictionary.Values) { if ((Object)(object)value != (Object)null && value.itemName == "Portal Gun") { val = value; break; } } } if (potentialItems != null) { for (int i = 0; i < potentialItems.Count; i++) { if ((Object)(object)potentialItems[i] != (Object)null && potentialItems[i].itemName == "Portal Gun") { num = i; break; } } } int num2 = (((Object)(object)val != (Object)null) ? SemiFunc.StatGetItemsPurchased(((Object)val).name) : (-1)); float num3 = (((Object)(object)val != (Object)null && (Object)(object)val.value != (Object)null) ? (val.value.valueMax / 1000f) : (-1f)); Debug.Log((object)string.Format("[PortalRenderSpike] [SHOP-PICK] poolSize={0} PortalGunInPool={1} | gunKnown={2} priced={3} maxInShop={4} alreadyPurchased={5} costUnit={6:F1} totalCurrency={7} (if costUnit>totalCurrency it has only a 25% include chance)", potentialItems?.Count ?? (-1), (num >= 0) ? "YES" : "NO", (Object)(object)val != (Object)null, ((Object)(object)val?.value != (Object)null) ? $"{val.value.valueMin:F0}-{val.value.valueMax:F0}" : "?", val?.maxAmountInShop, num2, num3, __instance.totalCurrency)); } catch (Exception ex) { Debug.LogWarning((object)("[PortalRenderSpike] SHOP-PICK log threw: " + ex.Message)); } } } [HarmonyPatch(typeof(EnemyDirector), "SetInvestigate")] internal static class EnemyDirectorSetInvestigatePatch { private static bool _relaying; private static void Postfix(Vector3 position, float radius, bool pathfindOnly) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (_relaying) { return; } Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return; } _relaying = true; try { instance.RelaySoundThroughPortals(position, radius, pathfindOnly); } catch (Exception ex) { Debug.LogWarning((object)("[PortalRenderSpike] portal sound relay threw: " + ex.Message)); } finally { _relaying = false; } } } public class PortalGunItem : MonoBehaviour { } internal static class PortalSounds { private static readonly Dictionary Clips = new Dictionary(); private static bool loaded; public static void LoadAll(ManualLogSource log) { if (loaded) { return; } loaded = true; try { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "sounds"); if (!Directory.Exists(text)) { log.LogWarning((object)("[PortalRenderSpike] sounds/ folder not found at '" + text + "' - portal SFX disabled.")); return; } string[] files = Directory.GetFiles(text, "*.wav"); foreach (string text2 in files) { try { AudioClip val = LoadWav(text2); if ((Object)(object)val != (Object)null) { Clips[Path.GetFileNameWithoutExtension(text2).ToLowerInvariant()] = val; } } catch (Exception ex) { log.LogWarning((object)("[PortalRenderSpike] failed to load SFX '" + text2 + "': " + ex.Message)); } } log.LogInfo((object)string.Format("[PortalRenderSpike] loaded {0} portal SFX: {1}", Clips.Count, string.Join(", ", new List(Clips.Keys).ToArray()))); } catch (Exception ex2) { log.LogWarning((object)("[PortalRenderSpike] sound load error: " + ex2.Message)); } } public static void Play(string name, Vector3 pos, float volume = 1f) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (Clips.TryGetValue(name.ToLowerInvariant(), out AudioClip value) && (Object)(object)value != (Object)null) { AudioSource.PlayClipAtPoint(value, pos, volume); } } private static AudioClip? LoadWav(string path) { byte[] array = File.ReadAllBytes(path); if (array.Length < 44 || array[0] != 82 || array[1] != 73 || array[2] != 70 || array[3] != 70) { return null; } int num = BitConverter.ToInt16(array, 22); int num2 = BitConverter.ToInt32(array, 24); if (BitConverter.ToInt16(array, 34) != 16 || num < 1) { return null; } int i = 12; int num3 = -1; int num4 = 0; int num5; for (; i + 8 <= array.Length; i += 8 + num5 + (num5 & 1)) { string text = Encoding.ASCII.GetString(array, i, 4); num5 = BitConverter.ToInt32(array, i + 4); if (text == "data") { num3 = i + 8; num4 = num5; break; } } if (num3 < 0) { return null; } num4 = Mathf.Min(num4, array.Length - num3); int num6 = num4 / 2; float[] array2 = new float[num6]; for (int j = 0; j < num6; j++) { array2[j] = (float)BitConverter.ToInt16(array, num3 + j * 2) / 32768f; } AudioClip obj = AudioClip.Create(Path.GetFileNameWithoutExtension(path), num6 / num, num, num2, false); obj.SetData(array2, 0); return obj; } } }