using System;
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;
}
}
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 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 void Awake()
{
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: 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");
isHitless = configHitlessBool.Value;
isIgnoreAnotherCrab = configIgnoreAnotherCrabBool.Value;
isIgnoreDeathDefiance = configIgnoreDeathDefianceBool.Value;
isShellBool = configShellessBool.Value;
isShellSpellDisabled = disableShellSpellBool.Value;
shellDamageMod = configShellDamageMod.Value;
microplasticsMod = configMicroplasticsMod.Value;
isUmamiCrabMelee = configUmamiCrabBool.Value;
Harmony val = new Harmony("com.example.patch");
val.PatchAll();
}
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";
}