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.Security; using System.Security.Permissions; using BepInEx; using DbsContentApi; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using RegionsExpanded; using RegionsExpanded.CustomContent; using RegionsExpanded.Net; using RegionsExpanded.Patches; using TMPro; using UnityEngine; using UnityEngine.Animations; using UnityEngine.Playables; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RegionsExpanded")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0+afdb3ebe6374dcaa0e1a00addcf6cd0cb036f554")] [assembly: AssemblyProduct("Regions Expanded")] [assembly: AssemblyTitle("RegionsExpanded")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.0.0")] [module: UnverifiableCode] [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; } } } public class MapIconInteractable : Interactable { private int _buyInDollars; private int _depthMeters; private int _mapIndex; private bool _configured; public void Setup(MapInstance entry, int mapIndex) { _buyInDollars = entry.BuyInDollars; _depthMeters = entry.DepthMeters; _mapIndex = mapIndex; _configured = true; } public override bool IsValid(Player player) { if (!_configured) { return false; } bool mapPaidEffective = MapSelectionRoomProps.IsMapBuyInPaidFromSources(); if (MapScreenVisualCoordinator.IsMapIconInteractionGloballyLocked(mapPaidEffective)) { return false; } return true; } public override void Interact(Player player) { if (!_configured) { Logger.LogError("RegionsExpanded: MapIconInteractable.Interact: not configured (Setup not called)."); } else if ((Object)(object)player == (Object)null) { Logger.LogError("RegionsExpanded: MapIconInteractable.Interact: player is null (unexpected)."); } else if (player.refs == null || (Object)(object)player.refs.view == (Object)null || !player.refs.view.IsMine) { Logger.LogError("RegionsExpanded: MapIconInteractable.Interact ignored — refs/view missing or not local. refsNull=" + (player.refs == null) + " viewNull=" + ((Object)(object)player.refs?.view == (Object)null) + " IsMine=" + ((Object)(object)player.refs?.view != (Object)null && player.refs.view.IsMine)); } else if (_depthMeters > CustomContent.MAX_DEPTH) { Logger.LogError("RegionsExpanded: Map buy-in interact blocked — depth " + _depthMeters + "m >= MAX_DEPTH " + CustomContent.MAX_DEPTH + "."); MapBuyInRouting.PlayNoMoneySfxSynced(); } else { MapBuyInRouting.RequestDeductMapBuyIn(_buyInDollars, _mapIndex); } } } public class TestButton : Interactable { public override void Interact(Player player) { Logger.Log("TestButton: Interact"); } } public class UpgradeDropBox : MonoBehaviourPunCallbacks { public const int PhotonViewId = 996; private const float DelayBeforeEvaluate = 0.3f; private const float MaxWaitAfterClosed = 1.5f; private const float ProcessingDuration = 3f; public UpgradeDropBoxItemDetector Detector; public UpgradeDropBoxLid Lid; public GameObject Particles; private PhotonView m_photonView; private ParticleSystem[] m_particleSystems = Array.Empty(); private bool m_checkingContents; private bool m_ejecting; private bool m_processing; private float m_elapsedSinceFullyClosed; private float m_processingElapsed; private DivingBellUpgrade? m_pendingUpgrade; private float m_ignoreNewInteractionsUntilRealtime; private void Awake() { m_photonView = ((Component)this).GetComponent(); if ((Object)(object)m_photonView == (Object)null) { Logger.LogError("UpgradeDropBox: PhotonView not found on Awake! Ensure it is added before this script."); } Transform val = ((Component)this).transform.Find("Particles/Left"); Transform val2 = ((Component)this).transform.Find("Particles/Right"); ParticleSystem val3 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); ParticleSystem val4 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent() : null); if ((Object)(object)val3 == (Object)null) { Logger.LogError("UpgradeDropBox: ParticleSystem not found on Particles/Left"); } if ((Object)(object)val4 == (Object)null) { Logger.LogError("UpgradeDropBox: ParticleSystem not found on Particles/Right"); } m_particleSystems = (ParticleSystem[])((!((Object)(object)val3 != (Object)null) || !((Object)(object)val4 != (Object)null)) ? ((!((Object)(object)val3 != (Object)null)) ? ((!((Object)(object)val4 != (Object)null)) ? ((Array)Array.Empty()) : ((Array)new ParticleSystem[1] { val4 })) : new ParticleSystem[1] { val3 }) : new ParticleSystem[2] { val3, val4 }); } private void FixedUpdate() { //IL_0093: 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_00b0: 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_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_00dc: 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) if (!PhotonNetwork.IsMasterClient || !m_ejecting) { return; } if (!Lid.m_opened) { Lid.Open(); } List<(Item, Pickup)> list = Detector.CheckForItems(); if (list.Count == 0) { m_ejecting = false; } else { if (!Lid.IsHalfwayOpenForEject()) { return; } Transform transform = ((Component)this).transform; foreach (var item2 in list) { Pickup item = item2.Item2; if (!((Object)(object)item == (Object)null) && !((Object)(object)item.Rigidbody == (Object)null)) { Rigidbody rigidbody = item.Rigidbody; if (!(rigidbody.linearVelocity.y > 0.1f)) { rigidbody.AddTorque(Vector3.right * 3f, (ForceMode)1); rigidbody.AddForce(Vector3.up * 25f + -transform.forward * 6f, (ForceMode)1); } } } } } private void Update() { if (PhotonNetwork.IsMasterClient) { UpdateLogic(); } } private static bool TryGetBellUpgrade(Pickup pickup, out DivingBellUpgrade upgrade) { upgrade = DivingBellUpgrade.Radar; if ((Object)(object)pickup?.itemInstance == (Object)null) { return false; } DivingBellUpgradeItemBehaviour component = ((Component)pickup.itemInstance).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } upgrade = component.BellUpgrade; return true; } private void UpdateLogic() { if (m_processing) { m_processingElapsed += Time.deltaTime; if (m_processingElapsed >= 3f) { EndProcessing(); } return; } List<(Item, Pickup)> list = Detector.CheckForItems(); bool flag = list.Count > 0; float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup < m_ignoreNewInteractionsUntilRealtime) { if (!flag) { m_ignoreNewInteractionsUntilRealtime = 0f; } return; } if (!m_checkingContents && !m_ejecting) { if (!flag && !Lid.m_opened) { Lid.Open(); } else if (flag && Lid.m_opened) { Lid.Close(); } } if (!m_checkingContents && !m_ejecting && flag && !Lid.m_opened && Lid.IsFullyClosed()) { m_checkingContents = true; m_elapsedSinceFullyClosed = 0f; } if (!m_checkingContents) { return; } list = Detector.CheckForItems(); if (list.Count == 0) { m_checkingContents = false; m_elapsedSinceFullyClosed = 0f; if (!Lid.m_opened) { Lid.Open(); } return; } m_elapsedSinceFullyClosed += Time.deltaTime; if (m_elapsedSinceFullyClosed < 0.3f) { return; } if (m_elapsedSinceFullyClosed <= 1.5f) { if (!TryConsumeSingleBellUpgrade(list)) { BeginEject(); } } else { BeginEject(); } } private bool TryConsumeSingleBellUpgrade(List<(Item item, Pickup pickup)> items) { if (items.Count != 1 || (Object)(object)items[0].pickup == (Object)null) { return false; } Pickup item = items[0].pickup; if (!TryGetBellUpgrade(item, out var upgrade)) { return false; } item.m_photonView.RPC("RPC_Remove", (RpcTarget)2, Array.Empty()); m_checkingContents = false; m_elapsedSinceFullyClosed = 0f; BeginProcessing(upgrade); return true; } private void BeginProcessing(DivingBellUpgrade upgradeKind) { if (PhotonNetwork.InRoom && (Object)(object)m_photonView != (Object)null) { m_photonView.RPC("RPC_BeginProcessing", (RpcTarget)0, new object[2] { (int)upgradeKind, true }); } else { StartProcessingState(upgradeKind, 0f); PlayProcessingVisuals(playSfx: true); } } private void StartProcessingState(DivingBellUpgrade upgradeKind, float elapsed) { m_processing = true; m_processingElapsed = elapsed; m_pendingUpgrade = upgradeKind; } private void PlayProcessingVisuals(bool playSfx) { if ((Object)(object)Particles != (Object)null) { if (!Particles.activeSelf) { Particles.SetActive(true); } ParticleSystem[] particleSystems = m_particleSystems; foreach (ParticleSystem val in particleSystems) { val.Clear(); val.Play(); } } else { Logger.LogError("UpgradeDropBox: Particles reference is null"); } if (!playSfx) { return; } Transform val2 = ((Component)this).transform.Find("SFX/Construction"); if ((Object)(object)val2 != (Object)null) { SFX_PlayOneShot component = ((Component)val2).GetComponent(); if ((Object)(object)component != (Object)null) { component.Play(); } else { Logger.LogError("UpgradeDropBox: SFX_PlayOneShot not found on SFX/Construction"); } } else { Logger.LogError("UpgradeDropBox: child SFX/Construction not found"); } } private void StopProcessingVisuals(ParticleSystemStopBehavior stopBehavior) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) ParticleSystem[] particleSystems = m_particleSystems; foreach (ParticleSystem val in particleSystems) { val.Stop(true, stopBehavior); } } private void EndProcessing() { m_processing = false; m_processingElapsed = 0f; if (m_pendingUpgrade.HasValue) { BellUpgradeRoomProps.MasterAddUpgrade(m_pendingUpgrade.Value); m_pendingUpgrade = null; } else { Logger.LogError("UpgradeDropBox: EndProcessing called but m_pendingUpgrade is null (unexpected)."); } if (PhotonNetwork.InRoom && (Object)(object)m_photonView != (Object)null) { m_photonView.RPC("RPC_EndProcessingVisuals", (RpcTarget)0, Array.Empty()); } else { StopProcessingVisuals((ParticleSystemStopBehavior)1); } m_ignoreNewInteractionsUntilRealtime = Time.realtimeSinceStartup + 0.65f; Lid.Open(); } private void BeginEject() { m_checkingContents = false; m_elapsedSinceFullyClosed = 0f; m_ejecting = true; if (!Lid.m_opened) { Lid.Open(); } } public void SyncHatchState() { if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient && (Object)(object)m_photonView != (Object)null) { m_photonView.RPC("RPC_SyncLid", (RpcTarget)1, new object[1] { Lid.m_opened }); } } [PunRPC] public void RPC_SyncLid(bool state) { Lid.SetOpenState(state, playSfx: true, syncIfMaster: false); } [PunRPC] private void RPC_BeginProcessing(int upgradeKind, bool playSfx) { StartProcessingState((DivingBellUpgrade)upgradeKind, 0f); PlayProcessingVisuals(playSfx); } [PunRPC] private void RPC_EndProcessingVisuals() { m_processing = false; m_processingElapsed = 0f; m_pendingUpgrade = null; StopProcessingVisuals((ParticleSystemStopBehavior)1); } public override void OnPlayerEnteredRoom(Player newPlayer) { ((MonoBehaviourPunCallbacks)this).OnPlayerEnteredRoom(newPlayer); if (PhotonNetwork.IsMasterClient && !((Object)(object)m_photonView == (Object)null)) { int num = (int)(m_pendingUpgrade.HasValue ? m_pendingUpgrade.Value : ((DivingBellUpgrade)(-1))); m_photonView.RPC("RPC_SyncState", newPlayer, new object[4] { Lid.m_opened, m_processing, num, m_processingElapsed }); } } [PunRPC] private void RPC_SyncState(bool lidOpened, bool processing, int pendingUpgrade, float processingElapsed) { Lid.SetOpenState(lidOpened, playSfx: false, syncIfMaster: false); if (processing) { if (pendingUpgrade >= 0) { StartProcessingState((DivingBellUpgrade)pendingUpgrade, processingElapsed); } PlayProcessingVisuals(playSfx: false); } else { m_processing = false; m_processingElapsed = 0f; m_pendingUpgrade = null; StopProcessingVisuals((ParticleSystemStopBehavior)0); } } } public class UpgradeDropBoxItemDetector : MonoBehaviour { private Collider[] results = (Collider[])(object)new Collider[10]; public List<(Item item, Pickup pickup)> CheckForItems() { //IL_0012: 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_0027: 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) HashSet hashSet = new HashSet(); List<(Item, Pickup)> list = new List<(Item, Pickup)>(); int num = Physics.OverlapBoxNonAlloc(((Component)this).transform.position, ((Component)this).transform.lossyScale * 0.5f, results, ((Component)this).transform.rotation); for (int i = 0; i < num; i++) { Collider val = results[i]; Pickup componentInParent = ((Component)val).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent) && (Object)(object)componentInParent.itemInstance != (Object)null && (Object)(object)componentInParent.itemInstance.item != (Object)null) { Item item = componentInParent.itemInstance.item; if (hashSet.Add(componentInParent)) { list.Add((item, componentInParent)); } } } return list; } private void OnDrawGizmos() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 matrix = Gizmos.matrix; Gizmos.matrix = ((Component)this).transform.localToWorldMatrix; Gizmos.color = new Color(0f, 1f, 0f, 0.5f); Gizmos.DrawCube(Vector3.zero, Vector3.one); Gizmos.matrix = matrix; } } public class UpgradeDropBoxLid : MonoBehaviour { public UpgradeDropBox Machine; public bool m_opened = true; public float Spring = 70f; public float Drag = 0.15f; public float m_openedRotation; public float m_closedRotation = 90f; private OneDPhysicsSpring m_spring; private void Awake() { //IL_0003: 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) OneDPhysicsSpring spring = default(OneDPhysicsSpring); ((OneDPhysicsSpring)(ref spring)).Spring = Spring; ((OneDPhysicsSpring)(ref spring)).Drag = Drag; m_spring = spring; } private void Update() { //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) ((OneDPhysicsSpring)(ref m_spring)).Drag = Drag; ((OneDPhysicsSpring)(ref m_spring)).Spring = Spring; ((OneDPhysicsSpring)(ref m_spring)).Update(); ((Component)this).transform.localRotation = Quaternion.Euler(new Vector3(0f, 0f, ((OneDPhysicsSpring)(ref m_spring)).Current)); } private void FixedUpdate() { //IL_002e: 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_006b: Unknown result type (might be due to invalid IL or missing references) ((OneDPhysicsSpring)(ref m_spring)).Target = (m_opened ? m_openedRotation : m_closedRotation); ((OneDPhysicsSpring)(ref m_spring)).FixedUpdate(); m_spring = SpringClamp.BounceClamp(m_spring, Mathf.Min(m_openedRotation, m_closedRotation) - 5f, Mathf.Max(m_openedRotation, m_closedRotation) + 5f, 0.6f); } public bool IsFullyClosed() { if (m_opened) { return false; } if (Mathf.Abs(((OneDPhysicsSpring)(ref m_spring)).Current - m_closedRotation) < 3f) { return Mathf.Abs(((OneDPhysicsSpring)(ref m_spring)).Velocity) < 0.25f; } return false; } public bool IsHalfwayOpenForEject() { if (!m_opened) { return false; } float num = (m_closedRotation + m_openedRotation) * 0.5f; return ((OneDPhysicsSpring)(ref m_spring)).Current <= num + 5f; } public void Close() { SetOpenState(opened: false, playSfx: true, syncIfMaster: true); } public void Open() { SetOpenState(opened: true, playSfx: true, syncIfMaster: true); } public void SetOpenState(bool opened, bool playSfx, bool syncIfMaster) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (m_opened == opened) { return; } m_opened = opened; if (syncIfMaster && PhotonNetwork.IsMasterClient) { Machine.SyncHatchState(); } if (playSfx) { SFX_Instance val = (opened ? CustomContent.hatchOpenSfx : CustomContent.hatchCloseSfx); if ((Object)(object)val != (Object)null) { val.Play(((Component)this).transform.position, false, 1f, (Transform)null); } } } } namespace RegionsExpanded { public sealed class PlatingVisualRoot : MonoBehaviour { } public sealed class RadarVisualRoot : MonoBehaviour { } public enum ElevatorButtonDirection { Up, Down } public class ElevatorCabinButton : Interactable { public ElevatorController? elevator; public ElevatorButtonDirection direction; private bool m_onCooldown; public override bool IsValid(Player player) { ((Interactable)this).hoverText = ((direction == ElevatorButtonDirection.Up) ? "Ascend" : "Descend"); if ((Object)(object)elevator == (Object)null) { return false; } if (direction != ElevatorButtonDirection.Up) { return elevator.CanDescend; } return elevator.CanAscend; } public override void Interact(Player player) { if (!m_onCooldown && !((Object)(object)elevator == (Object)null)) { if (direction == ElevatorButtonDirection.Up) { elevator.AttemptAscend(); } else { elevator.AttemptDescend(); } ((MonoBehaviour)this).StartCoroutine(Cooldown()); } } private IEnumerator Cooldown() { m_onCooldown = true; yield return (object)new WaitForSeconds(0.5f); m_onCooldown = false; } } public enum ElevatorState { DoorClosed, DoorOpening, DoorOpen, DoorClosing, Ascending, Descending, Crashing } public class ElevatorController : MonoBehaviourPunCallbacks { public const float BottomY = 88.2f; public const float TopY = 177.4f; public const float MoveSpeed = 6f; public const int ElevatorViewId = 997; private const float CrashChance = 0.2f; private const float CrashMinHeightProgress = 0.5f; private const float CrashMaxHeightProgress = 0.9f; private const float CrashGravity = 9.81f; private const float CrashWarningDelay = 0.4f; private const float MoveGamefeelInterval = 0.21f; private const float MoveGamefeelAmount = 2f; private const float MoveGamefeelDuration = 0.2f; private const float MoveGamefeelScale = 10f; private const float MechanicalJoltGamefeelAmount = 6f; private const float MechanicalJoltGamefeelDuration = 0.2f; private const float CrashWarningGamefeelAmount = 14f; private const float CrashWarningGamefeelDuration = 0.65f; private const float CrashStartGamefeelAmount = 10f; private const float CrashStartGamefeelDuration = 0.5f; private const float CrashImpactGamefeelAmount = 36f; private const float CrashImpactGamefeelDuration = 0.6f; private const float HardGamefeelScale = 30f; public ElevatorDoor? door; public ElevatorSFX? sfx; private PhotonView? m_photonView; private Rigidbody m_rigidbody; private ElevatorState m_state; private bool m_isAtTop; public bool CanAscend { get { if (m_state == ElevatorState.DoorClosed) { return !m_isAtTop; } return false; } } public bool CanDescend { get { if (m_state == ElevatorState.DoorClosed) { return m_isAtTop; } return false; } } public bool CanToggleDoor { get { if (m_state != ElevatorState.DoorOpen) { return m_state == ElevatorState.DoorClosed; } return true; } } public bool IsDoorOpen { get { if (m_state != ElevatorState.DoorOpen) { return m_state == ElevatorState.DoorOpening; } return true; } } public ElevatorState CurrentState => m_state; private void Start() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) m_photonView = ((Component)this).GetComponent(); m_rigidbody = ((Component)this).GetComponent(); m_isAtTop = ((Component)this).transform.localPosition.y > 132.79999f; m_state = ElevatorState.DoorClosed; if ((Object)(object)door != (Object)null) { door.Init(isOpen: false); } else { Debug.LogError((object)"[ElevatorController] 'door' reference is null — did CustomContent.cs wire it?"); } if (!((Object)(object)sfx == (Object)null)) { return; } Transform val = ((Component)this).transform.Find("SFX"); if ((Object)(object)val != (Object)null) { sfx = ((Component)val).GetComponent(); if ((Object)(object)sfx == (Object)null) { sfx = ((Component)val).gameObject.AddComponent(); } } else { Debug.LogWarning((object)"[ElevatorController] cabin/SFX not found — movement sounds disabled."); } } public void AttemptToggleDoor() { if (!((Object)(object)m_photonView == (Object)null)) { if (m_state == ElevatorState.DoorOpen) { m_photonView.RPC("RPC_Close", (RpcTarget)0, Array.Empty()); } else if (m_state == ElevatorState.DoorClosed) { m_photonView.RPC("RPC_Open", (RpcTarget)0, Array.Empty()); } } } [PunRPC] public void RPC_Open() { if (m_state == ElevatorState.DoorClosed && !((Object)(object)door == (Object)null)) { m_state = ElevatorState.DoorOpening; ((MonoBehaviour)this).StartCoroutine(RunDoorAnimation(door.Open(), ElevatorState.DoorOpen)); } } [PunRPC] public void RPC_Close() { if (m_state == ElevatorState.DoorOpen && !((Object)(object)door == (Object)null)) { m_state = ElevatorState.DoorClosing; ((MonoBehaviour)this).StartCoroutine(RunDoorAnimation(door.Close(), ElevatorState.DoorClosed)); } } private IEnumerator RunDoorAnimation(IEnumerator doorRoutine, ElevatorState stateAfter) { yield return doorRoutine; m_state = stateAfter; } public void AttemptAscend() { if (CanAscend && !((Object)(object)m_photonView == (Object)null)) { float crashLocalY; bool flag = RollCrash(out crashLocalY); m_photonView.RPC("RPC_StartAscend", (RpcTarget)0, new object[2] { flag, crashLocalY }); } } public void AttemptDescend() { if (CanDescend && !((Object)(object)m_photonView == (Object)null)) { float crashLocalY; bool flag = RollCrash(out crashLocalY); m_photonView.RPC("RPC_StartDescend", (RpcTarget)0, new object[2] { flag, crashLocalY }); } } [PunRPC] public void RPC_StartAscend(bool shouldCrash, float crashLocalY) { if (m_state == ElevatorState.DoorClosed && !m_isAtTop) { m_state = ElevatorState.Ascending; BeginMovementSfx(); ((MonoBehaviour)this).StartCoroutine(MoveCabin(177.4f, shouldCrash, crashLocalY, delegate { m_isAtTop = true; m_state = ElevatorState.DoorClosed; EndMovementSfx(); })); } } [PunRPC] public void RPC_StartDescend(bool shouldCrash, float crashLocalY) { if (m_state == ElevatorState.DoorClosed && m_isAtTop) { m_state = ElevatorState.Descending; BeginMovementSfx(); ((MonoBehaviour)this).StartCoroutine(MoveCabin(88.2f, shouldCrash, crashLocalY, delegate { m_isAtTop = false; m_state = ElevatorState.DoorClosed; EndMovementSfx(); })); } } private static bool RollCrash(out float crashLocalY) { crashLocalY = Mathf.Lerp(88.2f, 177.4f, Random.Range(0.5f, 0.9f)); return Random.value < 0.2f; } private void BeginMovementSfx() { sfx?.PlayStartMove(); sfx?.StartMoveLoop(); AddMechanicalJoltGamefeel(); } private void EndMovementSfx() { sfx?.PlayArrive(); AddMechanicalJoltGamefeel(); } private void AddMoveGamefeel() { GamefeelHandler instance = GamefeelHandler.instance; if (instance != null) { PerlinShake perlin = instance.perlin; if (perlin != null) { perlin.AddShake(2f, 0.2f, 10f); } } } private void AddMechanicalJoltGamefeel() { GamefeelHandler instance = GamefeelHandler.instance; if (instance != null) { PerlinShake perlin = instance.perlin; if (perlin != null) { perlin.AddShake(6f, 0.2f, 30f); } } } private void AddCrashWarningGamefeel() { GamefeelHandler instance = GamefeelHandler.instance; if (instance != null) { PerlinShake perlin = instance.perlin; if (perlin != null) { perlin.AddShake(14f, 0.65f, 30f); } } } private void AddCrashStartGamefeel() { GamefeelHandler instance = GamefeelHandler.instance; if (instance != null) { PerlinShake perlin = instance.perlin; if (perlin != null) { perlin.AddShake(10f, 0.5f, 30f); } } } private void AddCrashImpactGamefeel() { GamefeelHandler instance = GamefeelHandler.instance; if (instance != null) { PerlinShake perlin = instance.perlin; if (perlin != null) { perlin.AddShake(36f, 0.6f, 30f); } } } private IEnumerator MoveCabin(float targetLocalY, bool shouldCrash, float crashLocalY, Action onArrived) { float nextMoveGamefeelTime = Time.time; while (true) { float y = ((Component)this).transform.localPosition.y; if (Mathf.Abs(y - targetLocalY) <= 0.01f) { break; } if (Time.time >= nextMoveGamefeelTime) { AddMoveGamefeel(); nextMoveGamefeelTime = Time.time + 0.21f; } float num = Mathf.MoveTowards(y, targetLocalY, 6f * Time.fixedDeltaTime); m_rigidbody.MovePosition(GetWorldPositionForLocalY(num)); if (shouldCrash && HasReachedCrashHeight(num, targetLocalY, crashLocalY)) { yield return (object)new WaitForFixedUpdate(); yield return RunCrashWarning(); yield return CrashToBottom(); yield break; } yield return (object)new WaitForFixedUpdate(); } m_rigidbody.MovePosition(GetWorldPositionForLocalY(targetLocalY)); onArrived?.Invoke(); } private bool HasReachedCrashHeight(float nextLocalY, float targetLocalY, float crashLocalY) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!(targetLocalY > ((Component)this).transform.localPosition.y)) { return nextLocalY <= crashLocalY; } return nextLocalY >= crashLocalY; } private IEnumerator CrashToBottom() { m_state = ElevatorState.Crashing; m_isAtTop = false; sfx?.StartCrashLoop(); AddCrashStartGamefeel(); float fallSpeed = 0f; while (((Component)this).transform.localPosition.y > 88.21f) { fallSpeed += 9.81f * Time.fixedDeltaTime; float localY = Mathf.Max(88.2f, ((Component)this).transform.localPosition.y - fallSpeed * Time.fixedDeltaTime); m_rigidbody.MovePosition(GetWorldPositionForLocalY(localY)); yield return (object)new WaitForFixedUpdate(); } Vector3 worldPositionForLocalY = GetWorldPositionForLocalY(88.2f); m_rigidbody.MovePosition(worldPositionForLocalY); sfx?.StopCrashLoop(); AddCrashImpactGamefeel(); SpawnCrashExplosion(worldPositionForLocalY); m_state = ElevatorState.DoorClosed; } private IEnumerator RunCrashWarning() { sfx?.PlayArrive(); AddCrashWarningGamefeel(); yield return (object)new WaitForSeconds(0.4f); sfx?.PlayStartMove(); AddCrashWarningGamefeel(); } private Vector3 GetWorldPositionForLocalY(float localY) { //IL_0043: 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_005e: 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_001b: 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_0036: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Component)this).transform.parent; if (!((Object)(object)parent != (Object)null)) { return new Vector3(((Component)this).transform.position.x, localY, ((Component)this).transform.position.z); } return parent.TransformPoint(new Vector3(((Component)this).transform.localPosition.x, localY, ((Component)this).transform.localPosition.z)); } private void SpawnCrashExplosion(Vector3 worldPosition) { //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_0033: 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) GameObject elevatorCrashExplosionPrefab = global::RegionsExpanded.CustomContent.CustomContent.ElevatorCrashExplosionPrefab; if ((Object)(object)elevatorCrashExplosionPrefab == (Object)null) { Debug.LogError((object)"[ElevatorController] ElevatorCrashExplosion.prefab is null; did the RegionsExpanded asset bundle load?"); return; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(worldPosition.x, 3.36f, worldPosition.z); Object.Instantiate(elevatorCrashExplosionPrefab, val, Quaternion.identity); } public override void OnPlayerEnteredRoom(Player newPlayer) { ((MonoBehaviourPunCallbacks)this).OnPlayerEnteredRoom(newPlayer); if (PhotonNetwork.IsMasterClient) { float num = (m_isAtTop ? 177.4f : 88.2f); bool isDoorOpen = IsDoorOpen; m_photonView.RPC("RPC_SyncState", newPlayer, new object[2] { num, isDoorOpen }); } } [PunRPC] public void RPC_SyncState(float cabinLocalY, bool doorOpen) { //IL_0074: 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_0044: 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_005f: 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_0069: 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) ((MonoBehaviour)this).StopAllCoroutines(); sfx?.StopMoveLoop(); sfx?.StopCrashLoop(); Transform parent = ((Component)this).transform.parent; Vector3 val = default(Vector3); if ((Object)(object)parent != (Object)null) { val = parent.TransformPoint(new Vector3(((Component)this).transform.localPosition.x, cabinLocalY, ((Component)this).transform.localPosition.z)); } else { ((Vector3)(ref val))..ctor(((Component)this).transform.position.x, cabinLocalY, ((Component)this).transform.position.z); } m_rigidbody.MovePosition(val); m_isAtTop = Mathf.Approximately(cabinLocalY, 177.4f); if (doorOpen) { m_state = ElevatorState.DoorOpen; door?.Init(isOpen: true); } else { m_state = ElevatorState.DoorClosed; door?.Init(isOpen: false); } } } public class ElevatorDoor : MonoBehaviour { public AnimationClip? openedClip; public AnimationClip? closedClip; public AnimationClip? openClip; public AnimationClip? closeClip; private Optionable m_playableGraph; private Animator m_animator; private AnimationClip? m_currentClip; private void Awake() { m_animator = ((Component)this).GetComponent(); m_animator.runtimeAnimatorController = null; } public void Init(bool isOpen) { PlayClip(isOpen ? openedClip : closedClip); } public IEnumerator Open() { if (!((Object)(object)openClip == (Object)null)) { PlayClip(openClip); yield return (object)new WaitForSeconds(openClip.length); PlayClip(openedClip); } } public IEnumerator Close() { if (!((Object)(object)closeClip == (Object)null)) { PlayClip(closeClip); yield return (object)new WaitForSeconds(closeClip.length); PlayClip(closedClip); } } public bool IsFullyClosed() { return (Object)(object)m_currentClip == (Object)(object)closedClip; } private void PlayClip(AnimationClip? clip) { //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_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_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_006c: 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_0080: 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_0086: 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) if ((Object)(object)clip == (Object)null) { Debug.LogWarning((object)"[ElevatorDoor] Attempted to play a null clip — has it been assigned in CustomContent.cs?"); return; } if (m_playableGraph.IsSome) { PlayableGraph value = m_playableGraph.Value; ((PlayableGraph)(ref value)).Destroy(); } m_currentClip = clip; PlayableGraph val = PlayableGraph.Create("ElevatorDoor: " + ((Object)clip).name); ((PlayableGraph)(ref val)).SetTimeUpdateMode((DirectorUpdateMode)1); AnimationPlayableOutput val2 = AnimationPlayableOutput.Create(val, "Animation", m_animator); PlayableOutputExtensions.SetSourcePlayable(val2, AnimationClipPlayable.Create(val, clip)); ((PlayableGraph)(ref val)).Play(); m_playableGraph = Optionable.Some(val); } private void OnDestroy() { //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) if (m_playableGraph.IsSome) { PlayableGraph value = m_playableGraph.Value; ((PlayableGraph)(ref value)).Destroy(); } } } public class ElevatorInnerZone : MonoBehaviour { private ElevatorController m_controller; private BoxCollider? m_collider; private readonly Collider[] m_overlapBuffer = (Collider[])(object)new Collider[64]; private readonly HashSet m_playersInZone = new HashSet(); public float ascendForce = 30f; public float descendForce = 30f; private void Awake() { m_controller = ((Component)this).GetComponentInParent(); m_collider = ((Component)this).GetComponent(); if ((Object)(object)m_controller == (Object)null) { Debug.LogError((object)"[ElevatorInnerZone] ElevatorController not found in parent hierarchy!"); } } private void FixedUpdate() { //IL_0087: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: 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_0074: 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_007e: 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_00a4: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0122: 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_016c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_controller == (Object)null) { return; } bool flag = m_controller.CurrentState == ElevatorState.Ascending; bool flag2 = m_controller.CurrentState == ElevatorState.Descending; if (!flag && !flag2) { return; } Vector3 val; Vector3 val2; if ((Object)(object)m_collider != (Object)null) { val = ((Component)this).transform.TransformPoint(m_collider.center); val2 = Vector3.Scale(m_collider.size * 0.5f, ((Component)this).transform.lossyScale); } else { val = ((Component)this).transform.position; val2 = ((Component)this).transform.lossyScale * 0.5f; } int num = Physics.OverlapBoxNonAlloc(val, val2, m_overlapBuffer, ((Component)this).transform.rotation); m_playersInZone.Clear(); for (int i = 0; i < num; i++) { Player componentInParent = ((Component)m_overlapBuffer[i]).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { m_playersInZone.Add(componentInParent); } } Vector3 val3 = Vector3.zero; if (flag) { val3 = Vector3.up * ascendForce; } else if (flag2) { val3 = Vector3.down * descendForce; } foreach (Player item in m_playersInZone) { if ((Object)(object)item.refs.ragdoll != (Object)null) { item.refs.ragdoll.AddForce(val3, (ForceMode)5); } } } } public class ElevatorInsideDoorButton : Interactable { public ElevatorController? elevator; public Transform? lever; private bool m_onCooldown; private bool m_isOpen; private float m_sinceSwitch = 10f; private float m_currentAngle = 50f; private string m_openText = "Open"; private string m_closeText = "Close"; private void Start() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) m_openText = LocalizationKeys.GetLocalizedString((Keys)42); m_closeText = LocalizationKeys.GetLocalizedString((Keys)43); if ((Object)(object)elevator != (Object)null) { m_isOpen = elevator.IsDoorOpen; m_currentAngle = (m_isOpen ? (-50f) : 50f); if ((Object)(object)lever != (Object)null) { lever.localEulerAngles = new Vector3(m_currentAngle, 0f, 0f); } } } private void ToggleSwitch() { if (!((Object)(object)elevator == (Object)null)) { bool isDoorOpen = elevator.IsDoorOpen; if (m_isOpen != isDoorOpen) { m_isOpen = isDoorOpen; m_sinceSwitch = 0f; } } } public override bool IsValid(Player player) { if ((Object)(object)elevator == (Object)null) { return false; } ((Interactable)this).hoverText = (elevator.IsDoorOpen ? m_closeText : m_openText); return elevator.CanToggleDoor; } public override void Interact(Player player) { if (!m_onCooldown && !((Object)(object)elevator == (Object)null)) { elevator.AttemptToggleDoor(); ((MonoBehaviour)this).StartCoroutine(Cooldown()); } } private IEnumerator Cooldown() { m_onCooldown = true; yield return (object)new WaitForSeconds(0.5f); m_onCooldown = false; } private void Update() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)elevator == (Object)null || (Object)(object)lever == (Object)null) { return; } ToggleSwitch(); m_sinceSwitch += Time.deltaTime; if (m_sinceSwitch < 5f) { if (m_isOpen) { m_currentAngle = Mathf.Lerp(m_currentAngle, -50f, Time.deltaTime * 10f); } else { m_currentAngle = Mathf.Lerp(m_currentAngle, 50f, Time.deltaTime * 10f); } lever.localEulerAngles = new Vector3(m_currentAngle, 0f, 0f); } } } public class ElevatorOutsideDoorButton : Interactable { public ElevatorController? elevator; private bool m_onCooldown; private string m_openText = "Open"; private string m_closeText = "Close"; private void Start() { m_openText = LocalizationKeys.GetLocalizedString((Keys)42); m_closeText = LocalizationKeys.GetLocalizedString((Keys)43); } public override bool IsValid(Player player) { //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_004b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)elevator == (Object)null) { return false; } ((Interactable)this).hoverText = (elevator.IsDoorOpen ? m_closeText : m_openText); if (Vector3.Angle(-((Component)MainCamera.instance).transform.forward, ((Component)this).transform.forward) > 90f) { return false; } return elevator.CanToggleDoor; } public override void Interact(Player player) { if (!m_onCooldown && !((Object)(object)elevator == (Object)null)) { elevator.AttemptToggleDoor(); ((MonoBehaviour)this).StartCoroutine(Cooldown()); } } private IEnumerator Cooldown() { m_onCooldown = true; yield return (object)new WaitForSeconds(0.5f); m_onCooldown = false; } } public class ElevatorSFX : MonoBehaviour { private const float BaseMoveVolume = 1f; private AudioLoop? m_moveLoop; private AudioLoop? m_crashLoop; private SFX_PlayOneShot? m_startMove; private SFX_PlayOneShot? m_arrive; private Coroutine? m_fadeCoroutine; private void Awake() { Transform val = ((Component)this).transform.Find("SFX_MOVE"); Transform val2 = ((Component)this).transform.Find("SFX_MOVE_CRASH"); Transform val3 = ((Component)this).transform.Find("SFX_StartMove"); Transform val4 = ((Component)this).transform.Find("SFX_Arrive"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"[ElevatorSFX] Child 'SFX_MOVE' not found.", (Object)(object)this); } else if (!((Component)val).TryGetComponent(ref m_moveLoop)) { Debug.LogError((object)"[ElevatorSFX] Child 'SFX_MOVE' has no AudioLoop component.", (Object)(object)this); } if ((Object)(object)val2 == (Object)null) { Debug.LogError((object)"[ElevatorSFX] Child 'SFX_MOVE_CRASH' not found.", (Object)(object)this); } else if (!((Component)val2).TryGetComponent(ref m_crashLoop)) { Debug.LogError((object)"[ElevatorSFX] Child 'SFX_MOVE_CRASH' has no AudioLoop component.", (Object)(object)this); } if ((Object)(object)val3 == (Object)null) { Debug.LogError((object)"[ElevatorSFX] Child 'SFX_StartMove' not found.", (Object)(object)this); } else if (!((Component)val3).TryGetComponent(ref m_startMove)) { Debug.LogError((object)"[ElevatorSFX] Child 'SFX_StartMove' has no SFX_PlayOneShot component.", (Object)(object)this); } if ((Object)(object)val4 == (Object)null) { Debug.LogError((object)"[ElevatorSFX] Child 'SFX_Arrive' not found.", (Object)(object)this); } else if (!((Component)val4).TryGetComponent(ref m_arrive)) { Debug.LogError((object)"[ElevatorSFX] Child 'SFX_Arrive' has no SFX_PlayOneShot component.", (Object)(object)this); } StopMoveLoop(); StopCrashLoop(); } public void PlayStartMove() { SFX_PlayOneShot? startMove = m_startMove; if (startMove != null) { startMove.Play(); } } public void StartMoveLoop() { if (!((Object)(object)m_moveLoop == (Object)null)) { CancelFade(); m_moveLoop.volume = 1f; ((Behaviour)m_moveLoop).enabled = true; } } public void StartCrashLoop() { StopMoveLoop(); if (!((Object)(object)m_crashLoop == (Object)null)) { m_crashLoop.volume = 1f; ((Behaviour)m_crashLoop).enabled = true; } } public void StopMoveLoop() { if (!((Object)(object)m_moveLoop == (Object)null)) { CancelFade(); ((Behaviour)m_moveLoop).enabled = false; m_moveLoop.volume = 1f; } } public void StopCrashLoop() { if (!((Object)(object)m_crashLoop == (Object)null)) { ((Behaviour)m_crashLoop).enabled = false; m_crashLoop.volume = 1f; } } public void PlayArrive() { SFX_PlayOneShot? arrive = m_arrive; if (arrive != null) { arrive.Play(); } if (!((Object)(object)m_moveLoop == (Object)null) && ((Behaviour)m_moveLoop).enabled) { CancelFade(); m_fadeCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeOutMoveLoop()); } } private void CancelFade() { if (m_fadeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(m_fadeCoroutine); m_fadeCoroutine = null; } } private IEnumerator FadeOutMoveLoop() { float startVolume = m_moveLoop.volume; float t = 0f; while (t < 1f) { t += Time.deltaTime; m_moveLoop.volume = Mathf.Lerp(startVolume, 0.02f, t); yield return null; } ((Behaviour)m_moveLoop).enabled = false; m_moveLoop.volume = 1f; m_fadeCoroutine = null; } } public static class MapScreenCursorState { private static MeshRenderer? _cursorRenderer; private static int _mapScreenInteractableHoverDepth; public static Transform? MapScreenRoot { get; private set; } public static Material? VanillaCursorMaterial { get; private set; } public static Material? CustomHandPointerMaterial { get; private set; } public static void Register(Transform mapScreenRoot, MeshRenderer mapScreenCursor, Material vanilla, Material? customWithHandPointer) { MapScreenRoot = mapScreenRoot; _cursorRenderer = mapScreenCursor; VanillaCursorMaterial = vanilla; CustomHandPointerMaterial = customWithHandPointer; _mapScreenInteractableHoverDepth = 0; ApplyToRenderer(vanilla); } public static bool IsMapScreenInteractable(Interactable interactable) { if ((Object)(object)MapScreenRoot == (Object)null || (Object)(object)interactable == (Object)null) { return false; } return ((Component)interactable).transform.IsChildOf(MapScreenRoot); } public static void OnMapScreenInteractableHoverBegin() { if (!((Object)(object)CustomHandPointerMaterial == (Object)null) && !((Object)(object)_cursorRenderer == (Object)null)) { _mapScreenInteractableHoverDepth++; if (_mapScreenInteractableHoverDepth == 1) { ApplyToRenderer(CustomHandPointerMaterial); } } } public static void OnMapScreenInteractableHoverEnd() { if (!((Object)(object)VanillaCursorMaterial == (Object)null) && !((Object)(object)_cursorRenderer == (Object)null)) { if (_mapScreenInteractableHoverDepth > 0) { _mapScreenInteractableHoverDepth--; } if (_mapScreenInteractableHoverDepth == 0) { ApplyToRenderer(VanillaCursorMaterial); } } } private static void ApplyToRenderer(Material m) { if (!((Object)(object)_cursorRenderer == (Object)null)) { ((Renderer)_cursorRenderer).sharedMaterials = (Material[])(object)new Material[1] { m }; } } } public static class MapScreenVisualCoordinator { private static readonly Color TitleMapSelection = new Color(1f, 0.2784314f, 0.2784314f); private static readonly Color TitleMapSelected = new Color(0.14901961f, 0.81960785f, 0f); private static readonly Color TitleSelectInDays = new Color(1f, 0.99607843f, 0.29411766f); private const string TextMapSelection = "MAP SELECTION"; private const string TextMapSelected = "MAP SELECTED"; public const float YStartRight = 0f; public const float YEndRight = -166.6f; public const float BellIconRightYOffset = 47.7f; public static bool ShouldShowMaxDepthIndicator(int maxDepthMeters, MapInstance[]? maps) { if (maps == null || maps.Length < 2) { return false; } bool flag = false; bool flag2 = false; for (int i = 0; i < maps.Length; i++) { if (maps[i].DepthMeters <= maxDepthMeters) { flag = true; } else { flag2 = true; } } return flag && flag2; } public static bool IsDayTwoOrThreeWithinQuota() { if (SurfaceNetworkHandler.RoomStats == null) { return false; } int currentQuotaDay = SurfaceNetworkHandler.RoomStats.CurrentQuotaDay; if (currentQuotaDay <= 0) { return false; } return currentQuotaDay % 3 != 1; } public static bool IsScreenInteractible(bool mapPaidEffective) { //IL_000e: 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) if (mapPaidEffective) { return false; } if (IsDayTwoOrThreeWithinQuota()) { return false; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "SurfaceScene") { return false; } return IsMorning(); } private static bool IsMorning() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 TimeOfDayHandler val = Object.FindFirstObjectByType(); if ((Object)(object)val != (Object)null) { return (int)val.timeOfDay == 0; } return false; } public static bool IsMapIconInteractionGloballyLocked(bool mapPaidEffective) { return !IsScreenInteractible(mapPaidEffective); } public static void RefreshAll(bool newQuotaJustStarted = false, bool? mapPaidOverride = null) { MapScreenVisualRoot[] array = Object.FindObjectsByType((FindObjectsSortMode)0); if (array.Length == 0 && SurfaceNetworkHandler.RoomStats != null && SurfaceNetworkHandler.HasStarted) { Logger.LogError("RegionsExpanded: MapScreenVisualCoordinator.RefreshAll: no MapScreenVisualRoot in scene while run active (MapScreen not spawned or component missing)."); } bool flag = !newQuotaJustStarted && ((!mapPaidOverride.HasValue) ? MapSelectionRoomProps.IsMapBuyInPaidFromSources() : mapPaidOverride.Value); bool flag2 = IsScreenInteractible(flag); bool locked = !flag2; int selectedMapUiIndex = GetSelectedMapUiIndex(newQuotaJustStarted); MapScreenVisualRoot[] array2 = array; foreach (MapScreenVisualRoot mapScreenVisualRoot in array2) { if ((Object)(object)mapScreenVisualRoot == (Object)null) { Logger.LogError("RegionsExpanded: Map screen refresh: MapScreenVisualRoot entry is null (unexpected)."); continue; } ApplyTitle(((Component)mapScreenVisualRoot).transform, flag); ApplyMapIcons(((Component)mapScreenVisualRoot).transform, locked); ApplyMaxDepth(((Component)mapScreenVisualRoot).transform); ApplySubTitleDepth(((Component)mapScreenVisualRoot).transform); ApplyLineColors(((Component)mapScreenVisualRoot).transform, flag2); bool revealSelection = !flag2 || RegionsExpanded.DEBUG_MODE; ApplySelectedMapCircles(((Component)mapScreenVisualRoot).transform, selectedMapUiIndex, revealSelection); ApplyBellIconY(((Component)mapScreenVisualRoot).transform, selectedMapUiIndex, revealSelection); } RefreshRadarVisual(); RefreshPlatingVisual(); } public static void RefreshMaxDepth() { bool interactible = IsScreenInteractible(MapSelectionRoomProps.IsMapBuyInPaidFromSources()); MapScreenVisualRoot[] array = Object.FindObjectsByType((FindObjectsSortMode)0); MapScreenVisualRoot[] array2 = array; foreach (MapScreenVisualRoot mapScreenVisualRoot in array2) { if ((Object)(object)mapScreenVisualRoot != (Object)null) { ApplyMaxDepth(((Component)mapScreenVisualRoot).transform); ApplySubTitleDepth(((Component)mapScreenVisualRoot).transform); ApplyLineColors(((Component)mapScreenVisualRoot).transform, interactible); } } RefreshRadarVisual(); RefreshPlatingVisual(); } public static void RefreshRadarVisual() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) bool flag = global::RegionsExpanded.CustomContent.CustomContent.CurrentUpgrades.Contains(DivingBellUpgrade.Radar); RadarVisualRoot[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); if (flag && array.Length == 0) { Logger.LogError("RegionsExpanded: RefreshRadarVisual: radar upgrade is equipped but no RadarVisualRoot instances exist (unexpected; bell visual may not have spawned)."); } Logger.Log($"RegionsExpanded: RefreshRadarVisual: radarEquipped={flag}, instanceCount={array.Length}."); RadarVisualRoot[] array2 = array; foreach (RadarVisualRoot radarVisualRoot in array2) { if ((Object)(object)radarVisualRoot == (Object)null) { Logger.LogError("RegionsExpanded: RefreshRadarVisual: RadarVisualRoot entry is null (unexpected)."); continue; } bool activeSelf = ((Component)radarVisualRoot).gameObject.activeSelf; ((Component)radarVisualRoot).gameObject.SetActive(flag); if (flag && !activeSelf) { SpawnUpgradeAddedExplosion(((Component)radarVisualRoot).transform.position); } } } private static void SpawnUpgradeAddedExplosion(Vector3 worldPosition) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) GameObject upgradeAddedExplosionPrefab = global::RegionsExpanded.CustomContent.CustomContent.UpgradeAddedExplosionPrefab; if ((Object)(object)upgradeAddedExplosionPrefab == (Object)null) { Logger.LogError("RegionsExpanded: SpawnUpgradeAddedExplosion: UpgradeAddedExplosionPrefab is null; explosion not spawned."); return; } GameObject val = Object.Instantiate(upgradeAddedExplosionPrefab, worldPosition, Quaternion.identity); if ((Object)(object)val == (Object)null) { Logger.LogError("RegionsExpanded: SpawnUpgradeAddedExplosion: Instantiate returned null (unexpected)."); } else { Logger.Log($"RegionsExpanded: UpgradeAddedExplosion spawned at {worldPosition}."); } } public static void RefreshPlatingVisual() { //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_00aa: 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_00e2: Unknown result type (might be due to invalid IL or missing references) bool flag = global::RegionsExpanded.CustomContent.CustomContent.CurrentUpgrades.Contains(DivingBellUpgrade.HighPressureArmorPlatings); PlatingVisualRoot[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); if (flag && array.Length == 0) { Logger.LogError("RegionsExpanded: RefreshPlatingVisual: plating upgrade is equipped but no PlatingVisualRoot instances exist (unexpected; bell visual may not have spawned)."); } Logger.Log($"RegionsExpanded: RefreshPlatingVisual: platingEquipped={flag}, instanceCount={array.Length}."); PlatingVisualRoot[] array2 = array; foreach (PlatingVisualRoot platingVisualRoot in array2) { if ((Object)(object)platingVisualRoot == (Object)null) { Logger.LogError("RegionsExpanded: RefreshPlatingVisual: PlatingVisualRoot entry is null (unexpected)."); continue; } bool activeSelf = ((Component)platingVisualRoot).gameObject.activeSelf; ((Component)platingVisualRoot).gameObject.SetActive(flag); if (flag && !activeSelf) { Transform parent = ((Component)platingVisualRoot).transform.parent; Vector3 worldPosition = (((Object)(object)parent != (Object)null) ? parent.TransformPoint(new Vector3(0f, 0.93f, 0f)) : ((Component)platingVisualRoot).transform.position); if ((Object)(object)parent == (Object)null) { Logger.LogError("RegionsExpanded: RefreshPlatingVisual: PlatingVisualRoot has no parent; explosion will spawn at visual root position."); } SpawnUpgradeAddedExplosionPlatings(worldPosition); } } } private static void SpawnUpgradeAddedExplosionPlatings(Vector3 worldPosition) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) GameObject upgradeAddedExplosionPlatingsPrefab = global::RegionsExpanded.CustomContent.CustomContent.UpgradeAddedExplosionPlatingsPrefab; if ((Object)(object)upgradeAddedExplosionPlatingsPrefab == (Object)null) { Logger.LogError("RegionsExpanded: SpawnUpgradeAddedExplosionPlatings: UpgradeAddedExplosionPlatingsPrefab is null; explosion not spawned."); return; } GameObject val = Object.Instantiate(upgradeAddedExplosionPlatingsPrefab, worldPosition, Quaternion.identity); if ((Object)(object)val == (Object)null) { Logger.LogError("RegionsExpanded: SpawnUpgradeAddedExplosionPlatings: Instantiate returned null (unexpected)."); } else { Logger.Log($"RegionsExpanded: UpgradeAddedExplosionPlatings spawned at {worldPosition}."); } } private static void ApplySubTitleDepth(Transform mapScreenRoot) { Transform val = mapScreenRoot.Find("ScreenPivot/Canvas/SubTitleDepth"); if ((Object)(object)val != (Object)null) { TMP_Text component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { component.text = $"Max depth: {global::RegionsExpanded.CustomContent.CustomContent.MAX_DEPTH} meters"; } } } private static void ApplyLineColors(Transform mapScreenRoot, bool interactible) { Transform val = mapScreenRoot.Find("ScreenPivot/Canvas"); if ((Object)(object)val == (Object)null) { return; } MapInstance[] mapInstances = global::RegionsExpanded.CustomContent.CustomContent.MapInstances; for (int i = 0; i < mapInstances.Length; i++) { MapInstance entry = mapInstances[i]; Transform val2 = val.Find("MapLine_" + entry.DisplayName); if ((Object)(object)val2 != (Object)null) { MapScreenLineBindings.ApplyToLine(val2, entry, i, interactible); } } } private static void ApplyMaxDepth(Transform mapScreenRoot) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_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) Transform val = mapScreenRoot.Find("ScreenPivot/Canvas"); if ((Object)(object)val == (Object)null) { return; } Transform val2 = val.Find("MaxDepthIndicator"); if ((Object)(object)val2 == (Object)null) { return; } MapInstance[] mapInstances = global::RegionsExpanded.CustomContent.CustomContent.MapInstances; int mAX_DEPTH = global::RegionsExpanded.CustomContent.CustomContent.MAX_DEPTH; bool flag = ShouldShowMaxDepthIndicator(mAX_DEPTH, mapInstances); ((Component)val2).gameObject.SetActive(flag); if (flag) { RectTransform val3 = (RectTransform)(object)((val2 is RectTransform) ? val2 : null); if (val3 != null) { float maxDepthRightYAlignToMaps = GetMaxDepthRightYAlignToMaps(mAX_DEPTH, mapInstances, 0f, -166.6f); Vector2 anchoredPosition = val3.anchoredPosition; float num = maxDepthRightYAlignToMaps + 51.4f; val3.anchoredPosition = new Vector2(anchoredPosition.x, num); } } } public static float GetMaxDepthRightYAlignToMaps(int maxDepthMeters, MapInstance[] maps, float yStartRight, float yEndRight) { int n = maps.Length; if (n == 0) { return (yStartRight + yEndRight) * 0.5f; } int num = -1; int num2 = -1; for (int i = 0; i < n; i++) { if (maps[i].DepthMeters <= maxDepthMeters) { num = i; } else if (num2 < 0) { num2 = i; } } if (num >= 0 && num2 >= 0) { return (RightYForIndex(num) + RightYForIndex(num2)) * 0.5f; } if (num < 0) { return RightYForIndex(0); } return RightYForIndex(n - 1); float RightYForIndex(int num4) { if (n == 1) { return Mathf.Lerp(yStartRight, yEndRight, 0.5f); } float num3 = (float)num4 / (float)(n - 1); return Mathf.Lerp(yStartRight, yEndRight, num3); } } private static void ApplyTitle(Transform mapScreenRoot, bool paid) { //IL_00aa: 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_0079: Unknown result type (might be due to invalid IL or missing references) Transform val = mapScreenRoot.Find("ScreenPivot/Canvas/Title"); if ((Object)(object)val == (Object)null) { Logger.LogError("RegionsExpanded: Map screen: ScreenPivot/Canvas/Title not found under " + ((Object)mapScreenRoot).name + "."); return; } TMP_Text component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogError("RegionsExpanded: Map screen: Title has no TMP_Text on " + ((Object)mapScreenRoot).name + "."); } else if (!paid && !IsScreenInteractible(paid)) { int selectInDaysCountdown = GetSelectInDaysCountdown(); component.text = FormatSelectInDays(selectInDaysCountdown); ((Graphic)component).color = TitleSelectInDays; } else if (paid) { component.text = "MAP SELECTED"; ((Graphic)component).color = TitleMapSelected; } else { component.text = "MAP SELECTION"; ((Graphic)component).color = TitleMapSelection; } } private static int GetSelectInDaysCountdown() { if (SurfaceNetworkHandler.RoomStats == null) { Logger.LogError("RegionsExpanded: GetSelectInDaysCountdown: RoomStats is null during yellow title path (unexpected)."); return 0; } return Mathf.Max(0, SurfaceNetworkHandler.RoomStats.GetDaysLeft() + 1); } private static string FormatSelectInDays(int n) { if (n == 1) { return "SELECT IN 1 DAY"; } return $"SELECT IN {n} DAYS"; } public static void PlaySFX(string path) { MapScreenVisualRoot[] array = Object.FindObjectsByType((FindObjectsSortMode)0); MapScreenVisualRoot[] array2 = array; foreach (MapScreenVisualRoot mapScreenVisualRoot in array2) { if ((Object)(object)mapScreenVisualRoot == (Object)null) { continue; } Transform val = ((Component)mapScreenVisualRoot).transform.Find(path); if ((Object)(object)val != (Object)null) { SFX_PlayOneShot component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { component.Play(); } else { Logger.LogError("RegionsExpanded: MapScreenVisualCoordinator.PlaySFX: SFX_PlayOneShot component not found on " + path); } } else { Logger.LogError("RegionsExpanded: MapScreenVisualCoordinator.PlaySFX: child not found: " + path); } } } private static void ApplyMapIcons(Transform mapScreenRoot, bool locked) { MapIconInteractable[] componentsInChildren = ((Component)mapScreenRoot).GetComponentsInChildren(true); MapIconInteractable[] array = componentsInChildren; foreach (MapIconInteractable mapIconInteractable in array) { if ((Object)(object)mapIconInteractable == (Object)null) { Logger.LogError("RegionsExpanded: Map screen: null MapIconInteractable in children of " + ((Object)mapScreenRoot).name + "."); } else { ((Behaviour)mapIconInteractable).enabled = !locked; } } } public static int GetSelectedMapUiIndex(bool newQuotaJustStarted = false) { if (SurfaceNetworkHandler.RoomStats == null) { return -1; } if (!newQuotaJustStarted) { int selectedMapIndex = MapSelectionRoomProps.GetSelectedMapIndex(); if (selectedMapIndex >= 0) { return selectedMapIndex; } } int levelToPlay = SurfaceNetworkHandler.RoomStats.LevelToPlay; MapInstance[] mapInstances = global::RegionsExpanded.CustomContent.CustomContent.MapInstances; for (int i = 0; i < mapInstances.Length; i++) { if (MapLevelRouting.UiIndexToLevelToPlay(i) == levelToPlay) { return i; } } return -1; } private static void ApplySelectedMapCircles(Transform mapScreenRoot, int selectedUiIndex, bool revealSelection) { Transform val = mapScreenRoot.Find("ScreenPivot/Canvas"); if ((Object)(object)val == (Object)null) { Logger.LogError("RegionsExpanded: ApplySelectedMapCircles: ScreenPivot/Canvas not found."); return; } MapInstance[] mapInstances = global::RegionsExpanded.CustomContent.CustomContent.MapInstances; for (int i = 0; i < mapInstances.Length; i++) { Transform val2 = val.Find("MapLine_" + mapInstances[i].DisplayName); if ((Object)(object)val2 != (Object)null) { Transform val3 = val2.Find("MapSelectedCircle"); if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(revealSelection && i == selectedUiIndex); } } } } private static void ApplyBellIconY(Transform mapScreenRoot, int selectedUiIndex, bool revealSelection) { //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_0068: 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) if (!revealSelection) { return; } Transform val = mapScreenRoot.Find("ScreenPivot/Canvas/BellIcon"); if ((Object)(object)val == (Object)null) { return; } RectTransform val2 = (RectTransform)(object)((val is RectTransform) ? val : null); if (val2 != null) { MapInstance[] mapInstances = global::RegionsExpanded.CustomContent.CustomContent.MapInstances; int num = mapInstances.Length; if (selectedUiIndex >= 0 && selectedUiIndex < num) { float num2 = ((num > 1) ? ((float)selectedUiIndex / (float)(num - 1)) : 0.5f); float num3 = Mathf.Lerp(0f, -166.6f, num2); Vector2 anchoredPosition = val2.anchoredPosition; val2.anchoredPosition = new Vector2(anchoredPosition.x, num3 + 47.7f); } } } } public sealed class MapScreenVisualRoot : MonoBehaviour { } public static class Logger { private const string Prefix = "[RegionsExpanded]"; public static void Log(string message) { Debug.Log((object)("[RegionsExpanded] " + message)); } public static void LogWarning(string message) { Debug.LogWarning((object)("[RegionsExpanded] " + message)); } public static void LogError(string message) { Debug.LogError((object)("[RegionsExpanded] " + message)); } } public class MyPluginInfo { public const string PLUGIN_GUID = "db.regionsexpanded"; public const string PLUGIN_NAME = "Regions Expanded"; public const string PLUGIN_VERSION = "0.3.0"; public const bool VANILLA_COMPATIBLE = false; } [ContentWarningPlugin("db.regionsexpanded", "0.3.0", false)] [BepInPlugin("db.regionsexpanded", "Regions Expanded", "0.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class RegionsExpanded : BaseUnityPlugin { private bool _isPatched; public static bool DEBUG_MODE; private Harmony? Harmony { get; set; } public static RegionsExpanded Instance { get; private set; } private void Awake() { Instance = this; Logger.Log("RegionsExpanded constructor called. IntroScreenSlideshow.Request()"); global::RegionsExpanded.CustomContent.CustomContent.Init(); BellUpgradePersistence.Register(); if (DEBUG_MODE) { DbsContentApiPlugin.SetAllItemsFree(true); } PatchAll(); Logger.Log("Plugin db.regionsexpanded is loaded!"); } private void PatchAll() { //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_0032: Expected O, but got Unknown //IL_0037: Expected O, but got Unknown if (_isPatched) { Logger.LogError("Already patched!"); return; } Logger.Log("Patching..."); if (Harmony == null) { Harmony val = new Harmony("db.regionsexpanded"); Harmony val2 = val; Harmony = val; } try { Harmony.PatchAll(); _isPatched = true; Logger.Log("Patched!"); } catch (Exception arg) { Logger.LogError($"Failed to patch: {arg}"); } } public void UnpatchAll() { if (!_isPatched) { Logger.LogError("Already unpatched!"); return; } Logger.Log("Unpatching..."); try { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } _isPatched = false; Logger.Log("Unpatched!"); } catch (Exception arg) { Logger.LogError($"Failed to unpatch: {arg}"); } } } } namespace RegionsExpanded.Patches { [HarmonyPatch(typeof(PlayerRagdoll), "GroundRaycast")] internal static class GroundRaycastStandableRigPatch { [HarmonyPrefix] private static bool Prefix(PlayerRagdoll __instance, bool justChecking, bool justTryingToGetTheRaycastHit, bool ignoreAngle, ref RaycastHit __result) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_00bb: 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_00ed: 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_00e0: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) Traverse val = Traverse.Create((object)__instance); Dictionary value = val.Field>("bodypartDict").Value; Player value2 = val.Field("player").Value; RaycastHit groundPosRaycast = HelperFunctions.GetGroundPosRaycast(((Component)value[(BodypartType)4]).transform.position, (LayerType)1, value2.data.gravityDirection); if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref groundPosRaycast)).transform)) { __result = default(RaycastHit); return false; } if ((Object)(object)((RaycastHit)(ref groundPosRaycast)).rigidbody != (Object)null && (Object)(object)((Component)((RaycastHit)(ref groundPosRaycast)).rigidbody).GetComponent() == (Object)null) { __result = default(RaycastHit); return false; } float num = value2.data.targetHeight + 0.25f; if (justChecking) { num = 2f; } if (((RaycastHit)(ref groundPosRaycast)).distance > num) { __result = default(RaycastHit); return false; } if (!ignoreAngle && Vector3.Angle(Vector3.up, ((RaycastHit)(ref groundPosRaycast)).normal) > 60f) { __result = default(RaycastHit); return false; } if (justTryingToGetTheRaycastHit) { __result = groundPosRaycast; return false; } if (justChecking) { value2.data.groundBelow = true; } else { val.Method("RegisterGroundRaycast", new object[2] { groundPosRaycast, value[(BodypartType)0] }).GetValue(); } __result = groundPosRaycast; return false; } } [HarmonyPatch(typeof(Interactable), "OnStartHover")] public static class InteractableMapScreenOnStartCursorPatch { [HarmonyPostfix] public static void Postfix(Interactable __instance) { if (MapScreenCursorState.IsMapScreenInteractable(__instance)) { MapScreenCursorState.OnMapScreenInteractableHoverBegin(); } } } [HarmonyPatch(typeof(Interactable), "OnEndHover")] public static class InteractableMapScreenOnEndCursorPatch { [HarmonyPostfix] public static void Postfix(Interactable __instance) { if (MapScreenCursorState.IsMapScreenInteractable(__instance)) { MapScreenCursorState.OnMapScreenInteractableHoverEnd(); } } } public static class MapScreenLineBindings { private static readonly Color MapUiShallowerThanMaxDepthTint = new Color(0.14901961f, 0.81960785f, 0f, 1f); private static readonly Color MapUiAtOrDeeperThanMaxDepthTint = new Color(38f / 51f, 0.23529412f, 19f / 85f, 1f); public static void ApplyToLine(Transform lineRoot, MapInstance entry, int mapIndex, bool interactible) { //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_0033: 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_0104: 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) bool flag = entry.DepthMeters <= global::RegionsExpanded.CustomContent.CustomContent.MAX_DEPTH; Color color = (Color)((!interactible) ? new Color(0.58431375f, 0.58431375f, 0.58431375f, 1f) : (flag ? MapUiShallowerThanMaxDepthTint : MapUiAtOrDeeperThanMaxDepthTint)); Transform val = lineRoot.Find("PriceTag"); if ((Object)(object)val != (Object)null) { TMP_Text component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { component.text = entry.BuyInDollars + "$"; } } Transform val2 = lineRoot.Find("DepthTag"); if ((Object)(object)val2 != (Object)null) { TMP_Text component2 = ((Component)val2).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.text = entry.DepthMeters + "m"; } } Transform subtreeRoot = lineRoot.Find("MapSelectedCircle"); TMP_Text[] componentsInChildren = ((Component)lineRoot).GetComponentsInChildren(true); foreach (TMP_Text val3 in componentsInChildren) { if (!IsInSubtree(val3.transform, subtreeRoot)) { ((Graphic)val3).color = color; } } Image[] componentsInChildren2 = ((Component)lineRoot).GetComponentsInChildren(true); foreach (Image val4 in componentsInChildren2) { if (!IsInSubtree(((Component)val4).transform, subtreeRoot)) { ((Graphic)val4).color = color; } } Transform val5 = lineRoot.Find("MapIcon"); if ((Object)(object)val5 == (Object)null) { Logger.LogError("RegionsExpanded: MapIcon not found on " + ((Object)lineRoot).name); return; } Image component3 = ((Component)val5).GetComponent(); if ((Object)(object)component3 == (Object)null) { Logger.LogError("RegionsExpanded: MapIcon has no Image on " + ((Object)lineRoot).name); return; } Sprite sprite = CustomItems.GetSprite(entry.IconBundleName); if ((Object)(object)sprite == (Object)null) { Logger.LogError("RegionsExpanded: No Sprite in bundle for icon key: " + entry.IconBundleName); return; } component3.sprite = sprite; MapIconInteractable mapIconInteractable = ((Component)val5).GetComponent(); if ((Object)(object)mapIconInteractable == (Object)null) { mapIconInteractable = ((Component)val5).gameObject.AddComponent(); } mapIconInteractable.Setup(entry, mapIndex); } private static bool IsInSubtree(Transform t, Transform? subtreeRoot) { if ((Object)(object)subtreeRoot == (Object)null) { return false; } Transform val = t; while ((Object)(object)val != (Object)null) { if ((Object)(object)val == (Object)(object)subtreeRoot) { return true; } val = val.parent; } return false; } } [HarmonyPatch(typeof(RoomStatsHolder), "NewMapToPlay")] [HarmonyPriority(200)] internal static class NewMapToPlayPatch { [HarmonyPrefix] private static bool Prefix(RoomStatsHolder __instance) { int num = ((__instance.CurrentQuotaDay > 0) ? MapSelectionRoomProps.GetSelectedMapIndex() : (-1)); if (num >= 0 && num < global::RegionsExpanded.CustomContent.CustomContent.MapInstances.Length) { Logger.Log($"RegionsExpanded: NewMapToPlayPatch: Map was bought: {num}"); ApplyMapSelection(__instance, num); return false; } List list = new List(); for (int i = 0; i < global::RegionsExpanded.CustomContent.CustomContent.MapInstances.Length; i++) { if (global::RegionsExpanded.CustomContent.CustomContent.MapInstances[i].DepthMeters <= global::RegionsExpanded.CustomContent.CustomContent.MAX_DEPTH) { list.Add(i); } } if (list.Count == 0) { Logger.Log("RegionsExpanded: NewMapToPlayPatch: No accessible maps"); return false; } int num2 = 0; int num3; do { Logger.Log($"RegionsExpanded: NewMapToPlayPatch Trying to pick a map ({num2})"); num3 = list[Random.Range(0, list.Count)]; } while (++num2 < 100 && MapLevelRouting.UiIndexToLevelToPlay(num3) == __instance.LevelToPlay && list.Count > 1); Logger.Log($"RegionsExpanded: NewMapToPlayPatch Picked map: {num3}"); ApplyMapSelection(__instance, num3); return false; } private static void ApplyMapSelection(RoomStatsHolder roomStats, int uiIndex) { int num = MapLevelRouting.UiIndexToLevelToPlay(uiIndex); if (num >= 3) { Maps.SetSelectedMapId(global::RegionsExpanded.CustomContent.CustomContent.MapIdForScene(global::RegionsExpanded.CustomContent.CustomContent.MapInstances[uiIndex].SceneName)); } else { Maps.SetSelectedMapId((string)null); } roomStats.LevelToPlay = num; } } [HarmonyPatch(typeof(DivingBell), "Awake")] public static class SpawnMapScreenPatch { private static bool firstSetupDone; private static Material blueprintMaterial; private static Material frontTextMaterial; private static Material platingMaterial; [HarmonyPostfix] public static void Postfix(DivingBell __instance) { //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) Logger.Log("RegionsExpanded: DivingBell Awake postfix started."); Transform transform = ((Component)__instance).transform; SetupMapScreen(transform); SetupRadarVisual(transform); SetupPlatingVisual(transform); Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "SurfaceScene") { Logger.Log("RegionsExpanded: Dropbox setup skipped; not in SurfaceScene."); } else { SetupUpgradeDropbox(transform); } } private static void SetupRadarVisual(Transform parent) { //IL_007b: 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_00b9: Unknown result type (might be due to invalid IL or missing references) Logger.Log("RegionsExpanded: SetupRadarVisual started."); if ((Object)(object)parent == (Object)null) { Logger.LogError("RegionsExpanded: SetupRadarVisual: parent transform is null (unexpected); radar visual not spawned."); return; } GameObject upgradeRadarVisualPrefab = global::RegionsExpanded.CustomContent.CustomContent.UpgradeRadarVisualPrefab; if ((Object)(object)upgradeRadarVisualPrefab == (Object)null) { Logger.LogError("RegionsExpanded: UpgradeRadarVisualPrefab is null; radar visual not spawned."); return; } GameObject val = Object.Instantiate(upgradeRadarVisualPrefab, parent); if ((Object)(object)val == (Object)null) { Logger.LogError("RegionsExpanded: SetupRadarVisual: Instantiate returned null (unexpected); radar visual not spawned."); return; } ((Object)val).name = "UpgradeRadarVisual"; val.AddComponent(); val.transform.localPosition = new Vector3(-1.022857f, 2.788571f, 0.7314284f); val.transform.localEulerAngles = new Vector3(-90f, -32.71f, 0f); val.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); MeshRenderer component = val.GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogError("RegionsExpanded: UpgradeRadarVisual root has no MeshRenderer; applying material swap skipped (unexpected prefab layout)."); } else { ((Renderer)component).materials = (Material[])(object)new Material[7] { GameMaterials.GetMaterial((GameMaterial)285), GameMaterials.GetMaterial((GameMaterial)324), GameMaterials.GetMaterial((GameMaterial)324), GameMaterials.GetMaterial((GameMaterial)324), GameMaterials.GetMaterial((GameMaterial)8), GameMaterials.GetMaterial((GameMaterial)8), GameMaterials.GetMaterial((GameMaterial)283) }; } ObjectHelper.FixShadersForCurrentScene(val); bool flag = global::RegionsExpanded.CustomContent.CustomContent.CurrentUpgrades.Contains(DivingBellUpgrade.Radar); val.SetActive(flag); Logger.Log($"RegionsExpanded: UpgradeRadarVisual spawned under DivingBell; initial active={flag}."); } private static void SetupPlatingVisual(Transform parent) { //IL_007b: 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_00aa: Unknown result type (might be due to invalid IL or missing references) Logger.Log("RegionsExpanded: SetupPlatingVisual started."); if ((Object)(object)parent == (Object)null) { Logger.LogError("RegionsExpanded: SetupPlatingVisual: parent transform is null (unexpected); plating visual not spawned."); return; } GameObject upgradePlatingVisualPrefab = global::RegionsExpanded.CustomContent.CustomContent.UpgradePlatingVisualPrefab; if ((Object)(object)upgradePlatingVisualPrefab == (Object)null) { Logger.LogError("RegionsExpanded: UpgradePlatingVisualPrefab is null; plating visual not spawned."); return; } GameObject val = Object.Instantiate(upgradePlatingVisualPrefab, parent); if ((Object)(object)val == (Object)null) { Logger.LogError("RegionsExpanded: SetupPlatingVisual: Instantiate returned null (unexpected); plating visual not spawned."); return; } ((Object)val).name = "UpgradePlatingVisual"; val.AddComponent(); val.transform.localPosition = new Vector3(0f, -0.44f, 0f); val.transform.localEulerAngles = Vector3.zero; val.transform.localScale = new Vector3(1.43f, 1.43f, 1.43f); Transform val2 = val.transform.Find("Bolts"); Transform val3 = val.transform.Find("Plates"); Transform val4 = val.transform.Find("PlatingScrews"); if ((Object)(object)val2 != (Object)null) { GameMaterials.ApplyMaterial(((Component)val2).gameObject, (GameMaterial)283, true); } else { Logger.LogError("RegionsExpanded: UpgradePlatingVisual.Bolts child not found."); } if ((Object)(object)val4 != (Object)null) { GameMaterials.ApplyMaterial(((Component)val4).gameObject, (GameMaterial)283, true); } else { Logger.LogError("RegionsExpanded: UpgradePlatingVisual.PlatingScrews child not found."); } if ((Object)(object)val3 != (Object)null) { GameMaterials.ApplyMaterial(((Component)val3).gameObject, (GameMaterial)285, true); } else { Logger.LogError("RegionsExpanded: UpgradePlatingVisual.Plates child not found."); } ObjectHelper.FixShadersForCurrentScene(val); bool flag = global::RegionsExpanded.CustomContent.CustomContent.CurrentUpgrades.Contains(DivingBellUpgrade.HighPressureArmorPlatings); val.SetActive(flag); Logger.Log($"RegionsExpanded: UpgradePlatingVisual spawned under DivingBell; initial active={flag}."); } private static void SetupMapScreen(Transform parent) { //IL_0049: 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_0069: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) GameObject divingBellMapScreenPrefab = global::RegionsExpanded.CustomContent.CustomContent.DivingBellMapScreenPrefab; if ((Object)(object)divingBellMapScreenPrefab == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellMapScreenPrefab is null; map screen not spawned."); return; } GameObject val = Object.Instantiate(divingBellMapScreenPrefab, parent); ((Object)val).name = "MapScreen"; val.AddComponent(); val.transform.localPosition = new Vector3(-0.8342857f, 1.078f, 0.015f); val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; Transform val2 = val.transform.Find("DoorFrame"); if ((Object)(object)val2 != (Object)null) { GameMaterials.ApplyMaterial(((Component)val2).gameObject, (GameMaterial)286, true); } else { Logger.LogError("RegionsExpanded: MapScreen.DoorFrame not found."); } Transform val3 = val.transform.Find("ScreenPivot/Screen"); if ((Object)(object)val3 != (Object)null) { GameMaterials.ApplyMaterial(((Component)val3).gameObject, (GameMaterial)236, true); } else { Logger.LogError("RegionsExpanded: MapScreen.Screen not found."); } Transform val4 = val.transform.Find("ScreenPivot/Canvas"); if ((Object)(object)val4 == (Object)null) { Logger.LogError("RegionsExpanded: MapScreen.ScreenPivot/Canvas not found."); return; } GameObject gameObject = ((Component)((Component)val4).transform.Find("Cursor/Cursor/Quad")).gameObject; MeshRenderer component = gameObject.GetComponent(); Material val5 = Resources.Load("M_Cursor") ?? GameMaterials.GetMaterial((GameMaterial)158); if ((Object)(object)val5 == (Object)null) { Logger.LogError("RegionsExpanded: Cursor material not found."); return; } Material vanilla = new Material(val5) { name = "M_Cursor_MapScreen_Vanilla" }; Texture2D texture = CustomItems.GetTexture("HandPointer"); Material val6 = null; if ((Object)(object)texture != (Object)null) { val6 = new Material(val5) { name = "M_Cursor_MapScreen_Hand" }; ApplyUrpUnlitAlbedoTexture(val6, (Texture)(object)texture); } else { Logger.LogError("RegionsExpanded: HandPointer texture not found in bundle; map cursor will stay vanilla on hover too."); } MapScreenCursorState.Register(val.transform, component, vanilla, val6); Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "SurfaceScene") { GameObject gameObject2 = ((Component)val.transform.Find("DoorFrame")).gameObject; GameObject gameObject3 = ((Component)val.transform.Find("ScreenPivot/Screen")).gameObject; MeshRenderer component2 = gameObject2.GetComponent(); MeshRenderer component3 = gameObject3.GetComponent(); if ((Object)(object)component2 != (Object)null) { Logger.Log("RegionsExpanded: Fixing shaders for " + ((Object)gameObject2).name); ((Renderer)component2).material = GameMaterials.GetMaterial((GameMaterial)120); } else { Logger.LogError("RegionsExpanded: " + ((Object)gameObject2).name + " not found."); } if ((Object)(object)component3 != (Object)null) { Logger.Log("RegionsExpanded: Fixing shaders for " + ((Object)gameObject3).name); Transform val7 = val.gameObject.transform.parent.Find("Tools/Screen/ScreenPivot/Cube"); if ((Object)(object)val7 != (Object)null) { MeshRenderer component4 = ((Component)val7).GetComponent(); if ((Object)(object)component4 != (Object)null) { ((Renderer)component3).material = ((Renderer)component4).material; } else { Logger.LogError("RegionsExpanded: " + ((Object)val7).name + " not found."); } } else { Logger.LogError("RegionsExpanded: Diving bell vanilla screen not found."); } } else { Logger.LogError("RegionsExpanded: " + ((Object)gameObject3).name + " not found."); } } PopulateMapSelectionRows(val4); MapScreenVisualCoordinator.RefreshAll(); } private static void PopulateMapSelectionRows(Transform canvas) { //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_0113: 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) MapInstance[] mapInstances = global::RegionsExpanded.CustomContent.CustomContent.MapInstances; if (mapInstances == null || mapInstances.Length == 0) { Logger.Log("RegionsExpanded: No MapInstances defined; map lines skipped."); return; } Transform val = canvas.Find("RightLineMap"); Transform val2 = canvas.Find("LeftLineMap"); Transform val3 = canvas.Find("MaxDepthIndicator"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { Logger.LogError("RegionsExpanded: RightLineMap and/or LeftLineMap not found; map lines skipped."); return; } ApplyInvisMaterialToLineOutlineCube(val); ApplyInvisMaterialToLineOutlineCube(val2); int num = mapInstances.Length; for (int i = 0; i < num; i++) { float num2 = ((num > 1) ? ((float)i / (float)(num - 1)) : 0.5f); float num3 = Mathf.Lerp(0f, -166.6f, num2); bool flag = (i & 1) != 0; float num4 = (flag ? (num3 + -25.7f) : num3); MapInstance entry = mapInstances[i]; Transform val4 = (flag ? val2 : val); Transform val5 = Object.Instantiate(val4, canvas, false); ((Object)val5).name = "MapLine_" + entry.DisplayName; ((Component)val5).gameObject.SetActive(true); RectTransform val6 = (RectTransform)(object)((val5 is RectTransform) ? val5 : null); if (val6 != null) { Vector2 anchoredPosition = val6.anchoredPosition; val6.anchoredPosition = new Vector2(anchoredPosition.x, num4); } MapScreenLineBindings.ApplyToLine(val5, entry, i, interactible: false); } if ((Object)(object)val3 != (Object)null) { MapScreenVisualCoordinator.RefreshMaxDepth(); } Transform val7 = canvas.Find("BellIcon"); if ((Object)(object)val7 != (Object)null) { val7.SetAsLastSibling(); } if ((Object)(object)val3 != (Object)null) { val3.SetAsLastSibling(); } } private static void ApplyInvisMaterialToLineOutlineCube(Transform lineRoot) { Transform val = lineRoot.Find("MapIcon/Outline/OutlineCube"); if ((Object)(object)val == (Object)null) { Logger.LogError("RegionsExpanded: " + ((Object)lineRoot).name + ".MapIcon/Outline/OutlineCube not found."); return; } MeshRenderer component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogError("RegionsExpanded: OutlineCube has no MeshRenderer on " + ((Object)lineRoot).name + "."); return; } Material val2 = Resources.Load("M_Invis") ?? GameMaterials.GetMaterial((GameMaterial)298); if ((Object)(object)val2 == (Object)null) { Logger.LogError("RegionsExpanded: Invisible material not found."); return; } Material[] materials = ((Renderer)component).materials; for (int i = 0; i < materials.Length; i++) { materials[i] = val2; } ((Renderer)component).materials = materials; Logger.Log("RegionsExpanded: Applied invisible material to " + ((Object)lineRoot).name + ".MapIcon/Outline/OutlineCube."); } private static void SetupUpgradeDropbox(Transform parent) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Expected O, but got Unknown //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Expected O, but got Unknown //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_0635: Unknown result type (might be due to invalid IL or missing references) GameObject divingBellUpgradeDropboxPrefab = global::RegionsExpanded.CustomContent.CustomContent.DivingBellUpgradeDropboxPrefab; if ((Object)(object)divingBellUpgradeDropboxPrefab == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropboxPrefab is null; dropbox not spawned."); return; } GameObject val = Object.Instantiate(divingBellUpgradeDropboxPrefab); val.transform.localPosition = new Vector3(-3.49f, 0.81f, -15.46f); val.transform.localEulerAngles = new Vector3(0f, 90f, 0f); val.transform.localScale = new Vector3(0.6f, 0.6f, 0.6f); GameObject gameObject = ((Component)val.transform.Find("Dropbox")).gameObject; GameObject gameObject2 = ((Component)val.transform.Find("DropboxFrontText")).gameObject; GameObject gameObject3 = ((Component)val.transform.Find("InsulatingTape")).gameObject; GameObject gameObject4 = ((Component)val.transform.Find("Blueprint")).gameObject; GameObject gameObject5 = ((Component)val.transform.Find("Pliers")).gameObject; GameObject gameObject6 = ((Component)val.transform.Find("MeasuringTape")).gameObject; GameObject gameObject7 = ((Component)val.transform.Find("Screwdriver")).gameObject; GameObject gameObject8 = ((Component)val.transform.Find("Vents")).gameObject; GameObject gameObject9 = ((Component)val.transform.Find("Wheels")).gameObject; GameObject gameObject10 = ((Component)val.transform.Find("Wrench")).gameObject; GameObject gameObject11 = ((Component)val.transform.Find("LidPivot")).gameObject; GameObject gameObject12 = ((Component)gameObject11.transform.Find("Lid")).gameObject; GameObject gameObject13 = ((Component)gameObject11.transform.Find("WrenchLogo")).gameObject; GameObject gameObject14 = ((Component)val.transform.Find("UpgradeDetectionZone")).gameObject; PhotonView val2 = val.AddComponent(); val2.ViewID = 996; UpgradeDropBox upgradeDropBox = val.AddComponent(); upgradeDropBox.Particles = ((Component)val.transform.Find("Particles")).gameObject; UpgradeDropBoxItemDetector detector = gameObject14.AddComponent(); UpgradeDropBoxLid upgradeDropBoxLid = gameObject11.AddComponent(); upgradeDropBox.Detector = detector; upgradeDropBox.Lid = upgradeDropBoxLid; upgradeDropBoxLid.Machine = upgradeDropBox; if ((Object)(object)gameObject == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.Dropbox not found."); return; } if ((Object)(object)gameObject2 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.DropboxFrontText not found."); return; } if ((Object)(object)gameObject3 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.InsulatingTape not found."); return; } if ((Object)(object)gameObject4 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.Blueprint not found."); return; } if ((Object)(object)gameObject5 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.Pliers not found."); return; } if ((Object)(object)gameObject6 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.MeasuringTape not found."); return; } if ((Object)(object)gameObject7 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.Screwdriver not found."); return; } if ((Object)(object)gameObject8 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.Vents not found."); return; } if ((Object)(object)gameObject9 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.Wheels not found."); return; } if ((Object)(object)gameObject10 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.Wrench not found."); return; } if ((Object)(object)gameObject11 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.LidPivot not found."); return; } if ((Object)(object)gameObject12 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.Lid not found."); return; } if ((Object)(object)gameObject13 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.WrenchLogo not found."); return; } if ((Object)(object)gameObject == (Object)null || (Object)(object)gameObject2 == (Object)null || (Object)(object)gameObject3 == (Object)null || (Object)(object)gameObject4 == (Object)null || (Object)(object)gameObject5 == (Object)null || (Object)(object)gameObject6 == (Object)null || (Object)(object)gameObject7 == (Object)null || (Object)(object)gameObject8 == (Object)null || (Object)(object)gameObject9 == (Object)null || (Object)(object)gameObject10 == (Object)null || (Object)(object)gameObject11 == (Object)null || (Object)(object)gameObject12 == (Object)null || (Object)(object)gameObject13 == (Object)null) { Logger.LogError("RegionsExpanded: DivingBellUpgradeDropbox.Some components not found."); return; } GameMaterials.ApplyMaterial(gameObject, (GameMaterial)301, true); GameMaterials.ApplyMaterial(gameObject2, (GameMaterial)213, true); GameMaterials.ApplyMaterial(gameObject3, (GameMaterial)34, true); GameMaterials.ApplyMaterial(gameObject4, (GameMaterial)213, true); MeshRenderer component = gameObject5.GetComponent(); ((Renderer)component).materials = (Material[])(object)new Material[2] { GameMaterials.GetMaterial((GameMaterial)34), GameMaterials.GetMaterial((GameMaterial)213) }; MeshRenderer component2 = gameObject6.GetComponent(); ((Renderer)component2).materials = (Material[])(object)new Material[3] { GameMaterials.GetMaterial((GameMaterial)303), GameMaterials.GetMaterial((GameMaterial)34), GameMaterials.GetMaterial((GameMaterial)29) }; MeshRenderer component3 = gameObject7.GetComponent(); ((Renderer)component3).materials = (Material[])(object)new Material[2] { GameMaterials.GetMaterial((GameMaterial)213), GameMaterials.GetMaterial((GameMaterial)34) }; MeshRenderer component4 = gameObject8.GetComponent(); ((Renderer)component4).materials = (Material[])(object)new Material[2] { GameMaterials.GetMaterial((GameMaterial)302), GameMaterials.GetMaterial((GameMaterial)302) }; GameMaterials.ApplyMaterial(gameObject9, (GameMaterial)34, true); GameMaterials.ApplyMaterial(gameObject10, (GameMaterial)34, true); MeshRenderer component5 = gameObject12.GetComponent(); ((Renderer)component5).materials = (Material[])(object)new Material[2] { GameMaterials.GetMaterial((GameMaterial)302), GameMaterials.GetMaterial((GameMaterial)304) }; GameMaterials.ApplyMaterial(gameObject13, (GameMaterial)286, true); if (!firstSetupDone) { Material material = GameMaterials.GetMaterial((GameMaterial)277); Texture2D texture = global::RegionsExpanded.CustomContent.CustomContent.Bundle.LoadAsset("Dropbox_Map_Tex"); blueprintMaterial = new Material(material) { name = "M_Blueprint" }; global::RegionsExpanded.CustomContent.CustomContent.ApplyNiceShaderTexture(blueprintMaterial, (Texture)(object)texture); Texture2D texture2 = global::RegionsExpanded.CustomContent.CustomContent.Bundle.LoadAsset("Front_Dropbox_Tex"); frontTextMaterial = new Material(material) { name = "M_FrontText" }; global::RegionsExpanded.CustomContent.CustomContent.ApplyNiceShaderTexture(frontTextMaterial, (Texture)(object)texture2); firstSetupDone = true; } ((Renderer)gameObject4.GetComponent()).material = blueprintMaterial; ((Renderer)gameObject2.GetComponent()).material = frontTextMaterial; GameMaterials.ApplyMaterial(gameObject2, (GameMaterial)301, true); GameObject upgradeBoxTubePrefab = global::RegionsExpanded.CustomContent.CustomContent.UpgradeBoxTubePrefab; if ((Object)(object)upgradeBoxTubePrefab == (Object)null) { Logger.LogError("RegionsExpanded: UpgradeBoxTubePrefab is null; tube not spawned."); return; } GameObject val3 = Object.Instantiate(upgradeBoxTubePrefab); ((Object)val3).name = "UpgradeBoxTube"; val3.transform.position = new Vector3(-3.88f, 0.61f, -15.46f); val3.transform.eulerAngles = new Vector3(0f, 90f, 0f); val3.transform.localScale = new Vector3(0.6f, 0.6f, 0.6f); Transform val4 = val3.transform.Find("Tube"); if ((Object)(object)val4 != (Object)null) { SkinnedMeshRenderer component6 = ((Component)val4).GetComponent(); if ((Object)(object)component6 != (Object)null) { ((Renderer)component6).materials = (Material[])(object)new Material[2] { GameMaterials.GetMaterial((GameMaterial)284), GameMaterials.GetMaterial((GameMaterial)302) }; } else { Logger.LogError("RegionsExpanded: UpgradeBoxTube/Tube has no SkinnedMeshRenderer."); } } else { Logger.LogError("RegionsExpanded: UpgradeBoxTube/Tube child not found."); } } private static void ApplyUrpUnlitAlbedoTexture(Material material, Texture texture) { if (material.HasProperty("_BaseMap")) { material.SetTexture("_BaseMap", texture); } } } [HarmonyPatch(typeof(SurfaceNetworkHandler), "Awake")] internal static class SurfaceNetworkHandlerMapBuyInPatch { [HarmonyPostfix] public static void Postfix(SurfaceNetworkHandler __instance) { GameObject gameObject = ((Component)__instance).gameObject; if ((Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); } if (!SurfaceNetworkHandler.HasStarted) { global::RegionsExpanded.CustomContent.CustomContent.CurrentUpgrades.Clear(); if (PhotonNetwork.IsMasterClient) { BellUpgradeRoomProps.MasterReset(); } } } } [HarmonyPatch(typeof(SurfaceNetworkHandler), "OnRoomPropertiesUpdate")] internal static class SurfaceNetworkHandlerMapScreenSyncPatch { [HarmonyPostfix] public static void Postfix(Hashtable propertiesThatChanged) { if (propertiesThatChanged == null) { Logger.LogError("RegionsExpanded: SurfaceNetworkHandler.OnRoomPropertiesUpdate postfix: propertiesThatChanged is null (unexpected)."); return; } bool flag = MapSelectionRoomProps.WantsRefresh(propertiesThatChanged); bool flag2 = BellUpgradeRoomProps.TryApply(propertiesThatChanged); if (flag) { MapScreenVisualCoordinator.RefreshAll(); } else if (flag2) { MapScreenVisualCoordinator.RefreshMaxDepth(); } } } [HarmonyPatch(typeof(SurfaceNetworkHandler), "RPCA_OnNewWeek")] internal static class SurfaceNetworkHandlerMapScreenNewWeekPatch { [HarmonyPostfix] public static void Postfix() { MapSelectionRoomProps.ResetOfflineMapPaidForNewWeek(); if (PhotonNetwork.IsMasterClient) { MapSelectionRoomProps.MasterSetMapPaid(paid: false); } MapScreenVisualCoordinator.RefreshAll(newQuotaJustStarted: true); } } [HarmonyPatch(typeof(SurfaceNetworkHandler), "RPC_QuotaFailed")] internal static class SurfaceNetworkHandlerQuotaFailedPatch { [HarmonyPostfix] public static void Postfix() { MapSelectionRoomProps.ResetOfflineMapPaidForNewWeek(); global::RegionsExpanded.CustomContent.CustomContent.CurrentUpgrades.Clear(); if (PhotonNetwork.IsMasterClient) { MapSelectionRoomProps.MasterSetMapPaid(paid: false); BellUpgradeRoomProps.MasterReset(); } } } } namespace RegionsExpanded.Net { public static class BellUpgradeRoomProps { public const string Key = "re_bu"; public static void MasterReset() { //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_0028: Expected O, but got Unknown //IL_0029: Expected O, but got Unknown if (PhotonNetwork.IsMasterClient) { global::RegionsExpanded.CustomContent.CustomContent.CurrentUpgrades.Clear(); Hashtable val = new Hashtable(); ((Dictionary)val).Add((object)"re_bu", (object)(byte)0); Hashtable val2 = val; PhotonNetwork.CurrentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null); Logger.Log("BellUpgradeRoomProps: Master reset upgrades to 0."); } } public static void MasterAddUpgrade(DivingBellUpgrade upgrade) { //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_0035: Expected O, but got Unknown //IL_0036: Expected O, but got Unknown if (PhotonNetwork.IsMasterClient) { global::RegionsExpanded.CustomContent.CustomContent.CurrentUpgrades.Add(upgrade); byte b = SerializeUpgrades(global::RegionsExpanded.CustomContent.CustomContent.CurrentUpgrades); Hashtable val = new Hashtable(); ((Dictionary)val).Add((object)"re_bu", (object)b); Hashtable val2 = val; PhotonNetwork.CurrentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null); Logger.Log($"BellUpgradeRoomProps: Master added upgrade {upgrade}. New bitmask: {b}"); } } public static bool TryApply(Hashtable changed) { if (changed != null && ((Dictionary)(object)changed).TryGetValue((object)"re_bu", out object value)) { byte b = ToByte(value); DeserializeUpgrades(b, global::RegionsExpanded.CustomContent.CustomContent.CurrentUpgrades); Logger.Log($"BellUpgradeRoomProps: Applied new upgrade bitmask: {b}"); return true; } return false; } public static bool WantsRefresh(Hashtable changed) { return ((Dictionary)(object)changed)?.ContainsKey((object)"re_bu") ?? false; } private static byte SerializeUpgrades(HashSet upgrades) { byte b = 0; foreach (DivingBellUpgrade upgrade in upgrades) { b |= (byte)(1 << (int)upgrade); } return b; } private static void DeserializeUpgrades(byte mask, HashSet targetSet) { targetSet.Clear(); foreach (DivingBellUpgrade value in Enum.GetValues(typeof(DivingBellUpgrade))) { if ((mask & (1 << (int)value)) != 0) { targetSet.Add(value); } } } private static byte ToByte(object val) { if (val is byte) { return (byte)val; } if (val is int num) { return (byte)num; } return 0; } } public class MapBuyInNetReceiver : MonoBehaviourPun { [PunRPC] private void RPCM_MapBuyIn(int cost, int mapIndex) { if (!PhotonNetwork.IsMasterClient) { Logger.LogError("RegionsExpanded: RPCM_MapBuyIn received on non-master (unexpected). IsMasterClient=false cost=" + cost); return; } if (SurfaceNetworkHandler.RoomStats == null) { Logger.LogError("RegionsExpanded: RPCM_MapBuyIn: RoomStats is null; cannot deduct. cost=" + cost); ((MonoBehaviourPun)this).photonView.RPC("RPC_PlayNoMoneySFX", (RpcTarget)0, Array.Empty()); return; } if (!SurfaceNetworkHandler.RoomStats.CanAfford(cost)) { Logger.LogError("RegionsExpanded: RPCM_MapBuyIn: host cannot afford; rejecting. cost=" + cost + " money=" + SurfaceNetworkHandler.RoomStats.Money); ((MonoBehaviourPun)this).photonView.RPC("RPC_PlayNoMoneySFX", (RpcTarget)0, Array.Empty()); return; } SurfaceNetworkHandler.RoomStats.LevelToPlay = MapLevelRouting.UiIndexToLevelToPlay(mapIndex); SurfaceNetworkHandler.RoomStats.RemoveMoney(cost); MapSelectionRoomProps.MasterSetMapBoughtAndSelected(mapIndex); MapScreenVisualCoordinator.RefreshAll(newQuotaJustStarted: false, true); ((MonoBehaviourPun)this).photonView.RPC("RPC_PlayBoughtMapSFX", (RpcTarget)0, Array.Empty()); } [PunRPC] private void RPC_PlayBoughtMapSFX() { MapScreenVisualCoordinator.PlaySFX("SFX/BoughtMap"); } [PunRPC] private void RPC_PlayNoMoneySFX() { MapScreenVisualCoordinator.PlaySFX("SFX/NoMoney"); } } public static class MapBuyInRouting { public static void PlayNoMoneySfxSynced() { if (!PhotonNetwork.InRoom) { MapScreenVisualCoordinator.PlaySFX("SFX/NoMoney"); return; } SurfaceNetworkHandler val = Object.FindFirstObjectByType(); PhotonView val2 = (((Object)(object)val == (Object)null) ? null : ((Component)val).GetComponent()); if ((Object)(object)val2 == (Object)null) { MapScreenVisualCoordinator.PlaySFX("SFX/NoMoney"); } else { val2.RPC("RPC_PlayNoMoneySFX", (RpcTarget)0, Array.Empty()); } } public static void RequestDeductMapBuyIn(int cost, int mapIndex) { if (SurfaceNetworkHandler.RoomStats == null) { Logger.LogError("RegionsExpanded: Map buy-in: RoomStats is null."); PlayNoMoneySfxSynced(); return; } if (!PhotonNetwork.InRoom) { if (!SurfaceNetworkHandler.RoomStats.CanAfford(cost)) { Logger.LogError("RegionsExpanded: Map buy-in: offline deduct blocked — cannot afford. cost=" + cost + " money=" + SurfaceNetworkHandler.RoomStats.Money); PlayNoMoneySfxSynced(); return; } SurfaceNetworkHandler.RoomStats.LevelToPlay = MapLevelRouting.UiIndexToLevelToPlay(mapIndex); SurfaceNetworkHandler.RoomStats.RemoveMoney(cost); MapSelectionRoomProps.SetOfflineMapPaidAndSelected(mapIndex); MapScreenVisualCoordinator.RefreshAll(); MapScreenVisualCoordinator.PlaySFX("SFX/BoughtMap"); return; } SurfaceNetworkHandler val = Object.FindFirstObjectByType(); PhotonView val2 = (((Object)(object)val == (Object)null) ? null : ((Component)val).GetComponent()); if ((Object)(object)val2 == (Object)null) { Logger.LogError(((Object)(object)val == (Object)null) ? "RegionsExpanded: Map buy-in: SurfaceNetworkHandler not found in scene; falling back to local deduct (unexpected)." : "RegionsExpanded: Map buy-in: SurfaceNetworkHandler has no PhotonView; falling back to local deduct (unexpected)."); if (!SurfaceNetworkHandler.RoomStats.CanAfford(cost)) { Logger.LogError("RegionsExpanded: Map buy-in: local fallback deduct blocked — cannot afford. cost=" + cost + " money=" + SurfaceNetworkHandler.RoomStats.Money); PlayNoMoneySfxSynced(); return; } SurfaceNetworkHandler.RoomStats.LevelToPlay = MapLevelRouting.UiIndexToLevelToPlay(mapIndex); SurfaceNetworkHandler.RoomStats.RemoveMoney(cost); MapSelectionRoomProps.SetOfflineMapPaidAndSelected(mapIndex); MapScreenVisualCoordinator.RefreshAll(); MapScreenVisualCoordinator.PlaySFX("SFX/BoughtMap"); } else { val2.RPC("RPCM_MapBuyIn", (RpcTarget)2, new object[2] { cost, mapIndex }); } } } public static class MapLevelRouting { public static int UiIndexToLevelToPlay(int uiIndex) { if (uiIndex < 0 || uiIndex >= global::RegionsExpanded.CustomContent.CustomContent.MapInstances.Length) { return 0; } return SceneNameToLevelToPlay(global::RegionsExpanded.CustomContent.CustomContent.MapInstances[uiIndex].SceneName); } public static int SceneNameToLevelToPlay(string sceneName) { return sceneName switch { "FactoryScene" => 0, "MinesScene" => 1, "HarbourScene" => 2, _ => 3, }; } } public static class MapSelectionRoomProps { public const string Key = "re_mp"; public const string RunKey = "re_mpr"; public const string SelectedKey = "re_msi"; private static bool _offlineMapPaid; private static int _offlineMapPaidRun = -1; private static int _offlineSelectedMapIndex = -1; public static bool IsMapBuyInPaidFromSources() { if (SurfaceNetworkHandler.RoomStats == null) { return false; } int currentRun = SurfaceNetworkHandler.RoomStats.CurrentRun; if (PhotonNetwork.InRoom) { Room currentRoom = PhotonNetwork.CurrentRoom; if (((currentRoom != null) ? ((RoomInfo)currentRoom).CustomProperties : null) != null) { Hashtable customProperties = ((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties; if (!((Dictionary)(object)customProperties).TryGetValue((object)"re_mp", out object value) || !ToBool(value)) { return false; } if (!((Dictionary)(object)customProperties).TryGetValue((object)"re_mpr", out object value2)) { Logger.LogError("RegionsExpanded: room prop re_mp is set but re_mpr is missing; treating as unpaid for this quota (stale or pre-patch room)."); return false; } int num = ToInt(value2); return num == currentRun; } } if (_offlineMapPaid) { return _offlineMapPaidRun == currentRun; } return false; } public static int GetSelectedMapIndex() { if (!IsMapBuyInPaidFromSources()) { return -1; } if (PhotonNetwork.InRoom) { Room currentRoom = PhotonNetwork.CurrentRoom; if (((currentRoom != null) ? ((RoomInfo)currentRoom).CustomProperties : null) != null) { Hashtable customProperties = ((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties; if (((Dictionary)(object)customProperties).TryGetValue((object)"re_msi", out object value)) { return ToInt(value); } return -1; } } return _offlineSelectedMapIndex; } public static void SetOfflineMapPaidAndSelected(int mapIndex) { _offlineMapPaid = true; _offlineSelectedMapIndex = mapIndex; if (SurfaceNetworkHandler.RoomStats != null) { _offlineMapPaidRun = SurfaceNetworkHandler.RoomStats.CurrentRun; } else { _offlineMapPaidRun = -1; } if (mapIndex >= 0 && mapIndex < global::RegionsExpanded.CustomContent.CustomContent.MapInstances.Length) { Logger.Log("The next map will be " + global::RegionsExpanded.CustomContent.CustomContent.MapInstances[mapIndex].DisplayName); } } public static void ResetOfflineMapPaidForNewWeek() { _offlineMapPaid = false; _offlineMapPaidRun = -1; _offlineSelectedMapIndex = -1; } public static void MasterSetMapBoughtAndSelected(int mapIndex) { //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_00ad: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00d0: Expected O, but got Unknown if (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient) { Logger.LogError("RegionsExpanded: MasterSetMapBoughtAndSelected(" + mapIndex + ") ignored — InRoom=" + PhotonNetwork.InRoom + " IsMasterClient=" + PhotonNetwork.IsMasterClient + " (unexpected caller)."); return; } if (SurfaceNetworkHandler.RoomStats == null) { Logger.LogError("RegionsExpanded: MasterSetMapBoughtAndSelected(" + mapIndex + "): RoomStats is null."); return; } int currentRun = SurfaceNetworkHandler.RoomStats.CurrentRun; Hashtable val = new Hashtable(); ((Dictionary)val).Add((object)"re_mp", (object)true); ((Dictionary)val).Add((object)"re_mpr", (object)currentRun); ((Dictionary)val).Add((object)"re_msi", (object)mapIndex); Hashtable val2 = val; PhotonNetwork.CurrentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null); if (mapIndex >= 0 && mapIndex < global::RegionsExpanded.CustomContent.CustomContent.MapInstances.Length) { Logger.Log("The next map will be " + global::RegionsExpanded.CustomContent.CustomContent.MapInstances[mapIndex].DisplayName); } } public static void MasterSetMapPaid(bool paid) { //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_00bf: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00e2: Expected O, but got Unknown if (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient) { Logger.LogError("RegionsExpanded: MasterSetMapPaid(" + paid + ") ignored — InRoom=" + PhotonNetwork.InRoom + " IsMasterClient=" + PhotonNetwork.IsMasterClient + " (unexpected caller)."); } else if (SurfaceNetworkHandler.RoomStats == null) { Logger.LogError("RegionsExpanded: MasterSetMapPaid(" + paid + "): RoomStats is null."); } else { int num = (paid ? SurfaceNetworkHandler.RoomStats.CurrentRun : (-1)); int num2 = (paid ? GetSelectedMapIndex() : (-1)); Hashtable val = new Hashtable(); ((Dictionary)val).Add((object)"re_mp", (object)paid); ((Dictionary)val).Add((object)"re_mpr", (object)num); ((Dictionary)val).Add((object)"re_msi", (object)num2); Hashtable val2 = val; PhotonNetwork.CurrentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null); } } public static bool WantsRefresh(Hashtable propertiesThatChanged) { if (propertiesThatChanged == null || ((Dictionary)(object)propertiesThatChanged).Count == 0) { return false; } if (((Dictionary)(object)propertiesThatChanged).ContainsKey((object)"re_mp")) { return true; } if (((Dictionary)(object)propertiesThatChanged).ContainsKey((object)"re_mpr")) { return true; } if (((Dictionary)(object)propertiesThatChanged).ContainsKey((object)"re_msi")) { return true; } if (((Dictionary)(object)propertiesThatChanged).ContainsKey((object)"m")) { return true; } if (((Dictionary)(object)propertiesThatChanged).ContainsKey((object)"d")) { return true; } if (((Dictionary)(object)propertiesThatChanged).ContainsKey((object)"q")) { return true; } return false; } private static int ToInt(object? v) { if (v is int) { return (int)v; } if (v is byte) { return (byte)v; } if (v is short) { return (short)v; } if (v != null) { Logger.LogError("RegionsExpanded: room prop re_mpr has unsupported type " + v.GetType().FullName + "; treating as -1."); } return -1; } private static bool ToBool(object? v) { if (v is bool) { return (bool)v; } if (v is byte b) { return b != 0; } if (v is int num) { return num != 0; } if (v != null) { Logger.LogError("RegionsExpanded: room prop re_mp has unsupported type " + v.GetType().FullName + "; treating as false."); } return false; } } } namespace RegionsExpanded.CustomContent { public enum DivingBellUpgrade { Radar, HighPressureArmorPlatings } public static class CustomContent { private const string BundleName = "regionsexpanded"; private const string BundleNameMap = "scaffoldings_scene"; public static GameObject? DivingBellMapScreenPrefab; public static GameObject? DivingBellUpgradeDropboxPrefab; public static GameObject? UpgradeBoxTubePrefab; public static GameObject? UpgradeRadarVisualPrefab; public static GameObject? UpgradePlatingVisualPrefab; public static GameObject? UpgradeAddedExplosionPrefab; public static GameObject? UpgradeAddedExplosionPlatingsPrefab; public static GameObject? ElevatorCrashExplosionPrefab; public static SFX_Instance? hatchCloseSfx; public static SFX_Instance? hatchOpenSfx; public static readonly MapInstance[] MapInstances = new MapInstance[4] { new MapInstance("Factory", "FactoryScene", 50, 400, "factory_white", new MapLifecycleHooks()), new MapInstance("Harbour", "HarbourScene", 50, 600, "ship_white", new MapLifecycleHooks()), new MapInstance("Mines", "MinesScene", 50, 1000, "cave_white", new MapLifecycleHooks()), new MapInstance("Scaffoldings", "ScaffoldingsScene", 100, 1250, "scaff_map_icon", new MapLifecycleHooks { onAfterSceneLoaded = delegate { Logger.Log("[Scaffoldings] onAfterSceneLoaded"); }, onBeforeCleanup = delegate { Logger.Log("[Scaffoldings] onBeforeCleanup"); }, onAfterSetup = delegate(MapLoadContext ctx) { //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) Logger.Log("[Scaffoldings] onAfterSetup"); Scene? loadedScene = ctx.LoadedScene; if (loadedScene.HasValue) { Scene valueOrDefault = loadedScene.GetValueOrDefault(); GameObject val = null; GameObject[] rootGameObjects = ((Scene)(ref valueOrDefault)).GetRootGameObjects(); foreach (GameObject val2 in rootGameObjects) { if (((Object)val2).name == "ScaffoldingsBlockout") { val = val2; break; } } if ((Object)(object)val == (Object)null) { Logger.LogError("[Scaffoldings] Root object 'ScaffoldingsBlockout' not found in scene."); } else { Transform val3 = val.transform.Find("Terrain/UpperVillage/cabin"); if ((Object)(object)val3 == (Object)null) { Logger.LogError("[Scaffoldings] 'Terrain/UpperVillage/cabin' not found under ScaffoldingsBlockout."); } else { SetupElevator(val3); } } } else { Logger.LogError("[Scaffoldings] LoadedScene is null; cannot set up elevator."); } } }) }; public static HashSet CurrentUpgrades = new HashSet(); public const float MaxDepthIndicatorRightYAnchorOffset = 51.4f; public static AssetBundle? Bundle { get; private set; } public static AssetBundle? BundleMap { get; private set; } public static int MAX_DEPTH { get { if (RegionsExpanded.DEBUG_MODE) { return int.MaxValue; } int num = 700; if (CurrentUpgrades.Contains(DivingBellUpgrade.HighPressureArmorPlatings)) { num += 400; } if (CurrentUpgrades.Contains(DivingBellUpgrade.Radar)) { num += 900; } return num; } } public static string MapIdForScene(string sceneName) { return "regionsexpanded." + sceneName.ToLowerInvariant(); } public static void Init() { try { Logger.Log("Loading custom content..."); AssetBundle val = ContentLoader.LoadAssetBundle(Assembly.GetExecutingAssembly(), "regionsexpanded"); AssetBundle val2 = ContentLoader.LoadAssetBundle(Assembly.GetExecutingAssembly(), "scaffoldings_scene"); DivingBellMapScreenPrefab = ContentLoader.LoadPrefabFromBundle(val, "MapScreen.prefab"); DivingBellUpgradeDropboxPrefab = ContentLoader.LoadPrefabFromBundle(val, "UpgradeDropbox.prefab"); UpgradeBoxTubePrefab = ContentLoader.LoadPrefabFromBundle(val, "UpgradeBoxTube.prefab"); UpgradeRadarVisualPrefab = ContentLoader.LoadPrefabFromBundle(val, "UpgradeRadarVisual.prefab"); UpgradePlatingVisualPrefab = ContentLoader.LoadPrefabFromBundle(val, "UpgradePlatingVisual.prefab"); UpgradeAddedExplosionPrefab = ContentLoader.LoadPrefabFromBundle(val, "UpgradeAddedExplosion.prefab"); UpgradeAddedExplosionPlatingsPrefab = ContentLoader.LoadPrefabFromBundle(val, "UpgradeAddedExplosionPlatings.prefab"); ElevatorCrashExplosionPrefab = ContentLoader.LoadPrefabFromBundle(val, "ElevatorCrashExplosion.prefab"); hatchCloseSfx = val.LoadAsset("HatchCloseSFX"); hatchOpenSfx = val.LoadAsset("HatchOpenSFX"); Bundle = val; if ((Object)(object)val == (Object)null) { Logger.LogError("Failed to load asset bundle 'regionsexpanded' (file must sit next to the mod DLL)."); return; } if ((Object)(object)val2 == (Object)null) { Logger.LogError("Failed to load asset bundle 'scaffoldings_scene' (file must sit next to the mod DLL)."); return; } if ((Object)(object)UpgradeRadarVisualPrefab == (Object)null) { Logger.LogError("RegionsExpanded: UpgradeRadarVisual.prefab missing or failed to load from bundle 'regionsexpanded' (unexpected if asset is present)."); } else { Logger.Log("RegionsExpanded: UpgradeRadarVisual prefab loaded from bundle."); } if ((Object)(object)UpgradePlatingVisualPrefab == (Object)null) { Logger.LogError("RegionsExpanded: UpgradePlatingVisual.prefab missing or failed to load from bundle 'regionsexpanded' (unexpected if asset is present)."); } else { Logger.Log("RegionsExpanded: UpgradePlatingVisual prefab loaded from bundle."); } if ((Object)(object)UpgradeAddedExplosionPrefab == (Object)null) { Logger.LogError("RegionsExpanded: UpgradeAddedExplosion.prefab missing or failed to load from bundle 'regionsexpanded' (unexpected if asset is present)."); } else { Logger.Log("RegionsExpanded: UpgradeAddedExplosion prefab loaded from bundle."); } if ((Object)(object)UpgradeAddedExplosionPlatingsPrefab == (Object)null) { Logger.LogError("RegionsExpanded: UpgradeAddedExplosionPlatings.prefab missing or failed to load from bundle 'regionsexpanded' (unexpected if asset is present)."); } else { Logger.Log("RegionsExpanded: UpgradeAddedExplosionPlatings prefab loaded from bundle."); } if ((Object)(object)ElevatorCrashExplosionPrefab == (Object)null) { Logger.LogError("RegionsExpanded: ElevatorCrashExplosion.prefab missing or failed to load from bundle 'regionsexpanded' (unexpected if asset is present)."); } else { Logger.Log("RegionsExpanded: ElevatorCrashExplosion prefab loaded from bundle."); } CustomItems.Setup(val); RegisterCustomMaps(val2); Logger.Log("Custom content successfully initialized."); } catch (Exception ex) { Bundle = null; Logger.LogError("Failed to initialize custom content: " + ex.Message); } } private static void RegisterCustomMaps(AssetBundle bundleMap) { string[] allScenePaths = bundleMap.GetAllScenePaths(); foreach (string text in allScenePaths) { Logger.Log("[Maps] Scene: " + text); } MapInstance[] mapInstances = MapInstances; for (int j = 0; j < mapInstances.Length; j++) { MapInstance mapInstance = mapInstances[j]; if (MapLevelRouting.SceneNameToLevelToPlay(mapInstance.SceneName) >= 3) { string text2 = Maps.FindScenePath(bundleMap, mapInstance.SceneName) ?? Maps.FindScenePath(bundleMap, Path.GetFileNameWithoutExtension(mapInstance.SceneName)); if (text2 == null) { Logger.Log("[Maps] No bundle scene for '" + mapInstance.SceneName + "'; skipping DbsContentApi registration."); } else { Maps.RegisterMap(bundleMap, text2, mapInstance.DisplayName, (MapConfig)null, MapIdForScene(mapInstance.SceneName), mapInstance.Hooks); } } } } public static void ApplyNiceShaderTexture(Material material, Texture texture) { if (material.HasProperty("_Variation")) { material.SetTexture("_Variation", texture); } } private static void SetupElevator(Transform cabin) { PhotonView val = ((Component)cabin).gameObject.AddComponent(); val.ViewID = 997; Logger.Log($"[Scaffoldings] PhotonView added to cabin (ViewID={997})."); ((Component)cabin).gameObject.AddComponent(); Logger.Log("[Scaffoldings] StandableRig added to cabin."); ElevatorController elevatorController = ((Component)cabin).gameObject.AddComponent(); Transform val2 = cabin.Find("DoorPivot"); if ((Object)(object)val2 == (Object)null) { Logger.LogError("[Scaffoldings] 'DoorPivot' not found under cabin — elevator door will not animate."); } else { Animator component = ((Component)val2).GetComponent(); object obj; if (component == null) { obj = null; } else { RuntimeAnimatorController runtimeAnimatorController = component.runtimeAnimatorController; obj = ((runtimeAnimatorController != null) ? runtimeAnimatorController.animationClips : null); } if (obj == null) { obj = Array.Empty(); } AnimationClip[] array = (AnimationClip[])obj; Logger.Log($"[Scaffoldings] DoorPivot animator clips ({array.Length}):"); AnimationClip[] array2 = array; foreach (AnimationClip val3 in array2) { Logger.Log($" • {((Object)val3).name} (length={val3.length:F2}s, loop={((Motion)val3).isLooping})"); } ElevatorDoor elevatorDoor = ((Component)val2).gameObject.AddComponent(); AnimationClip[] array3 = array; foreach (AnimationClip val4 in array3) { string text = ((Object)val4).name.ToLowerInvariant(); if (text.Contains("open") && !text.Contains("close") && ((Motion)val4).isLooping) { elevatorDoor.openedClip = val4; } else if (text.Contains("close") && ((Motion)val4).isLooping) { elevatorDoor.closedClip = val4; } else if (text.Contains("open") && !text.Contains("close") && !((Motion)val4).isLooping) { elevatorDoor.openClip = val4; } else if (text.Contains("close") && !((Motion)val4).isLooping) { elevatorDoor.closeClip = val4; } } if ((Object)(object)elevatorDoor.openedClip == (Object)null) { Logger.LogError("[Scaffoldings] Could not auto-match 'openedClip' — check clip names in the log above."); } if ((Object)(object)elevatorDoor.closedClip == (Object)null) { Logger.LogError("[Scaffoldings] Could not auto-match 'closedClip' — check clip names in the log above."); } if ((Object)(object)elevatorDoor.openClip == (Object)null) { Logger.LogError("[Scaffoldings] Could not auto-match 'openClip' — check clip names in the log above."); } if ((Object)(object)elevatorDoor.closeClip == (Object)null) { Logger.LogError("[Scaffoldings] Could not auto-match 'closeClip' — check clip names in the log above."); } elevatorController.door = elevatorDoor; } Transform val5 = cabin.Find("DoorPivot/Door/Wheels/WheelOutside/COLLIDER"); if ((Object)(object)val5 == (Object)null) { Logger.LogError("[Scaffoldings] Door button collider 'DoorPivot/Door/Wheels/WheelOutside/COLLIDER' not found."); } else { ElevatorOutsideDoorButton elevatorOutsideDoorButton = ((Component)val5).gameObject.AddComponent(); elevatorOutsideDoorButton.elevator = elevatorController; Logger.Log("[Scaffoldings] ElevatorOutsideDoorButton (Outside) attached."); } Transform val6 = cabin.Find("DoorButton"); if ((Object)(object)val6 == (Object)null) { Logger.LogError("[Scaffoldings] Inside door button 'DoorButton' not found under cabin."); } else { ElevatorInsideDoorButton elevatorInsideDoorButton = ((Component)val6).gameObject.AddComponent(); elevatorInsideDoorButton.elevator = elevatorController; elevatorInsideDoorButton.lever = val6.Find("Box/Lever"); if ((Object)(object)elevatorInsideDoorButton.lever == (Object)null) { Logger.LogError("[Scaffoldings] 'Lever' not found under DoorButton."); } Logger.Log("[Scaffoldings] ElevatorInsideDoorButton (Inside) attached."); } Transform val7 = cabin.Find("TopBtn"); if ((Object)(object)val7 == (Object)null) { Logger.LogError("[Scaffoldings] 'TopBtn' not found under cabin."); } else { ElevatorCabinButton elevatorCabinButton = ((Component)val7).gameObject.AddComponent(); elevatorCabinButton.elevator = elevatorController; elevatorCabinButton.direction = ElevatorButtonDirection.Up; Logger.Log("[Scaffoldings] ElevatorCabinButton (Up) attached to TopBtn."); } Transform val8 = cabin.Find("BottomBtn"); if ((Object)(object)val8 == (Object)null) { Logger.LogError("[Scaffoldings] 'BottomBtn' not found under cabin."); } else { ElevatorCabinButton elevatorCabinButton2 = ((Component)val8).gameObject.AddComponent(); elevatorCabinButton2.elevator = elevatorController; elevatorCabinButton2.direction = ElevatorButtonDirection.Down; Logger.Log("[Scaffoldings] ElevatorCabinButton (Down) attached to BotBtn."); } Transform val9 = cabin.Find("InnerZone"); if ((Object)(object)val9 == (Object)null) { Logger.LogError("[Scaffoldings] 'InnerZone' not found under cabin — players will not receive movement force."); } else { ((Component)val9).gameObject.AddComponent(); Logger.Log("[Scaffoldings] ElevatorInnerZone attached to InnerZone."); } Logger.Log("[Scaffoldings] Elevator setup complete."); } } public static class BellUpgradePersistence { public static void Register() { ItemPersistence.RegisterInventoryItemProvider((Func>)GetEquippedUpgradeItems); } private static IEnumerable GetEquippedUpgradeItems() { foreach (DivingBellUpgrade currentUpgrade in CustomContent.CurrentUpgrades) { Item val = CustomItems.TryGetItemForUpgrade(currentUpgrade); if ((Object)(object)val != (Object)null) { yield return val; } } } } public static class CustomItems { private static AssetBundle? _bundle; public static ShopItemCategory DivingBellUpgradesCategory; public static GameObject? UpgradeItemOnePrefab; public static GameObject? UpgradeItemTwoPrefab; public static Item? RadarUpgradeItem; public static Item? ArmorPlatingsUpgradeItem; public static Material? boxFrontTexturePlateMaterial; public static Material? boxFrontTextureRadarMaterial; public static bool setupDone; public static void Setup(AssetBundle bundle) { //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) _bundle = bundle; DivingBellUpgradesCategory = Items.RegisterCustomCategory("Bell upgrades"); Items.DeferRegistration((Action)delegate { Texture2D val = CustomContent.Bundle.LoadAsset("FrontTexBoxPlate"); boxFrontTexturePlateMaterial = GameMaterials.CloneMaterial((GameMaterial)277, val, "M_FrontTextBoxPlates"); Texture2D val2 = CustomContent.Bundle.LoadAsset("FrontTexBoxRadar"); boxFrontTextureRadarMaterial = GameMaterials.CloneMaterial((GameMaterial)277, val2, "M_FrontTextBoxRadar"); RegisterDivingBellUpgradeRadar(); RegisterDivingBellUpgradeHighPressureArmorPlatings(); }); } private static void SetupDivingBellUpgradeDropboxPrefabMats(GameObject prefab) { GameObject gameObject = ((Component)prefab.transform.Find("Item/boxy")).gameObject; MeshRenderer component = ((Component)gameObject.transform.Find("CubeBase")).GetComponent(); MeshRenderer component2 = ((Component)gameObject.transform.Find("Plates")).GetComponent(); GameMaterials.Batch(gameObject).At("Blueprint1", (GameMaterial)245, false).At("Blueprint2", (GameMaterial)245, false) .At("MossFloor", (DescriptiveMaterial)2, false) .At("Nuts", (GameMaterial)34, false); GameMaterials.SetMaterialAt((Renderer)(object)component, 0, (DescriptiveMaterial)28); GameMaterials.SetMaterialAt((Renderer)(object)component, 1, (DescriptiveMaterial)26); GameMaterials.SetMaterialAt((Renderer)(object)component, 2, (DescriptiveMaterial)3); GameMaterials.SetMaterialAt((Renderer)(object)component2, 0, (DescriptiveMaterial)2); GameMaterials.SetMaterialAt((Renderer)(object)component2, 1, (GameMaterial)34); } private static void RegisterDivingBellUpgradeRadar() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //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) //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) GameObject val = ContentLoader.LoadPrefabFromBundle(_bundle, "BellBoxUpgradeItem1.prefab"); ((Object)val).name = "BellBoxUpgradeItem_Radar"; SetupDivingBellUpgradeDropboxPrefabMats(val); GameObject gameObject = ((Component)val.transform.Find("Item/boxy/FrontTexture")).gameObject; ((Renderer)gameObject.GetComponent()).material = boxFrontTextureRadarMaterial; DivingBellUpgradeItemBehaviour divingBellUpgradeItemBehaviour = val.AddComponent(); divingBellUpgradeItemBehaviour.BellUpgrade = DivingBellUpgrade.Radar; ItemConfig val2 = new ItemConfig(); val2.displayName = "Radar"; val2.price = 350; val2.category = DivingBellUpgradesCategory; val2.icon = GetSprite("radar_upgrade_icon"); val2.impactSoundTypes = (ImpactSoundType[])(object)new ImpactSoundType[1] { (ImpactSoundType)11 }; val2.holdPos = new Vector3(0.3f, -0.6f, 0.7f); RadarUpgradeItem = Items.RegisterItem(val, val2); } private static void RegisterDivingBellUpgradeHighPressureArmorPlatings() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_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) GameObject val = ContentLoader.LoadPrefabFromBundle(_bundle, "BellBoxUpgradeItem2.prefab"); ((Object)val).name = "BellBoxUpgradeItem_HighPressureArmorPlatings"; SetupDivingBellUpgradeDropboxPrefabMats(val); GameObject gameObject = ((Component)val.transform.Find("Item/boxy/FrontTexture")).gameObject; ((Renderer)gameObject.GetComponent()).material = boxFrontTexturePlateMaterial; DivingBellUpgradeItemBehaviour divingBellUpgradeItemBehaviour = val.AddComponent(); divingBellUpgradeItemBehaviour.BellUpgrade = DivingBellUpgrade.HighPressureArmorPlatings; ItemConfig val2 = new ItemConfig(); val2.displayName = "Armor Platings"; val2.price = 100; val2.category = DivingBellUpgradesCategory; val2.icon = GetSprite("armor_upgrade_icon"); val2.impactSoundTypes = (ImpactSoundType[])(object)new ImpactSoundType[1] { (ImpactSoundType)11 }; val2.holdPos = new Vector3(0.3f, -0.6f, 0.7f); ArmorPlatingsUpgradeItem = Items.RegisterItem(val, val2); } public static Item? TryGetItemForUpgrade(DivingBellUpgrade upgrade) { return (Item?)(upgrade switch { DivingBellUpgrade.Radar => RadarUpgradeItem, DivingBellUpgrade.HighPressureArmorPlatings => ArmorPlatingsUpgradeItem, _ => null, }); } public static Texture2D GetTexture(string iconName) { return _bundle.LoadAsset(iconName); } public static Sprite? GetSprite(string iconName) { if ((Object)(object)_bundle == (Object)null) { return null; } return _bundle.LoadAsset(iconName); } } public class DivingBellUpgradeItemBehaviour : ItemInstanceBehaviour { public DivingBellUpgrade BellUpgrade; public override void ConfigItem(ItemInstanceData data, PhotonView playerView) { } } public readonly struct MapInstance { private readonly int _buyInDollars; public string DisplayName { get; } public string SceneName { get; } public int BuyInDollars { get { if (!RegionsExpanded.DEBUG_MODE) { return _buyInDollars; } return 0; } } public int DepthMeters { get; } public string IconBundleName { get; } public MapLifecycleHooks Hooks { get; } public MapInstance(string displayName, string sceneName, int buyInDollars, int depthMeters, string iconBundleName, MapLifecycleHooks hooks) { DisplayName = displayName; SceneName = sceneName; _buyInDollars = buyInDollars; DepthMeters = depthMeters; IconBundleName = iconBundleName; Hooks = hooks; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }