using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; using WKStaminaDisplay.MonoBehaviours; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("WKStaminaDisplay")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("WKStaminaDisplay")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("75012409-a45a-429e-91fc-9f5d10da9cac")] [assembly: AssemblyFileVersion("1.0.2")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.2.0")] namespace WKStaminaDisplay { [BepInPlugin("com.overmet15.WKStaminaDisplay", "WKStaminaDisplay", "1.0.2")] public class Plugin : BaseUnityPlugin { private const string guid = "com.overmet15.WKStaminaDisplay"; private const string pluginName = "WKStaminaDisplay"; public const string versionString = "1.0.2"; public static ConfigEntry staminaDistanceFromCenter; public static ConfigEntry staminaSliderTransitionEnabled; public static ConfigEntry staminaTransitionSpeed; public static ConfigEntry staminaBackgroundColor; public static ConfigEntry staminaFillColor; public static UnityEvent onConfigChange = new UnityEvent(); private void Awake() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) staminaDistanceFromCenter = ((BaseUnityPlugin)this).Config.Bind("General", "Stamina Slider Distance From Center", 150, (ConfigDescription)null); staminaSliderTransitionEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Stamina Slider Transiotion Enabled", true, (ConfigDescription)null); staminaTransitionSpeed = ((BaseUnityPlugin)this).Config.Bind("General", "Stamina Slider Transition Speed", 0.25f, (ConfigDescription)null); staminaBackgroundColor = ((BaseUnityPlugin)this).Config.Bind("General", "Stamina Slider BG color", new Color(1f, 1f, 1f, 0.025f), (ConfigDescription)null); staminaFillColor = ((BaseUnityPlugin)this).Config.Bind("General", "Stamina Slider Fill color", new Color(1f, 1f, 1f, 0.05f), (ConfigDescription)null); ((ConfigEntryBase)staminaDistanceFromCenter).ConfigFile.SettingChanged += OnConfigChanged; SceneManager.sceneLoaded += OnSceneLoaded; ((BaseUnityPlugin)this).Logger.LogInfo((object)"WKStaminaDisplay v1.0.2 is loaded."); } private void OnConfigChanged(object sender, EventArgs e) { SettingChangedEventArgs val = (SettingChangedEventArgs)(object)((e is SettingChangedEventArgs) ? e : null); if (val != null) { onConfigChange.Invoke(); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00e5: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.FindGameObjectWithTag("Player"); if ((Object)(object)val == (Object)null) { return; } ENT_Player val2 = Object.FindObjectOfType(); if (!Object.op_Implicit((Object)(object)val2)) { ((BaseUnityPlugin)this).Logger.LogError((object)"ENT_Player component not found, returning."); return; } GameObject val3 = GameObject.Find("GameManager/Canvas/Game UI"); if ((Object)(object)val3 != (Object)null) { Transform transform = val3.transform; bool flag = true; Hand[] hands = val2.hands; foreach (Hand hand in hands) { GameObject val4 = null; try { val4 = new GameObject("Hand Slider", new Type[1] { typeof(RectTransform) }); val4.transform.SetParent(transform, false); RectTransform component = val4.GetComponent(); component.sizeDelta = new Vector2(20f, 75f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = new Vector2((float)(flag ? (-staminaDistanceFromCenter.Value) : staminaDistanceFromCenter.Value), 0f); Image val5 = val4.AddComponent(); ((Graphic)val5).color = staminaBackgroundColor.Value; GameObject val6 = new GameObject("Hand Slider Fill Parent", new Type[1] { typeof(RectTransform) }); val6.transform.SetParent(val4.transform, false); RectTransform component2 = val6.GetComponent(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; GameObject val7 = new GameObject("Hand Slider Fill", new Type[1] { typeof(RectTransform) }); val7.transform.SetParent(val6.transform, false); RectTransform component3 = val7.GetComponent(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(2.5f, 2.5f); component3.offsetMax = new Vector2(-2.5f, -2.5f); Image val8 = val7.AddComponent(); ((Graphic)val8).color = staminaFillColor.Value; Slider val9 = val4.AddComponent(); val9.direction = (Direction)2; val9.fillRect = component3; val4.AddComponent().Setup(hand, val9, flag); flag = false; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Exception on creating slider, destroying the slider if not null..\n Exception: " + ex.Message)); if ((Object)(object)val4 != (Object)null) { Object.Destroy((Object)(object)val4); } } } } else { ((BaseUnityPlugin)this).Logger.LogError((object)"Canvas not found. Returning."); } } } } namespace WKStaminaDisplay.MonoBehaviours { public class StaminaSlider : MonoBehaviour { private Hand hand; private RectTransform rectTransform; private Slider slider; private CanvasGroup canvasGroup; private bool hidden; private bool isLeft; private void Start() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) canvasGroup = ((Component)this).gameObject.AddComponent(); hidden = true; canvasGroup.alpha = 0f; rectTransform = ((Component)this).GetComponent(); Plugin.onConfigChange.AddListener(new UnityAction(OnConfigChange)); if (!Plugin.staminaSliderTransitionEnabled.Value) { ForceInPlace(); } else { rectTransform.anchoredPosition = Vector2.zero; } } public void Update() { if (hand == null || (Object)(object)slider == (Object)null) { return; } slider.maxValue = hand.GetPlayer().GetCurrentGripStrengthTimer(-1); slider.value = hand.gripStrength; if (Plugin.staminaSliderTransitionEnabled.Value) { if (hidden && hand.gripStrength < slider.maxValue) { Toggle(); } else if (!hidden && hand.gripStrength >= slider.maxValue) { Toggle(); } } } public void Setup(Hand hand, Slider slider, bool isLeft) { this.hand = hand; this.slider = slider; this.isLeft = isLeft; slider.maxValue = hand.gripStrength; } private void Toggle() { hidden = !hidden; int num = Plugin.staminaDistanceFromCenter.Value; if (isLeft) { num *= -1; } if (hidden) { TweenSettingsExtensions.SetEase>(DOTweenModuleUI.DOFade(canvasGroup, 0f, 0.25f), (Ease)12); TweenSettingsExtensions.SetEase>(DOTweenModuleUI.DOAnchorPosX(rectTransform, (float)(num + ((num < 0) ? 75 : (-75))), Plugin.staminaTransitionSpeed.Value, false), (Ease)12); } else { TweenSettingsExtensions.SetEase>(DOTweenModuleUI.DOFade(canvasGroup, 1f, 0.25f), (Ease)12); TweenSettingsExtensions.SetEase>(DOTweenModuleUI.DOAnchorPosX(rectTransform, (float)num, Plugin.staminaTransitionSpeed.Value, false), (Ease)12); } } private void OnConfigChange() { //IL_0043: 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) if (!Plugin.staminaSliderTransitionEnabled.Value) { ForceInPlace(); } else if (!hidden) { hidden = true; Toggle(); } ((Graphic)((Component)this).GetComponent()).color = Plugin.staminaBackgroundColor.Value; ((Graphic)((Component)((Component)this).transform.GetChild(0).GetChild(0)).GetComponent()).color = Plugin.staminaFillColor.Value; } private void ForceInPlace() { //IL_0031: 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) int num = Plugin.staminaDistanceFromCenter.Value; if (isLeft) { num *= -1; } canvasGroup.alpha = 1f; Vector2 anchoredPosition = rectTransform.anchoredPosition; ((Vector2)(ref anchoredPosition)).Set((float)num, 0f); } private void OnDestroy() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Plugin.onConfigChange.RemoveListener(new UnityAction(OnConfigChange)); } } }