using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates.VultureHunter.Body; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using R2API.Utils; using RoR2; using RoR2.EntitlementManagement; using RoR2.ExpansionManagement; using RoR2BepInExPack.GameAssetPaths.Version_1_35_0; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; [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("AlloyHunterSurprise")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+b904b917f7a3ae86c3f952fa22c980656994882e")] [assembly: AssemblyProduct("AlloyHunterSurprise")] [assembly: AssemblyTitle("AlloyHunterSurprise")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AlloyHunterSurprise { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("icebro.AlloyHunterSurprise", "AlloyHunterSurprise", "1.0.1")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class AlloyHunterSurprise : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Manipulator <>9__16_2; public static Func <>9__20_0; public static Func <>9__20_1; public static Func <>9__20_2; public static Func <>9__20_3; public static Func <>9__20_4; public static Func <>9__20_5; public static Action <>9__20_6; internal void b__16_2(ILContext il) { Debug.Log((object)"logging "); Debug.Log((object)il); } internal bool b__20_0(Instruction x) { return ILPatternMatchingExt.MatchCall(x, "get_instance"); } internal bool b__20_1(Instruction x) { return ILPatternMatchingExt.MatchLdfld(x, "bossDirector"); } internal bool b__20_2(Instruction x) { return ILPatternMatchingExt.MatchLdarg(x, 0); } internal bool b__20_3(Instruction x) { return ILPatternMatchingExt.MatchLdfld(x, "ForcedBossFight"); } internal bool b__20_4(Instruction x) { return ILPatternMatchingExt.MatchLdarg(x, 0); } internal bool b__20_5(Instruction x) { return ILPatternMatchingExt.MatchLdfld(x, "singularScaledBoss"); } internal void b__20_6(VultureFightOverride vultureOverride) { if (vultureOverride.ForcedBossFight != null) { TeleporterInteraction.instance.bossDirector.OverrideNextBossCard(vultureOverride.ForcedBossFight, vultureOverride.singularScaledBoss && (!Object.op_Implicit((Object)(object)TeleporterInteraction.instance) || TeleporterInteraction.instance.shrineBonusStacks <= 0)); } } } private const string PluginGUID = "icebro.AlloyHunterSurprise"; private const string PluginAuthor = "icebro"; private const string PluginName = "AlloyHunterSurprise"; private const string PluginVersion = "1.0.1"; private GameObject alloyHunterMasterOriginalRef; private GameObject alloyHunterMaster; private ConfigEntry invasionChance; private ConfigEntry minStageCount; private ConfigEntry invaderReplacement; private ConfigEntry healthPercent; private ConfigEntry asManyInvasionsAsBosses; private ConfigEntry dontInvadeHordes; private ConfigEntry invasionWhitelist; private List invasionWhitelistReal = new List(); private static bool UHRInstalled => Chainloader.PluginInfos.ContainsKey("iDeathHD.UnityHotReload"); public void Awake() { //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); invasionChance = ((BaseUnityPlugin)this).Config.Bind("AlloyHunterSurprise", "invasion chance.,.,.,", 30f, "chance for alloy hunter to invade (0-100% .,.,"); minStageCount = ((BaseUnityPlugin)this).Config.Bind("AlloyHunterSurprise", "minimum stage count,..,.,", 3, "chance for alloy hunter to invade (0-100% .,.,"); invaderReplacement = ((BaseUnityPlugin)this).Config.Bind("AlloyHunterSurprise", "invader replacement !! put master name ,. (eg. BrotherMaster", "", "itsl ike !! what autocompletes when doing spawn_ai .,., leave blank for no replacement!!"); invaderReplacement.SettingChanged += delegate { replaceInvader(); }; invasionWhitelist = ((BaseUnityPlugin)this).Config.Bind("AlloyHunterSurprise", "invasion whitelist !! seperate with comma ,.,.", "RoboBallBossMaster,SolusAmalgamatorMaster", "get from spawn_ai autocompletes !! eg. (RoboBallBossMaster,SolusAmalgamatorMaster)!!"); UpdateWhitelist(); invasionWhitelist.SettingChanged += delegate { UpdateWhitelist(); }; asManyInvasionsAsBosses = ((BaseUnityPlugin)this).Config.Bind("AlloyHunterSurprise", "have as many invasions as spawned bosses,.,.", false, "like !! if theres multiple bosses have mutliple invasion .,.,"); dontInvadeHordes = ((BaseUnityPlugin)this).Config.Bind("AlloyHunterSurprise", "dont invade hordes of many,..,", true, "explanitory i think.,,. .,.,"); healthPercent = ((BaseUnityPlugin)this).Config.Bind("AlloyHunterSurprise", "health percentage before steal !!!", 0.75f, "health threshold before killing !!!!"); TeleporterInteraction.Awake += new hook_Awake(TeleporterInteractionOnAwake); VultureFightOverride.TriggerVultureOnMasterServer += new hook_TriggerVultureOnMasterServer(VultureFightOverrideOnTriggerVultureOnMasterServer); VultureFightOverride.TriggerServer += new Manipulator(VultureFightOverrideOnTriggerServer); MasterCatalog.Init += new hook_Init(MasterCatalogOnInit); object obj = <>c.<>9__16_2; if (obj == null) { Manipulator val = delegate(ILContext il) { Debug.Log((object)"logging "); Debug.Log((object)il); }; <>c.<>9__16_2 = val; obj = (object)val; } VultureFightOverride.TriggerVultureOnMasterServer += (Manipulator)obj; AsyncOperationHandle val2 = Addressables.LoadAssetAsync((object)RoR2_DLC3_VultureHunter.VultureHunterMaster_prefab); val2.Completed += delegate(AsyncOperationHandle result) { alloyHunterMasterOriginalRef = result.Result; }; } private void UpdateWhitelist() { invasionWhitelistReal = new List(); string[] array = invasionWhitelist.Value.Split(","); foreach (string text in array) { if (!Utility.IsNullOrWhiteSpace(text.Trim())) { invasionWhitelistReal.Add(text.Trim()); } } } private void MasterCatalogOnInit(orig_Init orig) { orig.Invoke(); replaceInvader(); } private void replaceInvader() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) GameObject masterPrefab = MasterCatalog.GetMasterPrefab(MasterCatalog.FindMasterIndex(invaderReplacement.Value)); if ((Object)(object)masterPrefab != (Object)null) { Log.Debug($"replacing invader with {masterPrefab} !!"); alloyHunterMaster = masterPrefab; } else { Log.Debug("failed to find invader " + invaderReplacement.Value + ",.., falling back on alloyhunter !!"); alloyHunterMaster = alloyHunterMasterOriginalRef; } } private void VultureFightOverrideOnTriggerServer(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext(new Func[6] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, "get_instance"), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "bossDirector"), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "ForcedBossFight"), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "singularScaledBoss") })) { return; } val.RemoveRange(13); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(VultureFightOverride vultureOverride) { if (vultureOverride.ForcedBossFight != null) { TeleporterInteraction.instance.bossDirector.OverrideNextBossCard(vultureOverride.ForcedBossFight, vultureOverride.singularScaledBoss && (!Object.op_Implicit((Object)(object)TeleporterInteraction.instance) || TeleporterInteraction.instance.shrineBonusStacks <= 0)); } }); Log.Debug("added il hook to null chcek forcedbossfight !!"); Debug.Log((object)il); } private void VultureFightOverrideOnTriggerVultureOnMasterServer(orig_TriggerVultureOnMasterServer orig, VultureFightOverride self, CharacterMaster boss) { if (self.singularKiller && Reflection.GetFieldValue((object)self, "bossReplacementsPerformed") > 0) { return; } if (self.ForcedBossFight == null) { WeightedSelection monsterSelection = ClassicStageInfo.instance.monsterSelection; DirectorCard forcedBossFight = null; CharacterBody val = default(CharacterBody); for (int i = 0; i < monsterSelection._count; i++) { DirectorCard value = monsterSelection.choices[i].value; object obj; if (value == null) { obj = null; } else { SpawnCard spawnCard = value.spawnCard; if (spawnCard == null) { obj = null; } else { GameObject prefab = spawnCard.prefab; obj = ((prefab == null) ? null : prefab.GetComponent()?.bodyPrefab); } } if (!((Object)obj != (Object)(object)boss?.bodyPrefab)) { forcedBossFight = monsterSelection.choices[i].value; Log.Debug("found " + ((Object)boss).name + " s card !!! "); if (((Object)boss).name.Contains("RoboBallBoss") || ((Object)boss).name.Contains("SolusAmalgamator")) { SpawnAfterMuder.idleAfterTeleportDelay = 1.85f; DoMurder.enterDelay = 5.5f; self.healthbarHideDuration = 6.2f; } else { SpawnAfterMuder.idleAfterTeleportDelay = 1f; DoMurder.enterDelay = 3f; self.healthbarHideDuration = 4f; } if ((!dontInvadeHordes.Value || !Object.op_Implicit((Object)(object)boss.bodyPrefab) || !boss.bodyPrefab.TryGetComponent(ref val) || val.isChampion) && (invasionWhitelistReal.Count == 0 || invasionWhitelistReal.Contains(((Object)boss).name.Replace("(Clone)", "")))) { break; } self.watchingSquadMembers.Remove(boss); if (self.watchingSquadMembers.Count == 0) { TeleporterInteraction.instance.bossDirector.combatSquad.delayDefeat = false; } return; } } self.ForcedBossFight = forcedBossFight; } Log.Debug($" forced fight null ? {self.ForcedBossFight == null}"); if (self.ForcedBossFight != null) { orig.Invoke(self, boss); } } private void TeleporterInteractionOnAwake(orig_Awake orig, TeleporterInteraction self) { orig.Invoke(self); if (Object.op_Implicit((Object)(object)((Component)self).gameObject.GetComponent())) { SpawnAfterMuder.idleAfterTeleportDelay = 1.85f; DoMurder.enterDelay = 5f; } else if (NetworkServer.active && Run.instance.runRNG.RangeFloat(0f, 100f) <= invasionChance.Value && Run.instance.stageClearCount + 1 >= minStageCount.Value) { VultureFightOverride val = ((Component)self).gameObject.AddComponent(); val.singularKiller = !asManyInvasionsAsBosses.Value; val.triggerOnStart = true; val.nextKillSequenceMin = 2f; val.nextKillSequenceMax = 5f; val.healthbarHideDuration = 4f; val.replacementAtHealthThreshold = healthPercent.Value; val.replacementMaster = alloyHunterMaster; CharacterMaster val2 = default(CharacterMaster); CharacterBody val3 = default(CharacterBody); ExpansionRequirementComponent val4 = default(ExpansionRequirementComponent); if (alloyHunterMaster.TryGetComponent(ref val2) && val2.bodyPrefab.TryGetComponent(ref val3) && ((Component)val3).TryGetComponent(ref val4) && !((BaseUserEntitlementTracker)(object)EntitlementManager.networkUserEntitlementTracker).AnyUserHasEntitlement(val4.requiredExpansion.requiredEntitlement)) { Log.Debug("user doesnt have any entitlement !!! gorp ,,.,. get the dlc of whatever youre trying to spawn silly