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 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.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.2.0")] [assembly: AssemblyInformationalVersion("0.3.2+477d00f8c6e6102e4d9ad948d3169f90685e9781")] [assembly: AssemblyProduct("InfernoProtocol.BetterLights")] [assembly: AssemblyTitle("InfernoProtocol.BetterLights")] [assembly: AssemblyVersion("0.3.2.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 _targets = new List(); private readonly Dictionary _defaultColors = new Dictionary(StringComparer.Ordinal); private readonly Dictionary _networkColors = new Dictionary(StringComparer.Ordinal); private readonly List _disabledMaps = new List(); private readonly HashSet _compatibleClients = new HashSet(); private readonly HashSet _pendingSnapshotClients = new HashSet(); private const string HelloMessage = "BetterLights.Hello.v1"; private const string ColorMessage = "BetterLights.Color.v1"; 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 _presetDots = new List(); private LightTarget _target; private string _targetKey; private Color _currentColor; private Color _originalColor; private float _hue; private float _saturation; private float _nextTorchScan; private float _nextTargetScan; 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 NetworkManager _networkManager; private CustomMessagingManager _messaging; private HandleNamedMessageDelegate _helloHandler; private HandleNamedMessageDelegate _colorHandler; private float _nextNetworkCheck; private bool _helloSent; private bool _networkFailureReported; public BetterLightsController(IntPtr pointer) : base(pointer) { } private void Update() { if (!_built) { BuildUi(); } if (!BetterLightsPlugin.Enabled.Value) { if (_open) { ClosePicker(restoreOriginal: true); } HideUi(); } else { UpdateNetworkSync(); if (_open) { UpdatePicker(); } else { UpdateTargeting(); } } } private void UpdateTargeting() { if (!CanTarget()) { _target = null; _promptGroup.alpha = 0f; return; } float unscaledTime = Time.unscaledTime; if (unscaledTime >= _nextTorchScan) { _nextTorchScan = unscaledTime + 2f; RefreshTorches(); } if (unscaledTime >= _nextTargetScan) { _nextTargetScan = unscaledTime + 0.14f; _target = FindTarget(); RefreshPrompt(); } if (_target == null) { _promptGroup.alpha = 0f; return; } PositionPrompt(_target); _promptGroup.alpha = Mathf.MoveTowards(_promptGroup.alpha, 1f, Time.unscaledDeltaTime * 10f); if (TryGetActivation(out var mouseMode)) { OpenPicker(mouseMode); } } private void RefreshTorches() { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown _targets.Clear(); HashSet hashSet = new HashSet(); APlacable[] array = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); int num = 0; while (array != null && num < array.Length) { LightTarget lightTarget = TorchColorService.CreateTorchTarget(array[num]); if (lightTarget != null) { hashSet.Add(((Object)lightTarget.Root).GetInstanceID()); AddTarget(lightTarget); } num++; } Light[] array2 = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType(true)); int num2 = 0; while (array2 != null && num2 < array2.Length) { LightTarget lightTarget2 = TorchColorService.CreateLanternTarget(array2[num2]); if (lightTarget2 != null && hashSet.Add(((Object)lightTarget2.Root).GetInstanceID())) { 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(_targets.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" customizable torch and lantern lights."); } modLog.LogInfo(val); } FlushPendingSnapshots(); } private void AddTarget(LightTarget target) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) _targets.Add(target); if (!_defaultColors.ContainsKey(target.Key)) { _defaultColors[target.Key] = TorchColorService.ReadColor(target); } Color color; if (_networkColors.TryGetValue(target.Key, out var value)) { TorchColorService.Apply(target, value); } else if (!IsRemoteClient() && BetterLightsPlugin.TryGetTorchColor(target.Key, out color)) { TorchColorService.Apply(target, color); } } private LightTarget FindTarget() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) 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 result = null; for (int i = 0; i < _targets.Count; i++) { LightTarget lightTarget = _targets[i]; if (lightTarget == null || !lightTarget.IsValid) { continue; } Vector3 visualPosition = TorchColorService.GetVisualPosition(lightTarget); Vector3 val = visualPosition - ((Component)mainCamera).transform.position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.01f || magnitude > value) { continue; } float num2 = Vector3.Dot(((Component)mainCamera).transform.forward, val / magnitude); if (num2 < value2) { continue; } Vector3 val2 = mainCamera.WorldToViewportPoint(visualPosition); if (!(val2.z <= 0f) && !(val2.x < 0.04f) && !(val2.x > 0.96f) && !(val2.y < 0.05f) && !(val2.y > 0.95f)) { float num3 = magnitude + (1f - num2) * 5f; if (num3 < num) { num = num3; result = lightTarget; } } } return result; } 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (_target != null) { Color color = TorchColorService.ReadColor(_target); ((Graphic)_promptSwatch).color = color; ((Shadow)((Component)_promptPanel).GetComponent()).effectColor = WithAlpha(color, 0.76f); ((TMP_Text)_promptTitle).text = ((Time.unscaledTime < _confirmationUntil) ? _confirmationText : "R3 / F7 / 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; _promptGroup.alpha = 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)(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 ((current != null && current.rightStickButton.wasPressedThisFrame) || (BetterLightsPlugin.KeyboardFallback.Value && current2 != null && ((ButtonControl)current2.f7Key).wasPressedThisFrame)) { 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)(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)(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(); 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(_target.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" color "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((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()).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()).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(); 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; Gamepad current = Gamepad.current; if (current != null && current.rightStickButton.wasPressedThisFrame) { return true; } Keyboard current2 = Keyboard.current; if (BetterLightsPlugin.KeyboardFallback.Value && current2 != null && ((ButtonControl)current2.f7Key).wasPressedThisFrame) { mouseMode = Mouse.current != null; return true; } Mouse current3 = Mouse.current; if (current3 != null && current3.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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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) { ResetNetworkSync(); return; } if ((Object)(object)_networkManager == (Object)null || ((Object)_networkManager).GetInstanceID() != ((Object)singleton).GetInstanceID()) { ResetNetworkSync(); _networkManager = singleton; _messaging = singleton.CustomMessagingManager; _helloHandler = DelegateSupport.ConvertDelegate((Delegate)new Action(OnHelloMessage)); _colorHandler = DelegateSupport.ConvertDelegate((Delegate)new Action(OnColorMessage)); _messaging.RegisterNamedMessageHandler("BetterLights.Hello.v1", _helloHandler); _messaging.RegisterNamedMessageHandler("BetterLights.Color.v1", _colorHandler); _networkFailureReported = false; BetterLightsPlugin.ModLog.LogInfo((object)"BetterLights multiplayer color sync layer ready."); } if (singleton.IsClient && !singleton.IsServer && !_helloSent) { 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(ex.Message); } modLog.LogWarning(val); } } } private void SendHello() { //IL_0023: 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 { _messaging.SendNamedMessage("BetterLights.Hello.v1", NetworkManager.ServerClientId, val, (NetworkDelivery)3); _helloSent = true; } finally { ((FastBufferWriter)(ref val)).Dispose(); } } private void OnHelloMessage(ulong senderClientId, FastBufferReader reader) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown if ((Object)(object)_networkManager == (Object)null || !_networkManager.IsServer || senderClientId == _networkManager.LocalClientId) { return; } 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(senderClientId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" joined light color sync."); } modLog.LogInfo(val); } if (_targets.Count > 0) { SendSnapshot(senderClientId); } else { _pendingSnapshotClients.Add(senderClientId); } } 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) { 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; ApplyNetworkColor(text, val); } } } private void SendSnapshot(ulong clientId) { //IL_0025: 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) { SendColor(clientId, lightTarget.Key, TorchColorService.ReadColor(lightTarget)); } } } 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 list = new List(); 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 void ApplyNetworkColor(string key, Color color) { //IL_002c: 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 && string.Equals(lightTarget.Key, key, StringComparison.Ordinal)) { TorchColorService.Apply(lightTarget, color); } } } private bool IsRemoteClient() { try { NetworkManager singleton = NetworkManager.Singleton; return (Object)(object)singleton != (Object)null && singleton.IsListening && singleton.IsClient && !singleton.IsServer; } catch { return false; } } private void ResetNetworkSync() { if (_messaging != null) { try { _messaging.UnregisterNamedMessageHandler("BetterLights.Hello.v1"); _messaging.UnregisterNamedMessageHandler("BetterLights.Color.v1"); } catch { } } _networkManager = null; _messaging = null; _helloHandler = null; _colorHandler = null; _helloSent = false; _compatibleClients.Clear(); _pendingSnapshotClients.Clear(); if (_networkColors.Count > 0) { _networkColors.Clear(); _nextTorchScan = 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_066d: Unknown result type (might be due to invalid IL or missing references) //IL_067e: Unknown result type (might be due to invalid IL or missing references) //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_0716: Unknown result type (might be due to invalid IL or missing references) //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_0744: 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(), Il2CppType.Of(), Il2CppType.Of() }); val.transform.SetParent(((Component)this).transform, false); Canvas component = val.GetComponent(); component.renderMode = (RenderMode)0; component.sortingOrder = 31800; CanvasScaler component2 = val.GetComponent(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.matchWidthOrHeight = 0.5f; _canvasRect = val.GetComponent(); 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(); ((Shadow)obj).effectDistance = new Vector2(1f, -1f); ((Shadow)obj).useGraphicAlpha = true; _promptGroup = ((Component)_promptPanel).gameObject.AddComponent(); _promptGroup.alpha = 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(); ((Shadow)obj2).effectDistance = new Vector2(1.5f, -1.5f); ((Shadow)obj2).useGraphicAlpha = true; _pickerGroup = ((Component)_pickerPanel).gameObject.AddComponent(); _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()).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(); ((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) { _promptGroup.alpha = 0f; } if ((Object)(object)_pickerRoot != (Object)null) { ((Component)_pickerRoot).gameObject.SetActive(false); } } 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(); ((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(), Il2CppType.Of(), Il2CppType.Of() }); val.transform.SetParent(parent, false); Image component = val.GetComponent(); 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(), Il2CppType.Of(), Il2CppType.Of() }); val.transform.SetParent(parent, false); RawImage component = val.GetComponent(); 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(), Il2CppType.Of(), Il2CppType.Of() }); val.transform.SetParent(parent, false); TextMeshProUGUI component = val.GetComponent(); ((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.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.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.2")] public sealed class BetterLightsPlugin : BasePlugin { private static readonly Dictionary TorchColors = new Dictionary(StringComparer.Ordinal); private static BetterLightsController _controller; private static ConfigEntry _savedTorchColors; internal static ManualLogSource ModLog { get; private set; } internal static ConfigEntry Enabled { get; private set; } internal static ConfigEntry InteractionRange { get; private set; } internal static ConfigEntry AimThreshold { get; private set; } internal static ConfigEntry StickDeadzone { get; private set; } internal static ConfigEntry KeyboardFallback { get; private set; } 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown ModLog = ((BasePlugin)this).Log; Enabled = ((BasePlugin)this).Config.Bind("General", "Enabled", true, "Enables BetterLights torch and lantern customization."); InteractionRange = ((BasePlugin)this).Config.Bind("Interaction", "Range", 3f, new ConfigDescription("Maximum distance for the light color prompt.", (AcceptableValueBase)(object)new AcceptableValueRange(1.5f, 6f), Array.Empty())); if (Mathf.Approximately(InteractionRange.Value, 4.25f)) { InteractionRange.Value = 3f; } AimThreshold = ((BasePlugin)this).Config.Bind("Interaction", "AimThreshold", 0.78f, new ConfigDescription("How closely the camera must face a torch, from 0 to 1.", (AcceptableValueBase)(object)new AcceptableValueRange(0.45f, 0.95f), Array.Empty())); StickDeadzone = ((BasePlugin)this).Config.Bind("Interaction", "StickDeadzone", 0.16f, new ConfigDescription("Right-stick distance before the color changes.", (AcceptableValueBase)(object)new AcceptableValueRange(0.08f, 0.5f), Array.Empty())); KeyboardFallback = ((BasePlugin)this).Config.Bind("Interaction", "KeyboardFallback", true, "Allows F7 and arrow-key control in addition to the controller controls."); _savedTorchColors = ((BasePlugin)this).Config.Bind("Persistence", "TorchColors", string.Empty, "Per-light colors managed by BetterLights. Editing this value manually is not recommended."); LoadSavedColors(); _controller = ((BasePlugin)this).AddComponent(); ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(8, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("BetterLights"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("0.3.2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded"); } log.LogInfo(val); } public override bool Unload() { if ((Object)(object)_controller != (Object)null) { Object.Destroy((Object)(object)_controller); _controller = null; } return true; } 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 list = new List(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 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.2"; } 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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; return lightTarget; } 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())) { return null; } return new LightTarget { Root = val, 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (target == null || !target.IsValid) { return Vector3.zero; } Light[] array = Il2CppArrayBase.op_Implicit(((Component)target.Root).GetComponentsInChildren(true)); if (array != null && array.Length != 0 && (Object)(object)array[0] != (Object)null) { return ((Component)array[0]).transform.position; } if (target.HasFlame) { ParticleSystem[] array2 = Il2CppArrayBase.op_Implicit(((Component)target.Root).GetComponentsInChildren(true)); if (array2 != null && array2.Length != 0 && (Object)(object)array2[0] != (Object)null) { return ((Component)array2[0]).transform.position; } } return target.Root.position + Vector3.up * 0.45f; } 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if (target == null || !target.IsValid) { if (target == null || target.HasFlame) { return NaturalFire; } return NaturalLantern; } Light[] array = Il2CppArrayBase.op_Implicit(((Component)target.Root).GetComponentsInChildren(true)); int num = 0; while (array != null && num < array.Length) { if ((Object)(object)array[num] != (Object)null) { Color color = array[num].color; color.a = 1f; return color; } num++; } if (target.HasFlame) { ParticleSystem[] array2 = Il2CppArrayBase.op_Implicit(((Component)target.Root).GetComponentsInChildren(true)); int num2 = 0; while (array2 != null && num2 < array2.Length) { if (!((Object)(object)array2[num2] == (Object)null) && !IsSmoke(((Object)((Component)array2[num2]).gameObject).name)) { try { Color color2 = array2[num2].main.startColor.color; color2.a = 1f; return color2; } catch { } } num2++; } } if (!target.HasFlame) { return NaturalLantern; } return NaturalFire; } internal static int Apply(LightTarget target, Color color) { //IL_0074: 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_003f: 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[] array = Il2CppArrayBase.op_Implicit(((Component)target.Root).GetComponentsInChildren(true)); int num2 = 0; while (array != null && num2 < array.Length) { Light val = array[num2]; if (!((Object)(object)val == (Object)null)) { val.color = color; num++; } num2++; } if (target.HasFlame) { num += ApplyFlameColor(target.Root, color); } return num + ApplyEmissionColor(target.Root, color, target.HasFlame); } private static int ApplyFlameColor(Transform root, Color color) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_0113: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown int num = 0; ParticleSystem[] array = Il2CppArrayBase.op_Implicit(((Component)root).GetComponentsInChildren(true)); int num2 = 0; bool flag = default(bool); while (array != null && num2 < array.Length) { ParticleSystem val = array[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(((Object)((Component)val).gameObject).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } modLog.LogDebug(val3); } } num2++; } CompositeTorch[] array2 = Il2CppArrayBase.op_Implicit(((Component)root).GetComponentsInChildren(true)); int num3 = 0; while (array2 != null && num3 < array2.Length) { CompositeTorch val4 = array2[num3]; if (!((Object)(object)val4 == (Object)null)) { val4.enabledEmessiveColor = color * 2.4f; num++; } num3++; } return num; } private static int ApplyEmissionColor(Transform root, Color color, bool hasFlame) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) int num = 0; Renderer[] array = Il2CppArrayBase.op_Implicit(((Component)root).GetComponentsInChildren(true)); int num2 = 0; bool flag = default(bool); while (array != null && num2 < array.Length) { Renderer val = array[num2]; if (!((Object)(object)val == (Object)null) && !IsSmoke(((Object)((Component)val).gameObject).name)) { try { if (hasFlame) { Material material = val.material; if ((Object)(object)material != (Object)null && ApplyFlameMaterialColor(material, color)) { num++; } } else { Il2CppReferenceArray materials = val.materials; int num3 = 0; while (materials != null && num3 < ((Il2CppArrayBase)(object)materials).Length) { Material val2 = ((Il2CppArrayBase)(object)materials)[num3]; if ((Object)(object)val2 != (Object)null && ApplyLanternEmissionColor(val2, color)) { num++; } num3++; } } } catch (Exception ex) { ManualLogSource modLog = BetterLightsPlugin.ModLog; BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(26, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Could not tint renderer "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((Object)((Component)val).gameObject).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } modLog.LogDebug(val3); } } num2++; } return num; } 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("_EmissionColor", color * 2.4f); result = true; } if (material.HasProperty("_TintColor")) { material.SetColor("_TintColor", color); result = true; } bool flag = text.IndexOf("fire", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("flame", StringComparison.OrdinalIgnoreCase) >= 0; if (flag && material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", color); result = true; } else if (flag && material.HasProperty("_Color")) { material.SetColor("_Color", color); result = true; } return result; } private static bool HasEmissionMap(Material material) { for (int i = 0; i < EmissionMapProperties.Length; i++) { string text = EmissionMapProperties[i]; if (material.HasProperty(text) && (Object)(object)material.GetTexture(text) != (Object)null) { return true; } } return false; } private static bool ContainsAny(string value, params string[] fragments) { if (string.IsNullOrEmpty(value)) { return false; } for (int i = 0; i < fragments.Length; i++) { if (value.IndexOf(fragments[i], StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } private static Transform FindLanternRoot(Light light) { if ((Object)(object)light == (Object)null) { return null; } Transform val = ((Component)light).transform; Transform val2 = null; int num = -1; int num2 = 0; while ((Object)(object)val != (Object)null && num2 < 8) { if (ContainsLantern(((Object)((Component)val).gameObject).name)) { if (val2 == null) { val2 = val; } if (num < 0) { num = num2; } } if ((Object)(object)val2 != (Object)null && num2 - num <= 2) { Renderer[] array = Il2CppArrayBase.op_Implicit(((Component)val).GetComponentsInChildren(true)); if (array != null && array.Length != 0 && array.Length <= 12) { return val; } } else if ((Object)(object)val2 != (Object)null) { break; } val = val.parent; num2++; } return val2; } private static Transform FindLanternIdentity(Light light) { Transform val = (((Object)(object)light != (Object)null) ? ((Component)light).transform : null); int num = 0; while ((Object)(object)val != (Object)null && num < 8) { if (ContainsLantern(((Object)((Component)val).gameObject).name)) { return val; } val = val.parent; num++; } return null; } private static bool ContainsLantern(string value) { if (!string.IsNullOrEmpty(value)) { return value.IndexOf("lantern", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private static bool IsSmoke(string value) { if (!string.IsNullOrEmpty(value)) { return value.IndexOf("smoke", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } }