using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BingBongColorPlugin")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BingBongColorPlugin")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("da5dbf83-9020-49bf-9014-5a6f5e0adf15")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("peak.bingbong.modelswap", "BingBong Model Swap", "1.1.5")] public class BingBongSwapPlugin : BaseUnityPlugin { private class BingBongSwapMarker : MonoBehaviour { } private static GameObject _replacementPrefab; private MaterialPropertyBlock _mpb; private ConfigEntry ScaleMul; private ConfigEntry OffsetX; private ConfigEntry OffsetY; private ConfigEntry OffsetZ; private ConfigEntry StepPos; private ConfigEntry StepScale; private ConfigEntry ExtraRotX; private ConfigEntry ExtraRotY; private ConfigEntry ExtraRotZ; private ConfigEntry Flip180Enabled; private ConfigEntry HotkeyLeft; private ConfigEntry HotkeyRight; private ConfigEntry HotkeyUp; private ConfigEntry HotkeyDown; private ConfigEntry HotkeyForward; private ConfigEntry HotkeyBack; private ConfigEntry HotkeyScaleUp; private ConfigEntry HotkeyScaleDown; private ConfigEntry HotkeyToggleFlip; private ConfigEntry DisableOriginalTextures; private ConfigEntry ForceAllShaderColors; private ConfigEntry GlobalTint; private ConfigEntry ColBody; private ConfigEntry ColHat; private ConfigEntry ColAccent; private ConfigEntry ColEyes; private ConfigEntry ColPupils; private ConfigEntry ColMonocle; private Texture2D _whiteTex; private Texture2D _blackTex; private Texture2D _flatNormalTex; private string _cfgPath; private DateTime _cfgStampUtc; private ConfigEntry DumpShaderPropsOnce; private readonly HashSet _dumpedShaders = new HashSet(StringComparer.OrdinalIgnoreCase); private bool _baseCaptured; private Vector3 _baseLocalPos; private Quaternion _baseLocalRot; private Vector3 _baseLocalScale; private Texture2D WhiteTex => _whiteTex ?? (_whiteTex = Make1x1(new Color(1f, 1f, 1f, 1f))); private Texture2D BlackTex => _blackTex ?? (_blackTex = Make1x1(new Color(0f, 0f, 0f, 1f))); private Texture2D FlatNormalTex => _flatNormalTex ?? (_flatNormalTex = Make1x1(new Color(0.5f, 0.5f, 1f, 1f))); private void Awake() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_01ab: 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_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) _mpb = new MaterialPropertyBlock(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ScaleMul = ((BaseUnityPlugin)this).Config.Bind("Tuning", "ScaleMul", 30f, "Scale multiplier relative to original Bing Bong visual scale."); OffsetX = ((BaseUnityPlugin)this).Config.Bind("Tuning", "OffsetX", -0.19f, "Local X offset (left/right). Negative = left."); OffsetY = ((BaseUnityPlugin)this).Config.Bind("Tuning", "OffsetY", -0.15f, "Local Y offset (up/down)."); OffsetZ = ((BaseUnityPlugin)this).Config.Bind("Tuning", "OffsetZ", 0.06f, "Local Z offset (forward/back)."); StepPos = ((BaseUnityPlugin)this).Config.Bind("Tuning", "StepPos", 0.01f, "Hotkey step for offsets."); StepScale = ((BaseUnityPlugin)this).Config.Bind("Tuning", "StepScale", 1f, "Hotkey step for scale."); Flip180Enabled = ((BaseUnityPlugin)this).Config.Bind("Tuning", "Flip180Enabled", false, "If true, applies 180° Y rotation (face away)."); ExtraRotX = ((BaseUnityPlugin)this).Config.Bind("Tuning", "ExtraRotX", 0f, "Extra local rotation X (degrees)."); ExtraRotY = ((BaseUnityPlugin)this).Config.Bind("Tuning", "ExtraRotY", 180f, "Extra local rotation Y (degrees)."); ExtraRotZ = ((BaseUnityPlugin)this).Config.Bind("Tuning", "ExtraRotZ", 0f, "Extra local rotation Z (degrees)."); HotkeyLeft = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "MoveLeft", new KeyboardShortcut((KeyCode)276, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), "OffsetX -= StepPos"); HotkeyRight = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "MoveRight", new KeyboardShortcut((KeyCode)275, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), "OffsetX += StepPos"); HotkeyUp = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "MoveUp", new KeyboardShortcut((KeyCode)273, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), "OffsetY += StepPos"); HotkeyDown = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "MoveDown", new KeyboardShortcut((KeyCode)274, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), "OffsetY -= StepPos"); HotkeyForward = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "MoveForward", new KeyboardShortcut((KeyCode)280, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), "OffsetZ += StepPos"); HotkeyBack = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "MoveBack", new KeyboardShortcut((KeyCode)281, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), "OffsetZ -= StepPos"); HotkeyScaleUp = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "ScaleUp", new KeyboardShortcut((KeyCode)61, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), "ScaleMul += StepScale"); HotkeyScaleDown = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "ScaleDown", new KeyboardShortcut((KeyCode)45, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), "ScaleMul -= StepScale"); HotkeyToggleFlip = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "ToggleFlip180", new KeyboardShortcut((KeyCode)114, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), "Toggles Flip180Enabled on/off (useful for testing)."); DisableOriginalTextures = ((BaseUnityPlugin)this).Config.Bind("Colors", "DisableOriginalTextures", true, "If true, overrides original material textures with 1x1 dummy textures so only clean colors remain."); ForceAllShaderColors = ((BaseUnityPlugin)this).Config.Bind("Colors", "ForceAllShaderColors", true, "If true, sets ALL shader Color properties via MaterialPropertyBlock (most reliable)."); GlobalTint = ((BaseUnityPlugin)this).Config.Bind("Colors", "GlobalTint", "", "Optional. If set, applies this tint to ALL parts. Example: #FF0000 or 1,0,0,1"); ColBody = ((BaseUnityPlugin)this).Config.Bind("Colors", "Body", "#9c2e2eff", "Body color (Sphere001, Sphere003-010, Tube003)"); ColHat = ((BaseUnityPlugin)this).Config.Bind("Colors", "Hat", "#4B2E83", "Hat color (Cylinder001-002)"); ColAccent = ((BaseUnityPlugin)this).Config.Bind("Colors", "Accent", "#583b9291", "Accent color (bow, hat band, tail tips)"); ColEyes = ((BaseUnityPlugin)this).Config.Bind("Colors", "Eyes", "#FFFFFF", "Eye white color (GeoSphere001-002)"); ColPupils = ((BaseUnityPlugin)this).Config.Bind("Colors", "Pupils", "#000000", "Pupil color (GeoSphere003-004)"); ColMonocle = ((BaseUnityPlugin)this).Config.Bind("Colors", "Monocle", "#C8B44A", "Monocle color (Tube002)"); DumpShaderPropsOnce = ((BaseUnityPlugin)this).Config.Bind("Debug", "DumpShaderPropsOnce", false, "If true, dumps shader properties once per shader to BepInEx log."); _cfgPath = ((BaseUnityPlugin)this).Config.ConfigFilePath; TryUpdateCfgStamp(); LoadBundle(); SceneManager.sceneLoaded += OnSceneLoaded; ((MonoBehaviour)this).StartCoroutine(ScanLoop()); ((MonoBehaviour)this).StartCoroutine(ConfigWatchLoop()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BingBongSwap 1.1.5 loaded (base-transform lock for consistent positioning)."); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { ((MonoBehaviour)this).StartCoroutine(DelayedRescanAfterSceneLoad()); } private IEnumerator DelayedRescanAfterSceneLoad() { yield return null; yield return null; yield return (object)new WaitForSeconds(0.5f); try { FindAndApplyOrUpdate(); } catch (Exception ex) { Exception e = ex; ((BaseUnityPlugin)this).Logger.LogError((object)e); } yield return (object)new WaitForSeconds(0.5f); try { FindAndApplyOrUpdate(); } catch (Exception ex) { Exception e2 = ex; ((BaseUnityPlugin)this).Logger.LogError((object)e2); } } private void Update() { //IL_0021: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_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_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) bool flag = false; float value = StepPos.Value; float value2 = StepScale.Value; KeyboardShortcut value3 = HotkeyToggleFlip.Value; if (((KeyboardShortcut)(ref value3)).IsDown()) { Flip180Enabled.Value = !Flip180Enabled.Value; ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Flip180Enabled=" + Flip180Enabled.Value)); flag = true; } value3 = HotkeyLeft.Value; if (((KeyboardShortcut)(ref value3)).IsDown()) { ConfigEntry offsetX = OffsetX; offsetX.Value -= value; flag = true; } value3 = HotkeyRight.Value; if (((KeyboardShortcut)(ref value3)).IsDown()) { ConfigEntry offsetX2 = OffsetX; offsetX2.Value += value; flag = true; } value3 = HotkeyUp.Value; if (((KeyboardShortcut)(ref value3)).IsDown()) { ConfigEntry offsetY = OffsetY; offsetY.Value += value; flag = true; } value3 = HotkeyDown.Value; if (((KeyboardShortcut)(ref value3)).IsDown()) { ConfigEntry offsetY2 = OffsetY; offsetY2.Value -= value; flag = true; } value3 = HotkeyForward.Value; if (((KeyboardShortcut)(ref value3)).IsDown()) { ConfigEntry offsetZ = OffsetZ; offsetZ.Value += value; flag = true; } value3 = HotkeyBack.Value; if (((KeyboardShortcut)(ref value3)).IsDown()) { ConfigEntry offsetZ2 = OffsetZ; offsetZ2.Value -= value; flag = true; } value3 = HotkeyScaleUp.Value; if (((KeyboardShortcut)(ref value3)).IsDown()) { ConfigEntry scaleMul = ScaleMul; scaleMul.Value += value2; flag = true; } value3 = HotkeyScaleDown.Value; if (((KeyboardShortcut)(ref value3)).IsDown()) { ScaleMul.Value = Mathf.Max(0.1f, ScaleMul.Value - value2); flag = true; } if (flag) { ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format(CultureInfo.InvariantCulture, "Tuning: ScaleMul={0:0.###} Off=({1:0.###},{2:0.###},{3:0.###}) RotExtra=({4:0.###},{5:0.###},{6:0.###}) Flip={7}", ScaleMul.Value, OffsetX.Value, OffsetY.Value, OffsetZ.Value, ExtraRotX.Value, ExtraRotY.Value, ExtraRotZ.Value, Flip180Enabled.Value)); try { FindAndApplyOrUpdate(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } } private IEnumerator ConfigWatchLoop() { while (true) { try { if (File.Exists(_cfgPath)) { DateTime t = File.GetLastWriteTimeUtc(_cfgPath); if (t != _cfgStampUtc) { _cfgStampUtc = t; ((BaseUnityPlugin)this).Config.Reload(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Config reloaded (file changed)."); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Config watch failed: " + ex)); } yield return (object)new WaitForSeconds(0.5f); } } private void TryUpdateCfgStamp() { try { if (File.Exists(_cfgPath)) { _cfgStampUtc = File.GetLastWriteTimeUtc(_cfgPath); } } catch { } } private void LoadBundle() { string path = Path.Combine(Paths.PluginPath, "BingBongSwap"); string text = Path.Combine(path, "bingbongbundle"); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogError((object)("AssetBundle not found: " + text)); return; } AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load AssetBundle (Unity version mismatch or corrupted file)."); return; } _replacementPrefab = val.LoadAsset("Assets/Prefabs/BingBongReplacement.prefab"); if ((Object)(object)_replacementPrefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Prefab not found in bundle: Assets/Prefabs/BingBongReplacement.prefab"); } else { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Replacement prefab loaded successfully."); } } private IEnumerator ScanLoop() { while (true) { try { FindAndApplyOrUpdate(); } catch (Exception ex) { Exception e = ex; ((BaseUnityPlugin)this).Logger.LogError((object)e); } yield return (object)new WaitForSeconds(0.5f); } } private void FindAndApplyOrUpdate() { if ((Object)(object)_replacementPrefab == (Object)null) { return; } Transform[] array = Object.FindObjectsOfType(); foreach (Transform val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.parent != (Object)null)) { Transform val2 = val.Find("Holder/Bing Bong Plush") ?? val.Find("Bing Bong Plush"); if (!((Object)(object)val2 == (Object)null)) { ApplyOrUpdateSwap(((Component)val).gameObject); } } } } private void ApplyOrUpdateSwap(GameObject root) { //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_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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: 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_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_02df: 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) Transform val = root.transform.Find("Holder/Bing Bong Plush") ?? root.transform.Find("Bing Bong Plush"); if ((Object)(object)val == (Object)null) { return; } if (!_baseCaptured) { _baseLocalPos = val.localPosition; _baseLocalRot = val.localRotation; _baseLocalScale = val.localScale; _baseCaptured = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format(CultureInfo.InvariantCulture, "Captured base transform: Pos({0:0.###},{1:0.###},{2:0.###}) Scale({3:0.###},{4:0.###},{5:0.###})", _baseLocalPos.x, _baseLocalPos.y, _baseLocalPos.z, _baseLocalScale.x, _baseLocalScale.y, _baseLocalScale.z)); } Material[] array = null; Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && val2.sharedMaterials != null && val2.sharedMaterials.Length != 0) { array = val2.sharedMaterials; break; } } if ((Object)(object)root.GetComponent() == (Object)null) { root.AddComponent(); for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j] != (Object)null) { componentsInChildren[j].enabled = false; } } } Transform val3 = root.transform.Find("Holder") ?? root.transform; Transform val4 = val3.Find("BingBong_CustomModel"); GameObject val5; if ((Object)(object)val4 != (Object)null) { val5 = ((Component)val4).gameObject; } else { val5 = Object.Instantiate(_replacementPrefab, val3, false); ((Object)val5).name = "BingBong_CustomModel"; int layer = root.layer; Transform[] componentsInChildren2 = val5.GetComponentsInChildren(true); for (int k = 0; k < componentsInChildren2.Length; k++) { ((Component)componentsInChildren2[k]).gameObject.layer = layer; } Collider[] componentsInChildren3 = val5.GetComponentsInChildren(true); for (int l = 0; l < componentsInChildren3.Length; l++) { Object.Destroy((Object)(object)componentsInChildren3[l]); } } val5.transform.localPosition = _baseLocalPos + new Vector3(OffsetX.Value, OffsetY.Value, OffsetZ.Value); Quaternion val6 = _baseLocalRot; if (Flip180Enabled.Value) { val6 *= Quaternion.Euler(0f, 180f, 0f); } val6 *= Quaternion.Euler(ExtraRotX.Value, ExtraRotY.Value, ExtraRotZ.Value); val5.transform.localRotation = val6; val5.transform.localScale = _baseLocalScale * ScaleMul.Value; Renderer[] componentsInChildren4 = val5.GetComponentsInChildren(true); foreach (Renderer val7 in componentsInChildren4) { if (!((Object)(object)val7 == (Object)null)) { val7.enabled = true; val7.forceRenderingOff = false; if (array != null) { val7.sharedMaterials = array; } } } ApplyColorsAndOptionalTextureKill(val5); } private void ApplyColorsAndOptionalTextureKill(GameObject inst) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00a7: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_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_014f: 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_02b7: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_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_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_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_024b: 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_0264: 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_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0295: 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_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)inst == (Object)null) { return; } Color c; bool flag = TryParseColor(GlobalTint.Value, out c); Color val = ParseOrDefault(ColBody.Value, new Color(0.36f, 0.12f, 0.16f, 1f)); Color val2 = ParseOrDefault(ColHat.Value, new Color(0.05f, 0.05f, 0.05f, 1f)); Color val3 = ParseOrDefault(ColAccent.Value, new Color(0.29f, 0.18f, 0.51f, 1f)); Color val4 = ParseOrDefault(ColEyes.Value, Color.white); Color val5 = ParseOrDefault(ColPupils.Value, Color.black); Color val6 = ParseOrDefault(ColMonocle.Value, new Color(0.78f, 0.7f, 0.29f, 1f)); Renderer[] componentsInChildren = inst.GetComponentsInChildren(true); foreach (Renderer val7 in componentsInChildren) { if (!((Object)(object)val7 == (Object)null)) { string text = ((Object)((Component)val7).gameObject).name ?? ""; Color color = (Color)(flag ? c : ((!(text == "Cylinder001") && !(text == "Cylinder002")) ? ((!(text == "GeoSphere001") && !(text == "GeoSphere002")) ? ((!(text == "GeoSphere003") && !(text == "GeoSphere004")) ? ((text == "GeoSphere005") ? val3 : ((text == "Pyramid001" || text == "Pyramid002") ? val3 : ((text == "Sphere001") ? val : ((text == "Sphere002") ? val3 : (text.StartsWith("Sphere", StringComparison.Ordinal) ? val : (text switch { "Tube001" => val3, "Tube002" => val6, "Tube003" => val, _ => val, })))))) : val5) : val4) : val2)); ApplyColorWithMpb(val7, color); } } } private void ApplyColorWithMpb(Renderer r, Color color) { //IL_003f: 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_0111: 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: Invalid comparison between Unknown and I4 //IL_0134: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Invalid comparison between Unknown and I4 r.GetPropertyBlock(_mpb); Material sharedMaterial = r.sharedMaterial; Shader val = (((Object)(object)sharedMaterial != (Object)null) ? sharedMaterial.shader : null); if ((Object)(object)val == (Object)null) { _mpb.SetColor("_Color", color); r.SetPropertyBlock(_mpb); return; } if (DumpShaderPropsOnce.Value) { DumpShaderOnce(val); } int propertyCount = val.GetPropertyCount(); if (ForceAllShaderColors.Value) { for (int i = 0; i < propertyCount; i++) { if ((int)val.GetPropertyType(i) == 0) { string propertyName = val.GetPropertyName(i); _mpb.SetColor(propertyName, color); } } } else { if (sharedMaterial.HasProperty("_Color")) { _mpb.SetColor("_Color", color); } if (sharedMaterial.HasProperty("_BaseColor")) { _mpb.SetColor("_BaseColor", color); } if (sharedMaterial.HasProperty("_TintColor")) { _mpb.SetColor("_TintColor", color); } } if (DisableOriginalTextures.Value) { Texture2D whiteTex = WhiteTex; Texture2D blackTex = BlackTex; Texture2D flatNormalTex = FlatNormalTex; for (int j = 0; j < propertyCount; j++) { if ((int)val.GetPropertyType(j) == 4) { string propertyName2 = val.GetPropertyName(j); string text = propertyName2.ToLowerInvariant(); if (text.Contains("normal") || text.Contains("bump")) { _mpb.SetTexture(propertyName2, (Texture)(object)flatNormalTex); } else if (text.Contains("metal") || text.Contains("spec") || text.Contains("rough") || text.Contains("mask")) { _mpb.SetTexture(propertyName2, (Texture)(object)blackTex); } else { _mpb.SetTexture(propertyName2, (Texture)(object)whiteTex); } } } if (sharedMaterial.HasProperty("_Metallic")) { _mpb.SetFloat("_Metallic", 0f); } if (sharedMaterial.HasProperty("_Glossiness")) { _mpb.SetFloat("_Glossiness", 0f); } if (sharedMaterial.HasProperty("_Smoothness")) { _mpb.SetFloat("_Smoothness", 0f); } } r.SetPropertyBlock(_mpb); } private Texture2D Make1x1(Color c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, c); val.Apply(false, true); ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)0; ((Object)val).hideFlags = (HideFlags)61; return val; } private unsafe void DumpShaderOnce(Shader sh) { //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) if ((Object)(object)sh == (Object)null) { return; } string text = ((Object)sh).name ?? ""; if (_dumpedShaders.Contains(text)) { return; } _dumpedShaders.Add(text); try { int propertyCount = sh.GetPropertyCount(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("=== Shader dump: " + text + " (props: " + propertyCount + ") ===")); for (int i = 0; i < propertyCount; i++) { ShaderPropertyType propertyType = sh.GetPropertyType(i); string propertyName = sh.GetPropertyName(i); ((BaseUnityPlugin)this).Logger.LogInfo((object)(" " + ((object)(*(ShaderPropertyType*)(&propertyType))/*cast due to .constrained prefix*/).ToString() + " " + propertyName)); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Shader dump failed: " + ex)); } } private Color ParseOrDefault(string s, Color def) { //IL_000f: 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_0010: 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) Color c; return TryParseColor(s, out c) ? c : def; } private bool TryParseColor(string s, out Color c) { //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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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) c = Color.white; if (string.IsNullOrEmpty(s)) { return false; } s = s.Trim(); if (s.StartsWith("#", StringComparison.Ordinal)) { string text = s.Substring(1); if (text.Length == 6 || text.Length == 8) { byte b = byte.Parse(text.Substring(0, 2), NumberStyles.HexNumber); byte b2 = byte.Parse(text.Substring(2, 2), NumberStyles.HexNumber); byte b3 = byte.Parse(text.Substring(4, 2), NumberStyles.HexNumber); byte b4 = byte.MaxValue; if (text.Length == 8) { b4 = byte.Parse(text.Substring(6, 2), NumberStyles.HexNumber); } c = new Color((float)(int)b / 255f, (float)(int)b2 / 255f, (float)(int)b3 / 255f, (float)(int)b4 / 255f); return true; } return false; } string[] array = s.Split(new char[1] { ',' }); if (array.Length == 3 || array.Length == 4) { float num = float.Parse(array[0], CultureInfo.InvariantCulture); float num2 = float.Parse(array[1], CultureInfo.InvariantCulture); float num3 = float.Parse(array[2], CultureInfo.InvariantCulture); float num4 = ((array.Length == 4) ? float.Parse(array[3], CultureInfo.InvariantCulture) : 1f); c = new Color(num, num2, num3, num4); return true; } return false; } }