using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using PluginConfig.API.Functionals;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("bitmotte.MauriceBridge")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0")]
[assembly: AssemblyProduct("Maurice Bridge")]
[assembly: AssemblyTitle("bitmotte.MauriceBridge")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 MauriceBridge
{
public static class BridgeConfigurator
{
[CompilerGenerated]
private static class <>O
{
public static OnClick <0>__OpenDiscord;
public static PostConfigChangeEvent <1>__UpdateGlobalConfig;
}
public static BoolField welcomeMessageShown;
public static ButtonField joinDC;
public static PluginConfigurator CreateConfigurator()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Expected O, but got Unknown
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
PluginConfigurator val = PluginConfigurator.Create("Maurice Bridge", "bitmotte.MauriceBridge");
ConfigSpace val2 = new ConfigSpace(val.rootPanel, 15f);
welcomeMessageShown = new BoolField(val.rootPanel, "Welcome Message Already Shown", "welcome_shown", false);
ConfigSpace val3 = new ConfigSpace(val.rootPanel, 15f);
ConfigHeader val4 = new ConfigHeader(val.rootPanel, "Join my discord for sneak peeks,devlogs,and the possibility to test my mods early ! !", 20, (TextAlignmentOptions)513);
joinDC = new ButtonField(val.rootPanel, "Join my Discord", "joinDC");
ConfigSpace val5 = new ConfigSpace(val.rootPanel, 15f);
ButtonField obj = joinDC;
object obj2 = <>O.<0>__OpenDiscord;
if (obj2 == null)
{
OnClick val6 = OpenDiscord;
<>O.<0>__OpenDiscord = val6;
obj2 = (object)val6;
}
obj.onClick += (OnClick)obj2;
object obj3 = <>O.<1>__UpdateGlobalConfig;
if (obj3 == null)
{
PostConfigChangeEvent val7 = UpdateGlobalConfig;
<>O.<1>__UpdateGlobalConfig = val7;
obj3 = (object)val7;
}
val.postConfigChange += (PostConfigChangeEvent)obj3;
UpdateGlobalConfig();
AssetBundle val8 = BundleTool.Load("bridge.bundle");
Texture2D val9 = (Texture2D)val8.LoadAsset("Assets/bridge.png");
val.icon = Sprite.Create(val9, new Rect(0f, 0f, (float)((Texture)val9).width, (float)((Texture)val9).height), new Vector2(0.5f, 0.5f), 100f);
val8.Unload(false);
return val;
}
private static void UpdateGlobalConfig()
{
}
private static void OpenDiscord()
{
Process.Start("http://discord.gg/pVdr9e6hZ8");
}
}
public static class GlobalConfig
{
public static bool bestiaryAlreadyAdded;
public static bool sandboxItemAlreadyAdded;
}
[HarmonyPatch(typeof(MaliciousFace), "Start")]
public class KillMeKillMeComeOnPatch : MonoBehaviour
{
private static void Postfix(MaliciousFace __instance)
{
KillMeKillMeComeOn[] componentsInChildren = ((Component)((Component)__instance).transform.parent).GetComponentsInChildren<KillMeKillMeComeOn>();
foreach (KillMeKillMeComeOn killMeKillMeComeOn in componentsInChildren)
{
Object.Destroy((Object)(object)((Component)killMeKillMeComeOn).gameObject);
}
}
}
[HarmonyPatch(typeof(MaliciousFace), "HandleCollision")]
[HarmonyPriority(1000)]
public class PhysicalPatch : MonoBehaviour
{
private static void Postfix(MaliciousFace __instance)
{
if (!Store.baller)
{
Store.corpse = ((Component)__instance).gameObject;
}
}
}
[HarmonyPatch(typeof(EnemyInfoPage), "Start")]
public class BestiaryIcon : MonoBehaviour
{
private static bool Prefix(EnemyInfoPage __instance)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
AssetBundle val = BundleTool.Load("bridge.bundle");
SpawnableObject[] array = Array.Empty<SpawnableObject>();
SpawnableObject[] enemies = __instance.objects.enemies;
foreach (SpawnableObject val2 in enemies)
{
if (val2.objectName == "Malicious Face")
{
SpawnableObject val3 = (SpawnableObject)ScriptableObject.CreateInstance("SpawnableObject");
if (Store.legger)
{
val3 = (SpawnableObject)val.LoadAsset("Assets/Bridge/Bestiary/ObjLegger.asset");
}
if (Store.armer)
{
val3 = (SpawnableObject)val.LoadAsset("Assets/Bridge/Bestiary/ObjArmer.asset");
}
if (Store.legger && Store.armer)
{
val3 = (SpawnableObject)val.LoadAsset("Assets/Bridge/Bestiary/ObjLegArm.asset");
}
if (!Store.legger && !Store.armer)
{
val.Unload(false);
return true;
}
SetupResource.FixShader(val3.preview);
val2.gridIcon = val3.gridIcon;
val2.preview = val3.preview;
val3.gameObject.AddComponent<KillMeKillMeComeOn>();
val3.gameObject.transform.parent = val2.gameObject.transform;
val2.description = val3.description;
}
SpawnableObject[] array2 = array;
int num = 0;
SpawnableObject[] array3 = (SpawnableObject[])(object)new SpawnableObject[1 + array2.Length];
ReadOnlySpan<SpawnableObject> readOnlySpan = new ReadOnlySpan<SpawnableObject>(array2);
readOnlySpan.CopyTo(new Span<SpawnableObject>(array3).Slice(num, readOnlySpan.Length));
num += readOnlySpan.Length;
array3[num] = val2;
array = array3;
}
__instance.objects.enemies = array;
val.Unload(false);
return true;
}
}
[HarmonyPatch(typeof(SpawnMenu), "Awake")]
public class SandboxIcon : MonoBehaviour
{
private static bool Prefix(SpawnMenu __instance)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
AssetBundle val = BundleTool.Load("bridge.bundle");
SpawnableObject[] array = Array.Empty<SpawnableObject>();
SpawnableObject[] enemies = __instance.objects.enemies;
foreach (SpawnableObject val2 in enemies)
{
if (val2.objectName == "Malicious Face")
{
SpawnableObject val3 = (SpawnableObject)ScriptableObject.CreateInstance("SpawnableObject");
if (Store.legger)
{
val3 = (SpawnableObject)val.LoadAsset("Assets/Bridge/Bestiary/ObjLegger.asset");
}
if (Store.armer)
{
val3 = (SpawnableObject)val.LoadAsset("Assets/Bridge/Bestiary/ObjArmer.asset");
}
if (Store.legger && Store.armer)
{
val3 = (SpawnableObject)val.LoadAsset("Assets/Bridge/Bestiary/ObjLegArm.asset");
}
if (!Store.legger && !Store.armer)
{
val.Unload(false);
return true;
}
SetupResource.FixShader(val3.preview);
val2.gridIcon = val3.gridIcon;
val2.preview = val3.preview;
val3.gameObject.AddComponent<KillMeKillMeComeOn>();
val3.gameObject.transform.parent = val2.gameObject.transform;
val2.description = val3.description;
}
SpawnableObject[] array2 = array;
int num = 0;
SpawnableObject[] array3 = (SpawnableObject[])(object)new SpawnableObject[1 + array2.Length];
ReadOnlySpan<SpawnableObject> readOnlySpan = new ReadOnlySpan<SpawnableObject>(array2);
readOnlySpan.CopyTo(new Span<SpawnableObject>(array3).Slice(num, readOnlySpan.Length));
num += readOnlySpan.Length;
array3[num] = val2;
array = array3;
}
__instance.objects.enemies = array;
val.Unload(false);
return true;
}
}
public class KillMeKillMeComeOn : MonoBehaviour
{
}
public static class Store
{
public static bool baller;
public static bool legger;
public static bool armer;
public static bool leggerSpiderLegsAreDisabled;
public static GameObject corpse;
public static GameObject storedPhysicalLeg;
public static GameObject storedPhysicalArm;
}
[BepInPlugin("bitmotte.MauriceBridge", "Maurice Bridge", "2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static PluginConfigurator config;
private void Awake()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin bitmotte.MauriceBridge is loaded!");
Harmony val = new Harmony("bitmotte.MauriceBridge");
val.PatchAll();
config = BridgeConfigurator.CreateConfigurator();
SceneManager.sceneLoaded += SceneUtility.OnSceneLoad;
}
}
public static class BundleTool
{
public static AssetBundle Load(string fileName)
{
return AssetBundle.LoadFromMemory(EmbeddedAccess.AccessFile(fileName));
}
}
public static class EmbeddedAccess
{
public static byte[] AccessFile(string fileName)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
byte[] array;
using (Stream stream = executingAssembly.GetManifestResourceStream("MauriceBridge.resources." + fileName))
{
if (stream == null)
{
return null;
}
array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
}
return array;
}
}
public static class SceneUtility
{
public static string sceneName;
public static void OnSceneLoad(Scene scene, LoadSceneMode mode)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
sceneName = ((Scene)(ref scene)).name;
if (!(sceneName == "") && !(sceneName == "Bootstrap") && !(sceneName == "241a6a8caec7a13438a5ee786040de32") && !(sceneName == "b3e7f2f8052488a45b35549efb98d902") && !(sceneName == "af7c99b8734890e4b95c7e11dc5d9e3d") && !BridgeConfigurator.welcomeMessageShown.value)
{
BridgeConfigurator.welcomeMessageShown.value = true;
GameObject val = new GameObject("closer");
woah woah2 = val.AddComponent<woah>();
((MonoBehaviour)woah2).Invoke("clearhud", 15f);
MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("Hello ! Thank you for installing one of my Maurice mods .\nRemember to check the configs for extras !\n. . . Also the bestiary ! ! ! Thank You ! ! !", "", "", 3, false, false, false);
}
}
}
public static class SetupResource
{
public static GameObject FixShader(GameObject gameObject)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//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_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
Shader shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Environment/Metal/Pattern 1/Metal Pattern 1 8.mat").WaitForCompletion().shader;
SkinnedMeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
foreach (SkinnedMeshRenderer val in componentsInChildren)
{
Material[] materials = ((Renderer)val).materials;
foreach (Material val2 in materials)
{
if (((Object)val2.shader).name == "Hidden/InternalErrorShader")
{
val2.shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Dev/FadeToWhite.mat").WaitForCompletion().shader;
}
else
{
val2.shader = shader;
}
}
}
MeshRenderer[] componentsInChildren2 = gameObject.GetComponentsInChildren<MeshRenderer>();
foreach (MeshRenderer val3 in componentsInChildren2)
{
Material[] materials2 = ((Renderer)val3).materials;
foreach (Material val4 in materials2)
{
if (((Object)val4.shader).name == "Hidden/InternalErrorShader")
{
val4.shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Dev/FadeToWhite.mat").WaitForCompletion().shader;
}
else
{
val4.shader = shader;
}
}
}
ParticleSystem[] componentsInChildren3 = gameObject.GetComponentsInChildren<ParticleSystem>();
foreach (ParticleSystem val5 in componentsInChildren3)
{
Renderer[] componentsInChildren4 = ((Component)val5).gameObject.GetComponentsInChildren<Renderer>();
foreach (Renderer val6 in componentsInChildren4)
{
Material[] materials3 = val6.materials;
foreach (Material val7 in materials3)
{
if (((Object)val7.shader).name == "Hidden/InternalErrorShader")
{
val7.shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Dev/FadeToWhite.mat").WaitForCompletion().shader;
}
else
{
val7.shader = shader;
}
}
}
}
return gameObject;
}
}
public class woah : MonoBehaviour
{
private void clearhud()
{
MonoSingleton<HudMessageReceiver>.Instance.ClearMessage();
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "bitmotte.MauriceBridge";
public const string PLUGIN_NAME = "Maurice Bridge";
public const string PLUGIN_VERSION = "2.0.0";
}
}