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 RosuneModel v1.0.0
plugins/RosuneModel.dll
Decompiled 4 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using ModelReplacement; using RosuneMotion; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("LethalModOut")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalModOut")] [assembly: AssemblyTitle("LethalModOut")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace RosuneModel { public class MRROSUNEMODEL : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { string text = "RosuneModel"; GameObject val = Assets.MainAssetBundle.LoadAsset<GameObject>(text); AddMotions(val); return val; } internal static void AddMotions(GameObject model) { if (!((Object)(object)model == (Object)null)) { if ((Object)(object)model.GetComponent<SecondaryMotion>() == (Object)null) { model.AddComponent<SecondaryMotion>(); } if ((Object)(object)model.GetComponent<MouthMotion>() == (Object)null) { model.AddComponent<MouthMotion>(); } if ((Object)(object)model.GetComponent<BlinkMotion>() == (Object)null) { model.AddComponent<BlinkMotion>(); } } } } public class MRLETHALCOMPANYROSUNE : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { string text = "LethalCompany用Rosune"; GameObject val = Assets.MainAssetBundle.LoadAsset<GameObject>(text); MRROSUNEMODEL.AddMotions(val); return val; } } [BepInPlugin("com.spi.rosunemodel", "RosuneModel", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown Assets.PopulateAssets(); ModelReplacementAPI.RegisterSuitModelReplacement("RosuneSuit", typeof(MRROSUNEMODEL)); Harmony val = new Harmony("com.spi.rosunemodel"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.tomosu.rosunemodel is loaded!"); } } public static class Assets { public static string mainAssetBundleName = "rosunemodel"; public static AssetBundle MainAssetBundle = null; private static string GetAssemblyName() { return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_"); } public static void PopulateAssets() { if ((Object)(object)MainAssetBundle == (Object)null) { Console.WriteLine(GetAssemblyName() + "." + mainAssetBundleName); using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName); MainAssetBundle = AssetBundle.LoadFromStream(stream); } } } } namespace RosuneMotion { public class BlinkMotion : MonoBehaviour { private const string blinkName = "blink"; private const float minInterval = 2f; private const float maxInterval = 5f; private const float closeTime = 0.06f; private const float holdTime = 0.07f; private const float openTime = 0.14f; private const float maxWeight = 100f; private SkinnedMeshRenderer smr; private int index = -1; private float nextBlink; private float timer; private bool blinking; private Component controller; private float nextCheck; private bool dead; private void Start() { SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { if (!((Object)(object)val.sharedMesh == (Object)null)) { int blendShapeIndex = val.sharedMesh.GetBlendShapeIndex("blink"); if (blendShapeIndex >= 0) { smr = val; index = blendShapeIndex; break; } } } if ((Object)(object)smr == (Object)null) { Debug.LogWarning((object)"[BlinkMotion] blink のシェイプキーが見つかりません"); } nextBlink = Time.time + Random.Range(2f, 5f); } private void LateUpdate() { if ((Object)(object)smr == (Object)null) { return; } if (Time.time >= nextCheck) { nextCheck = Time.time + 0.5f; dead = DeathUtil.IsDead(((Component)this).gameObject, ref controller); } if (dead) { blinking = false; smr.SetBlendShapeWeight(index, 100f); return; } float num = 0f; if (!blinking && Time.time >= nextBlink) { blinking = true; timer = 0f; } if (blinking) { timer += Time.deltaTime; float num2 = 0.26999998f; if (timer < 0.06f) { num = timer / 0.06f; } else if (timer < 0.13f) { num = 1f; } else if (timer < num2) { num = 1f - (timer - 0.06f - 0.07f) / 0.14f; } else { blinking = false; nextBlink = Time.time + ((Random.value < 0.15f) ? 0.2f : Random.Range(2f, 5f)); } } smr.SetBlendShapeWeight(index, num * 100f); } } public static class DeathUtil { private const BindingFlags F = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static Type playerType; private static Type deadBodyType; private static FieldInfo deadField; private static readonly Dictionary<Type, FieldInfo[]> gameObjectFields = new Dictionary<Type, FieldInfo[]>(); public static Type PlayerType { get { Resolve(); return playerType; } } private static void Resolve() { if (playerType != null) { return; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (playerType == null) { playerType = assembly.GetType("GameNetcodeStuff.PlayerControllerB"); } if (deadBodyType == null) { deadBodyType = assembly.GetType("DeadBodyInfo"); } } if (playerType != null) { deadField = playerType.GetField("isPlayerDead", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } } public static FieldInfo GetFieldDeep(Type t, string name) { while (t != null) { FieldInfo field = t.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return field; } t = t.BaseType; } return null; } private static FieldInfo[] GetGameObjectFields(Type type) { if (gameObjectFields.TryGetValue(type, out FieldInfo[] value)) { return value; } List<FieldInfo> list = new List<FieldInfo>(); Type type2 = type; while (type2 != null) { FieldInfo[] fields = type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(GameObject)) { list.Add(fieldInfo); } } type2 = type2.BaseType; } value = list.ToArray(); gameObjectFields[type] = value; return value; } public static Component FindController(GameObject model) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown Resolve(); if (playerType == null) { return null; } Component componentInParent = model.GetComponentInParent(playerType); if ((Object)(object)componentInParent != (Object)null) { return componentInParent; } BodyReplacementBase[] array = Object.FindObjectsOfType<BodyReplacementBase>(); foreach (BodyReplacementBase val in array) { FieldInfo fieldDeep = GetFieldDeep(((object)val).GetType(), "replacementModel"); GameObject val2 = (GameObject)((fieldDeep != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val2 == (Object)(object)model) { componentInParent = ((Component)val).GetComponent(playerType); if ((Object)(object)componentInParent != (Object)null) { return componentInParent; } } } float num = 5f; Component result = null; Object[] array2 = Object.FindObjectsOfType(playerType); foreach (Object val3 in array2) { float num2 = Vector3.Distance(((Component)val3).transform.position, model.transform.position); if (num2 < num) { num = num2; result = (Component)val3; } } return result; } public static bool IsDead(GameObject model, ref Component controller) { //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) Resolve(); if (playerType == null) { return false; } if (deadBodyType != null && (Object)(object)model.GetComponentInParent(deadBodyType) != (Object)null) { return true; } bool flag = false; BodyReplacementBase[] array = Object.FindObjectsOfType<BodyReplacementBase>(); foreach (BodyReplacementBase val in array) { FieldInfo[] array2 = GetGameObjectFields(((object)val).GetType()); foreach (FieldInfo fieldInfo in array2) { object? value = fieldInfo.GetValue(val); if (!((Object)((value is GameObject) ? value : null) != (Object)(object)model)) { if (fieldInfo.Name.ToLower().Contains("dead")) { return true; } if (fieldInfo.Name == "replacementModel") { controller = ((Component)val).GetComponent(playerType); flag = true; } } } } if (flag && (Object)(object)controller != (Object)null && deadField != null) { return (bool)deadField.GetValue(controller); } if (deadBodyType != null) { Object[] array3 = Object.FindObjectsOfType(deadBodyType); foreach (Object val2 in array3) { if (Vector3.Distance(((Component)val2).transform.position, model.transform.position) < 1f) { return true; } } } return false; } } public class MouthMotion : MonoBehaviour { private static readonly string[] mouthNames = new string[5] { "vrc.v_aa", "あ", "MouthOpen", "Mouth Open", "aa" }; private const float maxWeight = 100f; private const float sensitivity = 25f; private const float minOpen = 0.4f; private const float smooth = 18f; private SkinnedMeshRenderer smr; private int index = -1; private float weight; private Component controller; private float nextFind; private float nextDeadCheck; private bool dead; private static FieldInfo voiceField; private static PropertyInfo speakingProp; private static PropertyInfo ampProp; private void Start() { SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { if ((Object)(object)val.sharedMesh == (Object)null) { continue; } string[] array = mouthNames; foreach (string text in array) { int blendShapeIndex = val.sharedMesh.GetBlendShapeIndex(text); if (blendShapeIndex >= 0) { smr = val; index = blendShapeIndex; return; } } } Debug.LogWarning((object)"[MouthMotion] 口のシェイプキーが見つかりません"); } private void LateUpdate() { if ((Object)(object)smr == (Object)null || index < 0) { return; } if ((Object)(object)controller == (Object)null) { if (Time.time < nextFind) { return; } nextFind = Time.time + 1f; controller = DeathUtil.FindController(((Component)this).gameObject); if ((Object)(object)controller == (Object)null) { return; } } if (Time.time >= nextDeadCheck) { nextDeadCheck = Time.time + 0.5f; dead = DeathUtil.IsDead(((Component)this).gameObject, ref controller); } if (voiceField == null) { voiceField = DeathUtil.GetFieldDeep(DeathUtil.PlayerType, "voicePlayerState"); } float num = 0f; bool flag = false; float num2 = 0f; object obj = ((voiceField != null) ? voiceField.GetValue(controller) : null); if (obj != null) { if (speakingProp == null) { speakingProp = obj.GetType().GetProperty("IsSpeaking"); ampProp = obj.GetType().GetProperty("Amplitude"); } flag = speakingProp != null && (bool)speakingProp.GetValue(obj, null); num2 = ((ampProp != null) ? ((float)ampProp.GetValue(obj, null)) : 0f); if (flag) { num = Mathf.Max(0.4f, Mathf.Clamp01(Mathf.Sqrt(num2 * 25f))); } } if (dead) { num = 0f; } weight = Mathf.Lerp(weight, num * 100f, 1f - Mathf.Exp(-18f * Time.deltaTime)); smr.SetBlendShapeWeight(index, weight); } } [DefaultExecutionOrder(1000)] public class SecondaryMotion : MonoBehaviour { private class Target { public string root; public float stiffness; public float drag; public float gravity; public Target(string r, float s, float d, float g) { root = r; stiffness = s; drag = d; gravity = g; } } private class Node { public Transform t; public Quaternion restLocalRot; public Vector3 localChildPos; public Vector3 boneAxis; public Vector3 currentTail; public Vector3 prevTail; public Target cfg; } private static readonly Target[] targets = new Target[3] { new Target("tailroot", 6f, 0.25f, 0f), new Target("EarRoot.L", 10f, 0.4f, 0f), new Target("EarRoot.R", 10f, 0.4f, 0f) }; private readonly List<Node> nodes = new List<Node>(); private void Start() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //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) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) Target[] array = targets; foreach (Target target in array) { Transform val = FindDeep(((Component)this).transform, target.root); if ((Object)(object)val == (Object)null) { continue; } Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(); foreach (Transform val2 in componentsInChildren) { if ((Object)(object)val2.parent == (Object)null) { continue; } Vector3 val3; if (val2.childCount > 0) { val3 = val2.GetChild(0).localPosition; } else { Vector3 val4 = val2.position - val2.parent.position; if (((Vector3)(ref val4)).sqrMagnitude < 1E-10f) { continue; } val3 = val2.InverseTransformPoint(val2.position + val4); } if (!(((Vector3)(ref val3)).sqrMagnitude < 1E-12f)) { Vector3 val5 = val2.TransformPoint(val3); nodes.Add(new Node { t = val2, restLocalRot = val2.localRotation, localChildPos = val3, boneAxis = ((Vector3)(ref val3)).normalized, currentTail = val5, prevTail = val5, cfg = target }); } } } } private void LateUpdate() { //IL_004f: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_014e: 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_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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: 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_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Min(Time.deltaTime, 0.033f); if (num <= 0f) { return; } foreach (Node node in nodes) { Transform t = node.t; Quaternion val = t.parent.rotation * node.restLocalRot; Vector3 val2 = t.TransformPoint(node.localChildPos) - t.position; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude < 1E-06f)) { val2 = node.currentTail - t.position; if (((Vector3)(ref val2)).sqrMagnitude > 4f) { node.prevTail = (node.currentTail = t.position + val * node.boneAxis * magnitude); } Vector3 val3 = node.currentTail + (node.currentTail - node.prevTail) * (1f - node.cfg.drag) + val * node.boneAxis * (magnitude * node.cfg.stiffness * num) + Vector3.down * (magnitude * node.cfg.gravity * num); Vector3 val4 = val3 - t.position; if (!(((Vector3)(ref val4)).sqrMagnitude < 1E-12f)) { val3 = t.position + ((Vector3)(ref val4)).normalized * magnitude; node.prevTail = node.currentTail; node.currentTail = val3; t.rotation = Quaternion.FromToRotation(val * node.boneAxis, val3 - t.position) * val; } } } } private static Transform FindDeep(Transform parent, string name) { Transform[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Transform>(); foreach (Transform val in componentsInChildren) { if (((Object)val).name == name) { return val; } } return null; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }