Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of EclipseArtifacts v1.3.0
plugins/EclipseArtifacts/EclipseArtifacts.dll
Decompiled 5 months agousing System; using System.CodeDom.Compiler; using System.Collections; 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.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EclipseArtifacts.Properties; using EclipseRefurbished; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour.HookGen; using R2API; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.ContentManagement; using UnityEngine; [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("Judgy")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+2f86bc68d2ed10db0acc670fab9cfd82b4b6f622")] [assembly: AssemblyProduct("EclipseArtifacts")] [assembly: AssemblyTitle("EclipseArtifacts")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 EclipseArtifacts { public static class EclipseArtifactsBehavior { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ILHook_FrailtyCompat; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Manipulator <>9__2_0; public static Manipulator <>9__2_1; public static Manipulator <>9__2_2; public static Manipulator <>9__2_3; public static Manipulator <>9__2_4; public static Manipulator <>9__2_5; public static Manipulator <>9__2_6; public static Manipulator <>9__2_7; public static Manipulator <>9__3_0; public static Manipulator <>9__3_1; public static Manipulator <>9__3_2; public static Manipulator <>9__3_3; public static Manipulator <>9__3_4; public static Manipulator <>9__3_5; public static Manipulator <>9__3_6; public static Manipulator <>9__3_7; public static Func<Instruction, bool> <>9__4_0; public static Func<Instruction, bool> <>9__4_1; public static Func<Instruction, bool> <>9__6_0; public static Func<Instruction, bool> <>9__6_1; public static Func<Instruction, bool> <>9__6_2; public static Func<Instruction, bool> <>9__6_3; public static Func<Instruction, bool> <>9__6_4; public static Func<float> <>9__6_5; internal void <EnableHooks>b__2_0(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <EnableHooks>b__2_1(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <EnableHooks>b__2_2(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <EnableHooks>b__2_3(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <EnableHooks>b__2_4(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <EnableHooks>b__2_5(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <EnableHooks>b__2_6(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <EnableHooks>b__2_7(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <DisableHooks>b__3_0(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <DisableHooks>b__3_1(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <DisableHooks>b__3_2(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <DisableHooks>b__3_3(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <DisableHooks>b__3_4(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <DisableHooks>b__3_5(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <DisableHooks>b__3_6(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal void <DisableHooks>b__3_7(ILContext il) { ILHook_GetSelectedDifficulty(il); } internal bool <ILHook_GetSelectedDifficulty>b__4_0(Instruction x) { return ILPatternMatchingExt.MatchCall<Run>(x, "get_instance"); } internal bool <ILHook_GetSelectedDifficulty>b__4_1(Instruction x) { return ILPatternMatchingExt.MatchCallvirt<Run>(x, "get_selectedDifficulty"); } internal bool <ILHook_FrailtyCompat>b__6_0(Instruction x) { return ILPatternMatchingExt.MatchLdloc(x, 7); } internal bool <ILHook_FrailtyCompat>b__6_1(Instruction x) { return ILPatternMatchingExt.MatchDup(x); } internal bool <ILHook_FrailtyCompat>b__6_2(Instruction x) { return ILPatternMatchingExt.MatchLdfld<DamageInfo>(x, "damage"); } internal bool <ILHook_FrailtyCompat>b__6_3(Instruction x) { return ILPatternMatchingExt.MatchLdcR4(x, 2f); } internal bool <ILHook_FrailtyCompat>b__6_4(Instruction x) { return ILPatternMatchingExt.MatchMul(x); } internal float <ILHook_FrailtyCompat>b__6_5() { bool num = RunArtifactManager.instance.IsArtifactEnabled(Artifacts.weakAssKneesArtifactDef); bool flag = IsArtifactEnabled(3); if (num && flag) { switch (EclipseArtifactsConfig.frailtyCompatMode.Value) { case EclipseArtifactsConfig.FrailtyCompatMode.Vanilla: return 2f; case EclipseArtifactsConfig.FrailtyCompatMode.Additive: return 3f; case EclipseArtifactsConfig.FrailtyCompatMode.Multiplicative: return 4f; } } return 2f; } } private static bool _hooksEnabled; public static bool IsArtifactEnabled(int eclipseLevel) { if ((Object)(object)RunArtifactManager.instance == (Object)null) { return false; } ArtifactDef artifactDefFromEclipseLevel = EclipseArtifactsContent.Artifacts.GetArtifactDefFromEclipseLevel(eclipseLevel); if ((Object)(object)artifactDefFromEclipseLevel == (Object)null) { return false; } return RunArtifactManager.instance.IsArtifactEnabled(artifactDefFromEclipseLevel); } public static void EnableHooks() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //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) //IL_004b: Expected O, but got Unknown //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_006f: Expected O, but got Unknown //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: Expected O, but got Unknown //IL_00ac: 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_00b7: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0118: 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_0123: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown if (_hooksEnabled) { return; } object obj = <>c.<>9__2_0; if (obj == null) { Manipulator val = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__2_0 = val; obj = (object)val; } CharacterMaster.OnBodyStart += (Manipulator)obj; object obj2 = <>c.<>9__2_1; if (obj2 == null) { Manipulator val2 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__2_1 = val2; obj2 = (object)val2; } HoldoutZoneController.DoUpdate += (Manipulator)obj2; object obj3 = <>c.<>9__2_2; if (obj3 == null) { Manipulator val3 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__2_2 = val3; obj3 = (object)val3; } GlobalEventManager.OnCharacterHitGroundServer += (Manipulator)obj3; object obj4 = <>c.<>9__2_3; if (obj4 == null) { Manipulator val4 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__2_3 = val4; obj4 = (object)val4; } CharacterBody.RecalculateStats += (Manipulator)obj4; object obj5 = <>c.<>9__2_4; if (obj5 == null) { Manipulator val5 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__2_4 = val5; obj5 = (object)val5; } HealthComponent.Heal += (Manipulator)obj5; object obj6 = <>c.<>9__2_5; if (obj6 == null) { Manipulator val6 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__2_5 = val6; obj6 = (object)val6; } DeathRewards.OnKilledServer += (Manipulator)obj6; object obj7 = <>c.<>9__2_6; if (obj7 == null) { Manipulator val7 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__2_6 = val7; obj7 = (object)val7; } CharacterBody.RecalculateStats += (Manipulator)obj7; object obj8 = <>c.<>9__2_7; if (obj8 == null) { Manipulator val8 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__2_7 = val8; obj8 = (object)val8; } HealthComponent.TakeDamageProcess += (Manipulator)obj8; object obj9 = <>O.<0>__ILHook_FrailtyCompat; if (obj9 == null) { Manipulator val9 = ILHook_FrailtyCompat; <>O.<0>__ILHook_FrailtyCompat = val9; obj9 = (object)val9; } GlobalEventManager.OnCharacterHitGroundServer += (Manipulator)obj9; if (EclipseRefurbishedCompat.Enabled) { EclipseRefurbishedCompat.EnableHooks(); } _hooksEnabled = true; } public static void DisableHooks() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //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) //IL_004b: Expected O, but got Unknown //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_006f: Expected O, but got Unknown //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: Expected O, but got Unknown //IL_00ac: 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_00b7: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0118: 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_0123: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown if (!_hooksEnabled) { return; } object obj = <>c.<>9__3_0; if (obj == null) { Manipulator val = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__3_0 = val; obj = (object)val; } CharacterMaster.OnBodyStart -= (Manipulator)obj; object obj2 = <>c.<>9__3_1; if (obj2 == null) { Manipulator val2 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__3_1 = val2; obj2 = (object)val2; } HoldoutZoneController.DoUpdate -= (Manipulator)obj2; object obj3 = <>c.<>9__3_2; if (obj3 == null) { Manipulator val3 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__3_2 = val3; obj3 = (object)val3; } GlobalEventManager.OnCharacterHitGroundServer -= (Manipulator)obj3; object obj4 = <>c.<>9__3_3; if (obj4 == null) { Manipulator val4 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__3_3 = val4; obj4 = (object)val4; } CharacterBody.RecalculateStats -= (Manipulator)obj4; object obj5 = <>c.<>9__3_4; if (obj5 == null) { Manipulator val5 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__3_4 = val5; obj5 = (object)val5; } HealthComponent.Heal -= (Manipulator)obj5; object obj6 = <>c.<>9__3_5; if (obj6 == null) { Manipulator val6 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__3_5 = val6; obj6 = (object)val6; } DeathRewards.OnKilledServer -= (Manipulator)obj6; object obj7 = <>c.<>9__3_6; if (obj7 == null) { Manipulator val7 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__3_6 = val7; obj7 = (object)val7; } CharacterBody.RecalculateStats -= (Manipulator)obj7; object obj8 = <>c.<>9__3_7; if (obj8 == null) { Manipulator val8 = delegate(ILContext il) { ILHook_GetSelectedDifficulty(il); }; <>c.<>9__3_7 = val8; obj8 = (object)val8; } HealthComponent.TakeDamageProcess -= (Manipulator)obj8; object obj9 = <>O.<0>__ILHook_FrailtyCompat; if (obj9 == null) { Manipulator val9 = ILHook_FrailtyCompat; <>O.<0>__ILHook_FrailtyCompat = val9; obj9 = (object)val9; } GlobalEventManager.OnCharacterHitGroundServer -= (Manipulator)obj9; if (EclipseRefurbishedCompat.Enabled) { EclipseRefurbishedCompat.DisableHooks(); } _hooksEnabled = false; } public static void ILHook_GetSelectedDifficulty(ILContext il, bool overrideDiffWhenAnyArtifactIsEnabled = false) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown ILCursor val = new ILCursor(il); bool flag = false; do { int checkedDiff = -1; flag = val.TryGotoNext(new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchCall<Run>(x, "get_instance"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt<Run>(x, "get_selectedDifficulty"), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref checkedDiff) }); if (flag && checkedDiff >= 3 && checkedDiff <= 10) { val.Index += 2; val.EmitDelegate<Func<DifficultyIndex, DifficultyIndex>>((Func<DifficultyIndex, DifficultyIndex>)((DifficultyIndex currentDiffIndex) => ShouldOverrideDifficulty(checkedDiff, overrideDiffWhenAnyArtifactIsEnabled) ? ((DifficultyIndex)checkedDiff) : currentDiffIndex)); } } while (flag); } public static bool ShouldOverrideDifficulty(int checkedDiff, bool overrideDiffWhenAnyArtifactIsEnabled) { int num = checkedDiff - 2; for (int i = 1; i <= 8; i++) { if ((i == num || overrideDiffWhenAnyArtifactIsEnabled) && IsArtifactEnabled(i)) { return true; } } return false; } public static void ILHook_FrailtyCompat(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (!val.TryGotoNext(new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 7), (Instruction x) => ILPatternMatchingExt.MatchDup(x), (Instruction x) => ILPatternMatchingExt.MatchLdfld<DamageInfo>(x, "damage"), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 2f), (Instruction x) => ILPatternMatchingExt.MatchMul(x) })) { Log.LogError("FrailtyCompat hook failed"); return; } val.Index += 3; val.Remove(); val.EmitDelegate<Func<float>>((Func<float>)delegate { bool num = RunArtifactManager.instance.IsArtifactEnabled(Artifacts.weakAssKneesArtifactDef); bool flag = IsArtifactEnabled(3); if (num && flag) { switch (EclipseArtifactsConfig.frailtyCompatMode.Value) { case EclipseArtifactsConfig.FrailtyCompatMode.Vanilla: return 2f; case EclipseArtifactsConfig.FrailtyCompatMode.Additive: return 3f; case EclipseArtifactsConfig.FrailtyCompatMode.Multiplicative: return 4f; } } return 2f; }); } } public static class EclipseArtifactsConfig { public enum FrailtyCompatMode { Vanilla, Additive, Multiplicative } public static ConfigEntry<FrailtyCompatMode> frailtyCompatMode; public static void Init(ConfigFile config) { frailtyCompatMode = config.Bind<FrailtyCompatMode>("Compatibility", "Artifact of Frailty", FrailtyCompatMode.Additive, "Determines how `Artifact of Eclipse 3` and `Artifact of Frailty` interacts with each other.\n- Vanilla: only counts 1 of them (+100% damage)\n- Additive: adds the values (+200% damage)\n- Multiplicative: multiplies the values (+300% damage)"); if (RiskOfOptionsCompat.Enabled) { RiskOfOptionsCompat.AddConfig(); } } } public class EclipseArtifactsContent : IContentPackProvider { public static class Artifacts { public static Dictionary<int, ArtifactDef> artifactDefs = new Dictionary<int, ArtifactDef>(); public static ArtifactDef GetArtifactDefFromEclipseLevel(int eclipseLevel) { if (artifactDefs.TryGetValue(eclipseLevel, out var value)) { return value; } return null; } public static void Create() { for (int i = 1; i <= 8; i++) { ArtifactDef val = ScriptableObject.CreateInstance<ArtifactDef>(); val.cachedName = GetArtifactCachedNameFromEclipseLevel(i); val.nameToken = GetArtifactNameTokenFromEclipseLevel(i); val.descriptionToken = GetArtifactDescTokenFromEclipseLevel(i); val.smallIconSelectedSprite = GetSelectedSpriteFromEclipseLevel(i); val.smallIconDeselectedSprite = GetDeselectedSpriteFromEclipseLevel(i); artifactDefs.Add(i, val); } } public static string GetArtifactNameTokenFromEclipseLevel(int eclipseLevel) { return $"ARTIFACT_INDIVIDUALECLIPSE{eclipseLevel}_NAME"; } public static string GetArtifactDescTokenFromEclipseLevel(int eclipseLevel) { return $"ARTIFACT_INDIVIDUALECLIPSE{eclipseLevel}_DESC"; } private static string GetArtifactCachedNameFromEclipseLevel(int eclipseLevel) { return $"ARTIFACT_INDIVIDUALECLIPSE{eclipseLevel}"; } private static Sprite GetSelectedSpriteFromEclipseLevel(int eclipseLevel) { //IL_003a: 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) Sprite val = EclipseArtifactsPlugin.LoadResourceSprite($"E{eclipseLevel}_selected"); if ((Object)(object)val != (Object)null) { return val; } return Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 4f, 4f), new Vector2(3f, 3f)); } private static Sprite GetDeselectedSpriteFromEclipseLevel(int eclipseLevel) { //IL_003a: 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) Sprite val = EclipseArtifactsPlugin.LoadResourceSprite($"E{eclipseLevel}_deselected"); if ((Object)(object)val != (Object)null) { return val; } return Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 4f, 4f), new Vector2(3f, 3f)); } } public ContentPack pack = new ContentPack(); public string identifier => "EclipseArtifactContent"; public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { Artifacts.Create(); pack.artifactDefs.Add(new List<ArtifactDef>(Artifacts.artifactDefs.Values).ToArray()); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(pack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } public static class EclipseArtifactsLanguage { public static bool TokensRegistered { get; private set; } public static void TryRegisterTokens() { if (TokensRegistered) { return; } for (int i = 1; i <= 8; i++) { if (Language.IsTokenInvalid($"ECLIPSE_{i}_DESCRIPTION")) { return; } } for (int j = 1; j <= 8; j++) { RegisterArtifactLanguageData(j); } TokensRegistered = true; } private static void RegisterArtifactLanguageData(int eclipseLevel) { LanguageAPI.Add(EclipseArtifactsContent.Artifacts.GetArtifactNameTokenFromEclipseLevel(eclipseLevel), GetArtifactName(eclipseLevel)); LanguageAPI.Add(EclipseArtifactsContent.Artifacts.GetArtifactDescTokenFromEclipseLevel(eclipseLevel), GetArtifactDescription(eclipseLevel)); } private static string GetArtifactName(int eclipseLevel) { return $"Artifact of Eclipse {eclipseLevel}"; } private static string GetArtifactDescription(int eclipseLevel) { string text = $"ECLIPSE_{eclipseLevel}_DESCRIPTION"; string prefix = $"<mspace=0.5em>({eclipseLevel})</mspace> "; string @string = Language.GetString(text); string text2 = @string.Split('\n').FirstOrDefault((string s) => s.StartsWith(prefix)); if (text2 == null) { Log.LogError("Error while parsing \"" + text + "\":\n\n" + @string); return text; } string text3 = text2; int length = prefix.Length; string text4 = text3.Substring(length, text3.Length - length).TrimEnd('\n'); string text5 = "<style=cStack>>" + text4; if (EclipseRefurbishedCompat.Enabled) { text5 = EclipseRefurbishedCompat.AddDirectorCreditsToDescription(text5); } return text5; } } [BepInPlugin("Judgy.EclipseArtifacts", "EclipseArtifacts", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class EclipseArtifactsPlugin : BaseUnityPlugin { public const string PluginGUID = "Judgy.EclipseArtifacts"; public const string PluginAuthor = "Judgy"; public const string PluginName = "EclipseArtifacts"; public const string PluginVersion = "1.3.0"; public static string PluginDirectory; public void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Log.Init(((BaseUnityPlugin)this).Logger); EclipseArtifactsConfig.Init(((BaseUnityPlugin)this).Config); ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders); EclipseArtifactsBehavior.EnableHooks(); Log.LogInfo("Awake done."); } public void OnDestroy() { EclipseArtifactsBehavior.DisableHooks(); } public void Update() { if (!EclipseArtifactsLanguage.TokensRegistered) { EclipseArtifactsLanguage.TryRegisterTokens(); } } private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)new EclipseArtifactsContent()); } public static Sprite LoadResourceSprite(string resName) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); Sprite result = null; try { byte[] array = (byte[])Resources.ResourceManager.GetObject(resName); ImageConversion.LoadImage(val, array, false); val.Apply(); result = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(64f, 64f)); } catch (Exception ex) { Debug.LogError((object)ex.ToString()); } return result; } } public class EclipseRefurbishedCompat { private static bool? _enabled; private static bool _hooksEnabled; private static string _creditsModifierDesc; public static bool Enabled { get { bool valueOrDefault = _enabled.GetValueOrDefault(); if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.Puporongod.EclipseRefurbished"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static string AddDirectorCreditsToDescription(string description) { if (_creditsModifierDesc == null) { _creditsModifierDesc = Language.GetString("ECLIPSE_1_DESCRIPTION").Split('\n').FirstOrDefault((string s) => s.StartsWith("Director Credits:")) .TrimEnd('\n'); } List<string> list = description.Split("\n").ToList(); list.Add("<style=cStack>>" + _creditsModifierDesc + " (Non-Stacking)</style>"); return string.Join('\n', list); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void EnableHooks() { if (!_hooksEnabled) { HookEndpointManager.Modify((MethodBase)GetCombatDirectorEnableMethod(), (Delegate)new Action<ILContext>(Modify_CombatDirector_OnEnable)); HookEndpointManager.Modify((MethodBase)GetATKSpeedMethod(), (Delegate)new Action<ILContext>(Modify_ATKSpeedAndAWUCooldown)); _hooksEnabled = true; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void DisableHooks() { if (_hooksEnabled) { HookEndpointManager.Unmodify((MethodBase)GetCombatDirectorEnableMethod(), (Delegate)new Action<ILContext>(Modify_CombatDirector_OnEnable)); HookEndpointManager.Unmodify((MethodBase)GetATKSpeedMethod(), (Delegate)new Action<ILContext>(Modify_ATKSpeedAndAWUCooldown)); _hooksEnabled = false; } } public static void Modify_CombatDirector_OnEnable(ILContext il) { EclipseArtifactsBehavior.ILHook_GetSelectedDifficulty(il, overrideDiffWhenAnyArtifactIsEnabled: true); } public static void Modify_ATKSpeedAndAWUCooldown(ILContext il) { EclipseArtifactsBehavior.ILHook_GetSelectedDifficulty(il); } private static MethodInfo GetCombatDirectorEnableMethod() { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic; return typeof(EclipseRefurbished).GetMethod("CombatDirector_OnEnable", bindingAttr); } private static MethodInfo GetATKSpeedMethod() { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic; return typeof(EclipseRefurbished).GetMethod("ATKSpeedAndAWUCooldown", bindingAttr); } } internal static class Log { internal static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void LogDebug(object data) { _logSource.LogDebug(data); } internal static void LogError(object data) { _logSource.LogError(data); } internal static void LogFatal(object data) { _logSource.LogFatal(data); } internal static void LogInfo(object data) { _logSource.LogInfo(data); } internal static void LogMessage(object data) { _logSource.LogMessage(data); } internal static void LogWarning(object data) { _logSource.LogWarning(data); } } internal class RiskOfOptionsCompat { private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled.GetValueOrDefault(); if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown ModSettingsManager.SetModIcon(LoadIcon()); ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)EclipseArtifactsConfig.frailtyCompatMode)); } private static Sprite LoadIcon() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown string text = FindIconFilePath(); if (text == null) { return null; } Texture2D val = new Texture2D(256, 256); ImageConversion.LoadImage(val, File.ReadAllBytes(text)); return Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0f, 0f)); } private static string FindIconFilePath() { DirectoryInfo directoryInfo = new DirectoryInfo(EclipseArtifactsPlugin.PluginDirectory); do { FileInfo[] files = directoryInfo.GetFiles("icon.png", SearchOption.TopDirectoryOnly); if (files != null && files.Length != 0) { return files[0].FullName; } directoryInfo = directoryInfo.Parent; } while (directoryInfo != null && !string.Equals(directoryInfo.Name, "plugins", StringComparison.OrdinalIgnoreCase)); return null; } } } namespace EclipseArtifacts.Properties { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] 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("EclipseArtifacts.Properties.Resources", typeof(Resources).Assembly); } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static byte[] E1_deselected => (byte[])ResourceManager.GetObject("E1_deselected", resourceCulture); internal static byte[] E1_selected => (byte[])ResourceManager.GetObject("E1_selected", resourceCulture); internal static byte[] E2_deselected => (byte[])ResourceManager.GetObject("E2_deselected", resourceCulture); internal static byte[] E2_selected => (byte[])ResourceManager.GetObject("E2_selected", resourceCulture); internal static byte[] E3_deselected => (byte[])ResourceManager.GetObject("E3_deselected", resourceCulture); internal static byte[] E3_selected => (byte[])ResourceManager.GetObject("E3_selected", resourceCulture); internal static byte[] E4_deselected => (byte[])ResourceManager.GetObject("E4_deselected", resourceCulture); internal static byte[] E4_selected => (byte[])ResourceManager.GetObject("E4_selected", resourceCulture); internal static byte[] E5_deselected => (byte[])ResourceManager.GetObject("E5_deselected", resourceCulture); internal static byte[] E5_selected => (byte[])ResourceManager.GetObject("E5_selected", resourceCulture); internal static byte[] E6_deselected => (byte[])ResourceManager.GetObject("E6_deselected", resourceCulture); internal static byte[] E6_selected => (byte[])ResourceManager.GetObject("E6_selected", resourceCulture); internal static byte[] E7_deselected => (byte[])ResourceManager.GetObject("E7_deselected", resourceCulture); internal static byte[] E7_selected => (byte[])ResourceManager.GetObject("E7_selected", resourceCulture); internal static byte[] E8_deselected => (byte[])ResourceManager.GetObject("E8_deselected", resourceCulture); internal static byte[] E8_selected => (byte[])ResourceManager.GetObject("E8_selected", resourceCulture); internal Resources() { } } }