Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BrutalCompanyMinusCurrentEventsCommand v1.1.0
Bknibb.BrutalCompanyMinusCurrentEventsCommand.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Bknibb.BrutalCompanyMinusCurrentEventsCommand.NetcodePatcher; using BrutalCompanyMinus; using BrutalCompanyMinus.Minus; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; [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("Bknibb.BrutalCompanyMinusCurrentEventsCommand")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BrutalCompanyMinusCurrentEventsCommand")] [assembly: AssemblyTitle("Bknibb.BrutalCompanyMinusCurrentEventsCommand")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } 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; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 BrutalCompanyMinusCurrentEventsCommand { internal class Assets { internal static AssetBundle bundle; internal static void Load() { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BrutalCompanyMinusCurrentEventsCommand.brutalcompanyminuscurrenteventscommand"); bundle = AssetBundle.LoadFromStream(stream); } } [BepInPlugin("Bknibb.BrutalCompanyMinusCurrentEventsCommand", "BrutalCompanyMinusCurrentEventsCommand", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BrutalCompanyMinusCurrentEventsCommand : BaseUnityPlugin { public static BrutalCompanyMinusCurrentEventsCommand Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; EventDescriptions.ValidateEvents(); Patch(); Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } Assets.Load(); Logger.LogInfo((object)"Bknibb.BrutalCompanyMinusCurrentEventsCommand v1.0.0 has loaded!"); } internal static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("Bknibb.BrutalCompanyMinusCurrentEventsCommand"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } internal static object getPrivateField(object o, string name) { return o.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(o); } internal static object getPrivateField(Type t, object o, string name) { return t.GetField(name, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(o); } internal static object getPrivateStaticField(Type t, string name) { return t.GetField(name, BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); } internal static object callPrivateMethod(object o, string name, object[] param) { return o.GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(o, param); } internal static object callStaticPrivateMethod(Type t, string name, object[] param) { return t.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, param); } internal static void setPrivateField(object o, string name, object value) { o.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(o, value); } } internal static class EventDescriptions { public static Dictionary<string, string> descriptions = new Dictionary<string, string> { { "BigBonus", "Large sum of credits" }, { "ScrapGalore", "Increased scrap value and amount" }, { "GoldenBars", "Only golden bars will spawn on the map" }, { "BigDelivery", "Spawns a shipment with a bunch of items" }, { "PlentyOutsideScrap", "Spawns scrap outside" }, { "BlackFriday", "Everything will go on sale" }, { "SafeOutside", "Will prevents enemies from spawning outside and certain events" }, { "Bounty", "Killing enemies will now reward credits" }, { "Bonus", "Sum of credits" }, { "SmallerMap", "Reduces factory size" }, { "MoreScrap", "Increased scrap amount" }, { "HigherScrapValue", "Increased scrap value" }, { "GoldenFacility", "Only spawns Goldencup, Ring, Goldbar, Fancylamp, Perfumebottle, Painting and Cashregister on the map" }, { "Dentures", "Only spawns teeth on the map" }, { "Pickles", "Only spawns pickles on the map" }, { "Honk", "Only spawns horns on the map" }, { "TransmuteScrapSmall", "Takes any one-handed scrap in map scrap pool and only spawns that" }, { "SmallDelivery", "Spawns a shipment with some items" }, { "ScarceOutsideScrap", "Spawns scrap outside" }, { "FragileEnemies", "Decreases enemy hp" }, { "FullAccess", "All Doors are unlocked and open and big doors are all unlocked, prevents facility ghost." }, { "EarlyShip", "Time will start earlier" }, { "MoreExits", "Spawns entrances and exits" }, { "NoBaboons", "Removes Baboon Hawk" }, { "NoBracken", "Removes Bracken" }, { "NoCoilhead", "Removes Coil Head" }, { "NoDogs", "Removes Eyeless Dog" }, { "NoGiants", "Removes Forest Keeper" }, { "NoHoardingBugs", "Removes Hoarding Bug" }, { "NoJester", "Removes Jester" }, { "NoGhosts", "Removes Ghost Girl and Facility Ghost" }, { "NoLizards", "Removes Spore Lizard" }, { "NoNutcracker", "Removes Nutcracker" }, { "NoSpiders", "Removes Bunker Spider" }, { "NoThumpers", "Removes Thumper" }, { "NoSnareFleas", "Removes Snare Flea" }, { "NoWorm", "Removes Earth Leviathan" }, { "NoSlimes", "Removes Hygrodere" }, { "NoMasks", "Removes Masked and removes related scraps" }, { "NoTurrets", "Removes Turret" }, { "NoLandmines", "Removes Landmine" }, { "NoOldBird", "Removes Oldbird" }, { "NoButlers", "Removes butlers" }, { "NoSpikeTraps", "Removes spiketraps" }, { "Nothing", "Nothing" }, { "Locusts", "Spawns Roaming Locusts" }, { "Birds", "Spawns Manticoils" }, { "Trees", "Spawns Trees" }, { "LeaflessBrownTrees", "Spawns trees without leaves" }, { "LeaflessTrees", "Spawns spooky trees" }, { "Gloomy", "Makes the atmosphere foggy" }, { "Raining", "Makes it rain (No mud)" }, { "HeavyRain", "Makes the atmosphere rainy, flooded and stormy. Triple rain." }, { "HoardingBugs", "Spawns Hoarding bugs outside and inside, comes with Scarce Outside Scrap" }, { "Bees", "Spawns Bees outside" }, { "Landmines", "Increased rates of landmines inside" }, { "Lizard", "Spawns Spore Lizard inside" }, { "Slimes", "Spawns Hygrodere outside and inside" }, { "Thumpers", "Spawns Thumpers inside" }, { "Turrets", "Increased rates of turrets inside" }, { "Spiders", "Spawns Bunker Spiders outside and inside, comes with Leafless Brown Trees" }, { "SnareFleas", "Spawns Snare Fleas inside" }, { "FacilityGhost", "The ghost can open/close bigdoors and doors, mess with lights, mess with the breaker and can lock/unlock doors(Rare)" }, { "OutsideTurrets", "Spawns turrets outside, comes with Trees" }, { "OutsideLandmines", "Spawns Landmines outside" }, { "GrabbableTurrets", "Turns some of the turrets on the map into scrap" }, { "GrabbableLandmines", "Turns some of the mines on the map into scrap" }, { "ShipmentFees", "Any shipment's on given moon will deduct credits as a fee" }, { "StrongEnemies", "Increases enemy hp" }, { "RealityShift", "Attempting to grab scrap will make it transform into something else, sometimes a landmine or turret" }, { "KamikazieBugs", "Hoarding bugs will now blow up when angered" }, { "Masked", "Spawned masked enemies" }, { "Butlers", "Will Spawn butlers" }, { "SpikeTraps", "Will spawn spike traps inside" }, { "FlowerSnake", "Will spawn flower snakes inside and outside" }, { "LateShip", "Time will start a little later" }, { "HolidaySeason", "Turns scrap into mystery boxes and eggs and spawns nutcrackers and hoarding bugs inside" }, { "Nutcracker", "Spawns Nutcrackers outside and inside, comes with Turrets" }, { "Arachnophobia", "Spawns alot of Bunker Spiders outside and inside, comes with Leafless Trees" }, { "Bracken", "Spawns Brackens Inside" }, { "Coilhead", "Spawns Coilheads Inside" }, { "BaboonHorde", "Spawns alot of Baboon Hawks outside" }, { "Dogs", "Spawns Eyeless Dogs outside and inside" }, { "Jester", "Spawns Jesters inside" }, { "LittleGirl", "Spawns Ghost Girls inside" }, { "AntiCoilhead", "Changes Coilhead AI and spawns them inside, comes with Leafless Trees and Gloomy" }, { "ChineseProduce", "Decreased Scrap Value but Increased Scrap Amount" }, { "TransmuteScrapBig", "Takes any two-handed scrap in map scrap pool and only spawns that" }, { "Warzone", "Acts as Quad event including Turrets, Landmines, Outside Turrets and Outside Landmines and will also come with artillery fire!!" }, { "BugHorde", "Spawns a load of Hoarding Bugs outside and inside, comes with Scarce Outside Scrap" }, { "ForestGiant", "Spawns a Forest Keeper inside" }, { "InsideBees", "Spawns Bees outside and inside" }, { "NutSlayer", "Spawns the Nutslayer inside the facility, kills everything... comes with gloomy, thumpers, spiders and masked." }, { "Hell", "Great reward, but at what cost..." }, { "AllWeather", "Acts as Eclipsed, Stormy, Flooded and Raining all in one day" }, { "Worms", "Will spawn worms inside and outside and snare fleas inside and outside" }, { "OldBirds", "Will spawn old birds and comes with Landmines and Outside Landmines" } }; public static void ValidateEvents() { List<MEvent> source = (List<MEvent>)BrutalCompanyMinusCurrentEventsCommand.getPrivateStaticField(typeof(EventManager), "vanillaEvents"); List<string> list = source.Select((MEvent e) => e.Name()).ToList(); foreach (string key in descriptions.Keys) { if (!list.Contains(key)) { BrutalCompanyMinusCurrentEventsCommand.Logger.LogWarning((object)("Descriptions Has Non-Existing Event \"" + key + "\"")); } } foreach (string item in list) { if (!descriptions.Keys.Contains(item)) { BrutalCompanyMinusCurrentEventsCommand.Logger.LogWarning((object)("Descriptions Missing Event \"" + item + "\"")); } } } } [HarmonyPatch] public class Net : NetworkBehaviour { public List<string> eventNames = new List<string>(); public static Net Instance { get; private set; } public static GameObject netObject { get; private set; } [HarmonyPrefix] [HarmonyPatch(typeof(Terminal), "Start")] private static void SpawnServerObject() { if (Object.FindObjectOfType<NetworkManager>().IsServer) { Object.Instantiate<GameObject>(netObject).GetComponent<NetworkObject>().Spawn(false); } } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "Start")] private static void InitalizeServerObject() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (!((Object)(object)netObject != (Object)null)) { BrutalCompanyMinusCurrentEventsCommand.Logger.LogInfo((object)"InitalizeServerObject"); netObject = (GameObject)Assets.bundle.LoadAsset("NetworkManagerBrutalCompanyMinusCurrentEventsCommand"); netObject.AddComponent<Net>(); NetworkManager.Singleton.AddNetworkPrefab(netObject); BrutalCompanyMinusCurrentEventsCommand.Logger.LogInfo((object)"InitalizeServerObject Done"); } } public override void OnNetworkSpawn() { Instance = this; ((NetworkBehaviour)this).OnNetworkSpawn(); } [ClientRpc] public void SyncEventsClientRpc(FixedString4096Bytes serializedEventNames) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3778516279u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<FixedString4096Bytes>(ref serializedEventNames, default(ForFixedStrings)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3778516279u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { MemoryStream serializationStream = new MemoryStream(Convert.FromBase64String(FixedStringMethods.ConvertToString<FixedString4096Bytes>(ref serializedEventNames))); BinaryFormatter binaryFormatter = new BinaryFormatter(); eventNames = (List<string>)binaryFormatter.Deserialize(serializationStream); } } } public void SyncEvents(List<MEvent> events) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) MemoryStream memoryStream = new MemoryStream(); BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, events.Select((MEvent e) => e.Name()).ToList()); string text = Convert.ToBase64String(memoryStream.GetBuffer()); SyncEventsClientRpc(FixedString4096Bytes.op_Implicit(text)); } [HarmonyPostfix] [HarmonyPatch(typeof(EventManager), "ChooseEvents")] private static void ChooseEvents(List<MEvent> ___currentEvents) { if (((NetworkBehaviour)Instance).IsServer) { Instance.SyncEvents(___currentEvents); } } [HarmonyPrefix] [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] private static void OnGameEnd() { if (NetworkManager.Singleton.IsServer) { Instance.SyncEvents(new List<MEvent>()); } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_Net() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(3778516279u, new RpcReceiveHandler(__rpc_handler_3778516279)); } private static void __rpc_handler_3778516279(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { FixedString4096Bytes serializedEventNames = default(FixedString4096Bytes); ((FastBufferReader)(ref reader)).ReadValueSafe<FixedString4096Bytes>(ref serializedEventNames, default(ForFixedStrings)); target.__rpc_exec_stage = (__RpcExecStage)2; ((Net)(object)target).SyncEventsClientRpc(serializedEventNames); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "Net"; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Bknibb.BrutalCompanyMinusCurrentEventsCommand"; public const string PLUGIN_NAME = "BrutalCompanyMinusCurrentEventsCommand"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace BrutalCompanyMinusCurrentEventsCommand.Patches { [HarmonyPatch] internal class TerminalCommands { public class MCommand { public string command; public string shortinfo; public string info; public Action<string[]> execute; } private static string response = ""; private static bool _clearPreviousText = true; public static List<MCommand> mCommands = new List<MCommand> { new MCommand { command = "EVENTS", shortinfo = "Displays details about current events.", info = "EVENTS\n This will display details about current events.", execute = delegate { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); List<MEvent> list2 = Net.Instance.eventNames.Select((string name) => MEvent.GetEvent(name)).ToList(); if (list2.Count == 0) { Respond("No Events To Display"); } else { foreach (MEvent item in list2) { string text = "=============== " + item.Name() + " ===============\n\n"; if (EventDescriptions.descriptions.ContainsKey(item.Name())) { text = text + EventDescriptions.descriptions[item.Name()] + "\n\n"; } text += string.Format("[ColorHex] [Weight] [Type]\n", item.ColorHex, item.Weight, item.Type); int num = 11; int length = item.Weight.ToString().Length; num -= (int)Mathf.Ceil((float)length / 2f); string text2 = new string(' ', num); int num2 = 12 - (int)Mathf.Floor((float)length / 2f); int length2 = ((object)(EventType)(ref item.Type)).ToString().Length; num2 -= (int)Mathf.Ceil((float)length2 / 2f); string text3 = new string(' ', num2); text += $" {item.ColorHex}{text2}{item.Weight}{text3}{item.Type}\n"; text = text + "[Descriptions]:\n" + string.Join("\n", item.Descriptions) + "\n"; text = text + "[EventsToSpawnWith]:\n" + string.Join("\n", item.EventsToSpawnWith) + "\n"; list.Add(text); } Respond(string.Join("\n", list)); } } } }; public static void Respond(string text, bool clearPreviousText = true) { BrutalCompanyMinusCurrentEventsCommand.Logger.LogInfo((object)text); response = text; _clearPreviousText = clearPreviousText; } [HarmonyPostfix] [HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")] private static void OnParsePlayerSentence(ref Terminal __instance, ref TerminalNode __result) { string text = __instance.screenText.text; int textAdded = __instance.textAdded; int length = text.Length; int num = length - textAdded; string[] array = text.Substring(num, length - num).Split(" "); if (array.Length == 0) { return; } string text2 = array[0]; string[] subArray = array[1..]; foreach (MCommand mCommand in mCommands) { if (!(mCommand.command.ToLower() != text2)) { mCommand.execute(subArray); } } if (!string.IsNullOrWhiteSpace(response)) { __result = ScriptableObject.CreateInstance<TerminalNode>(); __result.displayText = response + "\n\n"; __result.clearPreviousText = _clearPreviousText; response = ""; } } internal static string StringsToList(List<string> strings, string seperator) { return (string)BrutalCompanyMinusCurrentEventsCommand.callStaticPrivateMethod(typeof(Helper), "StringsToList", new object[2] { strings, seperator }); } internal static string GetStringFromScale(Scale from) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) return (string)BrutalCompanyMinusCurrentEventsCommand.callStaticPrivateMethod(typeof(Helper), "GetStringFromScale", new object[1] { from }); } public static string ScaleTypePadded(ScaleType type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return $"[{type}]:".PadRight(23); } } } namespace Bknibb.BrutalCompanyMinusCurrentEventsCommand.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }