using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.IL2CPP;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using UnhollowerBaseLib;
using UnhollowerRuntimeLib;
using UnityEngine;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Antro.RedLightVisualizer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Antro.RedLightVisualizer")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("Antro.RedLightVisualizer")]
[assembly: AssemblyTitle("Antro.RedLightVisualizer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Antro.RedlightVisualizer
{
[BepInPlugin("Antro.RedlightVisualizer", "Antro RLGL", "1.0.0")]
public class RedLightPlugin : BasePlugin
{
public override void Load()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
ClassInjector.RegisterTypeInIl2Cpp<RedLightController>();
GameObject val = new GameObject("Antro_RL_Manager_Fix");
Object.DontDestroyOnLoad((Object)(object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<RedLightController>();
}
}
public class RedLightController : MonoBehaviour
{
private bool _isMenuOpen = false;
private Rect _windowRect = new Rect(50f, 50f, 350f, 500f);
private float _scanRadius = 150f;
private float _scanDensity = 2f;
private float _timeBudget = 0.004f;
private bool _isScanning = false;
private Queue<Vector3> _scanQueue = new Queue<Vector3>();
private List<GameObject> _activeVisuals = new List<GameObject>();
private GameObject _tileTemplate;
private MonoBehaviourPublicQuSiQuTrSiheQuLawhQuUnique _cachedStatue;
private List<Collider> _safeZoneColliders = new List<Collider>();
private Vector3 _statueEyesPos;
private int _groundMask;
private int _sightMask;
private GUIStyle centeredStyle => new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4,
fontStyle = (FontStyle)1
};
public RedLightController(IntPtr ptr)
: base(ptr)
{
}//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
private void Update()
{
if (Input.GetKeyDown((KeyCode)93))
{
_isMenuOpen = !_isMenuOpen;
ToggleCursor(_isMenuOpen);
}
if (_isScanning)
{
ProcessScanBatch();
}
}
private void StartSmartScan()
{
//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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
ClearVisuals();
CreateTemplate();
SetupMasks();
_cachedStatue = Object.FindObjectOfType<MonoBehaviourPublicQuSiQuTrSiheQuLawhQuUnique>();
if ((Object)(object)_cachedStatue == (Object)null)
{
Debug.LogWarning(Object.op_Implicit("[Antro] Red Light Statue not found!"));
return;
}
_statueEyesPos = ((Component)_cachedStatue).transform.position + Vector3.up * 8f;
_safeZoneColliders.Clear();
Il2CppArrayBase<MonoBehaviourPublicLi1ObsaInObUnique> val = Object.FindObjectsOfType<MonoBehaviourPublicLi1ObsaInObUnique>();
foreach (MonoBehaviourPublicLi1ObsaInObUnique item in val)
{
if ((Object)(object)item != (Object)null)
{
Collider component = ((Component)item).GetComponent<Collider>();
if (Object.op_Implicit((Object)(object)component))
{
_safeZoneColliders.Add(component);
}
}
}
Vector3 val2 = Vector3.zero;
if ((Object)(object)Camera.main != (Object)null)
{
val2 = ((Component)Camera.main).transform.position;
}
else
{
MonoBehaviourPublicGaplfoGaTrorplTrRiBoUnique val3 = Object.FindObjectOfType<MonoBehaviourPublicGaplfoGaTrorplTrRiBoUnique>();
if (Object.op_Implicit((Object)(object)val3))
{
val2 = ((Component)val3).transform.position;
}
}
float num = Mathf.Floor((val2.x - _scanRadius) / _scanDensity) * _scanDensity;
float num2 = val2.x + _scanRadius;
float num3 = Mathf.Floor((val2.z - _scanRadius) / _scanDensity) * _scanDensity;
float num4 = val2.z + _scanRadius;
float num5 = val2.y + 100f;
for (float num6 = num; num6 <= num2; num6 += _scanDensity)
{
for (float num7 = num3; num7 <= num4; num7 += _scanDensity)
{
_scanQueue.Enqueue(new Vector3(num6, num5, num7));
}
}
_isScanning = true;
}
private void SetupMasks()
{
int num = LayerMask.NameToLayer("Player");
int num2 = 2;
int num3 = 1;
int num4 = 5;
_groundMask = LayerMask.GetMask(new string[4] { "Default", "Ground", "Terrain", "Map" });
if (_groundMask == 0)
{
_groundMask = -1;
}
if (num != -1)
{
_groundMask &= ~(1 << num);
}
_groundMask &= ~(1 << num2);
_groundMask &= ~(1 << num4);
_sightMask = -1;
if (num != -1)
{
_sightMask &= ~(1 << num);
}
_sightMask &= ~(1 << num2);
_sightMask &= ~(1 << num3);
_sightMask &= ~(1 << num4);
}
private void ProcessScanBatch()
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: 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)
if ((Object)(object)_cachedStatue == (Object)null || (Object)(object)_tileTemplate == (Object)null)
{
_isScanning = false;
return;
}
float realtimeSinceStartup = Time.realtimeSinceStartup;
RaycastHit val2 = default(RaycastHit);
RaycastHit val5 = default(RaycastHit);
while (_scanQueue.Count > 0)
{
if (Time.realtimeSinceStartup - realtimeSinceStartup > _timeBudget)
{
return;
}
Vector3 val = _scanQueue.Dequeue();
if (!Physics.Raycast(val, Vector3.down, ref val2, 300f, _groundMask, (QueryTriggerInteraction)1) || !(Vector3.Angle(Vector3.up, ((RaycastHit)(ref val2)).normal) < 60f))
{
continue;
}
Vector3 point = ((RaycastHit)(ref val2)).point;
if (!IsInsideSafeZone(point))
{
Vector3 val3 = point + Vector3.up * 0.5f;
Vector3 val4 = val3 - _statueEyesPos;
float magnitude = ((Vector3)(ref val4)).magnitude;
bool flag = false;
if (Physics.Raycast(_statueEyesPos, val4, ref val5, magnitude, _sightMask, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val5)).distance < magnitude - 1f)
{
flag = true;
}
if (!flag)
{
InstantiateRedTile(point, ((RaycastHit)(ref val2)).normal);
}
}
}
_isScanning = false;
}
private bool IsInsideSafeZone(Vector3 point)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
foreach (Collider safeZoneCollider in _safeZoneColliders)
{
if ((Object)(object)safeZoneCollider != (Object)null)
{
Bounds bounds = safeZoneCollider.bounds;
if (((Bounds)(ref bounds)).Contains(point))
{
return true;
}
}
}
return false;
}
private void CreateTemplate()
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_tileTemplate != (Object)null))
{
_tileTemplate = GameObject.CreatePrimitive((PrimitiveType)3);
Object.Destroy((Object)(object)_tileTemplate.GetComponent<Collider>());
Renderer component = _tileTemplate.GetComponent<Renderer>();
if (Object.op_Implicit((Object)(object)component))
{
component.shadowCastingMode = (ShadowCastingMode)0;
component.receiveShadows = false;
component.material.shader = Shader.Find("Sprites/Default");
component.material.color = new Color(1f, 0f, 0f, 0.4f);
}
_tileTemplate.SetActive(false);
_tileTemplate.transform.SetParent(((Component)this).transform);
}
}
private void InstantiateRedTile(Vector3 pos, Vector3 normal)
{
//IL_001b: 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_004a: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(_tileTemplate);
val.SetActive(true);
val.transform.position = pos;
val.transform.localScale = new Vector3(_scanDensity, 0.1f, _scanDensity);
val.transform.up = normal;
_activeVisuals.Add(val);
}
private void ClearVisuals()
{
_isScanning = false;
_scanQueue.Clear();
foreach (GameObject activeVisual in _activeVisuals)
{
if ((Object)(object)activeVisual != (Object)null)
{
Object.Destroy((Object)(object)activeVisual);
}
}
_activeVisuals.Clear();
}
private void ToggleCursor(bool show)
{
Cursor.lockState = (CursorLockMode)((!show) ? 1 : 0);
Cursor.visible = show;
}
private void OnGUI()
{
//IL_0024: 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_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)
if (_isMenuOpen)
{
GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.95f);
_windowRect = GUI.Window(999, _windowRect, WindowFunction.op_Implicit((Action<int>)DrawWindow), "RLGL Fix Real");
}
}
private void DrawWindow(int id)
{
//IL_0001: 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_0032: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
GUI.contentColor = Color.white;
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
if ((Object)(object)_cachedStatue != (Object)null)
{
GUI.color = Color.green;
}
else
{
GUI.color = Color.red;
}
GUILayout.Label(((Object)(object)_cachedStatue != (Object)null) ? "STATUS: READY" : "STATUS: NO STATUE", centeredStyle, Array.Empty<GUILayoutOption>());
GUI.color = Color.white;
GUILayout.Space(10f);
if (GUILayout.Button("SCAN AREA", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }))
{
StartSmartScan();
}
if (GUILayout.Button("CLEAR", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
{
ClearVisuals();
}
GUILayout.Space(15f);
GUILayout.Label($"Radius: {_scanRadius:F0}m", Array.Empty<GUILayoutOption>());
_scanRadius = GUILayout.HorizontalSlider(_scanRadius, 10f, 500f, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Tile Size: {_scanDensity:F1}m", Array.Empty<GUILayoutOption>());
_scanDensity = GUILayout.HorizontalSlider(_scanDensity, 1f, 5f, Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
if (_isScanning)
{
GUI.color = Color.yellow;
GUILayout.Label($"Scanning... Queue: {_scanQueue.Count}", centeredStyle, Array.Empty<GUILayoutOption>());
}
else
{
GUI.color = Color.green;
GUILayout.Label($"Objects: {_activeVisuals.Count}", centeredStyle, Array.Empty<GUILayoutOption>());
}
GUILayout.EndVertical();
GUI.DragWindow();
}
}
}