Decompiled source of MinorEdits v1.9.0
plugins/plugins/anormaltwig-LateCompany/LateCompanyV1.0.6.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; 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: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("LateCompany")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+31dbb98cfa5670c23f3ffb21c05582c54159b82d")] [assembly: AssemblyProduct("LateCompany")] [assembly: AssemblyTitle("LateCompany")] [assembly: AssemblyVersion("1.0.0.0")] [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 LateCompany { public static class PluginInfo { public const string GUID = "twig.latecompany"; public const string PrintName = "Late Company"; public const string Version = "1.0.6"; } [BepInPlugin("twig.latecompany", "Late Company", "1.0.6")] internal class Plugin : BaseUnityPlugin { private ConfigEntry<bool> configLateJoinOrbitOnly; public static bool OnlyLateJoinInOrbit = false; public static bool LobbyJoinable = true; public void Awake() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown configLateJoinOrbitOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Late join orbit only", true, "Don't allow joining while the ship is not in orbit."); OnlyLateJoinInOrbit = configLateJoinOrbitOnly.Value; Harmony val = new Harmony("twig.latecompany"); val.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Late Company loaded!"); } public static void SetLobbyJoinable(bool joinable) { LobbyJoinable = joinable; GameNetworkManager.Instance.SetLobbyJoinable(joinable); QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>(); if (Object.op_Implicit((Object)(object)val)) { val.inviteFriendsTextAlpha.alpha = (joinable ? 1f : 0.2f); } } } } namespace LateCompany.Patches { [HarmonyPatch(typeof(GameNetworkManager), "LeaveLobbyAtGameStart")] [HarmonyWrapSafe] internal static class LeaveLobbyAtGameStart_Patch { [HarmonyPrefix] private static bool Prefix() { return false; } } [HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")] [HarmonyWrapSafe] internal static class ConnectionApproval_Patch { [HarmonyPostfix] private static void Postfix(ConnectionApprovalRequest request, ConnectionApprovalResponse response) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (request.ClientNetworkId != NetworkManager.Singleton.LocalClientId && response.Reason.Contains("Game has already started") && Plugin.LobbyJoinable) { response.Reason = ""; response.CreatePlayerObject = false; response.Approved = true; response.Pending = false; } } } [HarmonyPatch(typeof(QuickMenuManager), "DisableInviteFriendsButton")] [HarmonyWrapSafe] internal static class DisableInviteFriendsButton_Patch { [HarmonyPrefix] private static bool Prefix() { return false; } } [HarmonyPatch(typeof(QuickMenuManager), "InviteFriendsButton")] [HarmonyWrapSafe] internal static class InviteFriendsButton_Patch { [HarmonyPrefix] private static bool Prefix() { if (Plugin.LobbyJoinable) { GameNetworkManager.Instance.InviteFriendsUI(); } return false; } } internal class RpcEnum : NetworkBehaviour { public static int None => 0; public static int Client => 2; public static int Server => 1; } internal static class WeatherSync { public static bool DoOverride = false; public static LevelWeatherType CurrentWeather = (LevelWeatherType)(-1); } [HarmonyPatch(typeof(RoundManager), "__rpc_handler_1193916134")] [HarmonyWrapSafe] internal static class __rpc_handler_1193916134_Patch { public static FieldInfo RPCExecStage = typeof(NetworkBehaviour).GetField("__rpc_exec_stage", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPrefix] private static bool Prefix(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) NetworkManager networkManager = target.NetworkManager; try { int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); int num2 = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num2); int num3 = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num3); WeatherSync.DoOverride = true; WeatherSync.CurrentWeather = (LevelWeatherType)num3; RPCExecStage.SetValue(target, RpcEnum.Client); ((RoundManager)((target is RoundManager) ? target : null)).GenerateNewLevelClientRpc(num, num2); RPCExecStage.SetValue(target, RpcEnum.None); } catch { ((FastBufferReader)(ref reader)).Seek(0); return true; } return false; } } [HarmonyPatch(typeof(RoundManager), "SetToCurrentLevelWeather")] [HarmonyWrapSafe] internal static class SetToCurrentLevelWeather_Patch { [HarmonyPrefix] private static bool Prefix() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!WeatherSync.DoOverride) { return true; } WeatherSync.DoOverride = false; TimeOfDay.Instance.currentLevelWeather = WeatherSync.CurrentWeather; return false; } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")] [HarmonyWrapSafe] internal class OnPlayerConnectedClientRpc_Patch { public static MethodInfo BeginSendClientRpc = typeof(RoundManager).GetMethod("__beginSendClientRpc", BindingFlags.Instance | BindingFlags.NonPublic); public static MethodInfo EndSendClientRpc = typeof(RoundManager).GetMethod("__endSendClientRpc", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPostfix] private static void Postfix(ulong clientId, int connectedPlayers, ulong[] connectedPlayerIdsOrdered, int assignedPlayerObjectId, int serverMoneyAmount, int levelID, int profitQuota, int timeUntilDeadline, int quotaFulfilled, int randomSeed) { //IL_0066: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_01a6: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; PlayerControllerB val = instance.allPlayerScripts[assignedPlayerObjectId]; if (instance.connectedPlayersAmount + 1 >= instance.allPlayerScripts.Length) { Plugin.SetLobbyJoinable(joinable: false); } val.DisablePlayerModel(instance.allPlayerObjects[assignedPlayerObjectId], true, true); if (((NetworkBehaviour)instance).IsServer && !instance.inShipPhase) { RoundManager instance2 = RoundManager.Instance; ClientRpcParams val2 = default(ClientRpcParams); val2.Send = new ClientRpcSendParams { TargetClientIds = new List<ulong> { clientId } }; ClientRpcParams val3 = val2; FastBufferWriter val4 = (FastBufferWriter)BeginSendClientRpc.Invoke(instance2, new object[3] { 1193916134u, val3, 0 }); BytePacker.WriteValueBitPacked(val4, StartOfRound.Instance.randomMapSeed); BytePacker.WriteValueBitPacked(val4, StartOfRound.Instance.currentLevelID); BytePacker.WriteValueBitPacked(val4, (short)instance2.currentLevel.currentWeather); EndSendClientRpc.Invoke(instance2, new object[4] { val4, 1193916134u, val3, 0 }); FastBufferWriter val5 = (FastBufferWriter)BeginSendClientRpc.Invoke(instance2, new object[3] { 2729232387u, val3, 0 }); EndSendClientRpc.Invoke(instance2, new object[4] { val5, 2729232387u, val3, 0 }); } instance.livingPlayers = instance.connectedPlayersAmount + 1; for (int i = 0; i < instance.allPlayerScripts.Length; i++) { PlayerControllerB val6 = instance.allPlayerScripts[i]; if (val6.isPlayerControlled && val6.isPlayerDead) { instance.livingPlayers--; } } } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")] [HarmonyWrapSafe] internal class OnPlayerDC_Patch { [HarmonyPostfix] public static void Postfix() { if (StartOfRound.Instance.inShipPhase || !Plugin.OnlyLateJoinInOrbit) { Plugin.SetLobbyJoinable(joinable: true); } } } [HarmonyPatch(typeof(StartOfRound), "StartGame")] [HarmonyWrapSafe] internal class StartGame_Patch { [HarmonyPrefix] public static void Prefix() { if (Plugin.OnlyLateJoinInOrbit) { Plugin.SetLobbyJoinable(joinable: false); } } } [HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")] [HarmonyWrapSafe] internal class SetShipReadyToLand_Patch { [HarmonyPrefix] public static void Postfix() { if (Plugin.OnlyLateJoinInOrbit && StartOfRound.Instance.connectedPlayersAmount + 1 < StartOfRound.Instance.allPlayerScripts.Length) { Plugin.SetLobbyJoinable(joinable: true); } } } }
plugins/plugins/anormaltwig-TerminalExtras/LethalAPI.TerminalCommands.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Concurrent; 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 System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalAPI.TerminalCommands.Attributes; using LethalAPI.TerminalCommands.Commands; using LethalAPI.TerminalCommands.Configs; using LethalAPI.TerminalCommands.Models; using LethalAPI.TerminalCommands.Patches; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.UI; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ShimmyMySherbet, LethalAPI Modding Team")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A library that allows the creation of custom terminal commands for Lethal Company mods")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+5290c6d02b20cc3e4c96dd09d0f7234c78366019")] [assembly: AssemblyProduct("LethalAPI.TerminalCommands")] [assembly: AssemblyTitle("LethalAPI.TerminalCommands")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/LethalCompany/LethalAPI.TerminalCommands")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.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 LethalAPI.TerminalCommands { [HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")] public static class ParseSentencePatch { [HarmonyPrefix] public static bool ParsePrefix(Terminal __instance, ref TerminalNode __state) { __state = null; string command = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded); __state = CommandHandler.TryExecute(command, __instance); return (Object)(object)__state == (Object)null; } [HarmonyPostfix] public static TerminalNode ParsePostfix(TerminalNode __result, TerminalNode __state, Terminal __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 if ((Object)(object)__state != (Object)null) { TerminalSubmitPatch.LastNode = __state; return __state; } if ((int)__instance.videoPlayer.source == 1) { __instance.videoPlayer.source = (VideoSource)0; } TerminalSubmitPatch.LastNode = __result; return __result; } } [BepInPlugin("LethalAPI.TerminalCommands", "LethalAPI.TerminalCommands", "1.1.0")] public class TerminalCommandsPlugin : BaseUnityPlugin { private Harmony HarmonyInstance = new Harmony("LethalAPI.TerminalCommands"); private TerminalModRegistry Terminal; private TerminalConfig TerminalConfig; private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalAPI.TerminalCommands is loading..."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Installing patches"); HarmonyInstance.PatchAll(typeof(TerminalCommandsPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registering built-in Commands"); Terminal = TerminalRegistry.CreateTerminalRegistry(); Terminal.RegisterFrom<CommandInfoCommands>(); TerminalConfig = Terminal.RegisterFrom<TerminalConfig>(); Object.DontDestroyOnLoad((Object)(object)this); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalAPI.TerminalCommands is loaded!"); } } public static class TerminalExtensions { public static void PlayVideoFile(this Terminal terminal, string filePath) { string url = "file:///" + filePath.Replace('\\', '/'); terminal.PlayVideoLink(url); } public static void PlayVideoLink(this Terminal terminal, Uri url) { ((MonoBehaviour)terminal).StartCoroutine(PlayVideoLink(url.AbsoluteUri, terminal)); } public static void PlayVideoLink(this Terminal terminal, string url) { ((MonoBehaviour)terminal).StartCoroutine(PlayVideoLink(url, terminal)); } private static IEnumerator PlayVideoLink(string url, Terminal terminal) { yield return (object)new WaitForFixedUpdate(); ((Behaviour)terminal.terminalImage).enabled = true; terminal.terminalImage.texture = (Texture)(object)terminal.videoTexture; terminal.displayingPersistentImage = null; terminal.videoPlayer.clip = null; terminal.videoPlayer.source = (VideoSource)1; terminal.videoPlayer.url = url; ((Behaviour)terminal.videoPlayer).enabled = true; } } public static class PluginInfo { public const string PLUGIN_GUID = "LethalAPI.TerminalCommands"; public const string PLUGIN_NAME = "LethalAPI.TerminalCommands"; public const string PLUGIN_VERSION = "1.1.0"; } } namespace LethalAPI.TerminalCommands.Patches { [HarmonyPatch(typeof(Terminal), "selectTextFieldDelayed")] public static class SelectTextFieldPatch { [HarmonyPrefix] public static bool Prefix() { return false; } [HarmonyPostfix] public static void Postfix(Terminal __instance, ref IEnumerator __result) { __result = Patch(__instance); } private static IEnumerator Patch(Terminal terminal) { yield return (object)new WaitForSeconds(0.2f); terminal.screenText.ActivateInputField(); ((Selectable)terminal.screenText).Select(); } } [HarmonyPatch(typeof(Terminal), "OnSubmit")] public static class TerminalSubmitPatch { private static ManualLogSource m_LogSource = new ManualLogSource("LethalAPI.TerminalCommands"); public static TerminalNode LastNode { get; set; } [HarmonyPrefix] public static void Prefix() { LastNode = null; } [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown CodeInstruction[] array = instructions.ToArray(); for (int num = array.Length - 1; num >= 0; num--) { if (!(array[num].opcode != OpCodes.Callvirt)) { if (array[num + 1].opcode != OpCodes.Ldarg_0) { ReportTranspileError("Ldarg_0 expected after final callVirt, not found"); return array; } array[num + 1] = new CodeInstruction(OpCodes.Ret, (object)null); return array; } } ReportTranspileError("Failed to find Callvirt in backward scan"); return array; } private static void ReportTranspileError(string message) { m_LogSource.LogError((object)("Failed to transpile OnSubmit to remove Scroll To Bottom. Did the method get modified in an update? (" + message + ")")); m_LogSource.LogWarning((object)"This won't break the mod, but it will cause some odd terminal scrolling behavior"); } [HarmonyPostfix] public static void Postfix(Terminal __instance, ref Coroutine ___forceScrollbarCoroutine) { if ((Object)(object)LastNode == (Object)null || LastNode.clearPreviousText) { ExecuteScrollCoroutine(__instance, ref ___forceScrollbarCoroutine); } else { ((MonoBehaviour)__instance).StartCoroutine("forceScrollbarDown"); } } private static void ExecuteScrollCoroutine(Terminal terminal, ref Coroutine forceScrollbarCoroutine) { if (forceScrollbarCoroutine != null) { ((MonoBehaviour)terminal).StopCoroutine(forceScrollbarCoroutine); } forceScrollbarCoroutine = ((MonoBehaviour)terminal).StartCoroutine("forceScrollbarUp"); } } [HarmonyPatch(typeof(Terminal), "TextPostProcess")] public static class TextPostProcessPatch { [HarmonyPrefix] public static void Prefix(ref string modifiedDisplayText) { modifiedDisplayText = modifiedDisplayText.TrimStart('\n', ' '); if (!modifiedDisplayText.EndsWith('\n')) { modifiedDisplayText += "\n"; } } } } namespace LethalAPI.TerminalCommands.Models { public enum AllowedCaller { None = -1, Player, Host } public class ArgumentStream { public string[] Arguments { get; } public int Index { get; set; } public bool EndOfStream => Index >= Arguments.Length; public ArgumentStream(string[] arguments) { Arguments = arguments; } public void Reset() { Index = 0; } public bool TryReadNext(Type type, out object value) { if (EndOfStream) { value = null; return false; } return StringConverter.TryConvert(Arguments[Index++], type, out value); } public bool TryReadRemaining(out string result) { if (EndOfStream) { result = null; return false; } result = string.Join(" ", Arguments.Skip(Index)); return true; } public bool TryReadNext(out string value) { value = string.Empty; if (EndOfStream) { return false; } value = Arguments[Index++]; return true; } public bool TryReadNext(out sbyte value) { value = 0; if (EndOfStream) { return false; } return sbyte.TryParse(Arguments[Index++], out value); } public bool TryReadNext(out byte value) { value = 0; if (EndOfStream) { return false; } return byte.TryParse(Arguments[Index++], out value); } public bool TryReadNext(out short value) { value = 0; if (EndOfStream) { return false; } return short.TryParse(Arguments[Index++], out value); } public bool TryReadNext(out ushort value) { value = 0; if (EndOfStream) { return false; } return ushort.TryParse(Arguments[Index++], out value); } public bool TryReadNext(out int value) { value = 0; if (EndOfStream) { return false; } return int.TryParse(Arguments[Index++], out value); } public bool TryReadNext(out uint value) { value = 0u; if (EndOfStream) { return false; } return uint.TryParse(Arguments[Index++], out value); } public bool TryReadNext(out long value) { value = 0L; if (EndOfStream) { return false; } return long.TryParse(Arguments[Index++], out value); } public bool TryReadNext(out ulong value) { value = 0uL; if (EndOfStream) { return false; } return ulong.TryParse(Arguments[Index++], out value); } public bool TryReadNext(out float value) { value = 0f; if (EndOfStream) { return false; } return float.TryParse(Arguments[Index++], out value); } public bool TryReadNext(out double value) { value = 0.0; if (EndOfStream) { return false; } return double.TryParse(Arguments[Index++], out value); } } public class CommandComparer : IComparer<TerminalCommand> { public int Compare(TerminalCommand x, TerminalCommand y) { if (x.Priority > y.Priority) { return 1; } if (x.Priority < y.Priority) { return -1; } return x.ArgumentCount.CompareTo(y.ArgumentCount); } } public static class CommandHandler { private static readonly Regex m_SplitRegex = new Regex("[\\\"](.+?)[\\\"]|([^ ]+)", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Compiled); private static readonly CommandComparer m_Comparer = new CommandComparer(); public static TerminalNode TryExecute(string command, Terminal terminal) { IEnumerable<string> source = from Match x in m_SplitRegex.Matches(command.Trim()) select x.Value.Trim('"', ' '); string commandName = source.First(); string[] arguments = source.Skip(1).ToArray(); List<(TerminalCommand, Func<TerminalNode>)> list = new List<(TerminalCommand, Func<TerminalNode>)>(); TerminalCommand[] array = TerminalRegistry.GetCommands(commandName).ToArray(); foreach (TerminalCommand terminalCommand in array) { if (terminalCommand.CheckAllowed() && terminalCommand.TryCreateInvoker(arguments, terminal, out var invoker)) { list.Add((terminalCommand, invoker)); } } foreach (var item in list.OrderByDescending<(TerminalCommand, Func<TerminalNode>), TerminalCommand>(((TerminalCommand command, Func<TerminalNode> invoker) x) => x.command, m_Comparer)) { TerminalNode val = item.Item2(); if ((Object)(object)val != (Object)null) { return val; } } return null; } } public static class DefaultStringConverters { [StringConverter] public static string ParseString(string input) { return input; } [StringConverter] public static sbyte ParseSByte(string input) { if (sbyte.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } [StringConverter] public static byte ParseByte(string input) { if (byte.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } [StringConverter] public static short ParseShort(string input) { if (short.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } [StringConverter] public static ushort ParseUShort(string input) { if (ushort.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } [StringConverter] public static int ParseInt(string input) { if (int.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } [StringConverter] public static uint ParseUInt(string input) { if (uint.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } [StringConverter] public static long ParseLong(string input) { if (long.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } [StringConverter] public static ulong ParseULong(string input) { if (ulong.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } [StringConverter] public static float ParseFloat(string input) { if (float.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } [StringConverter] public static double ParseDouble(string input) { if (double.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } [StringConverter] public static decimal ParseDecimal(string input) { if (decimal.TryParse(input, out var result)) { return result; } throw new ArgumentException(); } public static PlayerControllerB ParsePlayerControllerB(string value) { if ((Object)(object)StartOfRound.Instance == (Object)null) { throw new ArgumentException("Game has not started"); } PlayerControllerB val = null; if (ulong.TryParse(value, out var steamID)) { val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.playerSteamId == steamID)); } if ((Object)(object)val == (Object)null) { val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.playerUsername.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) != -1)); } if ((Object)(object)val == (Object)null) { throw new ArgumentException("Failed to find player"); } return val; } } public enum PersistType { LocalPlayer, Host, Save } public delegate object StringConversionHandler(string value); public static class StringConverter { private static bool m_Initialized = false; public static ConcurrentDictionary<Type, StringConversionHandler> StringConverters { get; } = new ConcurrentDictionary<Type, StringConversionHandler>(); public static bool TryConvert(string value, Type type, out object result) { if (!m_Initialized) { m_Initialized = true; RegisterFromType(typeof(DefaultStringConverters), null, replaceExisting: false); } if (!StringConverters.TryGetValue(type, out var value2)) { result = null; return false; } try { result = value2(value); return true; } catch (ArgumentException) { } result = null; return false; } public static void RegisterFrom<T>(T instance, bool replaceExisting = true) where T : class { RegisterFromType(typeof(T), instance, replaceExisting); } public static void RegisterFromType(Type type, object instance = null, bool replaceExisting = true) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo method in methods) { if (method.GetCustomAttribute<StringConverterAttribute>() == null) { continue; } ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length == 1 && !(parameters[0].ParameterType != typeof(string))) { Type returnType = method.ReturnType; StringConversionHandler value2 = (string value) => method.Invoke(instance, new object[1] { value }); if (replaceExisting || !StringConverters.ContainsKey(returnType)) { StringConverters[returnType] = value2; } } } } } public class TerminalCommand { private ManualLogSource m_LogSource = new ManualLogSource("LethalAPI.TerminalCommands"); public string Name { get; } public MethodInfo Method { get; } public object Instance { get; } public bool ClearConsole { get; } public int ArgumentCount { get; } public string Syntax { get; } public string Description { get; } public int Priority { get; } public TerminalCommand(string name, MethodInfo method, object instance, bool clearConsole, string syntax = null, string description = null, int priority = 0) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown Name = name; Method = method; Instance = instance; ClearConsole = clearConsole; ArgumentCount = method.GetParameters().Length; Syntax = syntax; Description = description; Priority = priority; } public bool CheckAllowed() { foreach (AccessControlAttribute customAttribute in Method.GetCustomAttributes<AccessControlAttribute>()) { if (!customAttribute.CheckAllowed()) { return false; } } return true; } public static TerminalCommand FromMethod(MethodInfo info, object instance, string overrideName = null) { bool clearConsole = false; string syntax = null; string description = null; string text = overrideName; int priority = 0; TerminalCommandAttribute customAttribute = info.GetCustomAttribute<TerminalCommandAttribute>(); if (customAttribute != null) { text = text ?? customAttribute.CommandName; clearConsole = customAttribute.ClearText; } CommandInfoAttribute customAttribute2 = info.GetCustomAttribute<CommandInfoAttribute>(); if (customAttribute2 != null) { syntax = customAttribute2.Syntax; description = customAttribute2.Description; } CommandPriority customAttribute3 = info.GetCustomAttribute<CommandPriority>(); if (customAttribute3 != null) { priority = customAttribute3.Priority; } return new TerminalCommand(text, info, instance, clearConsole, syntax, description, priority); } public bool TryCreateInvoker(string[] arguments, Terminal terminal, out Func<TerminalNode> invoker) { ParameterInfo[] parameters = Method.GetParameters(); object[] values = new object[parameters.Length]; ArgumentStream argumentStream = new ArgumentStream(arguments); invoker = null; for (int i = 0; i < parameters.Length; i++) { ParameterInfo parameterInfo = parameters[i]; Type parameterType = parameterInfo.ParameterType; if (parameterType == typeof(Terminal)) { values[i] = terminal; } else if (parameterType == typeof(ArgumentStream)) { values[i] = argumentStream; } else if (parameterType == typeof(string[])) { values[i] = arguments; } else if (parameterType == typeof(string) && parameterInfo.GetCustomAttribute<RemainingTextAttribute>() != null) { if (!argumentStream.TryReadRemaining(out var result)) { return false; } values[i] = result; } else { if (!argumentStream.TryReadNext(parameterType, out var value)) { return false; } values[i] = value; } } argumentStream.Reset(); invoker = () => ExecuteCommand(values); return true; } private TerminalNode ExecuteCommand(object[] arguments) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown object obj; try { obj = Method.Invoke(Instance, arguments); } catch (Exception ex) { m_LogSource.LogError((object)("Error caught while invoking command hander: " + ex.Message)); m_LogSource.LogError((object)ex.StackTrace); return null; } if (obj == null) { return null; } Type type = obj.GetType(); if (!typeof(TerminalNode).IsAssignableFrom(type)) { TerminalNode obj2 = ScriptableObject.CreateInstance<TerminalNode>(); obj2.displayText = obj.ToString() + "\n"; obj2.clearPreviousText = ClearConsole; return obj2; } return (TerminalNode)obj; } } public class TerminalModRegistry { public List<TerminalCommand> Commands { get; } = new List<TerminalCommand>(); public T RegisterFrom<T>() where T : class, new() { return RegisterFrom(new T()); } public T RegisterFrom<T>(T instance) where T : class { foreach (MethodInfo commandMethod in TerminalRegistry.GetCommandMethods<T>()) { TerminalCommand terminalCommand = TerminalCommand.FromMethod(commandMethod, instance); TerminalRegistry.RegisterCommand(terminalCommand); lock (Commands) { Commands.Add(terminalCommand); } } StringConverter.RegisterFrom(instance); return instance; } public void Deregister() { if (Commands != null) { for (int i = 0; i < Commands.Count; i++) { TerminalRegistry.Deregister(Commands[i]); } } } } public class TerminalRegistry { private static readonly ConcurrentDictionary<string, List<TerminalCommand>> m_RegisteredCommands = new ConcurrentDictionary<string, List<TerminalCommand>>(StringComparer.InvariantCultureIgnoreCase); public static TerminalModRegistry RegisterFrom<T>(T instance) where T : class { TerminalModRegistry terminalModRegistry = new TerminalModRegistry(); foreach (MethodInfo commandMethod in GetCommandMethods<T>()) { TerminalCommand terminalCommand = TerminalCommand.FromMethod(commandMethod, instance); RegisterCommand(terminalCommand); terminalModRegistry.Commands.Add(terminalCommand); } StringConverter.RegisterFrom(instance); return terminalModRegistry; } public static TerminalModRegistry CreateTerminalRegistry() { return new TerminalModRegistry(); } public static void RegisterCommand(TerminalCommand command) { if (!m_RegisteredCommands.TryGetValue(command.Name, out var value)) { value = new List<TerminalCommand>(); m_RegisteredCommands[command.Name] = value; } lock (value) { value.Add(command); } } public static void Deregister(TerminalCommand command) { if (!m_RegisteredCommands.TryGetValue(command.Name, out var value)) { return; } lock (value) { value.Remove(command); } } public static IReadOnlyList<TerminalCommand> GetCommands(string commandName) { if (m_RegisteredCommands.TryGetValue(commandName, out var value)) { return value; } return new List<TerminalCommand>(); } public static IEnumerable<TerminalCommand> EnumerateCommands(string name) { if (!m_RegisteredCommands.TryGetValue(name, out var value)) { return Enumerable.Empty<TerminalCommand>(); } return value; } public static IEnumerable<TerminalCommand> EnumerateCommands() { string[] keys = m_RegisteredCommands.Keys.ToArray(); for (int i = 0; i < keys.Length; i++) { List<TerminalCommand> overloads = m_RegisteredCommands[keys[i]]; for (int c = 0; c < overloads.Count; c++) { yield return overloads[c]; } } } public static IEnumerable<MethodInfo> GetCommandMethods<T>() { MethodInfo[] methods = typeof(T).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttribute<TerminalCommandAttribute>() != null) { yield return methodInfo; } } } } } namespace LethalAPI.TerminalCommands.Configs { [ConfigGroup("Terminal", "Configure the behavior of the terminal")] public class TerminalConfig { [TerminalConfig("Enables/Disables terminal verb commands", null)] [ConfigPersist(PersistType.LocalPlayer, null)] public bool VerbsEnabled { get; set; } [TerminalConfig("Specifies if the Confirm/Deny pop-up should be shown", null)] [ConfigPersist(PersistType.LocalPlayer, null)] public bool AutoConfirm { get; set; } } } namespace LethalAPI.TerminalCommands.Commands { public class CommandInfoCommands { [TerminalCommand("Other", true)] public string CommandList() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Other commands:"); stringBuilder.AppendLine(); stringBuilder.AppendLine(">VIEW MONITOR"); stringBuilder.AppendLine("To toggle on/off the main monitor's map cam"); stringBuilder.AppendLine(); stringBuilder.AppendLine(">SWITCH {RADAR}"); stringBuilder.AppendLine("To switch the player view on the main monitor"); stringBuilder.AppendLine(); stringBuilder.AppendLine(">PING [Radar booster name]"); stringBuilder.AppendLine("To switch the player view on the main monitor"); stringBuilder.AppendLine(); stringBuilder.AppendLine(">SCAN"); stringBuilder.AppendLine("To scan for the number of items left on the current planet"); stringBuilder.AppendLine(); foreach (TerminalCommand item in TerminalRegistry.EnumerateCommands()) { if (item.Description != null && item.CheckAllowed()) { stringBuilder.AppendLine(">" + item.Name.ToUpper() + " " + item.Syntax?.ToUpper()); stringBuilder.AppendLine(item.Description); stringBuilder.AppendLine(); } } return stringBuilder.ToString(); } [TerminalCommand("Help", false)] [CommandInfo("Shows further information about a command", "[Command]")] public string HelpCommand(string name) { StringBuilder stringBuilder = new StringBuilder(); TerminalCommand[] array = TerminalRegistry.EnumerateCommands(name).ToArray(); if (array.Length == 0) { return "Unknown command: '" + name + "'"; } TerminalCommand[] array2 = array; foreach (TerminalCommand terminalCommand in array2) { stringBuilder.AppendLine(">" + terminalCommand.Name.ToUpper() + " " + terminalCommand.Syntax?.ToUpper()); stringBuilder.AppendLine(terminalCommand.Description); if (!terminalCommand.CheckAllowed()) { stringBuilder.AppendLine("[Host Only]"); } stringBuilder.AppendLine(); } return stringBuilder.ToString(); } } } namespace LethalAPI.TerminalCommands.Attributes { [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public abstract class AccessControlAttribute : Attribute { public abstract bool CheckAllowed(); } [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class AllowedCallerAttribute : AccessControlAttribute { public AllowedCaller Caller { get; } public AllowedCallerAttribute(AllowedCaller caller) { Caller = caller; } public override bool CheckAllowed() { switch (Caller) { case AllowedCaller.None: return false; case AllowedCaller.Player: return true; case AllowedCaller.Host: if ((Object)(object)StartOfRound.Instance == (Object)null) { return false; } return ((NetworkBehaviour)StartOfRound.Instance).IsHost; default: return true; } } } [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class CommandInfoAttribute : Attribute { public string Syntax { get; } public string Description { get; } public CommandInfoAttribute(string description, string syntax = "") { Syntax = syntax; Description = description; } } public sealed class CommandPriority : Attribute { public int Priority { get; } public CommandPriority(int priority) { Priority = priority; } } [AttributeUsage(AttributeTargets.Class)] public sealed class ConfigGroupAttribute : Attribute { public string Name { get; } public string Description { get; } public ConfigGroupAttribute(string name, string description) { Name = name; Description = description; } } public class ConfigPersistAttribute : Attribute { public PersistType PersistType { get; } public string ConfigPath { get; } public ConfigPersistAttribute(PersistType persistType, string configPath = null) { PersistType = persistType; ConfigPath = configPath; } } [AttributeUsage(AttributeTargets.Parameter)] public sealed class RemainingTextAttribute : Attribute { } [AttributeUsage(AttributeTargets.Method)] public sealed class StringConverterAttribute : Attribute { } [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class TerminalCommandAttribute : Attribute { public string CommandName { get; } public bool ClearText { get; } public TerminalCommandAttribute(string name, bool clearText = false) { CommandName = name; ClearText = clearText; } } [AttributeUsage(AttributeTargets.Property)] public class TerminalConfigAttribute : Attribute { public string Name { get; } public string Description { get; } public TerminalConfigAttribute(string description, string name = null) { Name = name; Description = description; } } }
plugins/plugins/anormaltwig-TerminalExtras/TerminalExtras.dll
Decompiled a year agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using GameNetcodeStuff; using LethalAPI.TerminalCommands.Attributes; using LethalAPI.TerminalCommands.Models; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("TerminalExtras")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+32be330519c446b28ad5234b103989d788463a62")] [assembly: AssemblyProduct("TerminalExtras")] [assembly: AssemblyTitle("TerminalExtras")] [assembly: AssemblyVersion("1.0.0.0")] [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 TerminalExtras { public static class PluginInfo { public const string GUID = "twig.terminalextras"; public const string Name = "Terminal Extras"; public const string Version = "1.0.1"; } [BepInPlugin("twig.terminalextras", "Terminal Extras", "1.0.1")] internal class Plugin : BaseUnityPlugin { private TerminalModRegistry commands; public void Awake() { commands = TerminalRegistry.RegisterFrom<ExtraCommands>(new ExtraCommands()); } } public class ExtraCommands { [TerminalCommand("Door", false)] [CommandInfo("Toggles the door.", "")] public string DoorCommand() { InteractTrigger componentInChildren = GameObject.Find(StartOfRound.Instance.hangarDoorsClosed ? "StartButton" : "StopButton").GetComponentInChildren<InteractTrigger>(); ((UnityEvent<PlayerControllerB>)(object)componentInChildren.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController); return "Toggled door."; } [TerminalCommand("Doors", false)] [CommandInfo("Toggles the door.", "")] public string DoorsCommand() { return DoorCommand(); } [TerminalCommand("Teleport", false)] [CommandInfo("Activate the teleporter.", "")] public string TeleportCommand() { GameObject val = GameObject.Find("Teleporter(Clone)"); if (val == null) { return "You don't have a teleporter!"; } ShipTeleporter component = val.GetComponent<ShipTeleporter>(); if (component == null) { return "!! Can't find ShipTeleporter component !!"; } if (!component.buttonTrigger.interactable) { return "Teleporter is on cooldown!"; } ((UnityEvent<PlayerControllerB>)(object)component.buttonTrigger.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController); return "Teleporting player"; } [TerminalCommand("Lights", false)] [CommandInfo("Toggle the lights.", "")] public string LightsCommand() { InteractTrigger component = GameObject.Find("LightSwitch").GetComponent<InteractTrigger>(); ((UnityEvent<PlayerControllerB>)(object)component.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController); return "Toggled lights"; } [TerminalCommand("Light", false)] [CommandInfo("Toggle the lights.", "")] public string LightCommand() { return LightsCommand(); } [TerminalCommand("Tp", false)] [CommandInfo("Activate the teleporter.", "")] public string TeleportCommandShort() { return TeleportCommand(); } [TerminalCommand("Launch", false)] [CommandInfo("Pull the lever, Kronk!", "")] public string LaunchCommand() { GameObject val = GameObject.Find("StartGameLever"); if (val == null) { return "!! Can't find StartGameLever !!"; } StartMatchLever component = val.GetComponent<StartMatchLever>(); if (component == null) { return "!! Can't find StartMatchLever componen !!"; } if (StartOfRound.Instance.shipDoorsEnabled && !StartOfRound.Instance.shipHasLanded && !StartOfRound.Instance.shipIsLeaving) { return "Unable to comply. The ship is already in transit."; } if (!StartOfRound.Instance.shipDoorsEnabled && StartOfRound.Instance.travellingToNewLevel) { return "Unable to comply. The ship is already in transit."; } bool flag = !component.leverHasBeenPulled; component.PullLever(); component.LeverAnimation(); if (flag) { component.StartGame(); } else { component.EndGame(); } return "Initiating " + (component.leverHasBeenPulled ? "landing" : "launch") + " sequence."; } [TerminalCommand("Go", false)] [CommandInfo("Pull the lever, Kronk!", "")] public string GoCommand() { return LaunchCommand(); } } }
plugins/plugins/Drakorle-MoreItems/MoreItems.dll
Decompiled a year agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreItems.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MoreItems")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MoreItems")] [assembly: AssemblyTitle("MoreItems")] [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 MoreItems { [BepInPlugin("MoreItems", "MoreItems", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("MoreItems"); private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MoreItems is loaded!"); harmony.PatchAll(typeof(StartOfRoundPatch)); } } public static class PluginInfo { public const string PLUGIN_GUID = "MoreItems"; public const string PLUGIN_NAME = "MoreItems"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace MoreItems.Patches { [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { private const int newMaxItemCapacity = 999; [HarmonyPatch("Awake")] [HarmonyPostfix] private static void IncreaseShipItemCapacity(ref int ___maxShipItemCapacity) { ___maxShipItemCapacity = 999; Logger.CreateLogSource("MoreItems").LogInfo((object)$"Maximum amount of items that can be saved set to {999}."); } } }
plugins/plugins/FlipMods-LetMeLookDown/LetMeLookDown.dll
Decompiled a year agousing System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using GameNetcodeStuff; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LetMeLookDown")] [assembly: AssemblyDescription("Mod made by flipf17")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LetMeLookDown")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a9c88d54-8f01-44a7-be0d-bd61d38aadcb")] [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 LetMeLookDown { [BepInPlugin("FlipMods.LetMeLookDown", "LetMeLookDown", "1.0.1")] public class Plugin : BaseUnityPlugin { private Harmony _harmony; private static Plugin instance; public static float maxAngle = 80f; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown _harmony = new Harmony("LetMeLookDown"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LetMeLookDown mod loaded"); instance = this; } public static void Log(string message) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } } public static class PluginInfo { public const string PLUGIN_GUID = "FlipMods.LetMeLookDown"; public const string PLUGIN_NAME = "LetMeLookDown"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace LetMeLookDown.Patches { [HarmonyPatch] internal class AdjustSmoothLookingPatcher { [HarmonyPatch(typeof(PlayerControllerB), "CalculateSmoothLookingInput")] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 60f) { list[i].operand = Plugin.maxAngle; break; } } return list.AsEnumerable(); } } [HarmonyPatch] internal class AdjustNormalLookingPatcher { [HarmonyPatch(typeof(PlayerControllerB), "CalculateNormalLookingInput")] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 60f) { list[i].operand = Plugin.maxAngle; break; } } return list.AsEnumerable(); } } }
plugins/plugins/KoderTeh-Boombox_Controller/BoomboxController.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Net; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("MonoGame Team")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("BoomboxController")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BoomboxController")] [assembly: AssemblyTitle("BoomboxController")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/MonoGame/MonoGame")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } namespace BoomboxController { [BepInPlugin("BoomboxController", "BoomboxController", "1.0.0")] public class Plugin : BaseUnityPlugin { public static Plugin instance; public static string PLUGIN_GUID = "KoderTech.BoomboxController"; public static string PLUGIN_NAME = "BoomboxController"; public static string PLUGIN_VERSION = "1.0.8"; private static Harmony HarmonyLib; public static Configs config; private void Awake() { //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown instance = this; if (File.Exists("BoomboxController\\lang\\boombox_ru.cfg")) { File.Delete("BoomboxController\\lang\\boombox_ru.cfg"); } if (File.Exists("BoomboxController\\lang\\boombox_en.cfg")) { File.Delete("BoomboxController\\lang\\boombox_en.cfg"); } config = new Configs(); config.GetConfig(); string text = config.languages.Value.ToLower(); string text2 = text; if (!(text2 == "ru")) { if (text2 == "en") { config.GetLang().GetConfigEN(); } } else { config.GetLang().GetConfigRU(); } WriteLogo(); if (!Directory.Exists("BoomboxController\\lang")) { Directory.CreateDirectory("BoomboxController\\lang"); } if (!Directory.Exists("BoomboxController\\other")) { Directory.CreateDirectory("BoomboxController\\other"); } if (!Directory.Exists("BoomboxController\\other\\playlist")) { Directory.CreateDirectory("BoomboxController\\other\\playlist"); } FileInfo[] files = new DirectoryInfo("BoomboxController\\other").GetFiles("*.mp3"); if (files.Length == 1 && File.Exists("BoomboxController\\other\\" + files[0].Name)) { File.Delete("BoomboxController\\other\\" + files[0].Name); } if (!File.Exists("BoomboxController\\other\\ffmpeg.exe")) { if (File.Exists("BoomboxController\\other\\ffmpeg-master-latest-win64-gpl.zip")) { Unpacking(); } else { Thread thread = new Thread((ThreadStart)delegate { DownloadFilesToUnpacking(new Uri("https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip"), "BoomboxController\\other\\ffmpeg-master-latest-win64-gpl.zip"); }); thread.Start(); } } HarmonyLib = new Harmony("com.kodertech.BoomboxController"); HarmonyLib.PatchAll(typeof(BoomboxController)); } public void WriteLogo() { ((BaseUnityPlugin)this).Logger.LogInfo((object)" /$$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$__ $$ | $$__ $$ /$$__ $$ | $$ | $$| $$ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$ \\ $$ /$$$$$$ /$$$$$$ /$$$$$$/$$$$ | $$ \\ $$ /$$$$$$ /$$ /$$ | $$ \\__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ | $$| $$ /$$$$$$ /$$$$$$ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$$$$$$ /$$__ $$ /$$__ $$| $$_ $$_ $$| $$$$$$$ /$$__ $$| $$ /$$/ | $$ /$$__ $$| $$__ $$|_ $$_/ /$$__ $$ /$$__ $$| $$| $$ /$$__ $$ /$$__ $$"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$__ $$| $$ \\ $$| $$ \\ $$| $$ \\ $$ \\ $$| $$__ $$| $$ \\ $$ \\ $$$$/ | $$ | $$ \\ $$| $$ \\ $$ | $$ | $$ \\__/| $$ \\ $$| $$| $$| $$$$$$$$| $$ \\__/"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$ \\ $$| $$ | $$| $$ | $$| $$ | $$ | $$| $$ \\ $$| $$ | $$ >$$ $$ | $$ $$| $$ | $$| $$ | $$ | $$ /$$| $$ | $$ | $$| $$| $$| $$_____/| $$ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$$$$$$/| $$$$$$/| $$$$$$/| $$ | $$ | $$| $$$$$$$/| $$$$$$/ /$$/\\ $$ | $$$$$$/| $$$$$$/| $$ | $$ | $$$$/| $$ | $$$$$$/| $$| $$| $$$$$$$| $$ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"|_______/ \\______/ \\______/ |__/ |__/ |__/|_______/ \\______/ |__/ \\__/ \\______/ \\______/ |__/ |__/ \\___/ |__/ \\______/ |__/|__/ \\_______/|__/ "); } public static void DownloadFilesToUnpacking(Uri uri, string filename) { WebClient webClient = new WebClient(); webClient.DownloadFileCompleted += Web_DownloadFileCompletedToUnpacking; webClient.DownloadFileAsync(uri, filename); } public static void DownloadFiles(Uri uri, string filename) { WebClient webClient = new WebClient(); webClient.DownloadFileCompleted += Web_DownloadFileCompleted; webClient.DownloadFileAsync(uri, filename); } private static void Web_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { Thread.CurrentThread.Abort(); } private static void Web_DownloadFileCompletedToUnpacking(object sender, AsyncCompletedEventArgs e) { Unpacking(); if (!File.Exists("BoomboxController\\other\\yt-dlp.exe")) { Thread thread = new Thread((ThreadStart)delegate { DownloadFiles(new Uri("https://github.com/yt-dlp/yt-dlp/releases/download/2023.11.16/yt-dlp.exe"), "BoomboxController\\other\\yt-dlp.exe"); }); thread.Start(); } Thread.CurrentThread.Abort(); } public static void Unpacking() { using (ZipArchive zipArchive = ZipFile.OpenRead("BoomboxController\\other\\ffmpeg-master-latest-win64-gpl.zip")) { foreach (ZipArchiveEntry entry in zipArchive.Entries) { if (entry.Name.Equals("ffmpeg.exe")) { entry.ExtractToFile(Path.Combine("BoomboxController\\other", entry.Name)); } } } File.Delete("BoomboxController\\other\\ffmpeg-master-latest-win64-gpl.zip"); } public void Log(object message) { ((BaseUnityPlugin)this).Logger.LogInfo(message); } } public class Configs { public class Lang { public ConfigEntry<string> main_1; public ConfigEntry<string> main_2; public ConfigEntry<string> main_3; public ConfigEntry<string> main_4; public ConfigEntry<string> main_5; public ConfigEntry<string> main_6; public ConfigEntry<string> main_7; public ConfigEntry<string> main_8; public ConfigEntry<string> main_9; public ConfigEntry<string> main_10; public ConfigEntry<string> main_11; public ConfigEntry<string> main_12; public ConfigEntry<string> main_13; public ConfigEntry<string> main_14; public void GetConfigRU() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ConfigFile val = new ConfigFile("BoomboxController\\lang\\boombox_ru.cfg", true); main_1 = val.Bind<string>("General", "Main_1", "Пожалуйста, подождите, загружаются дополнительные библиотеки, чтобы модификация заработала.", (ConfigDescription)null); main_2 = val.Bind<string>("General", "Main_2", "Взять BoomBox[1.0.0] : [E]\n@2 - @3\n@1 громкость\nСейчас играет: @4\nДоступных треков: @5\nУвеличить громкость [PU]\nУменьшить громкость [PG]", (ConfigDescription)null); main_3 = val.Bind<string>("General", "Main_3", "Все дополнительные библиотеки загружены, теперь вы можете использовать команды для бумбокса.", (ConfigDescription)null); main_4 = val.Bind<string>("General", "Main_4", "Подождите, трек еще загружается!", (ConfigDescription)null); main_5 = val.Bind<string>("General", "Main_5", "Команды:\n/bplay - Проиграть музыку\n/btime - Изменить позицию песни\n/bvolume - Изменить громкость трека", (ConfigDescription)null); main_6 = val.Bind<string>("General", "Main_6", "Введите правильный URL-адрес!", (ConfigDescription)null); main_7 = val.Bind<string>("General", "Main_7", "Пожалуйста подождите...", (ConfigDescription)null); main_8 = val.Bind<string>("General", "Main_8", "Трек был загружен в бумбокс", (ConfigDescription)null); main_9 = val.Bind<string>("General", "Main_9", "@1 изменил громкость трека @2", (ConfigDescription)null); main_10 = val.Bind<string>("General", "Main_10", "Введите правильную громкость трека (пример: 0, 10, 20, 30...)!", (ConfigDescription)null); main_11 = val.Bind<string>("General", "Main_11", "Ссылка недействительная!", (ConfigDescription)null); main_12 = val.Bind<string>("General", "Main_12", "Позиция трека изменена на @1!", (ConfigDescription)null); main_13 = val.Bind<string>("General", "Main_13", "Загрузка трека отменена!", (ConfigDescription)null); main_14 = val.Bind<string>("General", "Main_14", "Текущий трек был переключен на: @1!", (ConfigDescription)null); } public void GetConfigEN() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ConfigFile val = new ConfigFile("BoomboxController\\lang\\boombox_en.cfg", true); main_1 = val.Bind<string>("General", "Main_1", "Please wait, additional libraries are being loaded for the modification to work.", (ConfigDescription)null); main_2 = val.Bind<string>("General", "Main_2", "Pickup BoomBox[1.0.0] : [E]\n@2 - @3\n@1 volume\nNow playing: @4\nAvailable tracks: @5\nIncrease volume [PU]\nDecrease volume [PG]", (ConfigDescription)null); main_3 = val.Bind<string>("General", "Main_3", "All libraries have loaded, now you can use the boombox commands.", (ConfigDescription)null); main_4 = val.Bind<string>("General", "Main_4", "Another track is being uploaded to the boombox!", (ConfigDescription)null); main_5 = val.Bind<string>("General", "Main_5", "Commands:\n/bplay - Play music\n/btime - Change the position of the song\n/bvolume - Change Boombox volume", (ConfigDescription)null); main_6 = val.Bind<string>("General", "Main_6", "Enter the correct URL!", (ConfigDescription)null); main_7 = val.Bind<string>("General", "Main_7", "Please wait...", (ConfigDescription)null); main_8 = val.Bind<string>("General", "Main_8", "The track was uploaded to the boombox", (ConfigDescription)null); main_9 = val.Bind<string>("General", "Main_9", "@1 changed the volume @2 of the boombox.", (ConfigDescription)null); main_10 = val.Bind<string>("General", "Main_10", "Enter the correct Volume (example: 0, 10, 20, 30...)!", (ConfigDescription)null); main_11 = val.Bind<string>("General", "Main_11", "Link is invalid!", (ConfigDescription)null); main_12 = val.Bind<string>("General", "Main_12", "Track position changed to @1!", (ConfigDescription)null); main_13 = val.Bind<string>("General", "Main_13", "Track download canceled!", (ConfigDescription)null); main_14 = val.Bind<string>("General", "Main_14", "The current track has been switched to: @1!", (ConfigDescription)null); } } public ConfigEntry<bool> requstbattery; public ConfigEntry<string> languages; public static Lang lang = new Lang(); public void GetConfig() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ConfigFile val = new ConfigFile("BoomboxController\\boombox_controller.cfg", true); requstbattery = val.Bind<bool>("General.Toggles", "RequestBattery", false, "Enable/disable boombox battery (that is true = Enable; false = Disable)"); languages = val.Bind<string>("General", "Languages", "en", "EN/RU"); } public Lang GetLang() { return lang; } } public class BoomboxController : MonoBehaviour { public static bool startMusics = true; public static AudioBoomBox bom; public static int timesPlayedWithoutTurningOff = 0; public static BoomboxItem boomboxItem = new BoomboxItem(); public static int isSendingItemRPC = 0; public static string LastMessage; public static bool LoadingMusicBoombox = false; public static bool LoadingLibrary = false; public static string LastnameOfUserWhoTyped; public static double curretTime = 0.0; public static double totalTime = 0.0; public static Thread thread; public static bool isplayList = false; public static int Id = 0; public static int totalTack = 0; public static int currectTrack = 0; public static string NameTrack; public static AudioClip[] musicList; [HarmonyPatch(typeof(PlayerControllerB), "SetHoverTipAndCurrentInteractTrigger")] [HarmonyPrefix] public static bool SetHoverTipAndCurrentInteractTrigger(PlayerControllerB __instance, ref RaycastHit ___hit, ref Ray ___interactRay, ref int ___playerMask, ref int ___interactableObjectsMask) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_09f5: Unknown result type (might be due to invalid IL or missing references) if (!__instance.isGrabbingObjectAnimation) { ___interactRay = new Ray(((Component)__instance.gameplayCamera).transform.position, ((Component)__instance.gameplayCamera).transform.forward); if (Physics.Raycast(___interactRay, ref ___hit, __instance.grabDistance, ___interactableObjectsMask) && ((Component)((RaycastHit)(ref ___hit)).collider).gameObject.layer != 8) { string tag = ((Component)((RaycastHit)(ref ___hit)).collider).tag; if (!(tag == "PhysicsProp")) { if (tag == "InteractTrigger") { InteractTrigger component = ((Component)((RaycastHit)(ref ___hit)).transform).gameObject.GetComponent<InteractTrigger>(); if ((Object)(object)component != (Object)(object)__instance.previousHoveringOverTrigger && (Object)(object)__instance.previousHoveringOverTrigger != (Object)null) { __instance.previousHoveringOverTrigger.isBeingHeldByPlayer = false; } if (!((Object)(object)component == (Object)null)) { __instance.hoveringOverTrigger = component; if (!component.interactable) { __instance.cursorIcon.sprite = component.disabledHoverIcon; ((Behaviour)__instance.cursorIcon).enabled = (Object)(object)component.disabledHoverIcon != (Object)null; ((TMP_Text)__instance.cursorTip).text = component.disabledHoverTip; } else if (component.isPlayingSpecialAnimation) { ((Behaviour)__instance.cursorIcon).enabled = false; ((TMP_Text)__instance.cursorTip).text = ""; } else if (__instance.isHoldingInteract) { if (__instance.twoHanded) { ((TMP_Text)__instance.cursorTip).text = "[Hands full]"; } else if (!string.IsNullOrEmpty(component.holdTip)) { ((TMP_Text)__instance.cursorTip).text = component.holdTip; } } else { ((Behaviour)__instance.cursorIcon).enabled = true; __instance.cursorIcon.sprite = component.hoverIcon; ((TMP_Text)__instance.cursorTip).text = component.hoverTip; } } } } else { if (FirstEmptyItemSlot(__instance) == -1) { ((TMP_Text)__instance.cursorTip).text = "Inventory full!"; } else { GrabbableObject component2 = ((Component)((RaycastHit)(ref ___hit)).collider).gameObject.GetComponent<GrabbableObject>(); if (!GameNetworkManager.Instance.gameHasStarted && !component2.itemProperties.canBeGrabbedBeforeGameStart && (Object)(object)StartOfRound.Instance.testRoom == (Object)null) { ((TMP_Text)__instance.cursorTip).text = "(Cannot pickup until ship is landed)"; } if ((Object)(object)((Component)((RaycastHit)(ref ___hit)).transform).gameObject.GetComponent<BoomboxItem>() != (Object)null) { float volume = boomboxItem.boomboxAudio.volume; if ((Object)(object)component2 != (Object)null && !string.IsNullOrEmpty(component2.customGrabTooltip)) { ((TMP_Text)__instance.cursorTip).text = component2.customGrabTooltip; } if (GameNetworkManager.Instance.gameHasStarted && ((Object)((RaycastHit)(ref ___hit)).transform).name.ToString() == "Boombox(Clone)") { if (!File.Exists("BoomboxController\\other\\ffmpeg.exe") || !File.Exists("BoomboxController\\other\\yt-dlp.exe")) { ((TMP_Text)__instance.cursorTip).text = Plugin.config.GetLang().main_1.Value; } else { if (!boomboxItem.isPlayingMusic) { curretTime = 0.0; totalTime = 0.0; } int num = (int)curretTime % 3600; string text = Mathf.Floor((float)((int)curretTime / 3600)).ToString("00"); string text2 = Mathf.Floor((float)(num / 60)).ToString("00"); string text3 = Mathf.Floor((float)(num % 60)).ToString("00"); int num2 = (int)totalTime % 3600; string text4 = Mathf.Floor((float)((int)totalTime / 3600)).ToString("00"); string text5 = Mathf.Floor((float)(num2 / 60)).ToString("00"); string text6 = Mathf.Floor((float)(num2 % 60)).ToString("00"); if (Plugin.config.languages.Value == "en" && (musicList == null || musicList.Length != 0)) { string text7 = (boomboxItem.isPlayingMusic ? "[Home]" : "Nothing"); ((TMP_Text)__instance.cursorTip).text = Plugin.config.GetLang().main_2.Value.Replace("@1", $"{Math.Round(volume * 100f)}%").Replace("@2", text + ":" + text2 + ":" + text3).Replace("@3", text4 + ":" + text5 + ":" + text6) .Replace("@4", text7 ?? "") .Replace("@5", $"{totalTack}"); } if (Plugin.config.languages.Value == "ru" && (musicList == null || musicList.Length != 0)) { string text8 = (boomboxItem.isPlayingMusic ? "[Home]" : "Нечего"); ((TMP_Text)__instance.cursorTip).text = Plugin.config.GetLang().main_2.Value.Replace("@1", $"{Math.Round(volume * 100f)}%").Replace("@2", text + ":" + text2 + ":" + text3).Replace("@3", text4 + ":" + text5 + ":" + text6) .Replace("@4", text8 ?? "") .Replace("@5", $"{totalTack}"); } if (((ButtonControl)Keyboard.current.pageDownKey).wasPressedThisFrame && volume > 0f) { float volume2 = volume - 0.1f; boomboxItem.boomboxAudio.volume = volume2; } if (((ButtonControl)Keyboard.current.pageUpKey).wasPressedThisFrame && volume < 1f) { float volume3 = volume + 0.1f; boomboxItem.boomboxAudio.volume = volume3; } if (InputControlExtensions.IsPressed((InputControl)(object)Keyboard.current.homeKey, 0f)) { ((TMP_Text)__instance.cursorTip).text = Plugin.config.GetLang().main_2.Value.Replace("@1", $"{Math.Round(volume * 100f)}%").Replace("@2", text + ":" + text2 + ":" + text3).Replace("@3", text4 + ":" + text5 + ":" + text6) .Replace("@4", NameTrack.Substring(0, NameTrack.Length - 4).Replace(" ", "") ?? "") .Replace("@5", $"{totalTack}"); } } } } } ((Behaviour)__instance.cursorIcon).enabled = true; __instance.cursorIcon.sprite = __instance.grabItemIcon; } } else { ((Behaviour)__instance.cursorIcon).enabled = false; ((TMP_Text)__instance.cursorTip).text = ""; if ((Object)(object)__instance.hoveringOverTrigger != (Object)null) { __instance.previousHoveringOverTrigger = __instance.hoveringOverTrigger; } __instance.hoveringOverTrigger = null; } } if (StartOfRound.Instance.localPlayerUsingController) { StringBuilder stringBuilder = new StringBuilder(((TMP_Text)__instance.cursorTip).text); stringBuilder.Replace("[E]", "[X]"); stringBuilder.Replace("[LMB]", "[X]"); stringBuilder.Replace("[RMB]", "[R-Trigger]"); stringBuilder.Replace("[F]", "[R-Shoulder]"); stringBuilder.Replace("[Z]", "[L-Shoulder]"); ((TMP_Text)__instance.cursorTip).text = stringBuilder.ToString(); } else { ((TMP_Text)__instance.cursorTip).text = ((TMP_Text)__instance.cursorTip).text.Replace("[LMB]", "[E]"); } if (!__instance.isFreeCamera && Physics.Raycast(___interactRay, ref ___hit, 5f, ___playerMask)) { PlayerControllerB component3 = ((Component)((RaycastHit)(ref ___hit)).collider).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component3 != (Object)null) { component3.ShowNameBillboard(); } } return false; } [HarmonyPatch(typeof(BoomboxItem), "Start")] [HarmonyPrefix] private static void Start(BoomboxItem __instance) { bom = new AudioBoomBox(); __instance.boomboxAudio.volume = 0.5f; __instance.musicAudios = null; ((GrabbableObject)__instance).itemProperties.requiresBattery = Plugin.config.requstbattery.Value; boomboxItem = __instance; } [HarmonyPatch(typeof(BoomboxItem), "StartMusic")] [HarmonyPrefix] private static bool Prefix(BoomboxItem __instance, bool startMusic, bool pitchDown, ref int ___timesPlayedWithoutTurningOff) { if (!LoadingMusicBoombox) { Plugin.instance.Log(startMusic + " startmusic"); if (startMusic) { boomboxItem.boomboxAudio.clip = musicList[currectTrack]; boomboxItem.boomboxAudio.pitch = 1f; boomboxItem.boomboxAudio.Play(); boomboxItem.isPlayingMusic = startMusic; ((GrabbableObject)boomboxItem).isBeingUsed = startMusic; startMusics = false; } else if (boomboxItem.isPlayingMusic) { boomboxItem.boomboxAudio.Stop(); boomboxItem.boomboxAudio.PlayOneShot(boomboxItem.stopAudios[Random.Range(0, boomboxItem.stopAudios.Length)]); timesPlayedWithoutTurningOff = 0; boomboxItem.isPlayingMusic = startMusic; ((GrabbableObject)boomboxItem).isBeingUsed = startMusic; startMusics = true; } } return false; } [HarmonyPatch(typeof(BoomboxItem), "Update")] [HarmonyPrefix] private static void Postfix(BoomboxItem __instance, ref int ___timesPlayedWithoutTurningOff) { if (timesPlayedWithoutTurningOff <= 0) { ___timesPlayedWithoutTurningOff = 0; } timesPlayedWithoutTurningOff = ___timesPlayedWithoutTurningOff; if (boomboxItem.isPlayingMusic) { curretTime = boomboxItem.boomboxAudio.time; totalTime = boomboxItem.boomboxAudio.clip.length; } else { boomboxItem.boomboxAudio.time = 0f; } if (musicList != null) { totalTack = musicList.Length; } } [HarmonyPatch(typeof(HUDManager), "Update")] [HarmonyPrefix] private static void Updat(HUDManager __instance) { if (File.Exists("BoomboxController\\other\\ffmpeg.exe") && File.Exists("BoomboxController\\other\\yt-dlp.exe") && LoadingLibrary) { DrawString(__instance, Plugin.config.GetLang().main_3.Value, "Boombox", "Boombox"); LoadingLibrary = false; } } [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyPrefix] private static void StartPostfix(HUDManager __instance) { __instance.chatTextField.characterLimit = 200; } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] [HarmonyPrefix] private static bool AddChatMessage(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped) { if (!(__instance.lastChatMessage == chatMessage)) { __instance.lastChatMessage = chatMessage; __instance.PingHUDElement(__instance.Chat, 4f, 1f, 0.2f); if (__instance.ChatMessageHistory.Count >= 4) { ((TMP_Text)__instance.chatText).text.Remove(0, __instance.ChatMessageHistory[0].Length); __instance.ChatMessageHistory.Remove(__instance.ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); stringBuilder.Replace("[playerNum0]", StartOfRound.Instance.allPlayerScripts[0].playerUsername); stringBuilder.Replace("[playerNum1]", StartOfRound.Instance.allPlayerScripts[1].playerUsername); stringBuilder.Replace("[playerNum2]", StartOfRound.Instance.allPlayerScripts[2].playerUsername); stringBuilder.Replace("[playerNum3]", StartOfRound.Instance.allPlayerScripts[3].playerUsername); chatMessage = stringBuilder.ToString(); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#FF0000>" + nameOfUserWhoTyped + "</color>: <color=#FFFF00>'" + chatMessage + "'</color>") : ("<color=#7069ff>" + chatMessage + "</color>")); __instance.ChatMessageHistory.Add(item); ((TMP_Text)__instance.chatText).text = ""; for (int i = 0; i < __instance.ChatMessageHistory.Count; i++) { TextMeshProUGUI chatText = __instance.chatText; ((TMP_Text)chatText).text = ((TMP_Text)chatText).text + "\n" + __instance.ChatMessageHistory[i]; } } AddChatMessageMain(__instance, chatMessage, nameOfUserWhoTyped); return false; } public static async void AddChatMessageMain(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped) { if (!File.Exists("BoomboxController\\other\\ffmpeg.exe") || !File.Exists("BoomboxController\\other\\yt-dlp.exe")) { DrawString(__instance, Plugin.config.GetLang().main_1.Value, "Boombox", nameOfUserWhoTyped); LoadingLibrary = true; return; } string[] vs = chatMessage.Split(new char[1] { ' ' }); switch (vs[0].Replace("/", "")) { case "bhelp": if (Plugin.config.languages.Value.ToLower().Equals("en")) { DrawString(__instance, Plugin.config.GetLang().main_5.Value + "\nThe creator of the mod is KoderTech.\nWith love from Russia", "Boombox", nameOfUserWhoTyped); } if (Plugin.config.languages.Value.ToLower().Equals("ru")) { DrawString(__instance, Plugin.config.GetLang().main_5.Value + "\nСоздатель мода KoderTech.\nСпасибо что вы скачали именно этот мод)))", "Boombox", nameOfUserWhoTyped); } break; case "bplay": { Regex regex = new Regex("^https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$"); if (regex.IsMatch(vs[1])) { string url = vs[1].Remove(0, 8); string text2 = url.Substring(0, url.IndexOf('/')); string text3 = text2; string text4 = text3; if (!(text4 == "www.youtube.com")) { if (text4 == "soundcloud.com") { if (vs[1].Contains("sets")) { DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox SoundCloud", nameOfUserWhoTyped); break; } boomboxItem.boomboxAudio.Stop(); boomboxItem.boomboxAudio.PlayOneShot(boomboxItem.stopAudios[Random.Range(0, boomboxItem.stopAudios.Length)]); timesPlayedWithoutTurningOff = 0; boomboxItem.isPlayingMusic = false; ((GrabbableObject)boomboxItem).isBeingUsed = false; LoadingMusicBoombox = true; FileInfo[] file2 = new DirectoryInfo("BoomboxController\\other").GetFiles("*.mp3"); if (file2.Length == 1) { File.Delete("BoomboxController\\other\\" + file2[0].Name); } DrawString(__instance, Plugin.config.GetLang().main_7.Value, "Boombox SoundCloud", nameOfUserWhoTyped); if (isplayList) { break; } isplayList = true; await Task.Run(delegate { bool flag4 = false; Process process3 = new Process(); process3.StartInfo.FileName = "BoomboxController\\other\\yt-dlp.exe"; process3.StartInfo.UseShellExecute = false; process3.StartInfo.Arguments = vs[1] ?? ""; process3.StartInfo.WorkingDirectory = "BoomboxController\\other"; process3.StartInfo.CreateNoWindow = true; process3.Start(); Id = process3.Id; while (!flag4) { FileInfo[] files4 = new DirectoryInfo("BoomboxController\\other").GetFiles("*.mp3"); foreach (FileInfo fileInfo3 in files4) { if (fileInfo3.Exists) { NameTrack = fileInfo3.Name; } } if (Process.GetProcessById(process3.Id).HasExited) { if (File.Exists("BoomboxController\\other\\" + NameTrack)) { flag4 = true; } else { DrawString(__instance, Plugin.config.GetLang().main_11.Value, "Boombox SoundCloud", nameOfUserWhoTyped); } break; } Thread.Sleep(1000); } }); if (!File.Exists("\\BoomboxController\\other\\" + NameTrack)) { LoadingMusicBoombox = false; isplayList = false; } else { currectTrack = 0; bom.Start(bom.GetAudioClip("file:///" + Paths.GameRootPath + "\\BoomboxController\\other\\" + NameTrack, boomboxItem, (AudioType)13)); DrawString(__instance, Plugin.config.GetLang().main_8.Value, "Boombox SoundCloud", nameOfUserWhoTyped); } } else { int type = GetAudioType(vs[1].Remove(0, vs[1].Length - 3)); if (type == -1) { DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox", nameOfUserWhoTyped); break; } LoadingMusicBoombox = true; DrawString(__instance, Plugin.config.GetLang().main_7.Value, "Boombox", nameOfUserWhoTyped); bom.Start(bom.GetAudioClip(vs[1], boomboxItem, (AudioType)13)); DrawString(__instance, Plugin.config.GetLang().main_8.Value, "Boombox", nameOfUserWhoTyped); } break; } if (vs[1].Contains("playlist")) { boomboxItem.boomboxAudio.Stop(); boomboxItem.boomboxAudio.PlayOneShot(boomboxItem.stopAudios[Random.Range(0, boomboxItem.stopAudios.Length)]); timesPlayedWithoutTurningOff = 0; boomboxItem.isPlayingMusic = false; ((GrabbableObject)boomboxItem).isBeingUsed = false; LoadingMusicBoombox = true; if (File.Exists("BoomboxController\\other\\output.txt")) { File.Delete("BoomboxController\\other\\output.txt"); } FileInfo[] files = new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles(); foreach (FileInfo track in files) { track.Delete(); } DrawString(__instance, Plugin.config.GetLang().main_7.Value, "Boombox YouTube", nameOfUserWhoTyped); if (isplayList) { break; } isplayList = true; await Task.Run(delegate { bool flag3 = false; Process process2 = new Process(); process2.StartInfo.FileName = "BoomboxController\\other\\yt-dlp.exe"; process2.StartInfo.UseShellExecute = false; process2.StartInfo.Arguments = "-f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 " + vs[1]; process2.StartInfo.WorkingDirectory = "BoomboxController\\other\\playlist"; process2.StartInfo.CreateNoWindow = true; process2.StartInfo.RedirectStandardOutput = true; process2.Start(); string value = process2.StandardOutput.ReadToEnd(); Id = process2.Id; while (!flag3) { if (Process.GetProcessById(process2.Id).HasExited && new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles("*.webm").Length == 0) { flag3 = true; break; } Thread.Sleep(1000); } using StreamWriter streamWriter = File.CreateText("BoomboxController\\other\\output.txt"); streamWriter.WriteLine(value); }); if (new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles("*.mp3").Length == 0) { LoadingMusicBoombox = false; isplayList = false; DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox YouTube", nameOfUserWhoTyped); break; } using (StreamReader sr = new StreamReader("BoomboxController\\other\\output.txt")) { while (sr.Peek() >= 0) { string text = sr.ReadLine(); if (text.Contains("[download] Downloading playlist:")) { string[] vs2 = text.Split(new char[1] { ':' }); NameTrack = vs2[1]; } } } currectTrack = 0; thread = new Thread((ThreadStart)delegate { LoadPlaylist(__instance, nameOfUserWhoTyped); }); thread.Start(); break; } if (vs[1].Contains("list")) { DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox YouTube", nameOfUserWhoTyped); break; } boomboxItem.boomboxAudio.Stop(); boomboxItem.boomboxAudio.PlayOneShot(boomboxItem.stopAudios[Random.Range(0, boomboxItem.stopAudios.Length)]); timesPlayedWithoutTurningOff = 0; boomboxItem.isPlayingMusic = false; ((GrabbableObject)boomboxItem).isBeingUsed = false; LoadingMusicBoombox = true; FileInfo[] file = new DirectoryInfo("BoomboxController\\other").GetFiles("*.mp3"); if (file.Length == 1) { File.Delete("BoomboxController\\other\\" + file[0].Name); } DrawString(__instance, Plugin.config.GetLang().main_7.Value, "Boombox YouTube", nameOfUserWhoTyped); if (isplayList) { break; } isplayList = true; await Task.Run(delegate { bool flag = false; bool flag2 = false; Process process = new Process(); process.StartInfo.FileName = "BoomboxController\\other\\yt-dlp.exe"; process.StartInfo.UseShellExecute = false; process.StartInfo.Arguments = "-f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 " + vs[1]; process.StartInfo.WorkingDirectory = "BoomboxController\\other"; process.StartInfo.CreateNoWindow = true; process.Start(); Id = process.Id; while (!flag) { if (flag2) { if (File.Exists("BoomboxController\\other\\" + NameTrack)) { flag = true; break; } } else { FileInfo[] files2 = new DirectoryInfo("BoomboxController\\other").GetFiles("*.mp3"); foreach (FileInfo fileInfo in files2) { if (fileInfo.Exists) { NameTrack = fileInfo.Name; } } FileInfo[] files3 = new DirectoryInfo("BoomboxController\\other").GetFiles("*.webm"); foreach (FileInfo fileInfo2 in files3) { if (fileInfo2.Exists) { NameTrack = fileInfo2.Name; } } if (Process.GetProcessById(process.Id).HasExited) { if (!File.Exists("BoomboxController\\other\\" + NameTrack) && !File.Exists("BoomboxController\\other\\" + NameTrack)) { DrawString(__instance, Plugin.config.GetLang().main_11.Value, "Boombox YouTube", nameOfUserWhoTyped); break; } flag2 = true; } } Thread.Sleep(1000); } }); if (!File.Exists("BoomboxController\\other\\" + NameTrack)) { LoadingMusicBoombox = false; isplayList = false; } else { currectTrack = 0; bom.Start(bom.GetAudioClip("file:///" + Paths.GameRootPath + "\\BoomboxController\\other\\" + NameTrack, boomboxItem, (AudioType)13)); DrawString(__instance, Plugin.config.GetLang().main_8.Value, "Boombox YouTube", nameOfUserWhoTyped); } } else { DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox", nameOfUserWhoTyped); } break; } case "btime": { string[] arg = vs[1].Split(new char[1] { ':' }); switch (arg.Length) { case 2: { if (!boomboxItem.isPlayingMusic) { break; } int arg2 = Convert.ToInt32(arg[0]); int arg4 = Convert.ToInt32(arg[1]); switch (arg2) { case 0: switch (arg4) { case 0: boomboxItem.boomboxAudio.time = 0f; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:00:00"), "Boombox", nameOfUserWhoTyped); break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: boomboxItem.boomboxAudio.time = arg4; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:00:" + arg4.ToString("00")), "Boombox", nameOfUserWhoTyped); break; } break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: { int correct = arg2 * 60; if (arg4 > 0 && arg4 < 60) { int correct_sec = correct + arg4; boomboxItem.boomboxAudio.time = correct_sec; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:" + arg2.ToString("00") + ":" + arg4.ToString("00")), "Boombox", nameOfUserWhoTyped); } else { boomboxItem.boomboxAudio.time = correct; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:" + arg2.ToString("00") + ":00"), "Boombox", nameOfUserWhoTyped); } break; } } break; } case 3: { if (!boomboxItem.isPlayingMusic) { break; } int arg3 = Convert.ToInt32(arg[0]); int arg5 = Convert.ToInt32(arg[1]); int arg6 = Convert.ToInt32(arg[2]); switch (arg3) { case 0: if (arg5 == 0 && arg6 == 0) { boomboxItem.boomboxAudio.time = 0f; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:00:00"), "Boombox", nameOfUserWhoTyped); } else if (arg5 > 0 && arg5 < 60) { int correct2 = arg5 * 60; if (arg6 > 0 && arg6 < 60) { int correct_sec2 = correct2 + arg6; boomboxItem.boomboxAudio.time = correct_sec2; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:" + arg5.ToString("00") + ":" + arg6.ToString("00")), "Boombox", nameOfUserWhoTyped); } else { boomboxItem.boomboxAudio.time = correct2; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:" + arg5.ToString("00") + ":00"), "Boombox", nameOfUserWhoTyped); } } break; case 1: case 2: { int correct3 = arg3 * 3600; if (arg5 > 0 && arg5 < 60) { int correct_minutes = correct3 + arg5 * 60; if (arg6 > 0 && arg6 < 60) { int correct_sec3 = correct_minutes + arg6; boomboxItem.boomboxAudio.time = correct_sec3; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", arg3.ToString("00") + ":" + arg5.ToString("00") + ":" + arg6.ToString("00")), "Boombox", nameOfUserWhoTyped); } else { boomboxItem.boomboxAudio.time = correct_minutes; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", arg3.ToString("00") + ":" + arg5.ToString("00") + ":00"), "Boombox", nameOfUserWhoTyped); } } else { boomboxItem.boomboxAudio.time = correct3; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", arg3.ToString("00") + ":00:00"), "Boombox", nameOfUserWhoTyped); } break; } } break; } } break; } case "bvolume": { float volume = boomboxItem.boomboxAudio.volume; float correct_volume = (float)(Convert.ToInt32(vs[1]) / 10) * 0.1f; if (volume != correct_volume && (volume < correct_volume || volume > correct_volume)) { boomboxItem.boomboxAudio.volume = correct_volume; DrawString(__instance, Plugin.config.GetLang().main_9.Value.Replace("@1", nameOfUserWhoTyped ?? "").Replace("@2", vs[1] + "%"), "Boombox", nameOfUserWhoTyped); } break; } case "btrack": if (Convert.ToInt32(vs[1]) > 0 && Convert.ToInt32(vs[1]) <= totalTack) { int track2 = Convert.ToInt32(vs[1]) - 1; currectTrack = track2; boomboxItem.boomboxAudio.Stop(); timesPlayedWithoutTurningOff = 0; boomboxItem.boomboxAudio.clip = musicList[currectTrack]; boomboxItem.boomboxAudio.pitch = 1f; boomboxItem.boomboxAudio.Play(); DrawString(__instance, Plugin.config.GetLang().main_14.Value.Replace("@1", vs[1] ?? ""), "Boombox", nameOfUserWhoTyped); } break; } } public static void LoadPlaylist(HUDManager __instance, string nameOfUserWhoTyped) { bool flag = false; int num = 0; int num2 = new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles().Length; FileInfo[] files = new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles(); while (!flag && num != num2) { if (files[num].Exists) { bom.Start(bom.GetPlayList("file:///" + Paths.GameRootPath + "\\BoomboxController\\other\\playlist\\" + files[num].Name, boomboxItem, (AudioType)13)); num++; } Thread.Sleep(2000); } musicList = bom.audioclipsplay.ToArray(); bom.audioclipsplay.Clear(); LoadingMusicBoombox = false; DrawString(__instance, Plugin.config.GetLang().main_8.Value, "Boombox YouTube", nameOfUserWhoTyped); isplayList = false; thread.Abort(); } public static int GetAudioType(string ext) { if (ext == "mp3") { return 13; } return -1; } public static void DrawString(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped, string? name) { if (!(LastMessage == chatMessage)) { LastMessage = chatMessage; LastnameOfUserWhoTyped = name; __instance.PingHUDElement(__instance.Chat, 4f, 1f, 0.2f); if (__instance.ChatMessageHistory.Count >= 4) { ((TMP_Text)__instance.chatText).text.Remove(0, __instance.ChatMessageHistory[0].Length); __instance.ChatMessageHistory.Remove(__instance.ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); stringBuilder.Replace("[playerNum0]", StartOfRound.Instance.allPlayerScripts[0].playerUsername); stringBuilder.Replace("[playerNum1]", StartOfRound.Instance.allPlayerScripts[1].playerUsername); stringBuilder.Replace("[playerNum2]", StartOfRound.Instance.allPlayerScripts[2].playerUsername); stringBuilder.Replace("[playerNum3]", StartOfRound.Instance.allPlayerScripts[3].playerUsername); chatMessage = stringBuilder.ToString(); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#FF0000>" + nameOfUserWhoTyped + "</color>: <color=#FFFF00>'" + chatMessage + "'</color>") : ("<color=#7069ff>" + chatMessage + "</color>")); __instance.ChatMessageHistory.Add(item); ((TMP_Text)__instance.chatText).text = ""; for (int i = 0; i < __instance.ChatMessageHistory.Count; i++) { TextMeshProUGUI chatText = __instance.chatText; ((TMP_Text)chatText).text = ((TMP_Text)chatText).text + "\n" + __instance.ChatMessageHistory[i]; } } } [HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageServerRpc")] [HarmonyPostfix] [ServerRpc(RequireOwnership = false)] private static void AddPlayerChatMessageServerRpc(HUDManager __instance, string chatMessage, int playerId) { if (chatMessage.Length > 50) { MethodInfo method = ((object)__instance).GetType().GetMethod("AddPlayerChatMessageClientRpc", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(__instance, new object[2] { chatMessage, playerId }); } } [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] [HarmonyPrefix] private static bool SubmitChat_performed(HUDManager __instance, ref CallbackContext context) { //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (!LoadingMusicBoombox) { __instance.localPlayer = GameNetworkManager.Instance.localPlayerController; if (((CallbackContext)(ref context)).performed && !((Object)(object)__instance.localPlayer == (Object)null) && __instance.localPlayer.isTypingChat && ((((NetworkBehaviour)__instance.localPlayer).IsOwner && (!((NetworkBehaviour)__instance).IsServer || __instance.localPlayer.isHostPlayerObject)) || __instance.localPlayer.isTestingPlayer) && !__instance.localPlayer.isPlayerDead) { if (!string.IsNullOrEmpty(__instance.chatTextField.text) && __instance.chatTextField.text.Length < 200) { __instance.AddTextToChatOnServer(__instance.chatTextField.text, (int)__instance.localPlayer.playerClientId); } for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled && Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) > 24.4f && (!GameNetworkManager.Instance.localPlayerController.holdingWalkieTalkie || !StartOfRound.Instance.allPlayerScripts[i].holdingWalkieTalkie)) { __instance.playerCouldRecieveTextChatAnimator.SetTrigger("ping"); break; } } __instance.localPlayer.isTypingChat = false; __instance.chatTextField.text = ""; EventSystem.current.SetSelectedGameObject((GameObject)null); __instance.PingHUDElement(__instance.Chat, 2f, 1f, 0.2f); ((Behaviour)__instance.typingIndicator).enabled = false; return false; } } return false; } public static int FirstEmptyItemSlot(PlayerControllerB __instance) { int result = -1; if ((Object)(object)__instance.ItemSlots[__instance.currentItemSlot] == (Object)null) { result = __instance.currentItemSlot; } else { for (int i = 0; i < __instance.ItemSlots.Length; i++) { if ((Object)(object)__instance.ItemSlots[i] == (Object)null) { result = i; break; } } } return result; } } public class AudioBoomBox : MonoBehaviour { private static AudioBoomBox _instance; public List<AudioClip> audioclips = new List<AudioClip>(); public List<AudioClip> audioclipsplay = new List<AudioClip>(); public Coroutine Start(IEnumerator routine) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { _instance = new GameObject("AudioBoomBox").AddComponent<AudioBoomBox>(); Object.DontDestroyOnLoad((Object)_instance); } return ((MonoBehaviour)_instance).StartCoroutine(routine); } public IEnumerator GetAudioClip(string url, BoomboxItem boombox, AudioType type) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) audioclips.Clear(); UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, type); try { yield return www.SendWebRequest(); if ((int)www.result == 2) { BoomboxController.LoadingMusicBoombox = false; Plugin.instance.Log(www.error); BoomboxController.isplayList = false; } else { BoomboxController.LoadingMusicBoombox = false; AudioClip myClip = DownloadHandlerAudioClip.GetContent(www); audioclips.Add(myClip); BoomboxController.musicList = audioclips.ToArray(); BoomboxController.isplayList = false; } } finally { ((IDisposable)www)?.Dispose(); } } public IEnumerator GetPlayList(string url, BoomboxItem boombox, AudioType type) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, type); try { yield return www.SendWebRequest(); if ((int)www.result == 2) { Plugin.instance.Log(www.error); yield break; } AudioClip myClip = DownloadHandlerAudioClip.GetContent(www); audioclipsplay.Add(myClip); } finally { ((IDisposable)www)?.Dispose(); } } } public static class PluginInfo { public const string PLUGIN_GUID = "BoomboxController"; public const string PLUGIN_NAME = "BoomboxController"; public const string PLUGIN_VERSION = "1.0.0"; } }
plugins/plugins/MaxWasUnavailable-ScrollInverter/ScrollInverter.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; 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.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("ScrollInverter")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Inverts the scroll wheel direction for the item bar.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ScrollInverter")] [assembly: AssemblyTitle("ScrollInverter")] [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 ScrollInverter { [BepInPlugin("ScrollInverter", "ScrollInverter", "1.0.0")] public class ScrollInverter : BaseUnityPlugin { private bool _isPatched; private Harmony Harmony { get; set; } internal static ManualLogSource Logger { get; set; } public static ScrollInverter Instance { get; private set; } private void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; PatchAll(); Logger.LogInfo((object)"Plugin ScrollInverter is loaded!"); } public void PatchAll() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if (_isPatched) { Logger.LogWarning((object)"Already patched!"); return; } Logger.LogDebug((object)"Patching..."); Harmony = new Harmony("ScrollInverter"); Harmony.PatchAll(); _isPatched = true; Logger.LogDebug((object)"Patched!"); } public void UnpatchAll() { if (!_isPatched) { Logger.LogWarning((object)"Already unpatched!"); return; } Logger.LogDebug((object)"Unpatching..."); Harmony.UnpatchSelf(); _isPatched = false; Logger.LogDebug((object)"Unpatched!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "ScrollInverter"; public const string PLUGIN_NAME = "ScrollInverter"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ScrollInverter.Patches { [HarmonyPatch(typeof(PlayerControllerB))] public class PlayerControllerBPatches { [HarmonyPatch("SwitchItem_performed")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> InvertControlsSwitchItemPerformed(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func<CodeInstruction, bool>)delegate(CodeInstruction instruction) { string? name = instruction.opcode.Name; OpCode ble_Un = OpCodes.Ble_Un; return name == ble_Un.Name; }).ThrowIfInvalid("Could not find branch instruction").SetOpcodeAndAdvance(OpCodes.Bge_Un_S) .InstructionEnumeration(); } } }
plugins/plugins/Monkeytype-HideChat/HideChat.dll
Decompiled a year agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; 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("HideChat")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HideChat")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("fa900f4d-71b1-433a-ad23-a10fc53dc3d8")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace HideChat { [BepInPlugin("Miodec.HideChat", "Hide Chat", "1.0.0")] public class HidePlayerNames : BaseUnityPlugin { private const string modGUID = "Miodec.HideChat"; private const string modName = "Hide Chat"; private const string modVersion = "1.0.0"; private static HidePlayerNames Instance; internal ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("Miodec.HideChat"); mls.LogDebug((object)"hidechat is awake"); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } } } namespace HideChat.Patches { [HarmonyPatch(typeof(HUDManager))] internal class HUDManagerPatch { [HarmonyPatch("OpenMenu_performed")] [HarmonyPatch("SubmitChat_performed")] [HarmonyPatch("AddChatMessage")] [HarmonyPostfix] public static void FadeToNothing(ref HUDManager __instance) { __instance.PingHUDElement(__instance.Chat, 5f, 1f, 0f); } } }
plugins/plugins/NotAtomicBomb-Terminal_Clock/TerminalClock.dll
Decompiled a year agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using TerminalApi.Events; 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(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("TerminalClock")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5afd40ebd6827491e1c7c10c5c31c950b7e830c0")] [assembly: AssemblyProduct("TerminalClock")] [assembly: AssemblyTitle("TerminalClock")] [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 TerminalClock { [HarmonyPatch(typeof(HUDManager))] public static class OnSetClock { [HarmonyPatch("SetClock")] [HarmonyPostfix] public static void SetClock(ref HUDManager __instance) { ((TMP_Text)Plugin.ClockText).text = ((TMP_Text)__instance.clockNumber).text.Replace('\n', ' '); } } [BepInPlugin("atomic.terminalclock", "Terminal Clock", "1.0.5")] [BepInDependency("atomic.terminalapi", "1.2.0")] public class Plugin : BaseUnityPlugin { internal static GameObject _clock; internal const string UNKOWNTIME = "??:?? ??"; internal static ConfigEntry<bool> configDisplayUnkownTime; internal static TextMeshProUGUI ClockText => _clock.GetComponent<TextMeshProUGUI>(); private void Awake() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown SetupConfig(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Terminal Clock is loaded!"); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); Events.TerminalAwake += new TerminalEventHandler(OnTerminalAwake); } private void OnTerminalAwake(object sender, TerminalEventArgs e) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)e.Terminal).transform.parent.parent.Find("Canvas").Find("MainContainer"); try { _clock = ((Component)val.Find("Clock")).gameObject; } catch { _clock = Object.Instantiate<GameObject>(((Component)val.Find("CurrentCreditsNum")).gameObject, val); ((Object)_clock).name = "Clock"; _clock.transform.localPosition = new Vector3(255f, 200.6003f, -1.0003f); _clock.transform.localScale = new Vector3(0.9f, 0.9f, 1f); ((TMP_Text)ClockText).text = (configDisplayUnkownTime.Value ? "??:?? ??" : ""); } } internal void SetupConfig() { configDisplayUnkownTime = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "displayUnknown", true, "Whether or not to show '??:??' when the time is unkown."); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "TerminalClock"; public const string PLUGIN_NAME = "TerminalClock"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace TerminalClock.Patches { [HarmonyPatch(typeof(HUDManager))] public static class OnFillEndGameStats { [HarmonyPatch("FillEndGameStats")] [HarmonyPostfix] public static void FillEndGameStats() { ((TMP_Text)Plugin.ClockText).text = (Plugin.configDisplayUnkownTime.Value ? "??:?? ??" : ""); } } }
plugins/plugins/NotAtomicBomb-Terminal_History/Terminal History.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using TerminalApi; using TerminalApi.Events; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("Terminal History")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Terminal Command History")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+22af0d131fcfcb352cbbd5a5a6fc0cb15967e567")] [assembly: AssemblyProduct("Terminal History")] [assembly: AssemblyTitle("Terminal History")] [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 TerminalHistory { [BepInPlugin("atomic.terminalhistory", "Terminal History", "1.0.1")] [BepInDependency("atomic.terminalapi", "1.3.0")] public class Plugin : BaseUnityPlugin { private const int SIZE = 20; private Terminal Terminal; private List<string> _commands = new List<string>(); private InputAction _upArrow; private InputAction _downArrow; private int _index = -1; private void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Terminal History is loaded!"); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); Events.TerminalStarted += new TerminalEventHandler(OnTerminalStarted); Events.TerminalExited += new TerminalEventHandler(OnTerminalExited); Events.TerminalBeginUsing += new TerminalEventHandler(OnTerminalBeginUsing); Events.TerminalParsedSentence += new TerminalParseSentenceEventHandler(OnTerminalSubmit); Events.TerminalTextChanged += new TerminalTextChangedEventHandler(OnTerminalTextChange); } private void OnTerminalTextChange(object sender, TerminalTextChangedEventArgs e) { if (e.CurrentInputText == "" && _index != -1) { _index = -1; } } private void OnTerminalSubmit(object sender, TerminalParseSentenceEventArgs e) { if (_commands.Contains(e.SubmittedText)) { _commands.Remove(e.SubmittedText); } _commands.Insert(0, e.SubmittedText); if (_commands.Count > 20) { _commands.RemoveRange(20, _commands.Count - 20); } _index = -1; } private void OnTerminalExited(object sender, TerminalEventArgs e) { _upArrow.performed -= OnUpArrowPerformed; _upArrow.Disable(); _downArrow.performed -= OnDownArrowPerformed; _downArrow.Disable(); } private void OnTerminalBeginUsing(object sender, TerminalEventArgs e) { _upArrow.Enable(); _upArrow.performed += OnUpArrowPerformed; _downArrow.Enable(); _downArrow.performed += OnDownArrowPerformed; } private void OnTerminalStarted(object sender, TerminalEventArgs e) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown _commands.Clear(); _upArrow = new InputAction("UpArrow", (InputActionType)0, "<Keyboard>/uparrow", "Press", (string)null, (string)null); _downArrow = new InputAction("DownArrow", (InputActionType)0, "<Keyboard>/downarrow", "Press", (string)null, (string)null); Terminal = TerminalApi.Terminal; } private void OnDownArrowPerformed(CallbackContext context) { if (_commands.Count > 0 && Terminal.terminalInUse) { _index--; if (_index <= -1) { _index = -1; SetTerminalText(""); } else { string terminalText = _commands[_index]; SetTerminalText(terminalText); } } } private void OnUpArrowPerformed(CallbackContext context) { if (Terminal.terminalInUse && _commands.Count > 0) { _index++; if (_index >= _commands.Count) { _index = _commands.Count - 1; string terminalText = _commands[_commands.Count - 1]; SetTerminalText(terminalText); } else { string terminalText2 = _commands[_index]; SetTerminalText(terminalText2); } } } private void SetTerminalText(string text) { Terminal.TextChanged(TerminalApi.Terminal.currentText.Substring(0, TerminalApi.Terminal.currentText.Length - TerminalApi.Terminal.textAdded) + text); Terminal.screenText.text = TerminalApi.Terminal.currentText; Terminal.textAdded = text.Length; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Terminal History"; public const string PLUGIN_NAME = "Terminal History"; public const string PLUGIN_VERSION = "1.0.0"; } }
plugins/plugins/NotAtomicBomb-TerminalApi/TerminalApi.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("NotAtomicBomb")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Terminal Api for the terminal in Lethal Company")] [assembly: AssemblyFileVersion("1.3.2.0")] [assembly: AssemblyInformationalVersion("1.3.2+44e31091a66b8ea97adb9f97042f28b67097a1e2")] [assembly: AssemblyProduct("TerminalApi")] [assembly: AssemblyTitle("TerminalApi")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/NotAtomicBomb/TerminalApi")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.2.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 TerminalApi { internal class DelayedAction { internal Action<TerminalKeyword> Action { get; set; } internal TerminalKeyword Keyword { get; set; } internal void Run() { Action(Keyword); } } [BepInPlugin("atomic.terminalapi", "Terminal Api", "1.3.0")] public class Plugin : BaseUnityPlugin { public ManualLogSource Log = new ManualLogSource("Terminal Api"); private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TerminalApi is loaded!"); Logger.Sources.Add((ILogSource)(object)Log); TerminalApi.plugin = this; Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } } public static class TerminalApi { public static Plugin plugin; internal static List<DelayedAction> QueuedActions = new List<DelayedAction>(); public static Terminal Terminal { get; internal set; } public static bool IsInGame() { try { return Terminal != null; } catch (NullReferenceException) { return false; } } public static void AddCommand(string commandWord, string displayText, string verbWord = null, bool clearPreviousText = true) { commandWord = commandWord.ToLower(); TerminalKeyword val = CreateTerminalKeyword(commandWord); TerminalNode val2 = CreateTerminalNode(displayText, clearPreviousText); if (verbWord != null) { verbWord = verbWord.ToLower(); TerminalKeyword terminalKeyword = CreateTerminalKeyword(verbWord, isVerb: true); AddTerminalKeyword(val.defaultVerb = terminalKeyword.AddCompatibleNoun(val, val2)); AddTerminalKeyword(val); } else { val.specialKeywordResult = val2; AddTerminalKeyword(val); } } public static TerminalKeyword CreateTerminalKeyword(string word, bool isVerb = false, TerminalNode triggeringNode = null) { TerminalKeyword obj = ScriptableObject.CreateInstance<TerminalKeyword>(); obj.word = word.ToLower(); obj.isVerb = isVerb; obj.specialKeywordResult = triggeringNode; return obj; } public static TerminalKeyword CreateTerminalKeyword(string word, string displayText, bool clearPreviousText = false, string terminalEvent = "") { TerminalKeyword obj = ScriptableObject.CreateInstance<TerminalKeyword>(); obj.word = word.ToLower(); obj.isVerb = false; obj.specialKeywordResult = CreateTerminalNode(displayText, clearPreviousText, terminalEvent); return obj; } public static TerminalNode CreateTerminalNode(string displayText, bool clearPreviousText = false, string terminalEvent = "") { TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>(); obj.displayText = displayText; obj.clearPreviousText = clearPreviousText; obj.terminalEvent = terminalEvent; return obj; } public static void AddTerminalKeyword(TerminalKeyword terminalKeyword) { if (IsInGame()) { if (GetKeyword(terminalKeyword.word) == null) { Terminal.terminalNodes.allKeywords = Terminal.terminalNodes.allKeywords.Add(terminalKeyword); plugin.Log.LogMessage((object)("Added " + terminalKeyword.word + " keyword to terminal keywords.")); } else { plugin.Log.LogWarning((object)("Failed to add " + terminalKeyword.word + " keyword. Already exists.")); } } else { plugin.Log.LogMessage((object)("Not in game, waiting to be in game to add " + terminalKeyword.word + " keyword.")); Action<TerminalKeyword> action = AddTerminalKeyword; DelayedAction item = new DelayedAction { Action = action, Keyword = terminalKeyword }; QueuedActions.Add(item); } } public static TerminalKeyword GetKeyword(string keyword) { if (IsInGame()) { return ((IEnumerable<TerminalKeyword>)Terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword Kw) => Kw.word == keyword)); } return null; } public static void UpdateKeyword(TerminalKeyword keyword) { if (!IsInGame()) { return; } for (int i = 0; i < Terminal.terminalNodes.allKeywords.Length; i++) { if (Terminal.terminalNodes.allKeywords[i].word == keyword.word) { Terminal.terminalNodes.allKeywords[i] = keyword; return; } } plugin.Log.LogInfo((object)("Failed to update " + keyword.word + ". Was not found in keywords.")); } public static void UpdateKeywordCompatibleNoun(TerminalKeyword verbKeyword, string noun, TerminalNode newTriggerNode) { if (!IsInGame() || !verbKeyword.isVerb) { return; } for (int i = 0; i < verbKeyword.compatibleNouns.Length; i++) { CompatibleNoun val = verbKeyword.compatibleNouns[i]; if (val.noun.word == noun) { val.result = newTriggerNode; UpdateKeyword(verbKeyword); return; } } plugin.Log.LogWarning((object)$"WARNING: No noun found for {verbKeyword}"); } public static void UpdateKeywordCompatibleNoun(string verbWord, string noun, TerminalNode newTriggerNode) { if (!IsInGame()) { return; } TerminalKeyword keyword = GetKeyword(verbWord); if (!keyword.isVerb || verbWord == null) { return; } for (int i = 0; i < keyword.compatibleNouns.Length; i++) { CompatibleNoun val = keyword.compatibleNouns[i]; if (val.noun.word == noun) { val.result = newTriggerNode; UpdateKeyword(keyword); return; } } plugin.Log.LogWarning((object)$"WARNING: No noun found for {keyword}"); } public static void UpdateKeywordCompatibleNoun(TerminalKeyword verbKeyword, string noun, string newDisplayText) { if (!IsInGame() || !verbKeyword.isVerb) { return; } for (int i = 0; i < verbKeyword.compatibleNouns.Length; i++) { CompatibleNoun val = verbKeyword.compatibleNouns[i]; if (val.noun.word == noun) { val.result.displayText = newDisplayText; UpdateKeyword(verbKeyword); return; } } plugin.Log.LogWarning((object)$"WARNING: No noun found for {verbKeyword}"); } public static void UpdateKeywordCompatibleNoun(string verbWord, string noun, string newDisplayText) { if (!IsInGame()) { return; } TerminalKeyword keyword = GetKeyword(verbWord); if (!keyword.isVerb) { return; } for (int i = 0; i < keyword.compatibleNouns.Length; i++) { CompatibleNoun val = keyword.compatibleNouns[i]; if (val.noun.word == noun) { val.result.displayText = newDisplayText; UpdateKeyword(keyword); return; } } plugin.Log.LogWarning((object)$"WARNING: No noun found for {keyword}"); } public static void AddCompatibleNoun(TerminalKeyword verbKeyword, string noun, string displayText, bool clearPreviousText = false) { if (IsInGame()) { TerminalKeyword keyword = GetKeyword(noun); verbKeyword = verbKeyword.AddCompatibleNoun(keyword, displayText, clearPreviousText); UpdateKeyword(verbKeyword); } } public static void AddCompatibleNoun(TerminalKeyword verbKeyword, string noun, TerminalNode triggerNode) { if (IsInGame()) { TerminalKeyword keyword = GetKeyword(noun); verbKeyword = verbKeyword.AddCompatibleNoun(keyword, triggerNode); UpdateKeyword(verbKeyword); } } public static void AddCompatibleNoun(string verbWord, string noun, TerminalNode triggerNode) { if (IsInGame()) { TerminalKeyword keyword = GetKeyword(verbWord); TerminalKeyword keyword2 = GetKeyword(noun); if ((Object)(object)keyword == (Object)null) { plugin.Log.LogError((object)"The verb given does not exist."); return; } keyword = keyword.AddCompatibleNoun(keyword2, triggerNode); UpdateKeyword(keyword); } } public static void AddCompatibleNoun(string verbWord, string noun, string displayText, bool clearPreviousText = false) { if (IsInGame()) { TerminalKeyword keyword = GetKeyword(verbWord); TerminalKeyword keyword2 = GetKeyword(noun); if ((Object)(object)keyword == (Object)null) { plugin.Log.LogError((object)"The verb given does not exist."); return; } keyword = keyword.AddCompatibleNoun(keyword2, displayText, clearPreviousText); UpdateKeyword(keyword); } } } public static class TerminalExtenstionMethods { public static TerminalKeyword AddCompatibleNoun(this TerminalKeyword terminalKeyword, TerminalKeyword noun, TerminalNode result) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (terminalKeyword.isVerb) { CompatibleNoun val = new CompatibleNoun { noun = noun, result = result }; if (terminalKeyword.compatibleNouns == null) { terminalKeyword.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[1] { val }; } else { terminalKeyword.compatibleNouns = terminalKeyword.compatibleNouns.Add(val); } return terminalKeyword; } return null; } public static TerminalKeyword AddCompatibleNoun(this TerminalKeyword terminalKeyword, string noun, TerminalNode result) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown if (terminalKeyword.isVerb) { CompatibleNoun val = new CompatibleNoun { noun = TerminalApi.CreateTerminalKeyword(noun), result = result }; if (terminalKeyword.compatibleNouns == null) { terminalKeyword.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[1] { val }; } else { terminalKeyword.compatibleNouns = terminalKeyword.compatibleNouns.Add(val); } return terminalKeyword; } return null; } public static TerminalKeyword AddCompatibleNoun(this TerminalKeyword terminalKeyword, string noun, string displayText) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if (terminalKeyword.isVerb) { CompatibleNoun val = new CompatibleNoun { noun = TerminalApi.CreateTerminalKeyword(noun), result = TerminalApi.CreateTerminalNode(displayText) }; if (terminalKeyword.compatibleNouns == null) { terminalKeyword.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[1] { val }; } else { terminalKeyword.compatibleNouns = terminalKeyword.compatibleNouns.Add(val); } return terminalKeyword; } return null; } public static TerminalKeyword AddCompatibleNoun(this TerminalKeyword terminalKeyword, TerminalKeyword noun, string displayText, bool clearPreviousText = false) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (terminalKeyword.isVerb) { CompatibleNoun val = new CompatibleNoun { noun = noun, result = TerminalApi.CreateTerminalNode(displayText, clearPreviousText) }; if (terminalKeyword.compatibleNouns == null) { terminalKeyword.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[1] { val }; } else { terminalKeyword.compatibleNouns = terminalKeyword.compatibleNouns.Add(val); } return terminalKeyword; } return null; } internal static T[] Add<T>(this T[] array, T newItem) { int num = array.Length + 1; Array.Resize(ref array, num); array[num - 1] = newItem; return array; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "TerminalApi"; public const string PLUGIN_NAME = "TerminalApi"; public const string PLUGIN_VERSION = "1.3.2"; } } namespace TerminalApi.Events { [HarmonyPatch(typeof(Terminal))] [HarmonyPatch(typeof(Terminal))] [HarmonyPatch(typeof(Terminal))] [HarmonyPatch(typeof(Terminal))] [HarmonyPatch(typeof(Terminal))] [HarmonyPatch(typeof(Terminal))] [HarmonyPatch(typeof(Terminal))] [HarmonyPatch(typeof(Terminal))] [HarmonyPatch(typeof(Terminal))] public static class Events { public class TerminalEventArgs : EventArgs { public Terminal Terminal { get; set; } } public delegate void TerminalEventHandler(object sender, TerminalEventArgs e); public class TerminalParseSentenceEventArgs : TerminalEventArgs { public TerminalNode ReturnedNode { get; set; } public string SubmittedText { get; set; } } public delegate void TerminalParseSentenceEventHandler(object sender, TerminalParseSentenceEventArgs e); public class TerminalTextChangedEventArgs : TerminalEventArgs { public string NewText; public string CurrentInputText; } public delegate void TerminalTextChangedEventHandler(object sender, TerminalTextChangedEventArgs e); public static event TerminalEventHandler TerminalAwake; public static event TerminalEventHandler TerminalWaking; public static event TerminalEventHandler TerminalStarted; public static event TerminalEventHandler TerminalStarting; public static event TerminalEventHandler TerminalBeginUsing; public static event TerminalEventHandler TerminalBeganUsing; public static event TerminalEventHandler TerminalExited; public static event TerminalParseSentenceEventHandler TerminalParsedSentence; public static event TerminalTextChangedEventHandler TerminalTextChanged; [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Awake(ref Terminal __instance) { TerminalApi.Terminal = __instance; if (TerminalApi.QueuedActions.Count > 0) { TerminalApi.plugin.Log.LogMessage((object)"In game, now adding words."); foreach (DelayedAction queuedAction in TerminalApi.QueuedActions) { queuedAction.Run(); } TerminalApi.QueuedActions.Clear(); } Events.TerminalAwake?.Invoke(__instance, new TerminalEventArgs { Terminal = __instance }); } [HarmonyPatch("BeginUsingTerminal")] [HarmonyPostfix] public static void BeganUsing(ref Terminal __instance) { Events.TerminalBeganUsing?.Invoke(__instance, new TerminalEventArgs { Terminal = __instance }); } [HarmonyPatch("QuitTerminal")] [HarmonyPostfix] public static void OnQuitTerminal(ref Terminal __instance) { Events.TerminalExited?.Invoke(__instance, new TerminalEventArgs { Terminal = __instance }); } [HarmonyPatch("BeginUsingTerminal")] [HarmonyPrefix] public static void OnBeginUsing(ref Terminal __instance) { Events.TerminalBeginUsing?.Invoke(__instance, new TerminalEventArgs { Terminal = __instance }); } [HarmonyPatch("ParsePlayerSentence")] [HarmonyPostfix] public static void ParsePlayerSentence(ref Terminal __instance, TerminalNode __result) { string submittedText = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded); Events.TerminalParsedSentence?.Invoke(__instance, new TerminalParseSentenceEventArgs { Terminal = __instance, SubmittedText = submittedText, ReturnedNode = __result }); } [HarmonyPatch("Start")] [HarmonyPostfix] public static void Started(ref Terminal __instance) { Events.TerminalStarted?.Invoke(__instance, new TerminalEventArgs { Terminal = __instance }); } [HarmonyPatch("Start")] [HarmonyPrefix] public static void Starting(ref Terminal __instance) { Events.TerminalStarting?.Invoke(__instance, new TerminalEventArgs { Terminal = __instance }); } [HarmonyPatch("TextChanged")] [HarmonyPostfix] public static void OnTextChanged(ref Terminal __instance, string newText) { string currentInputText = ""; if (newText.Trim().Length >= __instance.textAdded) { currentInputText = newText.Substring(newText.Length - __instance.textAdded); } Events.TerminalTextChanged?.Invoke(__instance, new TerminalTextChangedEventArgs { Terminal = __instance, NewText = newText, CurrentInputText = currentInputText }); } [HarmonyPatch("Awake")] [HarmonyPrefix] public static void Waking(ref Terminal __instance) { Events.TerminalWaking?.Invoke(__instance, new TerminalEventArgs { Terminal = __instance }); } } }
plugins/plugins/Renegades-FlashlightToggle/FlashlightToggle.dll
Decompiled a year agousing 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.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [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: AssemblyCompany("Control")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0465852cfa101b431accf8b751972dc96a66f057")] [assembly: AssemblyProduct("Control")] [assembly: AssemblyTitle("Control")] [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 Control { public static class PluginInfo { public const string PLUGIN_GUID = "Control"; public const string PLUGIN_NAME = "Control"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Flashlight { [BepInPlugin("rr.Flashlight", "Flashlight", "1.4.0")] public class Plugin : BaseUnityPlugin { private static string path = Application.persistentDataPath + "/flashlightbutton.txt"; internal static ManualLogSource logSource; private static InputActionAsset asset; private static string defaultkey = "/Keyboard/f"; private Harmony _harmony = new Harmony("Flashlight"); private void Awake() { _harmony.PatchAll(typeof(Plugin)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"------Flashlight done.------"); logSource = ((BaseUnityPlugin)this).Logger; } public static void setAsset(string thing) { asset = InputActionAsset.FromJson("\r\n {\r\n \"maps\" : [\r\n {\r\n \"name\" : \"Flashlight\",\r\n \"actions\": [\r\n {\"name\": \"togglef\", \"type\" : \"button\"}\r\n ],\r\n \"bindings\" : [\r\n {\"path\" : \"" + thing + "\", \"action\": \"togglef\"}\r\n ]\r\n }\r\n ]\r\n }"); } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPostfix] public static void ClearFlashlight(PlayerControllerB __instance) { __instance.pocketedFlashlight = null; } [HarmonyPatch(typeof(IngamePlayerSettings), "CompleteRebind")] [HarmonyPrefix] public static void SavingToFile(IngamePlayerSettings __instance) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!(__instance.rebindingOperation.action.name != "togglef")) { File.WriteAllText(path, __instance.rebindingOperation.action.controls[0].path); string text = defaultkey; if (File.Exists(path)) { text = File.ReadAllText(path); } setAsset(text); } } [HarmonyPatch(typeof(KepRemapPanel), "LoadKeybindsUI")] [HarmonyPrefix] public static void Testing(KepRemapPanel __instance) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown string text = defaultkey; if (!File.Exists(path)) { File.WriteAllText(path, defaultkey); } else { text = File.ReadAllText(path); } for (int i = 0; i < __instance.remappableKeys.Count; i++) { if (__instance.remappableKeys[i].ControlName == "Flashlight") { return; } } RemappableKey val = new RemappableKey(); setAsset(text); InputActionReference currentInput = InputActionReference.Create(asset.FindAction("Flashlight/togglef", false)); val.ControlName = "Flashlight"; val.currentInput = currentInput; __instance.remappableKeys.Add(val); } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] public static void ReadInput(PlayerControllerB __instance) { if (((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer) || __instance.inTerminalMenu || __instance.isTypingChat || !Application.isFocused) { return; } if (__instance.currentlyHeldObjectServer is FlashlightItem && (Object)(object)__instance.currentlyHeldObjectServer != (Object)(object)__instance.pocketedFlashlight) { __instance.pocketedFlashlight = __instance.currentlyHeldObjectServer; } if ((Object)(object)__instance.pocketedFlashlight == (Object)null) { return; } string text = defaultkey; if (!File.Exists(path)) { File.WriteAllText(path, defaultkey); } else { text = File.ReadAllText(path); } if (!Object.op_Implicit((Object)(object)asset) || !asset.enabled) { setAsset(text); asset.Enable(); } if (!asset.FindAction("Flashlight/togglef", false).triggered || !(__instance.pocketedFlashlight is FlashlightItem) || !__instance.pocketedFlashlight.isHeld) { return; } try { __instance.pocketedFlashlight.UseItemOnClient(true); if (!(__instance.currentlyHeldObjectServer is FlashlightItem)) { GrabbableObject pocketedFlashlight = __instance.pocketedFlashlight; ((Behaviour)((FlashlightItem)((pocketedFlashlight is FlashlightItem) ? pocketedFlashlight : null)).flashlightBulbGlow).enabled = false; GrabbableObject pocketedFlashlight2 = __instance.pocketedFlashlight; ((Behaviour)((FlashlightItem)((pocketedFlashlight2 is FlashlightItem) ? pocketedFlashlight2 : null)).flashlightBulb).enabled = false; GrabbableObject pocketedFlashlight3 = __instance.pocketedFlashlight; if (((pocketedFlashlight3 is FlashlightItem) ? pocketedFlashlight3 : null).isBeingUsed) { ((Behaviour)__instance.helmetLight).enabled = true; GrabbableObject pocketedFlashlight4 = __instance.pocketedFlashlight; ((FlashlightItem)((pocketedFlashlight4 is FlashlightItem) ? pocketedFlashlight4 : null)).usingPlayerHelmetLight = true; GrabbableObject pocketedFlashlight5 = __instance.pocketedFlashlight; ((FlashlightItem)((pocketedFlashlight5 is FlashlightItem) ? pocketedFlashlight5 : null)).PocketFlashlightServerRpc(true); } else { ((Behaviour)__instance.helmetLight).enabled = false; GrabbableObject pocketedFlashlight6 = __instance.pocketedFlashlight; ((FlashlightItem)((pocketedFlashlight6 is FlashlightItem) ? pocketedFlashlight6 : null)).usingPlayerHelmetLight = false; GrabbableObject pocketedFlashlight7 = __instance.pocketedFlashlight; ((FlashlightItem)((pocketedFlashlight7 is FlashlightItem) ? pocketedFlashlight7 : null)).PocketFlashlightServerRpc(false); } } } catch { } } } }
plugins/plugins/RickArg-Helmet_Cameras/HelmetCamera.dll
Decompiled a year agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("HelmetCamera")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HelmetCamera")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b99c4d46-5f13-47b3-a5af-5e3f37772e77")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace HelmetCamera { [BepInPlugin("RickArg.lethalcompany.helmetcameras", "Helmet_Cameras", "2.1.5")] public class PluginInit : BaseUnityPlugin { public static Harmony _harmony; public static ConfigEntry<int> config_isHighQuality; public static ConfigEntry<int> config_renderDistance; public static ConfigEntry<int> config_cameraFps; private void Awake() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown config_isHighQuality = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "monitorResolution", 0, "Low FPS affection. High Quality mode. 0 - vanilla (48x48), 1 - vanilla+ (128x128), 2 - mid quality (256x256), 3 - high quality (512x512), 4 - Very High Quality (1024x1024)"); config_renderDistance = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "renderDistance", 20, "Low FPS affection. Render distance for helmet camera."); config_cameraFps = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "cameraFps", 30, "Very high FPS affection. FPS for helmet camera. To increase YOUR fps, you should low cameraFps value."); _harmony = new Harmony("HelmetCamera"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Helmet_Cameras is loaded with version 2.1.5!"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"--------Helmet camera patch done.---------"); } } public static class PluginInfo { public const string PLUGIN_GUID = "RickArg.lethalcompany.helmetcameras"; public const string PLUGIN_NAME = "Helmet_Cameras"; public const string PLUGIN_VERSION = "2.1.5"; } public class Plugin : MonoBehaviour { private RenderTexture renderTexture; private bool isMonitorChanged = false; private GameObject helmetCameraNew; private bool isSceneLoaded = false; private bool isCoroutineStarted = false; private int currentTransformIndex; private int resolution = 0; private int renderDistance = 50; private float cameraFps = 30f; private float elapsed; private void Awake() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown resolution = PluginInit.config_isHighQuality.Value; renderDistance = PluginInit.config_renderDistance.Value; cameraFps = PluginInit.config_cameraFps.Value; switch (resolution) { case 0: renderTexture = new RenderTexture(48, 48, 24); break; case 1: renderTexture = new RenderTexture(128, 128, 24); break; case 2: renderTexture = new RenderTexture(256, 256, 24); break; case 3: renderTexture = new RenderTexture(512, 512, 24); break; case 4: renderTexture = new RenderTexture(1024, 1024, 24); break; } } public void Start() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) isCoroutineStarted = false; while ((Object)(object)helmetCameraNew == (Object)null) { helmetCameraNew = new GameObject("HelmetCamera"); } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "MainMenu") { activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "InitScene") { activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "InitSceneLaunchOptions") { isSceneLoaded = true; Debug.Log((object)"[HELMET_CAMERAS] Starting coroutine..."); ((MonoBehaviour)this).StartCoroutine(LoadSceneEnter()); return; } } } isSceneLoaded = false; isMonitorChanged = false; } private IEnumerator LoadSceneEnter() { Debug.Log((object)"[HELMET_CAMERAS] 5 seconds for init mode... Please wait..."); yield return (object)new WaitForSeconds(5f); isCoroutineStarted = true; if ((Object)(object)GameObject.Find("Environment/HangarShip/Cameras/ShipCamera") != (Object)null) { Debug.Log((object)"[HELMET_CAMERAS] Ship camera founded..."); if (!isMonitorChanged) { ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube").GetComponent<MeshRenderer>()).materials[2].mainTexture = ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001").GetComponent<MeshRenderer>()).materials[2].mainTexture; ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001").GetComponent<MeshRenderer>()).materials[2].mainTexture = (Texture)(object)renderTexture; helmetCameraNew.AddComponent<Camera>(); ((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = false; helmetCameraNew.GetComponent<Camera>().targetTexture = renderTexture; helmetCameraNew.GetComponent<Camera>().cullingMask = 20649983; helmetCameraNew.GetComponent<Camera>().farClipPlane = renderDistance; helmetCameraNew.GetComponent<Camera>().nearClipPlane = 0.55f; isMonitorChanged = true; Debug.Log((object)"[HELMET_CAMERAS] Monitors were changed..."); Debug.Log((object)"[HELMET_CAMERAS] Turning off vanilla internal ship camera"); ((Behaviour)GameObject.Find("Environment/HangarShip/Cameras/ShipCamera").GetComponent<Camera>()).enabled = false; } } } public void Update() { //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: 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_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: 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) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) bool flag = isSceneLoaded && isCoroutineStarted; if (flag && StartOfRound.Instance.localPlayerController.isInHangarShipRoom) { helmetCameraNew.SetActive(true); elapsed += Time.deltaTime; if (elapsed > 1f / cameraFps) { elapsed = 0f; ((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = true; } else { ((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = false; } GameObject val = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001/CameraMonitorScript"); currentTransformIndex = val.GetComponent<ManualCameraRenderer>().targetTransformIndex; TransformAndName val2 = val.GetComponent<ManualCameraRenderer>().radarTargets[currentTransformIndex]; if (!val2.isNonPlayer) { try { helmetCameraNew.transform.SetPositionAndRotation(val2.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HelmetLights").position + new Vector3(0f, 0f, 0f), val2.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HelmetLights").rotation * Quaternion.Euler(0f, 0f, 0f)); DeadBodyInfo[] array = Object.FindObjectsOfType<DeadBodyInfo>(); for (int i = 0; i < array.Length; i++) { if (array[i].playerScript.playerUsername == val2.name) { helmetCameraNew.transform.SetPositionAndRotation(((Component)array[i]).gameObject.transform.Find("spine.001/spine.002/spine.003").position, ((Component)array[i]).gameObject.transform.Find("spine.001/spine.002/spine.003").rotation * Quaternion.Euler(0f, 0f, 0f)); } } return; } catch (NullReferenceException) { Debug.Log((object)"[HELMET_CAMERAS] ERROR NULL REFERENCE"); return; } } helmetCameraNew.transform.SetPositionAndRotation(val2.transform.position + new Vector3(0f, 1.6f, 0f), val2.transform.rotation * Quaternion.Euler(0f, -90f, 0f)); } else if (flag && !StartOfRound.Instance.localPlayerController.isInHangarShipRoom) { helmetCameraNew.SetActive(false); } } } } namespace HelmetCamera.Patches { [HarmonyPatch] internal class HelmetCamera { public static void InitCameras() { GameObject val = GameObject.Find("Environment/HangarShip/Cameras/ShipCamera"); val.AddComponent<Plugin>(); } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] public static void InitCamera(ref ManualCameraRenderer __instance) { InitCameras(); } } }
plugins/plugins/stefan750-LCUltrawide/LCUltrawide.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("stefan750")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A mod that allows changing of the resolution and aspect ratio of the game and UI elements")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+516a65c96fe17ba1154e9435a986f5bce37b2daf")] [assembly: AssemblyProduct("LCUltrawide")] [assembly: AssemblyTitle("LCUltrawide")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.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 LCUltrawide { [BepInPlugin("LCUltrawide", "LCUltrawide", "1.1.1")] public class Plugin : BaseUnityPlugin { private static ConfigEntry<int> configResW; private static ConfigEntry<int> configResH; private static ConfigEntry<float> configUIScale; private static ConfigEntry<float> configUIAspect; private static float aspectUpdateTime = 1f; private static bool aspectAutoDetect = false; private static float prevAspect = 0f; private static float prevTime = 0f; private static float fDefaultHelmetWidth = 0.3628f; private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LCUltrawide is loaded!"); configResW = ((BaseUnityPlugin)this).Config.Bind<int>("Resolution Override", "Width", 0, "Horizontal rendering resolution override.\nIf set to 0, the resolution will be automatically adjusted to fit your monitors aspect ratio.\nGame default value: 860"); configResH = ((BaseUnityPlugin)this).Config.Bind<int>("Resolution Override", "Height", 0, "Vertical rendering resolution override.\nIf set to 0, the original resolution will be used.\nGame default value: 520"); configUIScale = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Scale", 1f, "Changes the size of UI elements on the screen."); configUIAspect = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "AspectRatio", 0f, "Changes the aspect ratio of the ingame HUD, a higher number makes the HUD wider.\n(0 = auto, 1.33 = 4:3, 1.77 = 16:9, 2.33 = 21:9, 3.55 = 32:9)"); aspectAutoDetect = configResW.Value <= 0; Harmony.CreateAndPatchAll(typeof(Plugin), (string)null); } public static void ChangeAspectRatio(float newAspect) { //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) HUDManager instance = HUDManager.Instance; Texture texture = instance.playerScreenTexture.texture; RenderTexture val = (RenderTexture)(object)((texture is RenderTexture) ? texture : null); val.Release(); ((Texture)val).height = ((configResH.Value > 0) ? configResH.Value : ((Texture)val).height); ((Texture)val).width = ((configResW.Value > 0) ? configResW.Value : Convert.ToInt32((float)((Texture)val).height * newAspect)); GameObject val2 = GameObject.Find("TerminalScript"); Terminal val3 = default(Terminal); if ((Object)(object)val2 != (Object)null && val2.TryGetComponent<Terminal>(ref val3)) { RenderTexture playerScreenTexHighRes = val3.playerScreenTexHighRes; playerScreenTexHighRes.Release(); ((Texture)playerScreenTexHighRes).height = ((configResH.Value > 0) ? configResH.Value : ((Texture)playerScreenTexHighRes).height); ((Texture)playerScreenTexHighRes).width = ((configResW.Value > 0) ? configResW.Value : Convert.ToInt32((float)((Texture)playerScreenTexHighRes).height * newAspect)); } if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { GameNetworkManager.Instance.localPlayerController.gameplayCamera.ResetAspect(); } GameObject val4 = GameObject.Find("Systems/UI/Canvas/Panel"); AspectRatioFitter val5 = default(AspectRatioFitter); if ((Object)(object)val4 != (Object)null && val4.TryGetComponent<AspectRatioFitter>(ref val5)) { val5.aspectRatio = newAspect; } GameObject val6 = GameObject.Find("Systems/UI/Canvas"); CanvasScaler val7 = default(CanvasScaler); if ((Object)(object)val6 != (Object)null && val6.TryGetComponent<CanvasScaler>(ref val7)) { float num = 500f / configUIScale.Value; float num2 = num * newAspect; val7.referenceResolution = new Vector2(num2, num); } GameObject hUDContainer = instance.HUDContainer; AspectRatioFitter val8 = default(AspectRatioFitter); if ((Object)(object)hUDContainer != (Object)null && hUDContainer.TryGetComponent<AspectRatioFitter>(ref val8)) { val8.aspectRatio = ((configUIAspect.Value > 0f) ? configUIAspect.Value : newAspect); } GameObject val9 = GameObject.Find("Systems/UI/UICamera"); Camera val10 = default(Camera); if ((Object)(object)val9 != (Object)null && val9.TryGetComponent<Camera>(ref val10)) { val10.fieldOfView = Math.Min(106f / ((configUIAspect.Value > 0f) ? configUIAspect.Value : newAspect), 60f); } GameObject gameObject = ((Component)instance.Inventory.canvasGroup).gameObject; RectTransform val11 = default(RectTransform); if ((Object)(object)gameObject != (Object)null && gameObject.TryGetComponent<RectTransform>(ref val11)) { val11.anchoredPosition = Vector2.zero; val11.anchorMax = new Vector2(0.5f, 0f); val11.anchorMin = new Vector2(0.5f, 0.5f); val11.pivot = new Vector2(0.5f, 0f); } GameObject val12 = GameObject.Find("PlayerHUDHelmetModel"); Transform val13 = default(Transform); if ((Object)(object)val12 != (Object)null && val12.TryGetComponent<Transform>(ref val13)) { Vector3 localScale = val13.localScale; localScale.x = fDefaultHelmetWidth * Math.Max(newAspect / 2.3f, 1f); val13.localScale = localScale; } } [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyPostfix] private static void HUDManagerStart(HUDManager __instance) { if (!aspectAutoDetect) { ChangeAspectRatio(1.77f); } prevAspect = 0f; prevTime = 0f; } [HarmonyPatch(typeof(HUDManager), "Update")] [HarmonyPostfix] private static void HUDManagerUpdate(HUDManager __instance) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (aspectAutoDetect && Time.time > prevTime + aspectUpdateTime) { Vector2 renderingDisplaySize = ((Graphic)__instance.playerScreenTexture).canvas.renderingDisplaySize; float num = renderingDisplaySize.x / renderingDisplaySize.y; if (!Mathf.Approximately(num, prevAspect)) { ChangeAspectRatio(num); prevAspect = num; Debug.Log((object)("New Aspect Ratio: " + num)); } prevTime = Time.time; } } [HarmonyPatch(typeof(HUDManager), "UpdateScanNodes")] [HarmonyPostfix] private static void HUDManagerUpdateScanNodes(PlayerControllerB playerScript, HUDManager __instance, Dictionary<RectTransform, ScanNodeProperties> ___scanNodes) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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) RectTransform[] scanElements = __instance.scanElements; RectTransform val = default(RectTransform); if (!((Component)__instance.playerScreenTexture).gameObject.TryGetComponent<RectTransform>(ref val)) { return; } Rect rect = val.rect; for (int i = 0; i < scanElements.Length; i++) { if (___scanNodes.TryGetValue(scanElements[i], out var value)) { Vector3 val2 = playerScript.gameplayCamera.WorldToViewportPoint(((Component)value).transform.position); scanElements[i].anchoredPosition = new Vector2(((Rect)(ref rect)).xMin + ((Rect)(ref rect)).width * val2.x, ((Rect)(ref rect)).yMin + ((Rect)(ref rect)).height * val2.y); } } } } public static class PluginInfo { public const string PLUGIN_GUID = "LCUltrawide"; public const string PLUGIN_NAME = "LCUltrawide"; public const string PLUGIN_VERSION = "1.1.1"; } }
plugins/plugins/tinyhoot-ShipLoot/ShipLoot/ShipLoot.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ShipLoot")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("ShipLoot")] [assembly: AssemblyCopyright("Copyright © tinyhoot 2023")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ShipLoot { [BepInPlugin("com.github.tinyhoot.ShipLoot", "ShipLoot", "1.0")] internal class ShipLoot : BaseUnityPlugin { public const string GUID = "com.github.tinyhoot.ShipLoot"; public const string NAME = "ShipLoot"; public const string VERSION = "1.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.github.tinyhoot.ShipLoot").PatchAll(Assembly.GetExecutingAssembly()); } } } namespace ShipLoot.Patches { [HarmonyPatch] internal class HudManagerPatcher { private static GameObject _totalCounter; private static TextMeshProUGUI _textMesh; private static float _displayTimeLeft; private const float DisplayTime = 5f; [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "PingScan_performed")] private static void OnScan(HUDManager __instance, CallbackContext context) { if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && ((CallbackContext)(ref context)).performed && __instance.CanPlayerScan() && !(__instance.playerPingingScan > -0.5f) && (StartOfRound.Instance.inShipPhase || GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom)) { if (!Object.op_Implicit((Object)(object)_totalCounter)) { CopyValueCounter(); } float num = CalculateLootValue(); ((TMP_Text)_textMesh).text = $"SHIP: ${num:F0}"; _displayTimeLeft = 5f; if (!_totalCounter.activeSelf) { ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(ShipLootCoroutine()); } } } private static IEnumerator ShipLootCoroutine() { _totalCounter.SetActive(true); while (_displayTimeLeft > 0f) { float displayTimeLeft = _displayTimeLeft; _displayTimeLeft = 0f; yield return (object)new WaitForSeconds(displayTimeLeft); } _totalCounter.SetActive(false); } private static float CalculateLootValue() { List<GrabbableObject> list = (from obj in GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>() where ((Object)obj).name != "ClipboardManual" && ((Object)obj).name != "StickyNoteItem" select obj).ToList(); ShipLoot.Log.LogDebug((object)"Calculating total ship scrap value."); CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)list, (Action<GrabbableObject>)delegate(GrabbableObject scrap) { ShipLoot.Log.LogDebug((object)$"{((Object)scrap).name} - ${scrap.scrapValue}"); }); return list.Sum((GrabbableObject scrap) => scrap.scrapValue); } private static void CopyValueCounter() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/ValueCounter"); if (!Object.op_Implicit((Object)(object)val)) { ShipLoot.Log.LogError((object)"Failed to find ValueCounter object to copy!"); } _totalCounter = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false); _totalCounter.transform.Translate(0f, 1f, 0f); Vector3 localPosition = _totalCounter.transform.localPosition; _totalCounter.transform.localPosition = new Vector3(localPosition.x + 50f, -50f, localPosition.z); _textMesh = _totalCounter.GetComponentInChildren<TextMeshProUGUI>(); } } }