Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of MonsterEscortGamemode v1.0.0
MonsterEscort.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using MonsterEscort.Core; using MonsterEscort.Systems; using MonsterEscort.UI; using On.RoR2; using On.RoR2.UI; using R2API.Networking; using R2API.Networking.Interfaces; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; [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("MonsterEscort")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MonsterEscort")] [assembly: AssemblyTitle("MonsterEscort")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace MonsterEscort.UI { public static class HealthBarAssets { public static Sprite BuildBackgroundSprite(int width, int height, int edgeFadePixels, int borderPixels, float borderAlphaMult) { //IL_0028: 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_0035: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) width = Mathf.Max(1, width); height = Mathf.Max(1, height); edgeFadePixels = Mathf.Clamp(edgeFadePixels, 0, Mathf.Max(0, width / 2)); Texture2D val = new Texture2D(width, height, (TextureFormat)5, false) { wrapMode = (TextureWrapMode)1 }; for (int i = 0; i < height; i++) { float num = ((i < borderPixels || i >= height - borderPixels) ? borderAlphaMult : 1f); for (int j = 0; j < width; j++) { float num2 = ((j >= edgeFadePixels) ? ((j < width - edgeFadePixels) ? 1f : ((edgeFadePixels == 0) ? 1f : ((float)(width - 1 - j) / (float)edgeFadePixels))) : ((edgeFadePixels == 0) ? 1f : ((float)j / (float)edgeFadePixels))); num2 = Mathf.Clamp01(num2 * num); val.SetPixel(j, i, new Color(1f, 1f, 1f, num2)); } } val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f); } public static Sprite BuildStressGradientSprite(int width, int height) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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) width = Mathf.Max(1, width); height = Mathf.Max(1, height); Texture2D val = new Texture2D(width, height, (TextureFormat)5, false) { wrapMode = (TextureWrapMode)1 }; Color val2 = default(Color); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { float num = (float)j / (float)(width - 1) * 0.8f; ((Color)(ref val2))..ctor(0.8f, 0.8f - num, 0f, 0.6f); val.SetPixel(j, i, val2); } } val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f); } } public class HealthBarView : MonoBehaviour { public Color BarColor = new Color(0f, 0f, 0f, 0.75f); public int EdgeFadePixels = 64; public int BorderPixels = 3; public float BorderAlphaMult = 1.1f; public Vector4 FillInset = new Vector4(4f, 2f, 4f, 2f); public Color FillColor = new Color(0.3f, 0.8f, 0.25f, 0.6f); public int StripePixels = 1; public float TopDarkenAlpha = 0.18f; public float BotLightenAlpha = 0.14f; public float LowHealthThreshold = 0.25f; public Color FlashColorA = Color.white; public Color FlashColorB = new Color(1f, 0.2f, 0.2f, 1f); public float StressHeight = 5f; public float StressGap = 3f; public float StressWidthScale = 0.8f; public float StressTrackAlpha = 0.75f; public int StressBorderPx = 1; private Image _bg; private RectTransform _mask; private RectTransform _fillContent; private Image _fillBase; private Image _stripeTop; private Image _stripeBot; private RectTransform _stressMask; private RectTransform _stressFill; private Image _stressImg; private Image _stressTrack; private float _lastFrac; private float _stressMaxWidth = 1f; public Vector2 BarSize; public Vector2 BarAnchor; public Vector2 BarPosition; public RectTransform Root { get; private set; } public HGTextMeshProUGUI LabelTMP { get; private set; } public void Build(Transform hudMainContainer) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021a: 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_0235: 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_024b: Expected O, but got Unknown //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0296: 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_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Expected O, but got Unknown //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Expected O, but got Unknown //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("EscortBarRoot"); val.transform.SetParent(hudMainContainer, false); Root = val.AddComponent<RectTransform>(); Root.pivot = new Vector2(0.5f, 1f); GameObject val2 = new GameObject("BG"); val2.transform.SetParent((Transform)(object)Root, false); _bg = val2.AddComponent<Image>(); RectTransform rectTransform = ((Graphic)_bg).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; GameObject val3 = new GameObject("FillMask"); val3.transform.SetParent((Transform)(object)Root, false); _mask = val3.AddComponent<RectTransform>(); _mask.anchorMin = Vector2.zero; _mask.anchorMax = Vector2.one; _mask.offsetMin = new Vector2(FillInset.x, FillInset.y); _mask.offsetMax = new Vector2(0f - FillInset.z, 0f - FillInset.w); val3.AddComponent<RectMask2D>(); GameObject val4 = new GameObject("FillContent"); val4.transform.SetParent((Transform)(object)_mask, false); _fillContent = val4.AddComponent<RectTransform>(); _fillContent.anchorMin = new Vector2(0f, 0f); _fillContent.anchorMax = new Vector2(0f, 1f); _fillContent.pivot = new Vector2(0f, 0.5f); _fillContent.sizeDelta = new Vector2(0f, 0f); GameObject val5 = new GameObject("Base"); val5.transform.SetParent((Transform)(object)_fillContent, false); _fillBase = val5.AddComponent<Image>(); RectTransform rectTransform2 = ((Graphic)_fillBase).rectTransform; rectTransform2.anchorMin = Vector2.zero; rectTransform2.anchorMax = Vector2.one; rectTransform2.offsetMin = Vector2.zero; rectTransform2.offsetMax = Vector2.zero; ((Graphic)_fillBase).color = FillColor; GameObject val6 = new GameObject("TopStripe"); val6.transform.SetParent((Transform)(object)_fillContent, false); _stripeTop = val6.AddComponent<Image>(); RectTransform rectTransform3 = ((Graphic)_stripeTop).rectTransform; rectTransform3.anchorMin = new Vector2(0f, 1f); rectTransform3.anchorMax = new Vector2(1f, 1f); rectTransform3.pivot = new Vector2(0.5f, 1f); rectTransform3.sizeDelta = new Vector2(0f, (float)StripePixels); rectTransform3.anchoredPosition = Vector2.zero; ((Graphic)_stripeTop).color = new Color(1f, 1f, 1f, BotLightenAlpha); GameObject val7 = new GameObject("BottomStripe"); val7.transform.SetParent((Transform)(object)_fillContent, false); _stripeBot = val7.AddComponent<Image>(); RectTransform rectTransform4 = ((Graphic)_stripeBot).rectTransform; rectTransform4.anchorMin = new Vector2(0f, 0f); rectTransform4.anchorMax = new Vector2(1f, 0f); rectTransform4.pivot = new Vector2(0.5f, 0f); rectTransform4.sizeDelta = new Vector2(0f, (float)StripePixels); rectTransform4.anchoredPosition = Vector2.zero; ((Graphic)_stripeBot).color = new Color(0f, 0f, 0f, TopDarkenAlpha); GameObject val8 = new GameObject("Label"); val8.transform.SetParent((Transform)(object)Root, false); LabelTMP = val8.AddComponent<HGTextMeshProUGUI>(); RectTransform rectTransform5 = ((TMP_Text)LabelTMP).rectTransform; rectTransform5.anchorMin = Vector2.zero; rectTransform5.anchorMax = Vector2.one; rectTransform5.offsetMin = Vector2.zero; rectTransform5.offsetMax = Vector2.zero; ((TMP_Text)LabelTMP).enableWordWrapping = false; ((TMP_Text)LabelTMP).alignment = (TextAlignmentOptions)4098; ((TMP_Text)LabelTMP).fontSize = 18f; ((Graphic)LabelTMP).raycastTarget = false; ((TMP_Text)LabelTMP).text = "TEST"; ((Graphic)LabelTMP).color = Color.white; val8.transform.SetAsLastSibling(); ApplyLayout(); BuildStressUI(); SetVisible(v: false); } public void ApplyLayout() { //IL_002d: 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_0058: 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_007a: 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) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) GetBarPosition(out BarSize, out BarAnchor, out BarPosition); if (Object.op_Implicit((Object)(object)Root)) { Root.anchorMin = BarAnchor; Root.anchorMax = BarAnchor; Root.pivot = new Vector2(0.5f, 1f); Root.sizeDelta = BarSize; Root.anchoredPosition = BarPosition; Sprite sprite = HealthBarAssets.BuildBackgroundSprite(Mathf.RoundToInt(BarSize.x), Mathf.RoundToInt(BarSize.y), EdgeFadePixels, BorderPixels, BorderAlphaMult); _bg.sprite = sprite; _bg.type = (Type)0; ((Graphic)_bg).color = BarColor; if (Object.op_Implicit((Object)(object)_mask)) { _mask.offsetMin = new Vector2(FillInset.x, FillInset.y); _mask.offsetMax = new Vector2(0f - FillInset.z, 0f - FillInset.w); } RebuildStressGradient(); SetFillFraction(_lastFrac); } } public void GetBarPosition(out Vector2 size, out Vector2 anchor, out Vector2 position) { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_003a: Unknown result type (might be due to invalid IL or missing references) size = new Vector2(1100f, 16f); anchor = new Vector2(0.5f, 1f); position = new Vector2(0f, -180f); } public void SetVisible(bool v) { if (Object.op_Implicit((Object)(object)Root)) { ((Component)Root).gameObject.SetActive(v); } } public void SetLabel(string text) { if (Object.op_Implicit((Object)(object)LabelTMP)) { ((TMP_Text)LabelTMP).text = text; } } public void SetFillFraction(float frac) { //IL_0038: 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) if (!((Object)(object)_fillContent == (Object)null)) { frac = Mathf.Clamp01(frac); _lastFrac = frac; float num; if (!Object.op_Implicit((Object)(object)_mask)) { num = 0f; } else { Rect rect = _mask.rect; num = ((Rect)(ref rect)).width * frac; } float num2 = num; _fillContent.SetSizeWithCurrentAnchors((Axis)0, num2); } } public void SetFillColor(Color c) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_fillBase)) { ((Graphic)_fillBase).color = c; } } public Color GetFillColor() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_fillBase)) { return Color.white; } return ((Graphic)_fillBase).color; } public void RebuildStressGradient() { //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) if (Object.op_Implicit((Object)(object)_stressImg) && Object.op_Implicit((Object)(object)Root)) { Rect rect = Root.rect; _stressMaxWidth = Mathf.Max(1f, ((Rect)(ref rect)).width * Mathf.Max(0f, StressWidthScale)); ((Graphic)_stressTrack).rectTransform.SetSizeWithCurrentAnchors((Axis)0, _stressMaxWidth); _stressFill.SetSizeWithCurrentAnchors((Axis)0, _stressMaxWidth); Sprite sprite = HealthBarAssets.BuildStressGradientSprite(Mathf.RoundToInt(_stressMaxWidth), Mathf.RoundToInt(StressHeight)); _stressImg.sprite = sprite; } } public void SetStressFraction(float v01) { if (Object.op_Implicit((Object)(object)_stressMask)) { _stressMask.SetSizeWithCurrentAnchors((Axis)0, _stressMaxWidth * Mathf.Clamp01(v01)); } } public void BuildStressUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_003f: 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) //IL_0069: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_0192: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0267: 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_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("StressTrack"); val.transform.SetParent((Transform)(object)Root, false); _stressTrack = val.AddComponent<Image>(); RectTransform rectTransform = ((Graphic)_stressTrack).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 0f); rectTransform.anchorMax = new Vector2(0.5f, 0f); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.sizeDelta = new Vector2(0f, StressHeight); rectTransform.anchoredPosition = new Vector2(0f, 0f - StressGap); ((Graphic)_stressTrack).color = new Color(0f, 0f, 0f, StressTrackAlpha); val.transform.SetSiblingIndex(0); GameObject val2 = new GameObject("StressMask"); val2.transform.SetParent(((Component)_stressTrack).transform, false); _stressMask = val2.AddComponent<RectTransform>(); _stressMask.anchorMin = new Vector2(0f, 0f); _stressMask.anchorMax = new Vector2(0f, 1f); _stressMask.pivot = new Vector2(0f, 0.5f); _stressMask.sizeDelta = new Vector2(0f, 0f); _stressMask.anchoredPosition = new Vector2(0f, 0f); val2.AddComponent<RectMask2D>(); GameObject val3 = new GameObject("StressFill"); val3.transform.SetParent((Transform)(object)_stressMask, false); _stressFill = val3.AddComponent<RectTransform>(); _stressFill.anchorMin = new Vector2(0f, 0f); _stressFill.anchorMax = new Vector2(0f, 1f); _stressFill.pivot = new Vector2(0f, 0.5f); _stressFill.sizeDelta = new Vector2(0f, 0f); _stressImg = val3.AddComponent<Image>(); _stressImg.type = (Type)0; GameObject val4 = new GameObject("TopBorder"); val4.transform.SetParent(((Component)_stressTrack).transform, false); Image obj = val4.AddComponent<Image>(); RectTransform rectTransform2 = ((Graphic)obj).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 1f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.pivot = new Vector2(0.5f, 1f); rectTransform2.sizeDelta = new Vector2(0f, (float)StressBorderPx); ((Graphic)obj).color = new Color(1f, 1f, 1f, 0.08f); GameObject val5 = new GameObject("BotBorder"); val5.transform.SetParent(((Component)_stressTrack).transform, false); Image obj2 = val5.AddComponent<Image>(); RectTransform rectTransform3 = ((Graphic)obj2).rectTransform; rectTransform3.anchorMin = new Vector2(0f, 0f); rectTransform3.anchorMax = new Vector2(1f, 0f); rectTransform3.pivot = new Vector2(0.5f, 0f); rectTransform3.sizeDelta = new Vector2(0f, (float)StressBorderPx); ((Graphic)obj2).color = new Color(0f, 0f, 0f, 0.2f); RebuildStressGradient(); SetStressFraction(0f); } } } namespace MonsterEscort.Systems { public static class CameraSystem { public static void ForceSpectateAll(CharacterBody escortBody) { if (!Object.op_Implicit((Object)(object)escortBody)) { return; } Transform transform = ((Component)escortBody).transform; foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList) { Camera val = readOnlyInstances?.cameraRigController?.sceneCam; if (Object.op_Implicit((Object)(object)val)) { CameraHoldForward obj = ((Component)val).gameObject.GetComponent<CameraHoldForward>() ?? ((Component)val).gameObject.AddComponent<CameraHoldForward>(); float bodyCameraDistance = GetBodyCameraDistance(escortBody); obj.target = transform; obj.forward = bodyCameraDistance * 1.2f; obj.up = bodyCameraDistance * 0.4f; obj.right = 0f; obj.duration = 6f; } } } public static float GetBodyCameraDistance(CharacterBody body) { if (!Object.op_Implicit((Object)(object)body)) { return 6f; } return Mathf.Clamp(body.bestFitRadius * 3f, 4f, 12f); } } public class CameraHoldForward : MonoBehaviour { public Transform target; public float forward = 6f; public float up = 2f; public float right; public float duration = 5f; private Transform _parent; private Vector3 _origLocalPos; private Quaternion _origLocalRot; private float _end; private void OnEnable() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) _end = Time.unscaledTime + duration; _parent = ((Component)this).transform.parent; _origLocalPos = ((Component)this).transform.localPosition; _origLocalRot = ((Component)this).transform.localRotation; ((Component)this).transform.SetParent((Transform)null, true); } private void OnDisable() { //IL_0026: 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) if (Object.op_Implicit((Object)(object)_parent)) { ((Component)this).transform.SetParent(_parent, false); ((Component)this).transform.localPosition = _origLocalPos; ((Component)this).transform.localRotation = _origLocalRot; } } private void LateUpdate() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0047: 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_0057: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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) if (!Object.op_Implicit((Object)(object)target) || Time.unscaledTime > _end) { Object.Destroy((Object)(object)this); return; } Vector3 val = target.position + target.forward * forward + Vector3.up * up + target.right * right; Quaternion val2 = Quaternion.LookRotation(target.position - val, Vector3.up); ((Component)this).transform.SetPositionAndRotation(val, val2); } } public class HealthBarController : MonoBehaviour { public struct StressMsg : INetMessage, ISerializableObject { public uint masterId; public float value; public bool echoed; public readonly void Serialize(NetworkWriter w) { w.Write(masterId); w.Write(value); w.Write(echoed); } public void Deserialize(NetworkReader r) { masterId = r.ReadUInt32(); value = r.ReadSingle(); echoed = r.ReadBoolean(); } public void OnReceived() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { if (!echoed) { echoed = true; NetMessageExtensions.Send((INetMessage)(object)this, (NetworkDestination)1); } return; } GameObject val = ClientScene.FindLocalObject(new NetworkInstanceId(masterId)); CharacterMaster val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterMaster>() : null); if (Object.op_Implicit((Object)(object)val2)) { val2.GetBody(); } HealthBarController clientInstance = ClientInstance; if (Object.op_Implicit((Object)(object)clientInstance) && Object.op_Implicit((Object)(object)clientInstance.targetBody) && (Object)(object)clientInstance.targetBody.master == (Object)(object)val2) { clientInstance._stress01 = Mathf.Clamp01(value); } } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_Awake <>9__21_0; internal void <Init>b__21_0(orig_Awake orig, HUD self) { orig.Invoke(self); ClientInstance = ((Component)self).GetComponent<HealthBarController>() ?? ((Component)self).gameObject.AddComponent<HealthBarController>(); } } public HUD hud; public CharacterBody targetBody; public static HealthBarController ClientInstance; private HealthBarView _view; private CharacterMaster _lockedMaster; private float _nextReattachPoll; private const float UiUpdateInterval = 0.1f; private float _nextUiUpdateTime; private int _lastHP = -1; private int _lastMax = -1; private float _lastFracShown = -1f; public float HealthSmoothSpeed = 16f; public float StressSmoothSpeed = 3f; private float _hpFracTarget; private float _hpFracDisplay = -1f; private float _stress01; private float _stressDisplay; public float ScrollSensitivity = 0.05f; private float _lastSentStress = -1f; private float _nextSendAt; private float _pendingScrollDelta; public static void Init() { //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_001f: Expected O, but got Unknown object obj = <>c.<>9__21_0; if (obj == null) { hook_Awake val = delegate(orig_Awake orig, HUD self) { orig.Invoke(self); ClientInstance = ((Component)self).GetComponent<HealthBarController>() ?? ((Component)self).gameObject.AddComponent<HealthBarController>(); }; <>c.<>9__21_0 = val; obj = (object)val; } HUD.Awake += (hook_Awake)obj; NetworkingAPI.RegisterMessageType<StressMsg>(); } private void Awake() { hud = ((Component)this).GetComponent<HUD>(); _view = ((Component)hud).GetComponent<HealthBarView>(); if (!Object.op_Implicit((Object)(object)_view)) { _view = ((Component)hud).gameObject.AddComponent<HealthBarView>(); } _view.Build(hud.mainContainer.transform); _view.SetVisible(v: false); EscortState.OnEscortAssigned += OnEscortAssigned; CharacterBody.onBodyStartGlobal += OnAnyBodyStart; } private void OnDestroy() { EscortState.OnEscortAssigned -= OnEscortAssigned; CharacterBody.onBodyStartGlobal -= OnAnyBodyStart; } private void OnEscortAssigned(CharacterMaster m) { _lockedMaster = m; TryAttachToCurrentBody(); } private void OnAnyBodyStart(CharacterBody b) { if (!((Object)(object)_lockedMaster == (Object)null) && !((Object)(object)b == (Object)null)) { CharacterMaster master = b.master; if (!((Object)(object)master != (Object)(object)_lockedMaster) && IsPlayerOwnedMaster(master)) { SetTarget(b); } } } private static bool IsPlayerOwnedMaster(CharacterMaster m) { PlayerCharacterMasterController val = (Object.op_Implicit((Object)(object)m) ? m.playerCharacterMasterController : null); if ((Object)(object)val != (Object)null) { return (Object)(object)val.networkUser != (Object)null; } return false; } private void TryAttachToCurrentBody() { CharacterBody target = (Object.op_Implicit((Object)(object)_lockedMaster) ? _lockedMaster.GetBody() : null); SetTarget(target); } public void SetTarget(CharacterBody body) { targetBody = body; _view.SetVisible((Object)(object)body != (Object)null); if (Object.op_Implicit((Object)(object)body)) { HealthComponent healthComponent = body.healthComponent; float num = (_hpFracDisplay = (_hpFracTarget = ((Object.op_Implicit((Object)(object)healthComponent) && healthComponent.fullCombinedHealth > 0f) ? (healthComponent.combinedHealth / healthComponent.fullCombinedHealth) : 0f))); _view.SetFillFraction(num); _lastFracShown = num; int num2 = Mathf.CeilToInt(Object.op_Implicit((Object)(object)healthComponent) ? healthComponent.combinedHealth : 0f); int num3 = Mathf.CeilToInt(Object.op_Implicit((Object)(object)healthComponent) ? healthComponent.fullCombinedHealth : 0f); _view.SetLabel($"{num2} / {num3}"); } } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float y = Input.mouseScrollDelta.y; if (Mathf.Abs(y) > 1E-05f) { num = y; } else { float axis = Input.GetAxis("Mouse ScrollWheel"); if (Mathf.Abs(axis) > 1E-05f) { num = axis; } } if (Mathf.Abs(num) > 1E-05f) { _pendingScrollDelta += num; } } private void LateUpdate() { //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)targetBody) || !Object.op_Implicit((Object)(object)targetBody.healthComponent)) { _view.SetVisible(v: false); return; } _view.SetVisible(v: true); if (TargetControlledByLocalUser()) { float pendingScrollDelta = _pendingScrollDelta; _pendingScrollDelta = 0f; if (Mathf.Abs(pendingScrollDelta) > 1E-05f) { float num = Mathf.Clamp01(_stress01 + pendingScrollDelta * ScrollSensitivity); if (!Mathf.Approximately(num, _stress01)) { _stress01 = num; float unscaledTime = Time.unscaledTime; if (unscaledTime >= _nextSendAt && Mathf.Abs(num - _lastSentStress) >= 0.01f) { _lastSentStress = num; _nextSendAt = unscaledTime + 0.05f; CharacterMaster master = targetBody.master; StressMsg stressMsg = default(StressMsg); NetworkInstanceId netId = ((NetworkBehaviour)master).netId; stressMsg.masterId = ((NetworkInstanceId)(ref netId)).Value; stressMsg.value = num; NetMessageExtensions.Send((INetMessage)(object)stressMsg, (NetworkDestination)2); } } } } if (Time.unscaledTime >= _nextUiUpdateTime) { _nextUiUpdateTime = Time.unscaledTime + 0.1f; HealthComponent healthComponent = targetBody.healthComponent; int num2 = Mathf.CeilToInt(healthComponent.combinedHealth); int num3 = Mathf.CeilToInt(healthComponent.fullCombinedHealth); float num4 = (((float)num3 > 0f) ? (healthComponent.combinedHealth / healthComponent.fullCombinedHealth) : 0f); if (!Mathf.Approximately(num4, _lastFracShown)) { _hpFracTarget = num4; _lastFracShown = num4; } if (num2 != _lastHP || num3 != _lastMax) { _view.SetLabel($"{num2} / {num3}"); _lastHP = num2; _lastMax = num3; } } if (_hpFracDisplay < 0f) { _hpFracDisplay = _hpFracTarget; } float num5 = 1f - Mathf.Exp((0f - HealthSmoothSpeed) * Time.unscaledDeltaTime); _hpFracDisplay = Mathf.Lerp(_hpFracDisplay, _hpFracTarget, num5); _view.SetFillFraction(_hpFracDisplay); float num6 = 1f - Mathf.Exp((0f - StressSmoothSpeed) * Time.unscaledDeltaTime); _stressDisplay = Mathf.Lerp(_stressDisplay, _stress01, num6); _view.SetStressFraction(_stressDisplay); if (_lastFracShown <= _view.LowHealthThreshold) { float num7 = Mathf.PingPong(Time.unscaledTime * 6f, 1f); _view.SetFillColor(Color.Lerp(_view.FlashColorA, _view.FlashColorB, num7)); } else { _view.SetFillColor(_view.FillColor); } if (Object.op_Implicit((Object)(object)_lockedMaster) && !Object.op_Implicit((Object)(object)targetBody) && Time.unscaledTime >= _nextReattachPoll) { _nextReattachPoll = Time.unscaledTime + 0.25f; if (IsPlayerOwnedMaster(_lockedMaster)) { SetTarget(_lockedMaster.GetBody()); } } } private bool TargetControlledByLocalUser() { CharacterMaster val = (Object.op_Implicit((Object)(object)targetBody) ? targetBody.master : null); PlayerCharacterMasterController val2 = (Object.op_Implicit((Object)(object)val) ? val.playerCharacterMasterController : null); NetworkUser val3 = (Object.op_Implicit((Object)(object)val2) ? val2.networkUser : null); if (!Object.op_Implicit((Object)(object)val3)) { return false; } foreach (NetworkUser readOnlyLocalPlayers in NetworkUser.readOnlyLocalPlayersList) { if ((Object)(object)readOnlyLocalPlayers == (Object)(object)val3) { return true; } } return false; } } public static class ItemRules { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_Init <>9__0_0; internal void <Init>b__0_0(orig_Init orig) { orig.Invoke(); ItemDef extraLifeVoid = Items.ExtraLifeVoid; if (Config.RemoveLarva.Value && (Object)(object)extraLifeVoid != (Object)null) { extraLifeVoid.tier = (ItemTier)5; } } } public static void Init() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //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_001f: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { hook_Init val = delegate(orig_Init orig) { orig.Invoke(); ItemDef extraLifeVoid = Items.ExtraLifeVoid; if (Config.RemoveLarva.Value && (Object)(object)extraLifeVoid != (Object)null) { extraLifeVoid.tier = (ItemTier)5; } }; <>c.<>9__0_0 = val; obj = (object)val; } ItemCatalog.Init += (hook_Init)obj; CharacterMaster.OnBodyDeath += new hook_OnBodyDeath(OnBodyDeathReplace); } private static void OnBodyDeathReplace(orig_OnBodyDeath orig, CharacterMaster self, CharacterBody body) { if (!NetworkServer.active || (Object)(object)self == (Object)null) { orig.Invoke(self, body); return; } if (!((Object)(object)self.playerCharacterMasterController != (Object)null)) { orig.Invoke(self, body); return; } Inventory inventory = self.inventory; if ((Object)(object)inventory == (Object)null) { orig.Invoke(self, body); return; } int itemCount = inventory.GetItemCount(Items.ExtraLife); int itemCount2 = inventory.GetItemCount(Items.ExtraLifeVoid); if (itemCount > 0) { inventory.GiveItem(Items.ExtraLife, -itemCount); } if (itemCount2 > 0) { inventory.GiveItem(Items.ExtraLifeVoid, -itemCount2); } try { orig.Invoke(self, body); } finally { if (itemCount > 0) { inventory.GiveItem(Items.ExtraLife, itemCount); } if (itemCount2 > 0) { inventory.GiveItem(Items.ExtraLifeVoid, itemCount2); } } } } public static class RespawnSystem { private static TeleporterInteraction _teleporter; private static HoldoutZoneController _hz; private const float kChargedEpsilon = 0.999f; private static float _revivePunishmentAccumulated = 0f; private static readonly Dictionary<CharacterMaster, float> pendingRespawnTimes = new Dictionary<CharacterMaster, float>(); public static void Init() { RoR2Application.onFixedUpdate += OnFixedUpdate; GlobalEventManager.onCharacterDeathGlobal += OnCharacterDeath; Run.onRunStartGlobal += delegate { FindTeleporterRefsDelayed(); }; Stage.onServerStageBegin += delegate { FindTeleporterRefsDelayed(); }; Stage.onServerStageBegin += delegate { _revivePunishmentAccumulated = 0f; }; RoR2Application.onUpdate += UpdateFlushWhenFinished; Run.onRunStartGlobal += OnRunStart; Run.onRunDestroyGlobal += OnRunDestroy; } private static void OnRunStart(Run run) { pendingRespawnTimes.Clear(); _teleporter = null; _hz = null; _revivePunishmentAccumulated = 0f; } private static void OnRunDestroy(Run run) { pendingRespawnTimes.Clear(); _teleporter = null; _hz = null; _revivePunishmentAccumulated = 0f; } private static void FindTeleporterRefsDelayed() { if (NetworkServer.active) { _teleporter = Object.FindObjectOfType<TeleporterInteraction>(); _hz = (Object.op_Implicit((Object)(object)_teleporter) ? _teleporter.holdoutZoneController : null); } } private static bool TeleporterFinished() { if (!Object.op_Implicit((Object)(object)_hz)) { return false; } return Mathf.Clamp01(_hz.charge) >= 0.999f; } private static bool TeleporterCharging() { if (!Object.op_Implicit((Object)(object)_teleporter) || !Object.op_Implicit((Object)(object)_hz)) { return false; } float num = Mathf.Clamp01(_hz.charge); if (num > 0f) { return num < 0.999f; } return false; } private static void OnCharacterDeath(DamageReport report) { if (!NetworkServer.active) { return; } CharacterBody val = report?.victimBody; if (!Object.op_Implicit((Object)(object)val)) { return; } CharacterMaster master = val.master; if (!Object.op_Implicit((Object)(object)master)) { return; } if (Object.op_Implicit((Object)(object)EscortState.Master) && (Object)(object)master == (Object)(object)EscortState.Master) { CameraSystem.ForceSpectateAll(val); KillAllPlayers(); } else { if ((Object)(object)master.playerCharacterMasterController == (Object)null) { return; } if (!TeleporterFinished()) { float num = Mathf.Max(0f, Config.ReviveSecondsPunishment.Value); if (num > 0f) { _revivePunishmentAccumulated += num; } } bool flag = TeleporterCharging(); float num2; if (TeleporterFinished()) { num2 = 0f; } else if (Config.BlockDuringTele.Value && flag) { num2 = float.PositiveInfinity; } else { float num3 = Config.BaseRespawnSeconds.Value + _revivePunishmentAccumulated; num2 = (flag ? (num3 * Config.DuringTeleRespawnMulti.Value) : num3); } if (Config.DisableDioRevive_UseBonus.Value && num2 > 0f && !float.IsInfinity(num2)) { Inventory inventory = val.inventory; int num4 = (Object.op_Implicit((Object)(object)inventory) ? inventory.GetItemCount(Items.ExtraLife) : 0); if (num4 > 0) { float num5 = Mathf.Max(0f, Config.DioHyperbolicPerStack.Value); num2 /= 1f + num5 * (float)num4; } } float value = Run.instance.time + num2; pendingRespawnTimes[master] = value; } } private static void OnFixedUpdate() { if (!NetworkServer.active || pendingRespawnTimes.Count == 0) { return; } float num = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.time : 0f); List<CharacterMaster> list = new List<CharacterMaster>(); foreach (KeyValuePair<CharacterMaster, float> pendingRespawnTime in pendingRespawnTimes) { CharacterMaster key = pendingRespawnTime.Key; if (Object.op_Implicit((Object)(object)key)) { float value = pendingRespawnTime.Value; if (float.IsInfinity(value) && !TeleporterCharging()) { list.Add(key); } else if (!float.IsInfinity(value) && num >= value) { list.Add(key); } } } foreach (CharacterMaster item in list) { TryRespawn(item); pendingRespawnTimes.Remove(item); } } private static Vector3 RandomHorizontalUnit() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_0037: 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) Vector2 insideUnitCircle = Random.insideUnitCircle; if (((Vector2)(ref insideUnitCircle)).sqrMagnitude < 1E-06f) { ((Vector2)(ref insideUnitCircle))..ctor(1f, 0f); } ((Vector2)(ref insideUnitCircle)).Normalize(); return new Vector3(insideUnitCircle.x, 0f, insideUnitCircle.y); } private static void TryRespawn(CharacterMaster master) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00d6: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)master) || (Config.BlockDuringTele.Value && TeleporterCharging())) { return; } Vector3 deathFootPosition = master.deathFootPosition; if (Config.RespawnNearEscort.Value && Object.op_Implicit((Object)(object)EscortState.Master) && Object.op_Implicit((Object)(object)EscortState.Master.GetBody())) { CharacterBody body = EscortState.Master.GetBody(); Vector3 val = body.corePosition; if ((Object)(object)body != (Object)null) { Vector3 val2 = RandomHorizontalUnit() * 24f; val += val2; } deathFootPosition = TeleportHelper.FindSafeTeleportDestination(val, master.bodyPrefab.GetComponent<CharacterBody>(), RoR2Application.rng).GetValueOrDefault(val); } else { deathFootPosition = (Vector3)(((??)TeleportHelper.FindSafeTeleportDestination(master.deathFootPosition, master.bodyPrefab.GetComponent<CharacterBody>(), RoR2Application.rng)) ?? master.deathFootPosition); } master.Respawn(deathFootPosition, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), true); master.GetBody().AddTimedBuff(Buffs.Immune, 3f); GameObject val3 = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/HippoRezEffect"); if (Object.op_Implicit((Object)(object)master.GetBody())) { EntityStateMachine[] components = ((Component)master.GetBody()).GetComponents<EntityStateMachine>(); foreach (EntityStateMachine obj in components) { obj.initialStateType = obj.mainStateType; } if (Object.op_Implicit((Object)(object)val3)) { EffectManager.SpawnEffect(val3, new EffectData { origin = deathFootPosition, rotation = ((Component)master.GetBody()).transform.rotation }, true); } } } private static void UpdateFlushWhenFinished() { if (!NetworkServer.active || !TeleporterFinished()) { return; } foreach (CharacterMaster item in pendingRespawnTimes.Keys.ToList()) { if (float.IsInfinity(pendingRespawnTimes[item])) { TryRespawn(item); pendingRespawnTimes.Remove(item); } } } private static void KillAllPlayers() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList) { if (Object.op_Implicit((Object)(object)readOnlyInstances) && Object.op_Implicit((Object)(object)readOnlyInstances.healthComponent) && readOnlyInstances.healthComponent.alive && Object.op_Implicit((Object)(object)readOnlyInstances.teamComponent) && (int)readOnlyInstances.teamComponent.teamIndex == 1) { readOnlyInstances.healthComponent.Suicide(((Component)readOnlyInstances).gameObject, (GameObject)null, DamageTypeCombo.op_Implicit((DamageType)0)); } } } } public static class TeleporterSystem { private static TeleporterInteraction _teleporter; private static HoldoutZoneController _hz; private const float kChargedEpsilon = 0.999f; private static float _lastCharge; public static void Init() { Run.onRunStartGlobal += delegate { Reset(); }; Run.onRunDestroyGlobal += delegate { Reset(); }; Stage.onServerStageBegin += delegate { FindTeleporterRefsDelayed(); }; RoR2Application.onFixedUpdate += FixedTick; } private static void Reset() { _teleporter = null; _hz = null; _lastCharge = 0f; } private static void FindTeleporterRefsDelayed() { if (NetworkServer.active) { _teleporter = Object.FindObjectOfType<TeleporterInteraction>(); _hz = (Object.op_Implicit((Object)(object)_teleporter) ? _teleporter.holdoutZoneController : null); _lastCharge = 0f; } } public static bool IsCharging() { if (!Object.op_Implicit((Object)(object)_teleporter) || !Object.op_Implicit((Object)(object)_hz)) { return false; } float num = Mathf.Clamp01(_hz.charge); if (num > 0f) { return num < 0.999f; } return false; } public static bool IsFinished() { if (!Object.op_Implicit((Object)(object)_hz)) { return false; } return Mathf.Clamp01(_hz.charge) >= 0.999f; } private static void FixedTick() { if (!((Object)(object)_hz == (Object)null)) { _lastCharge = Mathf.Clamp01(_hz.charge); } } } } namespace MonsterEscort.Core { public static class EscortState { public static CharacterMaster Master { get; private set; } public static CharacterBody Body { get { if (!Object.op_Implicit((Object)(object)Master) || !Object.op_Implicit((Object)(object)Master.GetBody())) { return null; } return Master.GetBody(); } } public static event Action<CharacterMaster> OnEscortAssigned; public static void Reset() { Master = null; } public static void Assign(CharacterMaster master) { if (Object.op_Implicit((Object)(object)master) && !((Object)(object)master == (Object)(object)Master)) { Master = master; EscortState.OnEscortAssigned?.Invoke(Master); } } public static void EnsureAssignedOnceFromScene() { if (Object.op_Implicit((Object)(object)Master) || !NetworkServer.active || (Object)(object)Run.instance == (Object)null) { return; } foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList) { CharacterMaster val = ((readOnlyInstances != null) ? readOnlyInstances.master : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.GetBody())) { return; } } List<CharacterMaster> list = new List<CharacterMaster>(); foreach (CharacterMaster readOnlyInstances2 in CharacterMaster.readOnlyInstancesList) { if ((Object)(object)readOnlyInstances2 == (Object)null || (Object)(object)readOnlyInstances2.playerCharacterMasterController == (Object)null) { continue; } CharacterBody body = readOnlyInstances2.GetBody(); if (Object.op_Implicit((Object)(object)body)) { string bodyPrefabName = GetBodyPrefabName(body); if (!string.IsNullOrEmpty(bodyPrefabName) && bodyPrefabName.StartsWith("MonsterMash_", StringComparison.OrdinalIgnoreCase) && bodyPrefabName.IndexOf("Drone", StringComparison.OrdinalIgnoreCase) < 0) { list.Add(readOnlyInstances2); } } } if (list.Count == 1) { Assign(list[0]); } } private static string GetBodyPrefabName(CharacterBody body) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) string text = null; if (Object.op_Implicit((Object)(object)body) && (int)body.bodyIndex != -1) { GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(body.bodyIndex); if (Object.op_Implicit((Object)(object)bodyPrefab)) { text = ((Object)bodyPrefab).name; } } if (string.IsNullOrEmpty(text) && Object.op_Implicit((Object)(object)body)) { text = ((Object)((Component)body).gameObject).name ?? ""; if (text.EndsWith("(Clone)")) { text = text.Substring(0, text.Length - "(Clone)".Length); } } return text ?? ""; } } public static class GameEvents { public static event Action OnTeleporterChargeStart; public static event Action<float> OnTeleporterCharge; public static event Action OnTeleporterFinished; internal static void RaiseTeleporterStart() { GameEvents.OnTeleporterChargeStart?.Invoke(); } internal static void RaiseTeleporter(float t) { GameEvents.OnTeleporterCharge?.Invoke(t); } internal static void RaiseTeleporterDone() { GameEvents.OnTeleporterFinished?.Invoke(); } } [BepInPlugin("thebugreport.MonsterEscort", "MonsterEscort", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { private void Awake() { Config.Bind(((BaseUnityPlugin)this).Config); ItemRules.Init(); TeleporterSystem.Init(); RespawnSystem.Init(); HealthBarController.Init(); RoR2Application.onUpdate += delegate { EscortState.EnsureAssignedOnceFromScene(); }; Run.onRunStartGlobal += delegate { EscortState.Reset(); }; Run.onRunDestroyGlobal += delegate { EscortState.Reset(); }; } } public static class Config { public static ConfigEntry<float> BaseRespawnSeconds; public static ConfigEntry<float> ReviveSecondsPunishment; public static ConfigEntry<bool> BlockDuringTele; public static ConfigEntry<float> DuringTeleRespawnMulti; public static ConfigEntry<bool> RespawnNearEscort; public static ConfigEntry<float> EscortExclusionRadius; public static ConfigEntry<bool> CurseEscortOnRespawn; public static ConfigEntry<bool> CursePlayerOnRespawn; public static ConfigEntry<float> CurseFraction; public static ConfigEntry<bool> DebuffEscortOnRespawn; public static ConfigEntry<bool> DebuffPlayerOnRespawn; public static ConfigEntry<float> DebuffEffectDuration; public static ConfigEntry<bool> ApplyAllDebuffs; public static ConfigEntry<string> DebuffIDs; public static ConfigEntry<bool> AddCreditsOnRespawn; public static ConfigEntry<int> CreditsPerRespawnPerStage; public static ConfigEntry<bool> DisableDioRevive_UseBonus; public static ConfigEntry<float> DioHyperbolicPerStack; public static ConfigEntry<bool> RemoveLarva; public static void Bind(ConfigFile cfg) { BaseRespawnSeconds = cfg.Bind<float>("Respawn", "BaseRespawnSeconds", 20f, "Default respawn cooldown (seconds)."); ReviveSecondsPunishment = cfg.Bind<float>("Respawn", "ReviveSecondsPunishment", 5f, "Additional respawn cooldown per revive used (applies to team as a whole) (seconds)."); BlockDuringTele = cfg.Bind<bool>("Respawn", "BlockDuringTeleporterCharge", true, "If true, block respawns while teleporter is charging; respawn all when charged."); DuringTeleRespawnMulti = cfg.Bind<float>("Respawn", "DuringTeleporterRespawnMulti", 2f, "If not blocking during charge, multiply the respawn time by this amount."); RespawnNearEscort = cfg.Bind<bool>("Respawn", "RespawnNearEscort", false, "If true, respawn near escort; otherwise near death location."); EscortExclusionRadius = cfg.Bind<float>("Respawn", "EscortExclusionRadius", 6f, "Minimum distance from the escort when respawning near it."); CurseEscortOnRespawn = cfg.Bind<bool>("Debuff", "CurseEscortOnRespawn", false, "If true, curse the escort on player respawn."); CursePlayerOnRespawn = cfg.Bind<bool>("Debuff", "CursePlayerOnRespawn", false, "If true, curse the player on respawn."); CurseFraction = cfg.Bind<float>("Debuff", "CurseFraction", 0.08f, "Fraction of max health to apply as curse on respawn (0.0 to 1.0)."); DebuffEscortOnRespawn = cfg.Bind<bool>("Debuff", "DebuffEscortOnRespawn", false, "If true, apply debuff effect to escort on player respawn."); DebuffPlayerOnRespawn = cfg.Bind<bool>("Debuff", "DebuffPlayerOnRespawn", true, "If true, apply debuff effect to player on respawn."); DebuffEffectDuration = cfg.Bind<float>("Debuff", "DebuffEffectDuration", 12f, "Duration of debuff effect applied on respawn (seconds)."); ApplyAllDebuffs = cfg.Bind<bool>("Debuff", "ApplyAllDebuffs", false, "If true, apply all debuffs listed in DebuffEffectIDs; otherwise pick a random one from the list below."); DebuffIDs = cfg.Bind<string>("Debuff", "DebuffEffectID", "Weak, Slow50", "Internal effect name of debuff/buff to apply on respawn (eg. 'Bleeding', 'Slow50', 'Weak', etc.)."); AddCreditsOnRespawn = cfg.Bind<bool>("Debuff", "AddCreditsOnRespawn", true, "If true, add credits to monster director on respawn."); CreditsPerRespawnPerStage = cfg.Bind<int>("Debuff", "CreditsPerRespawnPerStage", 50, "Amount of credits to add per respawn, per stage."); DisableDioRevive_UseBonus = cfg.Bind<bool>("Items", "DisableDioAndUseHyperbolicBonus", true, "Stop Dio revives; use hyperbolic respawn-time reduction."); DioHyperbolicPerStack = cfg.Bind<float>("Items", "HyperbolicPerStack", 0.25f, "Hyperbolic per-stack: effective = base / (1 + v*stacks)."); RemoveLarva = cfg.Bind<bool>("Items", "RemovePluripotentLarva", true, "Remove ExtraLifeVoid (Pluripotent Larva) from droptables."); } } }