using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Brave.BulletScript;
using Gunfiguration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using OopsAllJammed;
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("Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mod")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6d7a494-722e-4763-959b-c2d6b6a42b01")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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 Gunfiguration
{
public static class JammedConfig
{
internal static Gunfig _Gunfig;
internal const string AllJammed = "Make All Enemies In The Game Jammed";
internal const string PreventUnJam = "Prevent Enemies From Being Un-Jammed";
internal const string JamMinecartTurrets = "Make Minecart Turrets Jammed";
internal const string JamProjectileTraps = "Make Projectile Traps Jammed";
internal const string JamGunjurers = "Make Gunjurers Jammed";
internal const string JamHammers = "Make Hammers Jammed";
internal const string JamStatuses = "Make Fire, Poision And Electricity Jammed";
internal const string JamFlamePipes = "Make Flame Pipes Jammed";
internal const string JamCrushDoors = "Make Crush Doors Jammed";
internal const string JamBasicTraps = "Make Basic Traps (Flames, Spikes) Jammed";
internal const string JamPathingTraps = "Make Pathing Traps (Saws, Rolling Spikes) Jammed";
internal const string JamPits = "Make Pits Jammed";
internal const string JamExplosions = "Make Explosions Jammed";
internal const string JamLordOfTheJammed = "Make Lord Of The Jammed Jammed";
internal static void Init(Plugin parent)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
_Gunfig = Gunfig.Get(GunfigHelpers.WithColor("All Jammed", Color.white));
parent.SetAllJammed(_Gunfig.Enabled("Make All Enemies In The Game Jammed"));
parent.SetPreventUnJam(_Gunfig.Enabled("Prevent Enemies From Being Un-Jammed"));
parent.SetJamMinecarts(_Gunfig.Enabled("Make Minecart Turrets Jammed"));
parent.SetJamProjectileTraps(_Gunfig.Enabled("Make Projectile Traps Jammed"));
parent.SetJamWizard(_Gunfig.Enabled("Make Gunjurers Jammed"));
parent.SetJamHammers(_Gunfig.Enabled("Make Hammers Jammed"));
parent.SetJamStatuses(_Gunfig.Enabled("Make Fire, Poision And Electricity Jammed"));
parent.SetJamFlamePipes(_Gunfig.Enabled("Make Flame Pipes Jammed"));
parent.SetJamCrushDoors(_Gunfig.Enabled("Make Crush Doors Jammed"));
parent.SetJamBasicTraps(_Gunfig.Enabled("Make Basic Traps (Flames, Spikes) Jammed"));
parent.SetJamPathingTraps(_Gunfig.Enabled("Make Pathing Traps (Saws, Rolling Spikes) Jammed"));
parent.SetJamPits(_Gunfig.Enabled("Make Pits Jammed"));
parent.SetJamExplosions(_Gunfig.Enabled("Make Explosions Jammed"));
parent.SetJamLOTJ(_Gunfig.Enabled("Make Lord Of The Jammed Jammed"));
_Gunfig.AddToggle("Make All Enemies In The Game Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetAllJammed((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Prevent Enemies From Being Un-Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetPreventUnJam((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Minecart Turrets Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamMinecarts((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Projectile Traps Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamProjectileTraps((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Gunjurers Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamWizard((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Hammers Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamHammers((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Fire, Poision And Electricity Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamStatuses((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Flame Pipes Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamFlamePipes((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Crush Doors Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamCrushDoors((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Basic Traps (Flames, Spikes) Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamBasicTraps((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Pathing Traps (Saws, Rolling Spikes) Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamPathingTraps((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Pits Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamPits((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Explosions Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamExplosions((optionValue == "1") ? true : false);
}, (Update)1);
_Gunfig.AddToggle("Make Lord Of The Jammed Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
{
parent.SetJamLOTJ((optionValue == "1") ? true : false);
}, (Update)1);
}
}
}
namespace OopsAllJammed
{
internal static class HarmonyPatches
{
[HarmonyPatch(typeof(CartTurretController), "FireBullet")]
private static class JamCartTurretPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
MethodReference val2 = default(MethodReference);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt(instr, ref val2) && ((MemberReference)val2).Name == "GetComponent"
}))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(JamCartTurretPatch).GetMethod("JamProjectile", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static Projectile JamProjectile(Projectile p)
{
if (Plugin.JamMinecarts)
{
p.BecomeBlackBullet();
}
return p;
}
}
[HarmonyPatch(typeof(ProjectileTrapController), "ShootProjectileInDirection")]
private static class JamProjectileTrapPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
MethodReference val2 = default(MethodReference);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt(instr, ref val2) && ((MemberReference)val2).Name == "GetComponent"
}))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(JamProjectileTrapPatch).GetMethod("JamProjectile", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static Projectile JamProjectile(Projectile p)
{
if (Plugin.JamProjectileTraps)
{
p.BecomeBlackBullet();
}
return p;
}
}
[HarmonyPatch(typeof(WizardSpinShootBehavior), "OnTriggerCollision")]
private static class WizardCollisionPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
MethodReference val2 = default(MethodReference);
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt(instr, ref val2) && ((MemberReference)val2).Name == "RemovePlayerOnlyModifiers"
}))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(WizardCollisionPatch).GetMethod("JamProjectile", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static Projectile JamProjectile(Projectile p)
{
if (Plugin.JamWizard)
{
((BraveBehaviour)p).sprite.usesOverrideMaterial = true;
((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material = Plugin.bulletMaterial;
ETGModConsole.Log((object)"First Pass", false);
((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material.SetFloat("_EmissivePower", -40f);
ETGModConsole.Log((object)((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material.GetFloat("_EmissivePower"), false);
((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material.SetFloat("_EmissiveColorPower", 35.36f);
ETGModConsole.Log((object)((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material.GetFloat("_EmissiveColorPower"), false);
((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material.SetFloat("_BlackBullet", 1f);
ETGModConsole.Log((object)((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material.GetFloat("_BlackBullet"), false);
p.BecomeBlackBullet();
ETGModConsole.Log((object)"Second Pass", false);
ETGModConsole.Log((object)((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material.GetFloat("_EmissivePower"), false);
ETGModConsole.Log((object)((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material.GetFloat("_EmissiveColorPower"), false);
ETGModConsole.Log((object)((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material.GetFloat("_BlackBullet"), false);
}
return p;
}
}
[HarmonyPatch(typeof(WizardSpinShootBehavior), "ContinuousUpdate")]
private static class WizardSpawningPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
MethodReference val2 = default(MethodReference);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt(instr, ref val2) && ((MemberReference)val2).Name == "GetComponent"
}))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(WizardSpawningPatch).GetMethod("JamProjectile", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static Projectile JamProjectile(Projectile p)
{
if (Plugin.JamWizard)
{
p.BecomeBlackBullet();
}
if ((Object)(object)Plugin.bulletShader == (Object)null)
{
Plugin.bulletShader = ((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material.shader;
}
if ((Object)(object)Plugin.bulletMaterial == (Object)null)
{
Plugin.bulletMaterial = ((BraveBehaviour)((BraveBehaviour)p).sprite).renderer.material;
}
return p;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static class PitPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.JumpToNext((Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 3), 2))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(PitPatch).GetMethod("JamPit", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static DamageCategory JamPit(DamageCategory p)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_0012: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.JamPits)
{
return (DamageCategory)4;
}
return p;
}
}
[HarmonyPatch(typeof(Exploder), "DoRadialDamage")]
private static class ExplosionPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.JumpToNext((Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 0), 8))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(ExplosionPatch).GetMethod("JamExplosion", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static DamageCategory JamExplosion(DamageCategory p)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_0012: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.JamExplosions)
{
return (DamageCategory)4;
}
return p;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static class ExplosionPatch2
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.JumpToNext((Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 0), 13))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(ExplosionPatch2).GetMethod("JamExplosion", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static DamageCategory JamExplosion(DamageCategory p)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_0012: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.JamPits)
{
return (DamageCategory)4;
}
return p;
}
}
[HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "DoTimelessGoopEffect")]
private static class ElectricityPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 3)
}))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(ElectricityPatch).GetMethod("JamGoop", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static DamageCategory JamGoop(DamageCategory p)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_0012: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.JamStatuses)
{
return (DamageCategory)4;
}
return p;
}
}
[HarmonyPatch(typeof(HealthHaver), "ApplyDamageDirectional")]
private static class DamageImmunityPatch
{
[HarmonyILManipulator]
private static void Patch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchLdcR4(instr, 1f)
}))
{
val.Emit(OpCodes.Ldarg_1);
val.Emit(OpCodes.Call, (MethodBase)typeof(DamageImmunityPatch).GetMethod("DamageCheck", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static float DamageCheck(float blackBullet, float damage)
{
if (damage == 0f)
{
return 0f;
}
return blackBullet;
}
}
[HarmonyPatch(typeof(DeadlyDeadlyGoopManager), "DoGoopEffect")]
private static class PoisonPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 3)
}))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(PoisonPatch).GetMethod("JamGoop", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static DamageCategory JamGoop(DamageCategory p)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_0012: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.JamStatuses)
{
return (DamageCategory)4;
}
return p;
}
}
[HarmonyPatch(typeof(PlayerController), "LateUpdate")]
private static class FirePatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.JumpToNext((Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 3), 2))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(FirePatch).GetMethod("JamGoop", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static DamageCategory JamGoop(DamageCategory p)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
ETGModConsole.Log((object)Plugin.JamStatuses, false);
if (Plugin.JamStatuses)
{
return (DamageCategory)4;
}
return p;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static class ForgeHammerPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
VariableDefinition val2 = val.DeclareLocal<DefaultBullet>();
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchNewobj<DefaultBullet>(instr)
}))
{
val.Emit(OpCodes.Ldloca_S, val2);
val.Emit(OpCodes.Call, (MethodBase)typeof(ForgeHammerPatch).GetMethod("SaveBullet", BindingFlags.Static | BindingFlags.NonPublic));
MethodReference val3 = default(MethodReference);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt(instr, ref val3) && ((MemberReference)val3).Name == "Fire"
}))
{
val.Emit(OpCodes.Ldloc_S, val2);
val.Emit(OpCodes.Call, (MethodBase)typeof(ForgeHammerPatch).GetMethod("JamProjectile", BindingFlags.Static | BindingFlags.NonPublic));
}
}
}
private static void JamProjectile(DefaultBullet p)
{
if (Plugin.JamHammer)
{
((Bullet)p).Projectile.BecomeBlackBullet();
}
}
private static DefaultBullet SaveBullet(DefaultBullet p, out DefaultBullet b)
{
b = p;
return p;
}
}
[HarmonyPatch(typeof(CircleBurst12), "Top")]
private static class LOTJPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_004b: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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)
ILCursor val = new ILCursor(il);
VariableDefinition val2 = val.DeclareLocal<DefaultBullet>();
MethodReference val4 = default(MethodReference);
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt(instr, ref val4) && ((MemberReference)val4).Name == "Fire"
}))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(LOTJPatch).GetMethod("CreateBullet", BindingFlags.Static | BindingFlags.NonPublic));
val.Emit(OpCodes.Ldloca_S, val2);
val.Emit(OpCodes.Call, (MethodBase)typeof(LOTJPatch).GetMethod("SaveBullet", BindingFlags.Static | BindingFlags.NonPublic));
MethodReference val3 = default(MethodReference);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt(instr, ref val3) && ((MemberReference)val3).Name == "Fire"
}))
{
val.Emit(OpCodes.Ldloc_S, val2);
val.Emit(OpCodes.Call, (MethodBase)typeof(ForgeHammerPatch).GetMethod("JamProjectile", BindingFlags.Static | BindingFlags.NonPublic));
}
}
}
private static Bullet CreateBullet(object p)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
return new Bullet((string)null, false, false, false);
}
private static void JamProjectile(DefaultBullet p)
{
if (Plugin.JamLordOfTheJammed)
{
((Bullet)p).Projectile.BecomeBlackBullet();
}
}
private static DefaultBullet SaveBullet(DefaultBullet p, out DefaultBullet b)
{
b = p;
return p;
}
}
[HarmonyPatch(typeof(PathingTrapController), "Damage")]
private static class PathingTrapPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.JumpToNext((Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 0), 3))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(PathingTrapPatch).GetMethod("JamPathing", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static DamageCategory JamPathing(DamageCategory p)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_0012: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.JamPathingTraps)
{
return (DamageCategory)4;
}
return p;
}
}
[HarmonyPatch(typeof(BasicTrapController), "Damage")]
private static class BasicTrapPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.JumpToNext((Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 0), 2))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(BasicTrapPatch).GetMethod("JamBasic", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static DamageCategory JamBasic(DamageCategory p)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_0012: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.JamBasicTraps)
{
return (DamageCategory)4;
}
return p;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static class ForgeFlamePipePatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.JumpToNext((Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 3), 2))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(ForgeFlamePipePatch).GetMethod("JamFlame", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static DamageCategory JamFlame(DamageCategory p)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_0012: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.JamFlamePipe)
{
return (DamageCategory)4;
}
return p;
}
}
[HarmonyPatch(typeof(ForgeCrushDoorController), "HandleAnimationEvent")]
private static class ForgeDoorsPatch
{
[HarmonyILManipulator]
private static void JamPatch(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.JumpToNext((Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 0), 5))
{
val.Emit(OpCodes.Call, (MethodBase)typeof(ForgeDoorsPatch).GetMethod("JamDoor", BindingFlags.Static | BindingFlags.NonPublic));
}
}
private static DamageCategory JamDoor(DamageCategory p)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_0012: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.JamCrushDoors)
{
return (DamageCategory)4;
}
return p;
}
}
public static void Patch(Harmony harmony)
{
harmony.PatchAll();
}
public static bool JumpToNext(this ILCursor crs, Func<Instruction, bool> match, int times = 1)
{
for (int i = 0; i < times; i++)
{
if (!crs.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { match }))
{
return false;
}
}
return true;
}
public static bool JumpBeforeNext(this ILCursor crs, Func<Instruction, bool> match, int times = 1)
{
for (int i = 0; i < times; i++)
{
if (!crs.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { match }))
{
return false;
}
}
return true;
}
public static VariableDefinition DeclareLocal<T>(this ILContext ctx)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
VariableDefinition val = new VariableDefinition(ctx.Import(typeof(T)));
ctx.Body.Variables.Add(val);
return val;
}
public static VariableDefinition DeclareLocal<T>(this ILCursor curs)
{
return curs.Context.DeclareLocal<T>();
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("SimplyFenton.etg.oopsalljammed", "Oops All Jammed", "1.0.9")]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "SimplyFenton.etg.oopsalljammed";
public const string NAME = "Oops All Jammed";
public const string VERSION = "1.0.9";
public const string TEXT_COLOR = "#00FFFF";
public static bool AllJammed = true;
public static bool PreventUnJam = true;
public static bool JamMinecarts = true;
public static bool JamProjectileTraps = true;
public static bool JamWizard = true;
public static bool JamHammer = true;
public static bool JamStatuses = true;
public static bool JamFlamePipe = true;
public static bool JamBasicTraps = true;
public static bool JamPathingTraps = true;
public static bool JamPits = true;
public static bool JamExplosions = true;
public static bool JamLordOfTheJammed = true;
public static bool JamRatTraps = true;
public static Shader bulletShader;
public static Material bulletMaterial;
public static bool JamCrushDoors { get; set; }
public void Start()
{
ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
Init();
}
private void makeJammed(AIActor enemy)
{
if (AllJammed && enemy.IsNormalEnemy)
{
enemy.ForceBlackPhantom = true;
}
}
public static void reJamHook(Action<AIActor> orig, AIActor self)
{
orig(self);
if (AllJammed)
{
self.ForceBlackPhantom = true;
self.BecomeBlackPhantom();
}
}
public static void forceJam(AIActor actor)
{
if (AllJammed && actor.IsNormalEnemy && PreventUnJam)
{
actor.ForceBlackPhantom = true;
actor.BecomeBlackPhantom();
}
}
public void SetAllJammed(bool jammed)
{
AllJammed = jammed;
}
public void SetPreventUnJam(bool prevent)
{
PreventUnJam = prevent;
}
public void SetJamMinecarts(bool jammed)
{
JamMinecarts = jammed;
}
public void SetJamProjectileTraps(bool jammed)
{
JamProjectileTraps = jammed;
}
public void SetJamWizard(bool jammed)
{
JamWizard = jammed;
}
public void SetJamHammers(bool jammed)
{
JamHammer = jammed;
}
public void SetJamStatuses(bool jammed)
{
JamStatuses = jammed;
}
public void SetJamFlamePipes(bool jammed)
{
JamFlamePipe = jammed;
}
public void SetJamCrushDoors(bool jammed)
{
JamCrushDoors = jammed;
}
public void SetJamBasicTraps(bool jammed)
{
JamBasicTraps = jammed;
}
public void SetJamPathingTraps(bool jammed)
{
JamPathingTraps = jammed;
}
public void SetJamPits(bool jammed)
{
JamPits = jammed;
}
public void SetJamExplosions(bool jammed)
{
JamExplosions = jammed;
}
public void SetJamLOTJ(bool jammed)
{
JamLordOfTheJammed = jammed;
}
public void Exit()
{
AllJammed = false;
}
public void Init()
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
AIActor.OnBlackPhantomnessCheck = (Action<AIActor>)Delegate.Combine(AIActor.OnBlackPhantomnessCheck, new Action<AIActor>(makeJammed));
AIActor.OnPreStart = (Action<AIActor>)Delegate.Combine(AIActor.OnPreStart, new Action<AIActor>(forceJam));
new Hook((MethodBase)typeof(AIActor).GetMethod("UnbecomeBlackPhantom", BindingFlags.Instance | BindingFlags.Public), typeof(Plugin).GetMethod("reJamHook"));
}
public void GMStart(GameManager g)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony harmony = new Harmony("SimplyFenton.etg.oopsalljammed");
HarmonyPatches.Patch(harmony);
Log("Oops All Jammed v1.0.9 started successfully.", "#00FFFF");
JammedConfig.Init(this);
}
public static void Log(string text, string color = "#FFFFFF")
{
ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
}
}
}