using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using EntityStates; using HG; using HG.Coroutines; using HG.Reflection; using HarmonyLib; using IL.RoR2; using IL.RoR2.Orbs; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using On.EntityStates; using On.RoR2; using R2API.AutoVersionGen; using R2API.SkinsAPI.Interop; using R2API.Utils; using RoR2; using RoR2.AddressableAssets; using RoR2.ContentManagement; using RoR2.Orbs; using RoR2.Projectile; using RoR2.Skills; using RoR2.SurvivorMannequins; using RoR2.UI.MainMenu; using Unity.Collections; using Unity.Jobs; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("R2API.Skins")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.7.0")] [assembly: AssemblyInformationalVersion("1.4.7+c6f4f4413f610d6c7f11bdd61955aa5c78dac091")] [assembly: AssemblyProduct("R2API.Skins")] [assembly: AssemblyTitle("R2API.Skins")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.7.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class MemberNotNullAttribute : Attribute { public string[] Members { get; } public MemberNotNullAttribute(string member) { Members = new string[1] { member }; } public MemberNotNullAttribute(params string[] members) { Members = members; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class MemberNotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public string[] Members { get; } public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; Members = new string[1] { member }; } public MemberNotNullWhenAttribute(bool returnValue, params string[] members) { ReturnValue = returnValue; Members = members; } } } namespace R2API { internal struct IconTexJob : IJobParallelFor { [ReadOnly] public Color32 Top; [ReadOnly] public Color32 Right; [ReadOnly] public Color32 Bottom; [ReadOnly] public Color32 Left; [ReadOnly] public Color32 Line; public NativeArray TexOutput; public void Execute(int index) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) int num = index % 128 - 64; int num2 = index / 128 - 64; if (Math.Abs(Math.Abs(num2) - Math.Abs(num)) <= 2) { TexOutput[index] = Line; } else if (num2 > num && num2 > -num) { TexOutput[index] = Top; } else if (num2 < num && num2 < -num) { TexOutput[index] = Bottom; } else if (num2 > num && num2 < -num) { TexOutput[index] = Left; } else if (num2 < num && num2 > -num) { TexOutput[index] = Right; } } } public class SkinCustomGameobjectComponent : MonoBehaviour { [Tooltip("CharacterModel of a character this object is instantiating to for custom uses. This field is null in Awake and first OnEnable")] [HideInInspector] public CharacterModel characterModel; [Tooltip("RendererInfos that will be added to CharacterModel.baseRendererInfos")] public RendererInfo[] extraRendererInfos; [Tooltip("LightInfos that will be added to CharacterModel.baseLightInfos")] public LightInfo[] extraLightInfos; } public struct SkinDefParamsInfo { public string Name; public string NameToken; public Sprite? Icon; public UnlockableDef? UnlockableDef; public GameObject? RootObject; public SkinDef?[]? BaseSkins; public SkinDefParams? SkinDefParams; public RendererInfo[]? RendererInfos; public MeshReplacement[]? MeshReplacements; public GameObjectActivation[]? GameObjectActivations; public ProjectileGhostReplacement[]? ProjectileGhostReplacements; public MinionSkinReplacement[]? MinionSkinReplacements; } [Obsolete] public struct SkinDefInfo { [Obsolete] public SkinDef?[]? BaseSkins; [Obsolete] public Sprite? Icon; [Obsolete] public string? NameToken; [Obsolete] public UnlockableDef? UnlockableDef; [Obsolete] public GameObject? RootObject; [Obsolete] public RendererInfo[]? RendererInfos; [Obsolete] public MeshReplacement[]? MeshReplacements; [Obsolete] public GameObjectActivation[]? GameObjectActivations; [Obsolete] public ProjectileGhostReplacement[]? ProjectileGhostReplacements; [Obsolete] public MinionSkinReplacement[]? MinionSkinReplacements; [Obsolete] public string? Name; public static implicit operator SkinDefParamsInfo(SkinDefInfo orig) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) SkinDefParamsInfo skinDefParamsInfo = default(SkinDefParamsInfo); skinDefParamsInfo.BaseSkins = orig.BaseSkins; skinDefParamsInfo.Icon = orig.Icon; skinDefParamsInfo.NameToken = orig.NameToken; skinDefParamsInfo.UnlockableDef = orig.UnlockableDef; skinDefParamsInfo.RootObject = orig.RootObject; skinDefParamsInfo.RendererInfos = orig.RendererInfos; skinDefParamsInfo.Name = orig.Name; SkinDefParamsInfo result = skinDefParamsInfo; if (orig.GameObjectActivations != null) { result.GameObjectActivations = (GameObjectActivation[]?)(object)new GameObjectActivation[orig.GameObjectActivations.Length]; for (int i = 0; i < orig.GameObjectActivations.Length; i++) { result.GameObjectActivations[i] = GameObjectActivation.op_Implicit(orig.GameObjectActivations[i]); } } if (orig.MeshReplacements != null) { result.MeshReplacements = (MeshReplacement[]?)(object)new MeshReplacement[orig.MeshReplacements.Length]; for (int j = 0; j < orig.MeshReplacements.Length; j++) { result.MeshReplacements[j] = MeshReplacement.op_Implicit(orig.MeshReplacements[j]); } } if (orig.ProjectileGhostReplacements != null) { result.ProjectileGhostReplacements = (ProjectileGhostReplacement[]?)(object)new ProjectileGhostReplacement[orig.ProjectileGhostReplacements.Length]; for (int k = 0; k < orig.ProjectileGhostReplacements.Length; k++) { result.ProjectileGhostReplacements[k] = ProjectileGhostReplacement.op_Implicit(orig.ProjectileGhostReplacements[k]); } } if (orig.MinionSkinReplacements != null) { result.MinionSkinReplacements = (MinionSkinReplacement[]?)(object)new MinionSkinReplacement[orig.MinionSkinReplacements.Length]; for (int l = 0; l < orig.MinionSkinReplacements.Length; l++) { result.MinionSkinReplacements[l] = MinionSkinReplacement.op_Implicit(orig.MinionSkinReplacements[l]); } } return result; } } public static class SkinIDRS { [CompilerGenerated] private static class <>O { public static hook_ApplySkinAsync <0>__SetCustomIDRS; } [CompilerGenerated] private sealed class d__9 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ItemDisplayRuleSet idrs; public Dictionary overrides; private IEnumerator 5__2; private int 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__3 = 0; goto IL_00aa; case 1: <>1__state = -1; 5__3++; goto IL_00aa; case 2: { <>1__state = -1; break; } IL_00aa: if (5__3 < 1000) { bool flag = false; KeyAssetRuleGroup[] keyAssetRuleGroups = idrs.keyAssetRuleGroups; foreach (KeyAssetRuleGroup val in keyAssetRuleGroups) { if (!Object.op_Implicit(val.keyAsset)) { IDRSKeyAssetReference keyAssetAddress = val.keyAssetAddress; if (keyAssetAddress != null && ((AssetReference)keyAssetAddress).RuntimeKeyIsValid()) { flag = true; break; } } } if (flag) { <>2__current = (object)new WaitForSecondsRealtime(0.25f); <>1__state = 1; return true; } } foreach (KeyValuePair @override in overrides) { idrs.SetDisplayRuleGroup(@override.Key, @override.Value); } 5__2 = idrs.GenerateRuntimeValuesAsync(); break; } if (5__2.MoveNext()) { <>2__current = 5__2.Current; <>1__state = 2; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly Dictionary skinToIDRS = new Dictionary(); private static readonly Dictionary> skinIDRSOverrides = new Dictionary>(); private static bool hooksSet = false; private static bool initialized = false; internal static void SetHooks() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if (!hooksSet) { hooksSet = true; object obj = <>O.<0>__SetCustomIDRS; if (obj == null) { hook_ApplySkinAsync val = SetCustomIDRS; <>O.<0>__SetCustomIDRS = val; obj = (object)val; } ModelSkinController.ApplySkinAsync += (hook_ApplySkinAsync)obj; } } internal static void UnsetHooks() { //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_0021: Expected O, but got Unknown hooksSet = false; object obj = <>O.<0>__SetCustomIDRS; if (obj == null) { hook_ApplySkinAsync val = SetCustomIDRS; <>O.<0>__SetCustomIDRS = val; obj = (object)val; } ModelSkinController.ApplySkinAsync -= (hook_ApplySkinAsync)obj; } public static bool AddPair(SkinDef skinDef, ItemDisplayRuleSet ruleSet) { SetHooks(); if (initialized) { SkinsPlugin.Logger.LogInfo((object)$"Cannot add pair {skinDef} && {ruleSet} as the SkinIDRS has already initialized."); return false; } if (skinToIDRS.ContainsKey(skinDef)) { SkinsPlugin.Logger.LogInfo((object)$"Cannot add pair {skinDef} && {ruleSet}, the skin {skinDef} already has an entry associated to it."); return false; } skinToIDRS[skinDef] = ruleSet; return true; } public static bool AddGroupOverride(SkinDef skinDef, Object keyAsset, DisplayRuleGroup displayRuleGroup) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) SetHooks(); if (initialized) { SkinsPlugin.Logger.LogInfo((object)"Cannot add group SkinIDRS has already initialized."); return false; } if (!skinIDRSOverrides.TryGetValue(skinDef, out Dictionary value)) { value = (skinIDRSOverrides[skinDef] = new Dictionary()); } value[keyAsset] = displayRuleGroup; return true; } [InitDuringStartupPhase(/*Could not decode attribute arguments.*/)] private static void SystemInit() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) initialized = true; ParallelCoroutine val = new ParallelCoroutine(); ModelLocator val2 = default(ModelLocator); CharacterModel val3 = default(CharacterModel); foreach (CharacterBody allBodyPrefabBodyBodyComponent in BodyCatalog.allBodyPrefabBodyBodyComponents) { if (!Object.op_Implicit((Object)(object)allBodyPrefabBodyBodyComponent) || !((Component)allBodyPrefabBodyBodyComponent).TryGetComponent(ref val2) || !Object.op_Implicit((Object)(object)val2.modelTransform) || !((Component)val2.modelTransform).TryGetComponent(ref val3)) { continue; } ItemDisplayRuleSet itemDisplayRuleSet = val3.itemDisplayRuleSet; SkinDef[] bodySkinDefs = SkinCatalog.GetBodySkinDefs(allBodyPrefabBodyBodyComponent.bodyIndex); foreach (SkinDef key in bodySkinDefs) { if (!skinIDRSOverrides.TryGetValue(key, out Dictionary value)) { if (!skinToIDRS.ContainsKey(key)) { skinToIDRS[key] = itemDisplayRuleSet; } continue; } if (!skinToIDRS.TryGetValue(key, out ItemDisplayRuleSet value2)) { value2 = (skinToIDRS[key] = (Object.op_Implicit((Object)(object)itemDisplayRuleSet) ? Object.Instantiate(itemDisplayRuleSet) : ScriptableObject.CreateInstance())); } val.Add(OverrideGroups(value2, value)); } } ((MonoBehaviour)SkinsPlugin.Instance).StartCoroutine((IEnumerator)val); skinIDRSOverrides.Clear(); } [IteratorStateMachine(typeof(d__9))] private static IEnumerator OverrideGroups(ItemDisplayRuleSet idrs, Dictionary overrides) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { idrs = idrs, overrides = overrides }; } private static IEnumerator SetCustomIDRS(orig_ApplySkinAsync orig, ModelSkinController self, int skinIndex, AsyncReferenceHandleUnloadType unloadType) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) IEnumerator result = orig.Invoke(self, skinIndex, unloadType); SkinDef safe = ArrayUtils.GetSafe(self.skins, skinIndex); if (!Object.op_Implicit((Object)(object)safe)) { return result; } CharacterModel characterModel = self.characterModel; if (!skinToIDRS.TryGetValue(safe, out ItemDisplayRuleSet value) || (Object)(object)value == (Object)(object)characterModel.itemDisplayRuleSet) { return result; } characterModel.itemDisplayRuleSet = value; if (Object.op_Implicit((Object)(object)characterModel.body) && Object.op_Implicit((Object)(object)characterModel.body.inventory)) { characterModel.DisableAllItemDisplays(); characterModel.SetEquipmentDisplay((EquipmentIndex)(-1)); characterModel.body.inventory.wasRecentlyCreated = true; characterModel.UpdateItemDisplay(characterModel.body.inventory); characterModel.SetEquipmentDisplay(characterModel.inventoryEquipmentIndex); } return result; } } [AutoVersion] public static class Skins { public const string PluginGUID = "com.bepis.r2api.skins"; public const string PluginName = "R2API.Skins"; private static bool _hooksSet; public const string PluginVersion = "1.4.7"; internal static void SetHooks() { if (!_hooksSet) { _hooksSet = true; MainMenuController.OnMainMenuInitialised += OnMainMenuInitialized; } } internal static void UnsetHooks() { _hooksSet = false; MainMenuController.OnMainMenuInitialised -= OnMainMenuInitialized; } private static void OnMainMenuInitialized() { MainMenuController.OnMainMenuInitialised -= OnMainMenuInitialized; SurvivorDef[] survivorDefs = SurvivorCatalog.survivorDefs; foreach (SurvivorDef val in survivorDefs) { if (!Object.op_Implicit((Object)(object)val)) { continue; } GameObject displayPrefab = val.displayPrefab; GameObject bodyPrefab = val.bodyPrefab; if (!Object.op_Implicit((Object)(object)displayPrefab) || !Object.op_Implicit((Object)(object)bodyPrefab)) { SkinsPlugin.Logger.LogWarning((object)("SurvivorDef " + val.cachedName + " is missing a displayPrefab or bodyPrefab! You need to have this! Skipping...")); continue; } ModelSkinController componentInChildren = bodyPrefab.GetComponentInChildren(); if (!Object.op_Implicit((Object)(object)componentInChildren) || componentInChildren.skins == null || componentInChildren.skins.Length == 0) { SkinsPlugin.Logger.LogWarning((object)("BodyPrefab for " + val.cachedName + " is missing a ModelSkinController on the bodyPrefab! You need to have this! Skipping...")); continue; } CharacterModel componentInChildren2 = displayPrefab.GetComponentInChildren(); if (!Object.op_Implicit((Object)(object)componentInChildren2)) { SkinsPlugin.Logger.LogWarning((object)("Display prefab " + ((Object)displayPrefab).name + " is missing the CharacterModel component! You need to have this! Skipping...")); continue; } ModelSkinController val2 = ((Component)componentInChildren2).GetComponent(); if (!Object.op_Implicit((Object)(object)val2)) { SkinsPlugin.Logger.LogWarning((object)("Display prefab " + ((Object)componentInChildren2).name + " is missing a ModelSkinController component!\r\nHighly recommended you set the controller up manually. Adding component...")); val2 = ((Component)componentInChildren2).gameObject.AddComponent(); } ModelSkinController val3 = val2; if (val3.skins == null) { val3.skins = Array.Empty(); } if (val2.skins.Length != componentInChildren.skins.Length) { SkinsPlugin.Logger.LogWarning((object)("ModelSkinController skins array on the displayPrefab " + ((Object)componentInChildren2).name + " array does not match the one on the bodyPrefab!\r\nHighly recommended you set the controller up manually. Cloning from body prefab...")); val2.skins = ArrayUtils.Clone(componentInChildren.skins); } } } public static SkinDef CreateNewSkinDef(SkinDefParamsInfo skin) { SetHooks(); SkinDef val = ScriptableObject.CreateInstance(); ((Object)val).name = skin.Name; val.nameToken = skin.NameToken; val.icon = skin.Icon; val.baseSkins = skin.BaseSkins ?? Array.Empty(); val.unlockableDef = skin.UnlockableDef; val.rootObject = skin.RootObject; val.skinDefParams = skin.SkinDefParams; if ((Object)(object)val.skinDefParams == (Object)null) { val.skinDefParams = ScriptableObject.CreateInstance(); val.skinDefParams.rendererInfos = skin.RendererInfos ?? Array.Empty(); val.skinDefParams.gameObjectActivations = skin.GameObjectActivations ?? Array.Empty(); val.skinDefParams.meshReplacements = skin.MeshReplacements ?? Array.Empty(); val.skinDefParams.projectileGhostReplacements = skin.ProjectileGhostReplacements ?? Array.Empty(); val.skinDefParams.minionSkinReplacements = skin.MinionSkinReplacements ?? Array.Empty(); } return val; } [Obsolete] public static SkinDef CreateNewSkinDef(SkinDefInfo skin) { SetHooks(); SkinDef obj = CreateNewSkinDef((SkinDefParamsInfo)skin); obj.rendererInfos = skin.RendererInfos; obj.gameObjectActivations = skin.GameObjectActivations; obj.meshReplacements = skin.MeshReplacements; obj.projectileGhostReplacements = skin.ProjectileGhostReplacements; obj.minionSkinReplacements = skin.MinionSkinReplacements; return obj; } public static bool AddSkinToCharacter(GameObject? bodyPrefab, SkinDefParamsInfo skin) { SetHooks(); SkinDef skin2 = CreateNewSkinDef(skin); return AddSkinToCharacter(bodyPrefab, skin2); } [Obsolete] public static bool AddSkinToCharacter(GameObject? bodyPrefab, SkinDefInfo skin) { SetHooks(); SkinDef skin2 = CreateNewSkinDef(skin); return AddSkinToCharacter(bodyPrefab, skin2); } public static bool AddSkinToCharacter(GameObject? bodyPrefab, SkinDef? skin) { //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) SetHooks(); if ((Object)(object)bodyPrefab == (Object)null) { SkinsPlugin.Logger.LogError((object)"Tried to add skin to null body prefab."); return false; } if ((Object)(object)skin == (Object)null) { SkinsPlugin.Logger.LogError((object)"Tried to add invalid skin."); return false; } if (string.IsNullOrEmpty(((Object)skin).name) || string.IsNullOrEmpty(skin.nameToken)) { SkinsPlugin.Logger.LogError((object)"Tried to add invalid skin. Please add a name and nameToken."); return false; } ModelLocator val = default(ModelLocator); if (!bodyPrefab.TryGetComponent(ref val)) { SkinsPlugin.Logger.LogError((object)"Tried to add skin to invalid body prefab (No ModelLocator)."); return false; } Transform modelTransform = val.modelTransform; if ((Object)(object)modelTransform == (Object)null) { SkinsPlugin.Logger.LogError((object)"Tried to add skin to body prefab with no modelTransform."); return false; } if ((Object)(object)skin.rootObject != (Object)(object)((Component)modelTransform).gameObject) { SkinsPlugin.Logger.LogError((object)"Tried to add skin with improper root object set."); return false; } ModelSkinController val2 = default(ModelSkinController); if (!((Component)modelTransform).TryGetComponent(ref val2)) { SkinsPlugin.Logger.LogWarning((object)(((Object)bodyPrefab).name + " does not have a modelSkinController.\nAdding a new one and attempting to populate the default skin.\nHighly recommended you set the controller up manually.")); CharacterModel val3 = default(CharacterModel); if (!((Component)modelTransform).TryGetComponent(ref val3)) { SkinsPlugin.Logger.LogError((object)"Unable to locate CharacterModel, default skin creation aborted."); return false; } SkinnedMeshRenderer mainSkinnedMeshRenderer = val3.mainSkinnedMeshRenderer; if ((Object)(object)mainSkinnedMeshRenderer == (Object)null) { SkinsPlugin.Logger.LogError((object)"CharacterModel did not contain a main SkinnedMeshRenderer, default skin creation aborted."); return false; } RendererInfo[] baseRendererInfos = val3.baseRendererInfos; if (baseRendererInfos == null || baseRendererInfos.Length == 0) { SkinsPlugin.Logger.LogError((object)"CharacterModel rendererInfos are invalid, default skin creation aborted."); return false; } val2 = ((Component)modelTransform).gameObject.AddComponent(); SkinDefParamsInfo skin2 = default(SkinDefParamsInfo); skin2.Icon = CreateDefaultSkinIcon(); skin2.Name = "skin" + ((Object)bodyPrefab).name + "Default"; skin2.NameToken = ((Object)bodyPrefab).name.ToUpper() + "_DEFAULT_SKIN_NAME"; skin2.RootObject = ((Component)modelTransform).gameObject; skin2.UnlockableDef = null; skin2.RendererInfos = ArrayUtils.Clone(val3.baseRendererInfos); skin2.MeshReplacements = (MeshReplacement[]?)(object)new MeshReplacement[1] { new MeshReplacement { renderer = (Renderer)(object)mainSkinnedMeshRenderer, mesh = mainSkinnedMeshRenderer.sharedMesh } }; SkinDef val4 = CreateNewSkinDef(skin2); val2.skins = (SkinDef[])(object)new SkinDef[1] { val4 }; } ArrayUtils.ArrayAppend(ref val2.skins, ref skin); return true; } public static Sprite CreateSkinIcon(Color top, Color right, Color bottom, Color left) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) SetHooks(); return CreateSkinIcon(top, right, bottom, left, new Color(0.6f, 0.6f, 0.6f)); } public static Sprite CreateSkinIcon(Color top, Color right, Color bottom, Color left, Color line) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) SetHooks(); Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); IconTexJob iconTexJob = default(IconTexJob); iconTexJob.Top = Color32.op_Implicit(top); iconTexJob.Bottom = Color32.op_Implicit(bottom); iconTexJob.Right = Color32.op_Implicit(right); iconTexJob.Left = Color32.op_Implicit(left); iconTexJob.Line = Color32.op_Implicit(line); iconTexJob.TexOutput = val.GetRawTextureData(); IconTexJob iconTexJob2 = iconTexJob; JobHandle val2 = default(JobHandle); val2 = IJobParallelForExtensions.Schedule(iconTexJob2, 16384, 1, val2); ((JobHandle)(ref val2)).Complete(); ((Texture)val).wrapMode = (TextureWrapMode)1; val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f)); } private static Sprite CreateDefaultSkinIcon() { //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_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) return CreateSkinIcon(Color.red, Color.green, Color.blue, Color.black); } } public static class SkinSkillVariants { [HarmonyPatch] private class Patches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(new Type[] { typeof(GameObject), typeof(List>), typeof(List>), typeof(List>), typeof(AsyncReferenceHandleUnloadType) })] [HarmonyILManipulator] private static void SkinDef_RuntimeSkin_ApplyAsync(ILContext il) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) int count = il.Body.Variables.Count; il.Body.Variables.Add(new VariableDefinition(il.Import(typeof(List)))); il.Body.Variables.Add(new VariableDefinition(il.Import(typeof(Mesh)))); FieldReference fieldReference = null; FieldReference fieldReference2 = null; int locID = 0; Instruction val = il.Instrs[il.Instrs.Count - 1]; int i = 0; ILCursor val2 = new ILCursor(il); if (val2.TryGotoNext((MoveType)2, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref fieldReference), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)Reflection.GetPropertyGetter(typeof(GameObject), "transform")) })) { val2.Emit(OpCodes.Ldarg_0); val2.Emit(OpCodes.Ldfld, fieldReference); val2.Emit(OpCodes.Ldloc, 1); val2.EmitDelegate>>((Func>)CacheSkillDefs); val2.Emit(OpCodes.Stloc, count); int num2 = default(int); int num = default(int); MethodReference val3 = default(MethodReference); if (val2.TryGotoNext((MoveType)2, new Func[6] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2), (Instruction x) => ILPatternMatchingExt.MatchLdflda(x, "rendererInfoTemplates"), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCall(x, ref val3), (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)Reflection.GetPropertyGetter(typeof(RendererInfoTemplate), "rendererInfoData")), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref i) })) { val2.Emit(OpCodes.Ldloca, i); val2.Emit(OpCodes.Ldloc, count); val2.EmitDelegate<<>A{00000001}>>((<>A{00000001}>)ApplyRendererInfoSkillVariants); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 2 failed!")); } if (val2.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 7) })) { Instruction prev = val2.Prev; val2.Index -= 2; Instruction next = val2.Next; val2.Emit(OpCodes.Dup); val2.Emit(OpCodes.Ldloc, count); val2.EmitDelegate<<>F{00000001}, bool>>((<>F{00000001}, bool>)CheckForLightInfoSkillVariants); val2.Emit(OpCodes.Brfalse_S, next); val2.Emit(OpCodes.Ldloc, count); val2.EmitDelegate<<>F{00000001}, LightInfo>>((<>F{00000001}, LightInfo>)ApplyLightInfoSkillVariants); val2.Emit(OpCodes.Br, prev); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 3 failed!")); } if (val2.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 19) })) { Instruction prev2 = val2.Prev; val2.Index -= 3; Instruction next2 = val2.Next; val2.Emit(OpCodes.Dup); val2.Emit(OpCodes.Ldloc, count); val2.EmitDelegate<<>F{00000001}, Mesh>>((<>F{00000001}, Mesh>)ApplyMeshReplacementSkillVariants); val2.Emit(OpCodes.Dup); val2.Emit(OpCodes.Stloc, count + 1); val2.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(Object), "op_Implicit", (Type[])null, (Type[])null)); val2.Emit(OpCodes.Brfalse_S, next2); val2.Emit(OpCodes.Pop); val2.Emit(OpCodes.Ldloc, count + 1); val2.Emit(OpCodes.Br, prev2); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 4 failed!")); } } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 1 failed!")); } if (val2.TryGotoPrev((MoveType)2, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref fieldReference2), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "forceUpdate") })) { if (val2.TryGotoNext((MoveType)2, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "customGameObjectActivationTransforms"), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locID) })) { val2.Emit(OpCodes.Ldarg_0); val2.Emit(OpCodes.Ldfld, fieldReference2); val2.Emit(OpCodes.Ldloc, locID); val2.EmitDelegate>((Action)HandleSkinCustomGameobjectComponent); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 6 failed!")); } } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 5 failed!")); } val2.Goto(val, (MoveType)0, false); int index = val2.Index; val2.Index = index - 1; val2.Emit(OpCodes.Ldarg_0); val2.Emit(OpCodes.Ldfld, fieldReference); val2.Emit(OpCodes.Ldloc, 1); val2.Emit(OpCodes.Ldloc, count); val2.EmitDelegate>>((Action>)RunOnSkinApplied); } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyILManipulator] private static void SkinCatalog_Init(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); MethodReference val4 = default(MethodReference); if (val.TryGotoNext((MoveType)2, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 6), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, ref val4) })) { val.Emit(OpCodes.Ldloc, 6); val.Emit(OpCodes.Ldloc, 2); val.EmitDelegate>((Action)AddSkinToBodyDictionary); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 1 failed!")); } FieldReference val3 = default(FieldReference); ILLabel val2 = default(ILLabel); if (val.TryGotoNext((MoveType)0, new Func[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, ref val3), (Instruction x) => ILPatternMatchingExt.MatchBr(x, ref val2) })) { val.EmitDelegate((Action)ApplyPendingSkinSkillVariations); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 2 failed!")); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyILManipulator] private static void SkinDef_BakeAsync(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "_runtimeSkin") })) { val.Emit(OpCodes.Ldloc, 1); val.EmitDelegate>((Action)AddSkinDefToRuntimeSkin); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!")); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyILManipulator] private static void ModelSkinController_ApplySkinAsync(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); FieldReference val3 = default(FieldReference); ILLabel val2 = default(ILLabel); if (val.TryGotoNext((MoveType)0, new Func[5] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val3), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1), (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)Reflection.GetPropertyGetter(typeof(ModelSkinController), "currentSkinIndex")), (Instruction x) => ILPatternMatchingExt.MatchBneUn(x, ref val2) })) { val.RemoveRange(7); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!")); } } } public delegate void OnSkinApplied(GameObject gameObject, List skillDefs); public interface ISkillVariantStruct { bool lowPriority { get; set; } bool NullCheck(); bool Compare(T t); void Add(ref T t); void AddPending(SkinDefParams skinDefParams, T t); void AddPending(ModelSkinController modelSkinController, T t); } [Serializable] public struct RendererInfoSkillVariant : ISkillVariantStruct { [PrefabReference] public Renderer renderer; public SkillDef skillDef; public Material material; public ShadowCastingMode defaultShadowCastingMode; public bool ignoreOverlays; public bool hideOnDeath; public bool ignoresMaterialOverrides; private bool _lowPriority; public bool lowPriority { get { return _lowPriority; } set { _lowPriority = value; } } public bool Compare(RendererInfo t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return (Object)(object)t.renderer == (Object)(object)renderer; } public bool NullCheck() { return (Object)(object)renderer == (Object)null; } public void Add(ref RendererInfo t) { t.AddSkillVariant(this); } public void AddPending(SkinDefParams skinDefParams, RendererInfo t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddPendingSkillVariant(skinDefParams, t, this); } public void AddPending(ModelSkinController modelSkinController, RendererInfo t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddPendingSkillVariant(modelSkinController, t, this); } } [Serializable] public struct MeshReplacementSkillVariant : ISkillVariantStruct { [PrefabReference] public Renderer renderer; public SkillDef skillDef; public Mesh mesh; private bool _lowPriority; public bool lowPriority { get { return _lowPriority; } set { _lowPriority = value; } } public bool Compare(MeshReplacement t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return (Object)(object)t.renderer == (Object)(object)renderer; } public bool NullCheck() { return (Object)(object)renderer == (Object)null; } public void Add(ref MeshReplacement t) { t.AddSkillVariant(this); } public void AddPending(SkinDefParams skinDefParams, MeshReplacement t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddPendingSkillVariant(skinDefParams, t, this); } public void AddPending(ModelSkinController modelSkinController, MeshReplacement t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddPendingSkillVariant(modelSkinController, t, this); } } [Serializable] public struct LightInfoSkillVariant : ISkillVariantStruct { [PrefabReference] public Light originalLight; public SkillDef skillDef; public LightInfo lightInfo; private bool _lowPriority; public bool lowPriority { get { return _lowPriority; } set { _lowPriority = value; } } public bool Compare(LightInfo t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return (Object)(object)t.light == (Object)(object)originalLight; } public bool NullCheck() { return (Object)(object)originalLight == (Object)null; } public void Add(ref LightInfo t) { t.AddSkillVariant(this); } public void AddPending(SkinDefParams skinDefParams, LightInfo t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddPendingSkillVariant(skinDefParams, t, this); } public void AddPending(ModelSkinController modelSkinController, LightInfo t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddPendingSkillVariant(modelSkinController, t, this); } } [Serializable] public struct ProjectileGhostReplacementSkillVariant : ISkillVariantStruct { public GameObject projectilePrefab; public SkillDef skillDef; public GameObject projectileGhostReplacementPrefab; private bool _lowPriority; public bool lowPriority { get { return _lowPriority; } set { _lowPriority = value; } } public bool Compare(ProjectileGhostReplacement t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return (Object)(object)t.projectilePrefab == (Object)(object)projectilePrefab; } public bool NullCheck() { return (Object)(object)projectilePrefab == (Object)null; } public void Add(ref ProjectileGhostReplacement t) { t.AddSkillVariant(this); } public void AddPending(SkinDefParams skinDefParams, ProjectileGhostReplacement t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddPendingSkillVariant(skinDefParams, t, this); } public void AddPending(ModelSkinController modelSkinController, ProjectileGhostReplacement t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddPendingSkillVariant(modelSkinController, t, this); } } [Serializable] public struct MinionSkinReplacementSkillVariant : ISkillVariantStruct { public GameObject minionBodyPrefab; public SkillDef skillDef; public SkinDef minionSkin; private bool _lowPriority; public bool lowPriority { get { return _lowPriority; } set { _lowPriority = value; } } public bool Compare(MinionSkinReplacement t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return (Object)(object)t.minionBodyPrefab == (Object)(object)minionBodyPrefab; } public bool NullCheck() { return (Object)(object)minionBodyPrefab == (Object)null; } public void Add(ref MinionSkinReplacement t) { t.AddSkillVariant(this); } public void AddPending(SkinDefParams skinDefParams, MinionSkinReplacement t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddPendingSkillVariant(skinDefParams, t, this); } public void AddPending(ModelSkinController modelSkinController, MinionSkinReplacement t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) AddPendingSkillVariant(modelSkinController, t, this); } } [CompilerGenerated] private sealed class <g__runLoadCoroutine|6_0>d : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <g__runLoadCoroutine|6_0>d(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = parallelCoroutine; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private static class <>O { public static hook_ctor <0>__MeshReplacementTemplate_ctor; public static hook_ctor <1>__GhostReplacementTemplate_ctor; public static hook_ctor <2>__LightReplacementTemplate_ctor; public static hook_ctor <3>__MinionSkinTemplate_ctor; public static Manipulator <4>__ProjectileGhostReplacementManager_FindProjectileGhostPrefab; public static Manipulator <5>__MasterSummon_Perform; public static Manipulator <6>__SurvivorCatalog_SetSurvivorDefs; public static hook_SetSurvivorDefs <7>__SurvivorCatalog_SetSurvivorDefs1; public static Action <8>__SetLobbySkinToBodySkin; public static Func> <9>__CollectSkills; public static <>F{00000001}, SkinDef> <10>__ApplyMinionSkinVariants; public static Func <11>__ReplaceProjectileGhost; } [CompilerGenerated] private sealed class d__25 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SurvivorDef survivorDef; private ModelLocator 5__2; private ModelSkinController 5__3; private ModelSkinController 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = (Object.op_Implicit((Object)(object)survivorDef.bodyPrefab) ? survivorDef.bodyPrefab.GetComponent() : null); <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; if (!Object.op_Implicit((Object)(object)5__2)) { return false; } 5__3 = (Object.op_Implicit((Object)(object)5__2._modelTransform) ? ((Component)5__2._modelTransform).GetComponent() : null); <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; if (!Object.op_Implicit((Object)(object)5__3)) { return false; } 5__4 = (Object.op_Implicit((Object)(object)survivorDef.displayPrefab) ? survivorDef.displayPrefab.GetComponentInChildren() : null); <>2__current = null; <>1__state = 3; return true; case 3: { <>1__state = -1; if (!Object.op_Implicit((Object)(object)5__4)) { return false; } SkinDef[] skins = 5__3.skins; SkinDef[] skins2 = 5__4.skins; if (skins == null || skins2 == null || skins.Length != skins2.Length) { return false; } for (int i = 0; i < skins.Length; i++) { SkinDef val = skins[i]; SkinDef val2 = skins2[i]; if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2) && !lobbySkinDefToBodySkinDef.ContainsKey(val2)) { lobbySkinDefToBodySkinDef.Add(val2, val); } } return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static Dictionary skinToBody = new Dictionary(); private static Dictionary lobbySkinDefToBodySkinDef = new Dictionary(); private static ParallelCoroutine parallelCoroutine; private static bool _hooksSet; private static bool _isLoaded; internal static void SetHooks() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0078: 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_0083: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown if (!_hooksSet) { _hooksSet = true; SkinsPlugin.harmonyPatcher.CreateClassProcessor(typeof(Patches)).Patch(); object obj = <>O.<0>__MeshReplacementTemplate_ctor; if (obj == null) { hook_ctor val = MeshReplacementTemplate_ctor; <>O.<0>__MeshReplacementTemplate_ctor = val; obj = (object)val; } MeshReplacementTemplate.ctor += (hook_ctor)obj; object obj2 = <>O.<1>__GhostReplacementTemplate_ctor; if (obj2 == null) { hook_ctor val2 = GhostReplacementTemplate_ctor; <>O.<1>__GhostReplacementTemplate_ctor = val2; obj2 = (object)val2; } GhostReplacementTemplate.ctor += (hook_ctor)obj2; object obj3 = <>O.<2>__LightReplacementTemplate_ctor; if (obj3 == null) { hook_ctor val3 = LightReplacementTemplate_ctor; <>O.<2>__LightReplacementTemplate_ctor = val3; obj3 = (object)val3; } LightReplacementTemplate.ctor += (hook_ctor)obj3; object obj4 = <>O.<3>__MinionSkinTemplate_ctor; if (obj4 == null) { hook_ctor val4 = MinionSkinTemplate_ctor; <>O.<3>__MinionSkinTemplate_ctor = val4; obj4 = (object)val4; } MinionSkinTemplate.ctor += (hook_ctor)obj4; object obj5 = <>O.<4>__ProjectileGhostReplacementManager_FindProjectileGhostPrefab; if (obj5 == null) { Manipulator val5 = ProjectileGhostReplacementManager_FindProjectileGhostPrefab; <>O.<4>__ProjectileGhostReplacementManager_FindProjectileGhostPrefab = val5; obj5 = (object)val5; } ProjectileGhostReplacementManager.FindProjectileGhostPrefab += (Manipulator)obj5; object obj6 = <>O.<5>__MasterSummon_Perform; if (obj6 == null) { Manipulator val6 = MasterSummon_Perform; <>O.<5>__MasterSummon_Perform = val6; obj6 = (object)val6; } MasterSummon.Perform += (Manipulator)obj6; object obj7 = <>O.<6>__SurvivorCatalog_SetSurvivorDefs; if (obj7 == null) { Manipulator val7 = SurvivorCatalog_SetSurvivorDefs; <>O.<6>__SurvivorCatalog_SetSurvivorDefs = val7; obj7 = (object)val7; } SurvivorCatalog.SetSurvivorDefs += (Manipulator)obj7; object obj8 = <>O.<7>__SurvivorCatalog_SetSurvivorDefs1; if (obj8 == null) { hook_SetSurvivorDefs val8 = SurvivorCatalog_SetSurvivorDefs1; <>O.<7>__SurvivorCatalog_SetSurvivorDefs1 = val8; obj8 = (object)val8; } SurvivorCatalog.SetSurvivorDefs += (hook_SetSurvivorDefs)obj8; } } private static void SurvivorCatalog_SetSurvivorDefs1(orig_SetSurvivorDefs orig, SurvivorDef[] newSurvivorDefs) { orig.Invoke(newSurvivorDefs); if (parallelCoroutine != null) { ((MonoBehaviour)RoR2Application.instance).StartCoroutine(runLoadCoroutine()); } [IteratorStateMachine(typeof(<g__runLoadCoroutine|6_0>d))] static IEnumerator runLoadCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <g__runLoadCoroutine|6_0>d(0); } } internal static void UnsetHooks() { //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_0021: Expected O, but got Unknown //IL_0036: 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_0041: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown _hooksSet = false; object obj = <>O.<0>__MeshReplacementTemplate_ctor; if (obj == null) { hook_ctor val = MeshReplacementTemplate_ctor; <>O.<0>__MeshReplacementTemplate_ctor = val; obj = (object)val; } MeshReplacementTemplate.ctor -= (hook_ctor)obj; object obj2 = <>O.<1>__GhostReplacementTemplate_ctor; if (obj2 == null) { hook_ctor val2 = GhostReplacementTemplate_ctor; <>O.<1>__GhostReplacementTemplate_ctor = val2; obj2 = (object)val2; } GhostReplacementTemplate.ctor -= (hook_ctor)obj2; object obj3 = <>O.<2>__LightReplacementTemplate_ctor; if (obj3 == null) { hook_ctor val3 = LightReplacementTemplate_ctor; <>O.<2>__LightReplacementTemplate_ctor = val3; obj3 = (object)val3; } LightReplacementTemplate.ctor -= (hook_ctor)obj3; object obj4 = <>O.<3>__MinionSkinTemplate_ctor; if (obj4 == null) { hook_ctor val4 = MinionSkinTemplate_ctor; <>O.<3>__MinionSkinTemplate_ctor = val4; obj4 = (object)val4; } MinionSkinTemplate.ctor -= (hook_ctor)obj4; object obj5 = <>O.<4>__ProjectileGhostReplacementManager_FindProjectileGhostPrefab; if (obj5 == null) { Manipulator val5 = ProjectileGhostReplacementManager_FindProjectileGhostPrefab; <>O.<4>__ProjectileGhostReplacementManager_FindProjectileGhostPrefab = val5; obj5 = (object)val5; } ProjectileGhostReplacementManager.FindProjectileGhostPrefab -= (Manipulator)obj5; object obj6 = <>O.<5>__MasterSummon_Perform; if (obj6 == null) { Manipulator val6 = MasterSummon_Perform; <>O.<5>__MasterSummon_Perform = val6; obj6 = (object)val6; } MasterSummon.Perform -= (Manipulator)obj6; object obj7 = <>O.<6>__SurvivorCatalog_SetSurvivorDefs; if (obj7 == null) { Manipulator val7 = SurvivorCatalog_SetSurvivorDefs; <>O.<6>__SurvivorCatalog_SetSurvivorDefs = val7; obj7 = (object)val7; } SurvivorCatalog.SetSurvivorDefs -= (Manipulator)obj7; } private static void SurvivorCatalog_SetSurvivorDefs(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int locID = 4; int num = default(int); if (val.TryGotoNext((MoveType)2, new Func[4] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(SurvivorCatalog), "survivorDefs"), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchLdelemRef(x), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref locID) })) { val.Emit(OpCodes.Ldloc, locID); val.EmitDelegate>((Action)SetLobbySkinToBodySkin); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!")); } } private static void MinionSkinTemplate_ctor(orig_ctor orig, ref MinionSkinTemplate self, MinionSkinReplacement minionSkinReplacement) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) self.SetSkillVariants(minionSkinReplacement.GetSkillVariants()); orig.Invoke(ref self, minionSkinReplacement); } private static void MasterSummon_Perform(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int count = il.Body.Variables.Count; il.Body.Variables.Add(new VariableDefinition(il.Import(typeof(List)))); il.Body.Variables.Add(new VariableDefinition(il.Import(typeof(SkinDef)))); if (val.TryGotoNext((MoveType)2, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)Reflection.GetPropertyGetter(typeof(CharacterBody), "master")), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 2) })) { val.Emit(OpCodes.Ldloc_1); val.EmitDelegate>>((Func>)CollectSkills); val.Emit(OpCodes.Stloc, count); il.Body.Variables.Add(new VariableDefinition(il.Import(typeof(List)))); if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "minionSkin") })) { Instruction next = val.Next; Instruction prev = val.Prev; int index = val.Index; val.Index = index - 1; val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldloc, count); val.EmitDelegate<<>F{00000001}, SkinDef>>((<>F{00000001}, SkinDef>)ApplyMinionSkinVariants); val.Emit(OpCodes.Dup); val.Emit(OpCodes.Stloc, count + 1); val.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(Object), "op_Implicit", (Type[])null, (Type[])null)); val.Emit(OpCodes.Brfalse_S, prev); val.Emit(OpCodes.Pop); val.Emit(OpCodes.Ldloc, count + 1); val.Emit(OpCodes.Br, next); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 2 failed!")); } } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 1 failed!")); } } private static void LightReplacementTemplate_ctor(orig_ctor orig, ref LightReplacementTemplate self, LightInfo source, GameObject rootObject) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) self.SetSkillVariants(source.GetSkillVariants()); orig.Invoke(ref self, source, rootObject); } private static void GhostReplacementTemplate_ctor(orig_ctor orig, ref GhostReplacementTemplate self, ProjectileGhostReplacement projectileGhostReplacement) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) self.SetSkillVariants(projectileGhostReplacement.GetSkillVariants()); orig.Invoke(ref self, projectileGhostReplacement); } private static void ProjectileGhostReplacementManager_FindProjectileGhostPrefab(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel iLLabel = null; Instruction val2 = il.Instrs[il.Instrs.Count - 1]; if (val.TryGotoNext((MoveType)2, new Func[5] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 5), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "projectileIndex"), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "catalogIndex"), (Instruction x) => ILPatternMatchingExt.MatchBneUn(x, ref iLLabel) })) { val.Emit(OpCodes.Ldloc, 5); val.Emit(OpCodes.Ldloc, 1); val.EmitDelegate>((Func)ReplaceProjectileGhost); val.Emit(OpCodes.Dup); val.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(Object), "op_Implicit", (Type[])null, (Type[])null)); val.Emit(OpCodes.Brtrue_S, val2); val.Emit(OpCodes.Pop); } else { SkinsPlugin.Logger.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!")); } } private static void MeshReplacementTemplate_ctor(orig_ctor orig, ref MeshReplacementTemplate self, MeshReplacement source, GameObject rootObject) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) self.SetSkillVariants(source.GetSkillVariants()); orig.Invoke(ref self, source, rootObject); } private static void HandleSkinCustomGameobjectComponent(CharacterModel characterModel, Transform transform) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)transform) || !Object.op_Implicit((Object)(object)characterModel)) { return; } SkinCustomGameobjectComponent component = ((Component)transform).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return; } component.characterModel = characterModel; if (characterModel.baseLightInfos != null && component.extraLightInfos != null && component.extraLightInfos.Length != 0) { int num = characterModel.baseLightInfos.Length; Array.Resize(ref characterModel.baseLightInfos, num + component.extraLightInfos.Length); for (int i = 0; i < component.extraLightInfos.Length; i++) { characterModel.baseLightInfos[i + num] = component.extraLightInfos[i]; } } if (characterModel.baseRendererInfos != null && component.extraRendererInfos != null && component.extraRendererInfos.Length != 0) { int num2 = characterModel.baseRendererInfos.Length; Array.Resize(ref characterModel.baseRendererInfos, num2 + component.extraRendererInfos.Length); for (int j = 0; j < component.extraRendererInfos.Length; j++) { characterModel.baseRendererInfos[j + num2] = component.extraRendererInfos[j]; } } } private static void SetLobbySkinToBodySkin(SurvivorDef survivorDef) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)survivorDef)) { if (parallelCoroutine == null) { parallelCoroutine = new ParallelCoroutine(); } parallelCoroutine.Add(SetLobbySkinToBodySkinAsync(survivorDef)); } } [IteratorStateMachine(typeof(d__25))] private static IEnumerator SetLobbySkinToBodySkinAsync(SurvivorDef survivorDef) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__25(0) { survivorDef = survivorDef }; } private static List CacheSkillDefs(GameObject gameObject, RuntimeSkin runtimeSkin) { HurtBoxGroup component = gameObject.GetComponent(); if ((Object)(object)component == (Object)null) { return CacheSkillDefsInLobby(gameObject, runtimeSkin); } HurtBox mainHurtBox = component.mainHurtBox; if ((Object)(object)mainHurtBox == (Object)null) { return CacheSkillDefsInLobby(gameObject, runtimeSkin); } HealthComponent healthComponent = mainHurtBox.healthComponent; if ((Object)(object)healthComponent == (Object)null) { return CacheSkillDefsInLobby(gameObject, runtimeSkin); } CharacterBody body = healthComponent.body; if ((Object)(object)body == (Object)null) { return null; } return CollectSkills(body); } private static List CollectSkills(CharacterBody characterBody) { SkillLocator skillLocator = characterBody.skillLocator; if ((Object)(object)skillLocator == (Object)null) { return null; } if (skillLocator.allSkills == null) { return null; } List list = new List(); GenericSkill[] allSkills = skillLocator.allSkills; foreach (GenericSkill val in allSkills) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.baseSkill == (Object)null)) { list.Add(val.baseSkill); } } return list; } private static List CacheSkillDefsInLobby(GameObject gameObject, RuntimeSkin runtimeSkin) { //IL_002e: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_005f: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) SkinDef skinDef = runtimeSkin.GetSkinDef(); if ((Object)(object)skinDef == (Object)null) { return null; } BodyIndex val; if (skinToBody.ContainsKey(skinDef)) { val = skinToBody[skinDef]; } else { val = (BodyIndex)(-1); if (lobbySkinDefToBodySkinDef.TryGetValue(skinDef, out SkinDef value) && skinToBody.ContainsKey(value)) { val = skinToBody[value]; } } if ((int)val == -1) { return null; } GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(val); if ((Object)(object)bodyPrefab == (Object)null) { return null; } SurvivorMannequinSlotController componentInParent = gameObject.GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null || (Object)(object)componentInParent.networkUser == (Object)null) { return null; } Loadout val2 = Loadout.RequestInstance(); componentInParent.networkUser.networkLoadout.CopyLoadout(val2); GenericSkill[] components = bodyPrefab.GetComponents(); if (components == null || components.Length == 0) { return null; } List list = new List(); for (int i = 0; i < components.Length; i++) { GenericSkill val3 = components[i]; if (!((Object)(object)val3 == (Object)null)) { SkillDef skillDef = val3.skillFamily.variants[val2.bodyLoadoutManager.GetSkillVariant(val, i)].skillDef; if (!((Object)(object)skillDef == (Object)null)) { list.Add(skillDef); } } } return list; } private static void ApplyRendererInfoSkillVariants(ref RendererInfo rendererInfoData, List skillDefs) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (skillDefs == null) { return; } object[] skillVariants = rendererInfoData.GetSkillVariants(); if (skillVariants == null) { return; } bool flag = false; object[] array = skillVariants; foreach (object obj in array) { if (obj != null) { RendererInfoSkillVariant rendererInfoSkillVariant = (RendererInfoSkillVariant)obj; SkillDef skillDef = rendererInfoSkillVariant.skillDef; if (!((Object)(object)skillDef == (Object)null) && skillDefs.Contains(skillDef) && (!flag || !rendererInfoSkillVariant.lowPriority)) { rendererInfoData.defaultMaterial = rendererInfoSkillVariant.material; rendererInfoData.defaultShadowCastingMode = rendererInfoSkillVariant.defaultShadowCastingMode; rendererInfoData.ignoreOverlays = rendererInfoSkillVariant.ignoreOverlays; rendererInfoData.hideOnDeath = rendererInfoSkillVariant.hideOnDeath; rendererInfoData.ignoresMaterialOverrides = rendererInfoSkillVariant.ignoresMaterialOverrides; _ = rendererInfoSkillVariant.lowPriority; } } } } private static Mesh ApplyMeshReplacementSkillVariants(ref MeshReplacementTemplate meshReplacementTemplate, List skillDefs) { Mesh result = null; if (skillDefs == null) { return result; } object[] skillVariants = meshReplacementTemplate.GetSkillVariants(); if (skillVariants == null) { return result; } bool flag = false; object[] array = skillVariants; foreach (object obj in array) { if (obj == null) { continue; } MeshReplacementSkillVariant meshReplacementSkillVariant = (MeshReplacementSkillVariant)obj; SkillDef skillDef = meshReplacementSkillVariant.skillDef; if (!((Object)(object)skillDef == (Object)null) && skillDefs.Contains(skillDef) && (!flag || !meshReplacementSkillVariant.lowPriority)) { result = meshReplacementSkillVariant.mesh; if (!meshReplacementSkillVariant.lowPriority) { flag = true; } } } return result; } private static SkinDef ApplyMinionSkinVariants(ref MinionSkinTemplate minionSkinTemplate, List skillDefs) { SkinDef minionSkin = minionSkinTemplate.minionSkin; if (skillDefs == null) { return minionSkin; } object[] skillVariants = minionSkinTemplate.GetSkillVariants(); if (skillVariants == null) { return minionSkin; } bool flag = false; object[] array = skillVariants; foreach (object obj in array) { if (obj == null) { continue; } MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant = (MinionSkinReplacementSkillVariant)obj; SkillDef skillDef = minionSkinReplacementSkillVariant.skillDef; if (!((Object)(object)skillDef == (Object)null) && skillDefs.Contains(skillDef) && (!flag || !minionSkinReplacementSkillVariant.lowPriority)) { minionSkin = minionSkinReplacementSkillVariant.minionSkin; if (minionSkinReplacementSkillVariant.lowPriority) { flag = true; } } } return minionSkin; } private static bool CheckForLightInfoSkillVariants(ref LightReplacementTemplate lightReplacementTemplate, List skillDefs) { if (skillDefs == null) { return false; } object[] skillVariants = lightReplacementTemplate.GetSkillVariants(); if (skillVariants == null) { return false; } object[] array = skillVariants; foreach (object obj in array) { if (obj != null) { SkillDef skillDef = ((LightInfoSkillVariant)obj).skillDef; if (!((Object)(object)skillDef == (Object)null) && skillDefs.Contains(skillDef)) { return true; } } } return false; } private static LightInfo ApplyLightInfoSkillVariants(ref LightReplacementTemplate lightReplacementTemplate, List skillDefs) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) LightInfo result = lightReplacementTemplate.data; if (skillDefs == null) { return result; } object[] skillVariants = lightReplacementTemplate.GetSkillVariants(); if (skillVariants == null) { return result; } bool flag = false; object[] array = skillVariants; foreach (object obj in array) { if (obj == null) { continue; } LightInfoSkillVariant lightInfoSkillVariant = (LightInfoSkillVariant)obj; SkillDef skillDef = lightInfoSkillVariant.skillDef; if (!((Object)(object)skillDef == (Object)null) && skillDefs.Contains(skillDef) && (!flag || !lightInfoSkillVariant.lowPriority)) { result = lightInfoSkillVariant.lightInfo; if (!lightInfoSkillVariant.lowPriority) { flag = true; } } } return result; } private static void AddSkinToBodyDictionary(SkinDef skinDef, BodyIndex bodyIndex) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!skinToBody.ContainsKey(skinDef)) { skinToBody.Add(skinDef, bodyIndex); } } private static void ApplyPendingSkinSkillVariations() { _isLoaded = true; foreach (SkinSkillVariantsDef pendingSkinSkillVariantsDef in SkinSkillVariantsDef.pendingSkinSkillVariantsDefs) { if (!((Object)(object)pendingSkinSkillVariantsDef == (Object)null)) { pendingSkinSkillVariantsDef.Apply(); } } } private static void AddSkinDefToRuntimeSkin(SkinDef skinDef) { skinDef.runtimeSkin.SetSkinDef(skinDef); } internal static SkinDefParams GetSkinDefParams(SkinDef skinDef) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) SkinDefParams val = skinDef.skinDefParams; if ((Object)(object)val == (Object)null && skinDef.skinDefParamsAddress != null) { val = (SkinDefParams)((!Object.op_Implicit(((AssetReference)skinDef.skinDefParamsAddress).Asset)) ? ((object)skinDef.skinDefParamsAddress.LoadAsset().WaitForCompletion()) : ((object)/*isinst with value type is only supported in some contexts*/)); } return val; } internal static SkinDefParams GetOptimizedSkinDefParams(SkinDef skinDef) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) SkinDefParams val = skinDef.skinDefParams; if ((Object)(object)val == (Object)null && skinDef.optimizedSkinDefParamsAddress != null) { val = (SkinDefParams)((!Object.op_Implicit(((AssetReference)skinDef.optimizedSkinDefParamsAddress).Asset)) ? ((object)skinDef.optimizedSkinDefParamsAddress.LoadAsset().WaitForCompletion()) : ((object)/*isinst with value type is only supported in some contexts*/)); } return val; } private static ref RendererInfo GetRendererInfoByName(SkinDefParams skinDefParams, string rendererName) { RendererInfo[] rendererInfos = skinDefParams.rendererInfos; for (int i = 0; i < rendererInfos.Length; i++) { ref RendererInfo reference = ref rendererInfos[i]; if (!((Object)(object)reference.renderer == (Object)null) && ((Object)reference.renderer).name == rendererName) { return ref reference; } } throw new NullReferenceException($"Couldn't find renderer \"{rendererName}\" for \"{skinDefParams}\""); } private static ref MeshReplacement GetMeshReplacementByName(SkinDefParams skinDefParams, string meshRendererName) { MeshReplacement[] meshReplacements = skinDefParams.meshReplacements; for (int i = 0; i < meshReplacements.Length; i++) { ref MeshReplacement reference = ref meshReplacements[i]; if (!((Object)(object)reference.renderer == (Object)null) && ((Object)reference.renderer).name == meshRendererName) { return ref reference; } } throw new NullReferenceException($"Couldn't find renderer \"{meshRendererName}\" for \"{skinDefParams}\""); } private static ref LightInfo GetLightInfoByName(SkinDefParams skinDefParams, string lightInfoName) { LightInfo[] lightReplacements = skinDefParams.lightReplacements; for (int i = 0; i < lightReplacements.Length; i++) { ref LightInfo reference = ref lightReplacements[i]; if (!((Object)(object)reference.light == (Object)null) && ((Object)reference.light).name == lightInfoName) { return ref reference; } } throw new NullReferenceException($"Couldn't find light \"{lightInfoName}\" for \"{skinDefParams}\""); } private static ref ProjectileGhostReplacement GetProjectileGhostReplacementByName(SkinDefParams skinDefParams, string projectileName) { ProjectileGhostReplacement[] projectileGhostReplacements = skinDefParams.projectileGhostReplacements; for (int i = 0; i < projectileGhostReplacements.Length; i++) { ref ProjectileGhostReplacement reference = ref projectileGhostReplacements[i]; if (!((Object)(object)reference.projectilePrefab == (Object)null) && ((Object)reference.projectilePrefab).name == projectileName) { return ref reference; } } throw new NullReferenceException($"Couldn't find projectile \"{projectileName}\" for \"{skinDefParams}\""); } private static ref ProjectileGhostReplacement GetProjectileGhostReplacementByPrefab(SkinDefParams skinDefParams, GameObject projectilePrefab) { ProjectileGhostReplacement[] projectileGhostReplacements = skinDefParams.projectileGhostReplacements; for (int i = 0; i < projectileGhostReplacements.Length; i++) { ref ProjectileGhostReplacement reference = ref projectileGhostReplacements[i]; if (!((Object)(object)reference.projectilePrefab == (Object)null) && (Object)(object)reference.projectilePrefab == (Object)(object)projectilePrefab) { return ref reference; } } throw new NullReferenceException($"Couldn't find projectile \"{((Object)projectilePrefab).name}\" for \"{skinDefParams}\""); } private static ref MinionSkinReplacement GetMinionSkinReplacementByName(SkinDefParams skinDefParams, string minionBodyName) { MinionSkinReplacement[] minionSkinReplacements = skinDefParams.minionSkinReplacements; for (int i = 0; i < minionSkinReplacements.Length; i++) { ref MinionSkinReplacement reference = ref minionSkinReplacements[i]; if (!((Object)(object)reference.minionBodyPrefab == (Object)null) && ((Object)reference.minionBodyPrefab).name == minionBodyName) { return ref reference; } } throw new NullReferenceException($"Couldn't find minion body \"{minionBodyName}\" for \"{skinDefParams}\""); } private static ref MinionSkinReplacement GetMinionSkinReplacementByPrefab(SkinDefParams skinDefParams, GameObject minionBodyPrefab) { MinionSkinReplacement[] minionSkinReplacements = skinDefParams.minionSkinReplacements; for (int i = 0; i < minionSkinReplacements.Length; i++) { ref MinionSkinReplacement reference = ref minionSkinReplacements[i]; if (!((Object)(object)reference.minionBodyPrefab == (Object)null) && (Object)(object)reference.minionBodyPrefab == (Object)(object)minionBodyPrefab) { return ref reference; } } throw new NullReferenceException($"Couldn't find minion body \"{minionBodyPrefab}\" for \"{skinDefParams}\""); } internal static void AddItemToObjects(ref object[] objects, T t) { if (objects == null) { objects = new object[1] { t }; } else { int num = objects.Length; Array.Resize(ref objects, num + 1); objects[num] = t; } } private static void RunOnSkinApplied(GameObject gameObject, RuntimeSkin runtimeSkin, List skillDefs) { SkinDef skinDef = runtimeSkin.GetSkinDef(); if (!((Object)(object)skinDef == (Object)null)) { skinDef.GetOnSkinApplied()?.Invoke(gameObject, skillDefs); } } private static GameObject ReplaceProjectileGhost(GhostReplacementTemplate ghostReplacementTemplate, CharacterBody characterBody) { object[] skillVariants = ghostReplacementTemplate.GetSkillVariants(); if (skillVariants == null || skillVariants.Length == 0) { return null; } SkillLocator skillLocator = characterBody.skillLocator; if ((Object)(object)skillLocator == (Object)null) { return null; } GenericSkill[] allSkills = skillLocator.allSkills; if (allSkills == null || allSkills.Length == 0) { return null; } List list = new List(); GenericSkill[] array = allSkills; foreach (GenericSkill val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.baseSkill == (Object)null)) { list.Add(val.baseSkill); } } GameObject result = null; bool flag = false; for (int j = 0; j < skillVariants.Length; j++) { ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant = (ProjectileGhostReplacementSkillVariant)skillVariants[j]; if (!((Object)(object)projectileGhostReplacementSkillVariant.skillDef == (Object)null) && list.Contains(projectileGhostReplacementSkillVariant.skillDef) && (!flag || !projectileGhostReplacementSkillVariant.lowPriority)) { result = projectileGhostReplacementSkillVariant.projectileGhostReplacementPrefab; if (!projectileGhostReplacementSkillVariant.lowPriority) { flag = true; } } } return result; } private static SkinSkillVariantsDef GetOrCreateSkinSkillVariantsDef(SkinDefParams skinDefParams) { SkinSkillVariantsDef skinSkillVariantsDef = skinDefParams.GetSkinSkillVariantsDef(); if ((Object)(object)skinSkillVariantsDef == (Object)null) { skinSkillVariantsDef = ScriptableObject.CreateInstance(); ((Object)skinSkillVariantsDef).name = ((Object)skinDefParams).name; skinSkillVariantsDef.Register(); skinSkillVariantsDef.AddSkinDefParams(skinDefParams); skinDefParams.SetSkinSkillVariantsDef(skinSkillVariantsDef); } return skinSkillVariantsDef; } private static SkinSkillVariantsDef GetOrCreateSkinSkillVariantsDef(ModelSkinController modelSkinController) { SkinSkillVariantsDef skinSkillVariantsDef = modelSkinController.GetSkinSkillVariantsDef(); if ((Object)(object)skinSkillVariantsDef == (Object)null) { skinSkillVariantsDef = ScriptableObject.CreateInstance(); ((Object)skinSkillVariantsDef).name = ((Object)modelSkinController).name; skinSkillVariantsDef.Register(); skinSkillVariantsDef.modelSkinController = modelSkinController; modelSkinController.SetSkinSkillVariantsDef(skinSkillVariantsDef); } return skinSkillVariantsDef; } private static void AddPendingSkillVariant(SkinDefParams skinDefParams, RendererInfo rendererInfo, RendererInfoSkillVariant rendererInfoSkillVariant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SkinSkillVariantsDef orCreateSkinSkillVariantsDef = GetOrCreateSkinSkillVariantsDef(skinDefParams); rendererInfoSkillVariant.renderer = rendererInfo.renderer; orCreateSkinSkillVariantsDef.AddRendererInfoSkillVariant(rendererInfoSkillVariant); } private static void AddPendingSkillVariant(ModelSkinController modelSkinController, RendererInfo rendererInfo, RendererInfoSkillVariant rendererInfoSkillVariant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SkinSkillVariantsDef orCreateSkinSkillVariantsDef = GetOrCreateSkinSkillVariantsDef(modelSkinController); rendererInfoSkillVariant.renderer = rendererInfo.renderer; orCreateSkinSkillVariantsDef.AddRendererInfoSkillVariant(rendererInfoSkillVariant); } private static void AddPendingSkillVariant(SkinDefParams skinDefParams, MeshReplacement meshReplacement, MeshReplacementSkillVariant meshReplacementSkillVariant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SkinSkillVariantsDef orCreateSkinSkillVariantsDef = GetOrCreateSkinSkillVariantsDef(skinDefParams); meshReplacementSkillVariant.renderer = meshReplacement.renderer; orCreateSkinSkillVariantsDef.AddMeshReplacementSkillVariant(meshReplacementSkillVariant); } private static void AddPendingSkillVariant(ModelSkinController modelSkinController, MeshReplacement meshReplacement, MeshReplacementSkillVariant meshReplacementSkillVariant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SkinSkillVariantsDef orCreateSkinSkillVariantsDef = GetOrCreateSkinSkillVariantsDef(modelSkinController); meshReplacementSkillVariant.renderer = meshReplacement.renderer; orCreateSkinSkillVariantsDef.AddMeshReplacementSkillVariant(meshReplacementSkillVariant); } private static void AddPendingSkillVariant(SkinDefParams skinDefParams, LightInfo lightInfo, LightInfoSkillVariant lightInfoSkillVariant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SkinSkillVariantsDef orCreateSkinSkillVariantsDef = GetOrCreateSkinSkillVariantsDef(skinDefParams); lightInfoSkillVariant.originalLight = lightInfo.light; orCreateSkinSkillVariantsDef.AddLightInfoSkillVariant(lightInfoSkillVariant); } private static void AddPendingSkillVariant(ModelSkinController modelSkinController, LightInfo lightInfo, LightInfoSkillVariant lightInfoSkillVariant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SkinSkillVariantsDef orCreateSkinSkillVariantsDef = GetOrCreateSkinSkillVariantsDef(modelSkinController); lightInfoSkillVariant.originalLight = lightInfo.light; orCreateSkinSkillVariantsDef.AddLightInfoSkillVariant(lightInfoSkillVariant); } private static void AddPendingSkillVariant(SkinDefParams skinDefParams, ProjectileGhostReplacement projectileGhostReplacement, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SkinSkillVariantsDef orCreateSkinSkillVariantsDef = GetOrCreateSkinSkillVariantsDef(skinDefParams); projectileGhostReplacementSkillVariant.projectilePrefab = projectileGhostReplacement.projectilePrefab; orCreateSkinSkillVariantsDef.AddProjectileGhostReplacementSkillVariant(projectileGhostReplacementSkillVariant); } private static void AddPendingSkillVariant(ModelSkinController modelSkinController, ProjectileGhostReplacement projectileGhostReplacement, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SkinSkillVariantsDef orCreateSkinSkillVariantsDef = GetOrCreateSkinSkillVariantsDef(modelSkinController); projectileGhostReplacementSkillVariant.projectilePrefab = projectileGhostReplacement.projectilePrefab; orCreateSkinSkillVariantsDef.AddProjectileGhostReplacementSkillVariant(projectileGhostReplacementSkillVariant); } private static void AddPendingSkillVariant(SkinDefParams skinDefParams, MinionSkinReplacement minionSkinReplacement, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SkinSkillVariantsDef orCreateSkinSkillVariantsDef = GetOrCreateSkinSkillVariantsDef(skinDefParams); minionSkinReplacementSkillVariant.minionBodyPrefab = minionSkinReplacement.minionBodyPrefab; orCreateSkinSkillVariantsDef.AddMinionSkinReplacementSkillVariant(minionSkinReplacementSkillVariant); } private static void AddPendingSkillVariant(ModelSkinController modelSkinController, MinionSkinReplacement minionSkinReplacement, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SkinSkillVariantsDef orCreateSkinSkillVariantsDef = GetOrCreateSkinSkillVariantsDef(modelSkinController); minionSkinReplacementSkillVariant.minionBodyPrefab = minionSkinReplacement.minionBodyPrefab; orCreateSkinSkillVariantsDef.AddMinionSkinReplacementSkillVariant(minionSkinReplacementSkillVariant); } private static void HandleAddition(SkinDefParams skinDefParams, T1 t1, ref T2 t2) where T1 : ISkillVariantStruct { if (_isLoaded) { t1.Add(ref t2); } else { t1.AddPending(skinDefParams, t2); } } private static void HandleAddition(ModelSkinController modelSkinController, T1 t1, ref T2 t2) where T1 : ISkillVariantStruct { if (_isLoaded) { t1.Add(ref t2); } else { t1.AddPending(modelSkinController, t2); } } private static ref object[] GetSkillVariants(this ref MeshReplacementTemplate meshReplacementTemplate) { return ref SkinAPIInterop.GetSkillVariants(ref meshReplacementTemplate); } private static void SetSkillVariants(this ref MeshReplacementTemplate meshReplacementTemplate, object[] value) { SkinAPIInterop.SetSkillVariants(ref meshReplacementTemplate, value); } private static ref object[] GetSkillVariants(this ref LightReplacementTemplate lightReplacementTemplate) { return ref SkinAPIInterop.GetSkillVariants(ref lightReplacementTemplate); } private static void SetSkillVariants(this ref LightReplacementTemplate lightReplacementTemplate, object[] value) { SkinAPIInterop.SetSkillVariants(ref lightReplacementTemplate, value); } private static ref object[] GetSkillVariants(this ref GhostReplacementTemplate ghostReplacementTemplate) { return ref SkinAPIInterop.GetSkillVariants(ref ghostReplacementTemplate); } private static void SetSkillVariants(this ref GhostReplacementTemplate ghostReplacementTemplate, object[] value) { SkinAPIInterop.SetSkillVariants(ref ghostReplacementTemplate, value); } private static ref object[] GetSkillVariants(this ref MinionSkinTemplate minionSkinTemplate) { return ref SkinAPIInterop.GetSkillVariants(ref minionSkinTemplate); } private static void SetSkillVariants(this ref MinionSkinTemplate minionSkinTemplate, object[] value) { SkinAPIInterop.SetSkillVariants(ref minionSkinTemplate, value); } private static SkinDef GetSkinDef(this RuntimeSkin runtimeSkin) { return SkinAPIInterop.GetSkinDef(runtimeSkin); } private static void SetSkinDef(this RuntimeSkin runtimeSkin, SkinDef skinDef) { SkinAPIInterop.SetSkinDef(runtimeSkin, skinDef); } internal static SkinSkillVariantsDef GetSkinSkillVariantsDef(this SkinDefParams skinDefParams) { if (SkinAPIInterop.GetSkinSkillVariantsDef(skinDefParams) != null) { return SkinAPIInterop.GetSkinSkillVariantsDef(skinDefParams) as SkinSkillVariantsDef; } return null; } internal static void SetSkinSkillVariantsDef(this SkinDefParams skinDefParams, SkinSkillVariantsDef skinSkillVariantsDef) { SkinAPIInterop.SetSkinSkillVariantsDef(skinDefParams, (object)skinSkillVariantsDef); } internal static SkinSkillVariantsDef GetSkinSkillVariantsDef(this ModelSkinController modelSkinController) { if (SkinAPIInterop.GetSkinSkillVariantsDef(modelSkinController) != null) { return SkinAPIInterop.GetSkinSkillVariantsDef(modelSkinController) as SkinSkillVariantsDef; } return null; } internal static void SetSkinSkillVariantsDef(this ModelSkinController modelSkinController, SkinSkillVariantsDef skinSkillVariantsDef) { SkinAPIInterop.SetSkinSkillVariantsDef(modelSkinController, (object)skinSkillVariantsDef); } public static void AddRenderInfoSkillVariant(this SkinDef skinDef, string rendererName, RendererInfoSkillVariant rendererInfoSkillVariant) { GetSkinDefParams(skinDef).AddRenderInfoSkillVariant(rendererName, rendererInfoSkillVariant); } public static void AddRenderInfoSkillVariant(this SkinDefParams skinDefParams, string rendererName, RendererInfoSkillVariant rendererInfoSkillVariant) { SetHooks(); HandleAddition(skinDefParams, rendererInfoSkillVariant, ref GetRendererInfoByName(skinDefParams, rendererName)); } public static void AddRenderInfoSkillVariant(this ModelSkinController modelSkinController, string rendererName, RendererInfoSkillVariant rendererInfoSkillVariant) { SetHooks(); HandleAddition(modelSkinController, rendererInfoSkillVariant, ref GetRendererInfoByName(GetSkinDefParams(modelSkinController.skins[0]), rendererName)); } public static void AddRenderInfoSkillVariant(this SkinDef skinDef, int index, RendererInfoSkillVariant rendererInfoSkillVariant) { GetSkinDefParams(skinDef).AddRenderInfoSkillVariant(index, rendererInfoSkillVariant); } public static void AddRenderInfoSkillVariant(this SkinDefParams skinDefParams, int index, RendererInfoSkillVariant rendererInfoSkillVariant) { SetHooks(); HandleAddition(skinDefParams, rendererInfoSkillVariant, ref skinDefParams.rendererInfos[index]); } public static void AddRenderInfoSkillVariant(this ModelSkinController modelSkinController, int index, RendererInfoSkillVariant rendererInfoSkillVariant) { SetHooks(); HandleAddition(modelSkinController, rendererInfoSkillVariant, ref GetSkinDefParams(modelSkinController.skins[0]).rendererInfos[index]); } public static void AddSkillVariant(this ref RendererInfo rendererInfo, RendererInfoSkillVariant rendererInfoSkillVariant) { SetHooks(); AddItemToObjects(ref rendererInfo.GetSkillVariants(), rendererInfoSkillVariant); } public static void AddMeshReplacementSkillVariant(this SkinDef skinDef, string meshRendererName, MeshReplacementSkillVariant meshReplacementSkillVariant) { GetSkinDefParams(skinDef).AddMeshReplacementSkillVariant(meshRendererName, meshReplacementSkillVariant); } public static void AddMeshReplacementSkillVariant(this SkinDefParams skinDefParams, string meshRendererName, MeshReplacementSkillVariant meshReplacementSkillVariant) { SetHooks(); HandleAddition(skinDefParams, meshReplacementSkillVariant, ref GetMeshReplacementByName(skinDefParams, meshRendererName)); } public static void AddMeshReplacementSkillVariant(this ModelSkinController modelSkinController, string meshRendererName, MeshReplacementSkillVariant meshReplacementSkillVariant) { SetHooks(); HandleAddition(modelSkinController, meshReplacementSkillVariant, ref GetMeshReplacementByName(GetSkinDefParams(modelSkinController.skins[0]), meshRendererName)); } public static void AddMeshReplacementSkillVariant(this SkinDef skinDef, int index, MeshReplacementSkillVariant meshReplacementSkillVariant) { GetSkinDefParams(skinDef).AddMeshReplacementSkillVariant(index, meshReplacementSkillVariant); } public static void AddMeshReplacementSkillVariant(this SkinDefParams skinDefParams, int index, MeshReplacementSkillVariant meshReplacementSkillVariant) { SetHooks(); HandleAddition(skinDefParams, meshReplacementSkillVariant, ref skinDefParams.meshReplacements[index]); } public static void AddMeshReplacementSkillVariant(this ModelSkinController modelSkinController, int index, MeshReplacementSkillVariant meshReplacementSkillVariant) { SetHooks(); HandleAddition(modelSkinController, meshReplacementSkillVariant, ref GetSkinDefParams(modelSkinController.skins[0]).meshReplacements[index]); } public static void AddSkillVariant(this ref MeshReplacement meshReplacement, MeshReplacementSkillVariant meshReplacementSkillVariant) { SetHooks(); AddItemToObjects(ref meshReplacement.GetSkillVariants(), meshReplacementSkillVariant); } public static void AddLightInfoSkillVariant(this SkinDef skinDef, string lightName, LightInfoSkillVariant lightInfoSkillVariant) { GetSkinDefParams(skinDef).AddLightInfoSkillVariant(lightName, lightInfoSkillVariant); } public static void AddLightInfoSkillVariant(this SkinDefParams skinDefParams, string lightName, LightInfoSkillVariant lightInfoSkillVariant) { SetHooks(); HandleAddition(skinDefParams, lightInfoSkillVariant, ref GetLightInfoByName(skinDefParams, lightName)); } public static void AddLightInfoSkillVariant(this ModelSkinController modelSkinController, string lightName, LightInfoSkillVariant lightInfoSkillVariant) { SetHooks(); HandleAddition(modelSkinController, lightInfoSkillVariant, ref GetLightInfoByName(GetSkinDefParams(modelSkinController.skins[0]), lightName)); } public static void AddLightInfoSkillVariant(this SkinDef skinDef, int index, LightInfoSkillVariant lightInfoSkillVariant) { GetSkinDefParams(skinDef).AddLightInfoSkillVariant(index, lightInfoSkillVariant); } public static void AddLightInfoSkillVariant(this SkinDefParams skinDefParams, int index, LightInfoSkillVariant lightInfoSkillVariant) { SetHooks(); HandleAddition(skinDefParams, lightInfoSkillVariant, ref skinDefParams.lightReplacements[index]); } public static void AddLightInfoSkillVariant(this ModelSkinController modelSkinController, int index, LightInfoSkillVariant lightInfoSkillVariant) { SetHooks(); HandleAddition(modelSkinController, lightInfoSkillVariant, ref GetSkinDefParams(modelSkinController.skins[0]).lightReplacements[index]); } public static void AddSkillVariant(this ref LightInfo lightInfo, LightInfoSkillVariant lightInfoSkillVariant) { SetHooks(); AddItemToObjects(ref lightInfo.GetSkillVariants(), lightInfoSkillVariant); } public static void AddProjectileGhostReplacementSkillVariant(this SkinDef skinDef, string projectileName, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { GetSkinDefParams(skinDef).AddProjectileGhostReplacementSkillVariant(projectileName, projectileGhostReplacementSkillVariant); } public static void AddProjectileGhostReplacementSkillVariant(this SkinDefParams skinDefParams, string projectileName, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { SetHooks(); HandleAddition(skinDefParams, projectileGhostReplacementSkillVariant, ref GetProjectileGhostReplacementByName(skinDefParams, projectileName)); } public static void AddProjectileGhostReplacementSkillVariant(this ModelSkinController modelSkinController, string projectileName, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { SetHooks(); HandleAddition(modelSkinController, projectileGhostReplacementSkillVariant, ref GetProjectileGhostReplacementByName(GetSkinDefParams(modelSkinController.skins[0]), projectileName)); } public static void AddProjectileGhostReplacementSkillVariant(this SkinDef skinDef, GameObject projectilePrefab, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { GetSkinDefParams(skinDef).AddProjectileGhostReplacementSkillVariant(projectilePrefab, projectileGhostReplacementSkillVariant); } public static void AddProjectileGhostReplacementSkillVariant(this SkinDefParams skinDefParams, GameObject projectilePrefab, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { SetHooks(); HandleAddition(skinDefParams, projectileGhostReplacementSkillVariant, ref GetProjectileGhostReplacementByPrefab(skinDefParams, projectilePrefab)); } public static void AddProjectileGhostReplacementSkillVariant(this ModelSkinController modelSkinController, GameObject projectilePrefab, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { SetHooks(); HandleAddition(modelSkinController, projectileGhostReplacementSkillVariant, ref GetProjectileGhostReplacementByPrefab(GetSkinDefParams(modelSkinController.skins[0]), projectilePrefab)); } public static void AddProjectileGhostReplacementSkillVariant(this SkinDef skinDef, int index, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { GetSkinDefParams(skinDef).AddProjectileGhostReplacementSkillVariant(index, projectileGhostReplacementSkillVariant); } public static void AddProjectileGhostReplacementSkillVariant(this SkinDefParams skinDefParams, int index, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { SetHooks(); HandleAddition(skinDefParams, projectileGhostReplacementSkillVariant, ref skinDefParams.projectileGhostReplacements[index]); } public static void AddProjectileGhostReplacementSkillVariant(this ModelSkinController modelSkinController, int index, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { SetHooks(); HandleAddition(modelSkinController, projectileGhostReplacementSkillVariant, ref GetSkinDefParams(modelSkinController.skins[0]).projectileGhostReplacements[index]); } public static void AddSkillVariant(this ref ProjectileGhostReplacement projectileGhostReplacement, ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { SetHooks(); AddItemToObjects(ref projectileGhostReplacement.GetSkillVariants(), projectileGhostReplacementSkillVariant); } public static void AddMinionSkinReplacementSkillVariant(this SkinDef skinDef, string minionBodyName, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { GetSkinDefParams(skinDef).AddMinionSkinReplacementSkillVariant(minionBodyName, minionSkinReplacementSkillVariant); } public static void AddMinionSkinReplacementSkillVariant(this SkinDefParams skinDefParams, string minionBodyName, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { SetHooks(); HandleAddition(skinDefParams, minionSkinReplacementSkillVariant, ref GetMinionSkinReplacementByName(skinDefParams, minionBodyName)); } public static void AddMinionSkinReplacementSkillVariant(this ModelSkinController modelSkinController, string minionBodyName, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { SetHooks(); HandleAddition(modelSkinController, minionSkinReplacementSkillVariant, ref GetMinionSkinReplacementByName(GetSkinDefParams(modelSkinController.skins[0]), minionBodyName)); } public static void AddMinionSkinReplacementSkillVariant(this SkinDef skinDef, GameObject minionBodyPrefab, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { GetSkinDefParams(skinDef).AddMinionSkinReplacementSkillVariant(minionBodyPrefab, minionSkinReplacementSkillVariant); } public static void AddMinionSkinReplacementSkillVariant(this SkinDefParams skinDefParams, GameObject minionBodyPrefab, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { SetHooks(); HandleAddition(skinDefParams, minionSkinReplacementSkillVariant, ref GetMinionSkinReplacementByPrefab(skinDefParams, minionBodyPrefab)); } public static void AddMinionSkinReplacementSkillVariant(this ModelSkinController modelSkinController, GameObject minionBodyPrefab, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { SetHooks(); HandleAddition(modelSkinController, minionSkinReplacementSkillVariant, ref GetMinionSkinReplacementByPrefab(GetSkinDefParams(modelSkinController.skins[0]), minionBodyPrefab)); } public static void AddMinionSkinReplacementSkillVariant(this SkinDef skinDef, int index, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { GetSkinDefParams(skinDef).AddMinionSkinReplacementSkillVariant(index, minionSkinReplacementSkillVariant); } public static void AddMinionSkinReplacementSkillVariant(this SkinDefParams skinDefParams, int index, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { SetHooks(); HandleAddition(skinDefParams, minionSkinReplacementSkillVariant, ref skinDefParams.minionSkinReplacements[index]); } public static void AddMinionSkinReplacementSkillVariant(this ModelSkinController modelSkinController, int index, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { SetHooks(); HandleAddition(modelSkinController, minionSkinReplacementSkillVariant, ref GetSkinDefParams(modelSkinController.skins[0]).minionSkinReplacements[index]); } public static void AddSkillVariant(this ref MinionSkinReplacement minionSkinReplacement, MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { SetHooks(); AddItemToObjects(ref minionSkinReplacement.GetSkillVariants(), minionSkinReplacementSkillVariant); } public static ref object[] GetSkillVariants(this ref RendererInfo rendererInfo) { return ref SkinAPIInterop.GetSkillVariants(ref rendererInfo); } public static void SetSkillVariants(this ref RendererInfo rendererInfo, object[] value) { SkinAPIInterop.SetSkillVariants(ref rendererInfo, value); } public static ref object[] GetSkillVariants(this ref MeshReplacement meshReplacement) { return ref SkinAPIInterop.GetSkillVariants(ref meshReplacement); } public static void SetSkillVariants(this ref MeshReplacement meshReplacement, object[] value) { SkinAPIInterop.SetSkillVariants(ref meshReplacement, value); } public static ref object[] GetSkillVariants(this ref LightInfo lightInfo) { return ref SkinAPIInterop.GetSkillVariants(ref lightInfo); } public static void SetSkillVariants(this ref LightInfo lightInfo, object[] value) { SkinAPIInterop.SetSkillVariants(ref lightInfo, value); } public static ref object[] GetSkillVariants(this ref ProjectileGhostReplacement projectileGhostReplacement) { return ref SkinAPIInterop.GetSkillVariants(ref projectileGhostReplacement); } public static void SetSkillVariants(this ref ProjectileGhostReplacement projectileGhostReplacement, object[] value) { SkinAPIInterop.SetSkillVariants(ref projectileGhostReplacement, value); } public static ref object[] GetSkillVariants(this ref MinionSkinReplacement minionSkinReplacement) { return ref SkinAPIInterop.GetSkillVariants(ref minionSkinReplacement); } public static void SetSkillVariants(this ref MinionSkinReplacement minionSkinReplacement, object[] value) { SkinAPIInterop.SetSkillVariants(ref minionSkinReplacement, value); } public static OnSkinApplied GetOnSkinApplied(this SkinDef skinDef) { if ((object)SkinAPIInterop.GetOnSkinApplied(skinDef) != null) { return SkinAPIInterop.GetOnSkinApplied(skinDef) as OnSkinApplied; } return null; } public static void SetOnSkinApplied(this SkinDef skinDef, OnSkinApplied onSkinApplied) { SkinAPIInterop.SetOnSkinApplied(skinDef, (Delegate)onSkinApplied); } } [CreateAssetMenu(menuName = "R2API/SkinsAPI/SkinSkillVariantsDef")] public class SkinSkillVariantsDef : ScriptableObject { [CompilerGenerated] private sealed class d__20 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SkinSkillVariantsDef <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; SkinSkillVariantsDef skinSkillVariantsDef = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; if (skinSkillVariantsDef.applied) { return false; } if ((Object)(object)skinSkillVariantsDef.modelSkinController != (Object)null) { List list = new List(); SkinDef[] skins = skinSkillVariantsDef.modelSkinController.skins; foreach (SkinDef skinDef in skins) { SkinDefParams skinDefParams = SkinSkillVariants.GetSkinDefParams(skinDef); if (Object.op_Implicit((Object)(object)skinDefParams) && !list.Contains(skinDefParams)) { list.Add(skinDefParams); } SkinDefParams optimizedSkinDefParams = SkinSkillVariants.GetOptimizedSkinDefParams(skinDef); if (Object.op_Implicit((Object)(object)optimizedSkinDefParams) && !list.Contains(skinDefParams)) { list.Add(optimizedSkinDefParams); } } skinSkillVariantsDef.HandleArray(list.ToArray()); } skinSkillVariantsDef.HandleArray(skinSkillVariantsDef.skinDefParameters); skinSkillVariantsDef.applied = true; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static List pendingSkinSkillVariantsDefs = new List(); [Tooltip("SkinDefParams to apply SkillVariants")] public SkinDefParams[] skinDefParameters = Array.Empty(); [Tooltip("Put ModelSkinController from body prefab if you want this to be applied to all possible skins")] [PrefabReference] public ModelSkinController modelSkinController; public SkinSkillVariants.RendererInfoSkillVariant[] rendererInfoSkillVariants = Array.Empty(); public SkinSkillVariants.MeshReplacementSkillVariant[] meshReplacementSkillVariants = Array.Empty(); public SkinSkillVariants.LightInfoSkillVariant[] lightInfoSkillVariants = Array.Empty(); public SkinSkillVariants.ProjectileGhostReplacementSkillVariant[] projectileGhostReplacementSkillVariants = Array.Empty(); public SkinSkillVariants.MinionSkinReplacementSkillVariant[] minionSkinReplacementSkillVariants = Array.Empty(); public bool lowPriority; private bool registered; private bool applied; public void AddSkinDefParams(SkinDefParams skinDefParams) { Add(ref skinDefParameters, skinDefParams); } public void AddRendererInfoSkillVariant(SkinSkillVariants.RendererInfoSkillVariant rendererInfoSkillVariant) { Add(ref rendererInfoSkillVariants, rendererInfoSkillVariant); } public void AddMeshReplacementSkillVariant(SkinSkillVariants.MeshReplacementSkillVariant meshReplacementSkillVariant) { Add(ref meshReplacementSkillVariants, meshReplacementSkillVariant); } public void AddLightInfoSkillVariant(SkinSkillVariants.LightInfoSkillVariant lightInfoSkillVariant) { Add(ref lightInfoSkillVariants, lightInfoSkillVariant); } public void AddProjectileGhostReplacementSkillVariant(SkinSkillVariants.ProjectileGhostReplacementSkillVariant projectileGhostReplacementSkillVariant) { Add(ref projectileGhostReplacementSkillVariants, projectileGhostReplacementSkillVariant); } public void AddMinionSkinReplacementSkillVariant(SkinSkillVariants.MinionSkinReplacementSkillVariant minionSkinReplacementSkillVariant) { Add(ref minionSkinReplacementSkillVariants, minionSkinReplacementSkillVariant); } private void Add(ref T[] values, T value) { int num = values.Length; Array.Resize(ref values, num + 1); values[num] = value; } public void Register() { if (!registered) { pendingSkinSkillVariantsDefs.Add(this); registered = true; } } internal void Apply() { IEnumerator enumerator = ApplyAsync(); while (enumerator.MoveNext()) { } } [IteratorStateMachine(typeof(d__20))] internal IEnumerator ApplyAsync() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0) { <>4__this = this }; } private void HandleArray(SkinDefParams[] skinDefParamsArray) { foreach (SkinDefParams val in skinDefParamsArray) { if (!((Object)(object)val == (Object)null)) { RendererInfo[] t1s = val.rendererInfos; PopulateValues(ref t1s, rendererInfoSkillVariants); MeshReplacement[] t1s2 = val.meshReplacements; PopulateValues(ref t1s2, meshReplacementSkillVariants); LightInfo[] t1s3 = val.lightReplacements; PopulateValues(ref t1s3, lightInfoSkillVariants); ProjectileGhostReplacement[] t1s4 = val.projectileGhostReplacements; PopulateValues(ref t1s4, projectileGhostReplacementSkillVariants); MinionSkinReplacement[] t1s5 = val.minionSkinReplacements; PopulateValues(ref t1s5, minionSkinReplacementSkillVariants); } } } private void PopulateValues(ref T1[] t1s, T2[] t2s) where T2 : SkinSkillVariants.ISkillVariantStruct { if (t1s == null || t1s.Length == 0 || t2s == null || t2s.Length == 0) { return; } for (int i = 0; i < t2s.Length; i++) { T2 val = t2s[i]; if (val.NullCheck()) { continue; } for (int j = 0; j < t1s.Length; j++) { ref T1 reference = ref t1s[j]; if (val.Compare(reference)) { val.lowPriority = lowPriority; val.Add(ref reference); } } } } } [BepInPlugin("com.bepis.r2api.skins", "R2API.Skins", "1.4.7")] public sealed class SkinsPlugin : BaseUnityPlugin { public static Harmony harmonyPatcher; internal static ManualLogSource Logger { get; set; } internal static SkinsPlugin Instance { get; private set; } private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Instance = this; Logger = ((BaseUnityPlugin)this).Logger; harmonyPatcher = new Harmony("com.bepis.r2api.skins"); } private void OnEnable() { Skins.SetHooks(); SkinIDRS.SetHooks(); SkinVFX.SetHooks(); SkinSkillVariants.SetHooks(); } private void OnDisable() { Skins.UnsetHooks(); SkinIDRS.UnsetHooks(); SkinVFX.UnsetHooks(); SkinSkillVariants.UnsetHooks(); } } public static class SkinVFX { public delegate void OnEffectSpawnedDelegate(GameObject spawnedEffect); [CompilerGenerated] private static class <>O { public static hook_Start <0>__ApplyModifier; public static hook_SpawnEffect_GameObject_EffectData_bool <1>__ApplyReplacement; public static Manipulator <2>__ModifyBulletAttack; public static Manipulator <3>__ModifyMuzzleFlash; public static hook_BeginMeleeAttackEffect <4>__ModifyGenericMelee; public static Manipulator <5>__ModifyGenericOrb; } private static List skinVFXInfos = new List(); private static bool hooksSet = false; private const uint BaseIdentifier = 24000u; private static uint currentIdentifier = 24000u; private static bool hasCatalogInitOccured = false; private static uint nextIdentifier => currentIdentifier++; internal static void SetHooks() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown if (!hooksSet) { hooksSet = true; object obj = <>O.<0>__ApplyModifier; if (obj == null) { hook_Start val = ApplyModifier; <>O.<0>__ApplyModifier = val; obj = (object)val; } EffectComponent.Start += (hook_Start)obj; object obj2 = <>O.<1>__ApplyReplacement; if (obj2 == null) { hook_SpawnEffect_GameObject_EffectData_bool val2 = ApplyReplacement; <>O.<1>__ApplyReplacement = val2; obj2 = (object)val2; } EffectManager.SpawnEffect_GameObject_EffectData_bool += (hook_SpawnEffect_GameObject_EffectData_bool)obj2; object obj3 = <>O.<2>__ModifyBulletAttack; if (obj3 == null) { Manipulator val3 = ModifyBulletAttack; <>O.<2>__ModifyBulletAttack = val3; obj3 = (object)val3; } BulletAttack.FireSingle += (Manipulator)obj3; object obj4 = <>O.<3>__ModifyMuzzleFlash; if (obj4 == null) { Manipulator val4 = ModifyMuzzleFlash; <>O.<3>__ModifyMuzzleFlash = val4; obj4 = (object)val4; } EffectManager.SimpleMuzzleFlash += (Manipulator)obj4; object obj5 = <>O.<4>__ModifyGenericMelee; if (obj5 == null) { hook_BeginMeleeAttackEffect val5 = ModifyGenericMelee; <>O.<4>__ModifyGenericMelee = val5; obj5 = (object)val5; } BasicMeleeAttack.BeginMeleeAttackEffect += (hook_BeginMeleeAttackEffect)obj5; object obj6 = <>O.<5>__ModifyGenericOrb; if (obj6 == null) { Manipulator val6 = ModifyGenericOrb; <>O.<5>__ModifyGenericOrb = val6; obj6 = (object)val6; } GenericDamageOrb.Begin += (Manipulator)obj6; } } internal static void UnsetHooks() { //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_0021: Expected O, but got Unknown //IL_0036: 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_0041: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown hooksSet = false; object obj = <>O.<0>__ApplyModifier; if (obj == null) { hook_Start val = ApplyModifier; <>O.<0>__ApplyModifier = val; obj = (object)val; } EffectComponent.Start -= (hook_Start)obj; object obj2 = <>O.<1>__ApplyReplacement; if (obj2 == null) { hook_SpawnEffect_GameObject_EffectData_bool val2 = ApplyReplacement; <>O.<1>__ApplyReplacement = val2; obj2 = (object)val2; } EffectManager.SpawnEffect_GameObject_EffectData_bool -= (hook_SpawnEffect_GameObject_EffectData_bool)obj2; object obj3 = <>O.<2>__ModifyBulletAttack; if (obj3 == null) { Manipulator val3 = ModifyBulletAttack; <>O.<2>__ModifyBulletAttack = val3; obj3 = (object)val3; } BulletAttack.FireSingle -= (Manipulator)obj3; object obj4 = <>O.<3>__ModifyMuzzleFlash; if (obj4 == null) { Manipulator val4 = ModifyMuzzleFlash; <>O.<3>__ModifyMuzzleFlash = val4; obj4 = (object)val4; } EffectManager.SimpleMuzzleFlash -= (Manipulator)obj4; object obj5 = <>O.<4>__ModifyGenericMelee; if (obj5 == null) { hook_BeginMeleeAttackEffect val5 = ModifyGenericMelee; <>O.<4>__ModifyGenericMelee = val5; obj5 = (object)val5; } BasicMeleeAttack.BeginMeleeAttackEffect -= (hook_BeginMeleeAttackEffect)obj5; object obj6 = <>O.<5>__ModifyGenericOrb; if (obj6 == null) { Manipulator val6 = ModifyGenericOrb; <>O.<5>__ModifyGenericOrb = val6; obj6 = (object)val6; } GenericDamageOrb.Begin -= (Manipulator)obj6; } [SystemInitializer(new Type[] { typeof(EffectCatalog) })] private static void FindEffectIndexes() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) hasCatalogInitOccured = true; for (int i = 0; i < skinVFXInfos.Count; i++) { SkinVFXInfo skinVFXInfo = skinVFXInfos[i]; if (Object.op_Implicit((Object)(object)skinVFXInfo.EffectPrefab)) { skinVFXInfo.TargetEffect = EffectCatalog.FindEffectIndexFromPrefab(skinVFXInfo.EffectPrefab); } else if (!string.IsNullOrEmpty(skinVFXInfo.EffectString)) { EffectDef val = ((IEnumerable)EffectCatalog.entries).FirstOrDefault((Func)((EffectDef effectDef) => effectDef.prefabName == skinVFXInfo.EffectString)); if (val == null) { SkinsPlugin.Logger.LogError((object)("Failed to find effect " + skinVFXInfo.EffectString + " for SkinVFXInfo!")); } else { skinVFXInfo.TargetEffect = val.index; } } } } private static SkinVFXInfo FindSkinVFXInfo(uint identifier) { if (identifier < 24000 || identifier >= (long)skinVFXInfos.Count + 24000L) { return null; } return skinVFXInfos[(int)(identifier - 24000)]; } private static SkinVFXInfo FindSkinVFXInfo(GameObject attacker, GameObject effectPrefab) { //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) GameObject effectPrefab2 = effectPrefab; if (!Object.op_Implicit((Object)(object)attacker) || !Object.op_Implicit((Object)(object)effectPrefab2)) { return null; } SkinDef skinDef = SkinCatalog.FindCurrentSkinDefForBodyInstance(attacker); EffectIndex index = EffectCatalog.FindEffectIndexFromPrefab(effectPrefab2); return skinVFXInfos.FirstOrDefault((SkinVFXInfo skinVFXInfo) => (Object)(object)skinVFXInfo.RequiredSkin == (Object)(object)skinDef && (((int)index != -1) ? (skinVFXInfo.TargetEffect == index) : ((Object)(object)skinVFXInfo.EffectPrefab == (Object)(object)effectPrefab2))); } private static void ModifyGenericMelee(orig_BeginMeleeAttackEffect orig, BasicMeleeAttack self) { SkinVFXInfo skinVFXInfo = FindSkinVFXInfo(((EntityState)self).gameObject, self.swingEffectPrefab); bool num = !Object.op_Implicit((Object)(object)self.swingEffectInstance); if (skinVFXInfo != null && Object.op_Implicit((Object)(object)skinVFXInfo.ReplacementEffectPrefab)) { self.swingEffectPrefab = skinVFXInfo.ReplacementEffectPrefab; } orig.Invoke(self); if (num && skinVFXInfo != null && skinVFXInfo.OnEffectSpawned != null && Object.op_Implicit((Object)(object)self.swingEffectInstance)) { skinVFXInfo.OnEffectSpawned(self.swingEffectInstance); } } private static void ApplyReplacement(orig_SpawnEffect_GameObject_EffectData_bool orig, GameObject effectPrefab, EffectData effectData, bool transmit) { if (effectData == null) { orig.Invoke(effectPrefab, effectData, transmit); return; } if (effectData.genericUInt < 24000) { orig.Invoke(effectPrefab, effectData, transmit); return; } SkinVFXInfo skinVFXInfo = FindSkinVFXInfo(effectData.genericUInt); if (skinVFXInfo == null) { orig.Invoke(effectPrefab, effectData, transmit); } else if ((Object)(object)skinVFXInfo.ReplacementEffectPrefab != (Object)null) { orig.Invoke(skinVFXInfo.ReplacementEffectPrefab, effectData, transmit); } else { orig.Invoke(effectPrefab, effectData, transmit); } } private static void ApplyModifier(orig_Start orig, EffectComponent self) { orig.Invoke(self); if (self.effectData != null && self.effectData.genericUInt >= 24000) { FindSkinVFXInfo(self.effectData.genericUInt)?.OnEffectSpawned?.Invoke(((Component)self).gameObject); } } private static void ModifyMuzzleFlash(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0049: 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_0061: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "SetChildLocatorTransformReference") })) { SkinsPlugin.Logger.LogError((object)"Failed to apply SkinVFX IL hook on EffectManager.SimpleMuzzleFlash"); return; } val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldarg_1); val.Emit(OpCodes.Ldloc, 4); val.EmitDelegate>((Action)delegate(GameObject effectPrefab, GameObject owner, EffectData data) { SkinVFXInfo skinVFXInfo = FindSkinVFXInfo(owner, effectPrefab); if (skinVFXInfo != null) { data.genericUInt = skinVFXInfo.Identifier; } }); } private static void ModifyGenericOrb(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "SetHurtBoxReference") })) { SkinsPlugin.Logger.LogError((object)$"Failed to apply SkinVFX IL hook on {il.Method.DeclaringType}.{((MemberReference)il.Method).Name}"); return; } val.Emit(OpCodes.Ldloc_0); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(EffectData data, GenericDamageOrb orb) { if (data != null && Object.op_Implicit((Object)(object)orb.attacker)) { SkinVFXInfo skinVFXInfo = FindSkinVFXInfo(orb.attacker, orb.GetOrbEffect()); if (skinVFXInfo != null) { data.genericUInt = skinVFXInfo.Identifier; } } }); } private static void ModifyBulletAttack(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "SetChildLocatorTransformReference") })) { SkinsPlugin.Logger.LogError((object)"Failed to apply SkinVFX IL hook on BulletAttack.FireSingle"); return; } val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(BulletAttack bulletAttack) { SkinVFXInfo skinVFXInfo = FindSkinVFXInfo(bulletAttack.owner, bulletAttack.tracerEffectPrefab); if (skinVFXInfo != null) { BulletAttack.pooledEffectData.genericUInt = skinVFXInfo.Identifier; } }); } public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, EffectIndex targetEffect, GameObject replacementPrefab) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) SetHooks(); SkinVFXInfo obj = new SkinVFXInfo { RequiredSkin = skinDef, TargetEffect = targetEffect, ReplacementEffectPrefab = replacementPrefab }; AddSkinVFX(obj); return obj; } public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, string targetEffect, GameObject replacementPrefab) { SetHooks(); SkinVFXInfo obj = new SkinVFXInfo { RequiredSkin = skinDef, EffectString = targetEffect, ReplacementEffectPrefab = replacementPrefab }; AddSkinVFX(obj); return obj; } public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, GameObject targetEffect, GameObject replacementPrefab) { SetHooks(); SkinVFXInfo obj = new SkinVFXInfo { RequiredSkin = skinDef, EffectPrefab = targetEffect, ReplacementEffectPrefab = replacementPrefab }; AddSkinVFX(obj); return obj; } public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, EffectIndex targetEffect, OnEffectSpawnedDelegate onEffectSpawned) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) SetHooks(); SkinVFXInfo obj = new SkinVFXInfo { RequiredSkin = skinDef, TargetEffect = targetEffect, OnEffectSpawned = onEffectSpawned }; AddSkinVFX(obj); return obj; } public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, string targetEffect, OnEffectSpawnedDelegate onEffectSpawned) { SetHooks(); SkinVFXInfo obj = new SkinVFXInfo { RequiredSkin = skinDef, EffectString = targetEffect, OnEffectSpawned = onEffectSpawned }; AddSkinVFX(obj); return obj; } public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, GameObject targetEffect, OnEffectSpawnedDelegate onEffectSpawned) { SetHooks(); SkinVFXInfo obj = new SkinVFXInfo { RequiredSkin = skinDef, EffectPrefab = targetEffect, OnEffectSpawned = onEffectSpawned }; AddSkinVFX(obj); return obj; } public static bool AddSkinVFX(SkinVFXInfo skinVFXInfo) { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) SkinVFXInfo skinVFXInfo2 = skinVFXInfo; SetHooks(); if (hasCatalogInitOccured && (Object)(object)skinVFXInfo2.EffectPrefab != (Object)null) { skinVFXInfo2.TargetEffect = EffectCatalog.FindEffectIndexFromPrefab(skinVFXInfo2.EffectPrefab); EffectDef val = ((IEnumerable)EffectCatalog.entries).FirstOrDefault((Func)((EffectDef effectDef) => effectDef.prefabName == skinVFXInfo2.EffectString)); if (val == null) { SkinsPlugin.Logger.LogError((object)("Failed to find effect " + skinVFXInfo2.EffectString + " for SkinVFXInfo!")); return false; } skinVFXInfo2.TargetEffect = val.index; } if ((Object)(object)skinVFXInfo2.RequiredSkin == (Object)null) { SkinsPlugin.Logger.LogError((object)"Cannot add a SkinVFXInfo with no assigned SkinDef."); return false; } if ((int)skinVFXInfo2.TargetEffect == -1 && (Object)(object)skinVFXInfo2.EffectPrefab == (Object)null && skinVFXInfo2.EffectString == null) { SkinsPlugin.Logger.LogError((object)"SkinVFXInfo may not have a TargetEffect of EffectIndex.Invalid, or must also specify an EffectPrefab or EffectString."); return false; } if ((Object)(object)skinVFXInfo2.ReplacementEffectPrefab == (Object)null && skinVFXInfo2.OnEffectSpawned == null) { SkinsPlugin.Logger.LogError((object)"SkinVFXInfo must have either a ReplacementEffectPrefab or an OnEffectSpawnedDelegate assigned."); return false; } skinVFXInfo2.Identifier = nextIdentifier; skinVFXInfos.Add(skinVFXInfo2); return true; } } public class SkinVFXInfo { public SkinDef RequiredSkin; public EffectIndex TargetEffect = (EffectIndex)(-1); public GameObject? ReplacementEffectPrefab; public SkinVFX.OnEffectSpawnedDelegate? OnEffectSpawned; public uint Identifier = uint.MaxValue; public GameObject EffectPrefab; public string EffectString; } } namespace R2API.AutoVersionGen { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] internal class AutoVersionAttribute : Attribute { } }