using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using EntityStates; using EntityStates.Drifter; using HG.Reflection; using Microsoft.CodeAnalysis; using On.EntityStates.Drifter; using On.RoR2; using On.RoR2.Skills; using RoR2; using RoR2.EntitlementManagement; using RoR2.Skills; using UnityEngine; using UnityEngine.AddressableAssets; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NewGenSkillSwapper")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+040d4e6ebae57843f8c9a778bd0a85ce04e480cd")] [assembly: AssemblyProduct("NewGenSkillSwapper")] [assembly: AssemblyTitle("NewGenSkillSwapper")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NewGenSkillSwapper { public class ExtraSkillSlotsCompat { public static bool IsEnabled() { return false; } } [BepInPlugin("acanthi.RailgunnerTinker", "RailgunnerTinker", "1.0.0")] public class NewGenSkillSwapper : BaseUnityPlugin { public class SkillSwapConfig { public string skillName; public string survivorName; public string family; } public const string PluginGUID = "acanthi.RailgunnerTinker"; public const string PluginAuthor = "acanthi"; public const string PluginName = "RailgunnerTinker"; public const string PluginVersion = "1.0.0"; public static List skillSwapConfig = new List(); public static ConfigEntry skillsToSwap; public static ConfigEntry debugMode; public void ParseConfig() { skillsToSwap = ((BaseUnityPlugin)this).Config.Bind("RailgunnerTinker", "skillsToSwap", "(Tinker,Railgunner,special),(PassiveStatsFromScrap,Railgunner,passive),(Tinker,Swarmling,special)", "This should NOT be touched if you don't know what you're doing. Theoretically you could use this to add Tinker to more survivors but it's not a supported feature. Here be Dragons! A list of skills to swap. Should be formatted like this: (skillDefName,survivorDefName,family),(otherSkillDefName,otherSurvivorDefName,otherFamily)"); debugMode = ((BaseUnityPlugin)this).Config.Bind("RailgunnerTinker", "debugMode", false, "Prints all names for skills and survivors."); Debug.Log((object)"Parsing Config..."); string[] array = skillsToSwap.Value.Trim().Split("),("); string[] array2 = array; string[] array3 = array2; foreach (string text in array3) { Debug.Log((object)text); string text2 = text.Trim('(', ')'); string[] array4 = text2.Split(','); skillSwapConfig.Add(new SkillSwapConfig { skillName = array4[0], survivorName = array4[1], family = array4[2] }); } } public static void PrintDebug() { if (debugMode.Value) { Debug.Log((object)"Printing skill names... Disable debugMode in config to disable this!"); foreach (SkillDef allSkillDef in SkillCatalog.allSkillDefs) { Debug.Log((object)(allSkillDef.skillName + " || Token (for reference, dont use!): " + allSkillDef.skillNameToken)); } Debug.Log((object)"Printing survivor names... Disable debugMode in config to disable this!"); { foreach (SurvivorDef allSurvivorDef in SurvivorCatalog.allSurvivorDefs) { Debug.Log((object)allSurvivorDef.cachedName); } return; } } Debug.Log((object)"Skipping logs..."); } public static void MatchConfig() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown foreach (SkillSwapConfig item in skillSwapConfig) { int num = SkillCatalog.FindSkillIndexByName(item.skillName); if (num == -1) { Debug.Log((object)"Couldn't find skill. Skipping..."); continue; } SkillDef skillDef = SkillCatalog.GetSkillDef(num); SurvivorDef val = SurvivorCatalog.FindSurvivorDef(item.survivorName); if (!Object.op_Implicit((Object)(object)skillDef) || !Object.op_Implicit((Object)(object)val)) { Debug.Log((object)"Couldn't add skill. Skipping..."); continue; } SkillLocator component = val.bodyPrefab.GetComponent(); if (!Object.op_Implicit((Object)component)) { Debug.Log((object)("No SkillLocator on " + val.cachedName + "!")); continue; } switch (item.family.ToLower()) { case "primary": { SkillFamily skillFamily = component.primary.skillFamily; ApplySkillFamilyResize(skillFamily, skillDef); break; } case "secondary": { SkillFamily skillFamily = component.secondary.skillFamily; ApplySkillFamilyResize(skillFamily, skillDef); break; } case "utility": { SkillFamily skillFamily = component.utility.skillFamily; ApplySkillFamilyResize(skillFamily, skillDef); break; } case "special": { SkillFamily skillFamily = component.special.skillFamily; ApplySkillFamilyResize(skillFamily, skillDef); break; } case "passive": { GenericSkill[] componentsInChildren = val.bodyPrefab.GetComponentsInChildren(); foreach (GenericSkill val2 in componentsInChildren) { if (((Object)val2._skillFamily).name.Contains(val.cachedName + "Passive") || ((Object)val2._skillFamily).name.Contains(val.cachedName + "BodyPassive")) { SkillFamily skillFamily2 = val2._skillFamily; ApplySkillFamilyResize(skillFamily2, skillDef); } } break; } case "extrafirst": if (!ExtraSkillSlotsCompat.IsEnabled()) { Debug.Log((object)"ExtraSkillSlots entry detected, but EntrySkillSlots not installed or unsupported?"); } break; case "extrasecond": if (!ExtraSkillSlotsCompat.IsEnabled()) { Debug.Log((object)"ExtraSkillSlots entry detected, but EntrySkillSlots not installed or unsupported?"); } break; case "extrathird": if (!ExtraSkillSlotsCompat.IsEnabled()) { Debug.Log((object)"ExtraSkillSlots entry detected, but EntrySkillSlots not installed or unsupported?"); } break; case "extrafourth": if (!ExtraSkillSlotsCompat.IsEnabled()) { Debug.Log((object)"ExtraSkillSlots entry detected, but EntrySkillSlots not installed or unsupported?"); } break; default: Debug.LogError((object)("Family is not set for " + item.skillName + ", " + item.survivorName + "!")); break; } DrifterSkills.MatchConfig_DrifterExtension(val.bodyPrefab); } } private static void ApplySkillFamilyResize(SkillFamily skillFamily, SkillDef skillDef) { //IL_0029: 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_004b: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1); Variant[] variants = skillFamily.variants; int num = skillFamily.variants.Length - 1; Variant val = new Variant { skillDef = skillDef }; ((Variant)(ref val)).viewableNode = new Node(skillDef.skillNameToken, false, (Node)null); variants[num] = val; } private void Awake() { ParseConfig(); DrifterSkills.Init(); } [SystemInitializer(new Type[] { typeof(SkillCatalog), typeof(SurvivorCatalog) })] public static void Init() { PrintDebug(); MatchConfig(); } } public class DrifterSkills { [CompilerGenerated] private static class <>O { public static hook_HasRequiredJunk <0>__DrifterSkillDef_HasRequiredJunk; public static hook_HasRequiredJunk <1>__DrifterTrackingSkillDef_HasRequiredJunk; public static hook_OnExecute <2>__DrifterTrackingSkillDef_OnExecute; public static hook_OnExecute <3>__DrifterSkillDef_OnExecute; public static hook_OnEnter <4>__CastTinker_OnEnter; public static hook_Awake <5>__DrifterTracker_Awake; public static hook_Start <6>__DrifterTrashToTreasureController_Start; } public static EntitlementDef alloyedCollectiveEntitlement; public static SkillDef tinkerDef; public static SkillDef treasureDef; private static bool configInitialized; public static void Init() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown alloyedCollectiveEntitlement = Addressables.LoadAssetAsync((object)"RoR2/DLC3/entitlementDLC3.asset").WaitForCompletion(); tinkerDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("tinker")); treasureDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("PassiveStatsFromScrap")); object obj = <>O.<0>__DrifterSkillDef_HasRequiredJunk; if (obj == null) { hook_HasRequiredJunk val = DrifterSkillDef_HasRequiredJunk; <>O.<0>__DrifterSkillDef_HasRequiredJunk = val; obj = (object)val; } DrifterSkillDef.HasRequiredJunk += (hook_HasRequiredJunk)obj; object obj2 = <>O.<1>__DrifterTrackingSkillDef_HasRequiredJunk; if (obj2 == null) { hook_HasRequiredJunk val2 = DrifterTrackingSkillDef_HasRequiredJunk; <>O.<1>__DrifterTrackingSkillDef_HasRequiredJunk = val2; obj2 = (object)val2; } DrifterTrackingSkillDef.HasRequiredJunk += (hook_HasRequiredJunk)obj2; object obj3 = <>O.<2>__DrifterTrackingSkillDef_OnExecute; if (obj3 == null) { hook_OnExecute val3 = DrifterTrackingSkillDef_OnExecute; <>O.<2>__DrifterTrackingSkillDef_OnExecute = val3; obj3 = (object)val3; } DrifterTrackingSkillDef.OnExecute += (hook_OnExecute)obj3; object obj4 = <>O.<3>__DrifterSkillDef_OnExecute; if (obj4 == null) { hook_OnExecute val4 = DrifterSkillDef_OnExecute; <>O.<3>__DrifterSkillDef_OnExecute = val4; obj4 = (object)val4; } DrifterSkillDef.OnExecute += (hook_OnExecute)obj4; object obj5 = <>O.<4>__CastTinker_OnEnter; if (obj5 == null) { hook_OnEnter val5 = CastTinker_OnEnter; <>O.<4>__CastTinker_OnEnter = val5; obj5 = (object)val5; } CastTinker.OnEnter += (hook_OnEnter)obj5; object obj6 = <>O.<5>__DrifterTracker_Awake; if (obj6 == null) { hook_Awake val6 = DrifterTracker_Awake; <>O.<5>__DrifterTracker_Awake = val6; obj6 = (object)val6; } DrifterTracker.Awake += (hook_Awake)obj6; object obj7 = <>O.<6>__DrifterTrashToTreasureController_Start; if (obj7 == null) { hook_Start val7 = DrifterTrashToTreasureController_Start; <>O.<6>__DrifterTrashToTreasureController_Start = val7; obj7 = (object)val7; } DrifterTrashToTreasureController.Start += (hook_Start)obj7; } private static void DrifterTrashToTreasureController_Start(orig_Start orig, DrifterTrashToTreasureController self) { Debug.Log((object)"Goont"); CharacterBody val = default(CharacterBody); if (!((Component)self).TryGetComponent(ref val)) { Debug.Log((object)"Goont returning"); return; } treasureDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("PassiveStatsFromScrap")); GenericSkill[] componentsInChildren = ((Component)val).GetComponentsInChildren(); foreach (GenericSkill val2 in componentsInChildren) { Debug.Log((object)((Object)val2._skillFamily).name); if (((Object)val2._skillFamily).name.Contains(((Object)val).name.Replace("Body", "") + "Passive") || ((Object)val2._skillFamily).name.Contains(((Object)val).name.Replace("Body", "") + "BodyPassive")) { SkillFamily skillFamily = val2._skillFamily; if ((Object)(object)val2.skillDef != (Object)(object)treasureDef) { ((Behaviour)self).enabled = false; return; } } } PlayerCharacterMasterController val3 = default(PlayerCharacterMasterController); PlayerCharacterMasterControllerEntitlementTracker val4 = default(PlayerCharacterMasterControllerEntitlementTracker); if (((Component)val.master).TryGetComponent(ref val3) && ((Component)val3).TryGetComponent(ref val4)) { if ((Object)(object)val4 == (Object)null) { Debug.Log((object)"RailgunnerTweaks - Exiting TrashToTreasure because entitlement couldn't be verified."); ((Behaviour)self).enabled = false; return; } if (!val4.HasEntitlement(alloyedCollectiveEntitlement)) { Debug.Log((object)"RailgunnerTweaks - Exiting TrashToTreasure because player did not pass entitlement."); ((Behaviour)self).enabled = false; return; } } orig.Invoke(self); } private static void DrifterTracker_Awake(orig_Awake orig, DrifterTracker self) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) self.rerollTrackingPrefab = Addressables.LoadAssetAsync((object)"RoR2/DLC3/Drifter/TinkerIndicatorReroll.prefab").WaitForCompletion(); self.breakTrackingPrefab = Addressables.LoadAssetAsync((object)"RoR2/DLC3/Drifter/TinkerIndicatorBreak.prefab").WaitForCompletion(); self.invalidTrackingPrefab = Addressables.LoadAssetAsync((object)"RoR2/DLC3/Drifter/TinkerIndicatorBad.prefab").WaitForCompletion(); orig.Invoke(self); } public static void MatchConfig_DrifterExtension(GameObject body) { SkillLocator val = default(SkillLocator); if (!body.TryGetComponent(ref val)) { return; } GenericSkill[] array = (GenericSkill[])(object)new GenericSkill[4] { val.primary, val.secondary, val.utility, val.special }; GenericSkill val2 = null; GenericSkill[] array2 = array; foreach (GenericSkill val3 in array2) { if ((Object)(object)val3.skillDef == (Object)(object)tinkerDef) { val2 = val3; break; } } if ((Object)(object)val2 != (Object)null) { DrifterTracker val4 = (Object.op_Implicit((Object)(object)body.gameObject.GetComponent()) ? body.gameObject.GetComponent() : body.gameObject.AddComponent()); val4.skillInstance = val2; } GenericSkill val5 = null; GenericSkill[] componentsInChildren = body.GetComponentsInChildren(); foreach (GenericSkill val6 in componentsInChildren) { if (((Object)val6._skillFamily).name.Contains(((Object)body.GetComponent()).name.Replace("Body", "") + "Passive") || ((Object)val6._skillFamily).name.Contains(((Object)body.GetComponent()).name.Replace("Body", "") + "BodyPassive")) { SkillFamily skillFamily = val6._skillFamily; if ((Object)(object)val6.skillDef == (Object)(object)treasureDef) { val5 = val6; } } } if ((Object)(object)val5 != (Object)null) { if (!Object.op_Implicit((Object)(object)body.gameObject.GetComponent())) { DrifterTrashToTreasureController val7 = body.gameObject.AddComponent(); } else { DrifterTrashToTreasureController val7 = body.gameObject.GetComponent(); } } } private static void CastTinker_OnEnter(orig_OnEnter orig, CastTinker self) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (((Object)((Component)((EntityState)self).characterBody).gameObject).name.Contains("DrifterBody")) { return; } PlayerCharacterMasterController val = default(PlayerCharacterMasterController); PlayerCharacterMasterControllerEntitlementTracker val2 = default(PlayerCharacterMasterControllerEntitlementTracker); if (((Component)((EntityState)self).characterBody).TryGetComponent(ref val) && ((Component)val).TryGetComponent(ref val2)) { if ((Object)(object)val2 == (Object)null) { Debug.Log((object)"RailgunnerTweaks - Exiting CastTinker_OnEnter because entitlement couldn't be verified."); return; } if (!val2.HasEntitlement(alloyedCollectiveEntitlement)) { Debug.Log((object)"RailgunnerTweaks - Exiting CastTinker_OnEnter because player did not pass entitlement."); return; } } ((GenericProjectileBaseState)self).FireProjectile(); ((GenericProjectileBaseState)self).DoFireEffects(); } private static void DrifterTrackingSkillDef_OnExecute(orig_OnExecute orig, DrifterTrackingSkillDef self, GenericSkill skillSlot) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown InstanceData val = (InstanceData)skillSlot.skillInstanceData; skillSlot.stateMachine.SetInterruptState(((SkillDef)self).InstantiateNextState(skillSlot), ((SkillDef)self).interruptPriority); if (!Object.op_Implicit((Object)val.junkController)) { skillSlot.stock -= ((SkillDef)self).stockToConsume; if (((SkillDef)self).cancelSprintingOnActivation) { skillSlot.characterBody.isSprinting = false; } if (((SkillDef)self).resetCooldownTimerOnUse) { skillSlot.rechargeStopwatch = 0f; } if (Object.op_Implicit((Object)skillSlot.characterBody)) { skillSlot.characterBody.OnSkillActivated(skillSlot); } } else { orig.Invoke(self, skillSlot); } } private static void DrifterSkillDef_OnExecute(orig_OnExecute orig, DrifterSkillDef self, GenericSkill skillSlot) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown InstanceData val = (InstanceData)skillSlot.skillInstanceData; skillSlot.stateMachine.SetInterruptState(((SkillDef)self).InstantiateNextState(skillSlot), ((SkillDef)self).interruptPriority); if (!Object.op_Implicit((Object)val.junkController)) { skillSlot.stock -= ((SkillDef)self).stockToConsume; if (((SkillDef)self).cancelSprintingOnActivation) { skillSlot.characterBody.isSprinting = false; } if (((SkillDef)self).resetCooldownTimerOnUse) { skillSlot.rechargeStopwatch = 0f; } if (Object.op_Implicit((Object)skillSlot.characterBody)) { skillSlot.characterBody.OnSkillActivated(skillSlot); } } else { orig.Invoke(self, skillSlot); } } private static bool DrifterSkillDef_HasRequiredJunk(orig_HasRequiredJunk orig, DrifterSkillDef self, GenericSkill skillSlot) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown InstanceData val = (InstanceData)skillSlot.skillInstanceData; if (!Object.op_Implicit((Object)val.junkController)) { return true; } return orig.Invoke(self, skillSlot); } private static bool DrifterTrackingSkillDef_HasRequiredJunk(orig_HasRequiredJunk orig, DrifterTrackingSkillDef self, GenericSkill skillSlot) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)((Component)skillSlot.characterBody).gameObject.GetComponent())) { ((Component)skillSlot.characterBody).gameObject.AddComponent(); } InstanceData val = (InstanceData)skillSlot.skillInstanceData; if (!Object.op_Implicit((Object)val.junkController)) { return true; } return orig.Invoke(self, skillSlot); } } }