using System;
using System.Collections;
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 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: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("SteelShellPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SteelShellPlugin")]
[assembly: AssemblyTitle("SteelShellPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SteelShellPlugin;
[BepInPlugin("ACTPlugins.Automagic.SteelShell", "Steel Shell Challenges", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Player), "ResetHealth")]
private class ResetHealthPatch
{
[HarmonyPrefix]
public static bool Prefix(Player __instance)
{
if (isHitless)
{
__instance.baseHealth = 1f;
__instance.extraHealth = 0f;
((Entity)__instance).startingHealth = __instance.baseHealth + ((Entity)__instance).startingHealth;
((Entity)__instance).health = ((Entity)__instance).startingHealth;
GUIManager.instance.HUD.healthBar.Initialize(Mathf.CeilToInt(((Entity)__instance).health));
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Player), "EditMaxHealth")]
private class EditMaxHealthPatch
{
[HarmonyPrefix]
public static bool Prefix(Player __instance)
{
if (isHitless)
{
__instance.baseHealth = 1f;
__instance.extraHealth = 0f;
((Entity)__instance).startingHealth = __instance.baseHealth + ((Entity)__instance).startingHealth;
GUIManager.instance.HUD.healthBar.Initialize((int)((Entity)__instance).startingHealth, (int)((Entity)__instance).health);
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Player), "TakeDamagePlayer")]
private class TakeDamagePatch
{
[HarmonyPrefix]
private static bool Prefix(Player __instance, HitEvent e, bool playSFX)
{
float num = 1f - Player.singlePlayer.stats.noneSomeLots[CrabFile.current.GetAssistInt("assist_damageTaken", false)];
e.damageMultiplier *= num;
GameManager.events.TriggerEntityDamaged(e);
FileAnalytics analytics = CrabFile.current.locationData.analytics;
analytics.totalDamageTaken += e.damage;
if (!DebugSettings.GetGodModeBool((GodModeBool)10))
{
((Entity)__instance).health = Mathf.Max(0f, ((Entity)__instance).health - e.damage);
}
if (((Entity)__instance).health > 0f && !isHitless)
{
return false;
}
if (((Entity)__instance).statusEffects.anotherChance && !isIgnoreDeathDefiance)
{
__instance.DeathDefiance(false);
((Entity)__instance).statusEffects.anotherChance = false;
return false;
}
int indexOfEquippedStowaway = PassengerManager.GetIndexOfEquippedStowaway((StowawayModType)4);
if (indexOfEquippedStowaway > -1 && !isIgnoreAnotherCrab)
{
PassengerManager.instance.LosePassengerAtIndex(indexOfEquippedStowaway);
__instance.DeathDefiance(true);
return false;
}
__instance.Die(e, playSFX);
GameManager.events.TriggerEntityKilled(e);
return true;
}
}
[HarmonyPatch(typeof(Player), "Update")]
private class PlayerUpdatePatch
{
[HarmonyPrefix]
public static bool Prefix(Player __instance)
{
if (__instance.HasEquippedShell && isShellBool)
{
__instance.RemoveAndDestroyShell();
}
return true;
}
}
[HarmonyPatch(typeof(Player), "TakeShellDamage")]
private class TakeShellDamagePatch
{
[HarmonyPrefix]
public static bool Prefix(ref float damage, bool crushing, bool trueDamage = false)
{
damage *= shellDamageMod;
return true;
}
}
[HarmonyPatch(typeof(Player), "TryShellAbility")]
private class TryShellAbilityPatch
{
[HarmonyPrefix]
public static bool Prefix()
{
if (isShellSpellDisabled)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Wallet), "AddCurrency")]
private class InventoryDataPrefix
{
[HarmonyPrefix]
public static bool Prefix(CURRENCY c, ref int amt, bool updateCurrencyText = true)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
Debug.Log((object)"AddCurr");
if ((int)c == 1 && amt > 0)
{
amt = (int)Math.Round(microplasticsMod * (float)amt);
}
return true;
}
}
[HarmonyPatch(typeof(Item), "Interact")]
private class PickupLocations
{
[HarmonyPrefix]
private static bool PickupItemPatch(Item __instance)
{
Debug.Log((object)((Object)__instance).name);
if (((Object)__instance).name == "ForkUnlock (1)" && isForkless)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(MoonSnailShell), "EnterShellRoutine")]
private class ForkFailsafePatch
{
[HarmonyPrefix]
public static bool Prefix(MoonSnailShell __instance)
{
if (!isForklessMSS)
{
return true;
}
((MonoBehaviour)__instance).StartCoroutine(ShellRoutinePatch(__instance));
return false;
}
public static IEnumerator ShellRoutinePatch(MoonSnailShell inst)
{
((MenuWindow)GUIManager.instance.MSSMenuManager).Open();
yield return null;
inst.OnShellEnterEnd();
}
}
private Rect windowRect = new Rect(0f, 0f, 200f, 150f);
private Color backgroundColor = Color.grey;
private static bool showMenu = true;
private float alphaAmount = 0f;
private bool showFadingLabel = false;
private Color originalColor;
private string fadingLabelContent = "";
private ConfigEntry<bool> configHitlessBool;
private ConfigEntry<bool> configIgnoreAnotherCrabBool;
private ConfigEntry<bool> configIgnoreDeathDefianceBool;
private ConfigEntry<bool> configShellessBool;
private ConfigEntry<bool> disableShellSpellBool;
private ConfigEntry<float> configShellDamageMod;
private ConfigEntry<float> configMicroplasticsMod;
private ConfigEntry<bool> configUmamiCrabBool;
private ConfigEntry<bool> configForklessBool;
private ConfigEntry<bool> configForklessMSSBool;
private static bool isHitless;
private static bool isIgnoreAnotherCrab;
private static bool isIgnoreDeathDefiance;
private static bool isShellBool;
private static bool isShellSpellDisabled;
private static float shellDamageMod;
private static float microplasticsMod;
private static bool isUmamiCrabMelee;
private static bool isForkless;
private static bool isForklessMSS;
private void Awake()
{
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Expected O, but got Unknown
SceneManager.sceneLoaded += UmamiCrabPatch;
configHitlessBool = ((BaseUnityPlugin)this).Config.Bind<bool>("Hitless", "Hitless", false, "Kril will die instantly if any damage is taken");
configIgnoreAnotherCrabBool = ((BaseUnityPlugin)this).Config.Bind<bool>("Hitless", "Ignore Another Crab", false, "Ignores the effect of the Another Crab Stowaway");
configIgnoreDeathDefianceBool = ((BaseUnityPlugin)this).Config.Bind<bool>("Hitless", "Ignore Another Chance", false, "Ignores the effect of the Another Chance Shellspell");
configShellessBool = ((BaseUnityPlugin)this).Config.Bind<bool>("Shell", "Shell-less", false, "Makes Kril unable to equip shells");
configUmamiCrabBool = ((BaseUnityPlugin)this).Config.Bind<bool>("Shell", "Shell-less: Umami Crab Melee Damage", false, "If active, the Umami Crab that appears during the Shell Spell tutorial can be damaged by your fork. Otherwise, it can only take Umami damage.");
disableShellSpellBool = ((BaseUnityPlugin)this).Config.Bind<bool>("Shell", "Disable Shell Spells", false, "Makes Kril unable to use shell spells. Redundant if Shell-less is enabled");
configShellDamageMod = ((BaseUnityPlugin)this).Config.Bind<float>("Shell", "Shell Damage Modifier", 1f, "Multiplies shell damage recieved. Supports decimal multipliers like 1.5 or 0.5");
configMicroplasticsMod = ((BaseUnityPlugin)this).Config.Bind<float>("Kril Modifiers", "Microplastics Modifier", 1f, "Multiplies microplastics recieved. Supports decimal multipliers like 1.5 or 0.5");
configForklessBool = ((BaseUnityPlugin)this).Config.Bind<bool>("Fork", "Forkless", false, "Makes Kril unable to pick up the Fork in the Cave of Respite");
configForklessMSSBool = ((BaseUnityPlugin)this).Config.Bind<bool>("Fork", "Moon Snail Shell Forks", false, "When enabled, will prevent Moon Snail Shells from giving the fork to the player");
isHitless = configHitlessBool.Value;
isIgnoreAnotherCrab = configIgnoreAnotherCrabBool.Value;
isIgnoreDeathDefiance = configIgnoreDeathDefianceBool.Value;
isShellBool = configShellessBool.Value;
isShellSpellDisabled = disableShellSpellBool.Value;
shellDamageMod = configShellDamageMod.Value;
microplasticsMod = configMicroplasticsMod.Value;
isUmamiCrabMelee = configUmamiCrabBool.Value;
isForkless = configForklessBool.Value;
isForklessMSS = configForklessMSSBool.Value;
Harmony val = new Harmony("com.example.patch");
val.PatchAll();
}
public void OnGUI()
{
//IL_0125: 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_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Expected O, but got Unknown
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
float num = 0f;
float num2 = 35f;
if (isHitless)
{
num += num2;
}
if (isIgnoreAnotherCrab)
{
num += num2;
}
if (isIgnoreDeathDefiance)
{
num += num2;
}
if (isShellBool)
{
num += num2;
}
if (isShellSpellDisabled)
{
num += num2;
}
if (isUmamiCrabMelee)
{
num += num2;
}
if (shellDamageMod != 1f)
{
num += num2;
}
if (microplasticsMod != 1f)
{
num += num2;
}
if (isForkless)
{
num += num2;
}
if (isForklessMSS)
{
num += num2;
}
if (showFadingLabel && alphaAmount < 1f)
{
alphaAmount += 0.3f * Time.deltaTime;
GUI.color = new Color(originalColor.r, originalColor.g, originalColor.b, alphaAmount);
GUI.Label(new Rect((float)(Screen.width / 2), 40f, 200f, 50f), fadingLabelContent);
}
else if (alphaAmount >= 1f)
{
alphaAmount = 0f;
GUI.color = originalColor;
showFadingLabel = false;
}
if (showMenu)
{
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "Title")
{
GUI.backgroundColor = backgroundColor;
windowRect = new Rect(1000f, 0f, 200f, 50f + num);
windowRect = GUI.Window(0, windowRect, new WindowFunction(SettingDisplay), "Steel Shell Settings");
}
}
}
private void SettingDisplay(int windowID)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
GUILayout.Label("Settings can be changed in Another Crab's Treasure/BepInEx/config\n-----------------------------------", Array.Empty<GUILayoutOption>());
GUILayout.ExpandHeight(true);
float num = 25f;
if (isHitless)
{
GUILayout.Label("Hitless", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
}
if (isIgnoreAnotherCrab)
{
GUILayout.Label("Ignore Another Crab", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
}
if (isIgnoreDeathDefiance)
{
GUILayout.Label("Ignore Death Defiance", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
}
if (isShellBool)
{
GUILayout.Label("Shell-less", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
}
if (isShellSpellDisabled)
{
GUILayout.Label("Shell Spell Disabled", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
}
if (isUmamiCrabMelee)
{
GUILayout.Label("Can Melee Umami Crab", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
}
if (shellDamageMod != 1f)
{
GUILayout.Label("Shell Damage x" + shellDamageMod, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
}
if (microplasticsMod != 1f)
{
GUILayout.Label("Microplastics x" + microplasticsMod, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
}
if (isForkless)
{
GUILayout.Label("Forkless", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
}
if (isForklessMSS)
{
GUILayout.Label("Forkless Moon Snail Shells", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUI.DragWindow();
}
public static void UmamiCrabPatch(Scene s, LoadSceneMode m)
{
Enemy val = null;
Debug.Log((object)"AWAKE");
Debug.Log((object)(((Scene)(ref s)).name + " | " + ((object)(LoadSceneMode)(ref m)).ToString()));
if (((Scene)(ref s)).name == "2_D-MoonSnailShellCave")
{
try
{
val = GameObject.Find("Rangoon_Normie_Ghost_Tutorial").GetComponent<Enemy>();
}
catch
{
Debug.Log((object)"Ghost not found");
}
}
FieldInfo fieldInfo = AccessTools.Field(typeof(Enemy), "p_isUmamiGhost");
if ((Object)(object)val != (Object)null && isUmamiCrabMelee)
{
fieldInfo.SetValue(val, false);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SteelShellPlugin";
public const string PLUGIN_NAME = "SteelShellPlugin";
public const string PLUGIN_VERSION = "1.0.0";
}