using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MechaChameleon")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+67f3cc4d0c9e867227f7474adb201e11df783e76")] [assembly: AssemblyProduct("MechaChameleon")] [assembly: AssemblyTitle("MechaChameleon")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MechaChameleon { public static class AudioSystem { private static AudioSource uiSource; private static AudioSource GetSource() { if ((Object)(object)uiSource == (Object)null && (Object)(object)ChameleonManager.Instance != (Object)null) { uiSource = ((Component)ChameleonManager.Instance).gameObject.AddComponent(); uiSource.spatialBlend = 0f; uiSource.playOnAwake = false; uiSource.bypassEffects = true; uiSource.bypassListenerEffects = true; } return uiSource; } public static void PlayOpen() { Terminal val = Object.FindObjectOfType(); AudioClip clip = (((Object)(object)val != (Object)null && (Object)(object)val.enterTerminalSFX != (Object)null) ? val.enterTerminalSFX : (((Object)(object)HUDManager.Instance != (Object)null) ? HUDManager.Instance.scanSFX : null)); Play(clip, 0.75f); } public static void PlayClose() { Terminal val = Object.FindObjectOfType(); AudioClip clip = (((Object)(object)val != (Object)null && (Object)(object)val.leaveTerminalSFX != (Object)null) ? val.leaveTerminalSFX : (((Object)(object)HUDManager.Instance != (Object)null) ? HUDManager.Instance.scanSFX : null)); Play(clip, 0.65f); } public static void PlayClick() { Terminal val = Object.FindObjectOfType(); AudioClip clip = null; if ((Object)(object)val != (Object)null && val.keyboardClips != null && val.keyboardClips.Length != 0) { clip = val.keyboardClips[Random.Range(0, val.keyboardClips.Length)]; } else if ((Object)(object)HUDManager.Instance != (Object)null && HUDManager.Instance.dialogueBleeps != null && HUDManager.Instance.dialogueBleeps.Length != 0) { clip = HUDManager.Instance.dialogueBleeps[0]; } Play(clip, 0.5f); } public static void PlaySample() { AudioClip clip = (((Object)(object)HUDManager.Instance != (Object)null) ? HUDManager.Instance.scanSFX : null); Play(clip, 0.6f); } public static void PlaySuit() { AudioClip val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.changeSuitSFX : null); if ((Object)(object)val == (Object)null && (Object)(object)HUDManager.Instance != (Object)null) { val = HUDManager.Instance.addToScrapTotalSFX; } Play(val, 0.7f); } public static void PlayError() { AudioClip val = null; if ((Object)(object)HUDManager.Instance != (Object)null) { if (HUDManager.Instance.warningSFX != null && HUDManager.Instance.warningSFX.Length != 0) { val = HUDManager.Instance.warningSFX[Random.Range(0, HUDManager.Instance.warningSFX.Length)]; } else if ((Object)(object)HUDManager.Instance.levelDecreaseSFX != (Object)null) { val = HUDManager.Instance.levelDecreaseSFX; } else if (HUDManager.Instance.tipsSFX != null && HUDManager.Instance.tipsSFX.Length != 0) { val = HUDManager.Instance.tipsSFX[0]; } } if ((Object)(object)val == (Object)null && (Object)(object)StartOfRound.Instance != (Object)null) { val = StartOfRound.Instance.HUDSystemAlertSFX; } if ((Object)(object)val == (Object)null) { Terminal val2 = Object.FindObjectOfType(); if ((Object)(object)val2 != (Object)null && val2.syncedAudios != null && val2.syncedAudios.Length > 1) { val = val2.syncedAudios[1]; } } if ((Object)(object)val != (Object)null) { Play(val, 0.75f); } else { PlayClick(); } } private static void Play(AudioClip clip, float volume = 1f) { if ((Object)(object)clip == (Object)null) { return; } try { AudioSource source = GetSource(); if ((Object)(object)source != (Object)null) { source.PlayOneShot(clip, volume); } else if ((Object)(object)HUDManager.Instance != (Object)null && (Object)(object)HUDManager.Instance.UIAudio != (Object)null) { HUDManager.Instance.UIAudio.PlayOneShot(clip, volume); } } catch { } } } public static class CameraMath { public static Rect DisplayRect(Camera cam) { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ce: Unknown result type (might be due to invalid IL or missing references) Rect val = (Rect)(((Object)(object)cam != (Object)null) ? cam.rect : new Rect(0f, 0f, 1f, 1f)); if (((Rect)(ref val)).x <= 0.001f && ((Rect)(ref val)).y <= 0.001f && ((Rect)(ref val)).width >= 0.999f && ((Rect)(ref val)).height >= 0.999f) { return new Rect(0f, 0f, (float)Screen.width, (float)Screen.height); } return new Rect(((Rect)(ref val)).x * (float)Screen.width, ((Rect)(ref val)).y * (float)Screen.height, ((Rect)(ref val)).width * (float)Screen.width, ((Rect)(ref val)).height * (float)Screen.height); } public static Matrix4x4 ViewMatrix(Camera cam) { //IL_0009: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0038: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)cam).transform; Matrix4x4 val = Matrix4x4.TRS(transform.position, transform.rotation, new Vector3(1f, 1f, -1f)); return ((Matrix4x4)(ref val)).inverse; } public static Ray BuildRay(Camera cam, Vector2 screenPos) { //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_001d: 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_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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f0: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) Rect val = DisplayRect(cam); float num = ((((Rect)(ref val)).width > 0f) ? ((screenPos.x - ((Rect)(ref val)).x) / ((Rect)(ref val)).width * 2f - 1f) : 0f); float num2 = ((((Rect)(ref val)).height > 0f) ? ((screenPos.y - ((Rect)(ref val)).y) / ((Rect)(ref val)).height * 2f - 1f) : 0f); Transform transform = ((Component)cam).transform; Matrix4x4 projectionMatrix = cam.projectionMatrix; Vector4 val2 = ((Matrix4x4)(ref projectionMatrix)).inverse * new Vector4(num, num2, -1f, 1f); if (Mathf.Abs(val2.w) > 1E-06f) { val2 /= val2.w; } Vector3 val3 = transform.TransformDirection(new Vector3(val2.x, val2.y, 0f - val2.z)); if (((Vector3)(ref val3)).sqrMagnitude < 1E-12f) { val3 = transform.forward; } return new Ray(transform.position, ((Vector3)(ref val3)).normalized); } public static bool ProjectToGui(Camera cam, Matrix4x4 viewProjection, Vector3 world, out Vector2 gui) { //IL_0002: 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_0024: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_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_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_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) gui = default(Vector2); if ((Object)(object)cam == (Object)null) { return false; } Vector4 val = viewProjection * new Vector4(world.x, world.y, world.z, 1f); if (val.w <= 1E-05f) { return false; } Rect val2 = DisplayRect(cam); float num = ((Rect)(ref val2)).x + (val.x / val.w * 0.5f + 0.5f) * ((Rect)(ref val2)).width; float num2 = ((Rect)(ref val2)).y + (val.y / val.w * 0.5f + 0.5f) * ((Rect)(ref val2)).height; gui = new Vector2(num, (float)Screen.height - num2); return true; } } [DefaultExecutionOrder(30000)] public class ChameleonManager : MonoBehaviour { private PlayerControllerB player; private Camera cam; private PaintTarget target; private PaintUI ui; private static readonly float[] ZoomSteps = new float[11] { 0.3f, 0.45f, 0.65f, 0.9f, 1.25f, 1.7f, 2.3f, 3.1f, 4.2f, 5.5f, 7f }; private Vector3 pivot; private Vector3 panOffset; private float yaw; private float pitch; private int zoomIndex = 5; private float savedAnimatorSpeed = 1f; private bool animatorFrozen; private PaintHit hoverHit; private bool hoverValid; private Vector3 camLocalPos; private Quaternion camLocalRot; private float camNear; private float camFov; private int frameCounter; private bool shouldPickScreen; private float lastScreenRead; private Vector2 pickScreenPos; private bool pickingWithSpace; private Keyboard textDevice; private const float PortraitFov = 34f; internal const float PortraitAspect = 0.75f; public static ChameleonManager Instance { get; private set; } public bool Active { get; private set; } public static bool HasMoreCompany { get { try { if (Chainloader.PluginInfos.ContainsKey("notnotnotswipez-MoreCompany") || Chainloader.PluginInfos.ContainsKey("MoreCompany")) { return true; } return Type.GetType("MoreCompany.MainClass, MoreCompany") != null; } catch { return false; } } } public bool CosmeticsVisible { get; set; } = true; private void Awake() { Instance = this; ui = new PaintUI(); } private void OnDestroy() { UnsubscribeText(); if (Active) { Exit(); } target?.Dispose(); ui?.Dispose(); ChameleonNet.Shutdown(); } private static PlayerControllerB GetLocalPlayer() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return null; } PlayerControllerB localPlayerController = instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null || !localPlayerController.isPlayerControlled) { return null; } return localPlayerController; } private void Update() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) ChameleonNet.Tick(); Keyboard current = Keyboard.current; PlayerControllerB localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null) { if (Active) { Exit(); } return; } if (target != null && (Object)(object)target.Player != (Object)(object)localPlayer) { if (Active) { Exit(); } target.Dispose(); target = null; } bool flag = Active && ui.CapturingText; if (current != null && !flag && ((ButtonControl)current[Plugin.ToggleKey.Value]).wasPressedThisFrame) { if (Active) { Exit(); } else { Enter(localPlayer); } } else if (!Active) { frameCounter++; if (target == null && localPlayer.isPlayerControlled && ((Object)(object)localPlayer.thisPlayerModel != (Object)null || ((Component)localPlayer).gameObject.activeInHierarchy)) { target = new PaintTarget(localPlayer); if (target.EnsureSetup()) { PublishPaint(); } } if (frameCounter % 15 == 0) { GameObject val = GameObject.Find("ThridPersonCam"); if ((Object)(object)val != (Object)null && val.activeInHierarchy) { LODGroup componentInChildren = ((Component)localPlayer).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null && componentInChildren.enabled && ((Component)componentInChildren).gameObject.activeInHierarchy) { componentInChildren.ForceLOD(0); } } } if (target != null && frameCounter % 30 == 0) { target.ReapplyIfNeeded(); } } else if (current != null && !flag && ((ButtonControl)current.escapeKey).wasPressedThisFrame) { Exit(); } else { if (flag) { HandleTypingInput(current); } else { UnsubscribeText(); } target.PreAnimationTick(); } } private void RunEditor() { //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_002a: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00d0: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; Mouse current2 = Mouse.current; if (current2 != null) { Vector2 val = ((InputControl)(object)((Pointer)current2).position).ReadValue(); Vector2 mouse = default(Vector2); ((Vector2)(ref mouse))..ctor(val.x, (float)Screen.height - val.y); bool flag = ui.HandleInput(mouse, current2.leftButton.wasPressedThisFrame, current2.leftButton.isPressed, current2.leftButton.wasReleasedThisFrame); hoverValid = !flag && target.RaycastSurface(BuildRay(val), out hoverHit); HandleCameraInput(current2, current, flag); HandlePaintInput(current2, current, val, flag); ui.SetCursor(cam, hoverValid, hoverHit.Point, hoverHit.Normal, ui.BrushRadius * 0.01f); target.FlushTextures(); } } private void LateUpdate() { //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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Invalid comparison between Unknown and I4 if (Active && !((Object)(object)cam == (Object)null) && target != null) { if ((Object)(object)player != (Object)null) { player.disableLookInput = true; player.disableMoveInput = true; player.disableInteract = true; player.moveInputVector = Vector2.zero; player.isJumping = false; } ApplyCameraPose(); target.AssertTPose(); RunEditor(); target?.TickVisibility(cam); if ((int)Cursor.lockState > 0) { Cursor.lockState = (CursorLockMode)0; } if (!Cursor.visible) { Cursor.visible = true; } } } private void HandleTypingInput(Keyboard kb) { if (kb != null) { SubscribeText(kb); if (((ButtonControl)kb.escapeKey).wasPressedThisFrame) { ui.TypeCancel(); } else if (((ButtonControl)kb.enterKey).wasPressedThisFrame || ((ButtonControl)kb.numpadEnterKey).wasPressedThisFrame) { ui.TypeCommit(); } else if (((ButtonControl)kb.backspaceKey).wasPressedThisFrame) { ui.TypeBackspace(); } } } private void SubscribeText(Keyboard kb) { if (textDevice != kb) { UnsubscribeText(); textDevice = kb; kb.onTextInput += OnTextInput; } } private void UnsubscribeText() { if (textDevice != null) { try { textDevice.onTextInput -= OnTextInput; } catch { } textDevice = null; } } private void OnTextInput(char c) { ui.TypeChar(c); } private Ray BuildRay(Vector2 screenPos) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return CameraMath.BuildRay(cam, screenPos); } private int GetEnvironmentMask() { if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.collidersAndRoomMaskAndDefault != 0) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } return LayerMask.GetMask(new string[7] { "Room", "Colliders", "Default", "Terrain", "PlaceableShipObject", "Props", "Railing" }); } private void ApplyCameraPose() { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_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_0058: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_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_007b: 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_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_0224: 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_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: 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_010a: 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_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) if ((Object)(object)cam == (Object)null || target == null) { return; } Vector3 anchor = target.GetAnchor(); int environmentMask = GetEnvironmentMask(); Vector3 val = anchor + panOffset; Vector3 val2 = val - anchor; float magnitude = ((Vector3)(ref val2)).magnitude; pivot = val; if (magnitude > 0.01f) { Vector3 val3 = val2 / magnitude; RaycastHit val4 = default(RaycastHit); if (Physics.SphereCast(anchor, 0.12f, val3, ref val4, magnitude, environmentMask, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val4)).collider != (Object)null && !((RaycastHit)(ref val4)).collider.isTrigger && ((Object)(object)player == (Object)null || !((Component)((RaycastHit)(ref val4)).collider).transform.IsChildOf(((Component)player).transform))) { float num = Mathf.Max(0f, ((RaycastHit)(ref val4)).distance - 0.06f); pivot = anchor + val3 * num; } } Quaternion val5 = Quaternion.Euler(pitch, yaw, 0f); Vector3 val6 = val5 * Vector3.back; float num2 = ZoomSteps[zoomIndex]; float num3 = num2; float num4 = 0.1f; Ray val7 = default(Ray); ((Ray)(ref val7))..ctor(pivot, val6); RaycastHit[] array = Physics.SphereCastAll(val7, num4, num2, environmentMask, (QueryTriggerInteraction)1); float num5 = num2; for (int i = 0; i < array.Length; i++) { RaycastHit val8 = array[i]; if (!((Object)(object)((RaycastHit)(ref val8)).collider == (Object)null) && !((RaycastHit)(ref val8)).collider.isTrigger && (!((Object)(object)player != (Object)null) || !((Component)((RaycastHit)(ref val8)).collider).transform.IsChildOf(((Component)player).transform)) && ((RaycastHit)(ref val8)).distance < num5) { num5 = ((RaycastHit)(ref val8)).distance; } } RaycastHit val9 = default(RaycastHit); if (Physics.Raycast(val7, ref val9, num2, environmentMask, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val9)).collider != (Object)null && !((RaycastHit)(ref val9)).collider.isTrigger && ((Object)(object)player == (Object)null || !((Component)((RaycastHit)(ref val9)).collider).transform.IsChildOf(((Component)player).transform))) { float num6 = Mathf.Max(0.12f, ((RaycastHit)(ref val9)).distance - 0.06f); if (num6 < num5) { num5 = num6; } } if (num5 < num2) { num3 = Mathf.Max(0.18f, num5); } ((Component)cam).transform.SetPositionAndRotation(pivot + val6 * num3, val5); } private void Enter(PlayerControllerB p) { //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_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_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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) try { player = p; cam = p.gameplayCamera; if ((Object)(object)cam == (Object)null) { return; } if (target == null) { target = new PaintTarget(p); } if (target.EnsureSetup()) { camLocalPos = ((Component)cam).transform.localPosition; camLocalRot = ((Component)cam).transform.localRotation; camNear = cam.nearClipPlane; camFov = cam.fieldOfView; cam.nearClipPlane = Mathf.Min(camNear, 0.03f); panOffset = Vector3.zero; pivot = target.GetAnchor(); yaw = ((Component)p).transform.eulerAngles.y + 180f; pitch = 6f; zoomIndex = 5; target.SetPerCameraVisibility(Plugin.RecordingCompat.Value); target.SetThirdPerson(on: true, cam); target.SetShadows(ui.ShadowsOn); ui.HasMoreCompany = HasMoreCompany; ui.CosmeticsOn = CosmeticsVisible; target.SetCosmeticsVisible(CosmeticsVisible); LockGameInput(locked: true); Active = true; ApplyCameraPose(); AudioSystem.PlayOpen(); if (Plugin.FreezePose.Value) { ((MonoBehaviour)this).StartCoroutine(FreezePoseSoon()); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to open the paint editor: {arg}"); Exit(); } } public void Exit() { //IL_00e3: 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 (!Active) { return; } Active = false; try { AudioSystem.PlayClose(); target?.EndStroke(); target?.SetTPose(on: false); target?.SetFlatView(on: false); ui.TPoseOn = false; ui.FlatViewOn = false; ui.SetPresetsOpen(open: false); UnsubscribeText(); target?.SetThirdPerson(on: false, cam); if (Plugin.AutoSave.Value) { target?.Save(); } PublishPaint(); if ((Object)(object)cam != (Object)null) { ((Component)cam).transform.localPosition = camLocalPos; ((Component)cam).transform.localRotation = camLocalRot; cam.nearClipPlane = camNear; cam.fieldOfView = camFov; } } catch (Exception arg) { Plugin.Log.LogError((object)$"Error while closing the paint editor: {arg}"); } finally { LockGameInput(locked: false); ThawPose(); } } private void PublishPaint() { try { if (target != null && target.TryGetSnapshot(out var albedoPixels, out var maskPixels, out var textureSize)) { ChameleonNet.PublishLocal(albedoPixels, maskPixels, textureSize); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Publishing paint to the lobby failed: {arg}"); } } private IEnumerator FreezePoseSoon() { yield return (object)new WaitForSeconds(0.35f); if (Active && !((Object)(object)player == (Object)null) && !((Object)(object)player.playerBodyAnimator == (Object)null)) { savedAnimatorSpeed = player.playerBodyAnimator.speed; player.playerBodyAnimator.speed = 0f; animatorFrozen = true; } } private void ThawPose() { if (animatorFrozen) { animatorFrozen = false; if ((Object)(object)player != (Object)null && (Object)(object)player.playerBodyAnimator != (Object)null) { player.playerBodyAnimator.speed = ((savedAnimatorSpeed <= 0f) ? 1f : savedAnimatorSpeed); } } } private void LockGameInput(bool locked) { //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_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) try { IngamePlayerSettings instance = IngamePlayerSettings.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerInput != (Object)null && (Object)(object)instance.playerInput.actions != (Object)null) { if (locked) { instance.playerInput.actions.Disable(); } else { instance.playerInput.actions.Enable(); } } } catch { } if ((Object)(object)player != (Object)null) { try { player.disableLookInput = locked; player.disableMoveInput = locked; player.disableInteract = locked; if (player.playerActions != null) { MovementActions movement; if (locked) { player.playerActions.Disable(); movement = player.playerActions.Movement; ((MovementActions)(ref movement)).Disable(); } else { player.playerActions.Enable(); movement = player.playerActions.Movement; ((MovementActions)(ref movement)).Enable(); } } } catch { } } if (!locked) { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } else { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private void HandleCameraInput(Mouse mouse, Keyboard kb, bool uiCaptured) { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_01c9: 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) //IL_01e9: 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_01ff: 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_0244: 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) if (((InputControl)(object)((Vector2Control)mouse.scroll).y).ReadValue() != 0f) { float num = ((InputControl)(object)((Vector2Control)mouse.scroll).y).ReadValue(); if (kb != null && (((ButtonControl)kb.leftAltKey).isPressed || ((ButtonControl)kb.rightAltKey).isPressed)) { float num2 = ((((ButtonControl)kb.leftShiftKey).isPressed || ((ButtonControl)kb.rightShiftKey).isPressed) ? 0.2f : 1f); ui.BrushRadius = Mathf.Clamp(ui.BrushRadius + ((num > 0f) ? num2 : (0f - num2)), 0.2f, 50f); } else if (!ui.TryScrollPresets(num) && !uiCaptured) { int num3 = zoomIndex; if (num > 0f && zoomIndex > 0) { zoomIndex--; } if (num < 0f && zoomIndex < ZoomSteps.Length - 1) { zoomIndex++; } } } if (mouse.middleButton.isPressed) { Vector2 val = ((InputControl)(object)((Pointer)mouse).delta).ReadValue(); if (kb != null && (((ButtonControl)kb.leftShiftKey).isPressed || ((ButtonControl)kb.rightShiftKey).isPressed)) { float num4 = Plugin.PanSensitivity.Value * ZoomSteps[zoomIndex]; panOffset += ((Component)cam).transform.right * ((0f - val.x) * num4) + ((Component)cam).transform.up * ((0f - val.y) * num4); panOffset = Vector3.ClampMagnitude(panOffset, 3.5f); } else { float value = Plugin.OrbitSensitivity.Value; float num5 = (Plugin.InvertOrbitY.Value ? (-1f) : 1f); yaw = Mathf.Repeat(yaw + val.x * value, 360f); pitch = Mathf.Clamp(pitch - val.y * value * num5, -80f, 85f); } } } private void HandlePaintInput(Mouse mouse, Keyboard kb, Vector2 screenPos, bool uiCaptured) { //IL_0023: 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_0055: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_014c: 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_0157: 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_0193: 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_019e: 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) if (kb != null && !ui.CapturingText) { if (((ButtonControl)kb[Plugin.PickKey.Value]).isPressed && !uiCaptured) { pickingWithSpace = true; shouldPickScreen = true; pickScreenPos = screenPos; } else if (pickingWithSpace) { pickingWithSpace = false; ui.Remember(ui.Tint, ui.Metallic, ui.Smoothness); AudioSystem.PlaySample(); } bool flag = ((ButtonControl)kb.leftCtrlKey).isPressed || ((ButtonControl)kb.rightCtrlKey).isPressed; if (flag && ((ButtonControl)kb.zKey).wasPressedThisFrame) { RequestUndo(); } if (flag && ((ButtonControl)kb.rKey).wasPressedThisFrame) { RequestReset(); } Key value = Plugin.TPoseKey.Value; if (!flag && (int)value != 0 && ((ButtonControl)kb[value]).wasPressedThisFrame) { SetTPose(!ui.TPoseOn); AudioSystem.PlayClick(); } Key value2 = Plugin.FlatViewKey.Value; if (!flag && (int)value2 != 0 && ((ButtonControl)kb[value2]).wasPressedThisFrame) { SetFlatView(!ui.FlatViewOn); AudioSystem.PlayClick(); } Key value3 = Plugin.PresetsKey.Value; if (!flag && (int)value3 != 0 && ((ButtonControl)kb[value3]).wasPressedThisFrame) { ui.TogglePresets(); AudioSystem.PlayClick(); } } if (uiCaptured || mouse.middleButton.isPressed) { target.EndStroke(); return; } bool isPressed = mouse.rightButton.isPressed; bool isPressed2 = mouse.leftButton.isPressed; if (mouse.leftButton.wasPressedThisFrame || mouse.rightButton.wasReleasedThisFrame) { target.BeginStroke(); ui.Remember(ui.Tint, ui.Metallic, ui.Smoothness); ui.ClearWearing(); } if (isPressed2 || isPressed) { if (hoverValid) { target.StrokeTo(hoverHit, ui.Brush, isPressed && !isPressed2); } else { target.BreakStroke(); } } if ((mouse.leftButton.wasReleasedThisFrame || mouse.rightButton.wasReleasedThisFrame) && !mouse.leftButton.isPressed && !mouse.rightButton.isPressed) { target.EndStroke(); } } private void ExecuteScreenPick(Vector2 screenPos) { //IL_0013: 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_0133: 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_014e: 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_0176: 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_019e: 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_01cd: 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_00c1: 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_00da: 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_011b: 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_021e: 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_023a: 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_02af: Unknown result type (might be due to invalid IL or missing references) Plugin.Log.LogInfo((object)$"[Eyedropper] Pick triggered at screenPos=({screenPos.x:0}, {screenPos.y:0}) [Screen: {Screen.width}x{Screen.height}]"); if (hoverValid) { target.SampleAt(hoverHit.UV, out var color, out var metallic, out var smoothness); Plugin.Log.LogInfo((object)$"[Eyedropper] Sampled own player paint at UV=({hoverHit.UV.x:0.000}, {hoverHit.UV.y:0.000}) -> Color={ToHex(color)} (RGB: {color.r:0.00},{color.g:0.00},{color.b:0.00}), Met={metallic:0.00}, Smooth={smoothness:0.00}"); ui.AdoptSample(color, metallic, smoothness, "own paint"); return; } Ray ray = BuildRay(screenPos); Plugin.Log.LogInfo((object)$"[Eyedropper] Firing MaterialProbe ray from origin=({((Ray)(ref ray)).origin.x:0.00},{((Ray)(ref ray)).origin.y:0.00},{((Ray)(ref ray)).origin.z:0.00}) dir=({((Ray)(ref ray)).direction.x:0.00},{((Ray)(ref ray)).direction.y:0.00},{((Ray)(ref ray)).direction.z:0.00})"); if (MaterialProbe.Sample(ray, ((Object)(object)player != (Object)null) ? ((Component)player).transform : null, out var color2, out var metallic2, out var smoothness2, out var what)) { Plugin.Log.LogInfo((object)$"[Eyedropper] MaterialProbe adopted: {what} -> Color={ToHex(color2)} (RGB: {color2.r:0.00},{color2.g:0.00},{color2.b:0.00}), Met={metallic2:0.00}, Smooth={smoothness2:0.00}"); ui.AdoptSample(color2, metallic2, smoothness2, what); } else { Plugin.Log.LogInfo((object)"[Eyedropper] MaterialProbe did not find readable mesh UV. Starting ReadScreenPixel coroutine..."); if (!(Time.unscaledTime - lastScreenRead < 0.06f)) { lastScreenRead = Time.unscaledTime; ((MonoBehaviour)this).StartCoroutine(ReadScreenPixel(screenPos)); } } } private IEnumerator ReadScreenPixel(Vector2 screenPos) { //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) yield return (object)new WaitForEndOfFrame(); Texture2D tex = null; RenderTexture prev = RenderTexture.active; RenderTexture tempRt = null; try { int px = Mathf.Clamp(Mathf.RoundToInt(screenPos.x), 0, Screen.width - 1); int py = Mathf.Clamp(Mathf.RoundToInt(screenPos.y), 0, Screen.height - 1); tex = new Texture2D(1, 1, (TextureFormat)4, false, false); _ = Color.black; Color col; if ((Object)(object)cam != (Object)null && (Object)(object)cam.targetTexture != (Object)null) { tempRt = RenderTexture.GetTemporary(1, 1, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2); ((Texture)tempRt).filterMode = (FilterMode)0; float normX = Mathf.Clamp01(screenPos.x / (float)Screen.width); float normY = Mathf.Clamp01(screenPos.y / (float)Screen.height); Vector2 scale = new Vector2(1f / (float)Mathf.Max(1, ((Texture)cam.targetTexture).width), 1f / (float)Mathf.Max(1, ((Texture)cam.targetTexture).height)); Vector2 offset = new Vector2(normX - scale.x * 0.5f, normY - scale.y * 0.5f); Graphics.Blit((Texture)(object)cam.targetTexture, tempRt, scale, offset); RenderTexture.active = tempRt; tex.ReadPixels(new Rect(0f, 0f, 1f, 1f), 0, 0); tex.Apply(); col = tex.GetPixel(0, 0); } else { RenderTexture.active = null; tex.ReadPixels(new Rect((float)px, (float)py, 1f, 1f), 0, 0); tex.Apply(); col = tex.GetPixel(0, 0); } col.a = 1f; Plugin.Log.LogInfo((object)$"[Eyedropper ReadScreenPixel] Sampled screen at ({px}, {py}) -> Color={ToHex(col)} (Raw RGBA: {col.r:0.000}, {col.g:0.000}, {col.b:0.000}, {col.a:0.000}), LinearSpace={QualitySettings.activeColorSpace}"); ui.AdoptSample(col, ui.Metallic, ui.Smoothness, "screen"); } catch (Exception ex) { Exception e = ex; Plugin.Log.LogWarning((object)("[Eyedropper ReadScreenPixel FAILED]: " + e.Message + "\n" + e.StackTrace)); } finally { RenderTexture.active = prev; if ((Object)(object)tempRt != (Object)null) { RenderTexture.ReleaseTemporary(tempRt); } if ((Object)(object)tex != (Object)null) { Object.Destroy((Object)(object)tex); } } } private static string ToHex(Color c) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) return "#" + ColorUtility.ToHtmlStringRGB(new Color(Mathf.Clamp01(c.r), Mathf.Clamp01(c.g), Mathf.Clamp01(c.b))); } private void OnGUI() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (Active) { if (shouldPickScreen) { shouldPickScreen = false; ExecuteScreenPick(pickScreenPos); } ui.Draw(this, target); } } internal void RequestFill() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (target != null) { ui.Remember(ui.Tint, ui.Metallic, ui.Smoothness); ui.ClearWearing(); target.FillAll(ui.Brush); AudioSystem.PlaySuit(); } } internal void RequestUndo() { target?.Undo(); AudioSystem.PlayClick(); } internal void RequestReset() { target?.ResetPaint(); ui.ClearWearing(); AudioSystem.PlaySuit(); } internal void RequestSave() { target?.Save(); AudioSystem.PlaySuit(); } internal void RequestLoad() { target?.Load(); AudioSystem.PlaySuit(); } internal void RequestClose() { Exit(); } internal void RequestSavePreset(string name) { if (Active && target != null && target.IsReady) { ((MonoBehaviour)this).StartCoroutine(SavePresetRoutine(name)); } } private IEnumerator SavePresetRoutine(string name) { yield return (object)new WaitForEndOfFrame(); Texture2D shot = CaptureModelShot(384); if (target == null || !target.TryGetSnapshot(out var albedo, out var mask, out var texSize)) { if ((Object)(object)shot != (Object)null) { Object.Destroy((Object)(object)shot); } ui.Announce("Nothing to save yet"); yield break; } SuitPreset saved = SuitPresets.Save(name, albedo, mask, texSize, shot); if (saved != null) { ui.OnPresetSaved(saved); ui.Announce("Saved '" + saved.Name + "'"); AudioSystem.PlaySuit(); yield break; } if ((Object)(object)shot != (Object)null) { Object.Destroy((Object)(object)shot); } ui.Announce("Saving the preset failed - see the log"); } internal void RequestApplyPreset(SuitPreset preset) { if (target != null && preset != null) { if (!SuitPresets.TryRead(preset, out var albedo, out var mask, out var size)) { ui.Announce("'" + preset.Name + "' could not be read"); AudioSystem.PlayClick(); } else if (target.ApplyLayers(albedo, mask, size)) { ui.Announce("Wearing '" + preset.Name + "'" + ((mask == null) ? " (colour only)" : "")); AudioSystem.PlaySuit(); } else { ui.Announce("'" + preset.Name + "' would not apply"); } } } private Texture2D CaptureModelShot(int height) { //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_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_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_00bd: 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_0114: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null || target == null) { return null; } if (!target.TryGetPosedBounds(out var bounds)) { return null; } int num = Mathf.RoundToInt((float)height * 0.75f); RenderTexture val = null; RenderTexture active = RenderTexture.active; RenderTexture targetTexture = cam.targetTexture; Vector3 position = ((Component)cam).transform.position; Quaternion rotation = ((Component)cam).transform.rotation; float fieldOfView = cam.fieldOfView; bool flatView = target.FlatView; Texture2D val2 = null; try { target.SetFlatView(on: true); PoseForPortrait(bounds); cam.aspect = 0.75f; val = RenderTexture.GetTemporary(num, height, 24, (RenderTextureFormat)0); cam.targetTexture = val; cam.Render(); RenderTexture.active = val; val2 = new Texture2D(num, height, (TextureFormat)4, false) { hideFlags = (HideFlags)61 }; val2.ReadPixels(new Rect(0f, 0f, (float)num, (float)height), 0, 0); val2.Apply(false); if (!CutOutBody(val2)) { Object.Destroy((Object)(object)val2); val2 = null; Plugin.Log.LogInfo((object)"[Presets] Preview came back empty; falling back to the paint's palette."); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Presets] Preview render failed (" + ex.Message + "); falling back to the paint's palette.")); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); val2 = null; } } finally { cam.targetTexture = targetTexture; RenderTexture.active = active; if ((Object)(object)val != (Object)null) { RenderTexture.ReleaseTemporary(val); } cam.fieldOfView = fieldOfView; cam.ResetAspect(); ((Component)cam).transform.SetPositionAndRotation(position, rotation); if (!flatView) { target.SetFlatView(on: false); } } return val2; } private void PoseForPortrait(Bounds body) { //IL_0021: 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_0026: 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_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_0076: 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_0094: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)player != (Object)null) ? ((Component)player).transform.forward : Vector3.forward); val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val)).normalized : Vector3.forward); cam.fieldOfView = 34f; float num = Mathf.Tan(0.29670596f); float num2 = num * 0.75f; float num3 = Mathf.Max(((Bounds)(ref body)).extents.x, ((Bounds)(ref body)).extents.z); float num4 = Mathf.Max(((Bounds)(ref body)).extents.y / num, num3 / num2) * 1.14f; Vector3 val2 = ((Bounds)(ref body)).center + val * num4; ((Component)cam).transform.SetPositionAndRotation(val2, Quaternion.LookRotation(-val, Vector3.up)); } private bool CutOutBody(Texture2D shot) { //IL_003f: 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_0082: 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_0097: 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_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_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_00c6: 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_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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_015d: 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_0190: 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_0197: 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_01e1: 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_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_01c2: 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_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_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_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: 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_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034b: 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_035d: 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_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_053d: 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_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_064f: Unknown result type (might be due to invalid IL or missing references) //IL_0684: Unknown result type (might be due to invalid IL or missing references) //IL_069f: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06df: Unknown result type (might be due to invalid IL or missing references) //IL_06e1: Unknown result type (might be due to invalid IL or missing references) if (!target.TryGetPosedGeometry(out var worldVertices, out var triangles)) { return false; } int width = ((Texture)shot).width; int height = ((Texture)shot).height; int num = width * 3; int num2 = height * 3; Matrix4x4 val = cam.projectionMatrix * CameraMath.ViewMatrix(cam); Vector3[] array = (Vector3[])(object)new Vector3[worldVertices.Length]; for (int i = 0; i + 2 < triangles.Length; i += 3) { int num3 = triangles[i]; int num4 = triangles[i + 1]; int num5 = triangles[i + 2]; Vector3 val2 = Vector3.Cross(worldVertices[num4] - worldVertices[num3], worldVertices[num5] - worldVertices[num3]); ref Vector3 reference = ref array[num3]; reference += val2; ref Vector3 reference2 = ref array[num4]; reference2 += val2; ref Vector3 reference3 = ref array[num5]; reference3 += val2; } for (int j = 0; j < array.Length; j++) { array[j] = ((Vector3)(ref array[j])).normalized; } Vector3[] array2 = (Vector3[])(object)new Vector3[worldVertices.Length]; for (int k = 0; k < worldVertices.Length; k++) { Vector4 val3 = val * new Vector4(worldVertices[k].x, worldVertices[k].y, worldVertices[k].z, 1f); if (val3.w <= 1E-05f) { array2[k] = new Vector3(0f, 0f, -1f); continue; } float num6 = 1f / val3.w; array2[k] = new Vector3((val3.x * num6 * 0.5f + 0.5f) * (float)num, (val3.y * num6 * 0.5f + 0.5f) * (float)num2, val3.w); } float[] array3 = new float[num * num2]; float[] array4 = new float[num * num2]; for (int l = 0; l < array3.Length; l++) { array3[l] = float.MaxValue; } Quaternion rotation = ((Component)cam).transform.rotation; Vector3 val4 = new Vector3(-0.45f, 0.62f, -1f); Vector3 key = rotation * ((Vector3)(ref val4)).normalized; Vector3 forward = ((Component)cam).transform.forward; long num7 = 0L; for (int m = 0; m + 2 < triangles.Length; m += 3) { int num8 = triangles[m]; int num9 = triangles[m + 1]; int num10 = triangles[m + 2]; Vector3 val5 = array2[num8]; Vector3 val6 = array2[num9]; Vector3 val7 = array2[num10]; if (!(val5.z < 0f) && !(val6.z < 0f) && !(val7.z < 0f)) { num7 += ShadeTriangle(array3, array4, num, num2, val5, val6, val7, array[num8], array[num9], array[num10], key, forward); } } if (num7 < (long)num * (long)num2 / 900) { Plugin.Log.LogWarning((object)$"[Presets] Silhouette covered almost nothing ({num7} subpixels of {(long)num * (long)num2})."); return false; } double num11 = 0.0; long num12 = 0L; for (int n = 0; n < array4.Length; n++) { if (array3[n] != float.MaxValue) { num11 += (double)array4[n]; num12++; } } float num13 = ((num12 > 0 && num11 > 1E-06) ? ((float)((double)num12 / num11)) : 1f); Color32[] pixels = shot.GetPixels32(); byte[] array5 = new byte[width * height]; float[] array6 = new float[width * height]; int[] array7 = new int[256]; long num14 = 0L; int num15 = 255; int num16 = 0; for (int num17 = 0; num17 < height; num17++) { for (int num18 = 0; num18 < width; num18++) { int num19 = 0; float num20 = 0f; for (int num21 = 0; num21 < 3; num21++) { int num22 = (num17 * 3 + num21) * num + num18 * 3; for (int num23 = 0; num23 < 3; num23++) { if (array3[num22 + num23] != float.MaxValue) { num19++; num20 += array4[num22 + num23]; } } } int num24 = num17 * width + num18; array5[num24] = (byte)(num19 * 255 / 9); array6[num24] = ((num19 > 0) ? (num20 / (float)num19 * num13) : 1f); Color32 val8 = pixels[num24]; int num25 = val8.r * 77 + val8.g * 150 + val8.b * 29 >> 8; if (num25 < num15) { num15 = num25; } if (num25 > num16) { num16 = num25; } if (num19 == 9) { array7[num25]++; num14++; } } } if (num14 == 0L || num16 - num15 < 4) { Plugin.Log.LogWarning((object)$"[Presets] Render came back blank (body px {num14}, frame range {num15}-{num16})."); return false; } byte[] array8 = BuildLevels(array7, num14); if (array8 == null) { return false; } for (int num26 = 0; num26 < pixels.Length; num26++) { Color32 val9 = pixels[num26]; byte b = array5[num26]; if (b == 0) { val9.r = 0; val9.g = 0; val9.b = 0; } else { val9.r = Shaded(array8[val9.r], array6[num26]); val9.g = Shaded(array8[val9.g], array6[num26]); val9.b = Shaded(array8[val9.b], array6[num26]); } val9.a = b; pixels[num26] = val9; } shot.SetPixels32(pixels); shot.Apply(false); return true; } private byte[] BuildLevels(int[] histogram, long inside) { //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_00aa: 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_00c7: Unknown result type (might be due to invalid IL or missing references) double num = 0.0; for (int i = 0; i < 256; i++) { if (histogram[i] > 0) { num += (double)((float)histogram[i] * Mathf.Pow((float)i / 255f, 2.2f)); } } num /= (double)inside; if (!target.TryGetSnapshot(out var albedoPixels, out var _, out var _) || albedoPixels == null) { return null; } double num2 = 0.0; long num3 = 0L; int num4 = Mathf.Max(1, albedoPixels.Length / 60000); for (int j = 0; j < albedoPixels.Length; j += num4) { Color32 val = albedoPixels[j]; float num5 = ((float)(int)val.r * 0.299f + (float)(int)val.g * 0.587f + (float)(int)val.b * 0.114f) / 255f; num2 += (double)Mathf.Pow(num5, 2.2f); num3++; } if (num3 == 0) { return null; } num2 /= (double)num3; float num6 = ((num > 1E-06) ? ((float)(num2 / num)) : 1f); num6 = Mathf.Clamp(num6, 0.05f, 64f); float num7 = (float)num * num6; if (num7 < 0.012f && num > 1E-06) { num6 = 0.012f / (float)num; } byte[] array = new byte[256]; for (int k = 0; k < 256; k++) { float num8 = Mathf.Pow((float)k / 255f, 2.2f) * num6; if (num8 > 0.7f) { num8 = 0.7f + (num8 - 0.7f) / (1f + (num8 - 0.7f) * 2.2f); } array[k] = (byte)Mathf.Clamp(Mathf.RoundToInt(Mathf.Pow(Mathf.Min(num8, 1f), 0.45454544f) * 255f), 0, 255); } return array; } private static long ShadeTriangle(float[] depth, float[] shade, int width, int height, Vector3 a, Vector3 b, Vector3 c, Vector3 na, Vector3 nb, Vector3 nc, Vector3 key, Vector3 eye) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00f9: 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_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_0176: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_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_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_01ca: 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_01ea: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_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_02b0: 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_02be: 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) //IL_02c9: 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_02ed: 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_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0304: 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_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(0, Mathf.FloorToInt(Mathf.Min(a.x, Mathf.Min(b.x, c.x)))); int num2 = Mathf.Min(width - 1, Mathf.CeilToInt(Mathf.Max(a.x, Mathf.Max(b.x, c.x)))); int num3 = Mathf.Max(0, Mathf.FloorToInt(Mathf.Min(a.y, Mathf.Min(b.y, c.y)))); int num4 = Mathf.Min(height - 1, Mathf.CeilToInt(Mathf.Max(a.y, Mathf.Max(b.y, c.y)))); if (num > num2 || num3 > num4) { return 0L; } float num5 = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); if (Mathf.Abs(num5) < 1E-06f) { return 0L; } float num6 = 1f / num5; long num7 = 0L; for (int i = num3; i <= num4; i++) { float num8 = (float)i + 0.5f; int num9 = i * width; for (int j = num; j <= num2; j++) { float num10 = (float)j + 0.5f; float num11 = ((b.x - a.x) * (num8 - a.y) - (b.y - a.y) * (num10 - a.x)) * num6; float num12 = ((c.x - b.x) * (num8 - b.y) - (c.y - b.y) * (num10 - b.x)) * num6; float num13 = ((a.x - c.x) * (num8 - c.y) - (a.y - c.y) * (num10 - c.x)) * num6; if (num11 < 0f || num12 < 0f || num13 < 0f) { continue; } int num14 = num9 + j; float num15 = a.z * num12 + b.z * num13 + c.z * num11; if (!(num15 >= depth[num14])) { if (depth[num14] == float.MaxValue) { num7++; } depth[num14] = num15; Vector3 val = na * num12 + nb * num13 + nc * num11; Vector3 val2 = ((Vector3)(ref val)).normalized; if (Vector3.Dot(val2, eye) > 0f) { val2 = -val2; } float num16 = Mathf.Max(0f, Vector3.Dot(val2, key)); float num17 = Mathf.Max(0f, Vector3.Dot(val2, -key)); shade[num14] = 0.37f + 0.84f * num16 + 0.12f * num17; } } } return num7; } private static byte Shaded(byte value, float light) { float num = Mathf.Pow((float)(int)value / 255f, 2.2f) * light; return (byte)Mathf.Clamp(Mathf.RoundToInt(Mathf.Pow(Mathf.Min(num, 1f), 0.45454544f) * 255f), 0, 255); } internal void SetShadows(bool on) { ui.ShadowsOn = on; target?.SetShadows(on); } internal void SetTPose(bool on) { if (target != null) { ui.TPoseOn = target.SetTPose(on); } } internal void SetFlatView(bool on) { if (target != null) { ui.FlatViewOn = target.SetFlatView(on); } } internal void SetCosmeticsVisible(bool on) { CosmeticsVisible = on; ui.CosmeticsOn = on; target?.SetCosmeticsVisible(on); ApplyGlobalCosmeticsVisibility(on); ui.Announce(on ? "Cosmetics: Shown" : "Cosmetics: Hidden"); } internal void ApplyGlobalCosmeticsVisibility(bool on) { try { MonoBehaviour[] array = Object.FindObjectsOfType(true); foreach (MonoBehaviour val in array) { if ((Object)(object)val == (Object)null || ((object)val).GetType().Name != "CosmeticInstance") { continue; } Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null) { val2.enabled = on; } } } } catch { } } } public static class ChameleonNet { private class Incoming { public uint BlobId; public byte[] Buffer; public bool[] Got; public int Received; public int ChunkCount; } private class Outgoing { public ulong Target; public ulong Sender; public uint BlobId; public byte[] Blob; public int NextChunk; public int ChunkCount; } private struct Decoded { public ulong ClientId; public byte[] Planes; public int Size; public byte[] Blob; } private struct Packed { public byte[] Blob; public ulong Hash; } [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnHello; public static HandleNamedMessageDelegate <1>__OnData; public static Action <2>__OnClientDisconnect; } private const string MsgHello = "MC_Hello"; private const string MsgData = "MC_Data"; private const byte Protocol = 1; private const int ChunkHeader = 22; private const int ChunkPayload = 8192; private const int MaxChunks = 514; private static NetworkManager boundTo; private static bool handlersRegistered; private static bool saidHello; private static byte[] localBlob; private static ulong localHash; private static bool compressing; private static bool blobDirty; private static uint nextBlobId = 1u; private static readonly HashSet moddedClients = new HashSet(); private static readonly Dictionary remotes = new Dictionary(); private static readonly Dictionary cache = new Dictionary(); private static readonly Dictionary inbox = new Dictionary(); private static readonly Queue outbox = new Queue(); private static float budget; private static float lastTick; private static readonly ConcurrentQueue decoded = new ConcurrentQueue(); private static readonly Dictionary latest = new Dictionary(); private static readonly ConcurrentQueue compressed = new ConcurrentQueue(); private static readonly List scratchIds = new List(); private static int frame; private static NetworkManager Net { get { NetworkManager singleton = NetworkManager.Singleton; return ((Object)(object)singleton != (Object)null && singleton.IsListening) ? singleton : null; } } private static bool Enabled => Plugin.NetSync != null && Plugin.NetSync.Value; public static void Tick() { if (!Enabled) { if (handlersRegistered) { Unbind(); } return; } DrainCompressed(); NetworkManager net = Net; if ((Object)(object)net == (Object)null) { if (handlersRegistered) { Unbind(); } return; } if (net != boundTo) { Bind(net); } if (handlersRegistered) { Handshake(net); if (blobDirty) { blobDirty = !BroadcastLocal(net); } PumpOutbox(net); ApplyOneDecoded(); if (++frame % 60 == 0) { TickRemotes(); } } } private static void Bind(NetworkManager nm) { //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_002e: Expected O, but got Unknown //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_005a: Expected O, but got Unknown Unbind(); try { CustomMessagingManager customMessagingManager = nm.CustomMessagingManager; object obj = <>O.<0>__OnHello; if (obj == null) { HandleNamedMessageDelegate val = OnHello; <>O.<0>__OnHello = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("MC_Hello", (HandleNamedMessageDelegate)obj); CustomMessagingManager customMessagingManager2 = nm.CustomMessagingManager; object obj2 = <>O.<1>__OnData; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnData; <>O.<1>__OnData = val2; obj2 = (object)val2; } customMessagingManager2.RegisterNamedMessageHandler("MC_Data", (HandleNamedMessageDelegate)obj2); nm.OnClientDisconnectCallback += OnClientDisconnect; boundTo = nm; handlersRegistered = true; saidHello = false; if (nm.IsServer) { moddedClients.Add(nm.LocalClientId); } if (localBlob != null) { blobDirty = true; } Plugin.Log.LogInfo((object)string.Format("[MC net] Bound as {0}, id {1}.", nm.IsServer ? "host" : "client", nm.LocalClientId)); } catch (Exception arg) { Plugin.Log.LogError((object)$"[MC net] Failed to register handlers: {arg}"); } } private static void Unbind() { if ((Object)(object)boundTo != (Object)null) { try { CustomMessagingManager customMessagingManager = boundTo.CustomMessagingManager; if (customMessagingManager != null) { customMessagingManager.UnregisterNamedMessageHandler("MC_Hello"); } CustomMessagingManager customMessagingManager2 = boundTo.CustomMessagingManager; if (customMessagingManager2 != null) { customMessagingManager2.UnregisterNamedMessageHandler("MC_Data"); } boundTo.OnClientDisconnectCallback -= OnClientDisconnect; } catch { } } foreach (RemotePaint value in remotes.Values) { value.Dispose(); } remotes.Clear(); moddedClients.Clear(); cache.Clear(); inbox.Clear(); outbox.Clear(); latest.Clear(); Decoded result; while (decoded.TryDequeue(out result)) { } boundTo = null; handlersRegistered = false; saidHello = false; } public static void Shutdown() { Unbind(); } private static void Handshake(NetworkManager nm) { if (!saidHello && !nm.IsServer && nm.IsConnectedClient) { SendHello(nm, 0uL); saidHello = true; } } private static void OnClientDisconnect(ulong clientId) { moddedClients.Remove(clientId); inbox.Remove(clientId); cache.Remove(clientId); latest.Remove(clientId); if (remotes.TryGetValue(clientId, out var value)) { value.Dispose(); remotes.Remove(clientId); } DropQueued((Outgoing o) => o.Target == clientId); NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && !singleton.IsServer && clientId == singleton.LocalClientId) { Unbind(); } } private static void DropQueued(Func drop) { if (outbox.Count == 0) { return; } int count = outbox.Count; for (int i = 0; i < count; i++) { Outgoing outgoing = outbox.Dequeue(); if (!drop(outgoing)) { outbox.Enqueue(outgoing); } } } public static void PublishLocal(Color32[] albedo, Color32[] mask, int srcSize) { if (!Enabled) { return; } if (compressing) { Plugin.Log.LogInfo((object)"[MC net] A publish is already packing; skipping this one."); return; } int num = ((Plugin.NetTextureSize != null) ? Plugin.NetTextureSize.Value : 512); byte[] planes = PaintCodec.ExtractPlanes(albedo, mask, srcSize, num); if (planes == null) { return; } ulong hash = PaintCodec.Hash(planes); if (hash == localHash && localBlob != null) { Plugin.Log.LogInfo((object)"[MC net] Paint unchanged since the last publish; nothing to send."); return; } int size = Mathf.Min(num, srcSize); compressing = true; Task.Run(delegate { try { compressed.Enqueue(new Packed { Blob = PaintCodec.Compress(planes, size), Hash = hash }); } catch (Exception ex) { Plugin.Log.LogError((object)("[MC net] Compression failed: " + ex.Message)); compressed.Enqueue(new Packed { Blob = null, Hash = 0uL }); } }); } private static void DrainCompressed() { Packed result; while (compressed.TryDequeue(out result)) { compressing = false; if (result.Blob != null && result.Blob.Length != 0) { if (result.Blob.Length > 4194304) { Plugin.Log.LogWarning((object)$"[MC net] Packed suit is {result.Blob.Length / 1024} KB, over the limit; not sending."); continue; } localBlob = result.Blob; localHash = result.Hash; blobDirty = true; Plugin.Log.LogInfo((object)$"[MC net] Paint packed to {(float)result.Blob.Length / 1024f:0.0} KB, queued for the lobby."); } } } private static bool BroadcastLocal(NetworkManager nm) { if (localBlob == null) { return true; } if (nm.IsServer) { cache[nm.LocalClientId] = localBlob; foreach (ulong moddedClient in moddedClients) { if (moddedClient != nm.LocalClientId) { Enqueue(moddedClient, nm.LocalClientId, localBlob); } } return true; } if (!saidHello || !nm.IsConnectedClient) { return false; } Enqueue(0uL, nm.LocalClientId, localBlob); return true; } private static void Enqueue(ulong target, ulong sender, byte[] blob) { if (blob == null) { return; } int num = (blob.Length + 8192 - 1) / 8192; if (num > 0 && num <= 514) { DropQueued((Outgoing o) => o.Target == target && o.Sender == sender); outbox.Enqueue(new Outgoing { Target = target, Sender = sender, BlobId = nextBlobId++, Blob = blob, NextChunk = 0, ChunkCount = num }); } } private static void PumpOutbox(NetworkManager nm) { float unscaledTime = Time.unscaledTime; float num = ((lastTick <= 0f) ? 0f : Mathf.Min(unscaledTime - lastTick, 0.5f)); lastTick = unscaledTime; int num2 = ((Plugin.NetUploadKBps != null) ? Plugin.NetUploadKBps.Value : 96); float num3 = (float)num2 * 1024f; budget = Mathf.Min(budget + num * num3, num3); while (outbox.Count > 0) { Outgoing outgoing = outbox.Peek(); int num4 = outgoing.NextChunk * 8192; int num5 = Mathf.Min(8192, outgoing.Blob.Length - num4); if (num5 <= 0) { outbox.Dequeue(); continue; } float num6 = num5 + 22; if (budget < num6) { break; } if (!SendChunk(nm, outgoing, num4, num5)) { outbox.Dequeue(); continue; } budget -= num6; if (++outgoing.NextChunk >= outgoing.ChunkCount) { outbox.Dequeue(); } } } private unsafe static bool SendChunk(NetworkManager nm, Outgoing o, int offset, int len) { //IL_001c: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_006a: 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_0085: 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_009b: 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_00c9: Unknown result type (might be due to invalid IL or missing references) try { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(22 + len + 8, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe(ref o.Sender, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref o.BlobId, default(ForPrimitives)); int num = o.Blob.Length; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num, default(ForPrimitives)); ushort num2 = (ushort)o.NextChunk; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num2, default(ForPrimitives)); num2 = (ushort)o.ChunkCount; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num2, default(ForPrimitives)); num2 = (ushort)len; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num2, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(o.Blob, len, offset); nm.CustomMessagingManager.SendNamedMessage("MC_Data", o.Target, val, (NetworkDelivery)4); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)$"[MC net] Dropping transfer to {o.Target}: {ex.Message}"); return false; } } private unsafe static void SendHello(NetworkManager nm, ulong target) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) try { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { byte b = 1; ((FastBufferWriter)(ref val)).WriteValueSafe(ref b, default(ForPrimitives)); nm.CustomMessagingManager.SendNamedMessage("MC_Hello", target, val, (NetworkDelivery)2); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)$"[MC net] Hello to {target} failed: {ex.Message}"); } } private static void OnHello(ulong sender, FastBufferReader reader) { //IL_0008: 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) try { byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe(ref b, default(ForPrimitives)); if (b != 1) { Plugin.Log.LogWarning((object)$"[MC net] Client {sender} runs protocol {b}, we run {(byte)1}; not syncing with them."); return; } NetworkManager net = Net; if ((Object)(object)net == (Object)null) { return; } moddedClients.Add(sender); if (net.IsServer) { SendHello(net, sender); int num = 0; foreach (KeyValuePair item in cache) { if (item.Key != sender) { Enqueue(sender, item.Key, item.Value); num++; } } Plugin.Log.LogInfo((object)$"[MC net] Client {sender} has the mod; sending {num} cached suit(s)."); } else if (localBlob != null) { blobDirty = true; } } catch (Exception ex) { Plugin.Log.LogWarning((object)$"[MC net] Malformed hello from {sender}: {ex.Message}"); } } private static void OnData(ulong sender, FastBufferReader reader) { //IL_001f: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_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_006f: 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_0083: 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) NetworkManager net = Net; if ((Object)(object)net == (Object)null) { return; } try { ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num, default(ForPrimitives)); uint num2 = default(uint); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num2, default(ForPrimitives)); int num3 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num3, default(ForPrimitives)); ushort num4 = default(ushort); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num4, default(ForPrimitives)); ushort num5 = default(ushort); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num5, default(ForPrimitives)); ushort num6 = default(ushort); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num6, default(ForPrimitives)); ulong num7 = (net.IsServer ? sender : num); if (num3 <= 0 || num3 > 4194304 || num5 <= 0 || num5 > 514 || num4 >= num5 || num6 <= 0 || num6 > 8192 || num4 * 8192 + num6 > num3) { return; } if (!inbox.TryGetValue(num7, out var value) || value.BlobId != num2 || value.Buffer.Length != num3) { Incoming incoming = new Incoming(); incoming.BlobId = num2; incoming.Buffer = new byte[num3]; incoming.Got = new bool[num5]; incoming.Received = 0; incoming.ChunkCount = num5; value = incoming; inbox[num7] = value; } if (!value.Got[num4]) { byte[] src = new byte[num6]; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref src, (int)num6, 0); Buffer.BlockCopy(src, 0, value.Buffer, num4 * 8192, num6); value.Got[num4] = true; if (++value.Received >= value.ChunkCount) { inbox.Remove(num7); OnBlobComplete(num7, value.Buffer); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)$"[MC net] Malformed chunk from {sender}: {ex.Message}"); } } private static void OnBlobComplete(ulong owner, byte[] blob) { Task.Run(delegate { try { if (!PaintCodec.Decompress(blob, out var planes, out var size)) { Plugin.Log.LogWarning((object)$"[MC net] Rejected an undecodable suit from {owner}."); } else { decoded.Enqueue(new Decoded { ClientId = owner, Planes = planes, Size = size, Blob = blob }); } } catch (Exception ex) { Plugin.Log.LogWarning((object)$"[MC net] Decode failed for {owner}: {ex.Message}"); } }); } private static void ApplyOneDecoded() { if (!decoded.TryDequeue(out var result)) { return; } NetworkManager net = Net; if ((Object)(object)net == (Object)null) { return; } if (net.IsServer) { cache[result.ClientId] = result.Blob; foreach (ulong moddedClient in moddedClients) { if (moddedClient != result.ClientId && moddedClient != net.LocalClientId) { Enqueue(moddedClient, result.ClientId, result.Blob); } } } if (result.ClientId != net.LocalClientId) { latest[result.ClientId] = result; TryApply(result.ClientId); } } private static void TryApply(ulong clientId) { if (!latest.TryGetValue(clientId, out var value)) { return; } PlayerControllerB val = FindPlayer(clientId); if ((Object)(object)val == (Object)null) { return; } if (!remotes.TryGetValue(clientId, out var value2)) { value2 = (remotes[clientId] = new RemotePaint(clientId)); } try { value2.Apply(val, value.Planes, value.Size); latest.Remove(clientId); Plugin.Log.LogInfo((object)$"[MC net] Applied {val.playerUsername}'s paint ({value.Size}px)."); } catch (Exception ex) { Plugin.Log.LogError((object)("[MC net] Failed to apply " + val.playerUsername + "'s paint: " + ex.Message)); } } private static void TickRemotes() { if (latest.Count > 0) { scratchIds.Clear(); scratchIds.AddRange(latest.Keys); for (int i = 0; i < scratchIds.Count; i++) { TryApply(scratchIds[i]); } } if (remotes.Count == 0) { return; } foreach (KeyValuePair remote in remotes) { PlayerControllerB val = FindPlayer(remote.Key); if (!((Object)(object)val == (Object)null)) { try { remote.Value.Tick(val); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[MC net] Remote upkeep failed: " + ex.Message)); } } } } private static PlayerControllerB FindPlayer(ulong clientId) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return null; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.actualClientId == clientId) { return (val.isPlayerControlled || val.isPlayerDead) ? val : null; } } return null; } } internal static class LethalConfigCompat { private const string LethalConfigGuid = "ainavt.lc.lethalconfig"; internal static void Initialize() { try { if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig")) { RegisterConfigs(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[LethalConfig] Could not register configs: " + ex.Message)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void RegisterConfigs() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem(Plugin.ToggleKey, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem(Plugin.PickKey, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem(Plugin.TPoseKey, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem(Plugin.FlatViewKey, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem(Plugin.PresetsKey, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(Plugin.TextureSize, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(Plugin.UndoSteps, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(Plugin.SeamPadding, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(Plugin.FlatViewLevel, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(Plugin.AutoSave, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(Plugin.OrbitSensitivity, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(Plugin.PanSensitivity, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(Plugin.InvertOrbitY, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(Plugin.FreezePose, false)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(Plugin.NetSync, false)); Plugin.Log.LogInfo((object)"[LethalConfig] Successfully registered in-game keybinds and settings with LethalConfig."); } } public static class MaterialProbe { private const int MaxCacheEntries = 32; private const int CacheSize = 512; private static readonly Dictionary readableCache = new Dictionary(); private static readonly Dictionary averageCache = new Dictionary(); private static readonly RaycastHit[] hitBuffer = (RaycastHit[])(object)new RaycastHit[24]; private static float lastLog; public static string LastResult; public static bool Sample(Ray ray, Transform ignoreRoot, out Color color, out float metallic, out float smoothness, out string what) { //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_001f: 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_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_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_0259: 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_0237: Unknown result type (might be due to invalid IL or missing references) //IL_026a: 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_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Invalid comparison between Unknown and I4 //IL_039f: 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_03a4: 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_0391: 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_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: 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_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0500: 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_051e: 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_0595: 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_05ad: 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_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_054a: 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_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0554: 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_069c: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Unknown result type (might be due to invalid IL or missing references) //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_0724: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07cf: Unknown result type (might be due to invalid IL or missing references) //IL_07f7: Unknown result type (might be due to invalid IL or missing references) color = Color.white; metallic = 0f; smoothness = 0.5f; what = null; int num = Physics.RaycastNonAlloc(ray, hitBuffer, 300f, -1, (QueryTriggerInteraction)1); if (num <= 0) { return false; } RaycastHit val = default(RaycastHit); Renderer val2 = null; float num2 = float.MaxValue; for (int i = 0; i < num; i++) { RaycastHit val3 = hitBuffer[i]; if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && !(((RaycastHit)(ref val3)).distance >= num2) && (!((Object)(object)ignoreRoot != (Object)null) || !((Component)((RaycastHit)(ref val3)).collider).transform.IsChildOf(ignoreRoot))) { Renderer val4 = ((Component)((RaycastHit)(ref val3)).collider).GetComponent() ?? ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() ?? ((Component)((RaycastHit)(ref val3)).collider).GetComponentInChildren(); if (!((Object)(object)val4 == (Object)null)) { num2 = ((RaycastHit)(ref val3)).distance; val = val3; val2 = val4; } } } if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogInfo((object)$"[MaterialProbe] Raycast hit {num} colliders, but no valid Renderer found."); return false; } what = ((Object)((Component)val2).gameObject).name; Plugin.Log.LogInfo((object)$"[MaterialProbe] Hit object='{what}' (layer={((Component)val2).gameObject.layer}) at distance={num2:0.00}m. Collider='{((object)((RaycastHit)(ref val)).collider).GetType().Name}'."); Vector2 val5 = ((RaycastHit)(ref val)).textureCoord; int num3 = 0; string text = "none"; Collider collider = ((RaycastHit)(ref val)).collider; MeshCollider val6 = (MeshCollider)(object)((collider is MeshCollider) ? collider : null); if (val6 != null && (Object)(object)val6.sharedMesh != (Object)null && val6.sharedMesh.isReadable && ((RaycastHit)(ref val)).triangleIndex >= 0) { num3 = GetSubmeshIndex(val6.sharedMesh, ((RaycastHit)(ref val)).triangleIndex); text = "collider"; Plugin.Log.LogInfo((object)$"[MaterialProbe] Resolved UV via MeshCollider: uv=({val5.x:0.000}, {val5.y:0.000}), submesh={num3}"); } else { if (!TryGetMeshUV(val2, ray, out var uv, out var submesh)) { Plugin.Log.LogInfo((object)("[MaterialProbe] Cannot resolve exact UV for '" + what + "' (mesh non-readable or box collider). Rejecting material probe to avoid averaging shared atlas.")); return false; } val5 = uv; num3 = submesh; text = "mesh"; Plugin.Log.LogInfo((object)$"[MaterialProbe] Resolved UV via MeshFilter ray-triangle intersection: uv=({val5.x:0.000}, {val5.y:0.000}), submesh={num3}"); } Material val7 = PickSubMaterial(val2, num3); if ((Object)(object)val7 == (Object)null) { Plugin.Log.LogWarning((object)$"[MaterialProbe] Submaterial {num3} is null on '{what}'"); return false; } Plugin.Log.LogInfo((object)("[MaterialProbe] Target material='" + ((Object)val7).name + "' shader='" + ((Object)val7.shader).name + "'")); bool flag = (int)QualitySettings.activeColorSpace == 1; Color val8 = (val7.HasProperty("_BaseColor") ? val7.GetColor("_BaseColor") : (val7.HasProperty("_Color") ? val7.GetColor("_Color") : Color.white)); if (val8.r < 0.001f && val8.g < 0.001f && val8.b < 0.001f) { val8 = Color.white; } Texture val9 = Get(val7, "_BaseColorMap") ?? Get(val7, "_MainTex") ?? Get(val7, "_BaseColorMap0") ?? Get(val7, "_BaseColorMap1") ?? Get(val7, "_LayerColorMap0") ?? Get(val7, "_Albedo") ?? Get(val7, "_AlbedoMap") ?? Get(val7, "_Diffuse"); Color result = Color.white; bool flag2 = false; if ((Object)(object)val9 != (Object)null) { Vector4 st = TilingOffset(val7, "_BaseColorMap", "_MainTex"); flag2 = TrySampleTexture(val9, val5, st, linear: false, out result); Plugin.Log.LogInfo((object)$"[MaterialProbe] Sampled texture '{((Object)val9).name}' ({val9.width}x{val9.height}) at UV=({val5.x:0.000}, {val5.y:0.000}) -> texel={Hex(result)} (RGBA: {result.r:0.00},{result.g:0.00},{result.b:0.00})"); if (flag2) { val8 *= (flag ? ((Color)(ref result)).linear : result); } } else { Plugin.Log.LogInfo((object)("[MaterialProbe] No albedo map found on '" + ((Object)val7).name + "'. Using tint=" + Hex(val8))); } if (flag) { val8 = ((Color)(ref val8)).gamma; } color = new Color(Mathf.Clamp01(val8.r), Mathf.Clamp01(val8.g), Mathf.Clamp01(val8.b), 1f); if (color.r + color.g + color.b < 0.02f && !flag2) { Plugin.Log.LogInfo((object)("[MaterialProbe] Sampled color is near-black (" + Hex(color) + ") without texture. Rejecting to allow screen pixel sampling.")); return false; } metallic = (val7.HasProperty("_Metallic") ? val7.GetFloat("_Metallic") : 0f); smoothness = (val7.HasProperty("_Smoothness") ? val7.GetFloat("_Smoothness") : (val7.HasProperty("_Glossiness") ? val7.GetFloat("_Glossiness") : 0.068f)); Texture val10 = Get(val7, "_MaskMap"); if ((Object)(object)val10 != (Object)null && TrySampleTexture(val10, val5, TilingOffset(val7, "_MaskMap", null), linear: true, out var result2)) { float num4 = GetFloat(val7, "_MetallicRemapMin", 0f); float num5 = GetFloat(val7, "_MetallicRemapMax", 1f); float num6 = GetFloat(val7, "_SmoothnessRemapMin", 0f); float num7 = GetFloat(val7, "_SmoothnessRemapMax", 1f); metallic = Mathf.Lerp(num4, num5, result2.r); smoothness = Mathf.Lerp(num6, num7, result2.a); Plugin.Log.LogInfo((object)$"[MaterialProbe] MaskMap sampled: metallic={metallic:0.00}, smoothness={smoothness:0.00}"); } metallic = Mathf.Clamp01(metallic); smoothness = Mathf.Clamp01(smoothness); LastResult = what + " uv=" + text + " map=" + (((Object)(object)val9 != (Object)null) ? ((Object)val9).name : "none") + " texel=" + (flag2 ? Hex(result) : "-") + " -> " + Hex(color); Plugin.Log.LogInfo((object)$"[MaterialProbe SUCCESS] Final Color={Hex(color)} (RGB: {color.r:0.00}, {color.g:0.00}, {color.b:0.00}), Metallic={metallic:0.00}, Smoothness={smoothness:0.00}"); return true; } private static string Hex(Color c) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) return "#" + ColorUtility.ToHtmlStringRGB(new Color(Mathf.Clamp01(c.r), Mathf.Clamp01(c.g), Mathf.Clamp01(c.b))); } private static bool TryAverageColor(Texture src, out Color average) { //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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Invalid comparison between Unknown and I4 //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00e0: 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_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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) average = Color.white; if ((Object)(object)src == (Object)null) { return false; } if (averageCache.TryGetValue(src, out average)) { return true; } Texture2D readable = GetReadable(src, linear: false); if ((Object)(object)readable == (Object)null) { return false; } Color32[] pixels = readable.GetPixels32(); if (pixels.Length == 0) { return false; } bool flag = (int)QualitySettings.activeColorSpace == 1; float num = 0f; float num2 = 0f; float num3 = 0f; int num4 = 0; int num5 = Mathf.Max(1, pixels.Length / 16384); for (int i = 0; i < pixels.Length; i += num5) { Color val = Color32.op_Implicit(pixels[i]); if (flag) { val = ((Color)(ref val)).linear; } num += val.r; num2 += val.g; num3 += val.b; num4++; } if (num4 == 0) { return false; } average = new Color(num / (float)num4, num2 / (float)num4, num3 / (float)num4, 1f); if (flag) { average = ((Color)(ref average)).gamma; } averageCache[src] = average; return true; } private static bool TryGetMeshUV(Renderer renderer, Ray worldRay, out Vector2 uv, out int submesh) { //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_018a: 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_0199: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: 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_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_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_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_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022a: 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_022e: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_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_0106: Expected O, but got Unknown //IL_02db: 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_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: 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_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: 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_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_0318: 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) uv = Vector2.zero; submesh = 0; Mesh val = null; Transform transform = ((Component)renderer).transform; if (renderer is MeshRenderer) { MeshFilter val2 = ((Component)renderer).GetComponent() ?? ((Component)renderer).GetComponentInParent() ?? ((Component)renderer).GetComponentInChildren(); if ((Object)(object)val2 != (Object)null) { val = val2.sharedMesh; transform = ((Component)val2).transform; } } else { SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); if (val3 != null) { val = val3.sharedMesh; transform = ((Component)val3).transform; } } if ((Object)(object)val == (Object)null) { return false; } Vector3[] array = null; int[] array2 = null; Vector2[] array3 = null; try { if (val.isReadable) { array = val.vertices; array2 = val.triangles; array3 = val.uv; } else { GameObject val4 = null; Mesh val5 = null; try { SkinnedMeshRenderer val6 = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); if ((Object)(object)val6 == (Object)null) { val4 = new GameObject("MC_ProbeExtractor") { hideFlags = (HideFlags)61 }; val6 = val4.AddComponent(); val6.sharedMesh = val; } val5 = new Mesh { hideFlags = (HideFlags)61 }; val6.BakeMesh(val5); array = val5.vertices; array3 = val5.uv; array2 = val5.triangles; } finally { if ((Object)(object)val5 != (Object)null) { Object.Destroy((Object)(object)val5); } if ((Object)(object)val4 != (Object)null) { Object.Destroy((Object)(object)val4); } } } } catch { } Vector3 orig = transform.InverseTransformPoint(((Ray)(ref worldRay)).origin); Vector3 val7 = transform.InverseTransformDirection(((Ray)(ref worldRay)).direction); Vector3 normalized = ((Vector3)(ref val7)).normalized; float num = float.MaxValue; int num2 = -1; float num3 = 0f; float num4 = 0f; for (int i = 0; i < array2.Length; i += 3) { int num5 = array2[i]; int num6 = array2[i + 1]; int num7 = array2[i + 2]; if (num5 < array.Length && num6 < array.Length && num7 < array.Length) { Vector3 v = array[num5]; Vector3 v2 = array[num6]; Vector3 v3 = array[num7]; if (RayTriangleIntersect(orig, normalized, v, v2, v3, out var t, out var u, out var v4) && t < num) { num = t; num2 = i; num3 = u; num4 = v4; } } } if (num2 < 0) { return false; } int num8 = array2[num2]; int num9 = array2[num2 + 1]; int num10 = array2[num2 + 2]; float num11 = 1f - num3 - num4; Vector2 val8 = ((num8 < array3.Length) ? array3[num8] : Vector2.zero); Vector2 val9 = ((num9 < array3.Length) ? array3[num9] : Vector2.zero); Vector2 val10 = ((num10 < array3.Length) ? array3[num10] : Vector2.zero); uv = num11 * val8 + num3 * val9 + num4 * val10; submesh = GetSubmeshIndex(val, num2 / 3); return true; } private static bool RayTriangleIntersect(Vector3 orig, Vector3 dir, Vector3 v0, Vector3 v1, Vector3 v2, out float t, out float u, out float v) { //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_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0032: 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_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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) t = 0f; u = 0f; v = 0f; Vector3 val = v1 - v0; Vector3 val2 = v2 - v0; Vector3 val3 = Vector3.Cross(dir, val2); float num = Vector3.Dot(val, val3); if (Mathf.Abs(num) < 1E-08f) { return false; } float num2 = 1f / num; Vector3 val4 = orig - v0; u = Vector3.Dot(val4, val3) * num2; if (u < -0.0001f || u > 1.0001f) { return false; } Vector3 val5 = Vector3.Cross(val4, val); v = Vector3.Dot(dir, val5) * num2; if (v < -0.0001f || u + v > 1.0001f) { return false; } t = Vector3.Dot(val2, val5) * num2; return t > 0.0001f; } private static int GetSubmeshIndex(Mesh mesh, int triangleIndex) { //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) if ((Object)(object)mesh == (Object)null || triangleIndex < 0) { return 0; } int num = triangleIndex * 3; for (int i = 0; i < mesh.subMeshCount; i++) { SubMeshDescriptor subMesh = mesh.GetSubMesh(i); if (num >= ((SubMeshDescriptor)(ref subMesh)).indexStart && num < ((SubMeshDescriptor)(ref subMesh)).indexStart + ((SubMeshDescriptor)(ref subMesh)).indexCount) { return i; } } return 0; } private static Vector2 GetBoxColliderUV(BoxCollider box, Vector3 worldPoint) { //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) //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_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_0020: 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_0043: 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_0071: 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: 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_00b8: 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_0141: 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_0118: 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_012b: 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_00e3: 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_00f6: 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_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) Vector3 val = ((Component)box).transform.InverseTransformPoint(worldPoint) - box.center; Vector3 size = box.size; float num = Mathf.Abs(val.x / Mathf.Max(0.0001f, size.x * 0.5f)); float num2 = Mathf.Abs(val.y / Mathf.Max(0.0001f, size.y * 0.5f)); float num3 = Mathf.Abs(val.z / Mathf.Max(0.0001f, size.z * 0.5f)); if (num >= num2 && num >= num3) { return new Vector2(val.z / size.z + 0.5f, val.y / size.y + 0.5f); } if (num2 >= num && num2 >= num3) { return new Vector2(val.x / size.x + 0.5f, val.z / size.z + 0.5f); } return new Vector2(val.x / size.x + 0.5f, val.y / size.y + 0.5f); } private static Material PickSubMaterial(Renderer r, int submeshIndex) { Material[] sharedMaterials = r.sharedMaterials; if (sharedMaterials == null || sharedMaterials.Length == 0) { return null; } if (submeshIndex >= 0 && submeshIndex < sharedMaterials.Length) { return sharedMaterials[submeshIndex]; } return sharedMaterials[0]; } private static Texture Get(Material m, string prop) { return m.HasProperty(prop) ? m.GetTexture(prop) : null; } private static float GetFloat(Material m, string prop, float fallback) { return m.HasProperty(prop) ? m.GetFloat(prop) : fallback; } private static Vector4 TilingOffset(Material m, string a, string b) { //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_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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) string text = ((a != null && m.HasProperty(a)) ? a : ((b != null && m.HasProperty(b)) ? b : null)); if (text == null) { return new Vector4(1f, 1f, 0f, 0f); } Vector2 textureScale = m.GetTextureScale(text); Vector2 textureOffset = m.GetTextureOffset(text); return new Vector4(textureScale.x, textureScale.y, textureOffset.x, textureOffset.y); } private static bool TrySampleTexture(Texture src, Vector2 uv, Vector4 st, bool linear, out Color result) { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_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) result = Color.white; Texture2D readable = GetReadable(src, linear); if ((Object)(object)readable == (Object)null) { return false; } result = readable.GetPixelBilinear(uv.x * st.x + st.z, uv.y * st.y + st.w); return true; } private static Texture2D GetReadable(Texture src, bool linear) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)src == (Object)null) { return null; } if (readableCache.TryGetValue(src, out var value) && (Object)(object)value != (Object)null) { return value; } int num = Mathf.Clamp(src.width, 4, 512); int num2 = Mathf.Clamp(src.height, 4, 512); RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)(linear ? 1 : 2)); RenderTexture active = RenderTexture.active; Texture2D val = null; try { Graphics.Blit(src, temporary); RenderTexture.active = temporary; val = new Texture2D(num, num2, (TextureFormat)4, false, linear); val.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0); val.Apply(false); ((Texture)val).wrapMode = (TextureWrapMode)0; } catch { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } val = null; } finally { RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); } if ((Object)(object)val == (Object)null) { return null; } if (readableCache.Count >= 32) { ClearCache(); } readableCache[src] = val; return val; } public static void ClearCache() { foreach (KeyValuePair item in readableCache) { if ((Object)(object)item.Value != (Object)null) { Object.Destroy((Object)(object)item.Value); } } readableCache.Clear(); averageCache.Clear(); } } public static class PaintCodec { public const byte Version = 1; public const int PlaneCount = 5; private const int HeaderBytes = 8; public const int MaxBlobBytes = 4194304; public static byte[] ExtractPlanes(Color32[] albedo, Color32[] mask, int srcSize, int dstSize) { //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_011c: 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_0125: 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_013d: 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_0155: Unknown result type (might be due to invalid IL or missing references) if (albedo == null || mask == null) { return null; } if (srcSize <= 0 || albedo.Length < srcSize * srcSize || mask.Length < srcSize * srcSize) { return null; } if (dstSize > srcSize) { dstSize = srcSize; } if (dstSize <= 0) { return null; } int num = dstSize * dstSize; byte[] array = new byte[num * 5]; int num2 = 0; int num3 = num; int num4 = num * 2; int num5 = num * 3; int num6 = num * 4; for (int i = 0; i < dstSize; i++) { int num7 = i * srcSize / dstSize; int num8 = (i + 1) * srcSize / dstSize; if (num8 <= num7) { num8 = num7 + 1; } for (int j = 0; j < dstSize; j++) { int num9 = j * srcSize / dstSize; int num10 = (j + 1) * srcSize / dstSize; if (num10 <= num9) { num10 = num9 + 1; } int num11 = 0; int num12 = 0; int num13 = 0; int num14 = 0; int num15 = 0; int num16 = 0; for (int k = num7; k < num8; k++) { int num17 = k * srcSize; for (int l = num9; l < num10; l++) { Color32 val = albedo[num17 + l]; Color32 val2 = mask[num17 + l]; num11 += val.r; num12 += val.g; num13 += val.b; num14 += val2.r; num15 += val2.a; num16++; } } if (num16 != 0) { int num18 = i * dstSize + j; array[num2 + num18] = (byte)(num11 / num16); array[num3 + num18] = (byte)(num12 / num16); array[num4 + num18] = (byte)(num13 / num16); array[num5 + num18] = (byte)(num14 / num16); array[num6 + num18] = (byte)(num15 / num16); } } } return array; } public static byte[] Compress(byte[] planes, int size) { if (planes == null || size <= 0) { return null; } using MemoryStream memoryStream = new MemoryStream(planes.Length / 8 + 8); memoryStream.WriteByte(1); memoryStream.WriteByte(0); memoryStream.WriteByte((byte)(size & 0xFF)); memoryStream.WriteByte((byte)((size >> 8) & 0xFF)); WriteInt(memoryStream, planes.Length); using (DeflateStream deflateStream = new DeflateStream(memoryStream, CompressionLevel.Optimal, leaveOpen: true)) { deflateStream.Write(planes, 0, planes.Length); } return memoryStream.ToArray(); } public static bool Decompress(byte[] blob, out byte[] planes, out int size) { planes = null; size = 0; if (blob == null || blob.Length <= 8) { return false; } if (blob[0] != 1) { return false; } size = blob[2] | (blob[3] << 8); int num = ReadInt(blob, 4); if (size <= 0 || size > 4096) { return false; } if (num != size * size * 5) { return false; } if (num > 4194304) { return false; } try { byte[] array = new byte[num]; using (MemoryStream stream = new MemoryStream(blob, 8, blob.Length - 8, writable: false)) { using DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress); int i; int num2; for (i = 0; i < num; i += num2) { num2 = deflateStream.Read(array, i, num - i); if (num2 <= 0) { break; } } if (i != num) { return false; } } planes = array; return true; } catch { return false; } } public static void ExpandInto(byte[] planes, int size, Color32[] albedo, Color32[] mask, Color32[] baseMask) { //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_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) int num = size * size; int num2 = 0; int num3 = num; int num4 = num * 2; int num5 = num * 3; int num6 = num * 4; bool flag = baseMask != null && baseMask.Length >= num; for (int i = 0; i < num; i++) { albedo[i] = new Color32(planes[num2 + i], planes[num3 + i], planes[num4 + i], byte.MaxValue); byte b = (flag ? baseMask[i].g : byte.MaxValue); byte b2 = (byte)(flag ? baseMask[i].b : 0); mask[i] = new Color32(planes[num5 + i], b, b2, planes[num6 + i]); } } public static ulong Hash(byte[] data) { if (data == null) { return 0uL; } ulong num = 14695981039346656037uL; for (int i = 0; i < data.Length; i++) { num ^= data[i]; num *= 1099511628211L; } return num; } private static void WriteInt(Stream s, int v) { s.WriteByte((byte)(v & 0xFF)); s.WriteByte((byte)((v >> 8) & 0xFF)); s.WriteByte((byte)((v >> 16) & 0xFF)); s.WriteByte((byte)((v >> 24) & 0xFF)); } private static int ReadInt(byte[] b, int o) { return b[o] | (b[o + 1] << 8) | (b[o + 2] << 16) | (b[o + 3] << 24); } } public class PaintUI { private struct Swatch { public Color Colour; public float Metallic; public float Smoothness; } private float openT; private const float OpenSeconds = 0.13f; private Rect presetBtn; private const float SaveButtonAspect = 0.9357798f; private Rect shelf; private Rect shelfHead; private Rect shelfFoot; private Rect gridArea; private Rect chooser; private Rect chooserHead; private Rect portraitRect; private Rect currentRect; private Rect applyRect; private Rect chooserClose; private float cellW; private float cellH; private const float CellGap = 12f; private const float Pad = 16f; private const float HeadH = 26f; private const float FootH = 30f; private const float CurrentH = 26f; private const float ApplyH = 52f; private const float LabelH = 22f; private const float ShelfChrome = 110f; private const float ChooserChrome = 170f; private readonly List cardSlots = new List(); private SuitPreset selected; private string wearing; private string armedId; private float armedUntil; private float scrollY; private float scrollMax; private bool naming; private string nameBuffer = ""; private float caretSince; private Vector2 lastMouse; private Vector2 drawerMouse; private Texture2D icCross; private Texture2D icBin; private Texture2D icBinOpen; private Texture2D icSaveBtn; private GUIStyle stHead; private GUIStyle stCell; private GUIStyle stFoot; private GUIStyle stApply; private GUIStyle stName; public float Hue = 0.92f; public float Sat = 1f; public float Val = 1f; public float Metallic = 1f; public float Smoothness = 0f; public float BrushRadius = 4f; public float Hardness = 0.6f; public float Flow = 0.9f; public bool PaintColor = true; public bool PaintMetallic = true; public bool PaintSmoothness = true; public bool ShadowsOn = true; public bool TPoseOn = false; public bool FlatViewOn = false; public float TransitionProgress = 1f; private static readonly Color PanelCol = new Color(0.04f, 0.04f, 0.04f, 0.38f); private static readonly Color LegendCol = new Color(0.04f, 0.04f, 0.04f, 0.38f); private static readonly Color FieldCol = new Color(0.02f, 0.02f, 0.02f, 0.5f); private static readonly Color TrackCol = new Color(0.03f, 0.03f, 0.03f, 0.6f); private static readonly Color Ink = new Color(0.96f, 0.96f, 0.96f, 1f); private static readonly Color InkDim = new Color(0.78f, 0.78f, 0.78f, 1f); private Color tint = Color.white; private float scale = 1.15f; private Rect panel; private Rect legend; private Rect wheelRect; private Rect svRect; private Rect satBar; private Rect valBar; private Rect swatchNew; private Rect swatchOld; private Rect fillBtn; private Rect cosmeticsBtn; private Rect hexDropdownRect; private Rect hexField; private Rect recentBar; private Rect recentClockBtn; private readonly Rect[] rgbBar = (Rect[])(object)new Rect[3]; private readonly Rect[] rgbNum = (Rect[])(object)new Rect[3]; private readonly Rect[] hsvBar = (Rect[])(object)new Rect[3]; private readonly Rect[] hsvNum = (Rect[])(object)new Rect[3]; private Rect metalField; private Rect roughField; private readonly Rect[] recentSwatch = (Rect[])(object)new Rect[8]; private readonly Rect[] legendRow = (Rect[])(object)new Rect[9]; private Rect tposeToggleRect; private Rect flatToggleRect; private Rect presetToggleRect; private float lockShakeTimer; private const float LockShakeDuration = 0.35f; private float wheelOuter; private float wheelInner; private Vector2 wheelCenter; private const int DragNone = 0; private const int DragHue = 1; private const int DragSV = 2; private const int DragSat = 3; private const int DragVal = 4; private const int DragRgb = 10; private const int DragHsv = 20; private const int DragMetal = 30; private const int DragRough = 31; private int drag = 0; private float scrubAnchor; private float scrubStart; private readonly List history = new List(); private string lastCommitted = ""; private Texture2D white; private Texture2D wheelTex; private Texture2D svTex; private Texture2D ringTex; private Texture2D checkerTex; private Texture2D barSatV; private Texture2D barValV; private Texture2D barHue; private Texture2D barSat; private Texture2D barVal; private readonly Texture2D[] barRgb = (Texture2D[])(object)new Texture2D[3]; private Texture2D icFill; private Texture2D icClock; private Texture2D icChevronDown; private Texture2D icEye; private Texture2D icLock; private float svTexHue = -1f; private Color barCacheColor = Color.clear; private Camera cursorCam; private bool cursorValid; private Vector3 cursorPoint; private Vector3 cursorNormal; private float cursorRadius; private Matrix4x4 cursorViewProjection = Matrix4x4.identity; private string status = ""; private float statusUntil; private Font gameFont; private GUIStyle stLabel; private GUIStyle stNum; private GUIStyle stSmall; private GUIStyle stKeyText; private GUIStyle stLegend; private GUIStyle stLegendDim; private GUIStyle stPlus; public bool PresetsOpen { get; private set; } public bool CapturingText => naming; private bool PresetsVisible => PresetsOpen || openT > 0.001f; private float DrawerSlide => (1f - openT) * 26f; public float Roughness { get { return 1f - Smoothness; } set { Smoothness = 1f - Mathf.Clamp01(value); } } public Color Tint => Color.HSVToRGB(Hue, Sat, Val); public BrushSettings Brush => new BrushSettings { Color = Tint, Metallic = Metallic, Smoothness = Smoothness, Radius = BrushRadius * 0.01f, Hardness = Hardness, Flow = Flow, PaintColor = PaintColor, PaintMetallic = PaintMetallic, PaintSmoothness = PaintSmoothness }; public bool CosmeticsOn { get; set; } = true; public bool HasMoreCompany { get; set; } = true; public void TogglePresets() { SetPresetsOpen(!PresetsOpen); } public void SetPresetsOpen(bool open) { if (open == PresetsOpen) { return; } PresetsOpen = open; if (open) { SuitPresets.Refresh(); scrollY = 0f; IList all = SuitPresets.All; if (selected == null || !all.Contains(selected)) { selected = ((all.Count > 0) ? all[0] : null); } } else { CancelNaming(); Disarm(); } } private void LayoutPresets() { //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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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) float num = (float)Screen.width / scale; float num2 = (float)Screen.height / scale; float num3 = 160.95413f; presetBtn = new Rect(num - 24f - num3, num2 * 0.5f - 86f, num3, 172f); float num4 = Mathf.Clamp(num2 - 60f, 300f, 860f); float num5 = ((Rect)(ref presetBtn)).x - 16f; float num6 = Mathf.Max(470f, num5 - (((Rect)(ref panel)).xMax + 16f)); float num7 = Mathf.Clamp(num6 * 0.4f, 250f, 390f); float num8 = Mathf.Clamp(num6 - num7 - 12f, 290f, 570f); cellW = (num8 - 32f - 24f) / 3f; cellH = cellW + 22f; int num9 = Mathf.Max(1, (SuitPresets.Count + 1 + 2) / 3); float num10 = (float)num9 * cellH + (float)(num9 - 1) * 12f; float num11 = Mathf.Clamp(num10 + 110f, 200f, num4); shelf = new Rect(num5 - num7 - 12f - num8, num2 * 0.5f - num11 * 0.5f, num8, num11); float num12 = (num7 - 32f) / 0.75f; float num13 = Mathf.Min(num4, num12 + 170f); chooser = new Rect(((Rect)(ref shelf)).xMax + 12f, num2 * 0.5f - num13 * 0.5f, num7, num13); LayoutShelf(); LayoutChooser(); LayoutCards(); } private void LayoutShelf() { //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_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_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) float num = ((Rect)(ref shelf)).x + 16f; float num2 = ((Rect)(ref shelf)).width - 32f; shelfHead = new Rect(num, ((Rect)(ref shelf)).y + 16f, num2, 26f); shelfFoot = new Rect(num, ((Rect)(ref shelf)).yMax - 16f - 30f, num2, 30f); float num3 = ((Rect)(ref shelfHead)).yMax + 12f; gridArea = new Rect(num, num3, num2, Mathf.Max(60f, ((Rect)(ref shelfFoot)).y - 10f - num3)); } private void LayoutChooser() { //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_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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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) float num = ((Rect)(ref chooser)).x + 16f; float num2 = ((Rect)(ref chooser)).width - 32f; chooserHead = new Rect(num, ((Rect)(ref chooser)).y + 16f, num2, 26f); chooserClose = new Rect(((Rect)(ref chooser)).xMax - 16f - 22f, ((Rect)(ref chooser)).y + 16f + 2f, 22f, 22f); applyRect = new Rect(num, ((Rect)(ref chooser)).yMax - 16f - 52f, num2, 52f); currentRect = new Rect(num, ((Rect)(ref applyRect)).y - 10f - 26f, num2, 26f); float num3 = ((Rect)(ref chooserHead)).yMax + 12f; portraitRect = new Rect(num, num3, num2, Mathf.Max(80f, ((Rect)(ref currentRect)).y - 12f - num3)); } private void LayoutCards() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) cardSlots.Clear(); int num = SuitPresets.All.Count + 1; for (int i = 0; i < num; i++) { int num2 = i % 3; int num3 = i / 3; cardSlots.Add(new Rect(((Rect)(ref gridArea)).x + (float)num2 * (cellW + 12f), ((Rect)(ref gridArea)).y + (float)num3 * (cellH + 12f) - scrollY, cellW, cellH)); } int num4 = (num + 2) / 3; float num5 = (float)num4 * cellH + (float)Mathf.Max(0, num4 - 1) * 12f; scrollMax = Mathf.Max(0f, num5 - ((Rect)(ref gridArea)).height); scrollY = Mathf.Clamp(scrollY, 0f, scrollMax); } private void StepPresetAnims(float dt) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) openT = Mathf.MoveTowards(openT, PresetsOpen ? 1f : 0f, dt / 0.13f); drawerMouse = new Vector2(lastMouse.x - DrawerSlide, lastMouse.y); if (armedUntil > 0f && Time.unscaledTime > armedUntil) { Disarm(); } PumpThumbnails(); } private void PumpThumbnails() { if (!PresetsVisible) { return; } int num = 2; IList all = SuitPresets.All; for (int i = 0; i < all.Count; i++) { if (num <= 0) { break; } if (all[i].ThumbPending) { all[i].LoadThumb(); num--; } } } private bool PresetButtonHit() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return ((Rect)(ref presetBtn)).Contains(lastMouse); } private bool PresetsCapture() { //IL_000f: 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) return PresetsOpen && (((Rect)(ref shelf)).Contains(drawerMouse) || ((Rect)(ref chooser)).Contains(drawerMouse)); } public bool TryScrollPresets(float delta) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!PresetsOpen || scrollMax <= 0f) { return false; } if (!((Rect)(ref gridArea)).Contains(drawerMouse)) { return false; } scrollY = Mathf.Clamp(scrollY - Mathf.Sign(delta) * (cellH + 12f), 0f, scrollMax); return true; } private void ClickPresets() { //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_000e: 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_004f: 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_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_00bb: 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) Vector2 val = drawerMouse; if (((Rect)(ref chooserClose)).Contains(val)) { SetPresetsOpen(open: false); AudioSystem.PlayClick(); return; } if (((Rect)(ref applyRect)).Contains(val)) { ApplySelected(); return; } if (((Rect)(ref shelfFoot)).Contains(val) && naming) { CommitNaming(); AudioSystem.PlayClick(); return; } if (!((Rect)(ref gridArea)).Contains(val)) { Disarm(); return; } IList all = SuitPresets.All; for (int i = 0; i < cardSlots.Count; i++) { Rect val2 = cardSlots[i]; if (!((Rect)(ref val2)).Contains(val)) { continue; } if (i >= all.Count) { Disarm(); if (naming) { CommitNaming(); } else { BeginNaming(); } AudioSystem.PlayClick(); return; } SuitPreset suitPreset = all[i]; val2 = TrashButton(cardSlots[i]); if (((Rect)(ref val2)).Contains(val)) { if (armedId == suitPreset.Id) { DeletePreset(suitPreset); return; } armedId = suitPreset.Id; armedUntil = Time.unscaledTime + 3f; Say("Click the bin again to delete '" + suitPreset.Name + "'"); AudioSystem.PlayClick(); } else { Disarm(); selected = suitPreset; AudioSystem.PlayClick(); } return; } Disarm(); } private void ApplySelected() { if (selected != null) { wearing = selected.Id; ChameleonManager.Instance?.RequestApplyPreset(selected); } } private void DeletePreset(SuitPreset p) { IList all = SuitPresets.All; int num = all.IndexOf(p); if (wearing == p.Id) { wearing = null; } Disarm(); SuitPresets.Delete(p); if (selected == p) { selected = ((all.Count > 0) ? all[Mathf.Clamp(num, 0, all.Count - 1)] : null); } Say("Deleted preset"); AudioSystem.PlaySuit(); } private void Disarm() { armedId = null; armedUntil = 0f; } private Rect TrashButton(Rect cell) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref cell)).x + 6f, ((Rect)(ref cell)).y + cellW - 32f, 26f, 26f); } public void Announce(string message) { Say(message); } public void ClearWearing() { wearing = null; } internal void OnPresetSaved(SuitPreset p) { if (p != null) { SetPresetsOpen(open: true); scrollY = 0f; selected = p; wearing = p.Id; } } private void BeginNaming() { naming = true; nameBuffer = SuitPresets.SuggestName(); caretSince = Time.unscaledTime; } private void CancelNaming() { naming = false; nameBuffer = ""; } private void CommitNaming() { string name = nameBuffer; naming = false; nameBuffer = ""; ChameleonManager.Instance?.RequestSavePreset(name); } public void TypeChar(char c) { if (naming && c >= ' ' && c != '\u007f' && nameBuffer.Length < 22) { nameBuffer += c; caretSince = Time.unscaledTime; AudioSystem.PlayClick(); } } public void TypeBackspace() { if (naming && nameBuffer.Length != 0) { nameBuffer = nameBuffer.Substring(0, nameBuffer.Length - 1); caretSince = Time.unscaledTime; AudioSystem.PlayClick(); } } public void TypeCommit() { if (naming) { CommitNaming(); AudioSystem.PlayClick(); } } public void TypeCancel() { if (naming) { CancelNaming(); AudioSystem.PlayClick(); } } private void DrawPresetButton() { //IL_0017: 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_0038: 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_0040: 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_00c4: 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_006d: 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_0080: Unknown result type (might be due to invalid IL or missing references) EnsurePresetStyles(); bool flag = PresetsOpen || ((Rect)(ref presetBtn)).Contains(lastMouse); if ((Object)(object)icSaveBtn == (Object)null) { Rounded(presetBtn, (Color)(flag ? new Color(0.16f, 0.16f, 0.16f, 0.85f) : FieldCol), 8f); Centred(presetBtn, "PRESETS", stCell, flag ? Ink : InkDim); return; } Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, flag ? 1f : 0.78f); GUI.DrawTexture(presetBtn, (Texture)(object)icSaveBtn, (ScaleMode)2, true); GUI.color = color; } private void DrawPresets() { //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_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_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_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_0085: 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_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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (PresetsVisible) { EnsurePresetStyles(); float num = Mathf.Clamp01(openT); if (!(num <= 0.004f)) { Matrix4x4 matrix = GUI.matrix; GUI.matrix = matrix * Matrix4x4.Translate(new Vector3(DrawerSlide, 0f, 0f)); Color val = tint; tint = new Color(1f, 1f, 1f, num); GUI.color = tint; DrawShelf(); DrawChooser(); tint = val; GUI.color = tint; GUI.matrix = matrix; } } } private void DrawShelf() { //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_001a: 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_0037: Unknown result type (might be due to invalid IL or missing references) Rounded(shelf, PanelCol, 12f); Label(shelfHead, "SAVED PRESETS", stHead, Ink); Rule(shelfHead); DrawCells(); DrawShelfFoot(); } private void DrawShelfFoot() { //IL_0050: 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_00a6: 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_0107: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_0130: 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_01d6: 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_0199: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (!naming) { int count = SuitPresets.Count; Label(shelfFoot, (count == 1) ? "1 PRESET" : (count + " PRESETS"), stFoot, InkDim); return; } Rounded(shelfFoot, new Color(0.17f, 0.17f, 0.17f, 0.88f), 5f); Label(new Rect(((Rect)(ref shelfFoot)).x + 10f, ((Rect)(ref shelfFoot)).y, 52f, ((Rect)(ref shelfFoot)).height), "NAME", stFoot, InkDim); Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref shelfFoot)).x + 62f, ((Rect)(ref shelfFoot)).y, ((Rect)(ref shelfFoot)).width - 62f - 120f, ((Rect)(ref shelfFoot)).height); Label(r, nameBuffer, stName, Ink); float x = stName.CalcSize(new GUIContent(nameBuffer)).x; if (Mathf.Repeat(Time.unscaledTime - caretSince, 1f) < 0.55f) { Fill(new Rect(((Rect)(ref r)).x + Mathf.Min(x, ((Rect)(ref r)).width) + 2f, ((Rect)(ref r)).y + 6f, 2f, ((Rect)(ref r)).height - 12f), Ink); } Label(new Rect(((Rect)(ref shelfFoot)).xMax - 114f, ((Rect)(ref shelfFoot)).y, 106f, ((Rect)(ref shelfFoot)).height), "ENTER TO SAVE", stFoot, InkDim); } private void DrawCells() { //IL_0008: 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_0157: 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_01aa: 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_00ec: 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) IList all = SuitPresets.All; GUI.BeginClip(gridArea); try { Rect cell = default(Rect); for (int i = 0; i < cardSlots.Count; i++) { Rect val = cardSlots[i]; if (!(((Rect)(ref val)).yMax < ((Rect)(ref gridArea)).y - 4f) && !(((Rect)(ref val)).y > ((Rect)(ref gridArea)).yMax + 4f)) { ((Rect)(ref cell))..ctor(((Rect)(ref val)).x - ((Rect)(ref gridArea)).x, ((Rect)(ref val)).y - ((Rect)(ref gridArea)).y, cellW, cellH); bool hot = ((Rect)(ref gridArea)).Contains(drawerMouse) && ((Rect)(ref val)).Contains(drawerMouse); if (i < all.Count) { DrawCell(cell, all[i], hot); } else { DrawNewCell(cell, hot); } } } } finally { GUI.EndClip(); } if (scrollY > 2f) { VFade(new Rect(((Rect)(ref gridArea)).x, ((Rect)(ref gridArea)).y, ((Rect)(ref gridArea)).width, 12f), topDown: true); } if (scrollY < scrollMax - 2f) { VFade(new Rect(((Rect)(ref gridArea)).x, ((Rect)(ref gridArea)).yMax - 12f, ((Rect)(ref gridArea)).width, 12f), topDown: false); } } private void DrawCell(Rect cell, SuitPreset p, bool hot) { //IL_0040: 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_0062: 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_00bb: 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_009f: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_01a0: 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_01b1: 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_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01da: 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) Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref cell)).x, ((Rect)(ref cell)).y, ((Rect)(ref cell)).width, cellW); bool flag = p == selected; bool flag2 = armedId == p.Id; Rounded(r, (Color)(flag ? new Color(0.2f, 0.2f, 0.2f, 0.75f) : (hot ? new Color(0.1f, 0.1f, 0.1f, 0.62f) : FieldCol)), 6f); if ((Object)(object)p.Thumb != (Object)null) { GUI.DrawTexture(Shrink(r, 3f), (Texture)(object)p.Thumb, (ScaleMode)2, true); } else { DrawPaletteField(Shrink(r, 3f), p, 1f); } if (flag) { Fill(new Rect(((Rect)(ref r)).x + 6f, ((Rect)(ref r)).yMax - 2f, ((Rect)(ref r)).width - 12f, 2f), Ink); } Centred(new Rect(((Rect)(ref cell)).x, ((Rect)(ref r)).yMax + 3f, ((Rect)(ref cell)).width, 18f), p.Name.ToUpperInvariant(), stCell, (flag || hot) ? Ink : InkDim); Rect r2 = TrashButton(cell); Rounded(r2, flag2 ? new Color(0.58f, 0.11f, 0.09f, 0.94f) : new Color(0.02f, 0.02f, 0.02f, 0.62f), 5f); Icon(Shrink(r2, 3f), flag2 ? icBinOpen : icBin, flag2 ? Color.white : (hot ? Ink : InkDim)); } private void DrawNewCell(Rect cell, bool hot) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0054: 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_00a7: 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_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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //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_0121: 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) Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref cell)).x, ((Rect)(ref cell)).y, ((Rect)(ref cell)).width, cellW); Color val = ((hot || naming) ? Ink : InkDim); Rounded(r, hot ? new Color(0.1f, 0.1f, 0.1f, 0.62f) : new Color(0.02f, 0.02f, 0.02f, 0.35f), 6f); float num = Mathf.Min(24f, ((Rect)(ref r)).width * 0.2f); float num2 = 2.5f; Vector2 center = ((Rect)(ref r)).center; Fill(new Rect(center.x - num, center.y - num2 * 0.5f, num * 2f, num2), val); Fill(new Rect(center.x - num2 * 0.5f, center.y - num, num2, num * 2f), val); Centred(new Rect(((Rect)(ref cell)).x, ((Rect)(ref r)).yMax + 3f, ((Rect)(ref cell)).width, 18f), "NEW PRESET", stCell, val); } private void DrawChooser() { //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_001a: 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_0037: 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_0056: 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_0062: 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_00db: 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_009b: 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_00b8: 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_0117: 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_0142: 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_0174: Unknown result type (might be due to invalid IL or missing references) Rounded(chooser, PanelCol, 12f); Label(chooserHead, "SKIN CHOOSER", stHead, Ink); Rule(chooserHead); Icon(chooserClose, icCross, ((Rect)(ref chooserClose)).Contains(drawerMouse) ? Ink : InkDim); Rounded(portraitRect, FieldCol, 8f); if (selected == null) { Centred(portraitRect, "NO SUITS SAVED", stCell, InkDim); Centred(currentRect, "PAINT ONE, THEN + NEW", stFoot, InkDim); } else { Rect val = Shrink(portraitRect, 8f); if ((Object)(object)selected.Thumb != (Object)null) { GUI.DrawTexture(val, (Texture)(object)selected.Thumb, (ScaleMode)2, true); } else { DrawPaletteField(val, selected, 1f); } bool flag = wearing == selected.Id; Centred(currentRect, (flag ? "CURRENT: " : "SELECTED: ") + selected.Name.ToUpperInvariant(), stFoot, flag ? Ink : InkDim); } DrawApply(); } private void DrawApply() { //IL_0032: 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_0065: 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_00a8: 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_00b2: Unknown result type (might be due to invalid IL or missing references) bool flag = selected != null; bool flag2 = flag && wearing == selected.Id; bool flag3 = flag && ((Rect)(ref applyRect)).Contains(drawerMouse); Rounded(applyRect, (Color)(flag3 ? new Color(0.22f, 0.22f, 0.22f, 0.88f) : FieldCol), 6f); Centred(applyRect, flag2 ? "APPLIED" : "APPLY", stApply, (Color)((!flag) ? new Color(0.5f, 0.5f, 0.5f, 0.6f) : (flag3 ? Color.white : Ink))); } private void DrawPaletteField(Rect r, SuitPreset p, float a) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) if (p.Palette != null && p.Palette.Length != 0) { float num = ((Rect)(ref r)).height / (float)p.Palette.Length; for (int i = 0; i < p.Palette.Length; i++) { Color val = p.Palette[i]; Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + (float)i * num, ((Rect)(ref r)).width, num + 1f), new Color(val.r, val.g, val.b, a)); } } } private void Rule(Rect head) { //IL_0021: 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) Fill(new Rect(((Rect)(ref head)).x, ((Rect)(ref head)).yMax + 5f, ((Rect)(ref head)).width, 1f), new Color(1f, 1f, 1f, 0.1f)); } private static Color Faded(Color c, float a) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return new Color(c.r, c.g, c.b, c.a * a); } private void Label(Rect r, string text, GUIStyle style, Color ink) { //IL_0007: 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) style.normal.textColor = ink; GUI.Label(r, text, style); } private void Centred(Rect r, string text, GUIStyle style, Color ink) { //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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) TextAnchor alignment = style.alignment; style.alignment = (TextAnchor)4; style.normal.textColor = ink; GUI.Label(r, text, style); style.alignment = alignment; } private void Icon(Rect r, Texture2D tex, Color col) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) Blit(r, tex, col); } private void Blit(Rect r, Texture2D tex, Color col) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //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) if (!((Object)(object)tex == (Object)null)) { Color color = GUI.color; GUI.color = Faded(col); GUI.DrawTexture(r, (Texture)(object)tex, (ScaleMode)0, true); GUI.color = color; } } private void VFade(Rect r, bool topDown) { //IL_0056: 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) for (int i = 0; i < 6; i++) { float num = (float)i / 5f; float num2 = (topDown ? (1f - num) : num) * 0.55f; Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + num * ((Rect)(ref r)).height, ((Rect)(ref r)).width, ((Rect)(ref r)).height / 6f + 1f), new Color(0.04f, 0.04f, 0.04f, num2)); } } private void EnsurePresetStyles() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_003c: Expected O, but got Unknown //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) //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_0066: Expected O, but got Unknown //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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00b2: Expected O, but got Unknown //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_00c7: 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_00dc: Expected O, but got Unknown if (stHead == null) { stHead = new GUIStyle(stLabel) { fontSize = 18, fontStyle = (FontStyle)1, wordWrap = false }; stCell = new GUIStyle(stLabel) { fontSize = 14, wordWrap = false, clipping = (TextClipping)1 }; stFoot = new GUIStyle(stLabel) { fontSize = 13, wordWrap = false }; stName = new GUIStyle(stLabel) { fontSize = 17, wordWrap = false, clipping = (TextClipping)1 }; stApply = new GUIStyle(stLabel) { fontSize = 22, fontStyle = (FontStyle)1, wordWrap = false }; } if ((Object)(object)gameFont != (Object)null && (Object)(object)stHead.font != (Object)(object)gameFont) { stHead.font = gameFont; stCell.font = gameFont; stFoot.font = gameFont; stName.font = gameFont; stApply.font = gameFont; } } private static Texture2D LoadEmbedded(string name, int maxSize = 0) { //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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown try { Assembly assembly = typeof(PaintUI).Assembly; using Stream stream = assembly.GetManifestResourceStream(name); if (stream == null) { Plugin.Log.LogWarning((object)("[Presets] Embedded art '" + name + "' is missing from the assembly.")); return null; } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { hideFlags = (HideFlags)61, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; if (ImageConversion.LoadImage(val, array)) { return (maxSize > 0) ? Downscale(val, maxSize) : val; } Object.Destroy((Object)(object)val); Plugin.Log.LogWarning((object)("[Presets] Embedded art '" + name + "' would not decode.")); return null; } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Presets] Loading embedded art '" + name + "' failed: " + ex.Message)); return null; } } private static Texture2D Downscale(Texture2D src, int maxSize) { //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_00fd: 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_011f: 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_0203: 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_0208: Unknown result type (might be due to invalid IL or missing references) int width = ((Texture)src).width; int height = ((Texture)src).height; if (width <= maxSize && height <= maxSize) { return src; } float num = Mathf.Min((float)maxSize / (float)width, (float)maxSize / (float)height); int num2 = Mathf.Max(1, Mathf.RoundToInt((float)width * num)); int num3 = Mathf.Max(1, Mathf.RoundToInt((float)height * num)); Color32[] pixels = src.GetPixels32(); Color32[] array = (Color32[])(object)new Color32[num2 * num3]; for (int i = 0; i < num3; i++) { int num4 = i * height / num3; int num5 = Mathf.Max(num4 + 1, (i + 1) * height / num3); for (int j = 0; j < num2; j++) { int num6 = j * width / num2; int num7 = Mathf.Max(num6 + 1, (j + 1) * width / num2); float num8 = 0f; float num9 = 0f; float num10 = 0f; float num11 = 0f; int num12 = 0; for (int k = num4; k < num5; k++) { int num13 = k * width; for (int l = num6; l < num7; l++) { Color32 val = pixels[num13 + l]; float num14 = (float)(int)val.a / 255f; num8 += (float)(int)val.r * num14; num9 += (float)(int)val.g * num14; num10 += (float)(int)val.b * num14; num11 += num14; num12++; } } if (num12 != 0) { float num15 = num11 / (float)num12; array[i * num2 + j] = ((num15 <= 0.0001f) ? new Color32((byte)0, (byte)0, (byte)0, (byte)0) : new Color32((byte)Mathf.Clamp(Mathf.RoundToInt(num8 / num11), 0, 255), (byte)Mathf.Clamp(Mathf.RoundToInt(num9 / num11), 0, 255), (byte)Mathf.Clamp(Mathf.RoundToInt(num10 / num11), 0, 255), (byte)Mathf.Clamp(Mathf.RoundToInt(num15 * 255f), 0, 255))); } } } Texture2D val2 = New(num2, num3); val2.SetPixels32(array); val2.Apply(false); Object.Destroy((Object)(object)src); return val2; } private static bool InRect(float u, float v, float x0, float x1, float y0, float y1) { return u > x0 && u < x1 && v > y0 && v < y1; } private static bool Frame(float u, float v, float x0, float x1, float y0, float y1, float w) { return InRect(u, v, x0, x1, y0, y1) && !InRect(u, v, x0 + w, x1 - w, y0 + w, y1 - w); } private static Texture2D MakeCross(int size) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) Texture2D val = New(size, size); Color32[] array = (Color32[])(object)new Color32[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num = ((float)j + 0.5f) / (float)size * 2f - 1f; float num2 = ((float)i + 0.5f) / (float)size * 2f - 1f; float num3 = Mathf.Min(Mathf.Abs(num - num2), Mathf.Abs(num + num2)) * 0.7071f; float num4 = Mathf.Max(Mathf.Abs(num), Mathf.Abs(num2)); float num5 = ((num4 > 0.72f) ? 0f : Mathf.Clamp01((0.09f - num3) * (float)size * 0.5f)); array[i * size + j] = Color32.op_Implicit(new Color(1f, 1f, 1f, num5)); } } val.SetPixels32(array); val.Apply(false); return val; } private void DisposePresets() { if ((Object)(object)icCross != (Object)null) { Object.Destroy((Object)(object)icCross); } if ((Object)(object)icBin != (Object)null) { Object.Destroy((Object)(object)icBin); } if ((Object)(object)icBinOpen != (Object)null) { Object.Destroy((Object)(object)icBinOpen); } if ((Object)(object)icSaveBtn != (Object)null) { Object.Destroy((Object)(object)icSaveBtn); } icCross = (icBin = (icBinOpen = (icSaveBtn = null))); SuitPresets.DropThumbnails(); } public void SetCursor(Camera cam, bool valid, Vector3 point, Vector3 normal, float worldRadius) { //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_0017: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) cursorCam = cam; cursorValid = valid; cursorPoint = point; cursorNormal = normal; cursorRadius = worldRadius; if ((Object)(object)cam != (Object)null) { cursorViewProjection = cam.projectionMatrix * CameraMath.ViewMatrix(cam); } } public bool HandleInput(Vector2 mouse, bool down, bool held, bool up) { //IL_0008: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_033e: 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_0144: 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_01c4: 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_0184: 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_0224: Unknown result type (might be due to invalid IL or missing references) //IL_01da: 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_0323: Unknown result type (might be due to invalid IL or missing references) //IL_028c: 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_02cb: 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) Layout(); Vector2 val = mouse / scale; if (up || !held) { drag = 0; } lastMouse = val; StepPresetAnims(Time.unscaledDeltaTime); if (lockShakeTimer > 0f) { lockShakeTimer = Mathf.Max(0f, lockShakeTimer - Time.unscaledDeltaTime); } if (drag == 0 && PresetButtonHit()) { if (down) { TogglePresets(); AudioSystem.PlayClick(); } return true; } if (drag == 0 && PresetsCapture()) { if (down) { ClickPresets(); } return true; } bool flag = ((Rect)(ref panel)).Contains(val) || ((Rect)(ref legend)).Contains(val) || naming; if (down && flag) { if (((Rect)(ref svRect)).Contains(val)) { drag = 2; } else if (((Rect)(ref satBar)).Contains(val)) { drag = 3; } else if (((Rect)(ref valBar)).Contains(val)) { drag = 4; } else if (((Rect)(ref metalField)).Contains(val)) { drag = 30; scrubAnchor = val.x; Metallic = Mathf.Clamp01((val.x - ((Rect)(ref metalField)).x) / ((Rect)(ref metalField)).width); scrubStart = Metallic; } else if (((Rect)(ref roughField)).Contains(val)) { drag = 31; scrubAnchor = val.x; Roughness = Mathf.Clamp01((val.x - ((Rect)(ref roughField)).x) / ((Rect)(ref roughField)).width); scrubStart = Roughness; } else { float num = Vector2.Distance(val, wheelCenter); if (num <= wheelOuter + 4f && num >= wheelInner - 4f) { drag = 1; } if (drag == 0) { for (int i = 0; i < 3; i++) { if (((Rect)(ref rgbBar[i])).Contains(val) || ((Rect)(ref rgbNum[i])).Contains(val)) { drag = 10 + i; break; } if (((Rect)(ref hsvBar[i])).Contains(val) || ((Rect)(ref hsvNum[i])).Contains(val)) { drag = 20 + i; break; } } } if (drag == 0) { ClickButtons(val); } } } if (drag != 0 && held) { ApplyDrag(val); } return flag || drag != 0; } private void ClickButtons(Vector2 m) { //IL_0018: 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_00a9: 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_0120: 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_01d4: Unknown result type (might be due to invalid IL or missing references) ChameleonManager instance = ChameleonManager.Instance; for (int i = 0; i < history.Count && i < recentSwatch.Length; i++) { if (((Rect)(ref recentSwatch[i])).Contains(m)) { ApplySwatch(history[i]); AudioSystem.PlayClick(); return; } } if (((Rect)(ref fillBtn)).Contains(m) && (Object)(object)instance != (Object)null) { instance.RequestFill(); Say("Filled model with active pigment"); AudioSystem.PlaySuit(); } else if (((Rect)(ref swatchOld)).Contains(m) && history.Count > 0) { ApplySwatch(history[0]); AudioSystem.PlayClick(); } else if (((Rect)(ref tposeToggleRect)).Contains(m)) { instance?.SetTPose(!TPoseOn); AudioSystem.PlayClick(); } else if (((Rect)(ref flatToggleRect)).Contains(m)) { instance?.SetFlatView(!FlatViewOn); AudioSystem.PlayClick(); } else if (((Rect)(ref cosmeticsBtn)).Contains(m) && (Object)(object)instance != (Object)null) { if (!HasMoreCompany) { lockShakeTimer = 0.35f; Say("MoreCompany not installed (Accessories unavailable)"); AudioSystem.PlayError(); } else { instance.SetCosmeticsVisible(!CosmeticsOn); Say(CosmeticsOn ? "MoreCompany accessories shown" : "MoreCompany accessories hidden"); AudioSystem.PlayClick(); } } else if (((Rect)(ref presetToggleRect)).Contains(m)) { TogglePresets(); AudioSystem.PlayClick(); } } private void ApplyDrag(Vector2 m) { //IL_003b: 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_0090: 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_00f2: 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_015b: 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_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) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) switch (drag) { case 1: { float num = m.x - wheelCenter.x; float num2 = wheelCenter.y - m.y; Hue = Mathf.Repeat(Mathf.Atan2(num2, num) * 57.29578f - 90f, 360f) / 360f; return; } case 2: Sat = Mathf.Clamp01((m.x - ((Rect)(ref svRect)).x) / ((Rect)(ref svRect)).width); Val = Mathf.Clamp01(1f - (m.y - ((Rect)(ref svRect)).y) / ((Rect)(ref svRect)).height); return; case 3: Sat = Mathf.Clamp01(1f - (m.y - ((Rect)(ref satBar)).y) / ((Rect)(ref satBar)).height); return; case 4: Val = Mathf.Clamp01(1f - (m.y - ((Rect)(ref valBar)).y) / ((Rect)(ref valBar)).height); return; case 30: Metallic = Mathf.Clamp01(scrubStart + (m.x - scrubAnchor) / ((Rect)(ref metalField)).width); return; case 31: Roughness = Mathf.Clamp01(scrubStart + (m.x - scrubAnchor) / ((Rect)(ref roughField)).width); return; } if (drag >= 10 && drag < 13) { int num3 = drag - 10; Color c = Tint; float num4 = Mathf.Clamp01((m.x - ((Rect)(ref rgbBar[num3])).x) / ((Rect)(ref rgbBar[num3])).width); switch (num3) { case 0: c.r = num4; break; case 1: c.g = num4; break; default: c.b = num4; break; } Adopt(c, remember: false); } else if (drag >= 20 && drag < 23) { int num5 = drag - 20; float num6 = Mathf.Clamp01((m.x - ((Rect)(ref hsvBar[num5])).x) / ((Rect)(ref hsvBar[num5])).width); switch (num5) { case 0: Hue = num6; break; case 1: Sat = num6; break; default: Val = num6; break; } } } private void Adopt(Color c, bool remember) { //IL_0001: 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) float hue = default(float); float sat = default(float); float val = default(float); Color.RGBToHSV(c, ref hue, ref sat, ref val); Hue = hue; Sat = sat; Val = val; if (remember) { Remember(c); } } public void Remember(Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Remember(c, Metallic, Smoothness); } public void Remember(Color c, float metallic, float smoothness) { //IL_0001: 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_00cd: 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) string text = ToHex(c) + metallic.ToString("0.00") + smoothness.ToString("0.00"); if (text == lastCommitted) { return; } lastCommitted = text; for (int num = history.Count - 1; num >= 0; num--) { Swatch swatch = history[num]; if (ToHex(swatch.Colour) + swatch.Metallic.ToString("0.00") + swatch.Smoothness.ToString("0.00") == text) { history.RemoveAt(num); } } history.Insert(0, new Swatch { Colour = c, Metallic = metallic, Smoothness = smoothness }); while (history.Count > recentSwatch.Length) { history.RemoveAt(history.Count - 1); } } private void ApplySwatch(Swatch s) { //IL_0003: 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) Adopt(s.Colour, remember: false); Metallic = Mathf.Clamp01(s.Metallic); Smoothness = Mathf.Clamp01(s.Smoothness); Say($"{ToHex(s.Colour)} metallic {s.Metallic:0.00} roughness {1f - s.Smoothness:0.00}"); } public void AdoptSample(Color c, float metallic, float smoothness, string what, bool remember = false) { //IL_0002: 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_006d: 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_0084: 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) Adopt(c, remember); Metallic = Mathf.Clamp01(metallic); Smoothness = Mathf.Clamp01(smoothness); Say("Picked " + ToHex(c) + " (" + what + ")"); Plugin.Log.LogInfo((object)$"[PaintUI AdoptSample] Color={ToHex(c)} (RGB: {c.r:0.00},{c.g:0.00},{c.b:0.00}), Met={Metallic:0.00}, Smooth={Smoothness:0.00}, Source='{what}'"); } private void Say(string msg) { status = msg; statusUntil = Time.unscaledTime + 3f; } private static string ToHex(Color c) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) return "#" + ColorUtility.ToHtmlStringRGB(new Color(Mathf.Clamp01(c.r), Mathf.Clamp01(c.g), Mathf.Clamp01(c.b))); } private void Layout() { //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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_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_01a3: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: 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_0213: 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_0243: 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_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: 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_0304: 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_033d: 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_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_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_03d0: 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_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_042a: 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_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0531: 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_0570: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) float num = 176f; float num2 = 16f + num + 18f + 88f + 30f + 36f + 28f + 22f + 16f; float num3 = 26f; float num4 = 5f; float num5 = 12f + ((float)legendRow.Length * num3 + (float)(legendRow.Length - 1) * num4) + 12f; float num6 = num2 + 14f + num5; float num7 = (float)Screen.height - 60f; scale = ((num6 > num7) ? Mathf.Max(0.4f, num7 / num6) : 1f); float num8 = (float)Screen.height / scale; float num9 = Mathf.Max(24f, (num8 - num6) * 0.5f); float num10 = 24f; float num11 = num10 + 16f; float num12 = num10 + 440f - 16f; float num13 = num9 + 16f; wheelRect = new Rect(num11, num13, num, num); wheelCenter = ((Rect)(ref wheelRect)).center; wheelOuter = ((Rect)(ref wheelRect)).width * 0.5f; wheelInner = wheelOuter * 0.68f; float num14 = wheelInner * 1.4f; svRect = new Rect(wheelCenter.x - num14 * 0.5f, wheelCenter.y - num14 * 0.5f, num14, num14); satBar = new Rect(((Rect)(ref wheelRect)).xMax + 12f, num13, 22f, num); valBar = new Rect(((Rect)(ref satBar)).xMax + 10f, num13, 22f, num); float num15 = ((Rect)(ref valBar)).xMax + 14f; float num16 = num12 - num15; swatchNew = new Rect(num15, num13, num16, 32f); swatchOld = new Rect(num15, num13 + 36f, num16, 32f); float num17 = 8f; float num18 = (num16 - num17) * 0.5f; cosmeticsBtn = new Rect(num15, num13 + 78f, num18, 46f); fillBtn = new Rect(num15 + num18 + num17, num13 + 78f, num18, 46f); num13 += num + 18f; float num19 = 18f; float num20 = (num12 - num11 - num19) * 0.5f; for (int i = 0; i < 3; i++) { float num21 = num13 + (float)i * 26f; rgbBar[i] = new Rect(num11 + 24f, num21, num20 - 24f - 46f, 20f); rgbNum[i] = new Rect(((Rect)(ref rgbBar[i])).xMax + 6f, num21, 40f, 20f); float num22 = num11 + num20 + num19; hsvBar[i] = new Rect(num22 + 24f, num21, num20 - 24f - 46f, 20f); hsvNum[i] = new Rect(((Rect)(ref hsvBar[i])).xMax + 6f, num21, 40f, 20f); } num13 += 88f; hexDropdownRect = new Rect(num12 - 220f, num13, 95f, 22f); hexField = new Rect(num12 - 120f, num13, 120f, 22f); num13 += 30f; recentBar = new Rect(num11, num13, num12 - num11, 28f); recentClockBtn = new Rect(((Rect)(ref recentBar)).x + 4f, ((Rect)(ref recentBar)).y + 3f, 32f, 22f); float num23 = (((Rect)(ref recentBar)).width - 44f - 42f) / 8f; for (int j = 0; j < recentSwatch.Length; j++) { recentSwatch[j] = new Rect(((Rect)(ref recentClockBtn)).xMax + 6f + (float)j * (num23 + 6f), ((Rect)(ref recentBar)).y + 3f, num23, 22f); } num13 += 36f; float num24 = 95f; metalField = new Rect(num11 + num24, num13, num12 - num11 - num24, 22f); num13 += 28f; roughField = new Rect(num11 + num24, num13, num12 - num11 - num24, 22f); num13 += 38f; panel = new Rect(num10, num9, 440f, num13 - num9); float num25 = ((Rect)(ref panel)).yMax + 14f; float num26 = num25 + 12f; for (int k = 0; k < legendRow.Length; k++) { legendRow[k] = new Rect(num11, num26, num12 - num11, num3); num26 += num3 + num4; } legend = new Rect(num10, num25, 440f, num26 - num25 + 6f); LayoutPresets(); } public void Draw(ChameleonManager mgr, PaintTarget target) { //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_007e: 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_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_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) EnsureTextures(); EnsureStyles(); Layout(); DrawBrushCursor(); Matrix4x4 matrix = GUI.matrix; if (scale != 1f) { GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(scale, scale, 1f)); } DrawColourPanel(); DrawLegend(); DrawPresets(); DrawPresetButton(); GUI.color = Color.white; GUI.matrix = matrix; } private void DrawColourPanel() { //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_0019: 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_0096: 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_00fe: 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_0116: 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_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_0176: 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_017b: 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_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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_026a: 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_039f: 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_0379: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: 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_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0538: 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_0304: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0413: 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_055c: Unknown result type (might be due to invalid IL or missing references) //IL_0541: 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_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04de: 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_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0432: 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_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0572: 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_05a2: 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_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_069f: 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_06e0: Unknown result type (might be due to invalid IL or missing references) //IL_0745: 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) //IL_0801: Unknown result type (might be due to invalid IL or missing references) //IL_0843: Unknown result type (might be due to invalid IL or missing references) //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_086d: Unknown result type (might be due to invalid IL or missing references) //IL_08bd: Unknown result type (might be due to invalid IL or missing references) //IL_079c: Unknown result type (might be due to invalid IL or missing references) //IL_09ba: 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_0a15: Unknown result type (might be due to invalid IL or missing references) //IL_0a2d: Unknown result type (might be due to invalid IL or missing references) //IL_0927: Unknown result type (might be due to invalid IL or missing references) //IL_0940: Unknown result type (might be due to invalid IL or missing references) //IL_0958: Unknown result type (might be due to invalid IL or missing references) //IL_08f8: Unknown result type (might be due to invalid IL or missing references) //IL_090a: Unknown result type (might be due to invalid IL or missing references) //IL_0a89: Unknown result type (might be due to invalid IL or missing references) Rounded(panel, PanelCol, 12f); GUI.DrawTexture(wheelRect, (Texture)(object)wheelTex, (ScaleMode)0, true); GUI.DrawTexture(svRect, (Texture)(object)svTex, (ScaleMode)0, false); float num = (Hue * 360f + 90f) * (MathF.PI / 180f); float num2 = (wheelOuter + wheelInner) * 0.5f; Handle(new Vector2(wheelCenter.x + Mathf.Cos(num) * num2, wheelCenter.y - Mathf.Sin(num) * num2), 10f, Color.HSVToRGB(Hue, 1f, 1f)); Handle(new Vector2(((Rect)(ref svRect)).x + Sat * ((Rect)(ref svRect)).width, ((Rect)(ref svRect)).y + (1f - Val) * ((Rect)(ref svRect)).height), 7.5f, Tint); VerticalStrip(satBar, barSatV, 1f - Sat); VerticalStrip(valBar, barValV, 1f - Val); Color val = Tint; Color fill = ((history.Count > 0) ? history[0].Colour : val); Rounded(swatchNew, val, 4f); Rounded(swatchOld, fill, 4f); bool flag = ((Rect)(ref cosmeticsBtn)).Contains(lastMouse); float num3 = 0f; if (lockShakeTimer > 0f) { float num4 = 1f - lockShakeTimer / 0.35f; num3 = Mathf.Sin(num4 * MathF.PI * 8f) * 5f * (1f - num4); } Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref cosmeticsBtn)).x + num3, ((Rect)(ref cosmeticsBtn)).y, ((Rect)(ref cosmeticsBtn)).width, ((Rect)(ref cosmeticsBtn)).height); if (!HasMoreCompany) { Color fill2 = (flag ? new Color(0.18f, 0.12f, 0.12f, 0.85f) : new Color(0.08f, 0.08f, 0.08f, 0.6f)); Rounded(r, fill2, 5f); if ((Object)(object)icLock != (Object)null) { GUI.color = (flag ? new Color(0.95f, 0.75f, 0.75f, 0.9f) : new Color(0.65f, 0.6f, 0.6f, 0.5f)); GUI.DrawTexture(new Rect(((Rect)(ref r)).center.x - 13f, ((Rect)(ref r)).center.y - 13f, 26f, 26f), (Texture)(object)icLock, (ScaleMode)2, true); GUI.color = tint; } if (flag) { Say("MoreCompany not installed (Accessories unavailable)"); } } else { Color fill3 = (Color)((!CosmeticsOn) ? (flag ? new Color(0.25f, 0.14f, 0.14f, 0.9f) : new Color(0.08f, 0.08f, 0.08f, 0.7f)) : (flag ? new Color(0.18f, 0.25f, 0.18f, 0.9f) : FieldCol)); Rounded(r, fill3, 5f); if ((Object)(object)icEye != (Object)null) { if (CosmeticsOn) { GUI.color = (Color)(flag ? new Color(0.4f, 1f, 0.6f, 1f) : Color.white); GUI.DrawTexture(new Rect(((Rect)(ref r)).center.x - 15f, ((Rect)(ref r)).center.y - 15f, 30f, 30f), (Texture)(object)icEye, (ScaleMode)2, true); GUI.color = tint; } else { GUI.color = (flag ? new Color(0.6f, 0.6f, 0.6f, 0.5f) : new Color(0.4f, 0.4f, 0.4f, 0.35f)); GUI.DrawTexture(new Rect(((Rect)(ref r)).center.x - 15f, ((Rect)(ref r)).center.y - 15f, 30f, 30f), (Texture)(object)icEye, (ScaleMode)2, true); GUI.color = tint; } } if (flag) { Say(CosmeticsOn ? "Accessories: Shown (Click to hide)" : "Accessories: Hidden (Click to show)"); } } bool flag2 = ((Rect)(ref fillBtn)).Contains(lastMouse); Rounded(fillBtn, (Color)(flag2 ? new Color(0.16f, 0.16f, 0.16f, 0.8f) : FieldCol), 5f); GUI.DrawTexture(new Rect(((Rect)(ref fillBtn)).center.x - 16f, ((Rect)(ref fillBtn)).center.y - 16f, 32f, 32f), (Texture)(object)icFill, (ScaleMode)2, true); if (flag2) { Say("Fill Suit: Flood model with active pigment"); } string[] array = new string[3] { "R", "G", "B" }; float[] array2 = new float[3] { val.r, val.g, val.b }; string[] array3 = new string[3] { "H", "S", "V" }; float[] array4 = new float[3] { Hue, Sat, Val }; for (int i = 0; i < 3; i++) { GUI.Label(new Rect(((Rect)(ref rgbBar[i])).x - 22f, ((Rect)(ref rgbBar[i])).y - 1f, 22f, ((Rect)(ref rgbBar[i])).height), array[i], stLabel); RampBar(rgbBar[i], barRgb[i], array2[i]); Field(rgbNum[i], array2[i].ToString("0.0")); GUI.Label(new Rect(((Rect)(ref hsvBar[i])).x - 22f, ((Rect)(ref hsvBar[i])).y - 1f, 22f, ((Rect)(ref hsvBar[i])).height), array3[i], stLabel); RampBar(hsvBar[i], (Texture2D)(i switch { 1 => barSat, 0 => barHue, _ => barVal, }), array4[i]); Field(hsvNum[i], array4[i].ToString("0.0")); } GUI.Label(new Rect(((Rect)(ref hexDropdownRect)).x, ((Rect)(ref hexDropdownRect)).y, ((Rect)(ref hexDropdownRect)).width - 16f, ((Rect)(ref hexDropdownRect)).height), "Hex sRGB", stSmall); GUI.DrawTexture(new Rect(((Rect)(ref hexDropdownRect)).xMax - 14f, ((Rect)(ref hexDropdownRect)).y + 6f, 12f, 12f), (Texture)(object)icChevronDown, (ScaleMode)0, true); Rounded(hexField, FieldCol, 4f); string text = ColorUtility.ToHtmlStringRGB(val) + "FF"; GUI.Label(new Rect(((Rect)(ref hexField)).x + 8f, ((Rect)(ref hexField)).y - 1f, ((Rect)(ref hexField)).width - 12f, ((Rect)(ref hexField)).height), text, stNum); for (int j = 0; j < recentSwatch.Length; j++) { if (j < history.Count) { Rounded(recentSwatch[j], history[j].Colour, 3f); continue; } Rounded(recentSwatch[j], new Color(0.12f, 0.12f, 0.12f, 0.3f), 3f); GUI.DrawTexture(recentSwatch[j], (Texture)(object)checkerTex, (ScaleMode)1, true); } GUI.Label(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref metalField)).y - 1f, 90f, ((Rect)(ref metalField)).height), "Metallic", stLabel); ScrubField(metalField, Metallic); GUI.Label(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref roughField)).y - 1f, 90f, ((Rect)(ref roughField)).height), "Roughness", stLabel); ScrubField(roughField, Roughness); if (Time.unscaledTime < statusUntil) { GUI.Label(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).yMax - 16f, ((Rect)(ref panel)).width - 32f, 14f), status, stSmall); } } private void DrawLegend() { //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_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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0184: 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_01f0: 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) Rounded(legend, LegendCol, 12f); DrawLegendRow(0, "Space", "3D Eyedropper (Hold)", null); DrawLegendRow(1, "Alt + Scroll", "Brush Size", BrushRadius.ToString("0.#") + " cm"); tposeToggleRect = legendRow[2]; DrawLegendRow(2, KeyLabel(Plugin.TPoseKey), "T-Pose", TPoseOn ? "on" : "off"); flatToggleRect = legendRow[3]; DrawLegendRow(3, KeyLabel(Plugin.FlatViewKey), "Flat View", FlatViewOn ? "on" : "off"); presetToggleRect = legendRow[4]; DrawLegendRow(4, KeyLabel(Plugin.PresetsKey), "Preset Library", PresetsOpen ? "open" : SuitPresets.Count.ToString()); DrawLegendRow(5, "Middle Mouse", "Rotate Camera", null); DrawLegendRow(6, "Scroll Wheel", "Zoom", null); DrawLegendRow(7, "Shift + Middle Mouse", "Pan", null); Rect val = legendRow[8]; float num = ((Rect)(ref val)).width * 0.5f; GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, 75f, ((Rect)(ref val)).height), "Ctrl + Z", stKeyText); GUI.Label(new Rect(((Rect)(ref val)).x + 80f, ((Rect)(ref val)).y, num - 80f, ((Rect)(ref val)).height), "Undo", stLegend); float num2 = ((Rect)(ref val)).x + num; GUI.Label(new Rect(num2, ((Rect)(ref val)).y, 75f, ((Rect)(ref val)).height), "Ctrl + R", stKeyText); GUI.Label(new Rect(num2 + 80f, ((Rect)(ref val)).y, ((Rect)(ref val)).width - num - 80f, ((Rect)(ref val)).height), "Strip Paint", stLegend); } private static string KeyLabel(ConfigEntry entry) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //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) if (entry == null || (int)entry.Value == 0) { return "Unbound"; } return ((object)entry.Value/*cast due to .constrained prefix*/).ToString(); } private void DrawLegendRow(int i, string inputKey, string title, string sub) { //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_0028: 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_00b6: Unknown result type (might be due to invalid IL or missing references) Rect val = legendRow[i]; GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, 160f, ((Rect)(ref val)).height), inputKey, stKeyText); float num = ((Rect)(ref val)).x + 165f; GUI.Label(new Rect(num, ((Rect)(ref val)).y, ((Rect)(ref val)).width - num - (string.IsNullOrEmpty(sub) ? 0f : 65f), ((Rect)(ref val)).height), title, stLegend); if (!string.IsNullOrEmpty(sub)) { GUI.Label(new Rect(((Rect)(ref val)).xMax - 65f, ((Rect)(ref val)).y, 65f, ((Rect)(ref val)).height), sub, stLegendDim); } } private void Field(Rect r, string text) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) Rounded(r, FieldCol, 3f); GUI.Label(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y - 1f, ((Rect)(ref r)).width - 4f, ((Rect)(ref r)).height), text, stNum); } private void ScrubField(Rect r, float value) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_005e: 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) Rounded(r, FieldCol, 3f); if (value > 0.005f) { float num = (((Rect)(ref r)).width - 4f) * Mathf.Clamp01(value); Rounded(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, num, ((Rect)(ref r)).height - 4f), new Color(0.35f, 0.35f, 0.35f, 0.35f), 2f); } GUI.Label(new Rect(((Rect)(ref r)).x + 10f, ((Rect)(ref r)).y - 1f, ((Rect)(ref r)).width - 20f, ((Rect)(ref r)).height), value.ToString("0.0"), stNum); } private void RampBar(Rect r, Texture2D tex, float t) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //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_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_0092: 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) Rounded(r, TrackCol, 3f); GUI.DrawTexture(r, (Texture)(object)tex, (ScaleMode)0, false); float num = ((Rect)(ref r)).x + Mathf.Clamp01(t) * ((Rect)(ref r)).width; Fill(new Rect(num - 1.5f, ((Rect)(ref r)).y - 1f, 3f, ((Rect)(ref r)).height + 2f), Color.black); Fill(new Rect(num - 0.5f, ((Rect)(ref r)).y - 1f, 1.5f, ((Rect)(ref r)).height + 2f), Color.white); } private void VerticalStrip(Rect r, Texture2D tex, float t) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //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_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_0092: 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) Rounded(r, TrackCol, 3f); GUI.DrawTexture(r, (Texture)(object)tex, (ScaleMode)0, false); float num = ((Rect)(ref r)).y + Mathf.Clamp01(t) * ((Rect)(ref r)).height; Fill(new Rect(((Rect)(ref r)).x - 1f, num - 1.5f, ((Rect)(ref r)).width + 2f, 3f), Color.black); Fill(new Rect(((Rect)(ref r)).x - 1f, num - 0.5f, ((Rect)(ref r)).width + 2f, 1.5f), Color.white); } private void Handle(Vector2 c, float radius, Color fill) { //IL_0003: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0066: 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_008b: 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) Rect val = default(Rect); ((Rect)(ref val))..ctor(c.x - radius, c.y - radius, radius * 2f, radius * 2f); GUI.color = Faded(new Color(0f, 0f, 0f, 0.65f)); GUI.DrawTexture(Grow(val, 1.5f), (Texture)(object)ringTex, (ScaleMode)0, true); GUI.color = Faded(fill); GUI.DrawTexture(Shrink(val, 1.5f), (Texture)(object)ringTex, (ScaleMode)0, true); GUI.color = tint; GUI.DrawTexture(val, (Texture)(object)ringTex, (ScaleMode)0, true); } private void DrawBrushCursor() { //IL_0054: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006d: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_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_008f: 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_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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_0140: 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_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_014c: 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_016a: 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_0176: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_0189: 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_01ad: 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 (cursorValid && !((Object)(object)cursorCam == (Object)null) && !(cursorRadius <= 0f)) { Vector3 val = ((((Vector3)(ref cursorNormal)).sqrMagnitude > 1E-06f) ? ((Vector3)(ref cursorNormal)).normalized : Vector3.up); Vector3 val2 = Vector3.Cross(val, (Mathf.Abs(val.y) > 0.9f) ? Vector3.right : Vector3.up); Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 b = Vector3.Cross(val, normalized); Vector3 val3 = val * Mathf.Max(0.002f, cursorRadius * 0.02f); if (Hardness < 0.97f) { Ring(cursorPoint + val3, normalized, b, cursorRadius * Mathf.Clamp01(Hardness), new Color(1f, 1f, 1f, 0.28f), 1f); } Ring(cursorPoint + val3, normalized, b, cursorRadius, new Color(0f, 0f, 0f, 0.5f), 3f); Ring(cursorPoint + val3, normalized, b, cursorRadius, Color.white, 1.5f); if (CameraMath.ProjectToGui(cursorCam, cursorViewProjection, cursorPoint + val3, out var gui)) { Fill(new Rect(gui.x - 1f, gui.y - 1f, 2f, 2f), new Color(1f, 1f, 1f, 0.8f)); } } } private void Ring(Vector3 center, Vector3 t, Vector3 b, float radius, Color col, float width) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_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_0080: 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_0073: 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_0078: Unknown result type (might be due to invalid IL or missing references) Vector2 a = default(Vector2); bool flag = false; for (int i = 0; i <= 40; i++) { float num = (float)i / 40f * MathF.PI * 2f; Vector3 world = center + (t * Mathf.Cos(num) + b * Mathf.Sin(num)) * radius; Vector2 gui; bool flag2 = CameraMath.ProjectToGui(cursorCam, cursorViewProjection, world, out gui); if (flag2 && flag) { Line(a, gui, width, col); } a = gui; flag = flag2; } } private void Line(Vector2 a, Vector2 b, float width, Color col) { //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0059: 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_006a: 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_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) float num = Vector2.Distance(a, b); if (!(num < 0.01f) && !(num > 4000f)) { float num2 = Mathf.Atan2(b.y - a.y, b.x - a.x) * 57.29578f; Matrix4x4 matrix = GUI.matrix; GUIUtility.RotateAroundPivot(num2, a); GUI.color = Faded(col); GUI.DrawTexture(new Rect(a.x, a.y - width * 0.5f, num, width), (Texture)(object)white); GUI.color = tint; GUI.matrix = matrix; } } private void Fill(Rect r, Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_001c: Unknown result type (might be due to invalid IL or missing references) GUI.color = Faded(c); GUI.DrawTexture(r, (Texture)(object)white); GUI.color = tint; } private void Rounded(Rect r, Color fill, float radius) { //IL_0001: 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_0016: 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) GUI.DrawTexture(r, (Texture)(object)white, (ScaleMode)0, true, 0f, Faded(fill), Vector4.zero, new Vector4(radius, radius, radius, radius)); } private Color Faded(Color c) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) return new Color(c.r, c.g, c.b, c.a * tint.a); } private static Rect Grow(Rect r, float by) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref r)).x - by, ((Rect)(ref r)).y - by, ((Rect)(ref r)).width + by * 2f, ((Rect)(ref r)).height + by * 2f); } private static Rect Shrink(Rect r, float by) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref r)).x + by, ((Rect)(ref r)).y + by, ((Rect)(ref r)).width - by * 2f, ((Rect)(ref r)).height - by * 2f); } private Font FindGameFont() { if ((Object)(object)gameFont != (Object)null) { return gameFont; } try { Font[] array = Resources.FindObjectsOfTypeAll(); Font[] array2 = array; foreach (Font val in array2) { if ((Object)(object)val != (Object)null && (((Object)val).name.IndexOf("3270", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val).name.IndexOf("edunline", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val).name.IndexOf("DOS", StringComparison.OrdinalIgnoreCase) >= 0)) { return val; } } TMP_FontAsset[] array3 = Resources.FindObjectsOfTypeAll(); TMP_FontAsset[] array4 = array3; foreach (TMP_FontAsset val2 in array4) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2.sourceFontFile != (Object)null && (((Object)val2).name.IndexOf("3270", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val2).name.IndexOf("edunline", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val2).name.IndexOf("DOS", StringComparison.OrdinalIgnoreCase) >= 0)) { return val2.sourceFontFile; } } Font[] array5 = array; foreach (Font val3 in array5) { if ((Object)(object)val3 != (Object)null && ((Object)val3).name != "Arial" && !((Object)val3).name.Contains("Default")) { return val3; } } } catch { } return null; } private void EnsureStyles() { //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_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_0040: Expected O, but got Unknown //IL_004b: 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_006b: 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_008b: 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_00ab: 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_00c0: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_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_0108: Expected O, but got Unknown //IL_0113: 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_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_0148: Expected O, but got Unknown //IL_0153: 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_0173: 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_0188: 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_01aa: 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_01c8: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) if (stLabel == null) { stLabel = new GUIStyle(GUI.skin.label) { fontSize = 14, alignment = (TextAnchor)3, wordWrap = false }; stLabel.normal.textColor = Ink; stNum = new GUIStyle(stLabel) { fontSize = 14, alignment = (TextAnchor)4, wordWrap = false }; stNum.normal.textColor = Ink; stSmall = new GUIStyle(stLabel) { fontSize = 12, alignment = (TextAnchor)3, wordWrap = false }; stSmall.normal.textColor = InkDim; stKeyText = new GUIStyle(stLabel) { fontSize = 13, fontStyle = (FontStyle)1, alignment = (TextAnchor)3, wordWrap = false }; stKeyText.normal.textColor = Ink; stLegend = new GUIStyle(stLabel) { fontSize = 13, alignment = (TextAnchor)3, wordWrap = false }; stLegend.normal.textColor = InkDim; stLegendDim = new GUIStyle(stLabel) { fontSize = 12, alignment = (TextAnchor)5, wordWrap = false }; stLegendDim.normal.textColor = InkDim; stPlus = new GUIStyle(stLabel) { fontSize = 13, alignment = (TextAnchor)4, wordWrap = false }; stPlus.normal.textColor = InkDim; } if ((Object)(object)gameFont == (Object)null) { Font val = FindGameFont(); if ((Object)(object)val != (Object)null) { gameFont = val; stLabel.font = val; stNum.font = val; stSmall.font = val; stKeyText.font = val; stLegend.font = val; stLegendDim.font = val; stPlus.font = val; } } } private void EnsureTextures() { //IL_0016: 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_01d6: 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_01dd: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)white == (Object)null) { white = Solid(Color.white); ringTex = MakeRing(64); wheelTex = MakeWheel(256, 0.68f); checkerTex = MakeChecker(16); barHue = MakeHueStrip(128); for (int i = 0; i < 3; i++) { barRgb[i] = New(128, 1); } barSat = New(128, 1); barVal = New(128, 1); barSatV = New(1, 128); barValV = New(1, 128); icClock = MakeClock(64); icFill = LoadEmbedded("MechaChameleon.fill_body.png", 48); icEye = LoadEmbedded("MechaChameleon.eye_icon.png", 48); icLock = LoadEmbedded("MechaChameleon.lock_icon.png", 48); icChevronDown = MakeChevronDown(32); icCross = MakeCross(48); icBin = LoadEmbedded("MechaChameleon.bin_normal.png", 48); icBinOpen = LoadEmbedded("MechaChameleon.bin_confirm.png", 48); icSaveBtn = LoadEmbedded("MechaChameleon.save_preset.png"); } if ((Object)(object)svTex == (Object)null || !Mathf.Approximately(svTexHue, Hue)) { if ((Object)(object)svTex == (Object)null) { svTex = New(128, 128); } FillSV(svTex, Hue); svTexHue = Hue; } Color val = Tint; if (barCacheColor != val) { barCacheColor = val; RefreshRamps(val); } } private void RefreshRamps(Color c) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_0064: 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_0036: 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_012d: 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_0188: 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) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[128]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 128; j++) { float num = (float)j / 127f; array[j] = Color32.op_Implicit((Color)(i switch { 1 => new Color(0f, num, 0f), 0 => new Color(num, 0f, 0f), _ => new Color(0f, 0f, num), })); } barRgb[i].SetPixels32(array); barRgb[i].Apply(false); } for (int k = 0; k < 128; k++) { array[k] = Color32.op_Implicit(Color.HSVToRGB(Hue, (float)k / 127f, 1f)); } barSat.SetPixels32(array); barSat.Apply(false); for (int l = 0; l < 128; l++) { array[l] = Color32.op_Implicit(Color.HSVToRGB(Hue, Sat, (float)l / 127f)); } barVal.SetPixels32(array); barVal.Apply(false); for (int m = 0; m < 128; m++) { array[m] = Color32.op_Implicit(Color.HSVToRGB(Hue, (float)m / 127f, Val)); } barSatV.SetPixels32(array); barSatV.Apply(false); for (int n = 0; n < 128; n++) { array[n] = Color32.op_Implicit(Color.HSVToRGB(Hue, Sat, (float)n / 127f)); } barValV.SetPixels32(array); barValV.Apply(false); } private static Texture2D Solid(Color c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false) { hideFlags = (HideFlags)61 }; val.SetPixel(0, 0, c); val.Apply(); return val; } private static Texture2D New(int w, int h) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0024: Expected O, but got Unknown return new Texture2D(w, h, (TextureFormat)4, false) { hideFlags = (HideFlags)61, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; } private static Texture2D MakeHueStrip(int w) { //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_0031: Unknown result type (might be due to invalid IL or missing references) Texture2D val = New(w, 1); Color32[] array = (Color32[])(object)new Color32[w]; for (int i = 0; i < w; i++) { array[i] = Color32.op_Implicit(Color.HSVToRGB((float)i / (float)(w - 1), 1f, 1f)); } val.SetPixels32(array); val.Apply(false); return val; } private static Texture2D MakeChecker(int size) { //IL_0056: 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_005b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = New(size, size); ((Texture)val).filterMode = (FilterMode)0; ((Texture)val).wrapMode = (TextureWrapMode)0; Color32[] array = (Color32[])(object)new Color32[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { array[i * size + j] = (((j < size / 2) ^ (i < size / 2)) ? new Color32((byte)54, (byte)54, (byte)54, (byte)85) : new Color32((byte)24, (byte)24, (byte)24, (byte)85)); } } val.SetPixels32(array); val.Apply(false); return val; } private static Texture2D MakeWheel(int size, float innerFrac) { //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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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) Texture2D val = New(size, size); Color32[] array = (Color32[])(object)new Color32[size * size]; float num = (float)size * 0.5f - 1f; float num2 = num * innerFrac; float num3 = (float)size * 0.5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num4 = (float)j + 0.5f - num3; float num5 = (float)i + 0.5f - num3; float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5); float num7 = Mathf.Clamp01(num - num6) * Mathf.Clamp01(num6 - num2); if (num7 <= 0f) { array[i * size + j] = new Color32((byte)0, (byte)0, (byte)0, (byte)0); continue; } float num8 = Mathf.Repeat(Mathf.Atan2(num5, num4) * 57.29578f - 90f, 360f) / 360f; Color val2 = Color.HSVToRGB(num8, 1f, 1f); array[i * size + j] = Color32.op_Implicit(new Color(val2.r, val2.g, val2.b, Mathf.Clamp01(num7))); } } val.SetPixels32(array); val.Apply(false); return val; } private static void FillSV(Texture2D tex, float hue) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) int width = ((Texture)tex).width; int height = ((Texture)tex).height; Color32[] array = (Color32[])(object)new Color32[width * height]; for (int i = 0; i < height; i++) { float num = (float)i / (float)(height - 1); for (int j = 0; j < width; j++) { array[i * width + j] = Color32.op_Implicit(Color.HSVToRGB(hue, (float)j / (float)(width - 1), num)); } } tex.SetPixels32(array); tex.Apply(false); } private static Texture2D MakeRing(int size) { //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) Texture2D val = New(size, size); Color32[] array = (Color32[])(object)new Color32[size * size]; float num = (float)size * 0.5f; float num2 = num - 1f; float num3 = num2 - Mathf.Max(1.5f, (float)size * 0.12f); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num4 = (float)j + 0.5f - num; float num5 = (float)i + 0.5f - num; float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5); float num7 = Mathf.Clamp01(num2 - num6) * Mathf.Clamp01(num6 - num3); array[i * size + j] = Color32.op_Implicit(new Color(1f, 1f, 1f, Mathf.Clamp01(num7))); } } val.SetPixels32(array); val.Apply(false); return val; } private static Texture2D MakeClock(int size) { //IL_0104: 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_0109: Unknown result type (might be due to invalid IL or missing references) Texture2D val = New(size, size); Color32[] array = (Color32[])(object)new Color32[size * size]; float num = (float)size * 0.5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = ((float)j + 0.5f - num) / num; float num3 = ((float)i + 0.5f - num) / num; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); bool flag = num4 > 0.65f && num4 < 0.9f; bool flag2 = num4 < 0.15f; bool flag3 = num2 < 0.05f && num2 > -0.35f && Mathf.Abs(num3 - 0.2f) < 0.08f; bool flag4 = num3 > -0.05f && num3 < 0.5f && Mathf.Abs(num2) < 0.08f; bool flag5 = flag || flag2 || flag3 || flag4; array[i * size + j] = (flag5 ? new Color32((byte)242, (byte)242, (byte)242, byte.MaxValue) : new Color32((byte)0, (byte)0, (byte)0, (byte)0)); } } val.SetPixels32(array); val.Apply(false); return val; } private static Texture2D MakeChevronDown(int size) { //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_00cb: Unknown result type (might be due to invalid IL or missing references) Texture2D val = New(size, size); Color32[] array = (Color32[])(object)new Color32[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num = (float)j / (float)(size - 1); float num2 = (float)i / (float)(size - 1); float num3 = 0.25f + Mathf.Abs(num - 0.5f) * 1.3f; float num4 = Mathf.Abs(num2 - num3); float num5 = ((num >= 0.12f && num <= 0.88f && num2 >= 0.18f && num2 <= 0.82f) ? Mathf.Clamp01((0.15f - num4) * (float)size * 0.5f) : 0f); array[i * size + j] = Color32.op_Implicit(new Color(0.85f, 0.85f, 0.85f, num5)); } } val.SetPixels32(array); val.Apply(false); return val; } public void Dispose() { Texture2D[] array = (Texture2D[])(object)new Texture2D[18] { white, wheelTex, svTex, ringTex, checkerTex, barHue, barSat, barVal, barSatV, barValV, barRgb[0], barRgb[1], barRgb[2], icClock, icFill, icChevronDown, icEye, icLock }; Texture2D[] array2 = array; foreach (Texture2D val in array2) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } DisposePresets(); white = (wheelTex = (svTex = (ringTex = (checkerTex = null)))); barHue = (barSat = (barVal = (barSatV = (barValV = null)))); barRgb[0] = (barRgb[1] = (barRgb[2] = null)); icClock = (icFill = (icChevronDown = (icEye = (icLock = null)))); } } public struct BrushSettings { public Color Color; public float Metallic; public float Smoothness; public float Radius; public float Hardness; public float Flow; public bool PaintColor; public bool PaintMetallic; public bool PaintSmoothness; } public struct PaintHit { public Vector2 UV; public Vector3 Point; public Vector3 Normal; public float TexelsPerMeter; } public class PaintTarget { private struct MatSlot { public Renderer Renderer; public int Index; } private class UndoEntry { public RectInt Rect; public Color32[] Albedo; public Color32[] Mask; } private struct CosmeticState { public bool Enabled; public bool Active; public bool ForceOff; public ShadowCastingMode Shadows; } public readonly PlayerControllerB Player; private Color32[] albedoPx; private Color32[] maskPx; private Color32[] baseAlbedoPx; private Color32[] baseMaskPx; private int size; private bool dirtyAlbedo; private bool dirtyMask; private const int TileSize = 256; private bool[] dirtyTiles; private int tileCols; private int tileRows; private bool anyTileDirty; private Color32[] scratch; private bool regionUploadBroken; private Texture2D staging; private bool cpuTextureStale; private SkinnedMeshRenderer smr; private Material originalMat; private Material paintMat; private readonly List slots = new List(); private Mesh bakedMesh; private int bakedFrame = -1; private int bakeSpace = -1; private string bakeSpaceName = "?"; private int lastHitTriangles; private Vector2 lastHitUV; private float lastHitDensity; private bool lastHitOk; private readonly Stopwatch clock = new Stopwatch(); private double msGeometry; private double msRay; private double msSweep; private double msUpload; private int paintedTexels; private int uploadedTiles; private float lastProfileLog; private int[] bakedTris; private Vector2[] bakedUVs; private readonly List bakedVerts = new List(); private Vector3[] worldVerts; private bool skinManually; private Transform[] bones; private Matrix4x4[] bindposes; private Matrix4x4[] boneMatrices; private Vector3[] baseVerts; private BoneWeight[] boneWeights; private Vector4[] poseSample; private Vector3[] triCenter; private float[] triRadius; private bool[] triOnUVBorder; private readonly List strokeTris = new List(); private bool strokeActive; private bool hasLastPoint; private Vector3 lastPoint; private Color32[] preStrokeAlbedo; private Color32[] preStrokeMask; private RectInt strokeRect; private bool strokeRectValid; private readonly List undo = new List(); private readonly Dictionary savedShadowModes = new Dictionary(); private bool savedUpdateOffscreen; private LODGroup lodGroup; private bool savedLodEnabled; private Camera visorCam; private bool savedVisorCamEnabled; private float savedLookWeight1 = 1f; private float savedLookWeight2 = 1f; private bool lookRigSaved; private int notVisibleFrames; private readonly List bodyRenderers = new List(); private readonly List viewModelRenderers = new List(); private bool usingReplacement; private Camera paintCam; private int savedCullingMask; private bool cullingMaskSaved; private readonly List hiddenWhilePainting = new List(); private readonly List cosmeticRenderers = new List(); private readonly Dictionary savedCosmetics = new Dictionary(); private readonly List wokenForPaint = new List(); private bool thirdPerson; private bool flatView; private Material flatMat; private bool tPose; private Vector3[] savedBonePos; private Quaternion[] savedBoneRot; private int[] boneOrder; private int[] boneParent; private Matrix4x4[] restRelative; private bool warnedSkipped; private static bool shadowsWanted = true; private bool perCameraHook; private Camera maskedCamera; private int maskedCameraMask; private float nextCosmeticScan; public Texture2D Albedo { get; private set; } public Texture2D Mask { get; private set; } public string HitTrace { get; private set; } = ""; public string MaterialInfo { get; private set; } = ""; public bool UsingReplacement => usingReplacement; public bool DirectDraw { get; private set; } public string Diagnostics { get; private set; } = ""; public bool CosmeticsVisible { get; set; } = true; public bool IsReady => (Object)(object)Albedo != (Object)null && (Object)(object)smr != (Object)null; private Material ActiveMat => (flatView && (Object)(object)flatMat != (Object)null) ? flatMat : paintMat; public bool FlatView => flatView; public bool TPose => tPose; private string AlbedoPath => Path.Combine(Plugin.SaveDir, "paint_basecolor.png"); private string MaskPath => Path.Combine(Plugin.SaveDir, "paint_mask.png"); public PaintTarget(PlayerControllerB player) { Player = player; } public bool EnsureSetup() { if (IsReady) { return true; } ResolveTarget(); if ((Object)(object)smr == (Object)null || (Object)(object)smr.sharedMesh == (Object)null) { return false; } originalMat = ((Renderer)smr).sharedMaterial; if ((Object)(object)originalMat == (Object)null) { return false; } size = Mathf.Clamp(Plugin.TextureSize.Value, 128, 4096); slots.Clear(); CollectSlots((Renderer)(object)smr); CollectSlots((Renderer)(object)Player.thisPlayerModelLOD1); CollectSlots((Renderer)(object)Player.thisPlayerModelLOD2); CollectSlots((Renderer)(object)Player.thisPlayerModelArms); Renderer[] componentsInChildren = ((Component)Player).GetComponentsInChildren(true); foreach (Renderer r in componentsInChildren) { CollectSlots(r); } foreach (Renderer bodyRenderer in bodyRenderers) { CollectSlots(bodyRenderer); } foreach (Renderer viewModelRenderer in viewModelRenderers) { CollectSlots(viewModelRenderer); } if (slots.Count == 0) { slots.Add(new MatSlot { Renderer = (Renderer)(object)smr, Index = 0 }); } BuildLayers(); BuildMaterial(); ApplyMaterial(); BuildBakeMesh(); foreach (Renderer bodyRenderer2 in bodyRenderers) { if ((Object)(object)bodyRenderer2 != (Object)null) { bodyRenderer2.receiveShadows = true; } } skinManually = PrepareSkinning(); Plugin.Log.LogInfo((object)(skinManually ? "Skinning the paint mesh manually from bone matrices." : "Mesh is not readable; falling back to BakeMesh with transform resolution.")); if (Plugin.AutoSave.Value) { Load(); } return true; } private void ResolveTarget() { bodyRenderers.Clear(); viewModelRenderers.Clear(); usingReplacement = false; GameObject val = null; GameObject val2 = null; try { MonoBehaviour[] components = ((Component)Player).GetComponents(); foreach (MonoBehaviour val3 in components) { if ((Object)(object)val3 == (Object)null) { continue; } bool flag = false; Type type = ((object)val3).GetType(); while (type != null) { if (type.Name == "BodyReplacementBase") { flag = true; break; } type = type.BaseType; } if (flag) { val = GetGameObjectField(val3, "replacementModel"); val2 = GetGameObjectField(val3, "replacementViewModel"); if ((Object)(object)val != (Object)null) { break; } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Model replacement lookup failed: " + ex.Message)); } if ((Object)(object)val != (Object)null) { SkinnedMeshRenderer val4 = null; SkinnedMeshRenderer[] componentsInChildren = val.GetComponentsInChildren(true); foreach (SkinnedMeshRenderer val5 in componentsInChildren) { if (!((Object)(object)val5.sharedMesh == (Object)null) && ((Object)(object)val4 == (Object)null || val5.sharedMesh.vertexCount > val4.sharedMesh.vertexCount)) { val4 = val5; } } if ((Object)(object)val4 != (Object)null) { smr = val4; usingReplacement = true; bodyRenderers.AddRange(val.GetComponentsInChildren(true)); if ((Object)(object)val2 != (Object)null) { viewModelRenderers.AddRange(val2.GetComponentsInChildren(true)); } if ((Object)(object)Player.thisPlayerModelArms != (Object)null) { viewModelRenderers.Add((Renderer)(object)Player.thisPlayerModelArms); } Plugin.Log.LogInfo((object)$"Painting the model replacement avatar '{((Object)val).name}' ({((Object)smr).name}, {smr.sharedMesh.vertexCount} verts)."); return; } } smr = Player.thisPlayerModel; if ((Object)(object)smr != (Object)null) { bodyRenderers.Add((Renderer)(object)smr); } if ((Object)(object)Player.thisPlayerModelLOD1 != (Object)null) { bodyRenderers.Add((Renderer)(object)Player.thisPlayerModelLOD1); } if ((Object)(object)Player.thisPlayerModelLOD2 != (Object)null) { bodyRenderers.Add((Renderer)(object)Player.thisPlayerModelLOD2); } if ((Object)(object)Player.thisPlayerModelArms != (Object)null) { viewModelRenderers.Add((Renderer)(object)Player.thisPlayerModelArms); } } private static GameObject GetGameObjectField(object obj, string name) { FieldInfo field = obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); return (GameObject)((field != null) ? /*isinst with value type is only supported in some contexts*/: null); } private void BuildLayers() { //IL_004c: 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_00b1: 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_00cf: 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) Texture src = GetTex(originalMat, "_BaseColorMap") ?? GetTex(originalMat, "_MainTex"); Texture tex = GetTex(originalMat, "_MaskMap"); float num = 1f; float num2 = 0f; Albedo = Bake(src, size, linear: false, Color.white); Mask = Bake(tex, size, linear: true, new Color(num, 1f, 0f, num2)); ((Object)Albedo).name = "MechaChameleon_BaseColor"; ((Object)Mask).name = "MechaChameleon_Mask"; Texture2D albedo = Albedo; Texture2D mask = Mask; TextureWrapMode wrapMode = (TextureWrapMode)0; ((Texture)mask).wrapMode = (TextureWrapMode)0; ((Texture)albedo).wrapMode = wrapMode; Texture2D albedo2 = Albedo; Texture2D mask2 = Mask; FilterMode filterMode = (FilterMode)1; ((Texture)mask2).filterMode = (FilterMode)1; ((Texture)albedo2).filterMode = filterMode; tileCols = (size + 256 - 1) / 256; tileRows = tileCols; dirtyTiles = new bool[tileCols * tileRows]; albedoPx = Albedo.GetPixels32(); maskPx = Mask.GetPixels32(); baseAlbedoPx = (Color32[])albedoPx.Clone(); baseMaskPx = (Color32[])maskPx.Clone(); } internal static Texture2D Bake(Texture src, int size, bool linear, Color fallback) { //IL_003a: 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: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) RenderTexture temporary = RenderTexture.GetTemporary(size, size, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)(linear ? 1 : 2)); RenderTexture active = RenderTexture.active; try { if ((Object)(object)src != (Object)null) { Graphics.Blit(src, temporary); } else { RenderTexture.active = temporary; GL.Clear(true, true, fallback); } RenderTexture.active = temporary; Texture2D val = new Texture2D(size, size, (TextureFormat)4, false, linear); val.ReadPixels(new Rect(0f, 0f, (float)size, (float)size), 0, 0); val.Apply(false); return val; } finally { RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); } } private static Texture GetTex(Material m, string prop) { return ((Object)(object)m != (Object)null && m.HasProperty(prop)) ? m.GetTexture(prop) : null; } private void CollectSlots(Renderer r) { if ((Object)(object)r == (Object)null || ((Component)r).gameObject.layer == 19 || ((Object)((Component)r).gameObject).name.IndexOf("Imperium", StringComparison.OrdinalIgnoreCase) >= 0) { return; } Material[] sharedMaterials = r.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { if (!IsSuitMaterial(sharedMaterials[i])) { continue; } bool flag = false; foreach (MatSlot slot in slots) { if ((Object)(object)slot.Renderer == (Object)(object)r && slot.Index == i) { flag = true; break; } } if (!flag) { slots.Add(new MatSlot { Renderer = r, Index = i }); } } } private bool IsSuitMaterial(Material m) { if ((Object)(object)m == (Object)null) { return false; } if ((Object)(object)m == (Object)(object)originalMat || (Object)(object)m == (Object)(object)paintMat || (Object)(object)m == (Object)(object)flatMat) { return true; } if ((Object)(object)m.shader != (Object)(object)originalMat.shader) { return false; } Texture val = GetTex(m, "_BaseColorMap") ?? GetTex(m, "_MainTex"); Texture val2 = GetTex(originalMat, "_BaseColorMap") ?? GetTex(originalMat, "_MainTex"); if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)val2) { return true; } return StripInstance(((Object)m).name) == StripInstance(((Object)originalMat).name); } private static string StripInstance(string name) { if (string.IsNullOrEmpty(name)) { return name; } int num = name.IndexOf(" (Instance)", StringComparison.Ordinal); return (num >= 0) ? name.Substring(0, num) : name; } private void BuildMaterial() { //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_001e: Expected O, but got Unknown //IL_0093: 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_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) paintMat = new Material(originalMat) { name = "MechaChameleonPaint" }; if (paintMat.HasProperty("_BaseColorMap")) { paintMat.SetTexture("_BaseColorMap", (Texture)(object)Albedo); } if (paintMat.HasProperty("_MainTex")) { paintMat.SetTexture("_MainTex", (Texture)(object)Albedo); } if (paintMat.HasProperty("_BaseColor")) { paintMat.SetColor("_BaseColor", Color.white); } if (paintMat.HasProperty("_Color")) { paintMat.SetColor("_Color", Color.white); } if (paintMat.HasProperty("_MaskMap")) { paintMat.SetTexture("_MaskMap", (Texture)(object)Mask); paintMat.EnableKeyword("_MASKMAP"); if (paintMat.HasProperty("_MetallicRemapMin")) { paintMat.SetFloat("_MetallicRemapMin", 0f); } if (paintMat.HasProperty("_MetallicRemapMax")) { paintMat.SetFloat("_MetallicRemapMax", 1f); } if (paintMat.HasProperty("_SmoothnessRemapMin")) { paintMat.SetFloat("_SmoothnessRemapMin", 0f); } if (paintMat.HasProperty("_SmoothnessRemapMax")) { paintMat.SetFloat("_SmoothnessRemapMax", 1f); } if (paintMat.HasProperty("_AORemapMin")) { paintMat.SetFloat("_AORemapMin", 0f); } if (paintMat.HasProperty("_AORemapMax")) { paintMat.SetFloat("_AORemapMax", 1f); } } else if (paintMat.HasProperty("_Metallic")) { paintMat.SetFloat("_Metallic", 0f); } string text = (paintMat.HasProperty("_BaseColorMap") ? "_BaseColorMap" : (paintMat.HasProperty("_MainTex") ? "_MainTex" : "NONE")); MaterialInfo = ((Object)paintMat.shader).name + " base=" + text + " mask=" + (paintMat.HasProperty("_MaskMap") ? "Y" : "N"); Plugin.Log.LogInfo((object)("[PaintTarget BuildMaterial] Original shader='" + ((Object)originalMat.shader).name + "', original _BaseColor=" + (originalMat.HasProperty("_BaseColor") ? ((object)originalMat.GetColor("_BaseColor")/*cast due to .constrained prefix*/).ToString() : "none") + ", original _Smoothness=" + (originalMat.HasProperty("_Smoothness") ? originalMat.GetFloat("_Smoothness").ToString("0.000") : "none"))); Plugin.Log.LogInfo((object)("[PaintTarget BuildMaterial] Created paintMat '" + ((Object)paintMat).name + "', bound base to " + text + ", _BaseColor=" + (paintMat.HasProperty("_BaseColor") ? ((object)paintMat.GetColor("_BaseColor")/*cast due to .constrained prefix*/).ToString() : "none"))); } private void ApplyMaterial() { Material activeMat = ActiveMat; if ((Object)(object)activeMat == (Object)null) { return; } foreach (MatSlot slot in slots) { Renderer renderer = slot.Renderer; if (!((Object)(object)renderer == (Object)null)) { Material[] sharedMaterials = renderer.sharedMaterials; if (slot.Index < sharedMaterials.Length && !((Object)(object)sharedMaterials[slot.Index] == (Object)(object)activeMat)) { sharedMaterials[slot.Index] = activeMat; renderer.sharedMaterials = sharedMaterials; } } } } public void ReapplyIfNeeded() { if (!IsReady) { return; } Material activeMat = ActiveMat; foreach (MatSlot slot in slots) { Renderer renderer = slot.Renderer; if (!((Object)(object)renderer == (Object)null)) { Material[] sharedMaterials = renderer.sharedMaterials; if (slot.Index < sharedMaterials.Length && (Object)(object)sharedMaterials[slot.Index] != (Object)(object)activeMat) { ApplyMaterial(); break; } } } } public bool SetFlatView(bool on) { if (on == flatView) { return flatView; } if (!on) { flatView = false; if (IsReady) { ApplyMaterial(); } return false; } if (!IsReady) { return false; } if ((Object)(object)flatMat == (Object)null && !BuildFlatMaterial()) { Plugin.Log.LogWarning((object)"[PaintTarget] No unlit shader available; cannot switch to flat view."); return false; } ApplyFlatLevel(); flatView = on; ApplyMaterial(); return flatView; } private bool BuildFlatMaterial() { //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_0052: Expected O, but got Unknown Shader val = Shader.Find("HDRP/Unlit") ?? Shader.Find("Unlit/Texture") ?? Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { return false; } flatMat = new Material(val) { name = "MechaChameleonFlat" }; if (flatMat.HasProperty("_UnlitColorMap")) { flatMat.SetTexture("_UnlitColorMap", (Texture)(object)Albedo); } if (flatMat.HasProperty("_BaseColorMap")) { flatMat.SetTexture("_BaseColorMap", (Texture)(object)Albedo); } if (flatMat.HasProperty("_MainTex")) { flatMat.SetTexture("_MainTex", (Texture)(object)Albedo); } if (flatMat.HasProperty("_EmissiveExposureWeight")) { flatMat.SetFloat("_EmissiveExposureWeight", 0f); } ApplyFlatLevel(); Plugin.Log.LogInfo((object)("[PaintTarget] Flat view using shader '" + ((Object)val).name + "'.")); return true; } private void ApplyFlatLevel() { //IL_005d: 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_00ad: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)flatMat == (Object)null)) { float num = ((Plugin.FlatViewLevel != null) ? Plugin.FlatViewLevel.Value : 0.5f); Color val = default(Color); ((Color)(ref val))..ctor(num, num, num, 1f); if (flatMat.HasProperty("_UnlitColor")) { flatMat.SetColor("_UnlitColor", val); } if (flatMat.HasProperty("_BaseColor")) { flatMat.SetColor("_BaseColor", val); } if (flatMat.HasProperty("_Color")) { flatMat.SetColor("_Color", val); } } } private void BuildBakeMesh() { //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_002a: Expected O, but got Unknown if (!((Object)(object)bakedMesh != (Object)null)) { bakedMesh = new Mesh { name = "MechaChameleonBaked" }; bakedMesh.MarkDynamic(); } } private void RefreshGeometry() { if ((Object)(object)smr == (Object)null || bakedFrame == Time.frameCount) { return; } bakedFrame = Time.frameCount; if (BonesMoved()) { long elapsedTicks = clock.ElapsedTicks; if (skinManually) { SkinToWorld(); } else { BakeToWorldFallback(); } RefreshTriangleBounds(); msGeometry += (double)(clock.ElapsedTicks - elapsedTicks) * 1000.0 / (double)Stopwatch.Frequency; } } public bool TryGetPosedGeometry(out Vector3[] worldVertices, out int[] triangles) { worldVertices = null; triangles = null; if ((Object)(object)smr == (Object)null) { return false; } RefreshGeometry(); if (worldVerts == null || worldVerts.Length == 0) { return false; } if (bakedTris == null || bakedTris.Length < 3) { return false; } worldVertices = worldVerts; triangles = bakedTris; return true; } public bool TryGetPosedBounds(out Bounds bounds) { //IL_0002: 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_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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_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_008d: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); if (!TryGetPosedGeometry(out var worldVertices, out var _)) { return false; } Vector3 val = worldVertices[0]; Vector3 val2 = worldVertices[0]; for (int i = 1; i < worldVertices.Length; i++) { val = Vector3.Min(val, worldVertices[i]); val2 = Vector3.Max(val2, worldVertices[i]); } bounds = new Bounds((val + val2) * 0.5f, val2 - val); return ((Bounds)(ref bounds)).size.y > 0.05f; } private bool BonesMoved() { //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_015f: 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_0168: 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_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_0189: 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_019f: 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_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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e7: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: 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_01c2: 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_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) if (bones == null || bones.Length == 0) { return true; } if (worldVerts == null) { return true; } int num = Mathf.Min(12, bones.Length); if (poseSample == null || poseSample.Length != num * 2) { poseSample = (Vector4[])(object)new Vector4[num * 2]; for (int i = 0; i < num; i++) { Transform val = bones[i * bones.Length / num]; if (!((Object)(object)val == (Object)null)) { poseSample[i * 2] = Vector4.op_Implicit(val.position); Quaternion rotation = val.rotation; poseSample[i * 2 + 1] = new Vector4(rotation.x, rotation.y, rotation.z, rotation.w); } } return true; } bool result = false; Vector4 val4 = default(Vector4); for (int j = 0; j < num; j++) { Transform val2 = bones[j * bones.Length / num]; if ((Object)(object)val2 == (Object)null) { continue; } Vector4 val3 = Vector4.op_Implicit(val2.position); Quaternion rotation2 = val2.rotation; ((Vector4)(ref val4))..ctor(rotation2.x, rotation2.y, rotation2.z, rotation2.w); Vector4 val5 = val3 - poseSample[j * 2]; if (!(((Vector4)(ref val5)).sqrMagnitude > 1E-10f)) { val5 = val4 - poseSample[j * 2 + 1]; if (!(((Vector4)(ref val5)).sqrMagnitude > 1E-10f)) { continue; } } result = true; poseSample[j * 2] = val3; poseSample[j * 2 + 1] = val4; } return result; } private bool PrepareSkinning() { Mesh sharedMesh = smr.sharedMesh; if ((Object)(object)sharedMesh == (Object)null || !sharedMesh.isReadable) { return false; } bones = smr.bones; bindposes = sharedMesh.bindposes; if (bones == null || bones.Length == 0 || bindposes == null || bindposes.Length == 0) { return false; } baseVerts = sharedMesh.vertices; boneWeights = sharedMesh.boneWeights; bakedUVs = sharedMesh.uv; bakedTris = sharedMesh.triangles; if (baseVerts == null || baseVerts.Length == 0) { return false; } if (boneWeights == null || boneWeights.Length != baseVerts.Length) { return false; } if (bakedUVs == null || bakedUVs.Length != baseVerts.Length) { return false; } boneMatrices = (Matrix4x4[])(object)new Matrix4x4[bones.Length]; worldVerts = (Vector3[])(object)new Vector3[baseVerts.Length]; return true; } private void SkinToWorld() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_007c: 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_0091: 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_00c8: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_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_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_012f: 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_0168: 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_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_01d6: 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_01a1: 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_01b7: 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_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) int num = Mathf.Min(bones.Length, bindposes.Length); for (int i = 0; i < num; i++) { boneMatrices[i] = (((Object)(object)bones[i] != (Object)null) ? (bones[i].localToWorldMatrix * bindposes[i]) : Matrix4x4.identity); } for (int j = 0; j < baseVerts.Length; j++) { BoneWeight val = boneWeights[j]; Vector3 val2 = baseVerts[j]; Vector3 val3 = Vector3.zero; if (((BoneWeight)(ref val)).weight0 > 0f && ((BoneWeight)(ref val)).boneIndex0 < num) { val3 += ((Matrix4x4)(ref boneMatrices[((BoneWeight)(ref val)).boneIndex0])).MultiplyPoint3x4(val2) * ((BoneWeight)(ref val)).weight0; } if (((BoneWeight)(ref val)).weight1 > 0f && ((BoneWeight)(ref val)).boneIndex1 < num) { val3 += ((Matrix4x4)(ref boneMatrices[((BoneWeight)(ref val)).boneIndex1])).MultiplyPoint3x4(val2) * ((BoneWeight)(ref val)).weight1; } if (((BoneWeight)(ref val)).weight2 > 0f && ((BoneWeight)(ref val)).boneIndex2 < num) { val3 += ((Matrix4x4)(ref boneMatrices[((BoneWeight)(ref val)).boneIndex2])).MultiplyPoint3x4(val2) * ((BoneWeight)(ref val)).weight2; } if (((BoneWeight)(ref val)).weight3 > 0f && ((BoneWeight)(ref val)).boneIndex3 < num) { val3 += ((Matrix4x4)(ref boneMatrices[((BoneWeight)(ref val)).boneIndex3])).MultiplyPoint3x4(val2) * ((BoneWeight)(ref val)).weight3; } worldVerts[j] = val3; } } private void BakeToWorldFallback() { //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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bakedMesh == (Object)null) { return; } smr.BakeMesh(bakedMesh, false); if (bakedTris == null) { bakedTris = bakedMesh.triangles; } if (bakedUVs == null || bakedUVs.Length != bakedMesh.vertexCount) { bakedUVs = bakedMesh.uv; if (bakedUVs == null || bakedUVs.Length != bakedMesh.vertexCount) { bakedUVs = smr.sharedMesh.uv; } } bakedMesh.GetVertices(bakedVerts); if (bakeSpace < 0) { ResolveBakeSpace(); } int count = bakedVerts.Count; if (worldVerts == null || worldVerts.Length != count) { worldVerts = (Vector3[])(object)new Vector3[count]; } Matrix4x4 val = BakeToWorld(); for (int i = 0; i < count; i++) { worldVerts[i] = ((Matrix4x4)(ref val)).MultiplyPoint3x4(bakedVerts[i]); } } private Matrix4x4 BakeToWorld() { //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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_004a: 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_008d: 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_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_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_00c1: 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_0061: 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_00f2: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)smr).transform; return (Matrix4x4)(bakeSpace switch { 1 => ((Object)(object)smr.rootBone != (Object)null) ? smr.rootBone.localToWorldMatrix : Matrix4x4.identity, 2 => Matrix4x4.identity, 3 => ((Object)(object)transform.parent != (Object)null) ? transform.parent.localToWorldMatrix : Matrix4x4.identity, 4 => Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one), 5 => ((Object)(object)smr.rootBone != (Object)null) ? Matrix4x4.TRS(smr.rootBone.position, smr.rootBone.rotation, Vector3.one) : Matrix4x4.identity, _ => transform.localToWorldMatrix, }); } private void ResolveBakeSpace() { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_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_0065: 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_0079: 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_009a: 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_00aa: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_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_010a: 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_0117: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_0156: 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_01b7: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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_01a1: 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) Bounds bounds = ((Renderer)smr).bounds; Transform transform = ((Component)smr).transform; if (bakedVerts.Count != 0) { Vector3 val = bakedVerts[0]; Vector3 val2 = bakedVerts[0]; for (int i = 1; i < bakedVerts.Count; i++) { val = Vector3.Min(val, bakedVerts[i]); val2 = Vector3.Max(val2, bakedVerts[i]); } Bounds local = default(Bounds); ((Bounds)(ref local))..ctor((val + val2) * 0.5f, val2 - val); int best = 0; float bestScore = float.MaxValue; string bestName = "renderer"; Score(0, "renderer", transform.localToWorldMatrix, ref best, ref bestScore, ref bestName, local, bounds); if ((Object)(object)smr.rootBone != (Object)null) { Score(1, "rootBone", smr.rootBone.localToWorldMatrix, ref best, ref bestScore, ref bestName, local, bounds); Score(5, "rootBoneNoScale", Matrix4x4.TRS(smr.rootBone.position, smr.rootBone.rotation, Vector3.one), ref best, ref bestScore, ref bestName, local, bounds); } Score(2, "world", Matrix4x4.identity, ref best, ref bestScore, ref bestName, local, bounds); if ((Object)(object)transform.parent != (Object)null) { Score(3, "parent", transform.parent.localToWorldMatrix, ref best, ref bestScore, ref bestName, local, bounds); } Score(4, "rendererNoScale", Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one), ref best, ref bestScore, ref bestName, local, bounds); bakeSpace = best; bakeSpaceName = bestName; } } private static void Score(int id, string name, Matrix4x4 m, ref int best, ref float bestScore, ref string bestName, Bounds local, Bounds want) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_00a3: 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_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_003a: 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_004f: 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_0064: 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_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_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) Vector3 center = ((Bounds)(ref local)).center; Vector3 extents = ((Bounds)(ref local)).extents; Bounds val = default(Bounds); ((Bounds)(ref val))..ctor(((Matrix4x4)(ref m)).MultiplyPoint3x4(center), Vector3.zero); for (int i = 0; i < 8; i++) { Vector3 val2 = center + new Vector3(((i & 1) == 0) ? (0f - extents.x) : extents.x, ((i & 2) == 0) ? (0f - extents.y) : extents.y, ((i & 4) == 0) ? (0f - extents.z) : extents.z); ((Bounds)(ref val)).Encapsulate(((Matrix4x4)(ref m)).MultiplyPoint3x4(val2)); } float num = Vector3.Distance(((Bounds)(ref val)).center, ((Bounds)(ref want)).center); Vector3 val3 = ((Bounds)(ref val)).size - ((Bounds)(ref want)).size; float num2 = num + ((Vector3)(ref val3)).magnitude; if (num2 < bestScore) { bestScore = num2; best = id; bestName = name; } } private Vector3 BodyCenter() { //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_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_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_0097: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_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_0085: 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_0094: Unknown result type (might be due to invalid IL or missing references) if (worldVerts == null || worldVerts.Length == 0) { return Vector3.zero; } Vector3 val = worldVerts[0]; Vector3 val2 = worldVerts[0]; for (int i = 1; i < worldVerts.Length; i += 7) { val = Vector3.Min(val, worldVerts[i]); val2 = Vector3.Max(val2, worldVerts[i]); } return (val + val2) * 0.5f; } private void FindUVBorders() { int num = bakedTris.Length / 3; triOnUVBorder = new bool[num]; Dictionary dictionary = new Dictionary(bakedTris.Length); for (int i = 0; i < bakedTris.Length; i += 3) { for (int j = 0; j < 3; j++) { int num2 = bakedTris[i + j]; int num3 = bakedTris[i + (j + 1) % 3]; long key = ((num2 < num3) ? (((long)num2 << 32) | (uint)num3) : (((long)num3 << 32) | (uint)num2)); dictionary.TryGetValue(key, out var value); dictionary[key] = value + 1; } } int num4 = 0; int num5 = 0; for (int k = 0; k < num; k++) { for (int l = 0; l < 3; l++) { int num6 = bakedTris[num5 + l]; int num7 = bakedTris[num5 + (l + 1) % 3]; long key2 = ((num6 < num7) ? (((long)num6 << 32) | (uint)num7) : (((long)num7 << 32) | (uint)num6)); if (dictionary[key2] < 2) { triOnUVBorder[k] = true; num4++; break; } } num5 += 3; } } private void RefreshTriangleBounds() { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_014f: 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_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_0161: 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_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_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) if (worldVerts == null || bakedTris == null) { return; } int num = bakedTris.Length / 3; if (triCenter == null || triCenter.Length != num) { triCenter = (Vector3[])(object)new Vector3[num]; triRadius = new float[num]; } if (triOnUVBorder == null || triOnUVBorder.Length != num) { FindUVBorders(); } int num2 = worldVerts.Length; int num3 = 0; int num4 = 0; while (num3 + 2 < bakedTris.Length) { int num5 = bakedTris[num3]; int num6 = bakedTris[num3 + 1]; int num7 = bakedTris[num3 + 2]; if (num5 >= num2 || num6 >= num2 || num7 >= num2) { triRadius[num4] = -1f; } else { Vector3 val = worldVerts[num5]; Vector3 val2 = worldVerts[num6]; Vector3 val3 = worldVerts[num7]; Vector3 val4 = (val + val2 + val3) / 3f; triCenter[num4] = val4; float[] array = triRadius; int num8 = num4; Vector3 val5 = val - val4; float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude; val5 = val2 - val4; float sqrMagnitude2 = ((Vector3)(ref val5)).sqrMagnitude; val5 = val3 - val4; array[num8] = Mathf.Sqrt(Mathf.Max(sqrMagnitude, Mathf.Max(sqrMagnitude2, ((Vector3)(ref val5)).sqrMagnitude))); } num3 += 3; num4++; } } public void LogGeometry() { //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_0029: 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_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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_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_0064: 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_012c: 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_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_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_019e: 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_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_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_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) Mesh val = (((Object)(object)smr != (Object)null) ? smr.sharedMesh : null); Vector3 val2 = Vector3.positiveInfinity; Vector3 val3 = Vector3.negativeInfinity; if (worldVerts != null) { for (int i = 0; i < worldVerts.Length; i++) { val2 = Vector3.Min(val2, worldVerts[i]); val3 = Vector3.Max(val3, worldVerts[i]); } } ManualLogSource log = Plugin.Log; string[] obj = new string[14] { "Geometry: mode=", skinManually ? "skinned" : ("baked:" + bakeSpaceName), " ", $"readable={(Object)(object)val != (Object)null && val.isReadable} verts={((worldVerts != null) ? worldVerts.Length : 0)} ", $"tris={((bakedTris != null) ? (bakedTris.Length / 3) : 0)} ", null, null, null, null, null, null, null, null, null }; object arg = val2; object arg2 = val3; object arg3; Bounds bounds; if (!((Object)(object)smr != (Object)null)) { arg3 = "?"; } else { bounds = ((Renderer)smr).bounds; arg3 = ((object)((Bounds)(ref bounds)).center/*cast due to .constrained prefix*/).ToString(); } obj[5] = $"worldBounds=({arg}..{arg2}) rendererBounds={arg3} "; obj[6] = "size="; object obj2; if (!((Object)(object)smr != (Object)null)) { obj2 = "?"; } else { bounds = ((Renderer)smr).bounds; obj2 = ((object)((Bounds)(ref bounds)).size/*cast due to .constrained prefix*/).ToString(); } obj[7] = (string)obj2; obj[8] = " smrPos="; obj[9] = (((Object)(object)smr != (Object)null) ? ((object)((Component)smr).transform.position/*cast due to .constrained prefix*/).ToString() : "?"); obj[10] = " smrScale="; obj[11] = (((Object)(object)smr != (Object)null) ? ((object)((Component)smr).transform.lossyScale/*cast due to .constrained prefix*/).ToString() : "?"); obj[12] = " rootBone="; obj[13] = (((Object)(object)smr != (Object)null && (Object)(object)smr.rootBone != (Object)null) ? (((Object)smr.rootBone).name + ((object)smr.rootBone.position/*cast due to .constrained prefix*/).ToString()) : "none"); log.LogInfo((object)string.Concat(obj)); } public bool RaycastUV(Ray ray, out Vector2 uv) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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) uv = default(Vector2); if (!RaycastSurface(ray, out var hit)) { return false; } uv = hit.UV; return true; } public void SetCosmeticsVisible(bool visible) { CosmeticsVisible = visible; if (visible) { ShowCosmetics(); } else { HideCosmetics(); } } public void HideCosmetics() { foreach (Renderer cosmeticRenderer in cosmeticRenderers) { if ((Object)(object)cosmeticRenderer != (Object)null) { cosmeticRenderer.enabled = false; } } } public bool RaycastSurface(Ray ray, out PaintHit hit) { //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_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_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0314: 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_031c: Unknown result type (might be due to invalid IL or missing references) //IL_031e: 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_0321: 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_036c: 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_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_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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_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_0106: 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_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0439: 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_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0449: 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_044d: 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_0457: 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_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: 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_04f4: 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_0182: 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_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_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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_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_01b5: 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_01bf: 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_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04da: 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_01f5: 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_01fc: 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_0200: 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_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0235: 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) hit = default(PaintHit); if (!IsReady) { return false; } RefreshGeometry(); if (bakedTris == null || bakedUVs == null || worldVerts == null || triRadius == null) { return false; } long elapsedTicks = clock.ElapsedTicks; Vector3 origin = ((Ray)(ref ray)).origin; Vector3 direction = ((Ray)(ref ray)).direction; int num = worldVerts.Length; float num2 = float.MaxValue; int num3 = -1; float num4 = 0f; float num5 = 0f; int num6 = 0; int num7 = 0; int num8 = 0; Vector3 val2; while (num7 + 2 < bakedTris.Length) { if (!(triRadius[num8] < 0f)) { Vector3 val = triCenter[num8] - origin; float num9 = Vector3.Dot(val, direction); if (!(num9 < 0f - triRadius[num8])) { val2 = val - direction * num9; if (!(((Vector3)(ref val2)).sqrMagnitude > triRadius[num8] * triRadius[num8])) { num6++; int num10 = bakedTris[num7]; int num11 = bakedTris[num7 + 1]; int num12 = bakedTris[num7 + 2]; if (num10 < num && num11 < num && num12 < num) { Vector3 val3 = worldVerts[num10]; Vector3 val4 = worldVerts[num11] - val3; Vector3 val5 = worldVerts[num12] - val3; Vector3 val6 = Vector3.Cross(direction, val5); float num13 = Vector3.Dot(val4, val6); if (!(num13 > -1E-09f) || !(num13 < 1E-09f)) { float num14 = 1f / num13; Vector3 val7 = origin - val3; float num15 = Vector3.Dot(val7, val6) * num14; if (!(num15 < 0f) && !(num15 > 1f)) { Vector3 val8 = Vector3.Cross(val7, val4); float num16 = Vector3.Dot(direction, val8) * num14; if (!(num16 < 0f) && !(num15 + num16 > 1f)) { float num17 = Vector3.Dot(val5, val8) * num14; if (!(num17 <= 0.0001f) && !(num17 >= num2)) { num2 = num17; num3 = num7; num4 = num15; num5 = num16; } } } } } } } } num7 += 3; num8++; } msRay += (double)(clock.ElapsedTicks - elapsedTicks) * 1000.0 / (double)Stopwatch.Frequency; lastHitTriangles = bakedTris.Length / 3; lastHitOk = num3 >= 0; Vector3 val9 = BodyCenter(); Vector3 val10 = val9 - origin; val2 = val10 - direction * Vector3.Dot(val10, direction); float magnitude = ((Vector3)(ref val2)).magnitude; HitTrace = $"near={num6}/{lastHitTriangles} miss={magnitude:0.00}m center={val9}"; if (num3 < 0) { return false; } int num18 = bakedTris[num3]; int num19 = bakedTris[num3 + 1]; int num20 = bakedTris[num3 + 2]; if (num18 >= bakedUVs.Length || num19 >= bakedUVs.Length || num20 >= bakedUVs.Length) { return false; } float num21 = 1f - num4 - num5; hit.UV = bakedUVs[num18] * num21 + bakedUVs[num19] * num4 + bakedUVs[num20] * num5; hit.Point = origin + direction * num2; Vector3 val11 = Vector3.Cross(worldVerts[num19] - worldVerts[num18], worldVerts[num20] - worldVerts[num18]); if (((Vector3)(ref val11)).sqrMagnitude > 1E-12f) { ((Vector3)(ref val11)).Normalize(); if (Vector3.Dot(val11, direction) > 0f) { val11 = -val11; } hit.Normal = val11; } else { hit.Normal = -((Vector3)(ref direction)).normalized; } hit.TexelsPerMeter = TexelDensity(num18, num19, num20); lastHitUV = hit.UV; lastHitDensity = hit.TexelsPerMeter; return true; } private float TexelDensity(int i0, int i1, int i2) { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_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) //IL_008a: 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_00a6: 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_00af: 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 (bakedUVs == null || worldVerts == null) { return 400f; } Vector3 val = worldVerts[i0]; Vector3 val2 = worldVerts[i1]; Vector3 val3 = worldVerts[i2]; float sum = 0f; int count = 0; Accumulate(ref sum, ref count, val, val2, bakedUVs[i0], bakedUVs[i1]); Accumulate(ref sum, ref count, val2, val3, bakedUVs[i1], bakedUVs[i2]); Accumulate(ref sum, ref count, val3, val, bakedUVs[i2], bakedUVs[i0]); return (count > 0) ? (sum / (float)count) : 400f; } private void Accumulate(ref float sum, ref int count, Vector3 a, Vector3 b, Vector2 ua, Vector2 ub) { //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_0018: 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) float num = Vector3.Distance(a, b); if (!(num < 1E-05f)) { float num2 = Vector2.Distance(ua, ub) * (float)size; if (!(num2 < 0.0001f)) { sum += num2 / num; count++; } } } public Vector3 GetAnchor() { //IL_0024: 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_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_0048: 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_004b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player == (Object)null) { return Vector3.zero; } return ((Component)Player).transform.position + ((Component)Player).transform.up * 1.15f; } public int CountUVTwins(PaintHit hit) { //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_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_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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_011a: 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_012e: 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_0147: 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_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_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_019a: 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: 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) if (bakedTris == null || bakedUVs == null || worldVerts == null || triCenter == null) { return 0; } Vector2 uV = hit.UV; int num = 0; int num2 = 0; int num3 = 0; while (num2 + 2 < bakedTris.Length) { if (!(triRadius[num3] < 0f)) { Vector3 val = triCenter[num3] - hit.Point; if (!(((Vector3)(ref val)).sqrMagnitude < 0.09f)) { int num4 = bakedTris[num2]; int num5 = bakedTris[num2 + 1]; int num6 = bakedTris[num2 + 2]; if (num4 < bakedUVs.Length && num5 < bakedUVs.Length && num6 < bakedUVs.Length) { Vector2 val2 = bakedUVs[num4]; Vector2 val3 = bakedUVs[num5]; Vector2 val4 = bakedUVs[num6]; if (!(uV.x < Mathf.Min(val2.x, Mathf.Min(val3.x, val4.x))) && !(uV.x > Mathf.Max(val2.x, Mathf.Max(val3.x, val4.x))) && !(uV.y < Mathf.Min(val2.y, Mathf.Min(val3.y, val4.y))) && !(uV.y > Mathf.Max(val2.y, Mathf.Max(val3.y, val4.y)))) { num++; } } } } num2 += 3; num3++; } return num; } public void BeginStroke() { if (IsReady && !strokeActive) { strokeActive = true; hasLastPoint = false; strokeRectValid = false; if (Plugin.UndoSteps.Value > 0) { preStrokeAlbedo = (Color32[])albedoPx.Clone(); preStrokeMask = (Color32[])maskPx.Clone(); } } } public void BreakStroke() { hasLastPoint = false; } public void EndStroke() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (strokeActive) { strokeActive = false; hasLastPoint = false; if (strokeRectValid && preStrokeAlbedo != null) { PushUndo(strokeRect); } preStrokeAlbedo = null; preStrokeMask = null; } } public void StrokeTo(PaintHit hit, BrushSettings b, bool erase) { //IL_0037: 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_005d: 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_0083: 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_00d5: 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_00da: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0120: 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_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) if (IsReady) { if (!hasLastPoint) { Plugin.Log.LogInfo((object)$"[PaintTarget StrokeTo] Starting new stroke at Point=({hit.Point.x:0.00},{hit.Point.y:0.00},{hit.Point.z:0.00}), UV=({hit.UV.x:0.000},{hit.UV.y:0.000}), Color=#{ColorUtility.ToHtmlStringRGB(b.Color)}, Radius={b.Radius:0.00}m, Erase={erase}"); } Vector3 val = (hasLastPoint ? lastPoint : hit.Point); GatherTriangles((val + hit.Point) * 0.5f, Vector3.Distance(val, hit.Point) * 0.5f + b.Radius); long elapsedTicks = clock.ElapsedTicks; Sweep(val, hit.Point, hit.Normal, b, erase); msSweep += (double)(clock.ElapsedTicks - elapsedTicks) * 1000.0 / (double)Stopwatch.Frequency; lastPoint = hit.Point; hasLastPoint = true; } } private void GatherTriangles(Vector3 center, float reach) { //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) //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) strokeTris.Clear(); if (triRadius == null) { return; } for (int i = 0; i < triRadius.Length; i++) { float num = triRadius[i]; if (!(num < 0f)) { num += reach; Vector3 val = triCenter[i] - center; if (((Vector3)(ref val)).sqrMagnitude <= num * num) { strokeTris.Add(i); } } } } private void Sweep(Vector3 from, Vector3 to, Vector3 brushNormal, BrushSettings b, bool erase) { //IL_0073: 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_0083: 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_0096: 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_00df: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0251: 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_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_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: 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_027f: 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_0291: 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_02a9: 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_02c1: 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_0326: 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_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_034a: 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_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0387: 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_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: 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_03de: Unknown result type (might be due to invalid IL or missing references) //IL_0831: Unknown result type (might be due to invalid IL or missing references) //IL_0836: 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_08d7: 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_08fc: Unknown result type (might be due to invalid IL or missing references) //IL_0906: Unknown result type (might be due to invalid IL or missing references) //IL_0921: 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_084c: Unknown result type (might be due to invalid IL or missing references) //IL_0851: Unknown result type (might be due to invalid IL or missing references) //IL_0855: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_0864: Unknown result type (might be due to invalid IL or missing references) //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_0887: Unknown result type (might be due to invalid IL or missing references) //IL_088e: Unknown result type (might be due to invalid IL or missing references) //IL_08a9: 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_08b8: Unknown result type (might be due to invalid IL or missing references) //IL_094d: Unknown result type (might be due to invalid IL or missing references) //IL_094f: 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_0a0f: Unknown result type (might be due to invalid IL or missing references) //IL_0996: Unknown result type (might be due to invalid IL or missing references) //IL_09a0: 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_09eb: Unknown result type (might be due to invalid IL or missing references) if (worldVerts == null || triRadius == null || bakedUVs == null) { return; } float num = Mathf.Max(0.001f, b.Radius); float num2 = num * num; bool paintColor = b.PaintColor; bool paintMetallic = b.PaintMetallic; bool paintSmoothness = b.PaintSmoothness; bool flag = paintMetallic || paintSmoothness; if (!paintColor && !flag) { return; } float x = from.x; float y = from.y; float z = from.z; float num3 = to.x - x; float num4 = to.y - y; float num5 = to.z - z; float num6 = num3 * num3 + num4 * num4 + num5 * num5; bool flag2 = num6 > 1E-10f; float num7 = (flag2 ? (1f / num6) : 0f); float x2 = brushNormal.x; float y2 = brushNormal.y; float z2 = brushNormal.z; Color32 val = Color32.op_Implicit(b.Color); byte r = val.r; byte g = val.g; byte b2 = val.b; byte b3 = (byte)Mathf.Clamp((int)(b.Metallic * 255f + 0.5f), 0, 255); byte b4 = (byte)Mathf.Clamp((int)(b.Smoothness * 255f + 0.5f), 0, 255); float flow = b.Flow; float hardness = b.Hardness; float num8 = Mathf.Max(0f, Plugin.SeamPadding.Value); float num9 = 1f / num; float num10 = ((hardness >= 0.999f) ? num2 : (hardness * num * (hardness * num))); int num11 = worldVerts.Length; int num12 = bakedUVs.Length; for (int i = 0; i < strokeTris.Count; i++) { int num13 = strokeTris[i]; int num14 = num13 * 3; int num15 = bakedTris[num14]; int num16 = bakedTris[num14 + 1]; int num17 = bakedTris[num14 + 2]; if (num15 >= num11 || num16 >= num11 || num17 >= num11 || num15 >= num12 || num16 >= num12 || num17 >= num12) { continue; } Vector3 val2 = worldVerts[num15]; Vector3 val3 = worldVerts[num16]; Vector3 val4 = worldVerts[num17]; float x3 = val2.x; float y3 = val2.y; float z3 = val2.z; float num18 = val3.x - x3; float num19 = val3.y - y3; float num20 = val3.z - z3; float num21 = val4.x - x3; float num22 = val4.y - y3; float num23 = val4.z - z3; float num24 = num19 * num23 - num20 * num22; float num25 = num20 * num21 - num18 * num23; float num26 = num18 * num22 - num19 * num21; if (num24 * x2 + num25 * y2 + num26 * z2 <= 0f) { continue; } float x4 = val3.x; float y4 = val3.y; float z4 = val3.z; float x5 = val4.x; float y5 = val4.y; float z5 = val4.z; Vector2 val5 = bakedUVs[num15]; Vector2 val6 = bakedUVs[num16]; Vector2 val7 = bakedUVs[num17]; float num27 = val5.x * (float)size; float num28 = val5.y * (float)size; float num29 = val6.x * (float)size; float num30 = val6.y * (float)size; float num31 = val7.x * (float)size; float num32 = val7.y * (float)size; float num33 = (num29 - num27) * (num32 - num28) - (num31 - num27) * (num30 - num28); if (num33 < 1E-06f && num33 > -1E-06f) { continue; } float num34 = 1f / num33; float num35 = ((triOnUVBorder != null && triOnUVBorder[num13]) ? num8 : 0f); float num36 = num35 * num35; float num37 = num35 + 1f; float num38 = ((!(num27 < num29)) ? ((num29 < num31) ? num29 : num31) : ((num27 < num31) ? num27 : num31)); float num39 = ((!(num27 > num29)) ? ((num29 > num31) ? num29 : num31) : ((num27 > num31) ? num27 : num31)); float num40 = ((!(num28 < num30)) ? ((num30 < num32) ? num30 : num32) : ((num28 < num32) ? num28 : num32)); float num41 = ((!(num28 > num30)) ? ((num30 > num32) ? num30 : num32) : ((num28 > num32) ? num28 : num32)); int num42 = (int)(num38 - num37); if (num42 < 0) { num42 = 0; } int num43 = (int)(num39 + num37) + 1; if (num43 > size - 1) { num43 = size - 1; } int num44 = (int)(num40 - num37); if (num44 < 0) { num44 = 0; } int num45 = (int)(num41 + num37) + 1; if (num45 > size - 1) { num45 = size - 1; } if (num43 < num42 || num45 < num44) { continue; } float num46 = num32 - num28; float num47 = num31 - num27; float num48 = num29 - num27; float num49 = num30 - num28; bool flag3 = false; for (int j = num44; j <= num45; j++) { int num50 = j * size; float num51 = (float)j + 0.5f - num28; for (int k = num42; k <= num43; k++) { float num52 = (float)k + 0.5f - num27; float num53 = (num52 * num46 - num47 * num51) * num34; float num54 = (num48 * num51 - num52 * num49) * num34; float num55 = 1f - num53 - num54; if (num55 < 0f || num53 < 0f || num54 < 0f) { if (num35 <= 0f) { continue; } float num56 = ((num55 > 0f) ? num55 : 0f); float num57 = ((num53 > 0f) ? num53 : 0f); float num58 = ((num54 > 0f) ? num54 : 0f); float num59 = num56 + num57 + num58; if (num59 < 1E-06f) { continue; } num59 = 1f / num59; num56 *= num59; num57 *= num59; num58 *= num59; float num60 = num52 - (num57 * num48 + num58 * num47); float num61 = num51 - (num57 * num49 + num58 * num46); if (num60 * num60 + num61 * num61 > num36) { continue; } num55 = num56; num53 = num57; num54 = num58; } float num62 = x3 * num55 + x4 * num53 + x5 * num54; float num63 = y3 * num55 + y4 * num53 + y5 * num54; float num64 = z3 * num55 + z4 * num53 + z5 * num54; float num65 = num62 - x; float num66 = num63 - y; float num67 = num64 - z; if (flag2) { float num68 = (num65 * num3 + num66 * num4 + num67 * num5) * num7; if (num68 < 0f) { num68 = 0f; } else if (num68 > 1f) { num68 = 1f; } num65 -= num3 * num68; num66 -= num4 * num68; num67 -= num5 * num68; } float num69 = num65 * num65 + num66 * num66 + num67 * num67; if (num69 > num2) { continue; } float num70 = ((num69 <= num10) ? flow : (flow * Falloff((float)Math.Sqrt(num69) * num9, hardness))); if (num70 <= 0.003f) { continue; } int num71 = num50 + k; if (paintColor) { Color32 val8 = albedoPx[num71]; if (erase) { Color32 val9 = baseAlbedoPx[num71]; val8.r = (byte)((float)(int)val8.r + (float)(val9.r - val8.r) * num70 + 0.5f); val8.g = (byte)((float)(int)val8.g + (float)(val9.g - val8.g) * num70 + 0.5f); val8.b = (byte)((float)(int)val8.b + (float)(val9.b - val8.b) * num70 + 0.5f); } else { val8.r = (byte)((float)(int)val8.r + (float)(r - val8.r) * num70 + 0.5f); val8.g = (byte)((float)(int)val8.g + (float)(g - val8.g) * num70 + 0.5f); val8.b = (byte)((float)(int)val8.b + (float)(b2 - val8.b) * num70 + 0.5f); } albedoPx[num71] = val8; } if (flag) { Color32 val10 = maskPx[num71]; if (paintMetallic) { int num72 = (erase ? baseMaskPx[num71].r : b3); val10.r = (byte)((float)(int)val10.r + (float)(num72 - val10.r) * num70 + 0.5f); } if (paintSmoothness) { int num73 = (erase ? baseMaskPx[num71].a : b4); val10.a = (byte)((float)(int)val10.a + (float)(num73 - val10.a) * num70 + 0.5f); } maskPx[num71] = val10; } flag3 = true; paintedTexels++; } } if (flag3) { ExpandStrokeRect(num42, num44, num43, num45); MarkTiles(num42, num44, num43, num45); if (paintColor) { dirtyAlbedo = true; } if (flag) { dirtyMask = true; } } } } private static float Falloff(float d, float hardness) { if (hardness >= 0.999f) { return 1f; } return Mathf.SmoothStep(1f, 0f, Mathf.InverseLerp(hardness, 1f, d)); } private static float Frac(float v) { return v - Mathf.Floor(v); } private void ReportProfile() { if (Plugin.Diagnostics.Value && !(Time.unscaledTime - lastProfileLog < 1f)) { lastProfileLog = Time.unscaledTime; if (paintedTexels > 0 || msSweep > 0.01) { Plugin.Log.LogInfo((object)($"Paint cost/sec: geometry {msGeometry:0.0}ms ray {msRay:0.0}ms sweep {msSweep:0.0}ms " + $"upload {msUpload:0.0}ms ({paintedTexels} texels, {uploadedTiles} tiles, {strokeTris.Count} tris under brush)")); } msGeometry = (msRay = (msSweep = (msUpload = 0.0))); paintedTexels = 0; uploadedTiles = 0; } } private void ForceFullUpload() { anyTileDirty = false; if (dirtyTiles != null) { Array.Clear(dirtyTiles, 0, dirtyTiles.Length); } } private void MarkTiles(int x0, int y0, int x1, int y1) { if (dirtyTiles == null) { return; } int num = Mathf.Clamp(x0 / 256, 0, tileCols - 1); int num2 = Mathf.Clamp(x1 / 256, 0, tileCols - 1); int num3 = Mathf.Clamp(y0 / 256, 0, tileRows - 1); int num4 = Mathf.Clamp(y1 / 256, 0, tileRows - 1); for (int i = num3; i <= num4; i++) { for (int j = num; j <= num2; j++) { dirtyTiles[i * tileCols + j] = true; } } anyTileDirty = true; } private void ExpandStrokeRect(int x0, int y0, int x1, int y1) { //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_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) if (!strokeRectValid) { strokeRect = new RectInt(x0, y0, x1 - x0 + 1, y1 - y0 + 1); strokeRectValid = true; return; } int num = Mathf.Min(((RectInt)(ref strokeRect)).xMin, x0); int num2 = Mathf.Min(((RectInt)(ref strokeRect)).yMin, y0); int num3 = Mathf.Max(((RectInt)(ref strokeRect)).xMax - 1, x1); int num4 = Mathf.Max(((RectInt)(ref strokeRect)).yMax - 1, y1); strokeRect = new RectInt(num, num2, num3 - num + 1, num4 - num2 + 1); } public void FlushTextures() { //IL_0151: 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) if (!clock.IsRunning) { clock.Start(); } ReportProfile(); if (!dirtyAlbedo && !dirtyMask) { return; } long elapsedTicks = clock.ElapsedTicks; if (anyTileDirty && !regionUploadBroken && dirtyTiles != null) { try { RectInt r = default(RectInt); for (int i = 0; i < tileRows; i++) { for (int j = 0; j < tileCols; j++) { if (dirtyTiles[i * tileCols + j]) { dirtyTiles[i * tileCols + j] = false; int num = j * 256; int num2 = i * 256; int num3 = Mathf.Min(256, size - num); int num4 = Mathf.Min(256, size - num2); ((RectInt)(ref r))..ctor(num, num2, num3, num4); if (scratch == null || scratch.Length < num3 * num4) { scratch = (Color32[])(object)new Color32[num3 * num4]; } if (dirtyAlbedo) { UploadRegion(Albedo, albedoPx, r); } if (dirtyMask) { UploadRegion(Mask, maskPx, r); } uploadedTiles++; } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Tiled texture upload failed, falling back to full uploads: " + ex.Message)); regionUploadBroken = true; Albedo.SetPixels32(albedoPx); Albedo.Apply(false); Mask.SetPixels32(maskPx); Mask.Apply(false); } } else { if (dirtyAlbedo) { Albedo.SetPixels32(albedoPx); Albedo.Apply(false); } if (dirtyMask) { Mask.SetPixels32(maskPx); Mask.Apply(false); } cpuTextureStale = false; } msUpload += (double)(clock.ElapsedTicks - elapsedTicks) * 1000.0 / (double)Stopwatch.Frequency; dirtyAlbedo = (dirtyMask = false); anyTileDirty = false; if (dirtyTiles != null && regionUploadBroken) { Array.Clear(dirtyTiles, 0, dirtyTiles.Length); } } private void UploadRegion(Texture2D tex, Color32[] src, RectInt r) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 for (int i = 0; i < ((RectInt)(ref r)).height; i++) { Array.Copy(src, (((RectInt)(ref r)).yMin + i) * size + ((RectInt)(ref r)).xMin, scratch, i * ((RectInt)(ref r)).width, ((RectInt)(ref r)).width); } if ((int)SystemInfo.copyTextureSupport > 0) { EnsureStaging(((RectInt)(ref r)).width, ((RectInt)(ref r)).height); if ((Object)(object)staging != (Object)null) { staging.SetPixels32(0, 0, ((RectInt)(ref r)).width, ((RectInt)(ref r)).height, scratch); staging.Apply(false); Graphics.CopyTexture((Texture)(object)staging, 0, 0, 0, 0, ((RectInt)(ref r)).width, ((RectInt)(ref r)).height, (Texture)(object)tex, 0, 0, ((RectInt)(ref r)).xMin, ((RectInt)(ref r)).yMin); cpuTextureStale = true; return; } } tex.SetPixels32(((RectInt)(ref r)).xMin, ((RectInt)(ref r)).yMin, ((RectInt)(ref r)).width, ((RectInt)(ref r)).height, scratch); tex.Apply(false); } private void EnsureStaging(int w, int h) { //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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown if (!((Object)(object)staging != (Object)null) || ((Texture)staging).width != w || ((Texture)staging).height != h) { if ((Object)(object)staging != (Object)null) { Object.Destroy((Object)(object)staging); } staging = new Texture2D(w, h, (TextureFormat)4, false) { name = "MechaChameleonStaging", hideFlags = (HideFlags)61 }; } } private void SyncTexturesFromPixels() { if (cpuTextureStale) { Albedo.SetPixels32(albedoPx); Albedo.Apply(false); Mask.SetPixels32(maskPx); Mask.Apply(false); cpuTextureStale = false; } } public void SampleAt(Vector2 uv, out Color color, out float metallic, out float smoothness) { //IL_0001: 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_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_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_006e: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_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_0095: 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) int num = Mathf.Clamp((int)(Frac(uv.x) * (float)size), 0, size - 1); int num2 = Mathf.Clamp((int)(Frac(uv.y) * (float)size), 0, size - 1); int num3 = num2 * size + num; Color32 val = albedoPx[num3]; Color32 val2 = maskPx[num3]; color = Color32.op_Implicit(new Color32(val.r, val.g, val.b, byte.MaxValue)); metallic = (float)(int)val2.r / 255f; smoothness = (float)(int)val2.a / 255f; } public bool TryGetSnapshot(out Color32[] albedoPixels, out Color32[] maskPixels, out int textureSize) { albedoPixels = albedoPx; maskPixels = maskPx; textureSize = size; return IsReady && albedoPx != null && maskPx != null && size > 0; } public bool SetTPose(bool on) { if ((Object)(object)smr == (Object)null) { return false; } if (on == tPose) { return tPose; } if (on) { if (!CaptureRestPose()) { Plugin.Log.LogWarning((object)"[PaintTarget] This model has no usable bind pose; cannot T-pose it."); return false; } tPose = true; warnedSkipped = false; AssertTPose(); } else { RestorePose(); tPose = false; } bakedFrame = -1; poseSample = null; return tPose; } private bool CaptureRestPose() { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) Mesh sharedMesh = smr.sharedMesh; Transform[] array = smr.bones; Matrix4x4[] array2 = (((Object)(object)sharedMesh != (Object)null) ? sharedMesh.bindposes : null); if (array == null || array2 == null || array.Length == 0 || array2.Length == 0) { return false; } int num = Mathf.Min(array.Length, array2.Length); savedBonePos = (Vector3[])(object)new Vector3[num]; savedBoneRot = (Quaternion[])(object)new Quaternion[num]; boneParent = new int[num]; restRelative = (Matrix4x4[])(object)new Matrix4x4[num]; Dictionary dictionary = new Dictionary(num); for (int i = 0; i < num; i++) { if ((Object)(object)array[i] != (Object)null) { dictionary[array[i]] = i; } } int num2 = 0; for (int j = 0; j < num; j++) { boneParent[j] = -1; if ((Object)(object)array[j] == (Object)null) { continue; } savedBonePos[j] = array[j].localPosition; savedBoneRot[j] = array[j].localRotation; Transform parent = array[j].parent; while ((Object)(object)parent != (Object)null) { if (dictionary.TryGetValue(parent, out var value) && value != j) { boneParent[j] = value; break; } parent = parent.parent; } if (boneParent[j] >= 0) { restRelative[j] = array2[boneParent[j]] * ((Matrix4x4)(ref array2[j])).inverse; } else { num2++; } } boneOrder = ParentFirstOrder(array, num); if (Plugin.Diagnostics.Value) { Plugin.Log.LogInfo((object)$"[PaintTarget] Rest pose captured: {num} bones, {num2} without a parent bone (left untouched)."); } return true; } private static int[] ParentFirstOrder(Transform[] bones, int n) { int[] array = new int[n]; int[] array2 = new int[n]; for (int i = 0; i < n; i++) { int num = 0; Transform val = bones[i]; while ((Object)(object)val != (Object)null) { num++; val = val.parent; } array[i] = num; array2[i] = i; } Array.Sort(array, array2); return array2; } public void AssertTPose() { //IL_01f9: 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_01fc: 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_0203: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0228: 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_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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_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_0159: 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_0179: 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_0182: 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_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) if (!tPose || (Object)(object)smr == (Object)null || boneOrder == null || restRelative == null) { return; } Transform[] array = smr.bones; if (array == null) { return; } int num = Mathf.Min(Mathf.Min(array.Length, restRelative.Length), boneOrder.Length); int num2 = 0; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(float.MaxValue, float.MaxValue, float.MaxValue); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(float.MinValue, float.MinValue, float.MinValue); int num3 = 0; for (int i = 0; i < num; i++) { int num4 = boneOrder[i]; if (num4 >= array.Length || num4 >= restRelative.Length) { continue; } int num5 = boneParent[num4]; if (num5 < 0) { continue; } Transform val3 = array[num4]; Transform val4 = ((num5 < array.Length) ? array[num5] : null); if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val4 == (Object)null)) { Matrix4x4 m = val4.localToWorldMatrix * restRelative[num4]; Vector3 val5 = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(3)); if (!IsFinite(val5) || !TryRotation(m, out var rot)) { num2++; continue; } val3.SetPositionAndRotation(val5, rot); val = Vector3.Min(val, val5); val2 = Vector3.Max(val2, val5); num3++; } } if (num2 > 0 && !warnedSkipped) { warnedSkipped = true; Plugin.Log.LogWarning((object)$"[PaintTarget] {num2} bone(s) have an unusable bindpose and were left posed by the animator."); } if (num3 > 0) { Vector3 val6 = val2 - val; if (!IsFinite(val6) || val6.x > 50f || val6.y > 50f || val6.z > 50f) { Plugin.Log.LogError((object)$"[PaintTarget] Rest pose produced a {val6} skeleton; reverting to the animator pose."); RestorePose(); tPose = false; bakedFrame = -1; poseSample = null; } } } private static bool TryRotation(Matrix4x4 m, out Quaternion rot) { //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_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_008f: 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_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_009c: Unknown result type (might be due to invalid IL or missing references) rot = Quaternion.identity; Vector3 val = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(2)); Vector3 val2 = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(1)); if (!IsFinite(val) || !IsFinite(val2)) { return false; } if (((Vector3)(ref val)).sqrMagnitude < 1E-12f || ((Vector3)(ref val2)).sqrMagnitude < 1E-12f) { return false; } Vector3 val3 = Vector3.Cross(val, val2); if (((Vector3)(ref val3)).sqrMagnitude < 1E-12f) { return false; } rot = Quaternion.LookRotation(val, val2); return IsFinite(rot); } private static bool IsFinite(Vector3 v) { //IL_0000: 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_001a: 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_0034: 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) return !float.IsNaN(v.x) && !float.IsNaN(v.y) && !float.IsNaN(v.z) && !float.IsInfinity(v.x) && !float.IsInfinity(v.y) && !float.IsInfinity(v.z); } private static bool IsFinite(Quaternion q) { //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_001b: 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_0028: 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_0058: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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: 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) if (float.IsNaN(q.x) || float.IsNaN(q.y) || float.IsNaN(q.z) || float.IsNaN(q.w)) { return false; } if (float.IsInfinity(q.x) || float.IsInfinity(q.y) || float.IsInfinity(q.z) || float.IsInfinity(q.w)) { return false; } return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w > 1E-08f; } private void RestorePose() { //IL_0089: 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) Transform[] array = (((Object)(object)smr != (Object)null) ? smr.bones : null); if (array == null || savedBonePos == null || boneParent == null) { return; } int num = Mathf.Min(Mathf.Min(array.Length, savedBonePos.Length), boneParent.Length); for (int i = 0; i < num; i++) { if (!((Object)(object)array[i] == (Object)null) && boneParent[i] >= 0) { array[i].localPosition = savedBonePos[i]; array[i].localRotation = savedBoneRot[i]; } } } private void PushUndo(RectInt rect) { //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) int value = Plugin.UndoSteps.Value; if (value > 0) { UndoEntry undoEntry = new UndoEntry(); undoEntry.Rect = rect; undoEntry.Albedo = (Color32[])(object)new Color32[((RectInt)(ref rect)).width * ((RectInt)(ref rect)).height]; undoEntry.Mask = (Color32[])(object)new Color32[((RectInt)(ref rect)).width * ((RectInt)(ref rect)).height]; UndoEntry undoEntry2 = undoEntry; for (int i = 0; i < ((RectInt)(ref rect)).height; i++) { int sourceIndex = (((RectInt)(ref rect)).yMin + i) * size + ((RectInt)(ref rect)).xMin; int destinationIndex = i * ((RectInt)(ref rect)).width; Array.Copy(preStrokeAlbedo, sourceIndex, undoEntry2.Albedo, destinationIndex, ((RectInt)(ref rect)).width); Array.Copy(preStrokeMask, sourceIndex, undoEntry2.Mask, destinationIndex, ((RectInt)(ref rect)).width); } undo.Add(undoEntry2); while (undo.Count > value) { undo.RemoveAt(0); } } } public void Undo() { if (undo.Count != 0) { UndoEntry undoEntry = undo[undo.Count - 1]; undo.RemoveAt(undo.Count - 1); for (int i = 0; i < ((RectInt)(ref undoEntry.Rect)).height; i++) { int destinationIndex = (((RectInt)(ref undoEntry.Rect)).yMin + i) * size + ((RectInt)(ref undoEntry.Rect)).xMin; int sourceIndex = i * ((RectInt)(ref undoEntry.Rect)).width; Array.Copy(undoEntry.Albedo, sourceIndex, albedoPx, destinationIndex, ((RectInt)(ref undoEntry.Rect)).width); Array.Copy(undoEntry.Mask, sourceIndex, maskPx, destinationIndex, ((RectInt)(ref undoEntry.Rect)).width); } dirtyAlbedo = (dirtyMask = true); ForceFullUpload(); FlushTextures(); } } public void FillAll(BrushSettings b) { //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_0038: 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_0046: 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_0062: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0124: 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_015f: 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_0196: 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) if (!IsReady) { return; } BeginStroke(); Color32 val = Color32.op_Implicit(b.Color); Plugin.Log.LogInfo((object)$"[PaintTarget FillAll] Filling entire suit: Color=#{ColorUtility.ToHtmlStringRGB(Color32.op_Implicit(val))} (RGBA: {val.r},{val.g},{val.b},{val.a}), Met={b.Metallic:0.00}, Smooth={b.Smoothness:0.00}"); byte r = (byte)Mathf.Clamp((int)(b.Metallic * 255f + 0.5f), 0, 255); byte a = (byte)Mathf.Clamp((int)(b.Smoothness * 255f + 0.5f), 0, 255); for (int i = 0; i < albedoPx.Length; i++) { if (b.PaintColor) { Color32 val2 = albedoPx[i]; val2.r = val.r; val2.g = val.g; val2.b = val.b; albedoPx[i] = val2; } if (b.PaintMetallic || b.PaintSmoothness) { Color32 val3 = maskPx[i]; if (b.PaintMetallic) { val3.r = r; } if (b.PaintSmoothness) { val3.a = a; } maskPx[i] = val3; } } ExpandStrokeRect(0, 0, size - 1, size - 1); dirtyAlbedo = (dirtyMask = true); ForceFullUpload(); FlushTextures(); EndStroke(); } public void SetShadows(bool on) { shadowsWanted = on; foreach (Renderer bodyRenderer in bodyRenderers) { if (!((Object)(object)bodyRenderer == (Object)null)) { bodyRenderer.receiveShadows = on; bodyRenderer.shadowCastingMode = (ShadowCastingMode)(on ? 1 : 0); } } } public void ResetPaint() { if (IsReady) { Array.Copy(baseAlbedoPx, albedoPx, albedoPx.Length); Array.Copy(baseMaskPx, maskPx, maskPx.Length); undo.Clear(); dirtyAlbedo = (dirtyMask = true); ForceFullUpload(); FlushTextures(); } } public void SetThirdPerson(bool on, Camera cam) { //IL_006a: 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) if ((Object)(object)smr == (Object)null) { return; } thirdPerson = on; if (on) { paintCam = cam; savedShadowModes.Clear(); foreach (Renderer bodyRenderer in bodyRenderers) { if ((Object)(object)bodyRenderer != (Object)null) { savedShadowModes[bodyRenderer] = bodyRenderer.shadowCastingMode; } } savedUpdateOffscreen = smr.updateWhenOffscreen; smr.updateWhenOffscreen = true; DirectDraw = Plugin.ForceDirectDraw.Value; notVisibleFrames = 0; bakeSpace = -1; bakedFrame = -1; poseSample = null; RefreshGeometry(); LogGeometry(); if ((Object)(object)cam != (Object)null && !cullingMaskSaved) { savedCullingMask = cam.cullingMask; cullingMaskSaved = true; } visorCam = Player.visorCamera; if ((Object)(object)visorCam != (Object)null) { savedVisorCamEnabled = ((Behaviour)visorCam).enabled; ((Behaviour)visorCam).enabled = false; } foreach (Renderer bodyRenderer2 in bodyRenderers) { ShowBody(bodyRenderer2); } CollectCosmetics(); if (CosmeticsVisible) { ShowCosmetics(); } else { HideCosmetics(); } LogCosmetics(cam); lodGroup = (usingReplacement ? null : ((Component)Player).GetComponentInChildren(true)); if ((Object)(object)lodGroup != (Object)null) { savedLodEnabled = lodGroup.enabled; lodGroup.enabled = true; lodGroup.ForceLOD(0); } hiddenWhilePainting.Clear(); foreach (Renderer viewModelRenderer in viewModelRenderers) { Hide(viewModelRenderer); } if ((Object)(object)Player.localVisor != (Object)null) { Renderer[] componentsInChildren = ((Component)Player.localVisor).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!bodyRenderers.Contains(val) && !cosmeticRenderers.Contains(val)) { Hide(val); } } } GameObject val2 = GameObject.Find("Systems/Rendering/PlayerHUDHelmetModel"); if ((Object)(object)val2 != (Object)null) { Renderer[] componentsInChildren2 = val2.GetComponentsInChildren(true); foreach (Renderer r in componentsInChildren2) { Hide(r); } } return; } RestoreCosmetics(); if ((Object)(object)visorCam != (Object)null) { ((Behaviour)visorCam).enabled = savedVisorCamEnabled; visorCam = null; } if (cullingMaskSaved && (Object)(object)paintCam != (Object)null) { paintCam.cullingMask = savedCullingMask; } cullingMaskSaved = false; paintCam = null; smr.updateWhenOffscreen = savedUpdateOffscreen; foreach (Renderer bodyRenderer3 in bodyRenderers) { if (!((Object)(object)bodyRenderer3 == (Object)null)) { if (savedShadowModes.TryGetValue(bodyRenderer3, out var value)) { bodyRenderer3.shadowCastingMode = value; } else { bodyRenderer3.shadowCastingMode = (ShadowCastingMode)3; } } } savedShadowModes.Clear(); if ((Object)(object)lodGroup != (Object)null) { GameObject val3 = GameObject.Find("ThridPersonCam"); if ((Object)(object)val3 != (Object)null && val3.activeInHierarchy) { lodGroup.ForceLOD(1); } else { lodGroup.ForceLOD(-1); lodGroup.enabled = savedLodEnabled; } lodGroup = null; } FreezeLookRig(freeze: false); foreach (Renderer item in hiddenWhilePainting) { if ((Object)(object)item != (Object)null) { item.enabled = true; } } hiddenWhilePainting.Clear(); } private void FreezeLookRig(bool freeze) { for (int i = 1; i <= 2; i++) { FieldInfo field = typeof(PlayerControllerB).GetField("cameraLookRig" + i); object obj = ((field != null) ? field.GetValue(Player) : null); if (obj == null) { continue; } PropertyInfo property = obj.GetType().GetProperty("weight"); if (property == null) { continue; } try { if (freeze) { float num = (float)property.GetValue(obj); if (num > 0f) { if (!lookRigSaved) { savedLookWeight1 = (savedLookWeight2 = num); lookRigSaved = true; } if (i == 1) { savedLookWeight1 = num; } else { savedLookWeight2 = num; } } property.SetValue(obj, 0f); } else if (lookRigSaved) { property.SetValue(obj, (i == 1) ? savedLookWeight1 : savedLookWeight2); } } catch { } } if (!freeze) { lookRigSaved = false; } } private void CollectCosmetics() { cosmeticRenderers.Clear(); int num = 0; int num2 = 0; string text = null; try { MonoBehaviour[] array = Object.FindObjectsOfType(true); foreach (MonoBehaviour val in array) { if ((Object)(object)val == (Object)null || ((object)val).GetType().Name != "CosmeticInstance") { continue; } num++; if (!BelongsToPlayer(((Component)val).transform)) { if (text == null) { text = PathOf(((Component)val).transform); } continue; } num2++; Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !cosmeticRenderers.Contains(val2) && !bodyRenderers.Contains(val2) && !viewModelRenderers.Contains(val2)) { cosmeticRenderers.Add(val2); } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Cosmetic lookup failed: " + ex.Message)); } Plugin.Log.LogInfo((object)($"Cosmetics: {num} in scene, {num2} on this player, " + $"{cosmeticRenderers.Count} renderer(s).")); if (num > 0 && num2 == 0 && text != null) { Plugin.Log.LogWarning((object)("Cosmetics exist but none resolved to this player. Example lives at: " + text)); } } private bool BelongsToPlayer(Transform t) { Transform val = (((Object)(object)Player != (Object)null) ? ((Component)Player).transform : null); Transform val2 = (((Object)(object)smr != (Object)null) ? ((Component)smr).transform : null); Transform val3 = t; while ((Object)(object)val3 != (Object)null) { if ((Object)(object)val != (Object)null && (Object)(object)val3 == (Object)(object)val) { return true; } if ((Object)(object)val2 != (Object)null && (Object)(object)val3 == (Object)(object)val2) { return true; } val3 = val3.parent; } return false; } private static string PathOf(Transform t) { StringBuilder stringBuilder = new StringBuilder(((Object)t).name); Transform parent = t.parent; while ((Object)(object)parent != (Object)null) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } private void ShowCosmetics() { //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) foreach (Renderer cosmeticRenderer in cosmeticRenderers) { if ((Object)(object)cosmeticRenderer == (Object)null) { continue; } if (!savedCosmetics.ContainsKey(cosmeticRenderer)) { savedCosmetics[cosmeticRenderer] = new CosmeticState { Enabled = cosmeticRenderer.enabled, Active = ((Component)cosmeticRenderer).gameObject.activeSelf, ForceOff = cosmeticRenderer.forceRenderingOff, Shadows = cosmeticRenderer.shadowCastingMode }; } Transform val = ((Component)cosmeticRenderer).transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)((Component)Player).transform) { if (!((Component)val).gameObject.activeSelf) { if (!wokenForPaint.Contains(((Component)val).gameObject)) { wokenForPaint.Add(((Component)val).gameObject); } ((Component)val).gameObject.SetActive(true); } val = val.parent; } ShowBody(cosmeticRenderer); } } private void LogCosmetics(Camera cam) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) foreach (Renderer cosmeticRenderer in cosmeticRenderers) { if (!((Object)(object)cosmeticRenderer == (Object)null)) { int layer = ((Component)cosmeticRenderer).gameObject.layer; bool flag = (Object)(object)cam != (Object)null && (cam.cullingMask & (1 << layer)) == 0; ManualLogSource log = Plugin.Log; string text = $"[Cosmetic] {((Object)cosmeticRenderer).name} layer={layer}({LayerMask.LayerToName(layer)}) "; string text2 = $"enabled={cosmeticRenderer.enabled} inHierarchy={((Component)cosmeticRenderer).gameObject.activeInHierarchy} "; string text3 = $"forceOff={cosmeticRenderer.forceRenderingOff} shadows={cosmeticRenderer.shadowCastingMode} "; object arg = flag; object arg2 = cosmeticRenderer.isVisible; Bounds bounds = cosmeticRenderer.bounds; log.LogInfo((object)(text + text2 + text3 + $"culledByCam={arg} visible={arg2} at={((Bounds)(ref bounds)).center}")); } } } private void RestoreCosmetics() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) for (int num = wokenForPaint.Count - 1; num >= 0; num--) { GameObject val = wokenForPaint[num]; if ((Object)(object)val != (Object)null) { val.SetActive(false); } } wokenForPaint.Clear(); foreach (KeyValuePair savedCosmetic in savedCosmetics) { Renderer key = savedCosmetic.Key; if (!((Object)(object)key == (Object)null)) { key.enabled = savedCosmetic.Value.Enabled; key.forceRenderingOff = savedCosmetic.Value.ForceOff; key.shadowCastingMode = savedCosmetic.Value.Shadows; if (((Component)key).gameObject.activeSelf != savedCosmetic.Value.Active) { ((Component)key).gameObject.SetActive(savedCosmetic.Value.Active); } } } savedCosmetics.Clear(); } private static void ShowBody(Renderer r) { if (!((Object)(object)r == (Object)null)) { r.shadowCastingMode = (ShadowCastingMode)(shadowsWanted ? 1 : 0); r.enabled = true; r.forceRenderingOff = false; if (!((Component)r).gameObject.activeSelf) { ((Component)r).gameObject.SetActive(true); } } } private void Hide(Renderer r) { if (!((Object)(object)r == (Object)null) && r.enabled) { r.enabled = false; hiddenWhilePainting.Add(r); } } public int CollectProbes(Camera cam, int want, List positions, List albedos) { //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_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_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_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_013b: 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_0142: 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_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_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_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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_0178: 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_01b1: 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_01d9: 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_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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_0222: 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_023e: Unknown result type (might be due to invalid IL or missing references) positions.Clear(); albedos.Clear(); if (worldVerts == null || bakedTris == null || bakedUVs == null || (Object)(object)cam == (Object)null) { return 0; } RefreshGeometry(); int num = bakedTris.Length / 3; if (num == 0) { return 0; } Vector3 position = ((Component)cam).transform.position; int num2 = Mathf.Max(1, num / Mathf.Max(1, want * 4)); int num3 = worldVerts.Length; int num4 = bakedUVs.Length; for (int i = 0; i < num; i += num2) { if (positions.Count >= want) { break; } int num5 = i * 3; int num6 = bakedTris[num5]; int num7 = bakedTris[num5 + 1]; int num8 = bakedTris[num5 + 2]; if (num6 < num3 && num7 < num3 && num8 < num3 && num6 < num4 && num7 < num4 && num8 < num4) { Vector3 val = worldVerts[num6]; Vector3 val2 = worldVerts[num7]; Vector3 val3 = worldVerts[num8]; Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); Vector3 val5 = (val + val2 + val3) * (1f / 3f); Vector3 val6 = position - val5; if (!(Vector3.Dot(val4, val6) <= 0f) && !(((Vector3)(ref val4)).sqrMagnitude < 1E-12f) && !(Vector3.Dot(((Vector3)(ref val4)).normalized, ((Vector3)(ref val6)).normalized) < 0.45f)) { Vector2 uv = (bakedUVs[num6] + bakedUVs[num7] + bakedUVs[num8]) * (1f / 3f); SampleAt(uv, out var color, out var _, out var _); positions.Add(val5 + ((Vector3)(ref val4)).normalized * 0.004f); albedos.Add(color); } } } return positions.Count; } public void SetPerCameraVisibility(bool on) { if (on != perCameraHook) { perCameraHook = on; if (on) { RenderPipelineManager.beginCameraRendering += OnBeginCamera; RenderPipelineManager.endCameraRendering += OnEndCamera; } else { RenderPipelineManager.beginCameraRendering -= OnBeginCamera; RenderPipelineManager.endCameraRendering -= OnEndCamera; RestoreMaskedCamera(); } } } private bool IsLocalView(Camera cam) { if ((Object)(object)Player == (Object)null) { return false; } return (Object)(object)cam == (Object)(object)Player.gameplayCamera || (Object)(object)cam == (Object)(object)Player.visorCamera; } private void OnBeginCamera(ScriptableRenderContext ctx, Camera cam) { //IL_003b: 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) if (thirdPerson || (Object)(object)cam == (Object)null || bodyRenderers.Count == 0) { return; } bool flag = IsLocalView(cam); ShadowCastingMode shadowCastingMode = (ShadowCastingMode)((!flag) ? 1 : 3); for (int i = 0; i < bodyRenderers.Count; i++) { Renderer val = bodyRenderers[i]; if (!((Object)(object)val == (Object)null) && val.enabled) { val.shadowCastingMode = shadowCastingMode; } } if (!flag) { int num = BodyLayerMask(); if (num != 0 && (cam.cullingMask & num) != num) { maskedCamera = cam; maskedCameraMask = cam.cullingMask; cam.cullingMask |= num; } } } private void OnEndCamera(ScriptableRenderContext ctx, Camera cam) { if ((Object)(object)maskedCamera == (Object)(object)cam) { RestoreMaskedCamera(); } } private void RestoreMaskedCamera() { if (!((Object)(object)maskedCamera == (Object)null)) { maskedCamera.cullingMask = maskedCameraMask; maskedCamera = null; } } private int BodyLayerMask() { int num = 0; foreach (Renderer bodyRenderer in bodyRenderers) { if ((Object)(object)bodyRenderer != (Object)null) { num |= 1 << ((Component)bodyRenderer).gameObject.layer; } } foreach (Renderer cosmeticRenderer in cosmeticRenderers) { if ((Object)(object)cosmeticRenderer != (Object)null) { num |= 1 << ((Component)cosmeticRenderer).gameObject.layer; } } return num; } public void PreAnimationTick() { if (thirdPerson) { FreezeLookRig(freeze: true); } } public void TickVisibility(Camera cam) { //IL_0238: Unknown result type (might be due to invalid IL or missing references) if (!thirdPerson || (Object)(object)smr == (Object)null) { return; } if (cosmeticRenderers.Count == 0 && Time.unscaledTime >= nextCosmeticScan) { nextCosmeticScan = Time.unscaledTime + 2f; CollectCosmetics(); if (cosmeticRenderers.Count > 0) { if (CosmeticsVisible) { ShowCosmetics(); } else { HideCosmetics(); } } } if ((Object)(object)cam != (Object)null) { cam.cullingMask |= BodyLayerMask(); } for (int i = 0; i < hiddenWhilePainting.Count; i++) { Renderer val = hiddenWhilePainting[i]; if ((Object)(object)val != (Object)null && val.enabled) { val.enabled = false; } } if (!DirectDraw) { bool flag = false; foreach (Renderer bodyRenderer in bodyRenderers) { if (!((Object)(object)bodyRenderer == (Object)null)) { ShowBody(bodyRenderer); if (bodyRenderer.isVisible) { flag = true; } } } if (CosmeticsVisible) { ShowCosmetics(); } else { HideCosmetics(); } if (flag) { notVisibleFrames = 0; } else if (++notVisibleFrames > 30) { DirectDraw = true; Plugin.Log.LogWarning((object)("Body renderer never became visible; drawing the model directly. " + DescribeState(cam))); } } if (DirectDraw) { foreach (Renderer bodyRenderer2 in bodyRenderers) { if (!((Object)(object)bodyRenderer2 == (Object)null)) { if (savedShadowModes.TryGetValue(bodyRenderer2, out var value)) { bodyRenderer2.shadowCastingMode = value; } else if ((Object)(object)bodyRenderer2 == (Object)(object)smr && !usingReplacement) { bodyRenderer2.shadowCastingMode = (ShadowCastingMode)3; } else { bodyRenderer2.shadowCastingMode = (ShadowCastingMode)1; } } } RenderDirect(cam); } if (Plugin.Diagnostics.Value) { UpdateDiagnostics(cam); } } private void RenderDirect(Camera cam) { //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_00cb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { return; } RefreshGeometry(); if ((Object)(object)bakedMesh == (Object)null || bakedMesh.vertexCount == 0) { return; } Matrix4x4 val = BakeToWorld(); Material[] sharedMaterials = ((Renderer)smr).sharedMaterials; int num = Mathf.Max(1, bakedMesh.subMeshCount); int layer = ((Component)smr).gameObject.layer; for (int i = 0; i < num; i++) { Material val2 = ((sharedMaterials != null && sharedMaterials.Length != 0) ? sharedMaterials[Mathf.Min(i, sharedMaterials.Length - 1)] : paintMat); if ((Object)(object)val2 == (Object)null) { val2 = paintMat; } if (!((Object)(object)val2 == (Object)null)) { Graphics.DrawMesh(bakedMesh, val, val2, layer, cam, i, (MaterialPropertyBlock)null, (ShadowCastingMode)0, true, (Transform)null, true); } } } private static string ShadowTag(ShadowCastingMode m) { //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_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_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected I4, but got Unknown return (int)m switch { 0 => "OFF", 1 => "ON", 2 => "2SID", _ => "SHDW", }; } private void UpdateDiagnostics(Camera cam) { //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_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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00ce: 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_00e7: 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) Vector3 anchor = GetAnchor(); Bounds bounds = ((Renderer)smr).bounds; Vector3 center = ((Bounds)(ref bounds)).center; string[] obj = new string[8] { string.Format("{0} {1} L{2} ", usingReplacement ? "AVATAR" : "BODY", ((Renderer)smr).isVisible ? "VIS" : "HID", ((Component)smr).gameObject.layer), DirectDraw ? "DIRECT" : "RENDER", " ", ShadowTag(((Renderer)smr).shadowCastingMode), " ", $"DIST {(((Object)(object)cam != (Object)null) ? Vector3.Distance(((Component)cam).transform.position, anchor) : 0f):0.0}M ", null, null }; Vector3 val = center - anchor; obj[6] = $"BOFS {((Vector3)(ref val)).magnitude:0.0}M\n"; obj[7] = (lastHitOk ? $"HIT uv {lastHitUV.x:0.00},{lastHitUV.y:0.00} {lastHitDensity:0}tx/m {lastHitTriangles}tri {MaterialInfo}" : ("NO HIT " + HitTrace)); Diagnostics = string.Concat(obj); Diagnostics = Diagnostics + " spc:" + bakeSpaceName; } public string DescribeState(Camera cam) { //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_0062: 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_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_0189: Unknown result type (might be due to invalid IL or missing references) Vector3 anchor = GetAnchor(); object[] obj = new object[6] { usingReplacement ? "replacement" : "vanilla", ((Object)(object)smr != (Object)null) ? ((Object)smr).name : "null", bodyRenderers.Count, anchor, ((Component)Player).transform.position, null }; object obj2; if (!((Object)(object)smr != (Object)null)) { obj2 = "n/a"; } else { Bounds bounds = ((Renderer)smr).bounds; obj2 = ((object)((Bounds)(ref bounds)).center/*cast due to .constrained prefix*/).ToString(); } obj[5] = obj2; string text = string.Format("target={0}({1}) renderers={2} anchor={3} player={4} bounds={5}", obj); if ((Object)(object)cam != (Object)null) { text += $" cam={((Component)cam).transform.position} camName={((Object)cam).name}"; } if ((Object)(object)smr != (Object)null) { text += $" body(on={((Renderer)smr).enabled},shadow={((Renderer)smr).shadowCastingMode},layer={((Component)smr).gameObject.layer})"; } if ((Object)(object)Player.thisPlayerModelLOD1 != (Object)null) { text += $" lod1(on={((Renderer)Player.thisPlayerModelLOD1).enabled},shadow={((Renderer)Player.thisPlayerModelLOD1).shadowCastingMode})"; } if ((Object)(object)lodGroup != (Object)null) { text = text + " lodGroup=" + ((Object)lodGroup).name; } if ((Object)(object)cam != (Object)null) { text += $" culls_body={(Object)(object)smr != (Object)null && (cam.cullingMask & (1 << ((Component)smr).gameObject.layer)) == 0}"; } return text + string.Format(" visorCam={0} directDraw={1}", ((Object)(object)Player.visorCamera != (Object)null) ? ((Behaviour)Player.visorCamera).enabled.ToString() : "null", DirectDraw); } public void Save() { if (!IsReady) { return; } try { Directory.CreateDirectory(Plugin.SaveDir); SyncTexturesFromPixels(); File.WriteAllBytes(AlbedoPath, ImageConversion.EncodeToPNG(Albedo)); File.WriteAllBytes(MaskPath, ImageConversion.EncodeToPNG(Mask)); Plugin.Log.LogInfo((object)("Paint saved to " + Plugin.SaveDir)); } catch (Exception ex) { Plugin.Log.LogError((object)("Saving paint failed: " + ex.Message)); } } public void Load() { if (!IsReady) { return; } try { if (File.Exists(AlbedoPath)) { LoadInto(AlbedoPath, albedoPx); } if (File.Exists(MaskPath)) { LoadInto(MaskPath, maskPx); } undo.Clear(); dirtyAlbedo = (dirtyMask = true); ForceFullUpload(); FlushTextures(); } catch (Exception ex) { Plugin.Log.LogError((object)("Loading paint failed: " + ex.Message)); } } private void LoadInto(string path, Color32[] dst) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); try { if (ImageConversion.LoadImage(val, File.ReadAllBytes(path)) && ((Texture)val).width == ((Texture)val).height) { Resample(val.GetPixels32(), ((Texture)val).width, dst); } } finally { Object.Destroy((Object)(object)val); } } private void Resample(Color32[] src, int srcSize, Color32[] dst) { //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) if (src == null || srcSize <= 0) { return; } if (srcSize == size) { Array.Copy(src, dst, dst.Length); return; } for (int i = 0; i < size; i++) { int num = Mathf.Clamp(i * srcSize / size, 0, srcSize - 1); int num2 = num * srcSize; int num3 = i * size; for (int j = 0; j < size; j++) { int num4 = Mathf.Clamp(j * srcSize / size, 0, srcSize - 1); dst[num3 + j] = src[num2 + num4]; } } } public bool ApplyLayers(Color32[] srcAlbedo, Color32[] srcMask, int srcSize) { if (!IsReady || srcAlbedo == null || srcSize <= 0) { return false; } if (srcAlbedo.Length < srcSize * srcSize) { return false; } if (srcMask != null && srcMask.Length < srcSize * srcSize) { srcMask = null; } BeginStroke(); Resample(srcAlbedo, srcSize, albedoPx); if (srcMask != null) { Resample(srcMask, srcSize, maskPx); } ExpandStrokeRect(0, 0, size - 1, size - 1); dirtyAlbedo = true; dirtyMask = srcMask != null; ForceFullUpload(); FlushTextures(); EndStroke(); return true; } public void Dispose() { try { SetPerCameraVisibility(on: false); if (tPose) { SetTPose(on: false); } if (thirdPerson) { SetThirdPerson(on: false, paintCam); } if ((Object)(object)bakedMesh != (Object)null) { Object.Destroy((Object)(object)bakedMesh); } if ((Object)(object)staging != (Object)null) { Object.Destroy((Object)(object)staging); } if ((Object)(object)Albedo != (Object)null) { Object.Destroy((Object)(object)Albedo); } if ((Object)(object)Mask != (Object)null) { Object.Destroy((Object)(object)Mask); } if ((Object)(object)paintMat != (Object)null) { Object.Destroy((Object)(object)paintMat); } if ((Object)(object)flatMat != (Object)null) { Object.Destroy((Object)(object)flatMat); } } catch { } Albedo = null; Mask = null; smr = null; } } [BepInPlugin("filip.mechachameleon", "MechaChameleon", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "filip.mechachameleon"; public const string Name = "MechaChameleon"; public const string Version = "1.0.0"; public static Plugin Instance; public static ManualLogSource Log; private Harmony harmony; public static ConfigEntry ToggleKey; public static ConfigEntry PickKey; public static ConfigEntry TPoseKey; public static ConfigEntry FlatViewKey; public static ConfigEntry PresetsKey; public static ConfigEntry FlatViewLevel; public static ConfigEntry TextureSize; public static ConfigEntry OrbitSensitivity; public static ConfigEntry PanSensitivity; public static ConfigEntry InvertOrbitY; public static ConfigEntry FreezePose; public static ConfigEntry ForceDirectDraw; public static ConfigEntry Diagnostics; public static ConfigEntry RecordingCompat; public static ConfigEntry EyedropperUsesScreenPixel; public static ConfigEntry FlatPaint; public static ConfigEntry FlatPaintBrightness; public static ConfigEntry BlendGloss; public static ConfigEntry CompensateLight; public static ConfigEntry AutoSave; public static ConfigEntry UndoSteps; public static ConfigEntry SeamPadding; public static ConfigEntry NetSync; public static ConfigEntry NetTextureSize; public static ConfigEntry NetUploadKBps; public static string SaveDir => Path.Combine(Paths.ConfigPath, "MechaChameleon"); private void Awake() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Expected O, but got Unknown //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Expected O, but got Unknown //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Expected O, but got Unknown //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Expected O, but got Unknown //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; try { harmony = new Harmony("filip.mechachameleon"); harmony.PatchAll(); } catch (Exception arg) { Log.LogError((object)$"Error applying Harmony patches: {arg}"); } ToggleKey = ((BaseUnityPlugin)this).Config.Bind("Input", "ToggleKey", (Key)99, "Opens / closes the paint editor."); PickKey = ((BaseUnityPlugin)this).Config.Bind("Input", "PickKey", (Key)1, "Eyedropper. Samples base colour + metallic + smoothness from whatever is under the cursor."); TPoseKey = ((BaseUnityPlugin)this).Config.Bind("Input", "TPoseKey", (Key)68, "Toggles the T-pose while the editor is open, opening the arms away from the body so the armpits and inner arms can be reached. Defaults to Home because letter and function keys collide with mods that bind through InputUtils (Imperium). Set to None to disable the shortcut and use the legend button only."); FlatViewKey = ((BaseUnityPlugin)this).Config.Bind("Input", "FlatViewKey", (Key)69, "Draws the suit unlit while the editor is open, so cast shadows in a dim ship stop making the model hard to see. An unlit surface has nothing for a shadow to darken, and what reaches the screen is the painted texel itself rather than the texel times some light, so the colour is neither darkened nor washed out. Local and cosmetic: other players always see you lit normally. Set to None to disable the shortcut and use the legend button only."); PresetsKey = ((BaseUnityPlugin)this).Config.Bind("Input", "PresetsKey", (Key)70, "Opens / closes the preset library while the editor is open. Same reasoning as TPoseKey for the default: letter and function keys collide with mods that bind through InputUtils. Set to None to disable the shortcut and use the panel button only."); TextureSize = ((BaseUnityPlugin)this).Config.Bind("Paint", "TextureSize", 1024, new ConfigDescription("Resolution of the paint layers. Higher = sharper, more RAM.", (AcceptableValueBase)(object)new AcceptableValueList(new int[4] { 256, 512, 1024, 2048 }), Array.Empty())); UndoSteps = ((BaseUnityPlugin)this).Config.Bind("Paint", "UndoSteps", 12, new ConfigDescription("How many brush strokes can be undone (ctrl+Z).", (AcceptableValueBase)(object)new AcceptableValueRange(0, 64), Array.Empty())); SeamPadding = ((BaseUnityPlugin)this).Config.Bind("Paint", "SeamPadding", 2.5f, new ConfigDescription("How far paint bleeds past the edge of a UV chart, in texels. Without this, the gap between charts stays unpainted and shows as thin lines of the original suit along every seam. Raise it if seams still show, lower it if paint leaks between unrelated parts of the layout.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 8f), Array.Empty())); FlatViewLevel = ((BaseUnityPlugin)this).Config.Bind("Paint", "FlatViewLevel", 0.5f, new ConfigDescription("How bright the flat view draws the suit. This is the fix for colours looking pale in flat view: HDRP multiplies unlit surfaces by the scene exposure, so in a dim ship the suit is pushed past white before the tonemapper sees it, and since blue clips first it is blue that goes white. Lower this until the colours match your swatch; raise it if flat view comes out too dark. Takes effect the next time you toggle flat view on.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 2f), Array.Empty())); AutoSave = ((BaseUnityPlugin)this).Config.Bind("Paint", "AutoSave", true, "Write the paint to BepInEx/config/MechaChameleon on close and load it again on startup."); OrbitSensitivity = ((BaseUnityPlugin)this).Config.Bind("Camera", "OrbitSensitivity", 0.25f, new ConfigDescription("Degrees of orbit per pixel of mouse movement.", (AcceptableValueBase)(object)new AcceptableValueRange(0.02f, 2f), Array.Empty())); PanSensitivity = ((BaseUnityPlugin)this).Config.Bind("Camera", "PanSensitivity", 0.0016f, new ConfigDescription("Pan speed (shift + middle mouse), scaled by camera distance.", (AcceptableValueBase)(object)new AcceptableValueRange(0.0001f, 0.02f), Array.Empty())); InvertOrbitY = ((BaseUnityPlugin)this).Config.Bind("Camera", "InvertOrbitY", false, "Invert vertical orbit."); FreezePose = ((BaseUnityPlugin)this).Config.Bind("Camera", "FreezePose", true, "Stop the body animator while the editor is open so the model holds still while you paint."); ForceDirectDraw = ((BaseUnityPlugin)this).Config.Bind("Debug", "ForceDirectDraw", false, "Always draw the body mesh ourselves instead of waiting for the game's renderer to show it. The mod switches to this automatically if the body stays culled for 12 frames."); Diagnostics = ((BaseUnityPlugin)this).Config.Bind("Debug", "Diagnostics", false, "Show a body/camera state readout at the bottom of the panel."); RecordingCompat = ((BaseUnityPlugin)this).Config.Bind("Paint", "ShowBodyToOtherCameras", true, "Let cameras other than your own - a recording camera, the ship monitor - see your painted body. Your own first person view is unaffected: the body stays hidden there."); EyedropperUsesScreenPixel = ((BaseUnityPlugin)this).Config.Bind("Paint", "EyedropperUsesScreenPixel", false, "Off (default): the eyedropper reads the surface's own colour, ignoring the light on it. Painting that onto the suit makes the suit render the same as the surface did, because the same light is then applied to both - but the swatch looks darker than the lit surface you clicked. On: returns the lit pixel exactly as seen, which matches the swatch but paints brighter than expected, because the room lights it a second time on the model."); FlatPaint = ((BaseUnityPlugin)this).Config.Bind("Paint", "BlendMode", true, "Make the suit behave like the flat surfaces around it: keep normal lighting, but drop the fabric normal map, the baked ambient occlusion and the detail weave. The paint then catches light and shadow the same way a wall does, instead of reading as cloth. Turn off to keep the suit's own surface detail."); FlatPaintBrightness = ((BaseUnityPlugin)this).Config.Bind("Paint", "FlatPaintBrightness", 1f, new ConfigDescription("Overall level of the flat paint. 1 should match the colour you picked; lower it if the suit reads brighter than the swatch, raise it if it reads darker. Takes effect next time the editor is opened.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 4f), Array.Empty())); BlendGloss = ((BaseUnityPlugin)this).Config.Bind("Paint", "BlendGloss", 0.12f, new ConfigDescription("Highest smoothness the suit can reach in blend mode. Walls are matte, so a shiny suit never sits against one however well the colour matches. Raise it if you want the suit to catch light again.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); CompensateLight = ((BaseUnityPlugin)this).Config.Bind("Paint", "CompensateLight", true, "Divide a picked colour by the light on your suit before painting it. A picked pixel is already lit, so using it as paint lights it twice and the bright channel clips, washing the colour out. Measured once per pick and held, so it never shifts while you paint."); NetSync = ((BaseUnityPlugin)this).Config.Bind("Multiplayer", "SyncPaint", true, "Share your painted suit with everyone else in the lobby, and show theirs on your end. The finished suit is sent once, when you close the editor - nothing is sent while you paint. Players without the mod are detected and never sent anything."); NetTextureSize = ((BaseUnityPlugin)this).Config.Bind("Multiplayer", "NetworkTextureSize", 512, new ConfigDescription("Resolution the suit is downscaled to before being sent. Your own suit is unaffected; this is only what others receive. 512 is indistinguishable at the distance you actually see another player, and costs a quarter of what 1024 does. Drop it to 256 on a slow connection.", (AcceptableValueBase)(object)new AcceptableValueList(new int[3] { 256, 512, 1024 }), Array.Empty())); NetUploadKBps = ((BaseUnityPlugin)this).Config.Bind("Multiplayer", "UploadKBPerSecond", 96, new ConfigDescription("Ceiling on how fast a suit is pushed out, in kilobytes per second. A suit is cut into chunks and drip fed at this rate so a big paint job spreads over a few seconds instead of stalling the connection in one burst.", (AcceptableValueBase)(object)new AcceptableValueRange(16, 1024), Array.Empty())); Directory.CreateDirectory(SaveDir); LethalConfigCompat.Initialize(); GameObject val = new GameObject("MechaChameleon"); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent(); } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class PlayerInputPatches { [HarmonyPatch("Jump_performed")] [HarmonyPrefix] private static bool PrefixJump() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } [HarmonyPatch("PlayerJump")] [HarmonyPrefix] private static bool PrefixPlayerJump() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } [HarmonyPatch("Crouch_performed")] [HarmonyPrefix] private static bool PrefixCrouch() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } [HarmonyPatch("ActivateItem_performed")] [HarmonyPrefix] private static bool PrefixActivateItem() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } [HarmonyPatch("ItemSecondaryUse_performed")] [HarmonyPrefix] private static bool PrefixItemSecondary() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } [HarmonyPatch("ScrollMouse_performed")] [HarmonyPrefix] private static bool PrefixScroll() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } [HarmonyPatch("Interact_performed")] [HarmonyPrefix] private static bool PrefixInteract() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } [HarmonyPatch("InspectItem_performed")] [HarmonyPrefix] private static bool PrefixInspect() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } [HarmonyPatch("Discard_performed")] [HarmonyPrefix] private static bool PrefixDiscard() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } [HarmonyPatch("Emote1_performed")] [HarmonyPrefix] private static bool PrefixEmote1() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } [HarmonyPatch("Emote2_performed")] [HarmonyPrefix] private static bool PrefixEmote2() { if ((Object)(object)ChameleonManager.Instance != (Object)null && ChameleonManager.Instance.Active) { return false; } return true; } } public class RemotePaint { private struct MatSlot { public Renderer Renderer; public int Index; public Material Original; } public readonly ulong ClientId; private PlayerControllerB player; private SkinnedMeshRenderer smr; private Material originalMat; private Material paintMat; private readonly List slots = new List(); private Texture2D albedo; private Texture2D mask; private Color32[] albedoPx; private Color32[] maskPx; private Color32[] baseMaskPx; private int size; private byte[] planes; private int planeSize; private GameObject boundDeadBody; public bool HasPaint => planes != null; private void BindDeadBody(PlayerControllerB p) { boundDeadBody = ((Component)p.deadBody).gameObject; int count = slots.Count; Renderer[] componentsInChildren = ((Component)p.deadBody).GetComponentsInChildren(true); foreach (Renderer r in componentsInChildren) { CollectSlots(r); } if (slots.Count != count) { ApplyMaterial(); } } public RemotePaint(ulong clientId) { ClientId = clientId; } private bool Rebind(PlayerControllerB p) { Release(restore: true); player = p; smr = null; List list = new List(); GameObject val = FindReplacementModel(p); if ((Object)(object)val != (Object)null) { SkinnedMeshRenderer val2 = null; SkinnedMeshRenderer[] componentsInChildren = val.GetComponentsInChildren(true); foreach (SkinnedMeshRenderer val3 in componentsInChildren) { if (!((Object)(object)val3.sharedMesh == (Object)null) && ((Object)(object)val2 == (Object)null || val3.sharedMesh.vertexCount > val2.sharedMesh.vertexCount)) { val2 = val3; } } if ((Object)(object)val2 != (Object)null) { smr = val2; list.AddRange(val.GetComponentsInChildren(true)); } } if ((Object)(object)smr == (Object)null) { smr = p.thisPlayerModel; if ((Object)(object)smr != (Object)null) { list.Add((Renderer)(object)smr); } if ((Object)(object)p.thisPlayerModelLOD1 != (Object)null) { list.Add((Renderer)(object)p.thisPlayerModelLOD1); } if ((Object)(object)p.thisPlayerModelLOD2 != (Object)null) { list.Add((Renderer)(object)p.thisPlayerModelLOD2); } } if ((Object)(object)smr == (Object)null) { return false; } originalMat = ((Renderer)smr).sharedMaterial; if ((Object)(object)originalMat == (Object)null) { return false; } if ((Object)(object)p.deadBody != (Object)null) { list.AddRange(((Component)p.deadBody).GetComponentsInChildren(true)); boundDeadBody = ((Component)p.deadBody).gameObject; } slots.Clear(); foreach (Renderer item in list) { CollectSlots(item); } if (slots.Count == 0) { return false; } size = 0; baseMaskPx = null; return true; } private static GameObject FindReplacementModel(PlayerControllerB p) { try { MonoBehaviour[] components = ((Component)p).GetComponents(); foreach (MonoBehaviour val in components) { if ((Object)(object)val == (Object)null) { continue; } bool flag = false; Type type = ((object)val).GetType(); while (type != null) { if (type.Name == "BodyReplacementBase") { flag = true; break; } type = type.BaseType; } if (flag) { FieldInfo field = ((object)val).GetType().GetField("replacementModel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); GameObject val2 = (GameObject)((field != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val2 != (Object)null) { return val2; } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[MC net] Model replacement lookup failed for " + p?.playerUsername + ": " + ex.Message)); } return null; } private void CollectSlots(Renderer r) { if ((Object)(object)r == (Object)null || ((Component)r).gameObject.layer == 19 || ((Object)((Component)r).gameObject).name.IndexOf("Imperium", StringComparison.OrdinalIgnoreCase) >= 0) { return; } Material[] sharedMaterials = r.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { if (!IsSuitMaterial(sharedMaterials[i])) { continue; } bool flag = false; foreach (MatSlot slot in slots) { if ((Object)(object)slot.Renderer == (Object)(object)r && slot.Index == i) { flag = true; break; } } if (!flag) { slots.Add(new MatSlot { Renderer = r, Index = i, Original = sharedMaterials[i] }); } } } private bool IsSuitMaterial(Material m) { if ((Object)(object)m == (Object)null || (Object)(object)originalMat == (Object)null) { return false; } if ((Object)(object)m == (Object)(object)originalMat || (Object)(object)m == (Object)(object)paintMat) { return true; } if ((Object)(object)m.shader != (Object)(object)originalMat.shader) { return false; } Texture val = GetTex(m, "_BaseColorMap") ?? GetTex(m, "_MainTex"); Texture val2 = GetTex(originalMat, "_BaseColorMap") ?? GetTex(originalMat, "_MainTex"); if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)val2) { return true; } return StripInstance(((Object)m).name) == StripInstance(((Object)originalMat).name); } private static Texture GetTex(Material m, string prop) { return ((Object)(object)m != (Object)null && m.HasProperty(prop)) ? m.GetTexture(prop) : null; } private static string StripInstance(string name) { if (string.IsNullOrEmpty(name)) { return name; } int num = name.IndexOf(" (Instance)", StringComparison.Ordinal); return (num >= 0) ? name.Substring(0, num) : name; } public void Apply(PlayerControllerB p, byte[] newPlanes, int newSize) { if (!((Object)(object)p == (Object)null) && newPlanes != null && newSize > 0) { planes = newPlanes; planeSize = newSize; if ((!((Object)(object)player != (Object)(object)p) && !((Object)(object)smr == (Object)null) && !((Object)(object)originalMat == (Object)null)) || Rebind(p)) { Refresh(); } } } private void Refresh() { //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_008d: 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_00a2: Expected O, but got Unknown //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_00c3: 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_00d8: Expected O, but got Unknown if (planes != null && !((Object)(object)smr == (Object)null) && !((Object)(object)originalMat == (Object)null)) { if ((Object)(object)albedo == (Object)null || size != planeSize) { DestroyTextures(); size = planeSize; albedo = new Texture2D(size, size, (TextureFormat)4, false, false) { name = "MechaChameleonRemote_BaseColor", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; mask = new Texture2D(size, size, (TextureFormat)4, false, true) { name = "MechaChameleonRemote_Mask", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; albedoPx = (Color32[])(object)new Color32[size * size]; maskPx = (Color32[])(object)new Color32[size * size]; } if (baseMaskPx == null) { baseMaskPx = BakeBaseMask(); } PaintCodec.ExpandInto(planes, size, albedoPx, maskPx, baseMaskPx); albedo.SetPixels32(albedoPx); albedo.Apply(false); mask.SetPixels32(maskPx); mask.Apply(false); BuildMaterial(); ApplyMaterial(); } } private Color32[] BakeBaseMask() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) Texture tex = GetTex(originalMat, "_MaskMap"); if ((Object)(object)tex == (Object)null) { return null; } RenderTexture temporary = RenderTexture.GetTemporary(size, size, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)1); RenderTexture active = RenderTexture.active; Texture2D val = null; try { Graphics.Blit(tex, temporary); RenderTexture.active = temporary; val = new Texture2D(size, size, (TextureFormat)4, false, true); val.ReadPixels(new Rect(0f, 0f, (float)size, (float)size), 0, 0); val.Apply(false); return val.GetPixels32(); } catch (Exception ex) { Plugin.Log.LogWarning((object)$"[MC net] Base mask bake failed for client {ClientId}: {ex.Message}"); return null; } finally { RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } private void BuildMaterial() { //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_003e: Expected O, but got Unknown //IL_00b3: 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) if ((Object)(object)paintMat == (Object)null) { paintMat = new Material(originalMat) { name = $"MechaChameleonRemote_{ClientId}" }; } if (paintMat.HasProperty("_BaseColorMap")) { paintMat.SetTexture("_BaseColorMap", (Texture)(object)albedo); } if (paintMat.HasProperty("_MainTex")) { paintMat.SetTexture("_MainTex", (Texture)(object)albedo); } if (paintMat.HasProperty("_BaseColor")) { paintMat.SetColor("_BaseColor", Color.white); } if (paintMat.HasProperty("_Color")) { paintMat.SetColor("_Color", Color.white); } if (paintMat.HasProperty("_MaskMap")) { paintMat.SetTexture("_MaskMap", (Texture)(object)mask); paintMat.EnableKeyword("_MASKMAP"); if (paintMat.HasProperty("_MetallicRemapMin")) { paintMat.SetFloat("_MetallicRemapMin", 0f); } if (paintMat.HasProperty("_MetallicRemapMax")) { paintMat.SetFloat("_MetallicRemapMax", 1f); } if (paintMat.HasProperty("_SmoothnessRemapMin")) { paintMat.SetFloat("_SmoothnessRemapMin", 0f); } if (paintMat.HasProperty("_SmoothnessRemapMax")) { paintMat.SetFloat("_SmoothnessRemapMax", 1f); } if (paintMat.HasProperty("_AORemapMin")) { paintMat.SetFloat("_AORemapMin", 0f); } if (paintMat.HasProperty("_AORemapMax")) { paintMat.SetFloat("_AORemapMax", 1f); } } } private void ApplyMaterial() { for (int i = 0; i < slots.Count; i++) { Renderer renderer = slots[i].Renderer; if (!((Object)(object)renderer == (Object)null)) { Material[] sharedMaterials = renderer.sharedMaterials; if (slots[i].Index < sharedMaterials.Length && !((Object)(object)sharedMaterials[slots[i].Index] == (Object)(object)paintMat)) { sharedMaterials[slots[i].Index] = paintMat; renderer.sharedMaterials = sharedMaterials; } } } } public void Tick(PlayerControllerB p) { if ((Object)(object)p == (Object)null || planes == null) { return; } if ((Object)(object)player != (Object)(object)p || (Object)(object)smr == (Object)null) { if (Rebind(p)) { Refresh(); } return; } Material sharedMaterial = ((Renderer)smr).sharedMaterial; if ((Object)(object)sharedMaterial == (Object)(object)paintMat) { if ((Object)(object)p.deadBody != (Object)null && ((Component)p.deadBody).gameObject != boundDeadBody) { BindDeadBody(p); } } else if (Rebind(p)) { Refresh(); } } private void DestroyTextures() { if ((Object)(object)albedo != (Object)null) { Object.Destroy((Object)(object)albedo); } if ((Object)(object)mask != (Object)null) { Object.Destroy((Object)(object)mask); } albedo = null; mask = null; albedoPx = null; maskPx = null; } private void Release(bool restore) { if (restore) { for (int i = 0; i < slots.Count; i++) { Renderer renderer = slots[i].Renderer; if (!((Object)(object)renderer == (Object)null) && !((Object)(object)slots[i].Original == (Object)null)) { Material[] sharedMaterials = renderer.sharedMaterials; if (slots[i].Index < sharedMaterials.Length && !((Object)(object)sharedMaterials[slots[i].Index] != (Object)(object)paintMat)) { sharedMaterials[slots[i].Index] = slots[i].Original; renderer.sharedMaterials = sharedMaterials; } } } } slots.Clear(); if ((Object)(object)paintMat != (Object)null) { Object.Destroy((Object)(object)paintMat); paintMat = null; } DestroyTextures(); baseMaskPx = null; boundDeadBody = null; size = 0; } public void Dispose() { try { Release(restore: true); } catch { } planes = null; player = null; smr = null; originalMat = null; } } public sealed class SuitPreset { public string Id; public string Dir; public string Name; public DateTime Saved; public int TextureSize; public float Metallic; public float Roughness; public Color[] Palette = (Color[])(object)new Color[0]; private Texture2D thumb; private bool thumbTried; public string AlbedoPath => Path.Combine(Dir, "albedo.png"); public string MaskPath => Path.Combine(Dir, "mask.png"); public string ThumbPath => Path.Combine(Dir, "thumb.png"); public string InfoPath => Path.Combine(Dir, "preset.cfg"); public Texture2D Thumb => thumb; public bool ThumbPending => !thumbTried; public void LoadThumb() { //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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (thumbTried) { return; } thumbTried = true; try { if (File.Exists(ThumbPath)) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; if (ImageConversion.LoadImage(val, File.ReadAllBytes(ThumbPath))) { thumb = val; } else { Object.Destroy((Object)(object)val); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Presets] Thumbnail for '" + Name + "' failed to load: " + ex.Message)); } } public void AdoptThumb(Texture2D tex) { if ((Object)(object)thumb != (Object)null && (Object)(object)thumb != (Object)(object)tex) { Object.Destroy((Object)(object)thumb); } thumb = tex; thumbTried = true; } public void DropThumb() { if ((Object)(object)thumb != (Object)null) { Object.Destroy((Object)(object)thumb); } thumb = null; thumbTried = false; } } public static class SuitPresets { private static readonly List presets = new List(); private static bool scanned; public static string Root => Path.Combine(Plugin.SaveDir, "presets"); public static IList All { get { if (!scanned) { Refresh(); } return presets; } } public static int Count => All.Count; public static void Refresh() { scanned = true; Dictionary dictionary = new Dictionary(); foreach (SuitPreset preset in presets) { if (preset.Id != null) { dictionary[preset.Id] = preset; } } presets.Clear(); int num = 0; try { if (Directory.Exists(Root)) { string[] directories = Directory.GetDirectories(Root); foreach (string text in directories) { num++; string fileName = Path.GetFileName(text); if (File.Exists(Path.Combine(text, "albedo.png"))) { if (dictionary.TryGetValue(fileName, out var value)) { ReadInfo(value); presets.Add(value); continue; } SuitPreset suitPreset = new SuitPreset { Id = fileName, Dir = text, Name = fileName, Saved = Directory.GetLastWriteTime(text) }; ReadInfo(suitPreset); presets.Add(suitPreset); } } } } catch (Exception ex) { Plugin.Log.LogError((object)("[Presets] Scanning " + Root + " failed: " + ex.Message)); } Plugin.Log.LogInfo((object)("[Presets] Scanned " + Root + " - " + num + " folders, " + presets.Count + " loaded.")); presets.Sort((SuitPreset a, SuitPreset b) => b.Saved.CompareTo(a.Saved)); foreach (KeyValuePair item in dictionary) { if (!presets.Contains(item.Value)) { item.Value.DropThumb(); } } } public static SuitPreset Save(string name, Color32[] albedo, Color32[] mask, int size, Texture2D thumb) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown if (albedo == null || mask == null || size <= 0) { return null; } name = CleanName(name); string text = DateTime.Now.ToString("yyyyMMdd-HHmmss", CultureInfo.InvariantCulture) + "-" + Slug(name); string text2 = Path.Combine(Root, text); int num = 2; while (Directory.Exists(text2) && num < 100) { text = DateTime.Now.ToString("yyyyMMdd-HHmmss", CultureInfo.InvariantCulture) + "-" + Slug(name) + "-" + num; text2 = Path.Combine(Root, text); num++; } Texture2D val = null; try { Directory.CreateDirectory(text2); val = new Texture2D(size, size, (TextureFormat)4, false) { hideFlags = (HideFlags)61 }; val.SetPixels32(albedo); val.Apply(false); File.WriteAllBytes(Path.Combine(text2, "albedo.png"), ImageConversion.EncodeToPNG(val)); val.SetPixels32(mask); val.Apply(false); File.WriteAllBytes(Path.Combine(text2, "mask.png"), ImageConversion.EncodeToPNG(val)); SuitPreset suitPreset = new SuitPreset { Id = text, Dir = text2, Name = name, Saved = DateTime.Now, TextureSize = size, Palette = ExtractPalette(albedo, size, 5) }; AverageFinish(mask, out suitPreset.Metallic, out var smoothness); suitPreset.Roughness = 1f - smoothness; if ((Object)(object)thumb != (Object)null) { File.WriteAllBytes(Path.Combine(text2, "thumb.png"), ImageConversion.EncodeToPNG(thumb)); suitPreset.AdoptThumb(thumb); } WriteInfo(suitPreset); if (!scanned) { Refresh(); } else { presets.Insert(0, suitPreset); } Plugin.Log.LogInfo((object)("[Presets] Saved '" + name + "' to " + text2)); return suitPreset; } catch (Exception ex) { Plugin.Log.LogError((object)("[Presets] Saving '" + name + "' failed: " + ex.Message)); return null; } finally { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } public static bool TryRead(SuitPreset p, out Color32[] albedo, out Color32[] mask, out int size) { albedo = null; mask = null; size = 0; if (p == null) { return false; } try { if (!TryDecode(p.AlbedoPath, out albedo, out size)) { return false; } if (!TryDecode(p.MaskPath, out mask, out var size2) || size2 != size) { mask = null; } return true; } catch (Exception ex) { Plugin.Log.LogError((object)("[Presets] Reading '" + p.Name + "' failed: " + ex.Message)); return false; } } private static bool TryDecode(string path, out Color32[] pixels, out int size) { //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_002b: Expected O, but got Unknown pixels = null; size = 0; if (!File.Exists(path)) { return false; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { hideFlags = (HideFlags)61 }; try { if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path))) { return false; } if (((Texture)val).width != ((Texture)val).height) { return false; } pixels = val.GetPixels32(); size = ((Texture)val).width; return true; } finally { Object.Destroy((Object)(object)val); } } public static void Rename(SuitPreset p, string name) { if (p != null) { p.Name = CleanName(name); WriteInfo(p); } } public static bool Delete(SuitPreset p) { if (p == null) { return false; } try { p.DropThumb(); if (Directory.Exists(p.Dir)) { Directory.Delete(p.Dir, recursive: true); } presets.Remove(p); Plugin.Log.LogInfo((object)("[Presets] Deleted '" + p.Name + "'")); return true; } catch (Exception ex) { Plugin.Log.LogError((object)("[Presets] Deleting '" + p.Name + "' failed: " + ex.Message)); return false; } } public static void DropThumbnails() { foreach (SuitPreset preset in presets) { preset.DropThumb(); } } public static string SuggestName() { HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (SuitPreset item in All) { hashSet.Add(item.Name); } for (int i = 1; i < 1000; i++) { string text = "Suit " + i.ToString("00", CultureInfo.InvariantCulture); if (!hashSet.Contains(text)) { return text; } } return "Suit"; } private static void WriteInfo(SuitPreset p) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) try { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("name=" + p.Name); stringBuilder.AppendLine("saved=" + p.Saved.ToString("o", CultureInfo.InvariantCulture)); stringBuilder.AppendLine("size=" + p.TextureSize.ToString(CultureInfo.InvariantCulture)); stringBuilder.AppendLine("metallic=" + p.Metallic.ToString("0.000", CultureInfo.InvariantCulture)); stringBuilder.AppendLine("roughness=" + p.Roughness.ToString("0.000", CultureInfo.InvariantCulture)); List list = new List(); Color[] palette = p.Palette; foreach (Color val in palette) { list.Add(ColorUtility.ToHtmlStringRGB(val)); } stringBuilder.AppendLine("palette=" + string.Join(",", list.ToArray())); File.WriteAllText(p.InfoPath, stringBuilder.ToString()); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Presets] Writing metadata for '" + p.Name + "' failed: " + ex.Message)); } } private static void ReadInfo(SuitPreset p) { try { if (!File.Exists(p.InfoPath)) { return; } string[] array = File.ReadAllLines(p.InfoPath); foreach (string text in array) { int num = text.IndexOf('='); if (num <= 0) { continue; } string text2 = text.Substring(0, num).Trim().ToLowerInvariant(); string text3 = text.Substring(num + 1).Trim(); switch (text2) { case "name": if (text3.Length > 0) { p.Name = text3; } break; case "saved": { if (DateTime.TryParse(text3, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out var result3)) { p.Saved = result3; } break; } case "size": { if (int.TryParse(text3, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result4)) { p.TextureSize = result4; } break; } case "metallic": { if (float.TryParse(text3, NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { p.Metallic = result2; } break; } case "roughness": { if (float.TryParse(text3, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { p.Roughness = result; } break; } case "palette": p.Palette = ParsePalette(text3); break; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Presets] Reading metadata for '" + p.Id + "' failed: " + ex.Message)); } } private static Color[] ParsePalette(string val) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) List list = new List(); string[] array = val.Split(','); Color item = default(Color); foreach (string text in array) { string text2 = text.Trim(); if (text2.Length != 0) { if (text2[0] != '#') { text2 = "#" + text2; } if (ColorUtility.TryParseHtmlString(text2, ref item)) { list.Add(item); } } } return list.ToArray(); } public static Color[] ExtractPalette(Color32[] albedo, int size, int want) { //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) //IL_004a: 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_0061: 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_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_00a5: 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_013b: 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_0152: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: 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_0190: 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_019a: 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_01ae: 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_01c3: 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) Dictionary dictionary = new Dictionary(512); Dictionary dictionary2 = new Dictionary(512); int num = Mathf.Max(1, size / 200); for (int i = 0; i < size; i += num) { int num2 = i * size; for (int j = 0; j < size; j += num) { Color32 val = albedo[num2 + j]; int key = (val.r >> 4 << 8) | (val.g >> 4 << 4) | (val.b >> 4); dictionary.TryGetValue(key, out var value); dictionary[key] = value + 1; dictionary2.TryGetValue(key, out var value2); dictionary2[key] = value2 + new Vector3((float)(int)val.r, (float)(int)val.g, (float)(int)val.b); } } List> list = new List>(dictionary); list.Sort((KeyValuePair a, KeyValuePair b) => b.Value.CompareTo(a.Value)); List list2 = new List(); Color val3 = default(Color); foreach (KeyValuePair item in list) { Vector3 val2 = dictionary2[item.Key] / (float)item.Value / 255f; ((Color)(ref val3))..ctor(val2.x, val2.y, val2.z, 1f); bool flag = false; foreach (Color item2 in list2) { if (Mathf.Abs(item2.r - val3.r) + Mathf.Abs(item2.g - val3.g) + Mathf.Abs(item2.b - val3.b) < 0.14f) { flag = true; break; } } if (!flag) { list2.Add(val3); if (list2.Count >= want) { break; } } } return list2.ToArray(); } private static void AverageFinish(Color32[] mask, out float metallic, out float smoothness) { long num = 0L; long num2 = 0L; long num3 = 0L; int num4 = Mathf.Max(1, mask.Length / 40000); for (int i = 0; i < mask.Length; i += num4) { num += mask[i].r; num2 += mask[i].a; num3++; } metallic = ((num3 > 0) ? ((float)num / (float)num3 / 255f) : 0f); smoothness = ((num3 > 0) ? ((float)num2 / (float)num3 / 255f) : 0f); } private static string CleanName(string name) { if (string.IsNullOrEmpty(name)) { return "Untitled"; } name = name.Trim(); if (name.Length == 0) { return "Untitled"; } return (name.Length > 28) ? name.Substring(0, 28) : name; } private static string Slug(string name) { StringBuilder stringBuilder = new StringBuilder(name.Length); foreach (char c in name) { if (char.IsLetterOrDigit(c)) { stringBuilder.Append(char.ToLowerInvariant(c)); } else if ((c == ' ' || c == '-' || c == '_') && stringBuilder.Length > 0 && stringBuilder[stringBuilder.Length - 1] != '-') { stringBuilder.Append('-'); } } string text = stringBuilder.ToString().Trim('-'); if (text.Length == 0) { text = "suit"; } return (text.Length > 24) ? text.Substring(0, 24) : text; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "MechaChameleon"; public const string PLUGIN_NAME = "MechaChameleon"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }