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 ChallengingUnlocks v1.9.1
ChallengingUnlocks.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EnemiesReturns.ModdedEntityStates.Judgement.Mission; using EntityStates; using EntityStates.Captain.Weapon; using EntityStates.Merc; using EntityStates.TimedChest; using EntityStates.VoidSurvivor.CorruptMode; using HG.Reflection; using HarmonyLib; using R2API.Networking; using R2API.Networking.Interfaces; using R2API.Utils; using RoR2; using RoR2.Achievements; using RoR2.ContentManagement; using RoR2.Projectile; using RoR2.Skills; using RoR2.Stats; using RoR2.UI; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.Rendering; [assembly: OptIn] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace ChallengingUnlocks; [BepInPlugin("binma.challengingunlocks", "Challenging Unlocks", "1.9.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "binma.challengingunlocks"; internal static ManualLogSource Log; internal static ConfigEntry<bool> AnointedEnabled; internal static readonly Dictionary<string, UnlockableDef> Unlockables = new Dictionary<string, UnlockableDef>(); internal static readonly Dictionary<string, string> SkinToAchievement = new Dictionary<string, string>(); internal static readonly Dictionary<string, string> Tokens = new Dictionary<string, string>(); internal static readonly Dictionary<string, string> JudgementBodies = new Dictionary<string, string>(); internal static readonly Dictionary<string, string> VoidRunBodies = new Dictionary<string, string>(); internal static readonly Dictionary<string, string> NoirBodies = new Dictionary<string, string>(); internal static event Action<CharacterMaster> OnSeedRevive; internal static event Action OnVoidRunComplete; internal static void RaiseSeedRevive(CharacterMaster m) { Plugin.OnSeedRevive?.Invoke(m); } internal static void RaiseVoidRunComplete() { Plugin.OnVoidRunComplete?.Invoke(); } internal static void Define(string id, string name, string desc, params string[] skinTokens) { UnlockableDef val = ScriptableObject.CreateInstance<UnlockableDef>(); val.cachedName = "Skins.Binma." + id; val.nameToken = ((skinTokens.Length <= 0) ? "" : skinTokens[0]); Unlockables[id] = val; foreach (string key in skinTokens) { SkinToAchievement[key] = id; } string text = id.ToUpperInvariant(); Tokens["ACHIEVEMENT_" + text + "_NAME"] = name; Tokens["ACHIEVEMENT_" + text + "_DESCRIPTION"] = desc; } private void Awake() { //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Expected O, but got Unknown //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Expected O, but got Unknown //IL_08ad: Unknown result type (might be due to invalid IL or missing references) //IL_08c2: Unknown result type (might be due to invalid IL or missing references) //IL_08cf: Expected O, but got Unknown //IL_08cf: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; AnointedEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("EnemiesReturns", "Enable Anointed Skins", false, "EnemiesReturns' generated Anointed skins. Off by default. This mod controls EnemiesReturns' own Anointed setting, so change it here."); ApplyAnointedSetting(); Define("BinmaMechaFiendDecompile", "「V??oid Fiend』: Leaked Memory", "As 「V??oid Fiend』, accept the offering of the Collective.", "KRONONCONPSIRATOR_SKIN_MECHAFIENDSKINDEF_NAME"); Define("BinmaZenithFalseSon", "False Son: Zenith", "As False Son, survive The Judgement.", "CRAZYHAMSTER_SKIN_ZENITH_NAME"); JudgementBodies["BinmaZenithFalseSon"] = "FalseSonBody"; Define("BinmaBiomassFalseSon", "False Son: Second Bloom", "As False Son, return from death with a Seed of Life.", "ORBITAL_SKIN_FALSESON_NAME"); Define("BinmaShackledAcrid", "Acrid: Shackled", "As Acrid, defeat Voidling and escape the Planetarium.", "ORBITAL_SKIN_SHACKLED_NAME"); VoidRunBodies["BinmaShackledAcrid"] = "CrocoBody"; Define("BinmaLunarVoidRex", "REX: Lunar Void", "As REX, defeat Voidling and escape the Planetarium.", "HILLIURN_SKIN_LUNARVOID_REX_SKIN_NAME"); VoidRunBodies["BinmaLunarVoidRex"] = "TreebotBody"; Define("BinmaBondrewdCaptain", "Captain: Made in Abyss", "As Captain, defeat Voidling and escape the Planetarium.", "FROSTY_ANGRIER_SKIN_SKINDEF_NAME"); VoidRunBodies["BinmaBondrewdCaptain"] = "CaptainBody"; DefineNoir("BinmaNoirBandit", "Bandit", "Bandit2Body", "Hidden in Plain Sight", "open 3 Cloaked Chests in a single run.", "BIGBADPIGEON_SKIN_NOIRBANDIT_NAME"); DefineNoir("BinmaNoirCommando", "Commando", "CommandoBody", "The Scoop", "open the Timed Security Chest.", "BIGBADPIGEON_SKIN_NOIRCOMMANDO_NAME"); DefineNoir("BinmaNoirEngi", "Engineer", "EngiBody", "Surveillance", "use a Radar Scanner on 3 different stages in a single run.", "BIGBADPIGEON_SKIN_NOIRENGI_NAME"); DefineNoir("BinmaNoirRex", "REX", "TreebotBody", "Stakeout", "ping 30 enemies in a single run.", "BIGBADPIGEON_SKIN_NOIRREX_NAME"); DefineNoir("BinmaNoirHuntress", "Huntress", "HuntressBody", "On the Trail", "activate 3 Newt Altars in a single run.", "BIGBADPIGEON_SKIN_NOIRHUNTRESS_NAME"); DefineNoir("BinmaNoirCaptain", "Captain", "CaptainBody", "The Family", "have 5 allies alive at once.", "BIGBADPIGEON_SKIN_NOIRCAPTAIN_NAME"); DefineNoir("BinmaNoirLoader", "Loader", "LoaderBody", "Protection Detail", "finish a teleporter event without an ally dying.", "BIGBADPIGEON_SKIN_NOIRLOADER_NAME"); DefineNoir("BinmaNoirMage", "Artificer", "MageBody", "Infiltration", "visit 2 hidden realms in a single run (any realm, including DLC ones).", "BIGBADPIGEON_SKIN_NOIRMAGE_NAME"); DefineNoir("BinmaNoirVoidfiend", "「V??oid Fiend』", "VoidSurvivorBody", "Unmasked", "stay corrupted for 60 seconds straight.", "BIGBADPIGEON_SKIN_NOIRVOIDFIEND_NAME"); DefineNoir("BinmaNoirMerc", "Mercenary", "MercBody", "No Witnesses", "kill 20 enemies within 5 seconds.", "BIGBADPIGEON_SKIN_NOIRMERC_NAME"); DefineNoir("BinmaNoirDrifter", "Drifter", "DrifterBody", "Sticky Fingers", "scrap 10 items in a single run.", "BIGBADPIGEON_SKIN_NOIRDRIFTER_NAME"); DefineNoir("BinmaNoirDronetech", "Operator", "DroneTechBody", "Stolen Clearance", "buy or repair 5 drones in a single run.", "BIGBADPIGEON_SKIN_NOIRDRONETECH_NAME"); DefineNoir("BinmaNoirToolbot", "MUL-T", "ToolbotBody", "Paper Trail", "open 3 Rusted Lockboxes in a single run.", "BIGBADPIGEON_SKIN_NOIRTOOLBOT_NAME"); DefineNoir("BinmaNoirSeeker", "Seeker", "SeekerBody", "Second Sight", "use a Lunar Seer in the Bazaar Between Time.", "BIGBADPIGEON_SKIN_NOIRSEEKER_NAME"); DefineNoir("BinmaNoirRailgunner", "Railgunner", "RailgunnerBody", "Long Lens", "kill a boss from over 100m away.", "BIGBADPIGEON_SKIN_NOIRRAILGUNNER_NAME"); DefineNoir("BinmaNoirFalseson", "False Son", "FalseSonBody", "Examine the Evidence", "inspect 25 different items.", "BIGBADPIGEON_SKIN_NOIRFALSESON_NAME"); DefineNoir("BinmaNoirAcrid", "Acrid", "CrocoBody", "Cold Case", "defeat the final boss after earning 8 karma.", "BIGBADPIGEON_SKIN_NOIRACRID_NAME"); DefineNoir("BinmaNoirChef", "CHEF", "ChefBody", "Secret Recipe", "cook 3 meals in a single run.", "BIGBADPIGEON_SKIN_NOIRCHEF_NAME"); Define("BinmaFenrisCaptainAtlas", "Captain: Fire for Effect", "As Captain, kill Mithrix with an orbital strike."); Define("BinmaFenrisRailPyro", "Railgunner: Trial by Fire", "As Railgunner, kill a boss that is burning."); Define("BinmaFenrisRailKinetic", "Railgunner: Kinetic Impact", "As Railgunner, kill a boss while airborne."); Define("BinmaSummerRailgunner", "Railgunner: Beach Day", "As Railgunner, open a Legendary Chest.", "BIGBADPIGEON_SKIN_SUMMERRAILGUNNER_NAME"); Define("BinmaSummerVoidFiend", "「V??oid Fiend』: Beach Day", "As 「V??oid Fiend』, open a Legendary Chest.", "BIGBADPIGEON_SKIN_SUMMERVOIDFIEND_NAME"); Define("BinmaSolusRailgunnerPurge", "Railgunner: Purge", "As Railgunner, reject the offering of the Collective.", "KRONONCONSPIRATOR_SKIN_SOLUSGUNNER_NAME"); Define("BinmaSteelConvictionCaptain", "Captain: Steel Conviction", "As Captain, defeat the Alloy Worship Unit.", "SHEPD_SKIN_TANIKSCAPTIAN_NAME"); Define("BinmaFreereinSeeker", "Seeker: Season's Greedings", "As Seeker, open 3 Legendary Chests in a single run.", "SHEP_SKIN_FESTIVESEEKER_NAME"); Define("BinmaAdornedFalseSon", "False Son: Memento Mori", "As False Son, defeat what lies beyond the door of Soulbound Threshold.", "ORBITAL_SKIN_ADORNED_NAME"); Define("BinmaMimikyuDrifter", "Drifter: Memento Mori", "As Drifter, defeat what lies beyond the door of Soulbound Threshold.", "CRAZYHAMSTER_SKIN_MIMIKYUSKIN_NAME"); DefineJudgement("BinmaJudgementCommando", "Commando", "CommandoBody", "ORBITAL_SKIN_MKII_NAME"); DefineJudgement("BinmaJudgementHuntress", "Huntress", "HuntressBody", "ORBITAL_SKIN_URBAN_NAME"); DefineJudgement("BinmaJudgementAcrid", "Acrid", "CrocoBody", "ORBITAL_SKIN_CHIMAERA_NAME"); DefineJudgement("BinmaJudgementLoader", "Loader", "LoaderBody", "ORBITAL_SKIN_REFURBISHED_NAME"); DefineJudgement("BinmaJudgementEngi", "Engineer", "EngiBody", "ORBITAL_SKIN_CHRONTECH_NAME"); DefineJudgement("BinmaJudgementMerc", "Mercenary", "MercBody", "ORBITAL_SKIN_HONOR_NAME", "ORBITAL_SKIN_MALICE_NAME"); DefineJudgement("BinmaJudgementBandit", "Bandit", "Bandit2Body", "ORBITAL_SKIN_INFAMY_NAME"); DefineJudgement("BinmaJudgementArtificer", "Artificer", "MageBody", "ORBITAL_SKIN_AMBER_NAME"); DefineJudgement("BinmaJudgementDrifter", "Drifter", "DrifterBody", "ORBITAL_SKIN_VAGABOND_NAME"); ExtraLocks.Define(); Dotflare.Define(); SkillLocks.Define(); VoidRunTracker.Init(); ExtraLocks.Init(); Dotflare.Init(); ParentOrder.Init(); Noir.Init(); CorruptTracker.Init(); FenrisLocks.Init(); SkillLocks.Init(); Summer.Init(); ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)delegate(AddContentPackProviderDelegate add) { add.Invoke((IContentPackProvider)(object)new ContentProvider()); }; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(AttachToSkins)); Harmony harmony = new Harmony("binma.challengingunlocks"); SafeGrant.Init(((BaseUnityPlugin)this).Config); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(DotflareDisable.Recheck)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(DullerCapeKeeper.Install)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate { try { SkillLocks.ApplyScenes(); SkillTweaks.SwapIcons(); SkillLocks.Attach(); } catch (Exception ex2) { Log.LogError((object)ex2); } }); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate { PolarVortexFix.Install(harmony); }); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate { MercSkillColors.Install(harmony); }); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate { FocusedStrikeTweaks.Install(harmony); }); Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0) { try { harmony.CreateClassProcessor(type).Patch(); } catch (Exception ex) { Log.LogError((object)("Couldn't apply " + type.Name + ": " + ex.Message)); } } } Type type2 = AccessTools.Inner(typeof(EquipmentSlot), "HealAndReviveLock"); if (type2 != null) { harmony.Patch((MethodBase)AccessTools.Method(type2, "FixedUpdate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SeedPatches), "LockPrefix", (Type[])null), new HarmonyMethod(typeof(SeedPatches), "LockPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { Log.LogWarning((object)"Couldn't find HealAndReviveLock; ally Seed of Life revives won't count."); } } private static void DefineNoir(string id, string survivor, string body, string title, string desc, string skin) { Define(id, survivor + ": " + title, "As " + survivor + ", " + desc, skin); NoirBodies[id] = body; } private static void ApplyAnointedSetting() { try { if (!Chainloader.PluginInfos.TryGetValue("com.Viliger.EnemiesReturns", out var value) || (Object)(object)value.Instance == (Object)null) { return; } foreach (ConfigDefinition key in value.Instance.Config.Keys) { if (!(key.Key != "Enable Anointed Skins") && value.Instance.Config[key] is ConfigEntry<bool> val && val.Value != AnointedEnabled.Value) { val.Value = AnointedEnabled.Value; Log.LogInfo((object)("EnemiesReturns Anointed skins " + ((!AnointedEnabled.Value) ? "disabled." : "enabled."))); } } } catch (Exception ex) { Log.LogWarning((object)("Couldn't change the Anointed skins setting: " + ex.Message)); } } private static void DefineJudgement(string id, string survivor, string body, params string[] skins) { Define(id, survivor + ": Returned", "As " + survivor + ", survive The Judgement.", skins); JudgementBodies[id] = body; } private static void AttachToSkins() { bool flag = Chainloader.PluginInfos.ContainsKey("Wolfo.WolfoQoL_Client"); int num = 0; for (int i = 0; i < BodyCatalog.bodyCount; i++) { SkinDef[] bodySkins = BodyCatalog.GetBodySkins((BodyIndex)i); if (bodySkins == null) { continue; } SkinDef[] array = bodySkins; foreach (SkinDef val in array) { if ((Object)(object)val == (Object)null || val.nameToken == null || !SkinToAchievement.TryGetValue(val.nameToken, out var value)) { continue; } UnlockableDef val2 = (val.unlockableDef = Unlockables[value]); if (val.nameToken == "ORBITAL_SKIN_MALICE_NAME" && flag && !((Object)val).name.EndsWith("Red")) { ((Object)val).name = ((Object)val).name + "Red"; } if ((Object)(object)val2.achievementIcon == (Object)null && (Object)(object)val.icon != (Object)null) { val2.achievementIcon = val.icon; AchievementDef achievementDef = AchievementManager.GetAchievementDef(value); if (achievementDef != null) { achievementDef.SetAchievedIcon(val.icon); } } num++; } } foreach (KeyValuePair<string, UnlockableDef> unlockable in Unlockables) { string text = unlockable.Key.ToUpperInvariant(); string nameTok = "ACHIEVEMENT_" + text + "_NAME"; string descTok = "ACHIEVEMENT_" + text + "_DESCRIPTION"; UnlockableDef value2 = unlockable.Value; value2.getHowToUnlockString = () => Language.GetStringFormatted("UNLOCK_VIA_ACHIEVEMENT_FORMAT", new object[2] { Language.GetString(nameTok), Language.GetString(descTok) }); value2.getUnlockedString = () => Language.GetStringFormatted("UNLOCKED_FORMAT", new object[2] { Language.GetString(nameTok), Language.GetString(descTok) }); } Log.LogInfo((object)("Locked " + num + " skins behind achievements.")); FenrisLocks.Attach(); ExtraLocks.Attach(); Summer.DetectTropics(); Dotflare.DetectStages(); DotflareFix.Apply(); } } internal static class Ids { public const string MechaFiend = "BinmaMechaFiendDecompile"; public const string Zenith = "BinmaZenithFalseSon"; public const string Biomass = "BinmaBiomassFalseSon"; public const string Shackled = "BinmaShackledAcrid"; public const string LunarVoidRex = "BinmaLunarVoidRex"; public const string Bondrewd = "BinmaBondrewdCaptain"; public const string CaptainAtlas = "BinmaFenrisCaptainAtlas"; public const string RailPyro = "BinmaFenrisRailPyro"; public const string RailKinetic = "BinmaFenrisRailKinetic"; public const string SummerRail = "BinmaSummerRailgunner"; public const string SummerVoid = "BinmaSummerVoidFiend"; public const string SolusRail = "BinmaSolusRailgunnerPurge"; public const string SteelCaptain = "BinmaSteelConvictionCaptain"; public const string FreereinSeeker = "BinmaFreereinSeeker"; public const string AdornedFalseSon = "BinmaAdornedFalseSon"; public const string MimikyuDrifter = "BinmaMimikyuDrifter"; public const string JCommando = "BinmaJudgementCommando"; public const string JHuntress = "BinmaJudgementHuntress"; public const string JAcrid = "BinmaJudgementAcrid"; public const string JLoader = "BinmaJudgementLoader"; public const string JEngi = "BinmaJudgementEngi"; public const string JMerc = "BinmaJudgementMerc"; public const string JBandit = "BinmaJudgementBandit"; public const string JArtificer = "BinmaJudgementArtificer"; public const string JDrifter = "BinmaJudgementDrifter"; } internal class ContentProvider : IContentPackProvider { private readonly ContentPack pack = new ContentPack(); public string identifier => "binma.challengingunlocks"; public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { pack.unlockableDefs.Add(new List<UnlockableDef>(Plugin.Unlockables.Values).ToArray()); pack.buffDefs.Add((BuffDef[])(object)new BuffDef[1] { FocusedStrikeTweaks.Concentrated }); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(pack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } [HarmonyPatch(typeof(Language), "GetLocalizedStringByToken")] internal static class LanguagePatch { internal static readonly Dictionary<string, string> ValueRenames = new Dictionary<string, string>(); internal static readonly Dictionary<string, string> Renames = new Dictionary<string, string> { { "DOTFLARE_SKIN_MAGE_CELTIEL_-_HOOD_NAME", "Lunar Zealot" }, { "FROSTY_ANGRIER_SKIN_SKINDEF_NAME", "Bondrewd" } }; private static void Postfix(string __0, ref string __result) { if (__0 != null) { if (Renames.TryGetValue(__0, out var value)) { __result = value; } else if (__result != null && ValueRenames.TryGetValue(__result, out value)) { __result = value; } else if ((__result == null || __result == __0) && Plugin.Tokens.TryGetValue(__0, out value)) { __result = value; } } } } internal static class Util2 { internal static bool PlaysAs(NetworkUser user, string bodyName) { //IL_000f: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_003c: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)user == (Object)null) { return false; } BodyIndex val = BodyCatalog.FindBodyIndex(bodyName); if ((int)val == -1) { return false; } CharacterBody currentBody = user.GetCurrentBody(); if ((Object)(object)currentBody != (Object)null) { return currentBody.bodyIndex == val; } return user.bodyIndexPreference == val; } } [RegisterAchievement("BinmaMechaFiendDecompile", "Skins.Binma.BinmaMechaFiendDecompile", "CompleteVoidEnding", 5u, null)] public class MechaFiendAchievement : BasePerSurvivorDecompileAchievement { protected override BodyIndex LookUpRequiredBodyIndex() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return BodyCatalog.FindBodyIndex("VoidSurvivorBody"); } } [RegisterAchievement("BinmaZenithFalseSon", "Skins.Binma.BinmaZenithFalseSon", "UnlockFalseSon", 5u, typeof(JudgementServer))] public class ZenithAchievement : ServerTrackedAchievement { } public abstract class ServerTrackedAchievement : BaseAchievement { public override void OnInstall() { ((BaseAchievement)this).OnInstall(); ((BaseAchievement)this).SetServerTracked(true); } public override void OnUninstall() { ((BaseAchievement)this).SetServerTracked(false); ((BaseAchievement)this).OnUninstall(); } } [RegisterAchievement("BinmaBiomassFalseSon", "Skins.Binma.BinmaBiomassFalseSon", "UnlockFalseSon", 5u, typeof(BiomassServer))] public class BiomassAchievement : ServerTrackedAchievement { } public class BiomassServer : BaseServerAchievement { public override void OnInstall() { ((BaseServerAchievement)this).OnInstall(); Plugin.OnSeedRevive += Handle; } public override void OnUninstall() { Plugin.OnSeedRevive -= Handle; ((BaseServerAchievement)this).OnUninstall(); } private void Handle(CharacterMaster master) { if (!((Object)(object)master == (Object)null) && !((Object)(object)((BaseServerAchievement)this).networkUser == (Object)null) && !((Object)(object)((BaseServerAchievement)this).networkUser.master != (Object)(object)master) && Util2.PlaysAs(((BaseServerAchievement)this).networkUser, "FalseSonBody")) { ((BaseServerAchievement)this).Grant(); } } } internal static class SeedPatches { internal static void LockPrefix(MonoBehaviour __instance, out bool __state) { __state = false; try { Traverse val = Traverse.Create((object)__instance); float value = val.Field("age").GetValue<float>(); float value2 = val.Field("delayDuration").GetValue<float>(); __state = value + Time.fixedDeltaTime > value2; } catch { } } internal static void LockPostfix(MonoBehaviour __instance, bool __state) { if (!__state || !NetworkServer.active) { return; } try { CharacterMaster component = ((Component)__instance).GetComponent<CharacterMaster>(); if ((Object)(object)component != (Object)null && component.hasBody) { Plugin.RaiseSeedRevive(component); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch] internal static class SeedSelfPatchHost { [HarmonyPatch(typeof(CharacterMaster), "RespawnExtraLifeHealAndRevive")] [HarmonyPostfix] private static void Postfix(CharacterMaster __instance) { try { if (NetworkServer.active) { Plugin.RaiseSeedRevive(__instance); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static class Noir { private static readonly Dictionary<string, Dictionary<CharacterMaster, int>> counts = new Dictionary<string, Dictionary<CharacterMaster, int>>(); private static readonly Dictionary<CharacterMaster, HashSet<string>> scannerStages = new Dictionary<CharacterMaster, HashSet<string>>(); private static readonly Dictionary<CharacterMaster, HashSet<int>> pingedEnemies = new Dictionary<CharacterMaster, HashSet<int>>(); private static readonly Dictionary<CharacterMaster, Queue<float>> recentKills = new Dictionary<CharacterMaster, Queue<float>>(); private static readonly HashSet<string> realmsVisited = new HashSet<string>(); private static readonly HashSet<string> hiddenRealms = new HashSet<string> { "bazaar", "goldshores", "mysteryspace", "limbo", "arena" }; private static bool teleporterCharging; private static bool allyDiedDuringTeleporter; internal static event Action<string, CharacterMaster> OnGrant; internal static void Grant(string id, CharacterMaster m) { Action<string, CharacterMaster> onGrant = Noir.OnGrant; if (onGrant != null) { try { onGrant(id, m); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static void Count(string id, CharacterMaster m, int needed) { if (!((Object)(object)m == (Object)null) && NetworkServer.active) { if (!counts.TryGetValue(id, out var value)) { value = (counts[id] = new Dictionary<CharacterMaster, int>()); } value.TryGetValue(m, out var value2); value2 = (value[m] = value2 + 1); if (value2 >= needed) { Grant(id, m); } } } internal static CharacterMaster MasterOf(Interactor i) { if ((Object)(object)i == (Object)null) { return null; } CharacterBody component = ((Component)i).GetComponent<CharacterBody>(); return (!((Object)(object)component != (Object)null)) ? null : component.master; } private static string CurrentScene() { SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef; return (!((Object)(object)mostRecentSceneDef != (Object)null)) ? "" : mostRecentSceneDef.cachedName; } internal static void Init() { Run.onRunStartGlobal += delegate { try { counts.Clear(); scannerStages.Clear(); pingedEnemies.Clear(); recentKills.Clear(); realmsVisited.Clear(); teleporterCharging = false; } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; GlobalEventManager.OnInteractionsGlobal += delegate(Interactor interactor, IInteractable interactable, GameObject obj) { try { if (NetworkServer.active && !((Object)(object)obj == (Object)null)) { CharacterMaster val = MasterOf(interactor); if (!((Object)(object)val == (Object)null)) { string text = ((Object)obj).name ?? ""; if (text.Contains("Stealthed")) { Count("BinmaNoirBandit", val, 3); } if ((Object)(object)obj.GetComponent<PortalStatueBehavior>() != (Object)null) { Count("BinmaNoirHuntress", val, 3); } if ((Object)(object)obj.GetComponent<SummonMasterBehavior>() != (Object)null) { Count("BinmaNoirDronetech", val, 5); } if (text.StartsWith("Lockbox") && !text.Contains("Void")) { Count("BinmaNoirToolbot", val, 3); } if ((Object)(object)obj.GetComponent<SeerStationController>() != (Object)null && CurrentScene() == "bazaar") { Grant("BinmaNoirSeeker", val); } } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; Opening.onOpened += delegate { try { if (NetworkServer.active) { Grant("BinmaNoirCommando", null); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; Stage.onServerStageBegin += delegate(Stage stage) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Invalid comparison between Unknown and I4 try { if (!((Object)(object)stage == (Object)null) && !((Object)(object)stage.sceneDef == (Object)null)) { string text = stage.sceneDef.cachedName ?? ""; if (text.StartsWith("artifactworld")) { text = "artifactworld"; } if ((hiddenRealms.Contains(text) || text == "artifactworld" || text == "voidstage" || (int)stage.sceneDef.sceneType == 2) && !(text == "voidraid")) { realmsVisited.Add(text); if (realmsVisited.Count >= 2) { Grant("BinmaNoirMage", null); } } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; TeleporterInteraction.onTeleporterBeginChargingGlobal += delegate { teleporterCharging = true; allyDiedDuringTeleporter = false; }; TeleporterInteraction.onTeleporterChargedGlobal += delegate { try { if (NetworkServer.active && teleporterCharging && !allyDiedDuringTeleporter) { Grant("BinmaNoirLoader", null); } teleporterCharging = false; } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; GlobalEventManager.onDeathProcServer += delegate(DamageReport report) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) try { if (NetworkServer.active && report != null) { if (teleporterCharging && (int)report.victimTeamIndex == 1) { allyDiedDuringTeleporter = true; } CharacterMaster attackerMaster = report.attackerMaster; if (!((Object)(object)attackerMaster == (Object)null) && (int)report.victimTeamIndex != 1) { if (!recentKills.TryGetValue(attackerMaster, out var value)) { value = (recentKills[attackerMaster] = new Queue<float>()); } float time = Time.time; value.Enqueue(time); while (value.Count > 0 && time - value.Peek() > 5f) { value.Dequeue(); } if (value.Count >= 20) { Grant("BinmaNoirMerc", attackerMaster); } if (report.victimIsBoss && (Object)(object)report.attackerBody != (Object)null && (Object)(object)report.victimBody != (Object)null && Vector3.Distance(report.attackerBody.corePosition, report.victimBody.corePosition) >= 100f) { Grant("BinmaNoirRailgunner", attackerMaster); } } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; CharacterBody.onBodyStartGlobal += delegate(CharacterBody body) { try { if (NetworkServer.active && !((Object)(object)body == (Object)null) && !((Object)(object)body.master == (Object)null)) { MinionOwnership minionOwnership = body.master.minionOwnership; CharacterMaster val = ((!((Object)(object)minionOwnership != (Object)null)) ? null : minionOwnership.ownerMaster); if (!((Object)(object)val == (Object)null)) { int num = 0; foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList) { if (!((Object)(object)readOnlyInstances == (Object)null) && !((Object)(object)readOnlyInstances.minionOwnership == (Object)null) && !((Object)(object)readOnlyInstances.minionOwnership.ownerMaster != (Object)(object)val)) { CharacterBody body2 = readOnlyInstances.GetBody(); if ((Object)(object)body2 != (Object)null && (Object)(object)body2.healthComponent != (Object)null && body2.healthComponent.alive) { num++; } } } if (num >= 5) { Grant("BinmaNoirCaptain", val); } } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; } internal static void ScannerUsed(CharacterMaster m) { if (!((Object)(object)m == (Object)null)) { if (!scannerStages.TryGetValue(m, out var value)) { value = (scannerStages[m] = new HashSet<string>()); } value.Add(CurrentScene()); if (value.Count >= 3) { Grant("BinmaNoirEngi", m); } } } internal static void EnemyPinged(CharacterMaster m, CharacterBody target) { if (!((Object)(object)m == (Object)null) && !((Object)(object)target == (Object)null)) { if (!pingedEnemies.TryGetValue(m, out var value)) { value = (pingedEnemies[m] = new HashSet<int>()); } value.Add(((Object)((Component)target).gameObject).GetInstanceID()); if (value.Count >= 30) { Grant("BinmaNoirRex", m); } } } } public class NoirServer : BaseServerAchievement { public override void OnInstall() { ((BaseServerAchievement)this).OnInstall(); Noir.OnGrant += Handle; } public override void OnUninstall() { Noir.OnGrant -= Handle; ((BaseServerAchievement)this).OnUninstall(); } private void Handle(string id, CharacterMaster master) { if (base.achievementDef != null && !(id != base.achievementDef.identifier) && !((Object)(object)((BaseServerAchievement)this).networkUser == (Object)null) && (!((Object)(object)master != (Object)null) || !((Object)(object)((BaseServerAchievement)this).networkUser.master != (Object)(object)master)) && Plugin.NoirBodies.TryGetValue(id, out var value) && Util2.PlaysAs(((BaseServerAchievement)this).networkUser, value)) { ((BaseServerAchievement)this).Grant(); } } } [RegisterAchievement("BinmaNoirBandit", "Skins.Binma.BinmaNoirBandit", null, 5u, typeof(NoirServer))] public class NoirBandit : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirCommando", "Skins.Binma.BinmaNoirCommando", null, 5u, typeof(NoirServer))] public class NoirCommando : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirEngi", "Skins.Binma.BinmaNoirEngi", null, 5u, typeof(NoirServer))] public class NoirEngi : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirRex", "Skins.Binma.BinmaNoirRex", null, 5u, typeof(NoirServer))] public class NoirRex : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirHuntress", "Skins.Binma.BinmaNoirHuntress", null, 5u, typeof(NoirServer))] public class NoirHuntress : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirCaptain", "Skins.Binma.BinmaNoirCaptain", null, 5u, typeof(NoirServer))] public class NoirCaptain : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirLoader", "Skins.Binma.BinmaNoirLoader", null, 5u, typeof(NoirServer))] public class NoirLoader : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirMage", "Skins.Binma.BinmaNoirMage", null, 5u, typeof(NoirServer))] public class NoirMage : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirVoidfiend", "Skins.Binma.BinmaNoirVoidfiend", null, 5u, typeof(NoirServer))] public class NoirVoidfiend : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirMerc", "Skins.Binma.BinmaNoirMerc", null, 5u, typeof(NoirServer))] public class NoirMerc : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirDrifter", "Skins.Binma.BinmaNoirDrifter", null, 5u, typeof(NoirServer))] public class NoirDrifter : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirDronetech", "Skins.Binma.BinmaNoirDronetech", null, 5u, typeof(NoirServer))] public class NoirDronetech : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirToolbot", "Skins.Binma.BinmaNoirToolbot", null, 5u, typeof(NoirServer))] public class NoirToolbot : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirSeeker", "Skins.Binma.BinmaNoirSeeker", null, 5u, typeof(NoirServer))] public class NoirSeeker : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirRailgunner", "Skins.Binma.BinmaNoirRailgunner", null, 5u, typeof(NoirServer))] public class NoirRailgunner : ServerTrackedAchievement { } [RegisterAchievement("BinmaNoirChef", "Skins.Binma.BinmaNoirChef", null, 5u, typeof(NoirServer))] public class NoirChef : ServerTrackedAchievement { } [HarmonyPatch(typeof(EquipmentSlot), "FireScanner")] internal static class ScannerPatch { private static void Postfix(EquipmentSlot __instance, bool __result) { try { if (__result && NetworkServer.active && (Object)(object)__instance.characterBody != (Object)null) { Noir.ScannerUsed(__instance.characterBody.master); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(PingerController), "CmdPing")] internal static class PingPatch { private static void Postfix(PingerController __instance, PingInfo __0) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 try { if (!NetworkServer.active) { return; } GameObject targetGameObject = ((PingInfo)(ref __0)).targetGameObject; if (!((Object)(object)targetGameObject == (Object)null)) { CharacterBody component = targetGameObject.GetComponent<CharacterBody>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.teamComponent == (Object)null) && (int)component.teamComponent.teamIndex != 1) { Noir.EnemyPinged(((Component)__instance).GetComponent<CharacterMaster>(), component); } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(ScrapperController), "BeginScrapping", new Type[] { typeof(UniquePickup) })] internal static class ScrapPatch { private static void Postfix(ScrapperController __instance) { try { if (NetworkServer.active) { Interactor value = Traverse.Create((object)__instance).Field("interactor").GetValue<Interactor>(); Noir.Count("BinmaNoirDrifter", Noir.MasterOf(value), 10); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(MealPrepController), "BeginCookingServer")] internal static class CookPatch { private static void Postfix(Interactor __0) { try { if (NetworkServer.active) { Noir.Count("BinmaNoirChef", Noir.MasterOf(__0), 3); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static class CorruptTracker { private static readonly Dictionary<CharacterBody, float> since = new Dictionary<CharacterBody, float>(); internal static void Init() { RoR2Application.onFixedUpdate += delegate { try { Tick(); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; Run.onRunStartGlobal += delegate { since.Clear(); }; } internal static void Gained(CharacterBody b, BuffDef d) { if (NetworkServer.active && (Object)(object)b != (Object)null && (Object)(object)d == (Object)(object)Buffs.VoidSurvivorCorruptMode) { since[b] = Time.fixedTime; } } internal static void Lost(CharacterBody b, BuffDef d) { if ((Object)(object)b != (Object)null && (Object)(object)d == (Object)(object)Buffs.VoidSurvivorCorruptMode) { since.Remove(b); } } private static void Tick() { if (!NetworkServer.active || since.Count == 0) { return; } List<CharacterBody> list = null; foreach (KeyValuePair<CharacterBody, float> item in since) { if ((Object)(object)item.Key == (Object)null) { List<CharacterBody> obj = list ?? new List<CharacterBody>(); list = obj; obj.Add(item.Key); } else if (!(Time.fixedTime - item.Value < 60f)) { Noir.Grant("BinmaNoirVoidfiend", item.Key.master); List<CharacterBody> obj2 = list ?? new List<CharacterBody>(); list = obj2; obj2.Add(item.Key); } } if (list == null) { return; } foreach (CharacterBody item2 in list) { since.Remove(item2); } } } [HarmonyPatch(typeof(CharacterBody), "OnBuffFirstStackGained")] internal static class CorruptGainPatch { private static void Postfix(CharacterBody __instance, BuffDef __0) { try { CorruptTracker.Gained(__instance, __0); } catch { } } } [HarmonyPatch(typeof(CharacterBody), "OnBuffFinalStackLost")] internal static class CorruptLossPatch { private static void Postfix(CharacterBody __instance, BuffDef __0) { try { CorruptTracker.Lost(__instance, __0); } catch { } } } [HarmonyPatch(typeof(CorruptMode), "FixedUpdate")] internal static class CorruptTimePatch { private static readonly HashSet<EntityState> done = new HashSet<EntityState>(); private static void Postfix(CorruptMode __instance) { try { if (!NetworkServer.active || done.Contains((EntityState)(object)__instance)) { return; } float value = Traverse.Create((object)__instance).Property("fixedAge", (object[])null).GetValue<float>(); if (!(value < 60f)) { done.Add((EntityState)(object)__instance); CharacterBody value2 = Traverse.Create((object)__instance).Property("characterBody", (object[])null).GetValue<CharacterBody>(); if ((Object)(object)value2 != (Object)null) { Noir.Grant("BinmaNoirVoidfiend", value2.master); } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [RegisterAchievement("BinmaNoirAcrid", "Skins.Binma.BinmaNoirAcrid", null, 5u, typeof(KarmaServer))] public class NoirAcrid : BasePerSurvivorBeatBrotherMaxKarmaAchievement { protected class KarmaServer : BasePerSurvivorBeatBrotherMaxKarmaServerAchievement { } protected override BodyIndex LookUpRequiredBodyIndex() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return BodyCatalog.FindBodyIndex("CrocoBody"); } } [RegisterAchievement("BinmaNoirFalseson", "Skins.Binma.BinmaNoirFalseson", "UnlockFalseSon", 5u, null)] public class NoirFalseSon : BaseAchievement { internal static event Action<PickupIndex> OnInspect; internal static void RaiseInspect(PickupIndex p) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) NoirFalseSon.OnInspect?.Invoke(p); } protected override BodyIndex LookUpRequiredBodyIndex() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return BodyCatalog.FindBodyIndex("FalseSonBody"); } protected override void OnBodyRequirementMet() { ((BaseAchievement)this).OnBodyRequirementMet(); OnInspect += Handle; } protected override void OnBodyRequirementBroken() { OnInspect -= Handle; ((BaseAchievement)this).OnBodyRequirementBroken(); } private string SavePath() { string text = ((((BaseAchievement)this).userProfile == null || ((BaseAchievement)this).userProfile.fileName == null) ? "default" : ((BaseAchievement)this).userProfile.fileName); char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { text = text.Replace(oldChar, '_'); } return Path.Combine(Paths.ConfigPath, "binma.challengingunlocks.inspected." + text + ".txt"); } private void Handle(PickupIndex p) { //IL_0000: 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_0014: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 try { PickupDef pickupDef = PickupCatalog.GetPickupDef(p); if (pickupDef != null && ((int)pickupDef.itemIndex != -1 || (int)pickupDef.equipmentIndex != -1)) { string path = SavePath(); HashSet<string> hashSet = new HashSet<string>((!File.Exists(path)) ? ((IEnumerable<string>)new string[0]) : ((IEnumerable<string>)File.ReadAllLines(path))); if (hashSet.Add(pickupDef.internalName)) { File.WriteAllLines(path, new List<string>(hashSet).ToArray()); } if (hashSet.Count >= 25) { ((BaseAchievement)this).Grant(); } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch] internal static class InspectPatch { private static IEnumerable<MethodBase> TargetMethods() { foreach (MethodInfo m in AccessTools.GetDeclaredMethods(typeof(InspectPanelController))) { ParameterInfo[] ps = m.GetParameters(); if (m.Name == "Show" && ps.Length > 0 && ps[0].ParameterType == typeof(InspectInfo)) { yield return m; } } } private static void Postfix(InspectInfo __0) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) try { if (__0 != null && __0.isDynamicInspectInfo) { NoirFalseSon.RaiseInspect(__0.dynamicInspectPickupIndex); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static class VoidRunTracker { private static readonly Dictionary<CharacterMaster, BodyIndex> atPlanetarium = new Dictionary<CharacterMaster, BodyIndex>(); private static readonly Dictionary<CharacterMaster, BodyIndex> atEnd = new Dictionary<CharacterMaster, BodyIndex>(); private static BodyIndex BodyOf(CharacterMaster m) { //IL_0022: 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) if ((Object)(object)m == (Object)null) { return (BodyIndex)(-1); } CharacterBody body = m.GetBody(); if ((Object)(object)body != (Object)null) { return body.bodyIndex; } return (BodyIndex)((!Object.op_Implicit((Object)(object)m.bodyPrefab)) ? (-1) : ((int)BodyCatalog.FindBodyIndex(m.bodyPrefab))); } private static void Snapshot(Dictionary<CharacterMaster, BodyIndex> into) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if ((Object)(object)instance != (Object)null && (Object)(object)instance.master != (Object)null) { into[instance.master] = BodyOf(instance.master); } } } internal static void Init() { Run.onRunStartGlobal += delegate { atPlanetarium.Clear(); atEnd.Clear(); }; Stage.onServerStageBegin += delegate(Stage stage) { if ((Object)(object)stage != (Object)null && (Object)(object)stage.sceneDef != (Object)null && stage.sceneDef.cachedName == "voidraid") { Snapshot(atPlanetarium); } }; Run.onServerGameOver += delegate(Run run, GameEndingDef ending) { if (!((Object)(object)ending == (Object)null) && !(ending.cachedName != "VoidEnding")) { Snapshot(atEnd); Plugin.RaiseVoidRunComplete(); } }; } internal static bool Qualifies(NetworkUser user, string bodyName) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0055: 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_007d: 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 ((Object)(object)user == (Object)null || (Object)(object)user.master == (Object)null) { return false; } BodyIndex val = BodyCatalog.FindBodyIndex(bodyName); if ((int)val == -1) { return false; } BodyIndex value; BodyIndex value2; return (atPlanetarium.Count == 0 || (atPlanetarium.TryGetValue(user.master, out value) && value == val)) && atEnd.TryGetValue(user.master, out value2) && value2 == val; } } [RegisterAchievement("BinmaShackledAcrid", "Skins.Binma.BinmaShackledAcrid", "BeatArena", 5u, typeof(ShackledServer))] public class ShackledAchievement : ServerTrackedAchievement { } public class ShackledServer : BaseServerAchievement { public override void OnInstall() { ((BaseServerAchievement)this).OnInstall(); Plugin.OnVoidRunComplete += Handle; } public override void OnUninstall() { Plugin.OnVoidRunComplete -= Handle; ((BaseServerAchievement)this).OnUninstall(); } private void Handle() { if (base.achievementDef != null && Plugin.VoidRunBodies.TryGetValue(base.achievementDef.identifier, out var value) && VoidRunTracker.Qualifies(((BaseServerAchievement)this).networkUser, value)) { ((BaseServerAchievement)this).Grant(); } } } [RegisterAchievement("BinmaLunarVoidRex", "Skins.Binma.BinmaLunarVoidRex", null, 5u, typeof(ShackledServer))] public class LunarVoidRexAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaBondrewdCaptain", "Skins.Binma.BinmaBondrewdCaptain", null, 5u, typeof(ShackledServer))] public class BondrewdCaptainAchievement : ServerTrackedAchievement { } internal static class FenrisLocks { private static readonly HashSet<string> probePrefabs = new HashSet<string>(); internal static event Action<string, CharacterMaster> OnGrant; internal static void NoteProbePrefab(GameObject prefab) { if ((Object)(object)prefab != (Object)null) { probePrefabs.Add(((Object)prefab).name); } } private static void Grant(string id, CharacterMaster m) { Action<string, CharacterMaster> onGrant = FenrisLocks.OnGrant; if (onGrant != null) { try { onGrant(id, m); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } private static void Lock(string bodyName, Func<Type, bool> match, string id) { GameObject val = BodyCatalog.FindBodyPrefab(bodyName); if ((Object)(object)val == (Object)null) { return; } GenericSkill[] components = val.GetComponents<GenericSkill>(); foreach (GenericSkill val2 in components) { SkillFamily skillFamily = val2.skillFamily; if ((Object)(object)skillFamily == (Object)null || skillFamily.variants == null) { continue; } for (int j = 0; j < skillFamily.variants.Length; j++) { SkillDef skillDef = skillFamily.variants[j].skillDef; if ((Object)(object)skillDef == (Object)null) { continue; } Type stateType = ((SerializableEntityStateType)(ref skillDef.activationState)).stateType; if (stateType == null || stateType.Namespace == null || !stateType.Namespace.StartsWith("FenrisSkills") || !match(stateType)) { continue; } UnlockableDef val3 = Plugin.Unlockables[id]; val3.nameToken = skillDef.skillNameToken; skillFamily.variants[j].unlockableDef = val3; if ((Object)(object)skillDef.icon != (Object)null) { val3.achievementIcon = skillDef.icon; AchievementDef achievementDef = AchievementManager.GetAchievementDef(id); if (achievementDef != null) { achievementDef.SetAchievedIcon(skillDef.icon); } } Plugin.Log.LogInfo((object)("Locked skill " + skillDef.skillName + " on " + bodyName + ".")); } } } internal static void Attach() { try { Lock("CaptainBody", (Type t) => true, "BinmaFenrisCaptainAtlas"); Lock("RailgunnerBody", (Type t) => t.Name == "FireMineExplosive", "BinmaFenrisRailKinetic"); Lock("RailgunnerBody", (Type t) => t.Name != "FireMineExplosive", "BinmaFenrisRailPyro"); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } internal static void Init() { GlobalEventManager.onDeathProcServer += delegate(DamageReport report) { try { if (NetworkServer.active && report != null && !((Object)(object)report.attackerMaster == (Object)null) && !((Object)(object)report.victimBody == (Object)null)) { CharacterMaster attackerMaster = report.attackerMaster; if (((Object)report.victimBody).name.StartsWith("BrotherHurtBody") && report.damageInfo != null && (Object)(object)report.damageInfo.inflictor != (Object)null) { string name = ((Object)report.damageInfo.inflictor).name; bool flag = name.Contains("Airstrike"); foreach (string probePrefab in probePrefabs) { if (name.StartsWith(probePrefab)) { flag = true; } } if (flag) { Grant("BinmaFenrisCaptainAtlas", attackerMaster); } } if (report.victimIsBoss) { CharacterBody victimBody = report.victimBody; if (victimBody.HasBuff(Buffs.OnFire) || ((Object)(object)Buffs.StrongerBurn != (Object)null && victimBody.HasBuff(Buffs.StrongerBurn))) { Grant("BinmaFenrisRailPyro", attackerMaster); } CharacterBody attackerBody = report.attackerBody; if ((Object)(object)attackerBody != (Object)null && (Object)(object)attackerBody.characterMotor != (Object)null && !attackerBody.characterMotor.isGrounded) { Grant("BinmaFenrisRailKinetic", attackerMaster); } } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; } } public class FenrisServer : BaseServerAchievement { private static readonly Dictionary<string, string> bodies = new Dictionary<string, string> { { "BinmaFenrisCaptainAtlas", "CaptainBody" }, { "BinmaFenrisRailPyro", "RailgunnerBody" }, { "BinmaFenrisRailKinetic", "RailgunnerBody" } }; public override void OnInstall() { ((BaseServerAchievement)this).OnInstall(); FenrisLocks.OnGrant += Handle; } public override void OnUninstall() { FenrisLocks.OnGrant -= Handle; ((BaseServerAchievement)this).OnUninstall(); } private void Handle(string id, CharacterMaster master) { if (base.achievementDef != null && !(id != base.achievementDef.identifier) && !((Object)(object)((BaseServerAchievement)this).networkUser == (Object)null) && !((Object)(object)((BaseServerAchievement)this).networkUser.master != (Object)(object)master) && bodies.TryGetValue(id, out var value) && Util2.PlaysAs(((BaseServerAchievement)this).networkUser, value)) { ((BaseServerAchievement)this).Grant(); } } } [RegisterAchievement("BinmaFenrisCaptainAtlas", "Skins.Binma.BinmaFenrisCaptainAtlas", "CompleteMainEnding", 5u, typeof(FenrisServer))] public class CaptainAtlasAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaFenrisRailPyro", "Skins.Binma.BinmaFenrisRailPyro", null, 5u, typeof(FenrisServer))] public class RailPyroAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaFenrisRailKinetic", "Skins.Binma.BinmaFenrisRailKinetic", null, 5u, typeof(FenrisServer))] public class RailKineticAchievement : ServerTrackedAchievement { } [HarmonyPatch(typeof(CallAirstrikeBase), "ModifyProjectile")] internal static class ProbePrefabPatch { private static void Postfix(ref FireProjectileInfo __0) { try { FenrisLocks.NoteProbePrefab(__0.projectilePrefab); } catch { } } } internal static class Summer { internal static bool TropicsInstalled; private static readonly HashSet<string> tropicsScenes = new HashSet<string> { "tropics_wormsworms", "tropicsnight_wormsworms" }; internal static event Action<CharacterMaster> OnLegendaryOpened; internal static event Action<CharacterMaster> OnAnyLegendaryOpened; internal static void DetectTropics() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 foreach (string tropicsScene in tropicsScenes) { if ((int)SceneCatalog.FindSceneIndex(tropicsScene) != -1) { TropicsInstalled = true; } } if (TropicsInstalled) { Plugin.Tokens["ACHIEVEMENT_" + "BinmaSummerRailgunner".ToUpperInvariant() + "_DESCRIPTION"] = "As Railgunner, open a Legendary Chest on Sunset Tropics or Midnight Tropics."; Plugin.Tokens["ACHIEVEMENT_" + "BinmaSummerVoidFiend".ToUpperInvariant() + "_DESCRIPTION"] = "As 「V??oid Fiend』, open a Legendary Chest on Sunset Tropics or Midnight Tropics."; Plugin.Log.LogInfo((object)"Sunset Tropics detected; Summer skins require the Tropics."); } } internal static bool LegendaryCountsHere() { return StageCounts(); } private static bool StageCounts() { if (TropicsInstalled) { SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef; return (Object)(object)mostRecentSceneDef != (Object)null && tropicsScenes.Contains(mostRecentSceneDef.cachedName); } return true; } internal static void Init() { GlobalEventManager.OnInteractionsGlobal += delegate(Interactor interactor, IInteractable interactable, GameObject obj) { try { if (NetworkServer.active && !((Object)(object)obj == (Object)null) && !((Object)(object)obj.GetComponent<PurchaseInteraction>() == (Object)null) && ((Object)obj).name.Contains("GoldChest")) { CharacterMaster val = Noir.MasterOf(interactor); Action<CharacterMaster> onAnyLegendaryOpened = Summer.OnAnyLegendaryOpened; if ((Object)(object)val != (Object)null) { onAnyLegendaryOpened?.Invoke(val); } if (StageCounts()) { Action<CharacterMaster> onLegendaryOpened = Summer.OnLegendaryOpened; if ((Object)(object)val != (Object)null) { onLegendaryOpened?.Invoke(val); } } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; } } public class SummerServer : BaseServerAchievement { public override void OnInstall() { ((BaseServerAchievement)this).OnInstall(); Summer.OnLegendaryOpened += Handle; } public override void OnUninstall() { Summer.OnLegendaryOpened -= Handle; ((BaseServerAchievement)this).OnUninstall(); } private void Handle(CharacterMaster master) { if (!((Object)(object)((BaseServerAchievement)this).networkUser == (Object)null) && !((Object)(object)((BaseServerAchievement)this).networkUser.master != (Object)(object)master)) { string bodyName = ((base.achievementDef == null || !(base.achievementDef.identifier == "BinmaSummerRailgunner")) ? "VoidSurvivorBody" : "RailgunnerBody"); if (Util2.PlaysAs(((BaseServerAchievement)this).networkUser, bodyName)) { ((BaseServerAchievement)this).Grant(); } } } } [RegisterAchievement("BinmaSummerRailgunner", "Skins.Binma.BinmaSummerRailgunner", null, 5u, typeof(SummerServer))] public class SummerRailAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaSummerVoidFiend", "Skins.Binma.BinmaSummerVoidFiend", "CompleteVoidEnding", 5u, typeof(SummerServer))] public class SummerVoidAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaSolusRailgunnerPurge", "Skins.Binma.BinmaSolusRailgunnerPurge", null, 5u, typeof(KillSolusHeartServer))] public class SolusRailAchievement : BasePerSurvivorPurgeAchievement { protected class KillSolusHeartServer : BasePerSurvivorKillSolusHeartServerAchievement { } protected override BodyIndex LookUpRequiredBodyIndex() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return BodyCatalog.FindBodyIndex("RailgunnerBody"); } } public class FreereinServer : BaseServerAchievement { private int count; private Run run; public override void OnInstall() { ((BaseServerAchievement)this).OnInstall(); Summer.OnAnyLegendaryOpened += Handle; } public override void OnUninstall() { Summer.OnAnyLegendaryOpened -= Handle; ((BaseServerAchievement)this).OnUninstall(); } private void Handle(CharacterMaster master) { if (!((Object)(object)((BaseServerAchievement)this).networkUser == (Object)null) && !((Object)(object)((BaseServerAchievement)this).networkUser.master != (Object)(object)master) && Util2.PlaysAs(((BaseServerAchievement)this).networkUser, "SeekerBody")) { if ((Object)(object)run != (Object)(object)Run.instance) { run = Run.instance; count = 0; } if (++count >= 3) { ((BaseServerAchievement)this).Grant(); } } } } [RegisterAchievement("BinmaFreereinSeeker", "Skins.Binma.BinmaFreereinSeeker", null, 5u, typeof(FreereinServer))] public class FreereinAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaAdornedFalseSon", "Skins.Binma.BinmaAdornedFalseSon", null, 5u, typeof(ProvidenceServer))] public class AdornedFalseSonAchievement : BasePerSurvivorClearUltimaAchievement { protected class ProvidenceServer : BasePerSurvivorClearUltimaServerAchievement { } protected override BodyIndex LookUpRequiredBodyIndex() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return BodyCatalog.FindBodyIndex("FalseSonBody"); } } [RegisterAchievement("BinmaMimikyuDrifter", "Skins.Binma.BinmaMimikyuDrifter", null, 5u, typeof(ProvidenceServer))] public class MimikyuDrifterAchievement : BasePerSurvivorClearUltimaAchievement { protected class ProvidenceServer : BasePerSurvivorClearUltimaServerAchievement { } protected override BodyIndex LookUpRequiredBodyIndex() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return BodyCatalog.FindBodyIndex("DrifterBody"); } } [RegisterAchievement("BinmaSteelConvictionCaptain", "Skins.Binma.BinmaSteelConvictionCaptain", "CompleteMainEnding", 5u, null)] public class SteelCaptainAchievement : BaseAchievement { internal static event Action<UserProfile, StatSheet> OnStatDelta; internal static void RaiseDelta(UserProfile p, StatSheet d) { SteelCaptainAchievement.OnStatDelta?.Invoke(p, d); } protected override BodyIndex LookUpRequiredBodyIndex() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return BodyCatalog.FindBodyIndex("CaptainBody"); } protected override void OnBodyRequirementMet() { ((BaseAchievement)this).OnBodyRequirementMet(); OnStatDelta += Handle; } protected override void OnBodyRequirementBroken() { OnStatDelta -= Handle; ((BaseAchievement)this).OnBodyRequirementBroken(); } private void Handle(UserProfile profile, StatSheet delta) { try { if (profile == ((BaseAchievement)this).userProfile && delta != null) { StatDef val = PerBodyStatDef.killsAgainst.FindStatDef("SuperRoboBallBossBody"); if (val != null && delta.GetStatValueAsDouble(val) > 0.0) { ((BaseAchievement)this).Grant(); } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(UserProfile), "ApplyDeltaStatSheet")] internal static class StatDeltaPatch { private static void Postfix(UserProfile __instance, StatSheet __0) { try { SteelCaptainAchievement.RaiseDelta(__instance, __0); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } public abstract class JudgementAchievement : ServerTrackedAchievement { } public class JudgementServer : BaseServerAchievement { public override void OnInstall() { ((BaseServerAchievement)this).OnInstall(); Ending.onArraignDefeated += Handle; } public override void OnUninstall() { Ending.onArraignDefeated -= Handle; ((BaseServerAchievement)this).OnUninstall(); } private void Handle() { if (base.achievementDef != null && Plugin.JudgementBodies.TryGetValue(base.achievementDef.identifier, out var value) && Util2.PlaysAs(((BaseServerAchievement)this).networkUser, value)) { ((BaseServerAchievement)this).Grant(); } } } [RegisterAchievement("BinmaJudgementCommando", "Skins.Binma.BinmaJudgementCommando", null, 5u, typeof(JudgementServer))] public class JudgementCommando : JudgementAchievement { } [RegisterAchievement("BinmaJudgementHuntress", "Skins.Binma.BinmaJudgementHuntress", null, 5u, typeof(JudgementServer))] public class JudgementHuntress : JudgementAchievement { } [RegisterAchievement("BinmaJudgementAcrid", "Skins.Binma.BinmaJudgementAcrid", null, 5u, typeof(JudgementServer))] public class JudgementAcrid : JudgementAchievement { } [RegisterAchievement("BinmaJudgementLoader", "Skins.Binma.BinmaJudgementLoader", null, 5u, typeof(JudgementServer))] public class JudgementLoader : JudgementAchievement { } [RegisterAchievement("BinmaJudgementEngi", "Skins.Binma.BinmaJudgementEngi", null, 5u, typeof(JudgementServer))] public class JudgementEngi : JudgementAchievement { } [RegisterAchievement("BinmaJudgementMerc", "Skins.Binma.BinmaJudgementMerc", null, 5u, typeof(JudgementServer))] public class JudgementMerc : JudgementAchievement { } [RegisterAchievement("BinmaJudgementBandit", "Skins.Binma.BinmaJudgementBandit", null, 5u, typeof(JudgementServer))] public class JudgementBandit : JudgementAchievement { } [RegisterAchievement("BinmaJudgementArtificer", "Skins.Binma.BinmaJudgementArtificer", null, 5u, typeof(JudgementServer))] public class JudgementArtificer : JudgementAchievement { } [RegisterAchievement("BinmaJudgementDrifter", "Skins.Binma.BinmaJudgementDrifter", null, 5u, typeof(JudgementServer))] public class JudgementDrifter : JudgementAchievement { } internal static class ParentOrder { internal static readonly Dictionary<string, string> Bodies = new Dictionary<string, string>(); internal static readonly Dictionary<string, string> ExtraBodies = new Dictionary<string, string>(); internal static void Init() { foreach (KeyValuePair<string, string> noirBody in Plugin.NoirBodies) { Bodies[noirBody.Key] = noirBody.Value; } foreach (KeyValuePair<string, string> judgementBody in Plugin.JudgementBodies) { Bodies[judgementBody.Key] = judgementBody.Value; } foreach (KeyValuePair<string, string> voidRunBody in Plugin.VoidRunBodies) { Bodies[voidRunBody.Key] = voidRunBody.Value; } Bodies["BinmaMechaFiendDecompile"] = "VoidSurvivorBody"; Bodies["BinmaBiomassFalseSon"] = "FalseSonBody"; Bodies["BinmaFenrisCaptainAtlas"] = "CaptainBody"; Bodies["BinmaSteelConvictionCaptain"] = "CaptainBody"; Bodies["BinmaFenrisRailPyro"] = "RailgunnerBody"; Bodies["BinmaFenrisRailKinetic"] = "RailgunnerBody"; Bodies["BinmaSummerRailgunner"] = "RailgunnerBody"; Bodies["BinmaSolusRailgunnerPurge"] = "RailgunnerBody"; Bodies["BinmaSummerVoidFiend"] = "VoidSurvivorBody"; Bodies["BinmaFreereinSeeker"] = "SeekerBody"; Bodies["BinmaAdornedFalseSon"] = "FalseSonBody"; Bodies["BinmaMimikyuDrifter"] = "DrifterBody"; Bodies["BinmaTF2Engineer"] = "EngiBody"; Bodies["BinmaTF2EngineerMonsoon"] = "EngiBody"; Bodies["BinmaExecutionerTaser"] = "Executioner2Body"; Bodies["BinmaExecutionerConsecration"] = "Executioner2Body"; foreach (KeyValuePair<string, string> body in Dotflare.Bodies) { Bodies[body.Key] = body.Value; } foreach (KeyValuePair<string, string> extraBody in ExtraBodies) { Bodies[extraBody.Key] = extraBody.Value; } RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Apply)); } private static void Apply() { try { int num = 0; foreach (KeyValuePair<string, string> body in Bodies) { AchievementDef def = AchievementManager.GetAchievementDef(body.Key); if (def == null) { continue; } GameObject val = BodyCatalog.FindBodyPrefab(body.Value); SurvivorDef val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : SurvivorCatalog.FindSurvivorDefFromBody(val)); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.unlockableDef == (Object)null) { continue; } AchievementDef achievementDefFromUnlockable = AchievementManager.GetAchievementDefFromUnlockable(val2.unlockableDef.cachedName); if (achievementDefFromUnlockable == null || achievementDefFromUnlockable.identifier == def.identifier || def.prerequisiteAchievementIdentifier == achievementDefFromUnlockable.identifier) { continue; } AchievementDef val3 = ((!string.IsNullOrEmpty(def.prerequisiteAchievementIdentifier)) ? AchievementManager.GetAchievementDef(def.prerequisiteAchievementIdentifier) : null); if (val3 != null && val3.childAchievementIdentifiers != null) { val3.childAchievementIdentifiers = val3.childAchievementIdentifiers.Where((string c) => c != def.identifier).ToArray(); } def.prerequisiteAchievementIdentifier = achievementDefFromUnlockable.identifier; string[] array = achievementDefFromUnlockable.childAchievementIdentifiers ?? new string[0]; if (!array.Contains(def.identifier)) { achievementDefFromUnlockable.childAchievementIdentifiers = array.Concat(new string[1] { def.identifier }).ToArray(); } num++; } MethodInfo methodInfo = AccessTools.Method(typeof(AchievementListPanelController), "BuildAchievementListOrder", (Type[])null, (Type[])null); if (methodInfo != null) { methodInfo.Invoke(null, null); } Plugin.Log.LogInfo((object)("Placed " + num + " skin achievement(s) under their character's unlock.")); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static class SafeGrant { [HarmonyPatch(typeof(BaseServerAchievement), "Grant")] private static class GrantPatch { private static bool Prefix(BaseServerAchievement __instance) { //IL_0095: 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_00c7: Unknown result type (might be due to invalid IL or missing references) try { if (!Handled(__instance.achievementDef)) { return true; } object? value = NetworkUserProp.GetValue(__instance, null); NetworkUser val = (NetworkUser)((value is NetworkUser) ? value : null); if (IsOurs(__instance.achievementDef) && UsesVanillaCheck(__instance) && ParentOrder.Bodies.TryGetValue(__instance.achievementDef.identifier, out var value2) && value2 != null && !Util2.PlaysAs(val, value2)) { return false; } if ((Object)(object)val != (Object)null && NetworkServer.active) { HashSet<string> sent = Sent; NetworkInstanceId netId = ((NetworkBehaviour)val).netId; if (sent.Add(((NetworkInstanceId)(ref netId)).Value + "|" + __instance.achievementDef.identifier)) { NetMessageExtensions.Send((INetMessage)(object)new GrantMessage(((NetworkBehaviour)val).netId, __instance.achievementDef.identifier), (NetworkDestination)1); } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } return false; } } [HarmonyPatch(typeof(ServerAchievementTracker), "CmdSetAchievementTrackerRequests")] private static class TrackPatch { private unsafe static void Postfix(ServerAchievementTracker __instance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_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_0060: Unknown result type (might be due to invalid IL or missing references) GenericStaticEnumerable<AchievementDef, Enumerator> allAchievementDefs = AchievementManager.allAchievementDefs; Enumerator enumerator = allAchievementDefs.GetEnumerator(); try { while (((Enumerator)(ref enumerator)).MoveNext()) { AchievementDef current = ((Enumerator)(ref enumerator)).Current; if (IsOurs(current) && current.serverIndex.intValue >= 0 && !Broken.Contains(current.identifier)) { try { SetTracked.Invoke(__instance, new object[2] { current.serverIndex, true }); } catch (Exception ex) { Broken.Add(current.identifier); Exception ex2 = ex.InnerException ?? ex; Plugin.Log.LogWarning((object)("Skipping multiplayer fix for achievement " + current.identifier + ": " + ex2.GetType().Name + " (" + ex2.Message + ")")); } } } } finally { ((IDisposable)(*(Enumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } } } [HarmonyPatch(typeof(UserAchievementManager), "HandleServerAchievementCompleted")] private static class BlockCompletePatch { private static bool Prefix(ServerAchievementIndex __0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return !Handled(AchievementManager.GetAchievementDef(__0)); } } [HarmonyPatch(typeof(UserAchievementManager), "HandleServerTryToCompleteActivity")] private static class BlockActivityPatch { private static bool Prefix(ServerAchievementIndex __0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return !Handled(AchievementManager.GetAchievementDef(__0)); } } internal static ConfigEntry<bool> AllAchievements; private static readonly HashSet<string> Broken = new HashSet<string>(); private static readonly HashSet<string> Sent = new HashSet<string>(); private static readonly PropertyInfo NetworkUserProp = AccessTools.Property(typeof(BaseServerAchievement), "networkUser"); private static readonly MethodInfo SetTracked = AccessTools.Method(typeof(ServerAchievementTracker), "SetAchievementTracked", (Type[])null, (Type[])null); internal static bool IsOurs(AchievementDef def) { return def != null && def.identifier != null && def.identifier.StartsWith("Binma", StringComparison.Ordinal); } internal static bool Handled(AchievementDef def) { if (def == null) { return false; } return (AllAchievements != null && AllAchievements.Value) || IsOurs(def); } internal static void Init(ConfigFile config) { Run.onRunStartGlobal += delegate { Sent.Clear(); }; AllAchievements = config.Bind<bool>("Multiplayer", "Fix all multiplayer unlocks", true, "Send every multiplayer unlock (vanilla and other mods too) to the right player by name, so players with different mod lists never get the wrong achievement or skin. Everyone in the lobby needs this mod."); NetworkingAPI.RegisterMessageType<GrantMessage>(); } private static bool UsesVanillaCheck(BaseServerAchievement a) { Type baseType = ((object)a).GetType().BaseType; return baseType != null && baseType != typeof(BaseServerAchievement) && baseType.Assembly == typeof(BaseServerAchievement).Assembly; } } internal class GrantMessage : INetMessage, ISerializableObject { private NetworkInstanceId user; private string id; public GrantMessage() { } public GrantMessage(NetworkInstanceId user, string id) { //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) this.user = user; this.id = id; } public void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) writer.Write(user); writer.Write(id); } public void Deserialize(NetworkReader reader) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) user = reader.ReadNetworkId(); id = reader.ReadString(); } public void OnReceived() { //IL_002b: 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) try { foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList) { NetworkUser currentNetworkUser = readOnlyLocalUsers.currentNetworkUser; if (!((Object)(object)currentNetworkUser == (Object)null) && !(((NetworkBehaviour)currentNetworkUser).netId != user)) { AchievementDef achievementDef = AchievementManager.GetAchievementDef(id); UserAchievementManager userAchievementManager = AchievementManager.GetUserAchievementManager(readOnlyLocalUsers); if (achievementDef != null && userAchievementManager != null) { userAchievementManager.GrantAchievement(achievementDef); } } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static class ExtraIds { public const string TF2Engi = "BinmaTF2Engineer"; public const string TF2EngiMonsoon = "BinmaTF2EngineerMonsoon"; public const string Rocket = "BinmaRocketUnlock"; public const string ExeTaser = "BinmaExecutionerTaser"; public const string ExeConsecration = "BinmaExecutionerConsecration"; } internal static class ExtraLocks { internal const int TurretKillGoal = 250; internal const int RocketMultiKill = 6; internal const float RocketWindow = 0.1f; internal const int OverloadingGoal = 10; internal const int FearGoal = 30; private static readonly Dictionary<CharacterMaster, int> turretKills = new Dictionary<CharacterMaster, int>(); private static readonly Dictionary<CharacterMaster, int> overloadingKills = new Dictionary<CharacterMaster, int>(); private static readonly Dictionary<CharacterMaster, int> fearKills = new Dictionary<CharacterMaster, int>(); private static readonly Dictionary<CharacterMaster, float> burstStart = new Dictionary<CharacterMaster, float>(); private static readonly Dictionary<CharacterMaster, int> burstCount = new Dictionary<CharacterMaster, int>(); private static readonly List<BuffIndex> fearBuffs = new List<BuffIndex>(); private static SurvivorDef rocketDef; internal static event Action<string, CharacterMaster> OnGrant; private static void Grant(string id, CharacterMaster m) { Action<string, CharacterMaster> onGrant = ExtraLocks.OnGrant; if (onGrant != null) { try { onGrant(id, m); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static void Define() { Plugin.Define("BinmaTF2Engineer", "Engineer: Silent Pardner", "As Engineer, have your turrets kill " + 250 + " enemies in a single run.", "12GAUGEAWAYFROMFACE_SKIN_TF2ENGISKIN_NAME", "12GAUGEAWAYFROMFACE_SKIN_TF2ENGISKINALTTURRETS_NAME"); Plugin.Define("BinmaTF2EngineerMonsoon", "Engineer: Revengineering", "As Engineer, have your turrets kill Mithrix on Monsoon or harder.", "12GAUGEAWAYFROMFACE_SKIN_TF2ENGISKINMONSOON_NAME", "12GAUGEAWAYFROMFACE_SKIN_TF2ENGISKINMONSOONALTTURRETS_NAME"); Plugin.Define("BinmaRocketUnlock", "Death From Above", "Kill " + 6 + " enemies at once while airborne."); Plugin.Define("BinmaExecutionerTaser", "Executioner: Lightning Rod", "As Executioner, kill " + 10 + " Overloading elites in a single run."); Plugin.Define("BinmaExecutionerConsecration", "Executioner: Last Rites", "As Executioner, kill " + 30 + " Feared enemies in a single run."); } internal static void Init() { Run.onRunStartGlobal += delegate { turretKills.Clear(); overloadingKills.Clear(); fearKills.Clear(); burstStart.Clear(); burstCount.Clear(); }; GlobalEventManager.onCharacterDeathGlobal += OnDeath; } private static int Bump(Dictionary<CharacterMaster, int> d, CharacterMaster m) { d.TryGetValue(m, out var value); return d[m] = value + 1; } private static bool IsTurret(CharacterBody b) { return (Object)(object)b != (Object)null && (((Object)b).name.StartsWith("EngiTurretBody") || ((Object)b).name.StartsWith("EngiWalkerTurretBody")); } private static void OnDeath(DamageReport report) { //IL_004d: 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) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) try { if (!NetworkServer.active || report == null || (Object)(object)report.attackerMaster == (Object)null || (Object)(object)report.victimBody == (Object)null) { return; } CharacterMaster attackerMaster = report.attackerMaster; CharacterBody attackerBody = report.attackerBody; CharacterBody victimBody = report.victimBody; if (report.victimTeamIndex == report.attackerTeamIndex) { return; } if (IsTurret(attackerBody) && (Object)(object)attackerMaster.minionOwnership != (Object)null && (Object)(object)attackerMaster.minionOwnership.ownerMaster != (Object)null) { CharacterMaster ownerMaster = attackerMaster.minionOwnership.ownerMaster; if (Bump(turretKills, ownerMaster) >= 250) { Grant("BinmaTF2Engineer", ownerMaster); } if (((Object)victimBody).name.StartsWith("BrotherHurtBody") && (Object)(object)Run.instance != (Object)null) { DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(Run.instance.selectedDifficulty); if (difficultyDef != null && difficultyDef.scalingValue >= 3f) { Grant("BinmaTF2EngineerMonsoon", ownerMaster); } } } if ((Object)(object)attackerBody != (Object)null && (Object)(object)attackerBody.characterMotor != (Object)null && !attackerBody.characterMotor.isGrounded) { float fixedTime = Time.fixedTime; if (!burstStart.TryGetValue(attackerMaster, out var value) || fixedTime - value > 0.1f) { burstStart[attackerMaster] = fixedTime; burstCount[attackerMaster] = 1; } else if (Bump(burstCount, attackerMaster) >= 6) { Grant("BinmaRocketUnlock", attackerMaster); } } if (victimBody.HasBuff(Buffs.AffixBlue) && Bump(overloadingKills, attackerMaster) >= 10) { Grant("BinmaExecutionerTaser", attackerMaster); } foreach (BuffIndex fearBuff in fearBuffs) { if (!victimBody.HasBuff(fearBuff)) { continue; } if (Bump(fearKills, attackerMaster) >= 30) { Grant("BinmaExecutionerConsecration", attackerMaster); } break; } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } private static void SetIcon(string id, Sprite icon) { if ((Object)(object)icon == (Object)null) { return; } UnlockableDef val = Plugin.Unlockables[id]; if (!((Object)(object)val.achievementIcon != (Object)null)) { val.achievementIcon = icon; AchievementDef achievementDef = AchievementManager.GetAchievementDef(id); if (achievementDef != null) { achievementDef.SetAchievedIcon(icon); } } } private static void LockSkill(string bodyName, string skillToken, string id) { GameObject val = BodyCatalog.FindBodyPrefab(bodyName); if ((Object)(object)val == (Object)null) { return; } bool flag = false; GenericSkill[] components = val.GetComponents<GenericSkill>(); foreach (GenericSkill val2 in components) { SkillFamily skillFamily = val2.skillFamily; if ((Object)(object)skillFamily == (Object)null || skillFamily.variants == null) { continue; } for (int j = 0; j < skillFamily.variants.Length; j++) { SkillDef skillDef = skillFamily.variants[j].skillDef; if (!((Object)(object)skillDef == (Object)null) && !(skillDef.skillNameToken != skillToken)) { UnlockableDef val3 = Plugin.Unlockables[id]; val3.nameToken = skillDef.skillNameToken; skillFamily.variants[j].unlockableDef = val3; SetIcon(id, skillDef.icon); flag = true; Plugin.Log.LogInfo((object)("Locked skill " + skillDef.skillName + " on " + bodyName + ".")); } } } if (!flag) { Plugin.Log.LogWarning((object)("Couldn't find skill " + skillToken + " on " + bodyName + ".")); } } internal static void LockRocket() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)rocketDef == (Object)null) { GameObject val = BodyCatalog.FindBodyPrefab("RocketSurvivorBody"); if ((Object)(object)val == (Object)null) { return; } rocketDef = SurvivorCatalog.FindSurvivorDefFromBody(val); if ((Object)(object)rocketDef == (Object)null) { return; } UnlockableDef val2 = Plugin.Unlockables["BinmaRocketUnlock"]; val2.nameToken = rocketDef.displayNameToken; CharacterBody component = val.GetComponent<CharacterBody>(); Texture2D val3 = (Texture2D)((!((Object)(object)component != (Object)null)) ? null : /*isinst with value type is only supported in some contexts*/); if ((Object)(object)val3 != (Object)null) { SetIcon("BinmaRocketUnlock", Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f))); } } UnlockableDef val4 = Plugin.Unlockables["BinmaRocketUnlock"]; if ((Object)(object)rocketDef.unlockableDef != (Object)(object)val4) { if ((Object)(object)rocketDef.unlockableDef != (Object)null) { Plugin.Log.LogInfo((object)("Replacing Rocket's unlock " + rocketDef.unlockableDef.cachedName + " with ours.")); } rocketDef.unlockableDef = val4; } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } internal static void Attach() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) try { fearBuffs.Clear(); string[] array = new string[3] { "BuffFear", "bdFear", "BuffFearRed" }; foreach (string text in array) { BuffIndex val = BuffCatalog.FindBuffIndex(text); if ((int)val != -1 && !fearBuffs.Contains(val)) { fearBuffs.Add(val); } } if ((Object)(object)BodyCatalog.FindBodyPrefab("Executioner2Body") != (Object)null && fearBuffs.Count == 0) { Plugin.Log.LogWarning((object)"Couldn't find Starstorm 2's Fear buff; Last Rites can't be earned."); } LockSkill("Executioner2Body", "SS2_EXECUTIONER2_TASER_NAME", "BinmaExecutionerTaser"); LockSkill("Executioner2Body", "SS2_EXECUTIONER2_CONSECRATION_NAME", "BinmaExecutionerConsecration"); LockRocket(); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(CharacterSelectController), "Awake")] internal static class RocketLockPatch { private static void Postfix() { ExtraLocks.LockRocket(); } } public class ExtraServer : BaseServerAchievement { private static readonly Dictionary<string, string> bodies = new Dictionary<string, string> { { "BinmaTF2Engineer", "EngiBody" }, { "BinmaTF2EngineerMonsoon", "EngiBody" }, { "BinmaExecutionerTaser", "Executioner2Body" }, { "BinmaExecutionerConsecration", "Executioner2Body" }, { "BinmaRocketUnlock", null } }; public override void OnInstall() { ((BaseServerAchievement)this).OnInstall(); ExtraLocks.OnGrant += Handle; } public override void OnUninstall() { ExtraLocks.OnGrant -= Handle; ((BaseServerAchievement)this).OnUninstall(); } private void Handle(string id, CharacterMaster master) { if (base.achievementDef != null && !(id != base.achievementDef.identifier) && !((Object)(object)((BaseServerAchievement)this).networkUser == (Object)null) && !((Object)(object)((BaseServerAchievement)this).networkUser.master != (Object)(object)master) && bodies.TryGetValue(id, out var value) && (value == null || Util2.PlaysAs(((BaseServerAchievement)this).networkUser, value))) { ((BaseServerAchievement)this).Grant(); } } } [RegisterAchievement("BinmaTF2Engineer", "Skins.Binma.BinmaTF2Engineer", null, 5u, typeof(ExtraServer))] public class TF2EngiAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaTF2EngineerMonsoon", "Skins.Binma.BinmaTF2EngineerMonsoon", null, 5u, typeof(ExtraServer))] public class TF2EngiMonsoonAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaRocketUnlock", "Skins.Binma.BinmaRocketUnlock", null, 5u, typeof(ExtraServer))] public class RocketAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaExecutionerTaser", "Skins.Binma.BinmaExecutionerTaser", null, 5u, typeof(ExtraServer))] public class ExeTaserAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaExecutionerConsecration", "Skins.Binma.BinmaExecutionerConsecration", null, 5u, typeof(ExtraServer))] public class ExeConsecrationAchievement : ServerTrackedAchievement { } internal static class DfIds { public const string DressedToKill = "BinmaDfDressedToKill"; public const string Noble = "BinmaDfNoble"; public const string Shaitan = "BinmaDfShaitan"; public const string Shugoki = "BinmaDfShugoki"; public const string Sherwood = "BinmaDfSherwood"; public const string Lovestruck = "BinmaDfLovestruck"; public const string Shikari = "BinmaDfShikari"; public const string DeepDemon = "BinmaDfDeepDemon"; public const string Grad = "BinmaDfGrad"; public const string Cryopath = "BinmaDfCryopath"; public const string Snowmando = "BinmaDfSnowmando"; public const string Jollymancer = "BinmaDfJollymancer"; public const string LunarDevotee = "BinmaDfLunarDevotee"; } internal static class Dotflare { internal const int ChestGoal = 100; internal const int PodGoal = 5; internal const int FrozenGoal = 25; internal const int LightsOutGoal = 5; internal const int LongShotGoal = 10; internal const float LongShotRange = 50f; internal const float AirTimeGoal = 20f; internal const float HeartGoal = 1000f; internal const int FungusGoal = 6; internal const int ElderGoal = 5; internal static readonly Dictionary<string, string> Bodies = new Dictionary<string, string>(); internal static bool TombsInstalled; internal static bool SummitInstalled; private static readonly HashSet<string> summitScenes = new HashSet<string> { "hollowsummit_wormsworms", "hollowsummitnight_wormsworms" }; private const string TombsScene = "sunkentombs_wormsworms"; private static readonly Dictionary<string, Dictionary<CharacterMaster, int>> counters = new Dictionary<string, Dictionary<CharacterMaster, int>>(); private static readonly Dictionary<CharacterMaster, float> airTime = new Dictionary<CharacterMaster, float>(); private static readonly HashSet<string> eldersDown = new HashSet<string>(); private static float pollTimer; internal static event Action<string, CharacterMaster> OnGrant; private static void Grant(string id, CharacterMaster m) { Action<string, CharacterMaster> onGrant = Dotflare.OnGrant; if (onGrant != null && (Object)(object)m != (Object)null) { try { onGrant(id, m); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } private static void GrantAll(string id) { foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.master)) { Grant(id, instance.master); } } } private static void D(string id, string body, string name, string desc, params string[] tokens) { Plugin.Define(id, name, desc, tokens); Bodies[id] = body; } internal static void Define() { D("BinmaDfDressedToKill", "CommandoBody", "Commando: Made Man", "As Commando, defeat the final boss after earning 8 karma.", "DOTFLARE_SKIN_MOBSTERMANDO_NAME"); D("BinmaDfNoble", "MageBody", "Artificer: Gilded Age", "As Artificer, defeat the prisoner of Gilded Coast.", "DOTFLARE_SKIN_VTIFICER_NAME"); D("BinmaDfShaitan", "MercBody", "Mercenary: Elder Blood", "As Mercenary, discover the hidden chamber in the Abandoned Aqueduct.", "DOTFLARE_SKIN_ARMERC_NAME"); D("BinmaDfShugoki", "MercBody", "Mercenary: Memento Mori", "As Mercenary, defeat what lies beyond the door of Soulbound Threshold.", "DOTFLARE_SKIN_OMERC_NAME"); D("BinmaDfSherwood", "HuntressBody", "Huntress: Bullseye", "As Huntress, kill " + 10 + " enemies from at least " + 50f + " meters away in a single run.", "DOTFLARE_SKIN_MHUNTRESS_NAME"); D("BinmaDfLovestruck", "HuntressBody", "Huntress: Heartthrob", "As Huntress, reach " + 1000f + " maximum health.", "DOTFLARE_SKIN_VAHUNTRESS_NAME"); D("BinmaDfShikari", "HuntressBody", "Huntress: Spirit Hunt", "As Huntress, defeat the final boss after earning 8 karma.", "DOTFLARE_SKIN_VHUNTRESS_NAME"); D("BinmaDfDeepDemon", "VoidSurvivorBody", "「V??oid Fiend』: From the Deep", "As 「V??oid Fiend』, defeat the unique guardian of Siren's Call.", "DOTFLARE_SKIN_DVIEND_NAME"); D("BinmaDfGrad", "ToolbotBody", "MUL-T: Graduation Day", "As MUL-T, defeat the final boss after earning 8 karma.", "DOTFLARE_SKIN_GMULT_NAME"); D("BinmaDfCryopath", "MinerBody", "Miner: Cold Storage", "As Miner, open a Legendary Chest on stage 5.", "DOTFLARE_SKIN_IMINER_NAME"); D("BinmaDfSnowmando", "CommandoBody", "Commando: Unwrapped", "As Commando, open " + 100 + " chests in a single run.", "DOTFLARE_SKIN_SMANDO_NAME"); D("BinmaDfJollymancer", "MageBody", "Artificer: Frosty Reception", "As Artificer, kill " + 25 + " frozen enemies in a single run.", "DOTFLARE_SKIN_XMAGE_NAME"); D("BinmaDfLunarDevotee", "MageBody", "Artificer: Devotion", "As Artificer, defeat the final boss after earning 8 karma.", "DOTFLARE_SKIN_MAGE_CELTIEL_NAME", "DOTFLARE_SKIN_MAGE_CELTIEL_-_HOOD_NAME"); } private static void SetDesc(string id, string desc) { Plugin.Tokens["ACHIEVEMENT_" + id.ToUpperInvariant() + "_DESCRIPTION"] = desc; } internal static void DetectStages() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 TombsInstalled = (int)SceneCatalog.FindSceneIndex("sunkentombs_wormsworms") != -1; foreach (string summitScene in summitScenes) { if ((int)SceneCatalog.FindSceneIndex(summitScene) != -1) { SummitInstalled = true; } } if (Summer.TropicsInstalled && SummitInstalled) { SetDesc("BinmaDfCryopath", "As Miner, open a Legendary Chest on Hollow Summit or Frozen Summit."); } if (TombsInstalled) { SetDesc("BinmaDfDeepDemon", "As 「V??oid Fiend』, defeat the monster locked in the cage on Sunken Tombs."); } RenameMercSkin("DOTFLARE_SKIN_ARMERC_NAME", "Red"); RenameMercSkin("DOTFLARE_SKIN_OMERC_NAME", "Green"); } private static void RenameMercSkin(string token, string suffix) { GameObject val = BodyCatalog.FindBodyPrefab("MercBody"); ModelLocator val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.GetComponent<ModelLocator>()); ModelSkinController val3 = ((!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.modelTransform)) ? null : ((Component)val2.modelTransform).GetComponent<ModelSkinController>()); if (!Object.op_Implicit((Object)(object)val3) || val3.skins == null) { return; } SkinDef[] skins = val3.skins; foreach (SkinDef val4 in skins) { if (Object.op_Implicit((Object)(object)val4) && val4.nameToken == token && !((Object)val4).name.EndsWith(suffix)) { ((Object)val4).name = ((Object)val4).name + suffix; } } } private static string Scene() { SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef; return (!Object.op_Implicit((Object)(object)mostRecentSceneDef)) ? "" : mostRecentSceneDef.cachedName; } private static bool SummitStage() { SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef; if (!Object.op_Implicit((Object)(object)mostRecentSceneDef)) { return false; } if (SummitInstalled) { return summitScenes.Contains(mostRecentSceneDef.cachedName); } return mostRecentSceneDef.stageOrder == 5; } private static int Bump(string key, CharacterMaster m) { if (!counters.TryGetValue(key, out var value)) { value = (counters[key] = new Dictionary<CharacterMaster, int>()); } value.TryGetValue(m, out var value2); return value[m] = value2 + 1; } internal static void Init() { Run.onRunStartGlobal += delegate { counters.Clear(); airTime.Clear(); }; Stage.onServerStageBegin += delegate { eldersDown.Clear(); }; GlobalEventManager.onCharacterDeathGlobal += OnDeath; GlobalEventManager.OnInteractionsGlobal += OnInteract; Summer.OnAnyLegendaryOpened += OnLegendary; RoR2Application.onFixedUpdate += delegate { try { Poll(); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } }; } private static void OnLegendary(CharacterMaster m) { if (SummitStage()) { Grant("BinmaDfCryopath", m); } } private static void OnInteract(Interactor interactor, IInteractable interactable, GameObject obj) { try { if (NetworkServer.active && Object.op_Implicit((Object)(object)obj)) { CharacterMaster val = Noir.MasterOf(interactor); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)obj.GetComponent<ChestBehavior>()) && Bump("chests", val) >= 100) { Grant("BinmaDfSnowmando", val); } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } private static void OnDeath(DamageReport r) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) try { if (!NetworkServer.active || r == null || !Object.op_Implicit((Object)(object)r.victimBody)) { return; } CharacterBody victimBody = r.victimBody; string name = ((Object)victimBody).name; bool flag = (int)r.victimTeamIndex != 1; if (flag && name.StartsWith("TitanGoldBody")) { GrantAll("BinmaDfNoble"); } if (flag && name.StartsWith("SuperRoboBallBossBody") && !TombsInstalled) { GrantAll("BinmaDfDeepDemon"); } if (flag && name.StartsWith("STWormCrocoMonsterBody") && Scene() == "sunkentombs_wormsworms") { GrantAll("BinmaDfDeepDemon"); } if (flag && Scene() == "goolake" && name.StartsWith("LemurianBruiserBody") && Object.op_Implicit((Object)(object)r.victimMaster)) { string name2 = ((Object)r.victimMaster).name; if (name2.Contains("Fire")) { eldersDown.Add("fire"); } if (name2.Contains("Ice")) { eldersDown.Add("ice"); } if (eldersDown.Count >= 2) { GrantAll("BinmaDfShaitan"); } } CharacterMaster attackerMaster = r.attackerMaster; CharacterBody attackerBody = r.attackerBody; if (!Object.op_Implicit((Object)(object)attackerMaster) || r.attackerTeamIndex == r.victimTeamIndex) { return; } if (Object.op_Implicit((Object)(object)victimBody.healthComponent) && victimBody.healthComponent.isInFrozenState && Bump("frozen", attackerMaster) >= 25) { Grant("BinmaDfJollymancer", attackerMaster); } if (Object.op_Implicit((Object)(object)attackerBody)) { Vector3 val = attackerBody.corePosition - victimBody.corePosition; if (((Vector3)(ref val)).sqrMagnitude >= 2500f && Bump("longshot", attackerMaster) >= 10) { Grant("BinmaDfSherwood", attackerMaster); } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } private static bool HasEquip(Inventory inv, EquipmentIndex idx) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0033: 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) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if ((int)idx == -1) { return false; } if (inv.currentEquipmentIndex == idx || inv.alternateEquipmentIndex == idx) { return true; } int equipmentSlotCount = inv.GetEquipmentSlotCount(); for (uint num = 0u; num < equipmentSlotCount; num++) { if (inv.GetEquipment(num).equipmentIndex == idx) { return true; } } return false; } private static void Poll() { if (!NetworkServer.active || (Object)(object)Run.instance == (Object)null) { return; } float fixedDeltaTime = Time.fixedDeltaTime; pollTimer += fixedDeltaTime; bool flag = pollTimer >= 0.5f; if (flag) { pollTimer = 0f; } foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterMaster val = ((!Object.op_Implicit((Object)(object)instance)) ? null : instance.master); CharacterBody val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.GetBody()); if (!Object.op_Implicit((Object)(object)val2)) { if (Object.op_Implicit((Object)(object)val)) { airTime.Remove(val); } } else if (flag && val2.maxHealth >= 1000f) { Grant("BinmaDfLovestruck", val); } } } } public class DotflareServer : BaseServerAchievement { public override void OnInstall() { ((BaseServerAchievement)this).OnInstall(); Dotflare.OnGrant += Handle; } public override void OnUninstall() { Dotflare.OnGrant -= Handle; ((BaseServerAchievement)this).OnUninstall(); } private void Handle(string id, CharacterMaster master) { if (base.achievementDef != null && !(id != base.achievementDef.identifier) && !((Object)(object)((BaseServerAchievement)this).networkUser == (Object)null) && !((Object)(object)((BaseServerAchievement)this).networkUser.master != (Object)(object)master) && Dotflare.Bodies.TryGetValue(id, out var value) && Util2.PlaysAs(((BaseServerAchievement)this).networkUser, value)) { ((BaseServerAchievement)this).Grant(); } } } [RegisterAchievement("BinmaDfNoble", "Skins.Binma.BinmaDfNoble", null, 5u, typeof(DotflareServer))] public class DfNobleAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaDfShaitan", "Skins.Binma.BinmaDfShaitan", null, 5u, typeof(DotflareServer))] public class DfShaitanAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaDfSherwood", "Skins.Binma.BinmaDfSherwood", null, 5u, typeof(DotflareServer))] public class DfSherwoodAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaDfLovestruck", "Skins.Binma.BinmaDfLovestruck", null, 5u, typeof(DotflareServer))] public class DfLovestruckAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaDfDeepDemon", "Skins.Binma.BinmaDfDeepDemon", "CompleteVoidEnding", 5u, typeof(DotflareServer))] public class DfDeepDemonAchievement : ServerTrackedAchievement { } [RegisterAchievement("BinmaDfCryopath", "Skins.Binma.BinmaDfCryopath", null,