using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using DetailedLevels.Config;
using DetailedLevels.Features;
using DetailedLevels.Tools;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DetailedLevels")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DetailedLevels")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f302fe77-1481-495a-84b9-5ba829a4cf2b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DetailedLevels
{
internal class ConfigurationFile
{
public static ConfigEntry<bool> debug;
public static ConfigEntry<KeyCode> hotKey;
public static ConfigEntry<int> numberOfDecimals;
public static ConfigEntry<int> skillUpMessageAfterMultipleLevel;
public static ConfigEntry<int> skillUpBigMessageAfterMultipleLevel;
public static ConfigEntry<Color> colorSkillBackground;
public static ConfigEntry<bool> saveSkillBuffs;
private static ConfigFile config;
internal static void LoadConfig(BaseUnityPlugin plugin)
{
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
config = plugin.Config;
debug = config.Bind<bool>("1 - General", "DebugMode", false, "Enabling/Disabling the debugging in the console (default = false)");
hotKey = config.Bind<KeyCode>("1 - General", "HotKey", (KeyCode)285, "Hot Key to show the skills tab without opening the inventory first (default = F7)");
numberOfDecimals = config.Bind<int>("2 - Levels Data", "NumberOfDecimals", 2, "Number of decimals to show in your levels information (default = 2, min = 0, max = 15)");
skillUpMessageAfterMultipleLevel = config.Bind<int>("2 - Levels Data", "SkillUpMessageAfterMultipleLevel", 5, "Shows skill up message after the new level is multiple of the indicated level (0 = disabled, default = 5)");
skillUpBigMessageAfterMultipleLevel = config.Bind<int>("2 - Levels Data", "SkillUpBigMessageAfterMultipleLevel", 20, "Shows skill up big message after the new level is multiple of the indicated level (0 = disabled, default = 5)");
colorSkillBackground = config.Bind<Color>("2 - Levels Data", "ColorSkillBackground", Color.cyan, "Choose the color background for selected skills in the skills dialog: red, green, blue, white, black, yellow, cyan, magenta, gray or grey (default = cyan)");
saveSkillBuffs = config.Bind<bool>("2 - Levels Data", "SaveSkillBuffs", false, "Enable/disable the option to reload tracked skills after dying (default = false");
}
}
[BepInPlugin("Turbero.DetailedLevels", "Detailed Levels", "1.3.2")]
public class DetailedLevels : BaseUnityPlugin
{
public const string GUID = "Turbero.DetailedLevels";
public const string NAME = "Detailed Levels";
public const string VERSION = "1.3.2";
private readonly Harmony harmony = new Harmony("Turbero.DetailedLevels");
private void Awake()
{
ConfigurationFile.LoadConfig((BaseUnityPlugin)(object)this);
harmony.PatchAll();
}
private void onDestroy()
{
harmony.UnpatchSelf();
}
private void Update()
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)InventoryGui.instance))
{
return;
}
if (Input.GetKeyDown((KeyCode)27) || Input.GetKeyDown((KeyCode)9) || ((Character)Player.m_localPlayer).IsDead())
{
hideCustomPanelAndSkillsDialog();
}
if (Input.GetKeyDown(ConfigurationFile.hotKey.Value) && Time.timeScale > 0f)
{
if (((Component)InventoryGui.instance.m_skillsDialog).gameObject.activeSelf)
{
hideCustomPanelAndSkillsDialog();
InventoryGui.instance.Hide();
}
else
{
InventoryGui.instance.Show((Container)null, 1);
WaitForSecondsAsync(0.15f);
}
}
}
private static void hideCustomPanelAndSkillsDialog()
{
if (!((Object)(object)InventoryGui.instance.m_skillsDialog == (Object)null))
{
((Component)InventoryGui.instance.m_skillsDialog).gameObject.SetActive(false);
if (!((Object)(object)((Component)InventoryGui.instance.m_skillsDialog).transform.Find("SkillsFrame") == (Object)null) && !((Object)(object)((Component)((Component)InventoryGui.instance.m_skillsDialog).transform.Find("SkillsFrame")).transform.Find("CustomSkillOptionsPanel") == (Object)null))
{
((Component)((Component)((Component)InventoryGui.instance.m_skillsDialog).transform.Find("SkillsFrame")).transform.Find("CustomSkillOptionsPanel")).gameObject.SetActive(false);
}
}
}
private static async Task WaitForSecondsAsync(float seconds)
{
await Task.Delay((int)(Math.Max(0f, seconds) * 1000f));
InventoryGui.instance.m_skillsDialog.Setup(Player.m_localPlayer);
((Component)InventoryGui.instance.m_skillsDialog).gameObject.SetActive(true);
}
}
[HarmonyPatch(typeof(Localization), "SetLanguage")]
public class Localization_SetLanguage_Patch
{
private static void Postfix(string language)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
Logger.Log("Language changed to: " + language);
foreach (SkillType key in PlayerUtils.skillStatusEffects.Keys)
{
int valueSafe = GeneralExtensions.GetValueSafe<SkillType, int>(PlayerUtils.skillStatusEffects, key);
Player_RaiseSkill_Patch.updateSkillTypeBuff(Player.m_localPlayer, key, valueSafe, forceUpdate: true);
}
}
}
public static class Logger
{
internal static void Log(object s)
{
if (ConfigurationFile.debug.Value)
{
string text = "Detailed Levels 1.3.2: " + ((s != null) ? s.ToString() : "null");
Debug.Log((object)text);
}
}
internal static void LogWarning(object s)
{
string text = "Detailed Levels 1.3.2: " + ((s != null) ? s.ToString() : "null");
Debug.LogWarning((object)text);
}
internal static void LogError(object s)
{
string text = "Detailed Levels 1.3.2: " + ((s != null) ? s.ToString() : "null");
Debug.LogError((object)text);
}
}
}
namespace DetailedLevels.Tools
{
public class CustomSlider
{
private readonly GameObject sliderObject;
private readonly Slider slider;
private readonly TextMeshProUGUI sliderValue;
public CustomSlider(string name, int maxValue, Vector2 sizeDelta, Vector2 position, int posXIcon, string spriteName, int posXDescription, string description, int posXValue, int initValue, string valueDesc)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
//IL_010d: 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)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Expected O, but got Unknown
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Expected O, but got Unknown
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Expected O, but got Unknown
//IL_0377: Unknown result type (might be due to invalid IL or missing references)
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Expected O, but got Unknown
//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
//IL_046f: Unknown result type (might be due to invalid IL or missing references)
//IL_0476: Expected O, but got Unknown
//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
sliderObject = new GameObject(name, new Type[1] { typeof(RectTransform) });
RectTransform component = sliderObject.GetComponent<RectTransform>();
component.sizeDelta = sizeDelta;
component.anchoredPosition = position;
slider = sliderObject.AddComponent<Slider>();
((Object)slider).name = name;
slider.minValue = 0f;
slider.maxValue = maxValue;
slider.value = initValue;
typeof(Slider).GetField("m_WholeNumbers", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(slider, true);
GameObject val = new GameObject("Background", new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
val.transform.SetParent(sliderObject.transform, false);
RectTransform component2 = val.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0f, 0f);
component2.anchorMax = new Vector2(1f, 1f);
component2.sizeDelta = new Vector2(0f, 0f);
((Graphic)val.GetComponent<Image>()).color = Color.gray;
GameObject val2 = new GameObject("Fill Area", new Type[1] { typeof(RectTransform) });
val2.transform.SetParent(sliderObject.transform, false);
RectTransform component3 = val2.GetComponent<RectTransform>();
component3.anchorMin = new Vector2(0f, 0.25f);
component3.anchorMax = new Vector2(1f, 0.75f);
component3.sizeDelta = new Vector2(0f, 0f);
GameObject val3 = new GameObject("Fill", new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
val3.transform.SetParent(val2.transform, false);
RectTransform component4 = val3.GetComponent<RectTransform>();
component4.anchorMin = new Vector2(0f, 0f);
component4.anchorMax = new Vector2(1f, 1f);
component4.sizeDelta = new Vector2(0f, 0f);
((Graphic)val3.GetComponent<Image>()).color = Color.green;
slider.fillRect = component4;
GameObject val4 = new GameObject("Handle", new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
val4.transform.SetParent(sliderObject.transform, false);
RectTransform component5 = val4.GetComponent<RectTransform>();
component5.sizeDelta = new Vector2(10f, 10f);
((Graphic)val4.GetComponent<Image>()).color = Color.white;
((Selectable)slider).targetGraphic = (Graphic)(object)val4.GetComponent<Image>();
slider.handleRect = component5;
if (spriteName != null)
{
GameObject val5 = new GameObject("Icon");
Image val6 = val5.AddComponent<Image>();
val6.sprite = PlayerUtils.getSprite(spriteName);
RectTransform component6 = val5.GetComponent<RectTransform>();
((Transform)component6).SetParent(sliderObject.transform, false);
component6.sizeDelta = new Vector2(25f, 25f);
component6.anchoredPosition = new Vector2((float)posXIcon, 0f);
}
if (description != null)
{
GameObject val7 = new GameObject("SliderLabel", new Type[2]
{
typeof(RectTransform),
typeof(TextMeshProUGUI)
});
val7.transform.SetParent(sliderObject.transform, false);
RectTransform component7 = val7.GetComponent<RectTransform>();
component7.anchoredPosition = new Vector2((float)posXDescription, 0f);
TextMeshProUGUI component8 = val7.GetComponent<TextMeshProUGUI>();
((TMP_Text)component8).text = description;
((TMP_Text)component8).fontSize = 18f;
((TMP_Text)component8).alignment = (TextAlignmentOptions)516;
}
if (initValue >= 0)
{
GameObject val8 = new GameObject("SliderValue", new Type[2]
{
typeof(RectTransform),
typeof(TextMeshProUGUI)
});
val8.transform.SetParent(sliderObject.transform, false);
RectTransform component9 = val8.GetComponent<RectTransform>();
component9.anchoredPosition = new Vector2((float)posXValue, 0f);
sliderValue = val8.GetComponent<TextMeshProUGUI>();
((TMP_Text)sliderValue).fontSize = 18f;
((TMP_Text)sliderValue).alignment = (TextAlignmentOptions)513;
((TMP_Text)sliderValue).text = valueDesc;
}
}
public GameObject getGameObject()
{
return sliderObject;
}
public void OnValueChanged(UnityAction<float> call)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
slider.onValueChanged = new SliderEvent();
((UnityEvent<float>)(object)slider.onValueChanged).AddListener(call);
}
public void updateValue(string value)
{
((TMP_Text)sliderValue).text = value;
}
}
}
namespace DetailedLevels.Features
{
public class PlayerBuffs
{
public static Dictionary<SkillType, Sprite> sprites = new Dictionary<SkillType, Sprite>();
public static Dictionary<SkillType, Skill> skills = new Dictionary<SkillType, Skill>();
public static void AddSkillBuff(Player player, Skill skill, Sprite skillIcon, GameObject skillRow = null)
{
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
SEMan sEMan = ((Character)player).GetSEMan();
string text = (((Object)(object)skillRow != (Object)null) ? ((Component)Utils.FindChild(skillRow.transform, "leveltext", (IterativeSearchType)0)).GetComponent<TMP_Text>().text : PlayerUtils.GetCurrentSkillLevelProgress(skill).ToString());
Logger.Log("Skill current value: " + text);
SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
((StatusEffect)val).m_name = "$skill_" + ((object)(SkillType)(ref skill.m_info.m_skill)).ToString().ToLower() + ": " + text;
((StatusEffect)val).m_tooltip = "$skill_" + ((object)(SkillType)(ref skill.m_info.m_skill)).ToString().ToLower() + "_description";
((StatusEffect)val).m_icon = skillIcon;
((Object)val).name = PlayerUtils.GetValueForNameHash(skill);
int num = ((StatusEffect)val).NameHash();
Logger.Log($"name: {((Object)val).name}, m_name: {((StatusEffect)val).m_name}, nameHash: {num}");
sEMan.AddStatusEffect((StatusEffect)(object)val, false, 0, 0f);
if (PlayerUtils.skillStatusEffects.ContainsKey(skill.m_info.m_skill))
{
PlayerUtils.skillStatusEffects.Remove(skill.m_info.m_skill);
}
PlayerUtils.skillStatusEffects.Add(skill.m_info.m_skill, num);
Logger.Log("Added buff: " + ((StatusEffect)val).m_name);
if (!sprites.ContainsKey(skill.m_info.m_skill))
{
sprites.Add(skill.m_info.m_skill, skillIcon);
Logger.Log("Cached sprite for " + ((StatusEffect)val).m_name + " with sprite.name " + ((Object)skillIcon).name);
}
if (!skills.ContainsKey(skill.m_info.m_skill))
{
skills.Add(skill.m_info.m_skill, skill);
Logger.Log("Cached skill for " + ((StatusEffect)val).m_name);
}
}
public static void RemoveSkillBuff(Player player, Skill skill)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
SEMan sEMan = ((Character)player).GetSEMan();
string text = ((object)(SkillType)(ref skill.m_info.m_skill)).ToString();
int valueSafe = GeneralExtensions.GetValueSafe<SkillType, int>(PlayerUtils.skillStatusEffects, skill.m_info.m_skill);
StatusEffect statusEffect = sEMan.GetStatusEffect(valueSafe);
if ((Object)(object)statusEffect != (Object)null)
{
sEMan.RemoveStatusEffect(statusEffect, false);
PlayerUtils.skillStatusEffects.Remove(skill.m_info.m_skill);
Logger.Log("Deleted buff: " + statusEffect.m_name);
sprites.Remove(skill.m_info.m_skill);
skills.Remove(skill.m_info.m_skill);
}
}
}
[HarmonyPatch(typeof(SkillsDialog), "Awake")]
public class PlayerSkillupOptionsPatch
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__3_0;
internal void <Postfix>b__3_0()
{
Logger.Log("DLOptionsButton clicked.");
panel.getPanel().SetActive(true);
Logger.Log("DLOptionsButton - panel created.");
}
}
public static CustomSkillOptionsPanel panel;
private static readonly Color TITLE_COLOR = new Color(1f, 0.7176f, 0.3603f);
private static TextMeshProUGUI buttonText;
private static void Postfix(SkillsDialog __instance)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
Transform val = ((Component)((Component)InventoryGui.instance.m_skillsDialog).transform.Find("SkillsFrame")).transform.Find("Closebutton");
((RectTransform)((val is RectTransform) ? val : null)).anchoredPosition = new Vector2(101f, 45f);
Button component = ((Component)val).GetComponent<Button>();
GameObject val2 = Object.Instantiate<GameObject>(((Component)component).gameObject, ((Component)component).transform.parent);
((Object)val2).name = "DLOptionsButton";
RectTransform component2 = val2.GetComponent<RectTransform>();
component2.anchoredPosition = new Vector2(-100f, 45f);
buttonText = val2.GetComponentInChildren<TextMeshProUGUI>();
((TMP_Text)buttonText).fontStyle = (FontStyles)0;
((Graphic)buttonText).color = TITLE_COLOR;
((TMP_Text)buttonText).alignment = (TextAlignmentOptions)514;
panel = new CustomSkillOptionsPanel(((Component)component).transform.parent);
Button component3 = val2.GetComponent<Button>();
component3.onClick = new ButtonClickedEvent();
ButtonClickedEvent onClick = component3.onClick;
object obj = <>c.<>9__3_0;
if (obj == null)
{
UnityAction val3 = delegate
{
Logger.Log("DLOptionsButton clicked.");
panel.getPanel().SetActive(true);
Logger.Log("DLOptionsButton - panel created.");
};
<>c.<>9__3_0 = val3;
obj = (object)val3;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
addSoftDeathInfo(panel.getPanel().transform);
addSaveSwitchButton(panel.getPanel().transform);
addNumberOfDecimalsSlider(panel.getPanel().transform);
addSkillUpMessage(panel.getPanel().transform);
addSkillUpBigMessage(panel.getPanel().transform);
reloadTexts();
}
public static void reloadTexts()
{
((TMP_Text)buttonText).text = Localization.instance.Localize("$button_ps_start");
panel.reloadTexts();
}
private static void addSoftDeathInfo(Transform parent)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
float num = ((Character)Player.m_localPlayer).GetSkills().m_DeathLowerFactor * 100f;
GameObject val = new GameObject("NoSkillDrainText");
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).text = $"Death penalty = -{num}%";
((TMP_Text)val2).fontStyle = (FontStyles)0;
((Graphic)val2).color = new Color(1f, 1f, 0f);
((TMP_Text)val2).fontSize = 18f;
RectTransform component = val.GetComponent<RectTransform>();
((Transform)component).SetParent(parent, false);
component.sizeDelta = new Vector2(200f, 50f);
component.anchoredPosition = new Vector2(-75f, 173f);
}
private static void addSaveSwitchButton(Transform parent)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
CustomSlider customSlider = new CustomSlider("SkillsLevelSaveSlider", 1, new Vector2(25f, 10f), new Vector2(-42f, 163f), -1, null, -124, "Reload after dying", 123, ConfigurationFile.saveSkillBuffs.Value ? 1 : 0, ConfigurationFile.saveSkillBuffs.Value.ToString());
customSlider.getGameObject().transform.SetParent(parent, false);
customSlider.OnValueChanged(delegate(float value)
{
ConfigurationFile.saveSkillBuffs.Value = value == 1f;
customSlider.updateValue(ConfigurationFile.saveSkillBuffs.Value.ToString());
});
}
private static void addNumberOfDecimalsSlider(Transform parent)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
CustomSlider customSlider = new CustomSlider("NumberOfDecimalsSlider", 15, new Vector2(150f, 10f), new Vector2(20f, 135f), 0, null, -186, "Number of decimals", 185, ConfigurationFile.numberOfDecimals.Value, ConfigurationFile.numberOfDecimals.Value.ToString());
customSlider.getGameObject().transform.SetParent(parent, false);
customSlider.OnValueChanged(delegate(float value)
{
Logger.Log("slider changed to " + value);
customSlider.updateValue(value.ToString());
ConfigurationFile.numberOfDecimals.Value = (int)value;
});
}
private static void addSkillUpMessage(Transform parent)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
CustomSlider customSlider = new CustomSlider("SkillUpMessageSlider", 100, new Vector2(150f, 10f), new Vector2(20f, 105f), 0, null, -186, "Skill up message", 185, ConfigurationFile.skillUpMessageAfterMultipleLevel.Value, $"Each {ConfigurationFile.skillUpMessageAfterMultipleLevel.Value} levels");
customSlider.getGameObject().transform.SetParent(parent, false);
customSlider.OnValueChanged(delegate(float value)
{
Logger.Log("slider changed to " + value);
customSlider.updateValue($"Each {value} levels");
ConfigurationFile.skillUpMessageAfterMultipleLevel.Value = (int)value;
});
}
private static void addSkillUpBigMessage(Transform parent)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
CustomSlider customSlider = new CustomSlider("SkillUpBigMessageSlider", 100, new Vector2(150f, 10f), new Vector2(20f, 75f), 0, null, -186, "Skill up big message", 185, ConfigurationFile.skillUpBigMessageAfterMultipleLevel.Value, $"Each {ConfigurationFile.skillUpBigMessageAfterMultipleLevel.Value} levels");
customSlider.getGameObject().transform.SetParent(parent, false);
customSlider.OnValueChanged(delegate(float value)
{
Logger.Log("slider changed to " + value);
customSlider.updateValue($"Each {value} levels");
ConfigurationFile.skillUpBigMessageAfterMultipleLevel.Value = (int)value;
});
}
}
[HarmonyPatch(typeof(Player), "OnDeath")]
public class Player_OnDeath_Patch
{
private static void Postfix(Player __instance)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
Player component = ((Component)__instance).GetComponent<Player>();
FieldInfo field = typeof(SkillsDialog).GetField("m_elements", BindingFlags.Instance | BindingFlags.NonPublic);
List<GameObject> list = (List<GameObject>)field.GetValue(InventoryGui.instance.m_skillsDialog);
foreach (GameObject item in list)
{
PlayerUtils.setSkillRowBackgroundColor(item, new Color(0f, 0f, 0f, 0f));
}
if (!ConfigurationFile.saveSkillBuffs.Value)
{
PlayerUtils.skillStatusEffects.Clear();
}
}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
public class Player_OnSpawned_Patch
{
private static void Postfix(Player __instance, bool spawnValkyrie)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
if (!ConfigurationFile.saveSkillBuffs.Value)
{
return;
}
List<SkillType> list = new List<SkillType>();
foreach (SkillType key in PlayerUtils.skillStatusEffects.Keys)
{
list.Add(key);
}
foreach (SkillType item in list)
{
PlayerBuffs.AddSkillBuff(Player.m_localPlayer, GeneralExtensions.GetValueSafe<SkillType, Skill>(PlayerBuffs.skills, item), GeneralExtensions.GetValueSafe<SkillType, Sprite>(PlayerBuffs.sprites, item));
}
}
}
[HarmonyPatch(typeof(SkillsDialog), "Setup")]
[HarmonyPriority(700)]
internal static class SkillsDialog_SkillStatusEffects_Patch
{
private static void Postfix(SkillsDialog __instance, ref Player player, ref List<GameObject> ___m_elements)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
Logger.Log("** SkillsDialog_SkillStatusEffects_Patch.Postfix");
if ((Object)(object)InventoryGui.instance == (Object)null)
{
return;
}
for (int i = 0; i < ___m_elements.Count; i++)
{
GameObject skillRow = ___m_elements[i];
int row = i;
skillRow.GetComponent<Button>().onClick = new ButtonClickedEvent();
((UnityEvent)skillRow.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
Player localPlayer = Player.m_localPlayer;
Skill skill = ((Character)localPlayer).GetSkills().GetSkillList()[row];
OnSkillClicked(localPlayer, skill, skillRow);
});
}
}
private static void OnSkillClicked(Player player, Skill skill, GameObject skillRow)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
SkillType skill2 = skill.m_info.m_skill;
string text = ((object)(SkillType)(ref skill.m_info.m_skill)).ToString();
bool flag = PlayerUtils.skillStatusEffects.ContainsKey(skill2);
Logger.Log($"skillStatusEffects.ContainsKey: {flag}");
if (!flag)
{
Sprite skillIcon = GetSkillIcon(skillRow);
PlayerBuffs.AddSkillBuff(player, skill, skillIcon, skillRow);
PlayerUtils.setSkillRowBackgroundColor(skillRow, ConfigurationFile.colorSkillBackground.Value);
}
else
{
PlayerBuffs.RemoveSkillBuff(player, skill);
PlayerUtils.setSkillRowBackgroundColor(skillRow, new Color(0f, 0f, 0f, 0f));
}
}
private static Sprite GetSkillIcon(GameObject skillRow)
{
Image component = ((Component)((Component)((Component)skillRow.transform.Find("icon_bkg")).GetComponent<Image>()).transform.Find("icon")).GetComponent<Image>();
if ((Object)(object)component != (Object)null)
{
return component.sprite;
}
return null;
}
}
[HarmonyPatch(typeof(Player), "RaiseSkill")]
public class Player_RaiseSkill_Patch
{
private static void Postfix(Player __instance, SkillType skill, float value)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (PlayerUtils.skillStatusEffects.TryGetValue(skill, out var value2))
{
updateSkillTypeBuff(__instance, skill, value2);
}
}
public static void updateSkillTypeBuff(Player player, SkillType skillType, int nameHash, bool forceUpdate = false)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
string text = ((object)(SkillType)(ref skillType)).ToString();
int valueForHashCode = PlayerUtils.GetValueForHashCode(skillType);
Logger.Log($"skillName to find corresponding buff: {text} with hash {valueForHashCode}. Stored nameHash: {nameHash}");
SEMan sEMan = ((Character)player).GetSEMan();
StatusEffect statusEffect = sEMan.GetStatusEffect(nameHash);
if ((Object)(object)statusEffect != (Object)null)
{
Skill skill = FindPlayerSkill(player, skillType);
float currentSkillLevelProgress = PlayerUtils.GetCurrentSkillLevelProgress(skill);
Logger.Log($"About to update buff: $skill_{text.ToLower()} with skill level: {currentSkillLevelProgress}.");
string text2 = $"$skill_{((object)(SkillType)(ref skillType)).ToString().ToLower()}: {currentSkillLevelProgress}";
Logger.Log("Old buff name: " + statusEffect.m_name + ". New buff name: " + text2);
if (statusEffect.m_name != text2 || forceUpdate)
{
statusEffect.m_name = $"$skill_{((object)(SkillType)(ref skillType)).ToString().ToLower()}: {currentSkillLevelProgress}";
Logger.Log($"Updated buff: {text} with skill level: {currentSkillLevelProgress}");
}
else
{
Logger.Log("No need to update buff");
}
}
}
private static Skill FindPlayerSkill(Player player, SkillType skillType)
{
//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)
foreach (Skill skill in ((Character)player).GetSkills().GetSkillList())
{
if (skill.m_info.m_skill == skillType)
{
return skill;
}
}
return null;
}
}
[HarmonyPatch(typeof(Character), "Damage")]
public class BloodMagic_BuffUpdate_Patch
{
private static void Postfix(Character __instance, HitData hit)
{
if ((Object)(object)__instance != (Object)null && __instance.IsMonsterFaction(0f))
{
Character attacker = hit.GetAttacker();
if ((Object)(object)attacker != (Object)null && attacker.IsTamed())
{
WaitForSecondsAsync(0.1f);
}
}
}
private static async Task WaitForSecondsAsync(float seconds)
{
await Task.Delay((int)(Math.Max(0f, seconds) * 1000f));
if (PlayerUtils.skillStatusEffects.TryGetValue((SkillType)10, out var nameHash))
{
Player_RaiseSkill_Patch.updateSkillTypeBuff(Player.m_localPlayer, (SkillType)10, nameHash);
}
}
}
[HarmonyPatch(typeof(SkillsDialog), "Setup")]
[HarmonyPriority(100)]
public class SkillsDialogAdditions_Patch
{
public static int azSorted;
public static int levelSorted;
private static bool init;
private static void Postfix(SkillsDialog __instance, ref Player player, ref List<GameObject> ___m_elements)
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
List<Skill> skillList = ((Character)player).GetSkills().GetSkillList();
for (int i = 0; i < skillList.Count; i++)
{
GameObject val = ___m_elements[i];
Skill val2 = skillList[i];
string text = PlayerUtils.GetCurrentSkillLevelProgress(val2).ToString();
((Component)Utils.FindChild(val.transform, "leveltext", (IterativeSearchType)0)).GetComponent<TMP_Text>().text = text;
string text2 = ((object)(SkillType)(ref val2.m_info.m_skill)).ToString();
int valueSafe = GeneralExtensions.GetValueSafe<SkillType, int>(PlayerUtils.skillStatusEffects, val2.m_info.m_skill);
StatusEffect statusEffect = ((Character)player).GetSEMan().GetStatusEffect(valueSafe);
if ((Object)(object)statusEffect != (Object)null)
{
PlayerUtils.setSkillRowBackgroundColor(val, ConfigurationFile.colorSkillBackground.Value);
statusEffect.m_name = "$skill_" + ((object)(SkillType)(ref val2.m_info.m_skill)).ToString().ToLower() + ": " + text;
}
else
{
PlayerUtils.setSkillRowBackgroundColor(val, new Color(0f, 0f, 0f, 0f));
}
}
if (!init)
{
Transform val3 = ((Component)((Component)InventoryGui.instance.m_skillsDialog).transform.Find("SkillsFrame")).transform.Find("Closebutton");
Button component = ((Component)val3).GetComponent<Button>();
azButton(component);
levelButton(component);
init = true;
}
}
private static void azButton(Button baseButton)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
GameObject val = Object.Instantiate<GameObject>(((Component)baseButton).gameObject, ((Component)baseButton).transform.parent);
((Object)val).name = "AZButton";
RectTransform component = val.GetComponent<RectTransform>();
component.anchoredPosition = new Vector2(-133f, 633f);
component.sizeDelta = new Vector2(50f, 35f);
TMP_Text buttonText = val.GetComponentInChildren<TMP_Text>();
buttonText.text = ((azSorted != 1) ? "A-Z" : "Z-A");
Button component2 = val.GetComponent<Button>();
component2.onClick = new ButtonClickedEvent();
((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
{
Logger.Log("AZButton clicked.");
levelSorted = 0;
if (azSorted != 1)
{
azSorted = 1;
buttonText.text = "Z-A";
}
else
{
azSorted = 2;
buttonText.text = "A-Z";
}
InventoryGui.instance.m_skillsDialog.Setup(Player.m_localPlayer);
});
}
private static void levelButton(Button baseButton)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
GameObject val = Object.Instantiate<GameObject>(((Component)baseButton).gameObject, ((Component)baseButton).transform.parent);
((Object)val).name = "LevelButton";
RectTransform component = val.GetComponent<RectTransform>();
component.anchoredPosition = new Vector2(133f, 633f);
component.sizeDelta = new Vector2(50f, 35f);
TMP_Text buttonText = val.GetComponentInChildren<TMP_Text>();
buttonText.text = ((levelSorted != 1) ? "1-100" : "100-1");
Button component2 = val.GetComponent<Button>();
component2.onClick = new ButtonClickedEvent();
((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
{
Logger.Log("LevelButton clicked.");
azSorted = 0;
if (levelSorted != 1)
{
levelSorted = 1;
buttonText.text = "100-1";
}
else
{
levelSorted = 2;
buttonText.text = "1-100";
}
InventoryGui.instance.m_skillsDialog.Setup(Player.m_localPlayer);
});
}
}
[HarmonyPatch(typeof(InventoryGui), "Show")]
public class InventoryGui_Show_Patch
{
private static void Postfix(InventoryGui __instance)
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)__instance.m_player != (Object)null))
{
return;
}
Transform obj = ((Component)__instance).transform.Find("root");
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
Transform obj3 = ((Component)obj).transform.Find("Info");
obj2 = ((obj3 != null) ? ((Component)obj3).transform.Find("Skills") : null);
}
Transform val = (Transform)obj2;
if (!((Object)(object)val != (Object)null))
{
return;
}
UITooltip component = ((Component)val).GetComponent<UITooltip>();
if ((Object)(object)component != (Object)null)
{
string text = "$inventory_skills";
string text2 = $" ({ConfigurationFile.hotKey.Value})";
component.m_text = text + text2;
}
if (PlayerSkillupOptionsPatch.panel == null)
{
return;
}
PlayerSkillupOptionsPatch.reloadTexts();
GameObject panel = PlayerSkillupOptionsPatch.panel.getPanel();
if (panel != null)
{
GameObject gameObject = panel.gameObject;
if (gameObject != null)
{
gameObject.SetActive(false);
}
}
}
}
[HarmonyPatch(typeof(Skills), "GetSkillList")]
public static class SkillsDialog_GetSkillListSorted_Patch
{
private static void Postfix(ref List<Skill> __result)
{
if (SkillsDialogAdditions_Patch.azSorted == 1)
{
Logger.Log("SkillsDialog_SkillStatusEffects_Patch.Postfix aZsorted = 1");
__result.Sort((Skill a, Skill b) => a.GetSkillTranslation().CompareTo(b.GetSkillTranslation()));
}
else if (SkillsDialogAdditions_Patch.azSorted == 2)
{
Logger.Log("SkillsDialog_SkillStatusEffects_Patch.Postfix aZsorted = 2");
__result.Sort((Skill a, Skill b) => b.GetSkillTranslation().CompareTo(a.GetSkillTranslation()));
}
else if (SkillsDialogAdditions_Patch.levelSorted == 1)
{
Logger.Log("SkillsDialog_SkillStatusEffects_Patch.Postfix levelSorted = 1");
__result.Sort((Skill a, Skill b) => PlayerUtils.GetCurrentSkillLevelProgress(a).CompareTo(PlayerUtils.GetCurrentSkillLevelProgress(b)));
}
else if (SkillsDialogAdditions_Patch.levelSorted == 2)
{
Logger.Log("SkillsDialog_SkillStatusEffects_Patch.Postfix levelSorted = 2");
__result.Sort((Skill a, Skill b) => PlayerUtils.GetCurrentSkillLevelProgress(b).CompareTo(PlayerUtils.GetCurrentSkillLevelProgress(a)));
}
}
private static string GetSkillTranslation(this Skill skill)
{
return Localization.instance.Localize("$skill_" + ((object)(SkillType)(ref skill.m_info.m_skill)).ToString().ToLower());
}
}
[HarmonyPatch(typeof(Player), "OnSkillLevelup")]
internal class Player_Skillup_Patch
{
private static void Postfix(ref SkillType skill, ref float level)
{
int num = Math.Max(1, Math.Min(100, ConfigurationFile.skillUpBigMessageAfterMultipleLevel.Value));
if ((int)level % num == 0 || (int)level == 100)
{
MessageHud.instance.ShowBiomeFoundMsg($"$skill_{((object)(SkillType)(ref skill)).ToString().ToLower()}: {(int)level}", true);
return;
}
int num2 = Math.Max(1, Math.Min(100, ConfigurationFile.skillUpMessageAfterMultipleLevel.Value));
if ((int)level % num2 == 0)
{
MessageHud.instance.ShowMessage((MessageType)2, $"$msg_skillup $skill_{((object)(SkillType)(ref skill)).ToString().ToLower()}: {(int)level}", 0, (Sprite)null);
}
}
}
public class PlayerUtils
{
private static Dictionary<string, Sprite> cachedSprites = new Dictionary<string, Sprite>();
public static Dictionary<SkillType, int> skillStatusEffects = new Dictionary<SkillType, int>();
public static float GetCurrentSkillLevelProgress(Skill skill)
{
float accumulator = skill.m_accumulator;
int num = (int)skill.m_level;
float num2 = num;
float levelPercentage = skill.GetLevelPercentage();
if (accumulator > 0f)
{
num2 = (float)Math.Round((float)num + levelPercentage, Math.Min(15, Math.Max(0, ConfigurationFile.numberOfDecimals.Value)));
}
float nextLevelRequirement = GetNextLevelRequirement(skill);
Logger.Log("******* " + ((object)(SkillType)(ref skill.m_info.m_skill)).ToString() + " *********");
Logger.Log($"skillLevel: {skill.m_level}, skillLevelRounded: {num}, accumulator: {accumulator}");
Logger.Log($"nextLevelRequirement: {nextLevelRequirement}, levelPercentage: {levelPercentage}, levelText: {num2}");
return num2;
}
private static float GetNextLevelRequirement(Skill skill)
{
MethodInfo method = ((object)skill).GetType().GetMethod("GetNextLevelRequirement", BindingFlags.Instance | BindingFlags.NonPublic);
return (method != null) ? ((float)method.Invoke(skill, new object[0])) : 0f;
}
public static void setSkillRowBackgroundColor(GameObject skillRow, Color color)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_001c: Unknown result type (might be due to invalid IL or missing references)
ColorBlock colors = ((Selectable)skillRow.GetComponentInChildren<Button>()).colors;
((ColorBlock)(ref colors)).normalColor = color;
((Selectable)skillRow.GetComponentInChildren<Button>()).colors = colors;
}
public static string GetValueForNameHash(Skill skill)
{
return ((object)(SkillType)(ref skill.m_info.m_skill)).ToString();
}
public static int GetValueForHashCode(Skill skill)
{
return GetValueForNameHash(skill).GetHashCode();
}
public static int GetValueForHashCode(SkillType skillType)
{
return ((object)(SkillType)(ref skillType)).ToString().GetHashCode();
}
public static Sprite getSprite(string name)
{
if (!cachedSprites.ContainsKey(name))
{
Logger.Log("Finding " + name + " sprite...");
Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>();
foreach (Sprite val in array)
{
if (((Object)val).name == name)
{
Logger.Log(name + " sprite found.");
cachedSprites.Add(name, val);
return val;
}
}
Logger.Log(name + " sprite NOT found.");
return null;
}
return GeneralExtensions.GetValueSafe<string, Sprite>(cachedSprites, name);
}
}
}
namespace DetailedLevels.Config
{
public class CustomSkillOptionsPanel
{
private GameObject panel;
private TextMeshProUGUI titleText;
private TMP_Text buttonText;
public CustomSkillOptionsPanel(Transform copyForCloseButton)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Expected O, but got Unknown
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Expected O, but got Unknown
panel = new GameObject("CustomSkillOptionsPanel", new Type[1] { typeof(RectTransform) });
panel.SetActive(false);
panel.transform.SetParent(((Component)((Component)InventoryGui.instance.m_skillsDialog).transform.Find("SkillsFrame")).transform, false);
RectTransform component = panel.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(512f, 512f);
component.anchoredPosition = new Vector2(0f, 0f);
Image val = panel.AddComponent<Image>();
val.sprite = PlayerUtils.getSprite("woodpanel_512x512");
val.type = (Type)1;
GameObject val2 = new GameObject("Title", new Type[1] { typeof(TextMeshProUGUI) });
val2.transform.SetParent(panel.transform, false);
titleText = val2.GetComponent<TextMeshProUGUI>();
((TMP_Text)titleText).fontSize = 24f;
((Graphic)titleText).color = Color.white;
((TMP_Text)titleText).alignment = (TextAlignmentOptions)514;
RectTransform component2 = val2.GetComponent<RectTransform>();
component2.anchoredPosition = new Vector2(0f, 220f);
Transform val3 = ((Component)((Component)InventoryGui.instance.m_skillsDialog).transform.Find("SkillsFrame")).transform.Find("Closebutton");
GameObject val4 = Object.Instantiate<GameObject>(((Component)val3).gameObject, copyForCloseButton);
((Object)val4).name = "DLOptionsCloseButton";
val4.transform.SetParent(panel.transform, false);
RectTransform component3 = val4.GetComponent<RectTransform>();
component3.anchoredPosition = new Vector2(0f, 40f);
buttonText = val4.GetComponentInChildren<TMP_Text>();
Button component4 = val4.GetComponent<Button>();
component4.onClick = new ButtonClickedEvent();
((UnityEvent)component4.onClick).AddListener((UnityAction)delegate
{
panel.SetActive(false);
InventoryGui.instance.m_skillsDialog.Setup(Player.m_localPlayer);
});
reloadTexts();
}
public GameObject getPanel()
{
return panel;
}
public void reloadTexts()
{
((TMP_Text)titleText).text = Localization.instance.Localize("$button_ps_start");
buttonText.text = Localization.instance.Localize("$menu_close");
}
}
}