Decompiled source of CCTV Security Cameras v1.0.0

RepoCCTVMod.dll

Decompiled 3 days ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RepoCCTVMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RepoCCTVMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c9a2dd9d-f779-4e05-82dd-5705d71a7432")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RepoCCTVMod;

[BepInPlugin("com.TuNombre.RepoCCTV", "CCTV System Mod", "1.0.0")]
public class CCTVPlugin : BaseUnityPlugin
{
	private const string MyGUID = "com.TuNombre.RepoCCTV";

	private const string PluginName = "CCTV System Mod";

	private const string VersionString = "1.0.0";

	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Mod CCTV System Mod cargado correctamente!");
		R_SecurityCam.GlobalCamRegistry.Clear();
	}
}
public class R_SecurityCam : MonoBehaviour
{
	public static List<R_SecurityCam> GlobalCamRegistry = new List<R_SecurityCam>();

	[Header("Componentes Internos")]
	public Camera lensCamera;

	public Light statusLight;

	[Header("Estado del Dispositivo")]
	public bool isUnitActive = false;

	private void Awake()
	{
		if ((Object)(object)lensCamera != (Object)null)
		{
			((Behaviour)lensCamera).enabled = false;
		}
		if ((Object)(object)statusLight != (Object)null)
		{
			((Behaviour)statusLight).enabled = false;
		}
	}

	private void OnEnable()
	{
		if (!GlobalCamRegistry.Contains(this))
		{
			GlobalCamRegistry.Add(this);
		}
	}

	private void OnDisable()
	{
		if (GlobalCamRegistry.Contains(this))
		{
			GlobalCamRegistry.Remove(this);
		}
	}

	public void TogglePower()
	{
		isUnitActive = !isUnitActive;
		if ((Object)(object)statusLight != (Object)null)
		{
			((Behaviour)statusLight).enabled = isUnitActive;
		}
		Debug.Log((object)$"[CCTV] {((Object)((Component)this).gameObject).name} estado: {isUnitActive}");
	}
}
public class R_MonitorPad : MonoBehaviour
{
	[Header("Configuración Visual")]
	public Renderer displayMesh;

	public RenderTexture feedTexture;

	public Material activeMat;

	public Material staticMat;

	private int _viewIndex = -1;

	private R_SecurityCam _connectedUnit;

	private List<R_SecurityCam> _onlineUnits = new List<R_SecurityCam>();

	private void Start()
	{
		ShutdownMonitor();
	}

	public void CycleChannels()
	{
		if (_viewIndex == -1)
		{
			ScanForCameras();
			if (_onlineUnits.Count > 0)
			{
				_viewIndex = 0;
				LinkToCamera(_onlineUnits[0]);
			}
		}
		else
		{
			_viewIndex++;
			if (_viewIndex >= _onlineUnits.Count)
			{
				ShutdownMonitor();
			}
			else
			{
				LinkToCamera(_onlineUnits[_viewIndex]);
			}
		}
	}

	private void ScanForCameras()
	{
		_onlineUnits.Clear();
		foreach (R_SecurityCam item in R_SecurityCam.GlobalCamRegistry)
		{
			if ((Object)(object)item != (Object)null && item.isUnitActive)
			{
				_onlineUnits.Add(item);
			}
		}
	}

	private void LinkToCamera(R_SecurityCam target)
	{
		if ((Object)(object)_connectedUnit != (Object)null && (Object)(object)_connectedUnit.lensCamera != (Object)null)
		{
			_connectedUnit.lensCamera.targetTexture = null;
			((Behaviour)_connectedUnit.lensCamera).enabled = false;
		}
		if ((Object)(object)target != (Object)null && (Object)(object)target.lensCamera != (Object)null)
		{
			target.lensCamera.targetTexture = feedTexture;
			((Behaviour)target.lensCamera).enabled = true;
			if ((Object)(object)displayMesh != (Object)null && (Object)(object)activeMat != (Object)null)
			{
				displayMesh.material = activeMat;
				displayMesh.material.mainTexture = (Texture)(object)feedTexture;
			}
			_connectedUnit = target;
		}
	}

	private void ShutdownMonitor()
	{
		if ((Object)(object)_connectedUnit != (Object)null && (Object)(object)_connectedUnit.lensCamera != (Object)null)
		{
			_connectedUnit.lensCamera.targetTexture = null;
			((Behaviour)_connectedUnit.lensCamera).enabled = false;
		}
		_connectedUnit = null;
		_viewIndex = -1;
		if ((Object)(object)displayMesh != (Object)null && (Object)(object)staticMat != (Object)null)
		{
			displayMesh.material = staticMat;
		}
	}
}
public class R_StickySensor : MonoBehaviour
{
	private Rigidbody _rb;

	[Header("Calibración")]
	public Vector3 modelCorrection = Vector3.zero;

	public float stickOffset = 0.05f;

	[Header("Sensibilidad")]
	public float minImpactForce = 3f;

	public float activationDelay = 0.2f;

	private float _timeSinceEnabled;

	private void Awake()
	{
		_rb = ((Component)this).GetComponent<Rigidbody>();
	}

	private void OnEnable()
	{
		_timeSinceEnabled = 0f;
		if ((Object)(object)_rb != (Object)null)
		{
			_rb.collisionDetectionMode = (CollisionDetectionMode)1;
		}
	}

	private void Update()
	{
		_timeSinceEnabled += Time.deltaTime;
	}

	private void OnCollisionEnter(Collision collision)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		if (!_rb.isKinematic && !(_timeSinceEnabled < activationDelay) && !collision.gameObject.CompareTag("Player"))
		{
			Vector3 relativeVelocity = collision.relativeVelocity;
			if (!(((Vector3)(ref relativeVelocity)).magnitude < minImpactForce))
			{
				StickToSurface(collision);
			}
		}
	}

	private void StickToSurface(Collision collision)
	{
		//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)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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)
		if ((Object)(object)_rb != (Object)null)
		{
			_rb.isKinematic = true;
			_rb.velocity = Vector3.zero;
			_rb.angularVelocity = Vector3.zero;
		}
		ContactPoint val = collision.contacts[0];
		Vector3 normal = ((ContactPoint)(ref val)).normal;
		Quaternion val2 = Quaternion.LookRotation(normal);
		((Component)this).transform.rotation = val2 * Quaternion.Euler(modelCorrection);
		((Component)this).transform.position = ((ContactPoint)(ref val)).point + normal * stickOffset;
		Debug.Log((object)"[CCTV] Cámara instalada.");
	}
}