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 VikingTrainee v1.0.0
SkeletonDance.dll
Decompiled 2 weeks 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.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("SkeletonDance")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SkeletonDance")] [assembly: AssemblyTitle("SkeletonDance")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SkeletonDance { [HarmonyPatch(typeof(Tameable), "UseItem")] public static class EggDancePatch { private const string SkeletonPrefabName = "Skeleton_Friendly"; private const string EggPrefabName = "ChickenEgg"; private static void Postfix(Tameable __instance, Humanoid user, ItemData item, ref bool __result) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!__result && !((Object)(object)item?.m_dropPrefab == (Object)null) && !((Object)(object)user == (Object)null) && !(Utils.GetPrefabName(item.m_dropPrefab) != "ChickenEgg") && !(Utils.GetPrefabName(((Component)__instance).gameObject) != "Skeleton_Friendly")) { SkeletonDanceController.PlayOn(((Component)__instance).gameObject, ((Component)user).transform.position); user.GetInventory().RemoveOneItem(item); __result = true; } } } public class MocapClip { private const int SupportedVersion = 2; private const int BallFloats = 5; public float Fps; public int FrameCount; public int VecCount; public float BallDiameterLegUnits; private float[] _data; private int _frameStride; public static MocapClip LoadEmbedded(string logicalName) { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(logicalName); if (stream == null) { return null; } using BinaryReader binaryReader = new BinaryReader(stream); if (binaryReader.ReadInt32() != 2) { return null; } MocapClip mocapClip = new MocapClip { Fps = binaryReader.ReadSingle(), FrameCount = binaryReader.ReadInt32(), VecCount = binaryReader.ReadInt32(), BallDiameterLegUnits = binaryReader.ReadSingle() }; mocapClip._frameStride = mocapClip.VecCount * 3 + 5; int num = mocapClip.FrameCount * mocapClip._frameStride; mocapClip._data = new float[num]; for (int i = 0; i < num; i++) { mocapClip._data[i] = binaryReader.ReadSingle(); } return mocapClip; } public Vector3 GetDir(int frame, int vecIndex) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) int num = frame * _frameStride + vecIndex * 3; return new Vector3(_data[num], _data[num + 1], _data[num + 2]); } public bool BallVisible(int frame) { return _data[frame * _frameStride + VecCount * 3] > 0.5f; } public bool BallOnLeftHand(int frame) { return _data[frame * _frameStride + VecCount * 3 + 1] < 0.5f; } public Vector3 BallOffset(int frame) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) int num = frame * _frameStride + VecCount * 3 + 2; return new Vector3(_data[num], _data[num + 1], _data[num + 2]); } } public class SkeletonDanceController : MonoBehaviour { private struct Limb { public Transform Bone; public Transform To; public int VecIndex; public Vector3 RestDir; public Quaternion RestRot; } private const string ClipResourceName = "SkeletonDance.dance.bin"; private const string BallPrefabName = "SurtlingCore"; private const float BlendInSeconds = 0.3f; private const string IntroMessage = "喜欢唱 跳 rap 篮球"; private const string MusicMessage = "music"; private const float IntroToMusicSeconds = 1.2f; private const int HipLine = 0; private const int Spine = 1; private const int LArm = 2; private const int RArm = 3; private const int LFore = 4; private const int RFore = 5; private const int LThigh = 6; private const int RThigh = 7; private const int LShin = 8; private const int RShin = 9; private const int ShoulderLine = 10; private static MocapClip _clip; private static bool _clipLoadAttempted; private Animator _animator; private CharacterAnimEvent _animEvent; private BaseAI _ai; private Character _character; private VisEquipment _visEquipment; private Transform _hips; private Transform _spine1; private Transform _neck; private Transform _leftArm; private Transform _rightArm; private Transform _leftForeArm; private Transform _rightForeArm; private Transform _leftHand; private Transform _rightHand; private Transform _leftUpLeg; private Transform _rightUpLeg; private Transform _leftLeg; private Transform _rightLeg; private Transform _leftFoot; private Transform _rightFoot; private bool _ready; private Limb[] _limbs; private Transform[] _posedBones; private Quaternion[] _restLocalRot; private Vector3 _hipsRestLocalPos; private Quaternion _hipsRestRot; private Quaternion _hipsRestBasis; private Quaternion _spineRestRot; private Quaternion _spineRestBasis; private float _restFootHeight; private float _legLength; private GameObject _ball; private float _ballRadius; private readonly List<GameObject> _hiddenGear = new List<GameObject>(); private AudioSource _bgmSource; private Coroutine _running; private bool _posed; private bool _hadAnimator; private bool _hadAnimEvent; private bool _hadAi; public static void PlayOn(GameObject skeleton, Vector3 faceTarget) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) SkeletonDanceController skeletonDanceController = skeleton.GetComponent<SkeletonDanceController>(); if ((Object)(object)skeletonDanceController == (Object)null) { skeletonDanceController = skeleton.AddComponent<SkeletonDanceController>(); } skeletonDanceController.StartDance(faceTarget); } private void Awake() { if (!_clipLoadAttempted) { _clipLoadAttempted = true; _clip = MocapClip.LoadEmbedded("SkeletonDance.dance.bin"); } _animator = ((Component)this).GetComponentInChildren<Animator>(); _animEvent = ((Component)this).GetComponentInChildren<CharacterAnimEvent>(); _ai = ((Component)this).GetComponent<BaseAI>(); _character = ((Component)this).GetComponent<Character>(); _visEquipment = ((Component)this).GetComponent<VisEquipment>(); Transform armature = FindDeep(((Component)this).transform, "Armature"); if ((Object)(object)armature == (Object)null) { return; } _hips = Find("Hips"); _spine1 = Find("Spine1"); _neck = Find("Neck"); _leftArm = Find("LeftArm"); _rightArm = Find("RightArm"); _leftForeArm = Find("LeftForeArm"); _rightForeArm = Find("RightForeArm"); _leftHand = Find("LeftHand"); _rightHand = Find("RightHand"); _leftUpLeg = Find("LeftUpLeg"); _rightUpLeg = Find("RightUpLeg"); _leftLeg = Find("LeftLeg"); _rightLeg = Find("RightLeg"); _leftFoot = Find("LeftFoot"); _rightFoot = Find("RightFoot"); Transform[] array = (Transform[])(object)new Transform[15] { _hips, _spine1, _neck, _leftArm, _rightArm, _leftForeArm, _rightForeArm, _leftHand, _rightHand, _leftUpLeg, _rightUpLeg, _leftLeg, _rightLeg, _leftFoot, _rightFoot }; for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] == (Object)null) { return; } } _limbs = new Limb[8] { new Limb { Bone = _leftArm, To = _leftForeArm, VecIndex = 2 }, new Limb { Bone = _rightArm, To = _rightForeArm, VecIndex = 3 }, new Limb { Bone = _leftForeArm, To = _leftHand, VecIndex = 4 }, new Limb { Bone = _rightForeArm, To = _rightHand, VecIndex = 5 }, new Limb { Bone = _leftUpLeg, To = _leftLeg, VecIndex = 6 }, new Limb { Bone = _rightUpLeg, To = _rightLeg, VecIndex = 7 }, new Limb { Bone = _leftLeg, To = _leftFoot, VecIndex = 8 }, new Limb { Bone = _rightLeg, To = _rightFoot, VecIndex = 9 } }; _posedBones = (Transform[])(object)new Transform[10] { _hips, _spine1, _leftArm, _rightArm, _leftForeArm, _rightForeArm, _leftUpLeg, _rightUpLeg, _leftLeg, _rightLeg }; _restLocalRot = (Quaternion[])(object)new Quaternion[_posedBones.Length]; _ready = true; Transform Find(string name) { return FindDeep(armature, name); } } private static Transform FindDeep(Transform root, string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (((Object)root).name == name) { return root; } foreach (Transform item in root) { Transform val = FindDeep(item, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } public void StartDance(Vector3 faceTarget) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (_clip == null || !_ready) { return; } if (_running != null) { ((MonoBehaviour)this).StopCoroutine(_running); Finish(); } Vector3 val = faceTarget - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { ((Component)this).transform.rotation = Quaternion.LookRotation(val); if ((Object)(object)_character != (Object)null) { _character.SetLookDir(((Vector3)(ref val)).normalized, 0f); } } _running = ((MonoBehaviour)this).StartCoroutine(DanceRoutine()); } private IEnumerator DanceRoutine() { _hadAi = (Object)(object)_ai != (Object)null && ((Behaviour)_ai).enabled; if ((Object)(object)_ai != (Object)null) { ((Behaviour)_ai).enabled = false; } HideGear(); ShowCenterMessage("喜欢唱 跳 rap 篮球"); yield return (object)new WaitForSeconds(1.2f); ShowCenterMessage("music"); PlayBgm(); CaptureRestPose(); EnsureBall(); _hadAnimator = (Object)(object)_animator != (Object)null && ((Behaviour)_animator).enabled; _hadAnimEvent = (Object)(object)_animEvent != (Object)null && ((Behaviour)_animEvent).enabled; if ((Object)(object)_animator != (Object)null) { ((Behaviour)_animator).enabled = false; } if ((Object)(object)_animEvent != (Object)null) { ((Behaviour)_animEvent).enabled = false; } float duration = (float)_clip.FrameCount / _clip.Fps; for (float t = 0f; t < duration; t += Time.deltaTime) { ApplyPose(t); yield return null; } Finish(); _running = null; } private void Finish() { //IL_001e: 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) if (_posed) { for (int i = 0; i < _posedBones.Length; i++) { _posedBones[i].localRotation = _restLocalRot[i]; } _hips.localPosition = _hipsRestLocalPos; _posed = false; if ((Object)(object)_animator != (Object)null) { ((Behaviour)_animator).enabled = _hadAnimator; } if ((Object)(object)_animEvent != (Object)null) { ((Behaviour)_animEvent).enabled = _hadAnimEvent; } } if ((Object)(object)_ball != (Object)null) { _ball.SetActive(false); } if ((Object)(object)_bgmSource != (Object)null) { _bgmSource.Stop(); } ShowGear(); if ((Object)(object)_ai != (Object)null) { ((Behaviour)_ai).enabled = _hadAi; } } private static void ShowCenterMessage(string text) { if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false, true); } } private void PlayBgm() { if ((Object)(object)SkeletonDancePlugin.Bgm == (Object)null) { return; } if ((Object)(object)_bgmSource == (Object)null) { _bgmSource = ((Component)this).gameObject.AddComponent<AudioSource>(); _bgmSource.playOnAwake = false; _bgmSource.loop = true; _bgmSource.spatialBlend = 1f; _bgmSource.rolloffMode = (AudioRolloffMode)1; _bgmSource.minDistance = 10f; _bgmSource.maxDistance = 50f; if ((Object)(object)MusicMan.instance != (Object)null) { _bgmSource.outputAudioMixerGroup = MusicMan.instance.m_musicMixer; } } _bgmSource.clip = SkeletonDancePlugin.Bgm; _bgmSource.Play(); } private void CaptureRestPose() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0050: 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_0067: 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_0077: 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_008c: 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) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_012c: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_01ba: 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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) _posed = true; for (int i = 0; i < _posedBones.Length; i++) { _restLocalRot[i] = _posedBones[i].localRotation; } _hipsRestLocalPos = _hips.localPosition; _hipsRestRot = _hips.rotation; _hipsRestBasis = Basis(_leftUpLeg.position - _rightUpLeg.position, _neck.position - _hips.position); _spineRestRot = _spine1.rotation; _spineRestBasis = Basis(_leftArm.position - _rightArm.position, _neck.position - _spine1.position); for (int j = 0; j < _limbs.Length; j++) { ref Limb reference = ref _limbs[j]; Vector3 val = _limbs[j].To.position - _limbs[j].Bone.position; reference.RestDir = ((Vector3)(ref val)).normalized; _limbs[j].RestRot = _limbs[j].Bone.rotation; } _restFootHeight = Mathf.Min(_leftFoot.position.y, _rightFoot.position.y) - ((Component)this).transform.position.y; _legLength = (Vector3.Distance(_leftUpLeg.position, _leftLeg.position) + Vector3.Distance(_leftLeg.position, _leftFoot.position) + Vector3.Distance(_rightUpLeg.position, _rightLeg.position) + Vector3.Distance(_rightLeg.position, _rightFoot.position)) / 2f; } private static Quaternion Basis(Vector3 side, Vector3 up) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(side, up); if (!(((Vector3)(ref val)).sqrMagnitude > 1E-08f)) { return Quaternion.identity; } return Quaternion.LookRotation(val, up); } private Vector3 MapToWorld(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //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_0032: 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_0048: Unknown result type (might be due to invalid IL or missing references) return (0f - v.x) * ((Component)this).transform.right - v.y * ((Component)this).transform.up - v.z * ((Component)this).transform.forward; } private void ApplyPose(float t) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_009f: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) float num = t * _clip.Fps; int f0 = Mathf.Min((int)num, _clip.FrameCount - 1); int f1 = Mathf.Min(f0 + 1, _clip.FrameCount - 1); float blend = num - (float)f0; float num2 = Mathf.Clamp01(t / 0.3f); _hips.localPosition = _hipsRestLocalPos; Quaternion val = Basis(Dir(0), Dir(1)) * Quaternion.Inverse(_hipsRestBasis) * _hipsRestRot; _hips.rotation = Quaternion.Slerp(_hipsRestRot, val, num2); Quaternion val2 = Basis(Dir(10), Dir(1)) * Quaternion.Inverse(_spineRestBasis) * _spineRestRot; _spine1.rotation = Quaternion.Slerp(_spineRestRot, val2, num2); Limb[] limbs = _limbs; for (int i = 0; i < limbs.Length; i++) { Limb limb = limbs[i]; Quaternion val3 = Quaternion.FromToRotation(limb.RestDir, Dir(limb.VecIndex)) * limb.RestRot; limb.Bone.rotation = Quaternion.Slerp(limb.RestRot, val3, num2); } float num3 = Mathf.Min(_leftFoot.position.y, _rightFoot.position.y); float num4 = Mathf.Clamp(((Component)this).transform.position.y + _restFootHeight - num3, -0.7f * _legLength, 0.3f * _legLength); Transform hips = _hips; hips.position += Vector3.up * num4; UpdateBall(f0); Vector3 Dir(int v) { //IL_000d: 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) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Vector3 val4 = MapToWorld(Vector3.Slerp(_clip.GetDir(f0, v), _clip.GetDir(f1, v), blend)); return ((Vector3)(ref val4)).normalized; } } private void UpdateBall(int frame) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ball == (Object)null) { return; } bool flag = _clip.BallVisible(frame); if (_ball.activeSelf != flag) { _ball.SetActive(flag); } if (flag) { Vector3 val = (_clip.BallOnLeftHand(frame) ? _leftHand : _rightHand).position + MapToWorld(_clip.BallOffset(frame)) * _legLength; float num = ((Component)this).transform.position.y + _ballRadius; if (val.y < num) { val.y = num; } _ball.transform.position = val; } } private void EnsureBall() { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ball != (Object)null || (Object)(object)ObjectDB.instance == (Object)null) { return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("SurtlingCore"); Transform val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.transform.Find("attach") : null); if ((Object)(object)val == (Object)null) { return; } _ball = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)this).transform); Collider[] componentsInChildren = _ball.GetComponentsInChildren<Collider>(); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } float num = _clip.BallDiameterLegUnits * _legLength; MeshFilter componentInChildren = _ball.GetComponentInChildren<MeshFilter>(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.sharedMesh != (Object)null) { Bounds bounds = componentInChildren.sharedMesh.bounds; float num2 = ((Bounds)(ref bounds)).size.x * ((Component)componentInChildren).transform.lossyScale.x; if (num2 > 0.0001f) { Transform transform = _ball.transform; transform.localScale *= num / num2; } } _ballRadius = num / 2f; _ball.SetActive(false); } private void HideGear() { _hiddenGear.Clear(); if ((Object)(object)_visEquipment == (Object)null) { return; } GameObject[] array = (GameObject[])(object)new GameObject[4] { _visEquipment.m_rightItemInstance, _visEquipment.m_leftItemInstance, _visEquipment.m_rightBackItemInstance, _visEquipment.m_leftBackItemInstance }; foreach (GameObject val in array) { if ((Object)(object)val != (Object)null && val.activeSelf) { val.SetActive(false); _hiddenGear.Add(val); } } } private void ShowGear() { foreach (GameObject item in _hiddenGear) { if ((Object)(object)item != (Object)null) { item.SetActive(true); } } _hiddenGear.Clear(); } } [BepInPlugin("yuxaio.skeletondance", "VikingTrainee", "1.0.0")] public class SkeletonDancePlugin : BaseUnityPlugin { public const string PluginGuid = "yuxaio.skeletondance"; public const string PluginName = "VikingTrainee"; public const string PluginVersion = "1.0.0"; public static AudioClip Bgm; private Harmony _harmony; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _harmony = new Harmony("yuxaio.skeletondance"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"VikingTrainee v1.0.0 loaded. Feed a friendly skeleton a chicken egg."); ((MonoBehaviour)this).StartCoroutine(LoadBgm()); } private IEnumerator LoadBgm() { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); (string, AudioType)[] array = new(string, AudioType)[3] { ("ogg", (AudioType)14), ("mp3", (AudioType)13), ("wav", (AudioType)20) }; for (int i = 0; i < array.Length; i++) { (string, AudioType) tuple = array[i]; string item = tuple.Item1; AudioType item2 = tuple.Item2; string path = Path.Combine(directoryName, "bgm." + item); if (!File.Exists(path)) { continue; } if (IsMp4Container(path)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("'" + path + "' is actually an MP4 video renamed to ." + item + "; it would play as static noise. Extract the audio into a real bgm.wav / bgm.ogg / bgm.mp3 first.")); continue; } UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, item2); try { yield return request.SendWebRequest(); if ((int)request.result != 1) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to load BGM '" + path + "': " + request.error)); yield break; } Bgm = DownloadHandlerAudioClip.GetContent(request); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"BGM loaded: {path} ({Bgm.length:F1}s)"); } finally { ((IDisposable)request)?.Dispose(); } yield break; } ((BaseUnityPlugin)this).Logger.LogInfo((object)("No BGM found. Put bgm.ogg / bgm.mp3 / bgm.wav into " + directoryName + " to enable it.")); } private static bool IsMp4Container(string path) { byte[] array = new byte[8]; using (FileStream fileStream = File.OpenRead(path)) { if (fileStream.Read(array, 0, 8) < 8) { return false; } } if (array[4] == 102 && array[5] == 116 && array[6] == 121) { return array[7] == 112; } return false; } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }