using System; using System.Diagnostics; using System.IO; using System.Reflection; 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 LethalLib.Modules; using Microsoft.CodeAnalysis; using Poltergeist; using Scoops.misc; using Scoops.service; using TMPro; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("LittleCompany")] [assembly: IgnoresAccessChecksTo("Poltergeist")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Potuzhnyy")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A template for Lethal Company")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+35b60208b4f6a065bd47ad916b2235fa8aaf7efd")] [assembly: AssemblyProduct("Potuzhnyy")] [assembly: AssemblyTitle("Potuzhnyy")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 Potuzhnyy { internal class Configuration { private static ConfigFile configFile; internal static ConfigEntry maxonPillowRarity; internal static ConfigEntry valikPillowRarity; internal static ConfigEntry giantSnowSightRange; internal static ConfigEntry BarkCoolDown; internal static void Init(ConfigFile cfg) { configFile = cfg; Config(); } private static void Config() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown maxonPillowRarity = configFile.Bind("Items", "MaxonPillowRarity", 10, new ConfigDescription("MaxonPillowRarity", (AcceptableValueBase)null, Array.Empty())); valikPillowRarity = configFile.Bind("Items", "ValikPillowRarity", 10, new ConfigDescription("ValikPillowRarity", (AcceptableValueBase)null, Array.Empty())); giantSnowSightRange = configFile.Bind("Giant", "GiantSnowSightRange", 30, new ConfigDescription("GiantSnowSightRange", (AcceptableValueBase)null, Array.Empty())); BarkCoolDown = configFile.Bind("Poltergeist", "Audio playing cooldown", 20, new ConfigDescription("The cooldown until a dead player can play audio again.", (AcceptableValueBase)null, Array.Empty())); } } [BepInPlugin("Potuzhnyy", "Potuzhnyy", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [HarmonyPatch] internal static class LethalPhonesPatches { [HarmonyPatch(typeof(PlayerPhone), "ToggleActive")] [HarmonyPostfix] private static void ToggleActivePostfix(bool active) { if (!active) { return; } string text = ""; foreach (PhoneBehavior allPhoneBehavior in PhoneNetworkHandler.allPhoneBehaviors) { if (allPhoneBehavior is PlayerPhone) { text = text + allPhoneBehavior.phoneNumber.ToString("D4") + " - " + allPhoneBehavior.GetPhoneName() + ", "; } } HUDManager instance = HUDManager.Instance; string text2 = text; instance.DisplayTip("Phonebook", text2.Substring(0, text2.Length - 2), false, false, "LC_Tip1"); } } public static ManualLogSource Logger; private AssetBundle bundle; private void Awake() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin Potuzhnyy is loading..."); Configuration.Init(((BaseUnityPlugin)this).Config); Harmony val = new Harmony("Potuzhnyy"); val.PatchAll(); Harmony val2 = new Harmony("Toybox.LittleCompany"); val2.Unpatch((MethodBase)AccessTools.Method(typeof(Turret), "TurnTowardsTargetIfHasLOS", (Type[])null, (Type[])null), (HarmonyPatchType)2, "Toybox.LittleCompany"); val2.Unpatch((MethodBase)AccessTools.Method(typeof(Turret), "Start", (Type[])null, (Type[])null), (HarmonyPatchType)2, "Toybox.LittleCompany"); RegisterItems(); } private void RegisterItems() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "itemmod"); bundle = AssetBundle.LoadFromFile(text); RegisterItem("Assets/MaxonPillowItem.asset", Configuration.maxonPillowRarity.Value); RegisterItem("Assets/ValikPillowItem.asset", Configuration.valikPillowRarity.Value); } private void RegisterItem(string path, int rarity) { Item val = bundle.LoadAsset(path); NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); Utilities.FixMixerGroups(val.spawnPrefab); Items.RegisterScrap(val, rarity, (LevelTypes)(-1)); Logger.LogInfo((object)(path + " registered")); } } public static class PluginInfo { public const string PLUGIN_GUID = "Potuzhnyy"; public const string PLUGIN_NAME = "Potuzhnyy"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Potuzhnyy.Patches { [HarmonyPatch(typeof(ForestGiantAI))] internal static class ForestKeeperPatches { [HarmonyPatch(typeof(EnemyAI), "GetAllPlayersInLineOfSightNonAlloc", new Type[] { typeof(float), typeof(int), typeof(Transform), typeof(float), typeof(int) })] [HarmonyPrefix] private static void EnemyAI_Pre_GetAllPlayersInLineOfSight(EnemyAI __instance, ref int range) { if (__instance.isOutside && !__instance.enemyType.canSeeThroughFog && range > 30 && ((NetworkBehaviour)__instance).IsOwner && __instance is ForestGiantAI && IsSnowLevel()) { range = Configuration.giantSnowSightRange.Value; } } private static bool IsSnowLevel() { return StartOfRound.Instance.currentLevel.levelIncludesSnowFootprints; } } [HarmonyPatch] internal static class SpectatorCamControllerPatch { private static long nextUseAvailable; private static float prePower; [HarmonyPatch(typeof(SpectatorCamController), "Bark")] [HarmonyPrefix] private static bool BarkPrefix(SpectatorCamController __instance) { if (isOnCoolDown()) { return false; } prePower = __instance.power; return true; } [HarmonyPatch(typeof(SpectatorCamController), "Bark")] [HarmonyPostfix] private static void BarkPostfix(SpectatorCamController __instance) { float power = __instance.power; if (power < prePower) { long num = DateTimeOffset.Now.ToUnixTimeMilliseconds(); nextUseAvailable = num + Configuration.BarkCoolDown.Value * 1000; } } [HarmonyPatch(typeof(SpectatorCamController), "LateUpdate")] [HarmonyPostfix] private static void LateUpdatePostfix() { long num = CalculateRemainingCooldown(); if (num > 0) { TextMeshProUGUI spectatingPlayerText = HUDManager.Instance.spectatingPlayerText; ((TMP_Text)spectatingPlayerText).text = ((TMP_Text)spectatingPlayerText).text + $" ({num / 1000}s)"; } } private static long CalculateRemainingCooldown() { return nextUseAvailable - DateTimeOffset.Now.ToUnixTimeMilliseconds(); } private static bool isOnCoolDown() { return CalculateRemainingCooldown() > 0; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }