Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ArlecchinoMercenarySkin v1.0.4
ArlecchinoMercenary.dll
Decompiled a year agousing System; using System.Collections; 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 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 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<ChildLocator>(); if (Object.op_Implicit((Object)(object)val)) { Debug.Log((object)"Locator Found"); } } } return val; } public static Transform FindChildInTree(Transform Root, string name) { Queue<Transform> queue = new Queue<Transform>(); 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<SkinnedMeshRenderer>(true); List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>(); SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val in array) { if ((Object)(object)((Component)val).transform.parent == (Object)(object)modelObject.transform) { list.Add(val); } } return list.ToArray(); } public static Transform[] BoneArrayBuilder(Transform NewBoneRoot) { List<Transform> list = new List<Transform>(); BoneArrayBuilderHelper(NewBoneRoot, list); return list.ToArray(); } public static void BoneArrayBuilderHelper(Transform parent, List<Transform> 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<string, SkinDef> SkinDefs = new Dictionary<string, SkinDef>(); private GameObject LastModelObject; internal Dictionary<string, SortedList<int, Modification>> ModificationList = new Dictionary<string, SortedList<int, Modification>>(); private Dictionary<GameObject, AppliedModifications> ModifiedObjects = new Dictionary<GameObject, AppliedModifications>(); internal ManualLogSource InstanceLogger; internal void AddModification(string skinNameToken, int boneIndex, Modification modification) { if (!ModificationList.TryGetValue(skinNameToken, out var value)) { value = new SortedList<int, Modification>(); ModificationList.Add(skinNameToken, value); } value.Add(boneIndex, modification); } internal void AddSkinDef(SkinDef skinDef) { SkinDefs.Add(skinDef.nameToken, skinDef); } 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<CharacterModel>(); LastModelObject = modelObject; if (!ModificationList.TryGetValue(skindef.nameToken, out var value)) { return; } foreach (KeyValuePair<int, Modification> 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<GameObject>(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<GameObject>(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<Transform> 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<DynamicBone>()); List<DynamicBoneCollider> list = new List<DynamicBoneCollider>(); foreach (DynamicBoneColliderData collider in modification.dynamicBoneData.m_Colliders) { DynamicBoneCollider val2 = ((Component)Utils.FindChildInTree(modelObject.transform, collider.m_parent_name)).gameObject.AddComponent<DynamicBoneCollider>(); 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<Transform>(); 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<SkinnedMeshRenderer>(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<Transform> 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 IEnumerator SkinDefApply(Func<SkinDef, GameObject, List<AssetReferenceT<Material>>, List<AssetReferenceT<Mesh>>, int, IEnumerator> orig, SkinDef self, GameObject modelObject, List<AssetReferenceT<Material>> loadedMaterials, List<AssetReferenceT<Mesh>> loadedMeshes, int unloadType) { IEnumerator result = orig(self, modelObject, loadedMaterials, loadedMeshes, unloadType); RemoveInvalidModelObjects(); ModifiedObjects.TryGetValue(modelObject, out var value); try { if (!SkinDefs.TryGetValue(self.nameToken, out var _)) { if (value != null) { ClearSkinModifications(LastModelObject, value); } return result; } 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); } return result; } } 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<DynamicBoneCollider> inst_DB_colliders = new List<DynamicBoneCollider>(); 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<GameObject>(prefabpath); if ((Object)(object)prefab == (Object)null) { Debug.LogWarning((object)("Asset at " + PrefabPath + " was not loaded")); } } } internal class AppliedModifications { public Stack<Modification> BaseModelModifications = new Stack<Modification>(); public List<Modification> OtherModifications = new List<Modification>(); } 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<DynamicBoneColliderData> m_Colliders; public List<string> 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<DynamicBoneColliderData> colliders, List<string> 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; } } } namespace ArlecchinoMercenary { [BepInPlugin("com.miminisusuki.ArlecchinoMercenary", "ArlecchinoMercenary", "1.0.4")] public class ArlecchinoMercenaryPlugin : BaseUnityPlugin { private class FieldException : Exception { public FieldException(string message, Exception innerException) : base(message, innerException) { } } public class DynamicSkinExtension { private Modification ArleMercSkinRednotreallyaskirtL1Modification; private Modification ArleMercSkinRednotreallyaskirtR1Modification; private Modification ArleMercSkinRedbobLModification; private Modification ArleMercSkinRedbobRModification; private Modification ArleMercSkinRedhair1Modification; 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("ApplyAsync"), (Delegate)new Func<Func<SkinDef, GameObject, List<AssetReferenceT<Material>>, List<AssetReferenceT<Mesh>>, int, IEnumerator>, SkinDef, GameObject, List<AssetReferenceT<Material>>, List<AssetReferenceT<Mesh>>, int, IEnumerator>(_DynamicSkinManager.SkinDefApply)).Apply(); } internal void AfterStart() { InitializeModifications(); InitializeDynamicBones(); AddModificationsToList(); } internal void BeforeBodyCatalogInit() { MercBodyArleMercSkinRedSkinAddedEvent += onSkinAdded; } internal void AfterBodyCatalogInit() { } private void InitializeModifications() { ArleMercSkinRednotreallyaskirtL1Modification = new Modification("notreallyaskirtL1.prefab", "pelvis", "MercBody", "MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", 79, AffectsBaseModel: true, assetBundle); ArleMercSkinRednotreallyaskirtR1Modification = new Modification("notreallyaskirtR1.prefab", "pelvis", "MercBody", "MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", 81, AffectsBaseModel: true, assetBundle); ArleMercSkinRedbobLModification = new Modification("bobL.prefab", "chest", "MercBody", "MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", 68, AffectsBaseModel: true, assetBundle); ArleMercSkinRedbobRModification = new Modification("bobR.prefab", "chest", "MercBody", "MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", 69, AffectsBaseModel: true, assetBundle); ArleMercSkinRedhair1Modification = new Modification("hair1.prefab", "head", "MercBody", "MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", 31, AffectsBaseModel: true, assetBundle); } private void InitializeDynamicBones() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) ArleMercSkinRednotreallyaskirtL1Modification.dynamicBoneData = new DynamicBoneData("notreallyaskirtL1", 0.01f, null, 0.1f, null, 0.01f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0); ArleMercSkinRednotreallyaskirtR1Modification.dynamicBoneData = new DynamicBoneData("notreallyaskirtR1", 0.01f, null, 0.1f, null, 0.01f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0); ArleMercSkinRedbobLModification.dynamicBoneData = new DynamicBoneData("bobL", 0.05f, null, 0.1f, null, 0.05f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0); ArleMercSkinRedbobRModification.dynamicBoneData = new DynamicBoneData("bobR", 0.05f, null, 0.1f, null, 0.05f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0); ArleMercSkinRedhair1Modification.dynamicBoneData = new DynamicBoneData("hair1", 0.01f, null, 0.1f, null, 0.01f, null, 0f, null, 0f, null, 0f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new List<DynamicBoneColliderData>(), new List<string>(), (FreezeAxis)0); } private void AddModificationsToList() { _DynamicSkinManager.AddModification("MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", 79, ArleMercSkinRednotreallyaskirtL1Modification); _DynamicSkinManager.AddModification("MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", 81, ArleMercSkinRednotreallyaskirtR1Modification); _DynamicSkinManager.AddModification("MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", 68, ArleMercSkinRedbobLModification); _DynamicSkinManager.AddModification("MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", 69, ArleMercSkinRedbobRModification); _DynamicSkinManager.AddModification("MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", 31, ArleMercSkinRedhair1Modification); } 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<Material> materialsWithRoRShader; private static DynamicSkinExtension _DynamicSkinExtension; private static DynamicSkinManager _DynamicSkinManager; private static VoidDelegate BeforeStartDelegate; private static VoidDelegate AfterStartDelegate; private static VoidDelegate BeforeBodyCatalogDelegate; private static VoidDelegate AfterBodyCatalogDelegate; internal static ArlecchinoMercenaryPlugin Instance { get; private set; } internal static ManualLogSource InstanceLogger { get { ArlecchinoMercenaryPlugin instance = Instance; if ((Object)(object)instance == (Object)null) { return null; } return ((BaseUnityPlugin)instance).Logger; } } private static event EventHandler<SkinAddedArgs> MercBodyArleMercSkinRedSkinAddedEvent; private void Start() { Instance = this; BeforeStart(); using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ArlecchinoMercenary.miminisusukiarlecchinomercenary")) { assetBundle = AssetBundle.LoadFromStream(stream); } ((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)BodyCatalogInit); HookEndpointManager.Add((MethodBase)typeof(Language).GetMethod("LoadStrings"), (Delegate)new Action<Action<Language>, 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/Mod/Resources/matArleMerc.mat", "Assets/Mod/Resources/matArleScytheMerc.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<Shader>((object)shaderPath).WaitForCompletion(); foreach (string text in materialPaths) { Material val = assetBundle.LoadAsset<Material>(text); val.shader = shader; materialsWithRoRShader.Add(val); } } private static void LanguageLoadStrings(Action<Language> orig, Language self) { orig(self); self.SetStringByToken("MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME", "Arlecchino"); } private static void Nothing(Action<SkinDef> orig, SkinDef self) { } private static void BodyCatalogInit() { BeforeBodyCatalogInit(); MethodInfo? method = typeof(SkinDef).GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic); HookEndpointManager.Add((MethodBase)method, (Delegate)new Action<Action<SkinDef>, SkinDef>(Nothing)); AddMercBodyArleMercSkinRedSkin(); HookEndpointManager.Remove((MethodBase)method, (Delegate)new Action<Action<SkinDef>, SkinDef>(Nothing)); AfterBodyCatalogInit(); } private static void MercBodyArleMercSkinRedSkinAdded(SkinDef skinDef, GameObject bodyPrefab) { ArlecchinoMercenaryPlugin.MercBodyArleMercSkinRedSkinAddedEvent(Instance, new SkinAddedArgs(skinDef, bodyPrefab)); } private static void AddMercBodyArleMercSkinRedSkin() { string text = "MercBody"; string text2 = "ArleMercSkinRed"; 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<ModelLocator>(); 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 val2 = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null); if (!Object.op_Implicit((Object)(object)val2)) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component")); return; } Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true); SkinDef skin = ScriptableObject.CreateInstance<SkinDef>(); TryCatchThrow("Icon", delegate { skin.icon = assetBundle.LoadAsset<Sprite>("Assets\\SkinMods\\ArlecchinoMercenary\\Icons\\ArleMercSkinRedIcon.png"); }); ((Object)skin).name = text2; skin.nameToken = "MIMINISUSUKI_SKIN_ARLEMERCSKINRED_NAME"; skin.rootObject = gameObject; TryCatchThrow("Base Skins", delegate { skin.baseSkins = Array.Empty<SkinDef>(); }); TryCatchThrow("Unlockable Name", delegate { skin.unlockableDef = null; }); TryCatchThrow("Game Object Activations", delegate { skin.gameObjectActivations = Array.Empty<GameObjectActivation>(); }); 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_004b: 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_0055: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[2] { new RendererInfo { defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Mod/Resources/matArleMerc.mat"), defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false, renderer = renderers[7] }, new RendererInfo { defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Mod/Resources/matArleScytheMerc.mat"), defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false, renderer = renderers[8] } }; }); TryCatchThrow("Mesh Replacements", delegate { //IL_0010: 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_0045: 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) //IL_0071: Unknown result type (might be due to invalid IL or missing references) skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[2] { new MeshReplacement { mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\ArlecchinoMercenary\\Meshes\\仆人_mesh.mesh"), renderer = renderers[7] }, new MeshReplacement { mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\ArlecchinoMercenary\\Meshes\\武器_mesh.mesh"), renderer = renderers[8] } }; }); TryCatchThrow("Minion Skin Replacements", delegate { skin.minionSkinReplacements = Array.Empty<MinionSkinReplacement>(); }); TryCatchThrow("Projectile Ghost Replacements", delegate { skin.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>(); }); Array.Resize(ref val2.skins, val2.skins.Length + 1); val2.skins[val2.skins.Length - 1] = skin; MercBodyArleMercSkinRedSkinAdded(skin, val); } catch (FieldException ex) { 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 ex2) { InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\"")); InstanceLogger.LogError((object)ex2); } } private static void TryCatchThrow(string message, Action action) { try { action?.Invoke(); } catch (Exception innerException) { throw new FieldException(message, innerException); } } static ArlecchinoMercenaryPlugin() { materialsWithRoRShader = new List<Material>(); _DynamicSkinExtension = new DynamicSkinExtension(); _DynamicSkinManager = new DynamicSkinManager(); } } }
ArleMercVoice.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BaseVoiceoverLib; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HG; using R2API; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.ContentManagement; using UnityEngine; using UnityEngine.AddressableAssets; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ArleMercVoice")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ArleMercVoice")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("fb7085ba-7967-409f-8ff6-392024ecd2e5")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] public static class Files { public static PluginInfo PluginInfo; internal static string assemblyDir => Path.GetDirectoryName(PluginInfo.Location); internal static void Init(PluginInfo info) { PluginInfo = info; } internal static string GetPathToFile(string folderName, string fileName) { return Path.Combine(assemblyDir, folderName, fileName); } } namespace ArleMercVoice; public class ArleMercVoiceComponents : BaseVoiceoverComponent { public static NetworkSoundEventDef nseArleMercPrimary; public static NetworkSoundEventDef nseArleMercSecondary; public static NetworkSoundEventDef nseArleMercUtility1; public static NetworkSoundEventDef nseArleMercUtility2; public static NetworkSoundEventDef nseArleMercUtility3; public static NetworkSoundEventDef nseArleMercSpecial1; public static NetworkSoundEventDef nseArleMercSpecial2; public static NetworkSoundEventDef nseArleMercSpecial3; public static NetworkSoundEventDef nseArleMercPrimaryENG; public static NetworkSoundEventDef nseArleMercSecondaryENG; public static NetworkSoundEventDef nseArleMercUtility1ENG; public static NetworkSoundEventDef nseArleMercUtility2ENG; public static NetworkSoundEventDef nseArleMercUtility3ENG; public static NetworkSoundEventDef nseArleMercSpecial1ENG; public static NetworkSoundEventDef nseArleMercSpecial2ENG; public static NetworkSoundEventDef nseArleMercSpecial3ENG; public static NetworkSoundEventDef nseArleMercPrimaryJP; public static NetworkSoundEventDef nseArleMercSecondaryJP; public static NetworkSoundEventDef nseArleMercUtility1JP; public static NetworkSoundEventDef nseArleMercUtility2JP; public static NetworkSoundEventDef nseArleMercUtility3JP; public static NetworkSoundEventDef nseArleMercSpecial1JP; public static NetworkSoundEventDef nseArleMercSpecial2JP; public static NetworkSoundEventDef nseArleMercSpecial3JP; public static string voArleMercChest1; public static string voArleMercChest2; public static string voArleMercChest3; public static string voArleMercFallen1; public static string voArleMercFallen2; public static string voArleMercFallen3; public static string voArleMercAscention1; public static string voArleMercAscention2; public static string voArleMercAscention3; public static string voArleMercHurt; public static string voArleMercJoin1; public static string voArleMercJoin2; public static string voArleMercWeather1; public static string voArleMercWeather2; public static string voArleMercLowHP1; public static string voArleMercLowHP2; public static string voArleMercLowHP3; private float primaryCooldown = 0f; private float secondaryCooldown = 0f; private float utilityCooldown = 0f; private float specialCooldown = 0f; private float itemGetCooldown = 0f; private float levelupCooldown = 0f; private float lowHealthCooldown = 0f; private float hurtCooldown = 0f; protected override void FixedUpdate() { ((BaseVoiceoverComponent)this).FixedUpdate(); if (primaryCooldown > 0f) { primaryCooldown -= Time.fixedDeltaTime; } if (secondaryCooldown > 0f) { secondaryCooldown -= Time.fixedDeltaTime; } if (utilityCooldown > 0f) { utilityCooldown -= Time.fixedDeltaTime; } if (specialCooldown > 0f) { specialCooldown -= Time.fixedDeltaTime; } if (itemGetCooldown > 0f) { itemGetCooldown -= Time.fixedDeltaTime; } if (levelupCooldown > 0f) { levelupCooldown -= Time.fixedDeltaTime; } if (lowHealthCooldown > 0f) { lowHealthCooldown -= Time.fixedDeltaTime; } if (hurtCooldown > 0f) { hurtCooldown -= Time.fixedDeltaTime; } } protected override void Start() { ((BaseVoiceoverComponent)this).Start(); } protected override void Awake() { ((BaseVoiceoverComponent)this).Awake(); } public override void PlayPrimaryAuthority(GenericSkill skill) { if (Util.CheckRoll(40f, 0f, (CharacterMaster)null) && !(primaryCooldown > 0f)) { ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseArleMercPrimary, 0f, false); primaryCooldown = 1.2f; } } public override void PlaySecondaryAuthority(GenericSkill skill) { if (!(secondaryCooldown > 0f)) { ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseArleMercSecondary, 0f, false); secondaryCooldown = 2.2f; } } public override void PlayUtilityAuthority(GenericSkill skill) { if (!(utilityCooldown > 0f)) { if (Util.CheckRoll(33.333332f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseArleMercUtility1, 0.9f, false); } else if (Util.CheckRoll(50f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseArleMercUtility2, 0.8f, false); } else { ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseArleMercUtility3, 0.8f, false); } utilityCooldown = 4f; } } public override void PlaySpecialAuthority(GenericSkill skill) { if (!(specialCooldown > 0f)) { if (Util.CheckRoll(33.333332f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseArleMercSpecial1, 2.1f, false); } else if (Util.CheckRoll(50f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseArleMercSpecial2, 2f, false); } else { ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseArleMercSpecial3, 1.7f, false); } specialCooldown = 6f; } } public override void PlayDeath() { if (Util.CheckRoll(33.333332f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercFallen1, 4f, true); } else if (Util.CheckRoll(50f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercFallen2, 3.2f, true); } else { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercFallen3, 4f, true); } } public override void PlayLevelUp() { if (!(levelupCooldown > 0f)) { if (Util.CheckRoll(33.333332f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercAscention1, 4.9f, false); } else if (Util.CheckRoll(50f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercAscention2, 8.2f, false); } else { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercAscention3, 7.1f, false); } levelupCooldown = 60f; } } public override void PlayHurt(float percentHPLost) { if (percentHPLost >= 0.1f && !(hurtCooldown > 0f)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercHurt, 0f, false); hurtCooldown = 1.3f; } } public override void PlayTeleporterStart() { if (Util.CheckRoll(50f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercJoin1, 3f, false); } else { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercJoin2, 2.9f, false); } } public override void PlayTeleporterFinish() { if (Util.CheckRoll(50f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercWeather1, 4.2f, false); } else { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercWeather2, 5f, false); } } public override void PlayVictory() { if (Util.CheckRoll(50f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercWeather1, 4.2f, true); } else { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercWeather2, 5f, true); } } public override void PlayLowHealth() { if (!(lowHealthCooldown > 0f)) { if (Util.CheckRoll(33.333332f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercLowHP1, 2f, false); } else if (Util.CheckRoll(50f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercLowHP2, 2.2f, false); } else { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercLowHP3, 2.7f, false); } lowHealthCooldown = 40f; } } protected override void Inventory_onItemAddedClient(ItemIndex itemIndex) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ((BaseVoiceoverComponent)this).Inventory_onItemAddedClient(itemIndex); PlayItemGet(); } protected void PlayItemGet() { if (!(itemGetCooldown > 0f)) { if (Util.CheckRoll(33.333332f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercChest1, 3f, false); } else if (Util.CheckRoll(50f, 0f, (CharacterMaster)null)) { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercChest2, 1.5f, false); } else { ((BaseVoiceoverComponent)this).TryPlaySound(voArleMercChest3, 3.6f, false); } itemGetCooldown = 80f; } } public override bool ComponentEnableVoicelines() { return ArleMercVoicePlugin.enableVoicelines.Value; } } public static class SoundBanks { private static bool initialized; public static string SoundBankDirectory => Files.assemblyDir; public static void Init() { if (!initialized) { initialized = true; Stream stream = new FileStream(SoundBankDirectory + "\\ArleMercSoundbank.bnk", FileMode.Open); byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); SoundBanks.Add(array); } } } public class Content : IContentPackProvider { internal ContentPack contentPack = new ContentPack(); public static List<NetworkSoundEventDef> networkSoundEventDefs = new List<NetworkSoundEventDef>(); public string identifier => "com.miminisusuki.ArleMercVoice"; public void Initialize() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders); } private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)this); } public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { contentPack.networkSoundEventDefs.Add(networkSoundEventDefs.ToArray()); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(contentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.miminisusuki.ArleMercVoice", "ArleMercVoice", "1.0.3")] public class ArleMercVoicePlugin : BaseUnityPlugin { public class NSEInfo { public NetworkSoundEventDef nse; public uint akId = 0u; public string eventName = string.Empty; public NSEInfo(NetworkSoundEventDef source) { nse = source; akId = source.akId; eventName = source.eventName; } private void DisableSound() { nse.akId = 0u; nse.eventName = string.Empty; } private void EnableSound() { nse.akId = akId; nse.eventName = eventName; } public void ValidateParams() { if (akId == 0) { akId = nse.akId; } if (eventName == string.Empty) { eventName = nse.eventName; } if (!enableVoicelines.Value) { DisableSound(); } else { EnableSound(); } if (jpVoicelines.Value) { DefineJPVO(); } else { DefineVO(); } } } public static ConfigEntry<bool> enableVoicelines; public static ConfigEntry<bool> jpVoicelines; public static SurvivorDef survivorDef = Addressables.LoadAssetAsync<SurvivorDef>((object)"RoR2/Base/Merc/Merc.asset").WaitForCompletion(); public static List<NSEInfo> nseList = new List<NSEInfo>(); private static string voArleMercLobby = null; public void Awake() { //IL_0054: 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_006f: Expected O, but got Unknown //IL_006f: Expected O, but got Unknown //IL_009b: 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_00b6: Expected O, but got Unknown //IL_00b6: Expected O, but got Unknown Files.PluginInfo = ((BaseUnityPlugin)this).Info; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad)); new Content().Initialize(); SoundBanks.Init(); InitNSE(); enableVoicelines = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Enable Voicelines"), true, new ConfigDescription("Enable voicelines when using the Arlecchino Mercenary Skin.", (AcceptableValueBase)null, Array.Empty<object>())); enableVoicelines.SettingChanged += Voicelines_SettingChanged; jpVoicelines = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Use JP Voicelines"), false, new ConfigDescription("Switches to the Japonese voicelines when using the Arlecchino Mercenary Skin.", (AcceptableValueBase)null, Array.Empty<object>())); jpVoicelines.SettingChanged += Voicelines_SettingChanged; if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { RiskOfOptionsCompat(); } } private void Voicelines_SettingChanged(object sender, EventArgs e) { RefreshNSE(); } private void RiskOfOptionsCompat() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(enableVoicelines)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(jpVoicelines)); } private void OnLoad() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00a2: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown SkinDef val = null; SkinDef[] array = ArrayUtils.Clone<SkinDef>(FindSkinsForBody(BodyCatalog.FindBodyIndex("MercBody"))); SkinDef[] array2 = array; foreach (SkinDef val2 in array2) { if (((Object)val2).name == "ArleMercSkinRed") { val = val2; break; } } if (!Object.op_Implicit((Object)(object)val)) { Debug.LogError((object)"ArleMercVoice: Arlecchino Mercenary SkinDef not found. Voicelines will not work!"); } else { VoiceoverInfo val3 = new VoiceoverInfo(typeof(ArleMercVoiceComponents), val, "MercBody"); val3.selectActions = (LobbySelectActions)Delegate.Combine((Delegate)(object)val3.selectActions, (Delegate?)new LobbySelectActions(ArleSelect)); } RefreshNSE(); } private void ArleSelect(GameObject mannequinObject) { if (enableVoicelines.Value) { Util.PlaySound(voArleMercLobby, mannequinObject); } } private void InitNSE() { ArleMercVoiceComponents.nseArleMercPrimaryENG = RegisterNSE("Play_ArleMerc_Primary"); ArleMercVoiceComponents.nseArleMercSecondaryENG = RegisterNSE("Play_ArleMerc_Secondary"); ArleMercVoiceComponents.nseArleMercUtility1ENG = RegisterNSE("Play_ArleMerc_Skill1"); ArleMercVoiceComponents.nseArleMercUtility2ENG = RegisterNSE("Play_ArleMerc_Skill2"); ArleMercVoiceComponents.nseArleMercUtility3ENG = RegisterNSE("Play_ArleMerc_Skill3"); ArleMercVoiceComponents.nseArleMercSpecial1ENG = RegisterNSE("Play_ArleMerc_Burst1"); ArleMercVoiceComponents.nseArleMercSpecial2ENG = RegisterNSE("Play_ArleMerc_Burst2"); ArleMercVoiceComponents.nseArleMercSpecial3ENG = RegisterNSE("Play_ArleMerc_Burst3"); ArleMercVoiceComponents.nseArleMercPrimaryJP = RegisterNSE("Play_ArleMerc_Primary_JP"); ArleMercVoiceComponents.nseArleMercSecondaryJP = RegisterNSE("Play_ArleMerc_Secondary_JP"); ArleMercVoiceComponents.nseArleMercUtility1JP = RegisterNSE("Play_ArleMerc_Skill1_JP"); ArleMercVoiceComponents.nseArleMercUtility2JP = RegisterNSE("Play_ArleMerc_Skill2_JP"); ArleMercVoiceComponents.nseArleMercUtility3JP = RegisterNSE("Play_ArleMerc_Skill3_JP"); ArleMercVoiceComponents.nseArleMercSpecial1JP = RegisterNSE("Play_ArleMerc_Burst1_JP"); ArleMercVoiceComponents.nseArleMercSpecial2JP = RegisterNSE("Play_ArleMerc_Burst2_JP"); ArleMercVoiceComponents.nseArleMercSpecial3JP = RegisterNSE("Play_ArleMerc_Burst3_JP"); } public void RefreshNSE() { foreach (NSEInfo nse in nseList) { nse.ValidateParams(); } } private NetworkSoundEventDef RegisterNSE(string eventName) { NetworkSoundEventDef val = ScriptableObject.CreateInstance<NetworkSoundEventDef>(); val.eventName = eventName; Content.networkSoundEventDefs.Add(val); nseList.Add(new NSEInfo(val)); return val; } private static void DefineVO() { ArleMercVoiceComponents.nseArleMercPrimary = ArleMercVoiceComponents.nseArleMercPrimaryENG; ArleMercVoiceComponents.nseArleMercSecondary = ArleMercVoiceComponents.nseArleMercSecondaryENG; ArleMercVoiceComponents.nseArleMercUtility1 = ArleMercVoiceComponents.nseArleMercUtility1ENG; ArleMercVoiceComponents.nseArleMercUtility2 = ArleMercVoiceComponents.nseArleMercUtility2ENG; ArleMercVoiceComponents.nseArleMercUtility3 = ArleMercVoiceComponents.nseArleMercUtility3ENG; ArleMercVoiceComponents.nseArleMercSpecial1 = ArleMercVoiceComponents.nseArleMercSpecial1ENG; ArleMercVoiceComponents.nseArleMercSpecial2 = ArleMercVoiceComponents.nseArleMercSpecial2ENG; ArleMercVoiceComponents.nseArleMercSpecial3 = ArleMercVoiceComponents.nseArleMercSpecial3ENG; ArleMercVoiceComponents.voArleMercChest1 = "Play_ArleMerc_Chest1"; ArleMercVoiceComponents.voArleMercChest2 = "Play_ArleMerc_Chest2"; ArleMercVoiceComponents.voArleMercChest1 = "Play_ArleMerc_Chest3"; ArleMercVoiceComponents.voArleMercFallen1 = "Play_ArleMerc_Fallen1"; ArleMercVoiceComponents.voArleMercFallen2 = "Play_ArleMerc_Fallen2"; ArleMercVoiceComponents.voArleMercFallen3 = "Play_ArleMerc_Fallen3"; ArleMercVoiceComponents.voArleMercAscention1 = "Play_ArleMerc_Ascention1"; ArleMercVoiceComponents.voArleMercAscention2 = "Play_ArleMerc_Ascention2"; ArleMercVoiceComponents.voArleMercAscention3 = "Play_ArleMerc_Ascention3"; ArleMercVoiceComponents.voArleMercHurt = "Play_ArleMerc_Hurt"; voArleMercLobby = "Play_ArleMerc_Lobby"; ArleMercVoiceComponents.voArleMercJoin1 = "Play_ArleMerc_Join1"; ArleMercVoiceComponents.voArleMercJoin2 = "Play_ArleMerc_Join2"; ArleMercVoiceComponents.voArleMercWeather1 = "Play_ArleMerc_Sun"; ArleMercVoiceComponents.voArleMercWeather2 = "Play_ArleMerc_Thunder"; ArleMercVoiceComponents.voArleMercLowHP1 = "Play_ArleMerc_LowHP1"; ArleMercVoiceComponents.voArleMercLowHP2 = "Play_ArleMerc_LowHP2"; ArleMercVoiceComponents.voArleMercLowHP3 = "Play_ArleMerc_LowHP3"; } private static void DefineJPVO() { ArleMercVoiceComponents.nseArleMercPrimary = ArleMercVoiceComponents.nseArleMercPrimaryJP; ArleMercVoiceComponents.nseArleMercSecondary = ArleMercVoiceComponents.nseArleMercSecondaryJP; ArleMercVoiceComponents.nseArleMercUtility1 = ArleMercVoiceComponents.nseArleMercUtility1JP; ArleMercVoiceComponents.nseArleMercUtility2 = ArleMercVoiceComponents.nseArleMercUtility2JP; ArleMercVoiceComponents.nseArleMercUtility3 = ArleMercVoiceComponents.nseArleMercUtility3JP; ArleMercVoiceComponents.nseArleMercSpecial1 = ArleMercVoiceComponents.nseArleMercSpecial1JP; ArleMercVoiceComponents.nseArleMercSpecial2 = ArleMercVoiceComponents.nseArleMercSpecial2JP; ArleMercVoiceComponents.nseArleMercSpecial3 = ArleMercVoiceComponents.nseArleMercSpecial3JP; ArleMercVoiceComponents.voArleMercChest1 = "Play_ArleMerc_Chest1_JP"; ArleMercVoiceComponents.voArleMercChest2 = "Play_ArleMerc_Chest2_JP"; ArleMercVoiceComponents.voArleMercChest1 = "Play_ArleMerc_Chest3_JP"; ArleMercVoiceComponents.voArleMercFallen1 = "Play_ArleMerc_Fallen1_JP"; ArleMercVoiceComponents.voArleMercFallen2 = "Play_ArleMerc_Fallen2_JP"; ArleMercVoiceComponents.voArleMercFallen3 = "Play_ArleMerc_Fallen3_JP"; ArleMercVoiceComponents.voArleMercAscention1 = "Play_ArleMerc_Ascention1_JP"; ArleMercVoiceComponents.voArleMercAscention2 = "Play_ArleMerc_Ascention2_JP"; ArleMercVoiceComponents.voArleMercAscention3 = "Play_ArleMerc_Ascention3_JP"; ArleMercVoiceComponents.voArleMercHurt = "Play_ArleMerc_Hurt_JP"; voArleMercLobby = "Play_ArleMerc_Lobby_JP"; ArleMercVoiceComponents.voArleMercJoin1 = "Play_ArleMerc_Join1_JP"; ArleMercVoiceComponents.voArleMercJoin2 = "Play_ArleMerc_Join2_JP"; ArleMercVoiceComponents.voArleMercWeather1 = "Play_ArleMerc_Sun_JP"; ArleMercVoiceComponents.voArleMercWeather2 = "Play_ArleMerc_Thunder_JP"; ArleMercVoiceComponents.voArleMercLowHP1 = "Play_ArleMerc_LowHP1_JP"; ArleMercVoiceComponents.voArleMercLowHP2 = "Play_ArleMerc_LowHP2_JP"; ArleMercVoiceComponents.voArleMercLowHP3 = "Play_ArleMerc_LowHP3_JP"; } private static SkinDef[] FindSkinsForBody(BodyIndex bodyIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ModelLocator component = BodyCatalog.GetBodyPrefab(bodyIndex).GetComponent<ModelLocator>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.modelTransform)) { return Array.Empty<SkinDef>(); } ModelSkinController component2 = ((Component)component.modelTransform).GetComponent<ModelSkinController>(); if (!Object.op_Implicit((Object)(object)component2)) { return Array.Empty<SkinDef>(); } return component2.skins; } }