using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using BabyBlocks; using BabyBlocks.Networking; using BabyBlocks.UI; using BabyStepsMenuLib; using HarmonyLib; using Il2Cpp; using Il2CppBeautifyEffect; using Il2CppCinemachine; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Attributes; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppNWH.DWP2.WaterObjects; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.SceneManagement; using UnityEngine.UI; using UniverseLib; using UniverseLib.Config; using UniverseLib.UI; using UniverseLib.UI.Models; using UniverseLib.UI.Panels; using UniverseLib.UI.Widgets; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Core), "Baby Blocks", "1.0.1", "Caleb Orchard", null)] [assembly: MelonGame("DefaultCompany", "BabySteps")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("BabyBlocks")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.1")] [assembly: AssemblyInformationalVersion("1.0.0+6bca26d40e0aea8157b6afaae13e39037c1f65c7")] [assembly: AssemblyProduct("BabyBlocks")] [assembly: AssemblyTitle("BabyBlocks")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BabyBlocks { public class Core : MelonMod { public static bool DebugMode = false; private static MelonPreferences_Category _prefs; private static MelonPreferences_Entry _lastSavePath; private static FieldInfo _mpUiManagerField; private static FieldInfo _mpShowChatTabField; private static bool _mpReflectionDone; private const float SomebodyLoadingStuckTimeout = 6f; private static bool _somebodyLoadingWasTrue; private static float _somebodyLoadingSinceTime; private const float MenuTeleportingStuckTimeout = 8f; private static bool _menuTeleportingWasTrue; private static float _menuTeleportingSinceTime; internal static float PendingMicroSplatRefreshTime = -1f; internal const float MicroSplatRefreshSettleDelay = 1.5f; private static bool _wasFarTeleportActive; private const int PostTeleportRescanFrames = 90; private static int _postTeleportRescanFramesRemaining; private static bool _networkingDisabled; public static Instance Logger { get; private set; } public static bool IsMultiplayerChatOpen { get { EnsureMpReflection(); if (_mpUiManagerField == null) { return false; } try { object value = _mpUiManagerField.GetValue(null); return value != null && (bool)_mpShowChatTabField.GetValue(value); } catch { return false; } } } public static bool IsKeyboardCaptured => IsMultiplayerChatOpen || ((Object)(object)Menu.me != (Object)null && Menu.me.paused); public static string LastSavePath { get { return _lastSavePath?.Value ?? ""; } set { if (_lastSavePath != null) { _lastSavePath.Value = value; _prefs.SaveToFile(true); } } } private static void EnsureMpReflection() { if (_mpReflectionDone) { return; } _mpReflectionDone = true; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!(assembly.GetName().Name != "BabyStepsMultiplayerClient")) { FieldInfo fieldInfo = assembly.GetType("BabyStepsMultiplayerClient.Core")?.GetField("uiManager", BindingFlags.Static | BindingFlags.Public); FieldInfo fieldInfo2 = fieldInfo?.FieldType.GetField("showChatTab", BindingFlags.Instance | BindingFlags.Public); if (fieldInfo != null && fieldInfo2 != null) { _mpUiManagerField = fieldInfo; _mpShowChatTabField = fieldInfo2; } break; } } } catch { } } private static void WatchSomebodyLoading() { if ((Object)(object)BestRegionLoader.me == (Object)null || FlyCamController.FarTeleportActive) { return; } if (BestRegionLoader.somebodyLoading) { if (!_somebodyLoadingWasTrue) { _somebodyLoadingWasTrue = true; _somebodyLoadingSinceTime = Time.realtimeSinceStartup; } else if (Time.realtimeSinceStartup - _somebodyLoadingSinceTime > 6f) { MelonLogger.Warning($"[BabyBlocks] BestRegionLoader.somebodyLoading stuck for {6f}s, force-clearing."); BestRegionLoader.somebodyLoading = false; _somebodyLoadingWasTrue = false; } } else { _somebodyLoadingWasTrue = false; } } private static void WatchMenuTeleporting() { if ((Object)(object)Menu.me == (Object)null) { return; } if (FlyCamController.FarTeleportActive || FlyCamController.LevelLoadTeleportActive || FlyCamController.NetworkLevelTransferActive) { _menuTeleportingWasTrue = false; } else if (Menu.me.teleporting) { if (!_menuTeleportingWasTrue) { _menuTeleportingWasTrue = true; _menuTeleportingSinceTime = Time.realtimeSinceStartup; } else if (Time.realtimeSinceStartup - _menuTeleportingSinceTime > 8f) { MelonLogger.Warning($"[BabyBlocks] Menu.me.teleporting stuck true for {8f}s, force-clearing."); Menu.me.teleporting = false; _menuTeleportingWasTrue = false; } } else { _menuTeleportingWasTrue = false; } } public override void OnInitializeMelon() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown Logger = ((MelonBase)this).LoggerInstance; _prefs = MelonPreferences.CreateCategory("BabyBlocks"); _lastSavePath = _prefs.CreateEntry("LastSavePath", "", (string)null, (string)null, false, false, (ValueValidator)null, (string)null); ClassInjector.RegisterTypeInIl2Cpp(); ClassInjector.RegisterTypeInIl2Cpp(); ClassInjector.RegisterTypeInIl2Cpp(); ClassInjector.RegisterTypeInIl2Cpp(); ClassInjector.RegisterTypeInIl2Cpp(); ClassInjector.RegisterTypeInIl2Cpp(); ClassInjector.RegisterTypeInIl2Cpp(); Harmony val = new Harmony("BabyBlocks.Patches"); val.PatchAll(Assembly.GetExecutingAssembly()); val.PatchAll(typeof(MenuInjectionLibrary).Assembly); MenuInjectionLibrary.Logger = Logger; CustomLevelsMenu.Initialize(); PropBrowserUI.Init(); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { MaterialVariantTracker.InvalidateMaterialCache(); PendingMicroSplatRefreshTime = Time.realtimeSinceStartup; } public override void OnUpdate() { CustomLevelsMenu.Update(); WatchSomebodyLoading(); WatchMenuTeleporting(); if (!_networkingDisabled) { try { ModNetworking.Update(); } catch (Exception ex) { _networkingDisabled = true; MelonLogger.Warning("[BabyBlocks] Networking unavailable, disabling: " + ex.Message); } } FlyCamController.OnUpdate(); PropBrowserUI.UpdateVisibility(); PropInstanceServices.RenderTints(); BaseMapController.TickWeatherPreset(); if (!BaseMapController.BaseMapEnabled && !FlyCamController.FarTeleportActive) { if (_wasFarTeleportActive) { _postTeleportRescanFramesRemaining = 90; } _wasFarTeleportActive = false; BestRegionLoader me = BestRegionLoader.me; if ((Object)(object)me != (Object)null) { if (_postTeleportRescanFramesRemaining > 0) { BaseMapController.RescanLoadedChunksForBaseMapOff(); _postTeleportRescanFramesRemaining--; } if (!me.off && !BaseMapController.DeferBrlOff && _postTeleportRescanFramesRemaining == 0) { me.off = true; } Renderer[] brlRendererCache = BaseMapController._brlRendererCache; bool flag = false; Renderer[] array = brlRendererCache; foreach (Renderer val in array) { if ((Object)(object)val == (Object)null) { flag = true; break; } if (val.enabled) { val.enabled = false; } } if (flag) { BaseMapController._brlRendererCache = Il2CppArrayBase.op_Implicit(((Component)me).GetComponentsInChildren(true)); } } BaseMapController.SuppressHiddenWhileBaseMapOff(); } else if (FlyCamController.FarTeleportActive) { _wasFarTeleportActive = true; } } public override void OnLateUpdate() { PropBrowserUI.RestoreCursor(); } public override void OnGUI() { FlyCamController.OnGUI(); HatPreviewRenderer.DrawWindowGUI(); } } [HarmonyPatch(typeof(FlyCam), "Update")] internal class FlyCamUpdatePatch { private static bool Prefix(FlyCam __instance) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (FlyCam.locked) { return false; } bool flag = FlyCamController.CursorMode && (LevelEditor.IsTypingInUI || Core.IsKeyboardCaptured); Vector3 val = Vector3.zero; if (!flag) { if (Input.GetKey((KeyCode)119)) { val += Vector3.forward; } if (Input.GetKey((KeyCode)115)) { val += Vector3.back; } if (Input.GetKey((KeyCode)100)) { val += Vector3.right; } if (Input.GetKey((KeyCode)97)) { val += Vector3.left; } if (Input.GetKey((KeyCode)101)) { val += Vector3.up; } if (Input.GetKey((KeyCode)113)) { val += Vector3.down; } if (Input.GetKey((KeyCode)304)) { val *= 10f; } if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)308)) { val *= 30f; } } if (!FlyCamController.CursorMode || (Input.GetMouseButton(1) && !LevelEditor.isDragging)) { Vector3 eulerAngles = ((Component)__instance).transform.eulerAngles; if (eulerAngles.x > 180f) { eulerAngles.x -= 360f; } eulerAngles.x -= Input.GetAxis("Mouse Y"); eulerAngles.x = Mathf.Clamp(eulerAngles.x, -85f, 85f); eulerAngles.y += Input.GetAxis("Mouse X"); ((Component)__instance).transform.eulerAngles = eulerAngles; } Transform transform = ((Component)__instance).transform; transform.position += ((Component)__instance).transform.rotation * (val * __instance.maxVel) * Time.unscaledDeltaTime; if (!FlyCamController.CursorMode && Input.GetMouseButtonDown(0) && !Menu.me.paused) { FlyCamController.HandleFarTeleport(); } return false; } } [HarmonyPatch(typeof(CinemachineBrain), "LateUpdate")] internal class CinemachineBrainLateUpdatePatch { private static void Postfix(CinemachineBrain __instance) { if (!BaseMapController.BaseMapEnabled) { __instance.ManualUpdate(); } GizmoRenderer.RefreshSSBufferMatrices(); } } [HarmonyPatch(typeof(BBConvoStarter), "OnTriggerEnter")] internal class BBConvoStarterTriggerPatch { private static bool Prefix(BBConvoStarter __instance) { bool suppressCutsceneTriggers = FlyCamController.SuppressCutsceneTriggers; return !suppressCutsceneTriggers; } } [HarmonyPatch(typeof(BBConvoStarter), "PlayCutscene")] internal class BBConvoStarterPlayCutscenePatch { private static bool Prefix(BBConvoStarter __instance) { bool suppressCutsceneTriggers = FlyCamController.SuppressCutsceneTriggers; if (suppressCutsceneTriggers) { FlyCamController.RegisterSuppressedCutscene(__instance); } return !suppressCutsceneTriggers; } } [HarmonyPatch(typeof(TractionByteKeeper), "GetGrassAt")] internal class TractionByteKeeperGetGrassAtPatch { private static bool Prefix(Vector3 pos, ref GrassType __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int grassTypeAtPos = PropInstanceServices.BushAudioTracker.GetGrassTypeAtPos(pos); if (grassTypeAtPos != 0) { __result = (GrassType)grassTypeAtPos; return false; } return true; } } internal static class BBLog { internal static bool Verbose; internal static void Msg(string msg) { if (Verbose) { MelonLogger.Msg(msg); } } } [HarmonyPatch(typeof(PlayerMovement), "PlaceCurrentHatOnHead")] internal class PlaceCurrentHatOnHeadPatch { private static bool Prefix(PlayerMovement __instance) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance.currentHat == (Object)null) { return true; } LevelEditorObject levelEditorObject = ((Component)__instance.currentHat).GetComponent() ?? ((Component)__instance.currentHat).GetComponentInChildren(); if ((Object)(object)levelEditorObject == (Object)null) { return true; } Transform transform = ((Component)__instance.currentHat).transform; transform.parent = (__instance.inCutscene ? __instance.head : __instance.headRB); transform.localPosition = new Vector3(0f, 0.207f, -0.02f) + levelEditorObject.hatOffsetPos; transform.localRotation = Quaternion.Euler(-25f + levelEditorObject.hatOffsetRot.x, levelEditorObject.hatOffsetRot.y, levelEditorObject.hatOffsetRot.z); if (!__instance.inCutscene) { transform.parent = null; } return false; } } [HarmonyPatch(typeof(SunglassesChecker), "Update")] internal class SunglassesCheckerUpdatePatch { private static readonly HashSet _forcedVisible = new HashSet(); private static void Postfix(SunglassesChecker __instance) { bool flyCamActive = FlyCamController.FlyCamActive; int instanceID = ((Object)__instance).GetInstanceID(); if (flyCamActive) { _forcedVisible.Add(instanceID); SetRends(__instance, enabled: true); } else if (_forcedVisible.Remove(instanceID)) { bool enabled = BbSunglassesChecker.IsWearingSunglasses(); SetRends(__instance, enabled); } } private static void SetRends(SunglassesChecker instance, bool enabled) { try { FieldInfo field = ((Object)instance).GetIl2CppType().GetField("rends"); if (field != (FieldInfo)null) { Object value = field.GetValue(((Il2CppObjectBase)instance).Cast()); Il2CppReferenceArray val = ((value != null) ? ((Il2CppObjectBase)value).TryCast>() : null); if (val != null) { foreach (Renderer item in (Il2CppArrayBase)(object)val) { if ((Object)(object)item != (Object)null) { item.enabled = enabled; } } return; } } } catch { } foreach (Renderer componentsInChild in ((Component)instance).GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild != (Object)null) { componentsInChild.enabled = enabled; } } } } public enum PhysicsMode { Static, Rigidbody, Grabable, Hat } public class LevelEditorObject : MonoBehaviour { public string objectType = "Cube"; public string addressableKey = ""; public int chunkIndex = -1; public Vector2Int chunkCoord = new Vector2Int(-1, -1); public Vector3 loopBasePosition; public Quaternion loopBaseRotation = Quaternion.identity; public Vector3 loopBaseScale = Vector3.one; public bool hasLoopBasePosition; public bool hasLoopBaseRotation; public bool hasLoopBaseScale; public PhysicsMode physicsMode = PhysicsMode.Static; public float hatHairAmt = 0f; public int groupId = 0; public int physicsGroupId = 0; public bool isPhysicsManaged; public bool editorFreezeStateValid; public Vector3 editorFreezePosition; public Quaternion editorFreezeRotation; public Vector3 editorFreezeScale; public Vector3 editorFreezeVelocity; public Vector3 editorFreezeAngularVelocity; public bool editorFreezeIsKinematic; public bool editorFreezeUseGravity; public RigidbodyConstraints editorFreezeConstraints; public Vector3 grabOffsetPos = Vector3.zero; public Vector3 grabOffsetRot = Vector3.zero; public Vector3 hatOffsetPos = Vector3.zero; public Vector3 hatOffsetRot = Vector3.zero; public int materialConstructionId = -1; public bool sunglassesNeeded; public bool playerPassthrough; public bool freezeUntilHit; public string surfaceTypeTag = ""; public Vector3 materialTint = new Vector3(255f, 255f, 255f); internal Renderer[] _tintRenderers; internal Material _tintMaterial; public ulong netId = 0uL; public LevelEditorObject(IntPtr ptr) : base(ptr) { }//IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) public void OnCollisionEnter(Collision collision) { if (!freezeUntilHit || !PhysicsObjectManager.HasFreezeUntilHit(this)) { return; } Rigidbody rigidbody = collision.rigidbody; int layer = ((Component)collision.collider).gameObject.layer; bool flag = layer == LayerCache.RagdollLayer; bool flag2 = (Object)(object)rigidbody != (Object)null && !rigidbody.isKinematic && (Object)(object)((Component)rigidbody).GetComponentInParent(true) != (Object)null; if (flag || flag2) { PhysicsObjectManager.OnFreezeUntilHitTriggered(this); PhysicsObjectManager.UnfreezeHitProp(this, collision); if (netId != 0) { ModNetworking.SendPropFreezeReleased(netId); } } } } public class GizmoHandle : MonoBehaviour { public int axisIndex; public GizmoHandle(IntPtr ptr) : base(ptr) { } } internal class OverlayCamPreRenderHook : MonoBehaviour { public OverlayCamPreRenderHook(IntPtr ptr) : base(ptr) { } public void OnPreRender() { GizmoRenderer.RefreshSSBufferMatrices(); } } internal class BbSunglassesChecker : MonoBehaviour { private bool[] _wasEnabled; public BbSunglassesChecker(IntPtr ptr) : base(ptr) { } public static bool IsWearingSunglasses() { if (FlyCamController.FlyCamActive) { return true; } PlayerMovement me = PlayerMovement.me; return (Object)(object)me != (Object)null && (Object)(object)me.currentHat != (Object)null && me.currentHat.isSunglasses && !me.inCutscene; } private void Awake() { Il2CppArrayBase componentsInChildren = ((Component)this).GetComponentsInChildren(true); _wasEnabled = new bool[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { _wasEnabled[i] = (Object)(object)componentsInChildren[i] != (Object)null && componentsInChildren[i].enabled; } } private void Update() { if (_wasEnabled == null) { return; } bool enabled = IsWearingSunglasses(); Il2CppArrayBase componentsInChildren = ((Component)this).GetComponentsInChildren(true); int num = Math.Min(componentsInChildren.Length, _wasEnabled.Length); for (int i = 0; i < num; i++) { if (!((Object)(object)componentsInChildren[i] == (Object)null) && _wasEnabled[i]) { componentsInChildren[i].enabled = enabled; } } } } internal static class BbHatSunglassesFlag { private static readonly HashSet _ids = new HashSet(); internal static void Clear() { _ids.Clear(); } internal static void Set(LevelEditorObject leo, bool on) { if (!((Object)(object)((leo != null) ? ((Component)leo).gameObject : null) == (Object)null)) { int instanceID = ((Object)((Component)leo).gameObject).GetInstanceID(); if (on) { _ids.Add(instanceID); } else { _ids.Remove(instanceID); } } } internal static bool Has(LevelEditorObject leo) { return (Object)(object)((leo != null) ? ((Component)leo).gameObject : null) != (Object)null && _ids.Contains(((Object)((Component)leo).gameObject).GetInstanceID()); } } internal static class FlyCamController { public static bool FlyCamActive; public static bool CursorMode; public static bool LevelLoadTeleportActive; public static bool NetworkLevelTransferActive; private const float CutsceneSuppressGraceTime = 0.3f; private static float _cutsceneSuppressUntil = -1f; private static readonly List _pendingCutscenes = new List(); private static float _noiseAmplitude = -1f; private static bool _editorScanDone; private static EnviroSkyRendering _enviroSkyRendering; private static Beautify _beautify; private static bool _farTeleportActive; private static Transform _teleportLoadAnchor; private static bool _freezeActive; private static PlayerMovement _frozenPlayer; private static CharacterController _frozenController; private static Rigidbody _frozenRigidbody; private static Animator _frozenAnimator; private static bool _movementWasEnabled; private static bool _controllerWasEnabled; private static bool _rigidbodyWasKinematic; private static bool _rigidbodyWasUseGravity; private static RigidbodyConstraints _rigidbodyConstraints; private static Vector3 _rigidbodyVelocity; private static Vector3 _rigidbodyAngularVelocity; private static float _animatorSpeed = 1f; private static GUIStyle _teleportLabelStyle; public static bool SuppressCutsceneTriggers => FlyCamActive || !BaseMapController.BaseMapEnabled || Time.unscaledTime < _cutsceneSuppressUntil; internal static bool FarTeleportActive => _farTeleportActive; private static Transform TeleportLoadAnchor { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)_teleportLoadAnchor == (Object)null) { GameObject val = new GameObject("BB_TeleportLoadAnchor"); Object.DontDestroyOnLoad((Object)(object)val); _teleportLoadAnchor = val.transform; } return _teleportLoadAnchor; } } public static void BeginLevelLoadTeleport() { LevelLoadTeleportActive = true; } public static void EndLevelLoadTeleport() { LevelLoadTeleportActive = false; } public static void BeginNetworkLevelTransfer() { NetworkLevelTransferActive = true; } public static void EndNetworkLevelTransfer() { NetworkLevelTransferActive = false; } public static void RegisterSuppressedCutscene(BBConvoStarter bcs) { if ((Object)(object)bcs == (Object)null) { return; } string saveName = bcs.GetSaveName(); foreach (BBConvoStarter pendingCutscene in _pendingCutscenes) { if ((Object)(object)pendingCutscene != (Object)null && pendingCutscene.GetSaveName() == saveName) { return; } } _pendingCutscenes.Add(bcs); } private static void ReplaySuppressedCutscenes() { if (_pendingCutscenes.Count == 0 || SuppressCutsceneTriggers) { return; } List list = new List(_pendingCutscenes); _pendingCutscenes.Clear(); foreach (BBConvoStarter item in list) { if (!((Object)(object)item == (Object)null)) { item.PlayCutscene(); } } } private static void SetEditorPostProcessing(bool enabled) { if ((Object)(object)_enviroSkyRendering == (Object)null || (Object)(object)_beautify == (Object)null) { GameObject obj = GameObject.Find("BigManagerPrefab"); Transform val = ((obj != null) ? obj.transform.Find("Camera") : null); if ((Object)(object)val == (Object)null) { return; } _enviroSkyRendering = ((Component)val).GetComponent(); _beautify = ((Component)val).GetComponent(); } if ((Object)(object)_enviroSkyRendering != (Object)null) { ((Behaviour)_enviroSkyRendering).enabled = enabled; } if ((Object)(object)_beautify != (Object)null) { ((Behaviour)_beautify).enabled = enabled; } } public static void OnUpdate() { ReplaySuppressedCutscenes(); if (Core.PendingMicroSplatRefreshTime >= 0f && Time.realtimeSinceStartup - Core.PendingMicroSplatRefreshTime >= 1.5f) { Core.PendingMicroSplatRefreshTime = -1f; MaterialCatalog.RefreshMicroSplatLayerMaterials(); MaterialVariantTracker.InvalidateMaterialCache(); MaterialCatalog.EnsureMaterialListLoaded(); MaterialCatalog.ReapplyAllMaterialOverrides(); if (!BaseMapController.BaseMapEnabled) { BaseMapController.SetEditorPropsSnowDisabled(disable: true); } LevelEditorManager.Instance?.PruneDestroyedObjects(); LevelEditor.PruneSelection(); if (GizmoRenderer.IsReady) { GizmoRenderer.RefreshAssets(); } } if (Input.GetKeyDown((KeyCode)114) && (Object)(object)PlayerMovement.me != (Object)null && !Menu.me.teleporting && !_farTeleportActive && !Core.IsKeyboardCaptured && !LevelEditor.IsTypingInUI && !PropPalette.IsDragging && !LevelEditor.IsSurfaceSnapDragging && !PlayerMovement.me.inCutscene) { ToggleFlyEditorMode(); } if (Input.GetKeyDown((KeyCode)96) && (Object)(object)PlayerMovement.me != (Object)null && !Menu.me.teleporting && !_farTeleportActive && !Core.IsKeyboardCaptured && !PlayerMovement.me.inCutscene) { ToggleTeleportMode(); } if (FlyCamActive && !CursorMode && Input.GetKeyDown((KeyCode)103) && !Menu.me.teleporting && !_farTeleportActive && !Core.IsKeyboardCaptured) { HandleFarTeleport(); } if (FlyCamActive && !Menu.me.teleporting) { PlayerMovement me = PlayerMovement.me; if ((Object)(object)me != (Object)null) { BestRegionLoader.me.loadingTransform = ((Component)me.flyCam).transform; } } if (FlyCamActive && CursorMode) { if (Input.GetMouseButtonDown(1)) { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } if (Input.GetMouseButtonUp(1)) { Cursor.lockState = (CursorLockMode)2; Cursor.visible = true; } } if (FlyCamActive && CursorMode && !LevelEditor.IsTypingInUI && !Core.IsKeyboardCaptured && Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)115)) { SaveLoadWindow.TriggerSave(); } if (FlyCamActive && CursorMode && !LevelEditor.IsTypingInUI && !Core.IsKeyboardCaptured && Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)97)) { LevelEditor.SelectAll(); } if (FlyCamActive && CursorMode && !LevelEditor.IsTypingInUI && !Core.IsKeyboardCaptured && Input.GetKeyDown((KeyCode)109)) { MaterialInspectorPanel.Toggle(); } if (FlyCamActive && CursorMode) { LevelEditor.Update(); } } public static void OnGUI() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) if (FlyCamActive && CursorMode && (!PropBrowserUI.Ready || Core.DebugMode)) { LevelEditor.OnGUI(); } bool flag = _farTeleportActive || LevelLoadTeleportActive; bool networkLevelTransferActive = NetworkLevelTransferActive; if (flag || networkLevelTransferActive) { if (_teleportLabelStyle == null) { _teleportLabelStyle = new GUIStyle(GUI.skin.label) { fontSize = 48, fontStyle = (FontStyle)1 }; _teleportLabelStyle.normal.textColor = Color.white; } string text = ((networkLevelTransferActive && !flag) ? "Loading level..." : "Teleporting..."); Rect val = default(Rect); ((Rect)(ref val))..ctor(13f, (float)Screen.height - 12f - 60f + 1f, 400f, 60f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(12f, (float)Screen.height - 12f - 60f, 400f, 60f); Color textColor = _teleportLabelStyle.normal.textColor; _teleportLabelStyle.normal.textColor = Color.black; GUI.Label(val, text, _teleportLabelStyle); _teleportLabelStyle.normal.textColor = textColor; GUI.Label(val2, text, _teleportLabelStyle); } } private static void ToggleTeleportMode() { if (!FlyCamActive) { ToggleFlyMode(); ToggleCursorMode(); } else { ToggleFlyMode(); } } public static void InvokeRKeyAction() { if (!((Object)(object)PlayerMovement.me == (Object)null) && !((Object)(object)Menu.me == (Object)null) && !Menu.me.teleporting && !_farTeleportActive && !PlayerMovement.me.inCutscene) { ToggleFlyEditorMode(); } } private static void ToggleFlyEditorMode() { if (!FlyCamActive) { ToggleFlyMode(); } else { ToggleCursorMode(); } } private static void ToggleFlyMode() { PlayerMovement me = PlayerMovement.me; bool flag = (Object)(object)((Component)me.flyCam).transform.parent != (Object)null; me.ToggleFlyCam(); if (flag) { FlyCamActive = true; CursorMode = false; Cursor.lockState = (CursorLockMode)1; FreezePlayer(me, frozen: true); LevelEditor.EnsureManager(); if (!_editorScanDone) { MaterialCatalog.MarkMaterialSourcesPending(); } MelonCoroutines.Start(ActivateEditorScanCo()); CinemachineBasicMultiChannelPerlin componentInChildren = ((Component)me.flyCam).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { if (_noiseAmplitude < 0f) { _noiseAmplitude = componentInChildren.m_AmplitudeGain; } componentInChildren.m_AmplitudeGain = 0f; } return; } if ((Object)(object)LevelEditorManager.Instance != (Object)null) { PhysicsObjectManager.SetEditorModeActive(active: false); } CursorMode = false; Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; SetEditorPostProcessing(enabled: true); FreezePlayer(me, frozen: false); me.pm.SwitchToActiveMode(); me.pm.SwitchModes(); me.OnStandUp(); LevelEditor.HideGizmo(); LevelEditor.ClearRemoteSelectionBroadcast(); FlyCamActive = false; _cutsceneSuppressUntil = Time.unscaledTime + 0.3f; if (_noiseAmplitude >= 0f) { CinemachineBasicMultiChannelPerlin componentInChildren2 = ((Component)me.flyCam).GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.m_AmplitudeGain = _noiseAmplitude; } } } private static IEnumerator ActivateEditorScanCo() { yield return null; GpuiPropScanner.ScanGpuiProps(); yield return null; if (!_editorScanDone) { MaterialCatalog.InvalidateMaterialSources(); _editorScanDone = true; } } private static void ToggleCursorMode() { CursorMode = !CursorMode; Cursor.lockState = (CursorLockMode)((!CursorMode) ? 1 : 2); Cursor.visible = CursorMode; if ((Object)(object)LevelEditorManager.Instance != (Object)null) { PhysicsObjectManager.SetEditorModeActive(CursorMode && FlyCamActive); } SetEditorPostProcessing(!CursorMode); if (!CursorMode) { LevelEditor.HideGizmo(); LevelEditor.ClearRemoteSelectionBroadcast(); } } private static void FreezePlayer(PlayerMovement player, bool frozen) { //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } if (frozen) { if (!_freezeActive || !((Object)(object)_frozenPlayer == (Object)(object)player)) { _frozenPlayer = player; _freezeActive = true; _movementWasEnabled = ((Behaviour)player).enabled; ((Behaviour)player).enabled = false; _frozenController = ((Component)player).GetComponent(); if ((Object)(object)_frozenController != (Object)null) { _controllerWasEnabled = ((Collider)_frozenController).enabled; ((Collider)_frozenController).enabled = false; } _frozenRigidbody = ((Component)player).GetComponent(); if ((Object)(object)_frozenRigidbody != (Object)null) { _rigidbodyWasKinematic = _frozenRigidbody.isKinematic; _rigidbodyWasUseGravity = _frozenRigidbody.useGravity; _rigidbodyConstraints = _frozenRigidbody.constraints; _rigidbodyVelocity = _frozenRigidbody.velocity; _rigidbodyAngularVelocity = _frozenRigidbody.angularVelocity; _frozenRigidbody.velocity = Vector3.zero; _frozenRigidbody.angularVelocity = Vector3.zero; _frozenRigidbody.isKinematic = true; _frozenRigidbody.useGravity = false; _frozenRigidbody.constraints = (RigidbodyConstraints)126; } _frozenAnimator = player.anim; if ((Object)(object)_frozenAnimator != (Object)null) { _animatorSpeed = _frozenAnimator.speed; _frozenAnimator.speed = 0f; } Physics.SyncTransforms(); } } else if (_freezeActive && !((Object)(object)_frozenPlayer != (Object)(object)player)) { if ((Object)(object)_frozenAnimator != (Object)null) { _frozenAnimator.speed = _animatorSpeed; } if ((Object)(object)_frozenRigidbody != (Object)null) { _frozenRigidbody.constraints = _rigidbodyConstraints; _frozenRigidbody.isKinematic = _rigidbodyWasKinematic; _frozenRigidbody.useGravity = _rigidbodyWasUseGravity; _frozenRigidbody.velocity = _rigidbodyVelocity; _frozenRigidbody.angularVelocity = _rigidbodyAngularVelocity; } if ((Object)(object)_frozenController != (Object)null) { ((Collider)_frozenController).enabled = _controllerWasEnabled; } ((Behaviour)player).enabled = _movementWasEnabled; _freezeActive = false; _frozenPlayer = null; _frozenController = null; _frozenRigidbody = null; _frozenAnimator = null; } } public static void HandleFarTeleport() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (Menu.me.teleporting || _farTeleportActive) { return; } PlayerMovement me = PlayerMovement.me; if (!((Object)(object)me == (Object)null)) { Ray val = Camera.main.ScreenPointToRay(new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f)); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, ref val2, 1000f, LayerMask.op_Implicit(LayerCache.PropTerrainMask))) { _farTeleportActive = true; MelonCoroutines.Start(FlyCamTeleportCo(me, ((RaycastHit)(ref val2)).point)); } } } private static IEnumerator FlyCamTeleportCo(PlayerMovement player, Vector3 target) { //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) BestRegionLoader brl = BestRegionLoader.me; if (!BaseMapController.BaseMapEnabled && (Object)(object)brl != (Object)null && brl.off) { brl.off = false; } FreezePlayer(player, frozen: false); float facingY = ((Component)player.flyCam).transform.eulerAngles.y; ((Component)player.anim).transform.rotation = Quaternion.Euler(0f, facingY, 0f); player.pm.SwitchToActiveMode(); player.pm.SwitchModes(); ((Component)player).gameObject.SetActive(false); GameObject crestWater = null; if (!BaseMapController.BaseMapEnabled) { GameObject bigManager = GameObject.Find("BigManagerPrefab"); object obj; if (bigManager == null) { obj = null; } else { Transform obj2 = bigManager.transform.Find("CrestWaterRenderer"); obj = ((obj2 != null) ? ((Component)obj2).gameObject : null); } crestWater = (GameObject)obj; if ((Object)(object)crestWater != (Object)null && !crestWater.activeSelf) { crestWater.SetActive(true); } else { crestWater = null; } } if ((Object)(object)brl != (Object)null && brl.chunkPositions != null && !brl.off) { Transform anchor = TeleportLoadAnchor; anchor.position = target; brl.loadingTransform = anchor; Il2CppStructArray chunkPositions = brl.chunkPositions; Vector3[] prevPositions = (Vector3[])(object)new Vector3[((Il2CppArrayBase)(object)chunkPositions).Length]; for (int i = 0; i < 64; i++) { for (int j = 0; j < ((Il2CppArrayBase)(object)chunkPositions).Length; j++) { prevPositions[j] = ((Il2CppArrayBase)(object)chunkPositions)[j]; } brl.Update(); bool changed = false; for (int k = 0; k < ((Il2CppArrayBase)(object)chunkPositions).Length; k++) { if (((Il2CppArrayBase)(object)chunkPositions)[k] != prevPositions[k]) { changed = true; break; } } if (!changed) { break; } } } SaveGod.me.stopSaving = true; SaveGod.theSave.continuePt = target; Menu.me.Teleport(target, false); float waitStart = Time.unscaledTime; bool slWasTrue = false; float slStuckSince = 0f; bool targetLoaded = false; while (Menu.me.teleporting) { float elapsed = Time.unscaledTime - waitStart; if (BestRegionLoader.somebodyLoading) { if (!slWasTrue) { slWasTrue = true; slStuckSince = Time.unscaledTime; } else if (Time.unscaledTime - slStuckSince > 5f) { BestRegionLoader.somebodyLoading = false; slWasTrue = false; } } else { slWasTrue = false; } if (!targetLoaded && elapsed >= 1f) { Vector3 origin = new Vector3(target.x, target.y + 100f, target.z); if (Physics.Raycast(origin, Vector3.down, 300f, LayerMask.op_Implicit(LayerCache.PropTerrainMask))) { targetLoaded = true; } } if (targetLoaded || elapsed > 60f) { if (elapsed > 60f && !targetLoaded) { MelonLogger.Warning("[FarTeleport] 60s with no terrain hit — forcing anyway"); } BestRegionLoader.fullyLoaded = true; } yield return null; } if ((Object)(object)crestWater != (Object)null && !BaseMapController.BaseMapEnabled) { crestWater.SetActive(false); } SaveGod.me.stopSaving = false; if ((Object)(object)brl != (Object)null) { brl.loadingTransform = ((Component)player.flyCam).transform; } FreezePlayer(player, frozen: true); if (((Component)player).gameObject.activeInHierarchy && player.torsoRbs != null && ((Il2CppArrayBase)(object)player.torsoRbs).Length > 0) { float playerY = ((Component)((Il2CppArrayBase)(object)player.torsoRbs)[0]).transform.position.y; Vector3 camPos = ((Component)player.flyCam).transform.position; Vector3 camToTarget = target - camPos; float camDist = ((Vector3)(ref camToTarget)).magnitude; RaycastHit verifyHit = default(RaycastHit); if (camDist > 0.1f && Physics.Raycast(camPos, camToTarget / camDist, ref verifyHit, camDist + 100f, LayerMask.op_Implicit(LayerCache.PropTerrainMask))) { float delta = Mathf.Abs(playerY - ((RaycastHit)(ref verifyHit)).point.y); if (delta > 3f) { Vector3 corrected = ((RaycastHit)(ref verifyHit)).point; FreezePlayer(player, frozen: false); ((Component)player).gameObject.SetActive(false); if (!BaseMapController.BaseMapEnabled && (Object)(object)crestWater != (Object)null) { crestWater.SetActive(true); } SaveGod.theSave.continuePt = corrected; Menu.me.Teleport(corrected, false); float corrStart = Time.unscaledTime; while (Menu.me.teleporting) { BestRegionLoader.fullyLoaded = true; if (Time.unscaledTime - corrStart > 10f) { MelonLogger.Warning("[FarTeleport] Correction teleport stuck 10s — forcing"); BestRegionLoader.fullyLoaded = true; } yield return null; } if (!BaseMapController.BaseMapEnabled && (Object)(object)crestWater != (Object)null) { crestWater.SetActive(false); } if ((Object)(object)brl != (Object)null) { brl.loadingTransform = ((Component)player.flyCam).transform; } FreezePlayer(player, frozen: true); } } } MaterialVariantTracker.InvalidateMaterialCache(); MaterialCatalog.EnsureMaterialListLoaded(); MaterialCatalog.ReapplyAllMaterialOverrides(); if (!BaseMapController.BaseMapEnabled) { BaseMapController.SetEditorPropsSnowDisabled(disable: true); } _farTeleportActive = false; } } internal static class GhostCubeConfig { private static Material _frameMaterial; public static void Configure(GameObject go) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go == (Object)null) { return; } foreach (MeshRenderer componentsInChild in go.GetComponentsInChildren(true)) { ((Renderer)componentsInChild).forceRenderingOff = true; ((Renderer)componentsInChild).enabled = false; } BuildFrame(go); BoxCollider val = go.GetComponent(); if ((Object)(object)val == (Object)null) { val = go.AddComponent(); } val.center = Vector3.zero; val.size = Vector3.one; ((Collider)val).isTrigger = true; if ((Object)(object)go.GetComponent() == (Object)null) { go.AddComponent(); } } internal static void BuildFrame(GameObject root) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0218: 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_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Expected O, but got Unknown //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Expected O, but got Unknown //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return; } Material frameMaterial = GetFrameMaterial(); if (!((Object)(object)frameMaterial == (Object)null)) { (Vector3, Vector3)[] array = new(Vector3, Vector3)[12] { (new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f)), (new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, 0.5f)), (new Vector3(0.5f, -0.5f, 0.5f), new Vector3(-0.5f, -0.5f, 0.5f)), (new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(-0.5f, -0.5f, -0.5f)), (new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f)), (new Vector3(0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, 0.5f)), (new Vector3(0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f)), (new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, -0.5f)), (new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, 0.5f, -0.5f)), (new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f)), (new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f)), (new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f)) }; Transform val = root.transform.Find("GhostFrame"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } GameObject val2 = new GameObject("GhostFrame"); val2.transform.SetParent(root.transform, false); val2.layer = root.layer; for (int i = 0; i < array.Length; i++) { GameObject val3 = new GameObject($"Edge_{i}"); val3.transform.SetParent(val2.transform, false); val3.layer = root.layer; LineRenderer val4 = val3.AddComponent(); val4.useWorldSpace = false; val4.positionCount = 2; val4.SetPosition(0, array[i].Item1); val4.SetPosition(1, array[i].Item2); val4.startWidth = 0.01f; val4.endWidth = 0.01f; val4.numCapVertices = 0; val4.numCornerVertices = 0; val4.alignment = (LineAlignment)0; ((Renderer)val4).material = frameMaterial; val4.startColor = new Color(1f, 0.95f, 0.3f, 0.9f); val4.endColor = new Color(1f, 0.95f, 0.3f, 0.9f); } } } private static Material GetFrameMaterial() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if ((Object)(object)_frameMaterial != (Object)null) { return _frameMaterial; } Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard"); _frameMaterial = new Material(val) { name = "BabyBlocks_GhostFrame", renderQueue = 5000 }; return _frameMaterial; } } public class GhostCollisionCutter : MonoBehaviour { private struct CarvedTerrainState { public TerrainData originalData; public Array originalHoles; public int xBase; public int yBase; public int width; public int height; public string carveKey; public bool IsValid => (Object)(object)originalData != (Object)null && originalHoles != null; } private static readonly Dictionary _carvedTerrains = new Dictionary(); private static readonly List _instances = new List(); private BoxCollider _volume; private const float PositionTolerance = 0.01f; private const float AngleTolerance = 0.05f; private bool _hasLastCarvePose; private Vector3 _lastCenter; private Vector3 _lastHalfExtents; private Quaternion _lastRotation; private string _lastCarveKey; private Transform _frameRoot; public GhostCollisionCutter(IntPtr ptr) : base(ptr) { } private void Awake() { _volume = ((Component)this).GetComponent(); if ((Object)(object)_volume != (Object)null) { ((Collider)_volume).isTrigger = true; } _frameRoot = ((Component)this).transform.Find("GhostFrame"); } private void OnEnable() { _instances.Add(this); Refresh(); } private void FixedUpdate() { Refresh(); } private void Update() { UpdateFrameVisibility(); } private void OnDisable() { _instances.Remove(this); ReleaseAll(); } private void OnDestroy() { _instances.Remove(this); ReleaseAll(); } private void UpdateFrameVisibility() { if ((Object)(object)_frameRoot == (Object)null) { _frameRoot = ((Component)this).transform.Find("GhostFrame"); } if (!((Object)(object)_frameRoot == (Object)null)) { bool flag = FlyCamController.FlyCamActive && FlyCamController.CursorMode; if (((Component)_frameRoot).gameObject.activeSelf != flag) { ((Component)_frameRoot).gameObject.SetActive(flag); } } } private void Refresh() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_volume == (Object)null) { _volume = ((Component)this).GetComponent(); } if (!((Object)(object)_volume == (Object)null) && ((Component)this).gameObject.activeInHierarchy) { Vector3 lossyScale = ((Component)this).transform.lossyScale; Vector3 val = ((Component)this).transform.TransformPoint(_volume.center); Vector3 val2 = Vector3.Scale(_volume.size * 0.5f, new Vector3(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z))); Quaternion rotation = ((Component)this).transform.rotation; string debouncedCarveKey = GetDebouncedCarveKey(val, val2, rotation); RefreshTerrains(debouncedCarveKey, val, rotation, val2); } } private void RefreshTerrains(string carveKey, Vector3 cutterCenter, Quaternion cutterRotation, Vector3 cutterHalfExtents) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) Il2CppReferenceArray activeTerrains = Terrain.activeTerrains; if (activeTerrains == null) { return; } HashSet hashSet = new HashSet(); for (int i = 0; i < ((Il2CppArrayBase)(object)activeTerrains).Length; i++) { Terrain val = ((Il2CppArrayBase)(object)activeTerrains)[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.terrainData == (Object)null) && CutterOverlapsTerrainBounds(val, cutterCenter, cutterRotation, cutterHalfExtents)) { hashSet.Add(val); ApplyTerrainCarve(val, carveKey, cutterCenter, cutterRotation, cutterHalfExtents); } } if (_carvedTerrains.Count == 0) { return; } List list = new List(); foreach (KeyValuePair carvedTerrain in _carvedTerrains) { if (!hashSet.Contains(carvedTerrain.Key)) { list.Add(carvedTerrain.Key); } } foreach (Terrain item in list) { RestoreTerrain(item); } } private static bool CutterOverlapsTerrainBounds(Terrain terrain, Vector3 cutterCenter, Quaternion cutterRotation, Vector3 cutterHalfExtents) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)terrain).transform; Vector3 size = terrain.terrainData.size; Vector3[] array = (Vector3[])(object)new Vector3[8]; int num = 0; Vector3 val = default(Vector3); for (int i = -1; i <= 1; i += 2) { for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { ((Vector3)(ref val))..ctor(cutterHalfExtents.x * (float)i, cutterHalfExtents.y * (float)j, cutterHalfExtents.z * (float)k); Vector3 val2 = cutterCenter + cutterRotation * val; array[num++] = transform.InverseTransformPoint(val2); } } } float num2 = array[0].x; float num3 = array[0].x; float num4 = array[0].z; float num5 = array[0].z; for (int l = 1; l < array.Length; l++) { num2 = Mathf.Min(num2, array[l].x); num3 = Mathf.Max(num3, array[l].x); num4 = Mathf.Min(num4, array[l].z); num5 = Mathf.Max(num5, array[l].z); } return num3 >= 0f && num5 >= 0f && num2 <= size.x && num4 <= size.z; } private void ReleaseAll() { _hasLastCarvePose = false; if (_carvedTerrains.Count <= 0) { return; } List list = new List(_carvedTerrains.Keys); foreach (Terrain item in list) { RestoreTerrain(item); } } private void ApplyTerrainCarve(Terrain terrain, string carveKey, Vector3 cutterCenter, Quaternion cutterRotation, Vector3 cutterHalfExtents) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)terrain == (Object)null || (Object)(object)terrain.terrainData == (Object)null) { return; } TerrainData terrainData = terrain.terrainData; int holesResolution = terrainData.holesResolution; if (holesResolution <= 0) { return; } CarvedTerrainState value; bool flag = _carvedTerrains.TryGetValue(terrain, out value); bool flag2 = flag && IsSameNativeObject((Il2CppObjectBase)(object)value.originalData, (Il2CppObjectBase)(object)terrainData); if (!flag || !value.IsValid || !flag2) { value = new CarvedTerrainState { originalData = terrainData, originalHoles = terrainData.GetHoles(0, 0, holesResolution, holesResolution).Cast() }; } if (!string.IsNullOrEmpty(value.carveKey) && string.Equals(value.carveKey, carveKey, StringComparison.Ordinal)) { return; } if (!string.IsNullOrEmpty(value.carveKey)) { RestoreTerrain(terrain, value); } if (!TryBuildTerrainHolePatch(terrain, terrainData, value.originalHoles, cutterCenter, cutterRotation, cutterHalfExtents, out var xBase, out var yBase, out var holes)) { if (flag) { value.carveKey = null; value.xBase = (value.yBase = (value.width = (value.height = 0))); _carvedTerrains[terrain] = value; } } else { terrainData.SetHoles(xBase, yBase, (Il2CppObjectBase)(object)holes); value.xBase = xBase; value.yBase = yBase; value.width = holes.GetLength(1); value.height = holes.GetLength(0); value.carveKey = carveKey; _carvedTerrains[terrain] = value; } } private void RestoreTerrain(Terrain terrain) { if (!((Object)(object)terrain == (Object)null) && _carvedTerrains.TryGetValue(terrain, out var value) && value.IsValid) { RestoreTerrain(terrain, value); _carvedTerrains.Remove(terrain); } } private static void RestoreTerrain(Terrain terrain, CarvedTerrainState state) { if (!((Object)(object)terrain == (Object)null) && state.IsValid) { Array val = ExtractTerrainPatch(state.originalHoles, state.xBase, state.yBase, state.width, state.height); if (val != null) { state.originalData.SetHoles(state.xBase, state.yBase, (Il2CppObjectBase)(object)val); } } } private static bool TryBuildTerrainHolePatch(Terrain terrain, TerrainData data, Array originalHoles, Vector3 cutterCenter, Quaternion cutterRotation, Vector3 cutterHalfExtents, out int xBase, out int yBase, out Array holes) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) xBase = 0; yBase = 0; holes = null; if ((Object)(object)terrain == (Object)null || (Object)(object)data == (Object)null || originalHoles == null) { return false; } int holesResolution = data.holesResolution; if (holesResolution <= 0) { return false; } Transform transform = ((Component)terrain).transform; Vector3 size = data.size; Vector3[] array = (Vector3[])(object)new Vector3[8]; int num = 0; Vector3 val = default(Vector3); for (int i = -1; i <= 1; i += 2) { for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { ((Vector3)(ref val))..ctor(cutterHalfExtents.x * (float)i, cutterHalfExtents.y * (float)j, cutterHalfExtents.z * (float)k); Vector3 val2 = cutterCenter + cutterRotation * val; array[num++] = transform.InverseTransformPoint(val2); } } } float num2 = array[0].x; float num3 = array[0].x; float num4 = array[0].z; float num5 = array[0].z; for (int l = 1; l < array.Length; l++) { num2 = Mathf.Min(num2, array[l].x); num3 = Mathf.Max(num3, array[l].x); num4 = Mathf.Min(num4, array[l].z); num5 = Mathf.Max(num5, array[l].z); } if (num3 < 0f || num5 < 0f || num2 > size.x || num4 > size.z) { return false; } num2 = Mathf.Clamp(num2, 0f, size.x); num3 = Mathf.Clamp(num3, 0f, size.x); num4 = Mathf.Clamp(num4, 0f, size.z); num5 = Mathf.Clamp(num5, 0f, size.z); int num6 = Mathf.Clamp(Mathf.FloorToInt(num2 / size.x * (float)(holesResolution - 1)), 0, holesResolution - 1); int num7 = Mathf.Clamp(Mathf.CeilToInt(num3 / size.x * (float)(holesResolution - 1)), 0, holesResolution - 1); int num8 = Mathf.Clamp(Mathf.FloorToInt(num4 / size.z * (float)(holesResolution - 1)), 0, holesResolution - 1); int num9 = Mathf.Clamp(Mathf.CeilToInt(num5 / size.z * (float)(holesResolution - 1)), 0, holesResolution - 1); int num10 = num7 - num6 + 1; int num11 = num9 - num8 + 1; if (num10 <= 0 || num11 <= 0) { return false; } xBase = num6; yBase = num8; holes = Array.CreateInstance(Il2CppType.Of(), new Il2CppStructArray(new long[2] { num11, num10 })); Quaternion val3 = Quaternion.Inverse(cutterRotation); int num12 = Mathf.Max(holesResolution - 1, 1); bool flag = false; Vector3 val4 = default(Vector3); for (int m = 0; m < num11; m++) { for (int n = 0; n < num10; n++) { int num13 = num6 + n; int num14 = num8 + m; float num15 = (float)num13 / (float)num12; float num16 = (float)num14 / (float)num12; float interpolatedHeight = data.GetInterpolatedHeight(num15, num16); ((Vector3)(ref val4))..ctor(num15 * size.x, interpolatedHeight, num16 * size.z); Vector3 val5 = transform.TransformPoint(val4); Vector3 local = val3 * (val5 - cutterCenter); bool flag2 = PointInsideBox(local, cutterHalfExtents); if (flag2) { flag = true; } holes.SetValue(flag2 ? Object.op_Implicit(false) : originalHoles.GetValue(num14, num13), m, n); } } if (!flag) { holes = null; return false; } return true; } private static Array ExtractTerrainPatch(Array source, int xBase, int yBase, int width, int height) { if (source == null || width <= 0 || height <= 0) { return null; } Array val = Array.CreateInstance(Il2CppType.Of(), new Il2CppStructArray(new long[2] { height, width })); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { val.SetValue(source.GetValue(yBase + i, xBase + j), i, j); } } return val; } private static bool IsSameNativeObject(Il2CppObjectBase a, Il2CppObjectBase b) { if (a == null || b == null) { return false; } return a.Pointer == b.Pointer; } private static string BuildCarveKey(Vector3 center, Vector3 half, Quaternion rot) { //IL_000d: 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_004d: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) return $"{center.x:F3},{center.y:F3},{center.z:F3}|{half.x:F3},{half.y:F3},{half.z:F3}|{rot.x:F3},{rot.y:F3},{rot.z:F3},{rot.w:F3}"; } private string GetDebouncedCarveKey(Vector3 center, Vector3 halfExtents, Quaternion rotation) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) if (_hasLastCarvePose && Vector3.Distance(center, _lastCenter) <= 0.01f && Vector3.Distance(halfExtents, _lastHalfExtents) <= 0.01f && Quaternion.Angle(rotation, _lastRotation) <= 0.05f) { return _lastCarveKey; } string lastCarveKey = BuildCarveKey(center, halfExtents, rotation); _lastCenter = center; _lastHalfExtents = halfExtents; _lastRotation = rotation; _lastCarveKey = lastCarveKey; _hasLastCarvePose = true; return _lastCarveKey; } private static bool PointInsideBox(Vector3 local, Vector3 half) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) return Mathf.Abs(local.x) <= half.x && Mathf.Abs(local.y) <= half.y && Mathf.Abs(local.z) <= half.z; } } internal static class SpawnPointConfig { private static Material _frameMaterial; private static readonly Color MarkerColor = new Color(0.3f, 1f, 0.45f, 0.9f); public static void Configure(GameObject go) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go == (Object)null) { return; } foreach (MeshRenderer componentsInChild in go.GetComponentsInChildren(true)) { ((Renderer)componentsInChild).forceRenderingOff = true; ((Renderer)componentsInChild).enabled = false; } BuildMarker(go); BoxCollider val = go.GetComponent(); if ((Object)(object)val == (Object)null) { val = go.AddComponent(); } val.center = new Vector3(0f, 0.9f, 0f); val.size = new Vector3(0.8f, 1.8f, 0.8f); ((Collider)val).isTrigger = true; if ((Object)(object)go.GetComponent() == (Object)null) { go.AddComponent(); } } internal static void BuildMarker(GameObject root) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return; } Material frameMaterial = GetFrameMaterial(); if (!((Object)(object)frameMaterial == (Object)null)) { Transform val = root.transform.Find("SpawnFrame"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } GameObject val2 = new GameObject("SpawnFrame"); val2.transform.SetParent(root.transform, false); val2.layer = root.layer; Vector3[] array = (Vector3[])(object)new Vector3[24]; for (int i = 0; i < 24; i++) { float num = (float)i / 24f * (float)Math.PI * 2f; array[i] = new Vector3(Mathf.Cos(num) * 0.4f, 0.02f, Mathf.Sin(num) * 0.4f); } AddLineLoop(val2, "Ring", array, frameMaterial, loop: true); AddLine(val2, "Pole", frameMaterial, new Vector3(0f, 0f, 0f), new Vector3(0f, 1.8f, 0f)); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0f, 0.05f, 0.7f); AddLine(val2, "ArrowShaft", frameMaterial, new Vector3(0f, 0.05f, 0f), val3); AddLine(val2, "ArrowHeadL", frameMaterial, val3, val3 + Quaternion.Euler(0f, 150f, 0f) * Vector3.forward * 0.18f); AddLine(val2, "ArrowHeadR", frameMaterial, val3, val3 + Quaternion.Euler(0f, -150f, 0f) * Vector3.forward * 0.18f); } } private static void AddLine(GameObject parent, string name, Material mat, Vector3 a, Vector3 b) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0041: 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_008b: 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) GameObject val = new GameObject(name); val.transform.SetParent(parent.transform, false); val.layer = parent.layer; LineRenderer val2 = val.AddComponent(); val2.useWorldSpace = false; val2.positionCount = 2; val2.SetPosition(0, a); val2.SetPosition(1, b); val2.startWidth = 0.015f; val2.endWidth = 0.015f; val2.numCapVertices = 0; val2.numCornerVertices = 0; val2.alignment = (LineAlignment)0; ((Renderer)val2).material = mat; val2.startColor = MarkerColor; val2.endColor = MarkerColor; } private static void AddLineLoop(GameObject parent, string name, Vector3[] points, Material mat, bool loop) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent.transform, false); val.layer = parent.layer; LineRenderer val2 = val.AddComponent(); val2.useWorldSpace = false; val2.loop = loop; val2.positionCount = points.Length; val2.SetPositions(Il2CppStructArray.op_Implicit(points)); val2.startWidth = 0.015f; val2.endWidth = 0.015f; val2.numCapVertices = 0; val2.numCornerVertices = 0; val2.alignment = (LineAlignment)0; ((Renderer)val2).material = mat; val2.startColor = MarkerColor; val2.endColor = MarkerColor; } private static Material GetFrameMaterial() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if ((Object)(object)_frameMaterial != (Object)null) { return _frameMaterial; } Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard"); _frameMaterial = new Material(val) { name = "BabyBlocks_SpawnFrame", renderQueue = 5000 }; return _frameMaterial; } } public class SpawnPointMarker : MonoBehaviour { private Transform _frameRoot; public SpawnPointMarker(IntPtr ptr) : base(ptr) { } private void Awake() { _frameRoot = ((Component)this).transform.Find("SpawnFrame"); } private void Update() { if ((Object)(object)_frameRoot == (Object)null) { _frameRoot = ((Component)this).transform.Find("SpawnFrame"); } if (!((Object)(object)_frameRoot == (Object)null)) { bool flag = FlyCamController.FlyCamActive && FlyCamController.CursorMode; if (((Component)_frameRoot).gameObject.activeSelf != flag) { ((Component)_frameRoot).gameObject.SetActive(flag); } } } } internal static class GizmoRenderer { private struct MeshData { public Vector3[] verts; public int[] tris; public Vector3[] smoothNormals; } private struct OutlineShellData { public int meshId; public Vector3 position; public Quaternion rotation; public Vector3 scale; public float thickness; public Vector3[] worldVerts; public int[] tris; public Mesh mesh; } public const int Layer = 31; public static readonly int Mask = int.MinValue; public const int FreeRotateAxis = 7; public const float FreeRotSphereDrawScale = 0.85f; private const float RingOuterRadius = 0.65f; private const float RingInnerRadius = 0.5f; private const float RingPickPadding = 0.05f; public static readonly Quaternion[] PivotRots = (Quaternion[])(object)new Quaternion[3] { Quaternion.Euler(0f, 0f, -90f), Quaternion.identity, Quaternion.Euler(-90f, 0f, 0f) }; private static readonly Quaternion[] RingPivotRots = (Quaternion[])(object)new Quaternion[3] { Quaternion.Euler(0f, 0f, -90f), Quaternion.identity, Quaternion.Euler(90f, 0f, 0f) }; private static readonly Vector3 ShaftPos = new Vector3(0f, 0.25f, 0f); private static readonly Vector3 ShaftScale = new Vector3(0.05f, 0.25f, 0.05f); private static readonly Vector3 TipPos = new Vector3(0f, 0.5f, 0f); private static readonly Vector3 TipScale = new Vector3(0.14f, 0.2f, 0.14f); private static readonly Vector3 ScaleTipPos = new Vector3(0f, 0.55f, 0f); private static readonly Vector3 ScaleTipScale = new Vector3(0.16f, 0.16f, 0.16f); private static readonly float PlaneSizeMove = 0.2625f; private static readonly float PlaneSizeScale = 0.3f; private static readonly float PlaneThickness = 0.03f; private static Mesh _shaftMesh; private static Mesh _coneTipMesh; private static Mesh _cubeTipMesh; private static Mesh _sphereMesh; private static Mesh _ringMesh; private static Material[] _mats; private static Material[] _hoverMats; private static Material[] _planeMats; private static Material[] _planeHoverMats; private static Material _freeMat; private static Material _freeHoverMat; private static Material _freeRotMat; private static Material _freeRotHoverMat; private static Material[] _occMats; private static Material[] _planeOccMats; private static Material _freeOccMat; public static float OutlineThickness = 0.03f; public static float OutlineOccludedAlpha = 0.35f; public static float OutlineWidth = 2f; private static Material _stencilClearMat; private static Material _stencilMarkMat; private static Material _outlineMat; private static Material _outlineOccMat; private static CommandBuffer _outlineBuffer; private static Camera _outlineCameraTarget; private static CommandBuffer _gizmoZTestBuffer; private static Material _maskMat; private static Material _ppMat; private static Material _depthCaptureMat; private static RenderTexture _depthCopyRT; private static CommandBuffer _depthCaptureBuffer; private static Camera _depthCaptureCameraTarget; private static readonly int _maskRTId = Shader.PropertyToID("_BabyBlocks_SelectionMaskRT"); private static readonly int _depthCopyTexId = Shader.PropertyToID("_BabyBlocksDepthCopy"); private static CommandBuffer _ssBuffer; private static Camera _ssCameraTarget; private static IReadOnlyList _ssLastSelection; private static readonly List<(Color color, IReadOnlyList targets)> _ssRemoteHighlights = new List<(Color, IReadOnlyList)>(); private static readonly List _ssRemoteMpbPool = new List(); private static bool _outlineTranslateDrag; private static Vector3 _outlineTranslateDelta; private static readonly Dictionary _meshDataCache = new Dictionary(); private static readonly Dictionary _outlineShellCache = new Dictionary(); private static Mesh _combinedOutlineShell; private static int _combinedOutlineSignature; private static readonly List _combinedOutlineCombines = new List(); private static readonly List<(Mesh mesh, Matrix4x4 matrix, int subMeshCount)> _outlineMarks = new List<(Mesh, Matrix4x4, int)>(); private static readonly List _remoteOutlineShells = new List(); private static readonly List<(Mesh mesh, Matrix4x4 matrix, int subMeshCount)> _remoteOutlineMarks = new List<(Mesh, Matrix4x4, int)>(); private static GameObject _root; private static GameObject _arrowHandles; private static GameObject _ringHandles; private static Camera _overlayCam; private static Vector3 _pivotPos; private static bool _pivotOverrideActive; private static Vector3 _pivotOverride; private static readonly Quaternion FlipArrowQ = Quaternion.Euler(180f, 0f, 0f); private static Transform[] _axisPivots = (Transform[])(object)new Transform[3]; private static Transform[] _planeHandles = (Transform[])(object)new Transform[3]; private static bool[] _axisFlipped = new bool[3]; private static GizmoHandle[] _ringHandleRefs = new GizmoHandle[3]; private const float MaxPlausibleBoundsExtent = 100f; public static bool HasRemoteHighlights => _ssRemoteHighlights.Count > 0; public static bool ScreenSpaceShadersLoaded => (Object)(object)_maskMat != (Object)null && (Object)(object)_ppMat != (Object)null; public static bool IsReady => (Object)(object)_root != (Object)null && (Object)(object)_overlayCam != (Object)null; public static Vector3 PivotPosition => _pivotPos; public static bool StencilMaterialsReady => (Object)(object)_stencilClearMat != (Object)null && (Object)(object)_stencilMarkMat != (Object)null; public static void ClearRemoteHighlights() { _ssRemoteHighlights.Clear(); } public static void AddRemoteHighlight(Color color, IReadOnlyList targets) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (targets != null && targets.Count > 0) { _ssRemoteHighlights.Add((color, targets)); } } public static void SetTranslateDragDelta(Vector3 delta) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) _outlineTranslateDrag = true; _outlineTranslateDelta = delta; } public static void ClearDragDelta() { _outlineTranslateDrag = false; } public static Quaternion GetEffectivePivotRot(int i) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) return (i >= 0 && i < 3 && _axisFlipped[i]) ? (PivotRots[i] * FlipArrowQ) : PivotRots[i]; } public static void SetPivotOverride(Vector3 pivot) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) _pivotOverrideActive = true; _pivotOverride = pivot; } public static void ClearPivotOverride() { _pivotOverrideActive = false; } public static void Init() { InitMeshes(); InitMaterials(); BuildColliders(); _overlayCam = BuildCam(100f, 500000f, (CameraClearFlags)3); AttachGizmoZTestBuffer(_overlayCam); LoadScreenSpaceShaders(); } public static void Sync(IReadOnlyList selection, LevelEditorObject primary, LevelEditor.ToolMode tool, Camera mainCam) { //IL_0080: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null) { return; } bool flag = selection != null && selection.Count > 0; _root.SetActive(flag); if ((Object)(object)_overlayCam != (Object)null) { ((Behaviour)_overlayCam).enabled = flag || _ssRemoteHighlights.Count > 0; } if (!flag) { return; } _pivotPos = (_pivotOverrideActive ? _pivotOverride : GetSelectionBoundsCenter(selection)); _root.transform.position = _pivotPos; Quaternion rotation; if ((!LevelEditor.LocalMode && tool != LevelEditor.ToolMode.Scale) || !((Object)(object)primary != (Object)null)) { rotation = Quaternion.identity; } else if (primary.groupId > 0) { GameObject groupRoot = GroupManager.GetGroupRoot(primary.groupId); rotation = ((groupRoot != null) ? groupRoot.transform.rotation : Quaternion.identity); } else { rotation = ((Component)primary).transform.rotation; } _root.transform.rotation = rotation; float num = Vector3.Distance(((Component)mainCam).transform.position, _root.transform.position); _root.transform.localScale = Vector3.one * Mathf.Max(num * 0.14f, 0.02f); bool flag2 = tool == LevelEditor.ToolMode.Rotate; if ((Object)(object)_arrowHandles != (Object)null) { _arrowHandles.SetActive(!flag2); } if ((Object)(object)_ringHandles != (Object)null) { _ringHandles.SetActive(flag2); } for (int i = 0; i < 3; i++) { if (!flag2 && (Object)(object)_axisPivots[i] != (Object)null) { Vector3 val = _root.transform.rotation * (PivotRots[i] * Vector3.up); _axisFlipped[i] = Vector3.Dot(val, ((Component)mainCam).transform.position - _pivotPos) < 0f; _axisPivots[i].localRotation = GetEffectivePivotRot(i); continue; } _axisFlipped[i] = false; if ((Object)(object)_axisPivots[i] != (Object)null) { _axisPivots[i].localRotation = PivotRots[i]; } } for (int j = 0; j < 3; j++) { if (!((Object)(object)_planeHandles[j] == (Object)null)) { int num2 = j switch { 1 => 1, 0 => 0, _ => 0, }; int num3 = j switch { 1 => 2, 0 => 1, _ => 2, }; float num4 = (_axisFlipped[num2] ? (-1f) : 1f); float num5 = (_axisFlipped[num3] ? (-1f) : 1f); Vector3 val2 = PivotRots[num2] * Vector3.up * num4; Vector3 val3 = PivotRots[num3] * Vector3.up * num5; _planeHandles[j].localPosition = (val2 + val3) * PlaneSizeMove * 0.5f; } } SyncCamToMain(_overlayCam, mainCam); } private static void SyncCamToMain(Camera cam, Camera mainCam) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)cam == (Object)null)) { ((Component)cam).transform.SetPositionAndRotation(((Component)mainCam).transform.position, ((Component)mainCam).transform.rotation); cam.fieldOfView = mainCam.fieldOfView; cam.aspect = mainCam.aspect; cam.nearClipPlane = mainCam.nearClipPlane; cam.rect = mainCam.rect; } } public static void EnsureCamera() { if ((Object)(object)_root != (Object)null && (Object)(object)_overlayCam == (Object)null) { _overlayCam = BuildCam(100f, 500000f, (CameraClearFlags)3); _gizmoZTestBuffer = null; AttachGizmoZTestBuffer(_overlayCam); } } private static void AttachGizmoZTestBuffer(Camera cam) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (!((Object)(object)cam == (Object)null) && _gizmoZTestBuffer == null) { _gizmoZTestBuffer = new CommandBuffer { name = "BabyBlocks_GizmoZTest" }; _gizmoZTestBuffer.SetGlobalFloat("unity_GUIZTestMode", 4f); cam.AddCommandBuffer((CameraEvent)10, _gizmoZTestBuffer); } } internal static void RefreshAssets() { InitMeshes(); InitMaterials(); if ((Object)(object)_maskMat == (Object)null || (Object)(object)_ppMat == (Object)null) { LoadScreenSpaceShaders(); } if (_occMats == null && (Object)(object)_maskMat != (Object)null) { Shader val = Shader.Find("Hidden/BabyBlocks/GizmoOccluded"); if ((Object)(object)val != (Object)null) { BuildGizmoOccMats(val); } } } public static void SetActive(bool on) { if ((Object)(object)_root != (Object)null) { _root.SetActive(on); } if ((Object)(object)_overlayCam != (Object)null) { ((Behaviour)_overlayCam).enabled = on; } if (!on) { DetachOutlineBuffer(); DetachSSBuffer(); } } private static void DetachOutlineBuffer() { if ((Object)(object)_outlineCameraTarget != (Object)null && _outlineBuffer != null) { _outlineCameraTarget.RemoveCommandBuffer((CameraEvent)20, _outlineBuffer); _outlineCameraTarget = null; } } private static void DetachSSBuffer() { if ((Object)(object)_ssCameraTarget != (Object)null && _ssBuffer != null) { _ssCameraTarget.RemoveCommandBuffer((CameraEvent)16, _ssBuffer); _ssCameraTarget = null; } _ssLastSelection = null; } internal static void LoadScreenSpaceShaders() { //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Expected O, but got Unknown //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Expected O, but got Unknown //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Expected O, but got Unknown try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream("BabyBlocks.Shaders.babyblocks_shaders.bundle"); if (stream == null) { string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); return; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); AssetBundle val = AssetBundle.LoadFromMemory(Il2CppStructArray.op_Implicit(array)); if ((Object)(object)val == (Object)null) { MelonLogger.Warning("[BabyBlocks] AssetBundle.LoadFromMemory returned null."); return; } Shader val2 = null; Shader val3 = null; Shader val4 = null; Shader val5 = null; Shader val6 = null; Il2CppReferenceArray val7 = val.LoadAllAssets(); if (val7 != null) { foreach (Object item in (Il2CppArrayBase)(object)val7) { if (item == (Object)null) { continue; } Shader val8 = ((Il2CppObjectBase)item).TryCast(); if (!((Object)(object)val8 == (Object)null)) { if (((Object)val8).name.Contains("SelectionMask")) { val2 = val8; } if (((Object)val8).name.Contains("SelectionOutline")) { val3 = val8; } if (((Object)val8).name.Contains("DepthCapture")) { val4 = val8; } if (((Object)val8).name.Contains("GizmoOccluded")) { val5 = val8; } if (((Object)val8).name.Contains("TintOverlay")) { val6 = val8; } } } } if ((Object)(object)val6 != (Object)null) { PropInstanceServices.SetTintShader(val6); } val.Unload(false); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null) { MelonLogger.Warning($"[BabyBlocks] Could not find shaders in bundle. mask={((val2 != null) ? ((Object)val2).name : null) ?? "null"} pp={((val3 != null) ? ((Object)val3).name : null) ?? "null"} depthCapture={((val4 != null) ? ((Object)val4).name : null) ?? "null"}"); return; } _maskMat = new Material(val2) { name = "BabyBlocks_SelectionMask" }; _ppMat = new Material(val3) { name = "BabyBlocks_SelectionOutline" }; _depthCaptureMat = new Material(val4) { name = "BabyBlocks_DepthCapture" }; _ppMat.SetColor("_OutlineColor", new Color(1f, 0.85f, 0.1f, 1f)); _ppMat.SetFloat("_OccludedAlpha", OutlineOccludedAlpha); _depthCopyRT = new RenderTexture(1630, 1080, 0, (RenderTextureFormat)14) { name = "BabyBlocks_DepthCopy", filterMode = (FilterMode)0 }; _depthCopyRT.Create(); _ppMat.SetTexture(_depthCopyTexId, (Texture)(object)_depthCopyRT); Shader.SetGlobalTexture("_BabyBlocksDepthCopy", (Texture)(object)_depthCopyRT); if ((Object)(object)val5 != (Object)null) { BuildGizmoOccMats(val5); } else { MelonLogger.Warning("[BabyBlocks] GizmoOccluded shader not found in bundle."); } } catch (Exception value) { MelonLogger.Warning($"[BabyBlocks] Failed to load screen-space shaders: {value}"); } } private static void BuildGizmoOccMats(Shader shader) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[3] { new Color(0.9f, 0.2f, 0.2f), new Color(0.2f, 0.8f, 0.2f), new Color(0.2f, 0.45f, 1f) }; Color[] array2 = (Color[])(object)new Color[3] { array[2], array[0], array[1] }; _occMats = (Material[])(object)new Material[3]; for (int i = 0; i < 3; i++) { _occMats[i] = MakeOccMat(shader, array[i], 4001); } _freeOccMat = MakeOccMat(shader, new Color(0.72f, 0.72f, 0.72f), 4001); _planeOccMats = (Material[])(object)new Material[3]; for (int j = 0; j < 3; j++) { _planeOccMats[j] = MakeOccMat(shader, array2[j], 4001); } } private static Material MakeOccMat(Shader shader, Color color, int queue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(shader) { renderQueue = queue }; val.SetColor("_Color", color); return val; } private static void DetachDepthCaptureBuffer() { if ((Object)(object)_depthCaptureCameraTarget != (Object)null && _depthCaptureBuffer != null) { _depthCaptureCameraTarget.RemoveCommandBuffer((CameraEvent)20, _depthCaptureBuffer); _depthCaptureCameraTarget = null; } } private static void AttachDepthCaptureBuffer(Camera mainCam) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) DetachDepthCaptureBuffer(); if (!((Object)(object)_depthCaptureMat == (Object)null) && !((Object)(object)_depthCopyRT == (Object)null)) { if (((Texture)_depthCopyRT).width != mainCam.pixelWidth || ((Texture)_depthCopyRT).height != mainCam.pixelHeight) { _depthCopyRT.Release(); ((Texture)_depthCopyRT).width = mainCam.pixelWidth; ((Texture)_depthCopyRT).height = mainCam.pixelHeight; _depthCopyRT.Create(); _ppMat.SetTexture(_depthCopyTexId, (Texture)(object)_depthCopyRT); Shader.SetGlobalTexture("_BabyBlocksDepthCopy", (Texture)(object)_depthCopyRT); } if (_depthCaptureBuffer == null) { _depthCaptureBuffer = new CommandBuffer { name = "BabyBlocks_DepthCapture" }; } else { _depthCaptureBuffer.Clear(); } _depthCaptureBuffer.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)0), RenderTargetIdentifier.op_Implicit((Texture)(object)_depthCopyRT), _depthCaptureMat); mainCam.AddCommandBuffer((CameraEvent)20, _depthCaptureBuffer); _depthCaptureCameraTarget = mainCam; } } private static void DrawOutlineScreenSpace(IReadOnlyList selection, Camera mainCam) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown DetachSSBuffer(); if (((selection != null && selection.Count > 0) || _ssRemoteHighlights.Count != 0) && !((Object)(object)mainCam == (Object)null) && ScreenSpaceShadersLoaded && !((Object)(object)_overlayCam == (Object)null)) { mainCam.depthTextureMode = (DepthTextureMode)(mainCam.depthTextureMode | 1); AttachDepthCaptureBuffer(mainCam); _ssLastSelection = selection; if (_ssBuffer == null) { _ssBuffer = new CommandBuffer { name = "BabyBlocks_SSOutline" }; } RecordSSBuffer(selection, mainCam); _overlayCam.AddCommandBuffer((CameraEvent)16, _ssBuffer); _ssCameraTarget = _overlayCam; } } internal static void RefreshSSBufferMatrices() { if (_ssBuffer != null && !((Object)(object)_ssCameraTarget == (Object)null) && ScreenSpaceShadersLoaded && ((_ssLastSelection != null && _ssLastSelection.Count != 0) || _ssRemoteHighlights.Count != 0)) { Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { RecordSSBuffer(_ssLastSelection, main); } } } private static void RecordSSBuffer(IReadOnlyList selection, Camera mainCam) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Expected O, but got Unknown //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) _ssBuffer.Clear(); _ppMat.SetFloat("_OccludedAlpha", OutlineOccludedAlpha); _ppMat.SetFloat("_OutlineWidth", OutlineWidth); _ppMat.SetFloat("_DebugMode", 0f); Shader.SetGlobalFloat("_BabyBlocksCamNear", mainCam.nearClipPlane); _ppMat.SetVector("_ViewportRect", new Vector4(0f, 0f, 1f, 1f)); _ssBuffer.GetTemporaryRT(_maskRTId, mainCam.pixelWidth, mainCam.pixelHeight, 24, (FilterMode)1, (RenderTextureFormat)11); _ssBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit(_maskRTId)); _ssBuffer.ClearRenderTarget(true, true, Color.clear); _ssBuffer.SetViewport(new Rect(0f, 0f, (float)mainCam.pixelWidth, (float)mainCam.pixelHeight)); _ssBuffer.SetViewProjectionMatrices(mainCam.worldToCameraMatrix, mainCam.projectionMatrix); _maskMat.SetColor("_Color", new Color(1f, 0.85f, 0.1f, 1f)); if (selection != null) { for (int i = 0; i < selection.Count; i++) { LevelEditorObject levelEditorObject = selection[i]; if ((Object)(object)levelEditorObject == (Object)null) { continue; } Il2CppArrayBase componentsInChildren = ((Component)levelEditorObject).GetComponentsInChildren(); if (componentsInChildren == null) { continue; } for (int j = 0; j < componentsInChildren.Length; j++) { MeshFilter val = componentsInChildren[j]; if ((Object)(object)val == (Object)null || (Object)(object)val.sharedMesh == (Object)null) { continue; } MeshRenderer component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && ((Renderer)component).enabled) { Mesh sharedMesh = val.sharedMesh; Matrix4x4 localToWorldMatrix = ((Component)val).transform.localToWorldMatrix; for (int k = 0; k < sharedMesh.subMeshCount; k++) { _ssBuffer.DrawMesh(sharedMesh, localToWorldMatrix, _maskMat, k); } } } } } for (int l = 0; l < _ssRemoteHighlights.Count; l++) { (Color, IReadOnlyList) tuple = _ssRemoteHighlights[l]; if (tuple.Item2 == null || tuple.Item2.Count == 0) { continue; } while (_ssRemoteMpbPool.Count <= l) { _ssRemoteMpbPool.Add(new MaterialPropertyBlock()); } MaterialPropertyBlock val2 = _ssRemoteMpbPool[l]; val2.SetColor("_Color", tuple.Item1); for (int m = 0; m < tuple.Item2.Count; m++) { LevelEditorObject levelEditorObject2 = tuple.Item2[m]; if ((Object)(object)levelEditorObject2 == (Object)null) { continue; } Il2CppArrayBase componentsInChildren2 = ((Component)levelEditorObject2).GetComponentsInChildren(); if (componentsInChildren2 == null) { continue; } for (int n = 0; n < componentsInChildren2.Length; n++) { MeshFilter val3 = componentsInChildren2[n]; if ((Object)(object)val3 == (Object)null || (Object)(object)val3.sharedMesh == (Object)null) { continue; } MeshRenderer component2 = ((Component)val3).GetComponent(); if (!((Object)(object)component2 == (Object)null) && ((Renderer)component2).enabled) { Mesh sharedMesh2 = val3.sharedMesh; Matrix4x4 localToWorldMatrix2 = ((Component)val3).transform.localToWorldMatrix; for (int num = 0; num < sharedMesh2.subMeshCount; num++) { _ssBuffer.DrawMesh(sharedMesh2, localToWorldMatrix2, _maskMat, num, 0, val2); } } } } } _ssBuffer.Blit(RenderTargetIdentifier.op_Implicit(_maskRTId), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), _ppMat); _ssBuffer.ReleaseTemporaryRT(_maskRTId); _ssBuffer.SetViewProjectionMatrices(mainCam.worldToCameraMatrix, mainCam.projectionMatrix); } public static GizmoHandle RaycastHandle(Ray ray) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) GizmoHandle gizmoHandle = null; GizmoHandle gizmoHandle2 = null; float num = float.MaxValue; if ((Object)(object)_ringHandles != (Object)null && _ringHandles.activeSelf) { Vector3 position = _root.transform.position; Quaternion rotation = _root.transform.rotation; float x = _root.transform.localScale.x; for (int i = 0; i < 3; i++) { if (RaycastRing(ray, position, rotation * RingPivotRots[i], x, out var dist) && dist < num) { num = dist; gizmoHandle = _ringHandleRefs[i]; } } } Il2CppStructArray val = Physics.RaycastAll(ray, 2000f, Mask); if (val != null) { foreach (RaycastHit item in (Il2CppArrayBase)(object)val) { RaycastHit current = item; GizmoHandle component = ((Component)((RaycastHit)(ref current)).collider).GetComponent(); if (!((Object)(object)component == (Object)null)) { if (component.axisIndex == 3) { return component; } if (component.axisIndex == 7) { gizmoHandle2 = component; } else if (((RaycastHit)(ref current)).distance < num) { num = ((RaycastHit)(ref current)).distance; gizmoHandle = component; } } } } return gizmoHandle ?? gizmoHandle2; } private static bool RaycastRing(Ray ray, Vector3 center, Quaternion ringRot, float scale, out float dist) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) dist = 0f; Vector3 val = ringRot * Vector3.up; float num = Vector3.Dot(((Ray)(ref ray)).direction, val); if (Mathf.Abs(num) < 1E-05f) { return false; } float num2 = Vector3.Dot(center - ((Ray)(ref ray)).origin, val) / num; if (num2 < 0f) { return false; } Vector3 val2 = ((Ray)(ref ray)).origin + ((Ray)(ref ray)).direction * num2; float num3 = Vector3.Distance(val2, center); float num4 = 0.7f * scale; float num5 = 0.45f * scale; if (num3 < num5 || num3 > num4) { return false; } dist = num2; return true; } public static void Draw(int hoveredAxis, LevelEditor.ToolMode tool) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: 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_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: 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_04f3: 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_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0518: 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_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null || !_root.activeSelf || (Object)(object)_overlayCam == (Object)null || (Object)(object)_shaftMesh == (Object)null || (Object)(object)_coneTipMesh == (Object)null || (Object)(object)_cubeTipMesh == (Object)null || (Object)(object)_sphereMesh == (Object)null || (Object)(object)_ringMesh == (Object)null) { return; } Vector3 position = _root.transform.position; float x = _root.transform.localScale.x; if (tool == LevelEditor.ToolMode.Rotate) { if ((Object)(object)_freeRotMat != (Object)null) { Material val = ((hoveredAxis == 7 && (Object)(object)_freeRotHoverMat != (Object)null) ? _freeRotHoverMat : _freeRotMat); Graphics.DrawMesh(_sphereMesh, Matrix4x4.TRS(position, Quaternion.identity, Vector3.one * 0.85f * x), val, 31, _overlayCam); } Quaternion rotation = _root.transform.rotation; for (int i = 0; i < 3; i++) { Material val2 = ((hoveredAxis == i && _hoverMats != null) ? _hoverMats[i] : _mats[i]); Matrix4x4 val3 = Matrix4x4.TRS(position, rotation * RingPivotRots[i], Vector3.one * x); Graphics.DrawMesh(_ringMesh, val3, val2, 31, _overlayCam); if (_occMats != null) { Graphics.DrawMesh(_ringMesh, val3, _occMats[i], 31, _overlayCam); } } return; } bool flag = tool == LevelEditor.ToolMode.Scale; Mesh val4 = (flag ? _cubeTipMesh : _coneTipMesh); Vector3 val5 = (flag ? ScaleTipPos : TipPos); Vector3 val6 = (flag ? ScaleTipScale : TipScale); float num = (flag ? PlaneSizeScale : PlaneSizeMove); Vector3 val7 = default(Vector3); ((Vector3)(ref val7))..ctor(num, num, PlaneThickness); Vector3 val8 = default(Vector3); ((Vector3)(ref val8))..ctor(PlaneThickness, num, num); Vector3 val9 = default(Vector3); ((Vector3)(ref val9))..ctor(num, PlaneThickness, num); Quaternion rotation2 = _root.transform.rotation; for (int j = 0; j < 3; j++) { Quaternion val10 = rotation2 * GetEffectivePivotRot(j); Material val11 = ((hoveredAxis == j && _hoverMats != null) ? _hoverMats[j] : _mats[j]); Matrix4x4 val12 = Matrix4x4.TRS(position + val10 * (ShaftPos * x), val10, ShaftScale * x); Matrix4x4 val13 = Matrix4x4.TRS(position + val10 * (val5 * x), val10, val6 * x); Graphics.DrawMesh(_shaftMesh, val12, val11, 31, _overlayCam); Graphics.DrawMesh(val4, val13, val11, 31, _overlayCam); if (_occMats != null) { Graphics.DrawMesh(_shaftMesh, val12, _occMats[j], 31, _overlayCam); Graphics.DrawMesh(val4, val13, _occMats[j], 31, _overlayCam); } } Material val14 = ((hoveredAxis == 3 && (Object)(object)_freeHoverMat != (Object)null) ? _freeHoverMat : _freeMat); Mesh val15 = (flag ? _cubeTipMesh : _sphereMesh); Quaternion val16 = (flag ? rotation2 : Quaternion.identity); Matrix4x4 val17 = Matrix4x4.TRS(position, val16, Vector3.one * 0.22f * x); if ((Object)(object)val14 != (Object)null) { Graphics.DrawMesh(val15, val17, val14, 31, _overlayCam); if ((Object)(object)_freeOccMat != (Object)null) { Graphics.DrawMesh(val15, val17, _freeOccMat, 31, _overlayCam); } } if (_planeMats == null || _planeHoverMats == null) { return; } for (int k = 0; k < 3; k++) { int num2 = 4 + k; Material val18 = ((hoveredAxis == num2) ? _planeHoverMats[k] : _planeMats[k]); if (!((Object)(object)val18 == (Object)null)) { int i2 = k switch { 1 => 1, 0 => 0, _ => 0, }; int i3 = k switch { 1 => 2, 0 => 1, _ => 2, }; Vector3 val19 = GetEffectivePivotRot(i2) * Vector3.up; Vector3 val20 = GetEffectivePivotRot(i3) * Vector3.up; Vector3 val21 = (val19 + val20) * num * 0.5f; Vector3 val22 = (Vector3)(k switch { 1 => val8, 0 => val7, _ => val9, }); Matrix4x4 val23 = Matrix4x4.TRS(position + rotation2 * (val21 * x), rotation2, val22 * x); Graphics.DrawMesh(_cubeTipMesh, val23, val18, 31, _overlayCam); if (_planeOccMats != null) { Graphics.DrawMesh(_cubeTipMesh, val23, _planeOccMats[k], 31, _overlayCam); } } } } public static void DrawOutline_Legacy(IReadOnlyList selection, Camera mainCam) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) DetachOutlineBuffer(); if (selection == null || selection.Count == 0 || (Object)(object)mainCam == (Object)null || (Object)(object)_stencilClearMat == (Object)null || (Object)(object)_stencilMarkMat == (Object)null || (Object)(object)_outlineMat == (Object)null) { return; } if (_outlineBuffer == null) { _outlineBuffer = new CommandBuffer { name = "PropOutline" }; } else { _outlineBuffer.Clear(); } _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 8f); if (_outlineTranslateDrag && (Object)(object)_combinedOutlineShell != (Object)null && _combinedOutlineShell.vertexCount > 0) { _outlineMarks.Clear(); CollectOutlineMarks(selection); if (_outlineMarks.Count > 0) { Matrix4x4 val = Matrix4x4.Translate(_outlineTranslateDelta); _outlineBuffer.DrawMesh(_combinedOutlineShell, val, _stencilClearMat); for (int i = 0; i < _outlineMarks.Count; i++) { (Mesh, Matrix4x4, int) tuple = _outlineMarks[i]; for (int j = 0; j < tuple.Item3; j++) { _outlineBuffer.DrawMesh(tuple.Item1, tuple.Item2, _stencilMarkMat, j); } } _outlineBuffer.DrawMesh(_combinedOutlineShell, val, _outlineMat); } _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 4f); mainCam.AddCommandBuffer((CameraEvent)20, _outlineBuffer); _outlineCameraTarget = mainCam; return; } _combinedOutlineCombines.Clear(); _outlineMarks.Clear(); int num = 17; CombineInstance item; for (int k = 0; k < selection.Count; k++) { LevelEditorObject levelEditorObject = selection[k]; if ((Object)(object)levelEditorObject == (Object)null) { continue; } Il2CppArrayBase componentsInChildren = ((Component)levelEditorObject).GetComponentsInChildren(); if (componentsInChildren == null) { continue; } num = num * 31 + ((Object)levelEditorObject).GetInstanceID(); for (int l = 0; l < componentsInChildren.Length; l++) { MeshFilter val2 = componentsInChildren[l]; if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) { continue; } MeshRenderer component = ((Component)val2).GetComponent(); if (!((Object)(object)component == (Object)null) && ((Renderer)component).enabled) { Mesh sharedMesh = val2.sharedMesh; Transform transform = ((Component)val2).transform; OutlineShellData orBuildOutlineShell = GetOrBuildOutlineShell(sharedMesh, transform); if (!((Object)(object)orBuildOutlineShell.mesh == (Object)null)) { num = num * 31 + ((Object)val2).GetInstanceID(); num = num * 31 + ((Object)sharedMesh).GetInstanceID(); num = num * 31 + ((object)transform.position/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + ((object)transform.rotation/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + ((object)transform.lossyScale/*cast due to .constrained prefix*/).GetHashCode(); List combinedOutlineCombines = _combinedOutlineCombines; item = default(CombineInstance); ((CombineInstance)(ref item)).mesh = orBuildOutlineShell.mesh; ((CombineInstance)(ref item)).transform = Matrix4x4.identity; combinedOutlineCombines.Add(item); _outlineMarks.Add((sharedMesh, transform.localToWorldMatrix, sharedMesh.subMeshCount)); } } } } if (_combinedOutlineCombines.Count == 0) { _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 4f); return; } if (!LevelEditor.IsDragging) { if ((Object)(object)_combinedOutlineShell == (Object)null) { _combinedOutlineShell = new Mesh { name = "PropOutlineCombinedShell" }; } if (_combinedOutlineSignature != num || _combinedOutlineShell.vertexCount == 0) { _combinedOutlineSignature = num; _combinedOutlineShell.Clear(false); _combinedOutlineShell.indexFormat = (IndexFormat)1; _combinedOutlineShell.CombineMeshes(Il2CppStructArray.op_Implicit(_combinedOutlineCombines.ToArray()), true, false, false); _combinedOutlineShell.RecalculateBounds(); } _outlineBuffer.DrawMesh(_combinedOutlineShell, Matrix4x4.identity, _stencilClearMat); for (int m = 0; m < _outlineMarks.Count; m++) { (Mesh, Matrix4x4, int) tuple2 = _outlineMarks[m]; for (int n = 0; n < tuple2.Item3; n++) { _outlineBuffer.DrawMesh(tuple2.Item1, tuple2.Item2, _stencilMarkMat, n); } } _outlineBuffer.DrawMesh(_combinedOutlineShell, Matrix4x4.identity, _outlineMat); } else { for (int num2 = 0; num2 < _combinedOutlineCombines.Count; num2++) { CommandBuffer outlineBuffer = _outlineBuffer; item = _combinedOutlineCombines[num2]; outlineBuffer.DrawMesh(((CombineInstance)(ref item)).mesh, Matrix4x4.identity, _stencilClearMat); } for (int num3 = 0; num3 < _outlineMarks.Count; num3++) { (Mesh, Matrix4x4, int) tuple3 = _outlineMarks[num3]; for (int num4 = 0; num4 < tuple3.Item3; num4++) { _outlineBuffer.DrawMesh(tuple3.Item1, tuple3.Item2, _stencilMarkMat, num4); } } for (int num5 = 0; num5 < _combinedOutlineCombines.Count; num5++) { CommandBuffer outlineBuffer2 = _outlineBuffer; item = _combinedOutlineCombines[num5]; outlineBuffer2.DrawMesh(((CombineInstance)(ref item)).mesh, Matrix4x4.identity, _outlineMat); } } _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 4f); mainCam.AddCommandBuffer((CameraEvent)20, _outlineBuffer); _outlineCameraTarget = mainCam; } public static void DrawOutline(IReadOnlyList selection, Camera mainCam) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_068c: 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_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_0704: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_0761: Unknown result type (might be due to invalid IL or missing references) //IL_076a: Unknown result type (might be due to invalid IL or missing references) if (ScreenSpaceShadersLoaded) { DetachOutlineBuffer(); DrawOutlineScreenSpace(selection, mainCam); return; } DetachOutlineBuffer(); if (selection == null || selection.Count == 0 || (Object)(object)mainCam == (Object)null || (Object)(object)_stencilClearMat == (Object)null || (Object)(object)_stencilMarkMat == (Object)null || (Object)(object)_outlineMat == (Object)null) { return; } if (_outlineBuffer == null) { _outlineBuffer = new CommandBuffer { name = "PropOutline" }; } else { _outlineBuffer.Clear(); } SyncOccludedColor(); bool flag = OutlineOccludedAlpha > 0.01f && (Object)(object)_outlineOccMat != (Object)null; if (_outlineTranslateDrag && (Object)(object)_combinedOutlineShell != (Object)null && _combinedOutlineShell.vertexCount > 0) { _outlineMarks.Clear(); CollectOutlineMarks(selection); if (_outlineMarks.Count > 0) { Matrix4x4 val = Matrix4x4.Translate(_outlineTranslateDelta); _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 8f); _outlineBuffer.DrawMesh(_combinedOutlineShell, val, _stencilClearMat); for (int i = 0; i < _outlineMarks.Count; i++) { (Mesh, Matrix4x4, int) tuple = _outlineMarks[i]; for (int j = 0; j < tuple.Item3; j++) { _outlineBuffer.DrawMesh(tuple.Item1, tuple.Item2, _stencilMarkMat, j); } } _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 4f); _outlineBuffer.DrawMesh(_combinedOutlineShell, val, _outlineMat); if (flag) { _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 5f); _outlineBuffer.DrawMesh(_combinedOutlineShell, val, _outlineOccMat); } } _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 4f); mainCam.AddCommandBuffer((CameraEvent)20, _outlineBuffer); _outlineCameraTarget = mainCam; return; } _combinedOutlineCombines.Clear(); _outlineMarks.Clear(); int num = 17; CombineInstance item; for (int k = 0; k < selection.Count; k++) { LevelEditorObject levelEditorObject = selection[k]; if ((Object)(object)levelEditorObject == (Object)null) { continue; } Il2CppArrayBase componentsInChildren = ((Component)levelEditorObject).GetComponentsInChildren(); if (componentsInChildren == null) { continue; } num = num * 31 + ((Object)levelEditorObject).GetInstanceID(); for (int l = 0; l < componentsInChildren.Length; l++) { MeshFilter val2 = componentsInChildren[l]; if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) { continue; } MeshRenderer component = ((Component)val2).GetComponent(); if (!((Object)(object)component == (Object)null) && ((Renderer)component).enabled) { Mesh sharedMesh = val2.sharedMesh; Transform transform = ((Component)val2).transform; OutlineShellData orBuildOutlineShell = GetOrBuildOutlineShell(sharedMesh, transform); if (!((Object)(object)orBuildOutlineShell.mesh == (Object)null)) { num = num * 31 + ((Object)val2).GetInstanceID(); num = num * 31 + ((Object)sharedMesh).GetInstanceID(); num = num * 31 + ((object)transform.position/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + ((object)transform.rotation/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + ((object)transform.lossyScale/*cast due to .constrained prefix*/).GetHashCode(); List combinedOutlineCombines = _combinedOutlineCombines; item = default(CombineInstance); ((CombineInstance)(ref item)).mesh = orBuildOutlineShell.mesh; ((CombineInstance)(ref item)).transform = Matrix4x4.identity; combinedOutlineCombines.Add(item); _outlineMarks.Add((sharedMesh, transform.localToWorldMatrix, sharedMesh.subMeshCount)); } } } } if (_combinedOutlineCombines.Count == 0) { _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 4f); return; } bool isDragging = LevelEditor.IsDragging; _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 8f); if (!isDragging) { if ((Object)(object)_combinedOutlineShell == (Object)null) { _combinedOutlineShell = new Mesh { name = "PropOutlineCombinedShell" }; } if (_combinedOutlineSignature != num || _combinedOutlineShell.vertexCount == 0) { _combinedOutlineSignature = num; _combinedOutlineShell.Clear(false); _combinedOutlineShell.indexFormat = (IndexFormat)1; _combinedOutlineShell.CombineMeshes(Il2CppStructArray.op_Implicit(_combinedOutlineCombines.ToArray()), true, false, false); _combinedOutlineShell.RecalculateBounds(); } _outlineBuffer.DrawMesh(_combinedOutlineShell, Matrix4x4.identity, _stencilClearMat); for (int m = 0; m < _outlineMarks.Count; m++) { (Mesh, Matrix4x4, int) tuple2 = _outlineMarks[m]; for (int n = 0; n < tuple2.Item3; n++) { _outlineBuffer.DrawMesh(tuple2.Item1, tuple2.Item2, _stencilMarkMat, n); } } _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 4f); _outlineBuffer.DrawMesh(_combinedOutlineShell, Matrix4x4.identity, _outlineMat); if (flag) { _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 5f); _outlineBuffer.DrawMesh(_combinedOutlineShell, Matrix4x4.identity, _outlineOccMat); } } else { for (int num2 = 0; num2 < _combinedOutlineCombines.Count; num2++) { CommandBuffer outlineBuffer = _outlineBuffer; item = _combinedOutlineCombines[num2]; outlineBuffer.DrawMesh(((CombineInstance)(ref item)).mesh, Matrix4x4.identity, _stencilClearMat); } for (int num3 = 0; num3 < _outlineMarks.Count; num3++) { (Mesh, Matrix4x4, int) tuple3 = _outlineMarks[num3]; for (int num4 = 0; num4 < tuple3.Item3; num4++) { _outlineBuffer.DrawMesh(tuple3.Item1, tuple3.Item2, _stencilMarkMat, num4); } } _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 4f); for (int num5 = 0; num5 < _combinedOutlineCombines.Count; num5++) { CommandBuffer outlineBuffer2 = _outlineBuffer; item = _combinedOutlineCombines[num5]; outlineBuffer2.DrawMesh(((CombineInstance)(ref item)).mesh, Matrix4x4.identity, _outlineMat); } if (flag) { _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 5f); for (int num6 = 0; num6 < _combinedOutlineCombines.Count; num6++) { CommandBuffer outlineBuffer3 = _outlineBuffer; item = _combinedOutlineCombines[num6]; outlineBuffer3.DrawMesh(((CombineInstance)(ref item)).mesh, Matrix4x4.identity, _outlineOccMat); } } } _outlineBuffer.SetGlobalFloat("unity_GUIZTestMode", 4f); mainCam.AddCommandBuffer((CameraEvent)20, _outlineBuffer); _outlineCameraTarget = mainCam; } public static void EnsureStencilMaterials() { if (!StencilMaterialsReady) { InitMaterials(); } } private static void SyncOccludedColor() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_outlineMat == (Object)null) && !((Object)(object)_outlineOccMat == (Object)null)) { Color color = _outlineMat.GetColor("_Color"); color.a = OutlineOccludedAlpha; _outlineOccMat.SetColor("_Color", color); } } public static Material CreateOutlineMaterial(Color color) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("UI/Default"); if ((Object)(object)val == (Object)null) { return null; } Material val2 = new Material(val); val2.SetColor("_Color", color); val2.SetInt("_Stencil", 1); val2.SetInt("_StencilComp", 6); val2.SetInt("_StencilOp", 0); val2.SetInt("_StencilWriteMask", 255); val2.SetInt("_StencilReadMask", 255); val2.SetInt("_ColorMask", 15); val2.renderQueue = 3000; return val2; } public static Material CreateOccludedOutlineMaterial(Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) return CreateOutlineMaterial(new Color(color.r, color.g, color.b, OutlineOccludedAlpha)); } public static void DrawRemoteOutline(IReadOnlyList targets, Material outlineMat, Material outlineOccMat, CommandBuffer buffer) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) if (targets == null || targets.Count == 0 || (Object)(object)outlineMat == (Object)null || buffer == null || !StencilMaterialsReady) { return; } if ((Object)(object)outlineOccMat != (Object)null) { Color color = outlineMat.GetColor("_Color"); color.a = OutlineOccludedAlpha; outlineOccMat.SetColor("_Color", color); } bool flag = OutlineOccludedAlpha > 0.01f && (Object)(object)outlineOccMat != (Object)null; _remoteOutlineShells.Clear(); _remoteOutlineMarks.Clear(); for (int i = 0; i < targets.Count; i++) { LevelEditorObject levelEditorObject = targets[i]; if ((Object)(object)levelEditorObject == (Object)null) { continue; } Il2CppArrayBase componentsInChildren = ((Component)levelEditorObject).GetComponentsInChildren(); if (componentsInChildren == null) { continue; } for (int j = 0; j < componentsInChildren.Length; j++) { MeshFilter val = componentsInChildren[j]; if ((Object)(object)val == (Object)null || (Object)(object)val.sharedMesh == (Object)null) { continue; } MeshRenderer component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && ((Renderer)component).enabled) { OutlineShellData orBuildOutlineShell = GetOrBuildOutlineShell(val.sharedMesh, ((Component)val).transform); if (!((Object)(object)orBuildOutlineShell.mesh == (Object)null)) { _remoteOutlineShells.Add(orBuildOutlineShell.mesh); _remoteOutlineMarks.Add((val.sharedMesh, ((Component)val).transform.localToWorldMatrix, val.sharedMesh.subMeshCount)); } } } } if (_remoteOutlineShells.Count == 0) { return; } buffer.SetGlobalFloat("unity_GUIZTestMode", 8f); for (int k = 0; k < _remoteOutlineShells.Count; k++) { buffer.DrawMesh(_remoteOutlineShells[k], Matrix4x4.identity, _stencilClearMat); } for (int l = 0; l < _remoteOutlineMarks.Count; l++) { (Mesh, Matrix4x4, int) tuple = _remoteOutlineMarks[l]; for (int m = 0; m < tuple.Item3; m++) { buffer.DrawMesh(tuple.Item1, tuple.Item2, _stencilMarkMat, m); } } buffer.SetGlobalFloat("unity_GUIZTestMode", 4f); for (int n = 0; n < _remoteOutlineShells.Count; n++) { buffer.DrawMesh(_remoteOutlineShells[n], Matrix4x4.identity, outlineMat); } if (flag) { buffer.SetGlobalFloat("unity_GUIZTestMode", 5f); for (int num = 0; num < _remoteOutlineShells.Count; num++) { buffer.DrawMesh(_remoteOutlineShells[num], Matrix4x4.identity, outlineOccMat); } } buffer.SetGlobalFloat("unity_GUIZTestMode", 4f); } private static void CollectOutlineMarks(IReadOnlyList selection) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < selection.Count; i++) { LevelEditorObject levelEditorObject = selection[i]; if ((Object)(object)levelEditorObject == (Object)null) { continue; } Il2CppArrayBase componentsInChildren = ((Component)levelEditorObject).GetComponentsInChildren(); if (componentsInChildren == null) { continue; } for (int j = 0; j < componentsInChildren.Length; j++) { MeshFilter val = componentsInChildren[j]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.sharedMesh == (Object)null)) { MeshRenderer component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && ((Renderer)component).enabled) { _outlineMarks.Add((val.sharedMesh, ((Component)val).transform.localToWorldMatrix, val.sharedMesh.subMeshCount)); } } } } } private static MeshData GetOrBuildMeshData(Mesh source) { if (_meshDataCache.TryGetValue(source, out var value)) { return value; } Il2CppStructArray vertices = source.vertices; Il2CppStructArray triangles = source.triangles; if (vertices == null || ((Il2CppArrayBase)(object)vertices).Length == 0 || triangles == null || ((Il2CppArrayBase)(object)triangles).Length == 0) { Mesh val = PhysicsObjectManager.BuildPhysicsMesh(source); if ((Object)(object)val == (Object)null) { return default(MeshData); } vertices = val.vertices; triangles = val.triangles; } MeshData meshData = new MeshData { verts = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)vertices), tris = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)triangles), smoothNormals = ComputeSmoothedNormals(Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)vertices), Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)triangles)) }; _meshDataCache[source] = meshData; return meshData; } private static OutlineShellData GetOrBuildOutlineShell(Mesh source, Transform t) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: 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_0239: 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) if ((Object)(object)source == (Object)null || (Object)(object)t == (Object)null) { return default(OutlineShellData); } int instanceID = ((Object)t).GetInstanceID(); int instanceID2 = ((Object)source).GetInstanceID(); if (_outlineShellCache.TryGetValue(instanceID, out var value) && (Object)(object)value.mesh != (Object)null && value.meshId == instanceID2 && value.position == t.position && value.rotation == t.rotation && value.scale == t.lossyScale && value.thickness == OutlineThickness) { return value; } MeshData orBuildMeshData = GetOrBuildMeshData(source); if (orBuildMeshData.verts == null || orBuildMeshData.tris == null || orBuildMeshData.smoothNormals == null) { return default(OutlineShellData); } Vector3[] array = (Vector3[])(object)new Vector3[orBuildMeshData.verts.Length]; for (int i = 0; i < orBuildMeshData.verts.Length; i++) { Vector3 val = t.TransformPoint(orBuildMeshData.verts[i]); Vector3 val2 = t.TransformDirection(orBuildMeshData.smoothNormals[i]); Vector3 normalized = ((Vector3)(ref val2)).normalized; array[i] = val + normalized * OutlineThickness; } Mesh val3 = (Mesh)(((Object)(object)value.mesh != (Object)null) ? ((object)value.mesh) : ((object)new Mesh { name = "PropOutlineShell" })); val3.Clear(false); val3.vertices = Il2CppStructArray.op_Implicit(array); val3.triangles = Il2CppStructArray.op_Implicit(orBuildMeshData.tris); Color[] array2 = (Color[])(object)new Color[array.Length]; for (int j = 0; j < array2.Length; j++) { array2[j] = Color.white; } val3.colors = Il2CppStructArray.op_Implicit(array2); val3.RecalculateBounds(); value.mesh = val3; value.meshId = instanceID2; value.position = t.position; value.rotation = t.rotation; value.scale = t.lossyScale; value.thickness = OutlineThickness; value.worldVerts = array; value.tris = orBuildMeshData.tris; _outlineShellCache[instanceID] = value; return value; } private static Vector3[] ComputeSmoothedNormals(Vector3[] verts, int[] tris) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[verts.Length]; for (int i = 0; i < tris.Length; i += 3) { int num = tris[i]; int num2 = tris[i + 1]; int num3 = tris[i + 2]; Vector3 val = Vector3.Cross(verts[num2] - verts[num], verts[num3] - verts[num]); ref Vector3 reference = ref array[num]; reference += val; ref Vector3 reference2 = ref array[num2]; reference2 += val; ref Vector3 reference3 = ref array[num3]; reference3 += val; } Dictionary<(int, int, int), Vector3> dictionary = new Dictionary<(int, int, int), Vector3>(verts.Length); for (int j = 0; j < verts.Length; j++) { (int, int, int) key = (Mathf.RoundToInt(verts[j].x * 8192f), Mathf.RoundToInt(verts[j].y * 8192f), Mathf.RoundToInt(verts[j].z * 8192f)); dictionary[key] = (dictionary.TryGetValue(key, out var value) ? (value + array[j]) : array[j]); } Vector3[] array2 = (Vector3[])(object)new Vector3[verts.Length]; for (int k = 0; k < verts.Length; k++) { (int, int, int) key2 = (Mathf.RoundToInt(verts[k].x * 8192f), Mathf.RoundToInt(verts[k].y * 8192f), Mathf.RoundToInt(verts[k].z * 8192f)); Vector3 value2; Vector3 val2 = (dictionary.TryGetValue(key2, out value2) ? value2 : array[k]); array2[k] = ((val2 == Vector3.zero) ? Vector3.up : ((Vector3)(ref val2)).normalized); } return array2; } private static void InitMeshes() { if ((Object)(object)_shaftMesh == (Object)null) { _shaftMesh = BorrowMesh((PrimitiveType)2); } if ((Object)(object)_sphereMesh == (Object)null) { _sphereMesh = BorrowMesh((PrimitiveType)0); } if ((Object)(object)_cubeTipMesh == (Object)null) { _cubeTipMesh = BorrowMesh((PrimitiveType)3); } if ((Object)(object)_coneTipMesh == (Object)null) { _coneTipMesh = BuildConeMesh(16); } if ((Object)(object)_ringMesh == (Object)null) { _ringMesh = BuildRingMesh(48, 0.65f, 0.5f); } } private static void InitMaterials() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Expected O, but got Unknown //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Expected O, but got Unknown //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Expected O, but got Unknown //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Expected O, but got Unknown //IL_0473: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Unlit/Color") ?? Shader.Find("Standard"); Color[] array = (Color[])(object)new Color[3] { new Color(0.9f, 0.2f, 0.2f), new Color(0.2f, 0.8f, 0.2f), new Color(0.2f, 0.45f, 1f) }; _mats = (Material[])(object)new Material[3]; _hoverMats = (Material[])(object)new Material[3]; for (int i = 0; i < 3; i++) { _mats[i] = MakeGizmoMat(val, array[i], 4000); _hoverMats[i] = MakeGizmoMat(val, Color.Lerp(array[i], Color.white, 0.45f), 4000); } _freeMat = MakeGizmoMat(val, new Color(0.72f, 0.72f, 0.72f), 4000); _freeHoverMat = MakeGizmoMat(val, Color.white, 4000); Color[] array2 = (Color[])(object)new Color[3] { array[2], array[0], array[1] }; _planeMats = (Material[])(object)new Material[3]; _planeHoverMats = (Material[])(object)new Material[3]; for (int j = 0; j < 3; j++) { _planeMats[j] = MakeGizmoMat(val, array2[j], 4000); _planeHoverMats[j] = MakeGizmoMat(val, Color.Lerp(array2[j], Color.white, 0.45f), 4000); } Shader val2 = Shader.Find("UI/Default") ?? val; _freeRotMat = new Material(val2); _freeRotMat.color = new Color(1f, 1f, 1f, 0.14f); _freeRotMat.SetInt("_ZTest", 8); _freeRotMat.renderQueue = 3999; _freeRotHoverMat = new Material(val2); _freeRotHoverMat.color = new Color(0.8f, 0.9f, 1f, 0.28f); _freeRotHoverMat.SetInt("_ZTest", 8); _freeRotHoverMat.renderQueue = 3999; Shader val3 = Shader.Find("UI/Default"); if ((Object)(object)val3 != (Object)null) { _stencilClearMat = new Material(val3); _stencilClearMat.SetInt("_Stencil", 0); _stencilClearMat.SetInt("_StencilComp", 8); _stencilClearMat.SetInt("_StencilOp", 2); _stencilClearMat.SetInt("_StencilWriteMask", 255); _stencilClearMat.SetInt("_StencilReadMask", 255); _stencilClearMat.SetInt("_ColorMask", 0); _stencilMarkMat = new Material(val3); _stencilMarkMat.SetInt("_Stencil", 1); _stencilMarkMat.SetInt("_StencilComp", 8); _stencilMarkMat.SetInt("_StencilOp", 2); _stencilMarkMat.SetInt("_StencilWriteMask", 255); _stencilMarkMat.SetInt("_StencilReadMask", 255); _stencilMarkMat.SetInt("_ColorMask", 0); Color val4 = default(Color); ((Color)(ref val4))..ctor(1f, 0.85f, 0.1f, 1f); _outlineMat = new Material(val3); _outlineMat.SetColor("_Color", val4); _outlineMat.SetInt("_Stencil", 1); _outlineMat.SetInt("_StencilComp", 6); _outlineMat.SetInt("_StencilOp", 0); _outlineMat.SetInt("_StencilWriteMask", 255); _outlineMat.SetInt("_StencilReadMask", 255); _outlineMat.SetInt("_ColorMask", 15); _outlineMat.renderQueue = 3000; Color val5 = default(Color); ((Color)(ref val5))..ctor(val4.r, val4.g, val4.b, OutlineOccludedAlpha); _outlineOccMat = new Material(val3); _outlineOccMat.SetColor("_Color", val5); _outlineOccMat.SetInt("_Stencil", 1); _outlineOccMat.SetInt("_StencilComp", 6); _outlineOccMat.SetInt("_StencilOp", 0); _outlineOccMat.SetInt("_StencilWriteMask", 255); _outlineOccMat.SetInt("_StencilReadMask", 255); _outlineOccMat.SetInt("_ColorMask", 15); _outlineOccMat.renderQueue = 3000; } } private static Material MakeGizmoMat(Shader shader, Color color, int queue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(shader); val.color = color; if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } val.renderQueue = queue; val.SetInt("_ZTest", 4); return val; } private static Camera BuildCam(float depth, float farClip = 500000f, CameraClearFlags clearFlags = (CameraClearFlags)3) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject($"GizmoOverlayCam_{depth}"); Object.DontDestroyOnLoad((Object)(object)val); Camera val2 = val.AddComponent(); val2.clearFlags = clearFlags; val2.cullingMask = Mask; val2.depth = depth; val2.nearClipPlane = 0.01f; val2.farClipPlane = farClip; ((Behaviour)val2).enabled = false; val.AddComponent(); return val2; } private static void BuildColliders() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Expected O, but got Unknown //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Expected O, but got Unknown //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Expected O, but got Unknown //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Expected O, but got Unknown //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Expected O, but got Unknown //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) _root = new GameObject("LevelEditorGizmo"); Object.DontDestroyOnLoad((Object)(object)_root); _arrowHandles = new GameObject("ArrowHandles"); _arrowHandles.transform.SetParent(_root.transform, false); for (int i = 0; i < 3; i++) { GameObject val = new GameObject($"GizmoPivot_{i}"); val.transform.SetParent(_arrowHandles.transform, false); val.transform.localRotation = PivotRots[i]; _axisPivots[i] = val.transform; GameObject val2 = new GameObject($"GizmoCol_{i}"); val2.transform.SetParent(val.transform, false); val2.transform.localPosition = new Vector3(0f, 0.35f, 0f); val2.transform.localScale = new Vector3(0.16f, 0.7f, 0.16f); val2.layer = 31; val2.AddComponent(); val2.AddComponent().axisIndex = i; } GameObject val3 = new GameObject("GizmoCol_Free"); val3.transform.SetParent(_arrowHandles.transform, false); val3.transform.localScale = Vector3.one * 0.22f; val3.layer = 31; val3.AddComponent(); val3.AddComponent().axisIndex = 3; Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(PlaneSizeMove * 0.5f, PlaneSizeMove * 0.5f, 0f); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(0f, PlaneSizeMove * 0.5f, (0f - PlaneSizeMove) * 0.5f); Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(PlaneSizeMove * 0.5f, 0f, (0f - PlaneSizeMove) * 0.5f); Vector3 val7 = default(Vector3); ((Vector3)(ref val7))..ctor(PlaneSizeMove, PlaneSizeMove, PlaneThickness); Vector3 val8 = default(Vector3); ((Vector3)(ref val8))..ctor(PlaneThickness, PlaneSizeMove, PlaneSizeMove); Vector3 val9 = default(Vector3); ((Vector3)(ref val9))..ctor(PlaneSizeMove, PlaneThickness, PlaneSizeMove); for (int j = 0; j < 3; j++) { GameObject val10 = new GameObject($"GizmoPlaneCol_{j}"); val10.transform.SetParent(_arrowHandles.transform, false); val10.transform.localPosition = (Vector3)(j switch { 1 => val5, 0 => val4, _ => val6, }); val10.transform.localScale = (Vector3)(j switch { 1 => val8, 0 => val7, _ => val9, }); val10.layer = 31; val10.AddComponent(); val10.AddComponent().axisIndex = 4 + j; _planeHandles[j] = val10.transform; } _ringHandles = new GameObject("RingHandles"); _ringHandles.transform.SetParent(_root.transform, false); _ringHandles.SetActive(false); for (int k = 0; k < 3; k++) { GameObject val11 = new GameObject($"GizmoRingPivot_{k}"); val11.transform.SetParent(_ringHandles.transform, false); val11.transform.localRotation = RingPivotRots[k]; GameObject val12 = new GameObject($"GizmoRingCol_{k}"); val12.transform.SetParent(val11.transform, false); val12.layer = 31; GizmoHandle gizmoHandle = val12.AddComponent(); gizmoHandle.axisIndex = k; _ringHandleRefs[k] = gizmoHandle; } GameObject val13 = new GameObject("GizmoCol_FreeRot"); val13.transform.SetParent(_ringHandles.transform, false); val13.transform.localScale = Vector3.one * 0.88f; val13.layer = 31; val13.AddComponent(); val13.AddComponent().axisIndex = 7; } private static Mesh BorrowMesh(PrimitiveType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive(type); Mesh sharedMesh = val.GetComponent().sharedMesh; Object.Destroy((Object)(object)val); return sharedMesh; } private static Mesh BuildConeMesh(int segments) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown Vector3[] array = (Vector3[])(object)new Vector3[segments + 2]; int[] array2 = new int[segments * 6]; array[0] = new Vector3(0f, 1f, 0f); array[1] = Vector3.zero; for (int i = 0; i < segments; i++) { float num = (float)Math.PI * 2f * (float)i / (float)segments; array[2 + i] = new Vector3(Mathf.Cos(num) * 0.5f, 0f, Mathf.Sin(num) * 0.5f); } for (int j = 0; j < segments; j++) { int num2 = 2 + j; int num3 = 2 + (j + 1) % segments; array2[j * 3] = 0; array2[j * 3 + 1] = num2; array2[j * 3 + 2] = num3; array2[segments * 3 + j * 3] = 1; array2[segments * 3 + j * 3 + 1] = num3; array2[segments * 3 + j * 3 + 2] = num2; } Mesh val = new Mesh(); val.vertices = Il2CppStructArray.op_Implicit(array); val.triangles = Il2CppStructArray.op_Implicit(array2); val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static Mesh BuildRingMesh(int segments, float outerRadius, float innerRadius) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown Vector3[] array = (Vector3[])(object)new Vector3[segments * 2]; int[] array2 = new int[segments * 12]; for (int i = 0; i < segments; i++) { float num = (float)Math.PI * 2f * (float)i / (float)segments; float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); array[i * 2] = new Vector3(num2 * outerRadius, 0f, num3 * outerRadius); array[i * 2 + 1] = new Vector3(num2 * innerRadius, 0f, num3 * innerRadius); } for (int j = 0; j < segments; j++) { int num4 = j * 2; int num5 = j * 2 + 1; int num6 = (j + 1) % segments * 2; int num7 = (j + 1) % segments * 2 + 1; array2[j * 6] = num4; array2[j * 6 + 1] = num6; array2[j * 6 + 2] = num5; array2[j * 6 + 3] = num5; array2[j * 6 + 4] = num6; array2[j * 6 + 5] = num7; int num8 = segments * 6 + j * 6; array2[num8] = num4; array2[num8 + 1] = num5; array2[num8 + 2] = num6; array2[num8 + 3] = num5; array2[num8 + 4] = num7; array2[num8 + 5] = num6; } Mesh val = new Mesh(); val.vertices = Il2CppStructArray.op_Implicit(array); val.triangles = Il2CppStructArray.op_Implicit(array2); val.RecalculateNormals(); val.RecalculateBounds(); return val; } public static Bounds GetSelectionBounds(IReadOnlyList selection) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) Bounds result = default(Bounds); bool flag = false; if (selection == null) { return result; } Bounds val = default(Bounds); for (int i = 0; i < selection.Count; i++) { LevelEditorObject levelEditorObject = selection[i]; if ((Object)(object)levelEditorObject == (Object)null) { continue; } if (PropLibrary.IsSpawnPointProp(levelEditorObject.addressableKey)) { ((Bounds)(ref val))..ctor(((Component)levelEditorObject).transform.position, Vector3.one); if (!flag) { result = val; flag = true; } else { ((Bounds)(ref result)).Encapsulate(val); } continue; } Il2CppArrayBase componentsInChildren = ((Component)levelEditorObject).GetComponentsInChildren(); if (componentsInChildren != null) { for (int j = 0; j < componentsInChildren.Length; j++) { Renderer val2 = componentsInChildren[j]; if ((Object)(object)val2 == (Object)null || !val2.enabled || !((Component)val2).gameObject.activeInHierarchy) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(size.x > 100f) && !(size.y > 100f) && !(size.z > 100f)) { if (!flag) { result = val2.bounds; flag = true; } else { ((Bounds)(ref result)).Encapsulate(val2.bounds); } } } } if (!flag) { ((Bounds)(ref result))..ctor(((Component)levelEditorObject).transform.position, Vector3.one); flag = true; } } return result; } public static Vector3 GetSelectionBoundsCenter(IReadOnlyList selection) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) if (selection == null || selection.Count == 0) { return Vector3.zero; } Vector3 val = Vector3.zero; int num = 0; for (int i = 0; i < selection.Count; i++) { LevelEditorObject levelEditorObject = selection[i]; if ((Object)(object)levelEditorObject == (Object)null) { continue; } if (PropLibrary.IsSpawnPointProp(levelEditorObject.addressableKey)) { val += ((Component)levelEditorObject).transform.position; num++; continue; } Il2CppArrayBase componentsInChildren = ((Component)levelEditorObject).GetComponentsInChildren(); Vector3 val2 = Vector3.zero; int num2 = 0; if (componentsInChildren != null) { for (int j = 0; j < componentsInChildren.Length; j++) { Renderer val3 = componentsInChildren[j]; if (!((Object)(object)val3 == (Object)null) && val3.enabled && ((Component)val3).gameObject.activeInHierarchy) { Bounds bounds = val3.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(size.x > 100f) && !(size.y > 100f) && !(size.z > 100f)) { Vector3 val4 = val2; bounds = val3.bounds; val2 = val4 + ((Bounds)(ref bounds)).center; num2++; } } } } val += ((num2 > 0) ? (val2 / (float)num2) : ((Component)levelEditorObject).transform.position); num++; } return (num > 0) ? (val / (float)num) : Vector3.zero; } } public static class LevelEditor { public enum ToolMode { Translate, Scale, Rotate } private struct CopyEntry { public string addressableKey; public PrimitiveType primType; public Vector3 offset; public Vector3 scale; public Quaternion rotation; public bool isAddressable; public int materialConstructionId; public PhysicsMode physicsMode; public bool sunglassesNeeded; public bool playerPassthrough; public bool freezeUntilHit; } public static ToolMode currentTool = ToolMode.Translate; public static LevelEditorObject selectedObject; public static bool LocalMode = true; private static readonly List _selection = new List(); private static bool _isDragging; private static int _dragAxis; private static Vector3 _dragStartPos; private static Vector3 _dragStartScale; private static Vector3 _dragStartHit; private static Vector3 _dragPlaneNormal; private static Vector3 _dragPivot; private static Quaternion _dragStartRot; private static Vector2 _dragStartMouse; private static Vector2 _rawMouseAccum; private static float _dragGizmoScale; private static Quaternion _accumulatedFreeRot; private static int _hoveredAxis = -1; private static bool _pivotLocked; private static readonly List _dragObjects = new List(); private static readonly List _dragStartPositions = new List(); private static readonly List _dragStartScales = new List(); private static readonly List _dragStartRotations = new List(); private static readonly List _dragScaleRoots = new List(); private static readonly List _dragStartRootScales = new List(); private static readonly List _dragStartRootPositions = new List(); private static readonly List _dragStartRootRotations = new List(); private static readonly List _dragStartLocalPositions = new List(); private static readonly HashSet _dragGroupScaleScratch = new HashSet(); private const float NetTransformSendIntervalSeconds = 0.15f; private const float NetTransformReliableIntervalSeconds = 1.5f; private static float _nextNetTransformSendTime; private static float _nextNetTransformReliableTime; private static List _lastBroadcastSelectedNetIds = new List(); private const float GhostSendIntervalSeconds = 0.15f; private const float GhostReliableIntervalSeconds = 1.5f; private static float _nextGhostSendTime; private static float _nextGhostReliableTime; private static readonly List _copyEntries = new List(); private static Vector3 _copyPivot; private static Vector3 _copyBoundsSize = Vector3.one; private static bool _copyHasValue; private static bool _snapEnabled = false; private const float SnapStep = 0.1f; private const float RotateSnapMultiplier = 100f; private static float _lastUnloadCheck; private const float UnloadCheckInterval = 15f; private static GameObject _propGhost; private static PropInfo _ghostProp; private static readonly Quaternion[] FaceUpRotations = (Quaternion[])(object)new Quaternion[6] { Quaternion.identity, Quaternion.Euler(180f, 0f, 0f), Quaternion.Euler(90f, 0f, 0f), Quaternion.Euler(-90f, 0f, 0f), Quaternion.Euler(0f, 0f, -90f), Quaternion.Euler(0f, 0f, 90f) }; private static readonly Quaternion[] DragOrientations = BuildDragOrientations(); private static int _dragStep; private const int DragReleaseDebounceFrames = 3; private static int _propDragReleaseFrames; private static int _matDragReleaseFrames; private const int GhostLayer = 16; public static bool isDragging => _isDragging; public static IReadOnlyList SelectedObjects => _selection; public static bool IsSurfaceSnapDragging => _isDragging && currentTool == ToolMode.Translate && _dragAxis == 3 && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)); public static bool IsTypingInUI => PropMetadataPanel.IsTypingInUI || ObjImportWindow.IsTypingInUI || PhysicsWindow.IsTypingInUI || PropBrowserUI.IsTypingInUI; public static bool IsDragging => _isDragging; public static bool SnapEnabled { get { return _snapEnabled; } set { _snapEnabled = value; } } private static Quaternion[] BuildDragOrientations() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Quaternion[] array = (Quaternion[])(object)new Quaternion[FaceUpRotations.Length * 4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < FaceUpRotations.Length; j++) { array[i * FaceUpRotations.Length + j] = FaceUpRotations[j] * Quaternion.Euler(0f, (float)i * 90f, 0f); } } return array; } public static void EnsureManager() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)LevelEditorManager.Instance != (Object)null)) { new GameObject("LevelEditorManager").AddComponent(); } } public static void HideGizmo() { GizmoRenderer.SetActive(on: false); } public static void SelectAll() { LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { return; } _selection.Clear(); foreach (LevelEditorObject @object in instance.Objects) { if ((Object)(object)@object != (Object)null) { _selection.Add(@object); } } selectedObject = ((_selection.Count > 0) ? _selection[_selection.Count - 1] : null); if (_selection.Count > 0 && !GizmoRenderer.IsReady) { GizmoRenderer.Init(); } } public static void Select(LevelEditorObject obj) { _selection.Clear(); if ((Object)(object)obj != (Object)null) { AddSelectionWithGroup(obj); selectedObject = obj; if (!GizmoRenderer.IsReady) { GizmoRenderer.Init(); } } else { selectedObject = null; } } private static void ToggleSelection(LevelEditorObject obj) { if ((Object)(object)obj == (Object)null) { return; } IEnumerable logicalGroupSelection = GetLogicalGroupSelection(obj); if (!logicalGroupSelection.Any((LevelEditorObject m) => (Object)(object)m != (Object)null && _selection.Contains(m))) { foreach (LevelEditorObject item in logicalGroupSelection) { if ((Object)(object)item != (Object)null && !_selection.Contains(item)) { _selection.Add(item); } } selectedObject = obj; } else { foreach (LevelEditorObject item2 in logicalGroupSelection) { _selection.Remove(item2); } if ((Object)(object)selectedObject == (Object)(object)obj) { selectedObject = ((_selection.Count > 0) ? _selection[_selection.Count - 1] : null); } } if (_selection.Count > 0 && !GizmoRenderer.IsReady) { GizmoRenderer.Init(); } } private static void AddSelectionWithGroup(LevelEditorObject obj) { foreach (LevelEditorObject item in GetLogicalGroupSelection(obj)) { if ((Object)(object)item != (Object)null && !_selection.Contains(item)) { _selection.Add(item); } } } private static IEnumerable GetLogicalGroupSelection(LevelEditorObject obj) { if ((Object)(object)obj == (Object)null) { yield break; } LevelEditorManager mgr = LevelEditorManager.Instance; if ((Object)(object)mgr != (Object)null && obj.groupId > 0) { foreach (LevelEditorObject logicalGroupMember in mgr.GetLogicalGroupMembers(obj.groupId)) { yield return logicalGroupMember; } } else { yield return obj; } } private static void ClearSelection() { _selection.Clear(); selectedObject = null; } public static void ClearAllSelectionState() { _selection.Clear(); selectedObject = null; _dragObjects.Clear(); _dragStartPositions.Clear(); _dragStartScales.Clear(); _dragStartRotations.Clear(); _isDragging = false; if (_pivotLocked) { GizmoRenderer.ClearPivotOverride(); _pivotLocked = false; } HideGizmo(); } public static void RemoveDeletedObject(LevelEditorObject obj) { if (!((Object)(object)obj == (Object)null)) { _selection.Remove(obj); if ((Object)(object)selectedObject == (Object)(object)obj) { selectedObject = ((_selection.Count > 0) ? _selection[_selection.Count - 1] : null); } if (_selection.Count == 0) { HideGizmo(); } int num = _dragObjects.IndexOf(obj); if (num >= 0) { _dragObjects.RemoveAt(num); _dragStartPositions.RemoveAt(num); _dragStartScales.RemoveAt(num); _dragStartRotations.RemoveAt(num); } } } internal static void PruneSelection() { for (int num = _selection.Count - 1; num >= 0; num--) { if ((Object)(object)_selection[num] == (Object)null) { _selection.RemoveAt(num); } } if ((Object)(object)selectedObject == (Object)null) { selectedObject = ((_selection.Count > 0) ? _selection[_selection.Count - 1] : null); } if (_selection.Count == 0) { HideGizmo(); } } public static void Update() { //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: 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_08f5: Unknown result type (might be due to invalid IL or missing references) //IL_0901: Unknown result type (might be due to invalid IL or missing references) //IL_093a: Unknown result type (might be due to invalid IL or missing references) //IL_094b: Unknown result type (might be due to invalid IL or missing references) //IL_095c: Unknown result type (might be due to invalid IL or missing references) //IL_082a: Unknown result type (might be due to invalid IL or missing references) //IL_083b: Unknown result type (might be due to invalid IL or missing references) //IL_084c: Unknown result type (might be due to invalid IL or missing references) //IL_07b7: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: 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_08c8: Unknown result type (might be due to invalid IL or missing references) //IL_08ba: Unknown result type (might be due to invalid IL or missing references) //IL_0742: Unknown result type (might be due to invalid IL or missing references) //IL_0772: Unknown result type (might be due to invalid IL or missing references) //IL_0764: Unknown result type (might be due to invalid IL or missing references) LevelEditorManager.Instance?.EnsurePropsContainer(); float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup - _lastUnloadCheck >= 15f) { _lastUnloadCheck = realtimeSinceStartup; PropLibrary.ProcessUnloadQueue(); } bool flag = IsTypingInUI || Core.IsKeyboardCaptured; bool flag2 = IsPointerOverUI(); if (!flag && Input.GetKeyDown((KeyCode)32) && (Object)(object)selectedObject != (Object)null) { currentTool = ((currentTool == ToolMode.Translate) ? ToolMode.Scale : ((currentTool == ToolMode.Scale) ? ToolMode.Rotate : ToolMode.Translate)); } if (!flag && Input.GetKeyDown((KeyCode)116)) { LocalMode = !LocalMode; } bool flag3 = !flag && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)); if (!flag && !flag3 && Input.GetKeyDown((KeyCode)121)) { _snapEnabled = !_snapEnabled; } if (!flag) { MaterialConstructionPanel.HandleScrollInput(); } GizmoRenderer.EnsureCamera(); Camera main = Camera.main; if ((Object)(object)main != (Object)null) { GizmoRenderer.Sync(_selection, selectedObject, currentTool, main); } UpdateHover(flag2); if (!IsSurfaceSnapDragging) { GizmoRenderer.Draw(_hoveredAxis, currentTool); } else { HideGizmo(); } if (_isDragging && currentTool == ToolMode.Translate && _dragObjects.Count > 0 && (Object)(object)_dragObjects[0] != (Object)null) { GizmoRenderer.SetTranslateDragDelta(((Component)_dragObjects[0]).transform.position - _dragStartPositions[0]); } else { GizmoRenderer.ClearDragDelta(); } GizmoRenderer.DrawOutline(IsSurfaceSnapDragging ? null : _selection, main); List list = new List(); for (int i = 0; i < _selection.Count; i++) { LevelEditorObject levelEditorObject = _selection[i]; if ((Object)(object)levelEditorObject != (Object)null && levelEditorObject.netId != 0) { list.Add(levelEditorObject.netId); } } if (!list.SequenceEqual(_lastBroadcastSelectedNetIds)) { ModNetworking.SendPropSelected(list); _lastBroadcastSelectedNetIds = list; } if (Input.GetMouseButton(1)) { return; } if (!flag && Input.GetKeyDown((KeyCode)127) && (Object)(object)selectedObject != (Object)null) { DeleteSelected(); } bool flag4 = flag3; bool flag5 = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); if (flag4 && Input.GetKeyDown((KeyCode)122)) { LevelEditorHistory.Undo(); } if (flag4 && Input.GetKeyDown((KeyCode)121)) { LevelEditorHistory.Redo(); } if (flag4 && Input.GetKeyDown((KeyCode)99)) { CopySelected(); } if (flag4 && flag5 && Input.GetKeyDown((KeyCode)118)) { PasteCopy(pasteInPlace: true); } else if (flag4 && !flag5 && Input.GetKeyDown((KeyCode)118)) { PasteCopy(); } if (PropPalette.IsDragging) { if (Input.GetMouseButton(0) || PropPalette.JustStartedDrag) { _propDragReleaseFrames = 0; if (Input.GetKeyDown((KeyCode)114)) { _dragStep = (_dragStep + 1) % DragOrientations.Length; } UpdatePropGhostForFrame(); } else if (++_propDragReleaseFrames >= 3) { if (flag2 || !TryDropProp()) { ModNetworking.SendPropGhostEnd(); } DestroyPropGhost(); PropPalette.CancelDrag(); _propDragReleaseFrames = 0; } else { UpdatePropGhostForFrame(); } return; } if (MaterialConstructionPanel.IsDragging) { if (Input.GetMouseButton(0) || MaterialConstructionPanel.JustStartedDrag) { _matDragReleaseFrames = 0; } else if (++_matDragReleaseFrames >= 3) { if (!flag2) { MaterialConstructionPanel.TryApplyToHoveredProp(); } MaterialConstructionPanel.CancelDrag(); _matDragReleaseFrames = 0; } return; } if (!flag2 && Input.GetMouseButtonDown(0)) { TryBeginDrag(); } if (!_isDragging) { return; } if (Input.GetMouseButton(0)) { if (IsSurfaceSnapDragging && Input.GetKeyDown((KeyCode)114)) { _dragStep = (_dragStep + 1) % DragOrientations.Length; } ContinueDrag(); BroadcastDragTransforms(); return; } _isDragging = false; if (_pivotLocked) { GizmoRenderer.ClearPivotOverride(); _pivotLocked = false; } if (_dragObjects.Count <= 0) { return; } if (currentTool == ToolMode.Scale || currentTool == ToolMode.Rotate) { HashSet hashSet = new HashSet(); for (int j = 0; j < _dragObjects.Count; j++) { LevelEditorObject levelEditorObject2 = _dragObjects[j]; GameObject val = ((j < _dragScaleRoots.Count) ? _dragScaleRoots[j] : null); if (!((Object)(object)levelEditorObject2 == (Object)null) && levelEditorObject2.groupId > 0 && !((Object)(object)val == (Object)null) && hashSet.Add(levelEditorObject2.groupId)) { ModNetworking.SendGroupRootTransform(levelEditorObject2.groupId); } } } HashSet hashSet2 = new HashSet(); bool flag6 = currentTool == ToolMode.Scale; bool flag7 = currentTool == ToolMode.Rotate; for (int k = 0; k < _dragObjects.Count; k++) { LevelEditorObject obj = _dragObjects[k]; if ((Object)(object)obj == (Object)null) { continue; } GameObject val2 = ((k < _dragScaleRoots.Count) ? _dragScaleRoots[k] : null); if (flag6 && (Object)(object)val2 != (Object)null) { if (obj.netId != 0) { ModNetworking.SendPropTransform(obj.netId, ((Component)obj).transform.position, ((Component)obj).transform.rotation, ((Component)obj).transform.localScale, reliable: true); } if (!hashSet2.Add(obj.groupId)) { continue; } List list2 = new List(); List list3 = new List(); List list4 = new List(); for (int l = 0; l < _dragObjects.Count; l++) { LevelEditorObject levelEditorObject3 = _dragObjects[l]; if (!((Object)(object)levelEditorObject3 == (Object)null) && levelEditorObject3.groupId == obj.groupId) { list2.Add(levelEditorObject3); list3.Add(_dragStartScales[l]); list4.Add((l < _dragStartLocalPositions.Count) ? _dragStartLocalPositions[l] : ((Component)levelEditorObject3).transform.localPosition); } } LevelEditorHistory.PushGroupScale(obj.groupId, val2, list2.ToArray(), _dragStartRootPositions[k], _dragStartRootScales[k], list3.ToArray(), list4.ToArray()); } else if (flag7 && (Object)(object)val2 != (Object)null) { if (obj.netId != 0) { ModNetworking.SendPropTransform(obj.netId, ((Component)obj).transform.position, ((Component)obj).transform.rotation, ((Component)obj).transform.localScale, reliable: true); } if (hashSet2.Add(obj.groupId)) { LevelEditorObject[] members = _dragObjects.Where((LevelEditorObject m) => (Object)(object)m != (Object)null && m.groupId == obj.groupId).ToArray(); LevelEditorHistory.PushGroupRotate(obj.groupId, val2, members, _dragStartRootPositions[k], (k < _dragStartRootRotations.Count) ? _dragStartRootRotations[k] : Quaternion.identity); } } else { LevelEditorHistory.PushTransform(obj, _dragStartPositions[k], _dragStartScales[k], _dragStartRotations[k]); if (obj.netId != 0) { ModNetworking.SendPropTransform(obj.netId, ((Component)obj).transform.position, ((Component)obj).transform.rotation, ((Component)obj).transform.localScale, reliable: true); } } } if ((Object)(object)LevelEditorManager.Instance != (Object)null) { LevelEditorManager.Instance.SyncLoopBases(_dragObjects); } } public static void OnGUI() { //IL_0211: 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_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) if (Core.DebugMode) { PropPalette.DrawGUI(Event.current); } PropMetadataPanel.DrawGUI(selectedObject); SaveLoadWindow.DrawGUI(Event.current); PhysicsWindow.DrawGUI(Event.current); ObjImportWindow.DrawGUI(Event.current); MaterialInspectorPanel.DrawGUI(); string value = ((currentTool == ToolMode.Translate) ? "MOVE" : ((currentTool == ToolMode.Scale) ? "SCALE" : "ROTATE")); string value2 = (LocalMode ? "LOCAL" : "GLOBAL"); string value3 = (_snapEnabled ? " [SNAP]" : ""); string text = (((Object)(object)selectedObject != (Object)null) ? $"LEVEL EDITOR [{value}] [{value2}]{value3} | Space=cycle tool T=local/global Y=snap Del=delete | R=teleport mode `=exit to player | LMB=teleport RMB=orbit" : "LEVEL EDITOR | Drag a prop from the palette onto the terrain | R=edit mode `=exit to player | LMB=teleport RMB=orbit"); if (Core.DebugMode) { IReadOnlyList filteredProps = PropLibrary.FilteredProps; int count = filteredProps.Count; int num = 0; for (int i = 0; i < count; i++) { if (PropMetadataStore.HasMetadata(filteredProps[i].id)) { num++; } } float value4 = ((count > 0) ? ((float)num * 100f / (float)count) : 0f); text += $" | {num}/{count} ({value4:F1}%)"; } float num2 = (float)Screen.width - 20f; GUI.color = new Color(0f, 0f, 0f, 0.6f); GUI.Box(new Rect(10f, (float)(Screen.height - 28), num2, 22f), ""); GUI.color = Color.white; GUI.Label(new Rect(14f, (float)(Screen.height - 27), num2 - 8f, 20f), text); GUI.color = Color.white; } private static void UpdateHover(bool overUI) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (overUI || !GizmoRenderer.IsReady || (Object)(object)selectedObject == (Object)null || Input.GetMouseButton(1)) { _hoveredAxis = -1; return; } if (_isDragging) { _hoveredAxis = _dragAxis; return; } GizmoHandle gizmoHandle = GizmoRenderer.RaycastHandle(Camera.main.ScreenPointToRay(Input.mousePosition)); _hoveredAxis = (((Object)(object)gizmoHandle != (Object)null) ? gizmoHandle.axisIndex : (-1)); } public static void ClearRemoteSelectionBroadcast() { if (_lastBroadcastSelectedNetIds.Count != 0) { ModNetworking.SendPropSelected(new List()); _lastBroadcastSelectedNetIds = new List(); } } private static bool IsPointerOverUI() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0077: Unknown result type (might be due to invalid IL or missing references) if (PropBrowserUI.IsPointerOverPanel()) { return true; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y); Rect panelRect = PropPalette.PanelRect; if (((Rect)(ref panelRect)).Contains(val)) { return true; } if (PropMetadataPanel.ContainsPoint(val)) { return true; } if (SaveLoadWindow.ContainsPoint(val)) { return true; } if (PhysicsWindow.ContainsPoint(val)) { return true; } if (ObjImportWindow.ContainsPoint(val)) { return true; } return false; } private static bool TryDropProp() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) Ray val = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = default(RaycastHit); if (!Physics.Raycast(val, ref hit, 2000f, LayerMask.op_Implicit(LayerCache.PropTerrainMask))) { return false; } PropInfo draggingProp = PropPalette.DraggingProp; if (draggingProp == null) { return false; } EnsureManager(); PropLibrary.LoadPropData(draggingProp); Quaternion rotation = ComputeDragRotation(((RaycastHit)(ref hit)).normal) * DragOrientations[_dragStep]; Vector3 position = ComputeSpawnPosition(draggingProp, hit, rotation); LevelEditorObject levelEditorObject = LevelEditorManager.Instance.SpawnFromPropInfo(draggingProp, position); if ((Object)(object)levelEditorObject == (Object)null) { return false; } ((Component)levelEditorObject).transform.rotation = rotation; Select(levelEditorObject); LevelEditorHistory.PushSpawn(levelEditorObject); ulong netId = ModNetworking.RegisterNetworkedObject(levelEditorObject); ModNetworking.SendPropPlaced(netId, draggingProp.id, ((Component)levelEditorObject).transform.position, ((Component)levelEditorObject).transform.rotation, ((Component)levelEditorObject).transform.localScale); return true; } private static Quaternion ComputeDragRotation(Vector3 normal) { //IL_0026: 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_001f: 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_002e: Unknown result type (might be due to invalid IL or missing references) return (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) ? Quaternion.identity : ComputeSpawnRotation(normal); } private static Quaternion ComputeSpawnRotation(Vector3 normal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_003c: Unknown result type (might be due to invalid IL or missing references) if (Vector3.Dot(normal, Vector3.up) < -0.999f) { return Quaternion.Euler(180f, 0f, 0f); } return Quaternion.FromToRotation(Vector3.up, normal); } private static Vector3 ComputeSpawnPosition(PropInfo prop, RaycastHit hit, Quaternion rotation, Vector3? scale = null) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) Bounds? propBounds = PropLibrary.GetPropBounds(prop); if (!propBounds.HasValue) { return ((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * 0.5f; } Vector3 val = (Vector3)(((??)scale) ?? Vector3.one); Vector3 normal = ((RaycastHit)(ref hit)).normal; Bounds value = propBounds.Value; Vector3 val2 = rotation * Vector3.Scale(((Bounds)(ref value)).center, val); value = propBounds.Value; Vector3 extents = ((Bounds)(ref value)).extents; float num = Mathf.Abs(Vector3.Dot(rotation * new Vector3(extents.x * val.x, 0f, 0f), normal)) + Mathf.Abs(Vector3.Dot(rotation * new Vector3(0f, extents.y * val.y, 0f), normal)) + Mathf.Abs(Vector3.Dot(rotation * new Vector3(0f, 0f, extents.z * val.z), normal)); return ((RaycastHit)(ref hit)).point - val2 + normal * num; } private static void UpdatePropGhostForFrame() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) PropInfo draggingProp = PropPalette.DraggingProp; if (draggingProp == null) { DestroyPropGhost(); return; } if ((Object)(object)_propGhost == (Object)null || _ghostProp != draggingProp) { DestroyPropGhost(); PropLibrary.LoadPropData(draggingProp); if (draggingProp.HasMesh) { _propGhost = CreateGhostObject(draggingProp); _ghostProp = draggingProp; } _nextGhostSendTime = 0f; _nextGhostReliableTime = 0f; } if ((Object)(object)_propGhost == (Object)null) { return; } Ray val = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = default(RaycastHit); if (Physics.Raycast(val, ref hit, 2000f, LayerMask.op_Implicit(LayerCache.PropTerrainMask))) { Quaternion val2 = ComputeDragRotation(((RaycastHit)(ref hit)).normal) * DragOrientations[_dragStep]; _propGhost.SetActive(true); _propGhost.transform.SetPositionAndRotation(ComputeSpawnPosition(_ghostProp, hit, val2), val2); float unscaledTime = Time.unscaledTime; if (unscaledTime >= _nextGhostSendTime) { bool flag = unscaledTime >= _nextGhostReliableTime; ModNetworking.SendPropGhostUpdate(_ghostProp.id, _propGhost.transform.position, _propGhost.transform.rotation, _propGhost.transform.localScale, flag); _nextGhostSendTime = unscaledTime + 0.15f; if (flag) { _nextGhostReliableTime = unscaledTime + 1.5f; } } } else { _propGhost.SetActive(false); } } private static void DestroyPropGhost() { if ((Object)(object)_propGhost != (Object)null) { Object.Destroy((Object)(object)_propGhost); _propGhost = null; } _ghostProp = null; } internal static GameObject CreateGhostObject(PropInfo prop) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("__PropGhost__"); val.layer = 16; for (int i = 0; i < prop.parts.Count; i++) { PropMeshPart propMeshPart = prop.parts[i]; if (!((Object)(object)propMeshPart?.mesh == (Object)null)) { GameObject val2 = new GameObject($"Part_{i}"); val2.layer = 16; val2.transform.SetParent(val.transform, false); val2.transform.localPosition = propMeshPart.localPosition; val2.transform.localRotation = propMeshPart.localRotation; val2.transform.localScale = propMeshPart.localScale; val2.AddComponent().mesh = propMeshPart.mesh; MeshRenderer val3 = val2.AddComponent(); if (propMeshPart.materials != null) { ((Renderer)val3).sharedMaterials = Il2CppReferenceArray.op_Implicit(propMeshPart.materials); } } } MaterialCatalog.ApplyMaterialOverridesToRoot(prop.id, val); PropInstanceServices.ApplyDisabledRenderersToRoot(prop.id, val); if (PropLibrary.IsNegativeCollisionProp(prop.id)) { foreach (MeshRenderer componentsInChild in val.GetComponentsInChildren(true)) { ((Renderer)componentsInChild).forceRenderingOff = true; ((Renderer)componentsInChild).enabled = false; } GhostCubeConfig.BuildFrame(val); } if (PropLibrary.IsSpawnPointProp(prop.id)) { foreach (MeshRenderer componentsInChild2 in val.GetComponentsInChildren(true)) { ((Renderer)componentsInChild2).forceRenderingOff = true; ((Renderer)componentsInChild2).enabled = false; } SpawnPointConfig.BuildMarker(val); } return val; } private static void TryBeginDrag() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: 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_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: 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_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058a: 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_0595: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: 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_05c3: 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_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: 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_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_063e: 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_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) Ray val = Camera.main.ScreenPointToRay(Input.mousePosition); GizmoHandle gizmoHandle = (((Object)(object)selectedObject != (Object)null) ? GizmoRenderer.RaycastHandle(val) : null); if ((Object)(object)gizmoHandle == (Object)null) { LevelEditorObject levelEditorObject = null; float num = float.MaxValue; foreach (RaycastHit item in (Il2CppArrayBase)(object)Physics.RaycastAll(val, 2000f, ~GizmoRenderer.Mask, (QueryTriggerInteraction)2)) { RaycastHit current = item; if (!(((RaycastHit)(ref current)).distance >= num)) { LevelEditorObject levelEditorObject2 = ((Component)((RaycastHit)(ref current)).collider).GetComponent() ?? ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent(); if (!((Object)(object)levelEditorObject2 == (Object)null)) { num = ((RaycastHit)(ref current)).distance; levelEditorObject = levelEditorObject2; } } } if ((Object)(object)levelEditorObject != (Object)null) { if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { ToggleSelection(levelEditorObject); } else { Select(levelEditorObject); } } else if (!Input.GetKey((KeyCode)304) && !Input.GetKey((KeyCode)303)) { ClearSelection(); } return; } _isDragging = true; _dragAxis = gizmoHandle.axisIndex; _dragStep = 0; _dragStartPos = ((Component)selectedObject).transform.position; _dragStartScale = ((Component)selectedObject).transform.localScale; _dragStartRot = ((Component)selectedObject).transform.rotation; _dragStartMouse = new Vector2(Input.mousePosition.x, Input.mousePosition.y); _rawMouseAccum = Vector2.zero; _dragPivot = GizmoRenderer.PivotPosition; if (currentTool == ToolMode.Rotate) { GizmoRenderer.SetPivotOverride(_dragPivot); _pivotLocked = true; } _dragObjects.Clear(); _dragStartPositions.Clear(); _dragStartScales.Clear(); _dragStartRotations.Clear(); _dragScaleRoots.Clear(); _dragStartRootScales.Clear(); _dragStartRootPositions.Clear(); _dragStartRootRotations.Clear(); _dragStartLocalPositions.Clear(); for (int i = 0; i < _selection.Count; i++) { LevelEditorObject levelEditorObject3 = _selection[i]; if (!((Object)(object)levelEditorObject3 == (Object)null)) { _dragObjects.Add(levelEditorObject3); _dragStartPositions.Add(((Component)levelEditorObject3).transform.position); _dragStartScales.Add(((Component)levelEditorObject3).transform.localScale); _dragStartRotations.Add(((Component)levelEditorObject3).transform.rotation); GameObject val2 = ((levelEditorObject3.groupId > 0) ? GroupManager.GetGroupRoot(levelEditorObject3.groupId) : null); _dragScaleRoots.Add(val2); _dragStartRootScales.Add((Vector3)(((Object)(object)val2 != (Object)null) ? GroupManager.GetGroupDisplayScale(levelEditorObject3.groupId) : default(Vector3))); _dragStartRootPositions.Add((Vector3)(((Object)(object)val2 != (Object)null) ? val2.transform.position : default(Vector3))); _dragStartRootRotations.Add((Quaternion)(((Object)(object)val2 != (Object)null) ? val2.transform.rotation : default(Quaternion))); _dragStartLocalPositions.Add(((Object)(object)val2 != (Object)null) ? ((Component)levelEditorObject3).transform.localPosition : Vector3.zero); } } Camera main = Camera.main; if (currentTool == ToolMode.Rotate) { if (_dragAxis == 7) { _accumulatedFreeRot = Quaternion.identity; return; } ? val3; if (!LocalMode || !((Object)(object)selectedObject != (Object)null)) { val3 = Quaternion.identity; } else if (selectedObject.groupId <= 0) { val3 = ((Component)selectedObject).transform.rotation; } else { GameObject groupRoot = GroupManager.GetGroupRoot(selectedObject.groupId); val3 = ((groupRoot != null) ? groupRoot.transform.rotation : Quaternion.identity); } Quaternion val4 = (Quaternion)val3; _dragPlaneNormal = val4 * AxisVec(_dragAxis); Plane val5 = default(Plane); ((Plane)(ref val5))..ctor(_dragPlaneNormal, _dragPivot); float num2 = default(float); if (((Plane)(ref val5)).Raycast(val, ref num2)) { _dragStartHit = ((Ray)(ref val)).GetPoint(num2); } Vector3 val6 = main.WorldToScreenPoint(_dragPivot); _dragStartMouse = new Vector2(Input.mousePosition.x, Input.mousePosition.y) - new Vector2(val6.x, val6.y); return; } Vector3 normal; if (_dragAxis == 3) { _dragPlaneNormal = ((Component)main).transform.forward; } else if (TryGetPlaneNormal(_dragAxis, out normal)) { _dragPlaneNormal = (LocalMode ? (((Component)selectedObject).transform.rotation * normal) : normal); } else { Vector3 val7 = (LocalMode ? (((Component)selectedObject).transform.rotation * AxisVec(_dragAxis)) : AxisVec(_dragAxis)); Vector3 forward = ((Component)main).transform.forward; Vector3 val8 = forward - Vector3.Dot(forward, val7) * val7; if (((Vector3)(ref val8)).sqrMagnitude < 0.01f) { Vector3 up = ((Component)main).transform.up; val8 = up - Vector3.Dot(up, val7) * val7; } _dragPlaneNormal = ((Vector3)(ref val8)).normalized; } Plane val9 = default(Plane); ((Plane)(ref val9))..ctor(_dragPlaneNormal, _dragPivot); float num3 = default(float); if (((Plane)(ref val9)).Raycast(val, ref num3)) { _dragStartHit = ((Ray)(ref val)).GetPoint(num3); } if (currentTool == ToolMode.Scale && (Object)(object)selectedObject != (Object)null) { float num4 = Vector3.Distance(((Component)main).transform.position, _dragPivot); _dragGizmoScale = Mathf.Max(num4 * 0.14f, 0.02f); } } private static void BroadcastDragTransforms() { //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (_dragObjects.Count == 0) { return; } float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextNetTransformSendTime) { return; } bool flag = unscaledTime >= _nextNetTransformReliableTime; if (currentTool == ToolMode.Scale || currentTool == ToolMode.Rotate) { _dragGroupScaleScratch.Clear(); for (int i = 0; i < _dragObjects.Count; i++) { LevelEditorObject levelEditorObject = _dragObjects[i]; GameObject val = ((i < _dragScaleRoots.Count) ? _dragScaleRoots[i] : null); if (!((Object)(object)levelEditorObject == (Object)null) && levelEditorObject.groupId > 0 && !((Object)(object)val == (Object)null) && _dragGroupScaleScratch.Add(levelEditorObject.groupId)) { ModNetworking.SendGroupRootTransform(levelEditorObject.groupId, flag); } } } for (int j = 0; j < _dragObjects.Count; j++) { LevelEditorObject levelEditorObject2 = _dragObjects[j]; if (!((Object)(object)levelEditorObject2 == (Object)null) && levelEditorObject2.netId != 0) { ModNetworking.SendPropTransform(levelEditorObject2.netId, ((Component)levelEditorObject2).transform.position, ((Component)levelEditorObject2).transform.rotation, ((Component)levelEditorObject2).transform.localScale, flag); } } _nextNetTransformSendTime = unscaledTime + 0.15f; if (flag) { _nextNetTransformReliableTime = unscaledTime + 1.5f; } } private static void ContinueDrag() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: 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_05b7: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: 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_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_061e: Unknown result type (might be due to invalid IL or missing references) //IL_0623: Unknown result type (might be due to invalid IL or missing references) //IL_062b: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_0640: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_0bc1: Unknown result type (might be due to invalid IL or missing references) //IL_0ae2: Unknown result type (might be due to invalid IL or missing references) //IL_0a9d: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0bdf: Unknown result type (might be due to invalid IL or missing references) //IL_0c0a: Unknown result type (might be due to invalid IL or missing references) //IL_0c0c: Unknown result type (might be due to invalid IL or missing references) //IL_0c13: Unknown result type (might be due to invalid IL or missing references) //IL_0c18: Unknown result type (might be due to invalid IL or missing references) //IL_0c1d: Unknown result type (might be due to invalid IL or missing references) //IL_0c1f: Unknown result type (might be due to invalid IL or missing references) //IL_0c21: Unknown result type (might be due to invalid IL or missing references) //IL_0c23: Unknown result type (might be due to invalid IL or missing references) //IL_0c2a: Unknown result type (might be due to invalid IL or missing references) //IL_0b08: Unknown result type (might be due to invalid IL or missing references) //IL_0b0a: Unknown result type (might be due to invalid IL or missing references) //IL_0b11: Unknown result type (might be due to invalid IL or missing references) //IL_0b16: Unknown result type (might be due to invalid IL or missing references) //IL_0b1b: Unknown result type (might be due to invalid IL or missing references) //IL_0b20: Unknown result type (might be due to invalid IL or missing references) //IL_0b25: Unknown result type (might be due to invalid IL or missing references) //IL_0b27: Unknown result type (might be due to invalid IL or missing references) //IL_0b2c: Unknown result type (might be due to invalid IL or missing references) //IL_0b31: Unknown result type (might be due to invalid IL or missing references) //IL_0b36: Unknown result type (might be due to invalid IL or missing references) //IL_0b38: Unknown result type (might be due to invalid IL or missing references) //IL_0b3d: Unknown result type (might be due to invalid IL or missing references) //IL_0b3f: Unknown result type (might be due to invalid IL or missing references) //IL_0b44: Unknown result type (might be due to invalid IL or missing references) //IL_0866: Unknown result type (might be due to invalid IL or missing references) //IL_0732: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0c05: Unknown result type (might be due to invalid IL or missing references) //IL_0bf9: Unknown result type (might be due to invalid IL or missing references) //IL_0b03: Unknown result type (might be due to invalid IL or missing references) //IL_0af6: Unknown result type (might be due to invalid IL or missing references) //IL_0884: Unknown result type (might be due to invalid IL or missing references) //IL_08af: Unknown result type (might be due to invalid IL or missing references) //IL_08b1: 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_08ba: Unknown result type (might be due to invalid IL or missing references) //IL_08bf: Unknown result type (might be due to invalid IL or missing references) //IL_08c1: 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_08ca: Unknown result type (might be due to invalid IL or missing references) //IL_08cf: Unknown result type (might be due to invalid IL or missing references) //IL_08d2: Unknown result type (might be due to invalid IL or missing references) //IL_08d7: Unknown result type (might be due to invalid IL or missing references) //IL_08dc: Unknown result type (might be due to invalid IL or missing references) //IL_08e1: Unknown result type (might be due to invalid IL or missing references) //IL_08e6: Unknown result type (might be due to invalid IL or missing references) //IL_08e8: Unknown result type (might be due to invalid IL or missing references) //IL_08ed: Unknown result type (might be due to invalid IL or missing references) //IL_08f7: Unknown result type (might be due to invalid IL or missing references) //IL_0900: Unknown result type (might be due to invalid IL or missing references) //IL_0905: Unknown result type (might be due to invalid IL or missing references) //IL_0907: Unknown result type (might be due to invalid IL or missing references) //IL_090c: Unknown result type (might be due to invalid IL or missing references) //IL_0916: Unknown result type (might be due to invalid IL or missing references) //IL_0926: Unknown result type (might be due to invalid IL or missing references) //IL_092b: Unknown result type (might be due to invalid IL or missing references) //IL_092d: Unknown result type (might be due to invalid IL or missing references) //IL_0932: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Unknown result type (might be due to invalid IL or missing references) //IL_0945: Unknown result type (might be due to invalid IL or missing references) //IL_094a: Unknown result type (might be due to invalid IL or missing references) //IL_094c: Unknown result type (might be due to invalid IL or missing references) //IL_0951: Unknown result type (might be due to invalid IL or missing references) //IL_095b: Unknown result type (might be due to invalid IL or missing references) //IL_0968: Unknown result type (might be due to invalid IL or missing references) //IL_0969: Unknown result type (might be due to invalid IL or missing references) //IL_096e: Unknown result type (might be due to invalid IL or missing references) //IL_0973: Unknown result type (might be due to invalid IL or missing references) //IL_0975: Unknown result type (might be due to invalid IL or missing references) //IL_097c: Unknown result type (might be due to invalid IL or missing references) //IL_0984: Unknown result type (might be due to invalid IL or missing references) //IL_098b: Unknown result type (might be due to invalid IL or missing references) //IL_0758: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_0761: Unknown result type (might be due to invalid IL or missing references) //IL_0766: Unknown result type (might be due to invalid IL or missing references) //IL_076b: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_0774: Unknown result type (might be due to invalid IL or missing references) //IL_0779: Unknown result type (might be due to invalid IL or missing references) //IL_077e: Unknown result type (might be due to invalid IL or missing references) //IL_0780: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_0784: 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_078b: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Unknown result type (might be due to invalid IL or missing references) //IL_0799: Unknown result type (might be due to invalid IL or missing references) //IL_079b: Unknown result type (might be due to invalid IL or missing references) //IL_07a0: Unknown result type (might be due to invalid IL or missing references) //IL_07a5: Unknown result type (might be due to invalid IL or missing references) //IL_07aa: 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_07b1: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_07b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_08aa: Unknown result type (might be due to invalid IL or missing references) //IL_089e: Unknown result type (might be due to invalid IL or missing references) //IL_0a90: Unknown result type (might be due to invalid IL or missing references) //IL_09ae: Unknown result type (might be due to invalid IL or missing references) //IL_09b5: 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_09d2: Unknown result type (might be due to invalid IL or missing references) //IL_09d9: Unknown result type (might be due to invalid IL or missing references) //IL_09e1: 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_09f6: Unknown result type (might be due to invalid IL or missing references) //IL_09fa: Unknown result type (might be due to invalid IL or missing references) //IL_09ff: Unknown result type (might be due to invalid IL or missing references) //IL_0a03: Unknown result type (might be due to invalid IL or missing references) //IL_0a08: Unknown result type (might be due to invalid IL or missing references) //IL_0a0d: Unknown result type (might be due to invalid IL or missing references) //IL_0753: Unknown result type (might be due to invalid IL or missing references) //IL_0746: Unknown result type (might be due to invalid IL or missing references) //IL_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_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0a3a: Unknown result type (might be due to invalid IL or missing references) //IL_0a3f: Unknown result type (might be due to invalid IL or missing references) //IL_0a41: Unknown result type (might be due to invalid IL or missing references) //IL_0a46: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_056b: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0a63: Unknown result type (might be due to invalid IL or missing references) //IL_0a53: Unknown result type (might be due to invalid IL or missing references) //IL_0a55: Unknown result type (might be due to invalid IL or missing references) //IL_0a5a: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0513: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)selectedObject == (Object)null) { _isDragging = false; return; } Camera main = Camera.main; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Input.mousePosition.x, Input.mousePosition.y); if (currentTool == ToolMode.Scale) { _rawMouseAccum += new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")) * 10f; } Vector3 val3; if (currentTool == ToolMode.Rotate && _dragAxis == 7) { Vector2 val2 = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")) * 10f; if (((Vector2)(ref val2)).sqrMagnitude > 0.0001f) { val3 = ((Component)main).transform.TransformDirection(0f - val2.y, val2.x, 0f); Vector3 normalized = ((Vector3)(ref val3)).normalized; float num = ((Vector2)(ref val2)).magnitude * 0.3f; _accumulatedFreeRot = Quaternion.AngleAxis(num, normalized) * _accumulatedFreeRot; } HashSet hashSet = new HashSet(); for (int i = 0; i < _dragObjects.Count; i++) { LevelEditorObject levelEditorObject = _dragObjects[i]; if ((Object)(object)levelEditorObject == (Object)null) { continue; } GameObject val4 = ((i < _dragScaleRoots.Count) ? _dragScaleRoots[i] : null); Quaternion val5 = ((!((Object)(object)val4 != (Object)null)) ? _dragStartRotations[i] : ((i < _dragStartRootRotations.Count) ? _dragStartRootRotations[i] : Quaternion.identity)); Quaternion val7; Quaternion val8; if (_snapEnabled) { Quaternion val6 = _accumulatedFreeRot * val5; Vector3 eulerAngles = ((Quaternion)(ref val6)).eulerAngles; eulerAngles.x = SnapAngleValue(eulerAngles.x); eulerAngles.y = SnapAngleValue(eulerAngles.y); eulerAngles.z = SnapAngleValue(eulerAngles.z); val7 = Quaternion.Euler(eulerAngles); val8 = val7 * Quaternion.Inverse(val5); } else { val7 = _accumulatedFreeRot * val5; val8 = _accumulatedFreeRot; } if ((Object)(object)val4 != (Object)null) { if (hashSet.Add(((Object)val4).GetInstanceID())) { val4.transform.rotation = val7; Vector3 val9 = ((i < _dragStartRootPositions.Count) ? _dragStartRootPositions[i] : val4.transform.position) - _dragPivot; val4.transform.position = _dragPivot + val8 * val9; } } else { ((Component)levelEditorObject).transform.rotation = val7; Vector3 val10 = _dragStartPositions[i] - _dragPivot; ((Component)levelEditorObject).transform.position = _dragPivot + val8 * val10; } } return; } if (currentTool == ToolMode.Rotate) { Ray val11 = main.ScreenPointToRay(Input.mousePosition); Plane val12 = default(Plane); ((Plane)(ref val12))..ctor(_dragPlaneNormal, _dragPivot); float num2 = default(float); if (!((Plane)(ref val12)).Raycast(val11, ref num2)) { return; } Vector3 point = ((Ray)(ref val11)).GetPoint(num2); Vector3 val13 = _dragStartHit - _dragPivot; Vector3 val14 = point - _dragPivot; if (((Vector3)(ref val13)).sqrMagnitude < 0.001f || ((Vector3)(ref val14)).sqrMagnitude < 0.001f) { return; } float num3 = Vector3.SignedAngle(val13, val14, _dragPlaneNormal); if (_snapEnabled) { num3 = SnapAngleValue(num3); } Quaternion val15 = Quaternion.AngleAxis(num3, _dragPlaneNormal); HashSet hashSet2 = new HashSet(); for (int j = 0; j < _dragObjects.Count; j++) { LevelEditorObject levelEditorObject2 = _dragObjects[j]; if ((Object)(object)levelEditorObject2 == (Object)null) { continue; } GameObject val16 = ((j < _dragScaleRoots.Count) ? _dragScaleRoots[j] : null); if ((Object)(object)val16 != (Object)null) { if (hashSet2.Add(((Object)val16).GetInstanceID())) { Quaternion val17 = ((j < _dragStartRootRotations.Count) ? _dragStartRootRotations[j] : val16.transform.rotation); val16.transform.rotation = val15 * val17; Vector3 val18 = ((j < _dragStartRootPositions.Count) ? _dragStartRootPositions[j] : val16.transform.position) - _dragPivot; val16.transform.position = _dragPivot + val15 * val18; } } else { ((Component)levelEditorObject2).transform.rotation = val15 * _dragStartRotations[j]; Vector3 val19 = _dragStartPositions[j] - _dragPivot; ((Component)levelEditorObject2).transform.position = _dragPivot + val15 * val19; } } SyncDraggedPhysicsTransforms(); return; } Ray val20 = main.ScreenPointToRay(Input.mousePosition); Plane val21 = default(Plane); ((Plane)(ref val21))..ctor(_dragPlaneNormal, _dragPivot); float num4 = default(float); if (!((Plane)(ref val21)).Raycast(val20, ref num4)) { return; } Vector3 val22 = ((Ray)(ref val20)).GetPoint(num4) - _dragStartHit; if (_dragAxis == 3) { if (currentTool == ToolMode.Scale) { Vector2 dstMouse = _dragStartMouse + _rawMouseAccum; val3 = ((Component)main).transform.right + ((Component)main).transform.up; Vector3 normalized2 = ((Vector3)(ref val3)).normalized; float num5 = CalcLineTranslation(_dragStartMouse, dstMouse, _dragPivot, normalized2, main); float num6 = Mathf.Max(0.001f, 1f + num5 / _dragGizmoScale); ApplyScaleToDragObjects(num6, num6, num6, scaleX: true, scaleY: true, scaleZ: true); } else if (currentTool == ToolMode.Translate && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))) { ApplySurfaceSnapTranslation(); } else { ApplyTranslation(val22); } } else if (_dragAxis >= 4) { int axisA2; int axisB2; if (currentTool == ToolMode.Scale) { if (TryGetPlaneAxes(_dragAxis, out var axisA, out var axisB)) { Quaternion val23 = ((!((Object)(object)selectedObject != (Object)null) || selectedObject.groupId <= 0) ? ((Component)selectedObject).transform.rotation : ((_dragStartRootRotations.Count > 0) ? _dragStartRootRotations[0] : Quaternion.identity)); Vector3 val24 = GizmoRenderer.GetEffectivePivotRot(axisA) * Vector3.up; Vector3 val25 = GizmoRenderer.GetEffectivePivotRot(axisB) * Vector3.up; val3 = val24 + val25; Vector3 unitDir = val23 * ((Vector3)(ref val3)).normalized; Vector2 dstMouse2 = _dragStartMouse + _rawMouseAccum; float num7 = CalcLineTranslation(_dragStartMouse, dstMouse2, _dragPivot, unitDir, main); float num8 = Mathf.Max(0.001f, 1f + num7 / _dragGizmoScale); ApplyScaleToDragObjects((axisA == 0 || axisB == 0) ? num8 : 1f, (axisA == 1 || axisB == 1) ? num8 : 1f, (axisA == 2 || axisB == 2) ? num8 : 1f, axisA == 0 || axisB == 0, axisA == 1 || axisB == 1, axisA == 2 || axisB == 2); } } else if (TryGetPlaneAxes(_dragAxis, out axisA2, out axisB2)) { ? val26; if (!LocalMode) { val26 = Quaternion.identity; } else if (selectedObject.groupId <= 0) { val26 = ((Component)selectedObject).transform.rotation; } else { GameObject groupRoot = GroupManager.GetGroupRoot(selectedObject.groupId); val26 = ((groupRoot != null) ? groupRoot.transform.rotation : Quaternion.identity); } Quaternion val27 = (Quaternion)val26; Vector3 val28 = val27 * AxisVec(axisA2); Vector3 val29 = val27 * AxisVec(axisB2); Vector3 val30 = main.WorldToScreenPoint(_dragPivot); Vector2 val31 = default(Vector2); ((Vector2)(ref val31))..ctor(main.WorldToScreenPoint(_dragPivot + val28).x - val30.x, main.WorldToScreenPoint(_dragPivot + val28).y - val30.y); Vector2 val32 = default(Vector2); ((Vector2)(ref val32))..ctor(main.WorldToScreenPoint(_dragPivot + val29).x - val30.x, main.WorldToScreenPoint(_dragPivot + val29).y - val30.y); Vector2 val33 = val - _dragStartMouse; float num9 = val31.x * val32.y - val32.x * val31.y; if (Mathf.Abs(num9) > 0.5f) { float num10 = (val33.x * val32.y - val33.y * val32.x) / num9; float num11 = (val33.y * val31.x - val33.x * val31.y) / num9; Vector3 val34 = val28 * num10 + val29 * num11; for (int k = 0; k < _dragObjects.Count; k++) { LevelEditorObject levelEditorObject3 = _dragObjects[k]; if (!((Object)(object)levelEditorObject3 == (Object)null)) { Vector3 val35 = _dragStartPositions[k] + val34; if (_snapEnabled) { val35 = SnapVector(val35); } ((Component)levelEditorObject3).transform.position = val35; } } SyncDraggedPhysicsTransforms(); } else { ApplyTranslation(val22); } } else { ApplyTranslation(val22); } } else if (currentTool == ToolMode.Scale) { Quaternion val36 = ((!((Object)(object)selectedObject != (Object)null) || selectedObject.groupId <= 0) ? ((Component)selectedObject).transform.rotation : ((_dragStartRootRotations.Count > 0) ? _dragStartRootRotations[0] : Quaternion.identity)); Vector3 unitDir2 = val36 * (GizmoRenderer.GetEffectivePivotRot(_dragAxis) * Vector3.up); Vector2 dstMouse3 = _dragStartMouse + _rawMouseAccum; float num12 = CalcLineTranslation(_dragStartMouse, dstMouse3, _dragPivot, unitDir2, main); float num13 = Mathf.Max(0.001f, 1f + num12 / _dragGizmoScale); ApplyScaleToDragObjects((_dragAxis == 0) ? num13 : 1f, (_dragAxis == 1) ? num13 : 1f, (_dragAxis == 2) ? num13 : 1f, _dragAxis == 0, _dragAxis == 1, _dragAxis == 2); } else { ? val37; if (!LocalMode) { val37 = Quaternion.identity; } else if (selectedObject.groupId <= 0) { val37 = ((Component)selectedObject).transform.rotation; } else { GameObject groupRoot2 = GroupManager.GetGroupRoot(selectedObject.groupId); val37 = ((groupRoot2 != null) ? groupRoot2.transform.rotation : Quaternion.identity); } Quaternion val38 = (Quaternion)val37; Vector3 val39 = val38 * AxisVec(_dragAxis); ApplyTranslation(val39 * Vector3.Dot(val22, val39)); } } public static void SetPhysicsMode(PhysicsMode mode) { LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null || _selection.Count == 0) { return; } List list = _selection.Where((LevelEditorObject o) => (Object)(object)o != (Object)null).Distinct().ToList(); if (list.Count != 0) { ApplyPhysicsModeToTargets(list, mode); List list2 = (from o in list where (Object)(object)o != (Object)null && o.netId != 0 select o.netId).ToList(); if (list2.Count > 0) { ModNetworking.SendPropPhysicsMode(list2, mode); } } } internal static void ApplyPhysicsModeToTargets(List targets, PhysicsMode mode) { if (targets == null) { return; } targets = targets.Where((LevelEditorObject o) => (Object)(object)o != (Object)null).Distinct().ToList(); if (targets.Count == 0) { return; } foreach (LevelEditorObject target in targets) { if (target.physicsMode != PhysicsMode.Static) { PhysicsObjectManager.ClearPhysics(target, mode == PhysicsMode.Static); } } if (mode == PhysicsMode.Static) { return; } int num = (targets.All((LevelEditorObject o) => o.groupId > 0 && o.groupId == targets[0].groupId) ? targets[0].groupId : 0); int num2 = (targets.All((LevelEditorObject o) => o.physicsGroupId > 0 && o.physicsGroupId == targets[0].physicsGroupId) ? targets[0].physicsGroupId : 0); bool flag = targets.Count > 1; if (flag && num <= 0) { num = GroupManager.AllocateGroupId(); } if (mode == PhysicsMode.Grabable || mode == PhysicsMode.Hat || mode == PhysicsMode.Rigidbody) { if (flag && num2 <= 0) { num2 = ((num > 0) ? num : GroupManager.AllocateGroupId()); } if (num <= 0 && num2 > 0) { num = num2; } } foreach (LevelEditorObject target2 in targets) { if (num > 0 || flag) { target2.groupId = num; } if (mode == PhysicsMode.Grabable || mode == PhysicsMode.Hat || mode == PhysicsMode.Rigidbody) { target2.physicsGroupId = (flag ? num2 : target2.physicsGroupId); } else { target2.physicsGroupId = 0; } target2.physicsMode = mode; } if (mode == PhysicsMode.Grabable || mode == PhysicsMode.Hat) { if (flag) { GroupManager.ActivateWearableGroup(targets, mode); } else { PhysicsObjectManager.ActivatePhysics(targets[0]); } return; } if (mode == PhysicsMode.Rigidbody) { if (flag) { GroupManager.ActivateRigidbodyGroup(targets); } else { PhysicsObjectManager.ActivatePhysics(targets[0]); } return; } foreach (LevelEditorObject target3 in targets) { PhysicsObjectManager.ActivatePhysics(target3); } } public static void SetHatHairAmount(float hairAmount) { LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null || _selection.Count == 0) { return; } hairAmount = Mathf.Clamp01(hairAmount); foreach (LevelEditorObject item in _selection) { if (!((Object)(object)item == (Object)null) && item.physicsMode == PhysicsMode.Hat) { item.hatHairAmt = hairAmount; PhysicsObjectManager.SyncHatHairAmount(item); if (item.netId != 0) { ModNetworking.MarkPropPropertiesDirty(item.netId); } } } } public static void SetGrabOffset(Vector3 pos, Vector3 rotEuler) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null || _selection.Count == 0) { return; } foreach (LevelEditorObject item in _selection) { if (!((Object)(object)item == (Object)null) && item.physicsMode == PhysicsMode.Grabable) { item.grabOffsetPos = pos; item.grabOffsetRot = rotEuler; PhysicsObjectManager.SyncGrabOffset(item); if (item.netId != 0) { ModNetworking.MarkPropPropertiesDirty(item.netId); } } } } public static void SetHatOffset(Vector3 pos, Vector3 rotEuler) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (_selection.Count == 0) { return; } foreach (LevelEditorObject item in _selection) { if (!((Object)(object)item == (Object)null) && item.physicsMode == PhysicsMode.Hat) { item.hatOffsetPos = pos; item.hatOffsetRot = rotEuler; if (item.netId != 0) { ModNetworking.MarkPropPropertiesDirty(item.netId); } } } } public static void GroupSelection() { LevelEditorManager instance = LevelEditorManager.Instance; List list = _selection.Where((LevelEditorObject o) => (Object)(object)o != (Object)null).Distinct().ToList(); if ((Object)(object)instance == (Object)null || list.Count == 0) { return; } if (list.Select((LevelEditorObject o) => o.physicsMode).Distinct().Count() > 1) { foreach (LevelEditorObject item in list) { if (item.physicsMode != PhysicsMode.Static) { PhysicsObjectManager.ClearPhysics(item); } item.physicsMode = PhysicsMode.Static; item.physicsGroupId = 0; } } HashSet hashSet = new HashSet(from o in list where o.groupId > 0 select o.groupId); foreach (int item2 in hashSet) { GroupManager.DissolveGroup(item2); } int groupId = GroupManager.AllocateGroupId(); foreach (LevelEditorObject item3 in list) { item3.groupId = groupId; } GroupManager.EnsureStaticGroupRoot(groupId, list); Select(list[0]); List list2 = (from o in list where o.netId != 0 select o.netId).ToList(); if (list2.Count > 0) { ModNetworking.SendGroupSync(list2, group: true); } } public static void UngroupSelection() { List list = _selection.Where((LevelEditorObject o) => (Object)(object)o != (Object)null).Distinct().ToList(); if (list.Count == 0) { return; } LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance != (Object)null) { HashSet hashSet = new HashSet(from o in list where o.groupId > 0 select o.groupId); foreach (int item in hashSet) { GroupManager.DissolveGroup(item); } } else { foreach (LevelEditorObject item2 in list) { item2.groupId = 0; } } selectedObject = list[0]; List list2 = (from o in list where o.netId != 0 select o.netId).ToList(); if (list2.Count > 0) { ModNetworking.SendGroupSync(list2, group: false); } } private static void DeleteSelected() { if ((Object)(object)LevelEditorManager.Instance == (Object)null || _selection.Count == 0) { return; } for (int i = 0; i < _selection.Count; i++) { LevelEditorObject levelEditorObject = _selection[i]; if (!((Object)(object)levelEditorObject == (Object)null)) { LevelEditorHistory.PushDelete(levelEditorObject); ulong netId = levelEditorObject.netId; LevelEditorManager.Instance.Remove(levelEditorObject); if (netId != 0) { ModNetworking.SendPropDeleted(netId); } } } ClearSelection(); } public static Vector3 AxisVec(int idx) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(idx switch { 1 => Vector3.up, 0 => Vector3.right, _ => Vector3.forward, }); } private static bool TryGetPlaneAxes(int axisIndex, out int axisA, out int axisB) { axisA = 0; axisB = 1; switch (axisIndex) { case 4: axisA = 0; axisB = 1; return true; case 5: axisA = 1; axisB = 2; return true; case 6: axisA = 0; axisB = 2; return true; default: return false; } } private static bool TryGetPlaneNormal(int axisIndex, out Vector3 normal) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) normal = Vector3.forward; switch (axisIndex) { case 4: normal = Vector3.forward; return true; case 5: normal = Vector3.right; return true; case 6: normal = Vector3.up; return true; default: return false; } } private static void CopySelected() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) if (_selection.Count == 0) { return; } _copyEntries.Clear(); _copyPivot = GizmoRenderer.GetSelectionBoundsCenter(_selection); Bounds selectionBounds = GizmoRenderer.GetSelectionBounds(_selection); _copyBoundsSize = ((Bounds)(ref selectionBounds)).size; for (int i = 0; i < _selection.Count; i++) { LevelEditorObject levelEditorObject = _selection[i]; if (!((Object)(object)levelEditorObject == (Object)null)) { CopyEntry item = new CopyEntry { addressableKey = levelEditorObject.addressableKey, offset = ((Component)levelEditorObject).transform.position - _copyPivot, scale = ((Component)levelEditorObject).transform.localScale, rotation = ((Component)levelEditorObject).transform.rotation, isAddressable = !string.IsNullOrEmpty(levelEditorObject.addressableKey), materialConstructionId = levelEditorObject.materialConstructionId, physicsMode = levelEditorObject.physicsMode, sunglassesNeeded = levelEditorObject.sunglassesNeeded, playerPassthrough = levelEditorObject.playerPassthrough, freezeUntilHit = levelEditorObject.freezeUntilHit }; if (!item.isAddressable && !Enum.TryParse(levelEditorObject.objectType, out item.primType)) { item.primType = (PrimitiveType)3; } _copyEntries.Add(item); } } _copyHasValue = _copyEntries.Count > 0; } private static void PasteCopy(bool pasteInPlace = false) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) if (!_copyHasValue) { return; } EnsureManager(); Vector3 val = ((_selection.Count > 0) ? GizmoRenderer.GetSelectionBoundsCenter(_selection) : _copyPivot); Vector3 v = (Vector3)(pasteInPlace ? Vector3.zero : new Vector3(0f, Mathf.Clamp(_copyBoundsSize.y * 0.1f, 0.05f, 0.5f), 0f)); Vector3 val2 = SnapVector(v); List list = new List(); for (int i = 0; i < _copyEntries.Count; i++) { CopyEntry copyEntry = _copyEntries[i]; Vector3 position = val + val2 + copyEntry.offset; LevelEditorObject levelEditorObject = null; if (copyEntry.isAddressable) { PropInfo propInfo = PropLibrary.FindById(copyEntry.addressableKey); if (propInfo != null) { levelEditorObject = LevelEditorManager.Instance.SpawnFromPropInfo(propInfo, position); PropHistory.RecordUse(copyEntry.addressableKey); if (copyEntry.materialConstructionId >= 0) { MaterialConstructionEntry materialConstructionEntry = MaterialConstructionLibrary.FindById(copyEntry.materialConstructionId); if (materialConstructionEntry != null) { MaterialConstructionPanel.ApplyToInstance(levelEditorObject, materialConstructionEntry, pushHistory: false); } } } } else { levelEditorObject = LevelEditorManager.Instance.SpawnPrimitive(copyEntry.primType, position); } if (!((Object)(object)levelEditorObject == (Object)null)) { ((Component)levelEditorObject).transform.localScale = copyEntry.scale; ((Component)levelEditorObject).transform.rotation = copyEntry.rotation; if (copyEntry.physicsMode != PhysicsMode.Static) { _selection.Clear(); _selection.Add(levelEditorObject); selectedObject = levelEditorObject; SetPhysicsMode(copyEntry.physicsMode); } levelEditorObject.sunglassesNeeded = copyEntry.sunglassesNeeded; levelEditorObject.playerPassthrough = copyEntry.playerPassthrough; levelEditorObject.freezeUntilHit = copyEntry.freezeUntilHit; if (copyEntry.sunglassesNeeded && (Object)(object)((Component)levelEditorObject).GetComponent() == (Object)null) { ((Component)levelEditorObject).gameObject.AddComponent(); } if (copyEntry.playerPassthrough) { PropInstanceServices.SetBushPassthrough(((Component)levelEditorObject).gameObject, passthrough: true); } list.Add(levelEditorObject); LevelEditorHistory.PushSpawn(levelEditorObject); if (copyEntry.isAddressable) { ulong netId = ModNetworking.RegisterNetworkedObject(levelEditorObject); ModNetworking.SendPropPlaced(netId, copyEntry.addressableKey, ((Component)levelEditorObject).transform.position, ((Component)levelEditorObject).transform.rotation, ((Component)levelEditorObject).transform.localScale); ModNetworking.SyncFullPropState(levelEditorObject); } } } if (list.Count > 0) { _selection.Clear(); _selection.AddRange(list); selectedObject = _selection[_selection.Count - 1]; } } private static void ApplyTranslation(Vector3 delta) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _dragObjects.Count; i++) { LevelEditorObject levelEditorObject = _dragObjects[i]; if (!((Object)(object)levelEditorObject == (Object)null)) { Vector3 val = _dragStartPositions[i] + delta; if (_snapEnabled) { val = SnapVector(val); } ((Component)levelEditorObject).transform.SetPositionAndRotation(val, _dragStartRotations[i]); } } SyncDraggedPhysicsTransforms(); } private static void ApplySurfaceSnapTranslation() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_010a: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; Ray val = main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = default(RaycastHit); float num = float.MaxValue; bool flag = false; foreach (RaycastHit item in (Il2CppArrayBase)(object)Physics.RaycastAll(val, 2000f, LayerMask.op_Implicit(LayerCache.PropTerrainMask))) { RaycastHit current = item; if (!(((RaycastHit)(ref current)).distance >= num) && !IsDraggedTransform(((Component)((RaycastHit)(ref current)).collider).transform)) { num = ((RaycastHit)(ref current)).distance; hit = current; flag = true; } } if (!flag) { return; } Quaternion val2 = ComputeSpawnRotation(((RaycastHit)(ref hit)).normal) * DragOrientations[_dragStep]; LevelEditorObject levelEditorObject = _dragObjects[0]; PropInfo propInfo = (((Object)(object)levelEditorObject != (Object)null) ? PropLibrary.FindById(levelEditorObject.addressableKey) : null); Vector3 val3; if (propInfo != null) { PropLibrary.LoadPropData(propInfo); val3 = ComputeSpawnPosition(propInfo, hit, val2, ((Component)levelEditorObject).transform.localScale); } else { val3 = ((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * 0.5f; } Quaternion val4 = val2 * Quaternion.Inverse(_dragStartRotations[0]); Vector3 val5 = val3 - _dragStartPositions[0]; for (int i = 0; i < _dragObjects.Count; i++) { LevelEditorObject levelEditorObject2 = _dragObjects[i]; if (!((Object)(object)levelEditorObject2 == (Object)null)) { ((Component)levelEditorObject2).transform.rotation = val4 * _dragStartRotations[i]; ((Component)levelEditorObject2).transform.position = _dragStartPositions[i] + val5; } } SyncDraggedPhysicsTransforms(); } private static bool IsDraggedTransform(Transform t) { for (int i = 0; i < _dragObjects.Count; i++) { LevelEditorObject levelEditorObject = _dragObjects[i]; if ((Object)(object)levelEditorObject != (Object)null && ((Object)(object)t == (Object)(object)((Component)levelEditorObject).transform || t.IsChildOf(((Component)levelEditorObject).transform))) { return true; } } return false; } private static void ApplyScaleToDragObjects(float xFactor, float yFactor, float zFactor, bool scaleX, bool scaleY, bool scaleZ) { //IL_0015: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) Quaternion val = ((LocalMode && (Object)(object)selectedObject != (Object)null) ? ((Component)selectedObject).transform.rotation : Quaternion.identity); HashSet hashSet = new HashSet(); Vector3 val4 = default(Vector3); Vector3 val8 = default(Vector3); for (int i = 0; i < _dragObjects.Count; i++) { LevelEditorObject levelEditorObject = _dragObjects[i]; if ((Object)(object)levelEditorObject == (Object)null || PropLibrary.IsSpawnPointProp(levelEditorObject.addressableKey)) { continue; } GameObject val2 = ((i < _dragScaleRoots.Count) ? _dragScaleRoots[i] : null); if ((Object)(object)val2 != (Object)null) { Vector3 val3 = _dragStartRootScales[i]; ((Vector3)(ref val4))..ctor(scaleX ? Mathf.Max(0.001f, val3.x * xFactor) : val3.x, scaleY ? Mathf.Max(0.001f, val3.y * yFactor) : val3.y, scaleZ ? Mathf.Max(0.001f, val3.z * zFactor) : val3.z); if (_snapEnabled) { val4 = SnapVector(val4); } float num = SafeScaleRatio(val3.x, val4.x); float num2 = SafeScaleRatio(val3.y, val4.y); float num3 = SafeScaleRatio(val3.z, val4.z); int instanceID = ((Object)val2).GetInstanceID(); if (hashSet.Add(instanceID)) { GroupManager.SetGroupDisplayScale(levelEditorObject.groupId, val4); Quaternion val5 = ((i < _dragStartRootRotations.Count) ? _dragStartRootRotations[i] : Quaternion.identity); Vector3 val6 = Quaternion.Inverse(val5) * (_dragStartRootPositions[i] - _dragPivot); if (scaleX) { val6.x *= num; } if (scaleY) { val6.y *= num2; } if (scaleZ) { val6.z *= num3; } val2.transform.position = _dragPivot + val5 * val6; } } else { Vector3 val7 = _dragStartScales[i]; ((Vector3)(ref val8))..ctor(scaleX ? Mathf.Max(0.001f, val7.x * xFactor) : val7.x, scaleY ? Mathf.Max(0.001f, val7.y * yFactor) : val7.y, scaleZ ? Mathf.Max(0.001f, val7.z * zFactor) : val7.z); if (_snapEnabled) { val8 = SnapVector(val8); } ((Component)levelEditorObject).transform.localScale = val8; Vector3 val9 = _dragStartPositions[i] - _dragPivot; Vector3 val10 = Quaternion.Inverse(val) * val9; if (scaleX) { val10.x *= SafeScaleRatio(val7.x, val8.x); } if (scaleY) { val10.y *= SafeScaleRatio(val7.y, val8.y); } if (scaleZ) { val10.z *= SafeScaleRatio(val7.z, val8.z); } ((Component)levelEditorObject).transform.position = _dragPivot + val * val10; } } SyncDraggedPhysicsTransforms(); } private static void SyncDraggedPhysicsTransforms() { for (int i = 0; i < _dragObjects.Count; i++) { LevelEditorObject levelEditorObject = _dragObjects[i]; if ((Object)(object)levelEditorObject != (Object)null && levelEditorObject.physicsMode != PhysicsMode.Static) { Physics.SyncTransforms(); break; } } } private static float SafeScaleRatio(float start, float final) { return (Mathf.Abs(start) < 1E-05f) ? 1f : (final / start); } private static Vector3 SnapVector(Vector3 v) { //IL_0001: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) return new Vector3(Mathf.Round(v.x / 0.1f) * 0.1f, Mathf.Round(v.y / 0.1f) * 0.1f, Mathf.Round(v.z / 0.1f) * 0.1f); } private static float SnapAngleValue(float angle) { return Mathf.Round(angle / 10f) * 10f; } private static float CalcLineTranslation(Vector2 srcMouse, Vector2 dstMouse, Vector3 origin, Vector3 unitDir, Camera cam) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) Vector3 val = cam.WorldToScreenPoint(origin); Vector3 val2 = cam.WorldToScreenPoint(origin + unitDir); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(val2.x - val.x, val2.y - val.y); float sqrMagnitude = ((Vector2)(ref val3)).sqrMagnitude; if (sqrMagnitude < 0.01f) { return 0f; } Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(val.x, val.y); float num = Vector2.Dot(srcMouse - val4, val3) / sqrMagnitude; float num2 = Vector2.Dot(dstMouse - val4, val3) / sqrMagnitude; return num2 - num; } } public class LevelEditorManager : MonoBehaviour { private const float WorldLoopSize = 512f; private const float ChunkWorldSize = 64f; private const int ChunksPerAxis = 8; public static bool ChunkLoopingEnabled = true; private readonly List _objects = new List(); internal readonly Dictionary _groupRoots = new Dictionary(); internal int _nextGroupId = 1; internal bool _editorModeActive; private GameObject _propsContainer; internal const int PropLayer = 16; internal const int PropsDynamicLayer = 24; private const float LoopHysteresis = 16f; public static LevelEditorManager Instance { get; private set; } internal static GameObject PropsContainer => ((Object)(object)Instance != (Object)null) ? Instance._propsContainer : null; [HideFromIl2Cpp] internal IReadOnlyList Objects => _objects; public LevelEditorManager(IntPtr ptr) : base(ptr) { } public void Awake() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); _propsContainer = new GameObject("Baby Blocks"); if (!PropLibrary.IsInitialized) { PropLibrary.Init(); } } [HideFromIl2Cpp] internal void PruneDestroyedObjects() { int num = 0; for (int num2 = _objects.Count - 1; num2 >= 0; num2--) { if ((Object)(object)_objects[num2] == (Object)null) { _objects.RemoveAt(num2); num++; } } List list = new List(); foreach (KeyValuePair groupRoot in _groupRoots) { if ((Object)(object)groupRoot.Value == (Object)null) { list.Add(groupRoot.Key); } } foreach (int item in list) { _groupRoots.Remove(item); } if (num != 0 || list.Count != 0) { BBLog.Msg($"[LevelEditorManager] Pruned {num} destroyed object(s) and {list.Count} dead group root(s) after a native save load."); LevelEditor.Select(null); } } [HideFromIl2Cpp] internal void EnsurePropsContainer() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown if (!((Object)(object)_propsContainer != (Object)null)) { BBLog.Msg("[LevelEditorManager] Props container was destroyed (scene reload?) — resetting editor state."); LevelEditor.Select(null); _objects.Clear(); _groupRoots.Clear(); _nextGroupId = 1; _propsContainer = new GameObject("Baby Blocks"); MaterialCatalog.RefreshMicroSplatLayerMaterials(); } } [HideFromIl2Cpp] internal LevelEditorObject SpawnFromPropInfo(PropInfo info, Vector3 position) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00f3: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) PropLibrary.LoadPropData(info); bool flag = (Object)(object)info.sourcePrefab != (Object)null && PropMetadataStore.GetKeepOriginalHierarchy(info.id); if (!flag && !info.HasMesh) { MelonLogger.Warning("[LevelEditorManager] Cannot spawn " + info.displayName + ": no mesh."); return null; } GameObject val; if (flag) { val = Object.Instantiate(info.sourcePrefab, position, Quaternion.identity); ((Object)val).name = "LEO_" + info.displayName; foreach (Transform componentsInChild in val.GetComponentsInChildren(true)) { ((Component)componentsInChild).gameObject.layer = 16; } } else { val = new GameObject("LEO_" + info.displayName); val.transform.position = position; val.layer = 16; for (int i = 0; i < info.parts.Count; i++) { PropMeshPart propMeshPart = info.parts[i]; GameObject val2 = new GameObject($"Part_{i}"); val2.transform.SetParent(val.transform, false); val2.transform.localPosition = propMeshPart.localPosition; val2.transform.localRotation = propMeshPart.localRotation; val2.transform.localScale = propMeshPart.localScale; val2.layer = 16; MeshFilter val3 = val2.AddComponent(); val3.sharedMesh = propMeshPart.mesh; MeshRenderer val4 = val2.AddComponent(); if (propMeshPart.materials != null) { ((Renderer)val4).sharedMaterials = Il2CppReferenceArray.op_Implicit(propMeshPart.materials); } } if (PropLibrary.IsNegativeCollisionProp(info.id)) { GhostCubeConfig.Configure(val); } else if (PropLibrary.IsSpawnPointProp(info.id)) { SpawnPointConfig.Configure(val); } } if ((Object)(object)_propsContainer != (Object)null) { val.transform.SetParent(_propsContainer.transform, true); } string surfaceType = PropMetadataStore.GetSurfaceType(info.id); if (!string.IsNullOrEmpty(surfaceType)) { PropInstanceServices.ApplySurfaceTypeToRoot(val, surfaceType); } MaterialCatalog.ApplyMaterialOverridesToRoot(info.id, val); PropInstanceServices.ApplyDisabledRenderersToRoot(info.id, val); if (!flag && !PropLibrary.IsNegativeCollisionProp(info.id) && !PropLibrary.IsSpawnPointProp(info.id)) { PhysicsObjectManager.ApplyColliderParts(val, info, PropMetadataStore.GetUseRenderMeshCollider(info.id)); } PropInstanceServices.ApplyBushColliderToRoot(info.id, val); if (PropLibrary.IsSpawnPointProp(info.id)) { for (int num = _objects.Count - 1; num >= 0; num--) { if ((Object)(object)_objects[num] != (Object)null && PropLibrary.IsSpawnPointProp(_objects[num].addressableKey)) { Remove(_objects[num]); } } } LevelEditorObject levelEditorObject = val.AddComponent(); levelEditorObject.objectType = "Addressable"; levelEditorObject.addressableKey = info.id; string surfaceType2 = PropMetadataStore.GetSurfaceType(info.id); if (!string.IsNullOrEmpty(surfaceType2) && surfaceType2 != "Untagged") { levelEditorObject.surfaceTypeTag = surfaceType2; } if (flag && (Object)(object)val.GetComponent() != (Object)null) { levelEditorObject.physicsMode = PhysicsMode.Rigidbody; PhysicsObjectManager.FreezeRigidBodyObject(levelEditorObject, freeze: true); PhysicsObjectManager.DisableKeepHierarchyBehaviours(levelEditorObject); levelEditorObject.isPhysicsManaged = true; foreach (LODGroup componentsInChild2 in val.GetComponentsInChildren(true)) { componentsInChild2.enabled = false; } } _objects.Add(levelEditorObject); InitializeLoopBase(levelEditorObject, position); PropLibrary.AddRef(info.id); return levelEditorObject; } [HideFromIl2Cpp] internal IReadOnlyList GetLogicalGroupMembers(int groupId) { if (groupId <= 0) { return Array.Empty(); } List list = new List(); foreach (LevelEditorObject @object in _objects) { if ((Object)(object)@object != (Object)null && @object.groupId == groupId) { list.Add(@object); } } return list; } public unsafe LevelEditorObject SpawnPrimitive(PrimitiveType type, Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive(type); val.transform.position = position; ((Object)val).name = $"LEO_{type}"; val.layer = 16; if ((Object)(object)_propsContainer != (Object)null) { val.transform.SetParent(_propsContainer.transform, true); } Collider component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshCollider val2 = val.AddComponent(); val2.sharedMesh = val.GetComponent().sharedMesh; LevelEditorObject levelEditorObject = val.AddComponent(); levelEditorObject.objectType = ((object)(*(PrimitiveType*)(&type))/*cast due to .constrained prefix*/).ToString(); _objects.Add(levelEditorObject); InitializeLoopBase(levelEditorObject, position); return levelEditorObject; } public void Remove(LevelEditorObject obj) { if (!((Object)(object)obj == (Object)null)) { int num = ((obj.groupId > 0) ? obj.groupId : ((obj.physicsGroupId > 0) ? obj.physicsGroupId : 0)); if (num > 0) { GroupManager.DissolveGroup(num); } _objects.Remove(obj); if (!string.IsNullOrEmpty(obj.addressableKey)) { PropLibrary.RemoveRef(obj.addressableKey); } Object.Destroy((Object)(object)((Component)obj).gameObject); } } public static Vector2Int GetChunkCoord(Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Repeat(position.x + 256f, 512f); int num2 = Mathf.Clamp(Mathf.FloorToInt(num / 64f), 0, 7); int num3 = Mathf.Clamp(Mathf.FloorToInt(position.z / 64f), 0, 7); return new Vector2Int(num2, num3); } public static int GetChunkIndex(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return GetChunkIndex(GetChunkCoord(position)); } public static int GetChunkIndex(Vector2Int chunkCoord) { return ((Vector2Int)(ref chunkCoord)).y * 8 + ((Vector2Int)(ref chunkCoord)).x; } public static void NotifyVisualStateChanged(GameObject root) { } public void SyncLoopBase(LevelEditorObject obj) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_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_0059: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)obj == (Object)null)) { obj.loopBasePosition = ((Component)obj).transform.position; obj.loopBaseRotation = ((Component)obj).transform.rotation; obj.loopBaseScale = ((Component)obj).transform.localScale; obj.hasLoopBasePosition = true; obj.hasLoopBaseRotation = true; obj.hasLoopBaseScale = true; UpdateChunkData(obj, obj.loopBasePosition); } } [HideFromIl2Cpp] internal void SyncLoopBases(IEnumerable objects) { if (objects == null) { return; } foreach (LevelEditorObject @object in objects) { SyncLoopBase(@object); } } private void Update() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) Transform renderReference = GetRenderReference(); Vector3 playerReferencePosition = PhysicsObjectManager.GetPlayerReferencePosition(renderReference); bool flag = (Object)(object)renderReference != (Object)null && ChunkLoopingEnabled && !LevelEditor.isDragging && !PropPalette.IsDragging; PhysicsObjectManager.PhysicsControlSeen.Clear(); for (int i = 0; i < _objects.Count; i++) { LevelEditorObject levelEditorObject = _objects[i]; if ((Object)(object)levelEditorObject == (Object)null) { continue; } Vector3 loopBasePosition = GetLoopBasePosition(levelEditorObject); if (levelEditorObject.isPhysicsManaged) { PhysicsObjectManager.UpdatePhysicsObjectState(levelEditorObject, playerReferencePosition); PhysicsObjectManager.MarkPhysicsChunkIndependent(levelEditorObject); continue; } if (flag) { Vector3 loopedPosition = GetLoopedPosition(loopBasePosition, renderReference.position); if (((Component)levelEditorObject).transform.position != loopedPosition) { float num = loopedPosition.x - ((Component)levelEditorObject).transform.position.x; if (!(Mathf.Abs(num) > 256f) || LoopBoundaryDist(loopBasePosition.x, renderReference.position.x) >= 16f) { ((Component)levelEditorObject).transform.position = loopedPosition; } } } UpdateChunkData(levelEditorObject, loopBasePosition); } } private float LoopBoundaryDist(float baseX, float refX) { return Mathf.Min(Mathf.Abs(refX - (baseX + 256f)), Mathf.Abs(refX - (baseX - 256f))); } private void UpdateChunkData(LevelEditorObject obj, Vector3 position) { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)obj == (Object)null)) { obj.chunkIndex = GetChunkIndex(obj.chunkCoord = GetChunkCoord(position)); } } private Vector3 GetLoopBasePosition(LevelEditorObject obj) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_0044: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)obj == (Object)null) { return Vector3.zero; } if (!obj.hasLoopBasePosition) { obj.loopBasePosition = ((Component)obj).transform.position; obj.hasLoopBasePosition = true; } return obj.loopBasePosition; } private void InitializeLoopBase(LevelEditorObject obj, Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)obj == (Object)null)) { obj.loopBasePosition = position; obj.loopBaseRotation = ((Component)obj).transform.rotation; obj.loopBaseScale = ((Component)obj).transform.localScale; obj.hasLoopBasePosition = true; obj.hasLoopBaseRotation = true; obj.hasLoopBaseScale = true; UpdateChunkData(obj, position); } } private Vector3 GetLoopedPosition(Vector3 basePosition, Vector3 referencePosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Round((referencePosition.x - basePosition.x) / 512f); return new Vector3(basePosition.x + num * 512f, basePosition.y, basePosition.z); } private Transform GetRenderReference() { PlayerMovement me = PlayerMovement.me; if ((Object)(object)me != (Object)null && FlyCamController.FlyCamActive && (Object)(object)me.flyCam != (Object)null) { return ((Component)me.flyCam).transform; } Camera main = Camera.main; return ((Object)(object)main != (Object)null) ? ((Component)main).transform : null; } public void RemoveAll() { while (_objects.Count > 0) { Remove(_objects[_objects.Count - 1]); } foreach (GameObject value in _groupRoots.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } } _groupRoots.Clear(); _nextGroupId = 1; } } internal static class HatBodyColls { internal static void SetIgnore(Hat hat, bool ignore) { try { PlayerMovement me = PlayerMovement.me; if ((Object)(object)me == (Object)null) { return; } Il2CppReferenceArray allBodyColliders = me.allBodyColliders; if (allBodyColliders == null) { return; } Il2CppArrayBase componentsInChildren = ((Component)hat).GetComponentsInChildren(true); foreach (Collider item in componentsInChildren) { foreach (Collider item2 in (Il2CppArrayBase)(object)allBodyColliders) { Physics.IgnoreCollision(item, item2, ignore); } } } catch { } } internal static bool IsCustomHat(Hat hat) { try { return (Object)(object)hat != (Object)null && (Object)(object)((Component)hat).GetComponent() != (Object)null; } catch { return false; } } } [HarmonyPatch(typeof(Grabable), "PlaceInHand")] internal class PlaceInHandPatch { private static void Postfix(Grabable __instance, Transform hand, int handIndex) { //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_0024: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { return; } Vector3 localScale = ((Component)__instance).transform.localScale; if (localScale.x != 1f || localScale.y != 1f || localScale.z != 1f) { List val = ((handIndex == 0) ? __instance.grabLocPtsR : __instance.grabLocPtsL); List val2 = ((handIndex == 0) ? __instance.grabLocRotsR : __instance.grabLocRotsL); if (val != null && val.Count != 0) { Vector3 val3 = val[0]; Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(val3.x * localScale.x, val3.y * localScale.y, val3.z * localScale.z); ((Component)__instance).transform.position = hand.TransformPoint(val4); ((Component)__instance).transform.rotation = hand.rotation * val2[0]; } } } } [HarmonyPatch(typeof(PlayerMovement), "WearHat")] internal class WearHatPatch { private static void Postfix(PlayerMovement __instance, Hat hat) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 if (!((Object)(object)hat == (Object)null) && HatBodyColls.IsCustomHat(hat) && (int)((Grabable)hat).heldState == 3) { HatBodyColls.SetIgnore(hat, ignore: true); } } } [HarmonyPatch(typeof(PlayerMovement), "KnockOffHat")] internal class KnockOffHatPatch { private static Hat _knockedOffHat; private static void Prefix(PlayerMovement __instance) { _knockedOffHat = __instance.currentHat; } private static void Postfix() { Hat knockedOffHat = _knockedOffHat; _knockedOffHat = null; if (!((Object)(object)knockedOffHat == (Object)null) && HatBodyColls.IsCustomHat(knockedOffHat)) { HatBodyColls.SetIgnore(knockedOffHat, ignore: false); } } } internal static class PhysicsObjectManager { private const float PhysicsActiveRadius = 25f; private const float PhysicsActiveRadiusSqr = 625f; internal static readonly HashSet PhysicsControlSeen = new HashSet(); private static readonly List _heldObjectsToRestore = new List(); private static readonly List _heldScalesToRestore = new List(); private static readonly HashSet _freezeUntilHitPending = new HashSet(); private static readonly Dictionary> _frozenKHBehaviours = new Dictionary>(); private static readonly Dictionary> _physicsMeshCache = new Dictionary>(); private const float PropDensityKgM3 = 500f; private const float PropMassMin = 0.1f; private const float PropMassMax = 200f; private const int FloaterVertexLimit = 5000; internal static bool HasFreezeUntilHit(LevelEditorObject obj) { return (Object)(object)((obj != null) ? ((Component)obj).gameObject : null) != (Object)null && _freezeUntilHitPending.Contains(((Object)((Component)obj).gameObject).GetInstanceID()); } private static void AddFreezeUntilHit(LevelEditorObject obj) { if ((Object)(object)((obj != null) ? ((Component)obj).gameObject : null) != (Object)null) { _freezeUntilHitPending.Add(((Object)((Component)obj).gameObject).GetInstanceID()); } } private static void RemoveFreezeUntilHit(LevelEditorObject obj) { if ((Object)(object)((obj != null) ? ((Component)obj).gameObject : null) != (Object)null) { _freezeUntilHitPending.Remove(((Object)((Component)obj).gameObject).GetInstanceID()); } } internal static void OnFreezeUntilHitTriggered(LevelEditorObject obj) { RemoveFreezeUntilHit(obj); } internal static void RemoveFreezeUntilHitForNetworkPeer(LevelEditorObject obj) { RemoveFreezeUntilHit(obj); } internal static void ReleasePhysicsMeshes(PropInfo info) { if (info == null) { return; } foreach (PropMeshPart part in info.parts) { if ((Object)(object)part?.mesh == (Object)null) { continue; } int instanceID = ((Object)part.mesh).GetInstanceID(); if (!_physicsMeshCache.TryGetValue(instanceID, out var value)) { continue; } _physicsMeshCache.Remove(instanceID); foreach (Mesh value3 in value.Values) { if ((Object)(object)value3 != (Object)null) { Object.Destroy((Object)(object)value3); } } } foreach (PropColliderPart colliderPart in info.colliderParts) { if ((Object)(object)colliderPart?.mesh == (Object)null) { continue; } int instanceID2 = ((Object)colliderPart.mesh).GetInstanceID(); if (!_physicsMeshCache.TryGetValue(instanceID2, out var value2)) { continue; } _physicsMeshCache.Remove(instanceID2); foreach (Mesh value4 in value2.Values) { if ((Object)(object)value4 != (Object)null) { Object.Destroy((Object)(object)value4); } } } } internal static Mesh BuildPhysicsMesh(Mesh source, HashSet ignoredSubmeshes = null) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Expected O, but got Unknown //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null) { return null; } int instanceID = ((Object)source).GetInstanceID(); string key = ((ignoredSubmeshes == null || ignoredSubmeshes.Count == 0) ? string.Empty : string.Join(",", ignoredSubmeshes.OrderBy((int v) => v))); if (_physicsMeshCache.TryGetValue(instanceID, out var value)) { if (value == null) { return null; } if (value.TryGetValue(key, out var value2)) { return value2; } } Mesh val = null; try { bool flag = false; foreach (VertexAttributeDescriptor item in (Il2CppArrayBase)(object)source.GetVertexAttributes()) { VertexAttributeDescriptor current = item; if ((int)((VertexAttributeDescriptor)(ref current)).attribute == 0 && (int)((VertexAttributeDescriptor)(ref current)).format == 0 && ((VertexAttributeDescriptor)(ref current)).dimension == 3 && ((VertexAttributeDescriptor)(ref current)).stream == 0) { flag = true; break; } } if (!flag) { _physicsMeshCache[instanceID] = null; return null; } GraphicsBuffer vertexBuffer = source.GetVertexBuffer(0); int num = vertexBuffer.stride / 4; int vertexCount = source.vertexCount; Il2CppStructArray val2 = new Il2CppStructArray((long)(vertexCount * num)); vertexBuffer.GetData(((Il2CppObjectBase)val2).Cast()); vertexBuffer.Release(); Vector3[] array = (Vector3[])(object)new Vector3[vertexCount]; for (int num2 = 0; num2 < vertexCount; num2++) { int num3 = num2 * num; array[num2] = new Vector3(((Il2CppArrayBase)(object)val2)[num3], ((Il2CppArrayBase)(object)val2)[num3 + 1], ((Il2CppArrayBase)(object)val2)[num3 + 2]); } GraphicsBuffer indexBuffer = source.GetIndexBuffer(); int count = indexBuffer.count; int[] array2 = new int[count]; if (indexBuffer.stride == 2) { Il2CppStructArray val3 = new Il2CppStructArray((long)count); indexBuffer.GetData(((Il2CppObjectBase)val3).Cast()); for (int num4 = 0; num4 < count; num4++) { array2[num4] = ((Il2CppArrayBase)(object)val3)[num4]; } } else { Il2CppStructArray val4 = new Il2CppStructArray((long)count); indexBuffer.GetData(((Il2CppObjectBase)val4).Cast()); for (int num5 = 0; num5 < count; num5++) { array2[num5] = ((Il2CppArrayBase)(object)val4)[num5]; } } int[] array3 = array2; if (ignoredSubmeshes != null && ignoredSubmeshes.Count > 0 && source.subMeshCount > 0) { List list = new List(); for (int num6 = 0; num6 < source.subMeshCount; num6++) { if (ignoredSubmeshes.Contains(num6)) { continue; } SubMeshDescriptor subMesh = source.GetSubMesh(num6); int indexStart = ((SubMeshDescriptor)(ref subMesh)).indexStart; int indexCount = ((SubMeshDescriptor)(ref subMesh)).indexCount; if (indexStart >= 0 && indexCount > 0 && indexStart + indexCount <= array2.Length) { for (int num7 = indexStart; num7 < indexStart + indexCount; num7++) { list.Add(array2[num7]); } } } if (list.Count > 0) { array3 = list.ToArray(); } } indexBuffer.Release(); if (array3 != array2) { HashSet hashSet = new HashSet(array3); Vector3[] array4 = (Vector3[])(object)new Vector3[hashSet.Count]; int[] array5 = new int[vertexCount]; int num8 = 0; for (int num9 = 0; num9 < vertexCount; num9++) { if (hashSet.Contains(num9)) { array5[num9] = num8; array4[num8++] = array[num9]; } } array = array4; for (int num10 = 0; num10 < array3.Length; num10++) { array3[num10] = array5[array3[num10]]; } } val = new Mesh { name = ((Object)source).name + "_phys" }; val.vertices = Il2CppStructArray.op_Implicit(array); val.triangles = Il2CppStructArray.op_Implicit(array3); val.RecalculateNormals(); val.RecalculateBounds(); if (!_physicsMeshCache.TryGetValue(instanceID, out value)) { value = new Dictionary(); _physicsMeshCache[instanceID] = value; } value[key] = val; } catch { val = null; } return val; } public static void ApplyColliderParts(GameObject root, PropInfo info, bool applyRenderMesh = false) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Expected O, but got Unknown //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null || info == null) { return; } int layer = 16; if (!applyRenderMesh) { if (!info.HasColliderParts) { return; } for (int i = 0; i < info.colliderParts.Count; i++) { PropColliderPart propColliderPart = info.colliderParts[i]; GameObject val = new GameObject($"PropCollider_{i}"); val.transform.SetParent(root.transform, false); val.transform.localPosition = propColliderPart.localPosition; val.transform.localRotation = propColliderPart.localRotation; val.transform.localScale = propColliderPart.localScale; val.layer = layer; switch (propColliderPart.type) { case PropColliderPart.ColliderType.Mesh: { MeshCollider val5 = val.AddComponent(); Mesh val6 = BuildPhysicsMesh(propColliderPart.mesh); val5.sharedMesh = val6 ?? propColliderPart.mesh; val5.convex = propColliderPart.convex; break; } case PropColliderPart.ColliderType.Box: { BoxCollider val4 = val.AddComponent(); val4.center = propColliderPart.center; val4.size = propColliderPart.size; break; } case PropColliderPart.ColliderType.Sphere: { SphereCollider val3 = val.AddComponent(); val3.center = propColliderPart.center; val3.radius = propColliderPart.radius; break; } case PropColliderPart.ColliderType.Capsule: { CapsuleCollider val2 = val.AddComponent(); val2.center = propColliderPart.center; val2.radius = propColliderPart.radius; val2.height = propColliderPart.height; val2.direction = propColliderPart.direction; break; } } } return; } HashSet hashSet = new HashSet(); int num = 0; foreach (MeshFilter componentsInChild in root.GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild == (Object)null || (Object)(object)componentsInChild.sharedMesh == (Object)null) { continue; } MeshRenderer component = ((Component)componentsInChild).GetComponent(); if ((Object)(object)component == (Object)null || !((Renderer)component).enabled) { continue; } Bounds bounds = componentsInChild.sharedMesh.bounds; string item = $"{((Bounds)(ref bounds)).center.x:F2},{((Bounds)(ref bounds)).center.y:F2},{((Bounds)(ref bounds)).center.z:F2}|{((Bounds)(ref bounds)).size.x:F2},{((Bounds)(ref bounds)).size.y:F2},{((Bounds)(ref bounds)).size.z:F2}"; if (hashSet.Add(item)) { GameObject val7 = new GameObject($"PropCollider_{num++}"); val7.transform.SetParent(root.transform, false); val7.transform.localPosition = ((Component)componentsInChild).transform.localPosition; val7.transform.localRotation = ((Component)componentsInChild).transform.localRotation; val7.transform.localScale = ((Component)componentsInChild).transform.localScale; val7.layer = layer; HashSet colliderIgnoredSubmeshes = PropMetadataStore.GetColliderIgnoredSubmeshes(info.id); Mesh val8 = BuildPhysicsMesh(componentsInChild.sharedMesh, colliderIgnoredSubmeshes); MeshCollider val9 = val7.AddComponent(); if ((Object)(object)val8 != (Object)null) { val9.sharedMesh = val8; } else if (colliderIgnoredSubmeshes == null || colliderIgnoredSubmeshes.Count == 0) { val9.sharedMesh = componentsInChild.sharedMesh; } else { Object.Destroy((Object)(object)val7); } } } } internal static Vector3 GetPlayerReferencePosition(Transform reference) { //IL_004c: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) PlayerMovement me = PlayerMovement.me; if ((Object)(object)me != (Object)null) { return ((Object)(object)me.head != (Object)null) ? me.head.position : ((Component)me).transform.position; } return ((Object)(object)reference != (Object)null) ? reference.position : Vector3.zero; } internal static void UpdatePhysicsObjectState(LevelEditorObject obj, Vector3 playerPos) { //IL_00b8: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) if (LevelEditorManager.Instance._editorModeActive) { return; } GameObject physicsControlObject = GetPhysicsControlObject(obj); if ((Object)(object)physicsControlObject == (Object)null) { return; } int instanceID = ((Object)physicsControlObject).GetInstanceID(); if (!PhysicsControlSeen.Add(instanceID)) { return; } Rigidbody component = physicsControlObject.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)physicsControlObject.GetComponent() != (Object)null) { return; } if (HasFreezeUntilHit(obj)) { if (!component.isKinematic) { component.isKinematic = true; component.useGravity = false; } return; } Vector3 val = physicsControlObject.transform.position - playerPos; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= 625f) { if (component.isKinematic) { component.isKinematic = false; SetMeshCollidersConvex(physicsControlObject, convex: true); SetColliderLayers(physicsControlObject, 24); } component.useGravity = true; } else if (!component.isKinematic) { component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; component.isKinematic = true; component.useGravity = false; SetMeshCollidersConvex(physicsControlObject, convex: false); SetColliderLayers(physicsControlObject, 16); } } private static GameObject GetPhysicsControlObject(LevelEditorObject obj) { if ((Object)(object)obj == (Object)null) { return null; } Grabable componentInParent = ((Component)obj).GetComponentInParent(true); if ((Object)(object)componentInParent != (Object)null) { return ((Component)componentInParent).gameObject; } Rigidbody componentInParent2 = ((Component)obj).GetComponentInParent(true); if ((Object)(object)componentInParent2 != (Object)null) { return ((Component)componentInParent2).gameObject; } return ((Component)obj).gameObject; } internal static void MarkPhysicsChunkIndependent(LevelEditorObject obj) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)obj == (Object)null)) { obj.chunkIndex = 255; obj.chunkCoord = new Vector2Int(-1, -1); } } public static void SetEditorModeActive(bool active) { LevelEditorManager instance = LevelEditorManager.Instance; if (instance._editorModeActive != active) { instance._editorModeActive = active; if (active) { ReleasePlayerHeldObjects(); RestoreHeldObjectScales(); EnterEditorPhysicsMode(); } else { ExitEditorPhysicsMode(); } } } private static void ReleasePlayerHeldObjects() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) PlayerMovement me = PlayerMovement.me; _heldObjectsToRestore.Clear(); _heldScalesToRestore.Clear(); if ((Object)(object)me == (Object)null) { return; } if ((Object)(object)me.currentHat != (Object)null) { LevelEditorObject component = ((Component)me.currentHat).GetComponent(); if ((Object)(object)component != (Object)null) { _heldObjectsToRestore.Add(component); _heldScalesToRestore.Add(((Component)component).transform.localScale); } me.KnockOffHat(); } for (int i = 0; i < ((Il2CppArrayBase)(object)me.handItems).Length; i++) { if ((Object)(object)((Il2CppArrayBase)(object)me.handItems)[i] != (Object)null) { LevelEditorObject component2 = ((Component)((Il2CppArrayBase)(object)me.handItems)[i]).GetComponent(); if ((Object)(object)component2 != (Object)null) { _heldObjectsToRestore.Add(component2); _heldScalesToRestore.Add(((Component)component2).transform.localScale); } me.DropHandItem(i); } } } private static void RestoreHeldObjectScales() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Min(_heldObjectsToRestore.Count, _heldScalesToRestore.Count); for (int i = 0; i < num; i++) { LevelEditorObject levelEditorObject = _heldObjectsToRestore[i]; if ((Object)(object)levelEditorObject != (Object)null) { ((Component)levelEditorObject).transform.localScale = _heldScalesToRestore[i]; } } _heldObjectsToRestore.Clear(); _heldScalesToRestore.Clear(); } private static void EnterEditorPhysicsMode() { LevelEditorManager instance = LevelEditorManager.Instance; HashSet hashSet = new HashSet(); foreach (LevelEditorObject @object in instance.Objects) { if ((Object)(object)@object == (Object)null || @object.physicsMode == PhysicsMode.Static) { continue; } if (@object.physicsMode == PhysicsMode.Rigidbody) { if (@object.physicsGroupId > 0) { if (hashSet.Add(@object.physicsGroupId)) { GroupManager.FreezeRigidBodyGroupForEditor(@object.physicsGroupId); } continue; } FreezeRigidBodyObject(@object, freeze: true); RestoreBasePose(@object); if (IsKeepHierarchyRigidbody(@object)) { DisableKeepHierarchyBehaviours(@object); } @object.isPhysicsManaged = true; } else if (@object.physicsGroupId > 0) { if (hashSet.Add(@object.physicsGroupId)) { GroupManager.DeactivateGroupForEditor(@object.physicsGroupId); } } else { DeactivateSoloWearableForEditor(@object); } } } private static void ExitEditorPhysicsMode() { LevelEditorManager instance = LevelEditorManager.Instance; HashSet hashSet = new HashSet(); foreach (LevelEditorObject @object in instance.Objects) { if ((Object)(object)@object == (Object)null || @object.physicsMode != PhysicsMode.Rigidbody) { continue; } if (@object.physicsGroupId > 0) { if (!hashSet.Add(@object.physicsGroupId)) { continue; } GroupManager.UnfreezeRigidBodyGroup(@object.physicsGroupId); } else { if (IsKeepHierarchyRigidbody(@object)) { ReEnableKeepHierarchyBehaviours(@object); } if (@object.freezeUntilHit) { @object.editorFreezeStateValid = false; Rigidbody component = ((Component)@object).GetComponent(); if ((Object)(object)component != (Object)null) { component.isKinematic = true; component.useGravity = false; component.constraints = (RigidbodyConstraints)126; } SetMeshCollidersConvex(((Component)@object).gameObject, convex: true); SetColliderLayers(((Component)@object).gameObject, 24); AddFreezeUntilHit(@object); } else { FreezeRigidBodyObject(@object, freeze: false); } } @object.isPhysicsManaged = true; } GroupManager.ApplyGroups(); } internal static void FreezeRigidBodyObject(LevelEditorObject obj, bool freeze) { //IL_010e: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)obj == (Object)null) { return; } Rigidbody component = ((Component)obj).GetComponent(); if ((Object)(object)component == (Object)null) { return; } if (freeze) { RemoveFreezeUntilHit(obj); if (!obj.editorFreezeStateValid) { obj.editorFreezeVelocity = Vector3.zero; obj.editorFreezeAngularVelocity = Vector3.zero; if (obj.physicsMode == PhysicsMode.Rigidbody) { obj.editorFreezeIsKinematic = false; obj.editorFreezeUseGravity = true; } else { obj.editorFreezeIsKinematic = component.isKinematic; obj.editorFreezeUseGravity = component.useGravity; } obj.editorFreezeConstraints = component.constraints; obj.editorFreezeStateValid = true; } component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; component.isKinematic = true; component.useGravity = false; component.constraints = (RigidbodyConstraints)126; SetMeshCollidersConvex(((Component)obj).gameObject, convex: false); SetColliderLayers(((Component)obj).gameObject, 16); } else if (obj.editorFreezeStateValid) { component.constraints = obj.editorFreezeConstraints; component.isKinematic = obj.editorFreezeIsKinematic; component.useGravity = obj.editorFreezeUseGravity; component.velocity = obj.editorFreezeVelocity; component.angularVelocity = obj.editorFreezeAngularVelocity; obj.editorFreezeStateValid = false; if (!component.isKinematic) { SetMeshCollidersConvex(((Component)obj).gameObject, convex: true); SetColliderLayers(((Component)obj).gameObject, 24); } } } internal static void UnfreezeHitProp(LevelEditorObject obj, Collision collision = null) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)obj == (Object)null) { return; } Rigidbody component = ((Component)obj).GetComponent(); if (!((Object)(object)component == (Object)null)) { component.constraints = (RigidbodyConstraints)0; component.isKinematic = false; component.useGravity = true; SetMeshCollidersConvex(((Component)obj).gameObject, convex: true); SetColliderLayers(((Component)obj).gameObject, 24); if (collision != null) { component.AddForce(-collision.relativeVelocity, (ForceMode)2); } } } internal static void FreezeRigidBodyGameObject(GameObject go, bool freeze) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go == (Object)null) { return; } Rigidbody component = go.GetComponent(); if (!((Object)(object)component == (Object)null)) { if (freeze) { component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; component.isKinematic = true; component.useGravity = false; component.constraints = (RigidbodyConstraints)126; SetMeshCollidersConvex(go, convex: false); SetColliderLayers(go, 16); } else { component.constraints = (RigidbodyConstraints)0; component.isKinematic = false; component.useGravity = true; SetMeshCollidersConvex(go, convex: true); SetColliderLayers(go, 24); } } } private static bool IsKeepHierarchyRigidbody(LevelEditorObject obj) { return (Object)(object)obj != (Object)null && !string.IsNullOrEmpty(obj.addressableKey) && PropMetadataStore.GetKeepOriginalHierarchy(obj.addressableKey) && (Object)(object)((Component)obj).GetComponent() != (Object)null; } internal static void DisableKeepHierarchyBehaviours(LevelEditorObject obj) { if ((Object)(object)obj == (Object)null) { return; } int instanceID = ((Object)obj).GetInstanceID(); if (_frozenKHBehaviours.ContainsKey(instanceID)) { return; } List list = new List(); Il2CppArrayBase components = ((Component)obj).gameObject.GetComponents(); for (int i = 0; i < components.Length; i++) { Behaviour val = components[i]; if (!((Object)(object)val == (Object)null) && val.enabled && !((Object)(object)((Il2CppObjectBase)val).TryCast() != (Object)null)) { val.enabled = false; list.Add(val); } } _frozenKHBehaviours[instanceID] = list; } internal static void ReEnableKeepHierarchyBehaviours(LevelEditorObject obj) { if ((Object)(object)obj == (Object)null) { return; } int instanceID = ((Object)obj).GetInstanceID(); if (!_frozenKHBehaviours.TryGetValue(instanceID, out var value)) { return; } foreach (Behaviour item in value) { if ((Object)(object)item != (Object)null) { item.enabled = true; } } _frozenKHBehaviours.Remove(instanceID); } internal static void SetHierarchyCollisions(GameObject go, bool enabled) { if ((Object)(object)go == (Object)null) { return; } foreach (Collider componentsInChild in go.GetComponentsInChildren(true)) { componentsInChild.enabled = enabled; } } private static void DeactivateSoloWearableForEditor(LevelEditorObject obj) { SetHierarchyCollisions(((Component)obj).gameObject, enabled: false); RemoveGrabableComponents(((Component)obj).gameObject); RestoreBasePose(obj); SetHierarchyCollisions(((Component)obj).gameObject, enabled: true); obj.isPhysicsManaged = false; } internal static void RestoreBasePose(LevelEditorObject obj) { //IL_001f: 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_0057: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)obj == (Object)null)) { if (obj.hasLoopBasePosition) { ((Component)obj).transform.position = obj.loopBasePosition; } if (obj.hasLoopBaseRotation) { ((Component)obj).transform.rotation = obj.loopBaseRotation; } if (obj.hasLoopBaseScale) { ((Component)obj).transform.localScale = obj.loopBaseScale; } } } private static void RebuildPropColliders(LevelEditorObject leo) { if ((Object)(object)leo == (Object)null || string.IsNullOrEmpty(leo.addressableKey)) { return; } PropInfo propInfo = PropLibrary.FindById(leo.addressableKey); if (propInfo == null) { return; } HashSet colliderIgnoredSubmeshes = PropMetadataStore.GetColliderIgnoredSubmeshes(propInfo.id); if (colliderIgnoredSubmeshes != null && colliderIgnoredSubmeshes.Count > 0) { string key = string.Join(",", colliderIgnoredSubmeshes.OrderBy((int v) => v)); foreach (MeshFilter componentsInChild in ((Component)leo).GetComponentsInChildren(true)) { if (!((Object)(object)((componentsInChild != null) ? componentsInChild.sharedMesh : null) == (Object)null)) { int instanceID = ((Object)componentsInChild.sharedMesh).GetInstanceID(); if (_physicsMeshCache.TryGetValue(instanceID, out var value)) { value?.Remove(key); } } } } GameObject gameObject = ((Component)leo).gameObject; for (int num = gameObject.transform.childCount - 1; num >= 0; num--) { Transform child = gameObject.transform.GetChild(num); if ((Object)(object)child != (Object)null && ((Object)child).name != null && ((Object)child).name.StartsWith("PropCollider_")) { Object.DestroyImmediate((Object)(object)((Component)child).gameObject); } } ApplyColliderParts(gameObject, propInfo, PropMetadataStore.GetUseRenderMeshCollider(propInfo.id)); } public static void ActivatePhysics(LevelEditorObject leo) { RebuildPropColliders(leo); Il2CppArrayBase componentsInChildren = ((Component)leo).gameObject.GetComponentsInChildren(true); if (leo.physicsMode == PhysicsMode.Rigidbody) { AddRigidBodyComponent(((Component)leo).gameObject, Il2CppArrayBase.op_Implicit(componentsInChildren), leo.addressableKey); FreezeRigidBodyObject(leo, freeze: true); } else { AddGrabableComponent(((Component)leo).gameObject, leo.physicsMode == PhysicsMode.Hat, Il2CppArrayBase.op_Implicit(componentsInChildren), leo.addressableKey); SyncHatHairAmount(leo); if (leo.physicsMode == PhysicsMode.Grabable || leo.physicsMode == PhysicsMode.Hat) { SyncGrabOffset(leo); } if (leo.physicsMode == PhysicsMode.Hat && BbHatSunglassesFlag.Has(leo)) { Hat component = ((Component)leo).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { component.isSunglasses = true; } } } MarkPhysicsChunkIndependent(leo); leo.isPhysicsManaged = true; } [HideFromIl2Cpp] internal static void SyncHatHairAmount(LevelEditorObject leo) { if ((Object)(object)leo == (Object)null) { return; } Hat component = ((Component)leo).GetComponent(); if ((Object)(object)component == (Object)null) { Transform parent = ((Component)leo).transform.parent; while ((Object)(object)parent != (Object)null && (Object)(object)component == (Object)null) { component = ((Component)parent).GetComponent(); parent = parent.parent; } } if ((Object)(object)component != (Object)null) { component.hairAmt = Mathf.Clamp01(leo.hatHairAmt); } } [HideFromIl2Cpp] internal static void SyncGrabOffset(LevelEditorObject leo) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)leo == (Object)null) { return; } Grabable component = ((Component)leo).GetComponent(); if ((Object)(object)component == (Object)null) { Transform parent = ((Component)leo).transform.parent; while ((Object)(object)parent != (Object)null && (Object)(object)component == (Object)null) { component = ((Component)parent).GetComponent(); parent = parent.parent; } } if (!((Object)(object)component == (Object)null)) { Vector3 localScale = ((Component)component).transform.localScale; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor((localScale.x != 0f) ? (leo.grabOffsetPos.x / localScale.x) : leo.grabOffsetPos.x, (localScale.y != 0f) ? (leo.grabOffsetPos.y / localScale.y) : leo.grabOffsetPos.y, (localScale.z != 0f) ? (leo.grabOffsetPos.z / localScale.z) : leo.grabOffsetPos.z); List val2 = new List(); List val3 = new List(); List val4 = new List(); List val5 = new List(); val2.Add(val); val3.Add(Quaternion.Euler(leo.grabOffsetRot)); val4.Add(val); val5.Add(Quaternion.Euler(leo.grabOffsetRot)); component.grabLocPtsR = val2; component.grabLocRotsR = val3; component.grabLocPtsL = val4; component.grabLocRotsL = val5; } } [HideFromIl2Cpp] internal static void SyncLoadedHatHairValues() { foreach (LevelEditorObject @object in LevelEditorManager.Instance.Objects) { if (!((Object)(object)@object == (Object)null) && @object.physicsMode == PhysicsMode.Hat) { SyncHatHairAmount(@object); } } } internal static void RefreshBakingForProp(string propId) { if (string.IsNullOrEmpty(propId)) { return; } foreach (LevelEditorObject @object in LevelEditorManager.Instance.Objects) { if (!((Object)(object)@object == (Object)null) && @object.physicsMode != PhysicsMode.Static && string.Equals(@object.addressableKey, propId, StringComparison.Ordinal)) { MaterialBaker.RestoreOriginal(((Component)@object).gameObject); MaterialBaker.Bake(((Component)@object).gameObject, propId); } } } public static void ClearPhysics(LevelEditorObject leo, bool restoreMaterial = true) { if ((Object)(object)leo == (Object)null || leo.physicsMode == PhysicsMode.Static) { return; } LevelEditorManager instance = LevelEditorManager.Instance; if (leo.physicsGroupId <= 0) { if (restoreMaterial) { MaterialBaker.RestoreOriginal(((Component)leo).gameObject); } RemoveGrabableComponents(((Component)leo).gameObject); if (restoreMaterial) { RebuildPropColliders(leo); } leo.isPhysicsManaged = false; leo.physicsMode = PhysicsMode.Static; leo.physicsGroupId = 0; instance.SyncLoopBase(leo); return; } int physicsGroupId = leo.physicsGroupId; GameObject groupRoot = GroupManager.GetGroupRoot(physicsGroupId); if ((Object)(object)groupRoot != (Object)null) { RemoveGrabableComponents(groupRoot); ((Object)groupRoot).name = "Group"; } foreach (LevelEditorObject @object in instance.Objects) { if (!((Object)(object)@object == (Object)null) && @object.physicsGroupId == physicsGroupId) { if (restoreMaterial) { MaterialBaker.RestoreOriginal(((Component)@object).gameObject); } if (restoreMaterial) { RebuildPropColliders(@object); } @object.physicsMode = PhysicsMode.Static; @object.physicsGroupId = 0; @object.isPhysicsManaged = false; instance.SyncLoopBase(@object); } } } private static void SetMeshCollidersConvex(GameObject go, bool convex) { if ((Object)(object)go == (Object)null) { return; } foreach (MeshCollider componentsInChild in go.GetComponentsInChildren(true)) { componentsInChild.convex = convex; } } private static void SetColliderLayers(GameObject go, int layer) { if ((Object)(object)go == (Object)null) { return; } foreach (Collider componentsInChild in go.GetComponentsInChildren(true)) { ((Component)componentsInChild).gameObject.layer = layer; } } private static float ComputePropMass(Collider[] colls) { float num = 0f; if (colls != null) { foreach (Collider val in colls) { if ((Object)(object)val != (Object)null && !val.isTrigger) { num += ColliderVolume(val); } } } float num2 = num * 500f; return Mathf.Clamp(num2, 0.1f, 200f); } private static float ColliderVolume(Collider c) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0224: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) Vector3 lossyScale = ((Component)c).transform.lossyScale; SphereCollider val = (SphereCollider)(object)((c is SphereCollider) ? c : null); if (val != null) { float num = val.radius * MaxAbs(lossyScale); return 4.1887903f * num * num * num; } BoxCollider val2 = (BoxCollider)(object)((c is BoxCollider) ? c : null); if (val2 != null) { Vector3 size = val2.size; return Mathf.Abs(size.x * lossyScale.x) * Mathf.Abs(size.y * lossyScale.y) * Mathf.Abs(size.z * lossyScale.z); } CapsuleCollider val3 = (CapsuleCollider)(object)((c is CapsuleCollider) ? c : null); if (val3 != null) { float num2; float num3; switch (val3.direction) { case 0: num2 = val3.radius * Mathf.Max(Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z)); num3 = Mathf.Max(0f, val3.height * Mathf.Abs(lossyScale.x) - 2f * num2); break; case 2: num2 = val3.radius * Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y)); num3 = Mathf.Max(0f, val3.height * Mathf.Abs(lossyScale.z) - 2f * num2); break; default: num2 = val3.radius * Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z)); num3 = Mathf.Max(0f, val3.height * Mathf.Abs(lossyScale.y) - 2f * num2); break; } return 4.1887903f * num2 * num2 * num2 + (float)Math.PI * num2 * num2 * num3; } MeshCollider val4 = (MeshCollider)(object)((c is MeshCollider) ? c : null); if (val4 != null && (Object)(object)val4.sharedMesh != (Object)null) { return MeshSignedVolume(val4.sharedMesh, lossyScale); } Bounds bounds = c.bounds; return ((Bounds)(ref bounds)).size.x * ((Bounds)(ref bounds)).size.y * ((Bounds)(ref bounds)).size.z * 0.5f; } private static float MeshSignedVolume(Mesh mesh, Vector3 scale) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) Il2CppStructArray vertices = mesh.vertices; Il2CppStructArray triangles = mesh.triangles; float num = 0f; for (int i = 0; i + 2 < ((Il2CppArrayBase)(object)triangles).Length; i += 3) { Vector3 val = Vector3.Scale(((Il2CppArrayBase)(object)vertices)[((Il2CppArrayBase)(object)triangles)[i]], scale); Vector3 val2 = Vector3.Scale(((Il2CppArrayBase)(object)vertices)[((Il2CppArrayBase)(object)triangles)[i + 1]], scale); Vector3 val3 = Vector3.Scale(((Il2CppArrayBase)(object)vertices)[((Il2CppArrayBase)(object)triangles)[i + 2]], scale); num += Vector3.Dot(val, Vector3.Cross(val2, val3)); } return Mathf.Abs(num) / 6f; } private static float MaxAbs(Vector3 v) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) return Mathf.Max(new float[3] { Mathf.Abs(v.x), Mathf.Abs(v.y), Mathf.Abs(v.z) }); } internal static void AddRigidBodyComponent(GameObject go, Collider[] colls, string propId = null) { Rigidbody val = go.GetComponent() ?? go.AddComponent(); val.mass = ComputePropMass(colls); val.isKinematic = false; val.useGravity = true; val.collisionDetectionMode = (CollisionDetectionMode)2; val.interpolation = (RigidbodyInterpolation)1; } internal static void AddGrabableComponent(GameObject go, bool isHat, Collider[] colls, string propId = null) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go == (Object)null) { return; } if (colls == null) { colls = Array.Empty(); } Hat component = go.GetComponent(); Grabable component2 = go.GetComponent(); Grabable val = null; if (isHat) { if ((Object)(object)component2 != (Object)null && (Object)(object)component == (Object)null) { Object.DestroyImmediate((Object)(object)component2); } val = (Grabable)(object)(((Object)(object)component != (Object)null) ? component : go.AddComponent()); } else { if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } val = (((Object)(object)component2 != (Object)null) ? component2 : go.AddComponent()); } if ((Object)(object)val == (Object)null) { return; } Rigidbody val2 = go.GetComponent() ?? go.AddComponent(); val2.mass = 5f; val2.isKinematic = true; val2.collisionDetectionMode = (CollisionDetectionMode)2; val2.interpolation = (RigidbodyInterpolation)1; Transform val3 = go.transform.Find("Crusher"); if ((Object)(object)val3 == (Object)null) { GameObject val4 = new GameObject("Crusher"); val4.transform.SetParent(go.transform, false); val3 = val4.transform; } ((Savable)val).rb = val2; val.rbs = new Il2CppReferenceArray(1L); ((Il2CppArrayBase)(object)val.rbs)[0] = val2; if (isHat) { Transform val5 = go.transform.Find("HatBoxTrigger"); if ((Object)(object)val5 == (Object)null) { GameObject val6 = new GameObject("HatBoxTrigger"); val6.transform.SetParent(go.transform, false); val5 = val6.transform; } BoxCollider val7 = ((Component)val5).GetComponent() ?? ((Component)val5).gameObject.AddComponent(); val7.size = new Vector3(0.01f, 0.01f, 0.01f); ((Collider)val7).isTrigger = true; int num = 0; for (int i = 0; i < colls.Length; i++) { if ((Object)(object)colls[i] != (Object)null && (Object)(object)colls[i] != (Object)(object)val7) { num++; } } Il2CppReferenceArray val8 = new Il2CppReferenceArray((long)(num + 1)); ((Il2CppArrayBase)(object)val8)[0] = (Collider)(object)val7; int num2 = 1; for (int j = 0; j < colls.Length; j++) { if ((Object)(object)colls[j] != (Object)null && (Object)(object)colls[j] != (Object)(object)val7) { ((Il2CppArrayBase)(object)val8)[num2++] = colls[j]; } } val.colls = val8; } else { val.colls = new Il2CppReferenceArray((long)colls.Length); for (int k = 0; k < colls.Length; k++) { if ((Object)(object)colls[k] != (Object)null) { ((Il2CppArrayBase)(object)val.colls)[k] = colls[k]; } } } val.crusher = val3; val.type = (GrabableType)(isHat ? 1 : 2); if (isHat) { Hat val9 = (Hat)(object)((val is Hat) ? val : null); if (val9 != null) { val9.enableOnWear = new Il2CppReferenceArray(0L); val9.disableOnWear = new Il2CppReferenceArray(0L); } } List val10 = new List(); List val11 = new List(); List val12 = new List(); List val13 = new List(); val10.Add(Vector3.zero); val11.Add(Quaternion.identity); val12.Add(Vector3.zero); val13.Add(Quaternion.identity); val.grabLocPtsR = val10; val.grabLocRotsR = val11; val.grabLocPtsL = val12; val.grabLocRotsL = val13; AddFloater(go); } private static void AddFloater(GameObject go) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)go == (Object)null)) { Transform val = go.transform.Find("Floater"); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } MeshFilter componentInChildren = go.GetComponentInChildren(); Mesh val2 = ((componentInChildren != null) ? componentInChildren.sharedMesh : null); Mesh val3 = null; if ((Object)(object)val2 != (Object)null) { val3 = ((val2.vertexCount > 5000) ? BuildBoundsMesh(val2.bounds) : BuildPhysicsMesh(val2)); } if ((Object)(object)val3 == (Object)null) { MelonLogger.Warning("[BabyBlocks] AddFloater: could not build floater mesh, skipping Floater."); return; } GameObject val4 = new GameObject("Floater"); val4.SetActive(false); val4.transform.SetParent(go.transform, false); val4.layer = go.layer; MeshFilter val5 = val4.AddComponent(); val5.sharedMesh = val3; WaterObject val6 = val4.AddComponent(); val6.convexifyMesh = true; val6.simplifyMesh = true; val6.targetTriangleCount = 16; val6.calculateWaterNormals = true; val6.GenerateSimMesh(); val4.SetActive(true); } } private static Mesh BuildBoundsMesh(Bounds b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh(); Vector3 center = ((Bounds)(ref b)).center; Vector3 extents = ((Bounds)(ref b)).extents; val.vertices = Il2CppStructArray.op_Implicit((Vector3[])(object)new Vector3[8] { new Vector3(center.x - extents.x, center.y - extents.y, center.z - extents.z), new Vector3(center.x + extents.x, center.y - extents.y, center.z - extents.z), new Vector3(center.x + extents.x, center.y + extents.y, center.z - extents.z), new Vector3(center.x - extents.x, center.y + extents.y, center.z - extents.z), new Vector3(center.x - extents.x, center.y - extents.y, center.z + extents.z), new Vector3(center.x + extents.x, center.y - extents.y, center.z + extents.z), new Vector3(center.x + extents.x, center.y + extents.y, center.z + extents.z), new Vector3(center.x - extents.x, center.y + extents.y, center.z + extents.z) }); val.triangles = Il2CppStructArray.op_Implicit(new int[36] { 0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 3, 6, 2, 3, 7, 6, 0, 4, 7, 0, 7, 3, 1, 2, 6, 1, 6, 5 }); val.RecalculateNormals(); return val; } internal static void RemoveGrabableComponents(GameObject go) { //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) Hat component = go.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } else { Grabable component2 = go.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } } Rigidbody component3 = go.GetComponent(); if ((Object)(object)component3 != (Object)null) { Object.DestroyImmediate((Object)(object)component3); } Transform val = go.transform.Find("Crusher"); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } Transform val2 = go.transform.Find("Floater"); if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val2).gameObject); } Transform val3 = go.transform.Find("HatBoxTrigger"); if ((Object)(object)val3 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val3).gameObject); } Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(0.01f, 0.01f, 0.01f); foreach (BoxCollider component4 in go.GetComponents()) { if (((Collider)component4).isTrigger && component4.size == val4) { Object.DestroyImmediate((Object)(object)component4); } } } } internal static class GroupManager { private static readonly Dictionary _groupDisplayScales = new Dictionary(); public static int AllocateGroupId() { return LevelEditorManager.Instance._nextGroupId++; } internal static GameObject GetGroupRoot(int groupId) { if (groupId <= 0) { return null; } LevelEditorManager.Instance._groupRoots.TryGetValue(groupId, out var value); return ((Object)(object)value != (Object)null) ? value : null; } private static void SetGroupRoot(int groupId, GameObject root) { if (groupId > 0 && (Object)(object)root != (Object)null) { LevelEditorManager.Instance._groupRoots[groupId] = root; } } private static void RemoveGroupRoot(int groupId) { LevelEditorManager.Instance._groupRoots.Remove(groupId); } public static Vector3 GetGroupDisplayScale(int groupId) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (groupId > 0 && _groupDisplayScales.TryGetValue(groupId, out var value)) { return value; } return Vector3.one; } public static void SetGroupDisplayScale(int groupId, Vector3 scale) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) _groupDisplayScales[groupId] = scale; GameObject groupRoot = GetGroupRoot(groupId); if ((Object)(object)groupRoot != (Object)null) { groupRoot.transform.localScale = scale; } } public static void RemoveGroupDisplayScale(int groupId) { _groupDisplayScales.Remove(groupId); } public static IEnumerable> GetAllGroupDisplayScales() { return _groupDisplayScales; } internal static void FreezeRigidBodyGroupForEditor(int physicsGroupId) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) LevelEditorManager instance = LevelEditorManager.Instance; List list = instance.Objects.Where((LevelEditorObject o) => (Object)(object)o != (Object)null && o.physicsMode == PhysicsMode.Rigidbody && o.physicsGroupId == physicsGroupId).ToList(); if (list.Count == 0) { return; } GameObject val = FindGroupRoot(list) ?? ActivateRigidbodyGroup(list); if ((Object)(object)val == (Object)null) { return; } Vector3 val2 = Vector3.zero; foreach (LevelEditorObject item in list) { val2 += (item.hasLoopBasePosition ? item.loopBasePosition : ((Component)item).transform.position); } val2 /= (float)list.Count; PhysicsObjectManager.SetHierarchyCollisions(val, enabled: false); val.transform.position = val2; foreach (LevelEditorObject item2 in list) { PhysicsObjectManager.RestoreBasePose(item2); } PhysicsObjectManager.FreezeRigidBodyGameObject(val, freeze: true); PhysicsObjectManager.SetHierarchyCollisions(val, enabled: true); foreach (LevelEditorObject item3 in list) { item3.isPhysicsManaged = true; } } internal static void UnfreezeRigidBodyGroup(int physicsGroupId) { LevelEditorManager instance = LevelEditorManager.Instance; List list = instance.Objects.Where((LevelEditorObject o) => (Object)(object)o != (Object)null && o.physicsMode == PhysicsMode.Rigidbody && o.physicsGroupId == physicsGroupId).ToList(); if (list.Count == 0) { return; } GameObject val = FindGroupRoot(list); if ((Object)(object)val == (Object)null) { return; } PhysicsObjectManager.FreezeRigidBodyGameObject(val, freeze: false); foreach (LevelEditorObject item in list) { item.isPhysicsManaged = true; } } internal static void CleanupGroupRoot(int groupId) { if (groupId <= 0) { return; } GameObject groupRoot = GetGroupRoot(groupId); if ((Object)(object)groupRoot == (Object)null) { RemoveGroupRoot(groupId); return; } for (int i = 0; i < groupRoot.transform.childCount; i++) { if ((Object)(object)((Component)groupRoot.transform.GetChild(i)).GetComponent() != (Object)null) { return; } } RemoveGroupRoot(groupId); Object.Destroy((Object)(object)groupRoot); } [HideFromIl2Cpp] private static GameObject FindGroupRoot(List members) { if (members == null || members.Count == 0) { return null; } int groupId = ((members[0].physicsGroupId > 0) ? members[0].physicsGroupId : members[0].groupId); return GetGroupRoot(groupId); } internal static void DeactivateGroupForEditor(int physicsGroupId) { LevelEditorManager instance = LevelEditorManager.Instance; List list = instance.Objects.Where((LevelEditorObject o) => (Object)(object)o != (Object)null && o.physicsGroupId == physicsGroupId).ToList(); if (list.Count == 0) { return; } GameObject groupRoot = GetGroupRoot(physicsGroupId); if ((Object)(object)groupRoot != (Object)null) { PhysicsObjectManager.SetHierarchyCollisions(groupRoot, enabled: false); GameObject propsContainer = LevelEditorManager.PropsContainer; while (groupRoot.transform.childCount > 0) { Transform child = groupRoot.transform.GetChild(0); child.SetParent(((Object)(object)propsContainer != (Object)null) ? propsContainer.transform : null, true); PhysicsObjectManager.SetHierarchyCollisions(((Component)child).gameObject, enabled: true); LevelEditorObject component = ((Component)child).GetComponent(); if ((Object)(object)component != (Object)null) { PhysicsObjectManager.RestoreBasePose(component); component.isPhysicsManaged = false; } } RemoveGroupRoot(physicsGroupId); Object.Destroy((Object)(object)groupRoot); } else { foreach (LevelEditorObject item in list) { PhysicsObjectManager.RemoveGrabableComponents(((Component)item).gameObject); PhysicsObjectManager.RestoreBasePose(item); item.isPhysicsManaged = false; } } foreach (IGrouping item2 in from m in list where (Object)(object)m != (Object)null && m.groupId > 0 group m by m.groupId) { EnsureStaticGroupRoot(item2.Key, item2.ToList()); } } public static void ApplyGroups() { LevelEditorManager instance = LevelEditorManager.Instance; List list = new List(); Dictionary> dictionary = new Dictionary>(); List list2 = new List(); Dictionary> dictionary2 = new Dictionary>(); int num = 0; foreach (LevelEditorObject @object in instance.Objects) { if ((Object)(object)@object == (Object)null || @object.physicsMode == PhysicsMode.Static) { continue; } if (@object.groupId > num) { num = @object.groupId; } if (@object.physicsGroupId > num) { num = @object.physicsGroupId; } if (@object.physicsMode == PhysicsMode.Rigidbody) { if (@object.physicsGroupId <= 0) { list.Add(@object); continue; } if (!dictionary.TryGetValue(@object.physicsGroupId, out var value)) { value = new List(); dictionary[@object.physicsGroupId] = value; } value.Add(@object); } else if (@object.physicsGroupId <= 0) { list2.Add(@object); } else { if (!dictionary2.TryGetValue(@object.physicsGroupId, out var value2)) { value2 = new List(); dictionary2[@object.physicsGroupId] = value2; } value2.Add(@object); } } foreach (LevelEditorObject item in list) { Il2CppArrayBase componentsInChildren = ((Component)item).gameObject.GetComponentsInChildren(true); PhysicsObjectManager.AddRigidBodyComponent(((Component)item).gameObject, Il2CppArrayBase.op_Implicit(componentsInChildren), item.addressableKey); PhysicsObjectManager.FreezeRigidBodyObject(item, instance._editorModeActive); PhysicsObjectManager.MarkPhysicsChunkIndependent(item); item.isPhysicsManaged = true; } foreach (KeyValuePair> item2 in dictionary) { List value3 = item2.Value; if (value3.Count == 0) { continue; } GameObject val = FindGroupRoot(value3) ?? ActivateRigidbodyGroup(value3); if ((Object)(object)val != (Object)null) { PhysicsObjectManager.FreezeRigidBodyGameObject(val, instance._editorModeActive); } foreach (LevelEditorObject item3 in value3) { PhysicsObjectManager.MarkPhysicsChunkIndependent(item3); item3.isPhysicsManaged = true; } } foreach (LevelEditorObject item4 in list2) { Il2CppArrayBase componentsInChildren2 = ((Component)item4).gameObject.GetComponentsInChildren(true); PhysicsObjectManager.AddGrabableComponent(((Component)item4).gameObject, item4.physicsMode == PhysicsMode.Hat, Il2CppArrayBase.op_Implicit(componentsInChildren2), item4.addressableKey); PhysicsObjectManager.SyncHatHairAmount(item4); if (item4.physicsMode == PhysicsMode.Grabable || item4.physicsMode == PhysicsMode.Hat) { PhysicsObjectManager.SyncGrabOffset(item4); } PhysicsObjectManager.MarkPhysicsChunkIndependent(item4); item4.isPhysicsManaged = true; } foreach (KeyValuePair> item5 in dictionary2) { List value4 = item5.Value; if (value4.Count != 0) { ActivateWearableGroup(value4, value4[0].physicsMode); } } if (num >= instance._nextGroupId) { instance._nextGroupId = num + 1; } } [HideFromIl2Cpp] internal static GameObject ActivateRigidbodyGroup(List members) { //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) if (members == null || members.Count == 0) { return null; } int num = ((members[0].physicsGroupId > 0) ? members[0].physicsGroupId : members[0].groupId); GameObject propsContainer = LevelEditorManager.PropsContainer; GameObject val = FindGroupRoot(members); if ((Object)(object)val != (Object)null) { ((Object)val).name = "PhysicsGroup"; PhysicsObjectManager.RemoveGrabableComponents(val); List list = new List(); foreach (LevelEditorObject member in members) { Transform parent = ((Component)member).transform.parent; GameObject val2 = ((parent != null) ? ((Component)parent).gameObject : null); if ((Object)(object)val2 == (Object)null || ((Object)val2).GetInstanceID() != ((Object)val).GetInstanceID()) { ((Component)member).transform.SetParent(val.transform, true); } foreach (Collider componentsInChild in ((Component)member).gameObject.GetComponentsInChildren(true)) { list.Add(componentsInChild); } member.isPhysicsManaged = true; } PhysicsObjectManager.AddRigidBodyComponent(val, list.ToArray()); PhysicsObjectManager.FreezeRigidBodyGameObject(val, LevelEditorManager.Instance._editorModeActive); foreach (LevelEditorObject member2 in members) { PhysicsObjectManager.MarkPhysicsChunkIndependent(member2); } return val; } Vector3 val3 = Vector3.zero; foreach (LevelEditorObject member3 in members) { val3 += (member3.hasLoopBasePosition ? member3.loopBasePosition : ((Component)member3).transform.position); } val3 /= (float)members.Count; GameObject val4 = new GameObject("PhysicsGroup"); val4.transform.position = val3; if ((Object)(object)propsContainer != (Object)null) { val4.transform.SetParent(propsContainer.transform, true); } List list2 = new List(); foreach (LevelEditorObject member4 in members) { foreach (Collider componentsInChild2 in ((Component)member4).gameObject.GetComponentsInChildren(true)) { list2.Add(componentsInChild2); } ((Component)member4).gameObject.transform.SetParent(val4.transform, true); member4.isPhysicsManaged = true; } PhysicsObjectManager.AddRigidBodyComponent(val4, list2.ToArray()); PhysicsObjectManager.FreezeRigidBodyGameObject(val4, LevelEditorManager.Instance._editorModeActive); foreach (LevelEditorObject member5 in members) { PhysicsObjectManager.MarkPhysicsChunkIndependent(member5); } if (num > 0) { SetGroupRoot(num, val4); } return val4; } [HideFromIl2Cpp] internal static void ActivateWearableGroup(List members, PhysicsMode mode) { //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Expected O, but got Unknown //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) if (members == null || members.Count == 0) { return; } int num = ((members[0].physicsGroupId > 0) ? members[0].physicsGroupId : members[0].groupId); GameObject propsContainer = LevelEditorManager.PropsContainer; GameObject val = FindGroupRoot(members); if ((Object)(object)val != (Object)null) { ((Object)val).name = "PhysicsGroup"; PhysicsObjectManager.RemoveGrabableComponents(val); List list = new List(); foreach (LevelEditorObject member in members) { Transform parent = ((Component)member).transform.parent; GameObject val2 = ((parent != null) ? ((Component)parent).gameObject : null); if ((Object)(object)val2 == (Object)null || ((Object)val2).GetInstanceID() != ((Object)val).GetInstanceID()) { ((Component)member).transform.SetParent(val.transform, true); } foreach (Collider componentsInChild in ((Component)member).gameObject.GetComponentsInChildren(true)) { list.Add(componentsInChild); } member.isPhysicsManaged = true; } PhysicsObjectManager.AddGrabableComponent(val, mode == PhysicsMode.Hat, list.ToArray()); if (mode == PhysicsMode.Hat) { Hat component = val.GetComponent(); if ((Object)(object)component != (Object)null) { foreach (LevelEditorObject member2 in members) { if ((Object)(object)member2 != (Object)null && BbHatSunglassesFlag.Has(member2)) { component.isSunglasses = true; break; } } } } if (mode == PhysicsMode.Hat && members.Count > 0) { PhysicsObjectManager.SyncHatHairAmount(members[0]); } if ((mode == PhysicsMode.Grabable || mode == PhysicsMode.Hat) && members.Count > 0) { PhysicsObjectManager.SyncGrabOffset(members[0]); } { foreach (LevelEditorObject member3 in members) { PhysicsObjectManager.MarkPhysicsChunkIndependent(member3); } return; } } Vector3 val3 = Vector3.zero; foreach (LevelEditorObject member4 in members) { val3 += (member4.hasLoopBasePosition ? member4.loopBasePosition : ((Component)member4).transform.position); } val3 /= (float)members.Count; GameObject val4 = new GameObject("PhysicsGroup"); val4.transform.position = val3; if ((Object)(object)propsContainer != (Object)null) { val4.transform.SetParent(propsContainer.transform, true); } List list2 = new List(); foreach (LevelEditorObject member5 in members) { foreach (Collider componentsInChild2 in ((Component)member5).gameObject.GetComponentsInChildren(true)) { list2.Add(componentsInChild2); } ((Component)member5).gameObject.transform.SetParent(val4.transform, true); member5.isPhysicsManaged = true; } PhysicsObjectManager.AddGrabableComponent(val4, mode == PhysicsMode.Hat, list2.ToArray()); if (mode == PhysicsMode.Hat) { Hat component2 = val4.GetComponent(); if ((Object)(object)component2 != (Object)null) { foreach (LevelEditorObject member6 in members) { if ((Object)(object)member6 != (Object)null && BbHatSunglassesFlag.Has(member6)) { component2.isSunglasses = true; break; } } } } if (mode == PhysicsMode.Hat && members.Count > 0) { PhysicsObjectManager.SyncHatHairAmount(members[0]); } if (mode == PhysicsMode.Grabable && members.Count > 0) { PhysicsObjectManager.SyncGrabOffset(members[0]); } foreach (LevelEditorObject member7 in members) { PhysicsObjectManager.MarkPhysicsChunkIndependent(member7); } if (num > 0) { SetGroupRoot(num, val4); } } [HideFromIl2Cpp] internal static void DissolveGroup(int groupId) { if (groupId <= 0) { return; } LevelEditorManager instance = LevelEditorManager.Instance; GameObject groupRoot = GetGroupRoot(groupId); if ((Object)(object)groupRoot != (Object)null) { PhysicsObjectManager.RemoveGrabableComponents(groupRoot); GameObject propsContainer = LevelEditorManager.PropsContainer; while (groupRoot.transform.childCount > 0) { Transform child = groupRoot.transform.GetChild(0); child.SetParent(((Object)(object)propsContainer != (Object)null) ? propsContainer.transform : null, true); LevelEditorObject component = ((Component)child).GetComponent(); if ((Object)(object)component != (Object)null) { if (component.physicsMode != PhysicsMode.Static) { MaterialBaker.RestoreOriginal(((Component)component).gameObject); } instance.SyncLoopBase(component); component.physicsMode = PhysicsMode.Static; component.physicsGroupId = 0; component.groupId = 0; component.isPhysicsManaged = false; } } RemoveGroupRoot(groupId); RemoveGroupDisplayScale(groupId); Object.Destroy((Object)(object)groupRoot); return; } foreach (LevelEditorObject @object in instance.Objects) { if (!((Object)(object)@object == (Object)null) && @object.groupId == groupId) { if (@object.physicsMode != PhysicsMode.Static) { MaterialBaker.RestoreOriginal(((Component)@object).gameObject); } PhysicsObjectManager.RemoveGrabableComponents(((Component)@object).gameObject); @object.physicsMode = PhysicsMode.Static; @object.physicsGroupId = 0; @object.groupId = 0; @object.isPhysicsManaged = false; } } RemoveGroupDisplayScale(groupId); } [HideFromIl2Cpp] internal static void EnsureStaticGroupRoot(int groupId, List members) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00ab: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (groupId <= 0 || members == null || members.Count == 0) { return; } GameObject val = GetGroupRoot(groupId); if ((Object)(object)val == (Object)null) { Vector3 val2 = Vector3.zero; foreach (LevelEditorObject member in members) { val2 += (member.hasLoopBasePosition ? member.loopBasePosition : ((Component)member).transform.position); } val2 /= (float)members.Count; val = new GameObject("Group"); val.transform.position = val2; GameObject propsContainer = LevelEditorManager.PropsContainer; if ((Object)(object)propsContainer != (Object)null) { val.transform.SetParent(propsContainer.transform, true); } SetGroupRoot(groupId, val); val.transform.localScale = GetGroupDisplayScale(groupId); } foreach (LevelEditorObject member2 in members) { if (!((Object)(object)member2 == (Object)null)) { Transform parent = ((Component)member2).transform.parent; GameObject val3 = ((parent != null) ? ((Component)parent).gameObject : null); if ((Object)(object)val3 == (Object)null || ((Object)val3).GetInstanceID() != ((Object)val).GetInstanceID()) { ((Component)member2).transform.SetParent(val.transform, true); } } } } } public static class MaterialBaker { public sealed class BakedPartData { public string rendererPath; public Vector3[] positions; public Vector3[] normals; public Vector2[] uv; public int[] triangles; public byte[] atlasImage; } private sealed class BakeLightingOverride { public Light[] lights; public bool[] lightWasEnabled; public ReflectionProbe[] probes; public bool[] probeWasEnabled; public AmbientMode prevAmbientMode; public Color prevAmbientLight; public DefaultReflectionMode prevReflectionMode; public Texture prevReflectionTexture; public float prevReflectionIntensity; public GameObject bakeLightGO; public Light bakeLight; } private struct TriCell { public int triIndex; public Vector2 p0; public Vector2 p1; public Vector2 p2; public float w; public float h; public int dir; public int cellX; public int cellY; public int cellW; public int cellH; } private static readonly Dictionary _bakeStash = new Dictionary(); private static readonly Vector3[] BakeDirs = (Vector3[])(object)new Vector3[6] { Vector3.right, Vector3.left, Vector3.up, Vector3.down, Vector3.forward, Vector3.back }; private static readonly Vector3[] BakeUps = (Vector3[])(object)new Vector3[6] { Vector3.up, Vector3.up, Vector3.forward, Vector3.forward, Vector3.up, Vector3.up }; private const int CapturePx = 512; private const float CaptureAmbient = 0.3f; private const float BakeLightIntensity = 0.001f; private static Cubemap _neutralCubemap; private static readonly MaterialPropertyBlock _bakeMPB = new MaterialPropertyBlock(); private static Material _maskMat; private static readonly RenderTexture[] _captureRTs = (RenderTexture[])(object)new RenderTexture[6]; private static readonly RenderTexture[] _maskRTs = (RenderTexture[])(object)new RenderTexture[6]; private static Texture2D _captureTex; private static Texture2D _maskTex; private const float CaptureTargetBrightness = 0.15f; private const float TexelsPerUnit = 1024f; private const int AtlasPadding = 2; private const int MinAtlasSize = 256; private const int MaxAtlasSize = 2048; private static readonly string[] BakedAtlasTexProps = new string[4] { "_MainTex", "_BaseMap", "_BaseColorMap", "_UnlitColorMap" }; public static void Bake(GameObject root, string propId = null) { //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(propId) && PropMetadataStore.GetDisableBaking(propId)) { return; } string materialKey = null; List list = null; if (!string.IsNullOrEmpty(propId)) { materialKey = PropMetadataStore.GetMaterialCacheKey(propId); list = MaterialBakeCache.TryLoad(propId, materialKey); if (list != null) { ImportBakedData(root, list); } } BakeLightingOverride bakeLightingOverride = OverrideLightingForBake(); List list2 = new List(); Vector3 localScale = root.transform.localScale; try { root.transform.localScale = Vector3.one; int drawLayer = FindUnusedLayer(); foreach (MeshRenderer componentsInChild in root.GetComponentsInChildren(true)) { int instanceID = ((Object)componentsInChild).GetInstanceID(); if (_bakeStash.ContainsKey(instanceID)) { continue; } LevelEditorObject componentInParent = ((Component)componentsInChild).GetComponentInParent(); string text = (((Object)(object)componentInParent != (Object)null) ? componentInParent.addressableKey : propId); if (!string.IsNullOrEmpty(text) && PropMetadataStore.GetDisableBaking(text)) { continue; } MeshFilter component = ((Component)componentsInChild).GetComponent(); if ((Object)(object)component == (Object)null) { continue; } Mesh sharedMesh = component.sharedMesh; if (!((Object)(object)sharedMesh == (Object)null)) { Il2CppReferenceArray sharedMaterials = ((Renderer)componentsInChild).sharedMaterials; if (sharedMaterials != null && ((Il2CppArrayBase)(object)sharedMaterials).Length != 0 && TryReadMeshForBake(sharedMesh, out var positions, out var normals, out var submeshTris)) { _bakeStash[instanceID] = (sharedMesh, Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)((Renderer)componentsInChild).sharedMaterials)); BakeOne(componentsInChild, component, sharedMesh, Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)sharedMaterials), positions, normals, submeshTris, bakeLightingOverride, drawLayer); list2.Add(componentsInChild); } } } } finally { root.transform.localScale = localScale; RestoreLighting(bakeLightingOverride); } if (string.IsNullOrEmpty(propId)) { return; } if (list == null) { List list3 = ExportBakedData(root); if (list3.Count > 0) { MaterialBakeCache.Save(propId, materialKey, list3); } } else if (list2.Count > 0) { List list4 = ExportBakedData(root, list2); if (list4.Count > 0) { list.AddRange(list4); MaterialBakeCache.Save(propId, materialKey, list); } } } public static void RestoreOriginal(GameObject root) { foreach (MeshRenderer componentsInChild in root.GetComponentsInChildren(true)) { MeshFilter component = ((Component)componentsInChild).GetComponent(); if (!((Object)(object)component == (Object)null)) { int instanceID = ((Object)componentsInChild).GetInstanceID(); if (_bakeStash.TryGetValue(instanceID, out (Mesh, Material[]) value)) { component.sharedMesh = value.Item1; ((Renderer)componentsInChild).sharedMaterials = Il2CppReferenceArray.op_Implicit(value.Item2); _bakeStash.Remove(instanceID); } } } } public static List ExportBakedData(GameObject root) { return ExportBakedData(root, null); } public static List ExportBakedData(GameObject root, ICollection only) { List list = new List(); foreach (MeshRenderer componentsInChild in root.GetComponentsInChildren(true)) { if (only != null && !only.Contains(componentsInChild)) { continue; } if (!_bakeStash.ContainsKey(((Object)componentsInChild).GetInstanceID())) { MelonLogger.Warning($"[BabyBlocks] ExportBakedData \"{((Object)componentsInChild).name}\": no _bakeStash entry (instanceId={((Object)componentsInChild).GetInstanceID()}, stashCount={_bakeStash.Count})"); continue; } MeshFilter component = ((Component)componentsInChild).GetComponent(); Mesh val = (((Object)(object)component != (Object)null) ? component.sharedMesh : null); Material val2 = ((((Renderer)componentsInChild).sharedMaterials != null && ((Il2CppArrayBase)(object)((Renderer)componentsInChild).sharedMaterials).Length > 0) ? ((Il2CppArrayBase)(object)((Renderer)componentsInChild).sharedMaterials)[0] : null); Texture2D bakedAtlasTexture = GetBakedAtlasTexture(val2); if ((Object)(object)val == (Object)null || (Object)(object)bakedAtlasTexture == (Object)null) { MelonLogger.Warning($"[BabyBlocks] ExportBakedData \"{((Object)componentsInChild).name}\": skipped (mesh={(Object)(object)val != (Object)null}, atlas={(Object)(object)bakedAtlasTexture != (Object)null}, mat={(((Object)(object)val2 != (Object)null) ? ((Object)val2.shader).name : "null")})"); } else { list.Add(new BakedPartData { rendererPath = GetRelativePath(root.transform, ((Component)componentsInChild).transform), positions = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)val.vertices), normals = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)val.normals), uv = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)val.uv), triangles = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)val.triangles), atlasImage = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)ImageConversion.EncodeToJPG(bakedAtlasTexture, 90)) }); } } return list; } public static void ImportBakedData(GameObject root, List parts) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown if ((Object)(object)root == (Object)null || parts == null) { return; } foreach (BakedPartData part in parts) { Transform val = ResolvePath(root.transform, part.rendererPath); if ((Object)(object)val == (Object)null) { continue; } MeshRenderer component = ((Component)val).GetComponent(); MeshFilter component2 = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { continue; } int instanceID = ((Object)component).GetInstanceID(); if (_bakeStash.ContainsKey(instanceID)) { continue; } Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false, true) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; if (!ImageConversion.LoadImage(val2, Il2CppStructArray.op_Implicit(part.atlasImage), true)) { Object.Destroy((Object)(object)val2); continue; } Mesh val3 = new Mesh { name = (((Object)(object)component2.sharedMesh != (Object)null) ? ((Object)component2.sharedMesh).name : "Mesh") + "_baked" }; if (part.positions.Length > 65535) { val3.indexFormat = (IndexFormat)1; } val3.vertices = Il2CppStructArray.op_Implicit(part.positions); val3.normals = Il2CppStructArray.op_Implicit(part.normals); val3.uv = Il2CppStructArray.op_Implicit(part.uv); val3.SetTriangles(Il2CppStructArray.op_Implicit(part.triangles), 0); val3.RecalculateBounds(); _bakeStash[instanceID] = (component2.sharedMesh, Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)((Renderer)component).sharedMaterials)); component2.sharedMesh = val3; ((Renderer)component).sharedMaterials = Il2CppReferenceArray.op_Implicit((Material[])(object)new Material[1] { CreateBakedMaterial(_bakeStash[instanceID].mats, val2) }); } } internal static void WritePartList(BinaryWriter bw, List parts) { bw.Write(parts.Count); foreach (BakedPartData part in parts) { WriteStr(bw, part.rendererPath); int num = part.positions.Length; bw.Write(num); for (int i = 0; i < num; i++) { bw.Write(part.positions[i].x); bw.Write(part.positions[i].y); bw.Write(part.positions[i].z); } for (int j = 0; j < num; j++) { bw.Write(part.normals[j].x); bw.Write(part.normals[j].y); bw.Write(part.normals[j].z); } for (int k = 0; k < num; k++) { bw.Write(part.uv[k].x); bw.Write(part.uv[k].y); } bw.Write(part.triangles.Length); int[] triangles = part.triangles; foreach (int value in triangles) { bw.Write(value); } bw.Write(part.atlasImage.Length); bw.Write(part.atlasImage); } } internal static List ReadPartList(BinaryReader br) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) int num = br.ReadInt32(); List list = new List(num); for (int i = 0; i < num; i++) { BakedPartData bakedPartData = new BakedPartData { rendererPath = ReadStr(br) }; int num2 = br.ReadInt32(); bakedPartData.positions = (Vector3[])(object)new Vector3[num2]; for (int j = 0; j < num2; j++) { bakedPartData.positions[j] = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); } bakedPartData.normals = (Vector3[])(object)new Vector3[num2]; for (int k = 0; k < num2; k++) { bakedPartData.normals[k] = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); } bakedPartData.uv = (Vector2[])(object)new Vector2[num2]; for (int l = 0; l < num2; l++) { bakedPartData.uv[l] = new Vector2(br.ReadSingle(), br.ReadSingle()); } int num3 = br.ReadInt32(); bakedPartData.triangles = new int[num3]; for (int m = 0; m < num3; m++) { bakedPartData.triangles[m] = br.ReadInt32(); } int count = br.ReadInt32(); bakedPartData.atlasImage = br.ReadBytes(count); list.Add(bakedPartData); } return list; } internal static void WriteStr(BinaryWriter w, string s) { byte[] bytes = Encoding.UTF8.GetBytes(s ?? ""); w.Write(bytes.Length); w.Write(bytes); } internal static string ReadStr(BinaryReader r) { int count = r.ReadInt32(); return Encoding.UTF8.GetString(r.ReadBytes(count)); } private static string GetRelativePath(Transform root, Transform target) { List list = new List(); Transform val = target; while ((Object)(object)val != (Object)(object)root) { if ((Object)(object)val == (Object)null) { return null; } list.Add(val.GetSiblingIndex()); val = val.parent; } list.Reverse(); return string.Join("/", list); } private static Transform ResolvePath(Transform root, string path) { Transform val = root; if (string.IsNullOrEmpty(path)) { return val; } string[] array = path.Split('/'); foreach (string s in array) { if ((Object)(object)val == (Object)null || !int.TryParse(s, out var result) || result < 0 || result >= val.childCount) { return null; } val = val.GetChild(result); } return val; } private static void BakeOne(MeshRenderer mr, MeshFilter mf, Mesh srcMesh, Material[] mats, Vector3[] positions, Vector3[] normals, int[][] submeshTris, BakeLightingOverride lightingOverride, int drawLayer) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown ClassifyTriangleDirections(positions, normals, submeshTris, ((Component)mr).transform, out var triDir, out var dirUsed); Bounds bounds = ((Renderer)mr).bounds; GameObject[] array = (GameObject[])(object)new GameObject[6]; Camera[] array2 = (Camera[])(object)new Camera[6]; Color[][] array3 = new Color[6][]; try { for (int i = 0; i < 6; i++) { if (dirUsed[i]) { array[i] = CreateBakeCamera(bounds, BakeDirs[i], BakeUps[i], drawLayer, out array2[i]); ((Component)lightingOverride.bakeLight).transform.rotation = Quaternion.LookRotation(-BakeDirs[i], BakeUps[i]); IssueCaptureRenders(srcMesh, mats, ((Component)mr).transform.localToWorldMatrix, array2[i], drawLayer, 512, i); } } for (int j = 0; j < 6; j++) { if (dirUsed[j]) { array3[j] = ReadbackCapture(j, 512); } } Vector2[][] outUV; Texture2D atlas = BuildPerTriangleAtlas(positions, submeshTris, ((Component)mr).transform, triDir, array2, array3, 512, out outUV); BuildBakedMeshData(positions, normals, submeshTris, outUV, out var outPositions, out var outNormals, out var outUV2, out var outTris); Mesh val = new Mesh { name = ((Object)srcMesh).name + "_baked" }; if (outPositions.Length > 65535) { val.indexFormat = (IndexFormat)1; } val.vertices = Il2CppStructArray.op_Implicit(outPositions); val.normals = Il2CppStructArray.op_Implicit(outNormals); val.uv = Il2CppStructArray.op_Implicit(outUV2); val.SetTriangles(Il2CppStructArray.op_Implicit(outTris), 0); val.RecalculateBounds(); mf.sharedMesh = val; ((Renderer)mr).sharedMaterials = Il2CppReferenceArray.op_Implicit((Material[])(object)new Material[1] { CreateBakedMaterial(mats, atlas) }); } finally { for (int k = 0; k < 6; k++) { if ((Object)(object)array[k] != (Object)null) { Object.Destroy((Object)(object)array[k]); } } } } private static BakeLightingOverride OverrideLightingForBake() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) BakeLightingOverride bakeLightingOverride = new BakeLightingOverride(); bakeLightingOverride.lights = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType()); bakeLightingOverride.lightWasEnabled = new bool[bakeLightingOverride.lights.Length]; for (int i = 0; i < bakeLightingOverride.lights.Length; i++) { bakeLightingOverride.lightWasEnabled[i] = ((Behaviour)bakeLightingOverride.lights[i]).enabled; ((Behaviour)bakeLightingOverride.lights[i]).enabled = false; } bakeLightingOverride.probes = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType()); bakeLightingOverride.probeWasEnabled = new bool[bakeLightingOverride.probes.Length]; for (int j = 0; j < bakeLightingOverride.probes.Length; j++) { bakeLightingOverride.probeWasEnabled[j] = ((Behaviour)bakeLightingOverride.probes[j]).enabled; ((Behaviour)bakeLightingOverride.probes[j]).enabled = false; } bakeLightingOverride.prevAmbientMode = RenderSettings.ambientMode; bakeLightingOverride.prevAmbientLight = RenderSettings.ambientLight; RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = Color.white * 0.3f; bakeLightingOverride.prevReflectionMode = RenderSettings.defaultReflectionMode; bakeLightingOverride.prevReflectionTexture = RenderSettings.customReflectionTexture; bakeLightingOverride.prevReflectionIntensity = RenderSettings.reflectionIntensity; RenderSettings.defaultReflectionMode = (DefaultReflectionMode)1; RenderSettings.customReflectionTexture = (Texture)(object)NeutralCubemap(); RenderSettings.reflectionIntensity = 0f; bakeLightingOverride.bakeLightGO = new GameObject("BabyBlocks_BakeLight"); bakeLightingOverride.bakeLight = bakeLightingOverride.bakeLightGO.AddComponent(); bakeLightingOverride.bakeLight.type = (LightType)1; bakeLightingOverride.bakeLight.color = Color.white; bakeLightingOverride.bakeLight.intensity = 0.001f; bakeLightingOverride.bakeLight.shadows = (LightShadows)0; return bakeLightingOverride; } private static void RestoreLighting(BakeLightingOverride o) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < o.lights.Length; i++) { if ((Object)(object)o.lights[i] != (Object)null) { ((Behaviour)o.lights[i]).enabled = o.lightWasEnabled[i]; } } for (int j = 0; j < o.probes.Length; j++) { if ((Object)(object)o.probes[j] != (Object)null) { ((Behaviour)o.probes[j]).enabled = o.probeWasEnabled[j]; } } RenderSettings.ambientMode = o.prevAmbientMode; RenderSettings.ambientLight = o.prevAmbientLight; RenderSettings.defaultReflectionMode = o.prevReflectionMode; RenderSettings.customReflectionTexture = o.prevReflectionTexture; RenderSettings.reflectionIntensity = o.prevReflectionIntensity; if ((Object)(object)o.bakeLightGO != (Object)null) { Object.Destroy((Object)(object)o.bakeLightGO); } } private static Cubemap NeutralCubemap() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_neutralCubemap == (Object)null) { _neutralCubemap = new Cubemap(4, (TextureFormat)4, false) { name = "BabyBlocks_NeutralCubemap" }; Color[] array = (Color[])(object)new Color[16]; Color val = default(Color); ((Color)(ref val))..ctor(0.5f, 0.5f, 0.5f, 1f); for (int i = 0; i < array.Length; i++) { array[i] = val; } for (int j = 0; j < 6; j++) { _neutralCubemap.SetPixels(Il2CppStructArray.op_Implicit(array), (CubemapFace)j); } _neutralCubemap.Apply(false); } return _neutralCubemap; } private static void ClassifyTriangleDirections(Vector3[] positions, Vector3[] normals, int[][] submeshTris, Transform transform, out int[] triDir, out bool[] dirUsed) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (int[] array in submeshTris) { num += array.Length / 3; } triDir = new int[num]; dirUsed = new bool[6]; int num2 = 0; foreach (int[] array2 in submeshTris) { for (int k = 0; k + 2 < array2.Length; k += 3) { int num3 = array2[k]; int num4 = array2[k + 1]; int num5 = array2[k + 2]; Vector3 val = transform.TransformPoint(positions[num3]); Vector3 val2 = transform.TransformPoint(positions[num4]); Vector3 val3 = transform.TransformPoint(positions[num5]); Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); float x = val4.x; float y = val4.y; float z = val4.z; float num6 = Mathf.Abs(x); float num7 = Mathf.Abs(y); float num8 = Mathf.Abs(z); int num9 = ((num6 >= num7 && num6 >= num8) ? ((!(x >= 0f)) ? 1 : 0) : ((!(num7 >= num8)) ? ((z >= 0f) ? 4 : 5) : ((y >= 0f) ? 2 : 3))); triDir[num2] = num9; dirUsed[num9] = true; num2++; } } } internal static int FindUnusedLayer() { bool[] array = new bool[32]; foreach (Renderer item in Object.FindObjectsOfType()) { array[((Component)item).gameObject.layer] = true; } for (int num = 31; num >= 0; num--) { if (!array[num]) { return num; } } return 31; } private static GameObject CreateBakeCamera(Bounds worldBounds, Vector3 dir, Vector3 up, int drawLayer, out Camera cam) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("BabyBlocks_BakeCam"); cam = val.AddComponent(); ((Behaviour)cam).enabled = false; cam.orthographic = true; cam.clearFlags = (CameraClearFlags)2; cam.backgroundColor = new Color(0f, 0f, 0f, 0f); cam.cullingMask = 1 << drawLayer; cam.allowHDR = true; Vector3 val2 = Vector3.Cross(up, dir); Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 extents = ((Bounds)(ref worldBounds)).extents; float num = Mathf.Max(Mathf.Abs(Vector3.Dot(extents, normalized)), 0.02f); float num2 = Mathf.Max(Mathf.Abs(Vector3.Dot(extents, up)), 0.02f); float num3 = ((Mathf.Abs(dir.x) > 0.5f) ? extents.x : ((!(Mathf.Abs(dir.y) > 0.5f)) ? extents.z : extents.y)); if (num3 < 0.05f) { num3 = 0.05f; } cam.orthographicSize = Mathf.Max(num, num2) * 1.02f; cam.aspect = 1f; cam.nearClipPlane = 0.01f; cam.farClipPlane = num3 * 2f + 0.5f; val.transform.position = ((Bounds)(ref worldBounds)).center + ((Vector3)(ref dir)).normalized * (num3 + 0.25f); val.transform.rotation = Quaternion.LookRotation(-dir, up); return val; } private static void IssueCaptureRenders(Mesh mesh, Material[] mats, Matrix4x4 localToWorld, Camera cam, int drawLayer, int size, int dir) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) RenderTexture captureRT = GetCaptureRT(dir, size); cam.targetTexture = captureRT; PrepareCullOffMPB(); for (int i = 0; i < mesh.subMeshCount; i++) { Material val = mats[Mathf.Min(i, mats.Length - 1)]; if (!((Object)(object)val == (Object)null)) { Graphics.DrawMesh(mesh, localToWorld, val, drawLayer, cam, i, _bakeMPB); } } cam.Render(); RenderTexture maskRT = GetMaskRT(dir, size); cam.targetTexture = maskRT; PrepareCullOffMPB(); for (int j = 0; j < mesh.subMeshCount; j++) { Graphics.DrawMesh(mesh, localToWorld, MaskMaterial(), drawLayer, cam, j, _bakeMPB); } cam.Render(); cam.targetTexture = null; } private static Color[] ReadbackCapture(int dir, int size) { Color[] real = ReadRenderTexture(_captureRTs[dir], ref _captureTex, (TextureFormat)17, size); Color[] mask = ReadRenderTexture(_maskRTs[dir], ref _maskTex, (TextureFormat)4, size); Color[] array = BuildNormalizedPixels(real, mask); FillRemainingTransparent(array); return array; } private static Material MaskMaterial() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_maskMat == (Object)null) { Shader val = Shader.Find("Unlit/Color") ?? Shader.Find("Standard"); _maskMat = new Material(val) { name = "BabyBlocks_BakeMask" }; _maskMat.SetColor("_Color", Color.white); if (_maskMat.HasProperty("_Glossiness")) { _maskMat.SetFloat("_Glossiness", 0f); } if (_maskMat.HasProperty("_Metallic")) { _maskMat.SetFloat("_Metallic", 0f); } } return _maskMat; } private static void PrepareCullOffMPB() { _bakeMPB.Clear(); _bakeMPB.SetFloat("_Cull", 0f); _bakeMPB.SetFloat("_CullMode", 0f); } private static RenderTexture GetCaptureRT(int dir, int size) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown RenderTexture val = _captureRTs[dir]; if ((Object)(object)val == (Object)null || ((Texture)val).width != size) { if ((Object)(object)val != (Object)null) { val.Release(); Object.Destroy((Object)(object)val); } val = new RenderTexture(size, size, 16, (RenderTextureFormat)2, (RenderTextureReadWrite)1); val.Create(); _captureRTs[dir] = val; } return val; } private static RenderTexture GetMaskRT(int dir, int size) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown RenderTexture val = _maskRTs[dir]; if ((Object)(object)val == (Object)null || ((Texture)val).width != size) { if ((Object)(object)val != (Object)null) { val.Release(); Object.Destroy((Object)(object)val); } val = new RenderTexture(size, size, 16, (RenderTextureFormat)0, (RenderTextureReadWrite)1); val.Create(); _maskRTs[dir] = val; } return val; } private static Color[] ReadRenderTexture(RenderTexture rt, ref Texture2D cacheTex, TextureFormat format, int size) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown RenderTexture active = RenderTexture.active; RenderTexture.active = rt; if ((Object)(object)cacheTex == (Object)null || ((Texture)cacheTex).width != size || cacheTex.format != format) { if ((Object)(object)cacheTex != (Object)null) { Object.Destroy((Object)(object)cacheTex); } cacheTex = new Texture2D(size, size, format, false); } cacheTex.ReadPixels(new Rect(0f, 0f, (float)size, (float)size), 0, 0, false); cacheTex.Apply(false); RenderTexture.active = active; return Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)cacheTex.GetPixels()); } private static Color[] BuildNormalizedPixels(Color[] real, Color[] mask) { //IL_0032: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) double num = 0.0; int num2 = 0; for (int i = 0; i < real.Length; i++) { if (!(mask[i].r < 0.5f)) { Color val = real[i]; num += (double)(val.r + val.g + val.b) / 3.0; num2++; } } float num3 = ((num2 > 0 && num > 0.0) ? (0.15f / (float)(num / (double)num2)) : 1f); Color[] array = (Color[])(object)new Color[real.Length]; for (int j = 0; j < real.Length; j++) { if (mask[j].r < 0.5f) { array[j] = new Color(0f, 0f, 0f, 0f); continue; } Color val2 = real[j]; array[j] = new Color(Mathf.Clamp01(val2.r * num3), Mathf.Clamp01(val2.g * num3), Mathf.Clamp01(val2.b * num3), 1f); } return array; } private static void DilateEdges(Color[] pixels, int size, int iterations) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < iterations; i++) { Color[] array = (Color[])pixels.Clone(); for (int j = 0; j < size; j++) { for (int k = 0; k < size; k++) { int num = j * size + k; if (array[num].a == 0f) { Color? val = null; if (k > 0 && array[num - 1].a != 0f) { val = array[num - 1]; } else if (k < size - 1 && array[num + 1].a != 0f) { val = array[num + 1]; } else if (j > 0 && array[num - size].a != 0f) { val = array[num - size]; } else if (j < size - 1 && array[num + size].a != 0f) { val = array[num + size]; } if (val.HasValue) { Color value = val.Value; value.a = 1f; pixels[num] = value; } } } } } } private static void FillRemainingTransparent(Color[] pixels) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_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_00c9: 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) double num = 0.0; double num2 = 0.0; double num3 = 0.0; int num4 = 0; foreach (Color val in pixels) { if (!(val.a < 0.5f)) { num += (double)val.r; num2 += (double)val.g; num3 += (double)val.b; num4++; } } if (num4 == 0) { return; } Color val2 = default(Color); ((Color)(ref val2))..ctor((float)(num / (double)num4), (float)(num2 / (double)num4), (float)(num3 / (double)num4), 1f); for (int j = 0; j < pixels.Length; j++) { if (pixels[j].a < 0.5f) { pixels[j] = val2; } } } private static Texture2D BuildPerTriangleAtlas(Vector3[] positions, int[][] submeshTris, Transform transform, int[] triDir, Camera[] cams, Color[][] captures, int captureSize, out Vector2[][] outUV) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Expected O, but got Unknown //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0452: 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_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_053b: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: 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) int num = triDir.Length; TriCell[] array = new TriCell[num]; outUV = new Vector2[num][]; for (int i = 0; i < num; i++) { outUV[i] = (Vector2[])(object)new Vector2[3]; } int num2 = 0; Vector2 val9 = default(Vector2); Vector2 val10 = default(Vector2); foreach (int[] array2 in submeshTris) { for (int k = 0; k + 2 < array2.Length; k += 3) { Vector3 val = positions[array2[k]]; Vector3 val2 = positions[array2[k + 1]]; Vector3 val3 = positions[array2[k + 2]]; Vector3 val4 = val2 - val; Vector3 val5 = val3 - val; Vector3 val6 = Vector3.Cross(val4, val5); float magnitude = ((Vector3)(ref val4)).magnitude; Vector2 zero = Vector2.zero; if (magnitude > 1E-06f && ((Vector3)(ref val6)).sqrMagnitude > 1E-12f) { Vector3 val7 = val4 / magnitude; Vector3 val8 = Vector3.Cross(((Vector3)(ref val6)).normalized, val7); ((Vector2)(ref val9))..ctor(magnitude, 0f); ((Vector2)(ref val10))..ctor(Vector3.Dot(val5, val7), Vector3.Dot(val5, val8)); } else { ((Vector2)(ref val9))..ctor(0.001f, 0f); ((Vector2)(ref val10))..ctor(0f, 0.001f); } float num3 = Mathf.Min(new float[3] { zero.x, val9.x, val10.x }); float num4 = Mathf.Max(new float[3] { zero.x, val9.x, val10.x }); float num5 = Mathf.Min(new float[3] { zero.y, val9.y, val10.y }); float num6 = Mathf.Max(new float[3] { zero.y, val9.y, val10.y }); zero -= new Vector2(num3, num5); val9 -= new Vector2(num3, num5); val10 -= new Vector2(num3, num5); array[num2] = new TriCell { triIndex = num2, p0 = zero, p1 = val9, p2 = val10, w = Mathf.Max(num4 - num3, 0.001f), h = Mathf.Max(num6 - num5, 0.001f), dir = triDir[num2] }; num2++; } } float texelsPerUnit; int num7 = PackCells(array, out texelsPerUnit); Color[] array3 = (Color[])(object)new Color[num7 * num7]; num2 = 0; foreach (int[] array4 in submeshTris) { for (int m = 0; m + 2 < array4.Length; m += 3) { ref TriCell reference = ref array[num2]; Camera val11 = cams[reference.dir]; Color[] src = captures[reference.dir]; Vector3 val12 = transform.TransformPoint(positions[array4[m]]); Vector3 val13 = transform.TransformPoint(positions[array4[m + 1]]); Vector3 val14 = transform.TransformPoint(positions[array4[m + 2]]); Vector2 vpA = Vector2.op_Implicit(val11.WorldToViewportPoint(val12)); Vector2 vpB = Vector2.op_Implicit(val11.WorldToViewportPoint(val13)); Vector2 vpC = Vector2.op_Implicit(val11.WorldToViewportPoint(val14)); float num8 = 1f; Vector2 val15 = reference.p0 * texelsPerUnit + new Vector2(num8, num8); Vector2 val16 = reference.p1 * texelsPerUnit + new Vector2(num8, num8); Vector2 val17 = reference.p2 * texelsPerUnit + new Vector2(num8, num8); RasterizeTriangle(array3, num7, reference.cellX, reference.cellY, reference.cellW, reference.cellH, val15, val16, val17, vpA, vpB, vpC, src, captureSize); outUV[num2][0] = new Vector2(((float)reference.cellX + val15.x) / (float)num7, ((float)reference.cellY + val15.y) / (float)num7); outUV[num2][1] = new Vector2(((float)reference.cellX + val16.x) / (float)num7, ((float)reference.cellY + val16.y) / (float)num7); outUV[num2][2] = new Vector2(((float)reference.cellX + val17.x) / (float)num7, ((float)reference.cellY + val17.y) / (float)num7); num2++; } } DilateEdges(array3, num7, 4); Texture2D val18 = new Texture2D(num7, num7, (TextureFormat)4, false, true); ((Texture)val18).wrapMode = (TextureWrapMode)1; ((Texture)val18).filterMode = (FilterMode)1; Color32[] array5 = (Color32[])(object)new Color32[array3.Length]; for (int n = 0; n < array5.Length; n++) { Color val19 = array3[n]; val19.a = 1f; array5[n] = Color32.op_Implicit(val19); } val18.SetPixels32(Il2CppStructArray.op_Implicit(array5)); val18.Apply(false); return val18; } private static int PackCells(TriCell[] cells, out float texelsPerUnit) { texelsPerUnit = 1024f; for (int i = 0; i < 4; i++) { for (int num = 256; num <= 2048; num *= 2) { if (TryPack(cells, num, texelsPerUnit)) { return num; } } texelsPerUnit *= 0.5f; } TryPack(cells, 2048, texelsPerUnit); return 2048; } private static bool TryPack(TriCell[] cells, int atlasSize, float texelsPerUnit) { int[] array = new int[cells.Length]; for (int i = 0; i < array.Length; i++) { array[i] = i; } Array.Sort(array, (int ia, int ib) => cells[ib].h.CompareTo(cells[ia].h)); int num = 0; int num2 = 0; int num3 = 0; int[] array2 = array; foreach (int num5 in array2) { int num6 = Mathf.Max(Mathf.CeilToInt(cells[num5].w * texelsPerUnit) + 2, 3); int num7 = Mathf.Max(Mathf.CeilToInt(cells[num5].h * texelsPerUnit) + 2, 3); if (num6 > atlasSize || num7 > atlasSize) { return false; } if (num + num6 > atlasSize) { num = 0; num2 += num3; num3 = 0; } if (num2 + num7 > atlasSize) { return false; } cells[num5].cellX = num; cells[num5].cellY = num2; cells[num5].cellW = num6; cells[num5].cellH = num7; num += num6; if (num7 > num3) { num3 = num7; } } return true; } private static void RasterizeTriangle(Color[] dst, int atlasSize, int cellX, int cellY, int cellW, int cellH, Vector2 a, Vector2 b, Vector2 c, Vector2 vpA, Vector2 vpB, Vector2 vpC, Color[] src, int captureSize) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) float num = (b.y - c.y) * (a.x - c.x) + (c.x - b.x) * (a.y - c.y); if (Mathf.Abs(num) < 1E-09f) { return; } int num2 = Mathf.Max(Mathf.FloorToInt(Mathf.Min(new float[3] { a.x, b.x, c.x })), 0); int num3 = Mathf.Min(Mathf.CeilToInt(Mathf.Max(new float[3] { a.x, b.x, c.x })), cellW - 1); int num4 = Mathf.Max(Mathf.FloorToInt(Mathf.Min(new float[3] { a.y, b.y, c.y })), 0); int num5 = Mathf.Min(Mathf.CeilToInt(Mathf.Max(new float[3] { a.y, b.y, c.y })), cellH - 1); for (int i = num4; i <= num5; i++) { for (int j = num2; j <= num3; j++) { float num6 = (float)j + 0.5f; float num7 = (float)i + 0.5f; float num8 = ((b.y - c.y) * (num6 - c.x) + (c.x - b.x) * (num7 - c.y)) / num; float num9 = ((c.y - a.y) * (num6 - c.x) + (a.x - c.x) * (num7 - c.y)) / num; float num10 = 1f - num8 - num9; if (!(num8 < -0.01f) && !(num9 < -0.01f) && !(num10 < -0.01f)) { Vector2 val = num8 * vpA + num9 * vpB + num10 * vpC; Color val2 = SampleBilinear(src, captureSize, val.x, val.y); val2.a = 1f; int num11 = cellX + j; int num12 = cellY + i; dst[num12 * atlasSize + num11] = val2; } } } } private static Color SampleBilinear(Color[] src, int size, float u, float v) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(u) * (float)(size - 1); float num2 = Mathf.Clamp01(v) * (float)(size - 1); int num3 = Mathf.FloorToInt(num); int num4 = Mathf.FloorToInt(num2); int num5 = Mathf.Min(num3 + 1, size - 1); int num6 = Mathf.Min(num4 + 1, size - 1); float num7 = num - (float)num3; float num8 = num2 - (float)num4; Color val = src[num4 * size + num3]; Color val2 = src[num4 * size + num5]; Color val3 = src[num6 * size + num3]; Color val4 = src[num6 * size + num5]; Color val5 = Color.Lerp(val, val2, num7); Color val6 = Color.Lerp(val3, val4, num7); return Color.Lerp(val5, val6, num8); } private static void BuildBakedMeshData(Vector3[] positions, Vector3[] normals, int[][] submeshTris, Vector2[][] triUV, out Vector3[] outPositions, out Vector3[] outNormals, out Vector2[] outUV, out int[] outTris) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_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) int num = triUV.Length; int num2 = num * 3; outPositions = (Vector3[])(object)new Vector3[num2]; outNormals = (Vector3[])(object)new Vector3[num2]; outUV = (Vector2[])(object)new Vector2[num2]; outTris = new int[num2]; int num3 = 0; int num4 = 0; foreach (int[] array in submeshTris) { for (int j = 0; j + 2 < array.Length; j += 3) { int[] array2 = new int[3] { array[j], array[j + 1], array[j + 2] }; for (int k = 0; k < 3; k++) { int num5 = array2[k]; outPositions[num3 + k] = positions[num5]; outNormals[num3 + k] = normals[num5]; outUV[num3 + k] = triUV[num4][k]; outTris[num3 + k] = num3 + k; } num3 += 3; num4++; } } } private static Texture2D GetBakedAtlasTexture(Material m) { if ((Object)(object)m == (Object)null) { return null; } string[] bakedAtlasTexProps = BakedAtlasTexProps; foreach (string text in bakedAtlasTexProps) { if (m.HasProperty(text)) { Texture texture = m.GetTexture(text); return (texture != null) ? ((Il2CppObjectBase)texture).TryCast() : null; } } return null; } private static Material CreateBakedMaterial(Material[] srcMats, Texture2D atlas) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) Material val = ((srcMats != null && srcMats.Length != 0) ? srcMats[0] : null); Shader val2 = null; string[] array = new string[6] { "Standard", "Legacy Shaders/Diffuse", "Sprites/Default", "UI/Default", "Unlit/Color", "Unlit/Texture" }; foreach (string text in array) { val2 = Shader.Find(text); if ((Object)(object)val2 != (Object)null) { break; } } if ((Object)(object)val2 == (Object)null && (Object)(object)val != (Object)null) { val2 = val.shader; } if ((Object)(object)val2 == (Object)null) { return val; } Material val3 = new Material(val2) { name = "BakedAtlas" }; string[] bakedAtlasTexProps = BakedAtlasTexProps; foreach (string text2 in bakedAtlasTexProps) { if (val3.HasProperty(text2)) { val3.SetTexture(text2, (Texture)(object)atlas); val3.SetTextureScale(text2, Vector2.one); val3.SetTextureOffset(text2, Vector2.zero); break; } } string[] array2 = new string[3] { "_Color", "_BaseColor", "_UnlitColor" }; foreach (string text3 in array2) { if (val3.HasProperty(text3)) { val3.SetColor(text3, Color.white); break; } } if (val3.HasProperty("_Mode")) { val3.SetFloat("_Mode", 0f); } if (val3.HasProperty("_Glossiness")) { val3.SetFloat("_Glossiness", 0f); } if (val3.HasProperty("_Metallic")) { val3.SetFloat("_Metallic", 0f); } if (val3.HasProperty("_SrcBlend")) { val3.SetInt("_SrcBlend", 1); } if (val3.HasProperty("_DstBlend")) { val3.SetInt("_DstBlend", 0); } if (val3.HasProperty("_ZWrite")) { val3.SetInt("_ZWrite", 1); } if (val3.HasProperty("_Cull")) { val3.SetInt("_Cull", 2); } val3.DisableKeyword("_ALPHATEST_ON"); val3.DisableKeyword("_ALPHABLEND_ON"); val3.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val3.renderQueue = 2000; return val3; } private static bool TryReadMeshForBake(Mesh src, out Vector3[] positions, out Vector3[] normals, out int[][] submeshTris) { //IL_0026: 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_004d: 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_0056: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Invalid comparison between Unknown and I4 //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) positions = null; normals = null; submeshTris = null; try { int num = -1; int num2 = 0; bool flag = false; foreach (VertexAttributeDescriptor item in (Il2CppArrayBase)(object)src.GetVertexAttributes()) { VertexAttributeDescriptor current = item; if (((VertexAttributeDescriptor)(ref current)).stream != 0) { num2 += BakeAttrFloatStride(current); continue; } if ((int)((VertexAttributeDescriptor)(ref current)).attribute == 0 && (int)((VertexAttributeDescriptor)(ref current)).format == 0 && ((VertexAttributeDescriptor)(ref current)).dimension == 3) { flag = true; } if ((int)((VertexAttributeDescriptor)(ref current)).format == 0 && (int)((VertexAttributeDescriptor)(ref current)).attribute == 1 && ((VertexAttributeDescriptor)(ref current)).dimension == 3) { num = num2; } num2 += BakeAttrFloatStride(current); } if (!flag) { return false; } GraphicsBuffer vertexBuffer = src.GetVertexBuffer(0); int num3 = vertexBuffer.stride / 4; int vertexCount = src.vertexCount; Il2CppStructArray val = new Il2CppStructArray((long)(vertexCount * num3)); vertexBuffer.GetData(((Il2CppObjectBase)val).Cast()); vertexBuffer.Release(); positions = (Vector3[])(object)new Vector3[vertexCount]; for (int i = 0; i < vertexCount; i++) { int num4 = i * num3; positions[i] = new Vector3(((Il2CppArrayBase)(object)val)[num4], ((Il2CppArrayBase)(object)val)[num4 + 1], ((Il2CppArrayBase)(object)val)[num4 + 2]); } normals = (Vector3[])(object)new Vector3[vertexCount]; if (num >= 0) { for (int j = 0; j < vertexCount; j++) { int num5 = j * num3 + num; normals[j] = new Vector3(((Il2CppArrayBase)(object)val)[num5], ((Il2CppArrayBase)(object)val)[num5 + 1], ((Il2CppArrayBase)(object)val)[num5 + 2]); } } else { for (int k = 0; k < vertexCount; k++) { normals[k] = Vector3.up; } } GraphicsBuffer indexBuffer = src.GetIndexBuffer(); int count = indexBuffer.count; int[] array = new int[count]; if (indexBuffer.stride == 2) { Il2CppStructArray val2 = new Il2CppStructArray((long)count); indexBuffer.GetData(((Il2CppObjectBase)val2).Cast()); for (int l = 0; l < count; l++) { array[l] = ((Il2CppArrayBase)(object)val2)[l]; } } else { Il2CppStructArray val3 = new Il2CppStructArray((long)count); indexBuffer.GetData(((Il2CppObjectBase)val3).Cast()); for (int m = 0; m < count; m++) { array[m] = ((Il2CppArrayBase)(object)val3)[m]; } } indexBuffer.Release(); int subMeshCount = src.subMeshCount; submeshTris = new int[subMeshCount][]; for (int n = 0; n < subMeshCount; n++) { SubMeshDescriptor subMesh = src.GetSubMesh(n); int num6 = ((SubMeshDescriptor)(ref subMesh)).indexStart + ((SubMeshDescriptor)(ref subMesh)).indexCount; int[] array2 = new int[((SubMeshDescriptor)(ref subMesh)).indexCount]; for (int num7 = ((SubMeshDescriptor)(ref subMesh)).indexStart; num7 < num6; num7++) { array2[num7 - ((SubMeshDescriptor)(ref subMesh)).indexStart] = array[num7]; } submeshTris[n] = array2; } return true; } catch { return false; } } private static int BakeAttrFloatStride(VertexAttributeDescriptor attr) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected I4, but got Unknown VertexAttributeFormat format = ((VertexAttributeDescriptor)(ref attr)).format; VertexAttributeFormat val = format; int num; switch (val - 1) { case 0: case 3: case 4: case 7: case 8: num = ((VertexAttributeDescriptor)(ref attr)).dimension * 2; break; case 1: case 2: case 5: case 6: num = ((VertexAttributeDescriptor)(ref attr)).dimension; break; default: num = ((VertexAttributeDescriptor)(ref attr)).dimension * 4; break; } return (num + 3) / 4; } } public static class MaterialBakeCache { private const int FormatVersion = 1; private static Dictionary<(string propId, string materialKey), (int rawLen, byte[] compressed)> _entries; private static string CachePath => Path.Combine(MelonEnvironment.UserDataDirectory, "BabyBlocks", "BakeCache.bin"); public static List TryLoad(string propId, string materialKey) { EnsureLoaded(); if (!_entries.TryGetValue((propId, materialKey), out (int, byte[]) value)) { return null; } try { using MemoryStream stream = new MemoryStream(value.Item2); using MemoryStream memoryStream = new MemoryStream(value.Item1); using (DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress)) { deflateStream.CopyTo(memoryStream); } memoryStream.Position = 0L; using BinaryReader br = new BinaryReader(memoryStream); return MaterialBaker.ReadPartList(br); } catch (Exception ex) { MelonLogger.Warning($"[BakeCache] Failed to decode entry for \"{propId}\"/\"{materialKey}\": {ex.Message}"); return null; } } public static void Save(string propId, string materialKey, List parts) { if (parts == null || parts.Count == 0) { return; } EnsureLoaded(); using MemoryStream memoryStream = new MemoryStream(); using (BinaryWriter bw = new BinaryWriter(memoryStream, Encoding.UTF8, leaveOpen: true)) { MaterialBaker.WritePartList(bw, parts); } using MemoryStream memoryStream2 = new MemoryStream(); memoryStream.Position = 0L; using (DeflateStream destination = new DeflateStream(memoryStream2, CompressionLevel.Optimal, leaveOpen: true)) { memoryStream.CopyTo(destination); } _entries[(propId, materialKey)] = ((int)memoryStream.Length, memoryStream2.ToArray()); WriteAll(); } private static void EnsureLoaded() { if (_entries != null) { return; } _entries = new Dictionary<(string, string), (int, byte[])>(); try { if (!File.Exists(CachePath)) { return; } using FileStream input = File.OpenRead(CachePath); using BinaryReader binaryReader = new BinaryReader(input); if (binaryReader.ReadInt32() == 1) { int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { string item = MaterialBaker.ReadStr(binaryReader); string item2 = MaterialBaker.ReadStr(binaryReader); int item3 = binaryReader.ReadInt32(); int count = binaryReader.ReadInt32(); byte[] item4 = binaryReader.ReadBytes(count); _entries[(item, item2)] = (item3, item4); } } } catch (Exception ex) { MelonLogger.Warning("[BakeCache] Failed to load \"" + CachePath + "\": " + ex.Message); _entries.Clear(); } } private static void WriteAll() { try { Directory.CreateDirectory(Path.GetDirectoryName(CachePath)); using FileStream output = File.Create(CachePath); using BinaryWriter binaryWriter = new BinaryWriter(output); binaryWriter.Write(1); binaryWriter.Write(_entries.Count); foreach (KeyValuePair<(string, string), (int, byte[])> entry in _entries) { MaterialBaker.WriteStr(binaryWriter, entry.Key.Item1); MaterialBaker.WriteStr(binaryWriter, entry.Key.Item2); binaryWriter.Write(entry.Value.Item1); binaryWriter.Write(entry.Value.Item2.Length); binaryWriter.Write(entry.Value.Item2); } } catch (Exception ex) { MelonLogger.Warning("[BakeCache] Failed to save \"" + CachePath + "\": " + ex.Message); } } } internal static class LevelEditorHistory { private struct TransformState { public Vector3 position; public Vector3 scale; public Quaternion rotation; public static TransformState Capture(Transform t) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) return new TransformState { position = t.position, scale = t.localScale, rotation = t.rotation }; } public void Apply(Transform t) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) t.position = position; t.localScale = scale; t.rotation = rotation; } } private interface IAction { void Undo(); void Redo(); } private class SpawnAction : IAction { private readonly string _addressableKey; private readonly PrimitiveType _primType; private TransformState _state; private LevelEditorObject _live; public SpawnAction(LevelEditorObject obj) { _addressableKey = obj.addressableKey; if (string.IsNullOrEmpty(_addressableKey)) { Enum.TryParse(obj.objectType, out _primType); } _state = TransformState.Capture(((Component)obj).transform); _live = obj; } public void Undo() { LevelEditor.ClearAllSelectionState(); LevelEditorManager.Instance?.Remove(_live); _live = null; } public void Redo() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) _live = Spawn(_state.position); if ((Object)(object)_live != (Object)null) { _state.Apply(((Component)_live).transform); LevelEditor.Select(_live); } } private LevelEditorObject Spawn(Vector3 pos) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(_addressableKey)) { PropInfo propInfo = PropLibrary.FindById(_addressableKey); return (propInfo == null) ? null : LevelEditorManager.Instance?.SpawnFromPropInfo(propInfo, pos); } return LevelEditorManager.Instance?.SpawnPrimitive(_primType, pos); } } private class DeleteAction : IAction { private readonly string _addressableKey; private readonly PrimitiveType _primType; private TransformState _state; private LevelEditorObject _live; public DeleteAction(LevelEditorObject obj) { _addressableKey = obj.addressableKey; if (string.IsNullOrEmpty(_addressableKey)) { Enum.TryParse(obj.objectType, out _primType); } _state = TransformState.Capture(((Component)obj).transform); _live = null; } public void Undo() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) _live = Spawn(_state.position); if ((Object)(object)_live != (Object)null) { _state.Apply(((Component)_live).transform); LevelEditor.Select(_live); } } public void Redo() { if (!((Object)(object)_live == (Object)null)) { if ((Object)(object)LevelEditor.selectedObject == (Object)(object)_live) { LevelEditor.selectedObject = null; } LevelEditorManager.Instance?.Remove(_live); _live = null; } } private LevelEditorObject Spawn(Vector3 pos) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(_addressableKey)) { PropInfo propInfo = PropLibrary.FindById(_addressableKey); return (propInfo == null) ? null : LevelEditorManager.Instance?.SpawnFromPropInfo(propInfo, pos); } return LevelEditorManager.Instance?.SpawnPrimitive(_primType, pos); } } private class TransformAction : IAction { private readonly LevelEditorObject _obj; private readonly TransformState _before; private readonly TransformState _after; public TransformAction(LevelEditorObject obj, TransformState before, TransformState after) { _obj = obj; _before = before; _after = after; } public void Undo() { if ((Object)(object)_obj != (Object)null) { _before.Apply(((Component)_obj).transform); LevelEditorManager.Instance?.SyncLoopBase(_obj); LevelEditor.Select(_obj); } } public void Redo() { if ((Object)(object)_obj != (Object)null) { _after.Apply(((Component)_obj).transform); LevelEditorManager.Instance?.SyncLoopBase(_obj); LevelEditor.Select(_obj); } } } private class MaterialAction : IAction { private readonly LevelEditorObject _obj; private readonly Renderer[] _renderers; private readonly Material[][] _matsBefore; private readonly Material[][] _matsAfter; private readonly GameObject[] _tagObjs; private readonly string[] _tagsBefore; private readonly string[] _tagsAfter; private readonly int _idBefore; private readonly int _idAfter; public MaterialAction(LevelEditorObject obj, Renderer[] renderers, Material[][] matsBefore, Material[][] matsAfter, GameObject[] tagObjs, string[] tagsBefore, string[] tagsAfter, int idBefore, int idAfter) { _obj = obj; _renderers = renderers; _matsBefore = matsBefore; _matsAfter = matsAfter; _tagObjs = tagObjs; _tagsBefore = tagsBefore; _tagsAfter = tagsAfter; _idBefore = idBefore; _idAfter = idAfter; } public void Undo() { Apply(_matsBefore, _tagsBefore, _idBefore); } public void Redo() { Apply(_matsAfter, _tagsAfter, _idAfter); } private void Apply(Material[][] mats, string[] tags, int id) { if ((Object)(object)_obj == (Object)null) { return; } for (int i = 0; i < _renderers.Length; i++) { if ((Object)(object)_renderers[i] != (Object)null) { _renderers[i].sharedMaterials = Il2CppReferenceArray.op_Implicit(mats[i]); } } for (int j = 0; j < _tagObjs.Length; j++) { if ((Object)(object)_tagObjs[j] != (Object)null) { try { _tagObjs[j].tag = tags[j]; } catch { } } } _obj.materialConstructionId = id; LevelEditor.Select(_obj); } } private class GroupScaleAction : IAction { private readonly int _groupId; private readonly GameObject _groupRoot; private readonly LevelEditorObject[] _members; private readonly Vector3 _rootPosBefore; private readonly Vector3 _rootPosAfter; private readonly Vector3 _displayScaleBefore; private readonly Vector3 _displayScaleAfter; private readonly Vector3[] _scalesBefore; private readonly Vector3[] _scalesAfter; private readonly Vector3[] _localPosBefore; private readonly Vector3[] _localPosAfter; public GroupScaleAction(int groupId, GameObject groupRoot, LevelEditorObject[] members, Vector3 rootPosBefore, Vector3 displayScaleBefore, Vector3[] scalesBefore, Vector3[] localPosBefore) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) _groupId = groupId; _groupRoot = groupRoot; _members = members; _rootPosBefore = rootPosBefore; _displayScaleBefore = displayScaleBefore; _scalesBefore = scalesBefore; _localPosBefore = localPosBefore; _rootPosAfter = ((groupRoot != null) ? groupRoot.transform.position : Vector3.zero); _displayScaleAfter = GroupManager.GetGroupDisplayScale(groupId); _scalesAfter = (Vector3[])(object)new Vector3[members.Length]; _localPosAfter = (Vector3[])(object)new Vector3[members.Length]; for (int i = 0; i < members.Length; i++) { if (!((Object)(object)members[i] == (Object)null)) { _scalesAfter[i] = ((Component)members[i]).transform.localScale; _localPosAfter[i] = ((Component)members[i]).transform.localPosition; } } } public bool HasChanges() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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) if (_displayScaleBefore != _displayScaleAfter) { return true; } for (int i = 0; i < _members.Length; i++) { if (_scalesBefore[i] != _scalesAfter[i]) { return true; } } return false; } public void Undo() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Apply(_scalesBefore, _localPosBefore, _rootPosBefore, _displayScaleBefore); } public void Redo() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Apply(_scalesAfter, _localPosAfter, _rootPosAfter, _displayScaleAfter); } private void Apply(Vector3[] scales, Vector3[] localPositions, Vector3 rootPos, Vector3 displayScale) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) if ((Object)(object)_groupRoot != (Object)null) { _groupRoot.transform.position = rootPos; } for (int i = 0; i < _members.Length; i++) { if (!((Object)(object)_members[i] == (Object)null)) { ((Component)_members[i]).transform.localScale = scales[i]; ((Component)_members[i]).transform.localPosition = localPositions[i]; } } GroupManager.SetGroupDisplayScale(_groupId, displayScale); LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance != (Object)null) { LevelEditorObject[] members = _members; foreach (LevelEditorObject levelEditorObject in members) { if ((Object)(object)levelEditorObject != (Object)null) { instance.SyncLoopBase(levelEditorObject); } } } LevelEditorObject levelEditorObject2 = _members.FirstOrDefault((LevelEditorObject m) => (Object)(object)m != (Object)null); if ((Object)(object)levelEditorObject2 != (Object)null) { LevelEditor.Select(levelEditorObject2); } } } private class GroupRotateAction : IAction { private readonly int _groupId; private readonly GameObject _groupRoot; private readonly LevelEditorObject[] _members; private readonly Vector3 _rootPosBefore; private readonly Vector3 _rootPosAfter; private readonly Quaternion _rootRotBefore; private readonly Quaternion _rootRotAfter; public GroupRotateAction(int groupId, GameObject groupRoot, LevelEditorObject[] members, Vector3 rootPosBefore, Quaternion rootRotBefore) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) _groupId = groupId; _groupRoot = groupRoot; _members = members; _rootPosBefore = rootPosBefore; _rootRotBefore = rootRotBefore; _rootPosAfter = ((groupRoot != null) ? groupRoot.transform.position : Vector3.zero); _rootRotAfter = ((groupRoot != null) ? groupRoot.transform.rotation : Quaternion.identity); } public bool HasChanges() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return _rootPosBefore != _rootPosAfter || _rootRotBefore != _rootRotAfter; } private void Apply(Vector3 pos, Quaternion rot) { //IL_001e: 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) if (!((Object)(object)_groupRoot == (Object)null)) { _groupRoot.transform.SetPositionAndRotation(pos, rot); LevelEditorObject levelEditorObject = _members.FirstOrDefault((LevelEditorObject m) => (Object)(object)m != (Object)null); if ((Object)(object)levelEditorObject != (Object)null) { LevelEditor.Select(levelEditorObject); } } } public void Undo() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Apply(_rootPosBefore, _rootRotBefore); } public void Redo() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Apply(_rootPosAfter, _rootRotAfter); } } private static readonly List _undo = new List(); private static readonly List _redo = new List(); public static void PushSpawn(LevelEditorObject obj) { Push(new SpawnAction(obj)); } public static void PushDelete(LevelEditorObject obj) { Push(new DeleteAction(obj)); } public static void PushGroupRotate(int groupId, GameObject groupRoot, LevelEditorObject[] members, Vector3 rootPosBefore, Quaternion rootRotBefore) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) GroupRotateAction groupRotateAction = new GroupRotateAction(groupId, groupRoot, members, rootPosBefore, rootRotBefore); if (groupRotateAction.HasChanges()) { Push(groupRotateAction); } } public static void PushGroupScale(int groupId, GameObject groupRoot, LevelEditorObject[] members, Vector3 rootPosBefore, Vector3 displayScaleBefore, Vector3[] memberScalesBefore, Vector3[] memberLocalPosBefore) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) GroupScaleAction groupScaleAction = new GroupScaleAction(groupId, groupRoot, members, rootPosBefore, displayScaleBefore, memberScalesBefore, memberLocalPosBefore); if (groupScaleAction.HasChanges()) { Push(groupScaleAction); } } public static void PushMaterial(LevelEditorObject obj, Renderer[] renderers, Material[][] matsBefore, GameObject[] tagObjs, string[] tagsBefore, int idBefore) { Material[][] array = new Material[renderers.Length][]; for (int i = 0; i < renderers.Length; i++) { array[i] = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)(((Object)(object)renderers[i] != (Object)null) ? renderers[i].sharedMaterials : null)); } string[] array2 = new string[tagObjs.Length]; for (int j = 0; j < tagObjs.Length; j++) { array2[j] = (((Object)(object)tagObjs[j] != (Object)null) ? tagObjs[j].tag : null); } Push(new MaterialAction(obj, renderers, matsBefore, array, tagObjs, tagsBefore, array2, idBefore, obj.materialConstructionId)); } public static void PushTransform(LevelEditorObject obj, Vector3 posBefore, Vector3 scaleBefore, Quaternion rotBefore) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) TransformState before = new TransformState { position = posBefore, scale = scaleBefore, rotation = rotBefore }; TransformState after = TransformState.Capture(((Component)obj).transform); if (before.position != after.position || before.scale != after.scale || before.rotation != after.rotation) { Push(new TransformAction(obj, before, after)); } } public static void Undo() { if (_undo.Count != 0) { IAction action = _undo[_undo.Count - 1]; _undo.RemoveAt(_undo.Count - 1); action.Undo(); _redo.Add(action); } } public static void Redo() { if (_redo.Count != 0) { IAction action = _redo[_redo.Count - 1]; _redo.RemoveAt(_redo.Count - 1); action.Redo(); _undo.Add(action); } } private static void Push(IAction action) { _undo.Add(action); _redo.Clear(); } } public class PropMeshPart { public Mesh mesh; public Material[] materials; public Vector3 localPosition; public Quaternion localRotation; public Vector3 localScale; public string rendererSubPath; } public class PropColliderPart { public enum ColliderType { Mesh, Box, Sphere, Capsule } public ColliderType type; public Mesh mesh; public bool convex; public Vector3 center; public Vector3 size; public float radius; public float height; public int direction; public Vector3 localPosition; public Quaternion localRotation; public Vector3 localScale; } public class PropInfo { public readonly string id; public string displayName; public List parts = new List(); public List colliderParts = new List(); public bool isLoaded; public bool isInvalid; public int gpuiIndex = -1; public string visualPath = ""; public string gpuiPrefabName = ""; internal Object _addressableAsset; internal GameObject sourcePrefab; public bool HasColliderParts => colliderParts != null && colliderParts.Count > 0; public bool IsGpui => gpuiIndex >= 0; public bool HasMesh => parts != null && parts.Count > 0; public bool IsPrimitive => id.StartsWith("primitive://", StringComparison.Ordinal); public PropInfo(string key, string name = null) { id = key; displayName = name ?? key; } } internal static class PropPreviewCache { private const int FormatVersion = 20; private static Dictionary _entries; private static string CachePath => Path.Combine(MelonEnvironment.UserDataDirectory, "BabyBlocks", "PropPreviews.bin"); public static Texture2D TryLoadTexture(string propId) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown EnsureLoaded(); if (!_entries.TryGetValue(propId, out var value)) { return null; } try { Texture2D val = new Texture2D(2, 2, (TextureFormat)3, false); ((Texture)val).filterMode = (FilterMode)1; ImageConversion.LoadImage(val, Il2CppStructArray.op_Implicit(value), false); return val; } catch (Exception ex) { MelonLogger.Warning("[PropPreviews] Decode failed for \"" + propId + "\": " + ex.Message); return null; } } public static void Save(string propId, byte[] jpg) { if (jpg != null && jpg.Length != 0) { EnsureLoaded(); _entries[propId] = jpg; WriteAll(); } } private static void EnsureLoaded() { if (_entries != null) { return; } _entries = new Dictionary(); try { if (!File.Exists(CachePath)) { return; } using FileStream input = File.OpenRead(CachePath); using BinaryReader binaryReader = new BinaryReader(input); if (binaryReader.ReadInt32() == 20) { int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { string key = MaterialBaker.ReadStr(binaryReader); int count = binaryReader.ReadInt32(); byte[] value = binaryReader.ReadBytes(count); _entries[key] = value; } } } catch (Exception ex) { MelonLogger.Warning("[PropPreviews] Load failed from \"" + CachePath + "\": " + ex.Message); _entries.Clear(); } } private static void WriteAll() { try { Directory.CreateDirectory(Path.GetDirectoryName(CachePath)); using FileStream output = File.Create(CachePath); using BinaryWriter binaryWriter = new BinaryWriter(output); binaryWriter.Write(20); binaryWriter.Write(_entries.Count); foreach (KeyValuePair entry in _entries) { MaterialBaker.WriteStr(binaryWriter, entry.Key); binaryWriter.Write(entry.Value.Length); binaryWriter.Write(entry.Value); } } catch (Exception ex) { MelonLogger.Warning("[PropPreviews] Save failed to \"" + CachePath + "\": " + ex.Message); } } } internal static class PropPreviewRenderer { private const int ThumbSize = 256; private const int JpgQuality = 85; private static readonly MaterialPropertyBlock _mpb = new MaterialPropertyBlock(); private static Material _fallbackMat; private static readonly string[] _snowPropNames = new string[9] { "_SnowAmount", "_SnowCover", "_Snow", "_SnowStrength", "_SnowWeight", "_TVE_SnowAmount", "_TVE_SeasonSnow", "_TVE_SnowIntensity", "_TVE_ColorStageSnow" }; private static readonly Vector3 RenderWorldOffset = new Vector3(50f, 50f, 50f); private static readonly Queue _queue = new Queue(); private static readonly HashSet _seen = new HashSet(); private static readonly Dictionary _ready = new Dictionary(); private static Mesh _sphereMesh; private static readonly Queue<(int id, Material mat)> _matQueue = new Queue<(int, Material)>(); private static readonly HashSet _matSeen = new HashSet(); private static readonly Dictionary _matReady = new Dictionary(); private static readonly Dictionary _matFailures = new Dictionary(); private static readonly Dictionary _matId2Name = new Dictionary(); public static void Request(PropInfo info) { if (info != null && !string.IsNullOrEmpty(info.id) && !_ready.ContainsKey(info.id) && !_seen.Contains(info.id)) { _seen.Add(info.id); _queue.Enqueue(info); } } public static Texture2D Get(string propId) { Texture2D value; return _ready.TryGetValue(propId, out value) ? value : null; } public static void Update() { if (_queue.Count > 0) { PropInfo propInfo = _queue.Dequeue(); if (propInfo == null || string.IsNullOrEmpty(propInfo.id)) { return; } Texture2D val = PropPreviewCache.TryLoadTexture(propInfo.id); if ((Object)(object)val != (Object)null) { _ready[propInfo.id] = val; return; } if (!propInfo.HasMesh || !propInfo.isLoaded) { _seen.Remove(propInfo.id); return; } Texture2D val2 = RenderThumbnail(propInfo); if (!((Object)(object)val2 == (Object)null)) { _ready[propInfo.id] = val2; byte[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)ImageConversion.EncodeToJPG(val2, 85)); if (array != null && array.Length != 0) { PropPreviewCache.Save(propInfo.id, array); } } } else { if (_matQueue.Count <= 0) { return; } var (num, val3) = _matQueue.Dequeue(); if (!((Object)(object)val3 != (Object)null)) { return; } Texture2D val4 = RenderMaterialSphere(num, val3); if ((Object)(object)val4 != (Object)null) { _matReady[num] = val4; _matFailures.Remove(num); return; } _matFailures.TryGetValue(num, out var value); int num2 = value + 1; _matFailures[num] = num2; BBLog.Msg($"[BB:MatSphere] id={num} '{((Object)val3).name}' render FAILED (attempt {num2})"); if (num2 < 5) { _matSeen.Remove(num); } } } private static Texture2D RenderThumbnail(PropInfo info) { //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Expected O, but got Unknown //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Expected O, but got Unknown //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Expected O, but got Unknown //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Expected O, but got Unknown //IL_0488: Unknown result type (might be due to invalid IL or missing references) PropMetadataStore.EnsureLoaded(); PropMetadataStore._byId.TryGetValue(info.id, out var value); BuildDisabledSets(value, out var disabledSubPaths, out var disabledIndices); MaterialCatalog.EnsureMaterialList(); MaterialCatalog.AddMicroSplatLayerMaterials(); Material[][] effectiveMaterials = BuildEffectiveMaterials(info, value, disabledSubPaths, disabledIndices); int num = MaterialBaker.FindUnusedLayer(); if (num < 0) { return null; } Bounds bounds = ComputeBounds(info, disabledSubPaths, disabledIndices); float num2 = Mathf.Max(new float[3] { ((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.y, ((Bounds)(ref bounds)).extents.z }) * 2f; if (num2 < 0.001f) { num2 = 1f; } Vector3 val; Vector3 normalized; if (!string.Equals(PropMetadataStore.GetCategory(info.id), "Holds", StringComparison.OrdinalIgnoreCase)) { val = new Vector3(-1f, -1f, -1f); normalized = ((Vector3)(ref val)).normalized; } else { val = new Vector3(1f, -1f, 1f); normalized = ((Vector3)(ref val)).normalized; } Vector3 camDir = normalized; float num3 = num2 * 3f; GameObject val2 = new GameObject("BB_PreviewCam"); Camera val3 = val2.AddComponent(); ((Behaviour)val3).enabled = false; val3.orthographic = true; val3.clearFlags = (CameraClearFlags)2; val3.backgroundColor = new Color(0.09f, 0.09f, 0.11f, 1f); val3.cullingMask = 1 << num; val3.nearClipPlane = Mathf.Min(0.01f, num3 * 0.05f); val3.farClipPlane = num3 * 4f; val3.aspect = 1f; SetupCameraTransform(val2, val3, ((Bounds)(ref bounds)).center, camDir, num3, bounds); RenderTexture val4 = (val3.targetTexture = new RenderTexture(256, 256, 24, (RenderTextureFormat)0)); AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientLight = RenderSettings.ambientLight; Il2CppArrayBase val6 = Object.FindObjectsOfType(); bool[] array = new bool[val6.Length]; for (int i = 0; i < val6.Length; i++) { array[i] = ((Behaviour)val6[i]).enabled; ((Behaviour)val6[i]).enabled = false; } RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.15f, 0.15f, 0.18f); GameObject val7 = new GameObject("BB_PreviewLight"); Light val8 = val7.AddComponent(); val8.type = (LightType)1; val8.intensity = 1.2f; val8.color = new Color(1f, 0.97f, 0.92f); val8.shadows = (LightShadows)0; val7.transform.rotation = val2.transform.rotation; GameObject val9 = new GameObject("BB_PreviewRim"); Light val10 = val9.AddComponent(); val10.type = (LightType)1; val10.intensity = 0.25f; val10.color = new Color(0.6f, 0.7f, 1f); val10.shadows = (LightShadows)0; val9.transform.rotation = Quaternion.LookRotation(-val2.transform.forward, val2.transform.up); Dictionary dictionary = new Dictionary(); float[] array2 = new float[_snowPropNames.Length]; for (int j = 0; j < _snowPropNames.Length; j++) { array2[j] = Shader.GetGlobalFloat(_snowPropNames[j]); Shader.SetGlobalFloat(_snowPropNames[j], 0f); } CommandBuffer val11 = new CommandBuffer { name = "BB_SnowSuppress" }; string[] snowPropNames = _snowPropNames; foreach (string text in snowPropNames) { val11.SetGlobalFloat(text, 0f); } val11.SetGlobalVector("_SnowHeightAngleRange", new Vector4(1000000f, 1f, 0f, 1f)); val3.AddCommandBuffer((CameraEvent)10, val11); val3.AddCommandBuffer((CameraEvent)4, val11); Texture2D val12 = null; RenderTexture active = RenderTexture.active; try { IssueDraws(info, disabledSubPaths, disabledIndices, effectiveMaterials, num, val3, dictionary); val3.Render(); RenderTexture.active = val4; val12 = new Texture2D(256, 256, (TextureFormat)3, false); ((Texture)val12).filterMode = (FilterMode)1; val12.ReadPixels(new Rect(0f, 0f, 256f, 256f), 0, 0); val12.Apply(); } catch (Exception ex) { MelonLogger.Warning("[PropPreviews] Render failed for \"" + info.id + "\": " + ex.Message); if ((Object)(object)val12 != (Object)null) { Object.Destroy((Object)(object)val12); val12 = null; } } finally { RenderTexture.active = active; RenderSettings.ambientMode = ambientMode; RenderSettings.ambientLight = ambientLight; for (int l = 0; l < val6.Length; l++) { if ((Object)(object)val6[l] != (Object)null) { ((Behaviour)val6[l]).enabled = array[l]; } } Object.Destroy((Object)(object)val7); Object.Destroy((Object)(object)val9); val3.RemoveAllCommandBuffers(); val11.Release(); val3.targetTexture = null; Object.Destroy((Object)(object)val2); val4.Release(); Object.Destroy((Object)(object)val4); foreach (Material value2 in dictionary.Values) { if ((Object)(object)value2 != (Object)null) { Object.Destroy((Object)(object)value2); } } for (int m = 0; m < _snowPropNames.Length; m++) { Shader.SetGlobalFloat(_snowPropNames[m], array2[m]); } } return val12; } private static Material GetOrCloneForRender(Material src, Dictionary cache) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)src == (Object)null) { return GetOrCreateFallback(); } if (cache.TryGetValue(src, out var value)) { return value; } Material val = new Material(src); val.SetFloat("_Cull", 2f); val.SetFloat("_CullMode", 2f); val.SetFloat("_RenderCull", 2f); val.DisableKeyword("_SNOW"); val.DisableKeyword("EFFECT_SUBSURFACE"); val.DisableKeyword("MUDBUN_PROCEDURAL"); string[] snowPropNames = _snowPropNames; foreach (string text in snowPropNames) { val.SetFloat(text, 0f); } val.SetVector("_SnowHeightAngleRange", new Vector4(1000000f, 1f, 0f, 1f)); float num = val.GetFloat("_SnowAmount"); if (num > 0.001f) { MelonLogger.Warning($"[PropPreviews] clone._SnowAmount SetFloat failed for \"{((Object)src).name}\" — reads back {num:F3}; clone={((Object)val).GetInstanceID()}"); } cache[src] = val; return val; } private static void SetupCameraTransform(GameObject camGO, Camera cam, Vector3 center, Vector3 camDir, float camDist, Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) Vector3 val = center + RenderWorldOffset; camGO.transform.position = val - camDir * camDist; camGO.transform.LookAt(val); Vector3 min = ((Bounds)(ref bounds)).min; Vector3 max = ((Bounds)(ref bounds)).max; Vector3 right = camGO.transform.right; Vector3 up = camGO.transform.up; float num = float.MaxValue; float num2 = float.MinValue; float num3 = float.MaxValue; float num4 = float.MinValue; Vector3 val2 = default(Vector3); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { ((Vector3)(ref val2))..ctor((i == 0) ? min.x : max.x, (j == 0) ? min.y : max.y, (k == 0) ? min.z : max.z); float num5 = Vector3.Dot(val2, right); float num6 = Vector3.Dot(val2, up); if (num5 < num) { num = num5; } if (num5 > num2) { num2 = num5; } if (num6 < num3) { num3 = num6; } if (num6 > num4) { num4 = num6; } } } } float num7 = Mathf.Max((num2 - num) * 0.5f, (num4 - num3) * 0.5f); if (num7 < 0.001f) { num7 = 0.5f; } cam.orthographicSize = num7 * 1.12f; } private static void BuildDisabledSets(PropExtraInfo extra, out HashSet disabledSubPaths, out HashSet disabledIndices) { disabledSubPaths = new HashSet(StringComparer.OrdinalIgnoreCase); disabledIndices = new HashSet(); if (extra?.disabledRenderers == null) { return; } foreach (string disabledRenderer in extra.disabledRenderers) { if (string.IsNullOrEmpty(disabledRenderer)) { continue; } int num = disabledRenderer.IndexOf('/'); string text = ((num >= 0) ? disabledRenderer.Substring(num + 1) : disabledRenderer); if (!string.IsNullOrEmpty(text)) { if (text.StartsWith("Part_", StringComparison.OrdinalIgnoreCase) && int.TryParse(text.Substring(5), NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { disabledIndices.Add(result); } else { disabledSubPaths.Add(text); } } } } private static bool IsPartDisabled(int partIndex, PropMeshPart part, HashSet disabledSubPaths, HashSet disabledIndices) { if (disabledIndices.Contains(partIndex)) { return true; } if (disabledSubPaths.Count == 0) { return false; } if (string.IsNullOrEmpty(part.rendererSubPath)) { return false; } if (disabledSubPaths.Contains(part.rendererSubPath)) { return true; } foreach (string disabledSubPath in disabledSubPaths) { if (part.rendererSubPath.StartsWith(disabledSubPath + "/", StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private static void IssueDraws(PropInfo info, HashSet disabledSubPaths, HashSet disabledIndices, Material[][] effectiveMaterials, int drawLayer, Camera cam, Dictionary matClones) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) _mpb.Clear(); string[] snowPropNames = _snowPropNames; foreach (string text in snowPropNames) { _mpb.SetFloat(text, 0f); } _mpb.SetVector("_SnowHeightAngleRange", new Vector4(1000000f, 1f, 0f, 1f)); for (int j = 0; j < info.parts.Count; j++) { PropMeshPart propMeshPart = info.parts[j]; if ((Object)(object)propMeshPart.mesh == (Object)null || IsPartDisabled(j, propMeshPart, disabledSubPaths, disabledIndices)) { continue; } Vector3 val = ((propMeshPart.localScale == Vector3.zero) ? Vector3.one : propMeshPart.localScale); Vector3 val2 = propMeshPart.localPosition + RenderWorldOffset; Matrix4x4 val3 = Matrix4x4.TRS(val2, propMeshPart.localRotation, val); Material[] array = ((effectiveMaterials != null && j < effectiveMaterials.Length) ? effectiveMaterials[j] : propMeshPart.materials); for (int k = 0; k < propMeshPart.mesh.subMeshCount; k++) { Material src = ((array != null && k < array.Length) ? array[k] : null); Material orCloneForRender = GetOrCloneForRender(src, matClones); if (!((Object)(object)orCloneForRender == (Object)null)) { Graphics.DrawMesh(propMeshPart.mesh, val3, orCloneForRender, drawLayer, cam, k, _mpb); } } } } private static Material GetOrCreateFallback() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0071: 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) if ((Object)(object)_fallbackMat != (Object)null) { return _fallbackMat; } Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { return null; } _fallbackMat = new Material(val); if (_fallbackMat.HasProperty("_Color")) { _fallbackMat.SetColor("_Color", new Color(1f, 0f, 1f)); } if (_fallbackMat.HasProperty("_EmissionColor")) { _fallbackMat.EnableKeyword("_EMISSION"); _fallbackMat.SetColor("_EmissionColor", new Color(0.4f, 0f, 0.4f)); } return _fallbackMat; } private static Material ResolveNonPlaceholder(string matName, string sourcePropId) { Material val = MaterialCatalog.ResolveMaterial(matName, sourcePropId); if ((Object)(object)val != (Object)null && (Object)(object)val.shader != (Object)null && ((Object)val.shader).name == "Standard" && (Object)(object)val.mainTexture == (Object)null) { MaterialCatalog.MaterialByName.Remove(matName); MaterialCatalog.VerifiedSourceMaterials.Remove(matName); val = MaterialCatalog.ResolveMaterial(matName, sourcePropId); } return val; } private static Material[][] BuildEffectiveMaterials(PropInfo info, PropExtraInfo extra, HashSet disabledSubPaths, HashSet disabledIndices) { Material val = null; Material[] array = null; if (extra != null) { if (extra.perSlotMaterialOverrides != null && extra.perSlotMaterialOverrides.Count > 0) { array = (Material[])(object)new Material[extra.perSlotMaterialOverrides.Count]; for (int i = 0; i < extra.perSlotMaterialOverrides.Count; i++) { string text = extra.perSlotMaterialOverrides[i]; if (!string.IsNullOrEmpty(text) && !string.Equals(text, "(no override)", StringComparison.OrdinalIgnoreCase)) { array[i] = ResolveNonPlaceholder(text, extra.materialSourcePropId); } } } else if (!string.IsNullOrEmpty(extra.overrideMaterialId) && !string.Equals(extra.overrideMaterialId, "(no override)", StringComparison.OrdinalIgnoreCase)) { val = ResolveNonPlaceholder(extra.overrideMaterialId, extra.materialSourcePropId); if ((Object)(object)val == (Object)null && !extra.overrideMaterialId.StartsWith("[MicroSplat]", StringComparison.Ordinal)) { MelonLogger.Warning($"[PropPreviews] ResolveMaterial(\"{extra.overrideMaterialId}\", \"{extra.materialSourcePropId}\") → null for \"{info.id}\""); } } } if (!((Object)(object)val != (Object)null) && array == null) { return null; } Material[][] array2 = new Material[info.parts.Count][]; for (int j = 0; j < info.parts.Count; j++) { PropMeshPart propMeshPart = info.parts[j]; if (IsPartDisabled(j, propMeshPart, disabledSubPaths, disabledIndices)) { array2[j] = null; continue; } Material[] materials = propMeshPart.materials; int num = ((materials != null) ? materials.Length : 0); int num2 = num; if (array != null) { num2 = Mathf.Max(num2, array.Length); } if ((Object)(object)val != (Object)null) { num2 = Mathf.Max(num2, 1); } if (num2 == 0) { array2[j] = null; continue; } Material[] array3 = (Material[])(object)new Material[num2]; for (int k = 0; k < num2; k++) { Material val2 = ((materials != null && k < num) ? materials[k] : null); if (array != null && k < array.Length && (Object)(object)array[k] != (Object)null) { val2 = array[k]; } else if ((Object)(object)val != (Object)null) { val2 = val; } array3[k] = val2; } array2[j] = array3; } return array2; } public static void RequestMaterialSphere(int id, Material mat) { if (!((Object)(object)mat == (Object)null) && !_matReady.ContainsKey(id) && !_matSeen.Contains(id)) { _matSeen.Add(id); _matId2Name[id] = ((Object)mat).name; _matQueue.Enqueue((id, mat)); } } public static void InvalidateMicroSplatSpheres() { List list = new List(); foreach (KeyValuePair item in _matId2Name) { if (item.Value.StartsWith("[MicroSplat]", StringComparison.Ordinal)) { list.Add(item.Key); } } foreach (int item2 in list) { InvalidateMaterialSphere(item2); } } public static Texture2D GetMaterialSphere(int id) { Texture2D value; return _matReady.TryGetValue(id, out value) ? value : null; } public static bool IsMaterialSeen(int id) { return _matSeen.Contains(id); } public static bool IsMaterialReady(int id) { return _matReady.ContainsKey(id); } public static void InvalidateMaterialSphere(int id) { _matReady.Remove(id); _matSeen.Remove(id); _matFailures.Remove(id); } private static Mesh GetSphereMesh() { if ((Object)(object)_sphereMesh != (Object)null) { return _sphereMesh; } GameObject val = GameObject.CreatePrimitive((PrimitiveType)0); _sphereMesh = val.GetComponent().sharedMesh; Object.Destroy((Object)(object)val); return _sphereMesh; } private static Texture2D RenderMaterialSphere(int matId, Material mat) { //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_0523: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Expected O, but got Unknown //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Expected O, but got Unknown //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: 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_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: 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_046c: Expected O, but got Unknown //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) Mesh sphereMesh = GetSphereMesh(); if ((Object)(object)sphereMesh == (Object)null) { BBLog.Msg($"[BB:MatSphere] id={matId} GetSphereMesh returned null"); return null; } int num = MaterialBaker.FindUnusedLayer(); if (num < 0) { BBLog.Msg($"[BB:MatSphere] id={matId} no unused render layer available"); return null; } Vector3 val = new Vector3(-1f, -1f, -1f); Vector3 normalized = ((Vector3)(ref val)).normalized; float num2 = 4f; GameObject val2 = new GameObject("BB_MatPreviewCam"); Camera val3 = val2.AddComponent(); ((Behaviour)val3).enabled = false; val3.orthographic = true; val3.clearFlags = (CameraClearFlags)2; val3.backgroundColor = new Color(0.09f, 0.09f, 0.11f, 1f); val3.cullingMask = 1 << num; val3.nearClipPlane = 0.1f; val3.farClipPlane = num2 * 4f; val3.aspect = 1f; val3.orthographicSize = 0.68f; val2.transform.position = RenderWorldOffset - normalized * num2; val2.transform.LookAt(RenderWorldOffset); RenderTexture val4 = (val3.targetTexture = new RenderTexture(256, 256, 24, (RenderTextureFormat)0)); AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientLight = RenderSettings.ambientLight; Il2CppArrayBase val6 = Object.FindObjectsOfType(); bool[] array = new bool[val6.Length]; for (int i = 0; i < val6.Length; i++) { array[i] = ((Behaviour)val6[i]).enabled; ((Behaviour)val6[i]).enabled = false; } RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.15f, 0.15f, 0.18f); GameObject val7 = new GameObject("BB_MatPreviewKey"); Light val8 = val7.AddComponent(); val8.type = (LightType)1; val8.intensity = 1.2f; val8.color = new Color(1f, 0.97f, 0.92f); val8.shadows = (LightShadows)0; val7.transform.rotation = val2.transform.rotation; GameObject val9 = new GameObject("BB_MatPreviewRim"); Light val10 = val9.AddComponent(); val10.type = (LightType)1; val10.intensity = 0.3f; val10.color = new Color(0.5f, 0.65f, 1f); val10.shadows = (LightShadows)0; val9.transform.rotation = Quaternion.LookRotation(-val2.transform.forward, val2.transform.up); Dictionary dictionary = new Dictionary(); float[] array2 = new float[_snowPropNames.Length]; for (int j = 0; j < _snowPropNames.Length; j++) { array2[j] = Shader.GetGlobalFloat(_snowPropNames[j]); Shader.SetGlobalFloat(_snowPropNames[j], 0f); } Texture2D val11 = null; RenderTexture active = RenderTexture.active; try { _mpb.Clear(); string[] snowPropNames = _snowPropNames; foreach (string text in snowPropNames) { _mpb.SetFloat(text, 0f); } _mpb.SetVector("_SnowHeightAngleRange", new Vector4(1000000f, 1f, 0f, 1f)); Matrix4x4 val12 = Matrix4x4.TRS(RenderWorldOffset, Quaternion.identity, Vector3.one); Material orCloneForRender = GetOrCloneForRender(mat, dictionary); if ((Object)(object)orCloneForRender != (Object)null) { for (int l = 0; l < sphereMesh.subMeshCount; l++) { Graphics.DrawMesh(sphereMesh, val12, orCloneForRender, num, val3, l, _mpb); } } val3.Render(); RenderTexture.active = val4; val11 = new Texture2D(256, 256, (TextureFormat)3, false); ((Texture)val11).filterMode = (FilterMode)1; val11.ReadPixels(new Rect(0f, 0f, 256f, 256f), 0, 0); val11.Apply(); } catch (Exception ex) { MelonLogger.Warning($"[PropPreviews] Material sphere render failed for id={matId}: {ex.Message}"); if ((Object)(object)val11 != (Object)null) { Object.Destroy((Object)(object)val11); val11 = null; } } finally { RenderTexture.active = active; RenderSettings.ambientMode = ambientMode; RenderSettings.ambientLight = ambientLight; for (int m = 0; m < val6.Length; m++) { if ((Object)(object)val6[m] != (Object)null) { ((Behaviour)val6[m]).enabled = array[m]; } } Object.Destroy((Object)(object)val7); Object.Destroy((Object)(object)val9); val3.targetTexture = null; Object.Destroy((Object)(object)val2); val4.Release(); Object.Destroy((Object)(object)val4); foreach (Material value in dictionary.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } } for (int n = 0; n < _snowPropNames.Length; n++) { Shader.SetGlobalFloat(_snowPropNames[n], array2[n]); } } return val11; } private static Bounds ComputeBounds(PropInfo info, HashSet disabledSubPaths, HashSet disabledIndices) { //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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) List list = new List(info.parts.Count); Vector3 val2 = default(Vector3); Vector3 val4 = default(Vector3); for (int i = 0; i < info.parts.Count; i++) { PropMeshPart propMeshPart = info.parts[i]; if ((Object)(object)propMeshPart.mesh == (Object)null || IsPartDisabled(i, propMeshPart, disabledSubPaths, disabledIndices)) { continue; } Vector3 val = ((propMeshPart.localScale == Vector3.zero) ? Vector3.one : propMeshPart.localScale); Bounds bounds = propMeshPart.mesh.bounds; ((Vector3)(ref val2))..ctor(Mathf.Abs(((Bounds)(ref bounds)).extents.x * val.x), Mathf.Abs(((Bounds)(ref bounds)).extents.y * val.y), Mathf.Abs(((Bounds)(ref bounds)).extents.z * val.z)); if (Mathf.Max(new float[3] { Mathf.Abs(((Bounds)(ref bounds)).extents.x), Mathf.Abs(((Bounds)(ref bounds)).extents.y), Mathf.Abs(((Bounds)(ref bounds)).extents.z) }) > 50f) { Bounds? tightMeshBounds = GetTightMeshBounds(propMeshPart.mesh, val); if (tightMeshBounds.HasValue) { Bounds value = tightMeshBounds.Value; Vector3 val3 = propMeshPart.localPosition + propMeshPart.localRotation * Vector3.Scale(((Bounds)(ref value)).center, val); ((Vector3)(ref val4))..ctor(Mathf.Abs(((Bounds)(ref value)).extents.x * val.x), Mathf.Abs(((Bounds)(ref value)).extents.y * val.y), Mathf.Abs(((Bounds)(ref value)).extents.z * val.z)); list.Add(new Bounds(val3, val4 * 2f)); continue; } } Vector3 val5 = propMeshPart.localPosition + propMeshPart.localRotation * Vector3.Scale(((Bounds)(ref bounds)).center, val); list.Add(new Bounds(val5, val2 * 2f)); } if (list.Count == 0) { return new Bounds(Vector3.zero, Vector3.one); } Bounds result = list[0]; for (int j = 1; j < list.Count; j++) { ((Bounds)(ref result)).Encapsulate(list[j]); } return result; } private static Bounds? GetTightMeshBounds(Mesh mesh, Vector3 scale) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(new float[3] { Mathf.Abs(scale.x), Mathf.Abs(scale.y), Mathf.Abs(scale.z) }); if (num < 0.0001f) { num = 1f; } float num2 = 15f / num * (15f / num); try { Il2CppStructArray vertices = mesh.vertices; if (vertices == null || ((Il2CppArrayBase)(object)vertices).Length == 0) { return null; } int num3 = 0; bool flag = false; Vector3 val = Vector3.zero; Vector3 val2 = Vector3.zero; for (int i = 0; i < ((Il2CppArrayBase)(object)vertices).Length; i++) { Vector3 val3 = ((Il2CppArrayBase)(object)vertices)[i]; float num4 = val3.x * val3.x + val3.y * val3.y + val3.z * val3.z; if (num4 > num2) { continue; } num3++; if (!flag) { val = (val2 = val3); flag = true; continue; } if (val3.x < val.x) { val.x = val3.x; } else if (val3.x > val2.x) { val2.x = val3.x; } if (val3.y < val.y) { val.y = val3.y; } else if (val3.y > val2.y) { val2.y = val3.y; } if (val3.z < val.z) { val.z = val3.z; } else if (val3.z > val2.z) { val2.z = val3.z; } } if (!flag || num3 * 2 < ((Il2CppArrayBase)(object)vertices).Length) { return null; } return new Bounds((val + val2) * 0.5f, val2 - val); } catch { return null; } } } [Serializable] public class PropExtraInfo { public string id; public string displayName; public string category; public bool excluded; public bool useRenderMeshCollider; public string colliderIgnoredSubmeshes; public string overrideMaterialId; public string nativeMaterialName; public string materialSourcePropId; public string surfaceType; public int index; public List disabledRenderers = new List(); public List perSlotMaterialOverrides; public int forcedMaterialSlots; public bool isBush; public float bushRadius; public int soundGrassType = 1; public bool keepOriginalHierarchy; public bool disableBaking; } [Serializable] internal class PropExtraInfoSave { public int nextIndex = 1; public List items = new List(); public int nextMaterialConstructionId = 0; public List materialConstructions = new List(); } public static class PropLibrary { internal const string NegativeCollisionPropId = "special://negative-hole"; internal const string SpawnPointPropId = "special://spawn-point"; internal static readonly List _all = new List(); private static readonly List _filtered = new List(); internal static readonly Dictionary _byId = new Dictionary(StringComparer.Ordinal); internal static readonly Dictionary _idAliases = new Dictionary(StringComparer.Ordinal); internal static readonly string[] PrimitiveNames = new string[10] { "Cube", "Sphere", "Capsule", "Cylinder", "Plane", "Quad", "Torus", "Cone", "Helix", "Egg" }; private static Type _bestRegionType; private static readonly Dictionary _refCounts = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary _zeroRefTime = new Dictionary(StringComparer.Ordinal); private const float UnloadDelay = 30f; private static readonly List _primitiveMeshHolder = new List(); public static IReadOnlyList AllProps => _all; public static IReadOnlyList FilteredProps => _filtered; private static string GpuiCachePath => Path.Combine(MelonEnvironment.UserDataDirectory, "BabyBlocks", "GpuiCache.txt"); public static bool IsInitialized { get; private set; } public static string SearchText { get; private set; } = ""; public static bool DebugSearchMetaNames { get; set; } = false; internal static bool TryLoadGpuiCache(string catalogPath, out List<(string baseName, string id, string visualPath, string prefabName)> entries) { entries = null; try { if (!File.Exists(GpuiCachePath)) { return false; } string[] array = File.ReadAllLines(GpuiCachePath); if (array.Length == 0 || !array[0].StartsWith("MTIME=")) { return false; } entries = new List<(string, string, string, string)>(); for (int i = 1; i < array.Length; i++) { string text = array[i]; if (text.StartsWith("PROP|")) { string[] array2 = text.Substring(5).Split('|'); if (array2.Length >= 4) { entries.Add((array2[0], array2[1], array2[2], array2[3])); } } else { if (!text.StartsWith("MAT|")) { continue; } string[] array3 = text.Substring(4).Split('|'); if (array3.Length >= 2 && !string.IsNullOrEmpty(array3[0]) && !string.IsNullOrEmpty(array3[1])) { MaterialPathCatalog.MaterialCatalogPathsDict[array3[0]] = array3[1]; MaterialPathCatalog.MaterialPathToKey[array3[1]] = array3[0]; if (array3[0] == "__IDX__") { MaterialPathCatalog.CatalogIndexed = true; } } } } return true; } catch { return false; } } internal static bool TryParseGpuiIndex(string id, out int index) { index = -1; if (string.IsNullOrEmpty(id)) { return false; } if (!id.StartsWith("gpui://", StringComparison.OrdinalIgnoreCase)) { return false; } return int.TryParse(id.Substring("gpui://".Length), out index) && index >= 0; } internal static string BuildStableGpuiId(string baseName, string prefabName, string visualPath) { string text = (string.IsNullOrWhiteSpace(prefabName) ? baseName : prefabName); if (string.IsNullOrWhiteSpace(text)) { text = "unnamed"; } text = text.Trim(); if (text.IndexOf('|') >= 0) { text = text.Replace("|", "_"); } string text2 = "gpui://" + text; if (!_byId.TryGetValue(text2, out var value)) { return text2; } string a = value.gpuiPrefabName + "|" + value.visualPath; string text3 = prefabName + "|" + visualPath; if (string.Equals(a, text3, StringComparison.OrdinalIgnoreCase)) { return text2; } return text2 + "#" + MaterialPathCatalog.ComputeStableHash(text3); } internal static void SaveGpuiCache(string catalogPath, List<(string baseName, string id, string visualPath, string prefabName)> entries) { try { Directory.CreateDirectory(Path.GetDirectoryName(GpuiCachePath)); string value = (File.Exists(catalogPath) ? File.GetLastWriteTimeUtc(catalogPath).Ticks.ToString() : "0"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("MTIME=").AppendLine(value); foreach (var (value2, value3, value4, value5) in entries) { stringBuilder.Append("PROP|").Append(value2).Append('|') .Append(value3) .Append('|') .Append(value4) .Append('|') .AppendLine(value5); } foreach (KeyValuePair item in MaterialPathCatalog.MaterialCatalogPathsDict) { stringBuilder.Append("MAT|").Append(item.Key).Append('|') .AppendLine(item.Value); } File.WriteAllText(GpuiCachePath, stringBuilder.ToString()); } catch (Exception ex) { MelonLogger.Warning("[PropLibrary] GPUI cache save failed: " + ex.Message); } } public static void SetSearch(string text) { if (text == null) { text = ""; } if (!string.Equals(text, SearchText, StringComparison.OrdinalIgnoreCase)) { SearchText = text; BuildFiltered(); } } public static void Init() { _all.Clear(); _byId.Clear(); _idAliases.Clear(); _filtered.Clear(); GpuiPropScanner.GpuiScannedNames.Clear(); string[] primitiveNames = PrimitiveNames; foreach (string text in primitiveNames) { string key = "primitive://" + text; PropInfo propInfo = new PropInfo(key, text); _all.Add(propInfo); _byId[key] = propInfo; LoadPropData(propInfo); } PropInfo propInfo2 = new PropInfo("special://negative-hole", "Hole"); _all.Add(propInfo2); _byId[propInfo2.id] = propInfo2; PropInfo propInfo3 = new PropInfo("special://spawn-point", "Spawn Point"); _all.Add(propInfo3); _byId[propInfo3.id] = propInfo3; int count = _all.Count; try { CatalogEnumerator.EnumerateFromCatalog(); } catch { } if (_all.Count > count) { _all.Sort(count, _all.Count - count, Comparer.Create((PropInfo a, PropInfo b) => NaturalStringCompare(a.displayName, b.displayName))); } IsInitialized = true; BuildFiltered(); } public static void RebuildFiltered() { BuildFiltered(); } private static void BuildFiltered() { _filtered.Clear(); bool flag = !string.IsNullOrEmpty(SearchText); if (Core.DebugMode) { foreach (PropInfo item in _all) { if (flag) { bool flag2; if (DebugSearchMetaNames) { string text = PropMetadataStore.GetDisplayName(item.id) ?? ""; flag2 = text.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) >= 0; } else { flag2 = item.displayName.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) >= 0 || item.id.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) >= 0; } if (!flag2) { continue; } } _filtered.Add(item); } } else { string selectedCategory = PropPalette.SelectedCategory; foreach (PropInfo item2 in _all) { if (!PropMetadataStore.HasCategory(item2.id)) { continue; } string category = PropMetadataStore.GetCategory(item2.id); if (selectedCategory != null && !string.Equals(category, selectedCategory, StringComparison.OrdinalIgnoreCase)) { continue; } if (flag) { string text2 = PropMetadataStore.GetDisplayName(item2.id) ?? item2.displayName; if (text2.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) < 0 && item2.id.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) < 0 && (category == null || category.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) < 0)) { continue; } } _filtered.Add(item2); } } _filtered.Sort(delegate(PropInfo a, PropInfo b) { string a2; string b2; if (Core.DebugMode) { a2 = a.displayName.Replace("_", " ").Trim(); b2 = b.displayName.Replace("_", " ").Trim(); } else { a2 = PropMetadataStore.GetDisplayName(a.id) ?? a.displayName; b2 = PropMetadataStore.GetDisplayName(b.id) ?? b.displayName; } return NaturalStringCompare(a2, b2); }); } public static void AddRef(string propId) { if (!string.IsNullOrEmpty(propId)) { _zeroRefTime.Remove(propId); _refCounts[propId] = ((!_refCounts.TryGetValue(propId, out var value)) ? 1 : (value + 1)); } } public static void RemoveRef(string propId) { if (!string.IsNullOrEmpty(propId) && _refCounts.TryGetValue(propId, out var value)) { value--; if (value <= 0) { _refCounts.Remove(propId); _zeroRefTime[propId] = Time.realtimeSinceStartup; } else { _refCounts[propId] = value; } } } public static void ProcessUnloadQueue() { if (_zeroRefTime.Count == 0) { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; List list = null; foreach (KeyValuePair item in _zeroRefTime) { if (realtimeSinceStartup - item.Value >= 30f) { (list ?? (list = new List())).Add(item.Key); } } if (list == null) { return; } foreach (string item2 in list) { _zeroRefTime.Remove(item2); if (_byId.TryGetValue(item2, out var value)) { UnloadPropData(value); } } MaterialCatalog.RefreshMicroSplatLayerMaterials(); } private static void UnloadPropData(PropInfo info) { if (!info.isLoaded && !info.HasMesh && info._addressableAsset == (Object)null) { return; } BBLog.Msg("[PropLibrary] Unloading \"" + info.displayName + "\" — no live instances."); PhysicsObjectManager.ReleasePhysicsMeshes(info); if (info._addressableAsset != (Object)null) { try { Addressables.Release(info._addressableAsset); } catch { } info._addressableAsset = null; } info.parts.Clear(); info.colliderParts.Clear(); info.isLoaded = false; info.isInvalid = false; } internal static bool IsLowerLodVariant(string key) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(key); int num = fileNameWithoutExtension.IndexOf("_LOD", StringComparison.OrdinalIgnoreCase); if (num < 0) { return false; } int num2 = num + 4; if (num2 >= fileNameWithoutExtension.Length) { return false; } char c = fileNameWithoutExtension[num2]; return c >= '1' && c <= '9'; } public static Bounds? GetPropBounds(PropInfo info) { //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_056b: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: 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_0478: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_051e: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: 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_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) if (info == null) { return null; } Bounds? result = null; if (info.parts != null) { for (int i = 0; i < info.parts.Count; i++) { PropMeshPart propMeshPart = info.parts[i]; if (propMeshPart == null || (Object)(object)propMeshPart.mesh == (Object)null) { continue; } Bounds bounds = propMeshPart.mesh.bounds; Vector3 center = ((Bounds)(ref bounds)).center; Vector3 extents = ((Bounds)(ref bounds)).extents; for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { for (int l = -1; l <= 1; l += 2) { Vector3 val = center + new Vector3((float)j * extents.x, (float)k * extents.y, (float)l * extents.z); Vector3 val2 = propMeshPart.localPosition + propMeshPart.localRotation * Vector3.Scale(val, propMeshPart.localScale); if (!result.HasValue) { result = new Bounds(val2, Vector3.zero); continue; } Bounds value = result.Value; ((Bounds)(ref value)).Encapsulate(val2); result = value; } } } } } if (!result.HasValue && info.colliderParts != null) { Bounds val9 = default(Bounds); for (int m = 0; m < info.colliderParts.Count; m++) { PropColliderPart propColliderPart = info.colliderParts[m]; if (propColliderPart == null) { continue; } if ((Object)(object)propColliderPart.mesh != (Object)null) { Bounds bounds2 = propColliderPart.mesh.bounds; Vector3 center2 = ((Bounds)(ref bounds2)).center; Vector3 extents2 = ((Bounds)(ref bounds2)).extents; for (int n = -1; n <= 1; n += 2) { for (int num = -1; num <= 1; num += 2) { for (int num2 = -1; num2 <= 1; num2 += 2) { Vector3 val3 = center2 + new Vector3((float)n * extents2.x, (float)num * extents2.y, (float)num2 * extents2.z); Vector3 val4 = propColliderPart.localPosition + propColliderPart.localRotation * Vector3.Scale(val3, propColliderPart.localScale); if (!result.HasValue) { result = new Bounds(val4, Vector3.zero); continue; } Bounds value2 = result.Value; ((Bounds)(ref value2)).Encapsulate(val4); result = value2; } } } } else if (propColliderPart.type == PropColliderPart.ColliderType.Box) { Vector3 val5 = propColliderPart.size * 0.5f; for (int num3 = -1; num3 <= 1; num3 += 2) { for (int num4 = -1; num4 <= 1; num4 += 2) { for (int num5 = -1; num5 <= 1; num5 += 2) { Vector3 val6 = propColliderPart.center + new Vector3((float)num3 * val5.x, (float)num4 * val5.y, (float)num5 * val5.z); Vector3 val7 = propColliderPart.localPosition + propColliderPart.localRotation * Vector3.Scale(val6, propColliderPart.localScale); if (!result.HasValue) { result = new Bounds(val7, Vector3.zero); continue; } Bounds value3 = result.Value; ((Bounds)(ref value3)).Encapsulate(val7); result = value3; } } } } else { Vector3 val8 = propColliderPart.localPosition + propColliderPart.localRotation * Vector3.Scale(propColliderPart.center, propColliderPart.localScale); float num6 = propColliderPart.radius * Mathf.Max(new float[3] { propColliderPart.localScale.x, propColliderPart.localScale.y, propColliderPart.localScale.z }); if (num6 < 0.01f) { num6 = 0.01f; } ((Bounds)(ref val9))..ctor(val8, Vector3.one * (num6 * 2f)); if (!result.HasValue) { result = val9; continue; } Bounds value4 = result.Value; ((Bounds)(ref value4)).Encapsulate(val9); result = value4; } } } if (!result.HasValue) { return null; } Bounds value5 = result.Value; Vector3 size = ((Bounds)(ref value5)).size; if (size.x > 100f || size.y > 100f || size.z > 100f) { return null; } return result; } public static Vector3 GetPropPivotCenter(PropInfo info) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Bounds? propBounds = GetPropBounds(info); Vector3 result; if (!propBounds.HasValue) { result = Vector3.zero; } else { Bounds value = propBounds.Value; result = ((Bounds)(ref value)).center; } return result; } private static int NaturalStringCompare(string a, string b) { if (a == b) { return 0; } if (a == null) { return -1; } if (b == null) { return 1; } int num = 0; int num2 = 0; int length = a.Length; int length2 = b.Length; while (num < length && num2 < length2) { char c = a[num]; char c2 = b[num2]; if (char.IsDigit(c) && char.IsDigit(c2)) { int i; for (i = num; i < length && char.IsDigit(a[i]); i++) { } int j; for (j = num2; j < length2 && char.IsDigit(b[j]); j++) { } int k; for (k = num; k < i && a[k] == '0'; k++) { } int l; for (l = num2; l < j && b[l] == '0'; l++) { } int num3 = i - k; int num4 = j - l; if (num3 != num4) { return (num3 >= num4) ? 1 : (-1); } for (int m = 0; m < num3; m++) { char c3 = a[k + m]; char c4 = b[l + m]; if (c3 != c4) { return (c3 >= c4) ? 1 : (-1); } } int num5 = i - num; int num6 = j - num2; if (num5 != num6) { return (num5 >= num6) ? 1 : (-1); } num = i; num2 = j; } else { int n; for (n = num; n < length && !char.IsDigit(a[n]); n++) { } int num7; for (num7 = num2; num7 < length2 && !char.IsDigit(b[num7]); num7++) { } int num8 = n - num; int num9 = num7 - num2; int num10 = string.Compare(a, num, b, num2, Math.Min(num8, num9), StringComparison.OrdinalIgnoreCase); if (num10 != 0) { return num10; } if (num8 != num9) { return (num8 >= num9) ? 1 : (-1); } num = n; num2 = num7; } } if (num < length) { return 1; } if (num2 < length2) { return -1; } return 0; } public static string ResolveCanonicalId(string id) { if (string.IsNullOrEmpty(id)) { return id; } if (_byId.ContainsKey(id)) { return id; } string text = id; for (int i = 0; i < 8; i++) { if (!_idAliases.TryGetValue(text, out var value)) { break; } if (string.IsNullOrEmpty(value)) { break; } if (_byId.ContainsKey(value)) { return value; } if (string.Equals(value, text, StringComparison.Ordinal)) { break; } text = value; } if (TryParseGpuiIndex(id, out var index)) { for (int j = 0; j < _all.Count; j++) { PropInfo propInfo = _all[j]; if (propInfo != null && propInfo.IsGpui && propInfo.gpuiIndex == index) { _idAliases[id] = propInfo.id; return propInfo.id; } } } return id; } public static PropInfo FindById(string id) { if (_byId.TryGetValue(id, out var value)) { return value; } string key = ResolveCanonicalId(id); PropInfo value2; return _byId.TryGetValue(key, out value2) ? value2 : null; } public static void LoadPropData(PropInfo info) { if (info == null) { return; } if (info.isLoaded) { if (info.HasMesh && (Object)(object)info.parts[0].mesh != (Object)null) { return; } if (info.HasMesh) { MelonLogger.Warning("[PropLibrary] Mesh for \"" + info.displayName + "\" was destroyed — retrying."); } info.parts.Clear(); info.colliderParts.Clear(); info.isLoaded = false; info.isInvalid = false; } if (info.IsPrimitive) { LoadPrimitive(info); return; } if (IsNegativeCollisionProp(info.id)) { LoadNegativeCollisionProp(info); return; } if (IsSpawnPointProp(info.id)) { LoadSpawnPointProp(info); return; } if (info.IsGpui) { LoadGpuiPropData(info); return; } try { if (TryLoadFromBestRegion(info)) { return; } } catch (Exception ex) { MelonLogger.Warning("[PropLibrary] BestRegion failed for \"" + info.displayName + "\": " + ex.Message); } try { if (TryLoadAddressable(info)) { return; } } catch (Exception ex2) { MelonLogger.Warning("[PropLibrary] Addressable failed for \"" + info.displayName + "\": " + ex2.Message); } MelonLogger.Warning($"[PropLibrary] All load methods failed for \"{info.displayName}\" (id: {info.id})."); CatalogEnumerator.LogCatalogBundleHint(info.id); } private static bool TryLoadFromBestRegion(PropInfo info) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) try { GameObject[] array = TryGetLoadedProps(); if (array == null || array.Length == 0) { return false; } string b = NormalizePropName(NormalizeIdToName(info.id)); foreach (GameObject val in array) { if ((Object)(object)val == (Object)null) { continue; } string a = NormalizePropName(((Object)val).name); if (string.Equals(a, b, StringComparison.OrdinalIgnoreCase)) { GameObject val2 = Object.Instantiate(val, new Vector3(0f, -99999f, 0f), Quaternion.identity); try { ExtractPartsFromInstance(val2, info); } finally { Object.Destroy((Object)(object)val2); } if (info.HasMesh) { info.sourcePrefab = val; info.isLoaded = true; info.isInvalid = false; return true; } MelonLogger.Warning("[PropLibrary] BestRegion found \"" + ((Object)val).name + "\" but extracted no mesh."); return false; } } } catch { } return false; } private static bool TryLoadFromLoadedScenes(PropInfo info) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) string text = NormalizePropName(NormalizeIdToName(info.id)); int sceneCount = SceneManager.sceneCount; BBLog.Msg($"[PropLibrary] Scene scan for \"{text}\": {sceneCount} scene(s) loaded."); for (int i = 0; i < sceneCount; i++) { Scene sceneAt; try { sceneAt = SceneManager.GetSceneAt(i); } catch (Exception ex) { MelonLogger.Warning($"[PropLibrary] GetSceneAt({i}) threw: {ex.Message}"); continue; } if (!((Scene)(ref sceneAt)).isLoaded) { BBLog.Msg($"[PropLibrary] Scene[{i}] \"{((Scene)(ref sceneAt)).name}\" not loaded, skipping."); continue; } GameObject[] array; try { array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)((Scene)(ref sceneAt)).GetRootGameObjects()); } catch (Exception ex2) { MelonLogger.Warning("[PropLibrary] GetRootGameObjects threw for \"" + ((Scene)(ref sceneAt)).name + "\": " + ex2.Message); continue; } BBLog.Msg($"[PropLibrary] Scene[{i}] \"{((Scene)(ref sceneAt)).name}\": {array.Length} root(s)."); GameObject[] array2 = array; foreach (GameObject val in array2) { if ((Object)(object)val == (Object)null) { continue; } if (string.Equals(NormalizePropName(((Object)val).name), text, StringComparison.OrdinalIgnoreCase)) { ExtractPartsFromInstance(val, info); if (info.HasMesh) { info.isLoaded = true; info.isInvalid = false; BBLog.Msg($"[PropLibrary] Found \"{info.displayName}\" in scene \"{((Scene)(ref sceneAt)).name}\" (root)."); return true; } info.parts.Clear(); info.colliderParts.Clear(); continue; } Transform[] array3; try { array3 = Il2CppArrayBase.op_Implicit(val.GetComponentsInChildren(true)); } catch { continue; } Transform[] array4 = array3; foreach (Transform val2 in array4) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)null) && string.Equals(NormalizePropName(((Object)((Component)val2).gameObject).name), text, StringComparison.OrdinalIgnoreCase)) { ExtractPartsFromInstance(((Component)val2).gameObject, info); if (info.HasMesh) { info.isLoaded = true; info.isInvalid = false; BBLog.Msg($"[PropLibrary] Found \"{info.displayName}\" in scene \"{((Scene)(ref sceneAt)).name}\" (child of \"{((Object)val).name}\")."); return true; } info.parts.Clear(); info.colliderParts.Clear(); } } } } BBLog.Msg("[PropLibrary] Scene scan: \"" + text + "\" not found in any loaded scene."); return false; } private static void LoadGpuiPropData(PropInfo info) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) BBLog.Msg($"[PropLibrary] GPUI \"{info.displayName}\": visualPath=\"{info.visualPath}\" prefabName=\"{info.gpuiPrefabName}\""); if (!string.IsNullOrEmpty(info.visualPath)) { try { AsyncOperationHandle val = Addressables.LoadAssetAsync(Object.op_Implicit(info.visualPath)); GameObject val2 = val.WaitForCompletion(); if ((Object)(object)val2 != (Object)null) { info._addressableAsset = (Object)(object)val2; GameObject val3 = Object.Instantiate(val2, new Vector3(0f, -99999f, 0f), Quaternion.identity); try { ExtractPartsFromInstance(val3, info); } finally { Object.Destroy((Object)(object)val3); } BBLog.Msg($"[PropLibrary] GPUI \"{info.displayName}\" visual: extracted {info.parts.Count} part(s)."); } else { MelonLogger.Warning($"[PropLibrary] GPUI \"{info.displayName}\" visual load returned null (path: {info.visualPath})."); } } catch (Exception ex) { MelonLogger.Warning("[PropLibrary] GPUI \"" + info.displayName + "\" visual load threw: " + ex.Message); } } else { BBLog.Msg("[PropLibrary] GPUI \"" + info.displayName + "\" has no visualPath — cannot load visual."); } if (!info.HasMesh && !string.IsNullOrEmpty(info.gpuiPrefabName)) { try { GameObject[] array = TryGetLoadedProps(); if (array != null) { string text = NormalizePropName(info.gpuiPrefabName); bool flag = false; foreach (GameObject val4 in array) { if (!((Object)(object)val4 == (Object)null) && string.Equals(NormalizePropName(((Object)val4).name), text, StringComparison.OrdinalIgnoreCase)) { flag = true; GameObject val5 = Object.Instantiate(val4, new Vector3(0f, -99999f, 0f), Quaternion.identity); try { GpuiPropScanner.ExtractPartsFromColliders(val5, info); } catch { } Object.Destroy((Object)(object)val5); BBLog.Msg($"[PropLibrary] GPUI \"{info.displayName}\" collider fallback: extracted {info.parts.Count} part(s)."); break; } } if (!flag) { BBLog.Msg($"[PropLibrary] GPUI \"{info.displayName}\" collider fallback: \"{text}\" not found in loadedProps ({array.Length} entries)."); } } else { MelonLogger.Warning("[PropLibrary] GPUI \"" + info.displayName + "\" collider fallback: loadedProps unavailable."); } } catch (Exception ex2) { MelonLogger.Warning("[PropLibrary] GPUI \"" + info.displayName + "\" collider load threw: " + ex2.Message); } } if (!info.HasMesh && !string.IsNullOrEmpty(info.gpuiPrefabName)) { Dictionary gpuiPlayerPaths = GpuiPropScanner.GetGpuiPlayerPaths(); if (gpuiPlayerPaths.TryGetValue(info.gpuiPrefabName, out var value)) { try { AsyncOperationHandle val6 = Addressables.LoadAssetAsync(Object.op_Implicit(value)); GameObject val7 = val6.WaitForCompletion(); if ((Object)(object)val7 != (Object)null) { if (info._addressableAsset == (Object)null) { info._addressableAsset = (Object)(object)val7; } GameObject val8 = Object.Instantiate(val7, new Vector3(0f, -99999f, 0f), Quaternion.identity); try { GpuiPropScanner.ExtractPartsFromColliders(val8, info); } catch { } Object.Destroy((Object)(object)val8); BBLog.Msg($"[PropLibrary] GPUI \"{info.displayName}\" addressable player: {info.parts.Count} part(s) from {value}"); } else { MelonLogger.Warning($"[PropLibrary] GPUI \"{info.displayName}\" addressable player returned null ({value})."); } } catch (Exception ex3) { MelonLogger.Warning("[PropLibrary] GPUI \"" + info.displayName + "\" addressable player failed: " + ex3.Message); } } else { MelonLogger.Warning($"[PropLibrary] GPUI \"{info.displayName}\": player prefab \"{info.gpuiPrefabName}\" not found in catalog."); } } BBLog.Msg($"[PropLibrary] GPUI \"{info.displayName}\" done: HasMesh={info.HasMesh}"); info.isLoaded = true; info.isInvalid = !info.HasMesh; } private static bool TryLoadAddressable(PropInfo info) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(info.id)) { return false; } if (IsMeshAssetPath(info.id)) { return TryLoadAddressableMesh(info); } AsyncOperationHandle val = Addressables.LoadAssetAsync(Object.op_Implicit(info.id)); GameObject val2 = val.WaitForCompletion(); if ((Object)(object)val2 == (Object)null) { return false; } info._addressableAsset = (Object)(object)val2; info.sourcePrefab = val2; GameObject val3 = Object.Instantiate(val2, new Vector3(0f, -99999f, 0f), Quaternion.identity); try { ExtractPartsFromInstance(val3, info); } finally { Object.Destroy((Object)(object)val3); } info.isLoaded = true; info.isInvalid = !info.HasMesh; return true; } private static bool TryLoadAddressableMesh(PropInfo info) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle val = Addressables.LoadAssetAsync(Object.op_Implicit(info.id)); Mesh val2 = val.WaitForCompletion(); if ((Object)(object)val2 == (Object)null) { return false; } info._addressableAsset = (Object)(object)val2; Material val3 = TryFindMaterialForMesh(val2); info.parts.Add(new PropMeshPart { mesh = val2, materials = (Material[])(object)((!((Object)(object)val3 != (Object)null)) ? null : new Material[1] { val3 }), localPosition = Vector3.zero, localRotation = Quaternion.identity, localScale = Vector3.one }); info.isLoaded = true; info.isInvalid = !info.HasMesh; return true; } internal static bool IsMeshAssetPath(string path) { if (string.IsNullOrEmpty(path)) { return false; } string text = path.ToLowerInvariant(); if (!text.StartsWith("assets/", StringComparison.Ordinal)) { return false; } if (!text.StartsWith("assets/meshes/", StringComparison.Ordinal) && !text.StartsWith("assets/_props/", StringComparison.Ordinal)) { return false; } return text.EndsWith(".asset", StringComparison.Ordinal) || text.EndsWith(".fbx", StringComparison.Ordinal) || text.EndsWith(".obj", StringComparison.Ordinal) || text.EndsWith(".mesh", StringComparison.Ordinal); } private static string StripLodSuffix(string name) { int num = name.IndexOf("_LOD", StringComparison.OrdinalIgnoreCase); return (num >= 0) ? name.Substring(0, num) : name; } private static Material TryFindMaterialForMesh(Mesh mesh) { if ((Object)(object)mesh == (Object)null || string.IsNullOrEmpty(((Object)mesh).name)) { return null; } string name = ((Object)mesh).name; string b = StripLodSuffix(name); try { Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); Material result = null; foreach (Material item in val) { if (!((Object)(object)item == (Object)null) && !string.IsNullOrEmpty(((Object)item).name) && (string.Equals(((Object)item).name, name, StringComparison.OrdinalIgnoreCase) || string.Equals(((Object)item).name, b, StringComparison.OrdinalIgnoreCase))) { if ((Object)(object)item.mainTexture != (Object)null) { return item; } result = item; } } return result; } catch { return null; } } internal static GameObject[] TryGetLoadedProps() { try { if (!TryGetBestRegion(out var brl)) { return null; } List list = TryGetListField(brl, "loadedProps"); if (list == null) { return null; } GameObject[] array = (GameObject[])(object)new GameObject[list.Count]; for (int i = 0; i < list.Count; i++) { ref GameObject reference = ref array[i]; object obj = list[i]; reference = (GameObject)((obj is GameObject) ? obj : null); } return array; } catch { } return null; } private static bool TryGetBestRegion(out object brl) { brl = null; try { Type type = _bestRegionType; if (type == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] array = assemblies; foreach (Assembly assembly in array) { type = assembly.GetType("BestRegionLoader"); if (type == null) { try { Type[] types = assembly.GetTypes(); foreach (Type type2 in types) { if (type2 != null && type2.Name == "BestRegionLoader") { type = type2; break; } } } catch (ReflectionTypeLoadException ex) { Type[] types2 = ex.Types; foreach (Type type3 in types2) { if (type3 != null && type3.Name == "BestRegionLoader") { type = type3; break; } } } } if (type != null) { _bestRegionType = type; break; } } } if (type == null) { return false; } FieldInfo field = type.GetField("me", BindingFlags.Static | BindingFlags.Public); if (field != null) { brl = field.GetValue(null); } else { PropertyInfo property = type.GetProperty("me", BindingFlags.Static | BindingFlags.Public); if (property != null) { brl = property.GetValue(null); } } if (brl != null) { return true; } } catch { } return false; } private static List TryGetListField(object obj, string memberName) { if (obj == null) { return null; } Type type = obj.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = type.GetField(memberName, bindingAttr); if (field != null) { object value = field.GetValue(obj); return ConvertToObjectList(value); } PropertyInfo property = type.GetProperty(memberName, bindingAttr); if (property != null) { object value2 = property.GetValue(obj, null); return ConvertToObjectList(value2); } return null; } private static List ConvertToObjectList(object val) { if (val == null) { return null; } if (val is IList list) { List list2 = new List(list.Count); foreach (object item in list) { list2.Add(item); } return list2; } if (val is Array array) { List list3 = new List(array.Length); foreach (object item2 in array) { list3.Add(item2); } return list3; } if (val is IEnumerable enumerable) { List list4 = new List(); foreach (object item3 in enumerable) { list4.Add(item3); } return list4; } Type type = val.GetType(); PropertyInfo property = type.GetProperty("Length"); MethodInfo method = type.GetMethod("get_Item", new Type[1] { typeof(int) }); if (property != null && method != null && property.GetValue(val, null) is int num) { List list5 = new List(num); for (int i = 0; i < num; i++) { list5.Add(method.Invoke(val, new object[1] { i })); } return list5; } return null; } private static string NormalizeIdToName(string id) { if (string.IsNullOrEmpty(id)) { return string.Empty; } string text = id; text = (text.StartsWith("primitive://", StringComparison.Ordinal) ? text.Substring("primitive://".Length) : ((!text.StartsWith("cached://", StringComparison.Ordinal)) ? Path.GetFileNameWithoutExtension(text) : text.Substring("cached://".Length))); int num = text.IndexOf('#'); if (num > 0) { text = text.Substring(0, num); } return text; } internal static string NormalizePropName(string name) { if (string.IsNullOrEmpty(name)) { return string.Empty; } string text = name.Replace("(Clone)", "").Trim(); return text.Replace("_player", "", StringComparison.OrdinalIgnoreCase).Replace("_Player", "", StringComparison.OrdinalIgnoreCase).Trim(); } private static void ExtractPartsFromInstance(GameObject root, PropInfo info) { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return; } Il2CppArrayBase componentsInChildren = root.GetComponentsInChildren(true); foreach (MeshFilter item in componentsInChildren) { if (!((Object)(object)item == (Object)null) && !((Object)(object)item.sharedMesh == (Object)null)) { MeshRenderer component = ((Component)item).GetComponent(); Il2CppReferenceArray val = (((Object)(object)component != (Object)null) ? ((Renderer)component).sharedMaterials : null); AddPart(info, item.sharedMesh, Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)val), ((Component)item).transform, root.transform); } } Il2CppArrayBase componentsInChildren2 = root.GetComponentsInChildren(true); foreach (SkinnedMeshRenderer item2 in componentsInChildren2) { if (!((Object)(object)item2 == (Object)null) && !((Object)(object)item2.sharedMesh == (Object)null)) { AddPart(info, item2.sharedMesh, Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)((Renderer)item2).sharedMaterials), ((Component)item2).transform, root.transform); } } Transform transform = root.transform; Vector3 lossyScale = transform.lossyScale; Il2CppArrayBase componentsInChildren3 = root.GetComponentsInChildren(true); foreach (Collider item3 in componentsInChildren3) { if ((Object)(object)item3 == (Object)null || item3.isTrigger) { continue; } Transform transform2 = ((Component)item3).transform; PropColliderPart propColliderPart = new PropColliderPart { localPosition = transform.InverseTransformPoint(transform2.position), localRotation = Quaternion.Inverse(transform.rotation) * transform2.rotation, localScale = new Vector3(transform2.lossyScale.x / ((lossyScale.x != 0f) ? lossyScale.x : 1f), transform2.lossyScale.y / ((lossyScale.y != 0f) ? lossyScale.y : 1f), transform2.lossyScale.z / ((lossyScale.z != 0f) ? lossyScale.z : 1f)) }; MeshCollider val2 = ((Il2CppObjectBase)item3).TryCast(); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.sharedMesh != (Object)null) { propColliderPart.type = PropColliderPart.ColliderType.Mesh; propColliderPart.mesh = val2.sharedMesh; propColliderPart.convex = val2.convex; } else { BoxCollider val3 = ((Il2CppObjectBase)item3).TryCast(); if (val3 != null) { propColliderPart.type = PropColliderPart.ColliderType.Box; propColliderPart.center = val3.center; propColliderPart.size = val3.size; } else { SphereCollider val4 = ((Il2CppObjectBase)item3).TryCast(); if (val4 != null) { propColliderPart.type = PropColliderPart.ColliderType.Sphere; propColliderPart.center = val4.center; propColliderPart.radius = val4.radius; } else { CapsuleCollider val5 = ((Il2CppObjectBase)item3).TryCast(); if (val5 == null) { continue; } propColliderPart.type = PropColliderPart.ColliderType.Capsule; propColliderPart.center = val5.center; propColliderPart.radius = val5.radius; propColliderPart.height = val5.height; propColliderPart.direction = val5.direction; } } } info.colliderParts.Add(propColliderPart); } } private static void LoadPrimitive(PropInfo info) { //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) try { string text = info.id.Substring("primitive://".Length); if (1 == 0) { } Mesh val = (Mesh)(text switch { "Torus" => PrimitiveMeshGen.BuildTorus(), "Cone" => PrimitiveMeshGen.BuildCone(), "Helix" => PrimitiveMeshGen.BuildHelix(), "Egg" => PrimitiveMeshGen.BuildEgg(), _ => null, }); if (1 == 0) { } Mesh val2 = val; if ((Object)(object)val2 != (Object)null) { ((Object)val2).hideFlags = (HideFlags)61; GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)0); MeshRenderer component = val3.GetComponent(); Il2CppReferenceArray val4 = (((Object)(object)component != (Object)null) ? ((Renderer)component).sharedMaterials : null); Object.Destroy((Object)(object)val3); info.parts.Add(new PropMeshPart { mesh = val2, materials = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)val4), localPosition = Vector3.zero, localRotation = Quaternion.identity, localScale = Vector3.one }); _primitiveMeshHolder.Add(val2); info.isLoaded = true; info.isInvalid = false; return; } if (!Enum.TryParse(text, out PrimitiveType result)) { info.isLoaded = true; info.isInvalid = true; return; } GameObject val5 = GameObject.CreatePrimitive(result); val5.transform.position = new Vector3(0f, -99999f, 0f); MeshFilter component2 = val5.GetComponent(); MeshRenderer component3 = val5.GetComponent(); if ((Object)(object)component2 != (Object)null && (Object)(object)component2.sharedMesh != (Object)null) { Mesh sharedMesh = component2.sharedMesh; PropMeshPart item = new PropMeshPart { mesh = sharedMesh, materials = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)(((Object)(object)component3 != (Object)null) ? ((Renderer)component3).sharedMaterials : null)), localPosition = Vector3.zero, localRotation = Quaternion.identity, localScale = val5.transform.localScale }; info.parts.Add(item); _primitiveMeshHolder.Add(sharedMesh); } Object.Destroy((Object)(object)val5); info.isLoaded = true; info.isInvalid = !info.HasMesh; } catch { info.isLoaded = true; info.isInvalid = true; } } private static void LoadNegativeCollisionProp(PropInfo info) { //IL_001a: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) try { (Vector3, Vector3)[] edges = new(Vector3, Vector3)[12] { (new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f)), (new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, 0.5f)), (new Vector3(0.5f, -0.5f, 0.5f), new Vector3(-0.5f, -0.5f, 0.5f)), (new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(-0.5f, -0.5f, -0.5f)), (new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f)), (new Vector3(0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, 0.5f)), (new Vector3(0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f)), (new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, -0.5f)), (new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, 0.5f, -0.5f)), (new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f)), (new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f)), (new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f)) }; info.parts.Add(new PropMeshPart { mesh = BuildEdgeTubeMesh(edges, 0.02f), materials = (Material[])(object)new Material[1] { BuildWireframeMaterial(new Color(1f, 0.95f, 0.3f)) }, localPosition = Vector3.zero, localRotation = Quaternion.identity, localScale = Vector3.one }); info.isLoaded = true; info.isInvalid = false; } catch { info.isLoaded = true; info.isInvalid = true; } } public static bool IsNegativeCollisionProp(string id) { return !string.IsNullOrEmpty(id) && string.Equals(id, "special://negative-hole", StringComparison.Ordinal); } private static void LoadSpawnPointProp(PropInfo info) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) info.parts.Clear(); try { List<(Vector3, Vector3)> list = new List<(Vector3, Vector3)>(); Vector3[] array = (Vector3[])(object)new Vector3[24]; for (int i = 0; i < 24; i++) { float num = (float)i / 24f * (float)Math.PI * 2f; array[i] = new Vector3(Mathf.Cos(num) * 0.4f, 0.02f, Mathf.Sin(num) * 0.4f); } for (int j = 0; j < 24; j++) { list.Add((array[j], array[(j + 1) % 24])); } list.Add((Vector3.zero, new Vector3(0f, 1.8f, 0f))); Vector3 item = default(Vector3); ((Vector3)(ref item))..ctor(0f, 0.05f, 0f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, 0.05f, 0.7f); list.Add((item, val)); list.Add((val, val + Quaternion.Euler(0f, 150f, 0f) * Vector3.forward * 0.18f)); list.Add((val, val + Quaternion.Euler(0f, -150f, 0f) * Vector3.forward * 0.18f)); info.parts.Add(new PropMeshPart { mesh = BuildEdgeTubeMesh(list.ToArray(), 0.018f), materials = (Material[])(object)new Material[1] { BuildWireframeMaterial(new Color(0.3f, 1f, 0.45f)) }, localPosition = Vector3.zero, localRotation = Quaternion.identity, localScale = Vector3.one }); info.isLoaded = true; info.isInvalid = false; } catch (Exception ex) { MelonLogger.Warning("[PropLibrary] Failed to build Spawn Point placeholder: " + ex.Message); info.isLoaded = true; info.isInvalid = true; } } public static bool IsSpawnPointProp(string id) { return !string.IsNullOrEmpty(id) && string.Equals(id, "special://spawn-point", StringComparison.Ordinal); } internal static void AddPart(PropInfo info, Mesh mesh, Material[] materials, Transform t, Transform rootT) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00d5: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)mesh == (Object)null) && info != null) { Vector3 lossyScale = t.lossyScale; Vector3 lossyScale2 = rootT.lossyScale; PropMeshPart item = new PropMeshPart { mesh = mesh, materials = materials, localPosition = rootT.InverseTransformPoint(t.position), localRotation = Quaternion.Inverse(rootT.rotation) * t.rotation, localScale = new Vector3((lossyScale2.x != 0f) ? (lossyScale.x / lossyScale2.x) : 1f, (lossyScale2.y != 0f) ? (lossyScale.y / lossyScale2.y) : 1f, (lossyScale2.z != 0f) ? (lossyScale.z / lossyScale2.z) : 1f), rendererSubPath = GetRendererSubPath(t, rootT) }; info.parts.Add(item); } } private static Mesh BuildEdgeTubeMesh((Vector3 a, Vector3 b)[] edges, float thickness) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); float num = thickness * 0.5f; for (int i = 0; i < edges.Length; i++) { (Vector3 a, Vector3 b) tuple = edges[i]; Vector3 item = tuple.a; Vector3 item2 = tuple.b; Vector3 val = item2 - item; if (!(((Vector3)(ref val)).sqrMagnitude < 1E-06f)) { ((Vector3)(ref val)).Normalize(); Vector3 val2; Vector3 normalized; if (!(Mathf.Abs(val.y) < 0.9f)) { val2 = new Vector3(0f, 0f - val.z, val.y); normalized = ((Vector3)(ref val2)).normalized; } else { val2 = new Vector3(0f - val.z, 0f, val.x); normalized = ((Vector3)(ref val2)).normalized; } Vector3 val3 = normalized; Vector3 val4 = Vector3.Cross(val, val3); Vector3 val5 = val3 * num; Vector3 val6 = val4 * num; int count = list.Count; list.Add(item - val5 - val6); list.Add(item + val5 - val6); list.Add(item + val5 + val6); list.Add(item - val5 + val6); list.Add(item2 - val5 - val6); list.Add(item2 + val5 - val6); list.Add(item2 + val5 + val6); list.Add(item2 - val5 + val6); AddTubeQuad(list2, count, 0, 1, 5, 4); AddTubeQuad(list2, count, 1, 2, 6, 5); AddTubeQuad(list2, count, 2, 3, 7, 6); AddTubeQuad(list2, count, 3, 0, 4, 7); AddTubeQuad(list2, count, 3, 2, 1, 0); AddTubeQuad(list2, count, 4, 5, 6, 7); } } Mesh val7 = new Mesh { name = "WireframeTubes" }; val7.vertices = Il2CppStructArray.op_Implicit(list.ToArray()); val7.triangles = Il2CppStructArray.op_Implicit(list2.ToArray()); val7.RecalculateNormals(); val7.RecalculateBounds(); return val7; } private static void AddTubeQuad(List tris, int vi, int a, int b, int c, int d) { tris.Add(vi + a); tris.Add(vi + b); tris.Add(vi + c); tris.Add(vi + a); tris.Add(vi + c); tris.Add(vi + d); } private static Material BuildWireframeMaterial(Color color) { //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_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); Material val2 = new Material(val) { name = "BabyBlocks_WirePreview" }; if (val2.HasProperty("_Color")) { val2.SetColor("_Color", color); } return val2; } private static string GetRendererSubPath(Transform t, Transform rootT) { if ((Object)(object)t == (Object)null || (Object)(object)t == (Object)(object)rootT) { return ""; } List list = new List(); Transform val = t; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)rootT) { list.Add(((Object)val).name); val = val.parent; } list.Reverse(); return string.Join("/", list); } } internal static class PropMetadataPanel { public static bool Enabled = true; private const float HeaderH = 22f; private const float Pad = 8f; private const float MaterialListH = 140f; private const float RendererListH = 120f; private const string SearchField = "propMetaSearch"; private const string DisplayNameField = "propMetaDisplayName"; private const string CategoryField = "propMetaCategory"; private const string OverrideField = "propMetaOverride"; private static Rect _windowRect; private static bool _windowInitialized; private static bool _windowDragging; private static Vector2 _windowDragOffset; private static bool _showMaterialDropdown; private static Vector2 _materialScroll; private static Vector2 _mainScroll; private static string _materialSearch = ""; private static GUIStyle _materialButtonStyle; private static GUIStyle _redLabelStyle; private static bool _showRendererDropdown; private static Vector2 _rendererScroll; private static bool _showSurfaceTypeDropdown; private static Vector2 _surfaceTypeScroll; private static bool _showGrassTypeDropdown; private static Vector2 _grassTypeScroll; private static int _openSlotDropdown = -1; private static Vector2 _slotDropdownScroll; private static string _slotDropdownSearch = ""; private static string _forcedMaterialSlotsStr = "2"; private static bool _showExportWindow; private static Rect _exportWindowRect; private static bool _exportWindowInitialized; private static bool _exportWindowDragging; private static Vector2 _exportWindowDragOffset; private static string _exportStatusMsg = ""; public static bool IsTypingInUI { get; private set; } public static bool IsPointerOverUI { get; private set; } public static void DrawGUI(LevelEditorObject selectedObject) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) if (!Enabled || !Core.DebugMode) { IsTypingInUI = false; IsPointerOverUI = false; return; } if (PropMetadataEditor.SyncFromSelection(selectedObject)) { _showMaterialDropdown = false; _showRendererDropdown = false; _showSurfaceTypeDropdown = false; _showGrassTypeDropdown = false; _openSlotDropdown = -1; _slotDropdownSearch = string.Empty; } EnsureWindowRect(); Rect windowRect = _windowRect; GUI.Box(windowRect, "Prop Details", GUI.skin.window); Rect headerRect = default(Rect); ((Rect)(ref headerRect))..ctor(((Rect)(ref windowRect)).x, ((Rect)(ref windowRect)).y, ((Rect)(ref windowRect)).width, 22f); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref windowRect)).x + 8f, ((Rect)(ref windowRect)).y + 22f + 8f, ((Rect)(ref windowRect)).width - 16f, ((Rect)(ref windowRect)).height - 22f - 16f); GUILayout.BeginArea(val); DrawContents(); GUILayout.EndArea(); HandleDrag(headerRect); PropMetadataEditor.AutoSaveIfIdle(); if (_showExportWindow) { DrawExportWindow(); } int isTypingInUI; switch (GUI.GetNameOfFocusedControl()) { default: isTypingInUI = (MaterialConstructionPanel.IsTypingInUI ? 1 : 0); break; case "propMetaSearch": case "propMetaDisplayName": case "propMetaCategory": case "propMetaOverride": isTypingInUI = 1; break; } IsTypingInUI = (byte)isTypingInUI != 0; if (string.IsNullOrEmpty(PropMetadataEditor.PropId) && !MaterialConstructionPanel.Active) { IsTypingInUI = false; } Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y); IsPointerOverUI = ((Rect)(ref windowRect)).Contains(val2); if (_showExportWindow && _exportWindowInitialized) { IsPointerOverUI |= ((Rect)(ref _exportWindowRect)).Contains(val2); } } public static bool ContainsPoint(Vector2 guiPoint) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!Enabled || !_windowInitialized) { return false; } return ((Rect)(ref _windowRect)).Contains(guiPoint); } private static void DrawContents() { //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Expected O, but got Unknown //IL_02bc: 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_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_0856: Unknown result type (might be due to invalid IL or missing references) //IL_085b: 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_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0da2: 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_0dbf: Unknown result type (might be due to invalid IL or missing references) //IL_135d: Unknown result type (might be due to invalid IL or missing references) //IL_1375: Unknown result type (might be due to invalid IL or missing references) //IL_137a: Unknown result type (might be due to invalid IL or missing references) //IL_0fbb: Unknown result type (might be due to invalid IL or missing references) //IL_0fc0: Unknown result type (might be due to invalid IL or missing references) //IL_1003: Unknown result type (might be due to invalid IL or missing references) //IL_101b: Unknown result type (might be due to invalid IL or missing references) //IL_1020: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical((Il2CppReferenceArray)null); GUILayout.Label("Search props", (Il2CppReferenceArray)null); GUI.SetNextControlName("propMetaSearch"); string text = GUILayout.TextField(PropLibrary.SearchText ?? string.Empty, Array.Empty()); if (!string.Equals(text, PropLibrary.SearchText, StringComparison.Ordinal)) { PropLibrary.SetSearch(text); } bool flag = GUILayout.Toggle(PropLibrary.DebugSearchMetaNames, "Search metadata names", (Il2CppReferenceArray)null); if (flag != PropLibrary.DebugSearchMetaNames) { PropLibrary.DebugSearchMetaNames = flag; PropLibrary.RebuildFiltered(); } GUILayout.Space(4f); GUI.enabled = !string.IsNullOrEmpty(PropMetadataEditor.PropId); if (GUILayout.Button("Save", (Il2CppReferenceArray)null)) { PropMetadataStore._loadedFromJson = true; PropMetadataEditor.ApplyCurrent(); PropMetadataEditor.Dirty = false; } GUI.enabled = true; if (GUILayout.Button("Save All", (Il2CppReferenceArray)null)) { PropMetadataStore._loadedFromJson = true; if (!string.IsNullOrEmpty(PropMetadataEditor.PropId)) { PropMetadataEditor.ApplyCurrent(); PropMetadataEditor.Dirty = false; } PropMetadataStore.Save(); } if (GUILayout.Button(_showExportWindow ? "Hide Export" : "Binary Export", (Il2CppReferenceArray)null)) { _showExportWindow = !_showExportWindow; } if (GUILayout.Button(MaterialConstructionPanel.Active ? "Exit Material Construction" : "Material Construction", (Il2CppReferenceArray)null)) { MaterialConstructionPanel.Active = !MaterialConstructionPanel.Active; } GUILayout.Space(4f); _mainScroll = GUILayout.BeginScrollView(_mainScroll, false, false, GUIStyle.none, GUI.skin.verticalScrollbar, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); if (MaterialConstructionPanel.Active) { MaterialConstructionPanel.DrawConstructor(); GUILayout.EndScrollView(); GUILayout.EndVertical(); return; } if (string.IsNullOrEmpty(PropMetadataEditor.PropId)) { GUILayout.Label("Select a prop in the world to edit its details.", (Il2CppReferenceArray)null); GUILayout.EndScrollView(); GUILayout.EndVertical(); return; } GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(375f) }); GUILayout.Label("Selected ID (click to copy)", (Il2CppReferenceArray)null); if (GUILayout.Button(PropMetadataEditor.PropId ?? string.Empty, GUI.skin.textField, Array.Empty())) { GUIUtility.systemCopyBuffer = PropMetadataEditor.PropId ?? string.Empty; } bool flag2 = GUILayout.Toggle(PropMetadataEditor.Excluded, "Exclude item", (Il2CppReferenceArray)null); if (flag2 != PropMetadataEditor.Excluded) { PropMetadataEditor.Excluded = flag2; PropMetadataEditor.MarkDirty(); } GUILayout.Space(4f); if (_redLabelStyle == null) { _redLabelStyle = new GUIStyle(GUI.skin.label); _redLabelStyle.normal.textColor = Color.red; } bool flag3 = !string.IsNullOrEmpty(PropMetadataEditor.DisplayName) && PropMetadataStore.HasDuplicateDisplayName(PropMetadataEditor.DisplayName, PropMetadataEditor.PropId); GUILayout.Label("Display name", flag3 ? _redLabelStyle : GUI.skin.label, (Il2CppReferenceArray)null); GUI.SetNextControlName("propMetaDisplayName"); string text2 = GUILayout.TextField(PropMetadataEditor.DisplayName ?? string.Empty, Array.Empty()); if (!string.Equals(text2, PropMetadataEditor.DisplayName, StringComparison.Ordinal)) { PropMetadataEditor.DisplayName = text2; PropMetadataEditor.MarkDirty(); } if (GUI.GetNameOfFocusedControl() == "propMetaDisplayName" && !string.IsNullOrEmpty(PropMetadataEditor.DisplayName) && PropMetadataEditor.DisplayName.Length >= 2) { int num = 0; foreach (KeyValuePair item3 in PropMetadataStore._byId) { if (item3.Key == PropMetadataEditor.PropId) { continue; } string displayName = item3.Value.displayName; if (!string.IsNullOrEmpty(displayName) && (displayName.IndexOf(PropMetadataEditor.DisplayName, StringComparison.OrdinalIgnoreCase) >= 0 || PropMetadataEditor.DisplayName.IndexOf(displayName, StringComparison.OrdinalIgnoreCase) >= 0)) { if (num == 0) { GUI.contentColor = new Color(1f, 1f, 0.5f, 1f); GUILayout.Label("Similar names:", (Il2CppReferenceArray)null); GUI.contentColor = Color.white; } GUILayout.Label(" • " + displayName, (Il2CppReferenceArray)null); num++; if (num >= 5) { break; } } } } GUILayout.Label("Category", (Il2CppReferenceArray)null); GUI.SetNextControlName("propMetaCategory"); string text3 = GUILayout.TextField(PropMetadataEditor.Category ?? string.Empty, Array.Empty()); if (!string.Equals(text3, PropMetadataEditor.Category, StringComparison.Ordinal)) { PropMetadataEditor.Category = text3; PropMetadataEditor.MarkDirty(); } if (GUI.GetNameOfFocusedControl() == "propMetaCategory" && !string.IsNullOrEmpty(PropMetadataEditor.Category) && PropMetadataEditor.Category.Length >= 2) { int num2 = 0; HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair item4 in PropMetadataStore._byId) { if (item4.Key == PropMetadataEditor.PropId) { continue; } string category = item4.Value.category; if (!string.IsNullOrEmpty(category) && (category.IndexOf(PropMetadataEditor.Category, StringComparison.OrdinalIgnoreCase) >= 0 || PropMetadataEditor.Category.IndexOf(category, StringComparison.OrdinalIgnoreCase) >= 0) && hashSet.Add(category)) { if (num2 == 0) { GUI.contentColor = new Color(1f, 1f, 0.5f, 1f); GUILayout.Label("Similar categories:", (Il2CppReferenceArray)null); GUI.contentColor = Color.white; } GUILayout.Label(" • " + category, (Il2CppReferenceArray)null); num2++; if (num2 >= 5) { break; } } } } GUILayout.Space(4f); GUILayout.Label("Surface type (traction / footstep audio)", (Il2CppReferenceArray)null); string text4 = (string.IsNullOrEmpty(PropMetadataEditor.SurfaceType) ? "(none — game default)" : PropMetadataEditor.SurfaceType); if (GUILayout.Button(text4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) })) { _showSurfaceTypeDropdown = !_showSurfaceTypeDropdown; } if (_showSurfaceTypeDropdown) { _surfaceTypeScroll = GUILayout.BeginScrollView(_surfaceTypeScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(120f) }); string[] knownSurfaceTags = PropMetadataEditor.KnownSurfaceTags; foreach (string text5 in knownSurfaceTags) { string text6 = (string.IsNullOrEmpty(text5) ? "(none — game default)" : text5); if (string.Equals(text5, PropMetadataEditor.SurfaceType, StringComparison.Ordinal)) { text6 = "> " + text6; } EnsureMaterialButtonStyle(); if (GUILayout.Button(text6, _materialButtonStyle, Array.Empty())) { PropMetadataEditor.SurfaceType = text5; _showSurfaceTypeDropdown = false; PropInstanceServices.ApplySurfaceType(PropMetadataEditor.SelectedLEO, text5); PropMetadataEditor.MarkDirty(); } } GUILayout.EndScrollView(); } GUILayout.Space(8f); bool flag4 = GUILayout.Toggle(PropMetadataEditor.UseRenderMeshCollider, "Use render mesh as collider", (Il2CppReferenceArray)null); if (flag4 != PropMetadataEditor.UseRenderMeshCollider) { PropMetadataEditor.UseRenderMeshCollider = flag4; PropMetadataEditor.ApplyColliderToSelected(flag4); PropMetadataEditor.BuildRendererEntries(PropMetadataEditor.SelectedLEO); PropMetadataEditor.ApplyRendererVisibility(); PropMetadataEditor.ApplyCurrent(); PropMetadataEditor.Dirty = false; } GUILayout.Label("Components", (Il2CppReferenceArray)null); if (GUILayout.Button(_showRendererDropdown ? "Hide components" : "Show components", (Il2CppReferenceArray)null)) { _showRendererDropdown = !_showRendererDropdown; } if (_showRendererDropdown) { _rendererScroll = GUILayout.BeginScrollView(_rendererScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(120f) }); for (int j = 0; j < PropMetadataEditor.RendererEntries.Count; j++) { PropMetadataEditor.RendererEntry rendererEntry = PropMetadataEditor.RendererEntries[j]; bool flag5 = GUILayout.Toggle(rendererEntry.enabled, rendererEntry.path, (Il2CppReferenceArray)null); if (flag5 != rendererEntry.enabled) { rendererEntry.enabled = flag5; if ((Object)(object)rendererEntry.renderer != (Object)null) { rendererEntry.renderer.enabled = flag5; } else if ((Object)(object)rendererEntry.collider != (Object)null) { rendererEntry.collider.enabled = flag5; } if (!flag5) { PropMetadataEditor.DisabledRendererPaths.Add(rendererEntry.path); } else { PropMetadataEditor.DisabledRendererPaths.Remove(rendererEntry.path); } PropMetadataEditor.MarkDirty(); } } GUILayout.EndScrollView(); } GUILayout.Space(8f); MaterialCatalog.EnsureMaterialList(); int num3 = (PropMetadataEditor.MultiMaterialEnabled ? Math.Max(PropMetadataEditor.ForcedMaterialSlots, PropMetadataEditor.MaxMaterialSlots) : PropMetadataEditor.MaxMaterialSlots); bool flag6 = GUILayout.Toggle(PropMetadataEditor.MultiMaterialEnabled, "Multiple materials", (Il2CppReferenceArray)null); if (flag6 != PropMetadataEditor.MultiMaterialEnabled) { PropMetadataEditor.MultiMaterialEnabled = flag6; int num4 = (PropMetadataEditor.MultiMaterialEnabled ? Math.Max(PropMetadataEditor.ForcedMaterialSlots, PropMetadataEditor.MaxMaterialSlots) : PropMetadataEditor.MaxMaterialSlots); while (PropMetadataEditor.PerSlotDefault.Count < num4) { PropMetadataEditor.PerSlotDefault.Add(string.Empty); } while (PropMetadataEditor.PerSlotSelected.Count < num4) { PropMetadataEditor.PerSlotSelected.Add(string.Empty); } _openSlotDropdown = -1; if (PropMetadataEditor.MultiMaterialEnabled) { if (!string.IsNullOrEmpty(PropMetadataEditor.OverrideMaterialName) && PropMetadataEditor.PerSlotSelected.Count > 0 && string.IsNullOrEmpty(PropMetadataEditor.PerSlotSelected[0])) { PropMetadataEditor.PerSlotSelected[0] = PropMetadataEditor.OverrideMaterialName; } PropMetadataEditor.ApplyAllSlotMaterials(); } else { PropMetadataEditor.RestoreDefaultMaterials(); } PropMetadataEditor.MarkDirty(); } if (PropMetadataEditor.MultiMaterialEnabled) { GUILayout.BeginHorizontal((Il2CppReferenceArray)null); GUILayout.Label("Slots:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); string text7 = GUILayout.TextField(_forcedMaterialSlotsStr, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); if (!string.Equals(text7, _forcedMaterialSlotsStr, StringComparison.Ordinal)) { _forcedMaterialSlotsStr = text7; if (int.TryParse(text7, out var result) && result >= 2) { int num5 = Math.Max(PropMetadataEditor.ForcedMaterialSlots, PropMetadataEditor.MaxMaterialSlots); PropMetadataEditor.ForcedMaterialSlots = result; int num6 = Math.Max(PropMetadataEditor.ForcedMaterialSlots, PropMetadataEditor.MaxMaterialSlots); if (num6 < num5) { for (int k = num6; k < num5; k++) { PropMetadataEditor.SlotHasExplicitOverride.Remove(k); } while (PropMetadataEditor.PerSlotSelected.Count > num6) { PropMetadataEditor.PerSlotSelected.RemoveAt(PropMetadataEditor.PerSlotSelected.Count - 1); } PropMetadataEditor.RestoreDefaultMaterials(); } while (PropMetadataEditor.PerSlotDefault.Count < num6) { PropMetadataEditor.PerSlotDefault.Add(string.Empty); } while (PropMetadataEditor.PerSlotSelected.Count < num6) { PropMetadataEditor.PerSlotSelected.Add(string.Empty); } PropMetadataEditor.ApplyAllSlotMaterials(); PropMetadataEditor.MarkDirty(); } } GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal((Il2CppReferenceArray)null); GUILayout.Label("Ignore collider submeshes (0-based):", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(230f) }); string text8 = GUILayout.TextField(PropMetadataEditor.ColliderIgnoredSubmeshes ?? string.Empty, Array.Empty()); if (!string.Equals(text8, PropMetadataEditor.ColliderIgnoredSubmeshes, StringComparison.Ordinal)) { PropMetadataEditor.ColliderIgnoredSubmeshes = text8; PropMetadataEditor.MarkDirty(); } GUILayout.EndHorizontal(); if (num3 <= 1) { GUILayout.Label("Override material", (Il2CppReferenceArray)null); GUILayout.BeginHorizontal((Il2CppReferenceArray)null); string overrideLabel = PropMetadataEditor.GetOverrideLabel(); GUI.SetNextControlName("propMetaOverride"); if (GUILayout.Button(overrideLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) })) { _showMaterialDropdown = !_showMaterialDropdown; } if (GUILayout.Button("Reset", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(22f), GUILayout.Width(50f) })) { PropMetadataEditor.SelectedMaterialName = PropMetadataEditor.DefaultMaterialName ?? string.Empty; PropMetadataEditor.OverrideMaterialName = string.Empty; _showMaterialDropdown = false; PropMetadataEditor.MaterialExplicitlyChosen = false; if (!string.IsNullOrEmpty(PropMetadataEditor.DefaultMaterialName)) { PropMetadataEditor.ApplyPreviewMaterial(PropMetadataEditor.DefaultMaterialName); } else { PropMetadataEditor.ApplyPreviewMaterial(string.Empty); } PropMetadataEditor.MarkDirty(); } GUILayout.EndHorizontal(); if (_showMaterialDropdown) { GUILayout.Label("Search", (Il2CppReferenceArray)null); _materialSearch = GUILayout.TextField(_materialSearch ?? string.Empty, Array.Empty()); _materialScroll = GUILayout.BeginScrollView(_materialScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(140f) }); int materialIndex = PropMetadataEditor.GetMaterialIndex(PropMetadataEditor.SelectedMaterialName); string value = ((_materialSearch != null) ? _materialSearch.Trim() : string.Empty); bool flag7 = !string.IsNullOrEmpty(value); for (int l = 0; l < MaterialCatalog.MaterialLabels.Count; l++) { string text9 = MaterialCatalog.MaterialLabels[l]; if (!flag7 || text9.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { if (l == materialIndex) { text9 = "> " + text9; } EnsureMaterialButtonStyle(); if (GUILayout.Button(text9, _materialButtonStyle, Array.Empty())) { PropMetadataEditor.SelectMaterialByIndex(l); _showMaterialDropdown = false; PropMetadataEditor.MaterialExplicitlyChosen = true; PropMetadataEditor.ApplyPreviewMaterial(PropMetadataEditor.SelectedMaterialName); PropMetadataEditor.MarkDirty(); } } } GUILayout.EndScrollView(); } } else { GUILayout.Label("Override materials", (Il2CppReferenceArray)null); for (int m = 0; m < num3; m++) { string text10 = ((m < PropMetadataEditor.PerSlotDefault.Count) ? PropMetadataEditor.PerSlotDefault[m] : string.Empty); string text11 = ((m < PropMetadataEditor.PerSlotSelected.Count) ? PropMetadataEditor.PerSlotSelected[m] : text10); bool flag8 = !string.IsNullOrEmpty(text11) && !string.Equals(text11, text10, StringComparison.OrdinalIgnoreCase); string text12 = (flag8 ? text11 : (string.IsNullOrEmpty(text10) ? "(unknown)" : (text10 + " (default)"))); GUILayout.Label("Slot " + m + ": " + (string.IsNullOrEmpty(text10) ? "(unknown)" : text10), (Il2CppReferenceArray)null); if (GUILayout.Button(text12, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) })) { if (_openSlotDropdown == m) { _openSlotDropdown = -1; } else { _openSlotDropdown = m; _slotDropdownScroll = Vector2.zero; } } if (_openSlotDropdown != m) { continue; } GUILayout.Label("Search", (Il2CppReferenceArray)null); _slotDropdownSearch = GUILayout.TextField(_slotDropdownSearch ?? string.Empty, Array.Empty()); _slotDropdownScroll = GUILayout.BeginScrollView(_slotDropdownScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(140f) }); string value2 = ((_slotDropdownSearch != null) ? _slotDropdownSearch.Trim() : string.Empty); bool flag9 = !string.IsNullOrEmpty(value2); for (int n = 0; n < MaterialCatalog.MaterialLabels.Count; n++) { string text13 = MaterialCatalog.MaterialLabels[n]; if (flag9 && text13.IndexOf(value2, StringComparison.OrdinalIgnoreCase) < 0) { continue; } if (string.Equals(text11, MaterialCatalog.MaterialNames[n], StringComparison.OrdinalIgnoreCase) || (n == 0 && !flag8)) { text13 = "> " + text13; } EnsureMaterialButtonStyle(); if (GUILayout.Button(text13, _materialButtonStyle, Array.Empty())) { string text14 = ((n == 0) ? string.Empty : MaterialCatalog.MaterialNames[n]); while (PropMetadataEditor.PerSlotSelected.Count <= m) { PropMetadataEditor.PerSlotSelected.Add(string.Empty); } PropMetadataEditor.PerSlotSelected[m] = (string.IsNullOrEmpty(text14) ? text10 : text14); if (string.IsNullOrEmpty(text14)) { PropMetadataEditor.SlotHasExplicitOverride.Remove(m); } else { PropMetadataEditor.SlotHasExplicitOverride.Add(m); } _openSlotDropdown = -1; PropMetadataEditor.ApplySlotMaterial(m, text14); PropMetadataEditor.MarkDirty(); } } GUILayout.EndScrollView(); } if (GUILayout.Button("Reset all to default materials", (Il2CppReferenceArray)null)) { for (int num7 = 0; num7 < PropMetadataEditor.PerSlotSelected.Count; num7++) { PropMetadataEditor.PerSlotSelected[num7] = ((num7 < PropMetadataEditor.PerSlotDefault.Count) ? PropMetadataEditor.PerSlotDefault[num7] : string.Empty); } PropMetadataEditor.SlotHasExplicitOverride.Clear(); _openSlotDropdown = -1; PropMetadataEditor.RestoreDefaultMaterials(); PropMetadataEditor.MarkDirty(); } } GUILayout.Space(8f); bool flag10 = GUILayout.Toggle(PropMetadataEditor.KeepOriginalHierarchy, "Keep original hierarchy", (Il2CppReferenceArray)null); if (flag10 != PropMetadataEditor.KeepOriginalHierarchy) { PropMetadataEditor.KeepOriginalHierarchy = flag10; PropMetadataEditor.MarkDirty(); } bool flag11 = GUILayout.Toggle(PropMetadataEditor.IsBush, "Is Bush", (Il2CppReferenceArray)null); if (flag11 != PropMetadataEditor.IsBush) { PropMetadataEditor.IsBush = flag11; PropMetadataEditor.ApplyBushCollider(PropMetadataEditor.SelectedLEO, flag11); PropMetadataEditor.ApplyCurrent(); PropMetadataEditor.Dirty = false; } if (PropMetadataEditor.IsBush) { GUILayout.Label($" Bush sphere radius: {PropMetadataEditor.BushRadius:F3} (local)", (Il2CppReferenceArray)null); GUILayout.Label(" Grass type (sound)", (Il2CppReferenceArray)null); if (GUILayout.Button(PropMetadataEditor.GrassTypeName(PropMetadataEditor.SoundGrassType), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) })) { _showGrassTypeDropdown = !_showGrassTypeDropdown; } if (_showGrassTypeDropdown) { _grassTypeScroll = GUILayout.BeginScrollView(_grassTypeScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(120f) }); (string, int)[] knownGrassTypes = PropMetadataEditor.KnownGrassTypes; for (int num8 = 0; num8 < knownGrassTypes.Length; num8++) { (string, int) tuple = knownGrassTypes[num8]; string item = tuple.Item1; int item2 = tuple.Item2; string text15 = ((item2 == PropMetadataEditor.SoundGrassType) ? ("> " + item) : item); EnsureMaterialButtonStyle(); if (GUILayout.Button(text15, _materialButtonStyle, Array.Empty())) { PropMetadataEditor.SoundGrassType = item2; _showGrassTypeDropdown = false; if ((Object)(object)PropMetadataEditor.SelectedLEO != (Object)null) { PropInstanceServices.BushAudioTracker.Unregister(((Component)PropMetadataEditor.SelectedLEO).transform); PropInstanceServices.BushAudioTracker.Register(((Component)PropMetadataEditor.SelectedLEO).transform, PropMetadataEditor.BushRadius, PropMetadataEditor.SoundGrassType); } PropMetadataEditor.ApplyCurrent(); PropMetadataEditor.Dirty = false; } } GUILayout.EndScrollView(); } } GUILayout.Space(4f); GUILayout.Label((PropMetadataEditor.Index > 0) ? $"Index: {PropMetadataEditor.Index}" : "Index: (not set)", (Il2CppReferenceArray)null); GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } private static void EnsureMaterialButtonStyle() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown if (_materialButtonStyle == null) { RectOffset val = new RectOffset(); val.left = 6; val.right = 6; val.top = 2; val.bottom = 2; _materialButtonStyle = new GUIStyle(GUI.skin.button) { alignment = (TextAnchor)3, padding = val }; } } private static void EnsureWindowRect() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!_windowInitialized) { float num = 410f; float num2 = 700f; float num3 = (float)Screen.width - num - 10f; if (num3 < 10f) { num3 = 10f; } _windowRect = new Rect(num3, 10f, num, num2); _windowInitialized = true; } } private static void HandleDrag(Rect headerRect) { //IL_0015: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Invalid comparison between Unknown and I4 //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if (current != null) { if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref headerRect)).Contains(current.mousePosition)) { _windowDragging = true; _windowDragOffset = current.mousePosition - new Vector2(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y); current.Use(); } else if ((int)current.type == 3 && _windowDragging) { ((Rect)(ref _windowRect)).x = current.mousePosition.x - _windowDragOffset.x; ((Rect)(ref _windowRect)).y = current.mousePosition.y - _windowDragOffset.y; float num = Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _windowRect)).width); float num2 = Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _windowRect)).height); ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, num); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, num2); current.Use(); } else if ((int)current.type == 1 && current.button == 0) { _windowDragging = false; } } } private static void DrawExportWindow() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Invalid comparison between Unknown and I4 //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Invalid comparison between Unknown and I4 //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) if (!_exportWindowInitialized) { _exportWindowRect = new Rect(10f, (float)Screen.height - 120f, 300f, 110f); _exportWindowInitialized = true; } Rect exportWindowRect = _exportWindowRect; GUI.Box(exportWindowRect, "Metadata Export", GUI.skin.window); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref exportWindowRect)).x, ((Rect)(ref exportWindowRect)).y, ((Rect)(ref exportWindowRect)).width, 22f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref exportWindowRect)).x + 8f, ((Rect)(ref exportWindowRect)).y + 22f + 8f, ((Rect)(ref exportWindowRect)).width - 16f, ((Rect)(ref exportWindowRect)).height - 22f - 16f); GUILayout.BeginArea(val2); GUILayout.BeginVertical((Il2CppReferenceArray)null); if (GUILayout.Button("Export prop_metadata.bin", (Il2CppReferenceArray)null)) { try { PropMetadataStore.SaveBinary(PropMetadataStore.BinaryExportPath); _exportStatusMsg = PropMetadataStore.BinaryExportPath; } catch (Exception ex) { _exportStatusMsg = "Error: " + ex.Message; } } if (!string.IsNullOrEmpty(_exportStatusMsg)) { GUILayout.Label(_exportStatusMsg, (Il2CppReferenceArray)null); } GUILayout.EndVertical(); GUILayout.EndArea(); Event current = Event.current; if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref val)).Contains(current.mousePosition)) { _exportWindowDragging = true; _exportWindowDragOffset = current.mousePosition - new Vector2(((Rect)(ref exportWindowRect)).x, ((Rect)(ref exportWindowRect)).y); current.Use(); } else if ((int)current.type == 3 && _exportWindowDragging) { ((Rect)(ref _exportWindowRect)).x = current.mousePosition.x - _exportWindowDragOffset.x; ((Rect)(ref _exportWindowRect)).y = current.mousePosition.y - _exportWindowDragOffset.y; current.Use(); } else if ((int)current.type == 1 && current.button == 0) { _exportWindowDragging = false; } } } internal static class PropHistory { public struct ResolvedHistoryEntry { public PropInfo Prop; public MaterialConstructionEntry Mat; public bool IsMat => Prop == null; } private const int MaxEntries = 32; private static readonly List _history = new List(); private static readonly List _resolvedCache = new List(); private static bool _resolvedDirty = true; private static bool _loaded; private static string SavePath => Path.Combine(MelonEnvironment.UserDataDirectory, "BabyBlocks", "history.txt"); public static void RecordUse(string propId) { if (!string.IsNullOrEmpty(propId)) { EnsureLoaded(); string item = "prop:" + propId; _history.Remove(item); _history.Insert(0, item); Trim(); _resolvedDirty = true; Save(); } } public static void RecordMaterialUse(int matId) { EnsureLoaded(); string item = "mat:" + matId; _history.Remove(item); _history.Insert(0, item); Trim(); _resolvedDirty = true; Save(); } private static void Trim() { while (_history.Count > 32) { _history.RemoveAt(_history.Count - 1); } } public static IReadOnlyList GetAllResolved() { EnsureLoaded(); if (_resolvedDirty) { _resolvedCache.Clear(); bool flag = false; foreach (string item in _history) { int result; if (item.StartsWith("prop:")) { PropInfo propInfo = PropLibrary.FindById(item.Substring(5)); if (propInfo != null) { _resolvedCache.Add(new ResolvedHistoryEntry { Prop = propInfo }); } else { flag = true; } } else if (item.StartsWith("mat:") && int.TryParse(item.Substring(4), out result)) { MaterialConstructionEntry materialConstructionEntry = MaterialConstructionLibrary.FindById(result); if (materialConstructionEntry != null) { _resolvedCache.Add(new ResolvedHistoryEntry { Mat = materialConstructionEntry }); } else { flag = true; } } } if (!flag) { _resolvedDirty = false; } } return _resolvedCache; } private static void EnsureLoaded() { if (!_loaded) { _loaded = true; Load(); } } private static void Load() { try { if (!File.Exists(SavePath)) { return; } _history.Clear(); string[] array = File.ReadAllLines(SavePath); foreach (string text in array) { string text2 = text.Trim(); if ((text2.StartsWith("prop:") || text2.StartsWith("mat:")) && _history.Count < 32) { _history.Add(text2); } } _resolvedDirty = true; } catch (Exception ex) { MelonLogger.Warning("[PropHistory] Load failed: " + ex.Message); } } private static void Save() { try { string directoryName = Path.GetDirectoryName(SavePath); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } File.WriteAllLines(SavePath, _history); } catch (Exception ex) { MelonLogger.Warning("[PropHistory] Save failed: " + ex.Message); } } } internal static class PropMetadataStore { public const string NoOverrideLabel = "(no override)"; private const byte PmdVersion = 3; internal static readonly Dictionary _byId = new Dictionary(StringComparer.Ordinal); internal static bool _loaded; internal static int _nextIndex = 1; private static bool _savePathLogged; internal static bool _loadedFromJson; private static List _materialConstructions = new List(); private static int _nextMaterialConstructionId; private static string SavePath => Path.Combine(MelonEnvironment.UserDataDirectory, "BabyBlocks", "prop_metadata.json"); public static string BinaryExportPath => Path.Combine(MelonEnvironment.UserDataDirectory, "BabyBlocks", "prop_metadata.bin"); public static List MaterialConstructions { get { EnsureLoaded(); return _materialConstructions; } } internal static void EnsureLoaded() { if (!_loaded) { Load(); } } public static MaterialConstructionEntry CreateMaterialConstruction() { EnsureLoaded(); MaterialConstructionEntry materialConstructionEntry = new MaterialConstructionEntry { id = _nextMaterialConstructionId++, name = "New Material " + (_materialConstructions.Count + 1) }; _materialConstructions.Add(materialConstructionEntry); _loadedFromJson = true; Save(); return materialConstructionEntry; } public static void DeleteMaterialConstruction(MaterialConstructionEntry entry) { EnsureLoaded(); if (entry != null) { _materialConstructions.Remove(entry); _loadedFromJson = true; Save(); } } public static MaterialConstructionEntry FindMaterialConstructionById(int id) { EnsureLoaded(); if (id < 0) { return null; } foreach (MaterialConstructionEntry materialConstruction in _materialConstructions) { if (materialConstruction.id == id) { return materialConstruction; } } return null; } public static void MarkMaterialConstructionsDirty() { _loadedFromJson = true; } public static void SaveMaterialConstructions() { EnsureLoaded(); _loadedFromJson = true; Save(); } internal static bool TryGetInfoById(string id, out PropExtraInfo info) { info = null; if (string.IsNullOrEmpty(id)) { return false; } if (_byId.TryGetValue(id, out info)) { return true; } string text = PropLibrary.ResolveCanonicalId(id); return !string.IsNullOrEmpty(text) && _byId.TryGetValue(text, out info); } private static bool MergeItem(PropExtraInfo target, PropExtraInfo source) { if (target == null || source == null || target == source) { return false; } bool result = false; if (target.index <= 0 && source.index > 0) { target.index = source.index; result = true; } if (string.IsNullOrEmpty(target.displayName) && !string.IsNullOrEmpty(source.displayName)) { target.displayName = source.displayName; result = true; } if (string.IsNullOrEmpty(target.category) && !string.IsNullOrEmpty(source.category)) { target.category = source.category; result = true; } if (string.IsNullOrEmpty(target.colliderIgnoredSubmeshes) && !string.IsNullOrEmpty(source.colliderIgnoredSubmeshes)) { target.colliderIgnoredSubmeshes = source.colliderIgnoredSubmeshes; result = true; } if (string.IsNullOrEmpty(target.overrideMaterialId) && !string.IsNullOrEmpty(source.overrideMaterialId)) { target.overrideMaterialId = source.overrideMaterialId; result = true; } if (string.IsNullOrEmpty(target.nativeMaterialName) && !string.IsNullOrEmpty(source.nativeMaterialName)) { target.nativeMaterialName = source.nativeMaterialName; result = true; } if (string.IsNullOrEmpty(target.materialSourcePropId) && !string.IsNullOrEmpty(source.materialSourcePropId)) { target.materialSourcePropId = source.materialSourcePropId; result = true; } if (string.IsNullOrEmpty(target.surfaceType) && !string.IsNullOrEmpty(source.surfaceType)) { target.surfaceType = source.surfaceType; result = true; } if (!target.useRenderMeshCollider && source.useRenderMeshCollider) { target.useRenderMeshCollider = true; result = true; } if (!target.disableBaking && source.disableBaking) { target.disableBaking = true; result = true; } if (target.forcedMaterialSlots <= 1 && source.forcedMaterialSlots > 1) { target.forcedMaterialSlots = source.forcedMaterialSlots; result = true; } if ((target.disabledRenderers == null || target.disabledRenderers.Count == 0) && source.disabledRenderers != null && source.disabledRenderers.Count > 0) { target.disabledRenderers = new List(source.disabledRenderers); result = true; } if (!HasNonEmptySlot(target.perSlotMaterialOverrides) && HasNonEmptySlot(source.perSlotMaterialOverrides)) { target.perSlotMaterialOverrides = new List(source.perSlotMaterialOverrides); result = true; } if (!target.excluded && source.excluded) { target.excluded = true; result = true; } if (!target.isBush && source.isBush) { target.isBush = true; result = true; } if (target.bushRadius <= 0f && source.bushRadius > 0f) { target.bushRadius = source.bushRadius; result = true; } return result; } public static void MigratePropIdsToCanonical() { EnsureLoaded(); if (_byId.Count == 0) { return; } bool flag = false; List<(string, string, PropExtraInfo)> list = new List<(string, string, PropExtraInfo)>(); foreach (KeyValuePair item in _byId) { string text = PropLibrary.ResolveCanonicalId(item.Key); if (!string.IsNullOrEmpty(text) && !string.Equals(text, item.Key, StringComparison.Ordinal)) { list.Add((item.Key, text, item.Value)); } } for (int i = 0; i < list.Count; i++) { (string, string, PropExtraInfo) tuple = list[i]; if (!_byId.TryGetValue(tuple.Item1, out var value)) { continue; } _byId.Remove(tuple.Item1); flag = true; value.id = tuple.Item2; if (_byId.TryGetValue(tuple.Item2, out var value2)) { if (MergeItem(value2, value)) { flag = true; } } else { _byId[tuple.Item2] = value; } } foreach (PropExtraInfo value3 in _byId.Values) { if (value3 != null && !string.IsNullOrEmpty(value3.materialSourcePropId)) { string text2 = PropLibrary.ResolveCanonicalId(value3.materialSourcePropId); if (!string.IsNullOrEmpty(text2) && !string.Equals(text2, value3.materialSourcePropId, StringComparison.Ordinal)) { value3.materialSourcePropId = text2; flag = true; } } } if (flag) { Save(); } } public static bool GetUseRenderMeshCollider(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return false; } if (!TryGetInfoById(id, out var info)) { PropInfo propInfo = PropLibrary.FindById(id); return propInfo == null || !propInfo.HasColliderParts; } return info.useRenderMeshCollider; } public static HashSet GetColliderIgnoredSubmeshes(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return null; } if (!TryGetInfoById(id, out var info)) { return null; } return ParseIntSet(info.colliderIgnoredSubmeshes); } public static string GetSurfaceType(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return string.Empty; } if (!TryGetInfoById(id, out var info)) { return string.Empty; } return info.surfaceType ?? string.Empty; } public static string GetOverrideMaterialId(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return string.Empty; } if (!TryGetInfoById(id, out var info)) { return string.Empty; } return info.overrideMaterialId ?? string.Empty; } public static bool GetDisableBaking(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return false; } if (!TryGetInfoById(id, out var info)) { return false; } return info.disableBaking; } public static void SetDisableBaking(string id, bool value) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return; } string text = PropLibrary.ResolveCanonicalId(id) ?? id; if (!_byId.TryGetValue(text, out var value2)) { if (!value) { return; } value2 = new PropExtraInfo { id = text, index = _nextIndex++ }; _byId[text] = value2; } if (value2.disableBaking != value) { value2.disableBaking = value; Save(); } } public static string GetMaterialCacheKey(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id) || !TryGetInfoById(id, out var info)) { return "default"; } if (HasNonEmptySlot(info.perSlotMaterialOverrides)) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < info.perSlotMaterialOverrides.Count; i++) { if (i > 0) { stringBuilder.Append('+'); } string text = info.perSlotMaterialOverrides[i]; stringBuilder.Append(string.IsNullOrEmpty(text) ? "_" : text); } return stringBuilder.ToString(); } if (!string.IsNullOrEmpty(info.overrideMaterialId) && !string.Equals(info.overrideMaterialId, "(no override)", StringComparison.OrdinalIgnoreCase)) { return info.overrideMaterialId; } return "default"; } public static bool GetIsBush(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return false; } PropExtraInfo info; return TryGetInfoById(id, out info) && info.isBush; } public static bool GetKeepOriginalHierarchy(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return false; } PropExtraInfo info; return TryGetInfoById(id, out info) && info.keepOriginalHierarchy; } public static bool HasMetadata(string id) { EnsureLoaded(); PropExtraInfo info; return !string.IsNullOrEmpty(id) && TryGetInfoById(id, out info); } public static bool IsExcluded(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return false; } PropExtraInfo info; return TryGetInfoById(id, out info) && info.excluded; } public static bool IsPartiallyFilled(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return false; } if (!TryGetInfoById(id, out var info)) { return false; } if (info.excluded || info.index <= 0) { return false; } int num = 0; if (!string.IsNullOrEmpty(info.displayName)) { num++; } if (!string.IsNullOrEmpty(info.category)) { num++; } if (!string.IsNullOrEmpty(info.surfaceType)) { num++; } return num > 0 && num < 3; } internal static bool HasDuplicateDisplayName(string name, string excludeId) { foreach (KeyValuePair item in _byId) { if (string.Equals(item.Key, excludeId, StringComparison.Ordinal) || !string.Equals(item.Value.displayName, name, StringComparison.OrdinalIgnoreCase)) { continue; } return true; } return false; } internal static bool TryGet(string id, out PropExtraInfo info) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { info = null; return false; } return _byId.TryGetValue(id, out info); } internal static bool HasNonEmptySlot(List list) { if (list == null) { return false; } for (int i = 0; i < list.Count; i++) { if (!string.IsNullOrEmpty(list[i])) { return true; } } return false; } internal static PropExtraInfo Apply(string id, string displayName, string category, bool excluded, bool useRenderMeshCollider, string overrideMaterialName, string nativeMaterialName, string materialSourcePropId, string surfaceType, HashSet disabledRenderers, string colliderIgnoredSubmeshes, List perSlotOverrides = null, int forcedMaterialSlots = 0, bool isBush = false, float bushRadius = 0f, int soundGrassType = 1, bool keepOriginalHierarchy = false) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return null; } bool flag = !string.IsNullOrEmpty(displayName) || !string.IsNullOrEmpty(category) || excluded || useRenderMeshCollider || !string.IsNullOrEmpty(overrideMaterialName) || !string.IsNullOrEmpty(surfaceType) || (disabledRenderers != null && disabledRenderers.Count > 0) || !string.IsNullOrEmpty(colliderIgnoredSubmeshes) || HasNonEmptySlot(perSlotOverrides) || forcedMaterialSlots > 1 || isBush || keepOriginalHierarchy; if (!_byId.TryGetValue(id, out var value)) { if (!flag) { return null; } value = new PropExtraInfo { id = id }; _byId[id] = value; } if (excluded) { value.displayName = string.Empty; value.category = string.Empty; value.excluded = true; value.useRenderMeshCollider = false; value.colliderIgnoredSubmeshes = string.Empty; value.overrideMaterialId = string.Empty; value.surfaceType = string.Empty; value.disabledRenderers = new List(); value.perSlotMaterialOverrides = null; value.forcedMaterialSlots = 0; value.isBush = false; value.bushRadius = 0f; value.soundGrassType = 1; value.keepOriginalHierarchy = false; value.disableBaking = false; value.index = 0; } else { if (value.index <= 0) { value.index = _nextIndex++; } value.displayName = displayName ?? string.Empty; value.category = category ?? string.Empty; value.excluded = false; value.useRenderMeshCollider = useRenderMeshCollider; value.colliderIgnoredSubmeshes = colliderIgnoredSubmeshes ?? string.Empty; value.overrideMaterialId = overrideMaterialName ?? string.Empty; if (!string.IsNullOrEmpty(overrideMaterialName)) { if (string.IsNullOrEmpty(value.nativeMaterialName) && !string.IsNullOrEmpty(nativeMaterialName) && !string.Equals(nativeMaterialName, overrideMaterialName, StringComparison.OrdinalIgnoreCase)) { value.nativeMaterialName = nativeMaterialName; } if (string.IsNullOrEmpty(value.materialSourcePropId) && !string.IsNullOrEmpty(materialSourcePropId)) { value.materialSourcePropId = materialSourcePropId; } } else { value.nativeMaterialName = string.Empty; value.materialSourcePropId = string.Empty; } value.surfaceType = surfaceType ?? string.Empty; value.disabledRenderers = new List(); if (disabledRenderers != null) { foreach (string disabledRenderer in disabledRenderers) { value.disabledRenderers.Add(disabledRenderer); } } value.perSlotMaterialOverrides = (HasNonEmptySlot(perSlotOverrides) ? perSlotOverrides : null); value.forcedMaterialSlots = forcedMaterialSlots; value.isBush = isBush; value.bushRadius = bushRadius; value.soundGrassType = soundGrassType; value.keepOriginalHierarchy = keepOriginalHierarchy; } _loadedFromJson = true; Save(); return value; } private static void Load() { _loaded = true; _byId.Clear(); _nextIndex = 1; _materialConstructions = new List(); _nextMaterialConstructionId = 0; try { if (Core.DebugMode) { if (File.Exists(SavePath)) { string text = File.ReadAllText(SavePath); if (!string.IsNullOrEmpty(text)) { LoadFromJson(text); return; } } if (File.Exists(BinaryExportPath)) { using (FileStream stream = File.OpenRead(BinaryExportPath)) { LoadFromBinaryStream(stream); return; } } } LoadFromEmbedded(); } catch (Exception ex) { MelonLogger.Warning("[PropMetadata] Load failed: " + ex.Message); } } private static void LoadFromJson(string json) { _loadedFromJson = true; PropExtraInfoSave propExtraInfoSave = Deserialize(json); if (propExtraInfoSave == null || propExtraInfoSave.items == null) { return; } _nextIndex = Math.Max(1, propExtraInfoSave.nextIndex); int num = _nextIndex - 1; foreach (PropExtraInfo item in propExtraInfoSave.items) { if (item != null && !string.IsNullOrEmpty(item.id)) { if (!item.excluded && item.index <= 0) { item.index = _nextIndex++; } if (item.index > num) { num = item.index; } _byId[item.id] = item; } } _nextIndex = Math.Max(_nextIndex, num + 1); _materialConstructions = propExtraInfoSave.materialConstructions ?? new List(); _nextMaterialConstructionId = Math.Max(0, propExtraInfoSave.nextMaterialConstructionId); ReconcileMaterialConstructionIds(); bool flag = false; foreach (PropExtraInfo value in _byId.Values) { if (!string.IsNullOrEmpty(value.materialSourcePropId) && !string.IsNullOrEmpty(value.overrideMaterialId) && value.overrideMaterialId.StartsWith("[MicroSplat]", StringComparison.Ordinal)) { value.materialSourcePropId = string.Empty; flag = true; } } if (flag) { Save(); } } internal static void Save() { if (!_loadedFromJson) { return; } try { string directoryName = Path.GetDirectoryName(SavePath); if (!string.IsNullOrEmpty(directoryName)) { Directory.CreateDirectory(directoryName); } PropExtraInfoSave data = new PropExtraInfoSave { nextIndex = _nextIndex, items = new List(_byId.Values), nextMaterialConstructionId = _nextMaterialConstructionId, materialConstructions = _materialConstructions }; string contents = Serialize(data); File.WriteAllText(SavePath, contents); if (!_savePathLogged) { _savePathLogged = true; BBLog.Msg("[PropMetadata] Saved to " + SavePath); } } catch (Exception ex) { MelonLogger.Warning("[PropMetadata] Save failed: " + ex.Message); } } internal static void SaveBinary(string path) { EnsureLoaded(); string directoryName = Path.GetDirectoryName(path); if (!string.IsNullOrEmpty(directoryName)) { Directory.CreateDirectory(directoryName); } using FileStream output = File.Open(path, FileMode.Create, FileAccess.Write); using BinaryWriter w = new BinaryWriter(output, Encoding.UTF8, leaveOpen: false); WriteBinary(w); } private static void WriteBinary(BinaryWriter w) { w.Write((byte)80); w.Write((byte)77); w.Write((byte)68); w.Write((byte)3); List list = new List(); foreach (PropExtraInfo value in _byId.Values) { if (value != null && !string.IsNullOrEmpty(value.id)) { list.Add(value); } } w.Write(_nextIndex); w.Write(list.Count); foreach (PropExtraInfo item in list) { w.Write(item.id); w.Write(item.index); bool flag = !item.excluded && !string.IsNullOrEmpty(item.displayName); bool flag2 = !item.excluded && !string.IsNullOrEmpty(item.category); bool flag3 = !item.excluded && !string.IsNullOrEmpty(item.colliderIgnoredSubmeshes); bool flag4 = !item.excluded && !string.IsNullOrEmpty(item.overrideMaterialId); byte b = 0; if (item.excluded) { b |= 1; } if (!item.excluded && item.useRenderMeshCollider) { b |= 2; } if (!item.excluded && item.isBush) { b |= 4; } if (!item.excluded && item.keepOriginalHierarchy) { b |= 8; } if (flag) { b |= 0x10; } if (flag2) { b |= 0x20; } if (flag3) { b |= 0x40; } if (flag4) { b |= 0x80; } w.Write(b); if (item.excluded) { continue; } bool flag5 = !string.IsNullOrEmpty(item.nativeMaterialName); bool flag6 = !string.IsNullOrEmpty(item.materialSourcePropId); bool flag7 = !string.IsNullOrEmpty(item.surfaceType); bool flag8 = item.disabledRenderers != null && item.disabledRenderers.Count > 0; bool flag9 = HasNonEmptySlot(item.perSlotMaterialOverrides); bool flag10 = item.forcedMaterialSlots > 1; byte b2 = 0; if (flag5) { b2 |= 1; } if (flag6) { b2 |= 2; } if (flag7) { b2 |= 4; } if (flag8) { b2 |= 8; } if (flag9) { b2 |= 0x10; } if (flag10) { b2 |= 0x20; } if (item.disableBaking) { b2 |= 0x40; } w.Write(b2); if (flag) { w.Write(item.displayName); } if (flag2) { w.Write(item.category); } if (flag3) { w.Write(item.colliderIgnoredSubmeshes); } if (flag4) { w.Write(item.overrideMaterialId); } if (flag5) { w.Write(item.nativeMaterialName); } if (flag6) { w.Write(item.materialSourcePropId); } if (flag7) { w.Write(item.surfaceType); } if (flag8) { List disabledRenderers = item.disabledRenderers; int num = Math.Min(disabledRenderers.Count, 255); w.Write((byte)num); for (int i = 0; i < num; i++) { w.Write(disabledRenderers[i] ?? ""); } } if (flag9) { List perSlotMaterialOverrides = item.perSlotMaterialOverrides; int num2 = Math.Min(perSlotMaterialOverrides.Count, 255); w.Write((byte)num2); for (int j = 0; j < num2; j++) { w.Write(perSlotMaterialOverrides[j] ?? ""); } } if (flag10) { w.Write(item.forcedMaterialSlots); } if (item.isBush) { w.Write(item.bushRadius); w.Write(item.soundGrassType); } } w.Write(_nextMaterialConstructionId); w.Write(_materialConstructions.Count); foreach (MaterialConstructionEntry materialConstruction in _materialConstructions) { w.Write(materialConstruction.id); w.Write(materialConstruction.name ?? ""); w.Write(materialConstruction.materialName ?? ""); w.Write(materialConstruction.surfaceType ?? ""); byte b3 = 0; if (materialConstruction.sunglassesNeeded) { b3 |= 1; } w.Write(b3); } } private static void LoadFromBinaryStream(Stream stream) { using BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8, leaveOpen: true); byte b = binaryReader.ReadByte(); byte b2 = binaryReader.ReadByte(); byte b3 = binaryReader.ReadByte(); if (b != 80 || b2 != 77 || b3 != 68) { throw new InvalidDataException("Not a PMD file"); } byte b4 = binaryReader.ReadByte(); if (b4 < 1 || b4 > 3) { throw new InvalidDataException($"Unsupported PMD version {b4}"); } _nextIndex = binaryReader.ReadInt32(); int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { string text = binaryReader.ReadString(); int index = binaryReader.ReadInt32(); byte b5 = binaryReader.ReadByte(); bool flag = (b5 & 1) != 0; if (string.IsNullOrEmpty(text)) { if (!flag) { binaryReader.ReadByte(); } continue; } PropExtraInfo propExtraInfo = new PropExtraInfo { id = text, index = index, excluded = flag }; if (!flag) { propExtraInfo.useRenderMeshCollider = (b5 & 2) != 0; propExtraInfo.isBush = (b5 & 4) != 0; propExtraInfo.keepOriginalHierarchy = (b5 & 8) != 0; bool flag2 = (b5 & 0x10) != 0; bool flag3 = (b5 & 0x20) != 0; bool flag4 = (b5 & 0x40) != 0; bool flag5 = (b5 & 0x80) != 0; byte b6 = binaryReader.ReadByte(); bool flag6 = (b6 & 1) != 0; bool flag7 = (b6 & 2) != 0; bool flag8 = (b6 & 4) != 0; bool flag9 = (b6 & 8) != 0; bool flag10 = (b6 & 0x10) != 0; bool flag11 = (b6 & 0x20) != 0; propExtraInfo.disableBaking = (b6 & 0x40) != 0; if (flag2) { propExtraInfo.displayName = binaryReader.ReadString(); } if (flag3) { propExtraInfo.category = binaryReader.ReadString(); } if (flag4) { propExtraInfo.colliderIgnoredSubmeshes = binaryReader.ReadString(); } if (flag5) { propExtraInfo.overrideMaterialId = binaryReader.ReadString(); } if (flag6) { propExtraInfo.nativeMaterialName = binaryReader.ReadString(); } if (flag7) { propExtraInfo.materialSourcePropId = binaryReader.ReadString(); } if (flag8) { propExtraInfo.surfaceType = binaryReader.ReadString(); } if (flag9) { int num2 = binaryReader.ReadByte(); propExtraInfo.disabledRenderers = new List(num2); for (int j = 0; j < num2; j++) { propExtraInfo.disabledRenderers.Add(binaryReader.ReadString()); } } if (flag10) { int num3 = binaryReader.ReadByte(); propExtraInfo.perSlotMaterialOverrides = new List(num3); for (int k = 0; k < num3; k++) { propExtraInfo.perSlotMaterialOverrides.Add(binaryReader.ReadString()); } } if (flag11) { propExtraInfo.forcedMaterialSlots = binaryReader.ReadInt32(); } if (propExtraInfo.isBush) { propExtraInfo.bushRadius = binaryReader.ReadSingle(); propExtraInfo.soundGrassType = binaryReader.ReadInt32(); } } _byId[text] = propExtraInfo; } _materialConstructions = new List(); _nextMaterialConstructionId = 0; if (b4 >= 2) { _nextMaterialConstructionId = binaryReader.ReadInt32(); int num4 = binaryReader.ReadInt32(); for (int l = 0; l < num4; l++) { MaterialConstructionEntry materialConstructionEntry = new MaterialConstructionEntry { id = binaryReader.ReadInt32(), name = binaryReader.ReadString(), materialName = binaryReader.ReadString(), surfaceType = binaryReader.ReadString() }; if (b4 >= 3) { byte b7 = binaryReader.ReadByte(); materialConstructionEntry.sunglassesNeeded = (b7 & 1) != 0; } _materialConstructions.Add(materialConstructionEntry); } } ReconcileMaterialConstructionIds(); } private static void ReconcileMaterialConstructionIds() { int num = -1; foreach (MaterialConstructionEntry materialConstruction in _materialConstructions) { if (materialConstruction != null && materialConstruction.id > num) { num = materialConstruction.id; } } _nextMaterialConstructionId = Math.Max(_nextMaterialConstructionId, num + 1); _materialConstructions.Sort((MaterialConstructionEntry a, MaterialConstructionEntry b) => string.Compare(a?.name, b?.name, StringComparison.OrdinalIgnoreCase)); } private static void LoadFromEmbedded() { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream("BabyBlocks.Props.prop_metadata.bin"); if (stream == null) { MelonLogger.Warning("[PropMetadata] Embedded prop_metadata.bin not found."); return; } LoadFromBinaryStream(stream); BBLog.Msg("[PropMetadata] Loaded from embedded binary."); } private static string Serialize(PropExtraInfoSave data) { return SerializeManual(data); } private static PropExtraInfoSave Deserialize(string json) { try { JsonSerializerOptions options = new JsonSerializerOptions { IncludeFields = true }; return JsonSerializer.Deserialize(json, options); } catch { return DeserializeManual(json); } } private static string SerializeManual(PropExtraInfoSave data) { StringBuilder stringBuilder = new StringBuilder(1024); stringBuilder.Append("{\n \"nextIndex\": ").Append(data.nextIndex).Append(",\n \"items\": [\n"); for (int i = 0; i < data.items.Count; i++) { PropExtraInfo propExtraInfo = data.items[i]; if (propExtraInfo == null) { continue; } stringBuilder.Append(" {\n"); if (propExtraInfo.excluded) { AppendJsonField(stringBuilder, "id", propExtraInfo.id, 6).Append(",\n"); stringBuilder.Append(" \"excluded\": true\n"); } else { AppendJsonField(stringBuilder, "id", propExtraInfo.id, 6).Append(",\n"); AppendJsonField(stringBuilder, "displayName", propExtraInfo.displayName, 6).Append(",\n"); AppendJsonField(stringBuilder, "category", propExtraInfo.category, 6).Append(",\n"); stringBuilder.Append(" \"excluded\": false,\n"); stringBuilder.Append(" \"useRenderMeshCollider\": ").Append(propExtraInfo.useRenderMeshCollider ? "true" : "false").Append(",\n"); AppendJsonField(stringBuilder, "colliderIgnoredSubmeshes", propExtraInfo.colliderIgnoredSubmeshes, 6).Append(",\n"); AppendJsonField(stringBuilder, "overrideMaterialId", propExtraInfo.overrideMaterialId, 6).Append(",\n"); AppendJsonField(stringBuilder, "nativeMaterialName", propExtraInfo.nativeMaterialName, 6).Append(",\n"); AppendJsonField(stringBuilder, "materialSourcePropId", propExtraInfo.materialSourcePropId, 6).Append(",\n"); AppendJsonField(stringBuilder, "surfaceType", propExtraInfo.surfaceType, 6).Append(",\n"); AppendJsonArray(stringBuilder, "disabledRenderers", propExtraInfo.disabledRenderers, 6).Append(",\n"); if (HasNonEmptySlot(propExtraInfo.perSlotMaterialOverrides)) { AppendJsonArray(stringBuilder, "perSlotMaterialOverrides", propExtraInfo.perSlotMaterialOverrides, 6).Append(",\n"); } if (propExtraInfo.forcedMaterialSlots > 1) { stringBuilder.Append(" \"forcedMaterialSlots\": ").Append(propExtraInfo.forcedMaterialSlots).Append(",\n"); } if (propExtraInfo.isBush) { stringBuilder.Append(" \"isBush\": true,\n"); stringBuilder.Append(" \"bushRadius\": ").Append(propExtraInfo.bushRadius.ToString("F4", CultureInfo.InvariantCulture)).Append(",\n"); stringBuilder.Append(" \"soundGrassType\": ").Append(propExtraInfo.soundGrassType).Append(",\n"); } if (propExtraInfo.keepOriginalHierarchy) { stringBuilder.Append(" \"keepOriginalHierarchy\": true,\n"); } if (propExtraInfo.disableBaking) { stringBuilder.Append(" \"disableBaking\": true,\n"); } stringBuilder.Append(" \"index\": ").Append(propExtraInfo.index).Append("\n"); } stringBuilder.Append(" }"); if (i < data.items.Count - 1) { stringBuilder.Append(","); } stringBuilder.Append("\n"); } stringBuilder.Append(" ],\n"); stringBuilder.Append(" \"nextMaterialConstructionId\": ").Append(data.nextMaterialConstructionId).Append(",\n"); stringBuilder.Append(" \"materialConstructions\": [\n"); for (int j = 0; j < data.materialConstructions.Count; j++) { MaterialConstructionEntry materialConstructionEntry = data.materialConstructions[j]; if (materialConstructionEntry != null) { stringBuilder.Append(" {\n"); stringBuilder.Append(" \"id\": ").Append(materialConstructionEntry.id).Append(",\n"); AppendJsonField(stringBuilder, "name", materialConstructionEntry.name, 6).Append(",\n"); AppendJsonField(stringBuilder, "materialName", materialConstructionEntry.materialName, 6).Append(",\n"); AppendJsonField(stringBuilder, "surfaceType", materialConstructionEntry.surfaceType, 6); if (materialConstructionEntry.sunglassesNeeded) { stringBuilder.Append(",\n \"sunglassesNeeded\": true"); } stringBuilder.Append("\n"); stringBuilder.Append(" }"); if (j < data.materialConstructions.Count - 1) { stringBuilder.Append(","); } stringBuilder.Append("\n"); } } stringBuilder.Append(" ]\n}"); return stringBuilder.ToString(); } private static StringBuilder AppendJsonField(StringBuilder sb, string key, string value, int indent) { sb.Append(' ', indent).Append('"').Append(key) .Append("\": "); AppendJsonString(sb, value ?? string.Empty); return sb; } private static StringBuilder AppendJsonArray(StringBuilder sb, string key, List values, int indent) { sb.Append(' ', indent).Append('"').Append(key) .Append("\": ["); if (values != null) { for (int i = 0; i < values.Count; i++) { if (i > 0) { sb.Append(", "); } AppendJsonString(sb, values[i] ?? string.Empty); } } sb.Append(']'); return sb; } private static void AppendJsonString(StringBuilder sb, string value) { sb.Append('"'); foreach (char c in value) { switch (c) { case '"': sb.Append("\\\""); continue; case '\\': sb.Append("\\\\"); continue; case '\n': sb.Append("\\n"); continue; case '\r': sb.Append("\\r"); continue; case '\t': sb.Append("\\t"); continue; } if (c < ' ') { StringBuilder stringBuilder = sb.Append("\\u"); int num = c; stringBuilder.Append(num.ToString("x4")); } else { sb.Append(c); } } sb.Append('"'); } private static PropExtraInfoSave DeserializeManual(string json) { PropExtraInfoSave propExtraInfoSave = new PropExtraInfoSave { items = new List() }; if (string.IsNullOrEmpty(json)) { return propExtraInfoSave; } propExtraInfoSave.nextIndex = ExtractInt(json, "nextIndex", 1); int num = json.IndexOf("\"items\"", StringComparison.OrdinalIgnoreCase); if (num < 0) { return propExtraInfoSave; } int num2 = json.IndexOf('[', num); if (num2 < 0) { return propExtraInfoSave; } int num3 = FindMatching(json, num2, '[', ']'); if (num3 < 0) { return propExtraInfoSave; } int index = num2 + 1; while (index < num3) { SkipWhitespace(json, ref index); if (index >= num3) { break; } if (json[index] == ',') { index++; continue; } if (json[index] != '{') { index++; continue; } int num4 = FindMatching(json, index, '{', '}'); if (num4 < 0) { break; } string json2 = json.Substring(index, num4 - index + 1); PropExtraInfo propExtraInfo = new PropExtraInfo { id = ExtractString(json2, "id"), displayName = ExtractString(json2, "displayName"), category = ExtractString(json2, "category"), excluded = ExtractBool(json2, "excluded"), useRenderMeshCollider = ExtractBool(json2, "useRenderMeshCollider"), colliderIgnoredSubmeshes = ExtractString(json2, "colliderIgnoredSubmeshes"), overrideMaterialId = ExtractString(json2, "overrideMaterialId"), nativeMaterialName = ExtractString(json2, "nativeMaterialName"), materialSourcePropId = ExtractString(json2, "materialSourcePropId"), surfaceType = ExtractString(json2, "surfaceType"), index = ExtractInt(json2, "index", 0), disabledRenderers = ExtractStringArray(json2, "disabledRenderers"), perSlotMaterialOverrides = ExtractStringArray(json2, "perSlotMaterialOverrides"), forcedMaterialSlots = ExtractInt(json2, "forcedMaterialSlots", 0), isBush = ExtractBool(json2, "isBush"), bushRadius = ExtractFloat(json2, "bushRadius", 0f), soundGrassType = ExtractInt(json2, "soundGrassType", 1), keepOriginalHierarchy = ExtractBool(json2, "keepOriginalHierarchy"), disableBaking = ExtractBool(json2, "disableBaking") }; if (!string.IsNullOrEmpty(propExtraInfo.id)) { propExtraInfoSave.items.Add(propExtraInfo); } index = num4 + 1; } propExtraInfoSave.nextMaterialConstructionId = ExtractInt(json, "nextMaterialConstructionId", 0); int num5 = json.IndexOf("\"materialConstructions\"", StringComparison.OrdinalIgnoreCase); if (num5 >= 0) { int num6 = json.IndexOf('[', num5); if (num6 >= 0) { int num7 = FindMatching(json, num6, '[', ']'); if (num7 >= 0) { int index2 = num6 + 1; while (index2 < num7) { SkipWhitespace(json, ref index2); if (index2 >= num7) { break; } if (json[index2] == ',') { index2++; continue; } if (json[index2] != '{') { index2++; continue; } int num8 = FindMatching(json, index2, '{', '}'); if (num8 < 0) { break; } string json3 = json.Substring(index2, num8 - index2 + 1); propExtraInfoSave.materialConstructions.Add(new MaterialConstructionEntry { id = ExtractInt(json3, "id", -1), name = ExtractString(json3, "name"), materialName = ExtractString(json3, "materialName"), surfaceType = ExtractString(json3, "surfaceType"), sunglassesNeeded = ExtractBool(json3, "sunglassesNeeded") }); index2 = num8 + 1; } } } } return propExtraInfoSave; } private static int FindMatching(string text, int start, char open, char close) { int num = 0; bool flag = false; for (int i = start; i < text.Length; i++) { char c = text[i]; if (c == '"' && (i == 0 || text[i - 1] != '\\')) { flag = !flag; } if (flag) { continue; } if (c == open) { num++; } else if (c == close) { num--; if (num == 0) { return i; } } } return -1; } private static HashSet ParseIntSet(string text) { if (string.IsNullOrWhiteSpace(text)) { return null; } HashSet hashSet = new HashSet(); string[] array = text.Split(new char[6] { ',', ';', ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { if (int.TryParse(array[i], out var result) && result >= 0) { hashSet.Add(result); } } return (hashSet.Count > 0) ? hashSet : null; } private static void SkipWhitespace(string text, ref int index) { while (index < text.Length && char.IsWhiteSpace(text[index])) { index++; } } private static int ExtractInt(string json, string key, int fallback) { if (!TryFindKey(json, key, out var valueStart)) { return fallback; } int index = valueStart; SkipWhitespace(json, ref index); int num = 1; if (index < json.Length && json[index] == '-') { num = -1; index++; } int num2 = 0; bool flag = false; while (index < json.Length && char.IsDigit(json[index])) { num2 = num2 * 10 + (json[index] - 48); index++; flag = true; } return flag ? (num2 * num) : fallback; } private static bool ExtractBool(string json, string key) { if (!TryFindKey(json, key, out var valueStart)) { return false; } int index = valueStart; SkipWhitespace(json, ref index); if (json.IndexOf("true", index, StringComparison.OrdinalIgnoreCase) == index) { return true; } return false; } private static float ExtractFloat(string json, string key, float fallback) { if (!TryFindKey(json, key, out var valueStart)) { return fallback; } int i = valueStart; SkipWhitespace(json, ref i); int num = i; if (i < json.Length && (json[i] == '-' || json[i] == '+')) { i++; } for (; i < json.Length && (char.IsDigit(json[i]) || json[i] == '.'); i++) { } if (i == num) { return fallback; } string s = json.Substring(num, i - num); float result; return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out result) ? result : fallback; } private static string ExtractString(string json, string key) { if (!TryFindKey(json, key, out var valueStart)) { return string.Empty; } int index = valueStart; SkipWhitespace(json, ref index); if (index >= json.Length || json[index] != '"') { return string.Empty; } index++; StringBuilder stringBuilder = new StringBuilder(); while (index < json.Length) { char c = json[index++]; if (c == '"') { break; } if (c == '\\' && index < json.Length) { char c2 = json[index++]; switch (c2) { case '"': stringBuilder.Append('"'); break; case '\\': stringBuilder.Append('\\'); break; case '/': stringBuilder.Append('/'); break; case 'b': stringBuilder.Append('\b'); break; case 'f': stringBuilder.Append('\f'); break; case 'n': stringBuilder.Append('\n'); break; case 'r': stringBuilder.Append('\r'); break; case 't': stringBuilder.Append('\t'); break; case 'u': if (index + 3 < json.Length) { string s = json.Substring(index, 4); if (int.TryParse(s, NumberStyles.HexNumber, null, out var result)) { stringBuilder.Append((char)result); } index += 4; } break; default: stringBuilder.Append(c2); break; } } else { stringBuilder.Append(c); } } return stringBuilder.ToString(); } private static bool TryFindKey(string json, string key, out int valueStart) { valueStart = -1; int num = json.IndexOf("\"" + key + "\"", StringComparison.OrdinalIgnoreCase); if (num < 0) { return false; } int num2 = json.IndexOf(':', num); if (num2 < 0) { return false; } valueStart = num2 + 1; return true; } private static List ExtractStringArray(string json, string key) { List list = new List(); if (!TryFindKey(json, key, out var valueStart)) { return list; } int index = valueStart; SkipWhitespace(json, ref index); if (index >= json.Length || json[index] != '[') { return list; } int num = FindMatching(json, index, '[', ']'); if (num < 0) { return list; } int index2 = index + 1; while (index2 < num) { SkipWhitespace(json, ref index2); if (index2 >= num) { break; } if (json[index2] == ',') { index2++; continue; } if (json[index2] != '"') { index2++; continue; } int num2 = index2; string text = ExtractString(json.Substring(num2, num - num2), string.Empty); if (!string.IsNullOrEmpty(text)) { list.Add(text); } int num3 = json.IndexOf('"', index2 + 1); if (num3 < 0 || num3 >= num) { break; } index2 = num3 + 1; } return list; } public static int GetMetaIndex(string id) { EnsureLoaded(); PropExtraInfo info; return TryGetInfoById(id, out info) ? info.index : 0; } public static string FindIdByIndex(int index) { EnsureLoaded(); if (index <= 0) { return null; } foreach (KeyValuePair item in _byId) { if (item.Value.index == index) { return item.Key; } } return null; } public static string GetDisplayName(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return null; } PropExtraInfo info; return (TryGetInfoById(id, out info) && !string.IsNullOrEmpty(info.displayName)) ? info.displayName : null; } public static string GetCategory(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return ""; } PropExtraInfo info; return TryGetInfoById(id, out info) ? (info.category ?? "") : ""; } public static bool HasCategory(string id) { EnsureLoaded(); if (string.IsNullOrEmpty(id)) { return false; } PropExtraInfo info; return TryGetInfoById(id, out info) && !string.IsNullOrEmpty(info.category); } public static List GetAllCategories() { EnsureLoaded(); SortedSet sortedSet = new SortedSet(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair item in _byId) { if (!string.IsNullOrEmpty(item.Value.category)) { sortedSet.Add(item.Value.category); } } return new List(sortedSet); } } internal static class PropMetadataEditor { internal class RendererEntry { public string path; public Renderer renderer; public Collider collider; public bool enabled; } internal const float AutoSaveDelay = 0.75f; public static readonly string[] KnownSurfaceTags = new string[23] { "", "Rock", "Cliff", "Stone", "Dirt", "Mud", "Sand", "Gravel", "Riverbed", "Grass", "DeadGrass", "ForestFloor", "Moss", "MossyRock", "Snow", "Ice", "Wood", "MassiveWood", "Metal", "Fabric", "Cactus", "SandCastle", "Milk" }; internal static readonly (string label, int value)[] KnownGrassTypes = new(string, int)[14] { ("Normal", 1), ("None (silent)", 0), ("Tall", 2), ("Dry Tall", 3), ("Fern", 4), ("Dry Leaf", 5), ("Wet Leaf", 6), ("Leafy Shrub", 7), ("Dry Shrub", 8), ("Wild Flower", 9), ("Twiggy", 10), ("Needle", 11), ("Cedar", 12), ("Reed", 13) }; internal static string PropId; internal static string DisplayName = ""; internal static string Category = ""; internal static bool Excluded; internal static bool UseRenderMeshCollider; internal static string ColliderIgnoredSubmeshes = ""; internal static string OverrideMaterialName = ""; internal static string SelectedMaterialName = ""; internal static string DefaultMaterialName = ""; internal static int Index = -1; internal static bool Dirty; internal static bool MaterialExplicitlyChosen; internal static float LastChangeTime; internal static bool IsBush; internal static float BushRadius; internal static int SoundGrassType = 1; internal static bool KeepOriginalHierarchy; internal static string SurfaceType = ""; internal static readonly HashSet DisabledRendererPaths = new HashSet(StringComparer.Ordinal); internal static readonly List PerSlotSelected = new List(); internal static readonly List PerSlotDefault = new List(); internal static readonly HashSet SlotHasExplicitOverride = new HashSet(); internal static int MaxMaterialSlots; internal static bool MultiMaterialEnabled; internal static int ForcedMaterialSlots = 2; internal static Renderer[] SelectedRenderers; internal static Material[][] SelectedDefaultMaterials; internal static LevelEditorObject SelectedLEO; internal static string PaletteSelectedId; internal static readonly List RendererEntries = new List(); internal static string GrassTypeName(int value) { (string, int)[] knownGrassTypes = KnownGrassTypes; for (int i = 0; i < knownGrassTypes.Length; i++) { var (result, num) = knownGrassTypes[i]; if (num == value) { return result; } } return value.ToString(); } internal static void MarkDirty() { Dirty = true; LastChangeTime = Time.unscaledTime; } internal static void AutoSaveIfIdle() { if (Dirty && !string.IsNullOrEmpty(PropId) && !(Time.unscaledTime - LastChangeTime < 0.75f)) { ApplyCurrent(); Dirty = false; } } internal static void SetPaletteSelection(string propId) { PaletteSelectedId = propId; } internal static string GetSelectedPropId(LevelEditorObject obj) { if ((Object)(object)obj != (Object)null) { PaletteSelectedId = null; if (!string.IsNullOrEmpty(obj.addressableKey)) { return obj.addressableKey; } if (!string.IsNullOrEmpty(obj.objectType)) { return "primitive://" + obj.objectType; } return null; } return string.IsNullOrEmpty(PaletteSelectedId) ? null : PaletteSelectedId; } internal static string BuildPath(Transform root, Transform t) { if ((Object)(object)t == (Object)null) { return "(null)"; } if ((Object)(object)root == (Object)null) { return ((Object)t).name; } List list = new List(); Transform val = t; while ((Object)(object)val != (Object)null) { list.Add(((Object)val).name); if ((Object)(object)val == (Object)(object)root) { break; } val = val.parent; } list.Reverse(); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < list.Count; i++) { if (i > 0) { stringBuilder.Append('/'); } stringBuilder.Append(list[i]); } return stringBuilder.ToString(); } internal static string GetOverrideLabel() { if (string.IsNullOrEmpty(SelectedMaterialName)) { return "(no override)"; } if (string.IsNullOrEmpty(OverrideMaterialName) && !string.IsNullOrEmpty(DefaultMaterialName) && string.Equals(SelectedMaterialName, DefaultMaterialName, StringComparison.OrdinalIgnoreCase)) { return SelectedMaterialName + " (default)"; } return SelectedMaterialName; } internal static void SelectMaterialByIndex(int index) { if (index <= 0 || index >= MaterialCatalog.MaterialNames.Count) { SelectedMaterialName = ""; } else { SelectedMaterialName = MaterialCatalog.MaterialNames[index]; } } internal static int GetMaterialIndex(string name) { if (string.IsNullOrEmpty(name)) { return 0; } for (int i = 0; i < MaterialCatalog.MaterialNames.Count; i++) { if (string.Equals(MaterialCatalog.MaterialNames[i], name, StringComparison.OrdinalIgnoreCase)) { return i; } } return 0; } internal static void AddRendererMaterialsToList() { if (SelectedRenderers == null) { return; } for (int i = 0; i < SelectedRenderers.Length; i++) { Renderer val = SelectedRenderers[i]; if ((Object)(object)val == (Object)null) { continue; } Il2CppReferenceArray sharedMaterials = val.sharedMaterials; if (sharedMaterials == null) { continue; } for (int j = 0; j < ((Il2CppArrayBase)(object)sharedMaterials).Length; j++) { Material val2 = ((Il2CppArrayBase)(object)sharedMaterials)[j]; if (!((Object)(object)val2 == (Object)null) && !string.IsNullOrEmpty(((Object)val2).name) && !MaterialVariantTracker.ShouldHideMaterial(((Object)val2).name)) { bool flag = !string.IsNullOrEmpty(OverrideMaterialName) && string.Equals(((Object)val2).name, OverrideMaterialName, StringComparison.OrdinalIgnoreCase); if (!string.IsNullOrEmpty(PropId) && !flag && MaterialCatalog.BackfillMaterialSource(((Object)val2).name, PropId)) { PropMetadataStore.Save(); } if (!MaterialCatalog.MaterialByName.ContainsKey(((Object)val2).name)) { MaterialCatalog.MaterialByName[((Object)val2).name] = val2; } } } } } internal static void ApplyCurrent() { if (string.IsNullOrEmpty(PropId)) { return; } if (MultiMaterialEnabled || MaxMaterialSlots > 1) { int num = (MultiMaterialEnabled ? Math.Max(ForcedMaterialSlots, MaxMaterialSlots) : MaxMaterialSlots); List list = new List(num); for (int i = 0; i < num; i++) { string text = ((i < PerSlotSelected.Count) ? PerSlotSelected[i] : string.Empty); list.Add(SlotHasExplicitOverride.Contains(i) ? text : string.Empty); } int forcedMaterialSlots = (MultiMaterialEnabled ? ForcedMaterialSlots : 0); PropExtraInfo propExtraInfo = PropMetadataStore.Apply(PropId, DisplayName, Category, Excluded, UseRenderMeshCollider, string.Empty, DefaultMaterialName, string.Empty, SurfaceType, DisabledRendererPaths, ColliderIgnoredSubmeshes, list, forcedMaterialSlots, IsBush, BushRadius, SoundGrassType, KeepOriginalHierarchy); if (propExtraInfo != null) { Index = propExtraInfo.index; } MaterialExplicitlyChosen = false; } else { string overrideToSave = GetOverrideToSave(); MaterialCatalog.KnownMaterialSources.TryGetValue(overrideToSave ?? string.Empty, out var value); PropExtraInfo propExtraInfo2 = PropMetadataStore.Apply(PropId, DisplayName, Category, Excluded, UseRenderMeshCollider, overrideToSave, DefaultMaterialName, value, SurfaceType, DisabledRendererPaths, ColliderIgnoredSubmeshes, null, 0, IsBush, BushRadius, SoundGrassType, KeepOriginalHierarchy); if (propExtraInfo2 != null) { Index = propExtraInfo2.index; } OverrideMaterialName = overrideToSave ?? string.Empty; MaterialExplicitlyChosen = false; } } internal static string GetOverrideToSave() { if (string.IsNullOrEmpty(SelectedMaterialName)) { return string.Empty; } if (string.Equals(SelectedMaterialName, "(no override)", StringComparison.OrdinalIgnoreCase)) { return string.Empty; } if (!string.IsNullOrEmpty(DefaultMaterialName) && string.Equals(SelectedMaterialName, DefaultMaterialName, StringComparison.OrdinalIgnoreCase) && !string.Equals(SelectedMaterialName, OverrideMaterialName, StringComparison.OrdinalIgnoreCase) && !MaterialExplicitlyChosen) { return string.Empty; } return SelectedMaterialName; } internal static bool SyncFromSelection(LevelEditorObject selectedObject) { SelectedLEO = selectedObject; string selectedPropId = GetSelectedPropId(selectedObject); if (string.Equals(selectedPropId, PropId, StringComparison.Ordinal)) { return false; } if (Dirty && !string.IsNullOrEmpty(PropId)) { ApplyCurrent(); Dirty = false; } PropId = selectedPropId; DisplayName = string.Empty; Category = string.Empty; OverrideMaterialName = string.Empty; SelectedMaterialName = string.Empty; DefaultMaterialName = string.Empty; CacheDefaultMaterials(selectedObject); Excluded = false; UseRenderMeshCollider = false; ColliderIgnoredSubmeshes = string.Empty; SurfaceType = string.Empty; IsBush = false; BushRadius = 0f; SoundGrassType = 1; KeepOriginalHierarchy = false; Index = -1; Dirty = false; MaterialExplicitlyChosen = false; DisabledRendererPaths.Clear(); RendererEntries.Clear(); PerSlotSelected.Clear(); SlotHasExplicitOverride.Clear(); MultiMaterialEnabled = false; ForcedMaterialSlots = 2; if (string.IsNullOrEmpty(selectedPropId)) { return true; } PropInfo propInfo = PropLibrary.FindById(selectedPropId); UseRenderMeshCollider = propInfo == null || !propInfo.HasColliderParts; List list = null; if (PropMetadataStore.TryGet(selectedPropId, out var info) && info != null) { DisplayName = info.displayName ?? string.Empty; Category = info.category ?? string.Empty; OverrideMaterialName = info.overrideMaterialId ?? string.Empty; SurfaceType = info.surfaceType ?? string.Empty; Excluded = info.excluded; UseRenderMeshCollider = info.useRenderMeshCollider; ColliderIgnoredSubmeshes = info.colliderIgnoredSubmeshes ?? string.Empty; IsBush = info.isBush; BushRadius = info.bushRadius; SoundGrassType = info.soundGrassType; KeepOriginalHierarchy = info.keepOriginalHierarchy; Index = info.index; if (info.disabledRenderers != null) { for (int i = 0; i < info.disabledRenderers.Count; i++) { string text = info.disabledRenderers[i]; if (!string.IsNullOrEmpty(text)) { DisabledRendererPaths.Add(text); } } } if (info.forcedMaterialSlots > 1) { MultiMaterialEnabled = true; ForcedMaterialSlots = info.forcedMaterialSlots; } list = info.perSlotMaterialOverrides; } SelectedMaterialName = (string.IsNullOrEmpty(OverrideMaterialName) ? DefaultMaterialName : OverrideMaterialName); int num = (MultiMaterialEnabled ? Math.Max(ForcedMaterialSlots, MaxMaterialSlots) : MaxMaterialSlots); while (PerSlotDefault.Count < num) { PerSlotDefault.Add(string.Empty); } for (int j = 0; j < num; j++) { string text2 = ((list != null && j < list.Count) ? (list[j] ?? string.Empty) : string.Empty); string text3 = ((j < PerSlotDefault.Count) ? PerSlotDefault[j] : string.Empty); PerSlotSelected.Add(string.IsNullOrEmpty(text2) ? text3 : text2); if (!string.IsNullOrEmpty(text2)) { SlotHasExplicitOverride.Add(j); } } BuildRendererEntries(selectedObject); ApplyRendererVisibility(); MaterialCatalog.EnsureMaterialList(); AddRendererMaterialsToList(); if (propInfo != null && propInfo.IsGpui) { if (!propInfo.isLoaded) { PropLibrary.LoadPropData(propInfo); } if (propInfo.isLoaded) { MaterialCatalog.AddPartsToMaterialList(propInfo); } } bool flag = !string.IsNullOrEmpty(OverrideMaterialName) && !MaterialCatalog.MaterialByName.ContainsKey(OverrideMaterialName); if (!flag) { foreach (int item3 in SlotHasExplicitOverride) { string text4 = ((item3 < PerSlotSelected.Count) ? PerSlotSelected[item3] : string.Empty); if (!string.IsNullOrEmpty(text4) && !MaterialCatalog.MaterialByName.ContainsKey(text4)) { flag = true; break; } } } if (flag) { try { Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); for (int k = 0; k < val.Length; k++) { Material val2 = val[k]; if (!((Object)(object)val2 == (Object)null) && !string.IsNullOrEmpty(((Object)val2).name) && !MaterialVariantTracker.ShouldHideMaterial(((Object)val2).name) && !MaterialCatalog.MaterialByName.ContainsKey(((Object)val2).name)) { MaterialCatalog.MaterialByName[((Object)val2).name] = val2; } } } catch { } bool flag2 = MaterialVariantTracker.SceneVariantByDisplayName.ContainsKey(OverrideMaterialName); if (!string.IsNullOrEmpty(OverrideMaterialName) && !MaterialCatalog.MaterialByName.ContainsKey(OverrideMaterialName) && !OverrideMaterialName.StartsWith("[MicroSplat]", StringComparison.Ordinal) && !flag2) { try { Material val3 = MaterialPathCatalog.TryLoadMaterialByName(OverrideMaterialName, info.materialSourcePropId); if ((Object)(object)val3 != (Object)null) { if (!MaterialCatalog.MaterialByName.ContainsKey(((Object)val3).name)) { string text5 = (((Object)(object)val3.shader != (Object)null) ? ((Object)val3.shader).name : string.Empty); string item = (string.IsNullOrEmpty(text5) ? ((Object)val3).name : (((Object)val3).name + " [" + text5 + "]")); MaterialCatalog.MaterialNames.Add(((Object)val3).name); MaterialCatalog.MaterialLabels.Add(item); MaterialCatalog.MaterialByName[((Object)val3).name] = val3; } if (!string.Equals(((Object)val3).name, OverrideMaterialName, StringComparison.OrdinalIgnoreCase) && !MaterialCatalog.MaterialByName.ContainsKey(OverrideMaterialName)) { MaterialCatalog.MaterialByName[OverrideMaterialName] = val3; } } } catch { } } foreach (int item4 in SlotHasExplicitOverride) { string text6 = ((item4 < PerSlotSelected.Count) ? PerSlotSelected[item4] : string.Empty); if (string.IsNullOrEmpty(text6) || MaterialCatalog.MaterialByName.ContainsKey(text6) || text6.StartsWith("[MicroSplat]", StringComparison.Ordinal) || MaterialVariantTracker.SceneVariantByDisplayName.ContainsKey(text6)) { continue; } try { Material val4 = MaterialPathCatalog.TryLoadMaterialByName(text6, info.materialSourcePropId); if (!((Object)(object)val4 == (Object)null)) { if (!MaterialCatalog.MaterialByName.ContainsKey(((Object)val4).name)) { string text7 = (((Object)(object)val4.shader != (Object)null) ? ((Object)val4.shader).name : string.Empty); string item2 = (string.IsNullOrEmpty(text7) ? ((Object)val4).name : (((Object)val4).name + " [" + text7 + "]")); MaterialCatalog.MaterialNames.Add(((Object)val4).name); MaterialCatalog.MaterialLabels.Add(item2); MaterialCatalog.MaterialByName[((Object)val4).name] = val4; } if (!string.Equals(((Object)val4).name, text6, StringComparison.OrdinalIgnoreCase) && !MaterialCatalog.MaterialByName.ContainsKey(text6)) { MaterialCatalog.MaterialByName[text6] = val4; } } } catch { } } } if (PropMetadataStore.TryGet(PropId, out var info2) && info2 != null) { if (!string.IsNullOrEmpty(info2.nativeMaterialName) && !string.Equals(info2.nativeMaterialName, info2.overrideMaterialId, StringComparison.OrdinalIgnoreCase)) { DefaultMaterialName = info2.nativeMaterialName; } bool flag3 = false; if (!string.IsNullOrEmpty(info2.overrideMaterialId)) { if (!string.IsNullOrEmpty(info2.nativeMaterialName) && string.Equals(info2.nativeMaterialName, info2.overrideMaterialId, StringComparison.OrdinalIgnoreCase)) { info2.nativeMaterialName = string.Empty; flag3 = true; } if (string.IsNullOrEmpty(info2.nativeMaterialName) && string.Equals(DefaultMaterialName, info2.overrideMaterialId, StringComparison.OrdinalIgnoreCase)) { string text8 = MaterialCatalog.FindNativeFromParts(propInfo, info2.overrideMaterialId); if (!string.IsNullOrEmpty(text8)) { DefaultMaterialName = text8; } } if (string.IsNullOrEmpty(info2.nativeMaterialName) && !string.IsNullOrEmpty(DefaultMaterialName) && !string.Equals(DefaultMaterialName, info2.overrideMaterialId, StringComparison.OrdinalIgnoreCase)) { info2.nativeMaterialName = DefaultMaterialName; flag3 = true; } if (string.IsNullOrEmpty(info2.materialSourcePropId) && MaterialCatalog.KnownMaterialSources.TryGetValue(info2.overrideMaterialId, out var value) && !string.IsNullOrEmpty(value) && MaterialCatalog.BackfillMaterialSource(info2.overrideMaterialId, value)) { flag3 = true; } } if (flag3) { PropMetadataStore.Save(); } } if (MultiMaterialEnabled || MaxMaterialSlots > 1) { ApplyAllSlotMaterials(); } else { ApplyPreviewMaterial(SelectedMaterialName); } PropInstanceServices.ApplySurfaceType(selectedObject, SurfaceType); return true; } internal static void CacheDefaultMaterials(LevelEditorObject obj) { SelectedRenderers = null; SelectedDefaultMaterials = null; if ((Object)(object)obj == (Object)null) { return; } try { Il2CppArrayBase componentsInChildren = ((Component)obj).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } SelectedRenderers = Il2CppArrayBase.op_Implicit(componentsInChildren); SelectedDefaultMaterials = new Material[componentsInChildren.Length][]; DefaultMaterialName = string.Empty; for (int i = 0; i < componentsInChildren.Length; i++) { Renderer val = componentsInChildren[i]; if ((Object)(object)val == (Object)null) { continue; } Il2CppReferenceArray sharedMaterials = val.sharedMaterials; if (sharedMaterials == null || ((Il2CppArrayBase)(object)sharedMaterials).Length == 0) { Material sharedMaterial = val.sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null) { SelectedDefaultMaterials[i] = (Material[])(object)new Material[1] { sharedMaterial }; if (string.IsNullOrEmpty(DefaultMaterialName)) { DefaultMaterialName = ((Object)sharedMaterial).name ?? string.Empty; } } else { SelectedDefaultMaterials[i] = null; } continue; } Material[] array = (Material[])(object)new Material[((Il2CppArrayBase)(object)sharedMaterials).Length]; for (int j = 0; j < ((Il2CppArrayBase)(object)sharedMaterials).Length; j++) { array[j] = ((Il2CppArrayBase)(object)sharedMaterials)[j]; } SelectedDefaultMaterials[i] = array; if (!string.IsNullOrEmpty(DefaultMaterialName)) { continue; } foreach (Material val2 in array) { if ((Object)(object)val2 != (Object)null && !string.IsNullOrEmpty(((Object)val2).name)) { DefaultMaterialName = ((Object)val2).name; break; } } } MaxMaterialSlots = 0; PerSlotDefault.Clear(); for (int l = 0; l < SelectedDefaultMaterials.Length; l++) { Material[] array2 = SelectedDefaultMaterials[l]; if (array2 != null && array2.Length > MaxMaterialSlots) { MaxMaterialSlots = array2.Length; } } for (int m = 0; m < MaxMaterialSlots; m++) { PerSlotDefault.Add(string.Empty); } for (int n = 0; n < SelectedDefaultMaterials.Length; n++) { Material[] array3 = SelectedDefaultMaterials[n]; if (array3 != null && array3.Length == MaxMaterialSlots) { for (int num = 0; num < MaxMaterialSlots; num++) { PerSlotDefault[num] = (((Object)(object)array3[num] != (Object)null) ? (((Object)array3[num]).name ?? string.Empty) : string.Empty); } break; } } } catch { } } internal static void BuildRendererEntries(LevelEditorObject obj) { RendererEntries.Clear(); if ((Object)(object)obj == (Object)null) { return; } Transform transform = ((Component)obj).transform; if (SelectedRenderers != null) { for (int i = 0; i < SelectedRenderers.Length; i++) { Renderer val = SelectedRenderers[i]; if (!((Object)(object)val == (Object)null)) { string text = BuildPath(transform, ((Component)val).transform); RendererEntry rendererEntry = new RendererEntry { path = text, renderer = val, enabled = val.enabled }; if (DisabledRendererPaths.Contains(text)) { rendererEntry.enabled = false; } RendererEntries.Add(rendererEntry); } } } Il2CppArrayBase componentsInChildren = ((Component)obj).GetComponentsInChildren(true); if (componentsInChildren == null) { return; } for (int j = 0; j < componentsInChildren.Length; j++) { Collider val2 = componentsInChildren[j]; if (!((Object)(object)val2 == (Object)null)) { string text2 = BuildPath(transform, ((Component)val2).transform) + " [" + ((object)val2).GetType().Name + "]"; RendererEntry rendererEntry2 = new RendererEntry { path = text2, collider = val2, enabled = val2.enabled }; if (DisabledRendererPaths.Contains(text2)) { rendererEntry2.enabled = false; } RendererEntries.Add(rendererEntry2); } } } internal static void ApplyBushCollider(LevelEditorObject leo, bool enable) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)leo == (Object)null)) { GameObject gameObject = ((Component)leo).gameObject; BushCollider component = gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } SphereCollider component2 = gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } PropInstanceServices.BushAudioTracker.Unregister(gameObject.transform); PropInstanceServices.SetBushPassthrough(gameObject, enable); if (!enable) { BushRadius = 0f; return; } BushRadius = PropInstanceServices.ComputeBushRadius(leo); PropInstanceServices.BushAudioTracker.Register(gameObject.transform, BushRadius, SoundGrassType); SphereCollider val = gameObject.AddComponent(); val.radius = BushRadius; ((Collider)val).isTrigger = true; BushCollider val2 = gameObject.AddComponent(); val2.rad = val.radius * gameObject.transform.localScale.x; } } internal static void ApplyColliderToSelected(bool enable) { if ((Object)(object)SelectedLEO == (Object)null) { return; } PropInfo propInfo = PropLibrary.FindById(SelectedLEO.addressableKey); List list = new List(); foreach (Transform componentsInChild in ((Component)SelectedLEO).GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild != (Object)null && (Object)(object)componentsInChild != (Object)(object)((Component)SelectedLEO).transform && ((Object)((Component)componentsInChild).gameObject).name.StartsWith("PropCollider")) { list.Add(((Component)componentsInChild).gameObject); } } foreach (GameObject item in list) { if ((Object)(object)item != (Object)null) { Object.DestroyImmediate((Object)(object)item); } } List list2 = new List(); foreach (string disabledRendererPath in DisabledRendererPaths) { if (disabledRendererPath.Contains("PropCollider")) { list2.Add(disabledRendererPath); } } foreach (string item2 in list2) { DisabledRendererPaths.Remove(item2); } if (propInfo != null) { PhysicsObjectManager.ApplyColliderParts(((Component)SelectedLEO).gameObject, propInfo, enable); } } internal static void ApplyRendererVisibility() { if (RendererEntries.Count == 0) { return; } for (int i = 0; i < RendererEntries.Count; i++) { RendererEntry rendererEntry = RendererEntries[i]; bool enabled = !DisabledRendererPaths.Contains(rendererEntry.path); if ((Object)(object)rendererEntry.renderer != (Object)null) { rendererEntry.renderer.enabled = enabled; } else if ((Object)(object)rendererEntry.collider != (Object)null) { rendererEntry.collider.enabled = enabled; } rendererEntry.enabled = enabled; } } internal static void ApplyPreviewMaterial(string materialName) { if (SelectedRenderers == null || SelectedRenderers.Length == 0) { return; } if (string.IsNullOrEmpty(materialName) || string.Equals(materialName, "(no override)", StringComparison.OrdinalIgnoreCase) || (!string.IsNullOrEmpty(DefaultMaterialName) && string.Equals(materialName, DefaultMaterialName, StringComparison.OrdinalIgnoreCase))) { RestoreDefaultMaterials(); return; } if (!MaterialCatalog.MaterialByName.TryGetValue(materialName, out var value) || (Object)(object)value == (Object)null) { value = MaterialPathCatalog.TryLoadMaterialByName(materialName, MaterialCatalog.GetKnownMaterialSource(materialName)); if ((Object)(object)value != (Object)null) { if (!MaterialCatalog.MaterialByName.ContainsKey(((Object)value).name)) { MaterialCatalog.MaterialByName[((Object)value).name] = value; } if (!string.Equals(((Object)value).name, materialName, StringComparison.OrdinalIgnoreCase) && !MaterialCatalog.MaterialByName.ContainsKey(materialName)) { MaterialCatalog.MaterialByName[materialName] = value; } } } if ((Object)(object)value == (Object)null) { RestoreDefaultMaterials(); return; } for (int i = 0; i < SelectedRenderers.Length; i++) { Renderer val = SelectedRenderers[i]; if (!((Object)(object)val == (Object)null)) { int num = 1; Il2CppReferenceArray sharedMaterials = val.sharedMaterials; if (sharedMaterials != null && ((Il2CppArrayBase)(object)sharedMaterials).Length > 0) { num = ((Il2CppArrayBase)(object)sharedMaterials).Length; } Material[] array = (Material[])(object)new Material[num]; for (int j = 0; j < num; j++) { array[j] = value; } val.sharedMaterials = Il2CppReferenceArray.op_Implicit(array); } } } internal static void RestoreDefaultMaterials() { if (SelectedDefaultMaterials == null) { return; } for (int i = 0; i < SelectedRenderers.Length; i++) { Renderer val = SelectedRenderers[i]; if ((Object)(object)val == (Object)null) { continue; } Material[] array = SelectedDefaultMaterials[i]; if (array != null) { Material[] array2 = (Material[])(object)new Material[array.Length]; for (int j = 0; j < array.Length; j++) { array2[j] = array[j]; } val.sharedMaterials = Il2CppReferenceArray.op_Implicit(array2); } } } internal static void ApplySlotMaterial(int slot, string materialName) { if (SelectedRenderers == null) { return; } bool flag = string.IsNullOrEmpty(materialName) || string.Equals(materialName, "(no override)", StringComparison.OrdinalIgnoreCase) || (slot < PerSlotDefault.Count && string.Equals(materialName, PerSlotDefault[slot], StringComparison.OrdinalIgnoreCase)); for (int i = 0; i < SelectedRenderers.Length; i++) { Renderer val = SelectedRenderers[i]; if ((Object)(object)val == (Object)null) { continue; } Il2CppReferenceArray val2 = val.sharedMaterials; if (val2 == null) { val2 = Il2CppReferenceArray.op_Implicit((Material[])(object)new Material[0]); } if (slot >= ((Il2CppArrayBase)(object)val2).Length) { if (flag) { continue; } Material[] array = (Material[])(object)new Material[slot + 1]; for (int j = 0; j < ((Il2CppArrayBase)(object)val2).Length; j++) { array[j] = ((Il2CppArrayBase)(object)val2)[j]; } val2 = Il2CppReferenceArray.op_Implicit(array); } if (flag) { Material[][] selectedDefaultMaterials = SelectedDefaultMaterials; Material[] array2 = ((selectedDefaultMaterials != null) ? selectedDefaultMaterials[i] : null); ((Il2CppArrayBase)(object)val2)[slot] = ((array2 != null && slot < array2.Length) ? array2[slot] : null); } else { if (!MaterialCatalog.MaterialByName.TryGetValue(materialName, out var value) || (Object)(object)value == (Object)null) { value = MaterialPathCatalog.TryLoadMaterialByName(materialName, MaterialCatalog.GetKnownMaterialSource(materialName)); if ((Object)(object)value != (Object)null) { if (!MaterialCatalog.MaterialByName.ContainsKey(((Object)value).name)) { MaterialCatalog.MaterialByName[((Object)value).name] = value; } if (!string.Equals(((Object)value).name, materialName, StringComparison.OrdinalIgnoreCase) && !MaterialCatalog.MaterialByName.ContainsKey(materialName)) { MaterialCatalog.MaterialByName[materialName] = value; } } } if ((Object)(object)value == (Object)null) { continue; } ((Il2CppArrayBase)(object)val2)[slot] = value; } val.sharedMaterials = val2; } } internal static void ApplyAllSlotMaterials() { for (int i = 0; i < PerSlotSelected.Count; i++) { ApplySlotMaterial(i, PerSlotSelected[i]); } } } internal static class PropInstanceServices { internal static class BushAudioTracker { private static readonly List<(Transform t, float localRad, int grassType)> _bushes = new List<(Transform, float, int)>(); public static void Register(Transform t, float localRad, int grassType = 1) { if ((Object)(object)t != (Object)null) { _bushes.Add((t, localRad, grassType)); } } public static void Unregister(Transform t) { for (int num = _bushes.Count - 1; num >= 0; num--) { if ((Object)(object)_bushes[num].t == (Object)(object)t) { _bushes.RemoveAt(num); break; } } } public static int GetGrassTypeAtPos(Vector3 pos) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) for (int num = _bushes.Count - 1; num >= 0; num--) { var (val, num2, result) = _bushes[num]; if ((Object)(object)val == (Object)null) { _bushes.RemoveAt(num); } else { float num3 = num2 * Mathf.Max(0.001f, val.lossyScale.x); Vector3 val2 = pos - val.position; if (((Vector3)(ref val2)).sqrMagnitude < num3 * num3) { return result; } } } return 0; } } private static readonly List _tintedObjects = new List(); private static Shader _overlayShader; internal static void SetTintShader(Shader s) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) _overlayShader = s; LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { return; } foreach (LevelEditorObject @object in instance.Objects) { if (!((Object)(object)@object == (Object)null) && !((Object)(object)@object._tintMaterial != (Object)null)) { Vector3 materialTint = @object.materialTint; if (!Mathf.Approximately(materialTint.x, 255f) || !Mathf.Approximately(materialTint.y, 255f) || !Mathf.Approximately(materialTint.z, 255f)) { ApplyTint(@object, materialTint); } } } } public static void RenderTints() { //IL_0133: Unknown result type (might be due to invalid IL or missing references) if (_tintedObjects.Count == 0) { return; } for (int num = _tintedObjects.Count - 1; num >= 0; num--) { LevelEditorObject levelEditorObject = _tintedObjects[num]; if ((Object)(object)levelEditorObject == (Object)null || (Object)(object)levelEditorObject._tintMaterial == (Object)null || levelEditorObject._tintRenderers == null) { _tintedObjects.RemoveAt(num); } else { Renderer[] tintRenderers = levelEditorObject._tintRenderers; foreach (Renderer val in tintRenderers) { if ((Object)(object)val == (Object)null || !val.enabled || !((Component)val).gameObject.activeInHierarchy) { continue; } Mesh val2 = null; MeshFilter component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { val2 = component.sharedMesh; } else { SkinnedMeshRenderer val3 = ((Il2CppObjectBase)val).TryCast(); if ((Object)(object)val3 != (Object)null) { val2 = val3.sharedMesh; } } if (!((Object)(object)val2 == (Object)null)) { Material tintMaterial = levelEditorObject._tintMaterial; int layer = ((Component)val).gameObject.layer; for (int j = 0; j < val2.subMeshCount; j++) { Graphics.DrawMesh(val2, ((Component)val).transform.localToWorldMatrix, tintMaterial, layer, (Camera)null, j); } } } } } } public static void ApplyTint(LevelEditorObject leo, Vector3 tint) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_00b1: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown if ((Object)(object)leo == (Object)null) { return; } leo.materialTint = tint; if (Mathf.Approximately(tint.x, 255f) && Mathf.Approximately(tint.y, 255f) && Mathf.Approximately(tint.z, 255f)) { if ((Object)(object)leo._tintMaterial != (Object)null) { Object.Destroy((Object)(object)leo._tintMaterial); leo._tintMaterial = null; } leo._tintRenderers = null; _tintedObjects.Remove(leo); return; } Shader overlayShader = _overlayShader; if ((Object)(object)overlayShader == (Object)null) { return; } Color val = default(Color); ((Color)(ref val))..ctor(tint.x / 255f, tint.y / 255f, tint.z / 255f, 1f); if ((Object)(object)leo._tintMaterial == (Object)null) { leo._tintMaterial = new Material(overlayShader); } leo._tintMaterial.SetColor("_TintColor", val); if (leo._tintRenderers == null) { Il2CppArrayBase componentsInChildren = ((Component)leo).GetComponentsInChildren(true); leo._tintRenderers = (Renderer[])(object)new Renderer[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { leo._tintRenderers[i] = componentsInChildren[i]; } if (!_tintedObjects.Contains(leo)) { _tintedObjects.Add(leo); } } } public static void ApplySurfaceType(LevelEditorObject leo, string surfaceTag) { if ((Object)(object)leo == (Object)null) { return; } string tag = (leo.surfaceTypeTag = (string.IsNullOrEmpty(surfaceTag) ? "Untagged" : surfaceTag)); try { SetTagSafe(((Component)leo).gameObject, tag); foreach (Collider componentsInChild in ((Component)leo).GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild != (Object)null) { SetTagSafe(((Component)componentsInChild).gameObject, tag); } } } catch (Exception ex) { MelonLogger.Warning("[PropMetadata] ApplySurfaceType failed: " + ex.Message); } } public static void ApplySurfaceTypeToRoot(GameObject root, string surfaceTag) { if ((Object)(object)root == (Object)null) { return; } try { string text = (string.IsNullOrEmpty(surfaceTag) ? "Untagged" : surfaceTag); SetTagSafe(root, text); LevelEditorObject component = root.GetComponent(); if ((Object)(object)component != (Object)null) { component.surfaceTypeTag = text; } foreach (Collider componentsInChild in root.GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild != (Object)null) { SetTagSafe(((Component)componentsInChild).gameObject, text); } } } catch (Exception ex) { MelonLogger.Warning("[PropMetadata] ApplySurfaceTypeToRoot failed: " + ex.Message); } } private static void SetTagSafe(GameObject go, string tag) { try { go.tag = tag; } catch (Exception ex) { MelonLogger.Warning($"[BabyBlocks][SetTag] Failed to set '{tag}' on '{((go != null) ? ((Object)go).name : null)}': {ex.Message}"); } } public static void ApplyDisabledRenderersToRoot(string propId, GameObject root) { PropMetadataStore.EnsureLoaded(); if (string.IsNullOrEmpty(propId) || (Object)(object)root == (Object)null || !PropMetadataStore._byId.TryGetValue(propId, out var value) || value.disabledRenderers == null || value.disabledRenderers.Count == 0) { return; } foreach (string disabledRenderer in value.disabledRenderers) { if (string.IsNullOrEmpty(disabledRenderer)) { continue; } int num = disabledRenderer.IndexOf('/'); string text = ((num >= 0) ? disabledRenderer.Substring(num + 1) : disabledRenderer); if (string.IsNullOrEmpty(text)) { continue; } Transform val = root.transform.Find(text); if (!((Object)(object)val == (Object)null)) { Renderer component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { component.enabled = false; } } } LevelEditorManager.NotifyVisualStateChanged(root); } public static void SetBushPassthrough(GameObject root, bool passthrough) { foreach (Collider componentsInChild in root.GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild == (Object)null || (Object)(object)((Component)componentsInChild).gameObject.GetComponent() != (Object)null) { continue; } if (passthrough) { MeshCollider val = ((Il2CppObjectBase)componentsInChild).TryCast(); if ((Object)(object)val != (Object)null && !val.convex) { val.convex = true; } } componentsInChild.isTrigger = passthrough; } } public static float ComputeBushRadius(LevelEditorObject leo) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00ac: Unknown result type (might be due to invalid IL or missing references) Bounds val = default(Bounds); bool flag = true; foreach (Renderer componentsInChild in ((Component)leo).GetComponentsInChildren(true)) { if (!((Object)(object)componentsInChild == (Object)null)) { if (flag) { val = componentsInChild.bounds; flag = false; } else { ((Bounds)(ref val)).Encapsulate(componentsInChild.bounds); } } } if (flag) { return 1f; } float num = Mathf.Max(((Bounds)(ref val)).extents.x, ((Bounds)(ref val)).extents.z); float num2 = Mathf.Max(0.001f, ((Component)leo).transform.lossyScale.x); return num / num2; } public static void ApplyBushColliderToRoot(string propId, GameObject root) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) PropMetadataStore.EnsureLoaded(); if (!string.IsNullOrEmpty(propId) && !((Object)(object)root == (Object)null) && PropMetadataStore._byId.TryGetValue(propId, out var value) && value.isBush) { BushCollider component = root.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } SphereCollider component2 = root.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } SetBushPassthrough(root, passthrough: true); float num = ((value.bushRadius > 0f) ? value.bushRadius : 1f); int grassType = ((value.soundGrassType <= 0) ? 1 : value.soundGrassType); BushAudioTracker.Register(root.transform, num, grassType); SphereCollider val = root.AddComponent(); val.radius = num; ((Collider)val).isTrigger = true; BushCollider val2 = root.AddComponent(); val2.rad = val.radius * root.transform.localScale.x; } } } internal static class MaterialVariantTracker { private const float VariantScanInterval = 5f; internal static readonly Dictionary<(string baseName, string texSig), Material> SceneVariantMats = new Dictionary<(string, string), Material>(); internal static readonly Dictionary SceneVariantByDisplayName = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary _materialSnapshotByInstance = new Dictionary(); internal static readonly Dictionary SceneCurrentByName = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary _watchedLiveMaterials = new Dictionary(); private static readonly HashSet _ownedMaterialIds = new HashSet(); internal static bool MaterialsLoaded; private static bool _initialVariantScanDone; private static float _lastVariantScanTime = -999f; internal static bool ShouldHideMaterial(string name) { return name.IndexOf("Imposter", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Impostor", StringComparison.OrdinalIgnoreCase) >= 0 || name.EndsWith(" (Instance)", StringComparison.Ordinal); } internal static string ComputeMatHash(Material m) { try { string textureSig = GetTextureSig(m); if (!string.IsNullOrEmpty(textureSig)) { return MaterialPathCatalog.ComputeStableHash(textureSig); } string text = (((Object)(object)m.shader != (Object)null) ? ((Object)m.shader).name : string.Empty); return MaterialPathCatalog.ComputeStableHash((text.Length > 0) ? text : ((Object)m).GetInstanceID().ToString()); } catch { return MaterialPathCatalog.ComputeStableHash(((Object)m).GetInstanceID().ToString()); } } private static bool ShouldSkipSceneVariantCapture(Material m) { if ((Object)(object)m == (Object)null || string.IsNullOrEmpty(((Object)m).name)) { return true; } if (ShouldHideMaterial(((Object)m).name)) { return true; } if (((Object)m).name.StartsWith("MicroSplat", StringComparison.OrdinalIgnoreCase)) { return true; } if (((Object)m).name.StartsWith("Hidden/", StringComparison.OrdinalIgnoreCase)) { return true; } if (((Object)m).name.IndexOf("MegaProxy", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (((Object)m).name.IndexOf("TVE Material", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (((Object)m).name.IndexOf("TVE Texture", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (((Object)m).name.IndexOf("(TVE", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (((Object)m).name.EndsWith("(Clone)", StringComparison.OrdinalIgnoreCase)) { return true; } return false; } public static void InvalidateMaterialCache() { MaterialsLoaded = false; _lastVariantScanTime = -999f; SceneCurrentByName.Clear(); _initialVariantScanDone = false; } internal static string GetTextureSig(Material m) { try { Il2CppStringArray texturePropertyNames = m.GetTexturePropertyNames(); if (texturePropertyNames == null || ((Il2CppArrayBase)(object)texturePropertyNames).Length == 0) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(); foreach (string item in (Il2CppArrayBase)(object)texturePropertyNames) { Texture texture = m.GetTexture(item); if ((Object)(object)texture != (Object)null) { stringBuilder.Append(((Object)texture).name).Append('\n'); } } return stringBuilder.ToString(); } catch { return string.Empty; } } internal static string GetFirstTextureName(Material m) { try { Il2CppStringArray texturePropertyNames = m.GetTexturePropertyNames(); if (texturePropertyNames == null) { return string.Empty; } foreach (string item in (Il2CppArrayBase)(object)texturePropertyNames) { Texture texture = m.GetTexture(item); if ((Object)(object)texture != (Object)null && !string.IsNullOrEmpty(((Object)texture).name)) { return ((Object)texture).name; } } } catch { } return string.Empty; } internal static void CaptureSceneVariants() { float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup - _lastVariantScanTime < 5f) { return; } _lastVariantScanTime = realtimeSinceStartup; try { if (!_initialVariantScanDone) { _initialVariantScanDone = true; Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); if (val == null) { return; } for (int i = 0; i < val.Length; i++) { try { Material val2 = val[i]; if (!ShouldSkipSceneVariantCapture(val2) && !_ownedMaterialIds.Contains(((Object)val2).GetInstanceID())) { _watchedLiveMaterials[((Object)val2).GetInstanceID()] = val2; CheckMaterialVariant(val2); } } catch { } } return; } foreach (KeyValuePair watchedLiveMaterial in _watchedLiveMaterials) { try { Material value = watchedLiveMaterial.Value; if (!((Object)(object)value == (Object)null)) { CheckMaterialVariant(value); } } catch { } } } catch (Exception ex) { MelonLogger.Warning("[PropMetadata] CaptureSceneVariants failed: " + ex.Message); } } private static void CheckMaterialVariant(Material m) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown int instanceID = ((Object)m).GetInstanceID(); SceneCurrentByName[((Object)m).name] = m; string textureSig = GetTextureSig(m); if (!_materialSnapshotByInstance.TryGetValue(instanceID, out (string, Material, string) value) || !string.Equals(value.Item1, ((Object)m).name, StringComparison.Ordinal)) { Material val = new Material(m); _ownedMaterialIds.Add(((Object)val).GetInstanceID()); _materialSnapshotByInstance[instanceID] = (((Object)m).name, val, textureSig); } else if (!string.Equals(textureSig, value.Item3, StringComparison.Ordinal)) { RegisterVariant(value.Item1, value.Item2, value.Item3); RegisterVariant(((Object)m).name, m, textureSig); Material val2 = new Material(m); _ownedMaterialIds.Add(((Object)val2).GetInstanceID()); _materialSnapshotByInstance[instanceID] = (((Object)m).name, val2, textureSig); } } private static void RegisterVariant(string baseName, Material source, string sig) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown (string, string) key = (baseName, sig); if (!SceneVariantMats.ContainsKey(key)) { string text = baseName + " [" + MaterialPathCatalog.ComputeStableHash(sig) + "]"; int num = 2; while (SceneVariantByDisplayName.ContainsKey(text)) { text = baseName + " [" + MaterialPathCatalog.ComputeStableHash(sig + num++) + "]"; } Material val = new Material(source) { name = text }; _ownedMaterialIds.Add(((Object)val).GetInstanceID()); SceneVariantMats[key] = val; SceneVariantByDisplayName[text] = val; } } internal static bool IsOwnedMaterial(int instanceId) { return _ownedMaterialIds.Contains(instanceId); } } internal static class MaterialCatalog { internal const float MicroSplatUVScaleMultiplier = 8f; internal static readonly List MaterialNames = new List(); internal static readonly List MaterialLabels = new List(); internal static readonly Dictionary MaterialByName = new Dictionary(StringComparer.OrdinalIgnoreCase); internal static readonly List MicroSplatLayerMats = new List(); internal static string[] MsControlProps; internal static Texture2D MsBlankControl; internal static readonly List MsActiveControls = new List(); internal static bool MsHasPerTexUV; internal static readonly Dictionary KnownMaterialSources = new Dictionary(StringComparer.OrdinalIgnoreCase); internal static bool MaterialSourcesLoaded; internal static bool MaterialSourcesLoading; internal static readonly Dictionary VerifiedSourceMaterials = new Dictionary(StringComparer.OrdinalIgnoreCase); private static float _microSplatRetryTime = float.MinValue; private static int _microSplatBuildGen = 0; public static bool IsLoadingMaterialSources => MaterialSourcesLoading; internal static void SortMaterialList() { if (MaterialNames.Count > 2) { List<(string, string)> list = new List<(string, string)>(MaterialNames.Count - 1); for (int i = 1; i < MaterialNames.Count; i++) { list.Add((MaterialNames[i], MaterialLabels[i])); } list.Sort(((string name, string label) a, (string name, string label) b) => string.Compare(a.label, b.label, StringComparison.OrdinalIgnoreCase)); for (int num = 0; num < list.Count; num++) { MaterialNames[num + 1] = list[num].Item1; MaterialLabels[num + 1] = list[num].Item2; } } } internal static void AddSceneVariantMaterials() { Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (var key in MaterialVariantTracker.SceneVariantMats.Keys) { dictionary.TryGetValue(key.baseName, out var value); dictionary[key.baseName] = value + 1; } foreach (KeyValuePair<(string, string), Material> sceneVariantMat in MaterialVariantTracker.SceneVariantMats) { string item = sceneVariantMat.Key.Item1; Material value2 = sceneVariantMat.Value; if (!((Object)(object)value2 == (Object)null)) { string name = ((Object)value2).name; if (!MaterialByName.ContainsKey(name) && dictionary.TryGetValue(item, out var value3) && value3 >= 2) { string text = (((Object)(object)value2.shader != (Object)null) ? ((Object)value2.shader).name : string.Empty); string item2 = (string.IsNullOrEmpty(text) ? name : (name + " [" + text + "]")); MaterialNames.Add(name); MaterialLabels.Add(item2); MaterialByName[name] = value2; } } } } internal static void EnsureMaterialList() { if (MicroSplatLayerMats.Count == 0) { float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup - _microSplatRetryTime >= 1f) { _microSplatRetryTime = realtimeSinceStartup; AddMicroSplatLayerMaterials(); if (MicroSplatLayerMats.Count > 0) { MaterialVariantTracker.MaterialsLoaded = false; } } } int count = MaterialVariantTracker.SceneVariantMats.Count; MaterialVariantTracker.CaptureSceneVariants(); if (MaterialVariantTracker.SceneVariantMats.Count != count) { MaterialVariantTracker.MaterialsLoaded = false; } if (MicroSplatLayerMats.Count > 0) { int microSplatBuildGen = _microSplatBuildGen; AddMicroSplatLayerMaterials(); if (_microSplatBuildGen != microSplatBuildGen) { MaterialVariantTracker.MaterialsLoaded = false; } } if (MaterialVariantTracker.MaterialsLoaded) { return; } MaterialVariantTracker.MaterialsLoaded = true; MaterialNames.Clear(); MaterialLabels.Clear(); MaterialByName.Clear(); MaterialNames.Add("(no override)"); MaterialLabels.Add("(no override)"); try { Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); if (val != null) { Dictionary> dictionary = new Dictionary>(StringComparer.OrdinalIgnoreCase); for (int i = 0; i < val.Length; i++) { Material val2 = val[i]; if (!((Object)(object)val2 == (Object)null) && !string.IsNullOrEmpty(((Object)val2).name) && !MaterialVariantTracker.IsOwnedMaterial(((Object)val2).GetInstanceID()) && !MaterialVariantTracker.ShouldHideMaterial(((Object)val2).name)) { if (!dictionary.TryGetValue(((Object)val2).name, out var value)) { value = new List(); dictionary[((Object)val2).name] = value; } value.Add(val2); } } Dictionary> dictionary2 = new Dictionary>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair> item5 in dictionary) { List value2 = item5.Value; List<(Material, string)> list = new List<(Material, string)>(); if (value2.Count == 1) { list.Add((value2[0], string.Empty)); } else { foreach (Material item6 in value2) { string textureSig = MaterialVariantTracker.GetTextureSig(item6); bool flag = false; foreach (var item7 in list) { string item = item7.Item2; if (string.Equals(item, textureSig, StringComparison.Ordinal)) { flag = true; break; } } if (!flag) { list.Add((item6, textureSig)); } } } dictionary2[item5.Key] = list; } Dictionary dictionary3 = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (var key in MaterialVariantTracker.SceneVariantMats.Keys) { dictionary3.TryGetValue(key.baseName, out var value3); dictionary3[key.baseName] = value3 + 1; } foreach (KeyValuePair> item8 in dictionary2) { List<(Material, string)> value4 = item8.Value; dictionary3.TryGetValue(item8.Key, out var value5); bool flag2 = value4.Count > 1 || value5 >= 2; foreach (var item9 in value4) { Material item2 = item9.Item1; string item3 = item9.Item2; string text = (flag2 ? (((Object)item2).name + " [" + MaterialPathCatalog.ComputeStableHash(item3) + "]") : ((Object)item2).name); if (!MaterialByName.ContainsKey(text)) { string text2 = (((Object)(object)item2.shader != (Object)null) ? ((Object)item2.shader).name : string.Empty); string item4 = (string.IsNullOrEmpty(text2) ? text : (text + " [" + text2 + "]")); MaterialNames.Add(text); MaterialLabels.Add(item4); MaterialByName[text] = item2; } } } } AddMicroSplatLayerMaterials(); AddSceneVariantMaterials(); if (MaterialNames.Count > 2) { List<(string, string)> list2 = new List<(string, string)>(MaterialNames.Count - 1); for (int j = 1; j < MaterialNames.Count; j++) { list2.Add((MaterialNames[j], MaterialLabels[j])); } list2.Sort(((string name, string label) a, (string name, string label) b) => string.Compare(a.label, b.label, StringComparison.OrdinalIgnoreCase)); for (int num = 0; num < list2.Count; num++) { MaterialNames[num + 1] = list2[num].Item1; MaterialLabels[num + 1] = list2[num].Item2; } } } catch (Exception ex) { MelonLogger.Warning("[PropMetadata] Material scan failed: " + ex.Message); } AddCatalogMaterialsToList(); EnsureMaterialSources(); } internal static bool BackfillMaterialSource(string materialName, string sourcePropId) { if (string.IsNullOrEmpty(materialName) || string.IsNullOrEmpty(sourcePropId)) { return false; } if (materialName.StartsWith("[MicroSplat]", StringComparison.Ordinal)) { return false; } if (!KnownMaterialSources.ContainsKey(materialName)) { KnownMaterialSources[materialName] = sourcePropId; } bool result = false; foreach (KeyValuePair item in PropMetadataStore._byId) { PropExtraInfo value = item.Value; if (!value.excluded && string.Equals(value.overrideMaterialId, materialName, StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(value.materialSourcePropId)) { value.materialSourcePropId = sourcePropId; result = true; } } return result; } internal static void EnsureMaterialSources() { if (!MaterialSourcesLoaded && !MaterialSourcesLoading) { MaterialSourcesLoaded = true; if (PropLibrary.IsInitialized) { PropMetadataStore.EnsureLoaded(); List candidates = CollectSourceCandidates(); bool anyLoaded; bool alreadySaved = RunSourcePass(candidates, out anyLoaded); List candidates2 = CollectSelfDiscoveryCandidates(); bool flag = RunSelfDiscoveryPass(candidates2); FinishMaterialSourcesScan(anyLoaded || flag, alreadySaved); } } } internal static IEnumerator EnsureMaterialSourcesCo() { if (MaterialSourcesLoaded || MaterialSourcesLoading) { yield break; } MaterialSourcesLoading = true; MaterialSourcesLoaded = true; yield return null; try { if (!PropLibrary.IsInitialized) { yield break; } PropMetadataStore.EnsureLoaded(); List sourceCandidates = CollectSourceCandidates(); bool anyLoaded = false; bool anyBackfilled = false; int sinceYield = 0; foreach (PropExtraInfo item in sourceCandidates) { if (RunOneSourceItem(item, out var loaded, out var backfilled)) { anyLoaded = anyLoaded || loaded; anyBackfilled = anyBackfilled || backfilled; } int num = sinceYield + 1; sinceYield = num; if (num >= 1) { sinceYield = 0; yield return null; } } if (anyBackfilled) { PropMetadataStore.Save(); } List selfCandidates = CollectSelfDiscoveryCandidates(); sinceYield = 0; foreach (PropExtraInfo item2 in selfCandidates) { if (RunOneSelfDiscoveryItem(item2)) { anyLoaded = true; } int num = sinceYield + 1; sinceYield = num; if (num >= 1) { sinceYield = 0; yield return null; } } FinishMaterialSourcesScan(anyLoaded, alreadySaved: false); } finally { MaterialSourcesLoading = false; } } public static void StartMaterialSourcesScanAsync() { if (!MaterialSourcesLoaded && !MaterialSourcesLoading) { MelonCoroutines.Start(EnsureMaterialSourcesCo()); } } internal static void MarkMaterialSourcesPending() { if (!MaterialSourcesLoading) { MaterialSourcesLoading = true; } } private static List CollectSourceCandidates() { List list = new List(); foreach (KeyValuePair item in PropMetadataStore._byId) { PropExtraInfo value = item.Value; if (!string.IsNullOrEmpty(value.overrideMaterialId) && !string.IsNullOrEmpty(value.materialSourcePropId)) { if (VerifiedSourceMaterials.TryGetValue(value.overrideMaterialId, out var value2) && (Object)(object)value2 != (Object)null) { MaterialByName[value.overrideMaterialId] = value2; } else { list.Add(value); } } } return list; } private static List CollectSelfDiscoveryCandidates() { List list = new List(); foreach (KeyValuePair item in PropMetadataStore._byId) { PropExtraInfo value = item.Value; if (!string.IsNullOrEmpty(value.overrideMaterialId) && !MaterialByName.ContainsKey(value.overrideMaterialId) && string.IsNullOrEmpty(value.materialSourcePropId) && !value.overrideMaterialId.StartsWith("[MicroSplat]", StringComparison.Ordinal)) { list.Add(value); } } return list; } private static bool RunSourcePass(List candidates, out bool anyLoaded) { bool flag = false; anyLoaded = false; foreach (PropExtraInfo candidate in candidates) { if (RunOneSourceItem(candidate, out var anyLoaded2, out var anyBackfilled)) { anyLoaded |= anyLoaded2; flag = flag || anyBackfilled; } } if (flag) { PropMetadataStore.Save(); } return flag; } private static Material FindPartMaterialByName(PropInfo info, string name) { if (info?.parts == null) { return null; } foreach (PropMeshPart part in info.parts) { if (part?.materials == null) { continue; } Material[] materials = part.materials; foreach (Material val in materials) { if ((Object)(object)val != (Object)null && string.Equals(((Object)val).name, name, StringComparison.OrdinalIgnoreCase)) { return val; } } } return null; } private static bool RunOneSourceItem(PropExtraInfo item, out bool anyLoaded, out bool anyBackfilled) { anyLoaded = false; anyBackfilled = false; if (VerifiedSourceMaterials.TryGetValue(item.overrideMaterialId, out var value) && (Object)(object)value != (Object)null) { MaterialByName[item.overrideMaterialId] = value; return false; } PropInfo propInfo = PropLibrary.FindById(item.materialSourcePropId); if (propInfo == null) { return false; } try { PropLibrary.LoadPropData(propInfo); anyLoaded = true; AddPartsToMaterialList(propInfo); Material val = FindPartMaterialByName(propInfo, item.overrideMaterialId); if ((Object)(object)val == (Object)null) { item.materialSourcePropId = string.Empty; anyBackfilled = true; return true; } if ((Object)(object)val.shader != (Object)null && ((Object)val.shader).name == "Standard" && (Object)(object)val.mainTexture == (Object)null) { item.materialSourcePropId = string.Empty; anyBackfilled = true; if (MaterialByName.TryGetValue(item.overrideMaterialId, out var value2) && (Object)(object)value2 != (Object)null && (Object)(object)value2.shader != (Object)null && ((Object)value2.shader).name == "Standard" && (Object)(object)value2.mainTexture == (Object)null) { MaterialByName.Remove(item.overrideMaterialId); } VerifiedSourceMaterials.Remove(item.overrideMaterialId); return true; } MaterialByName[item.overrideMaterialId] = val; VerifiedSourceMaterials[item.overrideMaterialId] = val; if (BackfillMaterialSource(item.overrideMaterialId, item.materialSourcePropId)) { anyBackfilled = true; } } catch (Exception) { } return true; } private static bool RunSelfDiscoveryPass(List candidates) { bool result = false; foreach (PropExtraInfo candidate in candidates) { if (RunOneSelfDiscoveryItem(candidate)) { result = true; } } return result; } private static bool RunOneSelfDiscoveryItem(PropExtraInfo item) { if (MaterialByName.TryGetValue(item.overrideMaterialId, out var value) && (Object)(object)value != (Object)null && (!((Object)(object)value.shader != (Object)null) || !(((Object)value.shader).name == "Standard") || !((Object)(object)value.mainTexture == (Object)null))) { return false; } PropInfo propInfo = PropLibrary.FindById(item.id); if (propInfo == null) { return false; } try { PropLibrary.LoadPropData(propInfo); AddPartsToMaterialList(propInfo); return true; } catch { return false; } } private static void FinishMaterialSourcesScan(bool anyLoaded, bool alreadySaved) { if (anyLoaded) { try { Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); if (val != null) { for (int i = 0; i < val.Length; i++) { Material val2 = val[i]; if (!((Object)(object)val2 == (Object)null) && !string.IsNullOrEmpty(((Object)val2).name) && !MaterialVariantTracker.ShouldHideMaterial(((Object)val2).name) && !MaterialByName.ContainsKey(((Object)val2).name)) { MaterialByName[((Object)val2).name] = val2; } } } } catch { } } AddCatalogMaterialsToList(); } internal static void AddCatalogMaterialsToList() { MaterialPathCatalog.IndexAllCatalogMaterials(); HashSet hashSet = new HashSet(MaterialNames, StringComparer.OrdinalIgnoreCase); bool flag = false; foreach (KeyValuePair materialCatalogPath in MaterialPathCatalog.MaterialCatalogPaths) { string key = materialCatalogPath.Key; if (!(key == "__IDX__") && !MaterialVariantTracker.ShouldHideMaterial(key) && hashSet.Add(key)) { MaterialNames.Add(key); MaterialLabels.Add(key); flag = true; } } if (flag) { SortMaterialList(); } } internal static string FindNativeFromParts(PropInfo info, string overrideMaterialName) { if (info == null) { return string.Empty; } if (!info.isLoaded) { PropLibrary.LoadPropData(info); } if (info.parts == null) { return string.Empty; } foreach (PropMeshPart part in info.parts) { if (part?.materials == null) { continue; } Material[] materials = part.materials; foreach (Material val in materials) { if (!((Object)(object)val == (Object)null) && !string.IsNullOrEmpty(((Object)val).name) && !string.Equals(((Object)val).name, overrideMaterialName, StringComparison.OrdinalIgnoreCase)) { return ((Object)val).name; } } } return string.Empty; } internal static void AddPartsToMaterialList(PropInfo info) { if (info?.parts == null) { return; } foreach (PropMeshPart part in info.parts) { if (part?.materials == null) { continue; } Material[] materials = part.materials; foreach (Material val in materials) { if (!((Object)(object)val == (Object)null) && !string.IsNullOrEmpty(((Object)val).name) && !MaterialVariantTracker.ShouldHideMaterial(((Object)val).name)) { if (!string.IsNullOrEmpty(info.id) && BackfillMaterialSource(((Object)val).name, info.id)) { PropMetadataStore.Save(); } if (!MaterialByName.ContainsKey(((Object)val).name)) { MaterialByName[((Object)val).name] = val; } } } } } private static Material FindMicroSplatBaseMaterial(out string[] controlProps) { controlProps = null; Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); Material val2 = null; int num = 0; for (int i = 0; i < val.Length; i++) { if (!((Object)(object)val2 == (Object)null)) { break; } Material val3 = val[i]; if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.shader == (Object)null) && !((Object)val3).name.StartsWith("[MicroSplat] Layer ", StringComparison.Ordinal) && ((Object)val3.shader).name.StartsWith("MicroSplat", StringComparison.OrdinalIgnoreCase)) { num++; if (val3.HasProperty("_CustomControl0")) { val2 = val3; } } } for (int j = 0; j < val.Length; j++) { if (!((Object)(object)val2 == (Object)null)) { break; } Material val4 = val[j]; if (!((Object)(object)val4 == (Object)null) && !((Object)(object)val4.shader == (Object)null) && !((Object)val4).name.StartsWith("[MicroSplat] Layer ", StringComparison.Ordinal) && ((Object)val4.shader).name.StartsWith("MicroSplat", StringComparison.OrdinalIgnoreCase)) { num++; val2 = val4; } } if ((Object)(object)val2 == (Object)null) { return null; } bool flag = val2.HasProperty("_CustomControl0"); List list = new List(); for (int k = 0; k <= 7; k++) { string text = (flag ? $"_CustomControl{k}" : $"_Control{k}"); if (val2.HasProperty(text)) { list.Add(text); } } if (list.Count == 0) { return null; } controlProps = list.ToArray(); return val2; } internal static void AddMicroSplatLayerMaterials() { //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Expected O, but got Unknown //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Expected O, but got Unknown //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Expected O, but got Unknown //IL_058d: 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_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) if (MicroSplatLayerMats.Count > 0) { bool flag = false; foreach (Material microSplatLayerMat in MicroSplatLayerMats) { if ((Object)(object)microSplatLayerMat == (Object)null) { flag = true; break; } } if (!flag) { { foreach (Material microSplatLayerMat2 in MicroSplatLayerMats) { if (!MaterialByName.ContainsKey(((Object)microSplatLayerMat2).name)) { MaterialNames.Add(((Object)microSplatLayerMat2).name); MaterialLabels.Add(((Object)microSplatLayerMat2).name); MaterialByName[((Object)microSplatLayerMat2).name] = microSplatLayerMat2; } } return; } } for (int i = 0; i < MicroSplatLayerMats.Count; i++) { string text = $"[MicroSplat] Layer {i}"; int num = MaterialNames.IndexOf(text); if (num >= 0) { MaterialNames.RemoveAt(num); MaterialLabels.RemoveAt(num); } MaterialByName.Remove(text); } MicroSplatLayerMats.Clear(); PropPreviewRenderer.InvalidateMicroSplatSpheres(); MsActiveControls.Clear(); MsBlankControl = null; MsControlProps = null; } try { string[] controlProps; Material val = FindMicroSplatBaseMaterial(out controlProps); if ((Object)(object)val == (Object)null) { BBLog.Msg("[PropMetadata] MicroSplat base material not found (terrain may not be loaded yet)."); return; } int num2 = 0; Il2CppArrayBase val2 = Resources.FindObjectsOfTypeAll(); for (int j = 0; j < val2.Length; j++) { Texture2DArray val3 = val2[j]; if ((Object)(object)val3 != (Object)null && string.Equals(((Object)val3).name, "MicroSplatConfig_diff_tarray", StringComparison.Ordinal)) { num2 = val3.depth; break; } } if (num2 == 0) { num2 = controlProps.Length * 4; } MsHasPerTexUV = val.HasProperty("_PerTexUVScaleRotation0"); BBLog.Msg($"[PropMetadata] MicroSplat base: '{((Object)val).name}' shader: '{((Object)val.shader).name}' controlSlots: {controlProps.Length} layers: {num2} hasPerTexUV: {MsHasPerTexUV}"); if (MsHasPerTexUV) { Vector4 vector = val.GetVector("_PerTexUVScaleRotation0"); BBLog.Msg($"[PropMetadata] _PerTexUVScaleRotation0 = ({vector.x:F4},{vector.y:F4},{vector.z:F4},{vector.w:F4})"); } MsControlProps = controlProps; MsBlankControl = new Texture2D(1, 1, (TextureFormat)4, false); MsBlankControl.SetPixel(0, 0, Color.clear); MsBlankControl.Apply(); ((Object)MsBlankControl).name = "MicroSplat_BlankControl"; for (int k = 0; k < num2; k++) { try { int num3 = k / 4; int num4 = k % 4; if (num3 >= controlProps.Length) { break; } Texture2D val4 = new Texture2D(1, 1, (TextureFormat)4, false); val4.SetPixel(0, 0, new Color((num4 == 0) ? 1f : 0f, (num4 == 1) ? 1f : 0f, (num4 == 2) ? 1f : 0f, (num4 == 3) ? 1f : 0f)); val4.Apply(); ((Object)val4).name = $"MicroSplat_SingleLayer_{k}"; MsActiveControls.Add(val4); Material val5 = new Material(val) { name = $"[MicroSplat] Layer {k}" }; for (int l = 0; l < controlProps.Length; l++) { val5.SetTexture(controlProps[l], (Texture)(object)MsBlankControl); } val5.SetTexture(controlProps[num3], (Texture)(object)val4); if (MsHasPerTexUV) { string text2 = $"_PerTexUVScaleRotation{k}"; Vector4 vector2 = val.GetVector(text2); val5.SetVector(text2, new Vector4(vector2.x * 8f, vector2.y * 8f, vector2.z, vector2.w)); } MicroSplatLayerMats.Add(val5); MaterialNames.Add(((Object)val5).name); MaterialLabels.Add(((Object)val5).name); MaterialByName[((Object)val5).name] = val5; continue; } catch { continue; } } if (MicroSplatLayerMats.Count > 0) { _microSplatBuildGen++; } else { MelonLogger.Warning("[BB:MicroSplat] Base material found but no layer materials could be created."); } } catch (Exception ex) { MelonLogger.Warning("[PropMetadata] MicroSplat layer material creation failed: " + ex.Message); } } public static void RefreshMicroSplatLayerMaterials() { //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) if (MicroSplatLayerMats.Count == 0 || MsControlProps == null) { BBLog.Msg($"[PropMetadata] RefreshMicroSplatLayerMaterials: skipped (MicroSplatLayerMats.Count={MicroSplatLayerMats.Count}, MsControlProps={((MsControlProps == null) ? "null" : "set")})"); return; } string[] controlProps; Material val = FindMicroSplatBaseMaterial(out controlProps); if ((Object)(object)val == (Object)null) { BBLog.Msg("[PropMetadata] RefreshMicroSplatLayerMaterials: no MicroSplat base material found."); return; } for (int i = 0; i < MicroSplatLayerMats.Count; i++) { Material val2 = MicroSplatLayerMats[i]; if ((Object)(object)val2 == (Object)null) { continue; } string name = ((Object)val2).name; val2.CopyPropertiesFromMaterial(val); ((Object)val2).name = name; int num = i / 4; if (num < MsControlProps.Length) { for (int j = 0; j < MsControlProps.Length; j++) { val2.SetTexture(MsControlProps[j], (Texture)(object)MsBlankControl); } val2.SetTexture(MsControlProps[num], (Texture)(object)MsActiveControls[i]); if (MsHasPerTexUV) { string text = $"_PerTexUVScaleRotation{i}"; Vector4 vector = val.GetVector(text); val2.SetVector(text, new Vector4(vector.x * 8f, vector.y * 8f, vector.z, vector.w)); } } } BBLog.Msg($"[PropMetadata] Refreshed {MicroSplatLayerMats.Count} MicroSplat layer materials."); } public static void ApplyMaterialOverridesToRoot(string propId, GameObject root) { PropMetadataStore.EnsureLoaded(); if (string.IsNullOrEmpty(propId) || (Object)(object)root == (Object)null || !PropMetadataStore._byId.TryGetValue(propId, out var value)) { return; } EnsureMaterialList(); AddMicroSplatLayerMaterials(); List perSlotMaterialOverrides = value.perSlotMaterialOverrides; if (perSlotMaterialOverrides != null && perSlotMaterialOverrides.Count > 0) { Il2CppArrayBase componentsInChildren = root.GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } for (int i = 0; i < perSlotMaterialOverrides.Count; i++) { string text = perSlotMaterialOverrides[i]; if (string.IsNullOrEmpty(text) || string.Equals(text, "(no override)", StringComparison.OrdinalIgnoreCase)) { continue; } Material val = ResolveMaterial(text, value.materialSourcePropId); if ((Object)(object)val == (Object)null) { MelonLogger.Warning($"[PropMaterial] FAIL \"{propId}\" slot={i} override=\"{text}\" source=\"{value.materialSourcePropId}\" inByName={MaterialByName.ContainsKey(text)} inVerified={VerifiedSourceMaterials.ContainsKey(text)}"); continue; } if ((Object)(object)val.shader != (Object)null && ((Object)val.shader).name == "Standard" && (Object)(object)val.mainTexture == (Object)null) { MelonLogger.Warning($"[PropMaterial] SKIP \"{propId}\" slot={i} override=\"{text}\" source=\"{value.materialSourcePropId}\" — Standard/no-texture placeholder, keeping native material"); MaterialByName.Remove(text); VerifiedSourceMaterials.Remove(text); continue; } for (int j = 0; j < componentsInChildren.Length; j++) { Renderer val2 = componentsInChildren[j]; if ((Object)(object)val2 == (Object)null) { continue; } Il2CppReferenceArray val3 = val2.sharedMaterials; if (val3 == null) { val3 = Il2CppReferenceArray.op_Implicit((Material[])(object)new Material[0]); } if (i >= ((Il2CppArrayBase)(object)val3).Length) { Material[] array = (Material[])(object)new Material[i + 1]; for (int k = 0; k < ((Il2CppArrayBase)(object)val3).Length; k++) { array[k] = ((Il2CppArrayBase)(object)val3)[k]; } val3 = Il2CppReferenceArray.op_Implicit(array); } ((Il2CppArrayBase)(object)val3)[i] = val; val2.sharedMaterials = val3; } } return; } string overrideMaterialId = value.overrideMaterialId; if (string.IsNullOrEmpty(overrideMaterialId) || string.Equals(overrideMaterialId, "(no override)", StringComparison.OrdinalIgnoreCase)) { return; } Material val4 = ResolveMaterial(overrideMaterialId, value.materialSourcePropId); if ((Object)(object)val4 == (Object)null) { bool value2 = MaterialByName.ContainsKey(overrideMaterialId); bool value3 = VerifiedSourceMaterials.ContainsKey(overrideMaterialId); MelonLogger.Warning($"[PropMaterial] FAIL \"{propId}\" override=\"{overrideMaterialId}\" source=\"{value.materialSourcePropId}\" inByName={value2} inVerified={value3}"); return; } if ((Object)(object)val4.shader != (Object)null && ((Object)val4.shader).name == "Standard" && (Object)(object)val4.mainTexture == (Object)null) { MelonLogger.Warning($"[PropMaterial] SKIP \"{propId}\" override=\"{overrideMaterialId}\" source=\"{value.materialSourcePropId}\" — Standard/no-texture placeholder, keeping native material"); MaterialByName.Remove(overrideMaterialId); VerifiedSourceMaterials.Remove(overrideMaterialId); return; } Il2CppArrayBase componentsInChildren2 = root.GetComponentsInChildren(true); if (componentsInChildren2 == null || componentsInChildren2.Length == 0) { return; } for (int l = 0; l < componentsInChildren2.Length; l++) { Renderer val5 = componentsInChildren2[l]; if (!((Object)(object)val5 == (Object)null)) { int num = 1; Il2CppReferenceArray sharedMaterials = val5.sharedMaterials; if (sharedMaterials != null && ((Il2CppArrayBase)(object)sharedMaterials).Length > 0) { num = ((Il2CppArrayBase)(object)sharedMaterials).Length; } Material[] array2 = (Material[])(object)new Material[num]; for (int m = 0; m < num; m++) { array2[m] = val4; } val5.sharedMaterials = Il2CppReferenceArray.op_Implicit(array2); } } } public static void ReapplyAllMaterialOverrides() { LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { return; } foreach (LevelEditorObject @object in instance.Objects) { if ((Object)(object)@object == (Object)null) { continue; } GameObject gameObject = ((Component)@object).gameObject; if ((Object)(object)gameObject == (Object)null) { continue; } ApplyMaterialOverridesToRoot(@object.addressableKey, gameObject); if (@object.materialConstructionId < 0) { continue; } MaterialConstructionEntry materialConstructionEntry = PropMetadataStore.FindMaterialConstructionById(@object.materialConstructionId); if (materialConstructionEntry == null || string.IsNullOrEmpty(materialConstructionEntry.materialName)) { continue; } Material val = ResolveMaterial(materialConstructionEntry.materialName, @object.addressableKey); if ((Object)(object)val == (Object)null) { continue; } Il2CppArrayBase componentsInChildren = gameObject.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Renderer val2 = componentsInChildren[i]; if (!((Object)(object)val2 == (Object)null)) { Il2CppReferenceArray sharedMaterials = val2.sharedMaterials; int num = ((sharedMaterials == null || ((Il2CppArrayBase)(object)sharedMaterials).Length <= 0) ? 1 : ((Il2CppArrayBase)(object)sharedMaterials).Length); Material[] array = (Material[])(object)new Material[num]; for (int j = 0; j < num; j++) { array[j] = val; } val2.sharedMaterials = Il2CppReferenceArray.op_Implicit(array); } } } } internal static string GetKnownMaterialSource(string materialName) { if (string.IsNullOrEmpty(materialName)) { return string.Empty; } string value; return KnownMaterialSources.TryGetValue(materialName, out value) ? value : string.Empty; } internal static Material ResolveMaterial(string matName, string sourcePropId = null) { if (string.IsNullOrEmpty(matName)) { return null; } bool flag = matName.LastIndexOf(" [", StringComparison.Ordinal) > 0 && matName.EndsWith("]", StringComparison.Ordinal); if (VerifiedSourceMaterials.TryGetValue(matName, out var value) && (Object)(object)value != (Object)null) { MaterialByName[matName] = value; return value; } if (MaterialVariantTracker.SceneCurrentByName.TryGetValue(matName, out var value2) && (Object)(object)value2 != (Object)null) { MaterialByName[matName] = value2; return value2; } if (MaterialByName.TryGetValue(matName, out var value3) && (Object)(object)value3 != (Object)null) { return value3; } if (MaterialVariantTracker.SceneVariantByDisplayName.TryGetValue(matName, out var value4) && (Object)(object)value4 != (Object)null) { MaterialByName[matName] = value4; return value4; } if (MaterialVariantTracker.SceneVariantByDisplayName.ContainsKey(matName)) { int num = matName.LastIndexOf(" [", StringComparison.Ordinal); string text = ((num > 0 && matName.EndsWith("]", StringComparison.Ordinal)) ? matName.Substring(0, num) : matName); if (MaterialByName.TryGetValue(text, out value3) && (Object)(object)value3 != (Object)null) { return value3; } value3 = MaterialPathCatalog.TryLoadMaterialByName(text, sourcePropId); if ((Object)(object)value3 != (Object)null && !MaterialByName.ContainsKey(text)) { MaterialByName[text] = value3; } return value3; } int num2 = matName.LastIndexOf(" [", StringComparison.Ordinal); if (num2 > 0 && matName.EndsWith("]", StringComparison.Ordinal)) { string b = matName.Substring(num2 + 2, matName.Length - num2 - 3); string text2 = matName.Substring(0, num2); try { Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); if (val != null) { for (int i = 0; i < val.Length; i++) { Material val2 = val[i]; if ((Object)(object)val2 == (Object)null || !string.Equals(((Object)val2).name, text2, StringComparison.OrdinalIgnoreCase) || MaterialVariantTracker.IsOwnedMaterial(((Object)val2).GetInstanceID())) { continue; } string textureSig = MaterialVariantTracker.GetTextureSig(val2); if (string.IsNullOrEmpty(textureSig)) { continue; } string a = MaterialPathCatalog.ComputeStableHash(textureSig); if (string.Equals(a, b, StringComparison.OrdinalIgnoreCase)) { MaterialByName[matName] = val2; if (!MaterialByName.ContainsKey(text2)) { MaterialByName[text2] = val2; } return val2; } } } } catch { } Material val3 = MaterialPathCatalog.TryLoadMaterialByName(matName, sourcePropId); if ((Object)(object)val3 != (Object)null) { MaterialByName[matName] = val3; if (!MaterialByName.ContainsKey(((Object)val3).name)) { MaterialByName[((Object)val3).name] = val3; } return val3; } if (MaterialByName.TryGetValue(text2, out value3) && (Object)(object)value3 != (Object)null) { return value3; } value3 = MaterialPathCatalog.TryLoadMaterialByName(text2, sourcePropId); if ((Object)(object)value3 != (Object)null) { if (!MaterialByName.ContainsKey(((Object)value3).name)) { MaterialByName[((Object)value3).name] = value3; } if (!MaterialByName.ContainsKey(text2)) { MaterialByName[text2] = value3; } } return value3; } value3 = MaterialPathCatalog.TryLoadMaterialByName(matName, sourcePropId); if ((Object)(object)value3 == (Object)null) { return null; } if (!MaterialByName.ContainsKey(((Object)value3).name)) { MaterialByName[((Object)value3).name] = value3; } if (!string.Equals(((Object)value3).name, matName, StringComparison.OrdinalIgnoreCase) && !MaterialByName.ContainsKey(matName)) { MaterialByName[matName] = value3; } return value3; } public static Material TryGetMaterialByName(string name) { if (string.IsNullOrEmpty(name)) { return null; } if (MaterialByName.TryGetValue(name, out var value) && (Object)(object)value != (Object)null) { return value; } if (MaterialVariantTracker.SceneVariantByDisplayName.TryGetValue(name, out value) && (Object)(object)value != (Object)null) { return value; } return null; } public static void EnsureMaterialListLoaded() { EnsureMaterialList(); } public static Material ResolveMaterialByName(string name) { return ResolveMaterial(name); } public static void InvalidateMaterialSources() { VerifiedSourceMaterials.Clear(); MaterialSourcesLoaded = false; MaterialSourcesLoading = true; EnsureMaterialList(); MaterialSourcesLoading = false; StartMaterialSourcesScanAsync(); } public static void InvalidateMaterialSourcesSync() { VerifiedSourceMaterials.Clear(); MaterialSourcesLoaded = false; MaterialVariantTracker.InvalidateMaterialCache(); MaterialSourcesLoading = true; EnsureMaterialList(); MaterialSourcesLoading = false; EnsureMaterialSources(); StartMaterialSourcesScanAsync(); } } internal static class BaseMapController { public static bool BaseMapEnabled = true; public static bool DeferBrlOff; public static int DayWeatherPlaylist; public static int RestoreDayWeatherPlaylist; private static bool _weatherPlaylistOverridden; public static int WeatherPreset = -1; private static readonly List _hiddenAudioObjects = new List(); private static readonly List _hiddenRenderObjects = new List(); private static readonly List _hiddenPropRenderers = new List(); internal static Renderer[] _brlRendererCache = Array.Empty(); internal static Light[] _brlLightCache = Array.Empty(); internal static bool[] _brlLightOrigStates = Array.Empty(); private static readonly List _disabledTerrainComponents = new List(); private static readonly List _disabledTerrainColliders = new List(); private static readonly HashSet _scannedChunkIds = new HashSet(); private static readonly List _suppressedWaterObjects = new List(); private static readonly List _disabledPropColliders = new List(); private static readonly List _disabledPropCollidersOrigState = new List(); private static readonly List _hiddenLights = new List(); private static readonly List _hiddenLightsOrigState = new List(); private static readonly List _disabledLightControllers = new List(); private static readonly Dictionary _propSnowCloneByOriginal = new Dictionary(); private static readonly HashSet _propSnowClones = new HashSet(); private static readonly HashSet _snowKeywordClones = new HashSet(); private static readonly Dictionary _snowAmountClones = new Dictionary(); private static float _nextLightSweepTime; public static int DayWeatherPlaylistCount => ((Object)(object)Menu.me != (Object)null && Menu.me.campfireDatas != null) ? ((Il2CppArrayBase)(object)Menu.me.campfireDatas).Length : 0; [HideFromIl2Cpp] internal static void SetEditorPropsSnowDisabled(bool disable) { //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: 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_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) if (disable) { GameObject propsContainer = LevelEditorManager.PropsContainer; if ((Object)(object)propsContainer == (Object)null) { return; } int num = 0; foreach (Renderer componentsInChild in propsContainer.GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild == (Object)null) { continue; } Il2CppReferenceArray sharedMaterials = componentsInChild.sharedMaterials; bool flag = false; for (int i = 0; i < ((Il2CppArrayBase)(object)sharedMaterials).Length; i++) { Material val = ((Il2CppArrayBase)(object)sharedMaterials)[i]; if ((Object)(object)val == (Object)null || _propSnowClones.Contains(val)) { continue; } if (!_propSnowCloneByOriginal.TryGetValue(val, out var value)) { bool flag2 = val.IsKeywordEnabled("_SNOW"); bool flag3 = !val.HasProperty("_SnowMode") && val.HasProperty("_SnowAmount"); if (!flag2 && !flag3) { continue; } value = new Material(val) { name = ((Object)val).name }; _propSnowCloneByOriginal[val] = value; _propSnowClones.Add(value); if (flag2) { _snowKeywordClones.Add(value); } if (flag3) { float item = val.GetFloat("_SnowAmount"); Vector4 item2 = (Vector4)(val.HasProperty("_SnowHeightAngleRange") ? val.GetVector("_SnowHeightAngleRange") : default(Vector4)); _snowAmountClones[value] = (item, item2); } } ((Il2CppArrayBase)(object)sharedMaterials)[i] = value; flag = true; num++; } if (flag) { componentsInChild.sharedMaterials = sharedMaterials; } } foreach (Material snowKeywordClone in _snowKeywordClones) { snowKeywordClone.DisableKeyword("_SNOW"); } foreach (KeyValuePair snowAmountClone in _snowAmountClones) { Vector4 item3 = snowAmountClone.Value.Item2; snowAmountClone.Key.SetFloat("_SnowAmount", 0f); if (snowAmountClone.Key.HasProperty("_SnowHeightAngleRange")) { snowAmountClone.Key.SetVector("_SnowHeightAngleRange", new Vector4(1000000f, 1f, item3.z, item3.w)); } } BBLog.Msg($"[BaseMap] suppressed snow on {_snowKeywordClones.Count} keyword + {_snowAmountClones.Count} _SnowAmount clone(s), {num} renderer slot(s) repointed"); return; } foreach (Material snowKeywordClone2 in _snowKeywordClones) { snowKeywordClone2.EnableKeyword("_SNOW"); } foreach (KeyValuePair snowAmountClone2 in _snowAmountClones) { var (num2, val2) = snowAmountClone2.Value; snowAmountClone2.Key.SetFloat("_SnowAmount", num2); if (snowAmountClone2.Key.HasProperty("_SnowHeightAngleRange")) { snowAmountClone2.Key.SetVector("_SnowHeightAngleRange", val2); } } BBLog.Msg($"[BaseMap] restored snow on {_snowKeywordClones.Count} keyword + {_snowAmountClones.Count} _SnowAmount clone(s)"); } private static IEnumerable AllSceneRoots() { for (int i = 0; i < SceneManager.sceneCount; i++) { Scene sceneAt = SceneManager.GetSceneAt(i); foreach (GameObject item in (Il2CppArrayBase)(object)((Scene)(ref sceneAt)).GetRootGameObjects()) { yield return item; } } } private static bool HasCameraComponent(GameObject go) { foreach (Component componentsInChild in go.GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild == (Object)null) { continue; } try { string name = ((MemberInfo)((Object)componentsInChild).GetIl2CppType()).Name; if (name.Contains("Camera") || name.Contains("Cinemachine") || name.Contains("FlyCam") || name.Contains("PlayerMovement")) { return true; } } catch { } } return false; } private static void HidePropRenderers(GameObject go) { foreach (Renderer componentsInChild in go.GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild != (Object)null && componentsInChild.enabled) { componentsInChild.enabled = false; _hiddenPropRenderers.Add(componentsInChild); } } foreach (Collider componentsInChild2 in go.GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild2 == (Object)null || componentsInChild2.isTrigger) { continue; } try { if (((MemberInfo)((Object)componentsInChild2).GetIl2CppType()).Name == "TerrainCollider") { continue; } } catch { } _disabledPropCollidersOrigState.Add(componentsInChild2.enabled); componentsInChild2.enabled = false; _disabledPropColliders.Add(componentsInChild2); } foreach (Light componentsInChild3 in go.GetComponentsInChildren(true)) { HideLight(componentsInChild3); } } private static void HideLight(Light light) { if (!((Object)(object)light == (Object)null)) { _hiddenLightsOrigState.Add(((Behaviour)light).enabled); ((Behaviour)light).enabled = false; _hiddenLights.Add(light); DisableLightControllers(light); } } private static void DisableLightControllers(Light light) { Transform val = ((Component)light).transform; int num = 0; while ((Object)(object)val != (Object)null && num < 3) { foreach (MonoBehaviour component in ((Component)val).gameObject.GetComponents()) { if ((Object)(object)component == (Object)null || !((Behaviour)component).enabled) { continue; } try { string name = ((MemberInfo)((Object)component).GetIl2CppType()).Name; if (name.Contains("PointAtPlayer") || name.Contains("Beacon")) { ((Behaviour)component).enabled = false; _disabledLightControllers.Add(component); } } catch { } } val = val.parent; num++; } } private static bool HasOwnCameraComponent(GameObject go) { foreach (Component component in go.GetComponents()) { if ((Object)(object)component == (Object)null) { continue; } try { string name = ((MemberInfo)((Object)component).GetIl2CppType()).Name; if (name.Contains("Camera") || name.Contains("Cinemachine") || name.Contains("FlyCam") || name.Contains("PlayerMovement")) { return true; } } catch { } } return false; } private static void HideNonCameraSubtree(GameObject go) { if ((Object)(object)go == (Object)null) { return; } BestRegionLoader me = BestRegionLoader.me; if (((Object)(object)me != (Object)null && (Object)(object)go == (Object)(object)((Component)me).gameObject) || (Object)(object)go == (Object)(object)LevelEditorManager.PropsContainer || ((Object)go).name.StartsWith("NateClone") || HasOwnCameraComponent(go)) { return; } if (HasCameraComponent(go)) { for (int i = 0; i < go.transform.childCount; i++) { HideNonCameraSubtree(((Component)go.transform.GetChild(i)).gameObject); } } else { HidePropRenderers(go); } } private static void SetRenderObjectsActive(bool enabled, List tracked, params string[] typeFragments) { if (!enabled) { tracked.Clear(); { foreach (GameObject item in AllSceneRoots()) { foreach (MonoBehaviour componentsInChild in item.GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild == (Object)null) { continue; } try { string name = ((MemberInfo)((Object)componentsInChild).GetIl2CppType()).Name; foreach (string value in typeFragments) { if (name.Contains(value)) { GameObject gameObject = ((Component)componentsInChild).gameObject; if (gameObject.activeSelf && !tracked.Contains(gameObject) && !HasCameraComponent(gameObject)) { BBLog.Msg($"[BaseMap] SetActive(false) on '{((Object)gameObject).name}' ({name})"); gameObject.SetActive(false); tracked.Add(gameObject); } break; } } } catch { } } } return; } } foreach (GameObject item2 in tracked) { if ((Object)(object)item2 != (Object)null) { item2.SetActive(true); } } tracked.Clear(); } private static void ScanChunkTerrainAndProps(GameObject loadedChunk, bool disableNow) { foreach (MonoBehaviour componentsInChild in loadedChunk.GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild == (Object)null || !((Behaviour)componentsInChild).enabled) { continue; } try { string name = ((MemberInfo)((Object)componentsInChild).GetIl2CppType()).Name; if (name == "Terrain" || name.Contains("MicroSplat") || name.Contains("Terrain")) { _disabledTerrainComponents.Add(componentsInChild); if (disableNow) { ((Behaviour)componentsInChild).enabled = false; } } } catch { } } foreach (Collider componentsInChild2 in loadedChunk.GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild2 == (Object)null || !componentsInChild2.enabled) { continue; } try { if (((MemberInfo)((Object)componentsInChild2).GetIl2CppType()).Name == "TerrainCollider") { _disabledTerrainColliders.Add(componentsInChild2); if (disableNow) { componentsInChild2.enabled = false; } } } catch { } } HidePropRenderers(loadedChunk); } public static void RescanLoadedChunksForBaseMapOff() { if (BaseMapEnabled) { return; } BestRegionLoader me = BestRegionLoader.me; if (((me != null) ? me.chunkMap : null) == null || me.off) { return; } foreach (ChunkCell item in (Il2CppArrayBase)(object)me.chunkMap) { if (!((Object)(object)((item != null) ? item.loadedChunk : null) == (Object)null) && _scannedChunkIds.Add(((Object)item.loadedChunk).GetInstanceID())) { ScanChunkTerrainAndProps(item.loadedChunk, disableNow: true); } } } public static void SetBaseMapEnabled(bool enabled, bool captureRestoreChapter = true, bool deferBrlOff = false) { BBLog.Msg($"[BaseMap] SetBaseMapEnabled({enabled}) — start"); BaseMapEnabled = enabled; ApplyDayWeatherPlaylistOverride(enabled, captureRestoreChapter); SetEditorPropsSnowDisabled(!enabled); BestRegionLoader me = BestRegionLoader.me; BBLog.Msg("[BaseMap] brl=" + (((Object)(object)me != (Object)null) ? "found" : "null")); if (!enabled) { _hiddenPropRenderers.Clear(); _hiddenLights.Clear(); _hiddenLightsOrigState.Clear(); _disabledLightControllers.Clear(); } if (enabled) { if ((Object)(object)me != (Object)null) { me.off = false; } BBLog.Msg("[BaseMap] brl.off=false done"); foreach (MonoBehaviour disabledTerrainComponent in _disabledTerrainComponents) { if ((Object)(object)disabledTerrainComponent != (Object)null) { ((Behaviour)disabledTerrainComponent).enabled = true; } } _disabledTerrainComponents.Clear(); foreach (Collider disabledTerrainCollider in _disabledTerrainColliders) { if ((Object)(object)disabledTerrainCollider != (Object)null) { disabledTerrainCollider.enabled = true; } } _disabledTerrainColliders.Clear(); _scannedChunkIds.Clear(); for (int i = 0; i < _disabledPropColliders.Count; i++) { if ((Object)(object)_disabledPropColliders[i] != (Object)null) { _disabledPropColliders[i].enabled = _disabledPropCollidersOrigState[i]; } } _disabledPropColliders.Clear(); _disabledPropCollidersOrigState.Clear(); Renderer[] brlRendererCache = _brlRendererCache; foreach (Renderer val in brlRendererCache) { if ((Object)(object)val != (Object)null) { val.enabled = true; } } _brlRendererCache = Array.Empty(); for (int k = 0; k < _brlLightCache.Length; k++) { if ((Object)(object)_brlLightCache[k] != (Object)null) { ((Behaviour)_brlLightCache[k]).enabled = _brlLightOrigStates[k]; } } _brlLightCache = Array.Empty(); _brlLightOrigStates = Array.Empty(); foreach (MonoBehaviour disabledLightController in _disabledLightControllers) { if ((Object)(object)disabledLightController != (Object)null) { ((Behaviour)disabledLightController).enabled = true; } } _disabledLightControllers.Clear(); BBLog.Msg("[BaseMap] terrain/renderer/light restore done"); } else if ((Object)(object)me != (Object)null) { _brlRendererCache = Il2CppArrayBase.op_Implicit(((Component)me).GetComponentsInChildren(true)); BBLog.Msg($"[BaseMap] brl renderer cache gathered: {_brlRendererCache.Length}"); _brlLightCache = ((IEnumerable)((Component)me).GetComponentsInChildren(true)).Where((Light l) => (Object)(object)l != (Object)null).ToArray(); _brlLightOrigStates = _brlLightCache.Select((Light l) => ((Behaviour)l).enabled).ToArray(); Light[] brlLightCache = _brlLightCache; foreach (Light light in brlLightCache) { DisableLightControllers(light); } BBLog.Msg($"[BaseMap] brl light cache gathered: {_brlLightCache.Length}"); _disabledTerrainComponents.Clear(); _disabledTerrainColliders.Clear(); _disabledPropColliders.Clear(); _disabledPropCollidersOrigState.Clear(); _scannedChunkIds.Clear(); if (me.chunkMap != null) { BBLog.Msg($"[BaseMap] chunkMap count: {((Il2CppArrayBase)(object)me.chunkMap).Length}"); foreach (ChunkCell item in (Il2CppArrayBase)(object)me.chunkMap) { if (!((Object)(object)((item != null) ? item.loadedChunk : null) == (Object)null)) { _scannedChunkIds.Add(((Object)item.loadedChunk).GetInstanceID()); ScanChunkTerrainAndProps(item.loadedChunk, disableNow: false); } } } BBLog.Msg($"[BaseMap] terrain components gathered: {_disabledTerrainComponents.Count}, terrain colliders: {_disabledTerrainColliders.Count}, prop colliders: {_disabledPropColliders.Count}"); } if (!enabled) { int num2 = 0; foreach (GameObject item2 in AllSceneRoots()) { num2++; BBLog.Msg($"[BaseMap] scanning root #{num2} '{((Object)item2).name}'"); int count = _hiddenPropRenderers.Count; int count2 = _hiddenLights.Count; HideNonCameraSubtree(item2); BBLog.Msg($"[BaseMap] hid {_hiddenPropRenderers.Count - count} renderers, {_hiddenLights.Count - count2} lights on '{((Object)item2).name}'"); } BBLog.Msg($"[BaseMap] hid {_hiddenPropRenderers.Count} renderers, {_hiddenLights.Count} lights across {num2} scene roots"); } else { foreach (Renderer hiddenPropRenderer in _hiddenPropRenderers) { if ((Object)(object)hiddenPropRenderer != (Object)null) { hiddenPropRenderer.enabled = true; } } _hiddenPropRenderers.Clear(); for (int num3 = 0; num3 < _hiddenLights.Count; num3++) { if ((Object)(object)_hiddenLights[num3] != (Object)null) { ((Behaviour)_hiddenLights[num3]).enabled = _hiddenLightsOrigState[num3]; } } _hiddenLights.Clear(); _hiddenLightsOrigState.Clear(); BBLog.Msg("[BaseMap] restored prop renderers and lights"); } SetRenderObjectsActive(enabled, _hiddenRenderObjects, "TVE", "GPUInstancer"); BBLog.Msg("[BaseMap] SetRenderObjectsActive done"); GameObject val2 = GameObject.Find("GlobalObjectParent"); if ((Object)(object)val2 != (Object)null && !enabled) { for (int num4 = 0; num4 < val2.transform.childCount; num4++) { GameObject gameObject = ((Component)val2.transform.GetChild(num4)).gameObject; if (!HasCameraComponent(gameObject)) { int count3 = _hiddenPropRenderers.Count; HidePropRenderers(gameObject); BBLog.Msg($"[BaseMap] GOP child '{((Object)gameObject).name}' hid {_hiddenPropRenderers.Count - count3} renderers"); } } } BBLog.Msg("[BaseMap] GlobalObjectParent done"); PlayerMovement me2 = PlayerMovement.me; if ((Object)(object)me2 != (Object)null) { if (!enabled) { _suppressedWaterObjects.Clear(); IEnumerable enumerable = ((IEnumerable)(me2.waterObjects ?? Il2CppReferenceArray.op_Implicit(Array.Empty()))).Concat((IEnumerable)(me2.footWaterObjs ?? Il2CppReferenceArray.op_Implicit(Array.Empty()))); foreach (WaterObject item3 in enumerable) { if ((Object)(object)item3 == (Object)null || !item3.calculateWaterHeights) { continue; } item3.calculateWaterHeights = false; if (item3.WaterHeights.IsCreated) { for (int num5 = 0; num5 < item3.WaterHeights.Length; num5++) { item3.WaterHeights[num5] = -10000f; } } _suppressedWaterObjects.Add(item3); } BBLog.Msg($"[BaseMap] suppressed {_suppressedWaterObjects.Count} player water objects"); } else { foreach (WaterObject suppressedWaterObject in _suppressedWaterObjects) { if ((Object)(object)suppressedWaterObject != (Object)null) { suppressedWaterObject.calculateWaterHeights = true; } } _suppressedWaterObjects.Clear(); BBLog.Msg("[BaseMap] restored player water objects"); } } GameObject obj = GameObject.Find("BigManagerPrefab"); object obj2; if (obj == null) { obj2 = null; } else { Transform obj3 = obj.transform.Find("CrestWaterRenderer"); obj2 = ((obj3 != null) ? ((Component)obj3).gameObject : null); } GameObject val3 = (GameObject)obj2; if ((Object)(object)val3 != (Object)null) { val3.SetActive(enabled); BBLog.Msg($"[BaseMap] CrestWaterRenderer SetActive({enabled})"); } if (!enabled) { _hiddenAudioObjects.Clear(); string[] array = new string[2] { "Arranger", "Gimbal" }; foreach (string text in array) { GameObject val4 = GameObject.Find(text); if ((Object)(object)val4 != (Object)null && !HasCameraComponent(val4)) { BBLog.Msg("[BaseMap] SetActive(false) on audio '" + text + "'"); val4.SetActive(false); _hiddenAudioObjects.Add(val4); } } } else { foreach (GameObject hiddenAudioObject in _hiddenAudioObjects) { if ((Object)(object)hiddenAudioObject != (Object)null) { hiddenAudioObject.SetActive(true); } } _hiddenAudioObjects.Clear(); } BBLog.Msg("[BaseMap] audio done"); if (!enabled) { foreach (MonoBehaviour disabledTerrainComponent2 in _disabledTerrainComponents) { if ((Object)(object)disabledTerrainComponent2 != (Object)null) { ((Behaviour)disabledTerrainComponent2).enabled = false; } } foreach (Collider disabledTerrainCollider2 in _disabledTerrainColliders) { if ((Object)(object)disabledTerrainCollider2 != (Object)null) { disabledTerrainCollider2.enabled = false; } } foreach (Collider disabledPropCollider in _disabledPropColliders) { if ((Object)(object)disabledPropCollider != (Object)null) { disabledPropCollider.enabled = false; } } Renderer[] brlRendererCache2 = _brlRendererCache; foreach (Renderer val5 in brlRendererCache2) { if ((Object)(object)val5 != (Object)null) { val5.enabled = false; } } Light[] brlLightCache2 = _brlLightCache; foreach (Light val6 in brlLightCache2) { if ((Object)(object)val6 != (Object)null) { ((Behaviour)val6).enabled = false; } } BBLog.Msg("[BaseMap] terrain/renderer/light disable done"); if ((Object)(object)me != (Object)null && !deferBrlOff) { me.off = true; } BBLog.Msg($"[BaseMap] brl.off=true done (deferred={deferBrlOff})"); _nextLightSweepTime = 0f; } BBLog.Msg($"[BaseMap] SetBaseMapEnabled({enabled}) — end"); } private static void SuppressNewlyEnabledLights() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) foreach (Light item in Resources.FindObjectsOfTypeAll()) { if ((Object)(object)item == (Object)null || !((Behaviour)item).enabled) { continue; } Scene scene = ((Component)item).gameObject.scene; if (((Scene)(ref scene)).IsValid() && !_hiddenLights.Contains(item) && !_brlLightCache.Contains(item) && !IsLightProtected(item)) { StringBuilder stringBuilder = new StringBuilder(((Object)((Component)item).gameObject).name); Transform parent = ((Component)item).transform.parent; while ((Object)(object)parent != (Object)null) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } BBLog.Msg($"[BaseMap] Hiding newly-enabled light: {stringBuilder}"); HideLight(item); } } } private static bool IsLightProtected(Light light) { Transform val = ((Component)light).transform; while ((Object)(object)val != (Object)null) { if ((Object)(object)((Component)val).gameObject == (Object)(object)LevelEditorManager.PropsContainer) { return true; } if (HasOwnCameraComponent(((Component)val).gameObject)) { return true; } val = val.parent; } return false; } internal static void SuppressHiddenWhileBaseMapOff() { Renderer[] brlRendererCache = _brlRendererCache; foreach (Renderer val in brlRendererCache) { if ((Object)(object)val != (Object)null && val.enabled) { val.enabled = false; } } Light[] brlLightCache = _brlLightCache; foreach (Light val2 in brlLightCache) { if ((Object)(object)val2 != (Object)null && ((Behaviour)val2).enabled) { ((Behaviour)val2).enabled = false; } } foreach (Light hiddenLight in _hiddenLights) { if ((Object)(object)hiddenLight != (Object)null && ((Behaviour)hiddenLight).enabled) { ((Behaviour)hiddenLight).enabled = false; } } foreach (Collider disabledPropCollider in _disabledPropColliders) { if ((Object)(object)disabledPropCollider != (Object)null && disabledPropCollider.enabled) { disabledPropCollider.enabled = false; } } foreach (MonoBehaviour disabledLightController in _disabledLightControllers) { if ((Object)(object)disabledLightController != (Object)null && ((Behaviour)disabledLightController).enabled) { ((Behaviour)disabledLightController).enabled = false; } } if (Time.unscaledTime >= _nextLightSweepTime) { _nextLightSweepTime = Time.unscaledTime + 0.5f; SuppressNewlyEnabledLights(); } } private static void ApplyDayWeatherPlaylistOverride(bool baseMapEnabled, bool captureRestoreChapter) { if ((Object)(object)Menu.me == (Object)null || Menu.me.campfireDatas == null || ((Il2CppArrayBase)(object)Menu.me.campfireDatas).Length == 0) { return; } if (!baseMapEnabled) { if (captureRestoreChapter && !_weatherPlaylistOverridden) { RestoreDayWeatherPlaylist = Menu.me.curChapter; } _weatherPlaylistOverridden = true; SetCurChapter(DayWeatherPlaylist); } else if (_weatherPlaylistOverridden) { _weatherPlaylistOverridden = false; SetCurChapter(RestoreDayWeatherPlaylist); } } private static void SetCurChapter(int index) { index = Mathf.Clamp(index, 0, ((Il2CppArrayBase)(object)Menu.me.campfireDatas).Length - 1); Menu.me.curChapter = index; } public static void SetDayWeatherPlaylist(int index) { DayWeatherPlaylist = index; if (!BaseMapEnabled && (Object)(object)Menu.me != (Object)null && Menu.me.campfireDatas != null && ((Il2CppArrayBase)(object)Menu.me.campfireDatas).Length > 0) { SetCurChapter(index); } } public static void SetWeatherPreset(int preset) { WeatherPreset = preset; if (!((Object)(object)Menu.me == (Object)null) && Menu.me.campfireDatas != null && ((Il2CppArrayBase)(object)Menu.me.campfireDatas).Length != 0) { if (preset >= 0) { SetCurChapter(preset); return; } int curChapter = ((SaveGod.theSave != null) ? Mathf.Clamp(SaveGod.theSave.lastCampfire, 0, ((Il2CppArrayBase)(object)Menu.me.campfireDatas).Length - 1) : 0); SetCurChapter(curChapter); } } public static void TickWeatherPreset() { if (WeatherPreset >= 0 && !((Object)(object)Menu.me == (Object)null) && Menu.me.campfireDatas != null && ((Il2CppArrayBase)(object)Menu.me.campfireDatas).Length != 0) { Menu.me.curChapter = Mathf.Clamp(WeatherPreset, 0, ((Il2CppArrayBase)(object)Menu.me.campfireDatas).Length - 1); } } public static void ApplyLoadedBaseMapState(bool baseMapOff, int dayWeatherPlaylist, int restoreChapter, bool deferBrlOff = false) { DayWeatherPlaylist = dayWeatherPlaylist; RestoreDayWeatherPlaylist = restoreChapter; _weatherPlaylistOverridden = false; SetBaseMapEnabled(!baseMapOff, captureRestoreChapter: false, deferBrlOff); } [HideFromIl2Cpp] internal static IEnumerator ApplyLoadedBaseMapStateDelayed(bool baseMapOff, int dayWeatherPlaylist, int restoreChapter) { while ((Object)(object)Menu.me != (Object)null && Menu.me.teleporting) { yield return null; } if (!baseMapOff) { ApplyLoadedBaseMapState(baseMapOff, dayWeatherPlaylist, restoreChapter); yield break; } DeferBrlOff = true; ApplyLoadedBaseMapState(baseMapOff, dayWeatherPlaylist, restoreChapter, deferBrlOff: true); for (int i = 0; i < 90; i++) { if (BaseMapEnabled) { break; } yield return null; RescanLoadedChunksForBaseMapOff(); } DeferBrlOff = false; BestRegionLoader brl = BestRegionLoader.me; if ((Object)(object)brl != (Object)null && !BaseMapEnabled) { brl.off = true; } } } internal static class MaterialPathCatalog { internal static readonly Dictionary MaterialCatalogPathsDict = new Dictionary(StringComparer.OrdinalIgnoreCase); internal static readonly Dictionary MaterialPathToKey = new Dictionary(StringComparer.OrdinalIgnoreCase); internal static bool CatalogIndexed; public static IReadOnlyDictionary MaterialCatalogPaths => MaterialCatalogPathsDict; public static string ComputeStableHash(string value) { uint num = 2166136261u; string text = value ?? ""; for (int i = 0; i < text.Length; i++) { num ^= text[i]; num *= 16777619; } return num.ToString("x8"); } public static Material TryLoadMaterialByName(string materialName) { return TryLoadMaterialByName(materialName, null); } public static Material TryLoadMaterialByName(string materialName, string sourcePropId) { if (string.IsNullOrEmpty(materialName)) { return null; } try { string text = materialName; while (text.EndsWith(" (Instance)", StringComparison.Ordinal)) { text = text.Substring(0, text.Length - " (Instance)".Length); } if (!MaterialCatalogPathsDict.TryGetValue(materialName, out var value) && !MaterialCatalogPathsDict.TryGetValue(text, out value)) { string path = Path.Combine(Application.streamingAssetsPath, "aa", "catalog.json"); if (!File.Exists(path)) { return null; } string text2 = File.ReadAllText(path); value = FindMaterialPath(text2, text); if (value == null) { int num = text2.IndexOf("\"m_KeyDataString\"", StringComparison.Ordinal); if (num >= 0) { int num2 = text2.IndexOf('"', num + 17) + 1; int num3 = text2.IndexOf('"', num2); if (num2 > 0 && num3 > num2) { string text3 = Encoding.UTF8.GetString(Convert.FromBase64String(text2.Substring(num2, num3 - num2))); value = FindMaterialPath(text3, text); } } } if (value == null) { return null; } MaterialCatalogPathsDict[text] = value; if (!string.Equals(text, materialName, StringComparison.Ordinal)) { MaterialCatalogPathsDict[materialName] = value; } SaveMaterialPathCache(); } AsyncOperationHandle val = Addressables.LoadAssetAsync(Object.op_Implicit(value)); Material val2 = val.WaitForCompletion(); if ((Object)(object)val2 != (Object)null) { BBLog.Msg("[PropLibrary] Loaded material \"" + text + "\" from catalog: " + value); } else { MelonLogger.Warning("[PropLibrary] Catalog path found but load returned null for \"" + text + "\": " + value); } return val2; } catch (Exception ex) { MelonLogger.Warning("[PropLibrary] TryLoadMaterialByName failed for \"" + materialName + "\": " + ex.Message); return null; } } private static void SaveMaterialPathCache() { try { string catalogPath = Path.Combine(Application.streamingAssetsPath, "aa", "catalog.json"); List<(string, string, string, string)> list = new List<(string, string, string, string)>(); foreach (PropInfo allProp in PropLibrary.AllProps) { if (allProp.IsGpui) { list.Add((allProp.displayName, allProp.id, allProp.visualPath ?? "", allProp.gpuiPrefabName ?? "")); } } PropLibrary.SaveGpuiCache(catalogPath, list); } catch (Exception ex) { MelonLogger.Warning("[PropLibrary] SaveMaterialPathCache failed: " + ex.Message); } } public static IReadOnlyList IndexAllCatalogMaterials() { if (CatalogIndexed) { return Array.Empty(); } CatalogIndexed = true; List list = new List(); try { string path = Path.Combine(Application.streamingAssetsPath, "aa", "catalog.json"); if (!File.Exists(path)) { return list; } string text = File.ReadAllText(path); string text2 = string.Empty; int num = text.IndexOf("\"m_KeyDataString\"", StringComparison.Ordinal); if (num >= 0) { int num2 = text.IndexOf('"', num + 17) + 1; int num3 = text.IndexOf('"', num2); if (num2 > 0 && num3 > num2) { try { text2 = Encoding.UTF8.GetString(Convert.FromBase64String(text.Substring(num2, num3 - num2))); } catch { } } } ScanStandaloneMatFiles(text, list, suffixedOnly: false); ScanStandaloneMatFiles(text2, list, suffixedOnly: false); ScanStandaloneMatFiles(text, list, suffixedOnly: true); ScanStandaloneMatFiles(text2, list, suffixedOnly: true); ScanSubAssets(text, list); ScanSubAssets(text2, list); MaterialCatalogPathsDict["__IDX__"] = "1"; SaveMaterialPathCache(); BBLog.Msg($"[PropLibrary] Full catalog material index built: {list.Count} material(s) found."); } catch (Exception ex) { MelonLogger.Warning("[PropLibrary] IndexAllCatalogMaterials failed: " + ex.Message); } return list; } private static bool TryStripUnityDupSuffix(string name, out string baseName) { int num = name.LastIndexOf('_'); if (num > 0) { bool flag = true; for (int i = num + 1; i < name.Length; i++) { if (!char.IsDigit(name[i])) { flag = false; break; } } if (flag && num + 1 < name.Length) { baseName = name.Substring(0, num); return true; } } baseName = name; return false; } private static void ScanStandaloneMatFiles(string text, List result, bool suffixedOnly) { if (string.IsNullOrEmpty(text)) { return; } int length = text.Length; int num = 0; while (num < length) { int num2 = text.IndexOf(".mat", num, StringComparison.OrdinalIgnoreCase); if (num2 < 0) { break; } int num3 = num2 + ".mat".Length; if (num3 < length && char.IsLetterOrDigit(text[num3])) { num = num3; continue; } int num4 = num2; while (num4 > 0 && text[num4 - 1] != '"' && text[num4 - 1] != 0 && text[num4 - 1] >= ' ') { num4--; } string text2 = text.Substring(num4, num3 - num4); if (!text2.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase)) { num = num3; continue; } if (MaterialPathToKey.ContainsKey(text2)) { num = num3; continue; } int num5 = text2.LastIndexOf('/'); if (num5 < 0) { num = num3; continue; } string text3 = text2.Substring(num5 + 1, text2.Length - num5 - 1 - ".mat".Length); if (text3.Length == 0) { num = num3; continue; } string baseName; bool flag = TryStripUnityDupSuffix(text3, out baseName); if (flag != suffixedOnly) { num = num3; continue; } string text4; if (flag && MaterialCatalogPathsDict.ContainsKey(baseName)) { text4 = baseName + " [" + ComputeStableHash(text2) + "]"; int num6 = 2; while (MaterialCatalogPathsDict.ContainsKey(text4)) { text4 = baseName + " [" + ComputeStableHash(text2 + num6++) + "]"; } } else { text4 = text3; int num7 = 2; while (MaterialCatalogPathsDict.ContainsKey(text4)) { text4 = text3 + " [" + ComputeStableHash(text2 + num7++) + "]"; } } MaterialCatalogPathsDict[text4] = text2; MaterialPathToKey[text2] = text4; result.Add(text4); num = num3; } } private static void ScanSubAssets(string text, List result) { if (string.IsNullOrEmpty(text)) { return; } int length = text.Length; int num = 0; while (num < length) { int num2 = text.IndexOf('[', num); if (num2 < 0) { break; } int num3 = text.IndexOf(']', num2 + 1); if (num3 < 0) { break; } string text2 = text.Substring(num2 + 1, num3 - num2 - 1); if (text2.Length >= 2 && text2.Length <= 100 && text2.IndexOf('/') < 0 && text2.IndexOf('\\') < 0) { int num4 = num2; while (num4 > 0 && text[num4 - 1] != '"' && text[num4 - 1] != 0 && text[num4 - 1] >= ' ') { num4--; } string text3 = text.Substring(num4, num3 - num4 + 1); if (text3.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase) && !MaterialPathToKey.ContainsKey(text3) && !MaterialCatalogPathsDict.ContainsKey(text2)) { MaterialCatalogPathsDict[text2] = text3; MaterialPathToKey[text3] = text2; result.Add(text2); } } num = num3 + 1; } } private static string FindMaterialPath(string text, string materialName) { string text2 = materialName; int num = 1; int num2 = materialName.LastIndexOf(' '); if (num2 > 0 && int.TryParse(materialName.Substring(num2 + 1), out var result) && result >= 2) { text2 = materialName.Substring(0, num2); num = result; } if (num >= 2) { string text3 = "/" + text2 + "_" + (num - 2) + ".mat"; int num3 = 0; while (num3 < text.Length) { int num4 = text.IndexOf(text3, num3, StringComparison.OrdinalIgnoreCase); if (num4 < 0) { break; } int num5 = num4 + text3.Length; int num6 = num4; while (num6 > 0 && text[num6 - 1] != '"' && text[num6 - 1] != 0 && text[num6 - 1] >= ' ') { num6--; } string text4 = text.Substring(num6, num5 - num6); if (text4.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase)) { return text4; } num3 = num5; } } string text5 = "/" + text2 + ".mat"; int num7 = 0; while (num7 < text.Length) { int num8 = text.IndexOf(text5, num7, StringComparison.OrdinalIgnoreCase); if (num8 < 0) { break; } int num9 = num8 + text5.Length; int num10 = num8; while (num10 > 0 && text[num10 - 1] != '"' && text[num10 - 1] != 0 && text[num10 - 1] >= ' ') { num10--; } string text6 = text.Substring(num10, num9 - num10); if (text6.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase)) { return text6; } num7 = num9; } if (num == 1) { string text7 = "[" + text2 + "]"; int num11 = 0; while (num11 < text.Length) { int num12 = text.IndexOf(text7, num11, StringComparison.OrdinalIgnoreCase); if (num12 < 0) { break; } int num13 = num12 + text7.Length; int num14 = num12; while (num14 > 0 && text[num14 - 1] != '"' && text[num14 - 1] != 0 && text[num14 - 1] >= ' ') { num14--; } string text8 = text.Substring(num14, num13 - num14); if (text8.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase)) { return text8; } num11 = num13; } } return null; } } internal static class GpuiPropScanner { internal static readonly HashSet GpuiScannedNames = new HashSet(StringComparer.OrdinalIgnoreCase); private static Dictionary _gpuiPlayerPaths; public static void ScanGpuiProps() { if (!PropLibrary.IsInitialized) { return; } string catalogPath = Path.Combine(Application.streamingAssetsPath, "aa", "catalog.json"); int num = PropLibrary.PrimitiveNames.Length; int num2 = 0; int num3 = 0; if (PropLibrary.TryLoadGpuiCache(catalogPath, out List<(string, string, string, string)> entries) && entries != null) { foreach (var (text, text2, visualPath, text3) in entries) { if (PropLibrary.TryParseGpuiIndex(text2, out var index)) { num3 = Math.Max(num3, index + 1); } string text4 = PropLibrary.BuildStableGpuiId(text, text3, visualPath); if (!string.Equals(text2, text4, StringComparison.Ordinal)) { PropLibrary._idAliases[text2] = text4; } if (!PropLibrary._byId.ContainsKey(text4)) { PropInfo propInfo = new PropInfo(text4, text) { gpuiIndex = num3++, visualPath = visualPath, gpuiPrefabName = text3, isLoaded = false, isInvalid = false }; PropLibrary._all.Insert(num++, propInfo); PropLibrary._byId[text4] = propInfo; GpuiScannedNames.Add(text); num2++; } } BBLog.Msg($"[PropLibrary] GPUI cache loaded: {entries.Count} props."); } GameObject[] array = PropLibrary.TryGetLoadedProps(); BBLog.Msg($"[PropLibrary] ScanGpuiProps: loadedProps count={((array != null) ? array.Length : (-1))}"); if (array == null || array.Length == 0) { PropMetadataStore.MigratePropIdsToCanonical(); if (num2 > 0) { PropLibrary.RebuildFiltered(); } return; } Dictionary dictionary = BuildGpuiVisualLookup(); int num4 = num3; foreach (GameObject val in array) { if ((Object)(object)val == (Object)null || (Object)(object)val.GetComponentInChildren() != (Object)null || (Object)(object)val.GetComponentInChildren() != (Object)null || !((Object)(object)val.GetComponentInChildren() != (Object)null)) { continue; } string text5 = PropLibrary.NormalizePropName(((Object)val).name); dictionary.TryGetValue(text5, out var value); if (value == null) { value = ""; } string name = ((Object)val).name; int num5 = num4++; string text6 = PropLibrary.BuildStableGpuiId(text5, name, value); if (!PropLibrary._byId.ContainsKey(text6)) { string text7 = $"gpui://{num5}"; if (!string.Equals(text7, text6, StringComparison.Ordinal)) { PropLibrary._idAliases[text7] = text6; } PropInfo propInfo2 = new PropInfo(text6, text5) { gpuiIndex = num5, visualPath = value, gpuiPrefabName = name, isLoaded = false, isInvalid = false }; GpuiScannedNames.Add(text5); PropLibrary._all.Insert(num++, propInfo2); PropLibrary._byId[text6] = propInfo2; num2++; } } Dictionary gpuiPlayerPaths = GetGpuiPlayerPaths(); int num6 = 0; foreach (KeyValuePair item in gpuiPlayerPaths) { string key = item.Key; if (string.IsNullOrEmpty(key)) { continue; } string text8 = PropLibrary.NormalizePropName(key); if (string.IsNullOrEmpty(text8)) { continue; } dictionary.TryGetValue(text8, out var value2); if (value2 == null) { value2 = ""; } int num7 = num4++; string text9 = PropLibrary.BuildStableGpuiId(text8, key, value2); if (!PropLibrary._byId.ContainsKey(text9)) { string text10 = $"gpui://{num7}"; if (!string.Equals(text10, text9, StringComparison.Ordinal)) { PropLibrary._idAliases[text10] = text9; } PropInfo propInfo3 = new PropInfo(text9, text8) { gpuiIndex = num7, visualPath = value2, gpuiPrefabName = key, isLoaded = false, isInvalid = false }; GpuiScannedNames.Add(text8); PropLibrary._all.Insert(num++, propInfo3); PropLibrary._byId[text9] = propInfo3; num2++; num6++; } } List<(string, string, string, string)> list = new List<(string, string, string, string)>(); foreach (PropInfo item2 in PropLibrary._all) { if (item2.IsGpui) { list.Add((item2.displayName, item2.id, item2.visualPath ?? "", item2.gpuiPrefabName ?? "")); } } PropLibrary.SaveGpuiCache(catalogPath, list); PropMetadataStore.MigratePropIdsToCanonical(); if (num2 > 0) { PropLibrary.RebuildFiltered(); } BBLog.Msg($"[PropLibrary] GPUI catalog backfill added: {num6} props."); BBLog.Msg($"[PropLibrary] GPUI scan complete: {num2} props added."); } private static Dictionary BuildGpuiVisualLookup() { Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); string path = Path.Combine(Application.streamingAssetsPath, "aa", "catalog.json"); if (!File.Exists(path)) { return dictionary; } try { string text = File.ReadAllText(path); AddVisualPathsToLookup(text, dictionary); int num = text.IndexOf("\"m_KeyDataString\"", StringComparison.Ordinal); if (num >= 0) { int num2 = text.IndexOf('"', num + 17) + 1; int num3 = text.IndexOf('"', num2); if (num2 > 0 && num3 > num2) { byte[] bytes = Convert.FromBase64String(text.Substring(num2, num3 - num2)); string text2 = Encoding.UTF8.GetString(bytes); AddVisualPathsToLookup(text2, dictionary); } } } catch (Exception ex) { MelonLogger.Warning("[PropLibrary] GPUI visual lookup build failed: " + ex.Message); } return dictionary; } private static void AddVisualPathsToLookup(string text, Dictionary lookup) { int num = 0; while (num < text.Length) { int num2 = text.IndexOf("Assets/_Props/", num, StringComparison.Ordinal); if (num2 < 0) { break; } int i; for (i = num2; i < text.Length; i++) { char c = text[i]; if (c == '"' || c == '\0' || c < ' ') { break; } } num = i + 1; string text2 = text.Substring(num2, i - num2); if (text2.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase)) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2); if (!fileNameWithoutExtension.EndsWith("_player", StringComparison.OrdinalIgnoreCase) && !PropLibrary.IsLowerLodVariant(text2) && !lookup.ContainsKey(fileNameWithoutExtension)) { lookup[fileNameWithoutExtension] = text2; } } } } internal static void ExtractPartsFromColliders(GameObject root, PropInfo info) { Il2CppArrayBase componentsInChildren = root.GetComponentsInChildren(true); Transform transform = root.transform; foreach (MeshCollider item in componentsInChildren) { if (!((Object)(object)item == (Object)null) && !((Object)(object)item.sharedMesh == (Object)null)) { PropLibrary.AddPart(info, item.sharedMesh, null, ((Component)item).transform, transform); } } } internal static Dictionary GetGpuiPlayerPaths() { if (_gpuiPlayerPaths != null) { return _gpuiPlayerPaths; } _gpuiPlayerPaths = new Dictionary(StringComparer.OrdinalIgnoreCase); try { string path = Path.Combine(Application.streamingAssetsPath, "aa", "catalog.json"); if (!File.Exists(path)) { return _gpuiPlayerPaths; } string text = File.ReadAllText(path); AddPlayerPathsToLookup(text, _gpuiPlayerPaths); int num = text.IndexOf("\"m_KeyDataString\"", StringComparison.Ordinal); if (num >= 0) { int num2 = text.IndexOf('"', num + 17) + 1; int num3 = text.IndexOf('"', num2); if (num2 > 0 && num3 > num2) { try { string text2 = Encoding.UTF8.GetString(Convert.FromBase64String(text.Substring(num2, num3 - num2))); AddPlayerPathsToLookup(text2, _gpuiPlayerPaths); } catch { } } } BBLog.Msg($"[PropLibrary] Built GPUI player-path lookup: {_gpuiPlayerPaths.Count} entries."); } catch (Exception ex) { MelonLogger.Warning("[PropLibrary] GetGpuiPlayerPaths failed: " + ex.Message); } return _gpuiPlayerPaths; } private static void AddPlayerPathsToLookup(string text, Dictionary lookup) { int num = 0; while (num < text.Length) { int num2 = text.IndexOf("Assets/_Props/", num, StringComparison.Ordinal); if (num2 < 0) { break; } int i; for (i = num2; i < text.Length; i++) { char c = text[i]; if (c == '"' || c == '\0' || c < ' ') { break; } } num = i + 1; string text2 = text.Substring(num2, i - num2); if (text2.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase)) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2); if (fileNameWithoutExtension.EndsWith("_player", StringComparison.OrdinalIgnoreCase) && !lookup.ContainsKey(fileNameWithoutExtension)) { lookup[fileNameWithoutExtension] = text2; } } } } } internal static class CatalogEnumerator { private static readonly string[] ExcludedAssetPrefixes = new string[18] { "Assets/Audio/", "Assets/BBitsy/", "Assets/CC_Assets/", "Assets/Character/", "Assets/Decals/", "Assets/ExternalPlugins/", "Assets/FX/", "Assets/Lod/", "Assets/Prefabs/Debug/", "Assets/Scripts/", "Assets/SlicedTerrain/", "Assets/TitleAreaAssets/", "Assets/_Props/Beacons/", "Assets/_Props/Bonfires/", "Assets/_Props/FX/", "Assets/_Props/Grasses/", "Assets/_Props/Rocks_TerrainMat/", "Assets/_Props/_PlayerProps/" }; internal static void LogCatalogBundleHint(string propId) { try { string path = Path.Combine(Application.streamingAssetsPath, "aa", "catalog.json"); if (!File.Exists(path)) { return; } string fileName = Path.GetFileName(propId); if (string.IsNullOrEmpty(fileName)) { return; } string text = File.ReadAllText(path); string text2 = ""; int num = text.IndexOf("\"m_KeyDataString\"", StringComparison.Ordinal); if (num >= 0) { int num2 = text.IndexOf('"', num + 17) + 1; int num3 = text.IndexOf('"', num2); if (num2 > 0 && num3 > num2) { try { text2 = Encoding.UTF8.GetString(Convert.FromBase64String(text.Substring(num2, num3 - num2))); } catch { } } } HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); HashSet hashSet2 = new HashSet(StringComparer.OrdinalIgnoreCase); string[] array = new string[2] { text, text2 }; foreach (string text3 in array) { if (string.IsNullOrEmpty(text3)) { continue; } int num4 = 0; while (num4 < text3.Length) { int num5 = text3.IndexOf(fileName, num4, StringComparison.OrdinalIgnoreCase); if (num5 < 0) { break; } num4 = num5 + 1; int num6 = Math.Max(0, num5 - 2048); int num7 = Math.Min(text3.Length, num5 + 2048); string text4 = text3.Substring(num6, num7 - num6); int num8 = 0; while (num8 < text4.Length) { int num9 = text4.IndexOf(".bundle", num8, StringComparison.OrdinalIgnoreCase); if (num9 < 0) { break; } int num10 = num9; while (num10 > 0 && text4[num10 - 1] != '"' && text4[num10 - 1] != '/' && text4[num10 - 1] != '\\' && text4[num10 - 1] > ' ') { num10--; } hashSet.Add(text4.Substring(num10, num9 - num10 + 7)); num8 = num9 + 7; } int num11 = 0; while (num11 < text4.Length) { int num12 = text4.IndexOf(".unity", num11, StringComparison.OrdinalIgnoreCase); if (num12 < 0) { break; } int num13 = num12; while (num13 > 0 && text4[num13 - 1] != '"' && text4[num13 - 1] > ' ') { num13--; } hashSet2.Add(text4.Substring(num13, num12 - num13 + 6)); num11 = num12 + 6; } } } if (hashSet2.Count > 0) { BBLog.Msg("[PropLibrary] Catalog hint for \"" + fileName + "\": scenes → " + string.Join(", ", hashSet2)); } else if (hashSet.Count > 0) { BBLog.Msg($"[PropLibrary] Catalog hint for \"{fileName}\": bundles → {string.Join(", ", hashSet.Take(5))} {((hashSet.Count > 5) ? $"(+{hashSet.Count - 5} more)" : "")}"); } else { BBLog.Msg("[PropLibrary] Catalog hint: \"" + fileName + "\" not found in catalog text."); } } catch (Exception ex) { MelonLogger.Warning("[PropLibrary] LogCatalogBundleHint failed: " + ex.Message); } } internal static void EnumerateFromCatalog() { string path = Path.Combine(Application.streamingAssetsPath, "aa", "catalog.json"); if (!File.Exists(path)) { return; } string text = File.ReadAllText(path); HashSet seen = new HashSet(StringComparer.OrdinalIgnoreCase); ScanTextForPaths(text, seen); int num = text.IndexOf("\"m_KeyDataString\"", StringComparison.Ordinal); if (num < 0) { return; } int num2 = text.IndexOf('"', num + 17) + 1; int num3 = text.IndexOf('"', num2); if (num2 <= 0 || num3 <= num2) { return; } try { byte[] bytes = Convert.FromBase64String(text.Substring(num2, num3 - num2)); string text2 = Encoding.UTF8.GetString(bytes); ScanTextForPaths(text2, seen); } catch { } } private static void ScanTextForPaths(string text, HashSet seen) { int num = 0; while (num < text.Length) { int num2 = text.IndexOf("Assets/", num, StringComparison.Ordinal); if (num2 < 0) { break; } int i; for (i = num2; i < text.Length; i++) { char c = text[i]; if (c == '"' || c == '\0' || c < ' ') { break; } } num = i + 1; string text2 = text.Substring(num2, i - num2); if ((text2.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase) || PropLibrary.IsMeshAssetPath(text2)) && !PropLibrary.IsLowerLodVariant(text2)) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2); if ((!text2.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase) || (!fileNameWithoutExtension.EndsWith("_player", StringComparison.OrdinalIgnoreCase) && !fileNameWithoutExtension.EndsWith("_Player", StringComparison.OrdinalIgnoreCase))) && !IsExcludedPath(text2) && seen.Add(text2)) { PropInfo propInfo = new PropInfo(text2, fileNameWithoutExtension); PropLibrary._all.Add(propInfo); PropLibrary._byId[text2] = propInfo; } } } } private static bool IsExcludedPath(string entry) { if (string.IsNullOrEmpty(entry)) { return false; } string text = entry.Replace('\\', '/'); if (text.IndexOf("imposter", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("impostor", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } string[] excludedAssetPrefixes = ExcludedAssetPrefixes; foreach (string value in excludedAssetPrefixes) { if (text.StartsWith(value, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } } internal static class PrimitiveMeshGen { public static Mesh BuildTorus(float majorRadius = 0.35f, float minorRadius = 0.15f, int segments = 24, int sides = 16) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); Vector3 val = default(Vector3); Vector3 val2 = default(Vector3); for (int i = 0; i <= segments; i++) { float num = (float)i / (float)segments; float num2 = num * (float)Math.PI * 2f; ((Vector3)(ref val))..ctor(Mathf.Cos(num2) * majorRadius, 0f, Mathf.Sin(num2) * majorRadius); ((Vector3)(ref val2))..ctor(Mathf.Cos(num2), 0f, Mathf.Sin(num2)); for (int j = 0; j <= sides; j++) { float num3 = (float)j / (float)sides; float num4 = num3 * (float)Math.PI * 2f; Vector3 val3 = Mathf.Cos(num4) * val2 + new Vector3(0f, Mathf.Sin(num4), 0f); list.Add(val + val3 * minorRadius); list2.Add(val3); list3.Add(new Vector2(num, num3)); } } for (int k = 0; k < segments; k++) { for (int l = 0; l < sides; l++) { int num5 = k * (sides + 1) + l; int num6 = num5 + sides + 1; list4.Add(num5); list4.Add(num5 + 1); list4.Add(num6); list4.Add(num6); list4.Add(num5 + 1); list4.Add(num6 + 1); } } return BuildFromLists(list, list2, list3, list4, "Torus"); } public static Mesh BuildCone(float radius = 0.5f, float height = 1f, int segments = 24) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); float num = height * 0.5f; float num2 = Mathf.Sqrt(radius * radius + height * height); float num3 = height / num2; float num4 = radius / num2; for (int i = 0; i <= segments; i++) { float num5 = (float)i / (float)segments; float num6 = num5 * (float)Math.PI * 2f; float num7 = Mathf.Cos(num6); float num8 = Mathf.Sin(num6); list.Add(new Vector3(num7 * radius, 0f - num, num8 * radius)); list2.Add(new Vector3(num7 * num3, num4, num8 * num3)); list3.Add(new Vector2(num5, 0f)); list.Add(new Vector3(0f, num, 0f)); list2.Add(new Vector3(num7 * num3, num4, num8 * num3)); list3.Add(new Vector2(num5 + 0.5f / (float)segments, 1f)); } for (int j = 0; j < segments; j++) { int num9 = j * 2; list4.Add(num9); list4.Add(num9 + 3); list4.Add(num9 + 2); list4.Add(num9); list4.Add(num9 + 1); list4.Add(num9 + 3); } int count = list.Count; list.Add(new Vector3(0f, 0f - num, 0f)); list2.Add(Vector3.down); list3.Add(new Vector2(0.5f, 0.5f)); for (int k = 0; k <= segments; k++) { float num10 = (float)k / (float)segments; float num11 = num10 * (float)Math.PI * 2f; float num12 = Mathf.Cos(num11); float num13 = Mathf.Sin(num11); list.Add(new Vector3(num12 * radius, 0f - num, num13 * radius)); list2.Add(Vector3.down); list3.Add(new Vector2(num12 * 0.5f + 0.5f, num13 * 0.5f + 0.5f)); } for (int l = 0; l < segments; l++) { int item = count; int item2 = count + 1 + l; int item3 = count + 2 + l; list4.Add(item); list4.Add(item2); list4.Add(item3); } return BuildFromLists(list, list2, list3, list4, "Cone"); } public static Mesh BuildHelix(float innerRadius = 0.15f, float outerRadius = 0.5f, float height = 0.6f, float turns = 2f, int segments = 128) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0225: 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_0241: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); float num = turns * (float)Math.PI * 2f; float num2 = height / num; int num3 = 0; Vector3 val; for (int i = 0; i <= segments; i++) { float num4 = (float)i / (float)segments; float num5 = num4 * num; float num6 = num4 * height - height * 0.5f; float num7 = Mathf.Cos(num5); float num8 = Mathf.Sin(num5); val = new Vector3(num8 * num2, 1f, (0f - num7) * num2); Vector3 normalized = ((Vector3)(ref val)).normalized; list.Add(new Vector3(num7 * innerRadius, num6, num8 * innerRadius)); list2.Add(normalized); list3.Add(new Vector2(0f, num4)); list.Add(new Vector3(num7 * outerRadius, num6, num8 * outerRadius)); list2.Add(normalized); list3.Add(new Vector2(1f, num4)); } for (int j = 0; j < segments; j++) { int item = num3 + j * 2; int item2 = num3 + j * 2 + 1; int item3 = num3 + (j + 1) * 2; int item4 = num3 + (j + 1) * 2 + 1; list4.Add(item); list4.Add(item3); list4.Add(item4); list4.Add(item); list4.Add(item4); list4.Add(item2); } int count = list.Count; for (int k = 0; k <= segments; k++) { float num9 = (float)k / (float)segments; float num10 = num9 * num; float num11 = num9 * height - height * 0.5f; float num12 = Mathf.Cos(num10); float num13 = Mathf.Sin(num10); val = new Vector3(num13 * num2, 1f, (0f - num12) * num2); Vector3 item5 = -((Vector3)(ref val)).normalized; list.Add(new Vector3(num12 * innerRadius, num11, num13 * innerRadius)); list2.Add(item5); list3.Add(new Vector2(0f, num9)); list.Add(new Vector3(num12 * outerRadius, num11, num13 * outerRadius)); list2.Add(item5); list3.Add(new Vector2(1f, num9)); } for (int l = 0; l < segments; l++) { int item6 = count + l * 2; int item7 = count + l * 2 + 1; int item8 = count + (l + 1) * 2; int item9 = count + (l + 1) * 2 + 1; list4.Add(item6); list4.Add(item9); list4.Add(item8); list4.Add(item6); list4.Add(item7); list4.Add(item9); } return BuildFromLists(list, list2, list3, list4, "Helix"); } public static Mesh BuildEgg(int latSegs = 40, int lonSegs = 40) { //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); for (int i = 0; i <= latSegs; i++) { float num = (float)i / (float)latSegs * (float)Math.PI; float num2 = Mathf.Sin(num); float num3 = Mathf.Cos(num); float num4 = 1f + 0.45f * num3; float num5 = ((num4 > 0.0001f) ? (0.38f * num2 / Mathf.Sqrt(num4)) : 0f); float num6 = 0.5f * num3; for (int j = 0; j <= lonSegs; j++) { float num7 = (float)j / (float)lonSegs; float num8 = num7 * (float)Math.PI * 2f; list.Add(new Vector3(Mathf.Cos(num8) * num5, num6, Mathf.Sin(num8) * num5)); list2.Add(new Vector2(num7, 1f - num / (float)Math.PI)); } } for (int k = 0; k < latSegs; k++) { for (int l = 0; l < lonSegs; l++) { int num9 = k * (lonSegs + 1) + l; int num10 = num9 + lonSegs + 1; list3.Add(num9); list3.Add(num9 + 1); list3.Add(num10); list3.Add(num10); list3.Add(num9 + 1); list3.Add(num10 + 1); } } Mesh val = new Mesh { name = "Egg" }; val.vertices = Il2CppStructArray.op_Implicit(list.ToArray()); val.uv = Il2CppStructArray.op_Implicit(list2.ToArray()); val.triangles = Il2CppStructArray.op_Implicit(list3.ToArray()); val.RecalculateNormals(); val.RecalculateBounds(); ((Object)val).hideFlags = (HideFlags)61; return val; } private static Mesh BuildFromLists(List verts, List norms, List uvs, List tris, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown Mesh val = new Mesh { name = name }; val.vertices = Il2CppStructArray.op_Implicit(verts.ToArray()); val.normals = Il2CppStructArray.op_Implicit(norms.ToArray()); val.uv = Il2CppStructArray.op_Implicit(uvs.ToArray()); val.triangles = Il2CppStructArray.op_Implicit(tris.ToArray()); val.RecalculateBounds(); ((Object)val).hideFlags = (HideFlags)61; return val; } } internal static class MaterialInspectorPanel { private static bool _visible; private static Rect _windowRect = new Rect(20f, 60f, 500f, 600f); private static bool _dragging; private static Vector2 _dragOffset; private static string _search = ""; private static Material _inspected; private static string _inspectedName = ""; private static Vector2 _scroll; private const float HeaderH = 22f; private const float Pad = 6f; private const float ThumbSize = 48f; public static bool Visible => _visible; public static void Toggle() { _visible = !_visible; } public static void DrawGUI() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Invalid comparison between Unknown and I4 //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Invalid comparison between Unknown and I4 //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (!_visible) { return; } Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y, ((Rect)(ref _windowRect)).width, 22f); if ((int)Event.current.type == 0 && ((Rect)(ref val)).Contains(Event.current.mousePosition)) { _dragging = true; _dragOffset = Event.current.mousePosition - new Vector2(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y); } if (_dragging) { if ((int)Event.current.type == 3) { ((Rect)(ref _windowRect)).position = Event.current.mousePosition - _dragOffset; } if ((int)Event.current.type == 1) { _dragging = false; } } GUI.color = new Color(0f, 0f, 0f, 0.85f); GUI.Box(_windowRect, ""); GUI.color = Color.white; GUILayout.BeginArea(_windowRect); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) }); GUILayout.Label(" Material Inspector", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("✕", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(24f) })) { _visible = false; } GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal((Il2CppReferenceArray)null); GUI.SetNextControlName("matInspSearch"); _search = GUILayout.TextField(_search ?? "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("Find", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { FindMaterial(_search); } GUILayout.EndHorizontal(); GUILayout.Space(6f); if ((Object)(object)_inspected != (Object)null) { DrawProperties(); } else if (!string.IsNullOrEmpty(_inspectedName)) { GUILayout.Label("No material found for \"" + _inspectedName + "\"", (Il2CppReferenceArray)null); } else { GUILayout.Label("Enter a material name above and press Find.", (Il2CppReferenceArray)null); } GUILayout.EndArea(); } private static void FindMaterial(string name) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _inspectedName = name ?? ""; _inspected = null; _scroll = Vector2.zero; if (string.IsNullOrEmpty(name)) { return; } _inspected = MaterialCatalog.TryGetMaterialByName(name); if ((Object)(object)_inspected != (Object)null) { return; } Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); if (val == null) { return; } for (int i = 0; i < val.Length; i++) { Material val2 = val[i]; if ((Object)(object)val2 == (Object)null) { continue; } try { if (string.Equals(((Object)val2).name, name, StringComparison.OrdinalIgnoreCase)) { _inspected = val2; break; } } catch { } } } private static void DrawProperties() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Expected O, but got Unknown //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected I4, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) Material inspected = _inspected; Shader shader; try { shader = inspected.shader; } catch { GUILayout.Label("(shader unavailable)", (Il2CppReferenceArray)null); return; } GUILayout.Label("" + TryGetName((Object)(object)inspected) + " shader: " + TryGetName((Object)(object)shader), new GUIStyle(GUI.skin.label) { richText = true }, (Il2CppReferenceArray)null); GUILayout.Space(4f); float num = ((Rect)(ref _windowRect)).height - 22f - 18f - 60f; _scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) }); int num2 = 0; try { num2 = shader.GetPropertyCount(); } catch { } for (int i = 0; i < num2; i++) { string propertyName; ShaderPropertyType propertyType; try { propertyName = shader.GetPropertyName(i); propertyType = shader.GetPropertyType(i); } catch { continue; } GUILayout.BeginHorizontal((Il2CppReferenceArray)null); GUILayout.Label("" + propertyName + "", new GUIStyle(GUI.skin.label) { richText = true }, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) }); try { ShaderPropertyType val = propertyType; ShaderPropertyType val2 = val; switch ((int)val2) { case 2: case 3: { float value = inspected.GetFloat(propertyName); GUILayout.Label($"{value:G6}", (Il2CppReferenceArray)null); break; } case 5: GUILayout.Label(inspected.GetInt(propertyName).ToString(), (Il2CppReferenceArray)null); break; case 0: { Color color = inspected.GetColor(propertyName); Color color2 = GUI.color; GUI.color = new Color(color.r, color.g, color.b, 1f); GUILayout.Box("", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(16f), GUILayout.Height(16f) }); GUI.color = color2; GUILayout.Label($" R:{color.r:F3} G:{color.g:F3} B:{color.b:F3} A:{color.a:F3}", (Il2CppReferenceArray)null); break; } case 1: { Vector4 vector = inspected.GetVector(propertyName); GUILayout.Label($"({vector.x:G5}, {vector.y:G5}, {vector.z:G5}, {vector.w:G5})", (Il2CppReferenceArray)null); break; } case 4: { Texture val3; try { val3 = inspected.GetTexture(propertyName); } catch { val3 = null; } if ((Object)(object)val3 == (Object)null) { GUILayout.Label("(none)", (Il2CppReferenceArray)null); break; } GUILayout.Label(TryGetName((Object)(object)val3), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) }); Texture2D val4 = ((Il2CppObjectBase)val3).TryCast(); if ((Object)(object)val4 != (Object)null) { Rect rect = GUILayoutUtility.GetRect(48f, 48f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(48f), GUILayout.Height(48f) }); GUI.DrawTexture(rect, (Texture)(object)val4, (ScaleMode)2); break; } GUILayout.Label($"[{((object)val3).GetType().Name} {val3.width}×{val3.height}]", (Il2CppReferenceArray)null); break; } default: GUILayout.Label($"({propertyType})", (Il2CppReferenceArray)null); break; } } catch (Exception ex) { GUILayout.Label("(error: " + ex.Message + ")", (Il2CppReferenceArray)null); } GUILayout.EndHorizontal(); } GUILayout.Space(6f); GUILayout.Label("Enabled keywords:", new GUIStyle(GUI.skin.label) { richText = true }, (Il2CppReferenceArray)null); try { Il2CppStringArray shaderKeywords = inspected.shaderKeywords; if (shaderKeywords == null || ((Il2CppArrayBase)(object)shaderKeywords).Length == 0) { GUILayout.Label(" (none)", (Il2CppReferenceArray)null); } else { foreach (string item in (Il2CppArrayBase)(object)shaderKeywords) { GUILayout.Label(" " + item, (Il2CppReferenceArray)null); } } } catch { GUILayout.Label(" (unavailable)", (Il2CppReferenceArray)null); } GUILayout.EndScrollView(); } private static string TryGetName(Object obj) { try { return (obj != (Object)null) ? obj.name : "(null)"; } catch { return "(unavailable)"; } } } [Serializable] public class MaterialConstructionEntry { public int id = -1; public string name = "New Material"; public string materialName = ""; public string surfaceType = ""; public bool sunglassesNeeded; } internal static class MaterialConstructionLibrary { public static List Entries => PropMetadataStore.MaterialConstructions; public static void Save() { PropMetadataStore.SaveMaterialConstructions(); } public static void MarkDirty() { PropMetadataStore.MarkMaterialConstructionsDirty(); } public static MaterialConstructionEntry CreateNew() { return PropMetadataStore.CreateMaterialConstruction(); } public static void Delete(MaterialConstructionEntry entry) { PropMetadataStore.DeleteMaterialConstruction(entry); } public static MaterialConstructionEntry FindById(int id) { return PropMetadataStore.FindMaterialConstructionById(id); } } internal static class LevelSaveLoad { private struct SaveRecord { public LevelEditorObject obj; public int metaIndex; public int chunkIndex; public Vector3 position; public Quaternion rotation; public Vector3 scale; public PhysicsMode physicsType; public int groupId; public int physicsGroupId; public float hatHairAmt; public Vector3 grabOffsetPos; public Vector3 grabOffsetRot; public Vector3 hatOffsetPos; public Vector3 hatOffsetRot; public int materialConstructionId; public byte instanceFlags; public Vector3 materialTint; } private static readonly byte[] Magic = new byte[3] { 66, 66, 66 }; private const byte FormatVersion = 12; private const int SpawnPointMetaIndex = -1; public static bool Save(string path) { LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { MelonLogger.Warning("[SaveLoad] LevelEditorManager not ready."); return false; } try { Directory.CreateDirectory(Path.GetDirectoryName(path)); using FileStream output = File.Open(path, FileMode.Create, FileAccess.Write); using BinaryWriter binaryWriter = new BinaryWriter(output, Encoding.UTF8, leaveOpen: false); binaryWriter.Write(Magic); binaryWriter.Write((byte)12); binaryWriter.Write(!BaseMapController.BaseMapEnabled); binaryWriter.Write(BaseMapController.DayWeatherPlaylist); binaryWriter.Write(BaseMapController.RestoreDayWeatherPlaylist); binaryWriter.Write(BaseMapController.WeatherPreset); List list = BuildSortedRecords(instance); binaryWriter.Write(list.Count); for (int i = 0; i < list.Count; i++) { WriteRecord(binaryWriter, list[i]); } WriteBakedData(binaryWriter, list); WriteGroupScales(binaryWriter); MelonLogger.Msg($"[SaveLoad] Saved {list.Count} object(s) → {path}"); return true; } catch (Exception ex) { MelonLogger.Warning("[SaveLoad] Save failed: " + ex.Message); return false; } } public static (bool ok, int count, string error) Load(string path) { LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { return (ok: false, count: 0, error: "Level editor not ready."); } if (!File.Exists(path)) { return (ok: false, count: 0, error: "File not found."); } try { using FileStream input = File.Open(path, FileMode.Open, FileAccess.Read); using BinaryReader r = new BinaryReader(input, Encoding.UTF8, leaveOpen: false); return LoadFromReader(r, instance, path); } catch (Exception ex) { MelonLogger.Warning("[SaveLoad] Load failed: " + ex.Message); return (ok: false, count: 0, error: ex.Message); } } public static (bool ok, int count, string error) LoadFromNetworkData(byte[] data) { if (data == null || data.Length == 0) { return (ok: false, count: 0, error: "No data."); } LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { return (ok: false, count: 0, error: "Level editor not ready."); } try { using MemoryStream input = new MemoryStream(data); using BinaryReader r = new BinaryReader(input, Encoding.UTF8, leaveOpen: false); return LoadFromReader(r, instance, "[network]", teleportOnLoad: false); } catch (Exception ex) { MelonLogger.Warning("[SaveLoad] LoadFromNetworkData failed: " + ex.Message); return (ok: false, count: 0, error: ex.Message); } } public static byte[] SerializeForNetwork() { LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { return null; } List list = BuildSortedRecords(instance); if (list.Count == 0) { return null; } try { using MemoryStream memoryStream = new MemoryStream(); using BinaryWriter binaryWriter = new BinaryWriter(memoryStream, Encoding.UTF8, leaveOpen: false); binaryWriter.Write(Magic); binaryWriter.Write((byte)12); binaryWriter.Write(!BaseMapController.BaseMapEnabled); binaryWriter.Write(BaseMapController.DayWeatherPlaylist); binaryWriter.Write(BaseMapController.RestoreDayWeatherPlaylist); binaryWriter.Write(BaseMapController.WeatherPreset); binaryWriter.Write(list.Count); foreach (SaveRecord item in list) { WriteRecord(binaryWriter, item); } binaryWriter.Write(0); WriteGroupScales(binaryWriter); return memoryStream.ToArray(); } catch (Exception ex) { MelonLogger.Warning("[SaveLoad] SerializeForNetwork failed: " + ex.Message); return null; } } private static (bool ok, int count, string error) LoadFromReader(BinaryReader r, LevelEditorManager mgr, string sourceName, bool teleportOnLoad = true) { //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: 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_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_083f: Unknown result type (might be due to invalid IL or missing references) LevelEditor.Select(null); byte[] array = r.ReadBytes(3); if (array.Length < 3 || array[0] != 66 || array[1] != 66 || array[2] != 66) { return (ok: false, count: 0, error: "Not a .bbb file."); } byte b = r.ReadByte(); if (b > 12) { return (ok: false, count: 0, error: $"Unsupported format version {b}."); } bool baseMapOff = false; int dayWeatherPlaylist = 0; int restoreChapter = 0; int weatherPreset = -1; if (b >= 7) { baseMapOff = r.ReadBoolean(); dayWeatherPlaylist = r.ReadInt32(); restoreChapter = r.ReadInt32(); } if (b >= 9) { weatherPreset = r.ReadInt32(); } int num = r.ReadInt32(); int num2 = 0; mgr.RemoveAll(); LevelEditor.ClearAllSelectionState(); ModNetworking.ClearNetworkedObjects(); BbHatSunglassesFlag.Clear(); LevelEditorObject[] array2 = new LevelEditorObject[num]; Vector3 position = default(Vector3); Vector3 val = default(Vector3); for (int i = 0; i < num; i++) { int num3 = -1; string text; switch (b) { case 1: text = ReadLegacyString(r); r.ReadInt32(); break; case 2: { int num5 = r.ReadInt32(); text = PropMetadataStore.FindIdByIndex(num5); if (string.IsNullOrEmpty(text)) { MelonLogger.Warning($"[SaveLoad] No prop for index {num5}"); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); continue; } break; } default: { int num4 = r.ReadInt32(); num3 = r.ReadByte(); text = ((num4 == -1) ? "special://spawn-point" : PropMetadataStore.FindIdByIndex(num4)); if (!string.IsNullOrEmpty(text)) { break; } MelonLogger.Warning($"[SaveLoad] No prop for index {num4}"); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); r.ReadSingle(); if (b >= 4) { r.ReadByte(); r.ReadByte(); r.ReadByte(); r.ReadSingle(); } if (b >= 5) { for (int j = 0; j < 12; j++) { r.ReadSingle(); } } if (b >= 8) { r.ReadInt32(); } if (b >= 10) { r.ReadByte(); } if (b >= 12) { r.ReadByte(); r.ReadByte(); r.ReadByte(); } continue; } } ((Vector3)(ref position))..ctor(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); Quaternion rotation = (Quaternion)((b >= 3) ? ReadCompactRotation(r) : new Quaternion(r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle())); ((Vector3)(ref val))..ctor(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); PhysicsMode physicsMode = PhysicsMode.Static; int groupId = 0; int physicsGroupId = 0; float hatHairAmt = 0f; Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; Vector3 zero3 = Vector3.zero; Vector3 zero4 = Vector3.zero; if (b >= 4) { byte b2 = r.ReadByte(); physicsMode = (PhysicsMode)(Enum.IsDefined(typeof(PhysicsMode), (int)b2) ? b2 : 0); groupId = r.ReadByte(); physicsGroupId = r.ReadByte(); hatHairAmt = Mathf.Clamp01(r.ReadSingle()); } if (b >= 5) { ((Vector3)(ref zero))..ctor(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); ((Vector3)(ref zero2))..ctor(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); ((Vector3)(ref zero3))..ctor(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); ((Vector3)(ref zero4))..ctor(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } int num6 = ((b >= 8) ? r.ReadInt32() : (-1)); byte b3 = (byte)((b >= 10) ? r.ReadByte() : 0); Vector3 tint = ((b >= 12) ? new Vector3((float)(int)r.ReadByte(), (float)(int)r.ReadByte(), (float)(int)r.ReadByte()) : new Vector3(255f, 255f, 255f)); PropInfo propInfo = PropLibrary.FindById(text); if (propInfo == null) { MelonLogger.Warning("[SaveLoad] Prop not found: " + text); continue; } LevelEditorObject levelEditorObject = mgr.SpawnFromPropInfo(propInfo, position); if ((Object)(object)levelEditorObject == (Object)null) { continue; } ((Component)levelEditorObject).transform.rotation = rotation; ((Component)levelEditorObject).transform.localScale = (PropLibrary.IsSpawnPointProp(text) ? Vector3.one : val); mgr.SyncLoopBase(levelEditorObject); if (b >= 3 && num3 >= 0) { if (num3 == 255) { levelEditorObject.chunkIndex = 255; levelEditorObject.chunkCoord = new Vector2Int(-1, -1); } else { int num7 = (levelEditorObject.chunkIndex = Mathf.Clamp(num3, 0, 63)); levelEditorObject.chunkCoord = new Vector2Int(num7 % 8, num7 / 8); } } levelEditorObject.physicsMode = physicsMode; levelEditorObject.groupId = groupId; levelEditorObject.physicsGroupId = physicsGroupId; levelEditorObject.hatHairAmt = hatHairAmt; levelEditorObject.grabOffsetPos = zero; levelEditorObject.grabOffsetRot = zero2; levelEditorObject.hatOffsetPos = zero3; levelEditorObject.hatOffsetRot = zero4; levelEditorObject.materialConstructionId = num6; if (num6 >= 0) { MaterialConstructionEntry materialConstructionEntry = MaterialConstructionLibrary.FindById(num6); if (materialConstructionEntry != null) { MelonLogger.Msg($"[SaveLoad] Applying construction id={num6} name=\"{materialConstructionEntry.name}\" matName=\"{materialConstructionEntry.materialName}\" to {levelEditorObject.addressableKey}"); MaterialConstructionPanel.ApplyToInstance(levelEditorObject, materialConstructionEntry, pushHistory: false); } else { MelonLogger.Warning($"[SaveLoad] Material construction {num6} not found for {levelEditorObject.addressableKey}"); levelEditorObject.materialConstructionId = -1; } } else if (text.IndexOf("Stone", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Drystone", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Wall", StringComparison.OrdinalIgnoreCase) >= 0) { MelonLogger.Msg($"[SaveLoad] No construction (id={num6}) for {text}"); } levelEditorObject.sunglassesNeeded = (b3 & 1) != 0; levelEditorObject.playerPassthrough = (b3 & 2) != 0; levelEditorObject.freezeUntilHit = (b3 & 8) != 0; if (levelEditorObject.sunglassesNeeded && (Object)(object)((Component)levelEditorObject).GetComponent() == (Object)null) { ((Component)levelEditorObject).gameObject.AddComponent(); } if (levelEditorObject.playerPassthrough) { PropInstanceServices.SetBushPassthrough(((Component)levelEditorObject).gameObject, passthrough: true); } if ((b3 & 4) != 0) { BbHatSunglassesFlag.Set(levelEditorObject, on: true); } PropInstanceServices.ApplyTint(levelEditorObject, tint); array2[i] = levelEditorObject; num2++; ModNetworking.RegisterLoadedNetworkedObject((ulong)(i + 1), levelEditorObject); } if (b >= 6) { ReadBakedData(r, array2); } GroupManager.ApplyGroups(); PhysicsObjectManager.SyncLoadedHatHairValues(); if (b >= 11) { ReadGroupScales(r); } if (teleportOnLoad) { TeleportToSpawnPoint(array2); } if (b >= 7) { MelonCoroutines.Start(BaseMapController.ApplyLoadedBaseMapStateDelayed(baseMapOff, dayWeatherPlaylist, restoreChapter)); } BaseMapController.SetWeatherPreset(weatherPreset); MelonLogger.Msg($"[SaveLoad] Loaded {num2}/{num} object(s) from {sourceName}"); return (ok: true, count: num2, error: null); } private static void TeleportToSpawnPoint(LevelEditorObject[] leos) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) foreach (LevelEditorObject levelEditorObject in leos) { if (!((Object)(object)levelEditorObject == (Object)null) && PropLibrary.IsSpawnPointProp(levelEditorObject.addressableKey)) { PlayerMovement me = PlayerMovement.me; if (!((Object)(object)me == (Object)null) && !((Object)(object)Menu.me == (Object)null)) { FlyCamController.BeginLevelLoadTeleport(); ((Component)me.anim).transform.rotation = Quaternion.Euler(0f, ((Component)levelEditorObject).transform.eulerAngles.y, 0f); Menu.me.Teleport(((Component)levelEditorObject).transform.position, false); MelonCoroutines.Start(SnapFlyCamToPlayer(me)); } break; } } } private static IEnumerator SnapFlyCamToPlayer(PlayerMovement player) { yield return null; while ((Object)(object)Menu.me != (Object)null && Menu.me.teleporting) { yield return null; } FlyCamController.EndLevelLoadTeleport(); if ((Object)(object)player != (Object)null && (Object)(object)player.flyCam != (Object)null && player.torsoRbs != null && ((Il2CppArrayBase)(object)player.torsoRbs).Length > 0) { ((Component)player.flyCam).transform.position = ((Component)((Il2CppArrayBase)(object)player.torsoRbs)[0]).transform.position; } } private static string ReadLegacyString(BinaryReader r) { int num = r.ReadInt32(); if (num <= 0) { return ""; } return Encoding.UTF8.GetString(r.ReadBytes(num)); } private static List BuildSortedRecords(LevelEditorManager mgr) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if ((Object)(object)mgr == (Object)null) { return list; } foreach (LevelEditorObject @object in mgr.Objects) { if ((Object)(object)@object == (Object)null || string.IsNullOrEmpty(@object.addressableKey)) { continue; } int num; if (PropLibrary.IsSpawnPointProp(@object.addressableKey)) { num = -1; } else { num = PropMetadataStore.GetMetaIndex(@object.addressableKey); if (num <= 0) { continue; } } Vector3 position = (@object.hasLoopBasePosition ? @object.loopBasePosition : ((Component)@object).transform.position); list.Add(new SaveRecord { obj = @object, metaIndex = num, chunkIndex = ((@object.physicsMode == PhysicsMode.Static) ? LevelEditorManager.GetChunkIndex(position) : 255), position = position, rotation = CanonicalizeRotation(((Component)@object).transform.rotation), scale = ((Component)@object).transform.localScale, physicsType = @object.physicsMode, groupId = @object.groupId, physicsGroupId = @object.physicsGroupId, hatHairAmt = @object.hatHairAmt, grabOffsetPos = @object.grabOffsetPos, grabOffsetRot = @object.grabOffsetRot, hatOffsetPos = @object.hatOffsetPos, hatOffsetRot = @object.hatOffsetRot, materialConstructionId = @object.materialConstructionId, instanceFlags = (byte)((@object.sunglassesNeeded ? 1 : 0) | (@object.playerPassthrough ? 2 : 0) | (BbHatSunglassesFlag.Has(@object) ? 4 : 0) | (@object.freezeUntilHit ? 8 : 0)), materialTint = @object.materialTint }); } list.Sort(CompareRecords); return list; } private static int CompareRecords(SaveRecord a, SaveRecord b) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) int num = a.chunkIndex.CompareTo(b.chunkIndex); if (num != 0) { return num; } int num2 = a.position.z.CompareTo(b.position.z); if (num2 != 0) { return num2; } int num3 = a.position.x.CompareTo(b.position.x); if (num3 != 0) { return num3; } int num4 = a.position.y.CompareTo(b.position.y); if (num4 != 0) { return num4; } return string.Compare(a.obj?.addressableKey, b.obj?.addressableKey, StringComparison.Ordinal); } private static void WriteRecord(BinaryWriter w, SaveRecord record) { //IL_0029: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0209: 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) w.Write(record.metaIndex); w.Write((byte)Mathf.Clamp(record.chunkIndex, 0, 255)); w.Write(record.position.x); w.Write(record.position.y); w.Write(record.position.z); WriteCompactRotation(w, record.rotation); w.Write(record.scale.x); w.Write(record.scale.y); w.Write(record.scale.z); w.Write((byte)record.physicsType); w.Write((byte)Mathf.Clamp(record.groupId, 0, 255)); w.Write((byte)Mathf.Clamp(record.physicsGroupId, 0, 255)); w.Write(Mathf.Clamp01(record.hatHairAmt)); w.Write(record.grabOffsetPos.x); w.Write(record.grabOffsetPos.y); w.Write(record.grabOffsetPos.z); w.Write(record.grabOffsetRot.x); w.Write(record.grabOffsetRot.y); w.Write(record.grabOffsetRot.z); w.Write(record.hatOffsetPos.x); w.Write(record.hatOffsetPos.y); w.Write(record.hatOffsetPos.z); w.Write(record.hatOffsetRot.x); w.Write(record.hatOffsetRot.y); w.Write(record.hatOffsetRot.z); w.Write(record.materialConstructionId); w.Write(record.instanceFlags); w.Write((byte)Mathf.Clamp(Mathf.RoundToInt(record.materialTint.x), 0, 255)); w.Write((byte)Mathf.Clamp(Mathf.RoundToInt(record.materialTint.y), 0, 255)); w.Write((byte)Mathf.Clamp(Mathf.RoundToInt(record.materialTint.z), 0, 255)); } private static void WriteBakedData(BinaryWriter w, List records) { List<(int, List)> list = new List<(int, List)>(); int num = 0; for (int i = 0; i < records.Count; i++) { if (records[i].physicsType != PhysicsMode.Static) { num++; List list2 = MaterialBaker.ExportBakedData(((Component)records[i].obj).gameObject); if (list2.Count > 0) { list.Add((i, list2)); } } } MelonLogger.Msg($"[SaveLoad] WriteBakedData: {list.Count}/{num} physics object(s) had exportable bake data"); if (list.Count == 0) { w.Write(0); return; } using MemoryStream memoryStream = new MemoryStream(); using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream, Encoding.UTF8, leaveOpen: true)) { binaryWriter.Write(list.Count); foreach (var (value, parts) in list) { binaryWriter.Write(value); MaterialBaker.WritePartList(binaryWriter, parts); } } using MemoryStream memoryStream2 = new MemoryStream(); memoryStream.Position = 0L; using (DeflateStream destination = new DeflateStream(memoryStream2, CompressionLevel.Optimal, leaveOpen: true)) { memoryStream.CopyTo(destination); } byte[] array = memoryStream2.ToArray(); w.Write(array.Length); w.Write((int)memoryStream.Length); w.Write(array); } private static void ReadBakedData(BinaryReader r, LevelEditorObject[] leos) { int num = r.ReadInt32(); if (num <= 0) { return; } int capacity = r.ReadInt32(); byte[] buffer = r.ReadBytes(num); using MemoryStream stream = new MemoryStream(buffer); using MemoryStream memoryStream = new MemoryStream(capacity); using (DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress)) { deflateStream.CopyTo(memoryStream); } memoryStream.Position = 0L; using BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8, leaveOpen: true); int num2 = binaryReader.ReadInt32(); for (int i = 0; i < num2; i++) { int num3 = binaryReader.ReadInt32(); List parts = MaterialBaker.ReadPartList(binaryReader); if (num3 >= 0 && num3 < leos.Length && (Object)(object)leos[num3] != (Object)null && !PropMetadataStore.GetDisableBaking(leos[num3].addressableKey)) { MaterialBaker.ImportBakedData(((Component)leos[num3]).gameObject, parts); } } } private static void WriteGroupScales(BinaryWriter w) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) List> list = GroupManager.GetAllGroupDisplayScales().ToList(); w.Write(list.Count); foreach (KeyValuePair item in list) { w.Write(item.Key); w.Write(item.Value.x); w.Write(item.Value.y); w.Write(item.Value.z); } } private static void ReadGroupScales(BinaryReader r) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) int num = r.ReadInt32(); Vector3 scale = default(Vector3); for (int i = 0; i < num; i++) { int groupId = r.ReadInt32(); ((Vector3)(ref scale))..ctor(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); GroupManager.SetGroupDisplayScale(groupId, scale); } } private static void WriteCompactRotation(BinaryWriter w, Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) rotation = CanonicalizeRotation(rotation); w.Write(rotation.x); w.Write(rotation.y); w.Write(rotation.z); } private static Quaternion ReadCompactRotation(BinaryReader r) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) float num = r.ReadSingle(); float num2 = r.ReadSingle(); float num3 = r.ReadSingle(); float num4 = 1f - (num * num + num2 * num2 + num3 * num3); num4 = ((num4 > 0f) ? Mathf.Sqrt(num4) : 0f); return new Quaternion(num, num2, num3, num4); } private static Quaternion CanonicalizeRotation(Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0022: 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_0039: Unknown result type (might be due to invalid IL or missing references) if (rotation.w < 0f) { ((Quaternion)(ref rotation))..ctor(0f - rotation.x, 0f - rotation.y, 0f - rotation.z, 0f - rotation.w); } return rotation; } } internal static class NativeFileDialog { private struct OPENFILENAME { public int lStructSize; public IntPtr hwndOwner; public IntPtr hInstance; public IntPtr lpstrFilter; public IntPtr lpstrCustomFilter; public int nMaxCustFilter; public int nFilterIndex; public IntPtr lpstrFile; public int nMaxFile; public IntPtr lpstrFileTitle; public int nMaxFileTitle; public IntPtr lpstrInitialDir; public IntPtr lpstrTitle; public int Flags; public short nFileOffset; public short nFileExtension; public IntPtr lpstrDefExt; public IntPtr lCustData; public IntPtr lpfnHook; public IntPtr lpTemplateName; public IntPtr pvReserved; public int dwReserved; public int FlagsEx; } private const int OFN_EXPLORER = 524288; private const int OFN_FILEMUSTEXIST = 4096; private const int OFN_PATHMUSTEXIST = 2048; private const int OFN_OVERWRITEPROMPT = 2; private const int OFN_NOCHANGEDIR = 8; private const int OFN_HIDEREADONLY = 4; private static readonly string FilterStr = "BabyBlocks Level (*.bbb)\0*.bbb\0All Files (*.*)\0*.*\0\0"; [DllImport("comdlg32.dll", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool GetOpenFileNameW(ref OPENFILENAME ofn); [DllImport("comdlg32.dll", CharSet = CharSet.Unicode, SetLastError = true)] private static extern bool GetSaveFileNameW(ref OPENFILENAME ofn); public static string OpenDialog(string initialPath) { return RunDialog(initialPath, open: true); } public static string SaveDialog(string initialPath) { return RunDialog(initialPath, open: false); } private static string RunDialog(string initialPath, bool open) { string text = null; string text2 = null; if (!string.IsNullOrEmpty(initialPath)) { text = Path.GetDirectoryName(initialPath); text2 = Path.GetFileName(initialPath); } IntPtr intPtr = Marshal.AllocHGlobal(65536); IntPtr intPtr2 = WriteWString(FilterStr); IntPtr intPtr3 = WriteWString("bbb"); IntPtr intPtr4 = WriteWString(open ? "Open Level" : "Save Level"); IntPtr intPtr5 = ((text != null) ? WriteWString(text) : IntPtr.Zero); try { for (int i = 0; i < 65536; i++) { Marshal.WriteByte(intPtr, i, 0); } if (!string.IsNullOrEmpty(text2)) { byte[] bytes = Encoding.Unicode.GetBytes(text2); int length = Math.Min(bytes.Length, 65534); Marshal.Copy(bytes, 0, intPtr, length); } OPENFILENAME ofn = new OPENFILENAME { lStructSize = Marshal.SizeOf(), lpstrFilter = intPtr2, nFilterIndex = 1, lpstrFile = intPtr, nMaxFile = 32768, lpstrTitle = intPtr4, lpstrDefExt = intPtr3, lpstrInitialDir = intPtr5, Flags = (0x8000C | (open ? 6144 : 2)) }; if (!(open ? GetOpenFileNameW(ref ofn) : GetSaveFileNameW(ref ofn))) { return null; } string text3 = Marshal.PtrToStringUni(intPtr); if (!open && !string.IsNullOrEmpty(text3) && !text3.EndsWith(".bbb", StringComparison.OrdinalIgnoreCase)) { text3 += ".bbb"; } return text3; } finally { Marshal.FreeHGlobal(intPtr); Marshal.FreeHGlobal(intPtr2); Marshal.FreeHGlobal(intPtr3); Marshal.FreeHGlobal(intPtr4); if (intPtr5 != IntPtr.Zero) { Marshal.FreeHGlobal(intPtr5); } } } private static IntPtr WriteWString(string s) { byte[] bytes = Encoding.Unicode.GetBytes(s); IntPtr intPtr = Marshal.AllocHGlobal(bytes.Length + 2); Marshal.Copy(bytes, 0, intPtr, bytes.Length); Marshal.WriteInt16(intPtr, bytes.Length, 0); return intPtr; } } internal static class SaveLoadWindow { private const float WinW = 310f; private const float BaseWinH = 232f; private const float HeaderH = 30f; private const float Pad = 7f; private const float DropdownItemH = 18f; private static Rect _windowRect; private static bool _initialized; private static bool _dragging; private static Vector2 _dragOffset; private static bool _weatherDropdownOpen; private static bool _confirmClear; private static bool _confirmLoad; private static float _confirmClearTime; private static float _confirmLoadTime; private const float ConfirmTimeout = 3f; private static string _filePath = ""; private static string _status = ""; private static float _statusTime; private const float StatusDuration = 4f; public static bool HasObjects => (Object)(object)LevelEditorManager.Instance != (Object)null && LevelEditorManager.Instance.Objects.Count > 0; private static void EnsureInit() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (!_initialized) { _initialized = true; string lastSavePath = Core.LastSavePath; _filePath = ((!string.IsNullOrEmpty(lastSavePath)) ? lastSavePath : Path.Combine(MelonEnvironment.UserDataDirectory, "BabyBlocks", "levels", "level.bbb")); _windowRect = new Rect((float)Screen.width - 310f - 10f, (float)Screen.height - 232f - 40f, 310f, 232f); } } public static bool ContainsPoint(Vector2 guiPoint) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return _initialized && ((Rect)(ref _windowRect)).Contains(guiPoint); } public static void DrawGUI(Event e) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Invalid comparison between Unknown and I4 //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Invalid comparison between Unknown and I4 //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_058d: 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_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) EnsureInit(); int dayWeatherPlaylistCount = BaseMapController.DayWeatherPlaylistCount; if (BaseMapController.BaseMapEnabled) { _weatherDropdownOpen = false; } float num = ((_weatherDropdownOpen && dayWeatherPlaylistCount > 0) ? ((float)dayWeatherPlaylistCount * 18f) : 0f); float num2 = 232f + num; ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, (float)Screen.width - 310f); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, (float)Screen.height - num2); ((Rect)(ref _windowRect)).height = num2; GUI.color = new Color(0f, 0f, 0f, 0.72f); GUI.Box(_windowRect, ""); GUI.color = Color.white; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y, 310f, 30f); GUI.Label(new Rect(((Rect)(ref _windowRect)).x + 7f, ((Rect)(ref _windowRect)).y + 6f, 296f, 20f), "Save / Load"); if ((int)e.type == 0 && e.button == 0 && ((Rect)(ref val)).Contains(e.mousePosition)) { _dragging = true; _dragOffset = e.mousePosition - new Vector2(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y); e.Use(); } if (_dragging) { if ((int)e.type == 3) { ((Rect)(ref _windowRect)).x = e.mousePosition.x - _dragOffset.x; ((Rect)(ref _windowRect)).y = e.mousePosition.y - _dragOffset.y; e.Use(); } if ((int)e.type == 1) { _dragging = false; } } float num3 = ((Rect)(ref _windowRect)).y + 30f + 7f; float num4 = ((Rect)(ref _windowRect)).x + 7f; float num5 = 296f; float num6 = (num5 - 7f) * 0.5f; if (_confirmClear && Time.realtimeSinceStartup - _confirmClearTime > 3f) { _confirmClear = false; } if (_confirmLoad && Time.realtimeSinceStartup - _confirmLoadTime > 3f) { _confirmLoad = false; } if (GUI.Button(new Rect(num4, num3, num6, 22f), "Save")) { _confirmLoad = false; DoSave(); } if (GUI.Button(new Rect(num4 + num6 + 7f, num3, num6, 22f), _confirmLoad ? "Are you sure?" : "Load")) { RequestLoad(); } num3 += 26f; if (GUI.Button(new Rect(num4, num3, num5, 22f), _confirmClear ? "Are you sure?" : "Clear")) { RequestClear(); } num3 += 26f; bool flag = GUI.Toggle(new Rect(num4, num3, num5, 20f), LevelEditorManager.ChunkLoopingEnabled, "Chunk looping"); if (flag != LevelEditorManager.ChunkLoopingEnabled) { LevelEditorManager.ChunkLoopingEnabled = flag; } num3 += 24f; bool flag2 = GUI.Toggle(new Rect(num4, num3, num5, 20f), BaseMapController.BaseMapEnabled, "Base map"); if (flag2 != BaseMapController.BaseMapEnabled) { BaseMapController.SetBaseMapEnabled(flag2); ModNetworking.SendBaseMapState(flag2); } num3 += 24f; bool flag3 = (GUI.enabled = !BaseMapController.BaseMapEnabled && dayWeatherPlaylistCount > 0); string text = ((dayWeatherPlaylistCount > 0) ? $"Weather playlist: {BaseMapController.DayWeatherPlaylist}" : "Weather playlist: n/a"); if (GUI.Button(new Rect(num4, num3, num5, 20f), text + (_weatherDropdownOpen ? " ▲" : " ▼"))) { _weatherDropdownOpen = !_weatherDropdownOpen; } GUI.enabled = true; num3 += 24f; if (flag3 && _weatherDropdownOpen) { for (int i = 0; i < dayWeatherPlaylistCount; i++) { string text2 = ((i == BaseMapController.DayWeatherPlaylist) ? "> " : "") + $"Playlist {i}"; if (GUI.Button(new Rect(num4, num3, num5, 18f), text2)) { BaseMapController.SetDayWeatherPlaylist(i); _weatherDropdownOpen = false; } num3 += 18f; } } if (GUI.Button(new Rect(num4, num3, num5, 22f), "Open Levels Folder")) { OpenLevelsFolder(); } num3 += 26f; float num7 = 26f; float num8 = num5 - num7 - 7f; _filePath = GUI.TextField(new Rect(num4, num3, num8, 20f), _filePath ?? ""); if (GUI.Button(new Rect(num4 + num8 + 7f, num3, num7, 20f), "…")) { BrowseForFile(); } if (!string.IsNullOrEmpty(_status) && Time.realtimeSinceStartup - _statusTime < 4f) { float num9 = Mathf.Clamp01(4f - (Time.realtimeSinceStartup - _statusTime)); GUI.color = new Color(1f, 1f, 0.4f, num9); GUI.Label(new Rect(num4, num3 + 22f, num5, 18f), _status); GUI.color = Color.white; } } private static void DoSave() { if (string.IsNullOrWhiteSpace(_filePath)) { SetStatus("No file path set."); return; } bool flag = LevelSaveLoad.Save(_filePath); if (flag) { Core.LastSavePath = _filePath; } SetStatus(flag ? "Saved." : "Save failed — see log."); } private static void RequestClear() { LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { SetStatus("Level editor not ready."); } else if (instance.Objects.Count == 0) { SetStatus("Nothing to clear."); } else if (_confirmClear) { _confirmClear = false; DoClear(); } else { _confirmClear = true; _confirmClearTime = Time.realtimeSinceStartup; } } private static void DoClear() { LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { SetStatus("Level editor not ready."); return; } instance.RemoveAll(); LevelEditor.ClearAllSelectionState(); ModNetworking.SendLevelCleared(); SetStatus("Cleared."); } private static void RequestLoad() { if (string.IsNullOrWhiteSpace(_filePath)) { SetStatus("No file path set."); return; } LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null || instance.Objects.Count == 0) { DoLoad(); } else if (_confirmLoad) { _confirmLoad = false; DoLoad(); } else { _confirmLoad = true; _confirmLoadTime = Time.realtimeSinceStartup; } } private static void DoLoad() { if (string.IsNullOrWhiteSpace(_filePath)) { SetStatus("No file path set."); return; } var (flag, value, text) = LevelSaveLoad.Load(_filePath); if (flag) { Core.LastSavePath = _filePath; ModNetworking.BroadcastLevelLoad(); } SetStatus(flag ? $"Loaded {value} object(s)." : ("Load failed: " + text)); } private static void BrowseForFile() { string text = NativeFileDialog.OpenDialog(_filePath); if (text != null) { _filePath = text; Core.LastSavePath = text; } } private static void OpenLevelsFolder() { string text = Path.Combine(MelonEnvironment.UserDataDirectory, "BabyBlocks", "levels"); try { Directory.CreateDirectory(text); } catch { } try { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Process.Start("explorer.exe", text); return; } Process.Start(new ProcessStartInfo("xdg-open", text) { UseShellExecute = false }); } catch (Exception ex) { SetStatus("Could not open folder: " + ex.Message); } } public static void TriggerSave() { EnsureInit(); DoSave(); } public static void TriggerSaveDialog() { EnsureInit(); string text = NativeFileDialog.SaveDialog(_filePath); if (!string.IsNullOrEmpty(text)) { _filePath = text; DoSave(); } } public static void TriggerLoadDialog() { EnsureInit(); string text = NativeFileDialog.OpenDialog(_filePath); if (!string.IsNullOrEmpty(text)) { _filePath = text; DoLoad(); } } public static void TriggerClear() { DoClear(); } private static void SetStatus(string msg) { _status = msg; _statusTime = Time.realtimeSinceStartup; } } internal static class GuiStyleHelpers { public static void EnsureItemAndGhostStyles(ref GUIStyle itemStyle, ref GUIStyle ghostStyle) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown if (itemStyle == null) { RectOffset padding = new RectOffset { left = 4, right = 4, top = 4, bottom = 4 }; itemStyle = new GUIStyle(GUI.skin.box) { wordWrap = true, alignment = (TextAnchor)4, clipping = (TextClipping)1, padding = padding }; } if (ghostStyle == null) { ghostStyle = new GUIStyle(itemStyle); } } } internal static class PropPalette { private const float Pad = 8f; private const float ItemH = 60f; private const float PanelW = 110f; private const float ItemW = 94f; private const float CatPad = 6f; private const float CatItemH = 26f; private static GUIStyle _itemStyle; private static GUIStyle _ghostStyle; private static GUIStyle _excludedXStyle; private static GUIStyle _warningStyle; private static GUIStyle _catStyle; private static int _scrollOffset = 0; private static int _draggingIndex = -1; private static int _dragStartFrame = -1; private static int _lastFilterCount = -1; private static float _scrollTimer; private static bool _scrollActive; private static bool _scrollInDelay; private const float ScrollInitialDelay = 0.35f; private const float ScrollRepeatInterval = 0.08f; public static string SelectedCategory = null; public static bool ShowingMaterials = false; private static List _cachedCategories; private static PropInfo _overrideDragInfo; private static int VisibleSlots => Mathf.Clamp(Mathf.FloorToInt(((float)Screen.height - 50f) / 68f), 4, 15); public static Rect PanelRect { get; internal set; } public static bool IsDragging => _draggingIndex >= 0 || _overrideDragInfo != null; public static int DragPropIndex => _draggingIndex; public static PropInfo DraggingProp => (_overrideDragInfo != null) ? _overrideDragInfo : ((_draggingIndex >= 0) ? PropLibrary.FilteredProps[_draggingIndex] : null); public static bool JustStartedDrag => IsDragging && Time.frameCount == _dragStartFrame; public static int StepPageOffset(int current, int dir, int page, int total) { if (total <= 0) { return 0; } int num = (total - 1) / page * page; int num2 = current + dir * page; if (num2 > num) { return 0; } if (num2 < 0) { return num; } return num2; } public static void InvalidateCategories() { _cachedCategories = null; } public static void CancelDrag() { _draggingIndex = -1; _overrideDragInfo = null; } public static void BeginDrag(int filteredIndex, PropInfo info) { if (!info.isLoaded) { PropLibrary.LoadPropData(info); } _draggingIndex = filteredIndex; _overrideDragInfo = null; _dragStartFrame = Time.frameCount; } public static void BeginDragDirect(PropInfo info) { if (!info.isLoaded) { PropLibrary.LoadPropData(info); } _draggingIndex = -1; _overrideDragInfo = info; _dragStartFrame = Time.frameCount; } public static void HandleScrollInput() { if (!PropLibrary.IsInitialized) { return; } int count = PropLibrary.FilteredProps.Count; if (count == 0) { return; } bool key = Input.GetKey((KeyCode)45); bool key2 = Input.GetKey((KeyCode)61); if (!key && !key2) { _scrollActive = false; _scrollTimer = 0f; return; } int dir = ((!key) ? 1 : (-1)); int visibleSlots = VisibleSlots; if (!_scrollActive) { _scrollActive = true; _scrollInDelay = true; _scrollTimer = 0f; _scrollOffset = StepPageOffset(_scrollOffset, dir, visibleSlots, count); return; } _scrollTimer += Time.unscaledDeltaTime; float num = (_scrollInDelay ? 0.35f : 0.08f); if (_scrollTimer >= num) { _scrollTimer -= num; _scrollInDelay = false; _scrollOffset = StepPageOffset(_scrollOffset, dir, visibleSlots, count); } } public static void DrawGUI(Event e) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_0708: Unknown result type (might be due to invalid IL or missing references) //IL_073d: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Expected O, but got Unknown //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_067a: 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_068b: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_083a: 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_0850: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_0878: Unknown result type (might be due to invalid IL or missing references) //IL_0884: Unknown result type (might be due to invalid IL or missing references) //IL_0895: Unknown result type (might be due to invalid IL or missing references) //IL_08af: Unknown result type (might be due to invalid IL or missing references) //IL_08c9: Unknown result type (might be due to invalid IL or missing references) //IL_07ff: Unknown result type (might be due to invalid IL or missing references) //IL_0828: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_08e4: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) EnsureStyles(); if (Core.DebugMode && MaterialConstructionPanel.Active) { MaterialConstructionPanel.DrawPalette(e); return; } if (!Core.DebugMode && ShowingMaterials) { MaterialConstructionPanel.DrawPalette(e, showAddButton: false); DrawCategoryPanel(e, PanelRect); return; } if (!PropLibrary.IsInitialized) { PanelRect = new Rect(10f, 10f, 110f, 40f); GUI.color = new Color(0f, 0f, 0f, 0.65f); GUI.Box(PanelRect, ""); GUI.color = Color.white; GUI.Label(new Rect(18f, 18f, 94f, 20f), "Loading props…"); return; } if (MaterialCatalog.IsLoadingMaterialSources) { PanelRect = new Rect(10f, 10f, 110f, 40f); GUI.color = new Color(0f, 0f, 0f, 0.65f); GUI.Box(PanelRect, ""); GUI.color = Color.white; GUI.Label(new Rect(18f, 18f, 94f, 20f), "Loading materials…"); return; } IReadOnlyList filteredProps = PropLibrary.FilteredProps; int count = filteredProps.Count; int visibleSlots = VisibleSlots; if (count != _lastFilterCount) { _scrollOffset = 0; _lastFilterCount = count; } _scrollOffset = Mathf.Clamp(_scrollOffset, 0, Mathf.Max(0, count - 1)); float num = 8f + (float)visibleSlots * 68f + 22f; Rect val = default(Rect); ((Rect)(ref val))..ctor(10f, 10f, 110f, num); PanelRect = val; GUI.color = new Color(0f, 0f, 0f, 0.65f); GUI.Box(val, ""); GUI.color = Color.white; Rect val2 = default(Rect); for (int i = 0; i < visibleSlots; i++) { int num2 = _scrollOffset + i; float num3 = 18f + (float)i * 68f; ((Rect)(ref val2))..ctor(18f, num3, 94f, 60f); if (num2 < count) { PropInfo propInfo = filteredProps[num2]; bool flag = propInfo.isLoaded && !propInfo.HasMesh; bool flag2 = PropMetadataStore.IsExcluded(propInfo.id); bool flag3 = ((Rect)(ref val2)).Contains(e.mousePosition) && !IsDragging && !flag && !flag2; string text = (Core.DebugMode ? propInfo.displayName : (PropMetadataStore.GetDisplayName(propInfo.id) ?? propInfo.displayName)); if (flag) { GUI.color = new Color(0.45f, 0.45f, 0.45f, 0.7f); if (GUI.Button(val2, text + "\n(no mesh)", _itemStyle)) { PropMetadataEditor.SetPaletteSelection(propInfo.id); } } else { GUI.color = (flag2 ? new Color(0.35f, 0.35f, 0.35f, 0.7f) : (flag3 ? new Color(1f, 1f, 1f, 0.95f) : new Color(0.6f, 0.6f, 0.6f, 0.85f))); GUI.Box(val2, text, _itemStyle); if ((int)e.type == 0 && e.button == 0 && ((Rect)(ref val2)).Contains(e.mousePosition)) { if (flag2) { PropMetadataEditor.SetPaletteSelection(propInfo.id); } else { _draggingIndex = num2; _dragStartFrame = Time.frameCount; GUI.FocusControl((string)null); if (!propInfo.isLoaded) { PropLibrary.LoadPropData(propInfo); } } e.Use(); } } if (Core.DebugMode) { if (flag2) { GUI.color = new Color(1f, 0.15f, 0.15f, 0.85f); GUI.Label(val2, "✕", _excludedXStyle); } if (PropMetadataStore.IsPartiallyFilled(propInfo.id)) { GUI.color = new Color(1f, 0.85f, 0f, 0.85f); GUI.Label(val2, "!", _warningStyle); } if (PropMetadataStore.HasMetadata(propInfo.id)) { GUI.color = new Color(0.4f, 1f, 0.4f, 0.95f); GUI.Label(new Rect(((Rect)(ref val2)).xMax - 16f, ((Rect)(ref val2)).y + 3f, 16f, 16f), "✓"); } } GUI.color = Color.white; } else { GUI.color = new Color(0.25f, 0.25f, 0.25f, 0.5f); GUI.Box(val2, "", _itemStyle); } } if (!IsDragging) { string text2 = null; Rect val3 = default(Rect); for (int j = 0; j < visibleSlots; j++) { if (text2 != null) { break; } int num4 = _scrollOffset + j; if (num4 >= count) { break; } float num5 = 18f + (float)j * 68f; ((Rect)(ref val3))..ctor(18f, num5, 94f, 60f); PropInfo propInfo2 = filteredProps[num4]; if (((Rect)(ref val3)).Contains(e.mousePosition)) { text2 = propInfo2.id; } } if (!string.IsNullOrEmpty(text2)) { GUI.color = new Color(1f, 1f, 1f, 0.9f); Vector2 mousePosition = e.mousePosition; Vector2 val4 = GUI.skin.box.CalcSize(new GUIContent(text2)); Rect val5 = default(Rect); ((Rect)(ref val5))..ctor(mousePosition.x + 12f, mousePosition.y + 12f, val4.x + 8f, val4.y + 6f); GUI.Box(val5, text2); GUI.color = Color.white; } } int value = ((count > 0) ? Mathf.CeilToInt((float)count / (float)visibleSlots) : 0); int value2 = ((count > 0) ? (_scrollOffset / visibleSlots + 1) : 0); GUI.color = new Color(0.75f, 0.75f, 0.75f, 1f); Rect val6 = default(Rect); ((Rect)(ref val6))..ctor(18f, 18f + (float)visibleSlots * 68f + 2f, 94f, 18f); GUI.Label(val6, $"{value2}/{value}"); if (Core.DebugMode && count > 0) { int scrollOffset = _scrollOffset; int num6 = Mathf.Min(_scrollOffset + visibleSlots, count); bool flag4 = true; for (int k = scrollOffset; k < num6; k++) { if (!PropMetadataStore.HasMetadata(filteredProps[k].id)) { flag4 = false; break; } } if (flag4) { GUI.color = new Color(0.4f, 1f, 0.4f, 0.95f); GUI.Label(new Rect(((Rect)(ref val6)).x + 38f, ((Rect)(ref val6)).y, 16f, 18f), "✓"); } } GUI.color = Color.white; if (IsDragging && ((Rect)(ref val)).Contains(e.mousePosition)) { GUI.color = new Color(1f, 1f, 0.4f, 0.8f); GUI.Box(new Rect(e.mousePosition.x + 12f, e.mousePosition.y + 12f, 70.5f, 45f), DraggingProp.displayName, _ghostStyle); GUI.color = Color.white; } if (!Core.DebugMode) { DrawCategoryPanel(e, val); } } private static void DrawCategoryPanel(Event e, Rect mainPanelRect) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) if (_cachedCategories == null) { _cachedCategories = PropMetadataStore.GetAllCategories(); } List cachedCategories = _cachedCategories; int num = cachedCategories.Count + 2; float num2 = ((Rect)(ref mainPanelRect)).xMax + 10f; float num3 = 98f; float num4 = 6f + (float)num * 32f; Rect val = default(Rect); ((Rect)(ref val))..ctor(num2, 10f, 110f, num4); GUI.color = new Color(0f, 0f, 0f, 0.65f); GUI.Box(val, ""); GUI.color = Color.white; Rect val2 = default(Rect); for (int i = 0; i < num; i++) { bool flag = i == num - 1; string text = ((i == 0 || flag) ? null : cachedCategories[i - 1]); string text2 = (flag ? "Materials" : (text ?? "(All)")); bool flag2 = (flag ? ShowingMaterials : (!ShowingMaterials && ((text == null && SelectedCategory == null) || (text != null && string.Equals(text, SelectedCategory, StringComparison.OrdinalIgnoreCase))))); float num5 = 16f + (float)i * 32f; ((Rect)(ref val2))..ctor(num2 + 6f, num5, num3, 26f); GUI.color = (flag2 ? new Color(1f, 0.85f, 0.3f, 0.95f) : new Color(0.6f, 0.6f, 0.6f, 0.85f)); if (GUI.Button(val2, text2, _catStyle) && !flag2) { if (flag) { ShowingMaterials = true; } else { ShowingMaterials = false; SelectedCategory = text; PropLibrary.RebuildFiltered(); } e.Use(); } GUI.color = Color.white; } } private static void EnsureStyles() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_004b: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown GuiStyleHelpers.EnsureItemAndGhostStyles(ref _itemStyle, ref _ghostStyle); if (_excludedXStyle == null) { _excludedXStyle = new GUIStyle(GUI.skin.label) { fontSize = 38, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _excludedXStyle.normal.textColor = new Color(1f, 0.15f, 0.15f, 0.9f); } if (_warningStyle == null) { _warningStyle = new GUIStyle(GUI.skin.label) { fontSize = 38, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _warningStyle.normal.textColor = new Color(1f, 0.85f, 0f, 0.9f); } if (_catStyle == null) { RectOffset padding = new RectOffset { left = 4, right = 4, top = 2, bottom = 2 }; _catStyle = new GUIStyle(GUI.skin.button) { wordWrap = false, alignment = (TextAnchor)4, clipping = (TextClipping)1, padding = padding, fontSize = 11 }; } } } internal static class MaterialConstructionPanel { private const float Pad = 8f; private const float ItemH = 60f; private const float PanelW = 110f; private const float ItemW = 94f; private const float AutoSaveDelay = 0.75f; private const int PreviewSize = 128; private const string NameField = "matConstructionName"; private const string SearchField = "matConstructionSearch"; private static bool _active; private static readonly Dictionary _origCache = new Dictionary(); private static readonly Dictionary _origTagCache = new Dictionary(); private static MaterialConstructionEntry _editing; private static int _draggingIndex = -1; private static int _dragStartFrame = -1; private static int _scrollOffset; private static float _scrollTimer; private static bool _scrollActive; private static bool _scrollInDelay; private const float ScrollInitialDelay = 0.35f; private const float ScrollRepeatInterval = 0.08f; private static bool _showMaterialDropdown; private static bool _showSurfaceDropdown; private static string _materialSearch = ""; private static Vector2 _materialScroll; private static Vector2 _surfaceScroll; private static bool _dirty; private static float _lastChangeTime; private static GUIStyle _itemStyle; private static GUIStyle _ghostStyle; private static GUIStyle _buttonStyle; private static GUIStyle _headerStyle; private static readonly List _displayEntries = new List(); private static GameObject _previewRoot; private static GameObject _previewSphere; private static Renderer _previewRenderer; private static Camera _previewCamera; private static RenderTexture _previewRT; private static Material _defaultPreviewMaterial; private static string _previewMatName; public static bool IsTypingInUI { get { if (!Active) { return false; } string nameOfFocusedControl = GUI.GetNameOfFocusedControl(); return nameOfFocusedControl == "matConstructionName" || nameOfFocusedControl == "matConstructionSearch"; } } private static int VisibleSlots => Mathf.Clamp(Mathf.FloorToInt(((float)Screen.height - 50f) / 68f), 4, 15); public static bool Active { get { return _active; } set { _active = value; if (!value) { CancelDrag(); _showMaterialDropdown = false; _showSurfaceDropdown = false; } } } public static bool IsDragging => _draggingIndex >= 0 && _draggingIndex < _displayEntries.Count; public static MaterialConstructionEntry DraggingEntry => IsDragging ? _displayEntries[_draggingIndex] : null; public static bool JustStartedDrag => IsDragging && Time.frameCount == _dragStartFrame; public static void CancelDrag() { _draggingIndex = -1; } public static void HandleScrollInput() { if ((!Core.DebugMode || !Active) && (Core.DebugMode || !PropPalette.ShowingMaterials)) { return; } int count = MaterialConstructionLibrary.Entries.Count; if (count == 0) { return; } bool key = Input.GetKey((KeyCode)45); bool key2 = Input.GetKey((KeyCode)61); if (!key && !key2) { _scrollActive = false; _scrollTimer = 0f; return; } int dir = ((!key) ? 1 : (-1)); int visibleSlots = VisibleSlots; if (!_scrollActive) { _scrollActive = true; _scrollInDelay = true; _scrollTimer = 0f; _scrollOffset = PropPalette.StepPageOffset(_scrollOffset, dir, visibleSlots, count); return; } _scrollTimer += Time.unscaledDeltaTime; float num = (_scrollInDelay ? 0.35f : 0.08f); if (_scrollTimer >= num) { _scrollTimer -= num; _scrollInDelay = false; _scrollOffset = PropPalette.StepPageOffset(_scrollOffset, dir, visibleSlots, count); } } public static void DrawPalette(Event e, bool showAddButton = true) { //IL_00b4: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Invalid comparison between Unknown and I4 //IL_00ff: 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_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_045c: 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_021b: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_0510: Unknown result type (might be due to invalid IL or missing references) EnsureStyles(); _displayEntries.Clear(); _displayEntries.AddRange(MaterialConstructionLibrary.Entries); _displayEntries.Sort((MaterialConstructionEntry a, MaterialConstructionEntry b) => string.Compare(a.name, b.name, StringComparison.OrdinalIgnoreCase)); List displayEntries = _displayEntries; int count = displayEntries.Count; int visibleSlots = VisibleSlots; _scrollOffset = Mathf.Clamp(_scrollOffset, 0, Mathf.Max(0, count - 1)); float num = 8f + (float)visibleSlots * 68f + (showAddButton ? 22f : 0f) + 18f; Rect val = default(Rect); ((Rect)(ref val))..ctor(10f, 10f, 110f, num); PropPalette.PanelRect = val; GUI.color = new Color(0f, 0f, 0f, 0.65f); GUI.Box(val, ""); GUI.color = Color.white; if ((int)e.type == 6 && ((Rect)(ref val)).Contains(e.mousePosition) && count > visibleSlots) { int dir = (int)Mathf.Sign(e.delta.y); _scrollOffset = PropPalette.StepPageOffset(_scrollOffset, dir, visibleSlots, count); e.Use(); } Rect val2 = default(Rect); for (int num2 = 0; num2 < visibleSlots; num2++) { int num3 = _scrollOffset + num2; float num4 = 18f + (float)num2 * 68f; ((Rect)(ref val2))..ctor(18f, num4, 94f, 60f); if (num3 < count) { MaterialConstructionEntry materialConstructionEntry = displayEntries[num3]; bool flag = showAddButton && _editing == materialConstructionEntry; bool flag2 = ((Rect)(ref val2)).Contains(e.mousePosition) && !IsDragging; GUI.color = (flag ? new Color(1f, 0.85f, 0.3f, 0.95f) : (flag2 ? new Color(1f, 1f, 1f, 0.95f) : new Color(0.6f, 0.6f, 0.6f, 0.85f))); GUI.Box(val2, materialConstructionEntry.name, _itemStyle); if ((int)e.type == 0 && e.button == 0 && ((Rect)(ref val2)).Contains(e.mousePosition)) { if (showAddButton) { _editing = materialConstructionEntry; _showMaterialDropdown = false; _showSurfaceDropdown = false; } _draggingIndex = num3; _dragStartFrame = Time.frameCount; GUI.FocusControl((string)null); e.Use(); } } else { GUI.color = new Color(0.25f, 0.25f, 0.25f, 0.5f); GUI.Box(val2, "", _itemStyle); } } GUI.color = Color.white; if (showAddButton) { Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(18f, 18f + (float)visibleSlots * 68f + 2f, 94f, 18f); if (GUI.Button(val3, "+ New")) { _editing = MaterialConstructionLibrary.CreateNew(); _showMaterialDropdown = false; _showSurfaceDropdown = false; } } if (count > 0) { int value = Mathf.CeilToInt((float)count / (float)visibleSlots); int value2 = _scrollOffset / visibleSlots + 1; GUI.color = new Color(0.75f, 0.75f, 0.75f, 1f); float num5 = 18f + (float)visibleSlots * 68f + (showAddButton ? 22f : 2f); GUI.Label(new Rect(18f, num5, 94f, 18f), $"{value2}/{value}"); GUI.color = Color.white; } if (count == 0) { GUI.color = new Color(1f, 1f, 1f, 0.85f); string text = (showAddButton ? "No materials yet.\nClick + New below." : "No materials created yet."); GUI.Label(new Rect(18f, 18f, 94f, 60f), text, _itemStyle); GUI.color = Color.white; } if (IsDragging && ((Rect)(ref val)).Contains(e.mousePosition)) { GUI.color = new Color(1f, 1f, 0.4f, 0.8f); GUI.Box(new Rect(e.mousePosition.x + 12f, e.mousePosition.y + 12f, 70.5f, 45f), DraggingEntry?.name ?? "", _ghostStyle); GUI.color = Color.white; } } public static void DrawConstructor() { //IL_01c6: 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) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) EnsureStyles(); GUILayout.Label("Material Construction", _headerStyle, (Il2CppReferenceArray)null); GUILayout.Space(4f); GUILayout.Label("Items on the left are your saved material+surface combos. Click one to edit it here, or drag it onto a prop in the world to apply it to just that prop.", (Il2CppReferenceArray)null); GUILayout.Space(8f); if (GUILayout.Button("New Material", (Il2CppReferenceArray)null)) { _editing = MaterialConstructionLibrary.CreateNew(); _showMaterialDropdown = false; _showSurfaceDropdown = false; } MaterialConstructionEntry editing = _editing; if (editing == null || !MaterialConstructionLibrary.Entries.Contains(editing)) { _editing = null; GUILayout.Space(8f); GUILayout.Label("Select an item on the left to edit it, or click New Material to create one.", (Il2CppReferenceArray)null); AutoSaveIfIdle(); return; } GUILayout.Space(8f); GUILayout.Label("Name", (Il2CppReferenceArray)null); GUI.SetNextControlName("matConstructionName"); string text = GUILayout.TextField(editing.name ?? "", Array.Empty()); if (!string.Equals(text, editing.name, StringComparison.Ordinal)) { editing.name = text; MarkDirty(); } GUILayout.Space(8f); DrawSpherePreview(editing); GUILayout.Space(8f); GUILayout.Label("Material", (Il2CppReferenceArray)null); string text2 = (string.IsNullOrEmpty(editing.materialName) ? "(no override)" : editing.materialName); if (GUILayout.Button(text2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) })) { _showMaterialDropdown = !_showMaterialDropdown; } if (_showMaterialDropdown) { MaterialCatalog.EnsureMaterialListLoaded(); GUILayout.Label("Search", (Il2CppReferenceArray)null); GUI.SetNextControlName("matConstructionSearch"); _materialSearch = GUILayout.TextField(_materialSearch ?? "", Array.Empty()); _materialScroll = GUILayout.BeginScrollView(_materialScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(140f) }); List materialNames = MaterialCatalog.MaterialNames; List materialLabels = MaterialCatalog.MaterialLabels; string value = (_materialSearch ?? "").Trim(); bool flag = !string.IsNullOrEmpty(value); for (int i = 0; i < materialLabels.Count; i++) { string text3 = materialLabels[i]; if (!flag || text3.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { string text4 = ((i == 0) ? string.Empty : materialNames[i]); if (string.Equals(text4, editing.materialName, StringComparison.OrdinalIgnoreCase)) { text3 = "> " + text3; } if (GUILayout.Button(text3, _buttonStyle, Array.Empty())) { editing.materialName = text4; _showMaterialDropdown = false; MarkDirty(); } } } GUILayout.EndScrollView(); } GUILayout.Space(8f); GUILayout.Label("Surface type (traction / footstep audio)", (Il2CppReferenceArray)null); string text5 = (string.IsNullOrEmpty(editing.surfaceType) ? "(none — game default)" : editing.surfaceType); if (GUILayout.Button(text5, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) })) { _showSurfaceDropdown = !_showSurfaceDropdown; } if (_showSurfaceDropdown) { _surfaceScroll = GUILayout.BeginScrollView(_surfaceScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(120f) }); string[] knownSurfaceTags = PropMetadataEditor.KnownSurfaceTags; foreach (string text6 in knownSurfaceTags) { string text7 = (string.IsNullOrEmpty(text6) ? "(none — game default)" : text6); if (string.Equals(text6, editing.surfaceType, StringComparison.Ordinal)) { text7 = "> " + text7; } if (GUILayout.Button(text7, _buttonStyle, Array.Empty())) { editing.surfaceType = text6; _showSurfaceDropdown = false; MarkDirty(); } } GUILayout.EndScrollView(); } GUILayout.Space(8f); bool flag2 = GUILayout.Toggle(editing.sunglassesNeeded, "Sunglasses Needed", (Il2CppReferenceArray)null); if (flag2 != editing.sunglassesNeeded) { editing.sunglassesNeeded = flag2; MarkDirty(); } GUILayout.Space(12f); if (GUILayout.Button("Delete this material", (Il2CppReferenceArray)null)) { MaterialConstructionLibrary.Delete(editing); if (IsDragging && DraggingEntry == editing) { CancelDrag(); } _editing = null; } AutoSaveIfIdle(); } private static void MarkDirty() { _dirty = true; _lastChangeTime = Time.unscaledTime; MaterialConstructionLibrary.MarkDirty(); } private static void AutoSaveIfIdle() { if (_dirty && !(Time.unscaledTime - _lastChangeTime < 0.75f)) { MaterialConstructionLibrary.Save(); _dirty = false; } } private static void DrawSpherePreview(MaterialConstructionEntry entry) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) EnsurePreviewRig(); UpdatePreview(entry.materialName); _previewCamera.Render(); GUILayout.BeginHorizontal((Il2CppReferenceArray)null); GUILayout.FlexibleSpace(); Rect rect = GUILayoutUtility.GetRect(128f, 128f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(128f), GUILayout.Height(128f) }); GUI.DrawTexture(rect, (Texture)(object)_previewRT); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } private static void EnsurePreviewRig() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: 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_0250: Expected O, but got Unknown if (!((Object)(object)_previewRoot != (Object)null)) { int num = MaterialBaker.FindUnusedLayer(); _previewRoot = new GameObject("BabyBlocks_MatConstructionPreview"); _previewRoot.transform.position = new Vector3(0f, 50000f, 0f); Object.DontDestroyOnLoad((Object)(object)_previewRoot); _previewSphere = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)_previewSphere).name = "PreviewSphere"; _previewSphere.transform.SetParent(_previewRoot.transform, false); _previewSphere.transform.localPosition = Vector3.zero; _previewSphere.layer = num; Collider component = _previewSphere.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } _previewRenderer = _previewSphere.GetComponent(); _defaultPreviewMaterial = _previewRenderer.sharedMaterial; GameObject val = new GameObject("PreviewLight"); val.transform.SetParent(_previewRoot.transform, false); val.transform.rotation = Quaternion.Euler(40f, -30f, 0f); Light val2 = val.AddComponent(); val2.type = (LightType)1; val2.cullingMask = 1 << num; val2.intensity = 1.2f; GameObject val3 = new GameObject("PreviewCamera"); val3.transform.SetParent(_previewRoot.transform, false); val3.transform.localPosition = new Vector3(0f, 0f, -2.6f); val3.transform.localRotation = Quaternion.identity; _previewCamera = val3.AddComponent(); ((Behaviour)_previewCamera).enabled = false; _previewCamera.clearFlags = (CameraClearFlags)2; _previewCamera.backgroundColor = new Color(0.12f, 0.12f, 0.12f, 1f); _previewCamera.cullingMask = 1 << num; _previewCamera.fieldOfView = 28f; _previewCamera.nearClipPlane = 0.05f; _previewCamera.farClipPlane = 10f; _previewRT = new RenderTexture(128, 128, 16, (RenderTextureFormat)0); _previewRT.Create(); _previewCamera.targetTexture = _previewRT; } } private static void UpdatePreview(string materialName) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (!string.Equals(materialName, _previewMatName, StringComparison.Ordinal)) { _previewMatName = materialName; Material val = null; if (!string.IsNullOrEmpty(materialName)) { MaterialCatalog.EnsureMaterialListLoaded(); val = MaterialCatalog.ResolveMaterialByName(materialName); } _previewRenderer.sharedMaterial = (((Object)(object)val != (Object)null) ? val : _defaultPreviewMaterial); } _previewSphere.transform.rotation = Quaternion.Euler(15f, Time.realtimeSinceStartup * 25f % 360f, 0f); } public static void TryApplyToHoveredProp() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) MaterialConstructionEntry draggingEntry = DraggingEntry; if (draggingEntry == null) { return; } Ray val = Camera.main.ScreenPointToRay(Input.mousePosition); LevelEditorObject levelEditorObject = null; float num = float.MaxValue; foreach (RaycastHit item in (Il2CppArrayBase)(object)Physics.RaycastAll(val, 2000f, ~GizmoRenderer.Mask, (QueryTriggerInteraction)2)) { RaycastHit current = item; if (!(((RaycastHit)(ref current)).distance >= num)) { LevelEditorObject levelEditorObject2 = ((Component)((RaycastHit)(ref current)).collider).GetComponent() ?? ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent(); if (!((Object)(object)levelEditorObject2 == (Object)null)) { num = ((RaycastHit)(ref current)).distance; levelEditorObject = levelEditorObject2; } } } if (!((Object)(object)levelEditorObject == (Object)null)) { ApplyToInstance(levelEditorObject, draggingEntry); if (levelEditorObject.netId != 0) { ModNetworking.SendMaterialApplied(levelEditorObject.netId, draggingEntry); } } } public static void ApplyToInstance(LevelEditorObject leo, MaterialConstructionEntry entry, bool pushHistory = true) { if ((Object)(object)leo == (Object)null || entry == null) { return; } if (entry.id == int.MinValue) { ResetToDefaultMaterials(leo, pushHistory); return; } Il2CppArrayBase componentsInChildren = ((Component)leo).GetComponentsInChildren(true); Material[][] array = new Material[componentsInChildren.Length][]; for (int i = 0; i < componentsInChildren.Length; i++) { array[i] = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)(((Object)(object)componentsInChildren[i] != (Object)null) ? componentsInChildren[i].sharedMaterials : null)); } Il2CppArrayBase componentsInChildren2 = ((Component)leo).GetComponentsInChildren(true); GameObject[] array2 = (GameObject[])(object)new GameObject[1 + componentsInChildren2.Length]; array2[0] = ((Component)leo).gameObject; for (int j = 0; j < componentsInChildren2.Length; j++) { array2[1 + j] = (((Object)(object)componentsInChildren2[j] != (Object)null) ? ((Component)componentsInChildren2[j]).gameObject : null); } string[] array3 = new string[array2.Length]; for (int k = 0; k < array2.Length; k++) { array3[k] = (((Object)(object)array2[k] != (Object)null) ? array2[k].tag : null); } int materialConstructionId = leo.materialConstructionId; if (leo.materialConstructionId < 0) { int instanceID = ((Object)((Component)leo).gameObject).GetInstanceID(); if (!_origCache.ContainsKey(instanceID)) { Material[][] array4 = new Material[componentsInChildren.Length][]; for (int l = 0; l < componentsInChildren.Length; l++) { Renderer obj = componentsInChildren[l]; Il2CppReferenceArray val = ((obj != null) ? obj.sharedMaterials : null); if (val != null && ((Il2CppArrayBase)(object)val).Length != 0) { array4[l] = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)val); } } _origCache[instanceID] = array4; _origTagCache[instanceID] = ((Component)leo).gameObject.tag; } } if (!string.IsNullOrEmpty(entry.materialName)) { MaterialCatalog.EnsureMaterialListLoaded(); Material val2 = MaterialCatalog.ResolveMaterialByName(entry.materialName); if ((Object)(object)val2 != (Object)null) { for (int m = 0; m < componentsInChildren.Length; m++) { Renderer val3 = componentsInChildren[m]; if (!((Object)(object)val3 == (Object)null)) { Il2CppReferenceArray sharedMaterials = val3.sharedMaterials; int num = ((sharedMaterials == null || ((Il2CppArrayBase)(object)sharedMaterials).Length <= 0) ? 1 : ((Il2CppArrayBase)(object)sharedMaterials).Length); Material[] array5 = (Material[])(object)new Material[num]; for (int n = 0; n < num; n++) { array5[n] = val2; } val3.sharedMaterials = Il2CppReferenceArray.op_Implicit(array5); } } } } PropInstanceServices.ApplySurfaceType(leo, entry.surfaceType); leo.materialConstructionId = entry.id; BbSunglassesChecker component = ((Component)leo).GetComponent(); if (entry.sunglassesNeeded) { if ((Object)(object)component == (Object)null) { ((Component)leo).gameObject.AddComponent(); } } else if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } if (pushHistory) { LevelEditorHistory.PushMaterial(leo, Il2CppArrayBase.op_Implicit(componentsInChildren), array, array2, array3, materialConstructionId); PropHistory.RecordMaterialUse(entry.id); } } internal static void EnsureOriginalsCache(LevelEditorObject leo) { if ((Object)(object)leo == (Object)null) { return; } int instanceID = ((Object)((Component)leo).gameObject).GetInstanceID(); if (_origCache.ContainsKey(instanceID)) { return; } Il2CppArrayBase componentsInChildren = ((Component)leo).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } Material[][] array = new Material[componentsInChildren.Length][]; for (int i = 0; i < componentsInChildren.Length; i++) { Renderer obj = componentsInChildren[i]; Il2CppReferenceArray val = ((obj != null) ? obj.sharedMaterials : null); if (val != null && ((Il2CppArrayBase)(object)val).Length > 0) { array[i] = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)val); } } _origCache[instanceID] = array; _origTagCache[instanceID] = ((Component)leo).gameObject.tag; } public static void ResetInstance(LevelEditorObject leo, bool pushHistory = true) { ResetToDefaultMaterials(leo, pushHistory); } private static void ResetToDefaultMaterials(LevelEditorObject leo, bool pushHistory) { Il2CppArrayBase componentsInChildren = ((Component)leo).GetComponentsInChildren(true); Material[][] array = new Material[componentsInChildren.Length][]; for (int i = 0; i < componentsInChildren.Length; i++) { array[i] = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)(((Object)(object)componentsInChildren[i] != (Object)null) ? componentsInChildren[i].sharedMaterials : null)); } Il2CppArrayBase componentsInChildren2 = ((Component)leo).GetComponentsInChildren(true); GameObject[] array2 = (GameObject[])(object)new GameObject[1 + componentsInChildren2.Length]; array2[0] = ((Component)leo).gameObject; for (int j = 0; j < componentsInChildren2.Length; j++) { array2[1 + j] = (((Object)(object)componentsInChildren2[j] != (Object)null) ? ((Component)componentsInChildren2[j]).gameObject : null); } string[] array3 = new string[array2.Length]; for (int k = 0; k < array2.Length; k++) { array3[k] = (((Object)(object)array2[k] != (Object)null) ? array2[k].tag : null); } int materialConstructionId = leo.materialConstructionId; int instanceID = ((Object)((Component)leo).gameObject).GetInstanceID(); if (_origCache.TryGetValue(instanceID, out var value) && value != null) { for (int l = 0; l < componentsInChildren.Length && l < value.Length; l++) { if (!((Object)(object)componentsInChildren[l] == (Object)null) && value[l] != null) { componentsInChildren[l].sharedMaterials = Il2CppReferenceArray.op_Implicit(value[l]); } } } else { PropInfo propInfo = PropLibrary.FindById(leo.addressableKey); if ((Object)(object)propInfo?.sourcePrefab != (Object)null) { Il2CppArrayBase componentsInChildren3 = propInfo.sourcePrefab.GetComponentsInChildren(true); for (int m = 0; m < componentsInChildren.Length && m < componentsInChildren3.Length; m++) { if (!((Object)(object)componentsInChildren[m] == (Object)null) && !((Object)(object)componentsInChildren3[m] == (Object)null)) { componentsInChildren[m].sharedMaterials = componentsInChildren3[m].sharedMaterials; } } } else { MelonLogger.Warning("[BabyBlocks] Reset to Default: no cached originals and no sourcePrefab for '" + leo.addressableKey + "' — apply a material first so originals can be captured."); } } int instanceID2 = ((Object)((Component)leo).gameObject).GetInstanceID(); if (_origTagCache.TryGetValue(instanceID2, out var value2)) { PropInstanceServices.ApplySurfaceType(leo, value2); } BbSunglassesChecker component = ((Component)leo).GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } leo.materialConstructionId = -1; if (pushHistory) { LevelEditorHistory.PushMaterial(leo, Il2CppArrayBase.op_Implicit(componentsInChildren), array, array2, array3, materialConstructionId); } } private static void EnsureStyles() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0044: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown GuiStyleHelpers.EnsureItemAndGhostStyles(ref _itemStyle, ref _ghostStyle); if (_buttonStyle == null) { RectOffset padding = new RectOffset { left = 6, right = 6, top = 2, bottom = 2 }; _buttonStyle = new GUIStyle(GUI.skin.button) { alignment = (TextAnchor)3, padding = padding }; } if (_headerStyle == null) { _headerStyle = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)1 }; } } } internal static class PhysicsWindow { private const float WinW = 210f; private const float HeaderH = 30f; private const float Pad = 7f; private const float LineH = 22f; private static Rect _windowRect; private static bool _initialized; private static bool _dragging; private static Vector2 _dragOffset; private static string[] _grabPosStr = new string[3] { "0", "0", "0" }; private static string[] _grabRotStr = new string[3] { "0", "0", "0" }; private static string[] _hatPosStr = new string[3] { "0", "0", "0" }; private static string[] _hatRotStr = new string[3] { "0", "0", "0" }; private static LevelEditorObject _lastPrimary; public static bool IsTypingInUI { get; private set; } private static void EnsureInit() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (!_initialized) { _initialized = true; float num = ComputeHeight(showGroup: false, showHatHair: false, showGrabOffset: false, showHatOffset: false, showBakeToggle: false); _windowRect = new Rect((float)Screen.width - 320f - 210f - 10f, (float)Screen.height - num - 40f, 210f, num); } } private static float ComputeHeight(bool showGroup, bool showHatHair, bool showGrabOffset, bool showHatOffset, bool showBakeToggle) { return 59f + (showHatHair ? 46f : 0f) + (showGrabOffset ? 66f : 0f) + (showHatOffset ? 66f : 0f) + (showGroup ? 22f : 0f) + (showBakeToggle ? 22f : 0f) + 22f + 22f + 7f; } public static bool ContainsPoint(Vector2 guiPoint) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return _initialized && ((Rect)(ref _windowRect)).Contains(guiPoint); } public static void DrawGUI(Event e) { //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Invalid comparison between Unknown and I4 //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Invalid comparison between Unknown and I4 //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_0620: 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_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06dc: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: 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_0706: 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_0519: Unknown result type (might be due to invalid IL or missing references) //IL_074f: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Unknown result type (might be due to invalid IL or missing references) //IL_07ad: Unknown result type (might be due to invalid IL or missing references) //IL_07c6: Unknown result type (might be due to invalid IL or missing references) //IL_07cb: Unknown result type (might be due to invalid IL or missing references) //IL_07d7: Unknown result type (might be due to invalid IL or missing references) //IL_07db: Unknown result type (might be due to invalid IL or missing references) //IL_0716: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07eb: Unknown result type (might be due to invalid IL or missing references) //IL_072d: Unknown result type (might be due to invalid IL or missing references) //IL_072f: 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_07fe: Unknown result type (might be due to invalid IL or missing references) //IL_0800: Unknown result type (might be due to invalid IL or missing references) //IL_098c: Unknown result type (might be due to invalid IL or missing references) //IL_09d1: Unknown result type (might be due to invalid IL or missing references) //IL_0a0a: Unknown result type (might be due to invalid IL or missing references) EnsureInit(); IReadOnlyList selectedObjects = LevelEditor.SelectedObjects; bool flag = false; PhysicsMode? physicsMode = null; int num = 0; bool flag2 = false; LevelEditorObject selectedObject = LevelEditor.selectedObject; HashSet hashSet = new HashSet(); foreach (LevelEditorObject item in selectedObjects) { if ((Object)(object)item == (Object)null) { continue; } if (!flag) { flag = true; physicsMode = item.physicsMode; num = item.groupId; } else { if (physicsMode != item.physicsMode) { physicsMode = null; } if (num != item.groupId) { num = 0; } } if (item.groupId > 0) { flag2 = true; } if (!string.IsNullOrEmpty(item.addressableKey)) { hashSet.Add(item.addressableKey); } } bool? flag3 = null; bool flag4 = true; foreach (string item2 in hashSet) { bool disableBaking = PropMetadataStore.GetDisableBaking(item2); if (flag4) { flag3 = disableBaking; flag4 = false; } else if (flag3 != disableBaking) { flag3 = null; } } bool flag5 = flag && num > 0; bool flag6 = flag && (Object)(object)selectedObject != (Object)null && selectedObject.physicsMode == PhysicsMode.Hat; bool flag7 = flag && (Object)(object)selectedObject != (Object)null && selectedObject.physicsMode == PhysicsMode.Grabable; bool flag8 = flag && (Object)(object)selectedObject != (Object)null && selectedObject.physicsMode == PhysicsMode.Hat; bool flag9 = hashSet.Count > 0; if ((Object)(object)selectedObject != (Object)(object)_lastPrimary) { _lastPrimary = selectedObject; SyncStrings(selectedObject); } float num2 = ComputeHeight(flag5, flag6, flag7, flag8, flag9); ((Rect)(ref _windowRect)).width = 210f; ((Rect)(ref _windowRect)).height = num2; ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, (float)Screen.width - 210f); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, (float)Screen.height - num2); GUI.color = new Color(0f, 0f, 0f, 0.72f); GUI.Box(_windowRect, ""); GUI.color = Color.white; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y, 210f, 30f); GUI.Label(new Rect(((Rect)(ref _windowRect)).x + 7f, ((Rect)(ref _windowRect)).y + 6f, 196f, 20f), "Physics"); if ((int)e.type == 0 && e.button == 0 && ((Rect)(ref val)).Contains(e.mousePosition)) { _dragging = true; _dragOffset = e.mousePosition - new Vector2(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y); e.Use(); } if (_dragging) { if ((int)e.type == 3) { ((Rect)(ref _windowRect)).x = e.mousePosition.x - _dragOffset.x; ((Rect)(ref _windowRect)).y = e.mousePosition.y - _dragOffset.y; e.Use(); } if ((int)e.type == 1) { _dragging = false; } } float num3 = ((Rect)(ref _windowRect)).y + 30f + 7f; float num4 = ((Rect)(ref _windowRect)).x + 7f; float num5 = 196f; string text = ((!flag) ? "—" : ((!physicsMode.HasValue) ? "Mixed" : ((physicsMode == PhysicsMode.Static) ? "Static" : ((physicsMode == PhysicsMode.Rigidbody) ? "Rigidbody" : ((physicsMode == PhysicsMode.Grabable) ? "Grabable" : "Hat"))))); GUI.Label(new Rect(num4, num3, num5, 22f), "Mode: " + text); num3 += 22f; if (flag9) { bool valueOrDefault = flag3 == true; string text2 = ((!flag3.HasValue) ? " Disable texture baking (Mixed)" : " Disable texture baking"); bool flag10 = GUI.Toggle(new Rect(num4, num3, num5, 22f), valueOrDefault, text2); if (flag10 != valueOrDefault) { foreach (string item3 in hashSet) { PropMetadataStore.SetDisableBaking(item3, flag10); if ((Object)(object)LevelEditorManager.Instance != (Object)null) { PhysicsObjectManager.RefreshBakingForProp(item3); } } } num3 += 22f; } if (flag6) { GUI.Label(new Rect(num4, num3, num5, 22f), $"Hair cut: {Mathf.RoundToInt(Mathf.Clamp01(selectedObject.hatHairAmt) * 100f)}%"); num3 += 22f; float num6 = GUI.HorizontalSlider(new Rect(num4, num3 + 4f, num5, 18f), selectedObject.hatHairAmt, 0f, 1f); if (!Mathf.Approximately(num6, selectedObject.hatHairAmt)) { LevelEditor.SetHatHairAmount(num6); } num3 += 24f; } if (flag7) { GUI.Label(new Rect(num4, num3, num5, 22f), "Grab Offset"); num3 += 22f; Vector3 val2 = Vec3Row(num4, num3, num5, "Pos", selectedObject.grabOffsetPos, _grabPosStr, "grab_px", "grab_py", "grab_pz"); num3 += 22f; Vector3 val3 = Vec3Row(num4, num3, num5, "Rot", selectedObject.grabOffsetRot, _grabRotStr, "grab_rx", "grab_ry", "grab_rz"); num3 += 22f; if (val2 != selectedObject.grabOffsetPos || val3 != selectedObject.grabOffsetRot) { LevelEditor.SetGrabOffset(val2, val3); } } if (flag8) { GUI.Label(new Rect(num4, num3, num5, 22f), "Hat Offset"); num3 += 22f; Vector3 val4 = Vec3Row(num4, num3, num5, "Pos", selectedObject.hatOffsetPos, _hatPosStr, "hat_px", "hat_py", "hat_pz"); num3 += 22f; Vector3 val5 = Vec3Row(num4, num3, num5, "Rot", selectedObject.hatOffsetRot, _hatRotStr, "hat_rx", "hat_ry", "hat_rz"); num3 += 22f; if (val4 != selectedObject.hatOffsetPos || val5 != selectedObject.hatOffsetRot) { LevelEditor.SetHatOffset(val4, val5); } } string nameOfFocusedControl = GUI.GetNameOfFocusedControl(); int isTypingInUI; switch (nameOfFocusedControl) { default: isTypingInUI = ((nameOfFocusedControl == "hat_rz") ? 1 : 0); break; case "grab_px": case "grab_py": case "grab_pz": case "grab_rx": case "grab_ry": case "grab_rz": case "hat_px": case "hat_py": case "hat_pz": case "hat_rx": case "hat_ry": isTypingInUI = 1; break; } IsTypingInUI = (byte)isTypingInUI != 0; if (flag5) { GUI.Label(new Rect(num4, num3, num5, 22f), $"Group: {num}"); num3 += 22f; } string text3 = ((!flag) ? "Cycle" : ((!physicsMode.HasValue) ? "→ Static" : ((physicsMode == PhysicsMode.Static) ? "→ Rigidbody" : ((physicsMode == PhysicsMode.Rigidbody) ? "→ Grabable" : ((physicsMode == PhysicsMode.Grabable) ? "→ Hat" : "→ Static"))))); GUI.enabled = flag; if (GUI.Button(new Rect(num4, num3, num5, 22f), text3)) { CycleMode(physicsMode); } num3 += 24f; float num7 = (num5 - 6f) * 0.5f; GUI.enabled = flag; if (GUI.Button(new Rect(num4, num3, num7, 22f), "Group")) { LevelEditor.GroupSelection(); } GUI.enabled = flag && flag2; if (GUI.Button(new Rect(num4 + num7 + 6f, num3, num7, 22f), "Ungroup")) { LevelEditor.UngroupSelection(); } GUI.enabled = true; } private static Vector3 Vec3Row(float x, float y, float w, string label, Vector3 current, string[] strs, string ctrlX, string ctrlY, string ctrlZ) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) float num = (w - 28f - 6f) / 3f; GUI.Label(new Rect(x, y + 2f, 28f, 22f), label); float num2 = x + 28f; GUI.SetNextControlName(ctrlX); strs[0] = GUI.TextField(new Rect(num2, y + 1f, num, 20f), strs[0]); num2 += num + 3f; GUI.SetNextControlName(ctrlY); strs[1] = GUI.TextField(new Rect(num2, y + 1f, num, 20f), strs[1]); num2 += num + 3f; GUI.SetNextControlName(ctrlZ); strs[2] = GUI.TextField(new Rect(num2, y + 1f, num, 20f), strs[2]); float num3 = TryParseFloat(strs[0], current.x); float num4 = TryParseFloat(strs[1], current.y); float num5 = TryParseFloat(strs[2], current.z); return new Vector3(num3, num4, num5); } private static float TryParseFloat(string s, float fallback) { float result; return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out result) ? result : fallback; } private static void SyncStrings(LevelEditorObject primary) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)primary == (Object)null) { for (int i = 0; i < 3; i++) { _grabPosStr[i] = (_grabRotStr[i] = (_hatPosStr[i] = (_hatRotStr[i] = "0"))); } } else { FormatVec(primary.grabOffsetPos, _grabPosStr); FormatVec(primary.grabOffsetRot, _grabRotStr); FormatVec(primary.hatOffsetPos, _hatPosStr); FormatVec(primary.hatOffsetRot, _hatRotStr); } } private static void FormatVec(Vector3 v, string[] strs) { strs[0] = v.x.ToString("F3", CultureInfo.InvariantCulture); strs[1] = v.y.ToString("F3", CultureInfo.InvariantCulture); strs[2] = v.z.ToString("F3", CultureInfo.InvariantCulture); } private static void CycleMode(PhysicsMode? current) { PhysicsMode physicsMode = ((current.HasValue && current != PhysicsMode.Hat) ? ((current == PhysicsMode.Static) ? PhysicsMode.Rigidbody : ((current == PhysicsMode.Rigidbody) ? PhysicsMode.Grabable : PhysicsMode.Hat)) : PhysicsMode.Static); LevelEditor.SetPhysicsMode(physicsMode); } } internal static class ObjImportWindow { private class MatGroup { public string MatName; public List Tris = new List(); } private struct MtlDef { public bool Initialized; public Color Diffuse; public Color Specular; public float Smoothness; public float Alpha; public string DiffuseTexPath; } public static bool Enabled = false; private const float WinW = 370f; private const float WinH = 150f; private const float HeaderH = 24f; private const float Pad = 7f; private const string PathField = "ObjImportPath"; private static Rect _windowRect; private static bool _initialized; private static bool _dragging; private static Vector2 _dragOffset; private static string _path = ""; private static string _status = ""; private static bool _invertFaces = false; public static bool IsTypingInUI { get; private set; } public static bool ContainsPoint(Vector2 guiPoint) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return _initialized && Enabled && ((Rect)(ref _windowRect)).Contains(guiPoint); } private static void EnsureInit() { //IL_0026: 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) if (!_initialized) { _initialized = true; _windowRect = new Rect(20f, 200f, 370f, 150f); } } public static void DrawGUI(Event e) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Invalid comparison between Unknown and I4 //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Invalid comparison between Unknown and I4 //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) if (!Enabled) { return; } EnsureInit(); ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, (float)Screen.width - 370f); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, (float)Screen.height - 150f); GUI.color = new Color(0f, 0f, 0f, 0.72f); GUI.Box(_windowRect, ""); GUI.color = Color.white; GUI.Label(new Rect(((Rect)(ref _windowRect)).x + 7f, ((Rect)(ref _windowRect)).y + 4f, 356f, 18f), "OBJ Importer"); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y, 370f, 24f); if ((int)e.type == 0 && e.button == 0 && ((Rect)(ref val)).Contains(e.mousePosition)) { _dragging = true; _dragOffset = e.mousePosition - new Vector2(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y); e.Use(); } if (_dragging) { if ((int)e.type == 3) { ((Rect)(ref _windowRect)).x = e.mousePosition.x - _dragOffset.x; ((Rect)(ref _windowRect)).y = e.mousePosition.y - _dragOffset.y; e.Use(); } if ((int)e.type == 1) { _dragging = false; } } float num = ((Rect)(ref _windowRect)).y + 24f + 7f; float num2 = ((Rect)(ref _windowRect)).x + 7f; float num3 = 356f; GUI.Label(new Rect(num2, num, num3, 18f), "OBJ path:"); num += 20f; GUI.SetNextControlName("ObjImportPath"); _path = GUI.TextField(new Rect(num2, num, num3, 20f), _path); num += 26f; _invertFaces = GUI.Toggle(new Rect(num2, num, num3, 18f), _invertFaces, "Invert faces"); num += 22f; if (GUI.Button(new Rect(num2, num, 80f, 22f), "Import")) { TryImport(); } if (GUI.Button(new Rect(num2 + 88f, num, 80f, 22f), "Import All")) { TryImportAll(); } if (!string.IsNullOrEmpty(_status)) { GUI.Label(new Rect(num2 + 176f, num + 2f, num3 - 176f, 22f), _status); } IsTypingInUI = GUI.GetNameOfFocusedControl() == "ObjImportPath"; } private static void TryImport() { //IL_009c: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) _status = ""; string text = _path.Trim(); if (!File.Exists(text)) { _status = "File not found."; return; } try { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); PropInfo propInfo = BuildPropInfo(text, fileNameWithoutExtension); if (propInfo == null) { _status = "No geometry found."; return; } LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { _status = "Editor not active."; return; } Vector3 position = default(Vector3); ((Vector3)(ref position))..ctor(0f, 200f, 256f); LevelEditorObject levelEditorObject = instance.SpawnFromPropInfo(propInfo, position); if ((Object)(object)levelEditorObject != (Object)null) { ((Component)levelEditorObject).transform.localScale = Vector3.one * 0.5f; levelEditorObject.loopBaseScale = ((Component)levelEditorObject).transform.localScale; RegisterChunkColliders(((Component)levelEditorObject).gameObject); PropInstanceServices.ApplySurfaceType(levelEditorObject, "Rock"); } _status = "Spawned '" + fileNameWithoutExtension + "'."; } catch (Exception ex) { _status = "Error: " + ex.Message; MelonLogger.Error($"[ObjImport] {ex}"); } } private static void TryImportAll() { //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0152: Unknown result type (might be due to invalid IL or missing references) _status = ""; string text = _path.Trim(); string text2 = null; if (Directory.Exists(text)) { text2 = text; } else { if (!File.Exists(text)) { _status = "Directory not found."; return; } text2 = Path.GetDirectoryName(text); } string[] files = Directory.GetFiles(text2, "*.obj"); if (files.Length == 0) { _status = "No OBJ files found."; return; } Array.Sort(files, (IComparer?)StringComparer.OrdinalIgnoreCase); try { LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { _status = "Editor not active."; return; } int num = 0; Vector3 position = default(Vector3); for (int i = 0; i < files.Length; i++) { string text3 = files[i]; string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text3); PropInfo propInfo = BuildPropInfo(text3, fileNameWithoutExtension); if (propInfo == null) { MelonLogger.Warning("[ObjImport] Skipping '" + text3 + "' - no geometry."); continue; } ((Vector3)(ref position))..ctor((float)i * 3f, 200f, 256f); LevelEditorObject levelEditorObject = instance.SpawnFromPropInfo(propInfo, position); if ((Object)(object)levelEditorObject != (Object)null) { ((Component)levelEditorObject).transform.localScale = Vector3.one * 0.5f; levelEditorObject.loopBaseScale = ((Component)levelEditorObject).transform.localScale; RegisterChunkColliders(((Component)levelEditorObject).gameObject); PropInstanceServices.ApplySurfaceType(levelEditorObject, "Rock"); num++; } } _status = $"Imported {num}/{files.Length} objs."; } catch (Exception ex) { _status = "Error: " + ex.Message; MelonLogger.Error($"[ObjImport] {ex}"); } } private static void RegisterChunkColliders(GameObject root) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown int num = 0; foreach (MeshFilter componentsInChild in root.GetComponentsInChildren(true)) { if (!((Object)(object)componentsInChild == (Object)null) && !((Object)(object)componentsInChild.sharedMesh == (Object)null)) { GameObject val = new GameObject($"ChunkCol_{num++}"); val.transform.SetParent(((Component)componentsInChild).transform.parent, false); val.layer = ((Component)componentsInChild).gameObject.layer; MeshCollider val2 = val.AddComponent(); val2.sharedMesh = componentsInChild.sharedMesh; } } } private static PropInfo BuildPropInfo(string objPath, string name) { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_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) string objDir = Path.GetDirectoryName(objPath) ?? ""; var (list, text, posArr, uvArr, normArr) = ParseObjFile(objPath, objDir); list.RemoveAll((MatGroup g) => g.Tris.Count == 0); if (list.Count == 0) { return null; } Dictionary mtlDefs = new Dictionary(StringComparer.OrdinalIgnoreCase); if (text != null && File.Exists(text)) { mtlDefs = ParseMtl(text); } PropInfo propInfo = new PropInfo("obj://" + name, name); foreach (MatGroup item in list) { var (val, val2) = BuildPartMesh(item.Tris, posArr, uvArr, normArr, item.MatName, mtlDefs); if (!((Object)(object)val == (Object)null)) { propInfo.parts.Add(new PropMeshPart { mesh = val, materials = (Material[])(object)new Material[1] { val2 }, localPosition = Vector3.zero, localRotation = Quaternion.identity, localScale = Vector3.one }); } } if (!propInfo.HasMesh) { return null; } propInfo.isLoaded = true; return propInfo; } private static (List, string mtllib, List pos, List uv, List norm) ParseObjFile(string path, string objDir) { //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); List groups = new List(); string item = null; MatGroup cur = null; EnsureGroup("__default"); string[] array = File.ReadAllLines(path); foreach (string text in array) { string text2 = text.Trim(); if (text2.Length == 0 || text2[0] == '#') { continue; } int num = text2.IndexOf(' '); if (num >= 0) { string text3 = text2.Substring(0, num); string text4 = text2.Substring(num + 1).Trim(); switch (text3) { case "v": { float[] array4 = SplitFloats(text4); list.Add(new Vector3(array4[0], array4[1], 0f - array4[2])); break; } case "vt": { float[] array3 = SplitFloats(text4); list2.Add(new Vector2(array3[0], array3[1])); break; } case "vn": { float[] array2 = SplitFloats(text4); list3.Add(new Vector3(array2[0], array2[1], 0f - array2[2])); break; } case "usemtl": EnsureGroup(text4); break; case "mtllib": item = Path.Combine(objDir, text4); break; case "f": ParseFaceInto(text4, list.Count, list2.Count, list3.Count, cur.Tris); break; } } } return (groups, mtllib: item, pos: list, uv: list2, norm: list3); void EnsureGroup(string matName) { if (cur == null || !(cur.MatName == matName)) { cur = new MatGroup { MatName = matName }; groups.Add(cur); } } } private static void ParseFaceInto(string s, int posC, int uvC, int normC, List tris) { string[] array = s.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); int[][] array2 = new int[array.Length][]; for (int i = 0; i < array.Length; i++) { array2[i] = ParseFaceVertex(array[i], posC, uvC, normC); } for (int j = 1; j < array2.Length - 1; j++) { tris.Add(array2[0]); tris.Add(array2[j]); tris.Add(array2[j + 1]); } } private static int[] ParseFaceVertex(string tok, int posC, int uvC, int normC) { string[] parts = tok.Split('/'); return new int[3] { ParseIdx(parts, 0, posC), ParseIdx(parts, 1, uvC), ParseIdx(parts, 2, normC) }; } private static int ParseIdx(string[] parts, int slot, int total) { if (slot >= parts.Length || string.IsNullOrEmpty(parts[slot])) { return -1; } int num = int.Parse(parts[slot], CultureInfo.InvariantCulture); return (num < 0) ? (total + num) : (num - 1); } private static float[] SplitFloats(string s) { string[] array = s.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); float[] array2 = new float[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = float.Parse(array[i], CultureInfo.InvariantCulture); } return array2; } private static (Mesh mesh, Material mat) BuildPartMesh(List tris, List posArr, List uvArr, List normArr, string matName, Dictionary mtlDefs) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0182: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) bool flag = uvArr != null && uvArr.Count > 0; bool flag2 = normArr != null && normArr.Count > 0; Dictionary<(int, int, int), int> dictionary = new Dictionary<(int, int, int), int>(); List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(tris.Count); foreach (int[] tri in tris) { int num = tri[0]; int num2 = tri[1]; int num3 = tri[2]; (int, int, int) key = (num, num2, num3); if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = list.Count); list.Add((num >= 0 && num < posArr.Count) ? posArr[num] : Vector3.zero); list2.Add((flag && num2 >= 0 && num2 < uvArr.Count) ? uvArr[num2] : Vector2.zero); list3.Add((flag2 && num3 >= 0 && num3 < normArr.Count) ? normArr[num3] : Vector3.up); } list4.Add(value); } if (list.Count == 0 || list4.Count == 0) { return (mesh: null, mat: null); } Mesh val = new Mesh { name = matName }; if (list.Count > 65535) { val.indexFormat = (IndexFormat)1; } val.vertices = Il2CppStructArray.op_Implicit(list.ToArray()); if (flag) { val.uv = Il2CppStructArray.op_Implicit(list2.ToArray()); } val.triangles = Il2CppStructArray.op_Implicit(list4.ToArray()); if (_invertFaces) { Il2CppStructArray triangles = val.triangles; for (int i = 0; i < ((Il2CppArrayBase)(object)triangles).Length; i += 3) { int num4 = ((Il2CppArrayBase)(object)triangles)[i + 1]; ((Il2CppArrayBase)(object)triangles)[i + 1] = ((Il2CppArrayBase)(object)triangles)[i + 2]; ((Il2CppArrayBase)(object)triangles)[i + 2] = num4; } val.triangles = triangles; } if (flag2) { Vector3[] array = list3.ToArray(); if (_invertFaces) { for (int j = 0; j < array.Length; j++) { array[j] = -array[j]; } } val.normals = Il2CppStructArray.op_Implicit(array); } else { val.RecalculateNormals(); Il2CppStructArray normals = val.normals; if (!_invertFaces) { for (int k = 0; k < ((Il2CppArrayBase)(object)normals).Length; k++) { ((Il2CppArrayBase)(object)normals)[k] = -((Il2CppArrayBase)(object)normals)[k]; } } val.normals = normals; } val.RecalculateBounds(); mtlDefs.TryGetValue(matName, out var value2); return (mesh: val, mat: BuildMaterial(value2, matName)); } private static MtlDef DefaultMtlDef() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) return new MtlDef { Initialized = true, Diffuse = Color.white, Specular = new Color(0.2f, 0.2f, 0.2f), Smoothness = 0.1f, Alpha = 1f, DiffuseTexPath = null }; } private static Dictionary ParseMtl(string mtlPath) { //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) Dictionary result = new Dictionary(StringComparer.OrdinalIgnoreCase); string path = Path.GetDirectoryName(mtlPath) ?? ""; string curName = null; MtlDef cur = DefaultMtlDef(); string[] array = File.ReadAllLines(mtlPath); foreach (string text in array) { string text2 = text.Trim(); if (text2.Length == 0 || text2[0] == '#') { continue; } int num = text2.IndexOf(' '); if (num >= 0) { string text3 = text2.Substring(0, num).ToLower(); string text4 = text2.Substring(num + 1).Trim(); switch (text3) { case "newmtl": Flush(); curName = text4; cur = DefaultMtlDef(); break; case "kd": { float[] array2 = SplitFloats(text4); cur.Diffuse = new Color(array2[0], array2[1], (array2.Length > 2) ? array2[2] : 0f, cur.Alpha); break; } case "ks": { float[] array3 = SplitFloats(text4); cur.Specular = new Color(array3[0], array3[1], (array3.Length > 2) ? array3[2] : 0f); break; } case "ns": cur.Smoothness = Mathf.Clamp01(float.Parse(text4, CultureInfo.InvariantCulture) / 1000f); break; case "d": cur.Alpha = float.Parse(text4, CultureInfo.InvariantCulture); cur.Diffuse.a = cur.Alpha; break; case "tr": cur.Alpha = 1f - float.Parse(text4, CultureInfo.InvariantCulture); cur.Diffuse.a = cur.Alpha; break; case "map_kd": cur.DiffuseTexPath = (Path.IsPathRooted(text4) ? text4 : Path.Combine(path, text4)); break; } } } Flush(); return result; void Flush() { if (curName != null) { result[curName] = cur; } } } private static Material BuildMaterial(MtlDef def, string fallbackName) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown if (!def.Initialized) { def = DefaultMtlDef(); } Shader val = Shader.Find("Standard") ?? Shader.Find("Universal Render Pipeline/Lit"); Material val2 = new Material(val) { name = fallbackName }; val2.color = def.Diffuse; val2.SetColor("_SpecColor", def.Specular); val2.SetFloat("_Glossiness", def.Smoothness); if (def.Alpha < 1f) { val2.SetFloat("_Mode", 3f); val2.SetInt("_SrcBlend", 5); val2.SetInt("_DstBlend", 10); val2.SetInt("_ZWrite", 0); val2.DisableKeyword("_ALPHATEST_ON"); val2.EnableKeyword("_ALPHABLEND_ON"); val2.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val2.renderQueue = 3000; } if (!string.IsNullOrEmpty(def.DiffuseTexPath) && File.Exists(def.DiffuseTexPath)) { try { Texture2D val3 = new Texture2D(2, 2); ImageConversion.LoadImage(val3, Il2CppStructArray.op_Implicit(File.ReadAllBytes(def.DiffuseTexPath))); ((Texture)val3).filterMode = (FilterMode)0; val2.mainTexture = (Texture)(object)val3; } catch (Exception ex) { MelonLogger.Warning("[ObjImport] Texture '" + def.DiffuseTexPath + "': " + ex.Message); } } return val2; } } } namespace BabyBlocks.Networking { internal static class ModNetworking { private class LevelChunkState { public byte[][] Chunks; public int ReceivedCount; public int TotalLen; } private const byte HelloMarker = 181; private const byte PropPlacedMarker = 182; private const byte FreecamUpdateMarker = 183; private const byte PropTransformMarker = 184; private const byte PropSelectedMarker = 185; private const byte PropGhostUpdateMarker = 186; private const byte PropGhostEndMarker = 187; private const byte PropDeletedMarker = 188; private const byte MaterialAppliedMarker = 189; private const byte LevelClearedMarker = 190; private const byte GroupSyncMarker = 191; private const byte BaseMapStateMarker = 192; private const byte LevelTransferRequestMarker = 193; private const byte LevelTransferDataMarker = 194; private const byte TintAppliedMarker = 195; private const byte PropFlagsAppliedMarker = 196; private const byte PropFreezeReleasedMarker = 197; private const byte CustomAccessoryDonMarker = 198; private const byte CustomAccessoryRemoveMarker = 199; private const byte PropPropertiesMarker = 200; private const byte PropPhysicsModeMarker = 201; private const byte GroupScaleMarker = 202; private const float AnnounceIntervalSeconds = 5f; private const float FreecamSendIntervalSeconds = 0.15f; private const float AccessoryRebroadcastInterval = 2.5f; private static float _nextAccRebroadcastTime; private static readonly int[] _lastAccInstId = new int[3]; private const float PropPropsFlushInterval = 0.12f; private static float _nextPropPropsFlushTime; private static readonly HashSet _dirtyPropProps = new HashSet(); private static byte[] _pendingLevelSnapshot; private const int LevelChunkSize = 8192; private static readonly Dictionary _levelChunkStates = new Dictionary(); private static bool _levelTransferPending; private static readonly List<(byte sender, byte[] payload)> _bufferedLivePackets = new List<(byte, byte[])>(); private const float LevelTransferTimeoutSeconds = 10f; private static float _levelTransferRequestTime; private static readonly Dictionary _networkedObjects = new Dictionary(); private const float FreecamReliableIntervalSeconds = 1.5f; private static float _nextFreecamReliableTime; public static readonly HashSet PeersWithBabyBlocks = new HashSet(); private static bool _reflectionDone; private static bool _reflectionOk; private static FieldInfo _networkManagerField; private static PropertyInfo _isConnectedProp; private static FieldInfo _networkClientField; private static FieldInfo _playerConfigField; private static FieldInfo _suitColorEntryField; private static FieldInfo _nicknameEntryField; private static PropertyInfo _suitColorValueProp; private static PropertyInfo _nicknameValueProp; private static FieldInfo _localPlayerInstanceField; private static FieldInfo _basePlayerHeadBoneField; private static FieldInfo _basePlayerHandBonesField; private static FieldInfo _handBonesItem1Field; private static FieldInfo _handBonesItem2Field; private static FieldInfo _playersField; private static MethodInfo _basePlayerSetHairHatMethod; private static object _channel; private static MethodInfo _createModChannelMethod; private static MethodInfo _channelSendMethod; private static EventInfo _channelDataReceivedEvent; private static object _packetDeliveryReliable; private static object _packetDeliveryUnreliable; private static Delegate _dataReceivedHandler; private static float _nextAnnounceTime; private static float _nextFreecamSendTime; private static bool _wasFlyCamActive; private static bool _channelCreateFailed; public static void Update() { EnsureReflection(); if (!_reflectionOk) { return; } object value; try { value = _networkManagerField.GetValue(null); } catch { return; } bool flag = false; if (value != null) { try { flag = (bool)_isConnectedProp.GetValue(value); } catch { flag = false; } } if (flag) { if (_channel == null && !_channelCreateFailed) { TryCreateChannel(value); } if (_levelTransferPending && Time.unscaledTime - _levelTransferRequestTime > 10f) { MelonLogger.Msg("[BabyBlocks][ModNetworking] Level transfer timed out — no response from peers"); _levelTransferPending = false; _bufferedLivePackets.Clear(); FlyCamController.EndNetworkLevelTransfer(); } if (_channel != null && Time.unscaledTime >= _nextAnnounceTime) { Announce(); _nextAnnounceTime = Time.unscaledTime + 5f; } if (_channel != null) { bool flyCamActive = FlyCamController.FlyCamActive; if (flyCamActive && Time.unscaledTime >= _nextFreecamSendTime) { bool flag2 = Time.unscaledTime >= _nextFreecamReliableTime; SendFreecamUpdate(active: true, flag2); _nextFreecamSendTime = Time.unscaledTime + 0.15f; if (flag2) { _nextFreecamReliableTime = Time.unscaledTime + 1.5f; } } else if (!flyCamActive && _wasFlyCamActive) { SendFreecamUpdate(active: false); } _wasFlyCamActive = flyCamActive; PollLocalAccessories(); FlushDirtyPropProperties(); } } else if (_channel != null) { TeardownChannel(); } RemoteFreecamManager.Update(); RemotePropHighlightManager.Update(); RemotePropGhostManager.Update(); RemoteAccessoryManager.Update(); } private static void EnsureReflection() { if (_reflectionDone) { return; } _reflectionDone = true; try { Assembly assembly = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { if (assembly2.GetName().Name == "BabyStepsMultiplayerClient") { assembly = assembly2; break; } } if (assembly == null) { return; } _networkManagerField = assembly.GetType("BabyStepsMultiplayerClient.Core")?.GetField("networkManager", BindingFlags.Static | BindingFlags.Public); Type type = _networkManagerField?.FieldType; if (type == null) { return; } _isConnectedProp = type.GetProperty("IsConnected", BindingFlags.Instance | BindingFlags.Public); _networkClientField = type.GetField("_networkClient", BindingFlags.Instance | BindingFlags.NonPublic); if (_isConnectedProp == null || _networkClientField == null) { return; } _reflectionOk = true; BBLog.Msg("[BabyBlocks][ModNetworking] Reflection bridge to BabyStepsMultiplayerClient established"); try { _playersField = type.GetField("players", BindingFlags.Instance | BindingFlags.Public); Type type2 = assembly.GetType("BabyStepsMultiplayerClient.Player.BasePlayer"); _localPlayerInstanceField = assembly.GetType("BabyStepsMultiplayerClient.Player.LocalPlayer")?.GetField("Instance", BindingFlags.Static | BindingFlags.Public); _basePlayerHeadBoneField = type2?.GetField("headBone", BindingFlags.Instance | BindingFlags.Public); _basePlayerHandBonesField = type2?.GetField("handBones", BindingFlags.Instance | BindingFlags.Public); if (_basePlayerHandBonesField != null) { _handBonesItem1Field = _basePlayerHandBonesField.FieldType.GetField("Item1"); _handBonesItem2Field = _basePlayerHandBonesField.FieldType.GetField("Item2"); } _basePlayerSetHairHatMethod = type2?.GetMethod("SetHairHat", new Type[2] { typeof(float), typeof(Vector4) }); if (_playersField != null && _localPlayerInstanceField != null && _basePlayerHeadBoneField != null && _basePlayerHandBonesField != null) { BBLog.Msg("[BabyBlocks][ModNetworking] Accessory-bone reflection resolved"); } else { MelonLogger.Warning("[BabyBlocks][ModNetworking] Accessory-bone reflection incomplete — custom hat/grabable sync disabled"); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] Accessory-bone reflection failed: " + ex.Message); } try { Assembly assembly3 = null; Assembly[] assemblies2 = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly4 in assemblies2) { if (assembly4.GetName().Name == "BabyStepsNetworking") { assembly3 = assembly4; break; } } if (assembly3 == null) { BBLog.Msg("[BabyBlocks][ModNetworking] BabyStepsNetworking not present — channel sync disabled"); } else { Type type3 = assembly3.GetType("BabyStepsNetworking.Client.NetworkClient"); Type type4 = assembly3.GetType("BabyStepsNetworking.Extensions.IModChannel"); Type type5 = assembly3.GetType("BabyStepsNetworking.Transport.PacketDelivery"); _createModChannelMethod = type3?.GetMethod("CreateModChannel", new Type[1] { typeof(string) }); _channelSendMethod = type4?.GetMethod("Send"); _channelDataReceivedEvent = type4?.GetEvent("DataReceived"); if (type5 != null) { _packetDeliveryReliable = Enum.Parse(type5, "ReliableOrdered"); _packetDeliveryUnreliable = Enum.Parse(type5, "Unreliable"); } if (_createModChannelMethod != null && _channelSendMethod != null && _channelDataReceivedEvent != null) { BBLog.Msg("[BabyBlocks][ModNetworking] BabyStepsNetworking channel types resolved"); } else { MelonLogger.Warning("[BabyBlocks][ModNetworking] BabyStepsNetworking found but channel types incomplete — sync disabled"); } } } catch (Exception ex2) { MelonLogger.Warning("[BabyBlocks][ModNetworking] BabyStepsNetworking reflection failed: " + ex2.Message); } try { _playerConfigField = assembly.GetType("BabyStepsMultiplayerClient.ModSettings")?.GetField("player", BindingFlags.Static | BindingFlags.Public); Type type6 = _playerConfigField?.FieldType; _suitColorEntryField = type6?.GetField("SuitColor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _nicknameEntryField = type6?.GetField("Nickname", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _suitColorValueProp = _suitColorEntryField?.FieldType.GetProperty("Value", BindingFlags.Instance | BindingFlags.Public); _nicknameValueProp = _nicknameEntryField?.FieldType.GetProperty("Value", BindingFlags.Instance | BindingFlags.Public); } catch (Exception ex3) { MelonLogger.Warning("[BabyBlocks][ModNetworking] Appearance reflection setup failed: " + ex3.Message); } } catch (Exception ex4) { MelonLogger.Warning("[BabyBlocks][ModNetworking] Reflection setup failed: " + ex4.Message); } } private static bool TryGetLocalAppearance(out Color suitColor, out string displayName) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) suitColor = Color.white; displayName = string.Empty; if (_playerConfigField == null) { return false; } try { object value = _playerConfigField.GetValue(null); if (value == null) { return false; } if (_suitColorEntryField != null && _suitColorValueProp != null) { object value2 = _suitColorEntryField.GetValue(value); if (value2 != null) { suitColor = (Color)_suitColorValueProp.GetValue(value2); } } if (_nicknameEntryField != null && _nicknameValueProp != null) { object value3 = _nicknameEntryField.GetValue(value); if (value3 != null) { displayName = ((string)_nicknameValueProp.GetValue(value3)) ?? string.Empty; } } return true; } catch { return false; } } private static void TryCreateChannel(object networkManager) { try { if (_createModChannelMethod == null || _channelSendMethod == null || _channelDataReceivedEvent == null) { return; } object value = _networkClientField.GetValue(networkManager); if (value == null) { return; } object obj = _createModChannelMethod.Invoke(value, new object[1] { "BabyBlocks" }); if (obj != null) { LevelEditor.EnsureManager(); if (GpuiPropScanner.GpuiScannedNames.Count == 0) { GpuiPropScanner.ScanGpuiProps(); MaterialCatalog.InvalidateMaterialSources(); } _pendingLevelSnapshot = LevelSaveLoad.SerializeForNetwork(); LevelEditorManager.Instance?.RemoveAll(); LevelEditor.ClearAllSelectionState(); _networkedObjects.Clear(); _dataReceivedHandler = Delegate.CreateDelegate(_channelDataReceivedEvent.EventHandlerType, null, typeof(ModNetworking).GetMethod("OnDataReceived", BindingFlags.Static | BindingFlags.NonPublic)); _channelDataReceivedEvent.AddEventHandler(obj, _dataReceivedHandler); _channel = obj; PeersWithBabyBlocks.Clear(); _nextAnnounceTime = 0f; _levelTransferPending = true; _levelTransferRequestTime = Time.unscaledTime; _bufferedLivePackets.Clear(); SendLevelTransferRequest(); BBLog.Msg("[BabyBlocks][ModNetworking] Mod channel established"); } } catch (Exception ex) { _channelCreateFailed = true; MelonLogger.Warning("[BabyBlocks][ModNetworking] Failed to create mod channel: " + ex.Message); } } private static void TeardownChannel() { try { if (_channel != null && _channelDataReceivedEvent != null && (object)_dataReceivedHandler != null) { _channelDataReceivedEvent.RemoveEventHandler(_channel, _dataReceivedHandler); } } catch { } _dataReceivedHandler = null; _channel = null; _channelCreateFailed = false; _pendingLevelSnapshot = null; _levelChunkStates.Clear(); _levelTransferPending = false; _bufferedLivePackets.Clear(); FlyCamController.EndNetworkLevelTransfer(); PeersWithBabyBlocks.Clear(); _networkedObjects.Clear(); RemoteFreecamManager.ClearAll(); RemotePropHighlightManager.ClearAll(); RemotePropGhostManager.ClearAll(); RemoteAccessoryManager.ClearAll(); Array.Clear(_lastAccInstId, 0, _lastAccInstId.Length); _nextAccRebroadcastTime = 0f; _dirtyPropProps.Clear(); _nextPropPropsFlushTime = 0f; } private static void Announce() { try { ChannelSend(new byte[1] { 181 }, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] Announce failed: " + ex.Message); } } private static ulong GenerateNetId() { byte[] value = Guid.NewGuid().ToByteArray(); ulong num = BitConverter.ToUInt64(value, 0); return (num == 0L) ? 1 : num; } public static ulong RegisterNetworkedObject(LevelEditorObject obj) { if ((Object)(object)obj == (Object)null) { return 0uL; } if (obj.netId != 0) { return obj.netId; } obj.netId = GenerateNetId(); _networkedObjects[obj.netId] = obj; return obj.netId; } public static void ClearNetworkedObjects() { _networkedObjects.Clear(); } public static void RegisterLoadedNetworkedObject(ulong netId, LevelEditorObject obj) { if (!((Object)(object)obj == (Object)null) && netId != 0) { obj.netId = netId; _networkedObjects[netId] = obj; } } public static void SendPropPlaced(ulong netId, string propId, Vector3 position, Quaternion rotation, Vector3 scale) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) if (_channel == null) { return; } try { byte[] bytes = Encoding.UTF8.GetBytes(propId); byte[] array = new byte[11 + bytes.Length + 40]; int offset = 0; array[offset++] = 182; WriteULong(array, ref offset, netId); array[offset++] = (byte)(bytes.Length & 0xFF); array[offset++] = (byte)((bytes.Length >> 8) & 0xFF); Buffer.BlockCopy(bytes, 0, array, offset, bytes.Length); offset += bytes.Length; WriteFloat(array, ref offset, position.x); WriteFloat(array, ref offset, position.y); WriteFloat(array, ref offset, position.z); WriteFloat(array, ref offset, rotation.x); WriteFloat(array, ref offset, rotation.y); WriteFloat(array, ref offset, rotation.z); WriteFloat(array, ref offset, rotation.w); WriteFloat(array, ref offset, scale.x); WriteFloat(array, ref offset, scale.y); WriteFloat(array, ref offset, scale.z); ChannelSend(array, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendPropPlaced failed: " + ex.Message); } } public static void SyncFullPropState(LevelEditorObject obj) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (_channel == null || (Object)(object)obj == (Object)null || obj.netId == 0) { return; } if (obj.physicsMode != PhysicsMode.Static) { SendPropPhysicsMode(new List { obj.netId }, obj.physicsMode); } if (obj.materialConstructionId >= 0) { MaterialConstructionEntry materialConstructionEntry = MaterialConstructionLibrary.FindById(obj.materialConstructionId); if (materialConstructionEntry != null) { SendMaterialApplied(obj.netId, materialConstructionEntry); } } if (obj.freezeUntilHit) { SendPropFlagsApplied(obj.netId, freezeUntilHit: true); } if (obj.materialTint != new Vector3(255f, 255f, 255f)) { SendTintApplied(obj.netId, obj.materialTint); } MarkPropPropertiesDirty(obj.netId); } private static void SendFreecamUpdate(bool active, bool reliable = false) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (_channel == null) { return; } try { Vector3 val = Vector3.zero; Color suitColor = Color.white; string displayName = string.Empty; if (active) { PlayerMovement me = PlayerMovement.me; if ((Object)(object)me == (Object)null || (Object)(object)me.flyCam == (Object)null) { return; } val = ((Component)me.flyCam).transform.position; TryGetLocalAppearance(out suitColor, out displayName); } byte[] bytes = Encoding.UTF8.GetBytes(displayName); byte[] array = new byte[19 + bytes.Length]; int offset = 0; array[offset++] = 183; array[offset++] = (byte)(active ? 1u : 0u); WriteFloat(array, ref offset, val.x); WriteFloat(array, ref offset, val.y); WriteFloat(array, ref offset, val.z); array[offset++] = (byte)Mathf.Clamp(Mathf.RoundToInt(suitColor.r * 255f), 0, 255); array[offset++] = (byte)Mathf.Clamp(Mathf.RoundToInt(suitColor.g * 255f), 0, 255); array[offset++] = (byte)Mathf.Clamp(Mathf.RoundToInt(suitColor.b * 255f), 0, 255); array[offset++] = (byte)(bytes.Length & 0xFF); array[offset++] = (byte)((bytes.Length >> 8) & 0xFF); Buffer.BlockCopy(bytes, 0, array, offset, bytes.Length); ChannelSend(array, !active || reliable); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendFreecamUpdate failed: " + ex.Message); } } private static void ChannelSend(byte[] payload, bool reliable) { if (_channel == null || _channelSendMethod == null) { return; } try { _channelSendMethod.Invoke(_channel, new object[2] { payload, reliable ? _packetDeliveryReliable : _packetDeliveryUnreliable }); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] Send failed: " + ex.Message); } } private static void WriteFloat(byte[] buf, ref int offset, float value) { Buffer.BlockCopy(BitConverter.GetBytes(value), 0, buf, offset, 4); offset += 4; } private static float ReadFloat(byte[] buf, ref int offset) { float result = BitConverter.ToSingle(buf, offset); offset += 4; return result; } private static void WriteULong(byte[] buf, ref int offset, ulong value) { Buffer.BlockCopy(BitConverter.GetBytes(value), 0, buf, offset, 8); offset += 8; } private static ulong ReadULong(byte[] buf, ref int offset) { ulong result = BitConverter.ToUInt64(buf, offset); offset += 8; return result; } private static void OnDataReceived(byte senderUuid, byte[] payload) { if (payload == null || payload.Length < 1) { return; } if (_levelTransferPending) { byte b = payload[0]; if (b == 182 || b == 188 || b == 190 || b == 189 || b == 195 || b == 191 || b == 200 || b == 201 || b == 202) { _bufferedLivePackets.Add((senderUuid, payload)); return; } } switch (payload[0]) { case 181: if (PeersWithBabyBlocks.Add(senderUuid)) { MelonLogger.Msg($"[BabyBlocks] Player {senderUuid} also has Baby Blocks installed"); } break; case 182: HandlePropPlaced(senderUuid, payload); break; case 183: HandleFreecamUpdate(senderUuid, payload); break; case 184: HandlePropTransformUpdate(senderUuid, payload); break; case 185: HandlePropSelected(senderUuid, payload); break; case 186: HandlePropGhostUpdate(senderUuid, payload); break; case 187: RemotePropGhostManager.NotifyDragEnded(senderUuid); break; case 188: HandlePropDeleted(senderUuid, payload); break; case 189: HandleMaterialApplied(senderUuid, payload); break; case 195: HandleTintApplied(senderUuid, payload); break; case 196: HandlePropFlagsApplied(senderUuid, payload); break; case 197: HandlePropFreezeReleased(senderUuid, payload); break; case 198: HandleCustomAccessoryDon(senderUuid, payload); break; case 199: HandleCustomAccessoryRemove(senderUuid, payload); break; case 200: HandlePropProperties(senderUuid, payload); break; case 201: HandlePropPhysicsMode(senderUuid, payload); break; case 202: HandleGroupScale(senderUuid, payload); break; case 190: HandleLevelCleared(senderUuid, payload); break; case 191: HandleGroupSync(senderUuid, payload); break; case 192: HandleBaseMapState(senderUuid, payload); break; case 193: HandleLevelTransferRequest(senderUuid, payload); break; case 194: HandleLevelTransferData(senderUuid, payload); break; } } private static void HandleFreecamUpdate(byte senderUuid, byte[] payload) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) try { int offset = 1; if (payload[offset++] == 0) { RemoteFreecamManager.Remove(senderUuid); return; } Vector3 position = default(Vector3); ((Vector3)(ref position))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); Color suitColor = default(Color); ((Color)(ref suitColor))..ctor((float)(int)payload[offset++] / 255f, (float)(int)payload[offset++] / 255f, (float)(int)payload[offset++] / 255f); int count = payload[offset] | (payload[offset + 1] << 8); offset += 2; string name = Encoding.UTF8.GetString(payload, offset, count); RemoteFreecamManager.UpdateFreecam(senderUuid, position, suitColor, name); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleFreecamUpdate failed: " + ex.Message); } } private static void HandlePropPlaced(byte senderUuid, byte[] payload) { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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) try { int offset = 1; ulong num = ReadULong(payload, ref offset); int num2 = payload[offset] | (payload[offset + 1] << 8); offset += 2; string text = Encoding.UTF8.GetString(payload, offset, num2); offset += num2; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); Quaternion val2 = default(Quaternion); ((Quaternion)(ref val2))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); Vector3 localScale = default(Vector3); ((Vector3)(ref localScale))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); LevelEditor.EnsureManager(); PropInfo propInfo = PropLibrary.FindById(text); if (propInfo == null && text.StartsWith("gpui://", StringComparison.OrdinalIgnoreCase) && GpuiPropScanner.GpuiScannedNames.Count == 0) { GpuiPropScanner.ScanGpuiProps(); propInfo = PropLibrary.FindById(text); MaterialCatalog.InvalidateMaterialSources(); } if (propInfo == null) { MelonLogger.Warning($"[BabyBlocks][ModNetworking] Player {senderUuid} placed unknown prop '{text}'"); return; } PropLibrary.LoadPropData(propInfo); LevelEditorObject levelEditorObject = LevelEditorManager.Instance.SpawnFromPropInfo(propInfo, val); if (!((Object)(object)levelEditorObject == (Object)null)) { ((Component)levelEditorObject).transform.SetPositionAndRotation(val, val2); ((Component)levelEditorObject).transform.localScale = localScale; LevelEditorManager.Instance.SyncLoopBase(levelEditorObject); if (num != 0) { levelEditorObject.netId = num; _networkedObjects[num] = levelEditorObject; } RemotePropGhostManager.NotifyDragEnded(senderUuid); MelonLogger.Msg($"[BabyBlocks] Player {senderUuid} placed prop '{text}'"); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandlePropPlaced failed: " + ex.Message); } } public static void SendPropTransform(ulong netId, Vector3 position, Quaternion rotation, Vector3 scale, bool reliable = false) { //IL_003e: 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_005c: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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) if (_channel == null || netId == 0) { return; } try { byte[] array = new byte[49]; int offset = 0; array[offset++] = 184; WriteULong(array, ref offset, netId); WriteFloat(array, ref offset, position.x); WriteFloat(array, ref offset, position.y); WriteFloat(array, ref offset, position.z); WriteFloat(array, ref offset, rotation.x); WriteFloat(array, ref offset, rotation.y); WriteFloat(array, ref offset, rotation.z); WriteFloat(array, ref offset, rotation.w); WriteFloat(array, ref offset, scale.x); WriteFloat(array, ref offset, scale.y); WriteFloat(array, ref offset, scale.z); ChannelSend(array, reliable); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendPropTransform failed: " + ex.Message); } } private static void HandlePropTransformUpdate(byte senderUuid, byte[] payload) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) try { int offset = 1; ulong key = ReadULong(payload, ref offset); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); Quaternion val2 = default(Quaternion); ((Quaternion)(ref val2))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); Vector3 localScale = default(Vector3); ((Vector3)(ref localScale))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); if (!_networkedObjects.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { _networkedObjects.Remove(key); return; } ((Component)value).transform.SetPositionAndRotation(val, val2); ((Component)value).transform.localScale = localScale; LevelEditorManager.Instance?.SyncLoopBase(value); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandlePropTransformUpdate failed: " + ex.Message); } } public static void SendPropDeleted(ulong netId) { if (_channel == null || netId == 0) { return; } _networkedObjects.Remove(netId); try { byte[] array = new byte[9]; int offset = 0; array[offset++] = 188; WriteULong(array, ref offset, netId); ChannelSend(array, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendPropDeleted failed: " + ex.Message); } } private static void HandlePropDeleted(byte senderUuid, byte[] payload) { try { int offset = 1; ulong key = ReadULong(payload, ref offset); if (!_networkedObjects.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { _networkedObjects.Remove(key); return; } _networkedObjects.Remove(key); LevelEditor.RemoveDeletedObject(value); LevelEditorManager.Instance?.Remove(value); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandlePropDeleted failed: " + ex.Message); } } public static void SendMaterialApplied(ulong netId, MaterialConstructionEntry entry) { if (_channel == null || netId == 0L || entry == null) { return; } try { byte[] bytes = Encoding.UTF8.GetBytes(entry.name ?? string.Empty); byte[] bytes2 = Encoding.UTF8.GetBytes(entry.materialName ?? string.Empty); byte[] bytes3 = Encoding.UTF8.GetBytes(entry.surfaceType ?? string.Empty); byte[] array = new byte[16 + bytes.Length + 2 + bytes2.Length + 2 + bytes3.Length]; int offset = 0; array[offset++] = 189; WriteULong(array, ref offset, netId); Buffer.BlockCopy(BitConverter.GetBytes(entry.id), 0, array, offset, 4); offset += 4; array[offset++] = (byte)(entry.sunglassesNeeded ? 1u : 0u); WriteString16(array, ref offset, bytes); WriteString16(array, ref offset, bytes2); WriteString16(array, ref offset, bytes3); ChannelSend(array, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendMaterialApplied failed: " + ex.Message); } } private static void WriteString16(byte[] buf, ref int offset, byte[] strBytes) { buf[offset++] = (byte)(strBytes.Length & 0xFF); buf[offset++] = (byte)((strBytes.Length >> 8) & 0xFF); Buffer.BlockCopy(strBytes, 0, buf, offset, strBytes.Length); offset += strBytes.Length; } private static string ReadString16(byte[] buf, ref int offset) { if (offset + 2 > buf.Length) { offset = buf.Length; return string.Empty; } int num = buf[offset] | (buf[offset + 1] << 8); offset += 2; if (num <= 0 || offset + num > buf.Length) { offset = Math.Min(offset + Math.Max(num, 0), buf.Length); return string.Empty; } string result = Encoding.UTF8.GetString(buf, offset, num); offset += num; return result; } public static void SendLevelCleared() { _networkedObjects.Clear(); if (_channel == null) { return; } try { ChannelSend(new byte[1] { 190 }, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendLevelCleared failed: " + ex.Message); } } private static void HandleLevelCleared(byte senderUuid, byte[] payload) { try { _networkedObjects.Clear(); LevelEditorManager.Instance?.RemoveAll(); LevelEditor.ClearAllSelectionState(); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleLevelCleared failed: " + ex.Message); } } public static void SendGroupSync(List netIds, bool group) { if (_channel == null || netIds == null) { return; } List list = new List(); foreach (ulong netId in netIds) { if (netId != 0) { list.Add(netId); } } if (list.Count == 0) { return; } try { int num = Math.Min(list.Count, 255); byte[] array = new byte[3 + num * 8]; int offset = 0; array[offset++] = 191; array[offset++] = (byte)(group ? 1u : 0u); array[offset++] = (byte)num; for (int i = 0; i < num; i++) { WriteULong(array, ref offset, list[i]); } ChannelSend(array, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendGroupSync failed: " + ex.Message); } } private static void HandleGroupSync(byte senderUuid, byte[] payload) { try { int offset = 1; bool flag = payload[offset++] != 0; int num = payload[offset++]; List list = new List(num); for (int i = 0; i < num; i++) { ulong key = ReadULong(payload, ref offset); if (_networkedObjects.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { list.Add(value); } } if (list.Count == 0) { return; } if (flag) { HashSet hashSet = new HashSet(); foreach (LevelEditorObject item in list) { if (item.groupId > 0) { hashSet.Add(item.groupId); } } foreach (int item2 in hashSet) { GroupManager.DissolveGroup(item2); } int groupId = GroupManager.AllocateGroupId(); foreach (LevelEditorObject item3 in list) { item3.groupId = groupId; } GroupManager.EnsureStaticGroupRoot(groupId, list); return; } HashSet hashSet2 = new HashSet(); foreach (LevelEditorObject item4 in list) { if (item4.groupId > 0) { hashSet2.Add(item4.groupId); } } foreach (int item5 in hashSet2) { GroupManager.DissolveGroup(item5); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleGroupSync failed: " + ex.Message); } } public static void SendBaseMapState(bool enabled) { if (_channel == null) { return; } try { ChannelSend(new byte[2] { 192, (byte)(enabled ? 1u : 0u) }, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendBaseMapState failed: " + ex.Message); } } private static void HandleBaseMapState(byte senderUuid, byte[] payload) { try { bool flag = payload[1] != 0; if (BaseMapController.BaseMapEnabled != flag) { BaseMapController.SetBaseMapEnabled(flag); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleBaseMapState failed: " + ex.Message); } } private static void SendLevelTransferRequest() { if (_channel == null) { return; } try { ChannelSend(new byte[1] { 193 }, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendLevelTransferRequest failed: " + ex.Message); } } private static void SendLevelTransferData(byte[] data) { if (_channel == null || data == null || data.Length == 0) { return; } try { int num = (data.Length + 8192 - 1) / 8192; for (int i = 0; i < num; i++) { int num2 = i * 8192; int num3 = Math.Min(8192, data.Length - num2); byte[] array = new byte[9 + num3]; int num4 = 0; array[num4++] = 194; Buffer.BlockCopy(BitConverter.GetBytes(data.Length), 0, array, num4, 4); num4 += 4; Buffer.BlockCopy(BitConverter.GetBytes((ushort)num), 0, array, num4, 2); num4 += 2; Buffer.BlockCopy(BitConverter.GetBytes((ushort)i), 0, array, num4, 2); num4 += 2; Buffer.BlockCopy(data, num2, array, num4, num3); ChannelSend(array, reliable: true); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendLevelTransferData failed: " + ex.Message); } } private static void HandleLevelTransferRequest(byte senderUuid, byte[] payload) { try { byte[] array = null; LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance != (Object)null && instance.Objects.Count > 0) { array = LevelSaveLoad.SerializeForNetwork(); } if (array == null) { array = _pendingLevelSnapshot; } if (array != null) { SendLevelTransferData(array); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleLevelTransferRequest failed: " + ex.Message); } } private static void HandleLevelTransferData(byte senderUuid, byte[] payload) { try { if (payload.Length < 9) { return; } int num = BitConverter.ToInt32(payload, 1); int num2 = BitConverter.ToUInt16(payload, 5); int num3 = BitConverter.ToUInt16(payload, 7); int num4 = payload.Length - 9; if (num <= 0 || num2 <= 0 || num3 >= num2 || num4 <= 0) { return; } if (!_levelChunkStates.TryGetValue(senderUuid, out var value) || value.Chunks.Length != num2) { LevelChunkState levelChunkState = new LevelChunkState(); levelChunkState.Chunks = new byte[num2][]; levelChunkState.ReceivedCount = 0; levelChunkState.TotalLen = num; value = levelChunkState; _levelChunkStates[senderUuid] = value; FlyCamController.BeginNetworkLevelTransfer(); } if (value.Chunks[num3] == null) { byte[] array = new byte[num4]; Buffer.BlockCopy(payload, 9, array, 0, num4); value.Chunks[num3] = array; value.ReceivedCount++; } if (value.ReceivedCount < num2) { return; } _levelChunkStates.Remove(senderUuid); byte[] array2 = new byte[value.TotalLen]; int num5 = 0; byte[][] chunks = value.Chunks; foreach (byte[] array3 in chunks) { Buffer.BlockCopy(array3, 0, array2, num5, array3.Length); num5 += array3.Length; } _pendingLevelSnapshot = null; LevelEditor.EnsureManager(); var (flag, value2, value3) = LevelSaveLoad.LoadFromNetworkData(array2); if (flag) { MelonLogger.Msg($"[BabyBlocks] Received level from player {senderUuid}: {value2} object(s)"); } else { MelonLogger.Warning($"[BabyBlocks] Level transfer from player {senderUuid} failed: {value3}"); } _levelTransferPending = false; FlyCamController.EndNetworkLevelTransfer(); if (_bufferedLivePackets.Count > 0) { List<(byte, byte[])> list = new List<(byte, byte[])>(_bufferedLivePackets); _bufferedLivePackets.Clear(); MelonLogger.Msg($"[BabyBlocks] Replaying {list.Count} buffered live event(s) after level transfer"); { foreach (var (senderUuid2, payload2) in list) { OnDataReceived(senderUuid2, payload2); } return; } } _bufferedLivePackets.Clear(); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleLevelTransferData failed: " + ex.Message); } } public static void BroadcastLevelLoad() { if (_channel != null) { byte[] array = LevelSaveLoad.SerializeForNetwork(); if (array != null) { SendLevelTransferData(array); MelonLogger.Msg($"[BabyBlocks] Broadcast level load: {array.Length} bytes"); } } } private static void HandleMaterialApplied(byte senderUuid, byte[] payload) { try { if (payload.Length >= 14) { int offset = 1; ulong key = ReadULong(payload, ref offset); int num = BitConverter.ToInt32(payload, offset); offset += 4; bool sunglassesNeeded = payload[offset++] != 0; string name = ReadString16(payload, ref offset); string materialName = ReadString16(payload, ref offset); string surfaceType = ReadString16(payload, ref offset); if (!_networkedObjects.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { _networkedObjects.Remove(key); return; } if (num == int.MinValue) { MaterialConstructionPanel.ResetInstance(value, pushHistory: false); return; } MaterialConstructionEntry entry = new MaterialConstructionEntry { id = num, name = name, materialName = materialName, surfaceType = surfaceType, sunglassesNeeded = sunglassesNeeded }; MaterialConstructionPanel.ApplyToInstance(value, entry); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleMaterialApplied failed: " + ex.Message); } } public static void SendTintApplied(ulong netId, Vector3 tint) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (_channel == null || netId == 0) { return; } try { byte[] array = new byte[12]; int offset = 0; array[offset++] = 195; WriteULong(array, ref offset, netId); array[offset++] = (byte)Mathf.Clamp(Mathf.RoundToInt(tint.x), 0, 255); array[offset++] = (byte)Mathf.Clamp(Mathf.RoundToInt(tint.y), 0, 255); array[offset++] = (byte)Mathf.Clamp(Mathf.RoundToInt(tint.z), 0, 255); ChannelSend(array, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendTintApplied failed: " + ex.Message); } } private static void HandleTintApplied(byte senderUuid, byte[] payload) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) try { int offset = 1; ulong key = ReadULong(payload, ref offset); Vector3 tint = default(Vector3); ((Vector3)(ref tint))..ctor((float)(int)payload[offset], (float)(int)payload[offset + 1], (float)(int)payload[offset + 2]); if (!_networkedObjects.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { _networkedObjects.Remove(key); } else { PropInstanceServices.ApplyTint(value, tint); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleTintApplied failed: " + ex.Message); } } public static void SendPropFlagsApplied(ulong netId, bool freezeUntilHit) { if (_channel == null || netId == 0) { return; } try { byte[] array = new byte[10]; int offset = 0; array[offset++] = 196; WriteULong(array, ref offset, netId); array[offset] = (byte)(freezeUntilHit ? 1u : 0u); ChannelSend(array, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendPropFlagsApplied failed: " + ex.Message); } } private static void HandlePropFlagsApplied(byte senderUuid, byte[] payload) { try { int offset = 1; ulong key = ReadULong(payload, ref offset); byte b = payload[offset]; if (!_networkedObjects.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { _networkedObjects.Remove(key); } else { value.freezeUntilHit = (b & 1) != 0; } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandlePropFlagsApplied failed: " + ex.Message); } } public static void SendPropFreezeReleased(ulong netId) { if (_channel == null || netId == 0) { return; } try { byte[] array = new byte[9]; int offset = 0; array[offset++] = 197; WriteULong(array, ref offset, netId); ChannelSend(array, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendPropFreezeReleased failed: " + ex.Message); } } private static void HandlePropFreezeReleased(byte senderUuid, byte[] payload) { try { int offset = 1; ulong key = ReadULong(payload, ref offset); if (!_networkedObjects.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { _networkedObjects.Remove(key); return; } PhysicsObjectManager.RemoveFreezeUntilHitForNetworkPeer(value); PhysicsObjectManager.UnfreezeHitProp(value); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandlePropFreezeReleased failed: " + ex.Message); } } public static void SendPropSelected(List netIds) { //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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if (_channel == null) { return; } try { int num = ((netIds != null) ? Math.Min(netIds.Count, 255) : 0); Color suitColor = Color.white; if (num > 0) { TryGetLocalAppearance(out suitColor, out var _); } byte[] array = new byte[2 + num * 8 + ((num > 0) ? 3 : 0)]; int offset = 0; array[offset++] = 185; array[offset++] = (byte)num; for (int i = 0; i < num; i++) { WriteULong(array, ref offset, netIds[i]); } if (num > 0) { array[offset++] = (byte)Mathf.Clamp(Mathf.RoundToInt(suitColor.r * 255f), 0, 255); array[offset++] = (byte)Mathf.Clamp(Mathf.RoundToInt(suitColor.g * 255f), 0, 255); array[offset++] = (byte)Mathf.Clamp(Mathf.RoundToInt(suitColor.b * 255f), 0, 255); } ChannelSend(array, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendPropSelected failed: " + ex.Message); } } private static void HandlePropSelected(byte senderUuid, byte[] payload) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) try { int offset = 1; int num = payload[offset++]; List list = new List(num); for (int i = 0; i < num; i++) { ulong key = ReadULong(payload, ref offset); if (_networkedObjects.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { list.Add(value); } } if (list.Count == 0) { RemotePropHighlightManager.Remove(senderUuid); return; } Color color = default(Color); ((Color)(ref color))..ctor((float)(int)payload[offset++] / 255f, (float)(int)payload[offset++] / 255f, (float)(int)payload[offset++] / 255f); RemotePropHighlightManager.SetHighlights(senderUuid, list, color); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandlePropSelected failed: " + ex.Message); } } public static void SendPropGhostUpdate(string propId, Vector3 position, Quaternion rotation, Vector3 scale, bool reliable) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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) if (_channel == null) { return; } try { byte[] bytes = Encoding.UTF8.GetBytes(propId); byte[] array = new byte[3 + bytes.Length + 40]; int num = 0; array[num++] = 186; array[num++] = (byte)(bytes.Length & 0xFF); array[num++] = (byte)((bytes.Length >> 8) & 0xFF); Buffer.BlockCopy(bytes, 0, array, num, bytes.Length); num += bytes.Length; WriteFloat(array, ref num, position.x); WriteFloat(array, ref num, position.y); WriteFloat(array, ref num, position.z); WriteFloat(array, ref num, rotation.x); WriteFloat(array, ref num, rotation.y); WriteFloat(array, ref num, rotation.z); WriteFloat(array, ref num, rotation.w); WriteFloat(array, ref num, scale.x); WriteFloat(array, ref num, scale.y); WriteFloat(array, ref num, scale.z); ChannelSend(array, reliable); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendPropGhostUpdate failed: " + ex.Message); } } public static void SendPropGhostEnd() { if (_channel == null) { return; } try { ChannelSend(new byte[1] { 187 }, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendPropGhostEnd failed: " + ex.Message); } } private static void HandlePropGhostUpdate(byte senderUuid, byte[] payload) { //IL_00e1: 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_00e4: Unknown result type (might be due to invalid IL or missing references) try { int num = 1; int num2 = payload[num] | (payload[num + 1] << 8); num += 2; string text = Encoding.UTF8.GetString(payload, num, num2); num += num2; Vector3 position = default(Vector3); ((Vector3)(ref position))..ctor(ReadFloat(payload, ref num), ReadFloat(payload, ref num), ReadFloat(payload, ref num)); Quaternion rotation = default(Quaternion); ((Quaternion)(ref rotation))..ctor(ReadFloat(payload, ref num), ReadFloat(payload, ref num), ReadFloat(payload, ref num), ReadFloat(payload, ref num)); Vector3 scale = default(Vector3); ((Vector3)(ref scale))..ctor(ReadFloat(payload, ref num), ReadFloat(payload, ref num), ReadFloat(payload, ref num)); PropInfo propInfo = PropLibrary.FindById(text); if (propInfo == null && text.StartsWith("gpui://", StringComparison.OrdinalIgnoreCase) && GpuiPropScanner.GpuiScannedNames.Count == 0) { GpuiPropScanner.ScanGpuiProps(); propInfo = PropLibrary.FindById(text); MaterialCatalog.InvalidateMaterialSources(); } if (propInfo != null) { RemotePropGhostManager.UpdateGhost(senderUuid, propInfo, position, rotation, scale); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandlePropGhostUpdate failed: " + ex.Message); } } private static void PollLocalAccessories() { PlayerMovement me = PlayerMovement.me; if ((Object)(object)me == (Object)null) { for (int i = 0; i < 3; i++) { if (_lastAccInstId[i] != 0) { SendCustomAccessoryRemove(i); _lastAccInstId[i] = 0; } } return; } bool flag = Time.unscaledTime >= _nextAccRebroadcastTime; if (flag) { _nextAccRebroadcastTime = Time.unscaledTime + 2.5f; } for (int j = 0; j < 3; j++) { LevelEditorObject localCustomAccessory = GetLocalCustomAccessory(me, j); int num = (((Object)(object)localCustomAccessory != (Object)null) ? ((Object)((Component)localCustomAccessory).gameObject).GetInstanceID() : 0); if (num != _lastAccInstId[j]) { if (num != 0) { if (SendCustomAccessoryDon(j, localCustomAccessory)) { _lastAccInstId[j] = num; } } else { SendCustomAccessoryRemove(j); _lastAccInstId[j] = 0; } } else if (num != 0 && flag) { SendCustomAccessoryDon(j, localCustomAccessory); } } } private static LevelEditorObject GetLocalCustomAccessory(PlayerMovement player, int slot) { try { LevelEditorObject levelEditorObject; if (slot == 0) { Hat currentHat = player.currentHat; levelEditorObject = (((Object)(object)currentHat != (Object)null) ? ((Component)currentHat).GetComponent() : null); } else { Il2CppReferenceArray handItems = player.handItems; int num = slot - 1; if (handItems == null || num >= ((Il2CppArrayBase)(object)handItems).Length) { return null; } Grabable val = ((Il2CppArrayBase)(object)handItems)[num]; levelEditorObject = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); } return ((Object)(object)levelEditorObject != (Object)null && !string.IsNullOrEmpty(levelEditorObject.addressableKey)) ? levelEditorObject : null; } catch { return null; } } private static bool SendCustomAccessoryDon(int slot, LevelEditorObject leo) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) if (_channel == null || (Object)(object)leo == (Object)null) { return false; } try { Transform localAccessoryBone = GetLocalAccessoryBone(slot); if ((Object)(object)localAccessoryBone == (Object)null) { return false; } string addressableKey = leo.addressableKey; if (string.IsNullOrEmpty(addressableKey)) { return false; } Transform transform = ((Component)leo).transform; Vector3 val = localAccessoryBone.InverseTransformPoint(transform.position); Quaternion val2 = Quaternion.Inverse(localAccessoryBone.rotation) * transform.rotation; Vector3 lossyScale = transform.lossyScale; float value = 1f; Vector4 val3 = default(Vector4); ((Vector4)(ref val3))..ctor(0f, 1f, 1f, 0f); if (slot == 0) { value = leo.hatHairAmt; Hat component = ((Component)leo).GetComponent(); if ((Object)(object)component != (Object)null) { val3 = Vector4.op_Implicit(component.hairlineUpVec); } } byte[] bytes = Encoding.UTF8.GetBytes(addressableKey); byte[] array = new byte[4 + bytes.Length + 60]; int num = 0; array[num++] = 198; array[num++] = (byte)slot; array[num++] = (byte)(bytes.Length & 0xFF); array[num++] = (byte)((bytes.Length >> 8) & 0xFF); Buffer.BlockCopy(bytes, 0, array, num, bytes.Length); num += bytes.Length; WriteFloat(array, ref num, val.x); WriteFloat(array, ref num, val.y); WriteFloat(array, ref num, val.z); WriteFloat(array, ref num, val2.x); WriteFloat(array, ref num, val2.y); WriteFloat(array, ref num, val2.z); WriteFloat(array, ref num, val2.w); WriteFloat(array, ref num, lossyScale.x); WriteFloat(array, ref num, lossyScale.y); WriteFloat(array, ref num, lossyScale.z); WriteFloat(array, ref num, value); WriteFloat(array, ref num, val3.x); WriteFloat(array, ref num, val3.y); WriteFloat(array, ref num, val3.z); WriteFloat(array, ref num, val3.w); ChannelSend(array, reliable: true); return true; } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendCustomAccessoryDon failed: " + ex.Message); return false; } } private static void SendCustomAccessoryRemove(int slot) { if (_channel == null) { return; } try { ChannelSend(new byte[2] { 199, (byte)slot }, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendCustomAccessoryRemove failed: " + ex.Message); } } private static void HandleCustomAccessoryDon(byte senderUuid, byte[] payload) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) try { if (payload.Length >= 4) { int num = 1; int num2 = payload[num++]; int num3 = payload[num] | (payload[num + 1] << 8); num += 2; if (num2 >= 0 && num2 <= 2 && num3 > 0 && num + num3 + 60 <= payload.Length) { string propId = Encoding.UTF8.GetString(payload, num, num3); num += num3; Vector3 localPos = default(Vector3); ((Vector3)(ref localPos))..ctor(ReadFloat(payload, ref num), ReadFloat(payload, ref num), ReadFloat(payload, ref num)); Quaternion localRot = default(Quaternion); ((Quaternion)(ref localRot))..ctor(ReadFloat(payload, ref num), ReadFloat(payload, ref num), ReadFloat(payload, ref num), ReadFloat(payload, ref num)); Vector3 worldScale = default(Vector3); ((Vector3)(ref worldScale))..ctor(ReadFloat(payload, ref num), ReadFloat(payload, ref num), ReadFloat(payload, ref num)); float hairAmt = ReadFloat(payload, ref num); Vector4 hairUp = default(Vector4); ((Vector4)(ref hairUp))..ctor(ReadFloat(payload, ref num), ReadFloat(payload, ref num), ReadFloat(payload, ref num), ReadFloat(payload, ref num)); RemoteAccessoryManager.SetDesired(senderUuid, num2, propId, localPos, localRot, worldScale, hairAmt, hairUp); } } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleCustomAccessoryDon failed: " + ex.Message); } } private static void HandleCustomAccessoryRemove(byte senderUuid, byte[] payload) { try { if (payload.Length >= 2) { int num = payload[1]; if (num >= 0 && num <= 2) { RemoteAccessoryManager.ClearDesired(senderUuid, num); } } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleCustomAccessoryRemove failed: " + ex.Message); } } internal static void MarkPropPropertiesDirty(ulong netId) { if (netId != 0) { _dirtyPropProps.Add(netId); } } private static void FlushDirtyPropProperties() { if (_dirtyPropProps.Count == 0 || Time.unscaledTime < _nextPropPropsFlushTime) { return; } _nextPropPropsFlushTime = Time.unscaledTime + 0.12f; foreach (ulong dirtyPropProp in _dirtyPropProps) { if (_networkedObjects.TryGetValue(dirtyPropProp, out var value) && (Object)(object)value != (Object)null) { SendPropProperties(value); } } _dirtyPropProps.Clear(); } private static void SendPropProperties(LevelEditorObject obj) { if (_channel == null || (Object)(object)obj == (Object)null || obj.netId == 0) { return; } try { string s = obj.surfaceTypeTag ?? string.Empty; byte[] bytes = Encoding.UTF8.GetBytes(s); byte[] array = new byte[64 + bytes.Length]; int offset = 0; array[offset++] = 200; WriteULong(array, ref offset, obj.netId); WriteFloat(array, ref offset, obj.hatHairAmt); WriteFloat(array, ref offset, obj.hatOffsetPos.x); WriteFloat(array, ref offset, obj.hatOffsetPos.y); WriteFloat(array, ref offset, obj.hatOffsetPos.z); WriteFloat(array, ref offset, obj.hatOffsetRot.x); WriteFloat(array, ref offset, obj.hatOffsetRot.y); WriteFloat(array, ref offset, obj.hatOffsetRot.z); WriteFloat(array, ref offset, obj.grabOffsetPos.x); WriteFloat(array, ref offset, obj.grabOffsetPos.y); WriteFloat(array, ref offset, obj.grabOffsetPos.z); WriteFloat(array, ref offset, obj.grabOffsetRot.x); WriteFloat(array, ref offset, obj.grabOffsetRot.y); WriteFloat(array, ref offset, obj.grabOffsetRot.z); byte b = 0; if (obj.sunglassesNeeded) { b |= 1; } if (obj.playerPassthrough) { b |= 2; } if (BbHatSunglassesFlag.Has(obj)) { b |= 4; } array[offset++] = b; array[offset++] = (byte)(bytes.Length & 0xFF); array[offset++] = (byte)((bytes.Length >> 8) & 0xFF); Buffer.BlockCopy(bytes, 0, array, offset, bytes.Length); ChannelSend(array, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendPropProperties failed: " + ex.Message); } } private static void HandlePropProperties(byte senderUuid, byte[] payload) { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) try { if (payload.Length < 64) { return; } int offset = 1; ulong key = ReadULong(payload, ref offset); float hatHairAmt = ReadFloat(payload, ref offset); Vector3 hatOffsetPos = default(Vector3); ((Vector3)(ref hatOffsetPos))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); Vector3 hatOffsetRot = default(Vector3); ((Vector3)(ref hatOffsetRot))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); Vector3 grabOffsetPos = default(Vector3); ((Vector3)(ref grabOffsetPos))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); Vector3 grabOffsetRot = default(Vector3); ((Vector3)(ref grabOffsetRot))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); byte b = payload[offset++]; int num = payload[offset] | (payload[offset + 1] << 8); offset += 2; string text = ((num > 0 && offset + num <= payload.Length) ? Encoding.UTF8.GetString(payload, offset, num) : string.Empty); if (!_networkedObjects.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { _networkedObjects.Remove(key); return; } value.hatHairAmt = hatHairAmt; value.hatOffsetPos = hatOffsetPos; value.hatOffsetRot = hatOffsetRot; value.grabOffsetPos = grabOffsetPos; value.grabOffsetRot = grabOffsetRot; bool flag = (b & 1) != 0; bool flag2 = (b & 2) != 0; bool flag3 = (b & 4) != 0; if (value.sunglassesNeeded != flag) { value.sunglassesNeeded = flag; BbSunglassesChecker component = ((Component)value).GetComponent(); if (flag && (Object)(object)component == (Object)null) { ((Component)value).gameObject.AddComponent(); } else if (!flag && (Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } } if (value.playerPassthrough != flag2) { value.playerPassthrough = flag2; PropInstanceServices.SetBushPassthrough(((Component)value).gameObject, flag2); } BbHatSunglassesFlag.Set(value, flag3); if (!string.IsNullOrEmpty(text) && value.surfaceTypeTag != text) { PropInstanceServices.ApplySurfaceType(value, text); } Hat component2 = ((Component)value).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.isSunglasses = flag3; } PhysicsObjectManager.SyncHatHairAmount(value); if (value.physicsMode == PhysicsMode.Grabable || value.physicsMode == PhysicsMode.Hat) { PhysicsObjectManager.SyncGrabOffset(value); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandlePropProperties failed: " + ex.Message); } } public static void SendPropPhysicsMode(List netIds, PhysicsMode mode) { if (_channel == null || netIds == null) { return; } List list = new List(); foreach (ulong netId in netIds) { if (netId != 0) { list.Add(netId); } } if (list.Count == 0) { return; } try { int num = Math.Min(list.Count, 255); byte[] array = new byte[3 + num * 8]; int offset = 0; array[offset++] = 201; array[offset++] = (byte)mode; array[offset++] = (byte)num; for (int i = 0; i < num; i++) { WriteULong(array, ref offset, list[i]); } ChannelSend(array, reliable: true); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendPropPhysicsMode failed: " + ex.Message); } } private static void HandlePropPhysicsMode(byte senderUuid, byte[] payload) { try { if (payload.Length < 3) { return; } int offset = 1; PhysicsMode mode = (PhysicsMode)payload[offset++]; int num = payload[offset++]; if (payload.Length < 3 + num * 8) { return; } List list = new List(num); for (int i = 0; i < num; i++) { ulong key = ReadULong(payload, ref offset); if (_networkedObjects.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { list.Add(value); } } if (list.Count != 0) { LevelEditor.ApplyPhysicsModeToTargets(list, mode); } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandlePropPhysicsMode failed: " + ex.Message); } } public static void SendGroupRootTransform(int groupId, bool reliable = true) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) if (_channel == null || groupId <= 0) { return; } LevelEditorManager instance = LevelEditorManager.Instance; if ((Object)(object)instance == (Object)null) { return; } List list = new List(); foreach (LevelEditorObject @object in instance.Objects) { if ((Object)(object)@object != (Object)null && @object.groupId == groupId && @object.netId != 0) { list.Add(@object.netId); } } if (list.Count == 0) { return; } Vector3 groupDisplayScale = GroupManager.GetGroupDisplayScale(groupId); GameObject groupRoot = GroupManager.GetGroupRoot(groupId); Quaternion val = (((Object)(object)groupRoot != (Object)null) ? groupRoot.transform.rotation : Quaternion.identity); try { int num = Math.Min(list.Count, 255); byte[] array = new byte[30 + num * 8]; int offset = 0; array[offset++] = 202; WriteFloat(array, ref offset, val.x); WriteFloat(array, ref offset, val.y); WriteFloat(array, ref offset, val.z); WriteFloat(array, ref offset, val.w); WriteFloat(array, ref offset, groupDisplayScale.x); WriteFloat(array, ref offset, groupDisplayScale.y); WriteFloat(array, ref offset, groupDisplayScale.z); array[offset++] = (byte)num; for (int i = 0; i < num; i++) { WriteULong(array, ref offset, list[i]); } ChannelSend(array, reliable); } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] SendGroupRootTransform failed: " + ex.Message); } } private static void HandleGroupScale(byte senderUuid, byte[] payload) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) try { if (payload.Length < 30) { return; } int offset = 1; Quaternion rotation = default(Quaternion); ((Quaternion)(ref rotation))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); Vector3 scale = default(Vector3); ((Vector3)(ref scale))..ctor(ReadFloat(payload, ref offset), ReadFloat(payload, ref offset), ReadFloat(payload, ref offset)); int num = payload[offset++]; if (payload.Length < offset + num * 8) { return; } int num2 = 0; for (int i = 0; i < num; i++) { ulong key = ReadULong(payload, ref offset); if (num2 == 0 && _networkedObjects.TryGetValue(key, out var value) && (Object)(object)value != (Object)null && value.groupId > 0) { num2 = value.groupId; } } if (num2 > 0) { GroupManager.SetGroupDisplayScale(num2, scale); GameObject groupRoot = GroupManager.GetGroupRoot(num2); if ((Object)(object)groupRoot != (Object)null) { groupRoot.transform.rotation = rotation; } } } catch (Exception ex) { MelonLogger.Warning("[BabyBlocks][ModNetworking] HandleGroupScale failed: " + ex.Message); } } private static Transform GetLocalAccessoryBone(int slot) { try { if (_localPlayerInstanceField == null) { return null; } object value = _localPlayerInstanceField.GetValue(null); return GetBoneFromPlayer(value, slot); } catch { return null; } } internal static Transform GetRemoteAccessoryBone(byte uuid, int slot) { try { object remotePlayerObject = GetRemotePlayerObject(uuid); return GetBoneFromPlayer(remotePlayerObject, slot); } catch { return null; } } private static object GetRemotePlayerObject(byte uuid) { if (_playersField == null || _networkManagerField == null) { return null; } object value = _networkManagerField.GetValue(null); if (value == null) { return null; } return (_playersField.GetValue(value) is IDictionary dictionary) ? dictionary[uuid] : null; } internal static void SetRemoteHair(byte uuid, float hatMax, Vector4 hatUp) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) try { if (!(_basePlayerSetHairHatMethod == null)) { object remotePlayerObject = GetRemotePlayerObject(uuid); if (remotePlayerObject != null) { _basePlayerSetHairHatMethod.Invoke(remotePlayerObject, new object[2] { hatMax, hatUp }); } } } catch { } } private static Transform GetBoneFromPlayer(object player, int slot) { if (player == null) { return null; } try { if (slot == 0) { object? obj = _basePlayerHeadBoneField?.GetValue(player); return (Transform)((obj is Transform) ? obj : null); } if (_basePlayerHandBonesField == null) { return null; } object value = _basePlayerHandBonesField.GetValue(player); if (value == null) { return null; } object obj2 = ((slot != 1) ? _handBonesItem2Field?.GetValue(value) : _handBonesItem1Field?.GetValue(value)); return (Transform)((obj2 is Transform) ? obj2 : null); } catch { return null; } } } internal static class RemoteFreecamManager { private class Marker { public GameObject root; public MeshRenderer renderer; public TextMeshPro nameText; public Transform nameTagTransform; public Color color; public float lastUpdateTime; } private const float SphereDiameter = 0.4f; private const float StaleTimeoutSeconds = 6f; private const float SphereAlpha = 0.35f; private static readonly Dictionary _markers = new Dictionary(); public static void Update() { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (_markers.Count == 0) { return; } bool flag = FlyCamController.FlyCamActive && FlyCamController.CursorMode; Camera main = Camera.main; float unscaledTime = Time.unscaledTime; List list = null; foreach (KeyValuePair marker in _markers) { Marker value = marker.Value; if ((Object)(object)value.root == (Object)null) { continue; } if (unscaledTime - value.lastUpdateTime > 6f) { (list ?? (list = new List())).Add(marker.Key); continue; } if (value.root.activeSelf != flag) { value.root.SetActive(flag); } if (flag && (Object)(object)main != (Object)null && (Object)(object)value.nameTagTransform != (Object)null) { value.nameTagTransform.rotation = Quaternion.LookRotation(value.nameTagTransform.position - ((Component)main).transform.position); } } if (list == null) { return; } foreach (byte item in list) { Remove(item); } } public static void UpdateFreecam(byte uuid, Vector3 position, Color suitColor, string name) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (!_markers.TryGetValue(uuid, out var value) || (Object)(object)value.root == (Object)null) { value = Create(suitColor, name); _markers[uuid] = value; } value.root.transform.position = position; value.lastUpdateTime = Time.unscaledTime; if (value.color != suitColor) { value.color = suitColor; if ((Object)(object)value.renderer != (Object)null) { SetSphereColor(((Renderer)value.renderer).material, suitColor); } } if ((Object)(object)value.nameText != (Object)null && ((TMP_Text)value.nameText).text != name) { ((TMP_Text)value.nameText).text = name; } } public static void Remove(byte uuid) { if (_markers.TryGetValue(uuid, out var value)) { if ((Object)(object)value.root != (Object)null) { Object.Destroy((Object)(object)value.root); } _markers.Remove(uuid); } } public static void ClearAll() { foreach (Marker value in _markers.Values) { if ((Object)(object)value.root != (Object)null) { Object.Destroy((Object)(object)value.root); } } _markers.Clear(); } private static Material CreateSphereMaterial(Color suitColor) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); Material val2 = new Material(val) { name = "BabyBlocks_RemoteFreecamSphere", renderQueue = 3000 }; SetSphereColor(val2, suitColor); return val2; } private static void SetSphereColor(Material mat, Color suitColor) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) float num = 0.35f; mat.color = new Color(suitColor.r * num, suitColor.g * num, suitColor.b * num, num); } private static Marker Create(Color suitColor, string name) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0040: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown GameObject val = new GameObject("BabyBlocks_RemoteFreecam"); val.SetActive(false); GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val2).name = "Sphere"; val2.transform.SetParent(val.transform, false); val2.transform.localScale = Vector3.one * 0.4f; Collider component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshRenderer component2 = val2.GetComponent(); Material material = CreateSphereMaterial(suitColor); ((Renderer)component2).material = material; GameObject val3 = new GameObject("Nametag"); val3.transform.SetParent(val.transform, false); val3.transform.localPosition = new Vector3(0f, 0.55f, 0f); TextMeshPro val4 = val3.AddComponent(); ((TMP_Text)val4).alignment = (TextAlignmentOptions)514; ((TMP_Text)val4).fontSize = 1.5f; ((Graphic)val4).color = Color.white; ((TMP_Text)val4).text = name; Shader val5 = Shader.Find("TextMeshPro/Distance Field Overlay"); if ((Object)(object)val5 != (Object)null) { TMP_FontAsset font = ((TMP_Text)val4).font; if ((Object)(object)((font != null) ? ((TMP_Asset)font).material : null) != (Object)null) { Material val6 = new Material(val5); val6.mainTexture = ((TMP_Asset)((TMP_Text)val4).font).material.mainTexture; ((TMP_Text)val4).fontMaterial = val6; } } return new Marker { root = val, renderer = component2, nameText = val4, nameTagTransform = val3.transform, color = suitColor, lastUpdateTime = Time.unscaledTime }; } } internal static class RemotePropHighlightManager { private class Highlight { public readonly List targets = new List(); public Color color; } private static readonly Dictionary _highlights = new Dictionary(); public static void Update() { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) GizmoRenderer.ClearRemoteHighlights(); if (_highlights.Count == 0) { return; } bool flag = FlyCamController.FlyCamActive && FlyCamController.CursorMode; List list = null; foreach (KeyValuePair highlight in _highlights) { Highlight value = highlight.Value; value.targets.RemoveAll((LevelEditorObject t) => (Object)(object)t == (Object)null); if (value.targets.Count == 0) { (list ?? (list = new List())).Add(highlight.Key); } else if (flag) { GizmoRenderer.AddRemoteHighlight(value.color, value.targets); } } if (list == null) { return; } foreach (byte item in list) { _highlights.Remove(item); } } public static void SetHighlights(byte uuid, List targets, Color color) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (targets == null || targets.Count == 0) { Remove(uuid); return; } if (!_highlights.TryGetValue(uuid, out var value)) { value = new Highlight(); _highlights[uuid] = value; } value.targets.Clear(); value.targets.AddRange(targets); value.color = color; } public static void Remove(byte uuid) { _highlights.Remove(uuid); } public static void ClearAll() { _highlights.Clear(); GizmoRenderer.ClearRemoteHighlights(); } } internal static class RemotePropGhostManager { private class Ghost { public GameObject root; public string propId; public float lastUpdateTime; } private const float StaleTimeoutSeconds = 6f; private const float PostEndSuppressSeconds = 1f; private static readonly Dictionary _ghosts = new Dictionary(); private static readonly Dictionary _suppressedUntil = new Dictionary(); public static void Update() { if (_ghosts.Count == 0) { return; } bool flag = FlyCamController.FlyCamActive && FlyCamController.CursorMode; float unscaledTime = Time.unscaledTime; List list = null; foreach (KeyValuePair ghost in _ghosts) { Ghost value = ghost.Value; if ((Object)(object)value.root == (Object)null || unscaledTime - value.lastUpdateTime > 6f) { (list ?? (list = new List())).Add(ghost.Key); } else if (value.root.activeSelf != flag) { value.root.SetActive(flag); } } if (list == null) { return; } foreach (byte item in list) { Remove(item); } } public static void UpdateGhost(byte uuid, PropInfo info, Vector3 position, Quaternion rotation, Vector3 scale) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) if (_suppressedUntil.TryGetValue(uuid, out var value)) { if (Time.unscaledTime < value) { return; } _suppressedUntil.Remove(uuid); } if (!_ghosts.TryGetValue(uuid, out var value2) || (Object)(object)value2.root == (Object)null || value2.propId != info.id) { if ((Object)(object)value2?.root != (Object)null) { Object.Destroy((Object)(object)value2.root); } PropLibrary.LoadPropData(info); if (!info.HasMesh) { return; } GameObject val = LevelEditor.CreateGhostObject(info); if ((Object)(object)val == (Object)null) { return; } value2 = new Ghost { root = val, propId = info.id }; _ghosts[uuid] = value2; } value2.root.transform.SetPositionAndRotation(position, rotation); value2.root.transform.localScale = scale; value2.lastUpdateTime = Time.unscaledTime; bool flag = FlyCamController.FlyCamActive && FlyCamController.CursorMode; if (value2.root.activeSelf != flag) { value2.root.SetActive(flag); } } public static void Remove(byte uuid) { if (_ghosts.TryGetValue(uuid, out var value)) { if ((Object)(object)value.root != (Object)null) { Object.Destroy((Object)(object)value.root); } _ghosts.Remove(uuid); } } public static void NotifyDragEnded(byte uuid) { Remove(uuid); _suppressedUntil[uuid] = Time.unscaledTime + 1f; } public static void ClearAll() { foreach (Ghost value in _ghosts.Values) { if ((Object)(object)value.root != (Object)null) { Object.Destroy((Object)(object)value.root); } } _ghosts.Clear(); _suppressedUntil.Clear(); } } internal static class RemoteAccessoryManager { private class Worn { public string propId; public Vector3 localPos; public Quaternion localRot; public Vector3 worldScale; public float hairAmt = 1f; public Vector4 hairUp = NoHatHairUp; public GameObject clone; public Transform attachedBone; public float lastSeenTime; } private const float UnresolvedTimeoutSeconds = 12f; private const float AttachedStaleSeconds = 8f; private static readonly Vector4 NoHatHairUp = new Vector4(0f, 1f, 1f, 0f); private const float NoHatHairAmt = 1f; private static readonly Dictionary<(byte uuid, int slot), Worn> _worn = new Dictionary<(byte, int), Worn>(); public static void SetDesired(byte uuid, int slot, string propId, Vector3 localPos, Quaternion localRot, Vector3 worldScale, float hairAmt, Vector4 hairUp) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(propId)) { return; } (byte, int) key = (uuid, slot); if (!_worn.TryGetValue(key, out var value)) { value = new Worn(); _worn[key] = value; } if ((Object)(object)value.clone != (Object)null && value.propId != propId) { Object.Destroy((Object)(object)value.clone); value.clone = null; value.attachedBone = null; } value.propId = propId; value.localPos = localPos; value.localRot = localRot; value.worldScale = worldScale; value.hairAmt = hairAmt; value.hairUp = hairUp; value.lastSeenTime = Time.unscaledTime; if ((Object)(object)value.clone != (Object)null && (Object)(object)value.attachedBone != (Object)null) { value.clone.transform.localPosition = localPos; value.clone.transform.localRotation = localRot; ApplyWorldScale(value.clone.transform, value.attachedBone, worldScale); if (slot == 0) { ModNetworking.SetRemoteHair(uuid, hairAmt, hairUp); } } } public static void ClearDesired(byte uuid, int slot) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) (byte, int) key = (uuid, slot); if (_worn.TryGetValue(key, out var value)) { if ((Object)(object)value.clone != (Object)null) { Object.Destroy((Object)(object)value.clone); } _worn.Remove(key); } if (slot == 0) { ModNetworking.SetRemoteHair(uuid, 1f, NoHatHairUp); } } public static void Update() { //IL_0195: Unknown result type (might be due to invalid IL or missing references) if (_worn.Count == 0) { return; } float unscaledTime = Time.unscaledTime; List<(byte, int)> list = null; foreach (KeyValuePair<(byte, int), Worn> item in _worn) { Worn value = item.Value; if ((Object)(object)value.clone == (Object)null) { value.attachedBone = null; } if ((Object)(object)value.clone == (Object)null) { if (!TryBuild(item.Key.Item1, item.Key.Item2, value) && unscaledTime - value.lastSeenTime > 12f) { (list ?? (list = new List<(byte, int)>())).Add(item.Key); } } else if (unscaledTime - value.lastSeenTime > 8f) { (list ?? (list = new List<(byte, int)>())).Add(item.Key); } } if (list == null) { return; } foreach (var item2 in list) { if (_worn.TryGetValue(item2, out var value2) && (Object)(object)value2.clone != (Object)null) { Object.Destroy((Object)(object)value2.clone); } _worn.Remove(item2); if (item2.Item2 == 0) { ModNetworking.SetRemoteHair(item2.Item1, 1f, NoHatHairUp); } } } private static bool TryBuild(byte uuid, int slot, Worn w) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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) Transform remoteAccessoryBone = ModNetworking.GetRemoteAccessoryBone(uuid, slot); if ((Object)(object)remoteAccessoryBone == (Object)null) { return false; } PropInfo propInfo = PropLibrary.FindById(w.propId); if (propInfo == null && w.propId.StartsWith("gpui://", StringComparison.OrdinalIgnoreCase) && GpuiPropScanner.GpuiScannedNames.Count == 0) { GpuiPropScanner.ScanGpuiProps(); propInfo = PropLibrary.FindById(w.propId); MaterialCatalog.InvalidateMaterialSources(); } if (propInfo == null) { return false; } PropLibrary.LoadPropData(propInfo); if (!propInfo.HasMesh) { return false; } GameObject val = LevelEditor.CreateGhostObject(propInfo); if ((Object)(object)val == (Object)null) { return false; } ((Object)val).name = "BabyBlocks_RemoteAccessory"; val.transform.SetParent(remoteAccessoryBone, false); val.transform.localPosition = w.localPos; val.transform.localRotation = w.localRot; ApplyWorldScale(val.transform, remoteAccessoryBone, w.worldScale); w.clone = val; w.attachedBone = remoteAccessoryBone; if (slot == 0) { ModNetworking.SetRemoteHair(uuid, w.hairAmt, w.hairUp); } return true; } private static void ApplyWorldScale(Transform t, Transform bone, Vector3 worldScale) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Vector3 lossyScale = bone.lossyScale; t.localScale = new Vector3((lossyScale.x != 0f) ? (worldScale.x / lossyScale.x) : worldScale.x, (lossyScale.y != 0f) ? (worldScale.y / lossyScale.y) : worldScale.y, (lossyScale.z != 0f) ? (worldScale.z / lossyScale.z) : worldScale.z); } public static void ClearAll() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<(byte, int), Worn> item in _worn) { if ((Object)(object)item.Value.clone != (Object)null) { Object.Destroy((Object)(object)item.Value.clone); } if (item.Key.Item2 == 0) { ModNetworking.SetRemoteHair(item.Key.Item1, 1f, NoHatHairUp); } } _worn.Clear(); } } } namespace BabyBlocks.UI { internal class FileBrowserPanel : PanelBase { private static readonly string LevelsDir = Path.Combine(MelonEnvironment.UserDataDirectory, "BabyBlocks", "levels"); private InputFieldRef _nameInput; private GameObject _fileListContent; private Text _statusText; private float _statusTime; private string _confirmPath; private bool _confirmDelete; private float _confirmTime; private const float ConfirmTimeout = 3f; private const float StatusDuration = 5f; private FileSystemWatcher _watcher; private volatile bool _pendingRefresh; private bool _nameInputActive; public static FileBrowserPanel Instance { get; private set; } internal bool IsTypingInUI => _nameInputActive; public override string Name => "Level Files"; public override int MinWidth => 360; public override int MinHeight => 220; public override bool CanDragAndResize => true; public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 0.5f); public override Vector2 DefaultAnchorMax => new Vector2(0.5f, 0.5f); public FileBrowserPanel(UIBase owner) : base(owner) { Instance = this; ((UIModel)this).UIRoot.SetActive(false); } public static void OpenPanel() { if (Instance != null) { Instance._confirmPath = null; Instance.Refresh(); ((UIModel)Instance).UIRoot.SetActive(true); Instance.StartWatcher(); } } public static void ClosePanel() { if (Instance != null) { Instance.StopWatcher(); ((UIModel)Instance).UIRoot.SetActive(false); } } private void StartWatcher() { StopWatcher(); try { Directory.CreateDirectory(LevelsDir); _watcher = new FileSystemWatcher(LevelsDir, "*.bbb") { NotifyFilter = NotifyFilters.FileName, EnableRaisingEvents = true }; _watcher.Created += delegate { _pendingRefresh = true; }; _watcher.Renamed += delegate { _pendingRefresh = true; }; _watcher.Deleted += delegate { _pendingRefresh = true; }; } catch { } } private void StopWatcher() { if (_watcher != null) { _watcher.EnableRaisingEvents = false; _watcher.Dispose(); _watcher = null; } } public void Tick() { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((UIModel)this).UIRoot == (Object)null || !((UIModel)this).UIRoot.activeSelf) { return; } if (_pendingRefresh) { _pendingRefresh = false; RebuildFileList(); } InputFieldRef nameInput = _nameInput; if ((Object)(object)((nameInput != null) ? nameInput.Component : null) != (Object)null) { if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { RectTransform component = ((Component)_nameInput.Component).GetComponent(); if ((Object)(object)component != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(component, Vector2.op_Implicit(Input.mousePosition), (Camera)null)) { _nameInputActive = true; } else if (_nameInputActive) { _nameInputActive = false; _nameInput.Component.DeactivateInputField(); EventSystem current = EventSystem.current; if (current != null) { current.SetSelectedGameObject((GameObject)null); } EventSystem eventSys = UniversalUI.EventSys; if (eventSys != null) { eventSys.SetSelectedGameObject((GameObject)null); } } } if (!_nameInputActive && _nameInput.Component.isFocused) { _nameInput.Component.DeactivateInputField(); EventSystem current2 = EventSystem.current; if (current2 != null) { current2.SetSelectedGameObject((GameObject)null); } EventSystem eventSys2 = UniversalUI.EventSys; if (eventSys2 != null) { eventSys2.SetSelectedGameObject((GameObject)null); } } } if (_confirmPath != null && Time.realtimeSinceStartup - _confirmTime > 3f) { _confirmPath = null; RebuildFileList(); } if ((Object)(object)_statusText != (Object)null && !string.IsNullOrEmpty(_statusText.text) && Time.realtimeSinceStartup - _statusTime >= 5f) { _statusText.text = ""; } } public override void SetDefaultSizeAndPosition() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) ((PanelBase)this).Rect.pivot = new Vector2(0.5f, 0.5f); ((PanelBase)this).Rect.anchorMin = new Vector2(0.5f, 0.5f); ((PanelBase)this).Rect.anchorMax = new Vector2(0.5f, 0.5f); ((PanelBase)this).Rect.sizeDelta = new Vector2(400f, 520f); ((PanelBase)this).Rect.anchoredPosition = Vector2.zero; } protected override void ConstructPanelContent() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) UIFactory.SetLayoutGroup(((PanelBase)this).ContentRoot, (bool?)true, (bool?)false, (bool?)true, (bool?)true, (int?)4, (int?)6, (int?)6, (int?)8, (int?)8, (TextAnchor?)null); GameObject val = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot, "SaveRow", false, false, true, true, 6, default(Vector4), default(Color), (TextAnchor?)null); int? num = 26; int? num2 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); Text val2 = UIFactory.CreateLabel(val, "NameLbl", "Save as:", (TextAnchor)3, default(Color), true, 14); GameObject gameObject = ((Component)val2).gameObject; int? num3 = 62; num2 = 0; UIFactory.SetLayoutElement(gameObject, num3, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); _nameInput = UIFactory.CreateInputField(val, "NameInput", "filename"); GameObject gameObject2 = ((Component)_nameInput.Component).gameObject; num2 = 9999; num = 22; UIFactory.SetLayoutElement(gameObject2, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); _nameInput.Component.characterLimit = 128; Text val3 = UIFactory.CreateLabel(val, "ExtLbl", ".bbb", (TextAnchor)3, new Color(0.45f, 0.45f, 0.45f), true, 13); GameObject gameObject3 = ((Component)val3).gameObject; int? num4 = 32; num = 0; UIFactory.SetLayoutElement(gameObject3, num4, (int?)null, num, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef val4 = UIFactory.CreateButton(val, "SaveBtn", "Save", (Color?)null); UIFactory.SetLayoutElement(((Component)val4.Component).gameObject, (int?)56, (int?)22, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); PropBrowserUI.ApplyButtonColors(val4); val4.OnClick = (Action)Delegate.Combine(val4.OnClick, new Action(OnSaveClick)); _statusText = UIFactory.CreateLabel(((PanelBase)this).ContentRoot, "Status", "", (TextAnchor)3, new Color(1f, 1f, 0.4f), true, 13); GameObject gameObject4 = ((Component)_statusText).gameObject; num = 18; num2 = 9999; UIFactory.SetLayoutElement(gameObject4, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef val5 = UIFactory.CreateButton(((PanelBase)this).ContentRoot, "OpenFolderBtn", "Open Levels Folder", (Color?)null); GameObject gameObject5 = ((Component)val5.Component).gameObject; num2 = 24; num = 9999; UIFactory.SetLayoutElement(gameObject5, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); PropBrowserUI.ApplyButtonColors(val5); val5.OnClick = (Action)Delegate.Combine(val5.OnClick, (Action)delegate { OpenFolder(LevelsDir); }); Text val6 = UIFactory.CreateLabel(((PanelBase)this).ContentRoot, "DivLbl", "── existing files ──", (TextAnchor)4, new Color(0.38f, 0.38f, 0.38f), true, 12); GameObject gameObject6 = ((Component)val6).gameObject; num = 16; num2 = 9999; UIFactory.SetLayoutElement(gameObject6, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); AutoSliderScrollbar val8 = default(AutoSliderScrollbar); GameObject val7 = UIFactory.CreateScrollView(((PanelBase)this).ContentRoot, "FileList", ref _fileListContent, ref val8, new Color(0.09f, 0.09f, 0.11f)); num2 = 9999; num = 9999; int? num5 = 80; UIFactory.SetLayoutElement(val7, (int?)null, num5, num, num2, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(_fileListContent, (bool?)true, (bool?)false, (bool?)true, (bool?)true, (int?)2, (int?)2, (int?)2, (int?)4, (int?)4, (TextAnchor?)null); } private void Refresh() { if (_nameInput != null) { string path = Core.LastSavePath ?? ""; string text = Path.GetFileNameWithoutExtension(path); if (string.IsNullOrEmpty(text)) { text = "level"; } _nameInput.Component.text = text; } RebuildFileList(); } private void RebuildFileList() { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fileListContent == (Object)null) { return; } for (int num = _fileListContent.transform.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)_fileListContent.transform.GetChild(num)).gameObject); } try { Directory.CreateDirectory(LevelsDir); } catch { } string[] array = Array.Empty(); try { array = Directory.GetFiles(LevelsDir, "*.bbb"); } catch { } Array.Sort(array, (string a, string b) => string.Compare(Path.GetFileName(a), Path.GetFileName(b), StringComparison.OrdinalIgnoreCase)); if (array.Length == 0) { Text val = UIFactory.CreateLabel(_fileListContent, "EmptyLbl", "No saved levels yet.", (TextAnchor)4, new Color(0.45f, 0.45f, 0.45f), true, 13); GameObject gameObject = ((Component)val).gameObject; int? num2 = 26; int? num3 = 9999; UIFactory.SetLayoutElement(gameObject, (int?)null, num2, num3, (int?)null, (int?)null, (int?)null, (bool?)null); return; } string[] array2 = array; foreach (string text in array2) { string path = text; string baseName = Path.GetFileNameWithoutExtension(text); bool flag = _confirmPath == path && !_confirmDelete; bool flag2 = _confirmPath == path && _confirmDelete; GameObject val2 = UIFactory.CreateHorizontalGroup(_fileListContent, "Row_" + baseName, false, false, true, true, 4, default(Vector4), default(Color), (TextAnchor?)null); int? num3 = 28; int? num2 = 9999; UIFactory.SetLayoutElement(val2, (int?)null, num3, num2, (int?)null, (int?)null, (int?)null, (bool?)null); Text val3 = UIFactory.CreateLabel(val2, "FileName", baseName, (TextAnchor)3, Color.white, true, 14); GameObject gameObject2 = ((Component)val3).gameObject; num2 = 9999; UIFactory.SetLayoutElement(gameObject2, (int?)null, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject gameObject3 = ((Component)val3).gameObject; Button val4 = gameObject3.AddComponent