using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using PEAKLib.UI; using PEAKLib.UI.Elements; using PEAKUsageSkills.Config; using PEAKUsageSkills.Core; using PEAKUsageSkills.Diagnostics; using PEAKUsageSkills.Effects; using PEAKUsageSkills.GameAdapters; using PEAKUsageSkills.GameAdapters.Patches; using PEAKUsageSkills.Localization; using PEAKUsageSkills.Persistence; using PEAKUsageSkills.Tracking; using PEAKUsageSkills.UI; using Peak.Afflictions; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core.Serizalization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PEAKUsageSkills")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.7.0")] [assembly: AssemblyInformationalVersion("0.4.7+ff2a3c774b0d6323303de590055096131c3b177a")] [assembly: AssemblyProduct("PEAKUsageSkills")] [assembly: AssemblyTitle("PEAKUsageSkills")] [assembly: AssemblyVersion("0.4.7.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 PEAKUsageSkills { [BepInPlugin("com.chiseled.peak.usageskills", "Elin's PEAK", "0.4.7")] [BepInProcess("PEAK.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.chiseled.peak.usageskills"; public const string PluginName = "Elin's PEAK"; public const string PluginVersion = "0.4.7"; private Harmony? harmony; internal static UsageSkillsConfig Settings { get; private set; } internal static RunStateAdapter RunState { get; private set; } internal static ProgressionService Progression { get; private set; } internal static EffectService Effects { get; private set; } internal static DiagnosticHub? Diagnostics { get; private set; } internal static ManualLogSource ModLog { get; private set; } private void Awake() { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown ModLog = ((BaseUnityPlugin)this).Logger; Settings = new UsageSkillsConfig(((BaseUnityPlugin)this).Config); LocalizationService.Initialize(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? Paths.PluginPath); RunState = new RunStateAdapter(Settings); SaveStore store = new SaveStore(((BaseUnityPlugin)this).Logger); Progression = new ProgressionService(Settings, store, ((BaseUnityPlugin)this).Logger, RunState); Effects = new EffectService(Settings, Progression, RunState); Diagnostics = new DiagnosticHub(((BaseUnityPlugin)this).Logger, Settings, RunState, Progression, Effects); Progression.LevelChanged += OnSkillLevelChanged; harmony = new Harmony("com.chiseled.peak.usageskills"); PatchAllFailSoft(Assembly.GetExecutingAssembly()); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); PauseMenuIntegration.Register(); SceneManager.sceneLoaded += OnSceneLoaded; InspectPatchHealth(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Elin's PEAK 0.4.7 loaded. Save levels are player-owned; Airport XP is disabled and anti-farming policy is deferred for the first runtime pass."); } private void Update() { Progression.Tick(); Diagnostics?.Tick(); } private void OnApplicationQuit() { Progression.Flush(); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; Progression.LevelChanged -= OnSkillLevelChanged; PauseMenuIntegration.Unregister(); LocalizationService.Shutdown(); Progression.Flush(); Harmony? obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) Progression.Flush(); ModLog.LogInfo((object)$"[UsageSkills:Scene] loaded={((Scene)(ref scene)).name} mode={mode} xpEligible={RunState.IsExperienceEligible}"); } private static void OnSkillLevelChanged(SkillId skillId, int level) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (skillId == SkillId.Strength && Settings.DebugAllSkillLevelOverride.Value < 0) { WeightPatch.RefreshLocalWeight($"StrengthLevel:{level}"); InventorySkillService.EnsureBackpackCapacity(InventorySkillService.TryGetEquippedBackpackData(Character.localCharacter, out var backpackType), backpackType, $"StrengthLevel:{level}"); } } private static void InspectPatchHealth() { RecordHook("StaminaCapacity", typeof(Character), "GetMaxStamina"); RecordHook("PassOutThreshold", typeof(CharacterAfflictions), "get_shouldPassOut"); RecordHook("PassOutRecovery", typeof(Character), "HandlePassedOut"); RecordHook("StaminaCost", typeof(Character), "UseStamina"); RecordHook("StaminaRegen", typeof(Character), "UpdateVariablesFixed"); RecordHook("StaminaHud", typeof(StaminaBar), "Update"); RecordHook("Weight", typeof(CharacterAfflictions), "UpdateWeight"); RecordHook("WallClimbing", typeof(CharacterClimbing), "GetRequestedPostition"); RecordHook("RopeClimbing", typeof(CharacterRopeHandling), "Update"); RecordHook("VineClimbing", typeof(CharacterVineClimbing), "FixedUpdate"); RecordHook("Athletics", typeof(CharacterMovement), "GetMovementForce"); RecordHook("Agility", typeof(CharacterMovement), "JumpRpc"); RecordHook("NormalFalls", typeof(CharacterMovement), "CheckFallDamage"); RecordHook("WallFalls", typeof(CharacterClimbing), "CheckFallDamage"); RecordHook("Afflictions", typeof(CharacterAfflictions), "AddStatus"); RecordHook("ConditionRecovery", typeof(CharacterAfflictions), "SubtractStatus"); RecordHook("Petrification", typeof(CharacterAfflictions), "AddPetrify", new Type[1] { typeof(int) }); RecordHook("BackpackInventory", typeof(BackpackData), "DeserializeValue"); RecordHook("BackpackWheel", typeof(BackpackWheel), "InitWheel"); RecordHook("WetGrip", typeof(WindChillZone), "ApplyStatus"); } private void PatchAllFailSoft(Assembly assembly) { Type[] types = assembly.GetTypes(); Array.Sort(types, (Type left, Type right) => string.CompareOrdinal(left.FullName, right.FullName)); Type[] array = types; foreach (Type type in array) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0) { try { harmony.CreateClassProcessor(type).Patch(); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"[UsageSkills:Patch] Failed patch class {type.FullName}; its adapter will remain disabled. {arg}"); } } } } private static void RecordHook(string adapter, Type type, string methodName, Type[]? parameterTypes = null) { MethodInfo methodInfo = ((parameterTypes == null) ? AccessTools.Method(type, methodName, (Type[])null, (Type[])null) : AccessTools.Method(type, methodName, parameterTypes, (Type[])null)); int num; if (methodInfo != null) { Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo); num = ((patchInfo != null && patchInfo.Owners.Contains("com.chiseled.peak.usageskills")) ? 1 : 0); } else { num = 0; } bool healthy = (byte)num != 0; string hook = ((parameterTypes == null) ? (type.FullName + "." + methodName) : (type.FullName + "." + methodName + "(" + string.Join(",", Array.ConvertAll(parameterTypes, (Type value) => value.Name)) + ")")); Diagnostics?.RecordPatchHealth(adapter, healthy, hook); } } } namespace PEAKUsageSkills.UI { internal sealed class DebugOverlay : MonoBehaviour { private GUIStyle? labelStyle; private void OnGUI() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Settings.EnableMod.Value && Plugin.Settings.ShowDebugOverlay.Value && Plugin.Diagnostics != null) { if (labelStyle == null) { labelStyle = new GUIStyle(GUI.skin.label) { fontSize = 14, wordWrap = false, richText = false, alignment = (TextAnchor)0 }; labelStyle.normal.textColor = Color.white; } Rect val = default(Rect); ((Rect)(ref val))..ctor(18f, 18f, 820f, 420f); GUI.Box(val, GUIContent.none); GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 12f, ((Rect)(ref val)).y + 10f, ((Rect)(ref val)).width - 24f, ((Rect)(ref val)).height - 20f)); GUILayout.Label(Plugin.Diagnostics.BuildOverlayText(), labelStyle, Array.Empty()); GUILayout.EndArea(); } } } internal static class PauseMenuIntegration { [CompilerGenerated] private static class <>O { public static Action <0>__OnLanguageChanged; public static BuilderDelegate <1>__BuildPauseMenu; } private const string RootObjectName = "UI_PEAKUsageSkills_ReleasePanels"; private const float PanelWidth = 390f; private const float HeaderHeight = 56f; private const float RowHeight = 32f; private static readonly Color MainPanelColor = new Color(0.66f, 0.09f, 0.15f, 1f); private static readonly Color ResiliencyPanelColor = new Color(0.08f, 0.3f, 0.68f, 1f); private static RectTransform? activeRoot; private static readonly SkillId[] MainSkills = new SkillId[10] { SkillId.Strength, SkillId.Endurance, SkillId.WallClimbing, SkillId.RopeClimbing, SkillId.VineClimbing, SkillId.Athletics, SkillId.Agility, SkillId.Vitality, SkillId.WetGrip, SkillId.ClimbingTenacity }; private static readonly SkillId[] ResiliencySkills = new SkillId[8] { SkillId.Toxicology, SkillId.ColdTolerance, SkillId.HeatTolerance, SkillId.DrowsyTolerance, SkillId.SporeTolerance, SkillId.HungerTolerance, SkillId.CurseTolerance, SkillId.PetrificationResistance }; public static void Register() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown LocalizationService.LanguageChanged += OnLanguageChanged; object obj = <>O.<1>__BuildPauseMenu; if (obj == null) { BuilderDelegate val = BuildPauseMenu; <>O.<1>__BuildPauseMenu = val; obj = (object)val; } MenuAPI.AddToPauseMenu((BuilderDelegate)obj); } public static void Unregister() { LocalizationService.LanguageChanged -= OnLanguageChanged; activeRoot = null; } private static void BuildPauseMenu(Transform parent) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00ff: Unknown result type (might be due to invalid IL or missing references) RemoveLegacyControls(parent); Transform val = parent.Find("UI_PEAKUsageSkills_ReleasePanels"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } RectTransform component = new GameObject("UI_PEAKUsageSkills_ReleasePanels", new Type[2] { typeof(RectTransform), typeof(SkillPanelRefresher) }).GetComponent(); ((Transform)component).SetParent(parent, false); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; activeRoot = component; BuildSection(component, "Main", LocalizationService.Get("section.main"), MainSkills, MainPanelColor, new Vector2(24f, -88f), alignRight: false); BuildSection(component, "Resiliency", LocalizationService.Get("section.resiliency"), ResiliencySkills, ResiliencyPanelColor, new Vector2(24f, -88f - SectionHeight(MainSkills.Length) - 18f), alignRight: false); SkillTooltip.Create(component); Refresh(component); Plugin.ModLog.LogInfo((object)"[UsageSkills:UI] release skill panels built; values refresh once when the pause UI opens"); } private static void BuildSection(RectTransform root, string sectionName, string title, SkillId[] skills, Color panelColor, Vector2 offset, bool alignRight) { //IL_004d: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) PeakMenuButton val = MenuAPI.CreatePauseMenuButton(title); ((Object)((Component)val).gameObject).name = "UI_PEAKUsageSkills_Section_" + sectionName; RectTransform component = ((Component)val).GetComponent(); ((Transform)component).SetParent((Transform)(object)root, false); Vector2 anchorMin = (component.anchorMax = (alignRight ? new Vector2(1f, 1f) : new Vector2(0f, 1f))); component.anchorMin = anchorMin; component.pivot = (alignRight ? new Vector2(1f, 1f) : new Vector2(0f, 1f)); component.anchoredPosition = offset; component.sizeDelta = new Vector2(390f, SectionHeight(skills.Length)); LayoutElement component2 = ((Component)val).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.ignoreLayout = true; } ConfigurePanelGraphics(val, panelColor); Button[] componentsInChildren = ((Component)val).GetComponentsInChildren