Decompiled source of BetterLights v0.3.8
BepInEx\plugins\BetterLights\InfernoProtocol.BetterLights.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using FrankMods; using Game.LevelOperations; using Game.PlayerOperations; using Game.UI; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.LowLevel; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("InfernoProtocol.BetterLights")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.8.0")] [assembly: AssemblyInformationalVersion("0.3.8+4a6b9500a1c2da20cf1d8f50aa0fa9e564f4c350")] [assembly: AssemblyProduct("InfernoProtocol.BetterLights")] [assembly: AssemblyTitle("InfernoProtocol.BetterLights")] [assembly: AssemblyVersion("0.3.8.0")] namespace InfernoProtocol.BetterLights; public sealed class BetterLightsController : MonoBehaviour { private static readonly Color[] PresetColors = (Color[])(object)new Color[7] { new Color(1f, 0.43f, 0.12f, 1f), new Color(1f, 0.12f, 0.09f, 1f), new Color(0.12f, 0.95f, 0.32f, 1f), new Color(0.12f, 0.68f, 1f, 1f), new Color(0.48f, 0.2f, 1f, 1f), new Color(1f, 0.28f, 0.78f, 1f), new Color(1f, 1f, 1f, 1f) }; private readonly List<LightTarget> _targets = new List<LightTarget>(); private readonly List<LightTarget> _nearbyTargets = new List<LightTarget>(); private readonly Dictionary<int, LightTarget> _targetsByRoot = new Dictionary<int, LightTarget>(); private readonly Dictionary<Vector2Int, List<LightTarget>> _spatialTargets = new Dictionary<Vector2Int, List<LightTarget>>(); private readonly Dictionary<string, Color> _defaultColors = new Dictionary<string, Color>(StringComparer.Ordinal); private readonly Dictionary<string, Color> _networkColors = new Dictionary<string, Color>(StringComparer.Ordinal); private readonly List<InputActionMap> _disabledMaps = new List<InputActionMap>(); private readonly HashSet<ulong> _compatibleClients = new HashSet<ulong>(); private readonly HashSet<ulong> _pendingSnapshotClients = new HashSet<ulong>(); private const string HelloMessage = "BetterLights.Hello.v1"; private const string ColorMessage = "BetterLights.Color.v1"; private const string AckMessage = "BetterLights.Ack.v1"; private const byte SyncProtocol = 1; private const float SpatialCellSize = 8f; private RectTransform _canvasRect; private RectTransform _promptRoot; private RectTransform _pickerRoot; private CanvasGroup _promptGroup; private CanvasGroup _pickerGroup; private Image _promptPanel; private Image _promptSwatch; private Image _pickerPanel; private Image _selectedSwatch; private RawImage _colorWheel; private RectTransform _selectorOuter; private RectTransform _selectorInner; private Image _saveButton; private Image _originalButton; private Image _cancelButton; private TextMeshProUGUI _promptTitle; private TextMeshProUGUI _promptName; private TextMeshProUGUI _pickerName; private TextMeshProUGUI _hexLabel; private TextMeshProUGUI _detailLabel; private TextMeshProUGUI _hintLabel; private Sprite _circleSprite; private readonly List<Image> _presetDots = new List<Image>(); private LightTarget _target; private string _targetKey; private Color _currentColor; private Color _originalColor; private float _hue; private float _saturation; private float _nextWorldScan; private float _nextNearbyScan; private float _nextTargetScan; private int _lastWorldTargetCount = -1; private int _stableWorldScans; private bool _worldRegistryReady; private bool _built; private bool _open; private bool _resetPending; private bool _mouseMode; private bool _mouseDraggingWheel; private bool _cursorStateCaptured; private bool _cursorWasVisible; private CursorLockMode _cursorLockMode; private int _presetIndex; private int _lastLoggedTargetCount = -1; private float _confirmationUntil; private string _confirmationText; private float _promptAlpha; private NetworkManager _networkManager; private CustomMessagingManager _messaging; private HandleNamedMessageDelegate _helloHandler; private HandleNamedMessageDelegate _colorHandler; private HandleNamedMessageDelegate _ackHandler; private float _nextNetworkCheck; private float _nextHelloAttempt; private bool _syncAcknowledged; private bool _networkFailureReported; private bool _isRemoteClient; public BetterLightsController(IntPtr pointer) : base(pointer) { } private void Update() { if (!_built) { BuildUi(); } if (!BetterLightsPlugin.Enabled.Value) { if (_open) { ClosePicker(restoreOriginal: true); } HideUi(); return; } UpdateNetworkSync(); UpdateLightRegistry(); if (_open) { UpdatePicker(); } else { UpdateTargeting(); } } private void UpdateTargeting() { if (!CanTarget()) { _target = null; SetPromptAlpha(0f); return; } float unscaledTime = Time.unscaledTime; if (unscaledTime >= _nextNearbyScan) { _nextNearbyScan = unscaledTime + 0.45f; RefreshNearbyTargets(); } if (unscaledTime >= _nextTargetScan) { _nextTargetScan = unscaledTime + 0.14f; _target = FindTarget(); RefreshPrompt(); } if (_target == null) { SetPromptAlpha(0f); return; } PositionPrompt(_target); SetPromptAlpha(Mathf.MoveTowards(_promptAlpha, 1f, Time.unscaledDeltaTime * 10f)); if (TryGetActivation(out var mouseMode)) { OpenPicker(mouseMode); } } private void UpdateLightRegistry() { if (!Player.isLocalPlayerLoaded) { return; } float unscaledTime = Time.unscaledTime; if (!_worldRegistryReady && !(unscaledTime < _nextWorldScan)) { _nextWorldScan = unscaledTime + 2f; RefreshTorches(); if (_targets.Count > 0 && _targets.Count == _lastWorldTargetCount) { _stableWorldScans++; } else { _stableWorldScans = 0; } _lastWorldTargetCount = _targets.Count; _worldRegistryReady = _stableWorldScans >= 1; } } private void RefreshTorches() { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown _targets.Clear(); _nearbyTargets.Clear(); _targetsByRoot.Clear(); _spatialTargets.Clear(); APlacable[] array = Il2CppArrayBase<APlacable>.op_Implicit(Object.FindObjectsOfType<APlacable>(true)); int num = 0; while (array != null && num < array.Length) { LightTarget lightTarget = TorchColorService.CreateTorchTarget(array[num]); if (lightTarget != null) { AddTarget(lightTarget); } num++; } Light[] array2 = Il2CppArrayBase<Light>.op_Implicit(Object.FindObjectsOfType<Light>(true)); int num2 = 0; while (array2 != null && num2 < array2.Length) { LightTarget lightTarget2 = TorchColorService.CreateLanternTarget(array2[num2]); if (lightTarget2 != null) { AddTarget(lightTarget2); } num2++; } if (_targets.Count != _lastLoggedTargetCount) { _lastLoggedTargetCount = _targets.Count; ManualLogSource modLog = BetterLightsPlugin.ModLog; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Found "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_targets.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" customizable torch and lantern lights."); } modLog.LogInfo(val); } FlushPendingSnapshots(); } private bool AddTarget(LightTarget target) { //IL_006f: 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) if ((Object)(object)target?.Root == (Object)null) { return false; } int instanceID = ((Object)target.Root).GetInstanceID(); if (_targetsByRoot.ContainsKey(instanceID)) { return false; } _targetsByRoot.Add(instanceID, target); _targets.Add(target); IndexTarget(target); Color color; if (_networkColors.TryGetValue(target.Key, out var value)) { RememberDefaultColor(target); TorchColorService.Apply(target, value); } else if (!_isRemoteClient && BetterLightsPlugin.TryGetTorchColor(target.Key, out color)) { RememberDefaultColor(target); TorchColorService.Apply(target, color); } return true; } private void RememberDefaultColor(LightTarget target) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!_defaultColors.ContainsKey(target.Key)) { _defaultColors[target.Key] = TorchColorService.ReadColor(target); } } private void RefreshNearbyTargets() { //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_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) _nearbyTargets.Clear(); Camera mainCamera = Player.mainCamera; if ((Object)(object)mainCamera == (Object)null) { return; } Vector3 position = ((Component)mainCamera).transform.position; float num = BetterLightsPlugin.InteractionRange.Value + 1.5f; float num2 = num * num; Vector2Int spatialCell = GetSpatialCell(position); int num3 = Mathf.Max(1, Mathf.CeilToInt(num / 8f)); for (int i = ((Vector2Int)(ref spatialCell)).x - num3; i <= ((Vector2Int)(ref spatialCell)).x + num3; i++) { for (int j = ((Vector2Int)(ref spatialCell)).y - num3; j <= ((Vector2Int)(ref spatialCell)).y + num3; j++) { if (!_spatialTargets.TryGetValue(new Vector2Int(i, j), out var value)) { continue; } for (int k = 0; k < value.Count; k++) { LightTarget lightTarget = value[k]; if (TryGetTargetPosition(lightTarget, out var position2)) { Vector3 val = position2 - position; if (((Vector3)(ref val)).sqrMagnitude <= num2) { _nearbyTargets.Add(lightTarget); } } } } } } private void IndexTarget(LightTarget target) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_002e: Unknown result type (might be due to invalid IL or missing references) if (TryGetTargetPosition(target, out var position)) { Vector2Int spatialCell = GetSpatialCell(position); if (!_spatialTargets.TryGetValue(spatialCell, out var value)) { value = new List<LightTarget>(); _spatialTargets.Add(spatialCell, value); } value.Add(target); } } private static Vector2Int GetSpatialCell(Vector3 position) { //IL_0000: 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_0022: Unknown result type (might be due to invalid IL or missing references) return new Vector2Int(Mathf.FloorToInt(position.x / 8f), Mathf.FloorToInt(position.z / 8f)); } private static bool TryGetTargetPosition(LightTarget target, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_005a: 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_007b: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; if ((Object)(object)target?.Root == (Object)null) { return false; } GameObject gameObject = ((Component)target.Root).gameObject; if ((Object)(object)gameObject == (Object)null || !gameObject.activeInHierarchy) { return false; } position = (((Object)(object)target.Visual != (Object)null) ? target.Visual.position : (target.Root.position + Vector3.up * 0.45f)); return true; } private LightTarget FindTarget() { //IL_0046: 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_0056: 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_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_0123: 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_014d: 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_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_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_016c: 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_0188: 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_01a4: Unknown result type (might be due to invalid IL or missing references) Camera mainCamera = Player.mainCamera; Transform localTransform = Player.localTransform; if ((Object)(object)mainCamera == (Object)null || (Object)(object)localTransform == (Object)null) { return null; } float value = BetterLightsPlugin.InteractionRange.Value; float value2 = BetterLightsPlugin.AimThreshold.Value; float num = float.MaxValue; LightTarget lightTarget = null; RaycastHit val = default(RaycastHit); if (Physics.Raycast(new Ray(((Component)mainCamera).transform.position, ((Component)mainCamera).transform.forward), ref val, value)) { APlacable val2 = (((Object)(object)((RaycastHit)(ref val)).collider != (Object)null) ? ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<APlacable>() : null); LightTarget value3 = null; if (TorchColorService.IsSupported(val2)) { int instanceID = ((Object)((Component)val2).transform).GetInstanceID(); if (!_targetsByRoot.TryGetValue(instanceID, out value3)) { value3 = TorchColorService.CreateTorchTarget(val2); } } if (value3 != null) { AddTarget(value3); lightTarget = value3; if (TryGetTargetPosition(lightTarget, out var position)) { num = Vector3.Distance(((Component)mainCamera).transform.position, position); } } } for (int i = 0; i < _nearbyTargets.Count; i++) { LightTarget lightTarget2 = _nearbyTargets[i]; if (!TryGetTargetPosition(lightTarget2, out var position2)) { continue; } Vector3 val3 = position2 - ((Component)mainCamera).transform.position; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude <= 0.01f || magnitude > value) { continue; } float num2 = Vector3.Dot(((Component)mainCamera).transform.forward, val3 / magnitude); if (num2 < value2) { continue; } Vector3 val4 = mainCamera.WorldToViewportPoint(position2); if (!(val4.z <= 0f) && !(val4.x < 0.04f) && !(val4.x > 0.96f) && !(val4.y < 0.05f) && !(val4.y > 0.95f)) { float num3 = magnitude + (1f - num2) * 5f; if (num3 < num) { num = num3; lightTarget = lightTarget2; } } } return lightTarget; } private void RefreshPrompt() { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_009e: Unknown result type (might be due to invalid IL or missing references) if (_target != null) { Color color = TorchColorService.ReadColor(_target); ((Graphic)_promptSwatch).color = color; ((Shadow)((Component)_promptPanel).GetComponent<Outline>()).effectColor = WithAlpha(color, 0.76f); ((TMP_Text)_promptTitle).text = ((Time.unscaledTime < _confirmationUntil) ? _confirmationText : (BetterLightsPlugin.PickerControllerName + " / " + BetterLightsPlugin.PickerKeyName + " / MMB LIGHT COLOR")); float value = (((Object)(object)Player.mainCamera != (Object)null) ? Vector3.Distance(((Component)Player.mainCamera).transform.position, TorchColorService.GetVisualPosition(_target)) : 0f); ((TMP_Text)_promptName).text = $"{_target.Name} // {value:0.0}m"; } } private void PositionPrompt(LightTarget target) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) Camera mainCamera = Player.mainCamera; if (!((Object)(object)mainCamera == (Object)null)) { Vector3 val = mainCamera.WorldToScreenPoint(TorchColorService.GetVisualPosition(target)); float num = Mathf.Clamp(val.x + 116f, 130f, (float)Screen.width - 130f); float num2 = Mathf.Clamp(val.y + 28f, 40f, (float)Screen.height - 40f); ((Transform)_promptRoot).position = new Vector3(num, num2, 0f); } } private void OpenPicker(bool mouseMode) { //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_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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (_target != null) { _targetKey = _target.Key; _originalColor = TorchColorService.ReadColor(_target); _currentColor = _originalColor; float num = default(float); Color.RGBToHSV(_currentColor, ref _hue, ref _saturation, ref num); _presetIndex = FindNearestPreset(_currentColor); _resetPending = false; _mouseMode = false; _mouseDraggingWheel = false; _open = true; SetPromptAlpha(0f); ((Component)_pickerRoot).gameObject.SetActive(true); _pickerGroup.alpha = 1f; PositionPicker(_target); DisableInputMaps(); if (mouseMode) { EnableMouseMode(); } else if ((Object)(object)_hintLabel != (Object)null) { ((TMP_Text)_hintLabel).text = "RIGHT STICK COLOR // D-PAD PRESETS"; } RefreshPickerVisuals(); } } private void UpdatePicker() { //IL_003c: 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_0041: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) if (_target == null || !CanRemainOpen()) { ClosePicker(restoreOriginal: true); return; } Gamepad current = Gamepad.current; Keyboard current2 = Keyboard.current; if (HandleMouseInput()) { return; } Vector2 val = ((current != null) ? ((InputControl<Vector2>)(object)current.rightStick).ReadValue() : Vector2.zero); float value = BetterLightsPlugin.StickDeadzone.Value; bool flag = false; if (((Vector2)(ref val)).magnitude >= value) { _hue = Mathf.Repeat(Mathf.Atan2(val.y, val.x) / ((float)Math.PI * 2f), 1f); _saturation = Mathf.Clamp01((((Vector2)(ref val)).magnitude - value) / Mathf.Max(0.01f, 1f - value)); flag = true; } if (BetterLightsPlugin.KeyboardFallback.Value && current2 != null) { float num = (((ButtonControl)current2.rightArrowKey).isPressed ? 1f : 0f) - (((ButtonControl)current2.leftArrowKey).isPressed ? 1f : 0f); float num2 = (((ButtonControl)current2.upArrowKey).isPressed ? 1f : 0f) - (((ButtonControl)current2.downArrowKey).isPressed ? 1f : 0f); if (Mathf.Abs(num) > 0.01f || Mathf.Abs(num2) > 0.01f) { _hue = Mathf.Repeat(_hue + num * Time.unscaledDeltaTime * 0.32f, 1f); _saturation = Mathf.Clamp01(_saturation + num2 * Time.unscaledDeltaTime * 0.7f); flag = true; } } if (flag) { _resetPending = false; _presetIndex = -1; _currentColor = Color.HSVToRGB(_hue, _saturation, 1f); TorchColorService.Apply(_target, _currentColor); RefreshPickerVisuals(); } if (current != null && (current.dpad.left.wasPressedThisFrame || current.dpad.right.wasPressedThisFrame)) { int direction = (current.dpad.right.wasPressedThisFrame ? 1 : (-1)); CyclePreset(direction); } if (current != null && current.leftStickButton.wasPressedThisFrame) { ResetToOriginalColor(); } if ((current != null && current.buttonEast.wasPressedThisFrame) || (current2 != null && ((ButtonControl)current2.escapeKey).wasPressedThisFrame)) { ClosePicker(restoreOriginal: true); } else if (BetterLightsPlugin.PickerControllerPressed(current) || BetterLightsPlugin.PickerKeyPressed(current2)) { ConfirmPicker(); } } private bool HandleMouseInput() { //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_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_0068: 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_0082: 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_00db: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) Mouse current = Mouse.current; if (current == null) { return false; } if (!_mouseMode) { Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).delta).ReadValue(); if (((Vector2)(ref val)).sqrMagnitude > 2f) { EnableMouseMode(); } } if (!_mouseMode) { return false; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; Vector2 val2 = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue(); bool wasPressedThisFrame = current.leftButton.wasPressedThisFrame; UpdateMouseButtonVisual(_saveButton, val2); UpdateMouseButtonVisual(_originalButton, val2); UpdateMouseButtonVisual(_cancelButton, val2); if (wasPressedThisFrame && ContainsPoint(((Object)(object)_saveButton != (Object)null) ? ((Graphic)_saveButton).rectTransform : null, val2)) { ConfirmPicker(); return true; } if (wasPressedThisFrame && ContainsPoint(((Object)(object)_originalButton != (Object)null) ? ((Graphic)_originalButton).rectTransform : null, val2)) { ResetToOriginalColor(); return false; } if (wasPressedThisFrame && ContainsPoint(((Object)(object)_cancelButton != (Object)null) ? ((Graphic)_cancelButton).rectTransform : null, val2)) { ClosePicker(restoreOriginal: true); return true; } if (wasPressedThisFrame) { for (int i = 0; i < _presetDots.Count; i++) { Image val3 = _presetDots[i]; if ((Object)(object)val3 != (Object)null && ContainsPoint(((Graphic)val3).rectTransform, val2, 6f)) { SelectPreset(i); return false; } } } if (wasPressedThisFrame && IsPointInsideWheel(val2)) { _mouseDraggingWheel = true; } if (_mouseDraggingWheel && current.leftButton.isPressed) { SetColorFromPointer(val2); } if (current.leftButton.wasReleasedThisFrame) { _mouseDraggingWheel = false; } return false; } private void EnableMouseMode() { //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) if (!_cursorStateCaptured) { _cursorWasVisible = Cursor.visible; _cursorLockMode = Cursor.lockState; _cursorStateCaptured = true; } _mouseMode = true; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if ((Object)(object)_hintLabel != (Object)null) { ((TMP_Text)_hintLabel).text = "CLICK + DRAG THE WHEEL // CLICK A PRESET"; } } private void RestoreCursorState() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (_cursorStateCaptured) { Cursor.lockState = _cursorLockMode; Cursor.visible = _cursorWasVisible; } _cursorStateCaptured = false; _mouseMode = false; } private bool IsPointInsideWheel(Vector2 pointer) { //IL_0019: 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_0036: 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) Vector2 val = default(Vector2); if ((Object)(object)_colorWheel == (Object)null || !RectTransformUtility.ScreenPointToLocalPointInRectangle(((Graphic)_colorWheel).rectTransform, pointer, (Camera)null, ref val)) { return false; } Rect rect = ((Graphic)_colorWheel).rectTransform.rect; float width = ((Rect)(ref rect)).width; rect = ((Graphic)_colorWheel).rectTransform.rect; float num = Mathf.Min(width, ((Rect)(ref rect)).height) * 0.5f; return ((Vector2)(ref val)).magnitude <= num; } private void SetColorFromPointer(Vector2 pointer) { //IL_0019: 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_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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ef: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); if (!((Object)(object)_colorWheel == (Object)null) && RectTransformUtility.ScreenPointToLocalPointInRectangle(((Graphic)_colorWheel).rectTransform, pointer, (Camera)null, ref val)) { Rect rect = ((Graphic)_colorWheel).rectTransform.rect; float width = ((Rect)(ref rect)).width; rect = ((Graphic)_colorWheel).rectTransform.rect; float num = Mathf.Min(width, ((Rect)(ref rect)).height) * 0.46f; float num2 = Mathf.Min(((Vector2)(ref val)).magnitude, num); _hue = ((num2 > 0.5f) ? Mathf.Repeat(Mathf.Atan2(val.y, val.x) / ((float)Math.PI * 2f), 1f) : _hue); _saturation = Mathf.Clamp01(num2 / Mathf.Max(1f, num)); _resetPending = false; _presetIndex = -1; _currentColor = Color.HSVToRGB(_hue, _saturation, 1f); TorchColorService.Apply(_target, _currentColor); RefreshPickerVisuals(); } } private void SelectPreset(int index) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (index >= 0 && index < PresetColors.Length) { _presetIndex = index; _currentColor = PresetColors[index]; float num = default(float); Color.RGBToHSV(_currentColor, ref _hue, ref _saturation, ref num); _resetPending = false; TorchColorService.Apply(_target, _currentColor); RefreshPickerVisuals(); } } private static bool ContainsPoint(RectTransform rect, Vector2 pointer, float padding = 0f) { //IL_001d: 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_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_006f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rect == (Object)null) { return false; } if (padding <= 0f) { return RectTransformUtility.RectangleContainsScreenPoint(rect, pointer, (Camera)null); } Vector2 val = default(Vector2); if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, pointer, (Camera)null, ref val)) { return false; } Rect rect2 = rect.rect; ((Rect)(ref rect2)).xMin = ((Rect)(ref rect2)).xMin - padding; ((Rect)(ref rect2)).xMax = ((Rect)(ref rect2)).xMax + padding; ((Rect)(ref rect2)).yMin = ((Rect)(ref rect2)).yMin - padding; ((Rect)(ref rect2)).yMax = ((Rect)(ref rect2)).yMax + padding; return ((Rect)(ref rect2)).Contains(val); } private void UpdateMouseButtonVisual(Image button, Vector2 pointer) { //IL_0010: 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_0046: 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_0076: 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_006f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)button == (Object)null)) { bool flag = ContainsPoint(((Graphic)button).rectTransform, pointer); ((Graphic)button).color = (Color)(flag ? WithAlpha(_currentColor, 0.42f) : new Color(0.045f, 0.06f, 0.052f, 0.92f)); Outline component = ((Component)button).GetComponent<Outline>(); if ((Object)(object)component != (Object)null) { ((Shadow)component).effectColor = (flag ? Color.white : WithAlpha(_currentColor, 0.55f)); } } } private void ResetToOriginalColor() { //IL_0036: 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_006d: 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) if (!_defaultColors.TryGetValue(_targetKey, out _currentColor)) { _currentColor = _originalColor; } _currentColor.a = 1f; float num = default(float); Color.RGBToHSV(_currentColor, ref _hue, ref _saturation, ref num); _resetPending = true; _presetIndex = FindNearestPreset(_currentColor); TorchColorService.Apply(_target, _currentColor); RefreshPickerVisuals(); } private void CyclePreset(int direction) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (_presetIndex < 0) { _presetIndex = FindNearestPreset(_currentColor); } SelectPreset((_presetIndex + direction + PresetColors.Length) % PresetColors.Length); } private static int FindNearestPreset(Color color) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) int result = 0; float num = float.MaxValue; for (int i = 0; i < PresetColors.Length; i++) { Color val = PresetColors[i]; float num2 = (val.r - color.r) * (val.r - color.r) + (val.g - color.g) * (val.g - color.g) + (val.b - color.b) * (val.b - color.b); if (num2 < num) { num = num2; result = i; } } return result; } private void ConfirmPicker() { //IL_001c: 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_0071: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) if (_resetPending) { BetterLightsPlugin.RemoveTorchColor(_targetKey); } else { BetterLightsPlugin.SaveTorchColor(_targetKey, _currentColor); } _confirmationText = (_resetPending ? "ORIGINAL COLOR RESTORED" : ("SAVED " + ((TMP_Text)_hexLabel).text)); _confirmationUntil = Time.unscaledTime + 1.35f; ManualLogSource modLog = BetterLightsPlugin.ModLog; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Saved "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_target.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" color "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((TMP_Text)_hexLabel).text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } modLog.LogInfo(val); BroadcastColor(_targetKey, _currentColor); ClosePicker(restoreOriginal: false); } private void ClosePicker(bool restoreOriginal) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (restoreOriginal && _target != null) { TorchColorService.Apply(_target, _originalColor); } _open = false; _mouseDraggingWheel = false; _pickerGroup.alpha = 0f; ((Component)_pickerRoot).gameObject.SetActive(false); RestoreCursorState(); RestoreInputMaps(); _nextTargetScan = 0f; } private void RefreshPickerVisuals() { //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_0027: 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_0136: 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_0158: 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_0194: 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_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) ((Graphic)_selectedSwatch).color = _currentColor; ((Shadow)((Component)_pickerPanel).GetComponent<Outline>()).effectColor = WithAlpha(_currentColor, 0.84f); ((TMP_Text)_pickerName).text = ((_target != null) ? _target.Name : "LIGHT"); ((TMP_Text)_hexLabel).text = "#" + ColorUtility.ToHtmlStringRGB(_currentColor); ((TMP_Text)_detailLabel).text = $"HUE {Mathf.RoundToInt(_hue * 360f):000}° SAT {Mathf.RoundToInt(_saturation * 100f):000}%"; float num = _hue * (float)Math.PI * 2f; Vector2 anchoredPosition = default(Vector2); ((Vector2)(ref anchoredPosition))..ctor(Mathf.Cos(num) * _saturation * 113f, Mathf.Sin(num) * _saturation * 113f); _selectorOuter.anchoredPosition = anchoredPosition; _selectorInner.anchoredPosition = Vector2.zero; ((Graphic)((Component)_selectorInner).GetComponent<Image>()).color = _currentColor; for (int i = 0; i < _presetDots.Count; i++) { ((Transform)((Graphic)_presetDots[i]).rectTransform).localScale = ((i == _presetIndex) ? (Vector3.one * 1.3f) : Vector3.one); Outline component = ((Component)_presetDots[i]).GetComponent<Outline>(); if ((Object)(object)component != (Object)null) { ((Shadow)component).effectColor = (Color)((i == _presetIndex) ? Color.white : new Color(1f, 1f, 1f, 0.2f)); } } } private void PositionPicker(LightTarget target) { //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_002c: 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_008b: Unknown result type (might be due to invalid IL or missing references) Camera mainCamera = Player.mainCamera; ? val = (((Object)(object)mainCamera != (Object)null) ? mainCamera.WorldToScreenPoint(TorchColorService.GetVisualPosition(target)) : new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f, 0f)); float num = Mathf.Clamp(((Vector3)val).x + 215f, 195f, (float)Screen.width - 195f); float num2 = Mathf.Clamp(((Vector3)val).y, 228f, (float)Screen.height - 228f); ((Transform)_pickerRoot).position = new Vector3(num, num2, 0f); } private bool CanTarget() { try { return !_isRemoteClient && Player.isLocalPlayerLoaded && (Object)(object)Player.localPlayer != (Object)null && (Object)(object)Player.mainCamera != (Object)null && !Cursor.visible && !PlayerInventoryUI.isOpen && !SkillWheelManager.isOpen; } catch { return false; } } private static bool CanRemainOpen() { try { return (Object)(object)Player.localPlayer != (Object)null && !PlayerInventoryUI.isOpen; } catch { return false; } } private static bool TryGetActivation(out bool mouseMode) { mouseMode = false; if (BetterLightsPlugin.PickerControllerPressed(Gamepad.current)) { return true; } if (BetterLightsPlugin.PickerKeyPressed(Keyboard.current)) { mouseMode = Mouse.current != null; return true; } Mouse current = Mouse.current; if (current != null && current.middleButton.wasPressedThisFrame) { mouseMode = true; return true; } return false; } private void DisableInputMaps() { _disabledMaps.Clear(); DisableMap(PlayerInputDispatcher.movementMap); DisableMap(PlayerInputDispatcher.inventoryMap); DisableMap(PlayerInputDispatcher.skillMap); DisableMap(PlayerInputDispatcher.drawingMap); DisableMap(PlayerInputDispatcher.placeableMap); } private void DisableMap(InputActionMap map) { if (map != null && map.enabled) { map.Disable(); _disabledMaps.Add(map); } } private void RestoreInputMaps() { for (int i = 0; i < _disabledMaps.Count; i++) { InputActionMap val = _disabledMaps[i]; if (val != null) { val.Enable(); } } _disabledMaps.Clear(); } private void UpdateNetworkSync() { //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextNetworkCheck) { return; } _nextNetworkCheck = unscaledTime + 0.75f; try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null) { if ((Object)(object)_networkManager != (Object)null || _messaging != null) { ResetNetworkSync(); } else { _isRemoteClient = false; } return; } if ((Object)(object)_networkManager == (Object)null || ((Object)_networkManager).GetInstanceID() != ((Object)singleton).GetInstanceID()) { ResetNetworkSync(); _networkManager = singleton; _messaging = singleton.CustomMessagingManager; _helloHandler = DelegateSupport.ConvertDelegate<HandleNamedMessageDelegate>((Delegate)new Action<ulong, FastBufferReader>(OnHelloMessage)); _colorHandler = DelegateSupport.ConvertDelegate<HandleNamedMessageDelegate>((Delegate)new Action<ulong, FastBufferReader>(OnColorMessage)); _ackHandler = DelegateSupport.ConvertDelegate<HandleNamedMessageDelegate>((Delegate)new Action<ulong, FastBufferReader>(OnAckMessage)); _messaging.RegisterNamedMessageHandler("BetterLights.Hello.v1", _helloHandler); _messaging.RegisterNamedMessageHandler("BetterLights.Color.v1", _colorHandler); _messaging.RegisterNamedMessageHandler("BetterLights.Ack.v1", _ackHandler); _networkFailureReported = false; BetterLightsPlugin.ModLog.LogInfo((object)"BetterLights multiplayer color sync layer ready."); } _isRemoteClient = singleton.IsClient && !singleton.IsServer; if (singleton.IsClient && !singleton.IsServer && singleton.IsConnectedClient && !_syncAcknowledged && unscaledTime >= _nextHelloAttempt) { SendHello(); } } catch (Exception ex) { if (!_networkFailureReported) { _networkFailureReported = true; ManualLogSource modLog = BetterLightsPlugin.ModLog; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(46, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("BetterLights multiplayer sync is unavailable: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } modLog.LogWarning(val); } } } private void SendHello() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (_messaging == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(1, (Allocator)2, 1); try { ((FastBufferWriter)(ref val)).WriteByte((byte)1); _messaging.SendNamedMessage("BetterLights.Hello.v1", NetworkManager.ServerClientId, val, (NetworkDelivery)3); _nextHelloAttempt = Time.unscaledTime + 2f; } finally { ((FastBufferWriter)(ref val)).Dispose(); } } private void OnHelloMessage(ulong senderClientId, FastBufferReader reader) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown if ((Object)(object)_networkManager == (Object)null || !_networkManager.IsServer || senderClientId == _networkManager.LocalClientId || ((FastBufferReader)(ref reader)).Length < 1) { return; } byte b = default(byte); ((FastBufferReader)(ref reader)).ReadByte(ref b); if (b != 1) { return; } SendAck(senderClientId); if (_compatibleClients.Add(senderClientId)) { ManualLogSource modLog = BetterLightsPlugin.ModLog; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("BetterLights client "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ulong>(senderClientId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" joined light color sync."); } modLog.LogInfo(val); } if (_targets.Count > 0) { SendSnapshot(senderClientId); } else { _pendingSnapshotClients.Add(senderClientId); } } private void SendAck(ulong clientId) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (_messaging == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(1, (Allocator)2, 1); try { ((FastBufferWriter)(ref val)).WriteByte((byte)1); _messaging.SendNamedMessage("BetterLights.Ack.v1", clientId, val, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val)).Dispose(); } } private void OnAckMessage(ulong senderClientId, FastBufferReader reader) { if (!((Object)(object)_networkManager == (Object)null) && _networkManager.IsClient && !_networkManager.IsServer && senderClientId == NetworkManager.ServerClientId && ((FastBufferReader)(ref reader)).Length >= 1) { byte b = default(byte); ((FastBufferReader)(ref reader)).ReadByte(ref b); if (b == 1 && !_syncAcknowledged) { _syncAcknowledged = true; BetterLightsPlugin.ModLog.LogInfo((object)"Connected to host BetterLights color sync."); } } } private void OnColorMessage(ulong senderClientId, FastBufferReader reader) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_networkManager == (Object)null || !_networkManager.IsClient || _networkManager.IsServer || senderClientId != NetworkManager.ServerClientId) { return; } string text = default(string); ((FastBufferReader)(ref reader)).ReadValue(ref text, true); Color val = default(Color); ((FastBufferReader)(ref reader)).ReadValue(ref val); if (!string.IsNullOrEmpty(text)) { val.a = 1f; _networkColors[text] = val; if (!ApplyNetworkColor(text, val) && _worldRegistryReady) { _worldRegistryReady = false; _stableWorldScans = 0; _lastWorldTargetCount = -1; _nextWorldScan = 0f; } } } private void SendSnapshot(ulong clientId) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _targets.Count; i++) { LightTarget lightTarget = _targets[i]; if (lightTarget != null && lightTarget.IsValid && BetterLightsPlugin.TryGetTorchColor(lightTarget.Key, out var color)) { SendColor(clientId, lightTarget.Key, color); } } } private void FlushPendingSnapshots() { if (_targets.Count == 0 || _pendingSnapshotClients.Count == 0) { return; } foreach (ulong pendingSnapshotClient in _pendingSnapshotClients) { SendSnapshot(pendingSnapshotClient); } _pendingSnapshotClients.Clear(); } private void BroadcastColor(string key, Color color) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) UpdateNetworkSync(); if ((Object)(object)_networkManager == (Object)null || !_networkManager.IsServer || _messaging == null) { return; } List<ulong> list = new List<ulong>(); foreach (ulong compatibleClient in _compatibleClients) { if (!SendColor(compatibleClient, key, color)) { list.Add(compatibleClient); } } for (int i = 0; i < list.Count; i++) { _compatibleClients.Remove(list[i]); } } private bool SendColor(ulong clientId, string key, Color color) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (_messaging == null || string.IsNullOrEmpty(key)) { return false; } int num = Mathf.Max(256, key.Length * 2 + 64); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num, (Allocator)2, num); try { ((FastBufferWriter)(ref val)).WriteValue(key, true); ((FastBufferWriter)(ref val)).WriteValue(ref color); _messaging.SendNamedMessage("BetterLights.Color.v1", clientId, val, (NetworkDelivery)3); return true; } catch { return false; } finally { ((FastBufferWriter)(ref val)).Dispose(); } } private bool ApplyNetworkColor(string key, Color color) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) bool result = false; for (int i = 0; i < _targets.Count; i++) { LightTarget lightTarget = _targets[i]; if (lightTarget != null && lightTarget.IsValid && string.Equals(lightTarget.Key, key, StringComparison.Ordinal)) { TorchColorService.Apply(lightTarget, color); result = true; } } return result; } private void ResetNetworkSync() { if (_messaging != null) { try { _messaging.UnregisterNamedMessageHandler("BetterLights.Hello.v1"); _messaging.UnregisterNamedMessageHandler("BetterLights.Color.v1"); _messaging.UnregisterNamedMessageHandler("BetterLights.Ack.v1"); } catch { } } _networkManager = null; _messaging = null; _helloHandler = null; _colorHandler = null; _ackHandler = null; _nextHelloAttempt = 0f; _syncAcknowledged = false; _compatibleClients.Clear(); _pendingSnapshotClients.Clear(); _targets.Clear(); _nearbyTargets.Clear(); _targetsByRoot.Clear(); _spatialTargets.Clear(); _worldRegistryReady = false; _stableWorldScans = 0; _lastWorldTargetCount = -1; _nextWorldScan = 0f; _nextNearbyScan = 0f; _isRemoteClient = false; if (_networkColors.Count > 0) { _networkColors.Clear(); _nextWorldScan = 0f; } } private void BuildUi() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_006a: 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_011c: 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_01b5: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0386: 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_03ae: 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_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_0689: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_0721: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_074f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("BetterLights_Canvas", (Type[])(object)new Type[3] { Il2CppType.Of<RectTransform>(), Il2CppType.Of<Canvas>(), Il2CppType.Of<CanvasScaler>() }); val.transform.SetParent(((Component)this).transform, false); Canvas component = val.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 31800; CanvasScaler component2 = val.GetComponent<CanvasScaler>(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.matchWidthOrHeight = 0.5f; _canvasRect = val.GetComponent<RectTransform>(); Stretch(_canvasRect); _circleSprite = CreateCircleSprite(); _promptPanel = CreateImage("Prompt", (Transform)(object)_canvasRect, null); _promptRoot = ((Graphic)_promptPanel).rectTransform; SetCenteredSize(_promptRoot, 284f, 54f); ((Graphic)_promptPanel).color = new Color(0.015f, 0.025f, 0.02f, 0.76f); Outline obj = ((Component)_promptPanel).gameObject.AddComponent<Outline>(); ((Shadow)obj).effectDistance = new Vector2(1f, -1f); ((Shadow)obj).useGraphicAlpha = true; _promptGroup = ((Component)_promptPanel).gameObject.AddComponent<CanvasGroup>(); _promptGroup.alpha = 0f; _promptAlpha = 0f; _promptGroup.interactable = false; _promptGroup.blocksRaycasts = false; _promptSwatch = CreateImage("Swatch", (Transform)(object)_promptRoot, _circleSprite); SetAnchored(((Graphic)_promptSwatch).rectTransform, new Vector2(-115f, 0f), new Vector2(28f, 28f)); _promptTitle = CreateText("Action", (Transform)(object)_promptRoot, 13f, (FontStyles)1, (TextAlignmentOptions)4097); SetAnchored(((TMP_Text)_promptTitle).rectTransform, new Vector2(18f, 9f), new Vector2(218f, 22f)); ((Graphic)_promptTitle).color = Color.white; _promptName = CreateText("Name", (Transform)(object)_promptRoot, 10f, (FontStyles)0, (TextAlignmentOptions)4097); SetAnchored(((TMP_Text)_promptName).rectTransform, new Vector2(18f, -11f), new Vector2(218f, 18f)); ((Graphic)_promptName).color = new Color(0.72f, 0.78f, 0.74f, 1f); _pickerPanel = CreateImage("Picker", (Transform)(object)_canvasRect, null); _pickerRoot = ((Graphic)_pickerPanel).rectTransform; SetCenteredSize(_pickerRoot, 370f, 444f); ((Graphic)_pickerPanel).color = new Color(0.01f, 0.018f, 0.014f, 0.86f); Outline obj2 = ((Component)_pickerPanel).gameObject.AddComponent<Outline>(); ((Shadow)obj2).effectDistance = new Vector2(1.5f, -1.5f); ((Shadow)obj2).useGraphicAlpha = true; _pickerGroup = ((Component)_pickerPanel).gameObject.AddComponent<CanvasGroup>(); _pickerGroup.interactable = false; _pickerGroup.blocksRaycasts = false; TextMeshProUGUI obj3 = CreateText("Title", (Transform)(object)_pickerRoot, 14f, (FontStyles)1, (TextAlignmentOptions)514); ((TMP_Text)obj3).text = "BETTERLIGHTS // COLOR CONTROL"; ((Graphic)obj3).color = new Color(0.88f, 0.94f, 0.9f, 1f); SetAnchored(((TMP_Text)obj3).rectTransform, new Vector2(0f, 198f), new Vector2(338f, 28f)); _pickerName = CreateText("TorchName", (Transform)(object)_pickerRoot, 11f, (FontStyles)0, (TextAlignmentOptions)514); ((Graphic)_pickerName).color = new Color(0.64f, 0.71f, 0.66f, 1f); SetAnchored(((TMP_Text)_pickerName).rectTransform, new Vector2(0f, 174f), new Vector2(320f, 20f)); _colorWheel = CreateRawImage("ColorWheel", (Transform)(object)_pickerRoot, (Texture)(object)CreateColorWheelTexture()); SetAnchored(((Graphic)_colorWheel).rectTransform, new Vector2(0f, 42f), new Vector2(246f, 246f)); _selectorOuter = ((Graphic)CreateImage("Selector", (Transform)(object)((Graphic)_colorWheel).rectTransform, _circleSprite)).rectTransform; SetAnchored(_selectorOuter, Vector2.zero, new Vector2(20f, 20f)); ((Graphic)((Component)_selectorOuter).GetComponent<Image>()).color = Color.white; _selectorInner = ((Graphic)CreateImage("SelectorColor", (Transform)(object)_selectorOuter, _circleSprite)).rectTransform; SetAnchored(_selectorInner, Vector2.zero, new Vector2(12f, 12f)); _selectedSwatch = CreateImage("SelectedColor", (Transform)(object)_pickerRoot, _circleSprite); SetAnchored(((Graphic)_selectedSwatch).rectTransform, new Vector2(-55f, -102f), new Vector2(30f, 30f)); _hexLabel = CreateText("Hex", (Transform)(object)_pickerRoot, 15f, (FontStyles)1, (TextAlignmentOptions)4097); ((Graphic)_hexLabel).color = Color.white; SetAnchored(((TMP_Text)_hexLabel).rectTransform, new Vector2(30f, -102f), new Vector2(124f, 28f)); _detailLabel = CreateText("ColorDetails", (Transform)(object)_pickerRoot, 10f, (FontStyles)0, (TextAlignmentOptions)514); ((Graphic)_detailLabel).color = new Color(0.62f, 0.7f, 0.65f, 1f); SetAnchored(((TMP_Text)_detailLabel).rectTransform, new Vector2(0f, -128f), new Vector2(318f, 20f)); for (int i = 0; i < PresetColors.Length; i++) { Image val2 = CreateImage("Preset_" + i, (Transform)(object)_pickerRoot, _circleSprite); SetAnchored(((Graphic)val2).rectTransform, new Vector2((float)(i - 3) * 27f, -154f), new Vector2(19f, 19f)); ((Graphic)val2).color = PresetColors[i]; Outline obj4 = ((Component)val2).gameObject.AddComponent<Outline>(); ((Shadow)obj4).effectDistance = new Vector2(1f, -1f); ((Shadow)obj4).useGraphicAlpha = false; _presetDots.Add(val2); } _hintLabel = CreateText("Hints", (Transform)(object)_pickerRoot, 11f, (FontStyles)0, (TextAlignmentOptions)514); ((TMP_Text)_hintLabel).text = "RIGHT STICK COLOR // D-PAD PRESETS"; ((Graphic)_hintLabel).color = new Color(0.72f, 0.78f, 0.74f, 1f); SetAnchored(((TMP_Text)_hintLabel).rectTransform, new Vector2(0f, -177f), new Vector2(338f, 20f)); _originalButton = CreateActionButton("OriginalButton", (Transform)(object)_pickerRoot, "L3 ORIGINAL", -112f); _saveButton = CreateActionButton("SaveButton", (Transform)(object)_pickerRoot, "R3 SAVE", 0f); _cancelButton = CreateActionButton("CancelButton", (Transform)(object)_pickerRoot, "B CANCEL", 112f); ((Component)_pickerRoot).gameObject.SetActive(false); _built = true; } private void HideUi() { if ((Object)(object)_promptGroup != (Object)null) { SetPromptAlpha(0f); } if ((Object)(object)_pickerRoot != (Object)null) { ((Component)_pickerRoot).gameObject.SetActive(false); } } private void SetPromptAlpha(float alpha) { alpha = Mathf.Clamp01(alpha); if (!((Object)(object)_promptGroup == (Object)null) && !Mathf.Approximately(_promptAlpha, alpha)) { _promptAlpha = alpha; _promptGroup.alpha = alpha; } } private Image CreateActionButton(string name, Transform parent, string label, float x) { //IL_0016: 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_0044: 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_0083: 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) Image val = CreateImage(name, parent, null); SetAnchored(((Graphic)val).rectTransform, new Vector2(x, -204f), new Vector2(102f, 30f)); ((Graphic)val).color = new Color(0.045f, 0.06f, 0.052f, 0.92f); Outline obj = ((Component)val).gameObject.AddComponent<Outline>(); ((Shadow)obj).effectDistance = new Vector2(1f, -1f); ((Shadow)obj).effectColor = new Color(1f, 1f, 1f, 0.24f); ((Shadow)obj).useGraphicAlpha = true; TextMeshProUGUI obj2 = CreateText(name + "Text", (Transform)(object)((Graphic)val).rectTransform, 10f, (FontStyles)1, (TextAlignmentOptions)514); ((TMP_Text)obj2).text = label; ((Graphic)obj2).color = new Color(0.88f, 0.94f, 0.9f, 1f); Stretch(((TMP_Text)obj2).rectTransform); return val; } private static Image CreateImage(string name, Transform parent, Sprite sprite) { //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) GameObject val = new GameObject(name, (Type[])(object)new Type[3] { Il2CppType.Of<RectTransform>(), Il2CppType.Of<CanvasRenderer>(), Il2CppType.Of<Image>() }); val.transform.SetParent(parent, false); Image component = val.GetComponent<Image>(); component.sprite = sprite; component.type = (Type)0; ((Graphic)component).raycastTarget = false; return component; } private static RawImage CreateRawImage(string name, Transform parent, Texture texture) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, (Type[])(object)new Type[3] { Il2CppType.Of<RectTransform>(), Il2CppType.Of<CanvasRenderer>(), Il2CppType.Of<RawImage>() }); val.transform.SetParent(parent, false); RawImage component = val.GetComponent<RawImage>(); component.texture = texture; ((Graphic)component).color = Color.white; ((Graphic)component).raycastTarget = false; return component; } private static TextMeshProUGUI CreateText(string name, Transform parent, float size, FontStyles style, TextAlignmentOptions alignment) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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) GameObject val = new GameObject(name, (Type[])(object)new Type[3] { Il2CppType.Of<RectTransform>(), Il2CppType.Of<CanvasRenderer>(), Il2CppType.Of<TextMeshProUGUI>() }); val.transform.SetParent(parent, false); TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).fontSize = size; ((TMP_Text)component).fontStyle = style; ((TMP_Text)component).alignment = alignment; ((TMP_Text)component).enableWordWrapping = false; ((TMP_Text)component).overflowMode = (TextOverflowModes)1; ((Graphic)component).raycastTarget = false; ((TMP_Text)component).characterSpacing = 0.7f; return component; } private static Texture2D CreateColorWheelTexture() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0070: 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_00bc: 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_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_0113: 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_0121: 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_0134: 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_00b5: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false) { name = "BetterLights_ColorWheel", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; Color32[] array = (Color32[])(object)new Color32[65536]; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(128f, 128f); float num = 126f; Vector2 val3 = default(Vector2); for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { ((Vector2)(ref val3))..ctor((float)j + 0.5f - val2.x, (float)i + 0.5f - val2.y); float num2 = ((Vector2)(ref val3)).magnitude / num; if (num2 > 1.02f) { array[i * 256 + j] = new Color32((byte)0, (byte)0, (byte)0, (byte)0); continue; } Color val4 = Color.HSVToRGB(Mathf.Repeat(Mathf.Atan2(val3.y, val3.x) / ((float)Math.PI * 2f), 1f), Mathf.Clamp01(num2), 1f); float num3 = Mathf.Clamp01((1.02f - num2) * 50f); array[i * 256 + j] = Color32.op_Implicit(new Color(val4.r, val4.g, val4.b, num3)); } } val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array)); val.Apply(false, true); return val; } private static Sprite CreateCircleSprite() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_00fa: 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_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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { name = "BetterLights_Circle", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; Color32[] array = (Color32[])(object)new Color32[4096]; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(32f, 32f); float num = 31f; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num2 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), val2); float num3 = Mathf.Clamp01(num + 0.75f - num2); array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(num3 * 255f)); } } val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array)); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); } private static Color WithAlpha(Color color, float alpha) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) color.a = alpha; return color; } private static void SetCenteredSize(RectTransform rect, float width, float height) { //IL_000b: 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_0035: 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_004d: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f); rect.pivot = new Vector2(0.5f, 0.5f); rect.sizeDelta = new Vector2(width, height); rect.anchoredPosition = Vector2.zero; } private static void SetAnchored(RectTransform rect, Vector2 position, Vector2 size) { //IL_000b: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f); rect.pivot = new Vector2(0.5f, 0.5f); rect.anchoredPosition = position; rect.sizeDelta = size; } private static void Stretch(RectTransform rect) { //IL_0001: 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_0017: 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) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.offsetMin = Vector2.zero; rect.offsetMax = Vector2.zero; } private void OnDisable() { if (_open) { ClosePicker(restoreOriginal: true); } } private void OnDestroy() { RestoreCursorState(); RestoreInputMaps(); ResetNetworkSync(); } } [BepInPlugin("com.holden.infernoprotocol.betterlights", "BetterLights", "0.3.8")] [BepInDependency("com.holden.infernoprotocol.frankmodscore", "1.0.0")] public sealed class BetterLightsPlugin : BasePlugin { private static readonly Dictionary<string, string> TorchColors = new Dictionary<string, string>(StringComparer.Ordinal); private static BetterLightsController _controller; private static ConfigEntry<string> _savedTorchColors; internal static ManualLogSource ModLog { get; private set; } internal static ConfigEntry<bool> Enabled { get; private set; } internal static ConfigEntry<float> InteractionRange { get; private set; } internal static ConfigEntry<float> AimThreshold { get; private set; } internal static ConfigEntry<float> StickDeadzone { get; private set; } internal static ConfigEntry<bool> KeyboardFallback { get; private set; } internal static ConfigEntry<Key> PickerKeyboardKey { get; private set; } internal static ConfigEntry<GamepadButton> PickerControllerButton { get; private set; } internal static string PickerKeyName { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<Key> pickerKeyboardKey = PickerKeyboardKey; string text = ((pickerKeyboardKey != null) ? ((object)pickerKeyboardKey.Value/*cast due to .constrained prefix*/).ToString() : null) ?? "F7"; if (text.StartsWith("Digit", StringComparison.Ordinal)) { return text.Substring(5); } return text.ToUpperInvariant(); } } internal static string PickerControllerName { get { //IL_000d: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<GamepadButton> pickerControllerButton = PickerControllerButton; return GamepadButtonName((GamepadButton)((pickerControllerButton == null) ? 9 : ((int)pickerControllerButton.Value))); } } public override void Load() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Expected O, but got Unknown ModLog = ((BasePlugin)this).Log; Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enables BetterLights torch and lantern customization."); InteractionRange = ((BasePlugin)this).Config.Bind<float>("Interaction", "Range", 3f, new ConfigDescription("Maximum distance for the light color prompt.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1.5f, 6f), Array.Empty<object>())); if (Mathf.Approximately(InteractionRange.Value, 4.25f)) { InteractionRange.Value = 3f; } AimThreshold = ((BasePlugin)this).Config.Bind<float>("Interaction", "AimThreshold", 0.78f, new ConfigDescription("How closely the camera must face a torch, from 0 to 1.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.45f, 0.95f), Array.Empty<object>())); StickDeadzone = ((BasePlugin)this).Config.Bind<float>("Interaction", "StickDeadzone", 0.16f, new ConfigDescription("Right-stick distance before the color changes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.08f, 0.5f), Array.Empty<object>())); KeyboardFallback = ((BasePlugin)this).Config.Bind<bool>("Interaction", "KeyboardFallback", true, "Allows the remappable keyboard shortcut and arrow-key control in addition to the controller controls."); PickerKeyboardKey = ((BasePlugin)this).Config.Bind<Key>("Interaction", "PickerKeyboardKey", (Key)100, "Keyboard shortcut used to open and save the BetterLights color picker."); PickerControllerButton = ((BasePlugin)this).Config.Bind<GamepadButton>("Interaction", "PickerControllerButton", (GamepadButton)9, "Controller shortcut used to open and save the BetterLights color picker."); _savedTorchColors = ((BasePlugin)this).Config.Bind<string>("Persistence", "TorchColors", string.Empty, "Per-light colors managed by BetterLights. Editing this value manually is not recommended."); LoadSavedColors(); ModSettingsRegistry.RegisterKeyBinding("com.holden.infernoprotocol.betterlights", "BetterLights", "PickerKeyboardKey", "Open / save color picker", (Key)100, (Func<Key>)(() => PickerKeyboardKey.Value), (Action<Key>)delegate(Key key) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) PickerKeyboardKey.Value = key; }); ModSettingsRegistry.RegisterGamepadBinding("com.holden.infernoprotocol.betterlights", "BetterLights", "PickerControllerButton", "Open / save color picker", (GamepadButton)9, (Func<GamepadButton>)(() => PickerControllerButton.Value), (Action<GamepadButton>)delegate(GamepadButton button) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) PickerControllerButton.Value = button; }); _controller = ((BasePlugin)this).AddComponent<BetterLightsController>(); ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(8, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BetterLights"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.3.8"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded"); } log.LogInfo(val); } public override bool Unload() { ModSettingsRegistry.UnregisterMod("com.holden.infernoprotocol.betterlights"); if ((Object)(object)_controller != (Object)null) { Object.Destroy((Object)(object)_controller); _controller = null; } return true; } internal static bool PickerKeyPressed(Keyboard keyboard) { //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) if (!KeyboardFallback.Value || keyboard == null || PickerKeyboardKey == null || (int)PickerKeyboardKey.Value == 0) { return false; } try { return ((ButtonControl)keyboard[PickerKeyboardKey.Value]).wasPressedThisFrame; } catch { return false; } } internal static bool PickerControllerPressed(Gamepad gamepad) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (gamepad == null || PickerControllerButton == null) { return false; } try { return gamepad[PickerControllerButton.Value].wasPressedThisFrame; } catch { return false; } } private unsafe static string GamepadButtonName(GamepadButton button) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected I4, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 switch ((int)button) { default: if ((int)button != 32) { if ((int)button == 33) { return "RT"; } return ((object)(*(GamepadButton*)(&button))/*cast due to .constrained prefix*/).ToString().ToUpperInvariant(); } return "LT"; case 6: return "A"; case 5: return "B"; case 7: return "X"; case 4: return "Y"; case 10: return "LB"; case 11: return "RB"; case 8: return "L3"; case 9: return "R3"; case 12: return "MENU"; case 13: return "VIEW"; case 0: return "D-PAD UP"; case 1: return "D-PAD DOWN"; case 2: return "D-PAD LEFT"; case 3: return "D-PAD RIGHT"; } } internal static string GetTorchKey(APlacable torch) { //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_007f: 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_00d4: 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_0023: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)torch == (Object)null) { return string.Empty; } if (torch.placableId == 0L) { Vector3 position = ((Component)torch).transform.position; return $"{torch.placableItem}-{torch.interiorIndex}-P{Mathf.RoundToInt(position.x * 10f)}_{Mathf.RoundToInt(position.y * 10f)}_{Mathf.RoundToInt(position.z * 10f)}"; } return $"{torch.placableItem}-{torch.interiorIndex}-{torch.placableId}"; } internal static string GetSceneLightKey(string type, Transform root) { //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_0035: 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_007d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return string.Empty; } Vector3 position = root.position; return $"{type}-P{Mathf.RoundToInt(position.x * 10f)}_{Mathf.RoundToInt(position.y * 10f)}_{Mathf.RoundToInt(position.z * 10f)}"; } internal static bool TryGetTorchColor(string key, out Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) color = default(Color); if (!string.IsNullOrEmpty(key) && TorchColors.TryGetValue(key, out var value)) { return ColorUtility.TryParseHtmlString(value, ref color); } return false; } internal static void SaveTorchColor(string key, Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(key)) { TorchColors[key] = "#" + ColorUtility.ToHtmlStringRGB(color); SaveColors(); } } internal static void RemoveTorchColor(string key) { if (!string.IsNullOrEmpty(key) && TorchColors.Remove(key)) { SaveColors(); } } private static void LoadSavedColors() { TorchColors.Clear(); string text = _savedTorchColors?.Value; if (string.IsNullOrWhiteSpace(text)) { return; } string[] array = text.Split(';', StringSplitOptions.RemoveEmptyEntries); Color val = default(Color); for (int i = 0; i < array.Length; i++) { int num = array[i].IndexOf('='); if (num > 0 && num < array[i].Length - 1) { string key = array[i].Substring(0, num); string text2 = array[i].Substring(num + 1); if (ColorUtility.TryParseHtmlString(text2, ref val)) { TorchColors[key] = text2; } } } } private static void SaveColors() { List<string> list = new List<string>(TorchColors.Keys); list.Sort(StringComparer.Ordinal); string[] array = new string[list.Count]; for (int i = 0; i < list.Count; i++) { array[i] = list[i] + "=" + TorchColors[list[i]]; } _savedTorchColors.Value = string.Join(";", array); } } internal sealed class LightTarget { internal APlacable Placable; internal Transform Root; internal Transform Visual; internal Light PrimaryLight; internal Light[] Lights; internal ParticleSystem[] Particles; internal CompositeTorch[] CompositeTorches; internal Renderer[] Renderers; internal Material[] EmissionMaterials; internal string Key; internal string Name; internal bool HasFlame; internal bool IsValid { get { if ((Object)(object)Root != (Object)null) { return ((Component)Root).gameObject.activeInHierarchy; } return false; } } } internal static class PluginInfo { internal const string Guid = "com.holden.infernoprotocol.betterlights"; internal const string Name = "BetterLights"; internal const string Version = "0.3.8"; } internal static class TorchColorService { private static readonly Color NaturalFire = new Color(1f, 0.43f, 0.12f, 1f); private static readonly Color NaturalLantern = new Color(1f, 0.72f, 0.42f, 1f); private static readonly string[] EmissionColorProperties = new string[7] { "_EmissionColor", "_EmissiveColor", "_EmissiveColorLDR", "_EmissiveColorHDR", "_EmissionTint", "_EmissiveTint", "_GlowColor" }; private static readonly string[] EmissionMapProperties = new string[4] { "_EmissionMap", "_EmissiveColorMap", "_EmissiveMap", "_GlowMap" }; internal static bool IsSupported(APlacable placable) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 if ((Object)(object)placable == (Object)null || !((Component)placable).gameObject.activeInHierarchy) { return false; } Items placableItem = placable.placableItem; if ((int)placableItem != 11 && (int)placableItem != 12) { return (int)placableItem == 326; } return true; } internal static LightTarget CreateTorchTarget(APlacable placable) { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 if (!IsSupported(placable)) { return null; } LightTarget lightTarget = new LightTarget(); lightTarget.Placable = placable; lightTarget.Root = ((Component)placable).transform; lightTarget.Key = BetterLightsPlugin.GetTorchKey(placable); LightTarget lightTarget2 = lightTarget; Items placableItem = placable.placableItem; string name = (((int)placableItem == 12) ? "STANDING TORCH" : (((int)placableItem != 326) ? "TORCH" : "WALL TORCH")); lightTarget2.Name = name; lightTarget.HasFlame = true; LightTarget lightTarget3 = lightTarget; lightTarget3.Lights = Il2CppArrayBase<Light>.op_Implicit(((Component)lightTarget3.Root).GetComponentsInChildren<Light>(true)); if (lightTarget3.Lights != null && lightTarget3.Lights.Length != 0 && (Object)(object)lightTarget3.Lights[0] != (Object)null) { lightTarget3.PrimaryLight = lightTarget3.Lights[0]; lightTarget3.Visual = ((Component)lightTarget3.PrimaryLight).transform; } if ((Object)(object)lightTarget3.Visual == (Object)null) { lightTarget3.Particles = Il2CppArrayBase<ParticleSystem>.op_Implicit(((Component)lightTarget3.Root).GetComponentsInChildren<ParticleSystem>(true)); int num = 0; while (lightTarget3.Particles != null && num < lightTarget3.Particles.Length) { if ((Object)(object)lightTarget3.Particles[num] != (Object)null && !IsSmoke(((Object)((Component)lightTarget3.Particles[num]).gameObject).name)) { lightTarget3.Visual = ((Component)lightTarget3.Particles[num]).transform; break; } num++; } } return lightTarget3; } internal static LightTarget CreateLanternTarget(Light light) { Transform val = FindLanternRoot(light); Transform val2 = FindLanternIdentity(light); if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy) { return null; } if (IsSupported(((Component)val).GetComponentInParent<APlacable>())) { return null; } return new LightTarget { Root = val, Visual = ((Component)light).transform, PrimaryLight = light, Key = BetterLightsPlugin.GetSceneLightKey("Lantern", ((Object)(object)val2 != (Object)null) ? val2 : val), Name = "LANTERN", HasFlame = false }; } internal static Vector3 GetVisualPosition(LightTarget target) { //IL_000b: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (target == null || !target.IsValid) { return Vector3.zero; } if (!((Object)(object)target.Visual != (Object)null)) { return target.Root.position + Vector3.up * 0.45f; } return target.Visual.position; } internal static Color ReadColor(LightTarget target) { //IL_0016: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_010a: 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_007c: 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_00e7: 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_0116: Unknown result type (might be due to invalid IL or missing references) if (target == null || !target.IsValid) { if (target == null || target.HasFlame) { return NaturalFire; } return NaturalLantern; } Light primaryLight = target.PrimaryLight; if ((Object)(object)primaryLight != (Object)null) { Color color = primaryLight.color; color.a = 1f; return color; } Light[] lights = GetLights(target); int num = 0; while (lights != null && num < lights.Length) { if (!((Object)(object)lights[num] == (Object)null)) { target.PrimaryLight = lights[num]; Color color2 = lights[num].color; color2.a = 1f; return color2; } num++; } if (target.HasFlame) { ParticleSystem[] particles = GetParticles(target); int num2 = 0; while (particles != null && num2 < particles.Length) { if (!((Object)(object)particles[num2] == (Object)null) && !IsSmoke(((Object)((Component)particles[num2]).gameObject).name)) { try { Color color3 = particles[num2].main.startColor.color; color3.a = 1f; return color3; } catch { } } num2++; } } if (!target.HasFlame) { return NaturalLantern; } return NaturalFire; } internal static int Apply(LightTarget target, Color color) { //IL_005f: 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_0034: Unknown result type (might be due to invalid IL or missing references) if (target == null || !target.IsValid) { return 0; } color.a = 1f; int num = 0; Light[] lights = GetLights(target); int num2 = 0; while (lights != null && num2 < lights.Length) { Light val = lights[num2]; if (!((Object)(object)val == (Object)null)) { val.color = color; num++; } num2++; } if (target.HasFlame) { num += ApplyFlameColor(target, color); } return num + ApplyEmissionColor(target, color); } private static int ApplyFlameColor(LightTarget target, Color color) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown int num = 0; ParticleSystem[] particles = GetParticles(target); int num2 = 0; bool flag = default(bool); while (particles != null && num2 < particles.Length) { ParticleSystem val = particles[num2]; if (!((Object)(object)val == (Object)null) && !IsSmoke(((Object)((Component)val).gameObject).name)) { try { MainModule main = val.main; Color val2 = color; float a = main.startColor.color.a; val2.a = ((a > 0.01f) ? a : 1f); main.startColor = new MinMaxGradient(val2); num++; } catch (Exception ex) { ManualLogSource modLog = BetterLightsPlugin.ModLog; BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(26, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Could not tint particle "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)((Component)val).gameObject).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } modLog.LogDebug(val3); } } num2++; } CompositeTorch[] array = target.CompositeTorches ?? (target.CompositeTorches = Il2CppArrayBase<CompositeTorch>.op_Implicit(((Component)target.Root).GetComponentsInChildren<CompositeTorch>(true))); int num3 = 0; while (array != null && num3 < array.Length) { CompositeTorch val4 = array[num3]; if (!((Object)(object)val4 == (Object)null)) { val4.enabledEmessiveColor = color * 2.4f; num++; } num3++; } return num; } private static int ApplyEmissionColor(LightTarget target, Color color) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0033: 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 num = 0; Material[] emissionMaterials = GetEmissionMaterials(target); int num2 = 0; bool flag = default(bool); while (emissionMaterials != null && num2 < emissionMaterials.Length) { Material val = emissionMaterials[num2]; if (!((Object)(object)val == (Object)null)) { try { if (target.HasFlame) { if (ApplyFlameMaterialColor(val, color)) { num++; } } else if (ApplyLanternEmissionColor(val, color)) { num++; } } catch (Exception ex) { ManualLogSource modLog = BetterLightsPlugin.ModLog; BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Could not tint emissive material: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } modLog.LogDebug(val2); } } num2++; } return num; } private static Light[] GetLights(LightTarget target) { return target.Lights ?? (target.Lights = Il2CppArrayBase<Light>.op_Implicit(((Component)target.Root).GetComponentsInChildren<Light>(true))); } private static ParticleSystem[] GetParticles(LightTarget target) { return target.Particles ?? (target.Particles = Il2CppArrayBase<ParticleSystem>.op_Implicit(((Component)target.Root).GetComponentsInChildren<ParticleSystem>(true))); } private static Material[] GetEmissionMaterials(LightTarget target) { if (target.EmissionMaterials != null) { return target.EmissionMaterials; } if (target.Renderers == null) { target.Renderers = Il2CppArrayBase<Renderer>.op_Implicit(((Component)target.Root).GetComponentsInChildren<Renderer>(true)); } List<Material> list = new List<Material>(); int num = 0; while (target.Renderers != null && num < target.Renderers.Length) { Renderer val = target.Renderers[num]; if (!((Object)(object)val == (Object)null) && !IsSmoke(((Object)((Component)val).gameObject).name)) { if (target.HasFlame) { Material material = val.material; if ((Object)(object)material != (Object)null) { list.Add(material); } } else { Material[] array = Il2CppArrayBase<Material>.op_Implicit((Il2CppArrayBase<Material>)(object)val.materials); int num2 = 0; while (array != null && num2 < array.Length) { Material val2 = array[num2]; if ((Object)(object)val2 != (Object)null) { list.Add(val2); } num2++; } } } num++; } target.EmissionMaterials = list.ToArray(); return target.EmissionMaterials; } private static bool ApplyLanternEmissionColor(Material material, Color color) { //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_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_011e: Unknown result type (might be due to invalid IL or missing references) bool flag = false; bool flag2 = HasEmissionMap(material); bool flag3 = false; float num = 0f; for (int i = 0; i < EmissionColorProperties.Length; i++) { string text = EmissionColorProperties[i]; if (material.HasProperty(text)) { Color color2 = material.GetColor(text); float num2 = Mathf.Max(color2.r, Mathf.Max(color2.g, color2.b)); num = Mathf.Max(num, num2); flag3 = flag3 || num2 > 0.01f; } } bool flag4 = ContainsAny(((Object)material).name ?? string.Empty, "emiss", "glow", "bulb", "glass"); if (flag2 || flag3 || flag4) { float num3 = Mathf.Clamp(num, 0.8f, 2f); for (int j = 0; j < EmissionColorProperties.Length; j++) { string text2 = EmissionColorProperties[j]; if (material.HasProperty(text2)) { bool flag5 = text2.EndsWith("LDR", StringComparison.OrdinalIgnoreCase) || text2.IndexOf("Tint", StringComparison.OrdinalIgnoreCase) >= 0; material.SetColor(text2, flag5 ? color : (color * num3)); flag = true; } } if (flag) { material.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)(material.globalIlluminationFlags & -5); } } return flag; } private static bool ApplyFlameMaterialColor(Material material, Color color) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) bool result = false; string text = ((Object)material).name ?? string.Empty; if (material.HasProperty("_EmissionColor")) { material.SetColor("_Emissi