Decompiled source of ScoutFallFlat v1.0.3
plugins/YonDev.ScoutFallFlat.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.Tilemaps; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("YonDev.ScoutFallFlat")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+fe7e8ba9ddf9f354846a9d8605003ee6ba242421")] [assembly: AssemblyProduct("YonDev.ScoutFallFlat")] [assembly: AssemblyTitle("ScoutFallFlat")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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 AutomaticDoor : MonoBehaviour { [SerializeField] private GameObject Left; [SerializeField] private GameObject Right; [SerializeField] private List<Light> Indicators = new List<Light>(); public List<PressurePlate> CombinedSignals = new List<PressurePlate>(); public float moveSpeed = 2f; public bool isOpen = false; public bool isCombinedSignal = false; private Coroutine doorMovementCoroutine; private void Awake() { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown if ((Object)(object)Left == (Object)null || (Object)(object)Right == (Object)null) { Left = ((Component)((Component)this).transform.Find("Left")).gameObject; Right = ((Component)((Component)this).transform.Find("Right")).gameObject; } Light[] componentsInChildren = ((Component)((Component)this).transform.parent).GetComponentsInChildren<Light>(); foreach (Light val in componentsInChildren) { if (((Object)((Component)val).transform.parent).name.Equals("Indicator") || ((Object)((Component)val).transform.parent).name.Equals("ExitSign")) { ((Behaviour)val).enabled = isOpen; Indicators.Add(val); } } foreach (Transform item in ((Component)this).transform.parent) { Transform val2 = item; if (((Object)val2).name.Contains("SignalCombine")) { isCombinedSignal = true; break; } } if (isCombinedSignal) { checkCombinedSignal(); } } public void ToggleDoor(bool toOpen = true) { //IL_00f6: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) if (isCombinedSignal) { if (CombinedSignals.Count < 2) { checkCombinedSignal(); } foreach (PressurePlate combinedSignal in CombinedSignals) { if (!combinedSignal.isPressed) { return; } } foreach (PressurePlate combinedSignal2 in CombinedSignals) { Object.Destroy((Object)(object)combinedSignal2); } } isOpen = !isOpen; if (isOpen != toOpen) { isOpen = toOpen; } Vector3 leftTarget = (Vector3)(isOpen ? new Vector3(0f, 0f, 0.8f) : Vector3.zero); Vector3 rightTarget = (Vector3)(isOpen ? new Vector3(0f, 0f, -0.8f) : Vector3.zero); foreach (Light indicator in Indicators) { ((Behaviour)indicator).enabled = isOpen; } if (doorMovementCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(doorMovementCoroutine); } doorMovementCoroutine = ((MonoBehaviour)this).StartCoroutine(MoveDoors(leftTarget, rightTarget)); } private IEnumerator MoveDoors(Vector3 leftTarget, Vector3 rightTarget) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Left == (Object)null || (Object)(object)Right == (Object)null) { Left = ((Component)((Component)this).transform.Find("Left")).gameObject; Right = ((Component)((Component)this).transform.Find("Right")).gameObject; } while (Left.transform.localPosition != leftTarget || Right.transform.localPosition != rightTarget) { Left.transform.localPosition = Vector3.MoveTowards(Left.transform.localPosition, leftTarget, moveSpeed * Time.deltaTime); Right.transform.localPosition = Vector3.MoveTowards(Right.transform.localPosition, rightTarget, moveSpeed * Time.deltaTime); yield return null; } } private void checkCombinedSignal() { PressurePlate[] componentsInChildren = ((Component)((Component)this).transform.parent).GetComponentsInChildren<PressurePlate>(); foreach (PressurePlate pressurePlate in componentsInChildren) { CombinedSignals.Add(pressurePlate); pressurePlate.isDependant = true; } } } public class ElevatorButton : MonoBehaviour { public ElevatorLinear elevator; private Vector3 ogPos; private int objectsOnPlate = 0; private float timeSincePressed = 0f; private void Awake() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) ogPos = ((Component)this).transform.localPosition; } private void Update() { timeSincePressed += Time.deltaTime; } private void OnTriggerEnter(Collider other) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)elevator == (Object)null) { elevator = ((Component)((Component)this).transform.parent.parent).GetComponent<ElevatorLinear>(); if ((Object)(object)elevator == (Object)null) { elevator = ((Component)((Component)this).transform.parent.parent).GetComponentInChildren<ElevatorLinear>(); } } if (((Component)other).gameObject.layer != LayerMask.NameToLayer("Character")) { return; } objectsOnPlate++; Debug.LogWarning((object)("Valid Elevator button pressed by: " + ((Object)((Component)other).gameObject).name)); if (objectsOnPlate == 1) { ((Component)this).transform.localPosition = ((Component)this).transform.localPosition - new Vector3(0.06f, 0f, 0f); if (!(timeSincePressed < 0.5f)) { elevator.ToggleElevator(); timeSincePressed = 0f; } } } private void OnTriggerExit(Collider other) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (((Component)other).gameObject.layer == LayerMask.NameToLayer("Character")) { objectsOnPlate--; if (objectsOnPlate < 0) { objectsOnPlate = 0; } if (objectsOnPlate == 0) { Debug.Log((object)("Valid Exit other is " + ((Object)((Component)other).gameObject).name)); ((Component)this).transform.localPosition = ogPos; } } } } public class ElevatorLinear : MonoBehaviour { [SerializeField] private GameObject Platform; [SerializeField] private GameObject ElevatorControl; private bool isUp = false; public float moveSpeed = 2f; private Vector3 OriginalPosPlatform; private Vector3 OriginalPosElevatorControl; private Coroutine ElevMovementCoroutine; private float Height = -1f; private void Awake() { //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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Platform == (Object)null) { Platform = ((Component)((Component)this).transform.Find("Platform")).gameObject; } if ((Object)(object)ElevatorControl == (Object)null) { ElevatorControl = ((Component)((Component)this).transform.Find("ElevatorControl")).gameObject; } Height = Platform.GetComponentInChildren<CapsuleCollider>().height; Platform.GetComponent<Rigidbody>().isKinematic = true; ElevatorControl.GetComponent<Rigidbody>().isKinematic = true; OriginalPosPlatform = Platform.transform.position; OriginalPosElevatorControl = ElevatorControl.transform.position; } public void ToggleElevator() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) isUp = !isUp; Vector3 targetPosPlatform = (isUp ? (OriginalPosPlatform + new Vector3(0f, Height, 0f)) : OriginalPosPlatform); Vector3 targetPosElevatorControl = (isUp ? (OriginalPosElevatorControl + new Vector3(0f, Height, 0f)) : OriginalPosElevatorControl); if (ElevMovementCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(ElevMovementCoroutine); } ElevMovementCoroutine = ((MonoBehaviour)this).StartCoroutine(MoveElevator(targetPosPlatform, targetPosElevatorControl)); } private IEnumerator MoveElevator(Vector3 TargetPosPlatform, Vector3 TargetPosElevatorControl) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) while (Platform.transform.position != TargetPosPlatform && ElevatorControl.transform.position != TargetPosElevatorControl) { Platform.transform.position = Vector3.MoveTowards(Platform.transform.position, TargetPosPlatform, moveSpeed * Time.deltaTime); ElevatorControl.transform.position = Vector3.MoveTowards(ElevatorControl.transform.position, TargetPosElevatorControl, moveSpeed * Time.deltaTime); yield return null; } } } public class PressurePlate : MonoBehaviour { private float nextAllowedOffTime = 0f; private float safetyBuffer = 0.25f; [SerializeField] private Light lit = null; public bool isPressed = false; public bool isDependant = false; public int objectsOnPlate = 0; private void Awake() { if (!((Object)(object)lit != (Object)null)) { lit = ((Component)((Component)this).transform).GetComponentInChildren<Light>(); ((Behaviour)lit).enabled = isPressed; lit.intensity = 25f; if (!((Object)((Component)this).gameObject).name.Contains("Button_Apply")) { ((Component)this).GetComponent<Renderer>().material.DisableKeyword("_EMISSION"); } } } private void OnTriggerEnter(Collider other) { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (((Component)other).gameObject.layer != LayerMask.NameToLayer("Character")) { return; } objectsOnPlate++; Debug.LogWarning((object)("Pressure plate pressed by: " + ((Object)((Component)other).gameObject).name)); if (objectsOnPlate != 1) { return; } ((MonoBehaviour)this).CancelInvoke("TurnVisualsOff"); isPressed = true; nextAllowedOffTime = Time.time + safetyBuffer; ((Behaviour)lit).enabled = isPressed; ToggleDoors(isPressed); if (((Object)((Component)this).gameObject).name.Contains("Button_Apply")) { ((Component)this).transform.localPosition = new Vector3(0.06f, 0f, 0f); if (!isDependant) { Object.Destroy((Object)(object)this); } } else { ((Component)this).GetComponent<Renderer>().material.EnableKeyword("_EMISSION"); ((Component)this).transform.localPosition = new Vector3(0f, -0.05f, 0f); } } private void OnTriggerExit(Collider other) { if (((Component)other).gameObject.layer != LayerMask.NameToLayer("Character")) { return; } objectsOnPlate--; if (objectsOnPlate < 0) { objectsOnPlate = 0; } Debug.LogWarning((object)("Pressure plate released by: " + ((Object)((Component)other).gameObject).name)); if (objectsOnPlate == 0) { ((MonoBehaviour)this).CancelInvoke("TurnVisualsOff"); isPressed = false; ToggleDoors(isPressed); if (Time.time < nextAllowedOffTime) { float num = nextAllowedOffTime - Time.time; ((MonoBehaviour)this).Invoke("TurnVisualsOff", num); } else { TurnVisualsOff(); } } } private void ToggleDoors(bool toOpen = true) { AutomaticDoor[] componentsInChildren = ((Component)((Component)this).transform.parent.parent).GetComponentsInChildren<AutomaticDoor>(); foreach (AutomaticDoor automaticDoor in componentsInChildren) { automaticDoor.ToggleDoor(toOpen); } } private void TurnVisualsOff() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)lit != (Object)null) { ((Behaviour)lit).enabled = false; } if (!((Object)((Component)this).gameObject).name.Contains("Button_Apply")) { ((Component)this).GetComponent<Renderer>().material.DisableKeyword("_EMISSION"); } if (!((Object)((Component)this).gameObject).name.Contains("Button_Apply")) { ((Component)this).transform.localPosition = new Vector3(0f, 0.1f, 0f); } else { ((Component)this).transform.localPosition = new Vector3(0f, 0f, 0f); } } } public class RigidBodyStandable : MonoBehaviour { private float originalMass = 0f; public Vector3 originalPos; public Quaternion originalRot; private float standableMass = 700f; private Rigidbody rb = null; private int playersOnTop = 0; private void Awake() { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) rb = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)rb == (Object)null) { Object.Destroy((Object)(object)this); } originalPos = rb.position; originalMass = rb.mass; originalRot = rb.rotation; } private void OnCollisionEnter(Collision other) { //IL_003f: 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_0048: Unknown result type (might be due to invalid IL or missing references) if (other.gameObject.layer != LayerMask.NameToLayer("Character") || !((Object)(object)other.gameObject.GetComponent<RigidBodyStandable>() == (Object)null)) { return; } ContactPoint[] contacts = other.contacts; for (int i = 0; i < contacts.Length; i++) { ContactPoint val = contacts[i]; if (((ContactPoint)(ref val)).normal.y < -0.6f) { playersOnTop++; rb.mass = standableMass; break; } } } private void OnCollisionExit(Collision other) { if (other.gameObject.layer == LayerMask.NameToLayer("Character") && (Object)(object)other.gameObject.GetComponent<RigidBodyStandable>() == (Object)null) { playersOnTop--; if (playersOnTop < 0) { playersOnTop = 0; } rb.mass = originalMass; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Embedded] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace ScoutFallFlat { public class FallTrigger : MonoBehaviour { public bool isLevelBeat = false; private Transform Checkpoint = null; private float nextAllowedTp = 0f; private float timeSinceCheck = 0f; private void OnTriggerEnter(Collider other) { //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)other).gameObject; ManualLogSource log = Plugin.Log; log.LogInfo((object)("Entered " + ((Object)gameObject).name)); if ((Object)(object)gameObject.GetComponent<RigCreatorCollider>() != (Object)null) { if (Time.time < nextAllowedTp) { return; } nextAllowedTp = Time.time + 1f; if (isLevelBeat) { if (!Plugin.AdvanceLevels.Value || Plugin.isLastLevel()) { if (!Plugin.AdvanceLevels.Value) { log.LogInfo((object)"Level Beat! Resetting level..."); } else { log.LogInfo((object)"Last Level! Resetting level..."); } Plugin.TryLoadLevel(); Object.Destroy((Object)(object)((Component)this).gameObject); } else { log.LogInfo((object)"Level Beat! Trying to load next level..."); Plugin.TryLoadLevel(); Object.Destroy((Object)(object)((Component)this).gameObject); } return; } gameObject = ((Component)gameObject.GetComponentInParent<Character>()).gameObject; if (!gameObject.GetComponent<Character>().IsLocal) { return; } Character component = gameObject.GetComponent<Character>(); Plugin.Log.LogInfo((object)("TP Player " + ((Object)component).name + " to Checkpoint")); component.data.sinceGrounded = 0f; component.data.sinceJump = 0f; Rigidbody[] componentsInChildren = ((Component)component).GetComponentsInChildren<Rigidbody>(); foreach (Rigidbody val in componentsInChildren) { if (!val.isKinematic) { val.linearVelocity = Vector3.zero; val.angularVelocity = Vector3.zero; } } if ((Object)(object)Checkpoint != (Object)null) { component.WarpPlayerRPC(Checkpoint.position, false, default(PhotonMessageInfo)); return; } ((MonoBehaviour)this).StartCoroutine(Plugin.WarpToSpawnWhenReady()); } RigidBodyStandable componentInParent = gameObject.GetComponentInParent<RigidBodyStandable>(); if ((Object)(object)componentInParent != (Object)null) { gameObject = ((Component)componentInParent).gameObject; log.LogInfo((object)(((Object)gameObject).name + " is a RigidBodyStandable attempting to tp...")); Rigidbody component2 = gameObject.GetComponent<Rigidbody>(); if (!component2.isKinematic) { component2.linearVelocity = Vector3.zero; component2.angularVelocity = Vector3.zero; } gameObject.transform.position = componentInParent.originalPos; gameObject.transform.rotation = componentInParent.originalRot; } } private void Update() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) timeSinceCheck += Time.deltaTime; if (timeSinceCheck < 15f) { return; } timeSinceCheck = 0f; Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)((Component)localCharacter).gameObject == (Object)null || !(localCharacter.Center.y < -10f)) { return; } Plugin.Log.LogWarning((object)("FALLBACK! TP Player " + ((Object)localCharacter).name + " to Checkpoint")); localCharacter.data.sinceGrounded = 0f; localCharacter.data.sinceJump = 0f; Rigidbody[] componentsInChildren = ((Component)localCharacter).GetComponentsInChildren<Rigidbody>(); foreach (Rigidbody val in componentsInChildren) { if (!val.isKinematic) { val.linearVelocity = Vector3.zero; val.angularVelocity = Vector3.zero; } } if ((Object)(object)Checkpoint != (Object)null) { localCharacter.WarpPlayerRPC(Checkpoint.position, false, default(PhotonMessageInfo)); } else { ((MonoBehaviour)this).StartCoroutine(Plugin.WarpToSpawnWhenReady()); } } } public static class MapTracker { private const string MapKey = "CurrentMap"; public static string GetMapName() { if (PhotonNetwork.InRoom && ((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"CurrentMap", out object value)) { return (value as string) ?? "Default"; } return "Default"; } public static void SendMapName(string name) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_002c: Expected O, but got Unknown if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient) { Hashtable val = new Hashtable(); ((Dictionary<object, object>)val).Add((object)"CurrentMap", (object)name); Hashtable val2 = val; PhotonNetwork.CurrentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null); } } } public class PassTrigger : MonoBehaviour { private GameObject FallTriggerGameObject = null; private void OnTriggerEnter(Collider other) { RigCreatorCollider component = ((Component)other).gameObject.GetComponent<RigCreatorCollider>(); if ((Object)(object)component != (Object)null) { if ((Object)(object)FallTriggerGameObject == (Object)null) { FallTriggerGameObject = GameObject.Find("FallTrigger"); } if ((Object)(object)FallTriggerGameObject == (Object)null) { Plugin.Log.LogError((object)"FallTrigger not found in PassTrigger!"); return; } FallTriggerGameObject.GetComponent<FallTrigger>().isLevelBeat = true; Plugin.Log.LogInfo((object)"PassTrigger Reached!"); Object.Destroy((Object)(object)this); } } } [BepInPlugin("YonDev.ScoutFallFlat", "ScoutFallFlat", "0.1.0")] public class Plugin : BaseUnityPlugin { private static class SceneWatcher { [HarmonyPatch(typeof(ScoutmasterSpawner), "Awake")] [HarmonyPostfix] private static void Postfix() { if ((Object)(object)Instance == (Object)null) { return; } Plugin.rpcManager = GameObject.Find("GAME"); if ((Object)(object)Plugin.rpcManager == (Object)null) { Log.LogError((object)"GAME object not found in scene. RPCs will not work."); } else { GameObject rpcManager = Plugin.rpcManager; if (rpcManager != null) { rpcManager.AddComponent<RPCs>(); } GameObject rpcManager2 = Plugin.rpcManager; if (rpcManager2 != null) { PhotonView component = rpcManager2.GetComponent<PhotonView>(); if (component != null) { component.RefreshRpcMonoBehaviourCache(); } } } ((MonoBehaviour)Instance).StartCoroutine(SpawnMapWhenReady()); } [HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")] [HarmonyPrefix] private static bool No_Hunger(STATUSTYPE statusType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)statusType == 1) { return false; } return true; } } private static class CustomRope { [HarmonyPatch(typeof(RopeAnchorWithRope), "SpawnRope")] [HarmonyPrefix] private static void Prefix(RopeAnchorWithRope __instance) { if (enableRopePatch.Value) { if (((Object)__instance.ropePrefab).name.Contains("Anti")) { Log.LogInfo((object)"Rope anchor has antigravity, skipping rope change"); return; } __instance.ropePrefab = Resources.Load<GameObject>("RopeDynamicBreakable"); __instance.ropeSegmentLength = ropeLength.Value; Log.LogInfo((object)"Rope prefab changed to breakable version"); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] public static bool max_Prefix(ref int __result) { __result = 9999; return false; } } private static ConfigEntry<string> Level = null; public static ConfigEntry<bool> AdvanceLevels = null; private static ConfigEntry<float> ropeLength = null; private static ConfigEntry<bool> enableRopePatch = null; private static Dictionary<string, Shader> _peakShaders; private const string BundleFileName = "maps.bundle"; private const string path = "Assets/_Maps/Maps/"; private string PrefabName = "Assets/_Maps/Maps/Intro.prefab"; private static GameObject rpcManager; private static readonly Vector3 SpawnPosition = new Vector3(0f, 10f, 0f); private static readonly Quaternion SpawnRotation = Quaternion.identity; private static AssetBundle _loadedBundle = null; private static string[] Levels = new string[5] { "Intro", "Train", "Carry", "Climb", "Break" }; public const string Id = "YonDev.ScoutFallFlat"; internal static ManualLogSource Log { get; private set; } = null; internal static Plugin Instance { get; private set; } = null; private static Dictionary<string, Shader> PeakShaders { get { if (_peakShaders == null) { string[] array = new string[16] { "W/Peak_Standard", "W/Character", "W/Peak_Transparent", "W/Peak_Glass", "W/Peak_Clip", "W/Peak_glass_liquid", "W/Peak_GroundTransition", "W/Peak_Guidebook", "W/Peak_Honey", "W/Peak_Ice", "W/Peak_Rock", "W/Peak_Rope", "W/Peak_Splash", "W/Peak_Waterfall", "W/Vine", "Universal Render Pipeline/Lit" }; _peakShaders = new Dictionary<string, Shader>(); string[] array2 = array; foreach (string text in array2) { Shader val = Shader.Find(text); if ((Object)(object)val != (Object)null) { _peakShaders[text] = val; } } } return _peakShaders; } } public static string Name => "ScoutFallFlat"; public static string Version => "0.1.0"; private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; Level = ((BaseUnityPlugin)this).Config.Bind<string>("Map", "Map Name", "Intro", "Name of the prefab to spawn, without the .prefab extension. Must match an asset in the bundle."); AdvanceLevels = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "Advance Levels", true, (ConfigDescription)null); enableRopePatch = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "CustomRope", false, (ConfigDescription)null); ropeLength = ((BaseUnityPlugin)this).Config.Bind<float>("Map", "Rope Length", 100f, (ConfigDescription)null); PrefabName = "Assets/_Maps/Maps/" + Level.Value + ".prefab"; Level.SettingChanged += delegate { string[] levels = Levels; foreach (string text in levels) { if (text.Equals(Level.Value, StringComparison.OrdinalIgnoreCase)) { Level.Value = text; PrefabName = "Assets/_Maps/Maps/" + Level.Value + ".prefab"; Log.LogInfo((object)("ScoutFallFlat: Map name changed to \"" + Level.Value + "\". Will spawn \"" + PrefabName + "\".")); return; } } Log.LogWarning((object)("ScoutFallFlat: Map name \"" + Level.Value + "\" not found in Levels array. Will spawn \"" + PrefabName + "\".")); }; SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode) { if (((Scene)(ref scene)).name == "Airport") { Log.LogInfo((object)"Airport scene loaded. Reloading PrefabName."); PrefabName = "Assets/_Maps/Maps/" + Level.Value + ".prefab"; } }; Harmony.CreateAndPatchAll(typeof(SceneWatcher), "YonDev.ScoutFallFlat"); Harmony.CreateAndPatchAll(typeof(CustomRope), (string)null); Log.LogInfo((object)("Plugin " + Name + " is loaded! Will spawn \"" + PrefabName + "\" from bundle \"maps.bundle\" on map load.")); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private static IEnumerator SpawnMapWhenReady() { if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient) { MapTracker.SendMapName(Instance.PrefabName); } yield return (object)new WaitForSeconds(2f); if (!PhotonNetwork.IsMasterClient) { Instance.PrefabName = MapTracker.GetMapName(); } float timeout = Time.realtimeSinceStartup + 15f; while (Time.realtimeSinceStartup < timeout && (!((Object)(object)GameObject.Find("Map") != (Object)null) || !((Object)(object)GameObject.Find("GAME") != (Object)null))) { yield return null; } if ((Object)(object)GameObject.Find("Map") == (Object)null || (Object)(object)GameObject.Find("GAME") == (Object)null) { Log.LogWarning((object)"timed out waiting for scene objects (Map / GAME). Prefab not spawned."); yield break; } if ((Object)(object)GameObject.Find(Instance.PrefabName + "(Clone)") != (Object)null || (Object)(object)GameObject.Find(Instance.PrefabName) != (Object)null) { Log.LogInfo((object)"prefab already present in scene, skipping spawn."); yield break; } ClearNormalMap(); yield return null; yield return ((MonoBehaviour)Instance).StartCoroutine(SpawnMapPrefabAsync()); yield return null; yield return ((MonoBehaviour)Instance).StartCoroutine(WarpToSpawnWhenReady()); } private static IEnumerator SpawnMapPrefabAsync() { string dllDirectory = Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location) ?? "."; string bundlePath = Path.Combine(dllDirectory, "maps.bundle"); if (!File.Exists(bundlePath)) { Log.LogError((object)("AssetBundle not found at \"" + bundlePath + "\". Place \"maps.bundle\" next to the plugin DLL.")); yield break; } if ((Object)(object)_loadedBundle == (Object)null) { AssetBundleCreateRequest bundleLoadRequest = AssetBundle.LoadFromFileAsync(bundlePath); yield return bundleLoadRequest; _loadedBundle = bundleLoadRequest.assetBundle; } AssetBundle bundle = _loadedBundle; if ((Object)(object)bundle == (Object)null) { Log.LogError((object)("Failed to load AssetBundle from \"" + bundlePath + "\".")); yield break; } Log.LogInfo((object)("AssetBundle contains assets: " + string.Join(", ", bundle.GetAllAssetNames()))); GameObject prefab = bundle.LoadAsset<GameObject>(Instance.PrefabName); if ((Object)(object)prefab == (Object)null) { Log.LogError((object)("Prefab \"" + Instance.PrefabName + "\" not found inside the bundle. ")); yield break; } SetupMaterial(prefab); if ((Object)(object)prefab.GetComponentInChildren<Collider>() == (Object)null) { ((Collider)prefab.AddComponent<BoxCollider>()).isTrigger = true; } GameObject map = Object.Instantiate<GameObject>(prefab, SpawnPosition, SpawnRotation); ((Object)map).name = Instance.PrefabName; Transform obj = map.transform.Find("Directional Light"); if (obj != null) { ((Component)obj).gameObject.SetActive(false); } AttachScriptsToGameObjets(map); ClearSceneFog(); HideSceneWalls(); Log.LogInfo((object)$"Spawned \"{Instance.PrefabName}\" at {SpawnPosition}."); } public static IEnumerator WarpToSpawnWhenReady() { string[] SpawnMarkersName = new string[2] { "Spawnpoint", "SpawnPoint" }; float timeout = Time.realtimeSinceStartup + 15f; while (Time.realtimeSinceStartup < timeout) { Character local = Character.localCharacter; if ((Object)(object)local == (Object)null) { yield return null; continue; } GameObject rootPrefab = GameObject.Find(Instance.PrefabName); if ((Object)(object)rootPrefab == (Object)null) { yield return null; continue; } GameObject marker = null; Transform[] componentsInChildren = rootPrefab.GetComponentsInChildren<Transform>(); foreach (Transform t in componentsInChildren) { bool isfound = false; string[] array = SpawnMarkersName; foreach (string spawnMarkerName in array) { if (((Object)t).name == spawnMarkerName) { marker = ((Component)t).gameObject; isfound = true; if ((Object)(object)marker != (Object)null) { break; } } } if (isfound) { break; } } if ((Object)(object)marker == (Object)null) { yield return null; continue; } Vector3 spawnPos = marker.transform.position + Vector3.up * 15f; local.data.sinceGrounded = 0f; local.data.sinceJump = -1f; Rigidbody[] componentsInChildren2 = ((Component)local).GetComponentsInChildren<Rigidbody>(); foreach (Rigidbody rb in componentsInChildren2) { if (!rb.isKinematic) { rb.linearVelocity = Vector3.zero; rb.angularVelocity = Vector3.zero; } } local.WarpPlayerRPC(spawnPos, false, default(PhotonMessageInfo)); Log.LogInfo((object)$"Warped local player to \"{((Object)marker).name}\" at {spawnPos}."); yield break; } Log.LogWarning((object)"Timed out waiting for SpawnPoint or local character. Player not warped."); } private static void SetupMaterial(GameObject go) { Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { Material[] materials = val.materials; foreach (Material val2 in materials) { if (PeakShaders.TryGetValue(((Object)val2.shader).name, out var value)) { val2.shader = value; } } } Renderer[] componentsInChildren2 = go.GetComponentsInChildren<Renderer>(); foreach (Renderer val3 in componentsInChildren2) { Material[] materials2 = val3.materials; foreach (Material val4 in materials2) { if (((Object)val4.shader).name == "Universal Render Pipeline/Lit" && !val4.IsKeywordEnabled("_EMISSION") && !IsTransparent(val4) && !HasAlphaClipping(val4)) { Texture texture = val4.GetTexture("_BaseMap"); if ((Object)(object)texture != (Object)null) { val4.shader = Shader.Find("W/Peak_Standard"); val4.SetTexture("_BaseTexture", texture); } } } } } private static bool IsTransparent(Material mat) { if (mat.HasProperty("_Surface")) { return mat.GetFloat("_Surface") > 0.5f; } return mat.renderQueue >= 3000; } private static bool HasAlphaClipping(Material mat) { return mat.IsKeywordEnabled("_ALPHATEST_ON"); } private static void ClearSceneFog() { RenderSettings.fog = false; Shader.SetGlobalFloat("FogHeight", -9999f); Shader.SetGlobalFloat("FogEnabled", 0f); Shader.SetGlobalFloat("_FogSphereSize", 99999f); Shader.SetGlobalFloat("EXTRAFOG", 0f); Shader.SetGlobalFloat("HeightFogAmount", 0f); Shader.SetGlobalFloat("_WeatherBlend", 0f); Shader.SetGlobalFloat("_GlobalHazeAmount", 0f); GameObject val = GameObject.Find("Fog"); if ((Object)(object)val != (Object)null && val != null) { val.SetActive(false); } GameObject val2 = GameObject.Find("FogSphereSystem"); if ((Object)(object)val2 != (Object)null && val2 != null) { val2.SetActive(false); } GameObject val3 = GameObject.Find("FogCutouts"); if ((Object)(object)val3 != (Object)null && val3 != null) { val3.SetActive(false); } GameObject val4 = GameObject.Find("Post Fog"); if ((Object)(object)val4 != (Object)null && val4 != null) { val4.SetActive(false); } } private static void HideSceneWalls() { string[] array = new string[2] { "EdgeWalls", "Global" }; string[] array2 = array; foreach (string text in array2) { GameObject val = GameObject.Find(text); if ((Object)(object)val != (Object)null && val != null) { val.SetActive(false); } } } private static void DebugLogRendererState(GameObject root) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) Log.LogInfo((object)"=== CustomMap Renderer Debug Dump ==="); Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { string hierarchyPath = GetHierarchyPath(((Component)val).transform); bool flag = val is MeshRenderer; MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null); Mesh val3 = (((Object)(object)component != (Object)null) ? component.sharedMesh : (((Object)(object)val2 != (Object)null) ? val2.sharedMesh : null)); string text = (((Object)(object)val3 == (Object)null) ? "MESH=NULL" : $"MESH='{((Object)val3).name}' verts={val3.vertexCount} subMeshes={val3.subMeshCount} bounds={val3.bounds}"); string text2 = string.Join(" | ", Array.ConvertAll(val.sharedMaterials, delegate(Material m) { object result; if (!((Object)(object)m == (Object)null)) { string name = ((Object)m).name; Shader shader = m.shader; result = string.Format("{0}[shader={1}, renderQueue={2}]", name, ((shader != null) ? ((Object)shader).name : null) ?? "NULL", m.renderQueue); } else { result = "MAT=NULL"; } return (string)result; })); bool flag2 = GameObjectUtility_IsBatchingStatic(((Component)val).gameObject); Log.LogInfo((object)("[" + hierarchyPath + "] " + $"enabled={val.enabled} activeInHierarchy={((Component)val).gameObject.activeInHierarchy} " + $"isVisible={val.isVisible} layer={LayerMask.LayerToName(((Component)val).gameObject.layer)} " + $"boundsWorld={val.bounds} " + text + " | " + text2)); } Log.LogInfo((object)"=== End Renderer Debug Dump ==="); } private static bool GameObjectUtility_IsBatchingStatic(GameObject go) { return go.isStatic; } private static string GetHierarchyPath(Transform t) { string text = ((Object)t).name; while ((Object)(object)t.parent != (Object)null) { t = t.parent; text = ((Object)t).name + "/" + text; } return text; } private static void AttachScriptsToGameObjets(GameObject map) { Transform[] componentsInChildren = map.GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { string name = ((Object)val).name; if (name.Contains("PlateButton") || ((Object)val).name.Contains("Button_Apply")) { ((Component)val).gameObject.AddComponent<PressurePlate>(); } if (name.Contains("AutomaticDoor")) { if ((Object)(object)val.Find("Left") == (Object)null || (Object)(object)val.Find("Right") == (Object)null) { Log.LogWarning((object)("AutomaticDoor '" + ((Object)val).name + "' is missing 'Left' or 'Right' child. Skipping script attachment.")); continue; } ((Component)val).gameObject.AddComponent<AutomaticDoor>(); } if (name.Contains("Elevator_Apply")) { ((Component)val).gameObject.AddComponent<ElevatorLinear>(); } if (name.Contains("ElevatorButton")) { ((Component)val).gameObject.AddComponent<ElevatorButton>(); } if ((Object)(object)((Component)val).GetComponent<Rigidbody>() != (Object)null) { GameObject gameObject = ((Component)val).gameObject; if (gameObject.GetComponent<Rigidbody>().mass < 700f) { gameObject.AddComponent<RigidBodyStandable>(); } } if (name.Contains("Crate")) { GameObject gameObject2 = ((Component)val).gameObject; gameObject2.AddComponent<PhotonView>(); gameObject2.AddComponent<PhotonRigidbodyView>(); ((Component)val).gameObject.layer = LayerMask.NameToLayer("Character"); } if (name.Contains("Shatter")) { ((Component)((Component)val).transform.parent).gameObject.AddComponent<VoronoiShatter>(); } if (name.Contains("FallTrigger")) { ((Component)val).gameObject.AddComponent<FallTrigger>(); } if (name.Contains("PassTrigger")) { ((Component)val).gameObject.AddComponent<PassTrigger>(); } } map.AddComponent<PVSyncer>(); } private static void ClearNormalMap() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown GameObject val = GameObject.Find("Map"); if ((Object)(object)val != (Object)null) { PhotonView[] componentsInChildren = val.GetComponentsInChildren<PhotonView>(true); PhotonView[] array = componentsInChildren; foreach (PhotonView val2 in array) { if ((Object)(object)val2 != (Object)null) { PhotonNetwork.LocalCleanPhotonView(val2); } } foreach (Transform item in val.transform) { Transform val3 = item; Object.Destroy((Object)(object)((Component)val3).gameObject); } } Transform[] array2 = Object.FindObjectsByType<Transform>((FindObjectsSortMode)0); foreach (Transform val4 in array2) { GameObject gameObject = ((Component)val4).gameObject; PhotonView component = gameObject.GetComponent<PhotonView>(); if (gameObject.layer == LayerMask.NameToLayer("Water")) { if ((Object)(object)component != (Object)null) { PhotonNetwork.LocalCleanPhotonView(component); } Object.Destroy((Object)(object)gameObject); } if ((Object)(object)gameObject.GetComponent<ItemParticles>() != (Object)null) { if ((Object)(object)component != (Object)null) { PhotonNetwork.LocalCleanPhotonView(component); } Object.Destroy((Object)(object)gameObject); } } } public static void TryLoadLevel(bool resetCurrentLevel = false) { if (!PhotonNetwork.InRoom) { return; } if (PhotonNetwork.IsMasterClient) { GameObject obj = rpcManager; if (obj != null) { obj.GetComponent<RPCs>()?.MapFinished(); } return; } Log.LogInfo((object)"Not master client, sending RPC to master to load next level."); GameObject obj2 = rpcManager; if (obj2 != null) { obj2.GetComponent<RPCs>()?.NotifyMasterFinishedLevel(); } } public static void LoadNextLevel(bool ResetCurrentLevel = false) { int num = 0; string[] levels = Levels; foreach (string text in levels) { string value = Instance.PrefabName.Replace("Assets/_Maps/Maps/", "").Replace(".prefab", ""); if (text.Equals(value)) { if (!ResetCurrentLevel) { num++; } LoadLevelRemoveLastLevel(num); break; } num++; } } private static void LoadLevelRemoveLastLevel(int numberInArray) { if (numberInArray >= Levels.Length) { Log.LogInfo((object)"Last Level!"); return; } string text = Levels[numberInArray]; Log.LogInfo((object)("Loading Level: " + text)); GameObject val = GameObject.Find(Instance.PrefabName); if ((Object)(object)val != (Object)null) { PhotonView[] componentsInChildren = val.GetComponentsInChildren<PhotonView>(true); PhotonView[] array = componentsInChildren; foreach (PhotonView val2 in array) { if ((Object)(object)val2 != (Object)null) { PhotonNetwork.LocalCleanPhotonView(val2); } } Object.Destroy((Object)(object)val); } Instance.PrefabName = "Assets/_Maps/Maps/" + text + ".prefab"; ((MonoBehaviour)Instance).StartCoroutine(SpawnMapWhenReady()); } public static bool isLastLevel() { int num = 0; string[] levels = Levels; foreach (string text in levels) { string value = Instance.PrefabName.Replace("Assets/_Maps/Maps/", "").Replace(".prefab", ""); if (text.Equals(value)) { num++; break; } num++; } if (num >= Levels.Length) { Log.LogInfo((object)"Last Level!"); return true; } return false; } } public class PVSyncer : MonoBehaviourPunCallbacks { private const int ROOT_VIEW_ID = 999; private List<GameObject> modObjects = new List<GameObject>(); private Dictionary<int, int> allocatedViewIDs = new Dictionary<int, int>(); private void Awake() { Debug.Log((object)$"[PVSyncer] Awake — IsMasterClient: {PhotonNetwork.IsMasterClient}, IsConnected: {PhotonNetwork.IsConnected}, InRoom: {PhotonNetwork.InRoom}"); PhotonView val = ((Component)this).gameObject.GetComponent<PhotonView>() ?? ((Component)this).gameObject.AddComponent<PhotonView>(); Debug.Log((object)("[PVSyncer] Root PhotonView " + (((Object)(object)val == (Object)null) ? "FAILED TO CREATE" : "created/found"))); bool flag = val.ViewID == 999; val.ViewID = 999; Debug.Log((object)$"[PVSyncer] Root ViewID set to {999} — was already set: {flag}, actual ViewID after: {val.ViewID}"); CollectObjects(); if (PhotonNetwork.IsMasterClient) { Debug.Log((object)"[PVSyncer] We are master — allocating ViewIDs."); AllocateAllViewIDs(); return; } Debug.Log((object)$"[PVSyncer] We are client — sending RPC_RequestViewIDs to master. Our ActorNumber: {PhotonNetwork.LocalPlayer.ActorNumber}"); if ((Object)(object)((MonoBehaviourPun)this).photonView == (Object)null) { Debug.LogError((object)"[PVSyncer] photonView is NULL — RPC cannot be sent! Make sure ViewID 999 was set correctly."); return; } ((MonoBehaviourPun)this).photonView.RPC("RPC_RequestViewIDs", (RpcTarget)2, new object[1] { PhotonNetwork.LocalPlayer.ActorNumber }); Debug.Log((object)"[PVSyncer] RPC_RequestViewIDs sent."); } private void CollectObjects() { modObjects.Clear(); Rigidbody[] componentsInChildren = ((Component)this).GetComponentsInChildren<Rigidbody>(true); Rigidbody[] array = componentsInChildren; foreach (Rigidbody val in array) { modObjects.Add(((Component)val).gameObject); } Tilemap[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Tilemap>(true); Tilemap[] array2 = componentsInChildren2; foreach (Tilemap val2 in array2) { if (!modObjects.Contains(((Component)val2).gameObject)) { modObjects.Add(((Component)val2).gameObject); } } Debug.Log((object)$"[PVSyncer] CollectObjects — found {modObjects.Count} objects ({componentsInChildren.Length} rigidbodies, {componentsInChildren2.Length} tilemaps)."); for (int k = 0; k < modObjects.Count; k++) { Debug.Log((object)$"[PVSyncer] [{k}] {((Object)modObjects[k]).name}"); } } private void AllocateAllViewIDs() { Debug.Log((object)$"[PVSyncer] AllocateAllViewIDs — allocating for {modObjects.Count} objects."); for (int i = 0; i < modObjects.Count; i++) { if (!allocatedViewIDs.ContainsKey(i)) { int num = PhotonNetwork.AllocateViewID(true); allocatedViewIDs[i] = num; Debug.Log((object)$"[PVSyncer] [{i}] {((Object)modObjects[i]).name} → ViewID {num}"); } } ApplyViewIDs(allocatedViewIDs); } [PunRPC] private void RPC_RequestViewIDs(int requesterActorNumber) { Debug.Log((object)$"[PVSyncer] RPC_RequestViewIDs received from ActorNumber {requesterActorNumber}. IsMaster: {PhotonNetwork.IsMasterClient}, allocated count: {allocatedViewIDs.Count}"); if (!PhotonNetwork.IsMasterClient) { Debug.LogWarning((object)"[PVSyncer] RPC_RequestViewIDs received but we are not master — ignoring."); return; } if (allocatedViewIDs.Count == 0) { Debug.LogError((object)"[PVSyncer] allocatedViewIDs is empty — master may not have finished allocating yet!"); return; } int[] array = new int[allocatedViewIDs.Count]; int[] array2 = new int[allocatedViewIDs.Count]; int num = 0; foreach (KeyValuePair<int, int> allocatedViewID in allocatedViewIDs) { array[num] = allocatedViewID.Key; array2[num] = allocatedViewID.Value; num++; } Player player = PhotonNetwork.CurrentRoom.GetPlayer(requesterActorNumber, false); if (player == null) { Debug.LogError((object)$"[PVSyncer] Could not find player with ActorNumber {requesterActorNumber} in room!"); return; } Debug.Log((object)$"[PVSyncer] Sending RPC_ReceiveViewIDs to ActorNumber {requesterActorNumber} with {array.Length} entries."); ((MonoBehaviourPun)this).photonView.RPC("RPC_ReceiveViewIDs", player, new object[2] { array, array2 }); } [PunRPC] private void RPC_ReceiveViewIDs(int[] indices, int[] viewIDs) { Debug.Log((object)$"[PVSyncer] RPC_ReceiveViewIDs received — {indices.Length} entries."); Dictionary<int, int> dictionary = new Dictionary<int, int>(); for (int i = 0; i < indices.Length; i++) { dictionary[indices[i]] = viewIDs[i]; Debug.Log((object)$"[PVSyncer] [{indices[i]}] → ViewID {viewIDs[i]}"); } ApplyViewIDs(dictionary); } private void ApplyViewIDs(Dictionary<int, int> map) { //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)$"[PVSyncer] ApplyViewIDs — applying {map.Count} ViewIDs."); foreach (KeyValuePair<int, int> item in map) { int key = item.Key; int value = item.Value; if (key >= modObjects.Count) { Debug.LogWarning((object)$"[PVSyncer] ViewID for index {key} but only {modObjects.Count} objects exist — skipping."); continue; } GameObject val = modObjects[key]; bool flag = (Object)(object)val.GetComponent<Rigidbody>() != (Object)null; bool flag2 = (Object)(object)val.GetComponent<Tilemap>() != (Object)null; Debug.Log((object)$"[PVSyncer] [{key}] {((Object)val).name} — Rigidbody: {flag}, Tilemap: {flag2}"); PhotonView val2 = val.GetComponent<PhotonView>() ?? val.AddComponent<PhotonView>(); val2.OwnershipTransfer = (OwnershipOption)0; List<Component> list = new List<Component>(); if (flag) { PhotonTransformView val3 = val.GetComponent<PhotonTransformView>() ?? val.AddComponent<PhotonTransformView>(); val3.m_SynchronizePosition = true; val3.m_SynchronizeRotation = true; val3.m_SynchronizeScale = false; PhotonRigidbodyView val4 = val.GetComponent<PhotonRigidbodyView>() ?? val.AddComponent<PhotonRigidbodyView>(); val4.m_SynchronizeVelocity = true; val4.m_SynchronizeAngularVelocity = true; list.Add((Component)(object)val3); list.Add((Component)(object)val4); } if (flag2) { Object.Destroy((Object)(object)val.GetComponent<Tilemap>()); Debug.Log((object)("[PVSyncer] Tilemap removed from '" + ((Object)val).name + "'")); TilemapRenderer component = val.GetComponent<TilemapRenderer>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); Debug.Log((object)("[PVSyncer] TilemapRenderer removed from '" + ((Object)val).name + "'")); } } val2.ObservedComponents = list; val2.Synchronization = (ViewSynchronization)((list.Count > 0) ? 3 : 0); val2.ViewID = value; Debug.Log((object)$"[PVSyncer] PhotonView on '{((Object)val).name}' — ViewID: {val2.ViewID}, ObservedComponents: {val2.ObservedComponents.Count}, Sync: {val2.Synchronization}"); } } public override void OnMasterClientSwitched(Player newMasterClient) { Debug.Log((object)$"[PVSyncer] OnMasterClientSwitched — new master: {newMasterClient.ActorNumber}, IsLocal: {newMasterClient.IsLocal}"); if (!newMasterClient.IsLocal) { return; } allocatedViewIDs.Clear(); for (int i = 0; i < modObjects.Count; i++) { PhotonView component = modObjects[i].GetComponent<PhotonView>(); if ((Object)(object)component != (Object)null) { allocatedViewIDs[i] = component.ViewID; } else { Debug.LogWarning((object)$"[PVSyncer] OnMasterClientSwitched — no PhotonView on [{i}] {((Object)modObjects[i]).name}"); } } Debug.Log((object)$"[PVSyncer] Rebuilt allocatedViewIDs with {allocatedViewIDs.Count} entries."); } } public class RPCs : MonoBehaviour { private PhotonView photonView; private ManualLogSource Log = Plugin.Log; private float delayGuard = 0f; private void Awake() { photonView = ((Component)this).GetComponent<PhotonView>(); } public void NotifyMasterFinishedLevel() { photonView.RPC("MapFinished", (RpcTarget)2, Array.Empty<object>()); } [PunRPC] public void MapFinished() { if (!(Time.time < delayGuard)) { delayGuard = Time.time + 5f; Log.LogInfo((object)"NotifyMasterFinishedLevel called"); if (Plugin.AdvanceLevels.Value) { Log.LogInfo((object)"Map finished, advancing to next level"); } else { Log.LogInfo((object)"Map finished, resetting current level"); } photonView.RPC("RPC_MapFinished", (RpcTarget)0, new object[1] { !Plugin.AdvanceLevels.Value }); } } [PunRPC] public void RPC_MapFinished(bool ResetCurrentLevel = false) { Log.LogInfo((object)"RPC_MapFinished called"); if (Plugin.AdvanceLevels.Value) { Log.LogInfo((object)"Map finished, advancing to next level"); } else { Log.LogInfo((object)"Map finished, resetting current level"); } Plugin.LoadNextLevel(ResetCurrentLevel); } } [RequireComponent(typeof(BoxCollider))] [RequireComponent(typeof(MeshRenderer))] public class VoronoiShatter : MonoBehaviourPunCallbacks { private struct Pending { public GameObject go; public Vector3 force; public Vector3 pos; } [Header("Shards")] public GameObject shardPrefab; public PhysicsMaterial physicsMaterial; public int shardLayer = 10; public float totalMass = 20f; public float cellInset = 0f; [Header("Impact")] public float impactThreshold = 500f; public float minExplodeImpulse = 0f; public float maxExplodeImpulse = float.PositiveInfinity; public float perShardImpulseFraction = 0.3f; public float maxShardVelocity = float.PositiveInfinity; [Header("Misc")] public bool resetOnReload = true; public Transform parentObject; [Tooltip("Unique root PhotonView ID. Set from your mod loader before Awake.")] public int rootViewID = 0; private BoxCollider col; private MeshRenderer meshRend; private Rigidbody body; private Material mat; private bool shattered; private bool readyForCollision; private readonly List<Pending> pending = new List<Pending>(); private readonly List<GameObject> cells = new List<GameObject>(); private readonly Dictionary<int, int> allocatedIDs = new Dictionary<int, int>(); private void Awake() { col = ((Component)this).GetComponent<BoxCollider>(); meshRend = ((Component)this).GetComponent<MeshRenderer>(); body = ((Component)this).GetComponent<Rigidbody>(); mat = ((Renderer)meshRend).sharedMaterial; PhotonView val = ((Component)this).GetComponent<PhotonView>() ?? ((Component)this).gameObject.AddComponent<PhotonView>(); if (rootViewID > 0) { val.ViewID = rootViewID; } else { Debug.LogError((object)("[VoronoiShatter] rootViewID not set on '" + ((Object)this).name + "'!")); } } public override void OnEnable() { ((MonoBehaviourPunCallbacks)this).OnEnable(); readyForCollision = false; ((MonoBehaviour)this).StartCoroutine(AllowCollision()); } private IEnumerator AllowCollision() { yield return (object)new WaitForFixedUpdate(); yield return (object)new WaitForFixedUpdate(); readyForCollision = true; } public void SetRootViewID(int id) { rootViewID = id; PhotonView val = ((Component)this).GetComponent<PhotonView>() ?? ((Component)this).gameObject.AddComponent<PhotonView>(); val.ViewID = id; } private void OnCollisionEnter(Collision c) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_00a1: 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) if (!readyForCollision || shattered) { return; } Vector3 impulse = c.impulse; if (!(((Vector3)(ref impulse)).magnitude < impactThreshold)) { shattered = true; FixedJoint component = ((Component)this).GetComponent<FixedJoint>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Vector3 point = ((ContactPoint)(ref c.contacts[0])).point; Vector3 impulse2 = c.impulse; int num = Random.Range(0, int.MaxValue); if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { ((MonoBehaviour)this).StartCoroutine(DoShatter(point, impulse2, num)); return; } ((MonoBehaviourPun)this).photonView.RPC("RPC_Shatter", (RpcTarget)0, new object[7] { point.x, point.y, point.z, impulse2.x, impulse2.y, impulse2.z, num }); } } [PunRPC] private void RPC_Shatter(float px, float py, float pz, float ix, float iy, float iz, int seed) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!shattered || cells.Count <= 0) { shattered = true; ((MonoBehaviour)this).StartCoroutine(DoShatter(new Vector3(px, py, pz), new Vector3(ix, iy, iz), seed)); } } private IEnumerator DoShatter(Vector3 contactWorld, Vector3 impulse, int seed) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((Collider)col).enabled = false; ((Renderer)meshRend).enabled = false; if ((Object)(object)body != (Object)null) { body.isKinematic = true; } yield return (object)new WaitForFixedUpdate(); Physics.IgnoreLayerCollision(shardLayer, shardLayer, true); pending.Clear(); BuildShards(contactWorld, impulse, seed); yield return (object)new WaitForFixedUpdate(); foreach (Pending p in pending) { if (Object.op_Implicit((Object)(object)p.go)) { p.go.SetActive(true); } } yield return (object)new WaitForFixedUpdate(); foreach (Pending p2 in pending) { if (Object.op_Implicit((Object)(object)p2.go)) { Rigidbody rb = p2.go.GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)rb) && !rb.isKinematic) { rb.AddForceAtPosition(p2.force, p2.pos, (ForceMode)1); } } } pending.Clear(); yield return (object)new WaitForSeconds(0.25f); Physics.IgnoreLayerCollision(shardLayer, shardLayer, false); if (PhotonNetwork.IsConnected && PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient) { ((MonoBehaviour)this).StartCoroutine(AllocIDs()); } } private void BuildShards(Vector3 contactWorld, Vector3 impulse, int seed) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_062e: Unknown result type (might be due to invalid IL or missing references) //IL_0633: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_0648: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_064c: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0679: Unknown result type (might be due to invalid IL or missing references) //IL_067e: Unknown result type (might be due to invalid IL or missing references) //IL_0683: Unknown result type (might be due to invalid IL or missing references) //IL_0690: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_06b8: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06ce: Unknown result type (might be due to invalid IL or missing references) //IL_06d3: Unknown result type (might be due to invalid IL or missing references) //IL_06e0: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_06f6: Unknown result type (might be due to invalid IL or missing references) //IL_06f8: Unknown result type (might be due to invalid IL or missing references) //IL_06fa: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Unknown result type (might be due to invalid IL or missing references) //IL_0705: Unknown result type (might be due to invalid IL or missing references) //IL_070a: Unknown result type (might be due to invalid IL or missing references) //IL_070f: Unknown result type (might be due to invalid IL or missing references) //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_077a: Unknown result type (might be due to invalid IL or missing references) //IL_077f: Unknown result type (might be due to invalid IL or missing references) //IL_0781: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Unknown result type (might be due to invalid IL or missing references) //IL_078c: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_079e: Unknown result type (might be due to invalid IL or missing references) //IL_07a3: Unknown result type (might be due to invalid IL or missing references) //IL_07ac: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_07cf: Unknown result type (might be due to invalid IL or missing references) //IL_07df: Unknown result type (might be due to invalid IL or missing references) //IL_07e4: Unknown result type (might be due to invalid IL or missing references) //IL_087a: Unknown result type (might be due to invalid IL or missing references) //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_0881: Unknown result type (might be due to invalid IL or missing references) //IL_0886: Unknown result type (might be due to invalid IL or missing references) //IL_088f: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Unknown result type (might be due to invalid IL or missing references) //IL_08a2: Unknown result type (might be due to invalid IL or missing references) //IL_08a7: Unknown result type (might be due to invalid IL or missing references) //IL_08b3: Unknown result type (might be due to invalid IL or missing references) //IL_08b5: Unknown result type (might be due to invalid IL or missing references) //IL_08c5: Unknown result type (might be due to invalid IL or missing references) //IL_08d9: Unknown result type (might be due to invalid IL or missing references) //IL_08e9: Unknown result type (might be due to invalid IL or missing references) //IL_08ee: Unknown result type (might be due to invalid IL or missing references) //IL_099d: Unknown result type (might be due to invalid IL or missing references) //IL_09a2: Unknown result type (might be due to invalid IL or missing references) //IL_09a4: Unknown result type (might be due to invalid IL or missing references) //IL_09a9: Unknown result type (might be due to invalid IL or missing references) //IL_09af: Unknown result type (might be due to invalid IL or missing references) //IL_09b4: Unknown result type (might be due to invalid IL or missing references) //IL_09b6: Unknown result type (might be due to invalid IL or missing references) //IL_09bb: Unknown result type (might be due to invalid IL or missing references) //IL_09bd: Unknown result type (might be due to invalid IL or missing references) //IL_09c4: Unknown result type (might be due to invalid IL or missing references) //IL_09cf: Unknown result type (might be due to invalid IL or missing references) //IL_09d4: Unknown result type (might be due to invalid IL or missing references) //IL_09d6: Unknown result type (might be due to invalid IL or missing references) //IL_09dd: Unknown result type (might be due to invalid IL or missing references) //IL_09e8: Unknown result type (might be due to invalid IL or missing references) //IL_09ed: Unknown result type (might be due to invalid IL or missing references) //IL_09ef: Unknown result type (might be due to invalid IL or missing references) //IL_09f6: Unknown result type (might be due to invalid IL or missing references) //IL_0a02: Unknown result type (might be due to invalid IL or missing references) //IL_0a07: Unknown result type (might be due to invalid IL or missing references) //IL_0a09: Unknown result type (might be due to invalid IL or missing references) //IL_0a10: Unknown result type (might be due to invalid IL or missing references) //IL_0a1c: Unknown result type (might be due to invalid IL or missing references) //IL_0a21: Unknown result type (might be due to invalid IL or missing references) //IL_0a23: Unknown result type (might be due to invalid IL or missing references) //IL_0a25: Unknown result type (might be due to invalid IL or missing references) //IL_0a27: Unknown result type (might be due to invalid IL or missing references) //IL_0a2c: Unknown result type (might be due to invalid IL or missing references) //IL_0a30: Unknown result type (might be due to invalid IL or missing references) //IL_0a35: Unknown result type (might be due to invalid IL or missing references) //IL_0a39: Unknown result type (might be due to invalid IL or missing references) //IL_0a40: Unknown result type (might be due to invalid IL or missing references) //IL_0a4d: Unknown result type (might be due to invalid IL or missing references) //IL_0a54: Unknown result type (might be due to invalid IL or missing references) //IL_0a62: Unknown result type (might be due to invalid IL or missing references) //IL_0a67: Unknown result type (might be due to invalid IL or missing references) //IL_0a6b: Unknown result type (might be due to invalid IL or missing references) //IL_0a70: Unknown result type (might be due to invalid IL or missing references) //IL_0a7f: Unknown result type (might be due to invalid IL or missing references) //IL_0a81: Unknown result type (might be due to invalid IL or missing references) //IL_0a8a: Unknown result type (might be due to invalid IL or missing references) //IL_0a8c: Unknown result type (might be due to invalid IL or missing references) //IL_0a97: Unknown result type (might be due to invalid IL or missing references) //IL_0a99: Unknown result type (might be due to invalid IL or missing references) //IL_0aa4: Unknown result type (might be due to invalid IL or missing references) //IL_0aa6: Unknown result type (might be due to invalid IL or missing references) //IL_0ab1: Unknown result type (might be due to invalid IL or missing references) //IL_0ab3: Unknown result type (might be due to invalid IL or missing references) //IL_0abe: Unknown result type (might be due to invalid IL or missing references) //IL_0ac0: Unknown result type (might be due to invalid IL or missing references) //IL_0acb: Unknown result type (might be due to invalid IL or missing references) //IL_0acd: Unknown result type (might be due to invalid IL or missing references) //IL_0ad8: Unknown result type (might be due to invalid IL or missing references) //IL_0ada: Unknown result type (might be due to invalid IL or missing references) //IL_0adf: Unknown result type (might be due to invalid IL or missing references) //IL_0ae1: Unknown result type (might be due to invalid IL or missing references) //IL_0ae3: Unknown result type (might be due to invalid IL or missing references) //IL_0ae8: Unknown result type (might be due to invalid IL or missing references) //IL_0b01: Unknown result type (might be due to invalid IL or missing references) //IL_0b06: Unknown result type (might be due to invalid IL or missing references) //IL_0b18: Unknown result type (might be due to invalid IL or missing references) //IL_0b1d: Unknown result type (might be due to invalid IL or missing references) //IL_0b2f: Unknown result type (might be due to invalid IL or missing references) //IL_0b34: Unknown result type (might be due to invalid IL or missing references) //IL_0b49: Unknown result type (might be due to invalid IL or missing references) //IL_0b4e: Unknown result type (might be due to invalid IL or missing references) //IL_0c02: Unknown result type (might be due to invalid IL or missing references) //IL_0c07: Unknown result type (might be due to invalid IL or missing references) //IL_0c21: Expected O, but got Unknown //IL_0c92: Unknown result type (might be due to invalid IL or missing references) //IL_0c97: Unknown result type (might be due to invalid IL or missing references) //IL_0ca6: Expected O, but got Unknown //IL_0d88: Unknown result type (might be due to invalid IL or missing references) //IL_0d8f: Unknown result type (might be due to invalid IL or missing references) //IL_0d9d: Unknown result type (might be due to invalid IL or missing references) //IL_0da8: Unknown result type (might be due to invalid IL or missing references) //IL_0dad: Unknown result type (might be due to invalid IL or missing references) //IL_0db2: Unknown result type (might be due to invalid IL or missing references) //IL_0dba: Unknown result type (might be due to invalid IL or missing references) //IL_0dbc: Unknown result type (might be due to invalid IL or missing references) //IL_0dc1: Unknown result type (might be due to invalid IL or missing references) //IL_0dca: Unknown result type (might be due to invalid IL or missing references) //IL_0dd2: Unknown result type (might be due to invalid IL or missing references) //IL_0eb3: Unknown result type (might be due to invalid IL or missing references) //IL_0ebe: Unknown result type (might be due to invalid IL or missing references) //IL_0ec3: Unknown result type (might be due to invalid IL or missing references) //IL_0ec8: Unknown result type (might be due to invalid IL or missing references) //IL_0ed0: Unknown result type (might be due to invalid IL or missing references) //IL_0ed2: Unknown result type (might be due to invalid IL or missing references) //IL_0ed7: Unknown result type (might be due to invalid IL or missing references) //IL_0ed9: Unknown result type (might be due to invalid IL or missing references) //IL_0eda: Unknown result type (might be due to invalid IL or missing references) //IL_0ee1: Unknown result type (might be due to invalid IL or missing references) //IL_0ee6: Unknown result type (might be due to invalid IL or missing references) //IL_0f01: Unknown result type (might be due to invalid IL or missing references) //IL_0f03: Unknown result type (might be due to invalid IL or missing references) //IL_0f0a: Unknown result type (might be due to invalid IL or missing references) //IL_0f0f: Unknown result type (might be due to invalid IL or missing references) //IL_0f16: Unknown result type (might be due to invalid IL or missing references) //IL_0f18: Unknown result type (might be due to invalid IL or missing references) Vector3 size = col.size; Vector3 lossyScale = ((Component)this).transform.lossyScale; float num = size.x * lossyScale.x; float num2 = size.y * lossyScale.y; float num3 = size.z * lossyScale.z; int thinAxis; float num4; float num5; float num6; if (num <= num2 && num <= num3) { thinAxis = 0; num4 = size.x * 0.5f; num5 = size.y * 0.5f; num6 = size.z * 0.5f; } else if (num2 <= num && num2 <= num3) { thinAxis = 1; num4 = size.y * 0.5f; num5 = size.x * 0.5f; num6 = size.z * 0.5f; } else { thinAxis = 2; num4 = size.z * 0.5f; num5 = size.x * 0.5f; num6 = size.y * 0.5f; } float num7 = num5 * 2f; float num8 = num6 * 2f; float num9 = num7 * num8; float num10 = totalMass / Mathf.Max(num9, 0.0001f); Vector3 local = ((Component)this).transform.InverseTransformPoint(contactWorld) - col.center; LocalToAB(local, thinAxis, out var a, out var b); a = Mathf.Clamp(a, 0f - num5, num5); b = Mathf.Clamp(b, 0f - num6, num6); State state = Random.state; Random.InitState(seed); int num11 = Mathf.Clamp((int)(num9 * 18f), 8, 55); float[] array = new float[num11]; float[] array2 = new float[num11]; int num12 = num11 / 3; for (int i = 0; i < num12; i++) { array[i] = Random.Range(0f - num5, num5); array2[i] = Random.Range(0f - num6, num6); } float num13 = Mathf.Min(num5, num6) * 0.9f; Vector2 val; for (int j = num12; j < num11; j++) { bool flag = false; for (int k = 0; k < 60; k++) { float num14 = Random.Range(0f, num13) * Random.Range(0f, 1f); val = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref val)).normalized; float num15 = a + normalized.x * num14; float num16 = b + normalized.y * num14; if (num15 >= 0f - num5 && num15 <= num5 && num16 >= 0f - num6 && num16 <= num6) { array[j] = num15; array2[j] = num16; flag = true; break; } } if (!flag) { array[j] = Random.Range(0f - num5, num5); array2[j] = Random.Range(0f - num6, num6); } } for (int l = 0; l < num11; l++) { for (int m = l + 1; m < num11; m++) { float num17 = array[l] - array[m]; float num18 = array2[l] - array2[m]; if (num17 * num17 + num18 * num18 < 0.0001f) { array[m] = Mathf.Clamp(array[m] + Random.Range(-0.05f, 0.05f), 0f - num5, num5); array2[m] = Mathf.Clamp(array2[m] + Random.Range(-0.05f, 0.05f), 0f - num6, num6); } } } Random.state = state; List<Vector2>[] array3 = new List<Vector2>[num11]; for (int n = 0; n < num11; n++) { array3[n] = BuildCellPolygon(n, array, array2, num11, 0f - num5, num5, 0f - num6, num6); } Vector3 normalized2 = ((Vector3)(ref impulse)).normalized; float num19 = Mathf.Clamp(((Vector3)(ref impulse)).magnitude, minExplodeImpulse, maxExplodeImpulse) * perShardImpulseFraction; Transform val2 = (((Object)(object)parentObject != (Object)null) ? parentObject : (((Object)(object)((Component)this).transform.parent != (Object)null) ? ((Component)this).transform.parent : ((Component)this).transform)); Vector3 val3 = ABTToLocal(0f, 0f, 1f, thinAxis); Vector3 normalized3 = ((Vector3)(ref val3)).normalized; val3 = ABTToLocal(0f, 0f, -1f, thinAxis); Vector3 normalized4 = ((Vector3)(ref val3)).normalized; Vector2 val22 = default(Vector2); for (int num20 = 0; num20 < num11; num20++) { List<Vector2> list = array3[num20]; int count = list.Count; if (count < 3) { continue; } float num21 = 0f; for (int num22 = 0; num22 < count; num22++) { Vector2 val4 = list[num22]; Vector2 val5 = list[(num22 + 1) % count]; num21 += val4.x * val5.y - val5.x * val4.y; } if (num21 < 0f) { list.Reverse(); } if (cellInset > 0f) { List<Vector2> list2 = new List<Vector2>(count); for (int num23 = 0; num23 < count; num23++) { Vector2 val6 = list[(num23 - 1 + count) % count]; Vector2 val7 = list[num23]; Vector2 val8 = list[(num23 + 1) % count]; val = val7 - val6; Vector2 normalized5 = ((Vector2)(ref val)).normalized; val = val8 - val7; Vector2 normalized6 = ((Vector2)(ref val)).normalized; val = new Vector2(0f - normalized5.y, normalized5.x) + new Vector2(0f - normalized6.y, normalized6.x); Vector2 normalized7 = ((Vector2)(ref val)).normalized; list2.Add(val7 + normalized7 * cellInset); } list = list2; count = list.Count; } Vector2 val9 = Vector2.zero; foreach (Vector2 item in list) { val9 += item; } val9 /= (float)list.Count; Vector3 val10 = ABTToLocal(list[0].x, list[0].y, 0f, thinAxis); Vector3 val11 = ABTToLocal(list[1].x, list[1].y, 0f, thinAxis); Vector3 val12 = ABTToLocal(list[2].x, list[2].y, 0f, thinAxis); Vector3 val13 = Vector3.Cross(val11 - val10, val12 - val10); bool flag2 = Vector3.Dot(val13, normalized3) < 0f; int num24 = count * 2 + count * 4; Vector3[] array4 = (Vector3[])(object)new Vector3[num24]; Vector3[] array5 = (Vector3[])(object)new Vector3[num24]; Vector2[] array6 = (Vector2[])(object)new Vector2[num24]; List<int> list3 = new List<int>(); float num25 = 1f / (num5 * 2f); float num26 = 1f / (num6 * 2f); for (int num27 = 0; num27 < count; num27++) { Vector2 val14 = list[num27] - val9; array4[num27] = ABTToLocal(val14.x, val14.y, num4, thinAxis); array5[num27] = normalized3; array6[num27] = new Vector2((list[num27].x + num5) * num25, (list[num27].y + num6) * num26); } for (int num28 = 1; num28 < count - 1; num28++) { if (!flag2) { list3.Add(0); list3.Add(num28); list3.Add(num28 + 1); } else { list3.Add(0); list3.Add(num28 + 1); list3.Add(num28); } } int num29 = count; for (int num30 = 0; num30 < count; num30++) { Vector2 val15 = list[num30] - val9; array4[num29 + num30] = ABTToLocal(val15.x, val15.y, 0f - num4, thinAxis); array5[num29 + num30] = normalized4; array6[num29 + num30] = new Vector2((list[num30].x + num5) * num25, (list[num30].y + num6) * num26); } for (int num31 = 1; num31 < count - 1; num31++) { if (!flag2) { list3.Add(num29); list3.Add(num29 + num31 + 1); list3.Add(num29 + num31); } else { list3.Add(num29); list3.Add(num29 + num31); list3.Add(num29 + num31 + 1); } } int num32 = count * 2; for (int num33 = 0; num33 < count; num33++) { int index = (num33 + 1) % count; Vector2 val16 = list[num33] - val9; Vector2 val17 = list[index] - val9; Vector3 val18 = ABTToLocal(val16.x, val16.y, num4, thinAxis); Vector3 val19 = ABTToLocal(val17.x, val17.y, num4, thinAxis); Vector3 val20 = ABTToLocal(val16.x, val16.y, 0f - num4, thinAxis); Vector3 val21 = ABTToLocal(val17.x, val17.y, 0f - num4, thinAxis); val = val17 - val16; Vector2 normalized8 = ((Vector2)(ref val)).normalized; ((Vector2)(ref val22))..ctor(normalized8.y, 0f - normalized8.x); val3 = ABTToLocal(val22.x, val22.y, 0f, thinAxis); Vector3 normalized9 = ((Vector3)(ref val3)).normalized; int num34 = num32 + num33 * 4; array4[num34] = val18; array5[num34] = normalized9; array4[num34 + 1] = val19; array5[num34 + 1] = normalized9; array4[num34 + 2] = val21; array5[num34 + 2] = normalized9; array4[num34 + 3] = val20; array5[num34 + 3] = normalized9; val = val17 - val16; float magnitude = ((Vector2)(ref val)).magnitude; array6[num34] = new Vector2(0f, 1f); array6[num34 + 1] = new Vector2(magnitude, 1f); array6[num34 + 2] = new Vector2(magnitude, 0f); array6[num34 + 3] = new Vector2(0f, 0f); if (!flag2) { list3.Add(num34); list3.Add(num34 + 3); list3.Add(num34 + 2); list3.Add(num34); list3.Add(num34 + 2); list3.Add(num34 + 1); } else { list3.Add(num34); list3.Add(num34 + 1); list3.Add(num34 + 2); list3.Add(num34); list3.Add(num34 + 2); list3.Add(num34 + 3); } } Mesh val23 = new Mesh { name = "shard" + num20 }; val23.vertices = array4; val23.normals = array5; val23.uv = array6; val23.triangles = list3.ToArray(); val23.RecalculateBounds(); float num35 = Mathf.Abs(num21) * 0.5f; MeshFilter val24 = null; MeshRenderer val25 = null; AudioSource val26 = null; GameObject val27; if ((Object)(object)shardPrefab == (Object)null) { val27 = new GameObject("shard" + num20) { layer = shardLayer }; } else { val27 = Object.Instantiate<GameObject>(shardPrefab); ((Object)val27).name = "shard" + num20; val24 = val27.GetComponent<MeshFilter>(); val25 = val27.GetComponent<MeshRenderer>(); val26 = val27.GetComponent<AudioSource>(); Collider component = val27.GetComponent<Collider>(); if (Object.op_Implicit((Object)(object)component)) { Object.Destroy((Object)(object)component); } } val27.SetActive(false); val27.layer = LayerMask.NameToLayer("Map"); if (!Object.op_Implicit((Object)(object)val24)) { val24 = val27.AddComponent<MeshFilter>(); } val24.mesh = val23; if (!Object.op_Implicit((Object)(object)val25)) { val25 = val27.AddComponent<MeshRenderer>(); } val27.AddComponent<RigidBodyStandable>(); if (Object.op_Implicit((Object)(object)mat)) { ((Renderer)val25).sharedMaterial = mat; } Vector3 val28 = ABTToLocal(val9.x, val9.y, 0f, thinAxis) + col.center; Vector3 val29 = ((Component)this).transform.TransformPoint(val28); val27.transform.SetPositionAndRotation(val29, ((Component)this).transform.rotation); val27.transform.SetParent(val2, true); MeshCollider val30 = val27.AddComponent<MeshCollider>(); ((Collider)val30).sharedMaterial = physicsMaterial; val30.convex = true; Rigidbody val31 = val27.AddComponent<Rigidbody>(); val31.mass = Mathf.Max(0.05f, num35 * num10); if (!Object.op_Implicit((Object)(object)val26)) { val26 = val27.AddComponent<AudioSource>(); } val26.spatialBlend = 1f; val26.playOnAwake = false; val26.pitch = Mathf.Clamp(8f / val31.mass, 0.85f, 1.15f); float num36 = Mathf.Clamp(num19 * 0.005f, 0f, maxShardVelocity * val31.mass); Vector3 val32 = ABTToLocal(array[num20], array2[num20], 0f, thinAxis) + col.center; Vector3 val33 = ((Component)this).transform.TransformPoint(val32); Vector3 pos = Vector3.Lerp(contactWorld, val33, 0.3f); pending.Add(new Pending { go = val27, force = -normalized2 * num36, pos = pos }); cells.Add(val27); } } private static Vector3 ABTToLocal(float a, float b, float t, int thinAxis) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(thinAxis switch { 0 => new Vector3(t, a, b), 1 => new Vector3(a, t, b), _ => new Vector3(a, b, t), }); } private static void LocalToAB(Vector3 local, int thinAxis, out float a, out float b) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) switch (thinAxis) { case 0: a = local.y; b = local.z; break; case 1: a = local.x; b = local.z; break; default: a = local.x; b = local.y; break; } } private static List<Vector2> BuildCellPolygon(int i, float[] sx, float[] sy, int n, float minA, float maxA, float minB, float maxB) { //IL_000b: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) List<Vector2> list = new List<Vector2> { new Vector2(minA, minB), new Vector2(maxA, minB), new Vector2(maxA, maxB), new Vector2(minA, maxB) }; float num = sx[i]; float num2 = sy[i]; for (int j = 0; j < n; j++) { if (j == i) { continue; } float num3 = sx[j]; float num4 = sy[j]; float mx = (num + num3) * 0.5f; float my = (num2 + num4) * 0.5f; float num5 = num3 - num; float num6 = num4 - num2; float num7 = num5 * num5 + num6 * num6; if (!(num7 < 1E-10f)) { list = ClipPolygonHalfPlane(list, mx, my, num5, num6); if (list.Count == 0) { break; } } } return list; } private static List<Vector2> ClipPolygonHalfPlane(List<Vector2> poly, float mx, float my, float dirX, float dirY) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) List<Vector2> list = new List<Vector2>(); int count = poly.Count; if (count == 0) { return list; } for (int i = 0; i < count; i++) { Vector2 val = poly[i]; Vector2 val2 = poly[(i + 1) % count]; float num = (val.x - mx) * dirX + (val.y - my) * dirY; float num2 = (val2.x - mx) * dirX + (val2.y - my) * dirY; bool flag = num <= 0f; bool flag2 = num2 <= 0f; if (flag) { list.Add(val); } if (flag != flag2) { float num3 = num / (num - num2); Vector2 item = val + (val2 - val) * num3; list.Add(item); } } return list; } private IEnumerator AllocIDs() { yield return null; allocatedIDs.Clear(); for (int i = 0; i < cells.Count; i++) { allocatedIDs[i] = PhotonNetwork.AllocateViewID(true); } ApplyIDs(allocatedIDs); int[] idx = new int[allocatedIDs.Count]; int[] ids = new int[allocatedIDs.Count]; int k = 0; foreach (KeyValuePair<int, int> kv in allocatedIDs) { idx[k] = kv.Key; ids[k] = kv.Value; k++; } ((MonoBehaviourPun)this).photonView.RPC("RPC_ReceiveIDs", (RpcTarget)1, new object[2] { idx, ids }); } [PunRPC] private void RPC_ReceiveIDs(int[] idx, int[] ids) { Dictionary<int, int> dictionary = new Dictionary<int, int>(); for (int i = 0; i < idx.Length; i++) { dictionary[idx[i]] = ids[i]; } ApplyIDs(dictionary); } [PunRPC] private void RPC_RequestIDs(int actor) { if (!PhotonNetwork.IsMasterClient || allocatedIDs.Count == 0) { return; } int[] array = new int[allocatedIDs.Count]; int[] array2 = new int[allocatedIDs.Count]; int num = 0; foreach (KeyValuePair<int, int> allocatedID in allocatedIDs) { array[num] = allocatedID.Key; array2[num] = allocatedID.Value; num++; } Player player = PhotonNetwork.CurrentRoom.GetPlayer(actor, false); if (player != null) { ((MonoBehaviourPun)this).photonView.RPC("RPC_ReceiveIDs", player, new object[2] { array, array2 }); } } private void ApplyIDs(Dictionary<int, int> map) { //IL_00a6: Unknown result type (might be due to