using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using Unity.Netcode; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("KookooEntity")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("KookooEntity")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("df24efe7-a262-4aa5-981a-01c019d26f0a")] [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 KookooEntity; public class KookooBehaviour : MonoBehaviour { private enum KookooState { Hidden, Appearing, Counting, WaitingClosing, Closing, HoldingClose } private float basePitch = 0.7f; private bool conditionChecked = false; private KookooState currentState = KookooState.Hidden; private float timer = 0f; private float nextAppearTime = 0f; private List deathCopies = new List(); private bool deathAnimPlaying = false; private float deathTimer = 0f; private float copyTimer = 0f; private GameObject deathCanvas; private Sprite lastClosingSprite; private AudioClip rememberClip; private AudioClip countClip; private AudioClip checkClip; private AudioClip killClip; private AudioSource rememberSource; private AudioSource countSource; private AudioSource checkSource; private AudioSource killSource; private bool isOnCooldown = false; private float cooldownTimer = 0f; private float cooldownTime = 0f; private GameObject rootObject; private Image bodyImage; private Image[] digitImages = (Image[])(object)new Image[2]; private Image particlesImage; private Sprite[] rememberSprites = (Sprite[])(object)new Sprite[2]; private Sprite[] numSprites = (Sprite[])(object)new Sprite[10]; private Sprite particlesSprite; private Sprite[] countSprites = (Sprite[])(object)new Sprite[6]; private Sprite[] closingSprites = (Sprite[])(object)new Sprite[4]; private Sprite errorSprite; private bool shouldSpawnErrorSprites = false; private float errorSpriteSpawnTimer = 0f; private List errorSpriteInstances = new List(); private float bodyAnimTimer = 0f; private int bodyAnimFrame = 0; private float countAnimTimer = 0f; private int countAnimFrame = 0; private bool countAnimPlaying = false; private float closingAnimTimer = 0f; private int closingAnimFrame = 0; private float particlesTimer = 0f; private float particlesInterval = 0f; private bool particlesVisible = false; private float particlesVisibleTimer = 0f; private int targetNumber = 0; private int currentCount = 0; private float countTimer = 0f; private float shakeTimer = 0f; private Vector2 basePosition = Vector2.zero; private bool scanBlocked = false; private float scanBlockTimer = 0f; private AudioSource scanDamageSource; private AudioSource scanErrorSource; private AudioClip scanDamageClip; private AudioClip scanErrorClip; private bool scanAttackPlaying = false; private float scanAttackTimer = 0f; private string modFolder; private AudioClip LoadAudioClip(string filename) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown string text = Path.Combine(modFolder, filename); if (!File.Exists(text)) { Debug.LogError((object)("Kookoo Entity: звук не найден — " + text)); return null; } WWW val = new WWW("file://" + text); try { while (!val.isDone) { } return val.GetAudioClip(false, false, (AudioType)13); } finally { ((IDisposable)val)?.Dispose(); } } private void Start() { string[] directories = Directory.GetDirectories(Paths.PluginPath, "KookooEntity", SearchOption.AllDirectories); modFolder = ((directories.Length != 0) ? directories[0] : Path.Combine(Paths.PluginPath, "KookooEntity")); LoadSprites(); rememberClip = LoadAudioClip("remember.mp3"); countClip = LoadAudioClip("count.mp3"); checkClip = LoadAudioClip("check.mp3"); killClip = LoadAudioClip("kill.mp3"); rememberSource = ((Component)this).gameObject.AddComponent(); rememberSource.loop = false; rememberSource.playOnAwake = false; countSource = ((Component)this).gameObject.AddComponent(); countSource.loop = false; countSource.playOnAwake = false; checkSource = ((Component)this).gameObject.AddComponent(); checkSource.loop = false; checkSource.playOnAwake = false; killSource = ((Component)this).gameObject.AddComponent(); killSource.loop = false; killSource.playOnAwake = false; scanDamageClip = LoadAudioClip("scandamage.mp3"); scanErrorClip = LoadAudioClip("scanerror.mp3"); scanDamageSource = ((Component)this).gameObject.AddComponent(); scanDamageSource.loop = false; scanDamageSource.playOnAwake = false; scanErrorSource = ((Component)this).gameObject.AddComponent(); scanErrorSource.loop = false; scanErrorSource.playOnAwake = false; CreateOverlay(); nextAppearTime = Random.Range(Plugin.MinSpawnTime.Value, Plugin.MaxSpawnTime.Value); } private void LoadSprites() { rememberSprites[0] = LoadSprite("remember1.png"); rememberSprites[1] = LoadSprite("remember2.png"); for (int i = 0; i < 10; i++) { numSprites[i] = LoadSprite($"num{i}.png"); } particlesSprite = LoadSprite("particles.png"); for (int j = 0; j < 6; j++) { countSprites[j] = LoadSprite($"count{j + 1}.png"); } for (int k = 0; k < 4; k++) { closingSprites[k] = LoadSprite($"closing{k + 1}.png"); } errorSprite = LoadSprite("error.png"); } private Sprite LoadSprite(string filename) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0062: 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) string text = Path.Combine(modFolder, filename); if (!File.Exists(text)) { Debug.LogError((object)("Kookoo Entity: файл не найден — " + text)); return null; } byte[] array = File.ReadAllBytes(text); Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, array); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } private void Update() { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) if (scanBlocked) { scanBlockTimer += Time.deltaTime; if (scanBlockTimer >= Plugin.ScanBlockDuration.Value) { scanBlocked = false; scanBlockTimer = 0f; } } if (scanAttackPlaying) { scanAttackTimer += Time.deltaTime; if (!(scanAttackTimer >= 0.5f)) { return; } scanAttackPlaying = false; rootObject.SetActive(false); ((Component)particlesImage).gameObject.SetActive(false); PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val != (Object)null) { int num = val.health - 1; if (num > 0) { val.DamagePlayer(num, true, true, (CauseOfDeath)0, 0, false, default(Vector3)); } } scanBlocked = true; scanBlockTimer = 0f; return; } PlayerControllerB val2 = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val2 == (Object)null) { return; } if (isOnCooldown) { cooldownTimer += Time.deltaTime; if (cooldownTimer >= cooldownTime) { isOnCooldown = false; cooldownTimer = 0f; timer = 0f; nextAppearTime = Random.Range(Plugin.MinSpawnTime.Value, Plugin.MaxSpawnTime.Value); } } else if (deathAnimPlaying) { deathTimer += Time.deltaTime; copyTimer += Time.deltaTime; if (shouldSpawnErrorSprites && (Object)(object)errorSprite != (Object)null && deathTimer >= 1f) { errorSpriteSpawnTimer += Time.deltaTime; if (errorSpriteSpawnTimer >= 0.01f) { errorSpriteSpawnTimer = 0f; SpawnErrorSprite(); } } if (copyTimer >= 0.01f) { copyTimer = 0f; CreateDeathCopy(); } if (!(deathTimer >= 2f)) { return; } deathAnimPlaying = false; shouldSpawnErrorSprites = false; deathCanvas.SetActive(false); foreach (GameObject deathCopy in deathCopies) { Object.Destroy((Object)(object)deathCopy); } deathCopies.Clear(); foreach (GameObject errorSpriteInstance in errorSpriteInstances) { if ((Object)(object)errorSpriteInstance != (Object)null) { Object.Destroy((Object)(object)errorSpriteInstance); } } errorSpriteInstances.Clear(); PlayerControllerB val3 = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val3 != (Object)null) { val3.KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 1, default(Vector3), false); } Hide(); } else if (val2.isPlayerDead) { ForceHide(); } else { if (!IsPlayerInGame()) { return; } timer += Time.deltaTime; if (currentState != 0) { AnimateBody(); } switch (currentState) { case KookooState.Hidden: if (timer >= nextAppearTime) { Appear(); } break; case KookooState.Appearing: if (timer >= Plugin.AppearDuration.Value) { StartCounting(); } break; case KookooState.Counting: UpdateCounting(); UpdateParticles(); if (countAnimPlaying) { AnimateCount(); } Shake(); break; case KookooState.WaitingClosing: if (countAnimPlaying) { AnimateCount(); } UpdateParticles(); Shake(); if (timer >= 1f) { StartClosing(); } break; case KookooState.Closing: AnimateClosing(); break; case KookooState.HoldingClose: if (!conditionChecked) { conditionChecked = true; CheckCondition(); } break; } } } private void AnimateBody() { if (currentState != KookooState.Appearing) { return; } bodyAnimTimer += Time.deltaTime; if (bodyAnimTimer >= 0.0667f) { bodyAnimTimer = 0f; bodyAnimFrame = (bodyAnimFrame + 1) % 2; if ((Object)(object)rememberSprites[bodyAnimFrame] != (Object)null) { bodyImage.sprite = rememberSprites[bodyAnimFrame]; } } } public bool IsScanBlocked() { return scanBlocked; } public void PlayScanError() { if ((Object)(object)scanErrorClip != (Object)null) { scanErrorSource.clip = scanErrorClip; scanErrorSource.Play(); } } public void TryTriggerScanAttack() { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) if (!scanAttackPlaying && Random.Range(0, Plugin.ScanAttackChance.Value) == 0) { scanAttackPlaying = true; scanAttackTimer = 0f; rootObject.SetActive(true); if ((Object)(object)closingSprites[3] != (Object)null) { bodyImage.sprite = closingSprites[3]; } ((Component)particlesImage).gameObject.SetActive(true); if ((Object)(object)scanDamageClip != (Object)null) { scanDamageSource.clip = scanDamageClip; scanDamageSource.Play(); } float num = Random.Range(-500f, 500f); float num2 = Random.Range(-250f, 250f); rootObject.GetComponent().anchoredPosition = new Vector2(num, num2); } } private void AnimateCount() { countAnimTimer += Time.deltaTime; if (!(countAnimTimer >= 0.0667f)) { return; } countAnimTimer = 0f; countAnimFrame++; if (countAnimFrame >= 6) { countAnimPlaying = false; countAnimFrame = 0; if ((Object)(object)countSprites[5] != (Object)null) { bodyImage.sprite = countSprites[5]; } } else if ((Object)(object)countSprites[countAnimFrame] != (Object)null) { bodyImage.sprite = countSprites[countAnimFrame]; } } private void AnimateClosing() { closingAnimTimer += Time.deltaTime; if (closingAnimTimer >= 0.0667f) { closingAnimTimer = 0f; closingAnimFrame++; if (closingAnimFrame >= 4) { currentState = KookooState.HoldingClose; timer = 0f; } else if ((Object)(object)closingSprites[closingAnimFrame] != (Object)null) { bodyImage.sprite = closingSprites[closingAnimFrame]; } } } private void UpdateCounting() { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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) countTimer += Time.deltaTime; if (countTimer >= Plugin.CountInterval.Value) { countTimer = 0f; currentCount++; if ((Object)(object)countClip != (Object)null) { countSource.clip = countClip; countSource.Play(); countSource.pitch = basePitch + (float)currentCount / (float)targetNumber * 0.6f; } UpdateDigits(currentCount); float num = Random.Range(-500f, 500f); float num2 = Random.Range(-250f, 250f); basePosition = new Vector2(num, num2); rootObject.GetComponent().anchoredPosition = basePosition; countAnimPlaying = true; countAnimFrame = 0; countAnimTimer = 0f; if ((Object)(object)countSprites[0] != (Object)null) { bodyImage.sprite = countSprites[0]; } if (currentCount >= targetNumber) { currentState = KookooState.WaitingClosing; timer = 0f; } } } private void UpdateParticles() { if (particlesVisible) { particlesVisibleTimer += Time.deltaTime; if (particlesVisibleTimer >= 0.2f) { particlesVisible = false; ((Component)particlesImage).gameObject.SetActive(false); } return; } particlesTimer += Time.deltaTime; if (particlesTimer >= particlesInterval) { particlesTimer = 0f; particlesInterval = Random.Range(0.1f, 1f); particlesVisible = true; particlesVisibleTimer = 0f; ((Component)particlesImage).gameObject.SetActive(true); } } private void Shake() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) shakeTimer += Time.deltaTime; if (shakeTimer >= 0.05f) { shakeTimer = 0f; float num = Random.Range(-5f, 5f); float num2 = Random.Range(-5f, 5f); rootObject.GetComponent().anchoredPosition = new Vector2(basePosition.x + num, basePosition.y + num2); } } private void UpdateDigits(int number) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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 (number < 10) { ((Component)digitImages[0]).gameObject.SetActive(false); ((Component)digitImages[1]).gameObject.SetActive(true); digitImages[1].sprite = numSprites[number]; ((Component)digitImages[1]).GetComponent().anchoredPosition = Vector2.zero; return; } int num = number / 10; int num2 = number % 10; ((Component)digitImages[0]).gameObject.SetActive(true); ((Component)digitImages[1]).gameObject.SetActive(true); digitImages[0].sprite = numSprites[num]; digitImages[1].sprite = numSprites[num2]; ((Component)digitImages[0]).GetComponent().anchoredPosition = new Vector2(-40f, 0f); ((Component)digitImages[1]).GetComponent().anchoredPosition = new Vector2(40f, 0f); } private void Appear() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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) currentState = KookooState.Appearing; timer = 0f; currentCount = 0; targetNumber = Random.Range(1, 31); float num = Random.Range(-500f, 500f); float num2 = Random.Range(-250f, 250f); basePosition = new Vector2(num, num2); rootObject.GetComponent().anchoredPosition = basePosition; if ((Object)(object)rememberClip != (Object)null) { rememberSource.clip = rememberClip; rememberSource.Play(); } rootObject.SetActive(true); if ((Object)(object)rememberSprites[0] != (Object)null) { bodyImage.sprite = rememberSprites[0]; } UpdateDigits(targetNumber); } private void StartCounting() { currentState = KookooState.Counting; timer = 0f; countTimer = 0f; currentCount = 0; UpdateDigits(0); countSource.pitch = basePitch; } private void StartClosing() { conditionChecked = false; currentState = KookooState.Closing; closingAnimFrame = 0; closingAnimTimer = 0f; countAnimPlaying = false; ((Component)digitImages[0]).gameObject.SetActive(false); ((Component)digitImages[1]).gameObject.SetActive(false); ((Component)particlesImage).gameObject.SetActive(false); if ((Object)(object)checkClip != (Object)null) { checkSource.clip = checkClip; checkSource.Play(); } if ((Object)(object)closingSprites[0] != (Object)null) { bodyImage.sprite = closingSprites[0]; } } public void CheckCondition() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { Hide(); } else if ((Object)(object)val.currentlyHeldObjectServer != (Object)null) { if ((Object)(object)killClip != (Object)null) { killSource.clip = killClip; killSource.Play(); } deathAnimPlaying = true; shouldSpawnErrorSprites = true; errorSpriteSpawnTimer = 0f; deathTimer = 0f; copyTimer = 0f; lastClosingSprite = closingSprites[3]; deathCanvas.SetActive(true); rootObject.SetActive(true); } else { Hide(); } } private void SpawnErrorSprite() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("KookooErrorSpriteCanvas"); Canvas val2; if ((Object)(object)val == (Object)null) { val = new GameObject("KookooErrorSpriteCanvas"); val2 = val.AddComponent(); val2.renderMode = (RenderMode)0; val2.sortingOrder = 10000; Object.DontDestroyOnLoad((Object)(object)val); } else { val2 = val.GetComponent(); } GameObject val3 = new GameObject("KookooErrorSprite"); val3.transform.SetParent(((Component)val2).transform, false); Image val4 = val3.AddComponent(); val4.sprite = errorSprite; RectTransform component = val3.GetComponent(); Rect rect = errorSprite.rect; float width = ((Rect)(ref rect)).width; rect = errorSprite.rect; component.sizeDelta = new Vector2(width, ((Rect)(ref rect)).height); component.anchoredPosition = new Vector2((float)Random.Range(-Screen.width / 2 + 160, Screen.width / 2 - 160), (float)Random.Range(-Screen.height / 2 + 80, Screen.height / 2 - 80)); errorSpriteInstances.Add(val3); } private void CreateDeathCopy() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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) float num = Random.Range((float)(-Screen.width) * 0.5f, (float)Screen.width * 0.5f); float num2 = Random.Range((float)(-Screen.height) * 0.5f, (float)Screen.height * 0.5f); GameObject val = new GameObject("KookooCopy"); val.transform.SetParent(deathCanvas.transform, false); Image val2 = val.AddComponent(); val2.sprite = lastClosingSprite; RectTransform component = val.GetComponent(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(800f, 800f); component.anchoredPosition = new Vector2(num, num2); deathCopies.Add(val); } private void Hide() { currentState = KookooState.Hidden; timer = 0f; rootObject.SetActive(false); isOnCooldown = true; cooldownTimer = 0f; cooldownTime = Plugin.CooldownTime.Value; ((Component)particlesImage).gameObject.SetActive(false); rememberSource.Stop(); countSource.Stop(); checkSource.Stop(); killSource.Stop(); } public void ForceHide() { currentState = KookooState.Hidden; timer = 0f; rootObject.SetActive(false); isOnCooldown = false; ((Component)particlesImage).gameObject.SetActive(false); ((MonoBehaviour)this).CancelInvoke("StartClosing"); deathAnimPlaying = false; shouldSpawnErrorSprites = false; if ((Object)(object)deathCanvas != (Object)null) { deathCanvas.SetActive(false); } foreach (GameObject deathCopy in deathCopies) { Object.Destroy((Object)(object)deathCopy); } deathCopies.Clear(); foreach (GameObject errorSpriteInstance in errorSpriteInstances) { if ((Object)(object)errorSpriteInstance != (Object)null) { Object.Destroy((Object)(object)errorSpriteInstance); } } errorSpriteInstances.Clear(); rememberSource.Stop(); countSource.Stop(); checkSource.Stop(); killSource.Stop(); } public void ResetKookoo() { ForceHide(); nextAppearTime = Random.Range(Plugin.MinSpawnTime.Value, Plugin.MaxSpawnTime.Value); cooldownTimer = 0f; } private bool IsPlayerInGame() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { return false; } if (val.isPlayerDead) { return false; } if (StartOfRound.Instance?.currentLevel?.sceneName == "CompanyBuilding") { return false; } return !val.isInHangarShipRoom && (Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.shipHasLanded; } private void CreateOverlay() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00b3: 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_00df: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0191: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("KookooCanvas"); Canvas val2 = val.AddComponent(); val2.renderMode = (RenderMode)0; val2.sortingOrder = 100; Object.DontDestroyOnLoad((Object)(object)val); deathCanvas = new GameObject("KookooDeathCanvas"); Canvas val3 = deathCanvas.AddComponent(); val3.renderMode = (RenderMode)0; val3.sortingOrder = 200; Object.DontDestroyOnLoad((Object)(object)deathCanvas); deathCanvas.SetActive(false); rootObject = new GameObject("KookooRoot"); rootObject.transform.SetParent(val.transform, false); RectTransform val4 = rootObject.AddComponent(); val4.anchorMin = new Vector2(0.5f, 0.5f); val4.anchorMax = new Vector2(0.5f, 0.5f); val4.sizeDelta = new Vector2(800f, 800f); val4.anchoredPosition = Vector2.zero; GameObject val5 = new GameObject("KookooParticles"); val5.transform.SetParent(rootObject.transform, false); particlesImage = val5.AddComponent(); if ((Object)(object)particlesSprite != (Object)null) { particlesImage.sprite = particlesSprite; } RectTransform component = val5.GetComponent(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.sizeDelta = Vector2.zero; val5.SetActive(false); GameObject val6 = new GameObject("KookooBody"); val6.transform.SetParent(rootObject.transform, false); bodyImage = val6.AddComponent(); RectTransform component2 = val6.GetComponent(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = Vector2.zero; for (int i = 0; i < 2; i++) { GameObject val7 = new GameObject($"KookooDigit_{i}"); val7.transform.SetParent(rootObject.transform, false); digitImages[i] = val7.AddComponent(); RectTransform component3 = val7.GetComponent(); component3.anchorMin = new Vector2(0.5f, 0.5f); component3.anchorMax = new Vector2(0.5f, 0.5f); component3.sizeDelta = new Vector2(800f, 800f); component3.anchoredPosition = new Vector2(((float)i - 0.5f) * 35f, 0f); val7.SetActive(false); } rootObject.SetActive(false); } } [HarmonyPatch(typeof(PlayerControllerB), "Start")] public class KookooPatch { private static void Postfix(PlayerControllerB __instance) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown if (((NetworkBehaviour)__instance).IsOwner && !((Object)(object)Object.FindObjectOfType() != (Object)null)) { int num = Random.Range(0, 100); if (num >= Plugin.SpawnChance.Value) { Debug.Log((object)$"Kookoo Entity: не появится в этом раунде (бросок {num})"); return; } GameObject val = new GameObject("KookooManager"); val.AddComponent(); Object.DontDestroyOnLoad((Object)(object)val); Debug.Log((object)"Kookoo Entity: менеджер создан!"); } } } [HarmonyPatch(typeof(PlayerControllerB), "SpawnDeadAnimation")] public class KookooRespawnPatch { private static void Postfix(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner) { KookooBehaviour kookooBehaviour = Object.FindObjectOfType(); if ((Object)(object)kookooBehaviour != (Object)null) { kookooBehaviour.ResetKookoo(); } } } } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] public class KookooDeathPatch { private static void Postfix(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner) { KookooBehaviour kookooBehaviour = Object.FindObjectOfType(); if ((Object)(object)kookooBehaviour != (Object)null) { kookooBehaviour.ForceHide(); } } } } [HarmonyPatch(typeof(HUDManager), "CanPlayerScan")] public class TestPatch { private static void Postfix() { Debug.Log((object)"MethodFinder: CanPlayerScan!"); } } public class KookooScanPatch { public static void OnScan() { Debug.Log((object)"Kookoo: скан нажат!"); KookooBehaviour kookooBehaviour = Object.FindObjectOfType(); if ((Object)(object)kookooBehaviour != (Object)null) { kookooBehaviour.TryTriggerScanAttack(); } } } [BepInPlugin("com.yourname.kookooentity", "Kookoo Entity", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("com.yourname.kookooentity"); public static ConfigEntry SpawnChance; public static ConfigEntry MinSpawnTime; public static ConfigEntry MaxSpawnTime; public static ConfigEntry CooldownTime; public static ConfigEntry AppearDuration; public static ConfigEntry CountInterval; public static ConfigEntry ScanAttackChance; public static ConfigEntry ScanBlockDuration; private void Awake() { SpawnChance = ((BaseUnityPlugin)this).Config.Bind("General", "SpawnChance", 50, "Chance of Kookoo appearing each round (0-100)"); MinSpawnTime = ((BaseUnityPlugin)this).Config.Bind("Timing", "MinSpawnTime", 30f, "Minimum time before Kookoo appears"); MaxSpawnTime = ((BaseUnityPlugin)this).Config.Bind("Timing", "MaxSpawnTime", 90f, "Maximum time before Kookoo appears"); CooldownTime = ((BaseUnityPlugin)this).Config.Bind("Timing", "CooldownTime", 60f, "Cooldown before Kookoo can appear again"); AppearDuration = ((BaseUnityPlugin)this).Config.Bind("Timing", "AppearDuration", 2f, "Time Kookoo shows the number before counting"); CountInterval = ((BaseUnityPlugin)this).Config.Bind("Timing", "CountInterval", 1f, "Time between each count"); ScanAttackChance = ((BaseUnityPlugin)this).Config.Bind("Scan", "ScanAttackChance", 5, "1 in X chance of Kookoo appearing on scan"); ScanBlockDuration = ((BaseUnityPlugin)this).Config.Bind("Scan", "ScanBlockDuration", 30f, "How long scan is blocked after Kookoo attack"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Kookoo Entity loaded!"); harmony.PatchAll(); } }