Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CollapseDisplay v1.5.2
plugins/CollapseDisplay/CollapseDisplay.dll
Decompiled 4 months agousing System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CollapseDisplay; using CollapseDisplay.Config; using CollapseDisplay.Networking; using CollapseDisplay.Properties; using CollapseDisplay.Utilities; using CollapseDisplay.Utilities.Extensions; using EntityStates.GlobalSkills.LunarDetonator; using HG; using IL.RoR2.UI; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using MonoMod.Cil; using MonoMod.Utils; using On.RoR2.UI; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using RoR2BepInExPack.GameAssetPaths.Version_1_39_0; using Unity; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.UI; [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CollapseDisplay")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyConfiguration("Release")] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyInformationalVersion("1.0.0+f766ac8e4fe74407e64d4906b8dd3926c5afcd7d")] [assembly: AssemblyTitle("CollapseDisplay")] [assembly: AssemblyProduct("CollapseDisplay")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CollapseDisplay { public class AcceptableValueMin<T> : AcceptableValueBase where T : IComparable { public T MinValue { get; } public AcceptableValueMin(T minValue) : base(typeof(T)) { if (minValue == null) { throw new ArgumentNullException("minValue"); } MinValue = minValue; } public override object Clamp(object value) { if (MinValue.CompareTo(value) > 0) { return MinValue; } return value; } public override bool IsValid(object value) { return MinValue.CompareTo(value) <= 0; } public override string ToDescriptionString() { return $"# Acceptable value range: Greater than or equal to {MinValue}"; } } [BepInPlugin("Gorakh.CollapseDisplay", "CollapseDisplay", "1.5.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class CollapseDisplayPlugin : BaseUnityPlugin { public const string PluginGUID = "Gorakh.CollapseDisplay"; public const string PluginAuthor = "Gorakh"; public const string PluginName = "CollapseDisplay"; public const string PluginVersion = "1.5.2"; internal static CollapseDisplayPlugin Instance { get; private set; } public static DelayedDamageDisplayOptions CollapseDisplayOptions { get; private set; } public static DelayedDamageDisplayOptions EssenceOfHeresyDisplayOptions { get; private set; } public static DelayedDamageDisplayOptions NetworkedSufferingDisplayOptions { get; private set; } private void Awake() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) Stopwatch stopwatch = Stopwatch.StartNew(); Log.Init(((BaseUnityPlugin)this).Logger); Instance = SingletonHelper.Assign<CollapseDisplayPlugin>(Instance, this); Texture2D val = new Texture2D(1, 1); Sprite val2; if (ImageConversion.LoadImage(val, Resources.HealthBarHighlight_Opaque)) { ((Object)val).name = "texHealthBarHighlightOpaque"; val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)1, new Vector4(4f, 3f, 3f, 4f)); ((Object)val2).name = ((Object)val).name; } else { Log.Error("Failed to load health bar overlay texture", "CollapseDisplay/CollapseDisplayPlugin.cs", "Awake", 48); Object.Destroy((Object)(object)val); val2 = Addressables.LoadAssetAsync<Sprite>((object)RoR2_Base_Common.texUIHighlightExecute_png_texUIHighlightExecute_).WaitForCompletion(); } CollapseDisplayOptions = new DelayedDamageDisplayOptions(val2, ((BaseUnityPlugin)this).Config, "Collapse", new Color(84f / 85f, 0.14509805f, 22f / 85f, 1f), 1f); EssenceOfHeresyDisplayOptions = new DelayedDamageDisplayOptions(val2, ((BaseUnityPlugin)this).Config, "Heretic Ruin", Color32.op_Implicit(new Color32((byte)41, (byte)138, (byte)242, byte.MaxValue)), 1f); NetworkedSufferingDisplayOptions = new DelayedDamageDisplayOptions(val2, ((BaseUnityPlugin)this).Config, "Networked Suffering", Color32.op_Implicit(new Color32((byte)70, (byte)252, (byte)131, byte.MaxValue)), 1f); if (RiskOfOptionsCompat.Enabled) { RiskOfOptionsCompat.Initialize(); } HealthBarTypeRegistration.Initialize(); HealthBarHooks.Initialize(); DelayedDamageProviderHooks.Initialize(); stopwatch.Stop(); Log.Info_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalMilliseconds:F0}ms"); } private void OnDestroy() { HealthBarTypeRegistration.Cleanup(); HealthBarHooks.Cleanup(); DelayedDamageProviderHooks.Cleanup(); Instance = SingletonHelper.Unassign<CollapseDisplayPlugin>(Instance, this); } } public struct DelayedDamageInfo : IEquatable<DelayedDamageInfo> { public static readonly DelayedDamageInfo None = new DelayedDamageInfo(-1f, FixedTimeStamp.negativeInfinity); public float Damage; public Net_RunFixedTimeStampWrapper Wrap_DamageTimestamp; public FixedTimeStamp DamageTimestamp { readonly get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Wrap_DamageTimestamp; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Wrap_DamageTimestamp = value; } } public DelayedDamageInfo() { Damage = 0f; Wrap_DamageTimestamp = default(Net_RunFixedTimeStampWrapper); } public DelayedDamageInfo(float damage, FixedTimeStamp damageTimestamp) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) Damage = damage; Wrap_DamageTimestamp = damageTimestamp; } public readonly bool Equals(DelayedDamageInfo other) { if (Damage == other.Damage) { return Wrap_DamageTimestamp.Equals(other.Wrap_DamageTimestamp); } return false; } } [DisallowMultipleComponent] public class DelayedDamageProvider : NetworkBehaviour { [SyncVar] private DelayedDamageInfo _collapseDamage; private CharacterBody _body; private HealthComponent _healthComponent; public DelayedDamageInfo CollapseDamage => _collapseDamage; public DelayedDamageInfo Network_collapseDamage { get { return _collapseDamage; } [param: In] set { ((NetworkBehaviour)this).SetSyncVar<DelayedDamageInfo>(value, ref _collapseDamage, 1u); } } private void Awake() { _body = ((Component)this).GetComponent<CharacterBody>(); _healthComponent = ((Component)this).GetComponent<HealthComponent>(); } private void FixedUpdate() { if (NetworkServer.active) { fixedUpdateServer(); } } [Server] private void fixedUpdateServer() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Invalid comparison between Unknown and I4 //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { Debug.LogWarning((object)"[Server] function 'System.Void CollapseDisplay.DelayedDamageProvider::fixedUpdateServer()' called on client"); return; } DelayedDamageInfo none = DelayedDamageInfo.None; if (Object.op_Implicit((Object)(object)_body) && Object.op_Implicit((Object)(object)_healthComponent) && _healthComponent.alive) { DotController val = DotController.FindDotController(((Component)this).gameObject); if (Object.op_Implicit((Object)(object)val) && val.HasDotActive((DotIndex)8)) { float num = float.PositiveInfinity; none.Damage = 0f; foreach (DotStack dotStack in val.dotStackList) { if ((int)dotStack.dotIndex == 8) { num = Mathf.Min(num, dotStack.timer); DamageInfo damageInfo = new DamageInfo { attacker = dotStack.attackerObject, damageType = (dotStack.damageType | DamageTypeCombo.op_Implicit((DamageType)67108864)), damage = dotStack.damage }; float num2 = HealthComponentUtils.EstimateTakeDamage(_healthComponent, damageInfo); if (num2 > 0f) { none.Damage += num2; } } } if (float.IsFinite(num) && num > 0f) { none.DamageTimestamp = FixedTimeStamp.now + num; } } } Network_collapseDamage = none; } private void UNetVersion() { } public override bool OnSerialize(NetworkWriter writer, bool forceAll) { if (forceAll) { GeneratedNetworkCode._WriteDelayedDamageInfo_None(writer, _collapseDamage); return true; } bool flag = false; if ((((NetworkBehaviour)this).syncVarDirtyBits & (true ? 1u : 0u)) != 0) { if (!flag) { writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits); flag = true; } GeneratedNetworkCode._WriteDelayedDamageInfo_None(writer, _collapseDamage); } if (!flag) { writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits); } return flag; } public override void OnDeserialize(NetworkReader reader, bool initialState) { if (initialState) { _collapseDamage = GeneratedNetworkCode._ReadDelayedDamageInfo_None(reader); return; } int num = (int)reader.ReadPackedUInt32(); if (((uint)num & (true ? 1u : 0u)) != 0) { _collapseDamage = GeneratedNetworkCode._ReadDelayedDamageInfo_None(reader); } } } internal static class DelayedDamageProviderHooks { private static readonly List<DelayedDamageProvider> _delayedDamageProviderPrefabComponents = new List<DelayedDamageProvider>(); public static void Initialize() { destroyAllPrefabComponents(); ((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)delegate { if (_delayedDamageProviderPrefabComponents.Capacity < BodyCatalog.bodyCount) { _delayedDamageProviderPrefabComponents.Capacity = BodyCatalog.bodyCount; } foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs) { if (Object.op_Implicit((Object)(object)allBodyPrefab.GetComponent<HealthComponent>())) { DelayedDamageProvider item = allBodyPrefab.AddComponent<DelayedDamageProvider>(); _delayedDamageProviderPrefabComponents.Add(item); } } }); } public static void Cleanup() { destroyAllPrefabComponents(); } private static void destroyAllPrefabComponents() { foreach (DelayedDamageProvider delayedDamageProviderPrefabComponent in _delayedDamageProviderPrefabComponents) { Object.Destroy((Object)(object)delayedDamageProviderPrefabComponent); } _delayedDamageProviderPrefabComponents.Clear(); } } internal static class HealthBarHooks { private readonly struct AdditionalBarInfos { public static readonly FieldInfo[] BarInfoFields = (from f in typeof(AdditionalBarInfos).GetFields(BindingFlags.Instance | BindingFlags.Public) where f.FieldType == typeof(BarInfo) select f).ToArray(); public readonly BarInfo CollapseDamageBarInfo; public readonly BarInfo EssenceOfHeresyBarInfo; public readonly BarInfo NetworkedSufferingBarInfo; public readonly int EnabledBarCount; public AdditionalBarInfos(BarInfo collapseDamageBarInfo, BarInfo essenceOfHeresyBarInfo, BarInfo networkedSufferingBarInfo) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0034: Unknown result type (might be due to invalid IL or missing references) int num = 0; CollapseDamageBarInfo = collapseDamageBarInfo; if (CollapseDamageBarInfo.enabled) { num++; } EssenceOfHeresyBarInfo = essenceOfHeresyBarInfo; if (EssenceOfHeresyBarInfo.enabled) { num++; } NetworkedSufferingBarInfo = networkedSufferingBarInfo; if (NetworkedSufferingBarInfo.enabled) { num++; } EnabledBarCount = num; } } [CompilerGenerated] private static class <>O { public static Manipulator <0>__HealthBar_ApplyBars; public static Func<HealthBar, AdditionalBarInfos> <1>__collectBarInfos; public static <>F{00000018}<int, AdditionalBarInfos, int> <2>__addDamageDisplayBarsToCount; } public static void Initialize() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__HealthBar_ApplyBars; if (obj == null) { Manipulator val = HealthBar_ApplyBars; <>O.<0>__HealthBar_ApplyBars = val; obj = (object)val; } HealthBar.ApplyBars += (Manipulator)obj; } public static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__HealthBar_ApplyBars; if (obj == null) { Manipulator val = HealthBar_ApplyBars; <>O.<0>__HealthBar_ApplyBars = val; obj = (object)val; } HealthBar.ApplyBars -= (Manipulator)obj; } private static void HealthBar_ApplyBars(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); MethodReference handleBarMethod = null; if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref handleBarMethod) && nameStartsWith(handleBarMethod, "<ApplyBars>g__HandleBar|") })) { int localsVarIndex = -1; if (val.TryGotoPrev(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref localsVarIndex) })) { VariableDefinition val2 = il.Method.Body.Variables[localsVarIndex]; val.Index = 0; VariableDefinition val3 = il.AddVariable<AdditionalBarInfos>(); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<HealthBar, AdditionalBarInfos>>((Func<HealthBar, AdditionalBarInfos>)collectBarInfos); val.Emit(OpCodes.Stloc, val3); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<BarInfoCollection>(x, "GetActiveCount") })) { val.Emit(OpCodes.Ldloca, val3); val.EmitDelegate<<>F{00000018}<int, AdditionalBarInfos, int>>((<>F{00000018}<int, AdditionalBarInfos, int>)addDamageDisplayBarsToCount); if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchRet(x) })) { Log.Error("Failed to find patch location", "CollapseDisplay/HealthBarHooks.cs", "HealthBar_ApplyBars", 125); return; } FieldInfo[] barInfoFields = AdditionalBarInfos.BarInfoFields; foreach (FieldInfo fieldInfo in barInfoFields) { val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldloca, val3); val.Emit(OpCodes.Ldflda, fieldInfo); val.Emit(OpCodes.Ldloca, val2); val.Emit(OpCodes.Call, handleBarMethod); } } else { Log.Error("Failed to find bar count patch location", "CollapseDisplay/HealthBarHooks.cs", "HealthBar_ApplyBars", 118); } } else { Log.Error("Failed to find locals variable", "CollapseDisplay/HealthBarHooks.cs", "HealthBar_ApplyBars", 85); } } else { Log.Error("Failed to find HandleBar method", "CollapseDisplay/HealthBarHooks.cs", "HealthBar_ApplyBars", 91); } [MethodImpl(MethodImplOptions.AggressiveInlining)] static int addDamageDisplayBarsToCount(int activeCount, in AdditionalBarInfos damageDisplayBarInfos) { return activeCount + damageDisplayBarInfos.EnabledBarCount; } static bool nameStartsWith(MethodReference methodReference, string value) { if (methodReference == null || ((MemberReference)methodReference).Name == null) { return false; } return ((MemberReference)methodReference).Name.StartsWith(value); } } private static AdditionalBarInfos collectBarInfos(HealthBar healthBar) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_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_0047: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0275: 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) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Expected I4, but got Unknown //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Expected O, but got Unknown HealthBarType barType = HealthBarType.Unknown; HealthBarTypeProvider healthBarTypeProvider = default(HealthBarTypeProvider); if (((Component)healthBar).TryGetComponent<HealthBarTypeProvider>(ref healthBarTypeProvider)) { barType = healthBarTypeProvider.Type; } DelayedDamageBarStyle damageBarStyle = CollapseDisplayPlugin.EssenceOfHeresyDisplayOptions.GetDamageBarStyle(barType); BarStyle barStyle = damageBarStyle.BarStyle; BarInfo val = default(BarInfo); val.enabled = false; val.color = barStyle.baseColor; val.sprite = barStyle.sprite; val.imageType = barStyle.imageType; val.sizeDelta = barStyle.sizeDelta; val.normalizedXMin = 0f; val.normalizedXMax = 0f; BarInfo barInfo2 = val; DelayedDamageBarStyle damageBarStyle2 = CollapseDisplayPlugin.NetworkedSufferingDisplayOptions.GetDamageBarStyle(barType); BarStyle barStyle2 = damageBarStyle2.BarStyle; val = default(BarInfo); val.enabled = false; val.color = barStyle2.baseColor; val.sprite = barStyle2.sprite; val.imageType = barStyle2.imageType; val.sizeDelta = barStyle2.sizeDelta; val.normalizedXMin = 0f; val.normalizedXMax = 0f; BarInfo barInfo3 = val; DelayedDamageBarStyle damageBarStyle3 = CollapseDisplayPlugin.CollapseDisplayOptions.GetDamageBarStyle(barType); BarStyle barStyle3 = damageBarStyle3.BarStyle; val = default(BarInfo); val.enabled = false; val.color = barStyle3.baseColor; val.sprite = barStyle3.sprite; val.imageType = barStyle3.imageType; val.sizeDelta = barStyle3.sizeDelta; val.normalizedXMin = 0f; val.normalizedXMax = 0f; BarInfo barInfo4 = val; HealthComponent healthComponent = healthBar.source; float totalBarDamageAmount = 0f; if (Object.op_Implicit((Object)(object)healthComponent)) { CharacterBody body = healthComponent.body; if (Object.op_Implicit((Object)(object)body)) { if (Object.op_Implicit((Object)(object)healthBar.viewerBody)) { int buffCount = body.GetBuffCount(Buffs.LunarDetonationCharge); if (buffCount > 0 && damageBarStyle.EnabledConfig.Value) { float num = healthBar.viewerBody.damage * Detonate.baseDamageCoefficient; float num2 = healthBar.viewerBody.damage * Detonate.damageCoefficientPerStack; float num3 = HealthComponentUtils.EstimateTakeDamage(healthComponent, new DamageInfo { damage = num + (float)buffCount * num2, attacker = ((Component)healthBar.viewerBody).gameObject }); if (num3 > 0f) { tryAddBar(ref barInfo2, num3); } } } if (((!Object.op_Implicit((Object)(object)body.teamComponent)) ? (-1) : ((int)body.teamComponent.teamIndex)) != -1 && damageBarStyle2.EnabledConfig.Value && body.HasBuff(Buffs.SharedSuffering) && Object.op_Implicit((Object)(object)SharedSufferingManager.instance) && SharedSufferingManager.instance.hasPendingDamage) { float safe = ArrayUtils.GetSafe<float>(SharedSufferingManager.instance.damagePools, (int)body.teamComponent.teamIndex); if (safe > 0f) { float num4 = HealthComponentUtils.EstimateTakeDamage(healthComponent, new DamageInfo { attacker = null, damage = safe, damageType = DamageTypeCombo.op_Implicit((DamageType)2) }); if (num4 > 0f) { tryAddBar(ref barInfo3, num4); } } } } DelayedDamageProvider delayedDamageProvider = default(DelayedDamageProvider); if (((Component)healthComponent).TryGetComponent<DelayedDamageProvider>(ref delayedDamageProvider) && damageBarStyle3.EnabledConfig.Value) { tryAddDelayedDamageBar(delayedDamageProvider.CollapseDamage, ref barInfo4); } } return new AdditionalBarInfos(barInfo4, barInfo2, barInfo3); void tryAddBar(ref BarInfo barInfo, float damageAmount) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) damageAmount -= healthComponent.barrier; if (!(damageAmount <= 0f)) { barInfo.enabled = true; HealthBarValues healthBarValues = healthComponent.GetHealthBarValues(); float combinedHealth = healthComponent.combinedHealth; float fullCombinedHealth = healthComponent.fullCombinedHealth; float num5 = Mathf.Max(0f, combinedHealth - totalBarDamageAmount); float num6 = Mathf.Max(0f, num5 - damageAmount); float num7 = 1f - healthBarValues.curseFraction; float num8 = num6 / fullCombinedHealth * num7; barInfo.normalizedXMin = Mathf.Clamp01(num8); float num9 = num5 / fullCombinedHealth * num7; barInfo.normalizedXMax = Mathf.Clamp01(num9); totalBarDamageAmount += Mathf.Max(0f, num5 - num6); } } void tryAddDelayedDamageBar(DelayedDamageInfo delayedDamageInfo, ref BarInfo barInfo) { //IL_0002: 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) FixedTimeStamp damageTimestamp = delayedDamageInfo.DamageTimestamp; if (((FixedTimeStamp)(ref damageTimestamp)).timeUntil > 0f) { tryAddBar(ref barInfo, delayedDamageInfo.Damage); } } } } public enum HealthBarType { Unknown, Hud, Combat, AllyList, BaggedObject, Count } public class HealthBarTypeProvider : MonoBehaviour { public HealthBarType Type; } internal static class HealthBarTypeRegistration { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__HealthBar_Awake; } private static readonly HealthBarStyle _combatHealthBarStyle = Addressables.LoadAssetAsync<HealthBarStyle>((object)RoR2_Base_Common.CombatHealthBar_asset).WaitForCompletion(); private static readonly HealthBarStyle _hudHealthBarStyle = Addressables.LoadAssetAsync<HealthBarStyle>((object)RoR2_Base_Common.HUDHealthBar_asset).WaitForCompletion(); private static readonly List<HealthBarTypeProvider> _addedPrefabProviders = new List<HealthBarTypeProvider>(); public static void Initialize() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__HealthBar_Awake; if (obj == null) { hook_Awake val = HealthBar_Awake; <>O.<0>__HealthBar_Awake = val; obj = (object)val; } HealthBar.Awake += (hook_Awake)obj; registerHealthBarPrefab(RoR2_Base_UI.HUDSimple_prefab, HealthBarType.Hud); registerHealthBarPrefab(RoR2_Base_UI.HUDSimple_Big_prefab, HealthBarType.Hud); registerHealthBarPrefab(RoR2_Base_UI.CombatHealthbar_prefab, HealthBarType.Combat); registerHealthBarPrefab(RoR2_Base_UI.AllyCard_prefab, HealthBarType.AllyList); registerHealthBarPrefab(RoR2_DLC3_Drifter.Bag_UI_prefab, HealthBarType.BaggedObject); static void registerHealthBarPrefab(string assetPath, HealthBarType type) { //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) GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)assetPath).WaitForCompletion(); if (!Object.op_Implicit((Object)(object)val2)) { Log.Error("Invalid asset path '" + assetPath + "'", "CollapseDisplay/HealthBarTypeRegistration.cs", "Initialize", 27); } else { int num = 0; HealthBar[] componentsInChildren = val2.GetComponentsInChildren<HealthBar>(true); foreach (HealthBar val3 in componentsInChildren) { if (!Object.op_Implicit((Object)(object)((Component)val3).GetComponent<HealthBarTypeProvider>())) { HealthBarTypeProvider healthBarTypeProvider = ((Component)val3).gameObject.AddComponent<HealthBarTypeProvider>(); healthBarTypeProvider.Type = type; _addedPrefabProviders.Add(healthBarTypeProvider); num++; } } if (num == 0) { Log.Warning("No health bars found on asset '" + ((Object)val2).name + "'", "CollapseDisplay/HealthBarTypeRegistration.cs", "Initialize", 47); } } } } public static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__HealthBar_Awake; if (obj == null) { hook_Awake val = HealthBar_Awake; <>O.<0>__HealthBar_Awake = val; obj = (object)val; } HealthBar.Awake -= (hook_Awake)obj; foreach (HealthBarTypeProvider addedPrefabProvider in _addedPrefabProviders) { Object.Destroy((Object)(object)addedPrefabProvider); } _addedPrefabProviders.Clear(); } private static void HealthBar_Awake(orig_Awake orig, HealthBar self) { if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<HealthBarTypeProvider>())) { HealthBarType type = HealthBarType.Unknown; if ((Object)(object)self.style == (Object)(object)_combatHealthBarStyle) { type = HealthBarType.Combat; } else if ((Object)(object)self.style == (Object)(object)_hudHealthBarStyle) { type = HealthBarType.Hud; } ((Component)self).gameObject.AddComponent<HealthBarTypeProvider>().Type = type; } orig.Invoke(self); } } internal static class Log { private static readonly StringBuilder _sharedStringBuilder = new StringBuilder(256); private static readonly object _stringBuilderLock = new object(); private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } private static string buildCallerLogString(string callerPath, string callerMemberName, int callerLineNumber, object data) { lock (_stringBuilderLock) { return _sharedStringBuilder.Clear().Append(callerPath).Append(':') .Append(callerLineNumber) .Append(" (") .Append(callerMemberName) .Append("): ") .Append(data) .ToString(); } } [Conditional("DEBUG")] internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogDebug((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [Conditional("DEBUG")] internal static void Debug_NoCallerPrefix(object data) { _logSource.LogDebug(data); } internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogError((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Error_NoCallerPrefix(object data) { _logSource.LogError(data); } internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogFatal((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Fatal_NoCallerPrefix(object data) { _logSource.LogFatal(data); } internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogInfo((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Info_NoCallerPrefix(object data) { _logSource.LogInfo(data); } internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogMessage((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Message_NoCallerPrefix(object data) { _logSource.LogMessage(data); } internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogWarning((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Warning_NoCallerPrefix(object data) { _logSource.LogWarning(data); } internal static void LogType(LogLevel level, object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { //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_000c: Unknown result type (might be due to invalid IL or missing references) if ((level & 0x20) == 0) { _logSource.Log(level, (object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogType_NoCallerPrefix(LogLevel level, object data) { //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_000c: Unknown result type (might be due to invalid IL or missing references) if ((level & 0x20) == 0) { _logSource.Log(level, data); } } } internal static class RiskOfOptionsCompat { public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void Initialize() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) addDisplayOptions(CollapseDisplayPlugin.CollapseDisplayOptions); addDisplayOptions(CollapseDisplayPlugin.EssenceOfHeresyDisplayOptions); ModSettingsManager.SetModDescription("Options for Collapse Display", "Gorakh.CollapseDisplay", "Collapse Display"); FileInfo fileInfo = null; DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(((BaseUnityPlugin)CollapseDisplayPlugin.Instance).Info.Location)); do { FileInfo[] files = directoryInfo.GetFiles("icon.png", SearchOption.TopDirectoryOnly); if (files != null && files.Length != 0) { fileInfo = files[0]; break; } directoryInfo = directoryInfo.Parent; } while (directoryInfo != null && !string.Equals(directoryInfo.Name, "plugins", StringComparison.OrdinalIgnoreCase)); if (fileInfo != null) { Texture2D val = new Texture2D(256, 256); if (ImageConversion.LoadImage(val, File.ReadAllBytes(fileInfo.FullName))) { Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); ((Object)obj).name = "CollapseDisplayIcon"; ModSettingsManager.SetModIcon(obj, "Gorakh.CollapseDisplay", "Collapse Display"); } } static void addDamageBarStyle(DelayedDamageBarStyle damageBarStyle) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(damageBarStyle.EnabledConfig), "Gorakh.CollapseDisplay", "Collapse Display"); } static void addDisplayOptions(DelayedDamageDisplayOptions displayOptions) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0035: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new ColorOption(displayOptions.IndicatorColor), "Gorakh.CollapseDisplay", "Collapse Display"); ConfigEntry<float> indicatorScale = displayOptions.IndicatorScale; FloatFieldConfig val2 = new FloatFieldConfig(); ((NumericFieldConfig<float>)val2).Min = 0f; ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(indicatorScale, val2), "Gorakh.CollapseDisplay", "Collapse Display"); addDamageBarStyle(displayOptions.HUDHealthBarStyle); addDamageBarStyle(displayOptions.AllyListHealthBarStyle); addDamageBarStyle(displayOptions.CombatHealthBarStyle); addDamageBarStyle(displayOptions.BaggedObjectBarStyle); } } } } namespace CollapseDisplay.Utilities { public static class HealthComponentUtils { public static float EstimateTakeDamage(HealthComponent victim, DamageInfo damageInfo) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_07b8: Unknown result type (might be due to invalid IL or missing references) //IL_07c2: Unknown result type (might be due to invalid IL or missing references) //IL_07c7: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_07d9: Unknown result type (might be due to invalid IL or missing references) //IL_07e3: Unknown result type (might be due to invalid IL or missing references) //IL_07e5: Invalid comparison between Unknown and I4 //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_084c: Unknown result type (might be due to invalid IL or missing references) //IL_0853: Unknown result type (might be due to invalid IL or missing references) //IL_0855: Invalid comparison between Unknown and I4 //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0814: Unknown result type (might be due to invalid IL or missing references) //IL_081a: Unknown result type (might be due to invalid IL or missing references) //IL_081f: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Invalid comparison between Unknown and I4 //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Invalid comparison between Unknown and I4 //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Invalid comparison between Unknown and I4 //IL_021b: 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_08ab: Unknown result type (might be due to invalid IL or missing references) //IL_08b2: Invalid comparison between Unknown and I4 //IL_08d3: Unknown result type (might be due to invalid IL or missing references) //IL_08da: Unknown result type (might be due to invalid IL or missing references) //IL_08df: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) if (damageInfo == null) { throw new ArgumentNullException("damageInfo"); } if (!Object.op_Implicit((Object)(object)victim) || !Object.op_Implicit((Object)(object)victim.body)) { return damageInfo.damage; } CharacterMaster val = null; CharacterBody val2 = null; TeamIndex val3 = (TeamIndex)(-1); Vector3 val4 = Vector3.zero; float combinedHealth = victim.combinedHealth; if (Object.op_Implicit((Object)(object)damageInfo.attacker)) { val2 = damageInfo.attacker.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)val2)) { val3 = val2.teamComponent.teamIndex; val4 = val2.corePosition - damageInfo.position; } } bool flag = DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)2)) != 0; bool num = DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)64)) != 0; bool flag2 = DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageTypeExtended)8192)) != 0; bool num2 = DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageTypeExtended)262144)) != 0; if ((int)DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageTypeExtended)268435456)) == 268435456) { damageInfo.damage = victim.fullHealth * 0.1f; } KnockbackFinUtil.ModifyDamageInfo(ref damageInfo, val2, victim.body); if (!num2) { if (victim.body.HasBuff(Buffs.lunarruin)) { float num3 = (float)victim.body.GetBuffCount(Buffs.lunarruin) * 0.1f; float num4 = damageInfo.damage * num3; DamageInfo obj = damageInfo; obj.damage += num4; } if (val3 == victim.body.teamComponent.teamIndex) { TeamDef teamDef = TeamCatalog.GetTeamDef(val3); if (teamDef != null) { DamageInfo obj2 = damageInfo; obj2.damage *= teamDef.friendlyFireScaling; } } if (damageInfo.damage > 0f) { if (Object.op_Implicit((Object)(object)val2)) { if (flag2 && val2.HasBuff(Buffs.ShockDamageEnergized)) { damageInfo.crit = true; } if (val2.canPerformBackstab && (int)DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)67108864)) != 67108864 && (((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)17) || BackstabManager.IsBackstab(-val4, victim.body))) { damageInfo.crit = true; ((ProcChainMask)(ref damageInfo.procChainMask)).AddProc((ProcType)17); } val = val2.master; if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.inventory)) { if (combinedHealth >= victim.fullCombinedHealth * 0.9f) { int itemCountEffective = val.inventory.GetItemCountEffective(Items.Crowbar); if (itemCountEffective > 0) { DamageInfo obj3 = damageInfo; obj3.damage *= 1f + 0.75f * (float)itemCountEffective; } } int itemCountEffective2 = val.inventory.GetItemCountEffective(Items.NearbyDamageBonus); if (itemCountEffective2 > 0 && ((Vector3)(ref val4)).sqrMagnitude <= 169f) { damageInfo.damageColorIndex = (DamageColorIndex)10; DamageInfo obj4 = damageInfo; obj4.damage *= 1f + (float)itemCountEffective2 * 0.2f; } int itemCountEffective3 = val.inventory.GetItemCountEffective(Items.FragileDamageBonus); if (itemCountEffective3 > 0) { DamageInfo obj5 = damageInfo; obj5.damage *= 1f + (float)itemCountEffective3 * 0.2f; } if (damageInfo.procCoefficient > 0f && victim.body.HasBuff(Buffs.MercExpose) && Object.op_Implicit((Object)(object)val2) && val2.bodyIndex == BodyCatalog.FindBodyIndex("MercBody")) { float num5 = val2.damage * 3.5f; DamageInfo obj6 = damageInfo; obj6.damage += num5; } if (victim.body.isBoss) { int itemCountEffective4 = val.inventory.GetItemCountEffective(Items.BossDamageBonus); if (itemCountEffective4 > 0) { DamageInfo obj7 = damageInfo; obj7.damage *= 1f + 0.2f * (float)itemCountEffective4; damageInfo.damageColorIndex = (DamageColorIndex)5; } } } if (damageInfo.crit) { DamageInfo obj8 = damageInfo; obj8.damage *= val2.critMultiplier; } } if (DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)16)) != 0L) { DamageInfo obj9 = damageInfo; obj9.damage *= 1.5f; damageInfo.damageColorIndex = (DamageColorIndex)5; } if (victim.body.HasBuff(Buffs.DeathMark)) { DamageInfo obj10 = damageInfo; obj10.damage *= 1.5f; damageInfo.damageColorIndex = (DamageColorIndex)7; } if (!flag) { float armor = victim.body.armor; armor += victim.adaptiveArmorValue; bool flag3 = DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)131072)) != 0; if ((victim.body.bodyFlags & 0x40) > 0 && flag3) { armor += 300f; } float num6 = ((armor >= 0f) ? (1f - armor / (armor + 100f)) : (2f - 100f / (100f - armor))); damageInfo.damage = Mathf.Max(1f, damageInfo.damage * num6); if (victim.itemCounts.armorPlate > 0) { damageInfo.damage = Mathf.Max(1f, damageInfo.damage - 5f * (float)victim.itemCounts.armorPlate); } int buffCount = victim.body.GetBuffCount(Buffs.DroneArmor); if (buffCount > 0) { DamageInfo obj11 = damageInfo; obj11.damage -= damageInfo.damage * ((float)buffCount * 0.05f); } } if (victim.body.hasOneShotProtection && (int)DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)262144)) != 262144) { float num7 = (victim.fullCombinedHealth + victim.barrier) * (1f - victim.body.oneShotProtectionFraction); float num8 = Mathf.Max(0f, num7 - victim.serverDamageTakenThisUpdate); damageInfo.damage = Mathf.Min(damageInfo.damage, num8); } if (DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)524288)) != 0L) { float num9 = Mathf.Lerp(3f, 1f, victim.combinedHealthFraction); DamageInfo obj12 = damageInfo; obj12.damage *= num9; } if (victim.body.HasBuff(Buffs.LunarShell) && damageInfo.damage > victim.fullHealth * 0.1f) { damageInfo.damage = victim.fullHealth * 0.1f; } if (victim.itemCounts.minHealthPercentage > 0) { float num10 = victim.fullCombinedHealth * ((float)victim.itemCounts.minHealthPercentage / 100f); damageInfo.damage = Mathf.Max(0f, Mathf.Min(damageInfo.damage, victim.combinedHealth - num10)); } } } if (!num && damageInfo.damage > 0f && !damageInfo.delayedDamageSecondHalf && !damageInfo.rejected && !damageInfo.firstHitOfDelayedDamageSecondHalf && victim.body.HasBuff(Buffs.DelayedDamageBuff)) { DamageInfo obj13 = damageInfo; obj13.damage *= 0.9f; } float num11 = Mathf.Min(damageInfo.damage, victim.barrier); float num12 = victim.barrier - num11; DamageInfo obj14 = damageInfo; obj14.damage -= num11; float num13 = Mathf.Min(damageInfo.damage, victim.shield); float num14 = victim.shield - num13; DamageInfo obj15 = damageInfo; obj15.damage -= num13; if (victim.itemCounts.unstableTransmitter > 0 && victim.IsHealthBelowThreshold(victim.health - damageInfo.damage, 0.25f) && victim.body.HasBuff(Buffs.TeleportOnLowHealth) && victim.health - damageInfo.damage > 0f && Object.op_Implicit((Object)(object)((Component)victim).GetComponent<TeleportOnLowHealthBehavior>())) { int num15 = victim.GetHealthAtThreshold(0.25f) + 1; float num16 = victim.health - (float)num15; if (num16 > 0f) { damageInfo.damage = num16; } } bool num17 = DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)65536)) != 0L && (victim.body.bodyFlags & 0x800) == 0; float num18 = victim.health; if (damageInfo.damage > 0f) { float num19 = num18 - damageInfo.damage; if (num19 < 1f && DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)1)) != 0L && num18 >= 1f) { num19 = 1f; } num18 = num19; } float num20 = float.NegativeInfinity; bool flag4 = (victim.body.bodyFlags & 0x10) > 0; if (!num17 && !flag4) { if (victim.isInFrozenState && num20 < 0.3f) { num20 = 0.3f; } if (Object.op_Implicit((Object)(object)val2) && victim.body.isElite) { float executeEliteHealthFraction = val2.executeEliteHealthFraction; if (num20 < executeEliteHealthFraction) { num20 = executeEliteHealthFraction; } } if ((int)damageInfo.damageType.damageTypeExtended == 64 && !victim.body.isBoss) { float num21 = 0.5f; if (num20 < num21) { num20 = num21; } } if (DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageTypeExtended)16)) != 0L) { float num22 = 0.2f; if (num20 < num22) { num20 = num22; } } } float num23 = (num18 + num14 + num12) / victim.fullCombinedHealth; if (num17 || (num20 > 0f && num23 <= num20)) { damageInfo.damage = victim.health; } DamageInfo obj16 = damageInfo; obj16.damage += num11 + num13; return damageInfo.damage; } } public static class ObjectUtils { public static T ShallowCopy<T>(T original, BindingFlags fieldCopyFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) { if (typeof(T).IsValueType || original == null) { return original; } if ((object)original is ICloneable cloneable) { return (T)cloneable.Clone(); } T val = Activator.CreateInstance<T>(); FieldInfo[] fields = typeof(T).GetFields(fieldCopyFlags); foreach (FieldInfo fieldInfo in fields) { try { object value = fieldInfo.GetValue(original); fieldInfo.SetValue(val, value); } catch (Exception arg) { Log.Error_NoCallerPrefix($"Failed to copy field value {fieldInfo.DeclaringType.FullName}.{fieldInfo.Name}: {arg}"); } } return val; } } } namespace CollapseDisplay.Utilities.Extensions { public static class PatchExtensions { public static void EmitSkipMethodCall(this ILCursor c, MethodDefinition method = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) c.EmitSkipMethodCall(OpCodes.Br, method); } public static void EmitSkipMethodCall(this ILCursor c, OpCode branchOpCode, MethodDefinition method = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) c.EmitSkipMethodCall(branchOpCode, null, method); } public static void EmitSkipMethodCall(this ILCursor c, OpCode branchOpCode, Action<ILCursor> emitSkippedReturnValue, MethodDefinition method = null) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) if (c == null) { throw new ArgumentNullException("c"); } if ((int)((OpCode)(ref branchOpCode)).FlowControl != 0 && (int)((OpCode)(ref branchOpCode)).FlowControl != 3) { throw new ArgumentException($"Invalid branch OpCode: {branchOpCode}"); } if (method == null) { MethodReference val = default(MethodReference); if (!ILPatternMatchingExt.MatchCallOrCallvirt(c.Next, ref val)) { Log.Error($"Failed to find method call to skip: {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "CollapseDisplay/Utilities/Extensions/PatchExtensions.cs", "EmitSkipMethodCall", 33); return; } method = Extensions.SafeResolve(val); if (method == null) { Log.Error($"Failed to resolve method '{((MemberReference)val).FullName}': {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "CollapseDisplay/Utilities/Extensions/PatchExtensions.cs", "EmitSkipMethodCall", 41); return; } } int num = ((MethodReference)method).Parameters.Count + ((!method.IsStatic) ? 1 : 0); bool flag = Extensions.Is((MemberReference)(object)((MethodReference)method).ReturnType, (MemberInfo)typeof(void)); ILLabel val2 = c.DefineLabel(); c.Emit(branchOpCode, (object)val2); int index = c.Index; c.Index = index + 1; if (num > 0 || !flag) { ILLabel val3 = c.DefineLabel(); c.Emit(OpCodes.Br, (object)val3); c.MarkLabel(val2); for (int i = 0; i < num; i++) { c.Emit(OpCodes.Pop); } if (emitSkippedReturnValue != null) { emitSkippedReturnValue(c); } else if (!flag) { Log.Warning($"Skipped method ({((MemberReference)method).FullName}) is not void, emitting default value: {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "CollapseDisplay/Utilities/Extensions/PatchExtensions.cs", "EmitSkipMethodCall", 73); if (((MethodReference)method).ReturnType.IsValueType) { VariableDefinition val4 = c.Context.AddVariable(((MethodReference)method).ReturnType); c.Emit(OpCodes.Ldloca, val4); c.Emit(OpCodes.Initobj, ((MethodReference)method).ReturnType); c.Emit(OpCodes.Ldloc, val4); } else { c.Emit(OpCodes.Ldnull); } } c.MarkLabel(val3); } else { c.MarkLabel(val2); } } public static bool TryFindParameter(this MethodReference method, Type type, string name, out ParameterDefinition parameter) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Enumerator<ParameterDefinition> enumerator = method.Parameters.GetEnumerator(); try { while (enumerator.MoveNext()) { ParameterDefinition current = enumerator.Current; if ((string.IsNullOrEmpty(name) || ((ParameterReference)current).Name == name) && (type == null || Extensions.Is((MemberReference)(object)((ParameterReference)current).ParameterType, (MemberInfo)type))) { parameter = current; return true; } } } finally { ((IDisposable)enumerator).Dispose(); } parameter = null; return false; } public static bool TryFindParameter(this MethodReference method, string name, out ParameterDefinition parameter) { return method.TryFindParameter(null, name, out parameter); } public static bool TryFindParameter(this MethodReference method, Type type, out ParameterDefinition parameter) { return method.TryFindParameter(type, null, out parameter); } public static bool TryFindParameter<T>(this MethodReference method, string name, out ParameterDefinition parameter) { return method.TryFindParameter(typeof(T), name, out parameter); } public static bool TryFindParameter<T>(this MethodReference method, out ParameterDefinition parameter) { return method.TryFindParameter(typeof(T), null, out parameter); } public static VariableDefinition AddVariable(this ILContext context, TypeReference variableType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown VariableDefinition val = new VariableDefinition(variableType); context.Method.Body.Variables.Add(val); return val; } public static VariableDefinition AddVariable(this ILContext context, Type variableType) { return context.AddVariable(context.Import(variableType)); } public static VariableDefinition AddVariable<T>(this ILContext context) { return context.AddVariable(context.Import(typeof(T))); } public static void EmitStoreStack(this ILCursor cursor, params VariableDefinition[] variables) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) if (cursor == null) { throw new ArgumentNullException("cursor"); } if (variables == null) { throw new ArgumentNullException("variables"); } if (variables.Length != 0) { for (int num = variables.Length - 1; num >= 1; num--) { cursor.Emit(OpCodes.Stloc, variables[num]); } cursor.Emit(OpCodes.Dup); cursor.Emit(OpCodes.Stloc, variables[0]); for (int i = 1; i < variables.Length; i++) { cursor.Emit(OpCodes.Ldloc, variables[i]); } } } } } namespace CollapseDisplay.Properties { [CompilerGenerated] [DebuggerNonUserCode] [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] internal class Resources { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static ResourceManager ResourceManager { get { if (resourceMan == null) { resourceMan = new ResourceManager("CollapseDisplay.Properties.Resources", typeof(Resources).Assembly); } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static byte[] HealthBarHighlight_Opaque => (byte[])ResourceManager.GetObject("HealthBarHighlight_Opaque", resourceCulture); internal Resources() { } } } namespace CollapseDisplay.Networking { public struct Net_RunFixedTimeStampWrapper : IEquatable<Net_RunFixedTimeStampWrapper> { public float t; public Net_RunFixedTimeStampWrapper() { t = 0f; } public readonly bool Equals(Net_RunFixedTimeStampWrapper other) { return t == other.t; } public static implicit operator FixedTimeStamp(Net_RunFixedTimeStampWrapper wrapper) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return new FixedTimeStamp(wrapper.t); } public static implicit operator Net_RunFixedTimeStampWrapper(FixedTimeStamp timeStamp) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) Net_RunFixedTimeStampWrapper result = new Net_RunFixedTimeStampWrapper(); result.t = timeStamp.t; return result; } } } namespace CollapseDisplay.Config { public class DelayedDamageBarStyle { public readonly ConfigEntry<bool> EnabledConfig; public readonly HealthBarType BarType; private readonly DelayedDamageDisplayOptions _displayOptions; private readonly float _baseSizeDelta; private BarStyle _barStyle; public BarStyle BarStyle => _barStyle; public DelayedDamageBarStyle(ConfigFile file, string sectionName, HealthBarType type, BarStyle baseStyle, DelayedDamageDisplayOptions displayOptions) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_0094: 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) BarType = type; string text = type switch { HealthBarType.Hud => "Player HUD", HealthBarType.AllyList => "Ally List", HealthBarType.Combat => "Enemy", HealthBarType.BaggedObject => "Drifter Bagged Object", _ => throw new NotImplementedException($"Bar type {type} is not implemented"), }; EnabledConfig = file.Bind<bool>(sectionName, "Show on " + text, true, new ConfigDescription("If this damage indicator should display on " + text + " healthbars", (AcceptableValueBase)null, Array.Empty<object>())); _barStyle = baseStyle; _baseSizeDelta = _barStyle.sizeDelta; _displayOptions = displayOptions; _displayOptions.IndicatorColor.SettingChanged += IndicatorColor_SettingChanged; updateBarColor(); _displayOptions.IndicatorScale.SettingChanged += IndicatorScale_SettingChanged; updateBarSizeDelta(); } private void IndicatorColor_SettingChanged(object sender, EventArgs e) { updateBarColor(); } private void updateBarColor() { //IL_0011: 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) _barStyle.baseColor = _displayOptions.IndicatorColor.Value; } private void IndicatorScale_SettingChanged(object sender, EventArgs e) { updateBarSizeDelta(); } private void updateBarSizeDelta() { _barStyle.sizeDelta = Mathf.Max(0f, _baseSizeDelta * _displayOptions.IndicatorScale.Value); } } public class DelayedDamageDisplayOptions { public readonly ConfigEntry<Color> IndicatorColor; public readonly ConfigEntry<float> IndicatorScale; public readonly DelayedDamageBarStyle HUDHealthBarStyle; public readonly DelayedDamageBarStyle AllyListHealthBarStyle; public readonly DelayedDamageBarStyle CombatHealthBarStyle; public readonly DelayedDamageBarStyle BaggedObjectBarStyle; public DelayedDamageBarStyle FallbackHealthBarStyle => CombatHealthBarStyle ?? AllyListHealthBarStyle ?? HUDHealthBarStyle; public DelayedDamageDisplayOptions(Sprite highlightSprite, ConfigFile file, string sectionName, Color defaultColor, float defaultIndicatorScale) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00cc: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) IndicatorColor = file.Bind<Color>(sectionName, "Indicator Color", defaultColor, new ConfigDescription("The color of this damage indicator", (AcceptableValueBase)null, Array.Empty<object>())); IndicatorScale = file.Bind<float>(sectionName, "Indicator Scale", defaultIndicatorScale, new ConfigDescription("The scale of this damage indicator", (AcceptableValueBase)null, Array.Empty<object>())); HUDHealthBarStyle = new DelayedDamageBarStyle(file, sectionName, HealthBarType.Hud, new BarStyle { enabled = true, imageType = (Type)1, sizeDelta = 5f, sprite = highlightSprite }, this); AllyListHealthBarStyle = new DelayedDamageBarStyle(file, sectionName, HealthBarType.AllyList, new BarStyle { enabled = true, imageType = (Type)1, sizeDelta = 1f, sprite = highlightSprite }, this); CombatHealthBarStyle = new DelayedDamageBarStyle(file, sectionName, HealthBarType.Combat, new BarStyle { enabled = true, imageType = (Type)1, sizeDelta = 1f, sprite = highlightSprite }, this); BaggedObjectBarStyle = new DelayedDamageBarStyle(file, sectionName, HealthBarType.BaggedObject, new BarStyle { enabled = true, imageType = (Type)1, sizeDelta = 1f, sprite = highlightSprite }, this); } public DelayedDamageBarStyle GetDamageBarStyle(HealthBarType barType) { return barType switch { HealthBarType.Hud => HUDHealthBarStyle, HealthBarType.Combat => CombatHealthBarStyle, HealthBarType.AllyList => AllyListHealthBarStyle, HealthBarType.BaggedObject => BaggedObjectBarStyle, HealthBarType.Unknown => FallbackHealthBarStyle, _ => throw new NotImplementedException($"{barType} is not implemented"), }; } } } namespace Unity { [StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)] public class GeneratedNetworkCode { public static void _WriteNet_RunFixedTimeStampWrapper_None(NetworkWriter writer, Net_RunFixedTimeStampWrapper value) { writer.Write(value.t); } public static void _WriteDelayedDamageInfo_None(NetworkWriter writer, DelayedDamageInfo value) { writer.Write(value.Damage); _WriteNet_RunFixedTimeStampWrapper_None(writer, value.Wrap_DamageTimestamp); } public static Net_RunFixedTimeStampWrapper _ReadNet_RunFixedTimeStampWrapper_None(NetworkReader reader) { Net_RunFixedTimeStampWrapper result = default(Net_RunFixedTimeStampWrapper); result.t = reader.ReadSingle(); return result; } public static DelayedDamageInfo _ReadDelayedDamageInfo_None(NetworkReader reader) { DelayedDamageInfo result = default(DelayedDamageInfo); result.Damage = reader.ReadSingle(); result.Wrap_DamageTimestamp = _ReadNet_RunFixedTimeStampWrapper_None(reader); return result; } } }