Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Vietnam v1.6.0
plugins/Vietnam.dll
Decompiled a day agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Aurate")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Vietnam")] [assembly: AssemblyTitle("Vietnam")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 Vietnam { [BepInPlugin("Aurate.Vietnam", "Vietnam", "1.6.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class VietnamPlugin : BaseUnityPlugin { internal static ManualLogSource Log = null; internal static ConfigFile PluginConfig = null; internal static VietnamPlugin Instance = null; public static ConfigEntry<int> DefaultExtraClones = null; public static ConfigEntry<int> MaxTotalEnemies = null; public static ConfigEntry<int> PhotonMaxViewIds = null; public static readonly Dictionary<string, ConfigEntry<int>> EnemyConfigEntries = new Dictionary<string, ConfigEntry<int>>(StringComparer.OrdinalIgnoreCase); public static ConfigEntry<float> CosmeticBoxChancePercent = null; public static ConfigEntry<int> CosmeticBoxMaxPerLevel = null; public static ConfigEntry<int> HuntersOnCommon = null; public static ConfigEntry<int> HuntersOnUncommon = null; public static ConfigEntry<int> HuntersOnRare = null; public static ConfigEntry<int> HuntersOnUltraRare = null; public static ConfigEntry<int> HuntersOnHunterDeath = null; public static ConfigEntry<float> DeadHunterCleanupDelay = null; public static ConfigEntry<bool> EnableShopKeeperGamble = null; public static ConfigEntry<float> ShopKeeperHitCooldown = null; public static ConfigEntry<bool> AllowGambleWhileSleeping = null; private void Awake() { //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; PluginConfig = ((BaseUnityPlugin)this).Config; DefaultExtraClones = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DefaultExtraClones", 2, "Сколько ДОПОЛНИТЕЛЬНЫХ копий врага спавнить по умолчанию (если для врага ниже указано -1)."); MaxTotalEnemies = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxTotalEnemies", 100, "Максимальное общее число врагов на уровне."); PhotonMaxViewIds = ((BaseUnityPlugin)this).Config.Bind<int>("General", "PhotonMaxViewIds", 5000, "Расширенный лимит сетевых объектов Photon на одного игрока (в оригинале 1000). Позволяет спавнить 100+ мобов без вылета сети. Для работы в кооперативе мод должен стоять у всех игроков."); CosmeticBoxChancePercent = ((BaseUnityPlugin)this).Config.Bind<float>("CosmeticBoxes", "SpawnChancePercent", 60f, "Шанс спавна косметической коробки (в процентах от 0 до 100). В оригинале растёт от 20% до 60%."); CosmeticBoxMaxPerLevel = ((BaseUnityPlugin)this).Config.Bind<int>("CosmeticBoxes", "MaxBoxesPerLevel", 2, "Максимальное количество попыток спавна коробок на одном уровне (в оригинале обычно 1)."); HuntersOnCommon = ((BaseUnityPlugin)this).Config.Bind<int>("CosmeticBoxes_Hunters", "Hunters_Common", 5, "Сколько Дедов с ружьем (Huntsman) заспавнится при сдаче ОБЫЧНОЙ (зелёной / Common) коробки."); HuntersOnUncommon = ((BaseUnityPlugin)this).Config.Bind<int>("CosmeticBoxes_Hunters", "Hunters_Uncommon", 7, "Сколько Дедов с ружьем (Huntsman) заспавнится при сдаче НЕОБЫЧНОЙ (синей / Uncommon) коробки."); HuntersOnRare = ((BaseUnityPlugin)this).Config.Bind<int>("CosmeticBoxes_Hunters", "Hunters_Rare", 9, "Сколько Дедов с ружьем (Huntsman) заспавнится при сдаче РЕДКОЙ (розовой / Rare) коробки."); HuntersOnUltraRare = ((BaseUnityPlugin)this).Config.Bind<int>("CosmeticBoxes_Hunters", "Hunters_UltraRare", 15, "Сколько Дедов с ружьем (Huntsman) заспавнится при сдаче УЛЬТРА-РЕДКОЙ (жёлтой / UltraRare) коробки."); HuntersOnHunterDeath = ((BaseUnityPlugin)this).Config.Bind<int>("CosmeticBoxes_Hunters", "HuntersOnHunterDeath", 2, "Сколько новых Дедов с ружьем заспавнится взамен каждого УБИТОГО Деда (0 = отключить замену)."); DeadHunterCleanupDelay = ((BaseUnityPlugin)this).Config.Bind<float>("CosmeticBoxes_Hunters", "DeadHunterCleanupDelay", 0.25f, "Задержка (в секундах) перед полным удалением трупа убитого Деда со сцены (чтобы успела выпасть ценность/душа)."); EnableShopKeeperGamble = ((BaseUnityPlugin)this).Config.Bind<bool>("ShopKeeper_Gamble", "EnableShopKeeperGamble", true, "Включить рулетку денег при ударе по турели-продавцу (ShopKeeper) в магазине."); ShopKeeperHitCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("ShopKeeper_Gamble", "HitCooldownSeconds", 1.5f, "Задержка (в секундах) между срабатываниями рулетки, чтобы один удар не срабатывал несколько раз."); AllowGambleWhileSleeping = ((BaseUnityPlugin)this).Config.Bind<bool>("ShopKeeper_Gamble", "AllowWhileSleeping", false, "Разрешить срабатывание рулетки, если продавец выключен (спит)."); PhotonViewLimitPatch.ApplyPhotonLimit(); Harmony val = new Harmony("AuthorName.Vietnam"); val.PatchAll(); Log.LogInfo((object)$"VietnamPlugin (v1.6.0) загружен! Лимит Photon ViewIDs: {PhotonMaxViewIds.Value}"); } internal static void RegisterAllEnemiesInConfig() { if (Enemies.AllEnemies == null) { return; } foreach (EnemySetup allEnemy in Enemies.AllEnemies) { if (!((Object)(object)allEnemy == (Object)null) && !string.IsNullOrWhiteSpace(((Object)allEnemy).name)) { string text = ((Object)allEnemy).name.Replace("Enemy - ", "").Trim(); if (!EnemyConfigEntries.ContainsKey(text)) { string text2 = SanitizeConfigKey(text); ConfigEntry<int> value = PluginConfig.Bind<int>("Enemies", text2, -1, "Враг: " + text + ". Значение по умолчанию: -1 (использовать DefaultExtraClones). Укажите 0, чтобы отключить клонирование этого врага, или любое число (1, 2, 3...) для точного количества копий."); EnemyConfigEntries[text] = value; } } } } private static string SanitizeConfigKey(string key) { char[] array = new char[8] { '=', '\n', '\t', '\\', '"', '\'', '[', ']' }; char[] array2 = array; foreach (char c in array2) { key = key.Replace(c.ToString(), ""); } return key.Trim(); } public static int GetClonesCountForEnemy(string enemyName) { if (string.IsNullOrWhiteSpace(enemyName)) { return DefaultExtraClones.Value; } foreach (KeyValuePair<string, ConfigEntry<int>> enemyConfigEntry in EnemyConfigEntries) { if (enemyName.IndexOf(enemyConfigEntry.Key, StringComparison.OrdinalIgnoreCase) >= 0 || enemyConfigEntry.Key.IndexOf(enemyName, StringComparison.OrdinalIgnoreCase) >= 0) { int value = enemyConfigEntry.Value.Value; return (value >= 0) ? value : DefaultExtraClones.Value; } } return DefaultExtraClones.Value; } public static int GetHuntersCountForRarity(Rarity rarity) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected I4, but got Unknown if (1 == 0) { } int result = (int)rarity switch { 0 => HuntersOnCommon.Value, 1 => HuntersOnUncommon.Value, 2 => HuntersOnRare.Value, 3 => HuntersOnUltraRare.Value, _ => 1, }; if (1 == 0) { } return result; } public static EnemySetup? FindHunterSetup() { if (Enemies.AllEnemies == null) { return null; } return ((IEnumerable<EnemySetup>)Enemies.AllEnemies).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup e) => (Object)(object)e != (Object)null && (((Object)e).name.IndexOf("Hunter", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)e).name.IndexOf("Huntsman", StringComparison.OrdinalIgnoreCase) >= 0))); } } public static class PhotonViewLimitPatch { public static void ApplyPhotonLimit() { try { int num = Mathf.Clamp(VietnamPlugin.PhotonMaxViewIds.Value, 1000, 30000); FieldInfo field = typeof(PhotonNetwork).GetField("MAX_VIEW_IDS", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && !field.IsLiteral) { field.SetValue(null, num); VietnamPlugin.Log.LogInfo((object)$"PhotonNetwork.MAX_VIEW_IDS изменён на {num}"); } } catch (Exception ex) { VietnamPlugin.Log.LogWarning((object)("Не удалось изменить поле MAX_VIEW_IDS напрямую (будет использован Transpiler): " + ex.Message)); } } public static void SafeNetworkDestroy(GameObject? targetObj) { if ((Object)(object)targetObj == (Object)null) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView[] componentsInChildren = targetObj.GetComponentsInChildren<PhotonView>(true); PhotonView component = targetObj.GetComponent<PhotonView>(); if ((Object)(object)component != (Object)null && component.ViewID > 0 && (component.IsMine || PhotonNetwork.IsMasterClient)) { try { PhotonNetwork.Destroy(targetObj); return; } catch { } } PhotonView[] array = componentsInChildren; foreach (PhotonView val in array) { if ((Object)(object)val != (Object)null && val.ViewID > 0) { PhotonNetwork.LocalCleanPhotonView(val); } } } Object.Destroy((Object)(object)targetObj); } } [HarmonyPatch(typeof(PhotonNetwork), "AllocateViewID", new Type[] { typeof(bool) })] public class PhotonAllocateViewIdTranspiler { [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { int customLimit = Mathf.Clamp(VietnamPlugin.PhotonMaxViewIds.Value, 1000, 30000); foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldc_I4 && instruction.operand is int val && val == 1000) { yield return new CodeInstruction(OpCodes.Ldc_I4, (object)customLimit); } else { yield return instruction; } } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class PhotonViewOwnerActorNrPatch { [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { int customLimit = Mathf.Clamp(VietnamPlugin.PhotonMaxViewIds.Value, 1000, 30000); foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldc_I4 && instruction.operand is int val && val == 1000) { yield return new CodeInstruction(OpCodes.Ldc_I4, (object)customLimit); } else { yield return instruction; } } } } [HarmonyPatch(typeof(ShopKeeper), "OnTriggerEnterLogic")] public class ShopKeeperGamblePatch { private static float lastGambleTime = -999f; [HarmonyPrefix] private static void Prefix(ShopKeeper __instance, out State __state) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) __state = (State)((!((Object)(object)__instance != (Object)null)) ? 3 : ((int)__instance.currentState)); } [HarmonyPostfix] private static void Postfix(ShopKeeper __instance, Collider other, State __state) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) if (!VietnamPlugin.EnableShopKeeperGamble.Value || !SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)__instance == (Object)null || (Object)(object)other == (Object)null || !other.isTrigger || (!VietnamPlugin.AllowGambleWhileSleeping.Value && (int)__state == 0)) { return; } HurtCollider component = ((Component)other).GetComponent<HurtCollider>(); if ((Object)(object)component == (Object)null || component.enemyDamage <= 0 || Time.time - lastGambleTime < VietnamPlugin.ShopKeeperHitCooldown.Value) { return; } lastGambleTime = Time.time; int num = SemiFunc.StatGetRunCurrency(); if (num <= 0) { SemiFunc.UIBigMessage("НА СЧЕТУ $0K — СТАВКА НЕ СЫГРАЛА!", "{!}", 20f, Color.gray, Color.white); return; } int num2 = Random.Range(-num, num + 1); int num3 = Mathf.Max(0, num + num2); SemiFunc.StatSetRunCurrency(num3); if ((Object)(object)CurrencyUI.instance != (Object)null) { CurrencyUI.instance.FetchCurrency(); } if ((Object)(object)RoundDirector.instance != (Object)null && (Object)(object)RoundDirector.instance.extractionPointCurrent != (Object)null) { Traverse.Create((object)RoundDirector.instance.extractionPointCurrent).Method("UpdateHaulTextShop", Array.Empty<object>()).GetValue(); } if (num2 > 0) { SemiFunc.UIBigMessage($"КАМЕРА ОДОБРЯЕТ: +${num2}K!", "{$$}", 25f, Color.green, Color.white); VietnamPlugin.Log.LogInfo((object)$"[ShopKeeper Gamble] Выигрыш +${num2}K! Было: {num}K -> Стало: {num3}K"); } else if (num2 < 0) { SemiFunc.UIBigMessage($"ШТРАФ ОТ КАМЕРЫ: -${Mathf.Abs(num2)}K!", "{X}", 25f, Color.red, Color.white); VietnamPlugin.Log.LogInfo((object)$"[ShopKeeper Gamble] Проигрыш -${Mathf.Abs(num2)}K! Было: {num}K -> Стало: {num3}K"); } else { SemiFunc.UIBigMessage("КАМЕРА ПОЩАДИЛА: $0K", "{!}", 22f, Color.yellow, Color.white); VietnamPlugin.Log.LogInfo((object)$"[ShopKeeper Gamble] Выпал 0! Баланс остался: {num}K"); } } } [HarmonyPatch(typeof(ValuableDirector), "SetupHost")] public class ValuableDirectorCosmeticChancePatch { [HarmonyPrefix] private static void Prefix(ValuableDirector __instance) { float num = Mathf.Clamp01(VietnamPlugin.CosmeticBoxChancePercent.Value / 100f); __instance.cosmeticWorldObjectsSpawnCurve = AnimationCurve.Constant(0f, 1f, num); if (VietnamPlugin.CosmeticBoxMaxPerLevel.Value > 1) { __instance.cosmeticWorldObjectsLevelLoop = 1; __instance.cosmeticWorldObjectsLevelLoopsMax = VietnamPlugin.CosmeticBoxMaxPerLevel.Value - 1; } } } [HarmonyPatch(typeof(ValuableDirector), "CosmeticWorldObjectLevelLoopsClampedGet")] public class CosmeticLimitOverridePatch { [HarmonyPostfix] private static void Postfix(ref int __result) { int num = Mathf.Max(1, VietnamPlugin.CosmeticBoxMaxPerLevel.Value); if (__result < num) { __result = num; } } } [HarmonyPatch(typeof(CosmeticWorldObject), "Extract")] public class CosmeticBoxExtractPatch { private static readonly HashSet<int> ExtractedBoxIds = new HashSet<int>(); internal static void ClearCache() { ExtractedBoxIds.Clear(); } [HarmonyPrefix] private static void Prefix(CosmeticWorldObject __instance) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)__instance == (Object)null || !__instance.inExtraction) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (ExtractedBoxIds.Contains(instanceID)) { return; } ExtractedBoxIds.Add(instanceID); int huntersCountForRarity = VietnamPlugin.GetHuntersCountForRarity(__instance.rarity); if (huntersCountForRarity <= 0) { return; } EnemySetup val = VietnamPlugin.FindHunterSetup(); if ((Object)(object)val == (Object)null) { VietnamPlugin.Log.LogWarning((object)"Не удалось найти шаблон врага Hunter (Дед с ружьем) в Enemies.AllEnemies!"); return; } Vector3 position = ((Component)__instance).transform.position; LevelPoint val2 = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)__instance).transform.position, 5f); if ((Object)(object)val2 != (Object)null) { position = ((Component)val2).transform.position; } Vector3 val3 = default(Vector3); for (int i = 0; i < huntersCountForRarity; i++) { ((Vector3)(ref val3))..ctor(Random.Range(-1.5f, 1.5f), 0f, Random.Range(-1.5f, 1.5f)); Enemies.SpawnEnemy(val, position + val3, Quaternion.identity, false); } VietnamPlugin.Log.LogInfo((object)$"Сдана коробка редкости [{__instance.rarity}]! Заспавнено Дедов с ружьем: {huntersCountForRarity}"); } } [HarmonyPatch(typeof(EnemyParent), "Despawn")] public class HunterDeathReplacementPatch { private static readonly HashSet<int> HandledDeadHunterIds = new HashSet<int>(); internal static void ClearCache() { HandledDeadHunterIds.Clear(); } [HarmonyPrefix] private static void Prefix(EnemyParent __instance) { //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)__instance == (Object)null || (Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated) { return; } string text = __instance.enemyName ?? string.Empty; if ((text.IndexOf("Hunter", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("Huntsman", StringComparison.OrdinalIgnoreCase) < 0) || (Object)(object)__instance.Enemy == (Object)null || !__instance.Enemy.HasHealth || __instance.Enemy.Health.healthCurrent > 0) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (HandledDeadHunterIds.Contains(instanceID)) { return; } HandledDeadHunterIds.Add(instanceID); int value = VietnamPlugin.HuntersOnHunterDeath.Value; int num = (((Object)(object)EnemyDirector.instance != (Object)null) ? EnemyDirector.instance.enemiesSpawned.Count : 0); if (value > 0 && num - 1 < VietnamPlugin.MaxTotalEnemies.Value) { EnemySetup val = VietnamPlugin.FindHunterSetup(); if ((Object)(object)val != (Object)null) { Vector3 position = ((Component)__instance.Enemy).transform.position; Vector3 val2 = position; LevelPoint val3 = SemiFunc.LevelPointGetFurthestFromPlayer(position, 5f); if ((Object)(object)val3 != (Object)null) { val2 = ((Component)val3).transform.position; } Vector3 val4 = default(Vector3); for (int i = 0; i < value; i++) { ((Vector3)(ref val4))..ctor(Random.Range(-1.5f, 1.5f), 0f, Random.Range(-1.5f, 1.5f)); Enemies.SpawnEnemy(val, val2 + val4, Quaternion.identity, false); } VietnamPlugin.Log.LogInfo((object)$"Дед с ружьем погиб! Заспавнено замен: {value}"); } } if ((Object)(object)VietnamPlugin.Instance != (Object)null) { ((MonoBehaviour)VietnamPlugin.Instance).StartCoroutine(DestroyDeadHunterCoroutine(__instance)); } } private static IEnumerator DestroyDeadHunterCoroutine(EnemyParent deadHunter) { yield return (object)new WaitForSeconds(Mathf.Max(0.05f, VietnamPlugin.DeadHunterCleanupDelay.Value)); if (!((Object)(object)deadHunter == (Object)null)) { if ((Object)(object)EnemyDirector.instance != (Object)null && EnemyDirector.instance.enemiesSpawned != null) { EnemyDirector.instance.enemiesSpawned.Remove(deadHunter); } PhotonViewLimitPatch.SafeNetworkDestroy(((Component)deadHunter).gameObject); VietnamPlugin.Log.LogInfo((object)"Старый объект убитого Деда полностью удалён и сетевой ID освобождён."); } } } [HarmonyPatch(typeof(LevelGenerator), "Start")] public class LevelGeneratorResetPatch { [HarmonyPrefix] private static void Prefix() { EnemyParentSpawnPatch.OriginalEnemyIds.Clear(); EnemyParentSpawnPatch.ClonedEnemyIds.Clear(); EnemyParentSpawnPatch.LastCloneTimeByType.Clear(); CosmeticBoxExtractPatch.ClearCache(); HunterDeathReplacementPatch.ClearCache(); VietnamPlugin.RegisterAllEnemiesInConfig(); } } [HarmonyPatch(typeof(EnemyParent), "Awake")] public class EnemyParentAwakePatch { [HarmonyPostfix] private static void Postfix(EnemyParent __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && !EnemyParentSpawnPatch.IsSpawningClone) { EnemyParentSpawnPatch.OriginalEnemyIds.Add(((Object)__instance).GetInstanceID()); } } } [HarmonyPatch(typeof(EnemyParent), "Spawn")] public class EnemyParentSpawnPatch { internal static bool IsSpawningClone = false; internal static readonly HashSet<int> OriginalEnemyIds = new HashSet<int>(); internal static readonly HashSet<int> ClonedEnemyIds = new HashSet<int>(); internal static readonly Dictionary<string, float> LastCloneTimeByType = new Dictionary<string, float>(StringComparer.OrdinalIgnoreCase); private static readonly string[] SwarmEnemyKeywords = new string[2] { "Gnome", "Banger" }; [HarmonyPostfix] private static void Postfix(EnemyParent __instance) { //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (!OriginalEnemyIds.Contains(instanceID) || ClonedEnemyIds.Contains(instanceID)) { return; } ClonedEnemyIds.Add(instanceID); string enemyKey = __instance.enemyName ?? "Unknown"; bool flag = SwarmEnemyKeywords.Any((string k) => enemyKey.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0); if ((flag && LastCloneTimeByType.TryGetValue(enemyKey, out var value) && Time.time - value < 1.5f) || ((Object)(object)EnemyDirector.instance != (Object)null && EnemyDirector.instance.enemiesSpawned.Count >= VietnamPlugin.MaxTotalEnemies.Value)) { return; } int clonesCountForEnemy = VietnamPlugin.GetClonesCountForEnemy(enemyKey); if (clonesCountForEnemy <= 0) { return; } string cleanObjName = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "").Replace("Enemy - ", "").Trim(); EnemySetup val = ((IEnumerable<EnemySetup>)Enemies.AllEnemies).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup e) => (Object)(object)e != (Object)null && (((Object)e).name.IndexOf(enemyKey, StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)e).name.IndexOf(cleanObjName, StringComparison.OrdinalIgnoreCase) >= 0))); if ((Object)(object)val != (Object)null) { if (flag) { LastCloneTimeByType[enemyKey] = Time.time; } Vector3 val2 = (((Object)(object)__instance.Enemy != (Object)null) ? ((Component)__instance.Enemy).transform.position : ((Component)__instance).transform.position); Quaternion val3 = (((Object)(object)__instance.Enemy != (Object)null) ? ((Component)__instance.Enemy).transform.rotation : ((Component)__instance).transform.rotation); try { IsSpawningClone = true; Vector3 val4 = default(Vector3); for (int num = 0; num < clonesCountForEnemy; num++) { ((Vector3)(ref val4))..ctor(Random.Range(-1.5f, 1.5f), 0f, Random.Range(-1.5f, 1.5f)); Enemies.SpawnEnemy(val, val2 + val4, val3, false); } } finally { IsSpawningClone = false; } VietnamPlugin.Log.LogInfo((object)$"Заспавнено {clonesCountForEnemy} доп. копий для врага: {enemyKey} (Setup: {((Object)val).name})"); } else { VietnamPlugin.Log.LogWarning((object)("Не найден EnemySetup для врага! enemyName='" + enemyKey + "', objectName='" + cleanObjName + "'")); } } } }