using System;
using System.Collections;
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 BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
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("Krild_CCTV_Stalk_Ur_Friends")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Krild_CCTV_Stalk_Ur_Friends")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f9a19156-27fa-4b94-a2ba-7e6aa68056c5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Krild_CCTV_Stalk_Ur_Friends
{
[BepInPlugin("KrildCCTV", "CCTV_Stalk_Ur_Friends", "1.0.0.0")]
public class KrildPatcher : BaseUnityPlugin
{
private const string modGUID = "KrildCCTV";
private const string modName = "CCTV_Stalk_Ur_Friends";
private const string modVersion = "1.0.0.0";
public ConfigEntry<Vector3> _CameraPlayerLocalPositionOverview;
public ConfigEntry<float> _CameraPlayerLocalPositionX;
public ConfigEntry<float> _CameraPlayerLocalPositionY;
public ConfigEntry<float> _CameraPlayerLocalPositionZ;
public Vector3 _CameraPlayerLocalPosition;
public ConfigEntry<float> _CameraPlayerClippingPlaneNear;
public ConfigEntry<float> _CameraFOV;
internal Harmony harmony = new Harmony("KrildCCTV");
internal static KrildPatcher current;
internal ManualLogSource log;
private void Awake()
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Expected O, but got Unknown
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Expected O, but got Unknown
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Expected O, but got Unknown
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Expected O, but got Unknown
if ((Object)(object)current == (Object)null)
{
current = this;
}
log = Logger.CreateLogSource("KrildCCTV");
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
_CameraPlayerLocalPositionOverview = ((BaseUnityPlugin)this).Config.Bind<Vector3>("PlayerLocalCameraPosition", "CameraPlayerLocalPosition", new Vector3(0f, 0f, 0.3f), "Local Camera Offset, when switched to a Player. Position (0,0,0) is in the middle of the Head. So there is a offset needed, to not render the head itselfs (eg. The Eyes or cosmetics).");
_CameraPlayerLocalPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("PlayerLocalCameraPosition", "CameraPlayerLocalPositionX", 0f, new ConfigDescription("Vector X", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), Array.Empty<object>()));
_CameraPlayerLocalPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("PlayerLocalCameraPosition", "CameraPlayerLocalPositionY", 0f, new ConfigDescription("Vector Y", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), Array.Empty<object>()));
_CameraPlayerLocalPositionZ = ((BaseUnityPlugin)this).Config.Bind<float>("PlayerLocalCameraPosition", "CameraPlayerLocalPositionZ", 0.3f, new ConfigDescription("Vector Z", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), Array.Empty<object>()));
_CameraPlayerLocalPosition = new Vector3(_CameraPlayerLocalPositionX.Value, _CameraPlayerLocalPositionY.Value, _CameraPlayerLocalPositionZ.Value);
_CameraPlayerClippingPlaneNear = ((BaseUnityPlugin)this).Config.Bind<float>("PlayerLocalCamera", "CameraPlayerClippingPlaneNear", 0.01f, new ConfigDescription("The distance from the Camera where rendering starts. Higher Value means u can look throw walls.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>()));
_CameraFOV = ((BaseUnityPlugin)this).Config.Bind<float>("LocalCamera", "CameraFOV", 90f, new ConfigDescription("Camera FOV", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 150f), Array.Empty<object>()));
Patch();
log.LogInfo((object)"Krildig geladen :3 You can stalk ur friends now!");
}
internal void Patch()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
if (harmony == null)
{
Harmony val = (harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID));
}
harmony.PatchAll();
}
public void WriteLog(string message)
{
log.LogInfo((object)message);
}
}
}
namespace Krild_CCTV_Stalk_Ur_Friends.Behaviours
{
public class KrildCameraManager : MonoBehaviour
{
public static KrildCameraManager current;
public List<KrildItemCamera> externalCameraItems;
private void Awake()
{
current = this;
externalCameraItems = new List<KrildItemCamera>();
}
public void AddElement(KrildItemCamera item)
{
externalCameraItems.Add(item);
}
public KrildItemCamera GetElement(int index)
{
return externalCameraItems[index];
}
public void RemoveElement(KrildItemCamera item)
{
externalCameraItems.Remove(item);
}
}
public class KrildItemCamera : MonoBehaviour
{
[SerializeField]
public Transform viewPoint;
public string nameCamera;
private void Start()
{
if ((Object)(object)KrildCameraManager.current == (Object)null)
{
GameObject.Find("Pun Manager").AddComponent<KrildCameraManager>();
}
SubscribeToCameraList();
nameCamera = "Item Camera " + KrildCameraManager.current.externalCameraItems.Count;
}
private void SubscribeToCameraList()
{
if ((Object)(object)KrildCameraManager.current != (Object)null)
{
KrildCameraManager.current.externalCameraItems.Add(this);
}
}
}
public class KrildItemMonitor : MonoBehaviour
{
[Serializable]
public class CCTVPlayer
{
public string name;
public Transform localCameraTransform;
public PlayerAvatar playerAvatar;
public Transform localDeathHeadTransform = null;
public CCTVPlayer(string value1, Transform value2, PlayerAvatar value3)
{
name = value1;
localCameraTransform = value2;
playerAvatar = value3;
}
public void SetDeadHead(Transform value1)
{
localDeathHeadTransform = value1;
}
}
[SerializeField]
private Camera cameraItem;
private Transform cameraTransform;
[SerializeField]
private Material materialRenderTexture;
[SerializeField]
private Material materialNoSignal;
[SerializeField]
private MeshRenderer screenRenderer;
[SerializeField]
private TMP_Text textCamName;
private string defaultTextCamName = "Error :c";
private ItemToggle itemToggle;
private bool prevToggleState;
private Transform transformShipCam;
private KrildItemCamera activeCamera = null;
private bool moveCameraSucces = false;
private bool noSignal = false;
private bool playerAlive = true;
private int maxPlayer = 1;
private int index;
private List<CCTVPlayer> listPlayerSorted;
private Vector3 cameraPlayerLocalPosition;
private float cameraPlayerClippingPlaneNear;
private float cameraFOV;
private void Start()
{
//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)
cameraPlayerLocalPosition = KrildPatcher.current._CameraPlayerLocalPositionOverview.Value;
cameraPlayerClippingPlaneNear = KrildPatcher.current._CameraPlayerClippingPlaneNear.Value;
cameraFOV = KrildPatcher.current._CameraFOV.Value;
cameraTransform = ((Component)cameraItem).transform;
cameraItem.fieldOfView = cameraFOV;
itemToggle = ((Component)this).gameObject.GetComponent<ItemToggle>();
SetCamName(defaultTextCamName);
transformShipCam = GameObject.Find("cctv camera").transform;
SetShipCam();
SetMaxPlayer();
SortPlayerAvatars();
if ((Object)(object)KrildCameraManager.current == (Object)null)
{
GameObject.Find("Pun Manager").AddComponent<KrildCameraManager>();
}
((MonoBehaviour)this).StartCoroutine(WaitAndLoadDeadHead());
}
private void SortPlayerAvatars()
{
List<string> list = new List<string>();
listPlayerSorted = new List<CCTVPlayer>();
foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
{
list.Add(SemiFunc.PlayerGetName(player));
}
list.Sort();
foreach (string item in list)
{
for (int i = 0; i < list.Count; i++)
{
if (item == SemiFunc.PlayerGetName(GameDirector.instance.PlayerList[i]))
{
listPlayerSorted.Add(new CCTVPlayer(item, GameDirector.instance.PlayerList[i].localCameraTransform, GameDirector.instance.PlayerList[i]));
}
}
}
}
private void Update()
{
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
if (itemToggle.toggleState == prevToggleState)
{
return;
}
moveCameraSucces = false;
prevToggleState = itemToggle.toggleState;
index = NextIndex();
if (index == 0)
{
SetShipCam();
}
else if (index <= maxPlayer)
{
MoveCam(listPlayerSorted[index - 1].localCameraTransform, listPlayerSorted[index - 1].name, cameraPlayerClippingPlaneNear);
cameraTransform.localPosition = cameraPlayerLocalPosition;
}
else if ((Object)(object)KrildCameraManager.current.externalCameraItems[index - 1 - maxPlayer] != (Object)null)
{
activeCamera = KrildCameraManager.current.externalCameraItems[index - 1 - maxPlayer];
if (((Component)activeCamera).transform.localPosition.y < 1000f)
{
MoveCam(activeCamera.viewPoint, activeCamera.nameCamera, 0.1f);
}
}
if (moveCameraSucces)
{
((Renderer)screenRenderer).material = materialRenderTexture;
noSignal = false;
playerAlive = true;
}
else
{
NoSignal();
}
}
private void SetMaxPlayer()
{
maxPlayer = GameDirector.instance.PlayerList.Count;
}
private int NextIndex()
{
index = (index + 1) % (1 + maxPlayer + KrildCameraManager.current.externalCameraItems.Count);
return index;
}
private void MoveCam(Transform transform, string value, float value2)
{
//IL_0014: 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)
cameraTransform.SetParent(transform);
cameraTransform.localPosition = Vector3.zero;
cameraTransform.localRotation = Quaternion.identity;
cameraItem.nearClipPlane = value2;
SetCamName(value);
moveCameraSucces = true;
}
private void SetCamName(string value)
{
if (value == "")
{
textCamName.text = "Cam " + (index + 1) + ": " + defaultTextCamName;
}
else
{
textCamName.text = "Cam " + (index + 1) + ": " + value;
}
}
private void NoSignal()
{
((Renderer)screenRenderer).material = materialNoSignal;
SetCamName("");
noSignal = true;
}
private void SetShipCam()
{
//IL_0034: 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)
index = 0;
MoveCam(transformShipCam, "Ship Camera", 0.6f);
cameraTransform.localPosition = new Vector3(0.4f, -0.1f, 0f);
cameraTransform.localRotation = new Quaternion(0f, 0.757f, 0f, 0.653f);
}
private IEnumerator WaitAndLoadDeadHead()
{
yield return (object)new WaitForSeconds(3f);
foreach (CCTVPlayer item in listPlayerSorted)
{
for (int i = 0; i < 20; i++)
{
if ((Object)(object)item.playerAvatar.playerDeathHead == (Object)null)
{
yield return (object)new WaitForSeconds(1f);
continue;
}
item.SetDeadHead(((Component)item.playerAvatar.playerDeathHead).transform);
break;
}
}
((MonoBehaviour)this).StartCoroutine(CheckCameraState());
}
private IEnumerator CheckCameraState()
{
if (index > maxPlayer)
{
if ((Object)(object)activeCamera == (Object)null)
{
NoSignal();
}
else if (((Component)activeCamera).transform.localPosition.y > 1000f)
{
NoSignal();
}
else if (noSignal)
{
((Renderer)screenRenderer).material = materialRenderTexture;
MoveCam(activeCamera.viewPoint, activeCamera.nameCamera, 0.1f);
noSignal = false;
}
}
else if (index > 0 && listPlayerSorted[index - 1] != null && (Object)(object)listPlayerSorted[index - 1].localDeathHeadTransform != (Object)null)
{
if (listPlayerSorted[index - 1].localDeathHeadTransform.position.y > 1000f)
{
if (!playerAlive)
{
MoveCam(listPlayerSorted[index - 1].localCameraTransform, listPlayerSorted[index - 1].name, cameraPlayerClippingPlaneNear);
cameraTransform.localPosition = cameraPlayerLocalPosition;
playerAlive = true;
}
}
else if (playerAlive)
{
MoveCam(listPlayerSorted[index - 1].localDeathHeadTransform, listPlayerSorted[index - 1].name, 0.1f);
playerAlive = false;
}
}
yield return (object)new WaitForSeconds(0.25f);
((MonoBehaviour)this).StartCoroutine(CheckCameraState());
}
}
}