using 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 BrutalCompanyMinus;
using BrutalCompanyMinus.Minus;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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)]
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
{
[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();
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 + "\""));
}
}
}
}
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_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
List<string> list = new List<string>();
List<MEvent> list2 = (List<MEvent>)BrutalCompanyMinusCurrentEventsCommand.getPrivateStaticField(typeof(EventManager), "currentEvents");
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);
}
}
}