using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SuperFantasyKingdom;
using SuperFantasyKingdom.Tavern;
using SuperFantasyKingdom.UI;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("PortraitLevels")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+dcd5abf4e3775fcbc4f93685ccc53b8812e48bfb")]
[assembly: AssemblyProduct("Portrait Levels")]
[assembly: AssemblyTitle("PortraitLevels")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 PortraitLevels
{
[BepInPlugin("ownly.portraitlevels", "Portrait Levels", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Portrait Levels loaded");
}
}
internal static class LevelLabel
{
private static readonly Vector2 Anchor = new Vector2(0.77f, 0.8f);
private static readonly Vector2 DiscSize = new Vector2(0.44f, 0.5f);
private static readonly Vector2 TextNudge = new Vector2(0.015f, 0.02f);
private const float TextFill = 1.4f;
private const float WideFactor = 1.6f;
private const float Opacity = 0.41f;
private const string OutlinedFont = "Passage7Outline";
private static Sprite s_Disc;
private static TMP_FontAsset s_Font;
private static Material s_Material;
internal static void Add(RectTransform icon, int level, Transform uiRoot)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Expected O, but got Unknown
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = DiscSize * 0.5f;
Vector2 val2 = DiscSize * 1.4f * 0.5f;
if (level > 9)
{
val.x *= 1.6f;
val2.x *= 1.6f;
}
GameObject val3 = new GameObject("LevelClip", new Type[1] { typeof(RectTransform) });
RectTransform val4 = (RectTransform)val3.transform;
((Transform)val4).SetParent((Transform)(object)icon, false);
val4.anchorMin = Vector2.zero;
val4.anchorMax = Vector2.one;
val4.offsetMin = Vector2.zero;
val4.offsetMax = Vector2.zero;
val3.AddComponent<RectMask2D>();
if ((Object)(object)s_Disc == (Object)null)
{
Texture2D val5 = new Texture2D(16, 16);
((Texture)val5).filterMode = (FilterMode)0;
for (int i = 0; i < 16; i++)
{
for (int j = 0; j < 16; j++)
{
val5.SetPixel(j, i, new Color(1f, 1f, 1f, (Vector2.Distance(new Vector2((float)j, (float)i), Vector2.one * 7.5f) <= 8f) ? 1f : 0f));
}
}
val5.Apply();
s_Disc = Sprite.Create(val5, new Rect(0f, 0f, 16f, 16f), Vector2.one * 0.5f);
}
Image obj = new GameObject("LevelDisc", new Type[1] { typeof(RectTransform) }).AddComponent<Image>();
((Transform)((Graphic)obj).rectTransform).SetParent((Transform)(object)val4, false);
((Graphic)obj).rectTransform.anchorMin = Anchor - val;
((Graphic)obj).rectTransform.anchorMax = Anchor + val;
((Graphic)obj).rectTransform.offsetMin = Vector2.zero;
((Graphic)obj).rectTransform.offsetMax = Vector2.zero;
obj.sprite = s_Disc;
((Graphic)obj).color = new Color(0f, 0f, 0f, 0.41f);
((Graphic)obj).raycastTarget = false;
if ((Object)(object)s_Font == (Object)null)
{
TMP_FontAsset[] source = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
s_Font = ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset font) => ((Object)font).name == "Passage7Outline")) ?? ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset font) => ((Object)font).name.Contains("Outline"))) ?? ((TMP_Text)((Component)uiRoot).GetComponentInChildren<TextMeshProUGUI>(true)).font;
s_Material = ((TMP_Asset)s_Font).material;
}
TextMeshProUGUI obj2 = new GameObject("Level", new Type[1] { typeof(RectTransform) }).AddComponent<TextMeshProUGUI>();
((Transform)((TMP_Text)obj2).rectTransform).SetParent((Transform)(object)icon, false);
((TMP_Text)obj2).rectTransform.anchorMin = Anchor - val2 + TextNudge;
((TMP_Text)obj2).rectTransform.anchorMax = Anchor + val2 + TextNudge;
((TMP_Text)obj2).rectTransform.offsetMin = Vector2.zero;
((TMP_Text)obj2).rectTransform.offsetMax = Vector2.zero;
((TMP_Text)obj2).font = s_Font;
((TMP_Text)obj2).fontSharedMaterial = s_Material;
((Graphic)obj2).color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)231, (byte)0, byte.MaxValue));
((TMP_Text)obj2).alignment = (TextAlignmentOptions)514;
((TMP_Text)obj2).enableWordWrapping = false;
((Graphic)obj2).raycastTarget = false;
((TMP_Text)obj2).enableAutoSizing = true;
((TMP_Text)obj2).fontSizeMin = 1f;
((TMP_Text)obj2).fontSizeMax = 400f;
((TMP_Text)obj2).text = level.ToString();
}
}
[HarmonyPatch(typeof(UIOverlayGameOverUnit), "Init")]
internal static class Patch_SummaryScreen
{
private static void Postfix(UIOverlayGameOverUnit __instance, UnitBase unit, Image ___icon)
{
LevelLabel.Add(((Graphic)___icon).rectTransform, unit.GetLevel(), ((Component)__instance).transform.root);
}
}
[HarmonyPatch(typeof(TavernStatistics), "GenerateDamageMeter")]
internal static class Patch_DamageMeter
{
private static void Postfix(TavernStatistics __instance)
{
Statistics dailyStatistic = TavernSaveManager.Instance.GetGameData().dailyStatistic;
float[] meter;
switch (Traverse.Create((object)__instance).Field("m_DamageMeterMode").GetValue<int>())
{
case 1:
meter = dailyStatistic.damageMeter;
break;
case 2:
meter = dailyStatistic.healMeter;
break;
case 3:
meter = dailyStatistic.defenseMeter;
break;
default:
meter = dailyStatistic.killCount.Take(30).Select((Func<int, float>)((int kills) => kills)).ToArray();
break;
}
List<UnitBase> list = (from identifier in Enumerable.Range(0, meter.Length)
orderby meter[identifier] descending
select TavernUnits.Instance.GetUnit(identifier) into unit
where (Object)(object)unit != (Object)null
select unit).ToList();
Transform val = ((Component)__instance).transform.Find("DamageMeterContainer/DamageMeter/ViewPort/Content");
int num = val.childCount - list.Count;
for (int num2 = 0; num2 < list.Count; num2++)
{
Transform obj = val.GetChild(num + num2).Find("Icon");
LevelLabel.Add((RectTransform)(object)((obj is RectTransform) ? obj : null), list[num2].GetLevel(), ((Component)__instance).transform.root);
}
}
}
}