Decompiled source of BattleImprovements fix v1.6.0
BattleImprove.dll
Decompiled 2 days 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.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BattleImprove.Components; using BattleImprove.Components.QOL; using BattleImprove.Integration; using BattleImprove.Patcher.QOL; using BattleImprove.Patcher.TakeHitPatcher; using BattleImprove.Transpiler; using BattleImprove.UI.InGame; using BattleImprove.Utils; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using I2.Loc; using Microsoft.CodeAnalysis; using PerfectRandom.Sulfur.Core; using PerfectRandom.Sulfur.Core.DevTools; using PerfectRandom.Sulfur.Core.Input; using PerfectRandom.Sulfur.Core.Items; using PerfectRandom.Sulfur.Core.LevelGeneration; using PerfectRandom.Sulfur.Core.Stats; using PerfectRandom.Sulfur.Core.UI; using PerfectRandom.Sulfur.Core.Units; using PerfectRandom.Sulfur.Core.Weapons; using PerfectRandom.Sulfur.Core.World; using PerfectRandom.Sulfur.Gameplay; using TMPro; using Unity.Collections; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Networking; using UnityEngine.UI; using UrGUI.UWindow; using UrGUI.UWindow.Utils; using UrGUI.Utils; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BattleImprove")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.6.0.0")] [assembly: AssemblyInformationalVersion("1.6.0+efc49fb2024cfa79cfcbfdc6a89460e1af4c5a1e")] [assembly: AssemblyProduct("Battle Improvements")] [assembly: AssemblyTitle("BattleImprove")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.6.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public class HitSoundEffect : PluginInstance<HitSoundEffect> { public AudioClip[] hitClose; public AudioClip[] hitFar; public AudioClip[] hitCrit; public void PlayHitSound(Vector3 position, bool isCrit, bool isFar = false, float volume = 1f) { //IL_0018: 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_0039: Unknown result type (might be due to invalid IL or missing references) if (isCrit) { AudioSource.PlayClipAtPoint(hitCrit[Random.Range(0, hitCrit.Length)], position, volume); } else if (isFar) { AudioSource.PlayClipAtPoint(hitFar[Random.Range(0, hitFar.Length)], position, volume); } else { AudioSource.PlayClipAtPoint(hitClose[Random.Range(0, hitClose.Length)], position, volume); } } } public class BF5MessageController : MessageController { public KillStreakController headshotStreak; public KillStreakController killStreak; protected override GameObject GetDamageInfo(string type, int damage, GameObject placeholder) { //IL_001e: 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) GameObject damageInfo = base.GetDamageInfo(type, damage, placeholder); damageInfo.transform.localPosition = new Vector3(0f, 0f, 0f); damageInfo.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f); TMP_Text component = damageInfo.GetComponent<TMP_Text>(); component.alignment = (TextAlignmentOptions)514; component.fontSize = 15f; return damageInfo; } public override void OnEnemyKill(string enemyName, string weaponName, string exp, bool isHeadShot, bool isFar = false) { base.OnEnemyKill(enemyName, weaponName, exp, isHeadShot, isFar); if (isHeadShot) { headshotStreak.AddKillStreak(); } else { killStreak.AddKillStreak(); } headshotStreak.ResetTimer(); killStreak.ResetTimer(); } } public class DamageSource : MonoBehaviour { public string damageType; public int damage; public TMP_Text message; private float timer; private GameObject placeholder; private void Start() { timer = 0f; message = ((Component)this).GetComponent<TMP_Text>(); } private void Update() { //IL_000c: 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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, placeholder.transform.position, 200f * CanvasScale() * Time.deltaTime); timer += Time.deltaTime; if (timer > 5f) { Object.Destroy((Object)(object)placeholder); Object.Destroy((Object)(object)((Component)this).gameObject); } } private float CanvasScale() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Component)this).transform.parent; if (!((Object)(object)parent != (Object)null)) { return 1f; } return Mathf.Abs(parent.lossyScale.y); } public void InitMessage(string type, int damage, GameObject placeholder) { //IL_0015: 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) ((Component)this).transform.localPosition = new Vector3(0f, 0f, 0f); ((Component)this).transform.position = placeholder.transform.position; damageType = type; this.damage = damage; message.text = damageType + " " + damage; this.placeholder = placeholder; Reset(); } public void Reset() { timer = 0f; message.text = damageType + " " + damage; } } public class KillStreakController : MonoBehaviour { public GameObject FirstStreak; public TMP_Text streakCounter; public GameObject iconPrefab; public GameObject container; private float timer; private int streakCount; private void Start() { streakCounter.text = ""; timer = 0f; } private void Update() { if (!Object.op_Implicit((Object)(object)FirstStreak)) { return; } timer += Time.deltaTime; if (timer > 6f) { StreakIcon[] componentsInChildren = container.GetComponentsInChildren<StreakIcon>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Fade(); } timer = 0f; streakCount = 0; streakCounter.text = ""; } } public void ResetTimer() { timer = 0f; } public void AddKillStreak() { GameObject placeholder = GetPlaceholder(); LayoutRebuilder.ForceRebuildLayoutImmediate(((Component)this).GetComponent<RectTransform>()); GameObject val = Object.Instantiate<GameObject>(iconPrefab, container.transform, false); val.GetComponent<StreakIcon>().InitStrekIcon(placeholder, this); streakCount++; if (!Object.op_Implicit((Object)(object)FirstStreak)) { FirstStreak = val; } if (streakCount % 5 == 0) { ((Component)streakCounter).gameObject.SetActive(true); StreakIcon[] componentsInChildren = container.GetComponentsInChildren<StreakIcon>(); foreach (StreakIcon streakIcon in componentsInChildren) { if ((Object)(object)((Component)streakIcon).gameObject != (Object)(object)FirstStreak && !streakIcon.NeedDestroyWhenOnPosition) { streakIcon.TargetPosition = FirstStreak; streakIcon.NeedDestroyWhenOnPosition = true; } } streakCounter.text = "×" + streakCount; } timer = 0f; } protected virtual GameObject GetPlaceholder() { //IL_0018: 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_002e: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown GameObject val = new GameObject("Placeholder", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(((Component)this).transform); val.transform.SetAsFirstSibling(); val.GetComponent<RectTransform>().sizeDelta = new Vector2(25f, 25f); return val; } } public class MessageController : PluginInstance<MessageController> { private GameObject banner; private TMP_Text tmpEnemyName; private TMP_Text tmpWeaponName; private TMP_Text tmpExp; private Animator bannerAnim; private bool isShowing; public AudioClip killSound; public AudioClip headShotKillSound; private AudioSource audioSource; private GameObject gameobjectTotalDamage; private TMP_Text tmpTotalDamage; private float timer; private int totalDamage; private int currentDamage; private GameObject damageInfoPlaceholder; private GameObject damageInfoContainer; private GameObject firstMessage; public GameObject damageSourcePrefab; internal PluginData.AttackFeedback data; protected override void Awake() { isShowing = false; InitBanner(); InitDamageInfo(); ResetDamageCounter(); base.Awake(); } protected virtual GameObject InitDamageInfo() { GameObject gameObject = ((Component)((Component)this).transform.Find("Damage")).gameObject; gameobjectTotalDamage = ((Component)gameObject.transform.Find("Total")).gameObject; tmpTotalDamage = gameobjectTotalDamage.GetComponent<TMP_Text>(); damageInfoPlaceholder = ((Component)gameObject.transform.Find("Placeholder")).gameObject; damageInfoContainer = ((Component)gameObject.transform.Find("Container")).gameObject; return gameObject; } protected virtual GameObject InitBanner() { banner = ((Component)((Component)this).transform.Find("Banner")).gameObject; tmpEnemyName = ((Component)FindChild(banner.transform, "Enemy")).GetComponent<TMP_Text>(); tmpWeaponName = ((Component)FindChild(banner.transform, "Weapon")).GetComponent<TMP_Text>(); tmpExp = ((Component)FindChild(banner.transform, "Exp")).GetComponent<TMP_Text>(); bannerAnim = banner.GetComponent<Animator>(); audioSource = banner.GetComponent<AudioSource>(); return banner; } protected virtual void Start() { data = DataManager.AttackFeedbackData; } protected void Update() { UpdateTotalDamage(); if ((isShowing || gameobjectTotalDamage.activeSelf) && (timer += Time.deltaTime) > 5f) { ResetDamageCounter(); if (isShowing) { HideMessage(); } } } public virtual void OnEnemyKill(string enemyName, string weaponName, string exp, bool isHeadShot, bool isFar = false) { if (!TmpFontFixer.Resolved) { TmpFontFixer.Apply(((Component)this).gameObject); } tmpEnemyName.text = enemyName; tmpWeaponName.text = weaponName; tmpExp.text = exp; ((MonoBehaviour)this).StartCoroutine(ShowMessage()); PlayKillAudio(isHeadShot, isFar); } public void OnEnemyHit(string type, int damage) { if (!TmpFontFixer.Resolved) { TmpFontFixer.Apply(((Component)this).gameObject); } gameobjectTotalDamage.SetActive(true); totalDamage += damage; if ((Object)(object)firstMessage != (Object)null && (Object)(object)damageInfoContainer != (Object)null) { DamageSource[] componentsInChildren = damageInfoContainer.GetComponentsInChildren<DamageSource>(); foreach (DamageSource damageSource in componentsInChildren) { if (damageSource.damageType == type) { damageSource.damage += damage; damageSource.Reset(); return; } } } AddDamageInfo(type, damage); } private static Transform FindChild(Transform parent, string name) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown foreach (Transform item in parent) { Transform val = item; if (((Object)val).name == name) { return val; } Transform val2 = FindChild(val, name); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } public void HideMessage() { isShowing = false; bannerAnim.SetTrigger("Fade"); } private void ResetDamageCounter() { gameobjectTotalDamage.SetActive(false); totalDamage = 0; currentDamage = 0; timer = 0f; } private IEnumerator ShowMessage() { if (!isShowing) { isShowing = true; bannerAnim.SetTrigger("Pop"); } yield return (object)new WaitForEndOfFrame(); Transform transform = banner.transform; LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)(object)((transform is RectTransform) ? transform : null)); } private void UpdateTotalDamage() { if (currentDamage < totalDamage) { timer = 0f; int num = Mathf.Max(1, (totalDamage - currentDamage) / 100); currentDamage += num; tmpTotalDamage.text = currentDamage.ToString(); } } protected virtual GameObject AddDamageInfo(string type, int damage) { GameObject placeholder = GetPlaceholder(); LayoutRebuilder.ForceRebuildLayoutImmediate(damageInfoPlaceholder.GetComponent<RectTransform>()); firstMessage = GetDamageInfo(type, damage, placeholder); return firstMessage; } protected virtual GameObject GetPlaceholder() { //IL_0018: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown GameObject val = new GameObject("Placeholder", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(damageInfoPlaceholder.transform); val.transform.SetAsFirstSibling(); val.GetComponent<RectTransform>().sizeDelta = new Vector2(25f, 25f); return val; } protected virtual GameObject GetDamageInfo(string type, int damage, GameObject placeholder) { GameObject obj = Object.Instantiate<GameObject>(damageSourcePrefab, damageInfoContainer.transform); TmpFontFixer.Apply(obj); obj.GetComponent<DamageSource>().InitMessage(type, damage, placeholder); return obj; } protected virtual void PlayKillAudio(bool isHeadShot, bool isFar) { audioSource.PlayOneShot(isFar ? headShotKillSound : killSound, data.messageVolume); } } public class StreakIcon : MonoBehaviour { private Animator animator; private KillStreakController controller; private GameObject targetPosition; private bool needDestroyWhenOnPosition; public GameObject TargetPosition { get { if (!((Object)(object)targetPosition == (Object)null)) { return targetPosition; } return controller.FirstStreak; } set { if (Object.op_Implicit((Object)(object)targetPosition)) { Object.Destroy((Object)(object)targetPosition); } targetPosition = value; } } public bool NeedDestroyWhenOnPosition { get { return needDestroyWhenOnPosition; } set { if (value) { needDestroyWhenOnPosition = value; ((MonoBehaviour)this).StartCoroutine(DestroyWhenOnPosition()); } } } private void Start() { animator = ((Component)this).GetComponent<Animator>(); } private void Update() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0068: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)TargetPosition)) { Transform parent = ((Component)this).transform.parent; float num = (((Object)(object)parent != (Object)null) ? Mathf.Abs(parent.lossyScale.y) : 1f); ((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, TargetPosition.transform.position, 200f * num * Time.deltaTime); } } public void InitStrekIcon(GameObject placeholder, KillStreakController controller) { //IL_0015: 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) ((Component)this).transform.localPosition = new Vector3(0f, 0f, 0f); ((Component)this).transform.position = placeholder.transform.position; targetPosition = placeholder; needDestroyWhenOnPosition = false; this.controller = controller; } public void Destroy(float delay = 0f) { Object.Destroy((Object)(object)targetPosition.gameObject, delay); Object.Destroy((Object)(object)((Component)this).gameObject, delay); } private IEnumerator DestroyWhenOnPosition() { while (((Component)this).transform.position != targetPosition.transform.position) { yield return (object)new WaitForEndOfFrame(); } Object.Destroy((Object)(object)((Component)this).gameObject); } public void Fade() { animator.SetTrigger("Fade"); Destroy(0.25f); } } public class xCrossHair : PluginInstance<xCrossHair> { public Animator crossHairAnim; private PluginData.AttackFeedback data; private Image[] images; private void Start() { data = DataManager.AttackFeedbackData; images = ((Component)this).GetComponentsInChildren<Image>(); } public void StartTrigger(string type) { if (!(type == "Hit")) { if (type == "Kill") { KillTrigger(); } } else { HitTrigger(); } } private void HitTrigger() { crossHairAnim.SetTrigger("Hit"); SetHitColor(); } private void KillTrigger() { crossHairAnim.SetTrigger("Kill"); SetKillColor(); } private void SetHitColor() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) Image[] array = images; for (int i = 0; i < array.Length; i++) { ((Graphic)array[i]).color = data.hitColor; } } private void SetKillColor() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) Image[] array = images; for (int i = 0; i < array.Length; i++) { ((Graphic)array[i]).color = data.killColor; } } } public class LootDropVFX : MonoBehaviour { public ParticleSystem[] systems; private bool hidden; private void Start() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) ((Component)this).transform.localPosition = new Vector3(0f, 0.1f, 0f); ((Component)this).transform.localScale = new Vector3(1f, 1f, 1f); ParticleSystem[] array = systems; for (int i = 0; i < array.Length; i++) { ((Component)array[i]).transform.localScale = new Vector3(0.4f, 0.4f, 0.4f); } } private void Update() { bool mouseButton = InputCompat.GetMouseButton(1); if (mouseButton != hidden) { hidden = mouseButton; ParticleSystem[] array = systems; for (int i = 0; i < array.Length; i++) { ((Component)array[i]).gameObject.SetActive(!mouseButton); } } } } namespace UrGUI.UWindow { public class UWindow { public string WinGuid; public string WindowTitle; public float X; public float Y; public float Width; public float Height; public bool IsDraggable; public bool DynamicHeight; private float _startX; private float _startY; private float _margin; private float _controlHeight; private float _controlSpace; private float _sameLineOffset; private List<float> _nextLineRatios = new List<float>(0); private bool _isDragging; private Vector2 _dragLastMouse; private float _nextControlY; private List<WControl> _controls; public GUISkin ActiveSkin { get; internal set; } public bool IsDrawing { get; set; } private protected UWindow() { } public static UWindow Begin(string windowTitle = "a Title", float startWidth = 200f, float margin = 10f, float controlHeight = 22f, float controlSpace = 5f, bool isEnabled = true, bool isDraggable = true, bool dynamicHeight = true) { //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) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) int num = 400; Vector2 dynamicWindowPos = UWindowManager.GetDynamicWindowPos(startWidth); return Begin(windowTitle, dynamicWindowPos.x, dynamicWindowPos.y, startWidth, num, margin, controlHeight, controlSpace, isEnabled, isDraggable, dynamicHeight); } public static UWindow Begin(string windowTitle, float startX, float startY, float startWidth, float startHeight, float margin = 10f, float controlHeight = 22f, float controlSpace = 5f, bool isDrawing = true, bool isDraggable = true, bool dynamicHeight = false) { UWindow obj = new UWindow { IsDrawing = isDrawing, WindowTitle = windowTitle, X = startX, Y = startY, Width = startWidth, Height = startHeight, _margin = margin, _controlHeight = controlHeight, _controlSpace = controlSpace, IsDraggable = isDraggable, DynamicHeight = dynamicHeight, _controls = new List<WControl>(), _startX = startX, _startY = startY }; UWindowManager.Register(obj); return obj; } internal void Draw() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Invalid comparison between Unknown and I4 //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Invalid comparison between Unknown and I4 //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_0216: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) if (!IsDrawing) { return; } if ((Object)(object)ActiveSkin != (Object)null) { GUI.skin = ActiveSkin; } if (UWindowManager.AllWindowsDisabled) { GUI.enabled = false; } Event current = Event.current; Rect val; if ((int)current.type == 0) { val = new Rect(X, Y, Width, Height); if (((Rect)(ref val)).Contains(current.mousePosition)) { UWindowManager.BringUWindowToFront(this); } } if (IsDraggable && (!UWindowManager.AnyWindowDragging || _isDragging)) { if ((int)current.type == 0) { val = new Rect(X, Y, Width, _controlHeight * 1.25f); if (((Rect)(ref val)).Contains(current.mousePosition)) { _isDragging = true; UWindowManager.AnyWindowDragging = true; _dragLastMouse = current.mousePosition; goto IL_00f9; } } if ((int)current.type == 1) { _isDragging = false; UWindowManager.AnyWindowDragging = false; } goto IL_00f9; } goto IL_015e; IL_015e: float viewWidth = UWindowManager.ViewWidth; float viewHeight = UWindowManager.ViewHeight; if (X + Width > viewWidth) { X = viewWidth - Width; } if (Y + Height > viewHeight) { Y = viewHeight - Height; } if (X < 0f) { X = 0f; } if (Y < 0f) { Y = 0f; } _nextControlY = Y + _controlHeight + _margin; if (_isDragging) { GUI.enabled = false; } GUI.Box(new Rect(X, Y, Width, Height), ""); GUI.Box(new Rect(X, Y, Width, 25f), WindowTitle); if ((Object)(object)ActiveSkin != (Object)null) { GUI.skin = ActiveSkin; } foreach (WControl control in _controls) { control.Draw(NextControlRect(control.SameLineRatio)); } GUI.enabled = true; return; IL_00f9: if ((int)current.type == 3 && _isDragging) { X += current.mousePosition.x - _dragLastMouse.x; Y += current.mousePosition.y - _dragLastMouse.y; _dragLastMouse = current.mousePosition; } goto IL_015e; } public void ResetPosition() { X = _startX; Y = _startY; } public bool SaveCfg(string absolutePath) { try { INIParser iNIParser = new INIParser(); iNIParser.Open(absolutePath); string sectionName = "UWindow." + WindowTitle; iNIParser.WriteValue(sectionName, "windowTitle", WindowTitle); iNIParser.WriteValue(sectionName, "x", X); iNIParser.WriteValue(sectionName, "y", Y); iNIParser.WriteValue(sectionName, "width", Width); iNIParser.WriteValue(sectionName, "height", Height); iNIParser.WriteValue(sectionName, "margin", _margin); iNIParser.WriteValue(sectionName, "controlHeight", _controlHeight); iNIParser.WriteValue(sectionName, "controlSpace", _controlSpace); for (int i = 0; i < _controls.Count; i++) { _controls[i].ExportData(i, sectionName, $"Control{i}.", iNIParser); } iNIParser.Close(); return true; } catch { return false; } } public bool LoadCfg(string absolutePath) { if (!File.Exists(absolutePath)) { return false; } try { INIParser iNIParser = new INIParser(); iNIParser.Open(absolutePath); string sectionName = "UWindow." + WindowTitle; WindowTitle = iNIParser.ReadValue(sectionName, "windowTitle", WindowTitle); X = iNIParser.ReadValue(sectionName, "x", X); Y = iNIParser.ReadValue(sectionName, "y", Y); Width = iNIParser.ReadValue(sectionName, "width", Width); Height = iNIParser.ReadValue(sectionName, "height", Height); _margin = iNIParser.ReadValue(sectionName, "margin", _margin); _controlHeight = iNIParser.ReadValue(sectionName, "controlHeight", _controlHeight); _controlSpace = iNIParser.ReadValue(sectionName, "controlSpace", _controlSpace); for (int i = 0; i < _controls.Count; i++) { _controls[i].ImportData(i, sectionName, $"Control{i}.", iNIParser); } iNIParser.Close(); return true; } catch { return false; } } public bool LoadSkin(GUISkin mainSkin) { if ((Object)(object)mainSkin == (Object)null) { return false; } ActiveSkin = mainSkin; return true; } public bool LoadSkinFromAssetBundle(string absolutePathAssetBundle, string mainSkinName) { AssetBundle assetBundle = AssetBundle.LoadFromFile(absolutePathAssetBundle); return LoadSkinFromAssetBundle(assetBundle, mainSkinName); } public bool LoadSkinFromAssetBundle(Stream assetFromStream, string mainSkinName) { AssetBundle assetBundle = AssetBundle.LoadFromStream(assetFromStream); return LoadSkinFromAssetBundle(assetBundle, mainSkinName); } public bool LoadSkinFromAssetBundle(byte[] assetFromMemory, string mainSkinName) { AssetBundle assetBundle = AssetBundle.LoadFromMemory(assetFromMemory); return LoadSkinFromAssetBundle(assetBundle, mainSkinName); } public bool LoadSkinFromAssetBundle(AssetBundle assetBundle, string mainSkinName) { if ((Object)(object)assetBundle == (Object)null) { return false; } LoadSkin(assetBundle.LoadAsset<GUISkin>(mainSkinName)); return true; } public bool RestoreDefaultSkin() { if ((Object)(object)UWindowManager.DefaultSkin == (Object)null) { return false; } ActiveSkin = UWindowManager.DefaultSkin; return true; } public static bool RestoreGlobalDefaultSkin() { return UWindowManager.LoadGlobalSkin_internal(UWindowManager.DefaultSkin); } public static void SetGuiScaleProvider(Func<float> provider) { UWindowManager.ScaleProvider = provider; } public static bool LoadGlobalSkin(GUISkin skin) { return UWindowManager.LoadGlobalSkin_internal(skin); } private Rect NextControlRect(float sameLineRatio) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) float num = Width - _margin * 2f; Rect result = default(Rect); ((Rect)(ref result))..ctor(X + _margin + _sameLineOffset, _nextControlY, num, _controlHeight); if (sameLineRatio.Equals(1f)) { _nextControlY += _controlHeight + _controlSpace; } else { ((Rect)(ref result)).width = ((Rect)(ref result)).width * sameLineRatio; _sameLineOffset += ((Rect)(ref result)).width; if (_sameLineOffset.Equals(num)) { _nextControlY += _controlHeight + _controlSpace; _sameLineOffset = 0f; } } return result; } public void Add(WControl c) { _controls.Add(c); if (_nextLineRatios.Count > 0) { c.SameLineRatio = _nextLineRatios[0]; _nextLineRatios.RemoveAt(0); } if (!DynamicHeight) { return; } float num = 25f + _margin; float num2 = _controlHeight + _controlSpace; int num3 = 0; float num4 = 1f; foreach (WControl control in _controls) { if (control.SameLineRatio.Equals(1f) || num4 < 0.05f) { num3++; num4 = 1f; continue; } num4 -= control.SameLineRatio; if (num4 < 0.05f) { num3++; } } Height = num + num2 * (float)num3; } public bool SameLine(int ratio1 = 1, int ratio2 = 1, int ratio3 = -1, int ratio4 = -1, int ratio5 = -1) { if (_nextLineRatios.Count > 0) { return false; } if (ratio1 <= 0 || ratio2 <= 0) { return false; } List<int> list = new List<int> { ratio1, ratio2 }; if (ratio3 > 0) { list.Add(ratio3); if (ratio4 > 0) { list.Add(ratio4); if (ratio5 > 0) { list.Add(ratio5); } } } int num = list.Min(); List<float> list2 = new List<float>(); foreach (int item in list) { list2.Add((float)item / (float)num); } float num2 = list2.Sum(); list2.Clear(); foreach (int item2 in list) { list2.Add((float)item2 / num2); } _nextLineRatios = list2; return true; } public UWindowControls.WSpace Space() { UWindowControls.WSpace wSpace = new UWindowControls.WSpace(); Add(wSpace); return wSpace; } public UWindowControls.WLabel Label(string text) { UWindowControls.WLabel wLabel = new UWindowControls.WLabel(text); Add(wLabel); return wLabel; } public UWindowControls.WButton Button(string text, Action onPressed) { UWindowControls.WButton wButton = new UWindowControls.WButton(onPressed, text); Add(wButton); return wButton; } public UWindowControls.WToggle Toggle(string text, Action<bool> onValueChanged, bool value = false) { UWindowControls.WToggle wToggle = new UWindowControls.WToggle(onValueChanged, value, text); Add(wToggle); return wToggle; } public UWindowControls.WSlider Slider(string text, Action<float> onValueChanged, float value, float min, float max, bool numberIndicator = false, string numberIndicatorFormat = "0.##") { UWindowControls.WSlider wSlider = new UWindowControls.WSlider(onValueChanged, value, min, max, numberIndicator, numberIndicatorFormat, text); Add(wSlider); return wSlider; } public UWindowControls.WTextField TextField(string text, Action<string> onValueChanged, string value, int maxSymbolLength = int.MaxValue, string regexReplace = "") { UWindowControls.WTextField wTextField = new UWindowControls.WTextField(onValueChanged, value, maxSymbolLength, regexReplace, text); Add(wTextField); return wTextField; } public UWindowControls.WIntField IntField(string text, Action<int> onValueChanged, int value, int maxSymbolLength = int.MaxValue) { UWindowControls.WIntField wIntField = new UWindowControls.WIntField(onValueChanged, value, maxSymbolLength, text); Add(wIntField); return wIntField; } public UWindowControls.WFloatField FloatField(string text, Action<float> onValueChanged, float value, int maxSymbolLength = int.MaxValue) { UWindowControls.WFloatField wFloatField = new UWindowControls.WFloatField(onValueChanged, value, maxSymbolLength, text); Add(wFloatField); return wFloatField; } public UWindowControls.WColorPicker ColorPicker(string text, Action<Color> onValueChanged, Color value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) UWindowControls.WColorPicker wColorPicker = new UWindowControls.WColorPicker(onValueChanged, value, text, _controlHeight); Add(wColorPicker); return wColorPicker; } public UWindowControls.WDropDown DropDown(string text, Action<int> onValueChanged, int value, Dictionary<int, string> list) { UWindowControls.WDropDown wDropDown = new UWindowControls.WDropDown(onValueChanged, value, list, text); Add(wDropDown); return wDropDown; } public UWindowControls.WSeparator Separator(Color lineColor = default(Color), float lineThickness = 2f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_002c: Unknown result type (might be due to invalid IL or missing references) if (lineColor == default(Color)) { ((Color)(ref lineColor))..ctor(1f, 1f, 1f, 0.9f); } UWindowControls.WSeparator wSeparator = new UWindowControls.WSeparator(lineColor, lineThickness); Add(wSeparator); return wSeparator; } } public static class UWindowControls { public class WLabel : WControl { private Rect _rect; internal WLabel(string displayedString) : base(displayedString) { if (displayedString == null || string.IsNullOrEmpty(displayedString) || string.IsNullOrWhiteSpace(displayedString)) { Logger.war("Label is null or empty! Are you sure you don't want to use Space control instead?"); } } internal override void Draw(Rect r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_0047: Unknown result type (might be due to invalid IL or missing references) _rect = r; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(((Rect)(ref _rect)).x, ((Rect)(ref _rect)).y); ((Rect)(ref _rect)).x = val.x; ((Rect)(ref _rect)).y = val.y; GUI.Label(_rect, DisplayedString); } internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ExportData(id, sectionName, keyBaseName, ini); } internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ImportData(id, sectionName, keyBaseName, ini); } } public class WButton : WControl { private readonly Action _onPressed; internal WButton(Action onPressed, string displayedString) : base(displayedString) { _onPressed = onPressed; } internal override void Draw(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (UGUI.Button(r, DisplayedString)) { _onPressed(); } } } public class WToggle : WControl { public readonly Action<bool> OnValueChanged; public bool Value; private GUIStyle _toggleStyle; internal WToggle(Action<bool> onValueChanged, bool value, string displayedString) : base(displayedString) { Value = value; OnValueChanged = onValueChanged; } internal override void Draw(Rect r) { //IL_0000: 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_001e: Expected O, but got Unknown Rect val = r; if (_toggleStyle == null) { _toggleStyle = new GUIStyle(GUI.skin.toggle); } int num = Mathf.RoundToInt(((Rect)(ref r)).width - ((Rect)(ref r)).height); _toggleStyle.overflow.left = -num; _toggleStyle.overflow.right = num; bool flag = GUI.Toggle(val, Value, string.Empty, _toggleStyle); if (flag != Value) { OnValueChanged(flag); } Value = flag; } internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ExportData(id, sectionName, keyBaseName, ini); ini.WriteValue(sectionName, keyBaseName + "value", Value); } internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ImportData(id, sectionName, keyBaseName, ini); Value = ini.ReadValue(sectionName, keyBaseName + "value", Value); } } public class WSlider : WControl { public readonly Action<float> OnValueChanged; public float Value; public float Step; private float _min; private float _max; private bool _numberIndicator; private bool _labelOnLeft; private string _numberIndicatorFormat; internal WSlider(Action<float> onValueChanged, float value, float min, float max, bool numberIndicator, string numberIndicatorFormat, string displayedString, bool labelOnLeft = true) : base(displayedString) { OnValueChanged = onValueChanged; Value = value; _min = min; _max = max; _numberIndicator = numberIndicator; _numberIndicatorFormat = numberIndicatorFormat; _labelOnLeft = labelOnLeft; } internal override void Draw(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) float num = UControls.LabelSlider(r, DisplayedString, Value, _min, _max, _numberIndicator, _numberIndicatorFormat, _labelOnLeft); if (Step > 0f && !num.Equals(Value)) { num = Mathf.Clamp(Mathf.Round(num / Step) * Step, _min, _max); } if (!num.Equals(Value)) { OnValueChanged(num); } Value = num; } internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ExportData(id, sectionName, keyBaseName, ini); ini.WriteValue(sectionName, keyBaseName + "value", Value); } internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ImportData(id, sectionName, keyBaseName, ini); Value = ini.ReadValue(sectionName, keyBaseName + "value", Value); } } public class WTextField : WControl { public readonly Action<string> OnValueChanged; public string Value; private string _regexReplace; private int _maxSymbolLength; private bool _labelOnLeft; internal WTextField(Action<string> onValueChanged, string value, int maxSymbolLength, string regexReplace, string displayedString, bool labelOnLeft = true) : base(displayedString) { OnValueChanged = onValueChanged; Value = value; _regexReplace = regexReplace; _maxSymbolLength = maxSymbolLength; _labelOnLeft = labelOnLeft; } internal override void Draw(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) string text = UControls.LabelTextField(r, DisplayedString, Value, _maxSymbolLength, _regexReplace, _labelOnLeft); if (_regexReplace != string.Empty) { text = Regex.Replace(text, _regexReplace, ""); } if (text != Value) { OnValueChanged(text); } Value = text; } internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ExportData(id, sectionName, keyBaseName, ini); ini.WriteValue(sectionName, keyBaseName + "value", Value); } internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ImportData(id, sectionName, keyBaseName, ini); Value = ini.ReadValue(sectionName, keyBaseName + "value", Value); } } public class WIntField : WControl { public readonly Action<int> OnValueChanged; public int Value; private string _regexReplace; private int _maxSymbolLength; private bool _labelOnLeft; internal WIntField(Action<int> onValueChanged, int value, int maxSymbolLength, string displayedString, bool labelOnLeft = true) : base(displayedString) { OnValueChanged = onValueChanged; Value = value; _regexReplace = "[^0-9]"; _maxSymbolLength = maxSymbolLength; _labelOnLeft = labelOnLeft; } internal override void Draw(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) string text = UControls.LabelTextField(r, DisplayedString, Value.ToString(), _maxSymbolLength, _regexReplace, _labelOnLeft); if (_regexReplace != string.Empty) { text = Regex.Replace(text, _regexReplace, ""); } long.TryParse(text, out var result); int num = (int)((result > int.MaxValue) ? int.MaxValue : result); if (!result.Equals(Value)) { OnValueChanged(num); } Value = num; } internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ExportData(id, sectionName, keyBaseName, ini); ini.WriteValue(sectionName, keyBaseName + "value", Value); } internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ImportData(id, sectionName, keyBaseName, ini); Value = ini.ReadValue(sectionName, keyBaseName + "value", Value); } } public class WFloatField : WControl { public readonly Action<float> OnValueChanged; public float Value; private string _regexReplace; private int _maxSymbolLength; private bool _labelOnLeft; internal WFloatField(Action<float> onValueChanged, float value, int maxSymbolLength, string displayedString, bool labelOnLeft = true) : base(displayedString) { OnValueChanged = onValueChanged; Value = value; _regexReplace = "[^0-9.,]"; _maxSymbolLength = maxSymbolLength; _labelOnLeft = labelOnLeft; } internal override void Draw(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) string text = UControls.LabelTextField(r, DisplayedString, Value.ToString(), _maxSymbolLength, _regexReplace, _labelOnLeft); if (_regexReplace != string.Empty) { text = Regex.Replace(text, _regexReplace, ""); } text = text.Replace(',', '.'); double.TryParse(text, out var result); float num = (float)result; if (!num.Equals(Value)) { OnValueChanged(num); } Value = num; } internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ExportData(id, sectionName, keyBaseName, ini); ini.WriteValue(sectionName, keyBaseName + "value", Value); } internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ImportData(id, sectionName, keyBaseName, ini); Value = ini.ReadValue(sectionName, keyBaseName + "value", Value); } } public class WColorPicker : WControl { public Color CurrentColor; private readonly Action<Color> _onValueChanged; private bool _isPickerOpen; private Rect _rect; private readonly float _controlHeight; private Color _revertColor; private readonly GUIStyle _whiteButtonGUIStyle = new GUIStyle { normal = new GUIStyleState { background = Texture2D.whiteTexture } }; private bool IsPickerOpen { get { return _isPickerOpen; } set { //IL_0023: 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) _isPickerOpen = value; UWindowManager.AllWindowsDisabled = value; if (value) { UWindowManager.ActiveOptionMenu = DrawPicker; _revertColor = CurrentColor; } else { UWindowManager.ActiveOptionMenu = null; } } } internal WColorPicker(Action<Color> onValueChanged, Color clr, string displayedString, float controlHeight) : base(displayedString) { //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_0007: 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_001c: Expected O, but got Unknown //IL_0021: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0045: Unknown result type (might be due to invalid IL or missing references) _onValueChanged = onValueChanged; CurrentColor = clr; _controlHeight = controlHeight; _revertColor = CurrentColor; } internal override void Draw(Rect r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) _rect = r; bool num = !string.IsNullOrEmpty(DisplayedString); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width * 0.666f, ((Rect)(ref r)).height); Rect bounds = default(Rect); ((Rect)(ref bounds))..ctor(((Rect)(ref val)).x + ((Rect)(ref val)).width, ((Rect)(ref r)).y, ((Rect)(ref r)).width - ((Rect)(ref val)).width, ((Rect)(ref r)).height); if (!num) { ((Rect)(ref bounds))..ctor(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 2f, ((Rect)(ref r)).height); } if (UWindowManager.AllWindowsDisabled && IsPickerOpen) { GUI.enabled = true; } if (num) { GUI.Label(val, DisplayedString); } Color color = GUI.color; GUI.color = CurrentColor; if (UGUI.Button(bounds, string.Empty, _whiteButtonGUIStyle)) { IsPickerOpen = !IsPickerOpen; } if (UWindowManager.AllWindowsDisabled && IsPickerOpen) { GUI.enabled = false; } GUI.color = color; } internal void DrawPicker() { //IL_0007: 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_003d: 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) //IL_006d: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_007f: Unknown result type (might be due to invalid IL or missing references) float num = 200f; Color color = CurrentColor; if (UControls.ColorPicker(new Vector2(((Rect)(ref _rect)).x + ((Rect)(ref _rect)).width - num, ((Rect)(ref _rect)).y + ((Rect)(ref _rect)).height), ref color, mainBoxColoredTexture: true, num, _controlHeight)) { color = _revertColor; IsPickerOpen = false; } if (color != CurrentColor) { _onValueChanged(color); } CurrentColor = color; } internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) base.ExportData(id, sectionName, keyBaseName, ini); ini.WriteValue(sectionName, keyBaseName + "color", CurrentColor); } internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) base.ImportData(id, sectionName, keyBaseName, ini); CurrentColor = ini.ReadValue(sectionName, keyBaseName + "color", CurrentColor); } } public class WDropDown : WControl { public readonly Action<int> OnValueChanged; public readonly Dictionary<int, string> ValuesList; public int Value; private bool _isDropDownOpen; private Vector2 _scrollPos; private Rect _selectedRect; private static GUIStyle _dropDownOptionGUIStyle; private bool IsDropDownOpen { get { return _isDropDownOpen; } set { _isDropDownOpen = value; UWindowManager.AllWindowsDisabled = value; if (value) { UWindowManager.ActiveOptionMenu = DrawDropDown; } else { UWindowManager.ActiveOptionMenu = null; } } } internal WDropDown(Action<int> onValueChanged, int value, Dictionary<int, string> valuesList, string displayedString) : base(displayedString) { OnValueChanged = onValueChanged; Value = value; ValuesList = valuesList; } internal override void Draw(Rect r) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0025: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if (_dropDownOptionGUIStyle == null) { _dropDownOptionGUIStyle = new GUIStyle(GUI.skin.label); _dropDownOptionGUIStyle.hover.textColor = Color.gray; _dropDownOptionGUIStyle.onHover.textColor = Color.gray; } float num = 5f; string text = ValuesList[Value]; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width * 0.5f, ((Rect)(ref r)).height); _selectedRect = new Rect(((Rect)(ref r)).x + ((Rect)(ref val)).width + num, ((Rect)(ref r)).y, ((Rect)(ref r)).width - ((Rect)(ref val)).width - num, ((Rect)(ref r)).height); if (string.IsNullOrEmpty(DisplayedString)) { _selectedRect = r; } if (UWindowManager.AllWindowsDisabled && IsDropDownOpen) { GUI.enabled = true; } if (!string.IsNullOrEmpty(DisplayedString)) { GUI.Label(val, DisplayedString); } if (UGUI.Button(_selectedRect, text)) { IsDropDownOpen = !IsDropDownOpen; } if (UWindowManager.AllWindowsDisabled && IsDropDownOpen) { GUI.enabled = false; } } internal void DrawDropDown() { //IL_0022: 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) bool isOpen; int num = UControls.DropDown(new Vector2(((Rect)(ref _selectedRect)).x, ((Rect)(ref _selectedRect)).y + ((Rect)(ref _selectedRect)).height), ValuesList, _scrollPos, out _scrollPos, out isOpen, _dropDownOptionGUIStyle, mainBoxColoredTexture: true, ((Rect)(ref _selectedRect)).width); if ((num >= 0) & (num != Value)) { OnValueChanged(num); } if (num >= 0) { Value = num; } IsDropDownOpen = isOpen; } internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ExportData(id, sectionName, keyBaseName, ini); ini.WriteValue(sectionName, keyBaseName + "value", Value); } internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini) { base.ImportData(id, sectionName, keyBaseName, ini); Value = ini.ReadValue(sectionName, keyBaseName + "value", Value); } } public class WSeparator : WControl { private Color _lineColor; private float _lineThickness; public WSeparator(Color lineColor, float lineThickness) : base(string.Empty) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) _lineColor = lineColor; _lineThickness = lineThickness; } internal override void Draw(Rect r) { //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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_002d: 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) Color color = _lineColor; if (!GUI.enabled) { color = _lineColor * new Color(1f, 1f, 1f, 0.5f); } UControls.ColoredBox(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + ((Rect)(ref r)).height / 2f - _lineThickness / 2f, ((Rect)(ref r)).width, _lineThickness), color); } } public class WSpace : WControl { internal WSpace() : base(string.Empty) { } internal override void Draw(Rect r) { } internal override void ExportData(int id, string sectionName, string keyBaseName, INIParser ini) { } internal override void ImportData(int id, string sectionName, string keyBaseName, INIParser ini) { } } } public abstract class WControl { internal float SameLineRatio = 1f; internal string DisplayedString; internal WControl(string displayedString) { DisplayedString = displayedString; } internal abstract void Draw(Rect r); internal virtual void ExportData(int id, string sectionName, string keyBaseName, INIParser ini) { ini.WriteValue(sectionName, keyBaseName + "displayString", DisplayedString); } internal virtual void ImportData(int id, string sectionName, string keyBaseName, INIParser ini) { DisplayedString = ini.ReadValue(sectionName, keyBaseName + "displayString", DisplayedString); } } internal static class UWindowManager { public static GameObject BManagerG = null; public static UWindowManagerBehaviour BManager = null; public static bool AllWindowsDisabled = false; public static bool AnyWindowDragging = false; public static Action ActiveOptionMenu = null; public static readonly Vector2 DynamicWindowsMargin = Vector2.one * 10f; private static Vector2 _dynamicWindowsNext = Vector2.one * 10f; internal static Func<float> ScaleProvider = null; private const float MinScale = 0.25f; private const float MaxScale = 8f; private static bool _pointerDown; public static List<UWindow> Windows { get; private set; } public static bool IsDrawing { get; set; } = true; public static GUISkin DefaultSkin { get; internal set; } = null; internal static float Scale { get; private set; } = 1f; internal static float ViewWidth => (float)Screen.width / Scale; internal static float ViewHeight => (float)Screen.height / Scale; internal static void Register(UWindow win) { if (Windows == null) { Windows = new List<UWindow>(); } if ((Object)(object)BManager == (Object)null || (Object)(object)BManagerG == (Object)null) { InitializeManager(); } string winGuid = Guid.NewGuid().ToString(); win.WinGuid = winGuid; Windows.Add(win); } internal static bool LoadGlobalSkin_internal(GUISkin skin) { if ((Object)(object)skin == (Object)null) { return false; } foreach (UWindow window in Windows) { window.LoadSkin(skin); } return true; } public static Vector2 GetDynamicWindowPos(float currentWidth) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Vector2 dynamicWindowsNext = _dynamicWindowsNext; _dynamicWindowsNext.x += currentWidth + DynamicWindowsMargin.x; return dynamicWindowsNext; } internal static void BringUWindowToFront(UWindow win) { Windows.Remove(win); Windows.Add(win); } private static int GetIndexByGuid(string guid) { return Windows.FindIndex((UWindow win) => win.WinGuid == guid); } private static UWindow GetUWinByGuid(string guid) { return Windows.FirstOrDefault((UWindow w) => w.WinGuid == guid); } internal static void OnBehaviourGUI() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_003f: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (!IsDrawing) { return; } EventType rawType = Event.current.rawType; if (Event.current.button == 0) { if ((int)rawType == 0) { _pointerDown = true; } else if ((int)rawType == 1) { _pointerDown = false; } } if ((int)Event.current.type == 8 && !_pointerDown) { Scale = ReadScale(); } Matrix4x4 matrix = GUI.matrix; if (Scale != 1f) { GUI.matrix = Matrix4x4.Scale(new Vector3(Scale, Scale, 1f)); } try { foreach (UWindow item in Windows.ToList()) { item.Draw(); } if (ActiveOptionMenu != null) { ActiveOptionMenu(); } } finally { GUI.matrix = matrix; } } private static float ReadScale() { float num; try { num = ScaleProvider?.Invoke() ?? 1f; } catch (Exception ex) { Logger.err("GUI scale provider failed, drawing at scale 1: " + ex.Message); ScaleProvider = null; return 1f; } if (float.IsNaN(num) || float.IsInfinity(num) || num <= 0f) { return 1f; } num = Mathf.Clamp(num, 0.25f, 8f); float num2 = LargestFittingScale(); if (num > 1f && num > num2) { num = Mathf.Max(1f, num2); } return num; } private static float LargestFittingScale() { float num = 0f; float num2 = 0f; if (Windows != null) { foreach (UWindow window in Windows) { num = Mathf.Max(num, window.Width); num2 = Mathf.Max(num2, window.Height); } } float num3 = ((num > 0f) ? ((float)Screen.width / num) : float.MaxValue); float num4 = ((num2 > 0f) ? ((float)Screen.height / num2) : float.MaxValue); return Mathf.Min(num3, num4); } private static void InitializeManager() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown BManagerG = new GameObject("UrGUI Manager"); BManager = BManagerG.AddComponent<UWindowManagerBehaviour>(); UWindowManagerBehaviour.Instance.LoadDefaultSkin(); } } internal class UWindowManagerBehaviour : MonoBehaviour { public static UWindowManagerBehaviour Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void Start() { } private void OnEnable() { } private void OnGUI() { UWindowManager.OnBehaviourGUI(); } public void LoadDefaultSkin() { ((MonoBehaviour)this).StartCoroutine(m_LoadDefaultSkin()); } private IEnumerator m_LoadDefaultSkin() { Assembly executingAssembly = Assembly.GetExecutingAssembly(); byte[] array = null; int num = 0; using (Stream stream = executingAssembly.GetManifestResourceStream("UrGUI.Skins.main")) { if (stream == null) { Debug.LogWarning((object)"Couldn't load default skin! Filestream is null"); yield break; } array = new byte[stream.Length]; num = stream.Read(array, 0, array.Length); } if (array.Length != num) { Debug.LogError((object)"Stream didn't ready all of available bytes!"); } AssetBundleCreateRequest assetBundleReq = AssetBundle.LoadFromMemoryAsync(array); while (!((AsyncOperation)assetBundleReq).isDone) { Logger.log($"Loading skin asset-bundle from memory... {((AsyncOperation)assetBundleReq).progress * 100f:0.##}%"); yield return null; } Logger.log("AssetBundle loaded!"); AssetBundleRequest skinReq = assetBundleReq.assetBundle.LoadAssetAsync<GUISkin>("main"); while (!((AsyncOperation)skinReq).isDone) { Logger.log($"Loading skin from asset-bundle... {((AsyncOperation)skinReq).progress * 100f:0.##}%"); yield return null; } Logger.log("Skin loaded!"); UWindowManager.DefaultSkin = (GUISkin)skinReq.asset; UWindowManager.LoadGlobalSkin_internal(UWindowManager.DefaultSkin); yield return null; } } } namespace UrGUI.UWindow.Utils { public static class GUIFormatting { public static GUIStyle StringStyle { get; set; } = new GUIStyle(GUI.skin.label); public static Vector2 GetContentStringSize(string text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) GUIContent val = new GUIContent(text); return StringStyle.CalcSize(val); } } public static class UControls { public static float LabelSlider(Rect rect, string label, float value, float min, float max, bool numberIndicator = false, string numberIndicatorFormat = "0.##", bool labelOnLeft = true, float offsetX = 5f) { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_00d0: 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_00e5: Unknown result type (might be due to invalid IL or missing references) Vector2 contentStringSize = GUIFormatting.GetContentStringSize(label); Rect val = default(Rect); if (labelOnLeft) { ((Rect)(ref val))..ctor(0f, 0f, contentStringSize.x, ((Rect)(ref rect)).height); } else { ((Rect)(ref val))..ctor(((Rect)(ref rect)).width - contentStringSize.x + offsetX, 0f, contentStringSize.x, ((Rect)(ref rect)).height); } Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(labelOnLeft ? (((Rect)(ref val)).width + offsetX) : 0f, 0f, ((Rect)(ref rect)).width - ((Rect)(ref val)).width - offsetX, ((Rect)(ref rect)).height); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref val2)).x + ((Rect)(ref val2)).width / 2f - 30f, 0f, ((Rect)(ref val2)).width / 2f, ((Rect)(ref rect)).height); GUI.BeginGroup(rect); GUI.Label(val, label); float result = GUI.HorizontalSlider(val2, value, min, max); if (numberIndicator) { GUI.Label(val3, value.ToString(numberIndicatorFormat)); } GUI.EndGroup(); return result; } public static string LabelTextField(Rect rect, string label, string value, int maxSymbolLength, string regexReplace = "", bool labelOnLeft = true, float offsetX = 5f) { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) Vector2 contentStringSize = GUIFormatting.GetContentStringSize(label); Rect val = default(Rect); if (labelOnLeft) { ((Rect)(ref val))..ctor(0f, 0f, contentStringSize.x, ((Rect)(ref rect)).height); } else { ((Rect)(ref val))..ctor(((Rect)(ref rect)).width - contentStringSize.x + offsetX, 0f, contentStringSize.x, ((Rect)(ref rect)).height); } Rect val2 = new Rect(labelOnLeft ? (((Rect)(ref val)).width + offsetX) : 0f, 0f, ((Rect)(ref rect)).width - ((Rect)(ref val)).width - offsetX, ((Rect)(ref rect)).height); GUI.BeginGroup(rect); GUI.Label(val, label); string text = GUI.TextField(val2, value, maxSymbolLength); GUI.EndGroup(); if (!string.IsNullOrEmpty(regexReplace)) { text = Regex.Replace(text, regexReplace, string.Empty); } return text; } public static Vector3 LabelVector3Field(Rect rect, string label, Vector3 value, Vector3 min, Vector3 max) { throw new NotImplementedException(); } public static bool ColorPicker(Vector2 leftTopCorner, ref Color color, bool mainBoxColoredTexture = false, float sliderWidth = 200f, float controlHeight = 12f, float offsetY = 5f, float margin = 5f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) //IL_004b: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) float x = GUIFormatting.GetContentStringSize("X: ").x; Rect val = default(Rect); ((Rect)(ref val))..ctor(leftTopCorner.x, leftTopCorner.y, x + sliderWidth + margin * 2f, controlHeight * 4f + offsetY * 3f + margin * 2f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(leftTopCorner.x + margin, leftTopCorner.y + margin, x + sliderWidth, controlHeight * 4f + offsetY * 3f); if (mainBoxColoredTexture) { ColoredBox(val, Color.black); } else { GUI.Box(val, ""); } if (UGUI.Button(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y - controlHeight, ((Rect)(ref val)).width / 3f, controlHeight), "Cancel")) { return true; } GUI.BeginGroup(val2); Color val3 = color; val3.r = LabelSlider(new Rect(0f, controlHeight * 0f + offsetY * 0f, ((Rect)(ref val2)).width, controlHeight), "R: ", color.r, 0f, 1f); val3.g = LabelSlider(new Rect(0f, controlHeight * 1f + offsetY * 1f, ((Rect)(ref val2)).width, controlHeight), "G: ", color.g, 0f, 1f); val3.b = LabelSlider(new Rect(0f, controlHeight * 2f + offsetY * 2f, ((Rect)(ref val2)).width, controlHeight), "B: ", color.b, 0f, 1f); val3.a = LabelSlider(new Rect(0f, controlHeight * 3f + offsetY * 3f, ((Rect)(ref val2)).width, controlHeight), "A: ", color.a, 0f, 1f); GUI.EndGroup(); color = val3; return false; } public static int DropDown(Vector2 leftTopCorner, Dictionary<int, string> list, Vector2 scrollPos, out Vector2 scrollPosNew, out bool isOpen, GUIStyle optionGUIStyle, bool mainBoxColoredTexture = false, float width = 0f, int optionCountShown = 4, float optionHeight = 22f) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008d: 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) int num = 4; int result = -1; isOpen = true; Rect val = default(Rect); ((Rect)(ref val))..ctor(leftTopCorner.x, leftTopCorner.y, width + 15f, optionHeight * (float)optionCountShown); if (mainBoxColoredTexture) { ColoredBox(val, Color.black); } else { GUI.Box(val, string.Empty); } GUI.BeginGroup(val); scrollPosNew = GUI.BeginScrollView(new Rect(0f, 0f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), scrollPos, new Rect(0f, 0f, 0f, (float)list.Count * optionHeight)); for (int i = 0; i < list.Count; i++) { if (UGUI.Button(new Rect((float)num, (float)i * optionHeight, ((Rect)(ref val)).width - (float)num - 15f, optionHeight), list[i], optionGUIStyle)) { result = i; isOpen = false; } } GUI.EndScrollView(); GUI.EndGroup(); return result; } public static void ColoredBox(Rect r, Color color) { //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_000b: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture); GUI.color = color2; } } } namespace UrGUI.Utils { public class INIParser { public int error; private object m_Lock = new object(); private string m_FileName; private string m_iniString; private bool m_AutoFlush; private Dictionary<string, Dictionary<string, string>> m_Sections = new Dictionary<string, Dictionary<string, string>>(); private Dictionary<string, Dictionary<string, string>> m_Modified = new Dictionary<string, Dictionary<string, string>>(); private bool m_CacheModified; public string FileName => m_FileName; public string iniString => m_iniString; public void Open(string path) { m_FileName = path; if (File.Exists(m_FileName)) { m_iniString = File.ReadAllText(m_FileName); } else { File.Create(m_FileName).Close(); m_iniString = ""; } Initialize(m_iniString, AutoFlush: false); } public void Open(TextAsset name) { if ((Object)(object)name == (Object)null) { error = 1; m_iniString = ""; m_FileName = null; Initialize(m_iniString, AutoFlush: false); return; } m_FileName = Application.persistentDataPath + ((Object)name).name; if (File.Exists(m_FileName)) { m_iniString = File.ReadAllText(m_FileName); } else { m_iniString = name.text; } Initialize(m_iniString, AutoFlush: false); } public void OpenFromString(string str) { m_FileName = null; Initialize(str, AutoFlush: false); } public override string ToString() { return m_iniString; } private void Initialize(string iniString, bool AutoFlush) { m_iniString = iniString; m_AutoFlush = AutoFlush; Refresh(); } public void Close() { lock (m_Lock) { PerformFlush(); m_FileName = null; m_iniString = null; } } private string ParseSectionName(string Line) { if (!Line.StartsWith("[")) { return null; } if (!Line.EndsWith("]")) { return null; } if (Line.Length < 3) { return null; } return Line.Substring(1, Line.Length - 2); } private bool ParseKeyValuePair(string Line, ref string Key, ref string Value) { int num; if ((num = Line.IndexOf('=')) <= 0) { return false; } int num2 = Line.Length - num - 1; Key = Line.Substring(0, num).Trim(); if (Key.Length <= 0) { return false; } Value = ((num2 > 0) ? Line.Substring(num + 1, num2).Trim() : ""); return true; } private bool isComment(string Line) { string Key = null; string Value = null; if (ParseSectionName(Line) != null) { return false; } if (ParseKeyValuePair(Line, ref Key, ref Value)) { return false; } return true; } private void Refresh() { lock (m_Lock) { StringReader stringReader = null; try { m_Sections.Clear(); m_Modified.Clear(); stringReader = new StringReader(m_iniString); Dictionary<string, string> dictionary = null; string Key = null; string Value = null; string text; while ((text = stringReader.ReadLine()) != null) { text = text.Trim(); string text2 = ParseSectionName(text); if (text2 != null) { if (m_Sections.ContainsKey(text2)) { dictionary = null; continue; } dictionary = new Dictionary<string, string>(); m_Sections.Add(text2, dictionary); } else if (dictionary != null && ParseKeyValuePair(text, ref Key, ref Value) && !dictionary.ContainsKey(Key)) { dictionary.Add(Key, Value); } } } finally { stringReader?.Close(); stringReader = null; } } } private void PerformFlush() { if (!m_CacheModified) { return; } m_CacheModified = false; StringWriter stringWriter = new StringWriter(); try { Dictionary<string, string> value = null; Dictionary<string, string> value2 = null; StringReader stringReader = null; try { stringReader = new StringReader(m_iniString); string Key = null; string Value = null; bool flag = true; bool flag2 = false; string Key2 = null; string Value2 = null; while (flag) { string text = stringReader.ReadLine(); flag = text != null; bool flag3; string text2; if (flag) { flag3 = true; text = text.Trim(); text2 = ParseSectionName(text); } else { flag3 = false; text2 = null; } if (text2 != null || !flag) { if (value != null && value.Count > 0) { StringBuilder stringBuilder = stringWriter.GetStringBuilder(); while (stringBuilder[stringBuilder.Length - 1] == '\n' || stringBuilder[stringBuilder.Length - 1] == '\r') { stringBuilder.Length--; } stringWriter.WriteLine(); foreach (string key in value.Keys) { if (value.TryGetValue(key, out Value)) { stringWriter.Write(key); stringWriter.Write('='); stringWriter.WriteLine(Value); } } stringWriter.WriteLine(); value.Clear(); } if (flag && !m_Modified.TryGetValue(text2, out value)) { value = null; } } else if (value != null && ParseKeyValuePair(text, ref Key, ref Value) && value.TryGetValue(Key, out Value)) { flag3 = false; value.Remove(Key); stringWriter.Write(Key); stringWriter.Write('='); stringWriter.WriteLine(Value); } if (flag3) { if (text2 != null) { if (!m_Sections.ContainsKey(text2)) { flag2 = true; value2 = null; } else { flag2 = false; m_Sections.TryGetValue(text2, out value2); } } else if (value2 != null && ParseKeyValuePair(text, ref Key2, ref Value2)) { flag2 = !value2.ContainsKey(Key2); } } if (flag3) { if (isComment(text)) { stringWriter.WriteLine(text); } else if (!flag2) { stringWriter.WriteLine(text); } } } stringReader.Close(); stringReader = null; } finally { stringReader?.Close(); stringReader = null; } foreach (KeyValuePair<string, Dictionary<string, string>> item in m_Modified) { value = item.Value; if (value.Count <= 0) { continue; } stringWriter.WriteLine(); stringWriter.Write('['); stringWriter.Write(item.Key); stringWriter.WriteLine(']'); foreach (KeyValuePair<string, string> item2 in value) { stringWriter.Write(item2.Key); stringWriter.Write('='); stringWriter.WriteLine(item2.Value); } value.Clear(); } m_Modified.Clear(); m_iniString = stringWriter.ToString(); stringWriter.Close(); stringWriter = null; if (m_FileName != null) { File.WriteAllText(m_FileName, m_iniString); } } finally { stringWriter?.Close(); stringWriter = null; } } public bool IsSectionExists(string SectionName) { return m_Sections.ContainsKey(SectionName); } public bool IsKeyExists(string SectionName, string Key) { if (m_Sections.ContainsKey(SectionName)) { m_Sections.TryGetValue(SectionName, out var value); return value.ContainsKey(Key); } return false; } public void SectionDelete(string SectionName) { if (!IsSectionExists(SectionName)) { return; } lock (m_Lock) { m_CacheModified = true; m_Sections.Remove(SectionName); m_Modified.Remove(SectionName); if (m_AutoFlush) { PerformFlush(); } } } public void KeyDelete(string SectionName, string Key) { if (!IsKeyExists(SectionName, Key)) { return; } lock (m_Lock) { m_CacheModified = true; m_Sections.TryGetValue(SectionName, out var value); value.Remove(Key); if (m_Modified.TryGetValue(SectionName, out value)) { value.Remove(SectionName); } if (m_AutoFlush) { PerformFlush(); } } } public string ReadValue(string SectionName, string Key, string DefaultValue) { lock (m_Lock) { if (!m_Sections.TryGetValue(SectionName, out var value)) { return DefaultValue; } if (!value.TryGetValue(Key, out var value2)) { return DefaultValue; } return value2; } } public void WriteValue(string SectionName, string Key, string Value) { lock (m_Lock) { m_CacheModified = true; if (!m_Sections.TryGetValue(SectionName, out var value)) { value = new Dictionary<string, string>(); m_Sections.Add(SectionName, value); } if (value.ContainsKey(Key)) { value.Remove(Key); } value.Add(Key, Value); if (!m_Modified.TryGetValue(SectionName, out value)) { value = new Dictionary<string, string>(); m_Modified.Add(SectionName, value); } if (value.ContainsKey(Key)) { value.Remove(Key); } value.Add(Key, Value); if (m_AutoFlush) { PerformFlush(); } } } private string EncodeByteArray(byte[] Value) { if (Value == null) { return null; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < Value.Length; i++) { string text = Convert.ToString(Value[i], 16); int length = text.Length; if (length > 2) { stringBuilder.Append(text.Substring(length - 2, 2)); continue; } if (length < 2) { stringBuilder.Append("0"); } stringBuilder.Append(text); } return stringBuilder.ToString(); } private byte[] DecodeByteArray(string Value) { if (Value == null) { return null; } int length = Value.Length; if (length < 2) { return new byte[0]; } length /= 2; byte[] array = new byte[length]; for (int i = 0; i < length; i++) { array[i] = Convert.ToByte(Value.Substring(i * 2, 2), 16); } return array; } public bool ReadValue(string SectionName, string Key, bool DefaultValue) { if (int.TryParse(ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture)), out var result)) { return result != 0; } return DefaultValue; } public int ReadValue(string SectionName, string Key, int DefaultValue) { if (int.TryParse(ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture)), NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } return DefaultValue; } public long ReadValue(string SectionName, string Key, long DefaultValue) { if (long.TryParse(ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture)), NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } return DefaultValue; } public double ReadValue(string SectionName, string Key, double DefaultValue) { if (double.TryParse(ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture)), NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } return DefaultValue; } public float ReadValue(string SectionName, string Key, float DefaultValue) { if (float.TryParse(ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture)), NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } return DefaultValue; } public byte[] ReadValue(string SectionName, string Key, byte[] DefaultValue) { string value = ReadValue(SectionName, Key, EncodeByteArray(DefaultValue)); try { return DecodeByteArray(value); } catch (FormatException) { return DefaultValue; } } public DateTime ReadValue(string SectionName, string Key, DateTime DefaultValue) { if (DateTime.TryParse(ReadValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture)), CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.NoCurrentDateDefault | DateTimeStyles.AssumeLocal, out var result)) { return result; } return DefaultValue; } public Color ReadValue(string SectionName, string Key, Color DefaultValue) { //IL_0008: 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_0021: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); if (ColorUtility.TryParseHtmlString(ReadValue(SectionName, Key, "#" + ColorUtility.ToHtmlStringRGB(DefaultValue)), ref result)) { return result; } return DefaultValue; } public void WriteValue(string SectionName, string Key, bool Value) { WriteValue(SectionName, Key, Value ? "1" : "0"); } public void WriteValue(string SectionName, string Key, int Value) { WriteValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture)); } public void WriteValue(string SectionName, string Key, long Value) { WriteValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture)); } public void WriteValue(string SectionName, string Key, double Value) { WriteValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture)); } public void WriteValue(string SectionName, string Key, float Value) { WriteValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture)); } public void WriteValue(string SectionName, string Key, byte[] Value) { WriteValue(SectionName, Key, EncodeByteArray(Value)); } public void WriteValue(string SectionName, string Key, DateTime Value) { WriteValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture)); } public void WriteValue(string SectionName, string Key, Color Value) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) WriteValue(SectionName, Key, "#" + ColorUtility.ToHtmlStringRGB(Value)); } } public static class Logger { [Flags] public enum PrintType { None = 0, Error = 1, Warnings = 2, Info = 4 } public static readonly Action<object, PrintType> OnLoggerPrint = delegate { }; private static PrintType _debugFilter = PrintType.Error | PrintType.Warnings; public static PrintType DebugFilter { get { return _debugFilter; } set { _debugFilter = value; } } internal static void log(object msg) { if (_debugFilter.HasFlag(PrintType.Info)) { Debug.Log(msg); if (OnLoggerPrint != null) { OnLoggerPrint(msg, PrintType.Info); } } } internal static void war(object msg) { if (_debugFilter.HasFlag(PrintType.Warnings)) { Debug.LogWarning(msg); if (OnLoggerPrint != null) { OnLoggerPrint(msg, PrintType.Warnings); } } } internal static void err(object msg) { if (_debugFilter.HasFlag(PrintType.Error)) { Debug.LogError(msg); if (OnLoggerPrint != null) { OnLoggerPrint(msg, PrintType.Error); } } } } internal static class UGUI { private static int highestDepthID = 0; private static Vector2 touchBeganPosition = Vector2.zero; private static EventType lastEventType = (EventType)8; private static bool wasDragging = false; private static int frame = 0; private static int lastEventFrame = 0; public static bool Button(string text, params GUILayoutOption[] options) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0013: Unknown result type (might be due to invalid IL or missing references) GUIContent val = new GUIContent(text); return Button(GUILayoutUtility.GetRect(val, GUI.skin.button, options), val, GUI.skin.button); } public static bool Button(string text, GUIStyle style = null, params GUILayoutOption[] options) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) GUIContent val = new GUIContent(text); return Button(GUILayoutUtility.GetRect(val, style, options), val, style); } public static bool Button(Texture image, params GUILayoutOption[] options) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0013: Unknown result type (might be due to invalid IL or missing references) GUIContent val = new GUIContent(image); return Button(GUILayoutUtility.GetRect(val, GUI.skin.button, options), val, GUI.skin.button); } public static bool Button(Texture image, GUIStyle style = null, params GUILayoutOption[] options) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) GUIContent val = new GUIContent(image); return Button(GUILayoutUtility.GetRect(val, style, options), val, style); } public static bool Button(GUIContent content, params GUILayoutOption[] options) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return Button(GUILayoutUtility.GetRect(content, GUI.skin.button, options), content, GUI.skin.button); } public static bool Button(GUIContent content, GUIStyle style = null, params GUILayoutOption[] options) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return Button(GUILayoutUtility.GetRect(content, style, options), content, style); } public static bool Button(Rect bounds, string text, GUIStyle style = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0007: Unknown result type (might be due to invalid IL or missing references) GUIContent content = new GUIContent(text); return Button(bounds, content, style); } public static bool Button(Rect bounds, Texture image, GUIStyle style = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0007: Unknown result type (might be due to invalid IL or missing references) GUIContent content = new GUIContent(image); return Button(bounds, content, style); } private unsafe static bool Button(Rect bounds, GUIContent content, GUIStyle style = null) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 //IL_0094: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Invalid comparison between Unknown and I4 //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Invalid comparison between Unknown and I4 //IL_00b6: 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_00dd: 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_00e6: Invalid comparison between Unknown and I4 int controlID = GUIUtility.GetControlID(((object)(*(Rect*)(&bounds))/*cast due to .constrained prefix*/).GetHashCode(), (FocusType)2); bool num = ((Rect)(ref bounds)).Contains(Event.current.mousePosition); int num2 = (1000 - GUI.depth) * 1000 + controlID; if (num && num2 > highestDepthID) { highestDepthID = num2; } bool flag = highestDepthID == num2; bool flag2 = flag; if (style == null) { style = GUI.skin.FindStyle("button"); } if ((int)Event.current.type == 8 && (int)lastEventType != 8) { highestDepthID = 0; frame++; } lastEventType = Event.current.type; if ((int)Event.current.type == 7) { bool flag3 = GUIUtility.hotControl == controlID; style.Draw(bounds, content, flag2, flag3, false, false); } if (frame <= 1 + lastEventFrame) { return false; } EventType typeForControl = Event.current.GetTypeForControl(controlID); if ((int)typeForControl != 0) { if ((int)typeForControl == 1 && flag && !wasDragging) { GUIUtility.hotControl = 0; lastEventFrame = frame; return true; } } else if (flag && !wasDragging) { GUIUtility.hotControl = controlID; } return false; } } } namespace BattleImprove { [BepInPlugin("BattleImprove", "Battle Improvements", "1.6.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; internal static Harmony Harmony; internal static LocalizationManager i18n; private static bool debugMode; internal static GameObject PluginGameObject; internal static GameObject IndicatorGameObject; public void Awake() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin BattleImprove 1.6.0 is loading!"); Config.InitConfig(((BaseUnityPlugin)this).Config); i18n = new LocalizationManager(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location)); Harmony = new Harmony("BattleImprove"); Patching(); ((MonoBehaviour)this).StartCoroutine(PrefabManager.LoadAssetBundle()); Logger.LogInfo((object)"Plugin BattleImprove is loaded!"); ((MonoBehaviour)this).StartCoroutine(InitPluginGameobject()); } private IEnumerator InitPluginGameobject() { while (SulfurSaveState.active == null || !PrefabManager.IsLoaded) { LoggingInfo("Waiting for game to load...", needDebug: true); yield return (object)new WaitForSeconds(1f); } LoggingInfo("Starting plugin initialization..."); LoggingInfo("Initializing plugin gameobject..."); GameObject val = GameObject.Find("CmPlugin"); if ((Object)(object)val == (Object)null) { PluginGameObject = new GameObject("CmPlugin"); Object.DontDestroyOnLoad((Object)(object)PluginGameObject); } else { PluginGameObject = val; } LoggingInfo("Loading plugin data..."); DataManager.SetUpData(); LoggingInfo("Loading plugin prefab..."); try { PrefabManager.LoadAttackFeedbackPrefab(); } catch (Exception ex) { LoggingInfo("Failed to load the combat-feedback prefab; its visuals are disabled: " + ex); } LoggingInfo("Loading other gameobject..."); PluginGameObject.AddComponent<LootSpawnHelper>(); GameObject val2 = new GameObject("Menu"); val2.transform.parent = PluginGameObject.transform; val2.AddComponent<MenuController>(); } private void Update() { i18n?.Tick(); } private void OnDestroy() { i18n?.Dispose(); Harmony.UnpatchSelf(); } private void Patching() { LoggingInfo("Patching...", needDebug: true); TryPatch(typeof(AttackFeedbackPatch)); TryPatch(typeof(DataManager)); TryPatch(typeof(ExpSharePatch)); TryPatch(typeof(HealthBarPatch)); TryPatch(typeof(LootDropPatch)); if (Config.EnableDeadUnitCollision.Value) { DeadBodyPassThrough.Apply(Harmony); } if (Config.EnableDeadProtection.Value) { TryPatch(typeof(DeadProtection)); } if (Config.ReverseMouseScroll.Value) { TryPatch(typeof(MouseScrollTranspiler)); } TryPatch(typeof(SoundPatch)); TryPatch(typeof(DamageInfoPatch)); TryPatch(typeof(KillMessagePatch)); TryPatch(typeof(CreditedKillPatch)); TryPatch(typeof(CrossHairPatch)); LoggingInfo("Patching complete!"); } private static void TryPatch(Type patch) { try { Harmony.PatchAll(patch); } catch (Exception arg) { Logger.LogError((object)$"Could not apply {patch.Name}; that feature may not work: {arg}"); } } public static void LoggingInfo(string info, bool needDebug = false) { if (needDebug) { if (debugMode) { Logger.LogInfo((object)("Debug info: " + info)); } } else { Logger.LogInfo((object)info); } } } public class Config { internal static ConfigEntry<bool> EnableHealthBar; internal static ConfigEntry<bool> EnableExpShare; internal static ConfigEntry<bool> EnableSoundFeedback; internal static ConfigEntry<bool> EnableDeadUnitCollision; internal static ConfigEntry<bool> EnableXCrossHair; internal static ConfigEntry<bool> EnableDamageMessage; internal static ConfigEntry<bool> EnableLoopDropVFX; internal static ConfigEntry<bool> EnableDeadProtection; internal static ConfigEntry<bool> EnableDeadUnitFeedback; internal static ConfigEntry<bool> ReverseMouseScroll; internal static ConfigEntry<float> Proportion; internal static ConfigEntry<float> HudScale; internal static ConfigEntry<float> MenuScale; internal const float ScaleMin = 0.5f; internal const float HudScaleMax = 2f; internal const float MenuScaleMax = 1.5f; internal const float ScaleStep = 0.05f; public static void InitConfig(ConfigFile cfg) { Plugin.LoggingInfo("Loading Config..."); ToggleConfigInit(cfg); ExpShareConfigInit(cfg); DisplayConfigInit(cfg); OtherConfigInit(cfg); Plugin.LoggingInfo("Config Loaded."); } private static void ToggleConfigInit(ConfigFile cfg) { EnableExpShare = cfg.Bind<bool>("Toggle/开关", "EnableExpShare", true, "Enable experience share/是否开启经验共享"); EnableHealthBar = cfg.Bind<bool>("Toggle/开关", "EnableHealthBar", true, "Enable health bar/是否开启血条"); EnableXCrossHair = cfg.Bind<bool>("Toggle/开关", "EnableHitFeedback", true, "Enable xCrossHair feedback/是否开启击中准心反馈"); EnableSoundFeedback = cfg.Bind<bool>("Toggle/开关", "EnableSoundFeedback", true, "Enable hit sound feedback on enemies/是否开启敌人受击声音反馈"); EnableDamageMessage = cfg.Bind<bool>("Toggle/开关", "EnableDamageMessage", true, "Enable damage and kill message/是否开启伤害与击杀信息"); EnableDeadUnitCollision = cfg.Bind<bool>("Toggle/开关", "EnableDeadUnitCollision", true, "Allowing bullets to pass through deadbody/是否使子弹能穿过尸体"); EnableDeadUnitFeedback = cfg.Bind<bool>("Toggle/开关", "EnableDeadUnitFeedback", false, "Show combat feedback when hitting an already dead body/是否在击中尸体时显示战斗反馈"); EnableLoopDropVFX = cfg.Bind<bool>("Toggle/开关", "EnableLoopDropVFX", true, "Enable loot drop VFX/是否开启掉落特效"); EnableDeadProtection = cfg.Bind<bool>("Toggle/开关", "EnableDeadProtection", false, "Enable dead protection (overlaps with the game's native insured-items system since 0.18.5)/是否开启死亡保护(0.18.5 起与游戏原生保险箱重叠,默认关闭)"); } private static void ExpShareConfigInit(ConfigFile cfg) { Proportion = cfg.Bind<float>("ExpShare/经验共享", "Proportion", 0.5f, "The proportion of experience shared to second weapon/共享给第二把武器的经验比例"); } private static void DisplayConfigInit(ConfigFile cfg) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing refe
BattleImprove.SulfurTogether.dll
Decompiled 2 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BattleImprove.Integration; using BepInEx; using Microsoft.CodeAnalysis; using SULFURTogether.Api; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BattleImprove.SulfurTogether")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+efc49fb2024cfa79cfcbfdc6a89460e1af4c5a1e")] [assembly: AssemblyProduct("BattleImprove.SulfurTogether")] [assembly: AssemblyTitle("BattleImprove.SulfurTogether")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BattleImprove.SulfurTogether { internal sealed class NetCombatRelay { [MethodImpl(MethodImplOptions.NoInlining)] internal static int ReadApiVersion() { return NetCombat.ApiVersion; } [MethodImpl(MethodImplOptions.NoInlining)] internal bool IsResolvingRemoteHit() { return NetCombat.IsResolvingRemoteHit; } [MethodImpl(MethodImplOptions.NoInlining)] internal void Subscribe() { NetCombat.LocalHitResolved += OnHitResolved; NetCombat.LocalKillCredited += OnKillCredited; } [MethodImpl(MethodImplOptions.NoInlining)] internal void Unsubscribe() { NetCombat.LocalHitResolved -= OnHitResolved; NetCombat.LocalKillCredited -= OnKillCredited; } private void OnHitResolved(LocalHitResolvedArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //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_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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0068: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00de: 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_00f6: Expected O, but got Unknown bool flag = (int)e.Outcome == 4; if ((int)e.Outcome == 1 || flag) { ClientHitSecondary[] array = (ClientHitSecondary[])(object)new ClientHitSecondary[e.Secondary.Count]; for (int i = 0; i < array.Length; i++) { int num = i; ClientHitSecondary val = new ClientHitSecondary(); SecondaryHit val2 = e.Secondary[i]; val.HealthRemoved = ((SecondaryHit)(ref val2)).HealthRemoved; val2 = e.Secondary[i]; val.DamageType = ((SecondaryHit)(ref val2)).DamageType; array[num] = val; } CoopCombat.ReportClientHit(new ClientHit { Target = e.Target, TargetWasDead = flag, Weapon = e.Weapon, Melee = e.Melee, DamageType = e.DamageType, IsCritical = e.IsCritical, HitPart = e.HitPart, HitPosition = e.HitPosition, HealthRemoved = e.HealthRemoved, Killed = e.Killed, Secondary = array }); } } private void OnKillCredited(LocalKillCreditedArgs e) { //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_0011: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown CoopCombat.ReportClientKill(new ClientKill { Target = e.Target, Weapon = e.Weapon, KillingBlow = e.KillingBlow, IsHeadshot = e.IsHeadshot, Experience = e.Experience }); } } [BepInPlugin("ryuka.sulfur.battle_improve_sulfur_together", "BattleImprove - SULFUR Together Adapter", "1.6.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class SulfurTogetherPlugin : BaseUnityPlugin { private const string PluginGuid = "ryuka.sulfur.battle_improve_sulfur_together"; private const string PluginName = "BattleImprove - SULFUR Together Adapter"; private const string PluginVersion = "1.6.0"; private const string BattleImproveGuid = "BattleImprove"; private const string SulfurTogetherGuid = "com.ryuka.sulfur.together"; private const int RequiredApiVersion = 1; private NetCombatRelay relay; private IDisposable registration; private void Awake() { try { int num = NetCombatRelay.ReadApiVersion(); if (num < 1) { LogUnavailable($"NetCombat API {num}, need {1}"); return; } NetCombatRelay netCombatRelay = new NetCombatRelay(); registration = Register(netCombatRelay); if (registration == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Another co-op integration is already registered; this one stays inactive."); return; } netCombatRelay.Subscribe(); relay = netCombatRelay; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Using SULFUR Together NetCombat API {num} for co-op combat feedback."); } catch (Exception ex) when (((ex is TypeLoadException || ex is MissingMemberException || ex is TypeInitializationException || ex is BadImageFormatException) ? 1 : 0) != 0) { registration?.Dispose(); registration = null; LogUnavailable(ex.GetType().Name + ": " + ex.Message); } } private void OnDestroy() { if (registration != null) { registration.Dispose(); registration = null; relay?.Unsubscribe(); relay = null; } } [MethodImpl(MethodImplOptions.NoInlining)] private static IDisposable Register(NetCombatRelay candidate) { return CoopCombat.Register((Func<bool>)candidate.IsResolvingRemoteHit); } private void LogUnavailable(string reason) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Co-op hit results are unavailable (" + reason + "); a client's combat feedback stays estimated.")); } } }