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.Logging;
using HarmonyLib;
using LootClicker;
using LootClicker.Entities;
using LootClicker.Entities.Characters;
using LootClicker.Items;
using LootClicker.Maps;
using LootClicker.Services;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("MissionSlots")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MissionSlots")]
[assembly: AssemblyTitle("MissionSlots")]
[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 MissionSlots
{
[BepInPlugin("com.corga.missionslots", "MissionSlots", "1.0.0")]
public class MissionSlotsPlugin : BaseUnityPlugin
{
public const string PluginGUID = "com.corga.missionslots";
public const string PluginName = "MissionSlots";
public const string PluginVersion = "1.0.0";
internal static ManualLogSource Log;
internal static Harmony HarmonyInstance;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
HarmonyInstance = new Harmony("com.corga.missionslots");
HarmonyInstance.PatchAll();
Log.LogInfo((object)"MissionSlots v1.0.0 loaded!");
}
}
[HarmonyPatch(typeof(CombatMenuController), "Setup")]
public static class MissionSlotExpansionPatch
{
public const int NewMaxEncounterSlots = 24;
public const int OriginalEncounterSlots = 5;
private static bool _costExtended;
private static void EnsureEncounterCostExtended()
{
if (_costExtended)
{
return;
}
_costExtended = true;
while (Upgrades.EncounterSlotCost.Count < 24)
{
int count = Upgrades.EncounterSlotCost.Count;
if (count % 2 == 0)
{
Upgrades.EncounterSlotCost.Add((50000 * (1 << (count - 6) / 2), (Currency)2));
}
else
{
Upgrades.EncounterSlotCost.Add((5000 * (1 << (count - 7) / 2), (Currency)3));
}
}
MissionSlotsPlugin.Log.LogInfo((object)$"[MissionSlots] Extended encounter slot costs to {Upgrades.EncounterSlotCost.Count} entries.");
}
[HarmonyPostfix]
private static void Postfix(CombatMenuController __instance)
{
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Expected O, but got Unknown
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Expected O, but got Unknown
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Expected O, but got Unknown
EnsureEncounterCostExtended();
if (__instance.EncounterPreviews == null || __instance.EncounterPreviews.Count < 5)
{
return;
}
int num = 24 - __instance.EncounterPreviews.Count;
for (int i = 0; i < num; i++)
{
int count = __instance.EncounterPreviews.Count;
GameObject obj = Object.Instantiate<GameObject>(__instance.EncounterPreviewPrefab);
TransformExtensions.SetParentScaled(obj.transform, __instance.EncounterSelectPanel.transform, false);
EncounterPreviewController component = obj.GetComponent<EncounterPreviewController>();
component.Setup(count);
__instance.EncounterPreviews.Add(component);
}
foreach (EncounterPreviewController encounterPreview in __instance.EncounterPreviews)
{
if (!((Object)(object)encounterPreview == (Object)null))
{
CompactEncounterSlot(encounterPreview);
}
}
LayoutGroup val = (LayoutGroup)(((object)__instance.EncounterSelectPanel.GetComponent<HorizontalLayoutGroup>()) ?? ((object)__instance.EncounterSelectPanel.GetComponent<GridLayoutGroup>()));
HorizontalLayoutGroup val2 = (HorizontalLayoutGroup)(object)((val is HorizontalLayoutGroup) ? val : null);
if (val2 != null)
{
((HorizontalOrVerticalLayoutGroup)val2).spacing = 0f;
((LayoutGroup)val2).padding = new RectOffset(0, 0, 0, 0);
}
else
{
VerticalLayoutGroup val3 = (VerticalLayoutGroup)(object)((val is VerticalLayoutGroup) ? val : null);
if (val3 != null)
{
((HorizontalOrVerticalLayoutGroup)val3).spacing = 0f;
((LayoutGroup)val3).padding = new RectOffset(0, 0, 0, 0);
}
else
{
GridLayoutGroup component2 = __instance.EncounterSelectPanel.GetComponent<GridLayoutGroup>();
if ((Object)(object)component2 != (Object)null)
{
component2.spacing = Vector2.zero;
((LayoutGroup)component2).padding = new RectOffset(0, 0, 0, 0);
}
}
}
MissionSlotsPlugin.Log.LogInfo((object)$"[MissionSlots] Expanded encounter slots to {__instance.EncounterPreviews.Count} (compact icon mode).");
}
private static void CompactEncounterSlot(EncounterPreviewController encounterPreview)
{
MissionPreviewController missionPreview = encounterPreview.MissionPreview;
if ((Object)(object)missionPreview != (Object)null)
{
Traverse trav = Traverse.Create((object)missionPreview);
SetChildActive(trav, "MissionNameBackground", active: false);
SetChildActive(trav, "MissionNameText", active: false);
SetChildActive(trav, "MissionLevelBackground", active: false);
SetChildActive(trav, "MissionLevelText", active: false);
SetChildActive(trav, "MonsterRarityBackground", active: false);
SetChildActive(trav, "MonsterElementBackground", active: false);
SetChildActive(trav, "BountyNameBackground", active: false);
SetChildActive(trav, "BountyNameText", active: false);
}
if ((Object)(object)encounterPreview.EncounterBuyText != (Object)null)
{
((Component)encounterPreview.EncounterBuyText).gameObject.SetActive(false);
}
if ((Object)(object)((Component)encounterPreview).gameObject.GetComponent<EncounterSlotTooltip>() == (Object)null)
{
((Component)encounterPreview).gameObject.AddComponent<EncounterSlotTooltip>().EncounterPreview = encounterPreview;
}
}
private static void SetChildActive(Traverse trav, string fieldName, bool active)
{
Traverse val = trav.Field(fieldName);
if (val == null)
{
return;
}
object value = val.GetValue();
Component val2 = (Component)((value is Component) ? value : null);
if (val2 != null)
{
val2.gameObject.SetActive(active);
return;
}
GameObject val3 = (GameObject)((value is GameObject) ? value : null);
if (val3 != null)
{
val3.SetActive(active);
}
}
}
public class EncounterSlotTooltip : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
{
public EncounterPreviewController EncounterPreview;
public void OnPointerEnter(PointerEventData eventData)
{
string text = BuildTooltipText();
if (!string.IsNullOrEmpty(text))
{
GameData.GameController.Tooltip.Activate(text, false, false, false, false);
}
}
public void OnPointerExit(PointerEventData eventData)
{
GameData.GameController.Tooltip.Deactivate();
}
private string BuildTooltipText()
{
if ((Object)(object)EncounterPreview == (Object)null)
{
return null;
}
Encounter encounter = EncounterPreview.Encounter;
if (encounter == null)
{
if (!EncounterPreview.SlotUnlocked)
{
return Locale.GetText("menu_buyMissionSlot");
}
return Locale.GetText("menu_emptyMissionSlot");
}
MissionBase map = encounter.Map;
string text = ((map != null) ? map.Name : null) ?? "???";
if (encounter.CombatPaused)
{
return text + "\n" + Locale.GetText("menu_paused");
}
int num = 0;
int num2 = 0;
foreach (Character character in encounter.Characters)
{
if (character != null)
{
num++;
if (((Entity)character).CurrentHealth > 0f)
{
num2++;
}
}
}
string text2 = string.Format(Locale.GetText("menu_charactersAlive"), num2, num);
string text3 = ((num2 <= 0) ? "#FF0000" : ((num2 == num) ? "#95FF6D" : "#FFC4B1"));
return text + "\n" + TextHelper.GetHtmlText(text2, text3, false, -1);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}