using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BoplFixedMath;
using HarmonyLib;
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("More_Ability")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("More_Ability")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6cff8b4f-b388-4a45-a438-317c4b678d5c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace More_Ability;
[BepInPlugin("com.000diggity000.More_Ability_Drop", "More Ability Drop", "1.1.1")]
public class Plugin : BaseUnityPlugin
{
public static int abilityCount = 0;
public static bool random = false;
internal static ConfigFile config = new ConfigFile(Path.Combine(Paths.ConfigPath, "More_Ability_Drop_Config.cfg"), true);
internal static ConfigEntry<int> AbilityConfig;
internal static ConfigEntry<bool> RandomConfig;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("com.000diggity000.More_Ability_Drop");
val.PatchAll(typeof(Patches));
AbilityConfig = config.Bind<int>("More Ability Drop", "Abilities", 3, "Minimum is 1");
RandomConfig = config.Bind<bool>("More Ability Drop", "Random", false, "If true, the abilities dropped are random. Only abilities from the ones being used can spawn.");
if (AbilityConfig.Value <= 0)
{
AbilityConfig.Value = 0;
}
abilityCount = AbilityConfig.Value;
random = RandomConfig.Value;
}
}
public class Patches
{
[HarmonyPatch(typeof(SlimeController), "DropAbilities")]
[HarmonyPrefix]
public static bool DropAbilities_Patch(SlimeController __instance, ref AbilityReadyIndicator[] ___AbilityReadyIndicators, ref NamedSpriteList ___abilityIconsFull, ref NamedSpriteList ___abilityIconsDemo, ref DynamicAbilityPickup ___abilityPickupPrefab)
{
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: 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)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
if (!GameSession.IsInitialized() || GameSessionHandler.HasGameEnded() || __instance.abilities.Count <= 0)
{
return false;
}
PlayerHandler.Get().GetPlayer(__instance.playerNumber);
for (int i = 0; i < ___AbilityReadyIndicators.Length; i++)
{
if ((Object)(object)___AbilityReadyIndicators[i] != (Object)null)
{
___AbilityReadyIndicators[i].InstantlySyncTransform();
}
}
int num = Settings.Get().NumberOfAbilities - 1;
while (num >= 0 && (num >= ___AbilityReadyIndicators.Length || (Object)(object)___AbilityReadyIndicators[num] == (Object)null))
{
num--;
}
if (num < 0)
{
return false;
}
Vec2 val = Vec2.NormalizedSafe(Vec2.up + new Vec2(Updater.RandomFix((Fix)(-0.3f), (Fix)0.3f), (Fix)0L));
for (int j = 1; j <= Plugin.abilityCount; j++)
{
int num2 = Updater.RandomInt(0, ___AbilityReadyIndicators.Length);
if (Plugin.random)
{
Sprite primarySprite = ___AbilityReadyIndicators[num2].GetPrimarySprite();
NamedSprite val2 = ___abilityIconsFull.sprites[___abilityIconsFull.IndexOf(primarySprite)];
DynamicAbilityPickup val3 = FixTransform.InstantiateFixed<DynamicAbilityPickup>(___abilityPickupPrefab, __instance.body.position);
val3.InitPickup(val2.associatedGameObject, primarySprite, val);
}
else
{
Sprite primarySprite2 = ___AbilityReadyIndicators[num].GetPrimarySprite();
NamedSprite val4 = ___abilityIconsFull.sprites[___abilityIconsFull.IndexOf(primarySprite2)];
DynamicAbilityPickup val5 = FixTransform.InstantiateFixed<DynamicAbilityPickup>(___abilityPickupPrefab, __instance.body.position);
val5.InitPickup(val4.associatedGameObject, primarySprite2, val);
}
}
return false;
}
}