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 HallowedTweaks v1.0.0
HallowedTweaks.dll
Decompiled 12 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using EntityStates; using EntityStates.BrotherMonster; using EntityStates.BrotherMonster.KarmaSpire; using EntityStates.CursedBook.RitualCircle; using EntityStates.CursedBook.Spells; using EntityStates.HallowedCauldron; using EntityStates.Heretic.Weapon; using EntityStates.Missions.BrotherEncounter; using EntityStates.NkuhanaChest; using HG; using HallowedTweaks; using HallowedTweaks.EnragedMithrix; using HallowedTweaks.Mithrix.EnragedMithrix; using HarmonyLib; using Microsoft.CodeAnalysis; using R2API; using RoR2; using RoR2.CharacterSpeech; using RoR2.Karma; using RoR2.Projectile; using RoR2.Quests; using RoR2.Quests.CompulsionQuests; using RoR2.Skills; using RoR2.UI; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.Networking; using UnityEngine.Rendering.PostProcessing; [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("HallowedTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HallowedTweaks")] [assembly: AssemblyTitle("HallowedTweaks")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [HarmonyPatch(typeof(PreEncounter), "OnEnter")] public static class EnragedPreEncounterDelay { private const float ExtraDelay = 0f; private static void Prefix() { bool num = HallowedTweaksPlugin.IsMithrixEnraged(); PreEncounter.duration = (num ? (HallowedTweaksPlugin.VanillaPreEncounterDuration + 0f) : HallowedTweaksPlugin.VanillaPreEncounterDuration); if (num) { EMMusic.FightMusicActive = true; } } } namespace HallowedTweaks { [HarmonyPatch] public static class CompulsionChallengeChanges { private const int VanillaKillsPerPlayer = 10; private const int KillsPerPlayer = 30; internal static readonly Action<BaseQuest, bool> EndQuest = AccessTools.MethodDelegate<Action<BaseQuest, bool>>(AccessTools.Method(typeof(BaseQuest), "EndQuest", (Type[])null, (Type[])null), (object)null, true); internal static readonly Func<BaseQuest, bool> IsQuestOver = AccessTools.MethodDelegate<Func<BaseQuest, bool>>(AccessTools.PropertyGetter(typeof(BaseQuest), "isQuestOver"), (object)null, true); private static readonly Action<BaseQuest> MarkDirty = AccessTools.MethodDelegate<Action<BaseQuest>>(AccessTools.Method(typeof(BaseQuest), "MarkDirtyServer", (Type[])null, (Type[])null), (object)null, true); private static readonly Func<BaseCompulsionQuest, CharacterBody, bool> IsParticipant = AccessTools.MethodDelegate<Func<BaseCompulsionQuest, CharacterBody, bool>>(AccessTools.Method(typeof(BaseCompulsionQuest), "IsBodyFromParticipatingTeam", (Type[])null, (Type[])null), (object)null, true); [HarmonyPostfix] [HarmonyPatch(typeof(CompulsionQuestNoHitRun), "OnEnter")] private static void MoreKills(CompulsionQuestNoHitRun __instance, ref int ____enemiesToKill) { ____enemiesToKill = ____enemiesToKill / 10 * 30; MarkDirty((BaseQuest)(object)__instance); } [HarmonyPrefix] [HarmonyPatch(typeof(CompulsionQuestNoHitRun), "OnDamageDealt")] private static bool NoHitFail(CompulsionQuestNoHitRun __instance, DamageReport damageReport) { if (IsQuestOver((BaseQuest)(object)__instance)) { return false; } CharacterBody victimBody = damageReport.victimBody; if (!Object.op_Implicit((Object)(object)victimBody) || !IsParticipant((BaseCompulsionQuest)(object)__instance, victimBody)) { return false; } if ((Object)(object)damageReport.attackerBody != (Object)(object)victimBody && victimBody.isPlayerControlled) { EndQuest((BaseQuest)(object)__instance, arg2: false); } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(CompulsionQuestMeteorShower), "CheckForPlayerDamageServer")] private static bool MeteorFail(CompulsionQuestMeteorShower __instance, DamageReport damageReport, MeteorStormController ____meteorStormControllerInstance) { if (IsQuestOver((BaseQuest)(object)__instance)) { return false; } CharacterBody victimBody = damageReport.victimBody; if (!Object.op_Implicit((Object)(object)victimBody) || !IsParticipant((BaseCompulsionQuest)(object)__instance, victimBody) || !victimBody.isPlayerControlled) { return false; } if (Object.op_Implicit((Object)(object)____meteorStormControllerInstance)) { ____meteorStormControllerInstance.waveCount = ____meteorStormControllerInstance.performedWaves + 1; } EndQuest((BaseQuest)(object)__instance, arg2: false); return false; } } public class CompulsionQuestArtifact : StageCompulsionQuest { internal const string Identifier = "HallowedTweaks_CompulsionArtifact"; private ArtifactIndex artifactIndex = (ArtifactIndex)(-1); private static ArtifactDef[] Pool => (ArtifactDef[])(object)new ArtifactDef[6] { Artifacts.FriendlyFire, Artifacts.WeakAssKnees, Artifacts.EliteOnly, Artifacts.WispOnDeath, Artifacts.Bomb, Artifacts.ShadowClone }; private ArtifactDef Artifact => ArtifactCatalog.GetArtifactDef(artifactIndex); public override string ObjectiveText { get { string text = (Object.op_Implicit((Object)(object)Artifact) ? Language.GetString(Artifact.nameToken) : "an Artifact"); return "Endure the " + text + " until the Teleporter is charged"; } } internal static bool CanStart(QuestRunner runner) { if (StageCompulsionQuest.CanStartStageChallenge("HallowedTweaks_CompulsionArtifact")) { return AvailableArtifacts().Any(); } return false; } private static IEnumerable<ArtifactDef> AvailableArtifacts() { RunArtifactManager manager = RunArtifactManager.instance; return Pool.Where((ArtifactDef a) => Object.op_Implicit((Object)(object)a) && Object.op_Implicit((Object)(object)manager) && !manager.IsArtifactEnabled(a)); } protected override bool StartEffect() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) ArtifactDef[] array = AvailableArtifacts().ToArray(); if (array.Length == 0) { return false; } ArtifactDef val = array[Random.Range(0, array.Length)]; artifactIndex = val.artifactIndex; RunArtifactManager.instance.SetArtifactEnabledServer(val, true); ((BaseQuest)this).MarkDirtyServer(); HallowedTweaksPlugin.Log.LogInfo((object)("Compulsion: artifact challenge enabled " + val.cachedName)); return true; } protected override void UndoEffect() { Disable(); } protected override void EndEffect() { Disable(); } private void Disable() { if (Object.op_Implicit((Object)(object)Artifact) && Object.op_Implicit((Object)(object)RunArtifactManager.instance)) { RunArtifactManager.instance.SetArtifactEnabledServer(Artifact, false); } } public override void OnSerialize(NetworkWriter writer) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected I4, but got Unknown ((BaseQuest)this).OnSerialize(writer); writer.Write((int)artifactIndex); } public override void OnDeserialize(NetworkReader reader) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) ((BaseQuest)this).OnDeserialize(reader); artifactIndex = (ArtifactIndex)reader.ReadInt32(); } } public abstract class CompulsionQuestEnemyItem : StageCompulsionQuest { private static readonly List<CompulsionQuestEnemyItem> giving = new List<CompulsionQuestEnemyItem>(); private static bool hooked; private readonly Dictionary<CharacterMaster, int> given = new Dictionary<CharacterMaster, int>(); protected abstract ItemDef Item { get; } protected abstract int Count { get; } public override string ObjectiveText => string.Format("Enemies spawn with {0} {1} until the Teleporter is charged", Count, Object.op_Implicit((Object)(object)Item) ? Language.GetString(Item.nameToken) : "items"); protected override bool StartEffect() { if (!Object.op_Implicit((Object)(object)Item)) { return false; } if (!hooked) { hooked = true; CharacterBody.onBodyStartGlobal += OnBodyStart; } giving.Add(this); return true; } protected override void UndoEffect() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) giving.Remove(this); foreach (KeyValuePair<CharacterMaster, int> item in given) { CharacterMaster key = item.Key; if (Object.op_Implicit((Object)(object)key) && Object.op_Implicit((Object)(object)key.inventory)) { key.inventory.RemoveItemPermanent(Item.itemIndex, item.Value); } } given.Clear(); } protected override void EndEffect() { giving.Remove(this); given.Clear(); } private static void OnBodyStart(CharacterBody body) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || giving.Count == 0 || !IsEnemy(body)) { return; } CharacterMaster master = body.master; if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory)) { return; } foreach (CompulsionQuestEnemyItem item in giving) { if (!item.given.ContainsKey(master)) { master.inventory.GiveItemPermanent(item.Item.itemIndex, item.Count); item.given[master] = item.Count; } } } private static bool IsEnemy(CharacterBody body) { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)body.teamComponent)) { return false; } TeamIndex teamIndex = body.teamComponent.teamIndex; if ((int)teamIndex != 2 && (int)teamIndex != 3) { return (int)teamIndex == 4; } return true; } } public class CompulsionQuestEnemyHooves : CompulsionQuestEnemyItem { internal const string Identifier = "HallowedTweaks_CompulsionEnemyHooves"; protected override ItemDef Item => Items.Hoof; protected override int Count => 7; internal static bool CanStart(QuestRunner runner) { return StageCompulsionQuest.CanStartStageChallenge("HallowedTweaks_CompulsionEnemyHooves"); } } public class CompulsionQuestEnemyAlienHeads : CompulsionQuestEnemyItem { internal const string Identifier = "HallowedTweaks_CompulsionEnemyAlienHeads"; protected override ItemDef Item => Items.AlienHead; protected override int Count => 2; internal static bool CanStart(QuestRunner runner) { return StageCompulsionQuest.CanStartStageChallenge("HallowedTweaks_CompulsionEnemyAlienHeads"); } } public class CompulsionQuestHeresy : StageCompulsionQuest { private class Grant { public CharacterMaster master; public ItemDef item; public int countBefore; } internal const string Identifier = "HallowedTweaks_CompulsionHeresy"; private static readonly Dictionary<string, Func<ItemDef>> BySurvivor = new Dictionary<string, Func<ItemDef>> { { "CommandoBody", () => Hooks }, { "HuntressBody", () => Strides }, { "Bandit2Body", () => Visions }, { "EngiBody", () => Strides }, { "MageBody", () => Hooks }, { "MercBody", () => Strides }, { "TreebotBody", () => Visions }, { "LoaderBody", () => Hooks }, { "CrocoBody", () => Strides }, { "CaptainBody", () => Visions }, { "RailgunnerBody", () => Visions }, { "VoidSurvivorBody", () => Hooks }, { "SeekerBody", () => Hooks }, { "FalseSonBody", () => Hooks }, { "ChefBody", () => Hooks }, { "DroneTechBody", () => Visions }, { "DrifterBody", () => Strides }, { "Enforcer2Body", () => Strides }, { "AcolyteBody", () => Visions } }; private readonly List<Grant> grants = new List<Grant>(); private static ItemDef Visions => Items.LunarPrimaryReplacement; private static ItemDef Hooks => Items.LunarSecondaryReplacement; private static ItemDef Strides => Items.LunarUtilityReplacement; private static ItemDef Essence => Items.LunarSpecialReplacement; public override string ObjectiveText => "Bear your Heresy until the Teleporter is charged. Do not cleanse it"; internal static bool CanStart(QuestRunner runner) { if (StageCompulsionQuest.CanStartStageChallenge("HallowedTweaks_CompulsionHeresy")) { return !AnyPlayerNearlyHeretic(); } return false; } private static bool AnyPlayerNearlyHeretic() { ItemDef[] source = (ItemDef[])(object)new ItemDef[4] { Visions, Hooks, Strides, Essence }; foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { Inventory inventory = (Object.op_Implicit((Object)(object)instance.master) ? instance.master.inventory : null); if (Object.op_Implicit((Object)(object)inventory) && source.Count((ItemDef item) => inventory.GetItemCountEffective(item) > 0) >= 3) { return true; } } return false; } private static ItemDef PickItem(CharacterBody body) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string bodyName = BodyCatalog.GetBodyName(body.bodyIndex); if (bodyName == "ToolbotBody") { GenericSkill val = (Object.op_Implicit((Object)(object)body.skillLocator) ? body.skillLocator.special : null); Type type = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.baseSkill)) ? ((SerializableEntityStateType)(ref val.baseSkill.activationState)).stateType : null); if (!(type != null) || !type.Name.Contains("DualWield")) { return Strides; } return Visions; } if (!BySurvivor.TryGetValue(bodyName, out var value)) { return null; } return value(); } protected override bool StartEffect() { PlayerCharacterMasterController[] array = ((BaseCompulsionQuest)this).GetPlayerCharacterMastersFromParticipatingTeam(true).ToArray(); foreach (PlayerCharacterMasterController val in array) { CharacterMaster val2 = (Object.op_Implicit((Object)(object)val) ? val.master : null); CharacterBody val3 = (Object.op_Implicit((Object)(object)val2) ? val2.GetBody() : null); if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val2.inventory)) { ItemDef val4 = PickItem(val3); if (Object.op_Implicit((Object)(object)val4)) { grants.Add(new Grant { master = val2, item = val4, countBefore = val2.inventory.GetItemCountPermanent(val4) }); val2.inventory.GiveItemPermanent(val4, 1); } } } return grants.Count > 0; } public override void FixedUpdate(float deltaTime) { base.FixedUpdate(deltaTime); if (!NetworkServer.active || ((BaseQuest)this).isQuestOver) { return; } foreach (Grant grant in grants) { if (Object.op_Implicit((Object)(object)grant.master) && Object.op_Implicit((Object)(object)grant.master.inventory) && grant.master.inventory.GetItemCountPermanent(grant.item) < grant.countBefore + 1) { HeresySquawk.Apply(grant.master, HeresySquawk.BuffForItem(grant.item)); ((BaseQuest)this).EndQuest(false); break; } } } protected override void UndoEffect() { foreach (Grant grant in grants) { TakeBack(grant); } grants.Clear(); } protected override void OnPassed() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) foreach (Grant grant in grants) { if (TakeBack(grant)) { CharacterBody val = (Object.op_Implicit((Object)(object)grant.master) ? grant.master.GetBody() : null); Vector3 val2 = (Object.op_Implicit((Object)(object)val) ? val.corePosition : (Object.op_Implicit((Object)(object)TeleporterInteraction.instance) ? ((Component)TeleporterInteraction.instance).transform.position : Vector3.zero)); Vector3 val3 = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.characterDirection)) ? val.characterDirection.forward : Vector3.forward); PickupDropletController.CreatePickupDroplet(new UniquePickup(PickupCatalog.FindPickupIndex(grant.item.itemIndex)), val2 + Vector3.up * 1.5f, Vector3.up * 15f + val3 * 5f, false); } } grants.Clear(); } private static bool TakeBack(Grant grant) { if (!Object.op_Implicit((Object)(object)grant.master) || !Object.op_Implicit((Object)(object)grant.master.inventory)) { return false; } if (grant.master.inventory.GetItemCountPermanent(grant.item) <= grant.countBefore) { return false; } grant.master.inventory.RemoveItemPermanent(grant.item, 1); return true; } } public abstract class CompulsionQuestInvasion : StageCompulsionQuest { private const float MinSpawnDistance = 25f; private const float MaxSpawnDistance = 70f; private const float BanishDepth = 1000f; private readonly List<CharacterMaster> invaders = new List<CharacterMaster>(); private int total; private int killed; private static readonly Dictionary<string, CharacterSpawnCard> cards = new Dictionary<string, CharacterSpawnCard>(); protected override bool PassOnTeleporterCharged => false; protected abstract string InvasionName { get; } protected abstract TeamIndex Team { get; } protected abstract (string cardPath, int soloCount)[] Spawns { get; } public override string ObjectiveText => $"Repel the {InvasionName} invasion ({killed}/{total})"; protected static CharacterSpawnCard LoadCard(string path) { //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) if (!cards.TryGetValue(path, out var value)) { value = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)path).WaitForCompletion(); if (!Object.op_Implicit((Object)(object)value)) { HallowedTweaksPlugin.Log.LogWarning((object)("Compulsion: spawn card not found: " + path)); } cards[path] = value; } return value; } protected static bool CanStartInvasion(string identifier, (string cardPath, int soloCount)[] spawns) { if (!BaseCompulsionQuest.IsInstanceActive(identifier)) { return spawns.All(((string cardPath, int soloCount) s) => Object.op_Implicit((Object)(object)LoadCard(s.cardPath))); } return false; } protected override bool StartEffect() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown CharacterBody val = (Object.op_Implicit((Object)(object)((BaseCompulsionQuest)this).compulsionQuestTracker) ? ((BaseCompulsionQuest)this).compulsionQuestTracker.questOwnerCharacterBody : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)DirectorCore.instance)) { return false; } int count = ((BaseCompulsionQuest)this).GetPlayerCharacterMastersFromParticipatingTeam(false).Count; int num = Mathf.Max(0, count - 1); (string, int)[] spawns = Spawns; for (int i = 0; i < spawns.Length; i++) { (string, int) tuple = spawns[i]; string item = tuple.Item1; int item2 = tuple.Item2; CharacterSpawnCard val2 = LoadCard(item); if (!Object.op_Implicit((Object)(object)val2)) { continue; } for (int j = 0; j < item2 + num; j++) { DirectorPlacementRule val3 = new DirectorPlacementRule { placementMode = (PlacementMode)1, minDistance = 25f, maxDistance = 70f, spawnOnTarget = ((Component)val).gameObject.transform }; DirectorSpawnRequest val4 = new DirectorSpawnRequest((SpawnCard)(object)val2, val3, ((BaseQuest)this).runner.questRNG) { teamIndexOverride = Team, ignoreTeamMemberLimit = true }; GameObject val5 = DirectorCore.instance.TrySpawnObject(val4); CharacterMaster val6 = (Object.op_Implicit((Object)(object)val5) ? val5.GetComponent<CharacterMaster>() : null); if (Object.op_Implicit((Object)(object)val6)) { invaders.Add(val6); } } } total = invaders.Count; ((BaseQuest)this).MarkDirtyServer(); return total > 0; } public override void FixedUpdate(float deltaTime) { base.FixedUpdate(deltaTime); if (NetworkServer.active && !((BaseQuest)this).isQuestOver) { int num = invaders.Count((CharacterMaster m) => !Object.op_Implicit((Object)(object)m) || m.IsDeadAndOutOfLivesServer()); if (num != killed) { killed = num; ((BaseQuest)this).MarkDirtyServer(); } if (killed >= total) { ((BaseQuest)this).EndQuest(true); } } } protected override void UndoEffect() { List<CharacterBody> list = (from m in invaders where Object.op_Implicit((Object)(object)m) select m.GetBody() into b where Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)b.healthComponent) && b.healthComponent.alive select b).ToList(); invaders.Clear(); foreach (CharacterBody item in list) { Banish(item); } } private static void Banish(CharacterBody body) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = FarBelow(body.footPosition); try { TeleportHelper.TeleportBody(body, val, false); ((Component)body).gameObject.transform.position = val; } catch (Exception ex) { HallowedTweaksPlugin.Log.LogWarning((object)("Compulsion: couldn't teleport " + ((Object)body).name + ": " + ex.Message)); } body.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo)); } private static Vector3 FarBelow(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) float y = position.y; RaycastHit val = default(RaycastHit); if (Physics.Raycast(position + Vector3.up, Vector3.down, ref val, 500f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask))) { y = ((RaycastHit)(ref val)).point.y; } return new Vector3(position.x, y - 1000f, position.z); } public override void OnSerialize(NetworkWriter writer) { ((BaseQuest)this).OnSerialize(writer); writer.Write(total); writer.Write(killed); } public override void OnDeserialize(NetworkReader reader) { ((BaseQuest)this).OnDeserialize(reader); total = reader.ReadInt32(); killed = reader.ReadInt32(); } } public class CompulsionQuestLunarInvasion : CompulsionQuestInvasion { internal const string Identifier = "HallowedTweaks_CompulsionLunarInvasion"; private static readonly (string, int)[] spawns = new(string, int)[3] { ("RoR2/Base/LunarExploder/cscLunarExploder.asset", 5), ("RoR2/Base/LunarGolem/cscLunarGolem.asset", 2), ("RoR2/Base/LunarWisp/cscLunarWisp.asset", 2) }; protected override string InvasionName => "Lunar"; protected override TeamIndex Team => (TeamIndex)2; protected override (string cardPath, int soloCount)[] Spawns => spawns; internal static bool CanStart(QuestRunner runner) { return CompulsionQuestInvasion.CanStartInvasion("HallowedTweaks_CompulsionLunarInvasion", spawns); } } public class CompulsionQuestVoidInvasion : CompulsionQuestInvasion { internal const string Identifier = "HallowedTweaks_CompulsionVoidInvasion"; private static readonly (string, int)[] spawns = new(string, int)[3] { ("RoR2/DLC1/VoidBarnacle/cscVoidBarnacle.asset", 3), ("RoR2/Base/Nullifier/cscNullifier.asset", 2), ("RoR2/DLC1/VoidMegaCrab/cscVoidMegaCrab.asset", 1) }; protected override string InvasionName => "Void"; protected override TeamIndex Team => (TeamIndex)4; protected override (string cardPath, int soloCount)[] Spawns => spawns; internal static bool CanStart(QuestRunner runner) { return CompulsionQuestInvasion.CanStartInvasion("HallowedTweaks_CompulsionVoidInvasion", spawns); } } public class CompulsionQuestScrapStack : StageCompulsionQuest { private class Target { public CharacterMaster master; public NetworkInstanceId masterId; public ItemIndex item; public int required; public int scrapped; public bool Done => scrapped >= required; } internal const string Identifier = "HallowedTweaks_CompulsionScrapStack"; private const string ScrapperCardPath = "RoR2/Base/Scrapper/iscScrapper.asset"; private static readonly List<CompulsionQuestScrapStack> active = new List<CompulsionQuestScrapStack>(); private readonly List<Target> targets = new List<Target>(); private GameObject scrapper; protected override bool PassOnTeleporterCharged => false; public override string ObjectiveText => "Everyone must scrap their largest stack"; internal static bool CanStart(QuestRunner runner) { if (!BaseCompulsionQuest.IsInstanceActive("HallowedTweaks_CompulsionScrapStack")) { return PlayerCharacterMasterController.instances.Any((PlayerCharacterMasterController p) => Object.op_Implicit((Object)(object)p.master) && Object.op_Implicit((Object)(object)p.master.inventory) && (int)LargestStack(p.master.inventory) != -1); } return false; } private static bool CanBeScrapped(ItemIndex index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) ItemDef itemDef = ItemCatalog.GetItemDef(index); if (!Object.op_Implicit((Object)(object)itemDef) || itemDef.hidden || !itemDef.canRemove || itemDef.ContainsTag((ItemTag)10)) { return false; } ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(itemDef.tier); if (Object.op_Implicit((Object)(object)itemTierDef)) { return itemTierDef.canScrap; } return false; } private static ItemIndex LargestStack(Inventory inventory) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) int num = 0; List<ItemIndex> list = new List<ItemIndex>(); for (int i = 0; i < ItemCatalog.itemCount; i++) { ItemIndex val = (ItemIndex)i; if (!CanBeScrapped(val)) { continue; } int itemCountPermanent = inventory.GetItemCountPermanent(val); if (itemCountPermanent > 0 && itemCountPermanent >= num) { if (itemCountPermanent > num) { num = itemCountPermanent; list.Clear(); } list.Add(val); } } if (list.Count != 0) { return list[Random.Range(0, list.Count)]; } return (ItemIndex)(-1); } protected override bool StartEffect() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) PlayerCharacterMasterController[] array = ((BaseCompulsionQuest)this).GetPlayerCharacterMastersFromParticipatingTeam(false).ToArray(); foreach (PlayerCharacterMasterController val in array) { CharacterMaster val2 = (Object.op_Implicit((Object)(object)val) ? val.master : null); if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.inventory)) { ItemIndex val3 = LargestStack(val2.inventory); if ((int)val3 != -1) { targets.Add(new Target { master = val2, masterId = ((NetworkBehaviour)val2).netId, item = val3, required = val2.inventory.GetItemCountPermanent(val3) }); } } } if (targets.Count == 0) { return false; } scrapper = SpawnScrapper(); if (!Object.op_Implicit((Object)(object)scrapper)) { targets.Clear(); return false; } active.Add(this); ((BaseQuest)this).MarkDirtyServer(); return true; } private GameObject SpawnScrapper() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown InteractableSpawnCard val = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/Scrapper/iscScrapper.asset").WaitForCompletion(); CharacterBody val2 = (Object.op_Implicit((Object)(object)((BaseCompulsionQuest)this).compulsionQuestTracker) ? ((BaseCompulsionQuest)this).compulsionQuestTracker.questOwnerCharacterBody : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)DirectorCore.instance)) { HallowedTweaksPlugin.Log.LogWarning((object)"Compulsion: couldn't spawn the scrapper"); return null; } DirectorPlacementRule val3 = new DirectorPlacementRule { placementMode = (PlacementMode)1, minDistance = 3f, maxDistance = 15f, spawnOnTarget = ((Component)val2).gameObject.transform }; return DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest((SpawnCard)(object)val, val3, ((BaseQuest)this).runner.questRNG)); } internal static void CreditScrap(CharacterMaster master, ItemIndex item, int amount) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) CompulsionQuestScrapStack[] array = active.ToArray(); for (int i = 0; i < array.Length; i++) { array[i].Credit(master, item, amount); } } private void Credit(CharacterMaster master, ItemIndex item, int amount) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!((BaseQuest)this).isQuestOver) { Target target = targets.FirstOrDefault((Target t) => (Object)(object)t.master == (Object)(object)master && t.item == item && !t.Done); if (target != null) { target.scrapped = Mathf.Min(target.required, target.scrapped + amount); ((BaseQuest)this).MarkDirtyServer(); CheckAllDone(); } } } public override void FixedUpdate(float deltaTime) { base.FixedUpdate(deltaTime); if (NetworkServer.active && !((BaseQuest)this).isQuestOver) { CheckAllDone(); } } private void CheckAllDone() { if (targets.All((Target t) => t.Done || !Object.op_Implicit((Object)(object)t.master) || t.master.IsDeadAndOutOfLivesServer())) { ((BaseQuest)this).EndQuest(true); } } protected override void UndoEffect() { active.Remove(this); if (Object.op_Implicit((Object)(object)scrapper)) { NetworkServer.Destroy(scrapper); } scrapper = null; } protected override void OnPassed() { active.Remove(this); } public override string GetObjectiveText(CharacterMaster viewer) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) Target target = (Object.op_Implicit((Object)(object)viewer) ? targets.FirstOrDefault((Target t) => t.masterId == ((NetworkBehaviour)viewer).netId) : null); if (target == null) { return ObjectiveText; } if (target.Done) { return "Wait for your allies to finish scrapping"; } ItemDef itemDef = ItemCatalog.GetItemDef(target.item); string text = (Object.op_Implicit((Object)(object)itemDef) ? Language.GetString(itemDef.nameToken) : "items"); return $"Scrap all {target.required} {text} ({target.scrapped}/{target.required})"; } public override void OnSerialize(NetworkWriter writer) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected I4, but got Unknown ((BaseQuest)this).OnSerialize(writer); writer.Write(targets.Count); foreach (Target target in targets) { writer.Write(target.masterId); writer.Write((int)target.item); writer.Write(target.required); writer.Write(target.scrapped); } } public override void OnDeserialize(NetworkReader reader) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) ((BaseQuest)this).OnDeserialize(reader); targets.Clear(); int num = reader.ReadInt32(); for (int i = 0; i < num; i++) { targets.Add(new Target { masterId = reader.ReadNetworkId(), item = (ItemIndex)reader.ReadInt32(), required = reader.ReadInt32(), scrapped = reader.ReadInt32() }); } } } [HarmonyPatch(typeof(ScrapperController), "BeginScrapping", new Type[] { typeof(UniquePickup) })] public static class CompulsionScrapTracking { private static void Prefix(Interactor ___interactor, UniquePickup pickupToTake, out (CharacterMaster master, ItemIndex item, int before) __state) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_005d: 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) __state = default((CharacterMaster, ItemIndex, int)); CharacterBody val = (Object.op_Implicit((Object)(object)___interactor) ? ((Component)___interactor).GetComponent<CharacterBody>() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.master) && Object.op_Implicit((Object)(object)val.inventory)) { PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupToTake.pickupIndex); if (pickupDef != null && (int)pickupDef.itemIndex != -1) { __state = (master: val.master, item: pickupDef.itemIndex, before: val.inventory.GetItemCountPermanent(pickupDef.itemIndex)); } } } private static void Postfix((CharacterMaster master, ItemIndex item, int before) __state) { //IL_0032: 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) if (Object.op_Implicit((Object)(object)__state.master) && Object.op_Implicit((Object)(object)__state.master.inventory)) { int num = __state.before - __state.master.inventory.GetItemCountPermanent(__state.item); if (num > 0) { CompulsionQuestScrapStack.CreditScrap(__state.master, __state.item, num); } } } } internal static class CompulsionQuestWeights { private static readonly Dictionary<string, float> NewWeights = new Dictionary<string, float> { { "CompulsionKillQuickly", 0f }, { "CompulsionQuestBlindPest", 0f }, { "CompulsionQuestCloakedChest", 0f }, { "CompulsionQuestDrinkSoda", 0f }, { "CompulsionQuestHoldGold", 0f }, { "CompulsionQuestReachArea", 0f }, { "CompulsionQuestScrapOrPrintItems", 0f }, { "CompulsionQuestHealTotalHealth", 0f }, { "CompulsionQuestOrder", 0f }, { "CompulsionQuestKillSuperTarget", 1f }, { "CompulsionQuestLemurianPolymorph", 1f }, { "CompulsionQuestMeteorShower", 1f }, { "CompulsionQuestNoHitRun", 1f }, { "HallowedTweaks_CompulsionArtifact", 3f }, { "HallowedTweaks_CompulsionEnemyHooves", 1f }, { "HallowedTweaks_CompulsionEnemyAlienHeads", 1f }, { "HallowedTweaks_CompulsionHeresy", 1f }, { "HallowedTweaks_CompulsionScrapStack", 1f }, { "HallowedTweaks_CompulsionLunarInvasion", 1f }, { "HallowedTweaks_CompulsionVoidInvasion", 1f } }; internal static void Apply() { if (!(AccessTools.Field(typeof(QuestCatalog), "_registeredQuests").GetValue(null) is RegisteredQuest[] array)) { HallowedTweaksPlugin.Log.LogWarning((object)"Compulsion: quest catalog not found"); return; } for (int i = 0; i < array.Length; i++) { if (NewWeights.TryGetValue(array[i].identifier, out var value)) { array[i].questWeight = value; } } } } [HarmonyPatch] public static class CompulsionShrineCancel { private const float ShrineRefresh = 2f; private static ShrineCompulsionBehaviour usingShrine; [HarmonyPrefix] [HarmonyPatch(typeof(ShrineCompulsionBehaviour), "AddShrineStack")] private static bool OnShrineUsed(ShrineCompulsionBehaviour __instance, ref bool ___waitingForRefresh, ref float ___refreshTimer) { CompulsionShrineLink component = ((Component)__instance).GetComponent<CompulsionShrineLink>(); if (Object.op_Implicit((Object)(object)component) && component.IsChallengeActive) { component.CancelChallenge(); if (__instance.purchaseCount < __instance.maxPurchaseCount) { ___waitingForRefresh = true; ___refreshTimer = 2f; } return false; } usingShrine = __instance; return true; } [HarmonyPostfix] [HarmonyPatch(typeof(ShrineCompulsionBehaviour), "AddShrineStack")] private static void AfterShrineUsed() { usingShrine = null; } [HarmonyPostfix] [HarmonyPatch(typeof(CompulsionQuestTracker), "BeginQuest")] private static void LinkQuestToShrine(CompulsionQuestTracker __instance) { if (Object.op_Implicit((Object)(object)usingShrine)) { (((Component)usingShrine).GetComponent<CompulsionShrineLink>() ?? ((Component)usingShrine).gameObject.AddComponent<CompulsionShrineLink>()).Begin(__instance); } } } public class CompulsionShrineLink : MonoBehaviour { private const float IconDelay = 2f; private const float IconHeightOffset = -1.5f; private const float StartTimeout = 5f; private const int CancelCurseStacks = 50; private static GameObject iconPrefab; private static Vector3 iconLocalPosition; private static bool triedLoadingIcon; private CompulsionQuestTracker tracker; private GameObject icon; private GameObject shrineSymbol; private bool shrineSymbolWasActive; private float timer; private bool started; internal bool IsChallengeActive { get { if (!Object.op_Implicit((Object)(object)tracker) || !Object.op_Implicit((Object)(object)tracker.questRunner) || !tracker.questRunner.hasActiveQuest) { return false; } return !CompulsionChallengeChanges.IsQuestOver(tracker.questRunner.quest); } } internal void Begin(CompulsionQuestTracker questTracker) { tracker = questTracker; timer = 0f; started = false; RemoveIcon(); } private void FixedUpdate() { if (!NetworkServer.active || !Object.op_Implicit((Object)(object)tracker)) { return; } timer += Time.fixedDeltaTime; bool isChallengeActive = IsChallengeActive; if (!started) { if (isChallengeActive) { started = true; } else if (timer > 5f) { Finish(); } return; } if (!isChallengeActive) { Finish(); return; } if (!Object.op_Implicit((Object)(object)icon) && timer >= 2f) { SpawnIcon(); PurchaseInteraction component = ((Component)this).GetComponent<PurchaseInteraction>(); if (component != null) { component.SetAvailable(true); } } if (Object.op_Implicit((Object)(object)icon) && Object.op_Implicit((Object)(object)shrineSymbol) && shrineSymbol.activeSelf) { shrineSymbol.SetActive(false); } } internal void CancelChallenge() { BaseCompulsionQuest val = (BaseCompulsionQuest)(Object.op_Implicit((Object)(object)tracker) ? /*isinst with value type is only supported in some contexts*/: null); if (val == null) { Finish(); return; } CompulsionQuestKillSuperTarget val2 = (CompulsionQuestKillSuperTarget)(object)((val is CompulsionQuestKillSuperTarget) ? val : null); List<CharacterMaster> list = ((val2 != null) ? CompulsionTargetTracker.TakeTargets(val2) : null); MeteorStormController val3 = ((val is CompulsionQuestMeteorShower) ? Traverse.Create((object)val).Field("_meteorStormControllerInstance").GetValue<MeteorStormController>() : null); CompulsionChallengeChanges.EndQuest((BaseQuest)(object)val, arg2: false); if (Object.op_Implicit((Object)(object)val3)) { val3.waveCount = val3.performedWaves + 1; } if (list != null) { foreach (CharacterMaster item in list) { if (Object.op_Implicit((Object)(object)item)) { item.DestroyBody(); NetworkServer.Destroy(((Component)item).gameObject); } } } foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterBody val4 = (Object.op_Implicit((Object)(object)instance.master) ? instance.master.GetBody() : null); if (Object.op_Implicit((Object)(object)val4)) { val4.AddUnmanagedBuff(Buffs.PermanentCurse, 50); } } Finish(); } private void Finish() { tracker = null; started = false; RemoveIcon(); ShrineCompulsionBehaviour component = ((Component)this).GetComponent<ShrineCompulsionBehaviour>(); if (Object.op_Implicit((Object)(object)component) && component.purchaseCount >= component.maxPurchaseCount) { PurchaseInteraction component2 = ((Component)this).GetComponent<PurchaseInteraction>(); if (component2 != null) { component2.SetAvailable(false); } } } private void SpawnIcon() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) LoadIcon(); if (Object.op_Implicit((Object)(object)iconPrefab)) { Vector3 val = ((Component)this).transform.TransformPoint(iconLocalPosition) + Vector3.up * -1.5f; icon = Object.Instantiate<GameObject>(iconPrefab, val, Quaternion.identity); icon.SetActive(true); shrineSymbol = FindShrineSymbol(); if (Object.op_Implicit((Object)(object)shrineSymbol)) { shrineSymbolWasActive = shrineSymbol.activeSelf; shrineSymbol.SetActive(false); } } } private void RemoveIcon() { if (Object.op_Implicit((Object)(object)icon)) { Object.Destroy((Object)(object)icon); } icon = null; if (Object.op_Implicit((Object)(object)shrineSymbol)) { shrineSymbol.SetActive(shrineSymbolWasActive); } shrineSymbol = null; } private void OnDestroy() { RemoveIcon(); } private GameObject FindShrineSymbol() { Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val != (Object)(object)((Component)this).transform && ((Object)val).name.ToLower().Contains("symbol")) { return ((Component)val).gameObject; } } return null; } private static void LoadIcon() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (!triedLoadingIcon) { triedLoadingIcon = true; GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ShrineBlood/ShrineBlood.prefab").WaitForCompletion(); ShrineBloodBehavior val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<ShrineBloodBehavior>() : null); if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.symbolTransform)) { HallowedTweaksPlugin.Log.LogWarning((object)"Compulsion: couldn't find the Shrine of Blood symbol"); return; } iconPrefab = ((Component)val2.symbolTransform).gameObject; iconLocalPosition = val.transform.InverseTransformPoint(val2.symbolTransform.position); } } } [HarmonyPatch] public static class CompulsionTargetTracker { private static readonly Dictionary<CompulsionQuestKillSuperTarget, List<CharacterMaster>> spawned = new Dictionary<CompulsionQuestKillSuperTarget, List<CharacterMaster>>(); [HarmonyPostfix] [HarmonyPatch(typeof(CompulsionQuestKillSuperTarget), "OnSpawned")] private static void Remember(CompulsionQuestKillSuperTarget __instance, SpawnResult result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!result.success || !Object.op_Implicit((Object)(object)result.spawnedInstance)) { return; } CharacterMaster component = result.spawnedInstance.GetComponent<CharacterMaster>(); if (Object.op_Implicit((Object)(object)component)) { if (!spawned.TryGetValue(__instance, out var value)) { value = new List<CharacterMaster>(); spawned[__instance] = value; } value.Add(component); } } [HarmonyPostfix] [HarmonyPatch(typeof(CompulsionQuestKillSuperTarget), "OnExit")] private static void Forget(CompulsionQuestKillSuperTarget __instance) { spawned.Remove(__instance); } internal static List<CharacterMaster> TakeTargets(CompulsionQuestKillSuperTarget quest) { if (!spawned.TryGetValue(quest, out var value)) { return null; } spawned.Remove(quest); return value; } } internal static class CustomCompulsionQuests { [CompilerGenerated] private static class <>O { public static CanStartQuestDelegate <0>__CanStart; public static CanStartQuestDelegate <1>__CanStart; public static CanStartQuestDelegate <2>__CanStart; public static CanStartQuestDelegate <3>__CanStart; public static CanStartQuestDelegate <4>__CanStart; public static CanStartQuestDelegate <5>__CanStart; public static CanStartQuestDelegate <6>__CanStart; } internal static void RegisterAll() { //IL_0024: 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_002f: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_0128: 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_0133: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Expected O, but got Unknown Type? typeFromHandle = typeof(CompulsionQuestArtifact); object obj = <>O.<0>__CanStart; if (obj == null) { CanStartQuestDelegate val = CompulsionQuestArtifact.CanStart; <>O.<0>__CanStart = val; obj = (object)val; } Register("HallowedTweaks_CompulsionArtifact", typeFromHandle, 1f, (CanStartQuestDelegate)obj); Type? typeFromHandle2 = typeof(CompulsionQuestEnemyHooves); object obj2 = <>O.<1>__CanStart; if (obj2 == null) { CanStartQuestDelegate val2 = CompulsionQuestEnemyHooves.CanStart; <>O.<1>__CanStart = val2; obj2 = (object)val2; } Register("HallowedTweaks_CompulsionEnemyHooves", typeFromHandle2, 1f, (CanStartQuestDelegate)obj2); Type? typeFromHandle3 = typeof(CompulsionQuestEnemyAlienHeads); object obj3 = <>O.<2>__CanStart; if (obj3 == null) { CanStartQuestDelegate val3 = CompulsionQuestEnemyAlienHeads.CanStart; <>O.<2>__CanStart = val3; obj3 = (object)val3; } Register("HallowedTweaks_CompulsionEnemyAlienHeads", typeFromHandle3, 1f, (CanStartQuestDelegate)obj3); Type? typeFromHandle4 = typeof(CompulsionQuestHeresy); object obj4 = <>O.<3>__CanStart; if (obj4 == null) { CanStartQuestDelegate val4 = CompulsionQuestHeresy.CanStart; <>O.<3>__CanStart = val4; obj4 = (object)val4; } Register("HallowedTweaks_CompulsionHeresy", typeFromHandle4, 1f, (CanStartQuestDelegate)obj4); Type? typeFromHandle5 = typeof(CompulsionQuestScrapStack); object obj5 = <>O.<4>__CanStart; if (obj5 == null) { CanStartQuestDelegate val5 = CompulsionQuestScrapStack.CanStart; <>O.<4>__CanStart = val5; obj5 = (object)val5; } Register("HallowedTweaks_CompulsionScrapStack", typeFromHandle5, 1f, (CanStartQuestDelegate)obj5); Type? typeFromHandle6 = typeof(CompulsionQuestLunarInvasion); object obj6 = <>O.<5>__CanStart; if (obj6 == null) { CanStartQuestDelegate val6 = CompulsionQuestLunarInvasion.CanStart; <>O.<5>__CanStart = val6; obj6 = (object)val6; } Register("HallowedTweaks_CompulsionLunarInvasion", typeFromHandle6, 1f, (CanStartQuestDelegate)obj6); Type? typeFromHandle7 = typeof(CompulsionQuestVoidInvasion); object obj7 = <>O.<6>__CanStart; if (obj7 == null) { CanStartQuestDelegate val7 = CompulsionQuestVoidInvasion.CanStart; <>O.<6>__CanStart = val7; obj7 = (object)val7; } Register("HallowedTweaks_CompulsionVoidInvasion", typeFromHandle7, 1f, (CanStartQuestDelegate)obj7); } private static void Register(string identifier, Type questType, float weight, CanStartQuestDelegate canStart) { //IL_006f: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) FieldInfo fieldInfo = AccessTools.Field(typeof(QuestCatalog), "_registeredQuests"); RegisteredQuest[] array = (RegisteredQuest[])fieldInfo.GetValue(null); Dictionary<string, QuestIndex> dictionary = (Dictionary<string, QuestIndex>)AccessTools.Field(typeof(QuestCatalog), "_identifierToQuestIndex").GetValue(null); Dictionary<Type, QuestIndex> dictionary2 = (Dictionary<Type, QuestIndex>)AccessTools.Field(typeof(QuestCatalog), "_typeToQuestIndex").GetValue(null); if (!dictionary.ContainsKey(identifier)) { QuestIndex val = (QuestIndex)array.Length; Array.Resize(ref array, array.Length + 1); array[val] = new RegisteredQuest { questIndex = val, identifier = identifier, questType = questType, canStartQuest = canStart, questWeight = weight }; fieldInfo.SetValue(null, array); dictionary[identifier] = val; dictionary2[questType] = val; } } } [HarmonyPatch] public static class HeresySquawk { internal static BuffDef PrimaryBuff; internal static BuffDef SecondaryBuff; internal static BuffDef UtilityBuff; private static readonly object OverrideSource = new object(); private static readonly Dictionary<CharacterMaster, BuffDef> squawked = new Dictionary<CharacterMaster, BuffDef>(); private static SkillDef squawkSkill; private static bool hooked; internal static void RegisterBuffs() { PrimaryBuff = MakeBuff("HallowedTweaksSquawkPrimary"); SecondaryBuff = MakeBuff("HallowedTweaksSquawkSecondary"); UtilityBuff = MakeBuff("HallowedTweaksSquawkUtility"); } private static BuffDef MakeBuff(string name) { BuffDef obj = ScriptableObject.CreateInstance<BuffDef>(); ((Object)obj).name = name; obj.isHidden = true; obj.canStack = false; ContentAddition.AddBuffDef(obj); return obj; } internal static BuffDef BuffForItem(ItemDef item) { if ((Object)(object)item == (Object)(object)Items.LunarPrimaryReplacement) { return PrimaryBuff; } if ((Object)(object)item == (Object)(object)Items.LunarSecondaryReplacement) { return SecondaryBuff; } if ((Object)(object)item == (Object)(object)Items.LunarUtilityReplacement) { return UtilityBuff; } return null; } internal static void Apply(CharacterMaster master, BuffDef slotBuff) { if (NetworkServer.active && Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)slotBuff)) { HookStatics(); squawked[master] = slotBuff; CharacterBody body = master.GetBody(); if (Object.op_Implicit((Object)(object)body) && !body.HasBuff(slotBuff)) { body.AddBuff(slotBuff); } } } private static void HookStatics() { if (hooked) { return; } hooked = true; CharacterBody.onBodyStartGlobal += delegate(CharacterBody body) { if (NetworkServer.active && Object.op_Implicit((Object)(object)body.master) && squawked.TryGetValue(body.master, out var value)) { body.AddBuff(value); } }; Stage.onServerStageComplete += delegate { squawked.Clear(); }; Run.onRunDestroyGlobal += delegate { squawked.Clear(); }; } [HarmonyPostfix] [HarmonyPatch(typeof(CharacterBody), "OnBuffFirstStackGained")] private static void OnGained(CharacterBody __instance, BuffDef buffDef) { GenericSkill val = SlotFor(__instance, buffDef); SkillDef val2 = Squawk(); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2)) { val.SetSkillOverride(OverrideSource, val2, (SkillOverridePriority)4); } } [HarmonyPostfix] [HarmonyPatch(typeof(CharacterBody), "OnBuffFinalStackLost")] private static void OnLost(CharacterBody __instance, BuffDef buffDef) { GenericSkill val = SlotFor(__instance, buffDef); SkillDef val2 = Squawk(); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2)) { val.UnsetSkillOverride(OverrideSource, val2, (SkillOverridePriority)4); } } private static GenericSkill SlotFor(CharacterBody body, BuffDef buff) { SkillLocator skillLocator = body.skillLocator; if (!Object.op_Implicit((Object)(object)skillLocator) || !Object.op_Implicit((Object)(object)buff)) { return null; } if ((Object)(object)buff == (Object)(object)PrimaryBuff) { return skillLocator.primary; } if ((Object)(object)buff == (Object)(object)SecondaryBuff) { return skillLocator.secondary; } if ((Object)(object)buff == (Object)(object)UtilityBuff) { return skillLocator.utility; } return null; } private static SkillDef Squawk() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)squawkSkill)) { return squawkSkill; } GameObject val = BodyCatalog.FindBodyPrefab("HereticBody"); if (Object.op_Implicit((Object)(object)val)) { GenericSkill[] components = val.GetComponents<GenericSkill>(); foreach (GenericSkill val2 in components) { if (!Object.op_Implicit((Object)(object)val2.skillFamily)) { continue; } Variant[] variants = val2.skillFamily.variants; foreach (Variant val3 in variants) { if (Object.op_Implicit((Object)(object)val3.skillDef) && ((SerializableEntityStateType)(ref val3.skillDef.activationState)).stateType == typeof(Squawk)) { return squawkSkill = val3.skillDef; } } } } HallowedTweaksPlugin.Log.LogWarning((object)"Squawk skill not found on HereticBody"); return null; } } public abstract class StageCompulsionQuest : BaseCompulsionQuest { public class ObjectiveTracker : BaseQuestObjectiveTracker { public override string GenerateString() { return (((BaseQuestObjectiveTracker)this).baseQuest as StageCompulsionQuest)?.GetObjectiveText(((ObjectiveTracker)this).sourceDescriptor.master) ?? ""; } } private static readonly HashSet<StageCompulsionQuest> running = new HashSet<StageCompulsionQuest>(); private static readonly List<Action> atStageEnd = new List<Action>(); private static bool hooked; private bool effectStarted; private bool effectClosed; public abstract string ObjectiveText { get; } protected virtual bool PassOnTeleporterCharged => true; protected abstract bool StartEffect(); protected abstract void UndoEffect(); protected virtual void EndEffect() { } protected virtual void OnPassed() { } public virtual string GetObjectiveText(CharacterMaster viewer) { return ObjectiveText; } protected static bool CanStartStageChallenge(string identifier) { if (!BaseCompulsionQuest.IsInstanceActive(identifier) && Object.op_Implicit((Object)(object)TeleporterInteraction.instance)) { return !TeleporterInteraction.instance.isCharged; } return false; } public override void OnEnter() { ((BaseCompulsionQuest)this).OnEnter(); if (NetworkServer.active) { HookStatics(); running.Add(this); TeleporterInteraction.onTeleporterChargedGlobal += OnTeleporterCharged; effectStarted = StartEffect(); if (!effectStarted) { ((BaseQuest)this).EndQuest(false); } } } public override void FixedUpdate(float deltaTime) { ((BaseQuest)this).FixedUpdate(deltaTime); if (NetworkServer.active && !((BaseQuest)this).isQuestOver && !PlayerCharacterMasterController.instances.Any((PlayerCharacterMasterController p) => Object.op_Implicit((Object)(object)p.master) && !p.master.IsDeadAndOutOfLivesServer())) { ((BaseQuest)this).EndQuest(false); } } private void OnTeleporterCharged(TeleporterInteraction teleporter) { if (PassOnTeleporterCharged && !((BaseQuest)this).isQuestOver) { ((BaseQuest)this).EndQuest(true); } } public override void OnExit() { TeleporterInteraction.onTeleporterChargedGlobal -= OnTeleporterCharged; if (NetworkServer.active) { Close(((BaseQuest)this).isQuestCompletedSuccesfully == true); running.Remove(this); } ((BaseCompulsionQuest)this).OnExit(); } private void Close(bool keepUntilStageEnd) { if (effectStarted && !effectClosed) { effectClosed = true; if (keepUntilStageEnd) { OnPassed(); atStageEnd.Add(EndEffect); } else { UndoEffect(); } } } private static void HookStatics() { if (hooked) { return; } hooked = true; Stage.onServerStageComplete += delegate { StageCompulsionQuest[] array = running.ToArray(); foreach (StageCompulsionQuest stageCompulsionQuest in array) { if (!((BaseQuest)stageCompulsionQuest).isQuestOver) { stageCompulsionQuest.Close(keepUntilStageEnd: false); ((BaseQuest)stageCompulsionQuest).EndQuest(false); } } Action[] array2 = atStageEnd.ToArray(); for (int i = 0; i < array2.Length; i++) { array2[i](); } atStageEnd.Clear(); }; Run.onRunDestroyGlobal += delegate { running.Clear(); atStageEnd.Clear(); }; } public override Type GetObjectiveType() { return typeof(ObjectiveTracker); } } [BepInPlugin("henrick.HallowedTweaks", "HallowedTweaks", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class HallowedTweaksPlugin : BaseUnityPlugin { public const string GUID = "henrick.HallowedTweaks"; public const string Name = "HallowedTweaks"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static HallowedTweaksPlugin Instance; public static bool isIncorrectScene; internal const string EnragedFlag = "HallowedTweaks_MithrixEnraged"; internal const string BetrayalFlag = "HallowedTweaks_MithrixBetrayed"; internal static int VanillaUltPhantomKarma; internal static string VanillaMithrixSubtitle; internal static float VanillaSlamWaveArc; internal static int VanillaSlamWaveCount; internal static float VanillaPreEncounterDuration; internal static bool IsMithrixEnraged() { if (Object.op_Implicit((Object)(object)Run.instance)) { return Run.instance.GetEventFlag("HallowedTweaks_MithrixEnraged"); } return false; } internal static bool IsMithrixBetrayed() { if (Object.op_Implicit((Object)(object)Run.instance)) { return Run.instance.GetEventFlag("HallowedTweaks_MithrixBetrayed"); } return false; } private void Awake() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"HallowedTweaks loaded!"); EMMusic.Register((BaseUnityPlugin)(object)this); bool flag = default(bool); ContentAddition.AddEntityState<EnragedThroneSpawnState>(ref flag); HeresySquawk.RegisterBuffs(); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate { //IL_0061: Unknown result type (might be due to invalid IL or missing references) ExitSkyLeap.requiredKarmaForSpires = 5; VanillaUltPhantomKarma = UltEnterState.requiredKarmaForPhantom; VanillaPreEncounterDuration = PreEncounter.duration; VanillaMithrixSubtitle = BrotherEncounterPhaseBaseState.subtitleReplacement; Phase3.requiredKarmaForElitePromotion = int.MaxValue; Purify.maxRadius = 2000f; SummonFeralToddlers.numberToSpawn = 5; VanillaSlamWaveArc = WeaponSlam.waveProjectileArc; VanillaSlamWaveCount = WeaponSlam.waveProjectileCount; CustomCompulsionQuests.RegisterAll(); CompulsionQuestWeights.Apply(); try { new Harmony("henrick.HallowedTweaks").PatchAll(); Log.LogInfo((object)"Harmony patches applied"); } catch (Exception arg) { Log.LogError((object)$"Patching failed: {arg}"); } }); } } [HarmonyPatch(typeof(CollectLunarItems), "onInventoryChangedGlobal")] public static class CollectLunarItemsNoBeads { private const int Threshold = 3; private static bool Prefix(CollectLunarItems __instance, Inventory inventory) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)inventory)) { return false; } CharacterMaster component = ((Component)inventory).GetComponent<CharacterMaster>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.playerCharacterMasterController)) { return false; } int num = inventory.GetTotalItemCountOfTier((ItemTier)3) - inventory.GetItemCountEffective(Items.LunarTrinket); EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(inventory.currentEquipmentIndex); if (Object.op_Implicit((Object)(object)equipmentDef) && equipmentDef.isLunar) { num++; } if (num >= 3) { ((BaseKarmaTrigger)__instance).MarkAsCompleted(); } return false; } } [HarmonyPatch(typeof(EclipseRun), "OverrideRuleChoices")] public static class EclipseLobbyKarmaPatch { private static void Postfix(RuleChoiceMask mustInclude, RuleChoiceMask mustExclude) { RuleChoiceDef val = RuleCatalog.FindChoiceDef("Karma.InitialLevel.0"); if (val == null) { return; } foreach (RuleChoiceDef choice in val.ruleDef.choices) { ((SerializableBitArray)mustInclude)[choice.globalIndex] = false; ((SerializableBitArray)mustExclude)[choice.globalIndex] = true; } ((SerializableBitArray)mustInclude)[val.globalIndex] = true; ((SerializableBitArray)mustExclude)[val.globalIndex] = false; } } [HarmonyPatch(typeof(CharacterMaster), "DestroyDeployablesInSlot")] public static class DestroySpiresPatch { private static bool Prefix(DeployableSlot slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)slot != 44) { return true; } if (Object.op_Implicit((Object)(object)PhaseCounter.instance)) { return PhaseCounter.instance.phase == 4; } return false; } } [HarmonyPatch(typeof(CharacterMaster), "GetDeployableSameSlotLimit")] public static class KarmaSpireCapPatch { private static void Postfix(DeployableSlot slot, ref int __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)slot == 44) { __result = 12; } } } [HarmonyPatch(typeof(HealthComponent), "TakeDamage")] public static class KarmaSpiresDamagePatch { private static void Prefix(HealthComponent __instance, DamageInfo damageInfo) { if (!KarmaPhasePatch.SpiresKillable && Object.op_Implicit((Object)(object)__instance.body) && BrotherKarmaUtils.IsKarmaSpire(__instance.body)) { damageInfo.rejected = true; } } } [HarmonyPatch(typeof(ExitSkyLeap), "OnEnter")] public static class SpireSlamWavePatch { private const float SlamDelay = 0.3f; private static void Postfix(ExitSkyLeap __instance) { if (NetworkServer.active) { ((MonoBehaviour)HallowedTweaksPlugin.Instance).StartCoroutine(FireSpireWavesLater(((Component)((EntityState)__instance).outer).gameObject)); } } private static IEnumerator FireSpireWavesLater(GameObject mithrix) { yield return (object)new WaitForSeconds(0.3f); if (!Object.op_Implicit((Object)(object)mithrix)) { yield break; } foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList) { if (BrotherKarmaUtils.IsKarmaSpire(readOnlyInstances) && readOnlyInstances.healthComponent.alive) { BrotherUltContext val = new BrotherUltContext { owner = mithrix, useOriginOverride = true, originOverride = readOnlyInstances.footPosition }; BrotherUltUtils.EvaluatePattern(UltChannelState.patternStatic, val); } } } } [HarmonyPatch] public static class SpireAuraAndPlacementPatches { [HarmonyPatch(typeof(IdleState), "FixedUpdate")] [HarmonyPostfix] private static void NoCrippleAura(BuffWard ___buffWard) { if (NetworkServer.active && Object.op_Implicit((Object)(object)___buffWard)) { ___buffWard.Networkradius = 0f; } } [HarmonyPatch(typeof(SkySpawnState), "AttemptSpawnSpireServer")] [HarmonyPatch(typeof(ExitSkyLeap), "AttemptSpawnSpireServer")] [HarmonyPatch(typeof(UltExitState), "AttemptSpawnSpireServer")] [HarmonyPrefix] private static void RandomizePlacement(ref Vector3 ___spireForward, ref float ___spireSpawnRadius, out float __state) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) __state = ___spireSpawnRadius; PhaseCounter instance = PhaseCounter.instance; if (instance != null && instance.phase == 3) { Vector3 val = Vector3.ProjectOnPlane(Random.onUnitSphere, Vector3.up); ___spireForward = ((Vector3)(ref val)).normalized; ___spireSpawnRadius = __state * Random.Range(0.25f, 1f); } } [HarmonyPatch(typeof(SkySpawnState), "AttemptSpawnSpireServer")] [HarmonyPatch(typeof(ExitSkyLeap), "AttemptSpawnSpireServer")] [HarmonyPatch(typeof(UltExitState), "AttemptSpawnSpireServer")] [HarmonyPostfix] private static void RestoreRadius(ref float ___spireSpawnRadius, float __state) { ___spireSpawnRadius = __state; } } [HarmonyPatch] public static class SpireWavePatches { [HarmonyPatch(typeof(SkySpawnState), "OnEnter")] [HarmonyPostfix] private static void OpeningWave(ref int ___spiresToSpawn) { ___spiresToSpawn = Math.Min(6, ___spiresToSpawn); } [HarmonyPatch(typeof(ExitSkyLeap), "OnEnter")] [HarmonyPatch(typeof(UltExitState), "OnEnter")] [HarmonyPostfix] private static void Refill(ref int ___spiresToSpawn) { ___spiresToSpawn = Math.Min(2, ___spiresToSpawn); } } [HarmonyPatch(typeof(KarmaManager), "SelectValidTriggers")] public static class RemoveKarmaTriggers { private static readonly HashSet<string> Removed = new HashSet<string> { "CollectHallowedItems", "CollectLotsOfItems", "CompleteHalcyonShrine", "GetEliteAffix", "KickedOutOfBazaar", "KickedOutOfCompExchange", "KillABossQuickly", "PledgeFealty", "ReachedMysterySpace" }; private static void Postfix(List<BaseKarmaTrigger> ___runTriggers) { if (___runTriggers == null) { return; } for (int num = ___runTriggers.Count - 1; num >= 0; num--) { BaseKarmaTrigger val = ___runTriggers[num]; if (val != null && Removed.Contains(((object)val).GetType().Name)) { val.Deactivate(); ___runTriggers.RemoveAt(num); } } } } [HarmonyPatch(typeof(BrotherEncounterPhaseBaseState), "OnMemberAddedServer")] public static class MithrixBetrayalLines { private const float FirstLineDelay = 1.5f; private const float LineSpacing = 3f; private static void Postfix(BrotherEncounterPhaseBaseState __instance) { if (__instance is Phase1 && NetworkServer.active && HallowedTweaksPlugin.IsMithrixBetrayed()) { ((MonoBehaviour)HallowedTweaksPlugin.Instance).StartCoroutine(SpeakLines()); } } private static IEnumerator SpeakLines() { yield return (object)new WaitForSeconds(1.5f); BrotherSpeechDriver val = Object.FindObjectOfType<BrotherSpeechDriver>(); CharacterSpeechController val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<CharacterSpeechController>() : null); if (!Object.op_Implicit((Object)(object)val2)) { HallowedTweaksPlugin.Log.LogWarning((object)"Betrayal: Mithrix's speech controller not found"); yield break; } Say(val2, "Another betrayal."); Say(val2, "You vermin are all the same."); } private static void Say(CharacterSpeechController speech, string line) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) SpeechInfo val = new SpeechInfo { token = line, duration = 3f, maxWait = 10f, priority = 100f, mustPlay = true }; speech.EnqueueSpeech(ref val); } } [HarmonyPatch(typeof(SummonFeralToddlers), "OnLynxSpawnedServer")] public static class FanaticSummonsPatch { private static void Postfix(SpawnResult spawnResult) { //IL_0007: 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) if (NetworkServer.active && Object.op_Implicit((Object)(object)spawnResult.spawnedInstance)) { CharacterMaster component = spawnResult.spawnedInstance.GetComponent<CharacterMaster>(); if (Object.op_Implicit((Object)(object)component)) { component.inventory.GiveItemPermanent(Items.BoostHp, 40); component.inventory.GiveItemPermanent(Items.BoostDamage, 10); } } } } [HarmonyPatch(typeof(SoulDamageWave), "InitializeWaveServer")] public static class PurifyWavePatch { private static void Postfix(SoulDamageWave __instance) { __instance.percentageHealthReductionBosses = 17.6f; } } [HarmonyPatch(typeof(HealthComponent), "Suicide", new Type[] { typeof(GameObject), typeof(GameObject), typeof(DamageTypeCombo) })] public static class ReincarnationApplyCurse { private static bool Prefix(HealthComponent __instance) { if (!HallowedTweaksPlugin.isIncorrectScene) { return true; } CharacterBody body = __instance.body; if (!Object.op_Implicit((Object)(object)body) || !body.isPlayerControlled) { return true; } body.AddUnmanagedBuff(Buffs.PermanentCurse, 100); return false; } } [HarmonyPatch(typeof(Kill), "KillAllMarked")] public static class ReincarnationCheckScene { private static void Prefix(bool ___foundTargetScene) { if (!___foundTargetScene) { HallowedTweaksPlugin.isIncorrectScene = true; } } } [HarmonyPatch(typeof(Kill), "KillAllMarked")] public static class ReincarnationSetFlagFalse { private static void Postfix() { HallowedTweaksPlugin.isIncorrectScene = false; } } [HarmonyPatch(typeof(ProvidenceShadowCloneController), "Start")] public static class ProvidenceLaserClonesBuff { private static void Postfix(ProvidenceShadowCloneType ___shadowCloneType, CharacterBody ___body) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 if (NetworkServer.active && Object.op_Implicit((Object)(object)___body) && Object.op_Implicit((Object)(object)___body.master) && Object.op_Implicit((Object)(object)___body.master.inventory) && (int)___shadowCloneType == 1) { ___body.master.inventory.GiveItemPermanent(Items.BoostHp, 10); } } } public class TrialClaimInteraction : MonoBehaviour, IInteractable { internal TrialController trialController; internal EntityStateMachine stateMachine; public string GetContextString(Interactor activator) { return "Claim trial rewards (seals the trials)"; } public Interactability GetInteractability(Interactor activator) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)trialController) && (int)trialController.trialControllerState == 2) { if (NetworkServer.active && TrialRewards.Claimed) { return (Interactability)0; } EntityState val = (Object.op_Implicit((Object)(object)stateMachine) ? stateMachine.state : null); if (!(val is OpenPageReward) && !(val is OpenBookReward) && !(val is OpenItemReward)) { return (Interactability)2; } return (Interactability)1; } return (Interactability)0; } public void OnInteractionBegin(Interactor activator) { TrialRewards.ClaimServer(this); } public bool ShouldIgnoreSpherecastForInteractibility(Interactor activator) { return false; } public bool ShouldShowOnScanner() { return true; } public bool ShouldProximityHighlight() { return true; } public int GetInteractablePriority(Interactor activator) { return 0; } public bool ShouldSpawnLesserInteractionRewards(Interactor activator) { return false; } } [HarmonyPatch(typeof(DrainingItems), "TakeItemServer")] public static class TrialHexTime { private const float SecondsPerHex = 10f; private static void Prefix(int ___itemsTaken, out int __state) { __state = ___itemsTaken; } private static void Postfix(int ___itemsTaken, int __state) { int num = ___itemsTaken - __state; if (!NetworkServer.active || num <= 0 || TrialRewards.Claimed) { return; } DLC4TrialSelector val = (Object.op_Implicit((Object)(object)DLC4ProgressionController.instance) ? DLC4ProgressionController.instance.trialSelector : null); if (!Object.op_Implicit((Object)(object)val)) { return; } int num2 = Mathf.Max(1, (!Object.op_Implicit((Object)(object)Run.instance)) ? 1 : Run.instance.participatingPlayerCount); float remainingTrialTimeServer = val.GetRemainingTrialTimeServer(); val.SetRemainingTrialTimeServer(remainingTrialTimeServer + 10f * (float)num / (float)num2); if (remainingTrialTimeServer <= 0f) { TrialGongInteraction[] array = Object.FindObjectsOfType<TrialGongInteraction>(); for (int i = 0; i < array.Length; i++) { array[i].UpdateAvailability(); } } } } [HarmonyPatch] public static class TrialItemPool { private static BasicPickupDropTable chestTable; private static TrialController currentTrial; private const string MoneyTrialScene = "sad1"; private static readonly Vector3[] MoneyTrialStartPoints = (Vector3[])(object)new Vector3[12] { new Vector3(256.94f, 51.44f, 156.43f), new Vector3(220.79f, 45.65f, 151.03f), new Vector3(215.44f, 45.31f, 146.06f), new Vector3(210.4f, 45.31f, 141.03f), new Vector3(-173.01f, 70.22f, 217.93f), new Vector3(-166.17f, 60.83f, 182.32f), new Vector3(-160.72f, 60.83f, 176.84f), new Vector3(-156.03f, 60.83f, 171.9f), new Vector3(234.89f, 71.27f, -246.49f), new Vector3(221.83f, 60.25f, -198.67f), new Vector3(216.63f, 60.25f, -193.35f), new Vector3(211.6f, 60.25f, -187.79f) }; internal static BasicPickupDropTable ChestTable { get { if (!Object.op_Implicit((Object)(object)chestTable)) { chestTable = ScriptableObject.CreateInstance<BasicPickupDropTable>(); ((Object)chestTable).name = "dtHallowedTweaksTrialItems"; ((Object)chestTable).hideFlags = (HideFlags)32; } return chestTable; } } [HarmonyPostfix] [HarmonyPatch(typeof(TrialController), "Awake")] private static void OnTrialSceneLoaded(TrialController __instance) { currentTrial = __instance; } [HarmonyPrefix] [HarmonyPatch(typeof(PickupSpawner), "Start")] private static void RandomizeSpawner(PickupSpawner __instance) { PickupDropTable pickupDropTable = __instance.pickupDropTable; if (Object.op_Implicit((Object)(object)pickupDropTable) && ((Object)pickupDropTable).name.Contains("RentalsExplicit")) { __instance.pickupDropTable = (PickupDropTable)(object)ChestTable; } } [HarmonyPrefix] [HarmonyPatch(typeof(ItemSpawnPoint), "SpawnItem")] private static void RandomizeSpawnPoint(ItemSpawnPoint __instance) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)currentTrial) || (int)__instance.storageType != 3 || IsMoneyTrialStartPoint(((Component)__instance).transform.position)) { return; } if (__instance.useExplicitItemDef) { ItemDef val = __instance.explicitItemDef.WaitForCompletion(); if (Object.op_Implicit((Object)(object)val) && TrialRewards.IsKey(val.itemIndex)) { return; } } __instance.useExplicitItemDef = false; __instance.dropTable = (PickupDropTable)(object)ChestTable; } private static bool IsMoneyTrialStartPoint(Vector3 position) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)SceneInfo.instance) || !Object.op_Implicit((Object)(object)SceneInfo.instance.sceneDef) || SceneInfo.instance.sceneDef.cachedName != "sad1") { return false; } Vector3[] moneyTrialStartPoints = MoneyTrialStartPoints; foreach (Vector3 val in moneyTrialStartPoints) { Vector3 val2 = position - val; if (((Vector3)(ref val2)).sqrMagnitude < 1f) { return true; } } return false; } } [HarmonyPatch] public static class TrialRewards { public const int MaxTrials = 9; private const string PageTableName = "dtPageOnly"; private static Run trackedRun; private static readonly List<Dictionary<CharacterMaster, List<PickupIndex>>> completedTrials = new List<Dictionary<CharacterMaster, List<PickupIndex>>>(); private static Dictionary<CharacterMaster, List<PickupIndex>> currentTrial; private static bool claimed; private static int guaranteedReincarnationPages; private static TrialController trialController; private static bool subscribed; private static GameObject gridPotentialPrefab; private static bool searchedForGridPrefab; public static bool Claimed { get { CheckRun(); return claimed; } } private static GameObject GridPotentialPrefab { get { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)gridPotentialPrefab) || searchedForGridPrefab) { return gridPotentialPrefab; } searchedForGridPrefab = true; DrainItemsAndDropMultiChoicePotentialController[] array = Resources.FindObjectsOfTypeAll<DrainItemsAndDropMultiChoicePotentialController>(); foreach (DrainItemsAndDropMultiChoicePotentialController val in array) { if (Object.op_Implicit((Object)(object)val.potentialPrefab)) { return gridPotentialPrefab = val.potentialPrefab; } } foreach (IResourceLocator resourceLocator in Addressables.ResourceLocators) { foreach (object key in resourceLocator.Keys) { if (key is string text && text.EndsWith(".prefab") && text.IndexOf("Cauldron", StringComparison.OrdinalIgnoreCase) >= 0) { GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)text).WaitForCompletion(); DrainItemsAndDropMultiChoicePotentialController val3 = (Object.op_Implicit((Object)(object)val2) ? val2.GetComponentInChildren<DrainItemsAndDropMultiChoicePotentialController>(true) : null); if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val3.potentialPrefab)) { HallowedTweaksPlugin.Log.LogInfo((object)("Trials: grid potential found in " + text)); return gridPotentialPrefab = val3.potentialPrefab; } } } } HallowedTweaksPlugin.Log.LogWarning((object)"Trials: couldn't find the Hallowed Cauldron's potential, using the normal one"); return null; } } private static void CheckRun() { if (!((Object)(object)trackedRun == (Object)(object)Run.instance)) { trackedRun = Run.instance; completedTrials.Clear(); currentTrial = null; claimed = false; guaranteedReincarnationPages = 0; } } [HarmonyPostfix] [HarmonyPatch(typeof(TrialController), "Awake")] private static void OnTrialSceneLoaded(TrialController __instance) { trialController = __instance; if (!subscribed) { GenericPickupController.onPickupConsumed += OnPickupConsumed; subscribed = true; } } [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static void OnTrialStateChanged(TrialController __instance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected I4, but got Unknown if (!NetworkServer.active) { return; } CheckRun(); TrialControllerState trialControllerState = __instance.trialControllerState; switch (trialControllerState - 1) { case 0: currentTrial = new Dictionary<CharacterMaster, List<PickupIndex>>(); break; case 1: if (currentTrial != null && completedTrials.Count < 9) { completedTrials.Add(currentTrial); if (completedTrials.Count == 9) { guaranteedReincarnationPages = CountPlayersWithoutReincarnation(); } } currentTrial = null; break; case 2: currentTrial = null; break; } } private static void OnPickupConsumed(CharacterBody body, UniquePickup pickup) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 //IL_0072: 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_00a2: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || currentTrial == null || !pickup.isRental || !Object.op_Implicit((Object)(object)trialController) || (int)trialController.trialControllerState != 1) { return; } CharacterMaster val = (Object.op_Implicit((Object)(object)body) ? body.master : null); PickupDef pickupDef = PickupCatalog.GetPickupDef(pickup.pickupIndex); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.playerCharacterMasterController) && pickupDef != null && (int)pickupDef.itemIndex != -1 && !IsKey(pickupDef.itemIndex)) { if (!currentTrial.TryGetValue(val, out var value)) { value = (currentTrial[val] = new List<PickupIndex>()); } value.Add(pickup.pickupIndex); } } internal static bool IsKey(ItemIndex item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (item != Items.TreasureCache.itemIndex) { return item == Items.TreasureCacheVoid.itemIndex; } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(OpenPageReward), "OnEnter")] private static void SetUpPillar(OpenPageReward __instance) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)((EntityState)__instance).outer).gameObject; if (Object.op_Implicit((Object)(object)gameObject.GetComponent<TrialClaimInteraction>())) { return; } TrialClaimInteraction trialClaimInteraction = gameObject.AddComponent<TrialClaimInteraction>(); trialClaimInteraction.trialController = trialController; trialClaimInteraction.stateMachine = ((EntityState)__instance).outer; if (!Object.op_Implicit((Object)(object)gameObject.GetComponent<Highlight>())) { Highlight val = gameObject.AddComponent<Highlight>(); val.highlightColor = (HighlightColor)0; val.strength = 1f; ModelLocator component = gameObject.GetComponent<ModelLocator>(); Transform obj = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.modelTransform)) ? component.modelTransform : gameObject.transform); List<Renderer> list = new List<Renderer>(); Renderer[] componentsInChildren = ((Component)obj).GetComponentsInChildren<Renderer>(); foreach (Renderer val2 in componentsInChildren) { if ((val2 is MeshRenderer || val2 is SkinnedMeshRenderer) && !((Object)val2).name.Contains("VFX")) { list.Add(val2); } } if (list.Count > 0) { val.targetRenderer = list[0]; } val.SetTargetRendererList(list); } Collider[] componentsInChildren2 = gameObject.GetComponentsInChildren<Collider>(true); foreach (Collider val3 in componentsInChildren2) { EntityLocator val4 = ((Component)val3).GetComponent<EntityLocator>(); if (!Object.op_Implicit((Object)(object)val4)) { val4 = ((Component)val3).gameObject.AddComponent<EntityLocator>(); } val4.entity = gameObject; } } [HarmonyPrefix] [HarmonyPatch(typeof(CreateItemPotentialFromPickedUpItems), "PreparePickupSpawns")] private static bool BlockVanillaItemReward(ref bool __result) { if (!Object.op_Implicit((Object)(object)trialController)) { return true; } __result = false; return false; } internal static void ClaimServer(TrialClaimInteraction pillar) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown if (!NetworkServer.active) { return; } CheckRun(); if (claimed) { return; } claimed = true; CreateItemPotentialFromPickedUpItems componentInChildren = ((Component)pillar).GetComponentInChildren<CreateItemPotentialFromPickedUpItems>(true); GameObject pickupPrefab = GridPotentialPrefab; if (!Object.op_Implicit((Object)(object)pickupPrefab) && Object.op_Implicit((Object)(object)componentInChildren)) { pickupPrefab = componentInChildren.pickupPrefab; } Vector3 position = ((Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)((BaseCreatePickupDroplet)componentInChildren).pickupSpawnPoint)) ? ((BaseCreatePickupDroplet)componentInChildren).pickupSpawnPoint.position : (((Component)pillar).transform.position + Vector3.up * 3f)); Vector3 val = (Object.op_Implicit((Object)(object)componentInChildren) ? ((BaseCreatePickupDroplet)componentInChildren).GetVelocity() : (Vector3.up * 20f + ((Component)pillar).transform.forward * 5f)); List<Option[]> list = new List<Option[]>(); foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (Object.op_Implicit((Object)(object)instance.master)) { Option[] array = BuildGrid(instance.master); if (array != null) { list.Add(array); } } } for (int i = 0; i < list.Count; i++) { Quaternion val2 = Quaternion.AngleAxis(360f * (float)i / (float)list.Count, Vector3.up); SpawnPotential(list[i], pickupPrefab, position, val2 * val); } SealTrials(); Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "<size=120%><style=cLunarObjective>The trials are sealed</style></size>" }); } private static Option[] BuildGrid(CharacterMaster master) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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) Option[] array = (Option[])(object)new Option[9]; bool flag = false; for (int i = 0; i < 9; i++) { List<PickupIndex> value = null; bool flag2 = i < completedTrials.Count && completedTrials[i].TryGetValue(master, out value) && value.Count > 0; PickupIndex val = (flag2 ? value[Run.instance.treasureRng.RangeInt(0, value.Count)] : ((PickupDropTable)TrialItemPool.ChestTable).GeneratePickup(Run.instance.treasureRng).pickupIndex); array[i] = new Option { pickup = new UniquePickup(val), available = flag2 }; flag = flag || flag2; } if (!flag) { return null; } return array; } [HarmonyPostfix] [HarmonyPatch(typeof(DrainItemsAndDropMultiChoicePotentialController), "Awake")] private static void RememberGridPrefab(DrainItemsAndDropMultiChoicePotentialController __instance) { if (Object.op_Implicit((Object)(object)__instance.potentialPrefab)) { gridPotentialPrefa