using System;
using System.Collections;
using System.Collections.Generic;
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.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[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("MoreWands")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreWands")]
[assembly: AssemblyTitle("MoreWands")]
[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 MoreWandsPlugin
{
[BepInPlugin("com.fizzy.morewand", "More Wands", "1.0.0")]
public class MoreWands : BaseUnityPlugin
{
public static int wandsAmount;
private static ConfigEntry<int> configWandsAmmount;
private void Awake()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
((ConfigEntry<bool>)AccessTools.Field(typeof(Chainloader), "ConfigHideBepInExGOs").GetValue(null)).Value = true;
configWandsAmmount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "WandAmmount", 4, new ConfigDescription("Number of wands that should drop", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
Harmony val = new Harmony("com.fizzy.morewand");
wandsAmount = configWandsAmmount.Value;
val.Patch((MethodBase)AccessTools.Method(typeof(OutputMgr), "GetLevelReward", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MoreWands), "Postfix_GetLevelReward", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
val.Patch((MethodBase)AccessTools.Method(typeof(UILevelReward), "ShowRewardIE", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MoreWands), "Postfix_ShowRewardIE", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"More Wands mod loaded successfully!");
}
[HarmonyPostfix]
private static void Postfix_GetLevelReward(LevelRewardType type, ref List<ItemInfo> __result)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Invalid comparison between Unknown and I4
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Invalid comparison between Unknown and I4
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
wandsAmount = configWandsAmmount.Value;
int currentStage = BattleMgr.Inst.CurrentStage;
if (((int)type == 100 && currentStage == 1) || (int)type == 101)
{
for (int i = 0; i < wandsAmount - 2; i++)
{
__result.Add(new ItemInfo((ItemType)0, PlayerMgr.Inst.BaData.GetWandFromPool(currentStage, Array.Empty<int>())));
}
if (wandsAmount == 1)
{
__result.RemoveAt(1);
}
}
}
[HarmonyPostfix]
private static IEnumerator Postfix_ShowRewardIE(IEnumerator original, UILevelReward __instance, LevelReward reward)
{
while (original.MoveNext())
{
yield return original.Current;
}
if ((int)reward.Type != 0 || GameMgr.IsMobile_Static)
{
yield break;
}
List<Transform> wandTransforms = new List<Transform>();
foreach (Transform item in __instance.tsf_UIParent)
{
Transform child = item;
if ((Object)(object)((Component)child).GetComponent<UIRewardWand>() != (Object)null)
{
wandTransforms.Add(child);
}
}
int wandCount = wandTransforms.Count;
if (wandCount > 2)
{
float screenWidth = Screen.width;
float screenHeight = Screen.height;
int columns = Mathf.CeilToInt(Mathf.Sqrt((float)wandCount));
int rows = Mathf.CeilToInt((float)wandCount / (float)columns);
float availableWidth = screenWidth - 200f;
float availableHeight = screenHeight - 100f;
float horizontalSpacing = availableWidth / (float)columns;
float verticalSpacing = availableHeight / (float)rows;
float startX = (0f - (float)(columns - 1) * horizontalSpacing) / 2f;
float startY = (float)(rows - 1) * verticalSpacing / 2f + 150f;
for (int i = 0; i < wandCount; i++)
{
int row = i / columns;
int col = i % columns;
Transform wandParent = wandTransforms[i];
wandParent.localPosition = Vector2.op_Implicit(new Vector2(startX + (float)col * horizontalSpacing, startY - (float)row * verticalSpacing));
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MoreWands";
public const string PLUGIN_NAME = "MoreWands";
public const string PLUGIN_VERSION = "1.0.0";
}
}