using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.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 PeakStaminaHost
{
internal static class ExtraBarUI
{
private sealed class CloneAffliction
{
public RectTransform rtf;
public Image icon;
public STATUSTYPE type;
public bool isPetrify;
public float desired;
public TextMeshProUGUI number;
}
private static bool _built;
private static bool _wasOn;
private static StaminaBar _src;
private static GameObject _clone;
private static RectTransform _cloneRoot;
private static RectTransform _fullBar;
private static RectTransform _maxStaminaRt;
private static RectTransform _staminaRt;
private static Image _fillImage;
private static TextMeshProUGUI _numberText;
private static RectTransform _outlineRt;
private static RectTransform _overflowLine;
private static readonly List<CloneAffliction> _affs = new List<CloneAffliction>();
public static void Tick(StaminaBar bar)
{
bool extraBar = SyncState.ExtraBar;
if (extraBar != _wasOn)
{
_wasOn = extraBar;
if (!extraBar && (Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.bar != (Object)null)
{
GUIManager.instance.bar.ChangeBar();
}
}
if (!extraBar || (Object)(object)bar == (Object)null)
{
if ((Object)(object)_clone != (Object)null)
{
_clone.SetActive(false);
}
return;
}
if (_built && ((Object)(object)_clone == (Object)null || (Object)(object)_src == (Object)null))
{
ResetState();
}
if (_built || Build(bar))
{
if (!_clone.activeSelf)
{
_clone.SetActive(true);
}
Drive();
}
}
private static bool Build(StaminaBar bar)
{
//IL_00b3: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
_built = true;
_src = bar;
RectTransform component = ((Component)bar).GetComponent<RectTransform>();
if ((Object)(object)component == (Object)null)
{
return false;
}
_clone = Object.Instantiate<GameObject>(((Component)bar).gameObject, ((Transform)component).parent);
((Object)_clone).name = "PeakExtraBar";
_cloneRoot = _clone.GetComponent<RectTransform>();
StaminaBar component2 = _clone.GetComponent<StaminaBar>();
if ((Object)(object)component2 != (Object)null)
{
Object.Destroy((Object)(object)component2);
}
Transform[] componentsInChildren = _clone.GetComponentsInChildren<Transform>(true);
foreach (Transform val in componentsInChildren)
{
if (((Object)val).name == "StaminaInfo")
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
Rect rect = component.rect;
float height = ((Rect)(ref rect)).height;
((Transform)_cloneRoot).localPosition = ((Transform)component).localPosition + new Vector3(0f, 0f - (height + 6f), 0f);
Transform obj = _clone.transform.Find("FullBar");
_fullBar = (RectTransform)(object)((obj is RectTransform) ? obj : null);
Transform obj2 = _clone.transform.Find("LayoutGroup/MaxStamina");
_maxStaminaRt = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null);
Transform obj3 = _clone.transform.Find("LayoutGroup/MaxStamina/Back/Stamina");
_staminaRt = (RectTransform)(object)((obj3 is RectTransform) ? obj3 : null);
Transform obj4 = _clone.transform.Find("OutlineMask/Outline");
_outlineRt = (RectTransform)(object)((obj4 is RectTransform) ? obj4 : null);
Transform obj5 = _clone.transform.Find("OutlineOverflowLine");
_overflowLine = (RectTransform)(object)((obj5 is RectTransform) ? obj5 : null);
if ((Object)(object)_overflowLine != (Object)null)
{
_overflowLine.anchorMin = new Vector2(0f, 0.5f);
_overflowLine.anchorMax = new Vector2(0f, 0.5f);
_overflowLine.pivot = new Vector2(0.5f, 0.5f);
_overflowLine.anchoredPosition = new Vector2(0f, 0f);
((Component)_overflowLine).gameObject.SetActive(false);
}
Transform val2 = _clone.transform.Find("LayoutGroup/MaxStamina/Back/Stamina/Fill");
if ((Object)(object)val2 != (Object)null)
{
_fillImage = ((Component)val2).GetComponent<Image>();
if ((Object)(object)_fillImage != (Object)null)
{
((Graphic)_fillImage).color = new Color(0.9411765f, 0.5882353f, 0.23529412f, 1f);
}
}
BuildNumber();
BarAffliction[] componentsInChildren2 = _clone.GetComponentsInChildren<BarAffliction>(true);
foreach (BarAffliction val3 in componentsInChildren2)
{
CloneAffliction cloneAffliction = new CloneAffliction
{
rtf = val3.rtf,
icon = val3.icon,
type = val3.afflictionType,
isPetrify = val3.isPetrify
};
if (!val3.isPetrify)
{
cloneAffliction.number = CreateNumber(val3.rtf, 16f, "PeakAfflictionNumber");
}
_affs.Add(cloneAffliction);
Object.Destroy((Object)(object)val3);
}
LayoutRebuilder.ForceRebuildLayoutImmediate(_cloneRoot);
HorizontalLayoutGroup componentInChildren = _clone.GetComponentInChildren<HorizontalLayoutGroup>();
if ((Object)(object)componentInChildren != (Object)null)
{
((Behaviour)componentInChildren).enabled = false;
}
ContentSizeFitter[] componentsInChildren3 = _clone.GetComponentsInChildren<ContentSizeFitter>(true);
for (int i = 0; i < componentsInChildren3.Length; i++)
{
((Behaviour)componentsInChildren3[i]).enabled = false;
}
return true;
}
private static void BuildNumber()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_staminaRt == (Object)null) && !((Object)(object)GUIManager.instance == (Object)null) && !((Object)(object)GUIManager.instance.heroDayText == (Object)null))
{
GameObject val = new GameObject("PeakExtraBarNumber");
val.transform.SetParent((Transform)(object)_staminaRt, false);
_numberText = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)_numberText).font = ((TMP_Text)GUIManager.instance.heroDayText).font;
((TMP_Text)_numberText).fontSize = 20f;
((TMP_Text)_numberText).alignment = (TextAlignmentOptions)514;
((TMP_Text)_numberText).textWrappingMode = (TextWrappingModes)0;
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.pivot = new Vector2(0.5f, 0.5f);
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
((Transform)component).localScale = Vector3.one;
((TMP_Text)_numberText).text = "";
}
}
private static TextMeshProUGUI CreateNumber(RectTransform parent, float fontSize, string goName)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_0078: 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)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: 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)
if ((Object)(object)parent == (Object)null || (Object)(object)GUIManager.instance == (Object)null || (Object)(object)GUIManager.instance.heroDayText == (Object)null)
{
return null;
}
GameObject val = new GameObject(goName);
val.transform.SetParent((Transform)(object)parent, false);
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).font = ((TMP_Text)GUIManager.instance.heroDayText).font;
((TMP_Text)val2).fontSize = fontSize;
((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0;
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.pivot = new Vector2(0.5f, 0.5f);
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
((Transform)component).localScale = Vector3.one;
((TMP_Text)val2).text = "";
return val2;
}
private static void Drive()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
Character observedCharacter = Character.observedCharacter;
if ((Object)(object)observedCharacter == (Object)null || observedCharacter.refs == null || (Object)(object)observedCharacter.refs.afflictions == (Object)null || (Object)(object)_fullBar == (Object)null)
{
return;
}
CharacterAfflictions afflictions = observedCharacter.refs.afflictions;
float num = SyncState.ExtraBarCap;
if (num <= 0f)
{
num = 0.5f;
}
Rect rect = _fullBar.rect;
float num2 = ((Rect)(ref rect)).width;
if (num2 <= 0f)
{
num2 = _fullBar.sizeDelta.x;
}
float lerp = Mathf.Min(Time.deltaTime * 10f, 0.1f);
float statusSum = afflictions.statusSum;
float num3 = Mathf.Clamp01(num - statusSum);
float targetW = num3 * num2;
SetWidth(_maxStaminaRt, targetW, lerp);
SetWidth(_staminaRt, targetW, lerp);
if ((Object)(object)_numberText != (Object)null)
{
((TMP_Text)_numberText).text = Mathf.Round(num3 * 100f).ToString();
}
float targetW2 = 14f + Mathf.Max(num, statusSum) * num2;
SetWidth(_outlineRt, targetW2, lerp);
if ((Object)(object)_overflowLine != (Object)null)
{
bool flag = statusSum > num * 1.005f;
((Component)_overflowLine).gameObject.SetActive(flag);
if (flag)
{
Vector2 anchoredPosition = _overflowLine.anchoredPosition;
anchoredPosition.x = num * num2;
_overflowLine.anchoredPosition = anchoredPosition;
}
}
foreach (CloneAffliction aff in _affs)
{
if (aff.isPetrify)
{
((Component)aff.rtf).gameObject.SetActive(false);
continue;
}
float currentStatus = afflictions.GetCurrentStatus(aff.type);
bool flag2 = currentStatus > 0.001f;
((Component)aff.rtf).gameObject.SetActive(flag2);
if ((Object)(object)aff.number != (Object)null)
{
((Component)aff.number).gameObject.SetActive(flag2);
}
if (flag2)
{
aff.desired = currentStatus * num2;
SetWidth(aff.rtf, aff.desired, lerp);
if ((Object)(object)aff.number != (Object)null)
{
((TMP_Text)aff.number).text = Mathf.Round(currentStatus * 100f).ToString();
}
}
}
LayoutChildren();
}
private static void LayoutChildren()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_maxStaminaRt == (Object)null)
{
return;
}
SetLeft(_maxStaminaRt, 0f);
float num = _maxStaminaRt.sizeDelta.x;
foreach (CloneAffliction aff in _affs)
{
if (!aff.isPetrify && ((Component)aff.rtf).gameObject.activeSelf)
{
SetLeft(aff.rtf, num);
num += aff.rtf.sizeDelta.x;
}
}
}
private static void SetLeft(RectTransform rt, float left)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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)
Vector2 anchoredPosition = rt.anchoredPosition;
anchoredPosition.x = left + rt.sizeDelta.x * rt.pivot.x;
rt.anchoredPosition = anchoredPosition;
}
private static void SetWidth(RectTransform rt, float targetW, float lerp)
{
//IL_000b: 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_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)rt == (Object)null))
{
Vector2 sizeDelta = rt.sizeDelta;
sizeDelta.x = Mathf.Lerp(sizeDelta.x, targetW, lerp);
rt.sizeDelta = sizeDelta;
}
}
private static void ResetState()
{
_built = false;
_src = null;
_clone = null;
_cloneRoot = null;
_fullBar = null;
_maxStaminaRt = null;
_staminaRt = null;
_fillImage = null;
_numberText = null;
_outlineRt = null;
_overflowLine = null;
_affs.Clear();
}
}
[HarmonyPatch(typeof(Character), "GetMaxStamina")]
internal static class Patch_GetMaxStamina
{
private static void Postfix(Character __instance, ref float __result)
{
if (__instance.IsLocal)
{
float num = SyncState.MaxMultiplier;
if (num <= 0f)
{
num = 1f;
}
if (SyncState.ExtraBar)
{
__result = Mathf.Max(1f * num, 0f);
}
else
{
__result = Mathf.Max(__result * num, 0f);
}
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "get_shouldPassOut")]
internal static class Patch_ShouldPassOut
{
private static bool Prefix(ref bool __result, CharacterAfflictions __instance)
{
if (!SyncState.ExtraBar)
{
return true;
}
float num = SyncState.ExtraBarCap;
if (num <= 0f)
{
num = 0.5f;
}
__result = __instance.statusSum > num;
return false;
}
}
[HarmonyPatch(typeof(Character), "HandlePassedOut")]
internal static class Patch_HandlePassedOut
{
private static void Prefix(Character __instance)
{
if (SyncState.ExtraBar && __instance.refs != null && !((Object)(object)__instance.refs.afflictions == (Object)null))
{
float num = SyncState.ExtraBarCap;
if (num <= 0f)
{
num = 0.5f;
}
if (__instance.refs.afflictions.statusSum >= num)
{
__instance.data.lastPassedOut = Time.time;
}
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "get_canGetHungry")]
internal static class Patch_CanGetHungry
{
private static void Postfix(ref bool __result)
{
if (SyncState.NoHunger)
{
__result = false;
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")]
internal static class Patch_AddStatus
{
private static bool Prefix(STATUSTYPE statusType)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
if (SyncState.GodMode && (int)statusType != 5 && (int)statusType != 13)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Character), "RPCA_Die")]
internal static class Patch_RPCADie
{
private static bool Prefix()
{
return !SyncState.GodMode;
}
}
[HarmonyPatch(typeof(Character), "DieInstantly")]
internal static class Patch_DieInstantly
{
private static bool Prefix()
{
return !SyncState.GodMode;
}
}
[HarmonyPatch(typeof(Character), "Die")]
internal static class Patch_Die
{
private static bool Prefix()
{
return !SyncState.GodMode;
}
}
[HarmonyPatch(typeof(Character), "Start")]
internal static class Patch_CharacterStart
{
private static void Postfix(Character __instance)
{
StaminaSyncComp.EnsureRegistered(__instance);
}
}
[HarmonyPatch(typeof(Character), "UseStamina")]
internal static class Patch_UseStamina
{
private static bool Prefix(ref bool __result)
{
if (SyncState.Infinite)
{
__result = true;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(BarAffliction), "ChangeAffliction")]
internal static class Patch_BarAffliction_Change
{
private static void Postfix(BarAffliction __instance)
{
if (SyncState.ExtraBar && !__instance.isPetrify)
{
((Component)__instance).gameObject.SetActive(false);
}
}
}
[HarmonyPatch(typeof(StaminaBar), "Update")]
[HarmonyPriority(600)]
internal static class Patch_StaminaBar
{
private static float _smoothStam;
private static float _smoothMax;
private static Character _smoothCh;
private static void Postfix(StaminaBar __instance)
{
DriveBarsProportional(__instance);
ExtraBarUI.Tick(__instance);
DriveOriginalBarFrame(__instance);
}
private static void DriveOriginalBarFrame(StaminaBar bar)
{
//IL_000e: 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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
if (!SyncState.ExtraBar)
{
return;
}
float x = bar.fullBar.sizeDelta.x;
if (!(x <= 0f))
{
float num = SyncState.MaxMultiplier;
if (num <= 0f)
{
num = 1f;
}
Vector2 sizeDelta = bar.staminaBarOutline.sizeDelta;
sizeDelta.x = 14f + Mathf.Clamp01(num) * x;
bar.staminaBarOutline.sizeDelta = sizeDelta;
((Component)bar.staminaBarOutlineOverflowBar).gameObject.SetActive(false);
}
}
private static void DriveBarsProportional(StaminaBar bar)
{
//IL_0016: 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_00c2: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: 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_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: 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_015e: Unknown result type (might be due to invalid IL or missing references)
Character observedCharacter = Character.observedCharacter;
if ((Object)(object)observedCharacter == (Object)null)
{
return;
}
float x = bar.fullBar.sizeDelta.x;
if (!(x <= 0f))
{
float num = Mathf.Clamp01(observedCharacter.GetMaxStamina()) * x;
float num2 = Mathf.Clamp01(observedCharacter.data.currentStamina) * x;
if ((Object)(object)_smoothCh != (Object)(object)observedCharacter)
{
_smoothCh = observedCharacter;
_smoothMax = num;
_smoothStam = num2;
}
else
{
float num3 = Mathf.Min(Time.deltaTime * 10f, 1f);
_smoothMax = Mathf.Lerp(_smoothMax, num, num3);
_smoothStam = Mathf.Lerp(_smoothStam, num2, num3);
}
bar.maxStaminaBar.sizeDelta = new Vector2(_smoothMax, bar.maxStaminaBar.sizeDelta.y);
bar.staminaBar.sizeDelta = new Vector2(_smoothStam, bar.staminaBar.sizeDelta.y);
Transform val = ((Transform)bar.staminaBar).Find("StaminaInfo");
if ((Object)(object)val != (Object)null)
{
RectTransform val2 = (RectTransform)val;
val2.anchorMin = Vector2.zero;
val2.anchorMax = new Vector2(0f, 1f);
val2.pivot = new Vector2(0f, 0.5f);
val2.anchoredPosition = Vector2.zero;
val2.sizeDelta = new Vector2(_smoothStam, 0f);
}
}
}
}
internal static class PeakStatsExPatch
{
public static void Apply(Harmony harmony)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
try
{
Type type = AccessTools.TypeByName("PeakStatsEx.MonoBehaviours.CharacterStaminaBar") ?? AccessTools.TypeByName("PeakStatsEx.CharacterStaminaBar");
if (type == null)
{
StaminaHostPlugin.Log.LogInfo((object)"[PeakStatsEx] 未检测到 CharacterStaminaBar,跳过头顶条钳制(未安装 PeakStatsEx 时属正常)。");
return;
}
MethodInfo methodInfo = AccessTools.Method(type, "UpdateStaminaBar", (Type[])null, (Type[])null);
if (methodInfo == null)
{
StaminaHostPlugin.Log.LogWarning((object)"[PeakStatsEx] 找到类但未找到 UpdateStaminaBar 方法,兼容补丁未挂载。");
return;
}
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(PeakStatsExPatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
StaminaHostPlugin.Log.LogInfo((object)"[PeakStatsEx] 已挂载队友头顶条钳制补丁。");
}
catch (Exception arg)
{
StaminaHostPlugin.Log.LogError((object)$"[PeakStatsEx] 挂载兼容补丁失败:{arg}");
}
}
private static void Postfix(object __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
Traverse val = new Traverse(__instance);
RectTransform value = val.Field("fullBarRectTransform").GetValue<RectTransform>();
if (!((Object)(object)value == (Object)null))
{
float x = value.sizeDelta.x;
if (!(x <= 0f))
{
ClampWidth(val.Field("staminaBarRectTransform").GetValue<RectTransform>(), x);
ClampWidth(val.Field("maxStaminaBarRectTransform").GetValue<RectTransform>(), x);
}
}
}
private static void ClampWidth(RectTransform rt, float frameW)
{
//IL_000b: 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_0011: 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_003a: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)rt == (Object)null))
{
Vector2 sizeDelta = rt.sizeDelta;
float num = Mathf.Clamp(sizeDelta.x, 0f, frameW);
if (!Mathf.Approximately(num, sizeDelta.x))
{
sizeDelta.x = num;
rt.sizeDelta = sizeDelta;
}
}
}
}
[BepInPlugin("com.peakstaminahost.mod", "PeakStaminaHost", "1.11.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class StaminaHostPlugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
internal ConfigEntry<string> _capPercent;
internal ConfigEntry<bool> _hostInfinite;
internal ConfigEntry<bool> _noHunger;
internal ConfigEntry<bool> _godMode;
internal ConfigEntry<bool> _extraBar;
internal ConfigEntry<string> _extraBarCapPercent;
internal ConfigEntry<KeyCode> _menuHotkey;
private bool _pending;
private bool _wasInRoom;
private bool _noHungerApplied;
private bool _suppressConfigEvents;
private const string ModPropKey = "PSH_Mod_v";
private bool _propMarked;
private bool _pollInit;
private string _lastCap;
private string _lastExtraCap;
private bool _lastInfinite;
private bool _lastNoHunger;
private bool _lastGodMode;
private bool _lastExtra;
public void Awake()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Expected O, but got Unknown
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Expected O, but got Unknown
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Expected O, but got Unknown
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Expected O, but got Unknown
//IL_01da: 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: Expected O, but got Unknown
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
_capPercent = ((BaseUnityPlugin)this).Config.Bind<string>("体力上限", "上限倍率(%)", "100", new ConfigDescription("所有玩家体力上限倍率(房主改,全房生效)。文本框直接输入百分数:2.5=原版2.5%(一丝)、100=原版、200=2倍、500=5倍,每2.5都能调。输入值÷100即倍率。", (AcceptableValueBase)null, Array.Empty<object>()));
_hostInfinite = ((BaseUnityPlugin)this).Config.Bind<bool>("体力上限", "全房无限体力", false, new ConfigDescription("开启后全房玩家攀爬不消耗体力(等效游戏内置无限体力),体力条保持满格。", (AcceptableValueBase)null, Array.Empty<object>()));
_noHunger = ((BaseUnityPlugin)this).Config.Bind<bool>("免伤/免饥饿", "免饥饿", false, new ConfigDescription("开启后全房角色饥饿状态不再累加,且不因饥饿压体力上限、不晕倒/饿死。", (AcceptableValueBase)null, Array.Empty<object>()));
_godMode = ((BaseUnityPlugin)this).Config.Bind<bool>("免伤/免饥饿", "免伤无敌", false, new ConfigDescription("开启后全房角色不受伤害性状态累加、不会死亡。适合配合一丝体力玩纯体力挑战。", (AcceptableValueBase)null, Array.Empty<object>()));
_extraBar = ((BaseUnityPlugin)this).Config.Bind<bool>("独立负面条", "独立负面条", true, new ConfigDescription("开(默认):负重/饥饿/伤害等负面条独立于体力条、不压体力上限,负面条满到下方「独立负面条上限」才倒地——拿再重的道具体力上限也不缩,更轻松爬山。\n关:贴体力条(原版)——负面条压体力上限,体力条低于负面条就倒地。", (AcceptableValueBase)null, Array.Empty<object>()));
_extraBarCapPercent = ((BaseUnityPlugin)this).Config.Bind<string>("独立负面条", "独立负面条上限(%)", "50", new ConfigDescription("仅独立负面条开启时生效。文本框输入负面条倒地阈值:50=负面条到一半倒下(默认)、100=几乎不因负面倒下(最宽松)、10=很严。范围10-100,输入超范围自动钳制。", (AcceptableValueBase)null, Array.Empty<object>()));
_menuHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("快捷键", "设置菜单呼出键", (KeyCode)289, new ConfigDescription("游戏中按该键呼出本插件独立设置面板(开关/文本框直接调,自动锁定人物并显示鼠标),再按一次或按 ESC 关闭。默认 F8,可在此改成任意键。", (AcceptableValueBase)null, Array.Empty<object>()));
_capPercent.SettingChanged += delegate(object _, EventArgs e)
{
OnSettingChanged("上限倍率", e);
};
_hostInfinite.SettingChanged += delegate(object _, EventArgs e)
{
OnSettingChanged("全房无限", e);
};
_noHunger.SettingChanged += delegate(object _, EventArgs e)
{
OnSettingChanged("免饥饿", e);
};
_godMode.SettingChanged += delegate(object _, EventArgs e)
{
OnSettingChanged("免伤", e);
};
_extraBar.SettingChanged += delegate(object _, EventArgs e)
{
OnSettingChanged("独立负面条", e);
};
_extraBarCapPercent.SettingChanged += delegate(object _, EventArgs e)
{
OnSettingChanged("独立上限", e);
};
Harmony val = new Harmony("com.peakstaminahost.mod");
val.PatchAll(Assembly.GetExecutingAssembly());
PeakStatsExPatch.Apply(val);
((Component)this).gameObject.AddComponent<RoomCallbacks>();
((Component)this).gameObject.AddComponent<QuickMenuController>();
Log.LogInfo((object)string.Format("{0} v{1} loaded。配置在 暂停菜单 → MOD SETTINGS(ModConfig 自动收集),或按 {2} 呼出独立面板;联机仅房主改配置并广播全房。", "PeakStaminaHost", "1.11.1", _menuHotkey.Value));
}
private void Update()
{
if (SyncState.NoHunger && !_noHungerApplied)
{
_noHungerApplied = true;
ClearLocalHunger();
}
else if (!SyncState.NoHunger)
{
_noHungerApplied = false;
}
bool inRoom = PhotonNetwork.InRoom;
if (inRoom && !_wasInRoom)
{
_wasInRoom = true;
_pending = true;
}
if (!inRoom && _wasInRoom)
{
_wasInRoom = false;
_propMarked = false;
}
if (inRoom && !_propMarked)
{
EnsureModProperty();
}
bool flag = HasLocalAuthority();
if (flag && PollConfigChanged())
{
_pending = true;
}
else if (!flag)
{
SyncConfigEntriesFromState();
}
if (_pending)
{
ApplyLocal();
_pending = false;
if (inRoom && PhotonNetwork.IsMasterClient && (Object)(object)Character.localCharacter != (Object)null)
{
Broadcast();
}
}
}
private void OnSettingChanged(string label, EventArgs e)
{
if (!_suppressConfigEvents)
{
EventArgs obj = ((e is SettingChangedEventArgs) ? e : null);
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
ConfigEntryBase changedSetting = ((SettingChangedEventArgs)obj).ChangedSetting;
obj2 = ((changedSetting != null) ? changedSetting.BoxedValue : null);
}
object arg = obj2;
if (!HasLocalAuthority())
{
Log.LogInfo((object)$"[权限] 非房主不可修改设置,已忽略 {label} 的本地改动(本地值={arg})");
SyncConfigEntriesFromState();
}
else
{
Log.LogInfo((object)$"[配置变更] {label} 新值={arg}");
_pending = true;
}
}
}
private bool HasLocalAuthority()
{
if (!PhotonNetwork.InRoom)
{
return true;
}
if (PhotonNetwork.IsMasterClient)
{
return true;
}
return !MasterHasMod();
}
private static bool MasterHasMod()
{
Player masterClient = PhotonNetwork.MasterClient;
if (masterClient != null && masterClient.CustomProperties != null)
{
return ((Dictionary<object, object>)(object)masterClient.CustomProperties).ContainsKey((object)"PSH_Mod_v");
}
return false;
}
private void EnsureModProperty()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
Hashtable val = new Hashtable { [(object)"PSH_Mod_v"] = "1.11.1" };
if (PhotonNetwork.LocalPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null))
{
_propMarked = true;
Log.LogInfo((object)"[标记] 已写入 mod 玩家属性 PSH_Mod_v=1.11.1");
}
}
private bool PollConfigChanged()
{
if (!_pollInit)
{
_pollInit = true;
_lastCap = _capPercent.Value;
_lastExtraCap = _extraBarCapPercent.Value;
_lastInfinite = _hostInfinite.Value;
_lastNoHunger = _noHunger.Value;
_lastGodMode = _godMode.Value;
_lastExtra = _extraBar.Value;
return false;
}
bool result = false;
if (_capPercent.Value != _lastCap)
{
_lastCap = _capPercent.Value;
Log.LogInfo((object)("[轮询检测] 上限倍率实际值变化=" + _lastCap));
result = true;
}
if (_hostInfinite.Value != _lastInfinite)
{
_lastInfinite = _hostInfinite.Value;
Log.LogInfo((object)$"[轮询检测] 全房无限实际值变化={_lastInfinite}");
result = true;
}
if (_noHunger.Value != _lastNoHunger)
{
_lastNoHunger = _noHunger.Value;
Log.LogInfo((object)$"[轮询检测] 免饥饿实际值变化={_lastNoHunger}");
result = true;
}
if (_godMode.Value != _lastGodMode)
{
_lastGodMode = _godMode.Value;
Log.LogInfo((object)$"[轮询检测] 免伤实际值变化={_lastGodMode}");
result = true;
}
if (_extraBar.Value != _lastExtra)
{
_lastExtra = _extraBar.Value;
Log.LogInfo((object)$"[轮询检测] 独立负面条实际值变化={_lastExtra}");
result = true;
}
if (_extraBarCapPercent.Value != _lastExtraCap)
{
_lastExtraCap = _extraBarCapPercent.Value;
Log.LogInfo((object)("[轮询检测] 独立上限实际值变化=" + _lastExtraCap));
result = true;
}
return result;
}
private void ApplyLocal()
{
SyncState.MaxMultiplier = ParseMultiplier(_capPercent.Value);
SyncState.Infinite = _hostInfinite.Value;
SyncState.NoHunger = _noHunger.Value;
SyncState.GodMode = _godMode.Value;
SyncState.ExtraBar = _extraBar.Value;
SyncState.ExtraBarCap = ParseExtraCap(_extraBarCapPercent.Value);
Log.LogInfo((object)$"[ApplyLocal] 倍率={SyncState.MaxMultiplier} 无限={SyncState.Infinite} 免饥饿={SyncState.NoHunger} 免伤={SyncState.GodMode} 独立={SyncState.ExtraBar} 独立上限={SyncState.ExtraBarCap}");
SyncConfigEntriesFromState();
}
private void SyncConfigEntriesFromState()
{
_suppressConfigEvents = true;
try
{
SetString(_capPercent, (SyncState.MaxMultiplier * 100f).ToString("0.##", CultureInfo.InvariantCulture));
SetString(_extraBarCapPercent, (SyncState.ExtraBarCap * 100f).ToString("0.##", CultureInfo.InvariantCulture));
SetBool(_hostInfinite, SyncState.Infinite);
SetBool(_noHunger, SyncState.NoHunger);
SetBool(_godMode, SyncState.GodMode);
SetBool(_extraBar, SyncState.ExtraBar);
}
finally
{
_suppressConfigEvents = false;
}
}
private static void SetString(ConfigEntry<string> entry, string value)
{
if (entry.Value != value)
{
entry.Value = value;
}
}
private static void SetBool(ConfigEntry<bool> entry, bool value)
{
if (entry.Value != value)
{
entry.Value = value;
}
}
private void Broadcast()
{
if (!((Object)(object)Character.localCharacter == (Object)null))
{
PhotonView val = ((Character.localCharacter.refs != null) ? Character.localCharacter.refs.view : ((MonoBehaviourPun)Character.localCharacter).photonView);
if (!((Object)(object)val == (Object)null))
{
float num = ParseMultiplier(_capPercent.Value);
float num2 = ParseExtraCap(_extraBarCapPercent.Value);
val.RPC("RPC_SetStaminaMultiplier", (RpcTarget)0, new object[6] { num, _hostInfinite.Value, _noHunger.Value, _godMode.Value, _extraBar.Value, num2 });
SyncState.MaxMultiplier = num;
SyncState.Infinite = _hostInfinite.Value;
SyncState.NoHunger = _noHunger.Value;
SyncState.GodMode = _godMode.Value;
SyncState.ExtraBar = _extraBar.Value;
SyncState.ExtraBarCap = num2;
}
}
}
private static void ClearLocalHunger()
{
Character localCharacter = Character.localCharacter;
if ((Object)(object)localCharacter != (Object)null && localCharacter.refs != null && (Object)(object)localCharacter.refs.afflictions != (Object)null)
{
localCharacter.refs.afflictions.SetStatus((STATUSTYPE)1, 0f, true);
}
}
private static float ParseMultiplier(string s)
{
if (float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && result > 0f)
{
if (result > 500f)
{
result = 500f;
}
return result / 100f;
}
return 1f;
}
private static float ParseExtraCap(string s)
{
if (float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && result > 0f)
{
return Mathf.Clamp(result / 100f, 0.1f, 1f);
}
return 0.5f;
}
internal void ReBroadcastToRoom()
{
Broadcast();
}
}
internal sealed class RoomCallbacks : MonoBehaviourPunCallbacks
{
public override void OnPlayerEnteredRoom(Player newPlayer)
{
if (PhotonNetwork.IsMasterClient)
{
((Component)this).GetComponent<StaminaHostPlugin>()?.ReBroadcastToRoom();
}
}
}
internal static class PluginInfo
{
public const string GUID = "com.peakstaminahost.mod";
public const string Name = "PeakStaminaHost";
public const string Version = "1.11.1";
}
internal sealed class QuickMenuController : MonoBehaviour
{
private sealed class BoolRow
{
public string label;
public ConfigEntry<bool> entry;
public Button button;
public TextMeshProUGUI buttonText;
public Image buttonImage;
}
private sealed class TextRow
{
public string label;
public ConfigEntry<string> entry;
public TMP_InputField input;
}
private static readonly MethodInfo OpenMethod = typeof(MenuWindow).GetMethod("Open", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly MethodInfo CloseMethod = typeof(MenuWindow).GetMethod("Close", BindingFlags.Instance | BindingFlags.NonPublic);
private StaminaHostPlugin _plugin;
private TMP_FontAsset _font;
private GameObject _root;
private RectTransform _panel;
private QuickMenuWindow _window;
private BoolRow[] _bools;
private TextRow[] _texts;
private bool _isOpen;
private void Awake()
{
_plugin = ((Component)this).GetComponent<StaminaHostPlugin>();
}
private void Update()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_plugin == (Object)null)
{
return;
}
if (Input.GetKeyDown(_plugin._menuHotkey.Value))
{
if (_isOpen)
{
CloseMenu();
}
else
{
OpenMenu();
}
}
if (_isOpen)
{
RefreshValues();
}
}
private void OpenMenu()
{
BuildIfNeeded();
if (!((Object)(object)_root == (Object)null) && !((Object)(object)_window == (Object)null))
{
RefreshValues();
OpenMethod?.Invoke(_window, null);
_isOpen = true;
}
}
private void CloseMenu()
{
if ((Object)(object)EventSystem.current != (Object)null)
{
EventSystem.current.SetSelectedGameObject((GameObject)null);
}
CloseMethod?.Invoke(_window, null);
_isOpen = false;
}
private void BuildIfNeeded()
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: 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_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: 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_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Expected O, but got Unknown
//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Unknown result type (might be due to invalid IL or missing references)
//IL_044a: Unknown result type (might be due to invalid IL or missing references)
//IL_0459: Unknown result type (might be due to invalid IL or missing references)
//IL_0472: Unknown result type (might be due to invalid IL or missing references)
//IL_0498: Unknown result type (might be due to invalid IL or missing references)
//IL_04a2: Expected O, but got Unknown
if ((Object)(object)_root != (Object)null)
{
return;
}
_font = GetFont();
if ((Object)(object)_font == (Object)null)
{
return;
}
GameObject val = new GameObject("PSH_QuickMenu", new Type[4]
{
typeof(RectTransform),
typeof(Canvas),
typeof(CanvasScaler),
typeof(GraphicRaycaster)
});
val.transform.SetParent(((Component)this).transform, false);
Canvas component = val.GetComponent<Canvas>();
component.renderMode = (RenderMode)0;
component.sortingOrder = 9999;
CanvasScaler component2 = val.GetComponent<CanvasScaler>();
component2.uiScaleMode = (ScaleMode)1;
component2.referenceResolution = new Vector2(1920f, 1080f);
component2.screenMatchMode = (ScreenMatchMode)0;
component2.matchWidthOrHeight = 0.5f;
_window = val.AddComponent<QuickMenuWindow>();
GameObject val2 = NewUIObject("Panel", val.transform);
_panel = val2.GetComponent<RectTransform>();
_panel.anchoredPosition = Vector2.zero;
_panel.sizeDelta = new Vector2(580f, 500f);
((Graphic)val2.AddComponent<Image>()).color = new Color(0.09f, 0.1f, 0.12f, 0.97f);
MakeText("Title", (Transform)(object)_panel, "PeakStaminaHost 设置", 30f, new Vector2(0f, 205f), new Vector2(540f, 44f), (TextAlignmentOptions)514, Color.white);
_bools = new BoolRow[4]
{
new BoolRow
{
label = "独立负面条",
entry = _plugin._extraBar
},
new BoolRow
{
label = "全房无限体力",
entry = _plugin._hostInfinite
},
new BoolRow
{
label = "免饥饿",
entry = _plugin._noHunger
},
new BoolRow
{
label = "免伤无敌",
entry = _plugin._godMode
}
};
float[] array = new float[4] { 140f, 88f, 36f, -16f };
for (int i = 0; i < _bools.Length; i++)
{
MakeLabel(_panel, _bools[i].label, array[i]);
Button val3 = MakeButton((Transform)(object)_panel, new Vector2(120f, array[i]), new Vector2(200f, 44f), new Color(0.4f, 0.22f, 0.24f, 1f));
_bools[i].button = val3;
_bools[i].buttonImage = ((Component)val3).GetComponent<Image>();
_bools[i].buttonText = ((Component)val3).GetComponentInChildren<TextMeshProUGUI>();
BoolRow row = _bools[i];
((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
{
row.entry.Value = !row.entry.Value;
});
}
_texts = new TextRow[2]
{
new TextRow
{
label = "体力上限(%)",
entry = _plugin._capPercent
},
new TextRow
{
label = "独立条上限(%)",
entry = _plugin._extraBarCapPercent
}
};
float[] array2 = new float[2] { -68f, -120f };
for (int num = 0; num < _texts.Length; num++)
{
MakeLabel(_panel, _texts[num].label, array2[num]);
TMP_InputField val4 = MakeInputField((Transform)(object)_panel, new Vector2(120f, array2[num]), new Vector2(200f, 44f));
_texts[num].input = val4;
TextRow row2 = _texts[num];
((UnityEvent<string>)(object)val4.onEndEdit).AddListener((UnityAction<string>)delegate(string v)
{
row2.entry.Value = v;
});
}
Button obj = MakeButton((Transform)(object)_panel, new Vector2(0f, -195f), new Vector2(200f, 46f), new Color(0.2f, 0.28f, 0.42f, 1f));
((TMP_Text)((Component)obj).GetComponentInChildren<TextMeshProUGUI>()).text = "关闭 (ESC)";
((UnityEvent)obj.onClick).AddListener(new UnityAction(CloseMenu));
_root = val;
_root.SetActive(false);
}
private void RefreshValues()
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
BoolRow[] bools = _bools;
foreach (BoolRow obj in bools)
{
bool value = obj.entry.Value;
((TMP_Text)obj.buttonText).text = (value ? "开 ON" : "关 OFF");
((Graphic)obj.buttonImage).color = (value ? new Color(0.18f, 0.52f, 0.27f, 1f) : new Color(0.4f, 0.22f, 0.24f, 1f));
}
TextRow[] texts = _texts;
foreach (TextRow textRow in texts)
{
if (!textRow.input.isFocused && textRow.input.text != textRow.entry.Value)
{
textRow.input.text = textRow.entry.Value;
}
}
}
private TMP_FontAsset GetFont()
{
if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.heroDayText != (Object)null)
{
return ((TMP_Text)GUIManager.instance.heroDayText).font;
}
return TMP_Settings.defaultFontAsset;
}
private GameObject NewUIObject(string name, Transform parent)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
val.transform.SetParent(parent, false);
return val;
}
private void MakeLabel(RectTransform parent, string text, float y)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
MakeText(text, (Transform)(object)parent, text, 20f, new Vector2(-270f, y), new Vector2(240f, 44f), (TextAlignmentOptions)513, Color.white, new Vector2(0f, 0.5f));
}
private TextMeshProUGUI MakeText(string name, Transform parent, string text, float fontSize, Vector2 anchoredPos, Vector2 size, TextAlignmentOptions align, Color color, Vector2 pivot = default(Vector2))
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
GameObject val = NewUIObject(name, parent);
TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)obj).font = _font;
((TMP_Text)obj).fontSize = fontSize;
((TMP_Text)obj).text = text;
((TMP_Text)obj).alignment = align;
((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0;
((Graphic)obj).color = color;
RectTransform component = val.GetComponent<RectTransform>();
component.pivot = (Vector2)((pivot == default(Vector2)) ? new Vector2(0.5f, 0.5f) : pivot);
component.anchoredPosition = anchoredPos;
component.sizeDelta = size;
return obj;
}
private Button MakeButton(Transform parent, Vector2 pos, Vector2 size, Color bgColor)
{
//IL_0013: 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)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
GameObject val = NewUIObject("Button", parent);
((Graphic)val.AddComponent<Image>()).color = bgColor;
Button result = val.AddComponent<Button>();
RectTransform component = val.GetComponent<RectTransform>();
component.anchoredPosition = pos;
component.sizeDelta = size;
GameObject obj = NewUIObject("Label", val.transform);
TextMeshProUGUI obj2 = obj.AddComponent<TextMeshProUGUI>();
((TMP_Text)obj2).font = _font;
((TMP_Text)obj2).fontSize = 20f;
((TMP_Text)obj2).alignment = (TextAlignmentOptions)514;
((TMP_Text)obj2).textWrappingMode = (TextWrappingModes)0;
RectTransform component2 = obj.GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = Vector2.zero;
component2.offsetMax = Vector2.zero;
return result;
}
private TMP_InputField MakeInputField(Transform parent, Vector2 pos, Vector2 size)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
GameObject val = NewUIObject("InputField", parent);
((Graphic)val.AddComponent<Image>()).color = new Color(0.13f, 0.14f, 0.16f, 1f);
TMP_InputField obj = val.AddComponent<TMP_InputField>();
RectTransform component = val.GetComponent<RectTransform>();
component.anchoredPosition = pos;
component.sizeDelta = size;
GameObject obj2 = NewUIObject("Text", val.transform);
TextMeshProUGUI val2 = obj2.AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).font = _font;
((TMP_Text)val2).fontSize = 20f;
((TMP_Text)val2).alignment = (TextAlignmentOptions)513;
((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0;
RectTransform component2 = obj2.GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = new Vector2(10f, 4f);
component2.offsetMax = new Vector2(-10f, -4f);
GameObject obj3 = NewUIObject("Placeholder", val.transform);
TextMeshProUGUI val3 = obj3.AddComponent<TextMeshProUGUI>();
((TMP_Text)val3).font = _font;
((TMP_Text)val3).fontSize = 20f;
((TMP_Text)val3).alignment = (TextAlignmentOptions)513;
((TMP_Text)val3).textWrappingMode = (TextWrappingModes)0;
((TMP_Text)val3).fontStyle = (FontStyles)2;
((Graphic)val3).color = new Color(1f, 1f, 1f, 0.4f);
((TMP_Text)val3).text = "输入百分数";
RectTransform component3 = obj3.GetComponent<RectTransform>();
component3.anchorMin = Vector2.zero;
component3.anchorMax = Vector2.one;
component3.offsetMin = new Vector2(10f, 4f);
component3.offsetMax = new Vector2(-10f, -4f);
obj.textComponent = (TMP_Text)(object)val2;
obj.placeholder = (Graphic)(object)val3;
obj.contentType = (ContentType)3;
obj.lineType = (LineType)0;
return obj;
}
}
internal sealed class QuickMenuWindow : MenuWindow
{
public override bool openOnStart => false;
public override bool closeOnUICancel => true;
}
public class StaminaSyncComp : MonoBehaviour
{
[PunRPC]
public void RPC_SetStaminaMultiplier(float multiplier, bool infinite, bool noHunger, bool godMode, bool extraBar, float extraBarCap)
{
SyncState.MaxMultiplier = multiplier;
SyncState.Infinite = infinite;
SyncState.NoHunger = noHunger;
SyncState.GodMode = godMode;
SyncState.ExtraBar = extraBar;
SyncState.ExtraBarCap = extraBarCap;
ManualLogSource log = StaminaHostPlugin.Log;
if (log != null)
{
log.LogInfo((object)$"[PeakStaminaHost] 收到房主设置: 倍率={multiplier}, 无限={infinite}, 免饥饿={noHunger}, 免伤={godMode}, 独立负面条={extraBar}(上限{extraBarCap})");
}
}
public static void EnsureRegistered(Character c)
{
StaminaSyncComp staminaSyncComp = ((Component)c).GetComponent<StaminaSyncComp>();
if ((Object)(object)staminaSyncComp == (Object)null)
{
staminaSyncComp = ((Component)c).gameObject.AddComponent<StaminaSyncComp>();
}
PhotonView val = ((c.refs != null) ? c.refs.view : null);
if ((Object)(object)val == (Object)null)
{
val = ((MonoBehaviourPun)c).photonView;
}
if (!((Object)(object)val == (Object)null))
{
if (val.ObservedComponents == null)
{
val.ObservedComponents = new List<Component>();
}
if (!val.ObservedComponents.Contains((Component)(object)staminaSyncComp))
{
val.ObservedComponents.Add((Component)(object)staminaSyncComp);
val.RefreshRpcMonoBehaviourCache();
}
}
}
}
internal static class SyncState
{
public static float MaxMultiplier = 1f;
public static bool Infinite = false;
public static bool NoHunger = false;
public static bool GodMode = false;
public static bool ExtraBar = true;
public static float ExtraBarCap = 0.5f;
}
}