Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of DamageIndicator Mono v1.0.0
Mods/DamageIndicator_Mono.dll
Decompiled 11 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using DamageIndicator; using DamageIndicator.Combat; using DamageIndicator.UI; using HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using S1Shared; using S1Shared.UI; using ScheduleOne; using ScheduleOne.AvatarFramework; using ScheduleOne.Combat; using ScheduleOne.DevUtilities; using ScheduleOne.NPCs; using ScheduleOne.NPCs.Behaviour; using ScheduleOne.PlayerScripts; using ScheduleOne.PlayerScripts.Health; using ScheduleOne.UI; using ScheduleOne.UI.MainMenu; using ScheduleOne.UI.Tooltips; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(DamageIndicatorMod), "DamageIndicator", "1.0.0", "BbIJABNPOBATEJb", "https://github.com/BbIJABNPOBATEJb/ScheduleI-Mods")] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: HarmonyDontPatchAll] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("DamageIndicator_Mono")] [assembly: AssemblyConfiguration("Mono")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e0261b1ee92870c45f3968e601d5a49616ce0ce0")] [assembly: AssemblyProduct("DamageIndicator_Mono")] [assembly: AssemblyTitle("DamageIndicator_Mono")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace S1Shared { internal sealed class CoRunner { private sealed class Routine { public readonly Stack<IEnumerator> Stack = new Stack<IEnumerator>(); public float WaitUntil; } private readonly List<Routine> _routines = new List<Routine>(); private readonly Action<Exception> _onError; public CoRunner(Action<Exception> onError) { _onError = onError; } public void Start(IEnumerator routine) { Routine routine2 = new Routine(); routine2.Stack.Push(routine); _routines.Add(routine2); } public void StopAll() { _routines.Clear(); } public void Tick() { float realtimeSinceStartup = Time.realtimeSinceStartup; for (int num = _routines.Count - 1; num >= 0; num--) { Routine routine = _routines[num]; if (!(realtimeSinceStartup < routine.WaitUntil)) { try { if (!Step(routine, realtimeSinceStartup)) { _routines.RemoveAt(num); } } catch (Exception obj) { _routines.RemoveAt(num); _onError(obj); } } } } private static bool Step(Routine r, float now) { while (r.Stack.Count > 0) { IEnumerator enumerator = r.Stack.Peek(); if (!enumerator.MoveNext()) { r.Stack.Pop(); continue; } object current = enumerator.Current; if (!(current is IEnumerator item)) { if (!(current is float num)) { if (current is int num2) { r.WaitUntil = now + (float)num2; return true; } return true; } r.WaitUntil = now + num; return true; } r.Stack.Push(item); } return false; } } internal static class SafePatcher { public static int Apply(Harmony harmony, Instance log) { int num = 0; Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(Assembly.GetExecutingAssembly()); foreach (Type type in typesFromAssembly) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Any()) { try { harmony.CreateClassProcessor(type).Patch(); } catch (Exception ex) { num++; log.Warning("Patch " + type.FullName + " not applied: " + (ex.InnerException ?? ex).Message); } } } return num; } } internal static class UiKit { public static void OnClick(Button button, Action action) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown button.onClick = new ButtonClickedEvent(); ((UnityEvent)button.onClick).AddListener(new UnityAction(action.Invoke)); } public static void OnValueChanged(Slider slider, Action<float> action) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown slider.onValueChanged = new SliderEvent(); ((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)action.Invoke); } public static void AddListener(Toggle toggle, Action<bool> action) { ((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)action.Invoke); } public static T? Get<T>(Component c) where T : Component { return c.GetComponent<T>(); } public static T? Get<T>(GameObject go) where T : Component { return Get<T>((Component)(object)go.transform); } public static T? InChildren<T>(Component c) where T : Component { return UnityQuery.GetComponentsInChildren<T>(c, includeInactive: true).FirstOrDefault(); } public static Transform? Find(Transform root, string name) { for (int i = 0; i < root.childCount; i++) { Transform child = root.GetChild(i); if (((Object)child).name == name) { return child; } Transform val = Find(child, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } public static List<Transform> Children(Transform t) { List<Transform> list = new List<Transform>(); for (int i = 0; i < t.childCount; i++) { list.Add(t.GetChild(i)); } return list; } public static string Namespace(Component c) { return ((object)c).GetType().Namespace ?? ""; } public static void SetMember(object target, string name, object? value) { Type type = target.GetType(); PropertyInfo propertyInfo = AccessTools.Property(type, name); if (propertyInfo != null && propertyInfo.CanWrite) { propertyInfo.SetValue(target, value); } else { AccessTools.Field(type, name)?.SetValue(target, value); } } } internal static class UnityQuery { public static List<T> ToManaged<T>(List<T>? list) { if (list != null) { return new List<T>(list); } return new List<T>(); } public static List<T> FindAllIncludingAssets<T>() where T : Object { List<T> list = new List<T>(); list.AddRange(Resources.FindObjectsOfTypeAll<T>()); return list; } public static List<T> FindInScenes<T>() where T : Component { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) List<T> list = new List<T>(); foreach (T item in UnityQuery.FindAllIncludingAssets<T>()) { Scene scene = ((Component)item).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { list.Add(item); } } return list; } public static T? GetComponentInParent<T>(Component component) where T : Component { return component.GetComponentInParent<T>(); } public static List<T> GetComponentsInChildren<T>(Component root, bool includeInactive) where T : Component { List<T> list = new List<T>(); list.AddRange(root.GetComponentsInChildren<T>(includeInactive)); return list; } public static bool TryCastTo<T>(Object? obj, out T result) where T : Object { result = (T)(object)((obj is T) ? obj : null); return (Object)(object)result != (Object)null; } public static string TypeName(Object obj) { return ((object)obj).GetType().Name; } public static string DumpHierarchy(Transform root, int maxDepth = 12) { StringBuilder sb = new StringBuilder(); Walk(root, 0); return sb.ToString(); void Walk(Transform t, int depth) { sb.Append(' ', depth * 2).Append(((Object)t).name).Append(((Component)t).gameObject.activeSelf ? "" : " [inactive]") .Append(" {"); Component[] components = ((Component)t).GetComponents<Component>(); foreach (Component val in components) { if (!((Object)(object)val == (Object)null)) { sb.Append(TypeName((Object)(object)val)).Append(' '); if (UnityQuery.TryCastTo<TMP_Text>((Object?)(object)val, out TMP_Text result)) { sb.Append("\"").Append(result.text?.Replace("\n", "\\n")).Append("\" "); } } } sb.Append("}\n"); if (depth < maxDepth) { for (int j = 0; j < t.childCount; j++) { Walk(t.GetChild(j), depth + 1); } } } } public static string PathOf(Transform t) { List<string> list = new List<string>(); Transform val = t; while ((Object)(object)val != (Object)null) { list.Add(((Object)val).name); val = val.parent; } list.Reverse(); return string.Join("/", list); } } } namespace S1Shared.UI { internal sealed class HudCanvas { private readonly string _name; private Canvas? _canvas; private CanvasScaler? _scaler; private TMP_FontAsset? _font; private Material? _outlineMaterial; public RectTransform? Root { get; private set; } public bool Visible { get { if ((Object)(object)_canvas != (Object)null) { return ((Behaviour)_canvas).enabled; } return false; } } public bool ShowWhilePaused { get; set; } public TMP_FontAsset? Font { get { if ((Object)(object)_font == (Object)null) { _font = FindHudFont(); } return _font; } } public Material? OutlineMaterial { get { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_outlineMaterial == (Object)null && (Object)(object)Font != (Object)null) { _outlineMaterial = new Material(((TMP_Asset)Font).material) { name = _name + " Outline" }; _outlineMaterial.EnableKeyword("OUTLINE_ON"); _outlineMaterial.SetFloat("_OutlineWidth", 0.22f); _outlineMaterial.SetColor("_OutlineColor", new Color(0f, 0f, 0f, 0.9f)); _outlineMaterial.SetFloat("_FaceDilate", 0.1f); } return _outlineMaterial; } } public float ScaleFactor { get { if (!((Object)(object)_scaler != (Object)null) || !(_scaler.scaleFactor > 0.01f)) { return 1f; } return _scaler.scaleFactor; } } public Vector2 Size { get { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Root != (Object)null)) { return new Vector2((float)Screen.width, (float)Screen.height); } Rect rect = Root.rect; return ((Rect)(ref rect)).size; } } public HudCanvas(string name) { _name = name; } public bool Tick() { HUD instance = Singleton<HUD>.Instance; if ((Object)(object)_canvas == (Object)null) { if ((Object)(object)instance == (Object)null) { return false; } Create(); } Canvas val = (((Object)(object)instance != (Object)null) ? instance.canvas : null); PauseMenu instance2 = Singleton<PauseMenu>.Instance; bool flag = (Object)(object)instance2 != (Object)null && instance2.IsPaused; bool flag2 = (Object)(object)val != (Object)null && (ShowWhilePaused || (((Behaviour)val).enabled && !flag)); if (((Behaviour)_canvas).enabled != flag2) { ((Behaviour)_canvas).enabled = flag2; } if ((Object)(object)val != (Object)null) { _canvas.sortingOrder = (ShowWhilePaused ? 30000 : (val.sortingOrder + 1)); float scaleFactor = val.scaleFactor; if (scaleFactor > 0.01f && !Mathf.Approximately(_scaler.scaleFactor, scaleFactor)) { _scaler.scaleFactor = scaleFactor; } } return flag2; } private void Create() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject(_name); Object.DontDestroyOnLoad((Object)(object)val); _canvas = val.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _scaler = val.AddComponent<CanvasScaler>(); _scaler.uiScaleMode = (ScaleMode)0; Root = UiKit.Get<RectTransform>(val); } public RectTransform NewRect(string name, Transform? parent = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = new GameObject(name).AddComponent<RectTransform>(); ((Transform)obj).SetParent((Transform)(((object)parent) ?? ((object)Root)), false); return obj; } public Image NewImage(string name, Transform? parent, Color color, Sprite? sprite = null) { //IL_0040: 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_002c: Unknown result type (might be due to invalid IL or missing references) Image val = ((Component)NewRect(name, parent)).gameObject.AddComponent<Image>(); val.sprite = sprite; if ((Object)(object)sprite != (Object)null && sprite.border != Vector4.zero) { val.type = (Type)1; } ((Graphic)val).color = color; ((Graphic)val).raycastTarget = false; return val; } public TextMeshProUGUI NewText(string name, Transform? parent, float size, Color color, bool outline = true) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = ((Component)NewRect(name, parent)).gameObject.AddComponent<TextMeshProUGUI>(); if ((Object)(object)Font != (Object)null) { ((TMP_Text)val).font = Font; } if (outline && (Object)(object)OutlineMaterial != (Object)null) { ((TMP_Text)val).fontSharedMaterial = OutlineMaterial; } ((TMP_Text)val).fontSize = size; ((Graphic)val).color = color; ((TMP_Text)val).alignment = (TextAlignmentOptions)514; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val).overflowMode = (TextOverflowModes)0; ((Graphic)val).raycastTarget = false; return val; } public Vector2 ScreenToCanvas(Vector2 screen) { //IL_0033: 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) float num = (((Object)(object)_scaler != (Object)null && _scaler.scaleFactor > 0.01f) ? _scaler.scaleFactor : 1f); return screen / num; } private static TMP_FontAsset? FindHudFont() { HUD instance = Singleton<HUD>.Instance; if ((Object)(object)instance != (Object)null) { TMP_Text val = ((IEnumerable<TMP_Text>)UnityQuery.GetComponentsInChildren<TMP_Text>((Component)(object)instance, includeInactive: true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => (Object)(object)t.font != (Object)null)); if ((Object)(object)val != (Object)null) { return val.font; } } return TMP_Settings.defaultFontAsset; } } internal sealed class HudElement { private readonly Func<Vector2> _getPos; private readonly Action<Vector2> _setPos; private readonly Func<float> _getScale; private readonly Action<float> _setScale; public string Label { get; } public Vector2 DefaultPos { get; } public float DefaultScale { get; } public float MinScale { get; set; } = 0.4f; public float MaxScale { get; set; } = 3f; public RectTransform? Rect { get; set; } public Vector2 Position { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _getPos(); } set { //IL_0006: 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_001c: Unknown result type (might be due to invalid IL or missing references) _setPos(new Vector2(Mathf.Clamp01(value.x), Mathf.Clamp01(value.y))); } } public float Scale { get { return _getScale(); } set { _setScale(Mathf.Clamp(value, MinScale, MaxScale)); } } public HudElement(string label, Vector2 defaultPos, float defaultScale, Func<Vector2> getPos, Action<Vector2> setPos, Func<float> getScale, Action<float> setScale) { //IL_0024: 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) Label = label; DefaultPos = defaultPos; DefaultScale = defaultScale; _getPos = getPos; _setPos = setPos; _getScale = getScale; _setScale = setScale; } public void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Rect == (Object)null)) { Vector2 position = Position; RectTransform? rect = Rect; Vector2 anchorMin = (Rect.anchorMax = position); rect.anchorMin = anchorMin; Rect.pivot = new Vector2(0.5f, 0.5f); Rect.anchoredPosition = Vector2.zero; ((Transform)Rect).localScale = Vector3.one * Scale; } } public void Reset() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Position = DefaultPos; Scale = DefaultScale; Apply(); } } internal sealed class HudEditor { private static readonly Color FrameColor = new Color(1f, 0.82f, 0.25f, 1f); private readonly HudCanvas _canvas; private readonly SettingsWindow _window; private readonly IReadOnlyList<HudElement> _elements; private readonly List<GameObject> _decorations = new List<GameObject>(); private RectTransform? _panel; private RectTransform? _doneButton; private RectTransform? _resetButton; private HudElement? _dragging; private Vector2 _dragOffset; private bool _changed; public bool Active { get; private set; } public event Action? Started; public event Action<bool>? Finished; public HudEditor(HudCanvas canvas, SettingsWindow window, IReadOnlyList<HudElement> elements) { _canvas = canvas; _window = window; _elements = elements; } public void Begin() { if (Active || (Object)(object)_canvas.Root == (Object)null) { return; } Active = true; _changed = false; _window.SetHidden(hidden: true); _canvas.ShowWhilePaused = true; this.Started?.Invoke(); foreach (HudElement element in _elements) { Decorate(element); } BuildPanel(); } public void End() { if (!Active) { return; } Active = false; _dragging = null; foreach (GameObject decoration in _decorations) { if ((Object)(object)decoration != (Object)null) { Object.Destroy((Object)(object)decoration); } } _decorations.Clear(); _canvas.ShowWhilePaused = false; _window.SetHidden(hidden: false); this.Finished?.Invoke(_changed); } public void Tick() { if (!Active) { return; } if (!_window.IsOpen || (Object)(object)_canvas.Root == (Object)null) { End(); return; } try { HandleInput(); } catch (Exception ex) { MelonLogger.Warning("HUD editor input failed: " + ex.Message); End(); } } private void HandleInput() { //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_00a9: 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_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) Vector2 val = Vector2.op_Implicit(Input.mousePosition); if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { End(); return; } if (Input.GetMouseButtonDown(0)) { if (Contains(_doneButton, val)) { End(); return; } if (Contains(_resetButton, val)) { foreach (HudElement element in _elements) { element.Reset(); } _changed = true; return; } HudElement hudElement = ElementAt(val); if (hudElement != null) { _dragging = hudElement; _dragOffset = val - Vector2.op_Implicit(((Transform)hudElement.Rect).position); } } if (_dragging != null) { if (Input.GetMouseButton(0)) { Vector2 val2 = val - _dragOffset; Vector2 position = default(Vector2); ((Vector2)(ref position))..ctor(val2.x / (float)Screen.width, val2.y / (float)Screen.height); if (Mathf.Abs(val2.x - (float)Screen.width * 0.5f) < 10f) { position.x = 0.5f; } _dragging.Position = position; _dragging.Apply(); _changed = true; } else { _dragging = null; } } HudElement hudElement2 = ElementAt(val); if (hudElement2 != null) { float y = Input.mouseScrollDelta.y; if (Mathf.Abs(y) > 0.01f) { hudElement2.Scale *= 1f + 0.08f * Mathf.Sign(y); hudElement2.Apply(); _changed = true; } if (Input.GetMouseButtonDown(1)) { hudElement2.Reset(); _changed = true; } } } private HudElement? ElementAt(Vector2 mouse) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) for (int num = _elements.Count - 1; num >= 0; num--) { HudElement hudElement = _elements[num]; if ((Object)(object)hudElement.Rect != (Object)null && ((Component)hudElement.Rect).gameObject.activeInHierarchy && Contains(hudElement.Rect, mouse)) { return hudElement; } } return null; } private static bool Contains(RectTransform? rect, Vector2 screen) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rect != (Object)null) { return RectTransformUtility.RectangleContainsScreenPoint(rect, screen, (Camera)null); } return false; } private void Decorate(HudElement element) { //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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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) //IL_014c: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)element.Rect == (Object)null)) { RectTransform val = _canvas.NewRect("EditorFrame", (Transform?)(object)element.Rect); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = new Vector2(-6f, -6f); val.offsetMax = new Vector2(6f, 6f); Image obj = ((Component)val).gameObject.AddComponent<Image>(); obj.sprite = SpriteKit.RoundedRect(6); obj.type = (Type)1; ((Graphic)obj).color = new Color(1f, 0.82f, 0.25f, 0.12f); ((Graphic)obj).raycastTarget = false; AddEdge(val, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, -2f), Vector2.zero); AddEdge(val, Vector2.zero, new Vector2(1f, 0f), Vector2.zero, new Vector2(0f, 2f)); AddEdge(val, Vector2.zero, new Vector2(0f, 1f), Vector2.zero, new Vector2(2f, 0f)); AddEdge(val, new Vector2(1f, 0f), Vector2.one, new Vector2(-2f, 0f), Vector2.zero); TextMeshProUGUI obj2 = _canvas.NewText("EditorLabel", (Transform?)(object)val, 18f, FrameColor); RectTransform rectTransform = ((TMP_Text)obj2).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 1f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = new Vector2(0f, 4f); rectTransform.sizeDelta = new Vector2(300f, 24f); ((TMP_Text)obj2).text = element.Label; _decorations.Add(((Component)val).gameObject); } } private void AddEdge(RectTransform frame, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_002b: 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) RectTransform rectTransform = ((Graphic)_canvas.NewImage("Edge", (Transform?)(object)frame, FrameColor)).rectTransform; rectTransform.anchorMin = anchorMin; rectTransform.anchorMax = anchorMax; rectTransform.offsetMin = offsetMin; rectTransform.offsetMax = offsetMax; } private void BuildPanel() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) Image val = _canvas.NewImage("HUD Editor", null, new Color(0.08f, 0.08f, 0.1f, 0.88f), SpriteKit.RoundedRect(10)); _panel = ((Graphic)val).rectTransform; RectTransform? panel = _panel; RectTransform? panel2 = _panel; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.66f); panel2.anchorMax = val2; panel.anchorMin = val2; _panel.pivot = new Vector2(0.5f, 0.5f); _panel.anchoredPosition = Vector2.zero; _panel.sizeDelta = new Vector2(760f, 104f); _decorations.Add(((Component)val).gameObject); TextMeshProUGUI obj = _canvas.NewText("Help", (Transform?)(object)_panel, 19f, Color.white, outline: false); RectTransform rectTransform = ((TMP_Text)obj).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.anchoredPosition = new Vector2(0f, -10f); rectTransform.sizeDelta = new Vector2(-24f, 30f); ((TMP_Text)obj).text = "Drag to move • Mouse wheel to resize • Right-click to reset"; _resetButton = MakeButton("Reset all", new Vector2(-110f, 14f), new Color(0.35f, 0.35f, 0.38f, 1f)); _doneButton = MakeButton("Done", new Vector2(110f, 14f), new Color(0.2f, 0.55f, 0.95f, 1f)); } private RectTransform MakeButton(string title, Vector2 pos, Color color) { //IL_000d: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00b4: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((Graphic)_canvas.NewImage(title, (Transform?)(object)_panel, color, SpriteKit.RoundedRect(8))).rectTransform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform.anchorMax = val; rectTransform.anchorMin = val; rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = pos; rectTransform.sizeDelta = new Vector2(190f, 40f); TextMeshProUGUI obj = _canvas.NewText("Label", (Transform?)(object)rectTransform, 20f, Color.white, outline: false); RectTransform rectTransform2 = ((TMP_Text)obj).rectTransform; rectTransform2.anchorMin = Vector2.zero; rectTransform2.anchorMax = Vector2.one; val = (rectTransform2.offsetMin = (rectTransform2.offsetMax = Vector2.zero)); ((TMP_Text)obj).text = title; return rectTransform; } } internal sealed class PrefsFile { private readonly MelonPreferences_Category _category; private readonly List<Action> _resets = new List<Action>(); private readonly List<Action> _originals = new List<Action>(); private float _saveAt = -1f; public bool SavingDisabled { get; set; } public PrefsFile(string name) { _category = MelonPreferences.CreateCategory(name); } public MelonPreferences_Entry<T> Entry<T>(string id, T defaultValue, string description) { return _category.CreateEntry<T>(id, defaultValue, (string)null, description, false, false, (ValueValidator)null, (string)null); } public Setting<T> Add<T>(string id, T defaultValue, string description) { MelonPreferences_Entry<T> entry = Entry(id, defaultValue, description); Setting<T> setting = new Setting<T>(this, entry, defaultValue); _resets.Add(setting.Reset); T loaded = entry.Value; _originals.Add(delegate { entry.Value = loaded; }); return setting; } public void RestoreLoadedValues() { foreach (Action original in _originals) { original(); } } public void ResetAll() { foreach (Action reset in _resets) { reset(); } MarkDirty(); } public void MarkDirty() { _saveAt = Time.realtimeSinceStartup + 1f; } public void Tick() { if (_saveAt > 0f && Time.realtimeSinceStartup >= _saveAt) { SaveNow(); } } public void SaveNow() { _saveAt = -1f; if (!SavingDisabled) { _category.SaveToFile(false); } } } internal sealed class Setting<T> { private readonly PrefsFile _file; private readonly MelonPreferences_Entry<T> _entry; public T Default { get; } public T Value { get { return _entry.Value; } set { _entry.Value = value; _file.MarkDirty(); } } public Setting(PrefsFile file, MelonPreferences_Entry<T> entry, T defaultValue) { _file = file; _entry = entry; Default = defaultValue; } public void Reset() { _entry.Value = Default; } } internal static class Keys { private static bool _broken; public static bool Down(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if ((int)key == 0 || _broken) { return false; } try { if (GameInput.IsTyping) { return false; } return Input.GetKeyDown(key); } catch (Exception ex) { _broken = true; MelonLogger.Warning("Hotkeys disabled, legacy input unavailable: " + ex.Message); return false; } } } internal sealed class SettingsWindow { internal sealed class RowTemplates { public Transform? Slider; public Transform? Toggle; public Transform? Choice; public Transform? Button; public Transform? Hint; } private const int MaxTabs = 6; private const string CloneSuffix = "ModScreen"; private readonly string _screenName; private readonly string _buttonName; private readonly string _title; private readonly string? _pauseButtonTitle; private readonly List<SettingsTab> _tabs = new List<SettingsTab>(); private SettingsScreen? _screen; private RectTransform? _screenRect; private bool _buildFailed; private bool _openWhenPaused; private bool _wasOpen; private int _fitIn; private string? _subtitle; private TMP_Text? _subtitleLabel; public bool IsOpen { get { if ((Object)(object)_screen != (Object)null) { return ((MenuScreen)_screen).IsOpen; } return false; } } internal bool Syncing { get; private set; } public event Action? Closed; public event Action? Changed; public SettingsWindow(string id, string title, string? pauseButtonTitle) { _screenName = id + "ModScreen"; _buttonName = id + "Button"; _title = title; _pauseButtonTitle = pauseButtonTitle; } public SettingsTab Tab(string title) { if (_tabs.Count >= 6) { throw new InvalidOperationException("The settings screen has room for " + 6 + " tabs"); } SettingsTab settingsTab = new SettingsTab(this, title); _tabs.Add(settingsTab); return settingsTab; } public void SetSubtitle(string? text) { _subtitle = text; if ((Object)(object)_subtitleLabel != (Object)null) { _subtitleLabel.text = text ?? ""; } } public void Tick() { PauseMenu instance = Singleton<PauseMenu>.Instance; if ((Object)(object)_screen == (Object)null) { if (_wasOpen) { _wasOpen = false; this.Closed?.Invoke(); } if ((Object)(object)instance != (Object)null && !_buildFailed) { TryBuild(instance); } if ((Object)(object)instance == (Object)null) { _buildFailed = false; } return; } if (_openWhenPaused && (Object)(object)instance != (Object)null && instance.IsPaused) { _openWhenPaused = false; Open(); } bool isOpen = ((MenuScreen)_screen).IsOpen; if (_wasOpen && !isOpen) { this.Closed?.Invoke(); } _wasOpen = isOpen; if (_fitIn > 0 && --_fitIn == 0) { PlaceHints(); } } public void Toggle() { PauseMenu instance = Singleton<PauseMenu>.Instance; if (!((Object)(object)_screen == (Object)null) && !((Object)(object)instance == (Object)null)) { if (((MenuScreen)_screen).IsOpen) { ((MenuScreen)_screen).Close(); } else if (!instance.IsPaused) { instance.Pause(); _openWhenPaused = true; } else { Open(); } } } public void Open() { if ((Object)(object)_screen == (Object)null) { return; } Refresh(); foreach (ScrollRect componentsInChild in UnityQuery.GetComponentsInChildren<ScrollRect>((Component)(object)_screen, includeInactive: true)) { componentsInChild.verticalNormalizedPosition = 1f; } _fitIn = 2; ((MenuScreen)_screen).Open(); } public void SetHidden(bool hidden) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_screenRect == (Object)null)) { _screenRect.anchoredPosition = (Vector2)(hidden ? new Vector2(0f, 100000f) : Vector2.zero); } } public void Refresh() { if ((Object)(object)_screen == (Object)null) { return; } Syncing = true; try { foreach (SettingsTab tab in _tabs) { foreach (SettingsRow row in tab.Rows) { row.Sync(); } } } finally { Syncing = false; } } internal void NotifyChanged() { Refresh(); this.Changed?.Invoke(); } private void TryBuild(PauseMenu pause) { try { Build(pause); } catch (Exception arg) { _buildFailed = true; _screen = null; MelonLogger.Error($"{_title} window could not be built: {arg}"); } } private void Build(PauseMenu pause) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown SettingsScreen val = ((IEnumerable<SettingsScreen>)UnityQuery.GetComponentsInChildren<SettingsScreen>((Component)(object)pause, includeInactive: true)).FirstOrDefault((Func<SettingsScreen, bool>)((SettingsScreen s) => !((Object)s).name.EndsWith("ModScreen", StringComparison.Ordinal) && ((Object)s).name != "WorldRatesScreen")) ?? throw new InvalidOperationException("in-game Settings screen not found"); GameObject val2 = new GameObject(_title + " Holder"); val2.SetActive(false); GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, val2.transform); ((Object)val3).name = _screenName; SettingsScreen val4 = UiKit.Get<SettingsScreen>(val3); GameObject val5 = new GameObject("Unused"); val5.transform.SetParent(val3.transform, false); val5.SetActive(false); RowTemplates rowTemplates = new RowTemplates { Slider = FindRow(val3.transform, "Master"), Toggle = (FindRow(val3.transform, "VSync") ?? FindRow(val3.transform, "PauseOnLoseFocus")), Choice = FindRow(val3.transform, "Units"), Button = UiKit.Find(val3.transform, "ViewCommands"), Hint = UiKit.Find(val3.transform, "Hint") }; if ((Object)(object)rowTemplates.Slider == (Object)null) { throw new InvalidOperationException("slider template not found"); } StripSettingsBindings(val3.transform); Transform[] array = (Transform[])(object)new Transform[5] { rowTemplates.Slider, rowTemplates.Toggle, rowTemplates.Choice, rowTemplates.Button, rowTemplates.Hint }; foreach (Transform obj in array) { if (obj != null) { obj.SetParent(val5.transform, false); } } Transform val6 = UiKit.Find(val3.transform, "Blocker"); if ((Object)(object)val6 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val6).gameObject); } SettingsCategory[] categories = val4.Categories; for (int num2 = 0; num2 < categories.Length; num2++) { Transform val7 = UiKit.Find(categories[num2].Panel.transform, "Vertical Layout"); if ((Object)(object)val7 == (Object)null) { continue; } foreach (Transform item in UiKit.Children(val7)) { item.SetParent(val5.transform, false); } } val4.HostOnlyGameObjects = (GameObject[])(object)new GameObject[0]; SetText(val3.transform, "Title", _title); Transform val8 = UiKit.Find(val3.transform, "Version"); _subtitleLabel = ((val8 != null) ? UiKit.Get<TMP_Text>((Component)(object)val8) : null); if ((Object)(object)_subtitleLabel != (Object)null) { _subtitleLabel.text = _subtitle ?? ""; } for (int num3 = 0; num3 < categories.Length; num3++) { Toggle toggle = categories[num3].Toggle; if (num3 >= _tabs.Count) { ((Component)toggle).gameObject.SetActive(false); continue; } TMP_Text val9 = UiKit.InChildren<TMP_Text>((Component)(object)toggle); if ((Object)(object)val9 != (Object)null) { val9.text = _tabs[num3].Title; } UiKit.AddListener(toggle, delegate(bool on) { if (on) { _fitIn = 2; } }); Transform val10 = UiKit.Find(categories[num3].Panel.transform, "Vertical Layout"); if ((Object)(object)val10 == (Object)null) { continue; } foreach (SettingsRow row in _tabs[num3].Rows) { row.Build(val10, rowTemplates); } } val3.transform.SetParent(((Component)val).transform.parent, false); val3.transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex() + 1); Object.Destroy((Object)(object)val2); val3.SetActive(true); _screen = val4; _screenRect = UiKit.Get<RectTransform>(val3); if (_pauseButtonTitle != null) { AddPauseButton(pause); } Refresh(); MelonLogger.Msg(_title + " window ready"); } private static void StripSettingsBindings(Transform root) { foreach (MonoBehaviour componentsInChild in UnityQuery.GetComponentsInChildren<MonoBehaviour>((Component)(object)root, includeInactive: true)) { if (!((Object)(object)componentsInChild == (Object)null)) { string text = UiKit.Namespace((Component)(object)componentsInChild); string text2 = UnityQuery.TypeName((Object)(object)componentsInChild); if (text.EndsWith("ScheduleOne.UI.Settings", StringComparison.Ordinal) || text2 == "GameSettingsWindow" || text2 == "VersionText") { Object.DestroyImmediate((Object)(object)componentsInChild); } } } } private static Transform? FindRow(Transform root, string name) { Transform val = UiKit.Find(root, name); if (!((Object)(object)val != (Object)null) || !((Object)(object)val.parent != (Object)null) || !(((Object)val.parent).name == "Vertical Layout")) { return null; } return val; } private void AddPauseButton(PauseMenu pause) { Transform val = UiKit.Find((Transform)(object)pause.Container, "Panel"); Transform val2 = ((val != null) ? val.Find("Settings") : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && !((Object)(object)val.Find(_buttonName) != (Object)null)) { GameObject obj = Object.Instantiate<GameObject>(((Component)val2).gameObject, val, false); ((Object)obj).name = _buttonName; obj.transform.SetSiblingIndex(val2.GetSiblingIndex() + 1); TMP_Text val3 = UiKit.Get<TMP_Text>((Component)(object)obj.transform.Find("ButtonText")); if ((Object)(object)val3 != (Object)null) { val3.text = _pauseButtonTitle; } UiKit.OnClick(UiKit.Get<Button>(obj), Open); } } private void PlaceHints() { foreach (SettingsTab tab in _tabs) { foreach (SettingsRow row in tab.Rows) { row.PlaceHint(); } } } private static void SetText(Transform root, string name, string text) { Transform val = UiKit.Find(root, name); TMP_Text val2 = (((Object)(object)val != (Object)null) ? UiKit.Get<TMP_Text>((Component)(object)val) : null); if ((Object)(object)val2 != (Object)null) { val2.text = text; } } } internal sealed class SettingsTab { private readonly SettingsWindow _window; internal readonly List<SettingsRow> Rows = new List<SettingsRow>(); public string Title { get; } internal SettingsTab(SettingsWindow window, string title) { _window = window; Title = title; } public SettingsTab Slider(string label, string? hint, float min, float max, float step, Func<float> get, Action<float> set, Func<float, string> format) { Rows.Add(new SliderRow(_window, label, hint, min, max, step, get, set, format)); return this; } public SettingsTab Toggle(string label, string? hint, Func<bool> get, Action<bool> set) { Rows.Add(new ToggleRow(_window, label, hint, get, set)); return this; } public SettingsTab Choice(string label, string? hint, string[] options, Func<int> get, Action<int> set) { Rows.Add(new ChoiceRow(_window, label, hint, options, get, set)); return this; } public SettingsTab Button(string title, Action onClick) { Rows.Add(new ButtonRow(title, onClick)); return this; } public SettingsTab Text(string text, bool header = false) { Rows.Add(new TextRow(text, header)); return this; } } internal abstract class SettingsRow { protected TMP_Text? LabelText; protected RectTransform? HintRect; public abstract void Build(Transform layout, SettingsWindow.RowTemplates templates); public virtual void Sync() { } public void PlaceHint() { //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_0045: 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_005f: 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) if (!((Object)(object)HintRect == (Object)null) && !((Object)(object)LabelText == (Object)null) && ((Behaviour)LabelText).isActiveAndEnabled) { LabelText.ForceMeshUpdate(false, false); Bounds textBounds = LabelText.textBounds; float x = ((Bounds)(ref textBounds)).size.x; Rect rect = LabelText.rectTransform.rect; float num = Mathf.Min(x, ((Rect)(ref rect)).width); HintRect.anchoredPosition = new Vector2(num + 8f, 0f); } } protected static GameObject Clone(Transform template, Transform layout, string name) { GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, layout, false); ((Object)obj).name = name; obj.SetActive(true); return obj; } protected void AddHint(Transform? template, TMP_Text label, string? hint) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_008e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)template == (Object)null) && !string.IsNullOrEmpty(hint)) { GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, label.transform, false); obj.SetActive(true); Tooltip val = UiKit.Get<Tooltip>(obj); if ((Object)(object)val != (Object)null) { val.text = hint; } RectTransform val2 = UiKit.Get<RectTransform>(obj); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(0f, 0.5f); val2.anchoredPosition = new Vector2(label.preferredWidth + 8f, 0f); HintRect = val2; } } private static float LeftEdgeIn(Transform row, RectTransform control) { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Rect rect = control.rect; float num = ((Rect)(ref rect)).xMin; Transform val = (Transform)(object)control; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)row) { num = val.localPosition.x + val.localScale.x * num; val = val.parent; } return num; } internal static void FitLabelColumn(Transform row, TMP_Text label, RectTransform control, bool roomForHint = true) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0048: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) RectTransform val = UiKit.Get<RectTransform>((Component)(object)row); RectTransform rectTransform = label.rectTransform; float x = ((Transform)rectTransform).localPosition.x; Rect rect = rectTransform.rect; float num = x + ((Rect)(ref rect)).xMin; float num2 = LeftEdgeIn(row, control) - (roomForHint ? 30f : 12f); rect = rectTransform.rect; float height = ((Rect)(ref rect)).height; float y = ((Transform)rectTransform).localPosition.y; rect = rectTransform.rect; float num3 = y + ((Rect)(ref rect)).center.y; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 0.5f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.sizeDelta = new Vector2(Mathf.Max(60f, num2 - num), height); rect = val.rect; float num4 = num - ((Rect)(ref rect)).xMin; rect = val.rect; rectTransform.anchoredPosition = new Vector2(num4, num3 - ((Rect)(ref rect)).center.y); label.textWrappingMode = (TextWrappingModes)0; label.fontSizeMax = label.fontSize; label.fontSizeMin = label.fontSize * 0.6f; label.enableAutoSizing = true; } } internal sealed class SliderRow : SettingsRow { private readonly SettingsWindow _window; private readonly string _label; private readonly string? _hint; private readonly float _min; private readonly float _max; private readonly float _step; private readonly Func<float> _get; private readonly Action<float> _set; private readonly Func<float, string> _format; private Slider? _slider; private TMP_Text? _value; public SliderRow(SettingsWindow window, string label, string? hint, float min, float max, float step, Func<float> get, Action<float> set, Func<float, string> format) { _window = window; _label = label; _hint = hint; _min = min; _max = max; _step = step; _get = get; _set = set; _format = format; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { GameObject obj = SettingsRow.Clone(templates.Slider, layout, _label); UISlider val = UiKit.Get<UISlider>(obj); if ((Object)(object)val != (Object)null) { UiKit.SetMember(val, "optionName", _label); UiKit.SetMember(val, "canUpdateValueText", false); } TMP_Text val2 = UiKit.Get<TMP_Text>((Component)(object)obj.transform.Find("Label")); val2.text = _label; Slider val3 = UiKit.InChildren<Slider>((Component)(object)obj.transform); SettingsRow.FitLabelColumn(obj.transform, val2, UiKit.Get<RectTransform>((Component)(object)((Component)val3).transform)); _value = UiKit.Get<TMP_Text>((Component)(object)((Component)val3).transform.Find("Value")); val3.wholeNumbers = true; val3.minValue = Mathf.Round(_min / _step); val3.maxValue = Mathf.Round(_max / _step); UiKit.OnValueChanged(val3, delegate(float v) { if (!_window.Syncing) { _set(v * _step); _window.NotifyChanged(); } }); _slider = val3; LabelText = val2; AddHint(templates.Hint, val2, _hint); } public override void Sync() { if (!((Object)(object)_slider == (Object)null)) { float num = _get(); _slider.value = Mathf.Round(num / _step); if ((Object)(object)_value != (Object)null) { _value.text = _format(num); } } } } internal sealed class ToggleRow : SettingsRow { private readonly SettingsWindow _window; private readonly string _label; private readonly string? _hint; private readonly Func<bool> _get; private readonly Action<bool> _set; private UIToggle? _toggle; public ToggleRow(SettingsWindow window, string label, string? hint, Func<bool> get, Action<bool> set) { _window = window; _label = label; _hint = hint; _get = get; _set = set; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { if (!((Object)(object)templates.Toggle == (Object)null)) { GameObject val = SettingsRow.Clone(templates.Toggle, layout, _label); UIToggle val2 = UiKit.Get<UIToggle>(val); UiKit.SetMember(val2, "optionName", _label); TMP_Text val3 = UnityQuery.GetComponentsInChildren<TMP_Text>((Component)(object)val.transform, includeInactive: true).First((TMP_Text t) => ((Object)t).name.StartsWith("Option Name", StringComparison.Ordinal)); val3.text = _label; Transform val4 = val.transform.Find("Toggle (OffOn)"); if ((Object)(object)val4 != (Object)null) { SettingsRow.FitLabelColumn(val.transform, val3, UiKit.Get<RectTransform>((Component)(object)val4)); } val2.OnChanged.AddListener((UnityAction<bool>)OnChanged); _toggle = val2; LabelText = val3; AddHint(templates.Hint, val3, _hint); } } private void OnChanged(bool value) { if (!_window.Syncing) { _set(value); _window.NotifyChanged(); } } public override void Sync() { UIToggle? toggle = _toggle; if (toggle != null) { toggle.SetStateWithoutNotify(_get()); } } } internal sealed class ChoiceRow : SettingsRow { private readonly SettingsWindow _window; private readonly string _label; private readonly string? _hint; private readonly string[] _options; private readonly Func<int> _get; private readonly Action<int> _set; private TMP_Dropdown? _dropdown; public ChoiceRow(SettingsWindow window, string label, string? hint, string[] options, Func<int> get, Action<int> set) { _window = window; _label = label; _hint = hint; _options = options; _get = get; _set = set; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown if (!((Object)(object)templates.Choice == (Object)null)) { GameObject obj = SettingsRow.Clone(templates.Choice, layout, _label); TMP_Dropdown val = UnityQuery.GetComponentsInChildren<TMP_Dropdown>((Component)(object)obj.transform, includeInactive: true).First(); TMP_Text val2 = UnityQuery.GetComponentsInChildren<TMP_Text>((Component)(object)obj.transform, includeInactive: true).First((TMP_Text t) => ((Object)t).name.StartsWith("Option Name", StringComparison.Ordinal)); val2.text = _label; SettingsRow.FitLabelColumn(obj.transform, val2, UiKit.Get<RectTransform>((Component)(object)((Component)val).transform)); ((UnityEventBase)val.onValueChanged).RemoveAllListeners(); val.ClearOptions(); string[] options = _options; foreach (string text in options) { val.options.Add(new OptionData(text)); } ((UnityEvent<int>)(object)val.onValueChanged).AddListener((UnityAction<int>)OnSelected); _dropdown = val; LabelText = val2; AddHint(templates.Hint, val2, _hint); } } private void OnSelected(int index) { if (!_window.Syncing && index >= 0 && index < _options.Length) { _set(index); _window.NotifyChanged(); } } public override void Sync() { if (!((Object)(object)_dropdown == (Object)null)) { _dropdown.SetValueWithoutNotify(Mathf.Clamp(_get(), 0, _options.Length - 1)); _dropdown.RefreshShownValue(); } } } internal sealed class ButtonRow : SettingsRow { private const float ButtonWidth = 460f; private readonly string _title; private readonly Action _onClick; public ButtonRow(string title, Action onClick) { _title = title; _onClick = onClick; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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) if (!((Object)(object)templates.Button == (Object)null)) { GameObject val = SettingsRow.Clone(templates.Button, layout, "Button " + _title); TMP_Text val2 = UiKit.InChildren<TMP_Text>((Component)(object)val.transform); if ((Object)(object)val2 != (Object)null) { val2.text = _title; val2.enableAutoSizing = true; val2.fontSizeMax = val2.fontSize; val2.fontSizeMin = val2.fontSize * 0.65f; } RectTransform val3 = UiKit.Get<RectTransform>(val); val3.sizeDelta = new Vector2(Mathf.Max(val3.sizeDelta.x, 460f), val3.sizeDelta.y); LayoutElement? obj = UiKit.Get<LayoutElement>(val) ?? val.AddComponent<LayoutElement>(); float minWidth = (obj.preferredWidth = 460f); obj.minWidth = minWidth; UiKit.OnClick(UiKit.Get<Button>(val), _onClick); } } } internal sealed class TextRow : SettingsRow { private readonly string _text; private readonly bool _header; public TextRow(string text, bool header) { _text = text; _header = header; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { //IL_0079: 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_0094: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) GameObject obj = SettingsRow.Clone(templates.Slider, layout, _header ? "Header" : "Text"); UISlider val = UiKit.Get<UISlider>(obj); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } Slider val2 = UiKit.InChildren<Slider>((Component)(object)obj.transform); if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val2).gameObject); } TMP_Text val3 = UiKit.Get<TMP_Text>((Component)(object)obj.transform.Find("Label")); RectTransform rectTransform = val3.rectTransform; rectTransform.anchorMin = new Vector2(0f, rectTransform.anchorMin.y); rectTransform.anchorMax = new Vector2(1f, rectTransform.anchorMax.y); rectTransform.offsetMax = new Vector2(-10f, rectTransform.offsetMax.y); val3.textWrappingMode = (TextWrappingModes)1; if (_header) { val3.fontStyle = (FontStyles)(val3.fontStyle | 1); } else { val3.fontStyle = (FontStyles)(val3.fontStyle | 2); } val3.text = _text; } } internal static class SpriteKit { private static readonly Dictionary<int, Sprite> Rounded = new Dictionary<int, Sprite>(); private static Sprite? _glow; private static Sprite? _arrow; public static Sprite RoundedRect(int radius) { //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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) if (Rounded.TryGetValue(radius, out Sprite value) && (Object)(object)value != (Object)null) { return value; } int num = radius * 2 + 4; Color32[] array = (Color32[])(object)new Color32[num * num]; Rect val = default(Rect); ((Rect)(ref val))..ctor((float)radius + 0.5f, (float)radius + 0.5f, (float)(num - 2 * radius) - 1f, (float)(num - 2 * radius) - 1f); for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num2 = (float)j + 0.5f; float num3 = (float)i + 0.5f; float num4 = Mathf.Max(new float[3] { ((Rect)(ref val)).xMin - num2, 0f, num2 - ((Rect)(ref val)).xMax }); float num5 = Mathf.Max(new float[3] { ((Rect)(ref val)).yMin - num3, 0f, num3 - ((Rect)(ref val)).yMax }); float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5); float num7 = Mathf.Clamp01((float)radius - num6 + 0.5f); array[i * num + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num7 * 255f)); } } float num8 = (float)radius + 1f; Sprite val2 = MakeSprite("Rounded" + radius, num, num, array, new Vector4(num8, num8, num8, num8)); Rounded[radius] = val2; return val2; } public static Sprite Glow() { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_glow != (Object)null) { return _glow; } Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = ((float)j + 0.5f) / 64f * 2f - 1f; float num2 = ((float)i + 0.5f) / 64f * 2f - 1f; float num3 = Mathf.Clamp01(Mathf.Sqrt(num * num + num2 * num2)); float num4 = (1f - num3) * (1f - num3); array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num4 * 255f)); } } _glow = MakeSprite("Glow", 64, 64, array, Vector4.zero); return _glow; } public static Sprite FlatArrow() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_arrow != (Object)null) { return _arrow; } Vector2[] poly = (Vector2[])(object)new Vector2[4] { new Vector2(32f, 62f), new Vector2(58f, 6f), new Vector2(32f, 20f), new Vector2(6f, 6f) }; Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = 0; for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { if (Inside(poly, new Vector2((float)j + ((float)l + 0.5f) / 4f, (float)i + ((float)k + 0.5f) / 4f))) { num++; } } } array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num * 255 / 16)); } } _arrow = MakeSprite("FlatArrow", 64, 64, array, Vector4.zero); return _arrow; } private static bool Inside(Vector2[] poly, Vector2 p) { //IL_001b: 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_0039: 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) bool flag = false; int num = 0; int num2 = poly.Length - 1; while (num < poly.Length) { if (poly[num].y > p.y != poly[num2].y > p.y && p.x < (poly[num2].x - poly[num].x) * (p.y - poly[num].y) / (poly[num2].y - poly[num].y) + poly[num].x) { flag = !flag; } num2 = num++; } return flag; } private static Sprite MakeSprite(string name, int width, int height, Color32[] pixels, Vector4 border) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0031: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height, (TextureFormat)4, false) { name = "S1Mods " + name, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; val.SetPixels32(pixels); val.Apply(false, true); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, border); ((Object)obj).name = ((Object)val).name; ((Object)obj).hideFlags = (HideFlags)61; return obj; } } } namespace DamageIndicator { internal enum PlayerBarMode { WhileHurt, AfterDamage, Always, Never } internal enum NpcBarMode { AfterDamage, InCombat, Never } internal enum NumbersFor { All, Yours, Off } internal static class Config { public static PrefsFile Prefs = null; public static Setting<bool> Enabled = null; public static Setting<int> PlayerBar = null; public static Setting<float> PlayerBarX = null; public static Setting<float> PlayerBarY = null; public static Setting<float> PlayerBarScale = null; public static Setting<int> PlayerBarWidth = null; public static Setting<bool> PlayerValueText = null; public static Setting<bool> PlayerNumbers = null; public static Setting<bool> PlayerHealNumbers = null; public static Setting<float> PlayerHideDelay = null; public static Setting<int> NpcBars = null; public static Setting<float> NpcBarScale = null; public static Setting<float> NpcHideDelay = null; public static Setting<int> NpcMaxDistance = null; public static Setting<bool> NpcNames = null; public static Setting<bool> NpcValueText = null; public static Setting<bool> Stun = null; public static Setting<int> Numbers = null; public static Setting<float> NumberScale = null; public static Setting<float> NumberDuration = null; public static readonly Vector2 DefaultPlayerBarPos = new Vector2(0.5f, 0.155f); public static PlayerBarMode PlayerBarMode => (PlayerBarMode)Mathf.Clamp(PlayerBar.Value, 0, 3); public static NpcBarMode NpcBarMode => (NpcBarMode)Mathf.Clamp(NpcBars.Value, 0, 2); public static NumbersFor NumbersFor => (NumbersFor)Mathf.Clamp(Numbers.Value, 0, 2); public static void Init() { Prefs = new PrefsFile("DamageIndicator"); Enabled = Prefs.Add("Enabled", defaultValue: true, "Master switch."); PlayerBar = Prefs.Add("PlayerBar", 0, "Your health bar: 0 = while hurt (hidden at full health), 1 = for a few seconds after damage, 2 = always, 3 = never."); PlayerBarX = Prefs.Add("PlayerBarX", DefaultPlayerBarPos.x, "Horizontal position of your health bar (0 = left edge, 1 = right edge)."); PlayerBarY = Prefs.Add("PlayerBarY", DefaultPlayerBarPos.y, "Vertical position of your health bar (0 = bottom, 1 = top)."); PlayerBarScale = Prefs.Add("PlayerBarScale", 1f, "Size of your health bar."); PlayerBarWidth = Prefs.Add("PlayerBarWidth", 300, "Width of your health bar."); PlayerValueText = Prefs.Add("PlayerValueText", defaultValue: true, "Show your health as a number on the bar."); PlayerNumbers = Prefs.Add("PlayerDamageNumbers", defaultValue: true, "Show damage you take as numbers next to your bar."); PlayerHealNumbers = Prefs.Add("PlayerHealNumbers", defaultValue: true, "Show healing (not slow regeneration) as green numbers."); PlayerHideDelay = Prefs.Add("PlayerHideDelay", 4f, "Seconds your bar stays after damage / after healing to full."); NpcBars = Prefs.Add("NpcBars", 0, "Health bars over characters: 0 = after they take damage, 1 = also while they fight you, 2 = never."); NpcBarScale = Prefs.Add("NpcBarScale", 1f, "Size of health bars over characters."); NpcHideDelay = Prefs.Add("NpcHideDelay", 6f, "Seconds a character's bar stays after the last damage."); NpcMaxDistance = Prefs.Add("NpcMaxDistance", 60, "Characters further away than this (meters) get no bar."); NpcNames = Prefs.Add("NpcNames", defaultValue: true, "Show the character's name above the bar."); NpcValueText = Prefs.Add("NpcValueText", defaultValue: false, "Show health as a number on characters' bars."); Stun = Prefs.Add("StunBars", defaultValue: true, "Yellow bar under the health bar while stunned (tased, staggered, knocked down) and a KO badge."); Numbers = Prefs.Add("DamageNumbers", 0, "Floating damage numbers on characters: 0 = all hits, 1 = only your hits, 2 = off."); NumberScale = Prefs.Add("NumberScale", 1f, "Size of damage numbers."); NumberDuration = Prefs.Add("NumberDuration", 1.2f, "Seconds a damage number stays on screen."); } } public sealed class DamageIndicatorMod : MelonMod { private static readonly Color YourHitColor = Color.white; private static readonly Color OtherHitColor = new Color(0.82f, 0.82f, 0.82f, 1f); private static readonly Color KillColor = new Color(1f, 0.32f, 0.28f, 1f); private CoRunner _runner; private string? _lastError; internal static HudCanvas Canvas { get; private set; } = null; internal static DamageNumbers Numbers { get; private set; } = null; internal static NpcBars NpcBars { get; private set; } = null; internal static PlayerBar PlayerBar { get; private set; } = null; internal static SettingsWindow Window { get; private set; } = null; internal static HudEditor Editor { get; private set; } = null; public override void OnInitializeMelon() { SafePatcher.Apply(((MelonBase)this).HarmonyInstance, ((MelonBase)this).LoggerInstance); Config.Init(); Canvas = new HudCanvas("DamageIndicator HUD"); Numbers = new DamageNumbers(Canvas); NpcBars = new NpcBars(Canvas); PlayerBar = new PlayerBar(Canvas, Numbers); Window = SettingsUi.Create(delegate { Editor.Begin(); }, delegate { Window.Refresh(); PlayerBar.Element.Apply(); }); Editor = new HudEditor(Canvas, Window, new HudElement[1] { PlayerBar.Element }); Editor.Started += delegate { PlayerBar.Preview = true; }; Editor.Finished += delegate { PlayerBar.Preview = false; }; CombatHooks.NpcHit += OnNpcHit; _runner = new CoRunner(delegate(Exception ex) { ((MelonBase)this).LoggerInstance.Error((object)ex); }); ((MelonBase)this).LoggerInstance.Msg("DamageIndicator 1.0.0 loaded"); } public override void OnUpdate() { _runner.Tick(); Window.Tick(); Editor.Tick(); Config.Prefs.Tick(); } public override void OnLateUpdate() { try { if (Canvas.Tick() || Canvas.ShowWhilePaused) { Camera camera = MainCamera(); PlayerBar.Tick(); NpcBars.Tick(camera); Numbers.Tick(camera); } } catch (Exception ex) { if (_lastError != ex.Message) { ((MelonBase)this).LoggerInstance.Warning($"HUD update failed: {ex}"); } _lastError = ex.Message; } } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { NpcBars.Clear(); Numbers.Clear(); PlayerBar.Reset(); } public override void OnApplicationQuit() { if (Config.Prefs.SavingDisabled) { Config.Prefs.RestoreLoadedValues(); } else { Config.Prefs.SaveNow(); } } private static void OnNpcHit(NpcHit hit) { //IL_00d8: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_0147: Unknown result type (might be due to invalid IL or missing references) NpcBars.OnHit(hit); NumbersFor numbersFor = Config.NumbersFor; if (!Config.Enabled.Value) { return; } switch (numbersFor) { case NumbersFor.Yours: if (!hit.ByLocalPlayer) { return; } break; case NumbersFor.Off: return; } bool flag = hit.HealthBefore > 0f && hit.HealthAfter <= 0f; float num = 30f * Config.NumberScale.Value; float num2 = 100f; try { num2 = Mathf.Max(1f, hit.Npc.Health.MaxHealth); } catch (Exception) { } if (hit.Damage >= num2 * 0.35f) { num *= 1.25f; } string text = Mathf.Max(1, Mathf.RoundToInt(hit.Damage)).ToString(); Color color; if (flag && hit.Lethal) { color = KillColor; num *= 1.15f; } else if (flag) { color = HealthBarView.StunColor; text += " KO"; num *= 1.15f; } else { color = (hit.ByLocalPlayer ? YourHitColor : OtherHitColor); } Vector3 val = hit.Point; if (val == Vector3.zero) { val = ((Component)hit.Npc).transform.position + Vector3.up * 1.5f; } Numbers.SpawnWorld(val, text, color, num); } internal static Camera? MainCamera() { PlayerCamera instance = PlayerSingleton<PlayerCamera>.Instance; if (!((Object)(object)instance != (Object)null)) { return Camera.main; } return instance.Camera; } } internal static class ModInfo { public const string Name = "DamageIndicator"; public const string Version = "1.0.0"; public const string Author = "BbIJABNPOBATEJb"; public const string DownloadLink = "https://github.com/BbIJABNPOBATEJb/ScheduleI-Mods"; } } namespace DamageIndicator.UI { internal sealed class DamageNumbers { private sealed class Item { public TextMeshProUGUI Text; public RectTransform Rect; public float Start; public float Duration; public Vector3 World; public bool InWorld; public Vector2 CanvasPos; public Vector2 Drift; public float Size; public Color Color; } private const int MaxActive = 48; private const float Rise = 80f; private readonly HudCanvas _canvas; private readonly List<Item> _active = new List<Item>(); private readonly Stack<Item> _pool = new Stack<Item>(); private RectTransform? _layer; private float _side = 1f; public DamageNumbers(HudCanvas canvas) { _canvas = canvas; } public void SpawnWorld(Vector3 world, string text, Color color, float size) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Spawn(text, color, size, delegate(Item item) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) item.InWorld = true; item.World = world; }); } public void SpawnCanvas(Vector2 canvasPos, string text, Color color, float size) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Spawn(text, color, size, delegate(Item item) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) item.InWorld = false; item.CanvasPos = canvasPos; }); } public void Clear() { foreach (Item item in _active) { Recycle(item); } _active.Clear(); } public void Tick(Camera? camera) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; for (int num = _active.Count - 1; num >= 0; num--) { Item item = _active[num]; float num2 = (unscaledTime - item.Start) / item.Duration; if (num2 >= 1f || (Object)(object)item.Rect == (Object)null) { Recycle(item); _active.RemoveAt(num); continue; } Vector2 val2; if (item.InWorld) { if ((Object)(object)camera == (Object)null) { ((Component)item.Rect).gameObject.SetActive(false); continue; } Vector3 val = camera.WorldToScreenPoint(item.World); if (val.z <= 0.1f) { ((Component)item.Rect).gameObject.SetActive(false); continue; } val2 = _canvas.ScreenToCanvas(Vector2.op_Implicit(val)); } else { val2 = item.CanvasPos; } if (!((Component)item.Rect).gameObject.activeSelf) { ((Component)item.Rect).gameObject.SetActive(true); } float num3 = 1f - (1f - num2) * (1f - num2); item.Rect.anchoredPosition = val2 + new Vector2(item.Drift.x * (item.InWorld ? (0.6f + 0.4f * num3) : num3), 80f * num3 + item.Drift.y); float num4 = ((num2 < 0.12f) ? Mathf.Lerp(1.55f, 1f, num2 / 0.12f) : 1f); ((Transform)item.Rect).localScale = Vector3.one * num4; Color color = item.Color; color.a = ((num2 < 0.6f) ? 1f : (1f - (num2 - 0.6f) / 0.4f)); ((Graphic)item.Text).color = color; } } private void Spawn(string text, Color color, float size, Action<Item> place) { //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_canvas.Root == (Object)null)) { if (_active.Count >= 48) { Recycle(_active[0]); _active.RemoveAt(0); } Item item = ((_pool.Count > 0) ? _pool.Pop() : Create()); if ((Object)(object)item.Rect == (Object)null) { item = Create(); } place(item); item.Start = Time.unscaledTime; item.Duration = Mathf.Max(0.3f, Config.NumberDuration.Value); _side = 0f - _side; item.Drift = (item.InWorld ? new Vector2(_side * Random.Range(55f, 85f), Random.Range(-10f, 10f)) : new Vector2(Random.Range(-12f, 12f), Random.Range(-4f, 6f))); item.Size = size; item.Color = color; ((TMP_Text)item.Text).text = text; ((TMP_Text)item.Text).fontSize = size; ((Graphic)item.Text).color = color; ((Transform)item.Rect).SetAsLastSibling(); ((Component)item.Rect).gameObject.SetActive(false); _active.Add(item); } } private Item Create() { //IL_0079: 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_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) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_005d: Unknown result type (might be due to invalid IL or missing references) Vector2 offsetMin; if ((Object)(object)_layer == (Object)null) { _layer = _canvas.NewRect("Damage Numbers"); _layer.anchorMin = Vector2.zero; _layer.anchorMax = Vector2.one; RectTransform? layer = _layer; offsetMin = (_layer.offsetMax = Vector2.zero); layer.offsetMin = offsetMin; } TextMeshProUGUI val = _canvas.NewText("Number", (Transform?)(object)_layer, 30f, Color.white); ((TMP_Text)val).fontStyle = (FontStyles)1; RectTransform rectTransform = ((TMP_Text)val).rectTransform; offsetMin = (rectTransform.anchorMax = Vector2.zero); rectTransform.anchorMin = offsetMin; rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.sizeDelta = new Vector2(200f, 50f); return new Item { Text = val, Rect = rectTransform }; } private void Recycle(Item item) { if (!((Object)(object)item.Rect == (Object)null)) { ((Component)item.Rect).gameObject.SetActive(false); _pool.Push(item); } } } internal sealed class HealthBarView { public static readonly Color HealthColor = new Color(0.9f, 0.2f, 0.18f, 1f); public static readonly Color TrailColor = new Color(1f, 1f, 1f, 0.6f); public static readonly Color HealColor = new Color(0.45f, 0.95f, 0.45f, 1f); public static readonly Color StunColor = new Color(1f, 0.78f, 0.1f, 1f); private static readonly Color FrameColor = new Color(0f, 0f, 0f, 0.62f); private static readonly Color DeadColor = new Color(0.45f, 0.45f, 0.45f, 1f); private const float TrailDelay = 0.45f; private const float TrailSpeed = 0.9f; private readonly RectTransform _bar; private readonly RectTransform _fill; private readonly RectTransform _trail; private readonly Image _fillImage; private readonly RectTransform _stun; private readonly RectTransform _stunFill; private readonly Image _stunImage; private readonly TextMeshProUGUI _value; private readonly TextMeshProUGUI? _name; private readonly TextMeshProUGUI _badge; private readonly CanvasGroup _group; private readonly float _height; private float _shown = 1f; private float _trailValue = 1f; private float _trailHoldUntil; private float _stunValue = -1f; private bool _stunPulse; public RectTransform Root { get; } public float Alpha { get { return _group.alpha; } set { _group.alpha = value; } } public HealthBarView(HudCanvas canvas, Transform? parent, string name, float width, float height, bool withName) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_048e: 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_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) _height = height; Root = canvas.NewRect(name, parent); Root.sizeDelta = new Vector2(width, height); _group = ((Component)Root).gameObject.AddComponent<CanvasGroup>(); _group.blocksRaycasts = false; _group.interactable = false; Stretch(((Graphic)canvas.NewImage("Frame", (Transform?)(object)Root, FrameColor, SpriteKit.RoundedRect(4))).rectTransform, 2f); _bar = canvas.NewRect("Bar", (Transform?)(object)Root); Stretch(_bar, 0f); Image val = canvas.NewImage("Trail", (Transform?)(object)_bar, TrailColor, SpriteKit.RoundedRect(3)); _trail = ((Graphic)val).rectTransform; _fillImage = canvas.NewImage("Fill", (Transform?)(object)_bar, HealthColor, SpriteKit.RoundedRect(3)); _fill = ((Graphic)_fillImage).rectTransform; RectTransform rectTransform = ((Graphic)canvas.NewImage("Shine", (Transform?)(object)_fill, new Color(1f, 1f, 1f, 0.18f), SpriteKit.RoundedRect(2))).rectTransform; rectTransform.anchorMin = new Vector2(0f, 0.55f); rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = new Vector2(1f, 0f); rectTransform.offsetMax = new Vector2(-1f, -1f); SetFraction(_trail, 1f); SetFraction(_fill, 1f); _stun = canvas.NewRect("Stun", (Transform?)(object)Root); _stun.anchorMin = new Vector2(0f, 0f); _stun.anchorMax = new Vector2(1f, 0f); _stun.pivot = new Vector2(0.5f, 1f); _stun.anchoredPosition = new Vector2(0f, -4f); _stun.sizeDelta = new Vector2(0f, Mathf.Max(4f, height * 0.35f)); Stretch(((Graphic)canvas.NewImage("Frame", (Transform?)(object)_stun, FrameColor, SpriteKit.RoundedRect(3))).rectTransform, 1.5f); _stunImage = canvas.NewImage("Fill", (Transform?)(object)_stun, StunColor, SpriteKit.RoundedRect(2)); _stunFill = ((Graphic)_stunImage).rectTransform; SetFraction(_stunFill, 1f); ((Component)_stun).gameObject.SetActive(false); _value = canvas.NewText("Value", (Transform?)(object)Root, Mathf.Max(12f, height * 0.95f), Color.white); Stretch(((TMP_Text)_value).rectTransform, 0f); ((TMP_Text)_value).rectTransform.offsetMax = new Vector2(-6f, 0f); ((TMP_Text)_value).alignment = (TextAlignmentOptions)4100; ((TMP_Text)_value).fontStyle = (FontStyles)1; if (withName) { _name = canvas.NewText("Name", (Transform?)(object)Root, 17f, Color.white); RectTransform rectTransform2 = ((TMP_Text)_name).rectTransform; rectTransform2.anchorMin = new Vector2(0f, 1f); rectTransform2.anchorMax = new Vector2(1f, 1f); rectTransform2.pivot = new Vector2(0.5f, 0f); rectTransform2.anchoredPosition = new Vector2(0f, 3f); rectTransform2.sizeDelta = new Vector2(80f, 22f); } _badge = canvas.NewText("Badge", (Transform?)(object)Root, Mathf.Max(15f, height * 1.6f), StunColor); RectTransform rectTransform3 = ((TMP_Text)_badge).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); rectTransform3.anchorMax = val2; rectTransform3.anchorMin = val2; rectTransform3.pivot = new Vector2(0.5f, 0.5f); rectTransform3.anchoredPosition = Vector2.zero; rectTransform3.sizeDelta = new Vector2(width, height * 2.5f); ((TMP_Text)_badge).alignment = (TextAlignmentOptions)514; ((TMP_Text)_badge).fontStyle = (FontStyles)1; ((Component)_badge).gameObject.SetActive(false); } public void SetWidth(float width) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Root.sizeDelta = new Vector2(width, _height); } public void SetName(string? name) { if (!((Object)(object)_name == (Object)null)) { ((Component)_name).gameObject.SetActive(!string.IsNullOrEmpty(name)); if (!string.IsNullOrEmpty(name)) { ((TMP_Text)_name).text = name; } } } public void SetValueText(string? text) { ((Component)_value).gameObject.SetActive(text != null); if (text != null) { ((TMP_Text)_value).text = text; } } public void SetHealth(float fraction, bool instant = false) { fraction = Mathf.Clamp01(fraction); if (instant) { _shown = (_trailValue = fraction); return; } if (fraction < _shown - 0.0001f) { _trailValue = Mathf.Max(_trailValue, _shown); _trailHoldUntil = Time.unscaledTime + 0.45f; _shown = fraction; return; } _shown = fraction; if (_trailValue < _shown) { _trailValue = _shown; } } public void SetDead(bool dead) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) ((Graphic)_fillImage).color = (dead ? DeadColor : HealthColor); } public void SetStun(float fraction, bool pulse) { _stunValue = fraction; _stunPulse = pulse; bool flag = fraction >= 0f; if (((Component)_stun).gameObject.activeSelf != flag) { ((Component)_stun).gameObject.SetActive(flag); } } public void SetBadge(string? text, Color color) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) bool flag = !string.IsNullOrEmpty(text); if (((Component)_badge).gameObject.activeSelf != flag) { ((Component)_badge).gameObject.SetActive(flag); } if (flag) { ((TMP_Text)_badge).text = text; ((Graphic)_badge).color = color; } } public void Tick() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; if (_trailValue > _shown && unscaledTime >= _trailHoldUntil) { _trailValue = Mathf.Max(_shown, _trailValue - 0.9f * Time.unscaledDeltaTime); } SetFraction(_fill, _shown); SetFraction(_trail, _trailValue); if (_stunValue >= 0f) { SetFraction(_stunFill, _stunValue); float a = (_stunPulse ? (0.65f + 0.35f * Mathf.Sin(unscaledTime * 8f)) : 1f); Color stunColor = StunColor; stunColor.a = a; ((Graphic)_stunImage).color = stunColor; } } private static void SetFraction(RectTransform r, float fraction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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) r.anchorMin = Vector2.zero; r.anchorMax = new Vector2(Mathf.Clamp01(fraction), 1f); r.offsetMin = Vector2.zero; r.offsetMax = Vector2.zero; bool flag = fraction > 0.001f; if (((Component)r).gameObject.activeSelf != flag) { ((Component)r).gameObject.SetActive(flag); } } private static void Stretch(RectTransform r, float outset) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) r.anchorMin