using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using MonoMod.RuntimeDetour; using MonoMod.RuntimeDetour.HookGen; using RoR2; using RoR2.ContentManagement; using RuneFoxMods.DynamicSkins; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace ExperimentAsNemesisCommando { [BepInPlugin("com.Nooooooah820.ExperimentAsNemesisCommando", "Experiment as Nemesis Commando", "1.0.1")] public class ExperimentAsNemesisCommandoPlugin : BaseUnityPlugin { private class FieldException : Exception { public FieldException(string message, Exception innerException) : base(message, innerException) { } } private class ElementException : Exception { public int Index { get; } public ElementException(int index, string message) : base(message) { Index = index; } } public class DynamicSkinExtension { private Modification ExpieYellowNemCommandoDeftail00Modification; private Modification ExpieYellowNemCommandoDefscarfbModification; private Modification ExpieYellowNemCommandoDefscarffModification; private Modification ExpieYellowNemCommandoDefbandageL00Modification; private Modification ExpieYellowNemCommandoDefbandageR00Modification; private Modification ExpieYellowNemCommandoDefbandageFR00Modification; private Modification GreenExpieYellowNemCommandoDeftail00Modification; private Modification GreenExpieYellowNemCommandoDefscarfbModification; private Modification GreenExpieYellowNemCommandoDefscarffModification; private Modification GreenExpieYellowNemCommandoDefbandageL00Modification; private Modification GreenExpieYellowNemCommandoDefbandageR00Modification; private Modification GreenExpieYellowNemCommandoDefbandageFR00Modification; internal void BeforeStart() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) _DynamicSkinManager.InstanceLogger = ((BaseUnityPlugin)Instance).Logger; new Hook((MethodBase)typeof(SkinDef).GetMethod("Apply"), (Delegate)new Action, SkinDef, GameObject>(_DynamicSkinManager.SkinDefApply)).Apply(); } internal void AfterStart() { InitializeModifications(); InitializeDynamicBones(); AddModificationsToList(); } internal void BeforeBodyCatalogInit() { NemCommandoBodyExpieYellowNemCommandoDefSkinAddedEvent += onSkinAdded; NemCommandoBodyGreenExpieYellowNemCommandoDefSkinAddedEvent += onSkinAdded; } internal void AfterBodyCatalogInit() { } private void InitializeModifications() { ExpieYellowNemCommandoDeftail00Modification = new Modification("tail00.prefab", "pelvis", "NemCommandoBody", "NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 92, AffectsBaseModel: true, assetBundle); ExpieYellowNemCommandoDefscarfbModification = new Modification("scarfb.prefab", "neck", "NemCommandoBody", "NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 5, AffectsBaseModel: true, assetBundle); ExpieYellowNemCommandoDefscarffModification = new Modification("scarff.prefab", "neck", "NemCommandoBody", "NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 19, AffectsBaseModel: true, assetBundle); ExpieYellowNemCommandoDefbandageL00Modification = new Modification("bandageL00.prefab", "lower_arm.l", "NemCommandoBody", "NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 42, AffectsBaseModel: true, assetBundle); ExpieYellowNemCommandoDefbandageR00Modification = new Modification("bandageR00.prefab", "lower_arm.r", "NemCommandoBody", "NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 76, AffectsBaseModel: true, assetBundle); ExpieYellowNemCommandoDefbandageFR00Modification = new Modification("bandageFR00.prefab", "hand.r", "NemCommandoBody", "NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 72, AffectsBaseModel: true, assetBundle); GreenExpieYellowNemCommandoDeftail00Modification = new Modification("tail00.prefab", "pelvis", "NemCommandoBody", "NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 92, AffectsBaseModel: true, assetBundle); GreenExpieYellowNemCommandoDefscarfbModification = new Modification("scarfb.prefab", "neck", "NemCommandoBody", "NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 5, AffectsBaseModel: true, assetBundle); GreenExpieYellowNemCommandoDefscarffModification = new Modification("scarff.prefab", "neck", "NemCommandoBody", "NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 19, AffectsBaseModel: true, assetBundle); GreenExpieYellowNemCommandoDefbandageL00Modification = new Modification("bandageL00.prefab", "lower_arm.l", "NemCommandoBody", "NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 42, AffectsBaseModel: true, assetBundle); GreenExpieYellowNemCommandoDefbandageR00Modification = new Modification("bandageR00.prefab", "lower_arm.r", "NemCommandoBody", "NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 76, AffectsBaseModel: true, assetBundle); GreenExpieYellowNemCommandoDefbandageFR00Modification = new Modification("bandageFR00.prefab", "hand.r", "NemCommandoBody", "NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 72, AffectsBaseModel: true, assetBundle); } private void InitializeDynamicBones() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0059: Unknown result type (might be due to invalid IL or missing references) //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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_01dd: Expected O, but got Unknown //IL_01dd: Expected O, but got Unknown //IL_0210: 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_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Expected O, but got Unknown //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_0605: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_064f: Unknown result type (might be due to invalid IL or missing references) //IL_0660: Unknown result type (might be due to invalid IL or missing references) //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0676: Unknown result type (might be due to invalid IL or missing references) //IL_0694: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_06af: Unknown result type (might be due to invalid IL or missing references) //IL_06b4: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Unknown result type (might be due to invalid IL or missing references) //IL_06c0: Unknown result type (might be due to invalid IL or missing references) //IL_06e1: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_0729: Unknown result type (might be due to invalid IL or missing references) //IL_0759: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Expected O, but got Unknown //IL_0789: Expected O, but got Unknown //IL_0789: Expected O, but got Unknown //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07c1: Unknown result type (might be due to invalid IL or missing references) //IL_07d2: Unknown result type (might be due to invalid IL or missing references) //IL_07d7: Unknown result type (might be due to invalid IL or missing references) //IL_07dc: Unknown result type (might be due to invalid IL or missing references) //IL_07e1: Unknown result type (might be due to invalid IL or missing references) //IL_07e8: Unknown result type (might be due to invalid IL or missing references) //IL_080f: Unknown result type (might be due to invalid IL or missing references) //IL_0823: Unknown result type (might be due to invalid IL or missing references) //IL_0837: Unknown result type (might be due to invalid IL or missing references) //IL_0857: Unknown result type (might be due to invalid IL or missing references) //IL_0887: Unknown result type (might be due to invalid IL or missing references) //IL_08b7: Expected O, but got Unknown //IL_08ea: Unknown result type (might be due to invalid IL or missing references) //IL_08ef: Unknown result type (might be due to invalid IL or missing references) //IL_0900: Unknown result type (might be due to invalid IL or missing references) //IL_0905: Unknown result type (might be due to invalid IL or missing references) //IL_090a: Unknown result type (might be due to invalid IL or missing references) //IL_090f: Unknown result type (might be due to invalid IL or missing references) //IL_0916: Unknown result type (might be due to invalid IL or missing references) //IL_093d: Unknown result type (might be due to invalid IL or missing references) //IL_0951: Unknown result type (might be due to invalid IL or missing references) //IL_0965: Unknown result type (might be due to invalid IL or missing references) //IL_0985: Unknown result type (might be due to invalid IL or missing references) //IL_09b5: Expected O, but got Unknown //IL_09f7: Unknown result type (might be due to invalid IL or missing references) //IL_0a0b: Unknown result type (might be due to invalid IL or missing references) //IL_0a1f: Unknown result type (might be due to invalid IL or missing references) //IL_0a81: Unknown result type (might be due to invalid IL or missing references) //IL_0a95: Unknown result type (might be due to invalid IL or missing references) //IL_0aa9: Unknown result type (might be due to invalid IL or missing references) //IL_0b0b: Unknown result type (might be due to invalid IL or missing references) //IL_0b1f: Unknown result type (might be due to invalid IL or missing references) //IL_0b33: Unknown result type (might be due to invalid IL or missing references) ExpieYellowNemCommandoDeftail00Modification.dynamicBoneData = new DynamicBoneData("tail00", 0.317f, null, 0.353f, new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 1f), new Keyframe(0.2862106f, 0.7048314f), new Keyframe(1.004181f, 0.2924528f) }) { postWrapMode = (WrapMode)8, preWrapMode = (WrapMode)8 }, 0.417f, new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(-0.112642f, 1.001313f), new Keyframe(0.6705229f, 0.4580552f), new Keyframe(1.004397f, 0.003409747f) }) { postWrapMode = (WrapMode)8, preWrapMode = (WrapMode)8 }, 0.209f, new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 1.00473f), new Keyframe(1.016656f, 0.2523579f) }) { postWrapMode = (WrapMode)8, preWrapMode = (WrapMode)8 }, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.03f, 0f), new List { new DynamicBoneColliderData("stomach", (Direction)0, new Vector3(0f, -0.8f, -0.28f), (Bound)0, 1f, 2.69f), new DynamicBoneColliderData("chest", (Direction)0, new Vector3(0f, 0.43f, -0.05f), (Bound)0, 1.07f, 3.26f) }, new List { "tail00" }, (FreezeAxis)0); ExpieYellowNemCommandoDefscarfbModification.dynamicBoneData = new DynamicBoneData("scarfb", 0.5f, null, 0f, null, 0.5f, new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0.004165649f, 1f), new Keyframe(0.4000142f, -0.002357699f) }) { postWrapMode = (WrapMode)8, preWrapMode = (WrapMode)8 }, 0.05f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.17f, -0.01f), new List { new DynamicBoneColliderData("chest", (Direction)0, new Vector3(0f, 0.43f, -0.05f), (Bound)0, 1.07f, 3.26f), new DynamicBoneColliderData("stomach", (Direction)0, new Vector3(0f, -0.8f, -0.28f), (Bound)0, 1f, 2.69f) }, new List { "scarfb" }, (FreezeAxis)0); ExpieYellowNemCommandoDefscarffModification.dynamicBoneData = new DynamicBoneData("scarff", 0.209f, null, 0.1f, null, 0.5f, new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0.004165649f, 1f), new Keyframe(0.4000142f, -0.002357699f) }) { postWrapMode = (WrapMode)8, preWrapMode = (WrapMode)8 }, 0.078f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.18f, 0f), new List { new DynamicBoneColliderData("chest", (Direction)0, new Vector3(0f, 0.43f, -0.05f), (Bound)0, 1.07f, 3.26f) }, new List { "scarff" }, (FreezeAxis)0); ExpieYellowNemCommandoDefbandageL00Modification.dynamicBoneData = new DynamicBoneData("bandageL00", 0.403f, null, 0f, null, 0.181f, null, 0.114f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List(), new List { "bandageL00" }, (FreezeAxis)0); ExpieYellowNemCommandoDefbandageR00Modification.dynamicBoneData = new DynamicBoneData("bandageR00", 0.403f, null, 0f, null, 0.181f, null, 0.114f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List(), new List { "bandageR00" }, (FreezeAxis)0); ExpieYellowNemCommandoDefbandageFR00Modification.dynamicBoneData = new DynamicBoneData("bandageFR00", 0.435f, null, 0f, null, 0.196f, null, 0.114f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List(), new List { "bandageFR00" }, (FreezeAxis)0); GreenExpieYellowNemCommandoDeftail00Modification.dynamicBoneData = new DynamicBoneData("tail00", 0.317f, null, 0.353f, new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 1f), new Keyframe(0.2862106f, 0.7048314f), new Keyframe(1.004181f, 0.2924528f) }) { postWrapMode = (WrapMode)8, preWrapMode = (WrapMode)8 }, 0.417f, new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(-0.112642f, 1.001313f), new Keyframe(0.6705229f, 0.4580552f), new Keyframe(1.004397f, 0.003409747f) }) { postWrapMode = (WrapMode)8, preWrapMode = (WrapMode)8 }, 0.209f, new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 1.00473f), new Keyframe(1.016656f, 0.2523579f) }) { postWrapMode = (WrapMode)8, preWrapMode = (WrapMode)8 }, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.03f, 0f), new List { new DynamicBoneColliderData("stomach", (Direction)0, new Vector3(0f, -0.8f, -0.28f), (Bound)0, 1f, 2.69f), new DynamicBoneColliderData("chest", (Direction)0, new Vector3(0f, 0.43f, -0.05f), (Bound)0, 1.07f, 3.26f) }, new List { "tail00" }, (FreezeAxis)0); GreenExpieYellowNemCommandoDefscarfbModification.dynamicBoneData = new DynamicBoneData("scarfb", 0.5f, null, 0f, null, 0.5f, new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0.004165649f, 1f), new Keyframe(0.4000142f, -0.002357699f) }) { postWrapMode = (WrapMode)8, preWrapMode = (WrapMode)8 }, 0.05f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.17f, -0.01f), new List { new DynamicBoneColliderData("chest", (Direction)0, new Vector3(0f, 0.43f, -0.05f), (Bound)0, 1.07f, 3.26f), new DynamicBoneColliderData("stomach", (Direction)0, new Vector3(0f, -0.8f, -0.28f), (Bound)0, 1f, 2.69f) }, new List { "scarfb" }, (FreezeAxis)0); GreenExpieYellowNemCommandoDefscarffModification.dynamicBoneData = new DynamicBoneData("scarff", 0.209f, null, 0.1f, null, 0.5f, new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0.004165649f, 1f), new Keyframe(0.4000142f, -0.002357699f) }) { postWrapMode = (WrapMode)8, preWrapMode = (WrapMode)8 }, 0.078f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.18f, 0f), new List { new DynamicBoneColliderData("chest", (Direction)0, new Vector3(0f, 0.43f, -0.05f), (Bound)0, 1.07f, 3.26f) }, new List { "scarff" }, (FreezeAxis)0); GreenExpieYellowNemCommandoDefbandageL00Modification.dynamicBoneData = new DynamicBoneData("bandageL00", 0.403f, null, 0f, null, 0.181f, null, 0.114f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List(), new List { "bandageL00" }, (FreezeAxis)0); GreenExpieYellowNemCommandoDefbandageR00Modification.dynamicBoneData = new DynamicBoneData("bandageR00", 0.403f, null, 0f, null, 0.181f, null, 0.114f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List(), new List { "bandageR00" }, (FreezeAxis)0); GreenExpieYellowNemCommandoDefbandageFR00Modification.dynamicBoneData = new DynamicBoneData("bandageFR00", 0.435f, null, 0f, null, 0.196f, null, 0.114f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, -0.02f, 0f), new List(), new List { "bandageFR00" }, (FreezeAxis)0); } private void AddModificationsToList() { _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 92, ExpieYellowNemCommandoDeftail00Modification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 5, ExpieYellowNemCommandoDefscarfbModification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 19, ExpieYellowNemCommandoDefscarffModification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 42, ExpieYellowNemCommandoDefbandageL00Modification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 76, ExpieYellowNemCommandoDefbandageR00Modification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", 72, ExpieYellowNemCommandoDefbandageFR00Modification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 92, GreenExpieYellowNemCommandoDeftail00Modification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 5, GreenExpieYellowNemCommandoDefscarfbModification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 19, GreenExpieYellowNemCommandoDefscarffModification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 42, GreenExpieYellowNemCommandoDefbandageL00Modification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 76, GreenExpieYellowNemCommandoDefbandageR00Modification); _DynamicSkinManager.AddModification("NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", 72, GreenExpieYellowNemCommandoDefbandageFR00Modification); } private static void onSkinAdded(object sender, SkinAddedArgs e) { _DynamicSkinManager.AddSkinDef(e.skinDef); } } public delegate void VoidDelegate(); public class SkinAddedArgs : EventArgs { public SkinDef skinDef { get; } public GameObject bodyPrefab { get; } public SkinAddedArgs(SkinDef newSkinDef, GameObject newGameObject) { skinDef = newSkinDef; bodyPrefab = newGameObject; } } private static AssetBundle assetBundle; private static readonly List materialsWithRoRShader = new List(); private static DynamicSkinExtension _DynamicSkinExtension = new DynamicSkinExtension(); private static DynamicSkinManager _DynamicSkinManager = new DynamicSkinManager(); private static VoidDelegate BeforeStartDelegate; private static VoidDelegate AfterStartDelegate; private static VoidDelegate BeforeBodyCatalogDelegate; private static VoidDelegate AfterBodyCatalogDelegate; internal static ExperimentAsNemesisCommandoPlugin Instance { get; private set; } internal static ManualLogSource InstanceLogger { get { ExperimentAsNemesisCommandoPlugin instance = Instance; if (instance == null) { return null; } return ((BaseUnityPlugin)instance).Logger; } } private static event EventHandler NemCommandoBodyExpieYellowNemCommandoDefSkinAddedEvent; private static event EventHandler NemCommandoBodyGreenExpieYellowNemCommandoDefSkinAddedEvent; private void Start() { Instance = this; BeforeStart(); using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ExperimentAsNemesisCommando.nooooooah820experimentasnemesiscommando")) { assetBundle = AssetBundle.LoadFromStream(stream); } ((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)BodyCatalogInit); HookEndpointManager.Add((MethodBase)typeof(Language).GetMethod("LoadStrings"), (Delegate)new Action, Language>(LanguageLoadStrings)); ReplaceShaders(); AfterStart(); } private void BeforeStart() { BeforeStartDelegate = (VoidDelegate)Delegate.Combine(BeforeStartDelegate, new VoidDelegate(_DynamicSkinExtension.BeforeStart)); BeforeStartDelegate?.Invoke(); } private void AfterStart() { AfterStartDelegate = (VoidDelegate)Delegate.Combine(AfterStartDelegate, new VoidDelegate(_DynamicSkinExtension.AfterStart)); AfterStartDelegate?.Invoke(); } private static void BeforeBodyCatalogInit() { BeforeBodyCatalogDelegate = (VoidDelegate)Delegate.Combine(BeforeBodyCatalogDelegate, new VoidDelegate(_DynamicSkinExtension.BeforeBodyCatalogInit)); BeforeBodyCatalogDelegate?.Invoke(); } private static void AfterBodyCatalogInit() { AfterBodyCatalogDelegate = (VoidDelegate)Delegate.Combine(AfterBodyCatalogDelegate, new VoidDelegate(_DynamicSkinExtension.AfterBodyCatalogInit)); AfterBodyCatalogDelegate?.Invoke(); } private static void ReplaceShaders() { LoadMaterialsWithReplacedShader("RoR2/Base/Shaders/HGStandard.shader", "Assets/Resources/Expie/NemCommando/ExpieNemCommando.mat", "Assets/Resources/Expie/NemCommando/WhatsapperimentNemCommando.mat"); } private static void LoadMaterialsWithReplacedShader(string shaderPath, params string[] materialPaths) { //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) Shader shader = Addressables.LoadAssetAsync((object)shaderPath).WaitForCompletion(); foreach (string text in materialPaths) { Material val = assetBundle.LoadAsset(text); val.shader = shader; materialsWithRoRShader.Add(val); } } private static void LanguageLoadStrings(Action orig, Language self) { orig(self); self.SetStringByToken("NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME", "Experiment"); self.SetStringByToken("NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME", "Whatsapperiment"); } private static void BodyCatalogInit() { BeforeBodyCatalogInit(); AddNemCommandoBodyExpieYellowNemCommandoDefSkin(); AddNemCommandoBodyGreenExpieYellowNemCommandoDefSkin(); AfterBodyCatalogInit(); } private static void NemCommandoBodyExpieYellowNemCommandoDefSkinAdded(SkinDef skinDef, GameObject bodyPrefab) { ExperimentAsNemesisCommandoPlugin.NemCommandoBodyExpieYellowNemCommandoDefSkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab)); } private static void AddNemCommandoBodyExpieYellowNemCommandoDefSkin() { string text = "NemCommandoBody"; string text2 = "ExpieYellowNemCommandoDef"; try { GameObject val = BodyCatalog.FindBodyPrefab(text); if (!Object.op_Implicit((Object)(object)val)) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin because \"" + text + "\" doesn't exist")); return; } ModelLocator component = val.GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelLocator\" component")); return; } GameObject gameObject = ((Component)component.modelTransform).gameObject; ModelSkinController skinController = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent() : null); if (!Object.op_Implicit((Object)(object)skinController)) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component")); return; } Renderer[] renderers = gameObject.GetComponentsInChildren(true); gameObject.GetComponentsInChildren(true); SkinDef skin = ScriptableObject.CreateInstance(); SkinDefParams skinParams = ScriptableObject.CreateInstance(); skin.skinDefParams = skinParams; TryCatchThrow("Icon", delegate { skin.icon = assetBundle.LoadAsset("Assets/The mods/Railgunner/Experiment/expie.png"); }); ((Object)skin).name = text2; skin.nameToken = "NOOOOOOAH820_SKIN_EXPIEYELLOWNEMCOMMANDODEF_NAME"; skin.rootObject = gameObject; TryCatchThrow("Base Skins", delegate { skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { ThrowIfOutOfBounds(0, "Index 1 is out of bounds of skins array", skinController.skins, 1) }; }); TryCatchThrow("Unlockable Name", delegate { skin.unlockableDef = ((IEnumerable)ContentManager.unlockableDefs).FirstOrDefault((Func)((UnlockableDef def) => def.cachedName == "Experiment")); }); TryCatchThrow("Game Object Activations", delegate { skinParams.gameObjectActivations = Array.Empty(); }); TryCatchThrow("Renderer Infos", delegate { //IL_0010: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) skinParams.rendererInfos = (RendererInfo[])(object)new RendererInfo[1] { new RendererInfo { defaultMaterial = assetBundle.LoadAsset("Assets/Resources/Expie/NemCommando/ExpieNemCommando.mat"), defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false, renderer = ThrowIfNull(0, "There is no renderer with the name \"NemmandoBody_LP\"", ((IEnumerable)renderers).FirstOrDefault((Func)((Renderer r) => ((Object)r).name == "NemmandoBody_LP"))) } }; }); TryCatchThrow("Mesh Replacements", delegate { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) skinParams.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1] { new MeshReplacement { mesh = assetBundle.LoadAsset("Assets\\SkinMods\\ExperimentAsNemesisCommando\\Meshes\\Body.mesh"), renderer = ThrowIfNull(0, "There is no renderer with the name \"NemmandoBody_LP\"", ((IEnumerable)renderers).FirstOrDefault((Func)((Renderer r) => ((Object)r).name == "NemmandoBody_LP"))) } }; }); TryCatchThrow("Light Infos", delegate { skinParams.lightReplacements = (LightInfo[])(object)new LightInfo[0]; }); TryCatchThrow("Minion Skin Replacements", delegate { skinParams.minionSkinReplacements = Array.Empty(); }); TryCatchThrow("Projectile Ghost Replacements", delegate { skinParams.projectileGhostReplacements = Array.Empty(); }); Array.Resize(ref skinController.skins, skinController.skins.Length + 1); skinController.skins[skinController.skins.Length - 1] = skin; NemCommandoBodyExpieYellowNemCommandoDefSkinAdded(skin, val); } catch (FieldException ex) { if (ex.InnerException is ElementException ex2) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\"")); InstanceLogger.LogWarning((object)$"Field causing issue: {ex.Message}, element: {ex2.Index}"); InstanceLogger.LogWarning((object)ex2.Message); InstanceLogger.LogError((object)ex.InnerException); } else { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\"")); InstanceLogger.LogWarning((object)("Field causing issue: " + ex.Message)); InstanceLogger.LogError((object)ex.InnerException); } } catch (Exception ex3) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\"")); InstanceLogger.LogError((object)ex3); } } private static void NemCommandoBodyGreenExpieYellowNemCommandoDefSkinAdded(SkinDef skinDef, GameObject bodyPrefab) { ExperimentAsNemesisCommandoPlugin.NemCommandoBodyGreenExpieYellowNemCommandoDefSkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab)); } private static void AddNemCommandoBodyGreenExpieYellowNemCommandoDefSkin() { string text = "NemCommandoBody"; string text2 = "GreenExpieYellowNemCommandoDef"; try { GameObject val = BodyCatalog.FindBodyPrefab(text); if (!Object.op_Implicit((Object)(object)val)) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin because \"" + text + "\" doesn't exist")); return; } ModelLocator component = val.GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelLocator\" component")); return; } GameObject gameObject = ((Component)component.modelTransform).gameObject; ModelSkinController skinController = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent() : null); if (!Object.op_Implicit((Object)(object)skinController)) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component")); return; } Renderer[] renderers = gameObject.GetComponentsInChildren(true); gameObject.GetComponentsInChildren(true); SkinDef skin = ScriptableObject.CreateInstance(); SkinDefParams skinParams = ScriptableObject.CreateInstance(); skin.skinDefParams = skinParams; TryCatchThrow("Icon", delegate { skin.icon = assetBundle.LoadAsset("Assets/The mods/NemCommando/Whatsapperiment/whatsappie.png"); }); ((Object)skin).name = text2; skin.nameToken = "NOOOOOOAH820_SKIN_GREENEXPIEYELLOWNEMCOMMANDODEF_NAME"; skin.rootObject = gameObject; TryCatchThrow("Base Skins", delegate { skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { ThrowIfOutOfBounds(0, "Index 1 is out of bounds of skins array", skinController.skins, 1) }; }); TryCatchThrow("Unlockable Name", delegate { skin.unlockableDef = ((IEnumerable)ContentManager.unlockableDefs).FirstOrDefault((Func)((UnlockableDef def) => def.cachedName == "Whatsapperiment")); }); TryCatchThrow("Game Object Activations", delegate { skinParams.gameObjectActivations = Array.Empty(); }); TryCatchThrow("Renderer Infos", delegate { //IL_0010: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) skinParams.rendererInfos = (RendererInfo[])(object)new RendererInfo[1] { new RendererInfo { defaultMaterial = assetBundle.LoadAsset("Assets/Resources/Expie/NemCommando/WhatsapperimentNemCommando.mat"), defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false, renderer = ThrowIfNull(0, "There is no renderer with the name \"NemmandoBody_LP\"", ((IEnumerable)renderers).FirstOrDefault((Func)((Renderer r) => ((Object)r).name == "NemmandoBody_LP"))) } }; }); TryCatchThrow("Mesh Replacements", delegate { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) skinParams.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1] { new MeshReplacement { mesh = assetBundle.LoadAsset("Assets\\SkinMods\\ExperimentAsNemesisCommando\\Meshes\\Body.mesh"), renderer = ThrowIfNull(0, "There is no renderer with the name \"NemmandoBody_LP\"", ((IEnumerable)renderers).FirstOrDefault((Func)((Renderer r) => ((Object)r).name == "NemmandoBody_LP"))) } }; }); TryCatchThrow("Light Infos", delegate { skinParams.lightReplacements = (LightInfo[])(object)new LightInfo[0]; }); TryCatchThrow("Minion Skin Replacements", delegate { skinParams.minionSkinReplacements = Array.Empty(); }); TryCatchThrow("Projectile Ghost Replacements", delegate { skinParams.projectileGhostReplacements = Array.Empty(); }); Array.Resize(ref skinController.skins, skinController.skins.Length + 1); skinController.skins[skinController.skins.Length - 1] = skin; NemCommandoBodyGreenExpieYellowNemCommandoDefSkinAdded(skin, val); } catch (FieldException ex) { if (ex.InnerException is ElementException ex2) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\"")); InstanceLogger.LogWarning((object)$"Field causing issue: {ex.Message}, element: {ex2.Index}"); InstanceLogger.LogWarning((object)ex2.Message); InstanceLogger.LogError((object)ex.InnerException); } else { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\"")); InstanceLogger.LogWarning((object)("Field causing issue: " + ex.Message)); InstanceLogger.LogError((object)ex.InnerException); } } catch (Exception ex3) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\"")); InstanceLogger.LogError((object)ex3); } } private static T ThrowIfEquals(int index, string message, T value, T expected) where T : Enum { if (value.Equals(expected)) { throw new ElementException(index, message); } return value; } private static T ThrowIfOutOfBounds(int index, string message, T[] array, int elementIndex) where T : class { if (array == null || array.Length <= elementIndex) { throw new ElementException(index, message); } return array[elementIndex]; } private static T ThrowIfNull(int index, string message, T value) where T : class { if (value == null) { throw new ElementException(index, message); } return value; } private static void TryCatchThrow(string message, Action action) { try { action?.Invoke(); } catch (Exception innerException) { throw new FieldException(message, innerException); } } private static void TryAddComponent(GameObject obj) where T : Component { if (Object.op_Implicit((Object)(object)obj) && !Object.op_Implicit((Object)(object)obj.GetComponent())) { obj.AddComponent(); } } } } namespace RuneFoxMods { internal class Utils { public static void PrintBodyCatalog() { Debug.Log((object)"\nBodyCatalog"); foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs) { Debug.Log((object)((Object)allBodyPrefab).name); } Debug.Log((object)"\n"); } public static void ReadChildren(GameObject parent, int tabs, bool includecomponents = true) { //IL_0082: 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) string text = ""; for (int i = 0; i < tabs; i++) { text += " "; } for (int j = 0; j < parent.transform.childCount; j++) { Transform child = parent.transform.GetChild(j); if ((Object)(object)child == (Object)null) { break; } string text2 = ((Component)child).gameObject.activeInHierarchy.ToString(); string[] obj = new string[6] { text, ((Object)child).name, " ", text2, " ", null }; Vector3 position = ((Component)child).transform.position; obj[5] = ((object)(Vector3)(ref position)).ToString(); Debug.Log((object)string.Concat(obj)); if (includecomponents) { ReadComponents(((Component)child).gameObject, tabs + 1); Debug.Log((object)""); } ReadChildren(((Component)child).gameObject, tabs + 1, includecomponents); } } public static void readheiarchy(GameObject parent, bool includeComponents = true) { Debug.Log((object)((Object)parent).name); if (includeComponents) { ReadComponents(parent, 1); Debug.Log((object)""); } ReadChildren(parent, 1, includeComponents); } public static void ReadComponents(GameObject obj, int tabs) { string text = ""; for (int i = 0; i < tabs; i++) { text += " "; } Component[] components = obj.GetComponents(typeof(Component)); foreach (Component val in components) { string text2 = ""; Debug.Log((object)(text + "Comp: " + ((object)val).GetType().ToString() + " " + text2)); } } public static void PrintAllPaths(GameObject parent) { Debug.Log((object)((Object)parent).name); PrintAllPathsInner(parent, ((Object)parent).name); } private static void PrintAllPathsInner(GameObject parent, string parent_string) { int childCount = parent.transform.childCount; for (int i = 0; i < childCount; i++) { Transform child = parent.transform.GetChild(i); if (!((Object)child).name.EndsWith("_end")) { string text = parent_string + "/" + ((Object)child).name; Debug.Log((object)(" " + ((Object)child).name + "\t\t" + text)); PrintAllPathsInner(((Component)child).gameObject, text); continue; } break; } } public static void PrintDynamicBone(DynamicBone DB) { //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)("Root: " + (object)DB.m_Root)); Debug.Log((object)("Damping: " + DB.m_Damping)); Debug.Log((object)("Damping Dist: " + (object)DB.m_DampingDistrib)); Debug.Log((object)("Elasticity: " + DB.m_Elasticity)); Debug.Log((object)("Elasticity Dist: " + (object)DB.m_ElasticityDistrib)); Debug.Log((object)("Stiffness: " + DB.m_Stiffness)); Debug.Log((object)("Stiffness Dist: " + (object)DB.m_StiffnessDistrib)); Debug.Log((object)("Inert: " + DB.m_Inert)); Debug.Log((object)("Inert Dist: " + (object)DB.m_InertDistrib)); Debug.Log((object)("Radius: " + DB.m_Radius)); Debug.Log((object)("Radius Dist: " + (object)DB.m_RadiusDistrib)); Debug.Log((object)("End Length: " + DB.m_EndLength)); Vector3 val = DB.m_EndOffset; Debug.Log((object)("End Offset: " + ((object)(Vector3)(ref val)).ToString())); val = DB.m_Gravity; Debug.Log((object)("Gravity: " + ((object)(Vector3)(ref val)).ToString())); val = DB.m_Force; Debug.Log((object)("Force: " + ((object)(Vector3)(ref val)).ToString())); Debug.Log((object)("FreezeAxis: " + ((object)(FreezeAxis)(ref DB.m_FreezeAxis)).ToString())); Debug.Log((object)("Colliders: " + DB.m_Colliders.Count)); foreach (DynamicBoneCollider collider in DB.m_Colliders) { Debug.Log((object)("\t Parent: " + ((Object)((Component)collider).transform).name)); Debug.Log((object)("\t Direction: " + ((object)(Direction)(ref collider.m_Direction)).ToString())); val = collider.m_Center; Debug.Log((object)("\t Center " + ((object)(Vector3)(ref val)).ToString())); Debug.Log((object)("\t Bound " + ((object)(Bound)(ref collider.m_Bound)).ToString())); Debug.Log((object)("\t Radius " + collider.m_Radius)); Debug.Log((object)("\t Height " + collider.m_Height)); } Debug.Log((object)("Exclusions: " + DB.m_Exclusions.Count)); foreach (Transform exclusion in DB.m_Exclusions) { Debug.Log((object)("\t Transform: " + ((Object)exclusion).name)); } } public static ChildLocator GetChildLocator(GameObject body) { ChildLocator val = null; Transform child = body.transform.GetChild(0); if (Object.op_Implicit((Object)(object)child)) { Transform child2 = child.GetChild(0); if (Object.op_Implicit((Object)(object)child2)) { val = ((Component)child2).GetComponent(); if (Object.op_Implicit((Object)(object)val)) { Debug.Log((object)"Locator Found"); } } } return val; } public static Transform FindChildInTree(Transform Root, string name) { Queue queue = new Queue(); queue.Enqueue(Root); while (queue.Count != 0) { Transform val = queue.Dequeue(); if (((Object)val).name == name) { return val; } for (int i = 0; i < val.childCount; i++) { Transform child = val.GetChild(i); queue.Enqueue(child); } } return null; } public static string RemoveCloneNaming(string str) { return str.Remove(str.Length - 7); } } } namespace RuneFoxMods.DynamicSkins { public static class DynamicSkinHelpers { public static SkinnedMeshRenderer[] GetBaseSkinRenderers(GameObject modelObject) { SkinnedMeshRenderer[] componentsInChildren = modelObject.GetComponentsInChildren(true); List list = new List(); SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val in array) { if ((Object)(object)((Component)val).transform.parent == (Object)(object)modelObject.transform && ((Object)((Component)val).gameObject).name != "NemmandoSword" && ((Object)((Component)val).gameObject).name != "gun") { list.Add(val); } } return list.ToArray(); } public static Transform[] BoneArrayBuilder(Transform NewBoneRoot) { List list = new List(); BoneArrayBuilderHelper(NewBoneRoot, list); return list.ToArray(); } public static void BoneArrayBuilderHelper(Transform parent, List list) { if (!((Object)parent).name.EndsWith("_end")) { list.Add(parent); } for (int i = 0; i < parent.childCount; i++) { BoneArrayBuilderHelper(parent.GetChild(i), list); } } public static Transform GetArmature(GameObject obj) { return GetArmatureHelper(obj); } public static Transform GetArmatureHelper(GameObject obj) { if (((Object)obj).name.ToLower().Contains("armature")) { return obj.transform; } for (int i = 0; i < obj.transform.childCount; i++) { Transform armatureHelper = GetArmatureHelper(((Component)obj.transform.GetChild(i)).gameObject); if (Object.op_Implicit((Object)(object)armatureHelper)) { return armatureHelper; } } return null; } public static Transform GetTopParent(Transform obj) { Transform val = obj; while ((Object)(object)val.parent != (Object)null) { val = val.parent; } return val; } public static string GetPrevBoneInList(Transform targetBone, SkinnedMeshRenderer meshRenderer) { Transform[] bones = meshRenderer.bones; for (int i = 0; i <= bones.Length - 1; i++) { if (((Object)bones[i + 1]).name == ((Object)targetBone).name) { return ((Object)bones[i]).name; } } return null; } public static int GetBoneIndexInList(Transform targetBone, SkinnedMeshRenderer meshRenderer) { Transform[] bones = meshRenderer.bones; for (int i = 0; i <= bones.Length; i++) { if (((Object)bones[i]).name == ((Object)targetBone).name) { return i; } } return -1; } public static int GetPrevBoneIndexInList(Transform targetBone, SkinnedMeshRenderer meshRenderer) { Transform[] bones = meshRenderer.bones; for (int i = 0; i <= bones.Length - 1; i++) { if (((Object)bones[i + 1]).name == ((Object)targetBone).name) { return i; } } return -1; } } internal class DynamicSkinManager { internal Dictionary SkinDefs = new Dictionary(); private GameObject LastModelObject; internal Dictionary> ModificationList = new Dictionary>(); private Dictionary ModifiedObjects = new Dictionary(); internal ManualLogSource InstanceLogger; internal void AddModification(string skinNameToken, int boneIndex, Modification modification) { if (!ModificationList.TryGetValue(skinNameToken, out var value)) { value = new SortedList(); ModificationList.Add(skinNameToken, value); } value.Add(boneIndex, modification); } internal void AddSkinDef(SkinDef skinDef) { SkinDefs.Add(skinDef.nameToken, skinDef); } internal void SkinDefApply(Action orig, SkinDef self, GameObject modelObject) { orig(self, modelObject); RemoveInvalidModelObjects(); ModifiedObjects.TryGetValue(modelObject, out var value); try { if (!SkinDefs.TryGetValue(self.nameToken, out var _)) { if (value != null) { ClearSkinModifications(LastModelObject, value); } } else if (value == null) { AppliedModifications appliedModifications = new AppliedModifications(); ModifiedObjects.Add(modelObject, appliedModifications); ApplySkinModifications(self, modelObject, appliedModifications); } } catch (Exception ex) { InstanceLogger.LogWarning((object)"An error occured while adding accessories to a skin"); InstanceLogger.LogError((object)ex); } } private void RemoveInvalidModelObjects() { foreach (GameObject item in ModifiedObjects.Keys.Where((GameObject el) => !Object.op_Implicit((Object)(object)el)).ToList()) { ModifiedObjects.Remove(item); } } private void ClearSkinModifications(GameObject modelObject, AppliedModifications modifications) { while (modifications.BaseModelModifications.Count != 0) { Modification modification = modifications.BaseModelModifications.Pop(); clearModification(modification, modelObject, modifications); } while (modifications.OtherModifications.Count != 0) { clearModification(modifications.OtherModifications[0], modelObject, modifications); } ModifiedObjects.Remove(modelObject); } private void ApplySkinModifications(SkinDef skindef, GameObject modelObject, AppliedModifications modifications) { CharacterModel component = modelObject.GetComponent(); LastModelObject = modelObject; if (!ModificationList.TryGetValue(skindef.nameToken, out var value)) { return; } foreach (KeyValuePair item in value) { ApplyModification(modelObject, component, item.Value, modifications); } } private static void ApplyModification(GameObject modelObject, CharacterModel characterModel, Modification modification, AppliedModifications modifications) { _ = modification.bodyname; string parentname = modification.parentname; Transform val = Utils.FindChildInTree(modelObject.transform, parentname); GameObject val2; if (modification.affectsbasemodel) { val2 = Object.Instantiate(modification.prefab, val, false); ((Object)val2).name = Utils.RemoveCloneNaming(((Object)val2).name); modification.instance = val2; modification.inst_armature = val2; ModificationApplyBones(modelObject, modification, modifications); } else { val2 = Object.Instantiate(modification.prefab, modelObject.transform, false); ((Object)val2).name = Utils.RemoveCloneNaming(((Object)val2).name); modification.instance = val2; Transform armature = DynamicSkinHelpers.GetArmature(val2); ((Component)armature).transform.SetParent(val, false); modification.inst_armature = ((Component)armature).gameObject; } modification.instance = val2; if (modification.dynamicBoneData != null) { ModificationApplyDynamicBones(modelObject, modification); } ModificationAddRenderers(val2, characterModel); modifications.OtherModifications.Add(modification); } private static void ModificationApplyBones(GameObject modelObject, Modification modification, AppliedModifications modifications) { SkinnedMeshRenderer[] baseSkinRenderers = DynamicSkinHelpers.GetBaseSkinRenderers(modelObject); List list = baseSkinRenderers[0].bones.ToList(); Transform[] array = DynamicSkinHelpers.BoneArrayBuilder(modification.instance.transform); list.InsertRange(modification.boneIndex, array); modification.boneCount = array.Length; SkinnedMeshRenderer[] array2 = baseSkinRenderers; for (int i = 0; i < array2.Length; i++) { array2[i].bones = list.ToArray(); } modifications.BaseModelModifications.Push(modification); } private static void ModificationApplyDynamicBones(GameObject modelObject, Modification modification) { //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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_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_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) DynamicBone val = (modification.inst_dynamicBone = modification.instance.AddComponent()); List list = new List(); foreach (DynamicBoneColliderData collider in modification.dynamicBoneData.m_Colliders) { DynamicBoneCollider val2 = ((Component)Utils.FindChildInTree(modelObject.transform, collider.m_parent_name)).gameObject.AddComponent(); val2.m_Direction = collider.m_Direction; val2.m_Center = collider.m_Center; val2.m_Bound = collider.m_Bound; val2.m_Radius = collider.m_Radius; val2.m_Height = collider.m_Height; list.Add(val2); } modification.inst_DB_colliders = list; Transform root = (val.m_Root = Utils.FindChildInTree(modification.inst_armature.transform, modification.dynamicBoneData.m_Root)); val.m_Damping = modification.dynamicBoneData.m_Damping; val.m_DampingDistrib = modification.dynamicBoneData.m_DampingDistrib; val.m_Elasticity = modification.dynamicBoneData.m_Elasticity; val.m_ElasticityDistrib = modification.dynamicBoneData.m_ElasticityDistrib; val.m_Stiffness = modification.dynamicBoneData.m_Stiffness; val.m_StiffnessDistrib = modification.dynamicBoneData.m_StiffnessDistrib; val.m_Inert = modification.dynamicBoneData.m_Inert; val.m_InertDistrib = modification.dynamicBoneData.m_InertDistrib; val.m_Radius = modification.dynamicBoneData.m_Radius; val.m_RadiusDistrib = modification.dynamicBoneData.m_RadiusDistrib; val.m_EndLength = modification.dynamicBoneData.m_EndLength; val.m_EndOffset = modification.dynamicBoneData.m_EndOffset; val.m_Gravity = modification.dynamicBoneData.m_Gravity; val.m_Force = modification.dynamicBoneData.m_Force; val.m_Colliders = list; val.m_Exclusions = new List(); foreach (string exclusion in modification.dynamicBoneData.m_Exclusions) { Transform val3 = Utils.FindChildInTree(root, exclusion); if ((Object)(object)val3 != (Object)null) { val.m_Exclusions.Add(val3); } else { Debug.LogWarning((object)"Tried to exclude a transform that could not be found"); } } val.m_FreezeAxis = modification.dynamicBoneData.m_FreezeAxis; } private static void ModificationAddRenderers(GameObject newPart, CharacterModel characterModel) { //IL_0044: 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_0076: 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) SkinnedMeshRenderer[] componentsInChildren = newPart.GetComponentsInChildren(true); Array.Resize(ref characterModel.baseRendererInfos, characterModel.baseRendererInfos.Length + componentsInChildren.Length); if (componentsInChildren.Length != 0) { int num = componentsInChildren.Length; SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val in array) { characterModel.baseRendererInfos[characterModel.baseRendererInfos.Length - num] = new RendererInfo { renderer = (Renderer)(object)componentsInChildren[^num], ignoreOverlays = false, defaultShadowCastingMode = (ShadowCastingMode)1, defaultMaterial = ((Renderer)val).sharedMaterial }; num--; } } } private void clearModification(Modification modification, GameObject modelObject, AppliedModifications modifications) { if (modification.inst_DB_colliders != null) { foreach (DynamicBoneCollider inst_DB_collider in modification.inst_DB_colliders) { Object.Destroy((Object)(object)inst_DB_collider); } } if (modification.affectsbasemodel) { SkinnedMeshRenderer[] baseSkinRenderers = DynamicSkinHelpers.GetBaseSkinRenderers(modelObject); List list = baseSkinRenderers[0].bones.ToList(); list.RemoveRange(modification.boneIndex, modification.boneCount); SkinnedMeshRenderer[] array = baseSkinRenderers; for (int i = 0; i < array.Length; i++) { array[i].bones = list.ToArray(); } } Object.Destroy((Object)(object)modifications.OtherModifications[0].inst_dynamicBone); Object.Destroy((Object)(object)modifications.OtherModifications[0].inst_armature); Object.Destroy((Object)(object)modifications.OtherModifications[0].instance); if (!modifications.OtherModifications.Remove(modification)) { InstanceLogger.LogError((object)"Skin Modification was not removed"); } } } internal class Modification { public string prefabpath; public string bodyname; public string parentname; public GameObject prefab; public bool affectsbasemodel; public DynamicBoneData dynamicBoneData; public string parentSkinToken; public int boneIndex; public int boneCount; public GameObject instance; public GameObject inst_armature; public DynamicBone inst_dynamicBone; public List inst_DB_colliders = new List(); public Modification(string PrefabPath, string ParentName, string BodyName, string ParentSkinToken, int BoneIndex, bool AffectsBaseModel, AssetBundle assetBundle) { bodyname = BodyName; prefabpath = PrefabPath; parentname = ParentName; parentSkinToken = ParentSkinToken; affectsbasemodel = AffectsBaseModel; boneIndex = BoneIndex; prefab = assetBundle.LoadAsset(prefabpath); if ((Object)(object)prefab == (Object)null) { Debug.LogWarning((object)("Asset at " + PrefabPath + " was not loaded")); } } } internal class AppliedModifications { public Stack BaseModelModifications = new Stack(); public List OtherModifications = new List(); } internal class DynamicBoneData { public string m_Root; public float m_Damping; public AnimationCurve m_DampingDistrib; public float m_Elasticity; public AnimationCurve m_ElasticityDistrib; public float m_Stiffness; public AnimationCurve m_StiffnessDistrib; public float m_Inert; public AnimationCurve m_InertDistrib; public float m_Radius; public AnimationCurve m_RadiusDistrib; public float m_EndLength; public Vector3 m_EndOffset; public Vector3 m_Gravity; public Vector3 m_Force; public List m_Colliders; public List m_Exclusions; public FreezeAxis m_FreezeAxis; public DynamicBoneData(string root, float damping, AnimationCurve damping_dist, float elasticity, AnimationCurve elasticity_dist, float stiffness, AnimationCurve stiffness_dist, float inert, AnimationCurve inert_dist, float radius, AnimationCurve radius_dist, float end_length, Vector3 end_offset, Vector3 gravity, Vector3 force, List colliders, List exclusions, FreezeAxis freeze_axis) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) m_Root = root; m_Damping = damping; m_DampingDistrib = damping_dist; m_Elasticity = elasticity; m_ElasticityDistrib = elasticity_dist; m_Stiffness = stiffness; m_StiffnessDistrib = stiffness_dist; m_Inert = inert; m_InertDistrib = inert_dist; m_Radius = radius; m_RadiusDistrib = radius_dist; m_EndLength = end_length; m_EndOffset = end_offset; m_Gravity = gravity; m_Force = force; m_Colliders = colliders; m_Exclusions = exclusions; m_FreezeAxis = freeze_axis; } } internal class DynamicBoneColliderData { public string m_parent_name; public Direction m_Direction; public Vector3 m_Center; public Bound m_Bound; public float m_Radius; public float m_Height; public DynamicBoneColliderData(string parent_name, Direction direction, Vector3 Center, Bound bound, float radius, float heaight) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) m_parent_name = parent_name; m_Direction = direction; m_Center = Center; m_Bound = bound; m_Radius = radius; m_Height = heaight; } } }