using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CHZZK_Donation_Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CHZZK_Donation_Mod")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("51fa1d01-e1cc-408f-bfce-66ff3ba8708f")]
[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 CHZZK_Donation_Mod;
[BepInPlugin("Poseidon.CHZZK_DonateMod", "CHZZK Donate Mod", "1.0.1")]
public class DonateModBase : BaseUnityPlugin
{
[Serializable]
public class DonationDetect
{
public int DonationAmount;
public bool NewDonation;
}
private const string modGUID = "Poseidon.CHZZK_DonateMod";
private const string modName = "CHZZK Donate Mod";
private const string modVersion = "1.0.1";
private readonly Harmony harmony = new Harmony("Poseidon.CHZZK_DonateMod");
internal static DonateModBase Instance;
internal static ManualLogSource mls;
private static int outsideMinCount;
private static int outsideMaxCount;
private static List<string> outsideNames;
private static float outsideSpawnChance;
private static int insideMinCount;
private static int insideMaxCount;
private static List<string> insideNames;
private static float insideSpawnChance;
private static bool insideSpawned;
private static float playerCountScaling;
private static bool onlyScaleMax;
internal bool EnemySpawnsFixed = false;
public static bool checkBool = false;
public static RoundManager rma;
public static PlayerControllerB playerScript;
public static GameObject playerObj;
public static ItemDropship itemDropship;
public static StartOfRound startOfRound;
public static HUDManager hudManager;
private static string LethalFolder = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Lethal Company\\Lethal Company_Data\\DonationDetect.json";
private DonationDetect donationDetect = new DonationDetect();
private string path;
private string jsonTxt;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("CHZZK_Donation_Mod.DonateModBase");
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Poseidon.CHZZK_DonateMod");
mls.LogInfo((object)"Mod Awake Success!");
mls = ((BaseUnityPlugin)this).Logger;
Debug.Log((object)"확인시작");
ConfigEntry<string> val2 = ((BaseUnityPlugin)this).Config.Bind<string>("Folder", "FolderPath", "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Lethal Company\\Lethal Company_Data", "Lethal Company Data Folder file path");
LethalFolder = val2.Value + "\\DonationDetect.json";
Harmony.CreateAndPatchAll(typeof(DonateModBase), (string)null);
Reset();
}
private static List<SpawnableEnemyWithRarity> GetEnemies()
{
Debug.Log((object)"GETTING ENEMIES");
List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
list = (from x in GameObject.Find("Terminal").GetComponentInChildren<Terminal>().moonsCatalogueList.SelectMany((SelectableLevel x) => x.Enemies.Concat(x.DaytimeEnemies).Concat(x.OutsideEnemies))
where x != null && (Object)(object)x.enemyType != (Object)null && ((Object)x.enemyType).name != null
select x).GroupBy((SpawnableEnemyWithRarity x) => ((Object)x.enemyType).name, (string k, IEnumerable<SpawnableEnemyWithRarity> v) => v.First()).ToList();
Debug.Log((object)$"Enemy types: {list.Count}");
return list;
}
[HarmonyPatch(typeof(EnemyAI), "PlayerIsTargetable")]
[HarmonyPrefix]
private static bool PatchTargetable(object[] __args, ref bool __result, ref EnemyAI __instance)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
PlayerControllerB val = (PlayerControllerB)__args[0];
bool flag = (bool)__args[1];
bool flag2 = true;
if (flag && val.isInHangarShipRoom)
{
__result = false;
return false;
}
if (val.isPlayerControlled && !val.isPlayerDead && (Object)val.inAnimationWithEnemy == (Object)null && (flag2 || val.isInsideFactory != __instance.isOutside) && val.sinkingValue < 0.73f)
{
if (__instance.isOutside && StartOfRound.Instance.hangarDoorsClosed)
{
__result = val.isInHangarShipRoom == __instance.isInsidePlayerShip;
return false;
}
__result = true;
return false;
}
__result = false;
return false;
}
[HarmonyPatch(typeof(EnemyVent), "Start")]
[HarmonyPostfix]
private static void SpawnInsideEnemies()
{
Random random = new Random();
RoundManager instance = RoundManager.Instance;
int connectedPlayers = GameNetworkManager.Instance.connectedPlayers;
float num = ((playerCountScaling > 0f) ? ((float)connectedPlayers * playerCountScaling) : 1f);
if (!insideSpawned && random.NextDouble() < (double)insideSpawnChance && (((NetworkBehaviour)instance).NetworkManager.IsServer || ((NetworkBehaviour)instance).NetworkManager.IsHost))
{
GameObject[] array = GameObject.FindGameObjectsWithTag("EnemySpawn");
List<SpawnableEnemyWithRarity> enemies = GetEnemies();
List<string> list = enemies.Select((SpawnableEnemyWithRarity x) => ((Object)x.enemyType).name).ToList();
int minValue = (onlyScaleMax ? insideMinCount : ((int)((float)insideMinCount * num)));
int maxValue = (int)((float)insideMaxCount * num);
IEnumerable<string> source = insideNames.Intersect(list);
List<string> source2 = ((source.Count() > 0) ? insideNames : list);
for (int i = 0; i < random.Next(minValue, maxValue); i++)
{
string text = source2.ElementAt(random.Next(insideNames.Count()));
Debug.Log((object)("Spawning a " + text + " inside"));
}
insideSpawned = true;
}
}
[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
[HarmonyPostfix]
private static void SpawnOutsideEnemies()
{
Random random = new Random();
RoundManager instance = RoundManager.Instance;
int connectedPlayers = GameNetworkManager.Instance.connectedPlayers;
float num = ((playerCountScaling > 0f) ? ((float)connectedPlayers * playerCountScaling) : 1f);
if (!(random.NextDouble() < (double)outsideSpawnChance) || (!((NetworkBehaviour)instance).NetworkManager.IsServer && !((NetworkBehaviour)instance).NetworkManager.IsHost))
{
return;
}
List<SpawnableEnemyWithRarity> enemies = GetEnemies();
List<string> list = enemies.Select((SpawnableEnemyWithRarity x) => ((Object)x.enemyType).name).ToList();
foreach (string item in list)
{
Debug.Log((object)item);
}
int minValue = (onlyScaleMax ? outsideMinCount : ((int)((float)outsideMinCount * num)));
int maxValue = (int)((float)outsideMaxCount * num);
IEnumerable<string> source = outsideNames.Intersect(list);
List<string> source2 = ((source.Count() > 0) ? outsideNames : list);
for (int i = 0; i < random.Next(minValue, maxValue); i++)
{
string text = source2.ElementAt(random.Next(source2.Count()));
Debug.Log((object)("Spawning a " + text + " outside"));
}
}
public static void SpawnEnemyFromVent(EnemyVent vent, RoundManager rm, string enemyName, Transform transform)
{
//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_002b: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_006d: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"SpawnEnemyFromVent");
Vector3 position = vent.floorNode.position;
float y = vent.floorNode.eulerAngles.y;
EnemyType enemyType = GetEnemies().Find((SpawnableEnemyWithRarity x) => ((Object)x.enemyType).name == enemyName).enemyType;
enemyType.isOutsideEnemy = false;
if ((Object)(object)transform != (Object)null)
{
position = transform.position;
}
NetworkObjectReference val = rm.SpawnEnemyGameObject(position, y, vent.enemyTypeIndex, enemyType);
}
public static void SpawnEnemyOutside(RoundManager rm, string enemyName, Transform transform)
{
//IL_003a: 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_0041: 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_004f: 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_005d: 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)
//IL_007a: 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_00d5: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"SpawnEnemyOutside");
GameObject[] array = GameObject.FindGameObjectsWithTag("OutsideAINode");
Vector3 position = array[rm.AnomalyRandom.Next(0, array.Length)].transform.position;
position = rm.GetRandomNavMeshPositionInRadius(position, 4f, default(NavMeshHit));
bool flag = false;
Debug.Log((object)position);
Debug.Log((object)$"Anomaly random 4: {position.x}, {position.y}, {position.z}");
EnemyType enemyType = GetEnemies().Find((SpawnableEnemyWithRarity x) => ((Object)x.enemyType).name == enemyName).enemyType;
enemyType.isOutsideEnemy = true;
if ((Object)(object)transform != (Object)null)
{
position = transform.position;
}
NetworkObjectReference val = rm.SpawnEnemyGameObject(position, 0f, 0, enemyType);
}
[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
[HarmonyPatch(typeof(PlayerControllerB))]
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void InputSpawn(ref float ___sprintMeter)
{
//IL_004e: 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_0086: 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)
RoundManager instance = RoundManager.Instance;
if (((ButtonControl)Keyboard.current.digit4Key).isPressed)
{
Debug.Log((object)"4번키완료");
GameObject val = StartOfRound.Instance.allPlayerObjects[0];
Random random = new Random();
GameObject[] array = GameObject.FindGameObjectsWithTag("EnemySpawn");
float num = Vector3.Distance(val.transform.position, array[0].transform.position);
GameObject val2 = array[0];
GameObject[] array2 = array;
foreach (GameObject val3 in array2)
{
float num2 = Vector3.Distance(val.transform.position, val3.transform.position);
if (num2 < num)
{
val2 = val3;
num = num2;
}
}
SpawnEnemyFromVent(val2.GetComponent<EnemyVent>(), instance, "SandSpider", null);
Debug.Log((object)"4번키종료");
}
if (((ButtonControl)Keyboard.current.digit3Key).isPressed)
{
Debug.Log((object)"3Key Detect");
mls.LogInfo((object)"3Key");
SpawnEnemyOutside(instance, "SpringMan", null);
___sprintMeter = 1f;
}
if (((ButtonControl)Keyboard.current.digit5Key).isPressed)
{
startOfRound = StartOfRound.Instance;
if (startOfRound.inShipPhase)
{
Debug.Log((object)"함선우주");
}
else
{
Debug.Log((object)"함선착륙");
}
}
if (((ButtonControl)Keyboard.current.digit8Key).isPressed)
{
hudManager = HUDManager.Instance;
hudManager.AddTextToChatOnServer("AAAAAAAAAAAAA", -1);
}
}
public void Amount(int amount, GameObject playerObj2, PlayerControllerB playerCtrl2)
{
EventList eventList = new EventList();
Debug.Log((object)"이벤트시작");
eventList.SpawnEvent(amount, playerObj2, playerCtrl2);
}
public static void DefinePlayerController()
{
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
for (int i = 0; i < array.Length; i++)
{
if (((NetworkBehaviour)array[i]).IsOwner)
{
playerScript = array[i];
}
}
}
public void Chat()
{
if ((Object)(object)HUDManager.Instance != (Object)null)
{
hudManager = HUDManager.Instance;
DefinePlayerController();
if (hudManager.lastChatMessage != "")
{
Debug.Log((object)("마지막 채팅" + hudManager.lastChatMessage + playerScript.actualClientId));
hudManager.lastChatMessage = "";
}
if (hudManager.ChatMessageHistory.Contains("a"))
{
Debug.Log((object)"A발견");
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
[HarmonyPatch("Update")]
private void Update()
{
Chat();
LoadCheckFile();
}
public void Reset()
{
path = LethalFolder;
donationDetect.DonationAmount = 0;
donationDetect.NewDonation = false;
jsonTxt = File.ReadAllText(path);
string contents = JsonUtility.ToJson((object)donationDetect, true);
File.WriteAllText(path, contents);
Debug.Log((object)"초기화");
Debug.Log((object)donationDetect.DonationAmount);
Debug.Log((object)donationDetect.NewDonation);
}
public void LoadCheckFile()
{
path = LethalFolder;
string text = File.ReadAllText(path);
donationDetect = JsonUtility.FromJson<DonationDetect>(text);
if (donationDetect.NewDonation)
{
DonateEventStart();
}
}
public void DonateEventStart()
{
Debug.Log((object)"가격과 활성화");
Debug.Log((object)donationDetect.DonationAmount);
Debug.Log((object)donationDetect.NewDonation);
DefinePlayerController();
Amount(donationDetect.DonationAmount, ((Component)playerScript).gameObject, playerScript);
Debug.Log((object)"밸류변경 성공");
donationDetect.DonationAmount = 0;
donationDetect.NewDonation = false;
Reset();
}
}
public class EventList : MonoBehaviour
{
public GameObject playerObj;
public PlayerControllerB playerCtrl;
public void SpawnEvent(int pay, GameObject playerObj2, PlayerControllerB playerCtrl2)
{
//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)
Debug.Log((object)"생성이벤트시작");
Vector3 position = playerObj2.transform.position;
bool isInsideFactory = playerCtrl2.isInsideFactory;
playerCtrl = playerCtrl2;
playerObj = playerObj2;
if (isInsideFactory)
{
switch (pay)
{
case 1000:
InSpawnPack("Blob", null);
break;
case 2000:
InSpawnPack("SandSpider", null);
break;
case 3000:
StillRun(isInsideFactory);
break;
}
}
else
{
switch (pay)
{
case 1000:
OutSpawnPack("MouthDog", null);
break;
case 2000:
OutSpawnPack("ForestGiant", null);
break;
case 3000:
StillRun(isInsideFactory);
break;
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
[HarmonyPostfix]
public void StillRun(bool inside)
{
Debug.Log((object)"아이템 떨구기");
playerCtrl.DropAllHeldItemsAndSync();
for (int i = 0; i < 3; i++)
{
if (inside)
{
InSpawnPack("HoarderBug", ((Component)playerCtrl).transform);
}
else
{
OutSpawnPack("HoarderBug", ((Component)playerCtrl).transform);
}
}
}
public void InSpawnPack(string name, Transform transform)
{
//IL_0030: 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_0065: 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)
RoundManager instance = RoundManager.Instance;
Debug.Log((object)"4번키완료");
GameObject val = playerObj;
Random random = new Random();
GameObject[] array = GameObject.FindGameObjectsWithTag("EnemySpawn");
float num = Vector3.Distance(val.transform.position, array[0].transform.position);
GameObject val2 = array[0];
GameObject[] array2 = array;
foreach (GameObject val3 in array2)
{
float num2 = Vector3.Distance(val.transform.position, val3.transform.position);
if (num2 < num)
{
val2 = val3;
num = num2;
}
}
DonateModBase.SpawnEnemyFromVent(val2.GetComponent<EnemyVent>(), instance, name, transform);
Debug.Log((object)"실내몹소환");
}
public void OutSpawnPack(string name, Transform transform)
{
Debug.Log((object)("소환된 야외몹" + name));
RoundManager instance = RoundManager.Instance;
DonateModBase.SpawnEnemyOutside(instance, name, transform);
}
}