using System; using System.Buffers; using System.Buffers.Binary; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using WKMPMod.Data; using WKMPMod.Util; [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: AssemblyCompany("WKMultiPlayerMod.Shared")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c664af9c6db0f762604a4131fc6e270d3b64a4b5")] [assembly: AssemblyProduct("WKMultiPlayerMod.Shared")] [assembly: AssemblyTitle("WKMultiPlayerMod.Shared")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } public enum HandType { Left, Right } [Serializable] public struct PlayerData : INetworkSerializable { [Serializable] public struct HandData : INetworkSerializable { public HandType handType; public float PosX; public float PosY; public float PosZ; public Vector3 Position { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(PosX, PosY, PosZ); } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) PosX = value.x; PosY = value.y; PosZ = value.z; } } public void Serialize(DataWriter writer) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) writer.Put((byte)handType); writer.Put(Position); } public void Deserialize(DataReader reader) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) handType = (HandType)reader.GetByte(); Position = reader.GetVector3(); } } public ulong playId; public long TimestampTicks; public float PosX; public float PosY; public float PosZ; public float RotX; public float RotY; public float RotZ; public float RotW; public HandData LeftHand; public HandData RightHand; public bool IsTeleport; public Vector3 Position { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(PosX, PosY, PosZ); } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) PosX = value.x; PosY = value.y; PosZ = value.z; } } public Quaternion Rotation { get { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Quaternion(RotX, RotY, RotZ, RotW); } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) RotX = value.x; RotY = value.y; RotZ = value.z; RotW = value.w; } } public void Serialize(DataWriter writer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) writer.Put(playId).Put(TimestampTicks); writer.Put(Position).Put(Rotation); writer.Put(LeftHand.Position).Put(RightHand.Position); writer.Put(IsTeleport); } public void Deserialize(DataReader reader) { //IL_001b: 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_003a: 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) playId = reader.GetULong(); TimestampTicks = reader.GetLong(); Position = reader.GetVector3(); Rotation = reader.GetQuaternion(); LeftHand.Position = reader.GetVector3(); RightHand.Position = reader.GetVector3(); IsTeleport = reader.GetBool(); } } namespace WKMPMod.Util { public static class DictionaryExtensions { public static List FindByKeySuffix(this Dictionary dictionary, ulong suffix) { List list = new List(); if (dictionary == null || dictionary.Count == 0) { return list; } ulong num = CalculateDivisor(suffix); foreach (KeyValuePair item in dictionary) { if (item.Key % num == suffix) { list.Add(item.Key); } } return list; } private static ulong CalculateDivisor(ulong suffix) { if (suffix == 0) { return 10uL; } ulong num; for (num = 1uL; num <= suffix; num *= 10) { } return num; } public static Dictionary SetDifference(Dictionary minuend, Dictionary subtrahend) { Dictionary dictionary = new Dictionary(); foreach (var (key, b2) in minuend) { if (subtrahend.TryGetValue(key, out var value)) { if (b2 > value) { dictionary[key] = (byte)(b2 - value); } } else { dictionary[key] = b2; } } return dictionary; } } public class TickTimer { private float _interval; private float _lastTickTime; public float Progress => Mathf.Clamp01((Time.time - _lastTickTime) / _interval); public float TimeRemaining => Mathf.Max(0f, _interval - (Time.time - _lastTickTime)); public bool IsTickReached => Time.time - _lastTickTime >= _interval; public TickTimer(float tick) { _interval = tick; _lastTickTime = 0f - _interval; } public TickTimer(int hz) { _interval = 1f / (float)hz; _lastTickTime = 0f - _interval; } public void SetInterval(float tick) { _interval = tick; } public void SetFrequency(float hz) { _interval = 1f / hz; } public void Reset() { _lastTickTime = Time.time; } public bool TryTick() { if (Time.time - _lastTickTime >= _interval) { _lastTickTime = Time.time; return true; } return false; } public void ForceTick() { _lastTickTime = Time.time; } } } namespace WKMPMod.MK_Component { public class MK_CL_Handhold : MonoBehaviour { public UnityEvent activeEvent = new UnityEvent(); public UnityEvent stopEvent = new UnityEvent(); public Renderer handholdRenderer; } public class MK_ObjectTagger : MonoBehaviour { public List tags = new List(); } public class MK_RemoteEntity : MonoBehaviour { public ulong PlayerId; public float AllActive = 1f; public float HammerActive = 1f; public float RebarActive = 1f; public float ReturnRebarActive = 1f; public float RebarExplosionActive = 1f; public float ExplosionActive = 1f; public float PitonActive = 1f; public float FlareActive = 1f; public float IceActive = 1f; public float OtherActive = 1f; public GameObject DamageObject; } } namespace WKMPMod.Data { public class DataReader { private ReadOnlyMemory _data; private int _position; public int AvailableBytes => _data.Length - _position; public void SetSource(ArraySegment source) { _data = source; _position = 0; } public void SetSource(byte[] source) { _data = source; _position = 0; } public void SetSource(byte[] source, int offset, int length) { _data = new ReadOnlyMemory(source, offset, length); _position = 0; } public bool GetBool() { bool result = _data.Span[_position] != 0; _position++; return result; } public byte GetByte() { byte result = _data.Span[_position]; _position++; return result; } public short GetShort() { short result = BinaryPrimitives.ReadInt16LittleEndian(_data.Span.Slice(_position)); _position += 2; return result; } public ushort GetUShort() { ushort result = BinaryPrimitives.ReadUInt16LittleEndian(_data.Span.Slice(_position)); _position += 2; return result; } public int GetInt() { int result = BinaryPrimitives.ReadInt32LittleEndian(_data.Span.Slice(_position)); _position += 4; return result; } public uint GetUInt() { uint result = BinaryPrimitives.ReadUInt32LittleEndian(_data.Span.Slice(_position)); _position += 4; return result; } public long GetLong() { long result = BinaryPrimitives.ReadInt64LittleEndian(_data.Span.Slice(_position)); _position += 8; return result; } public ulong GetULong() { ulong result = BinaryPrimitives.ReadUInt64LittleEndian(_data.Span.Slice(_position)); _position += 8; return result; } public float GetFloat() { int value = BinaryPrimitives.ReadInt32LittleEndian(_data.Span.Slice(_position)); _position += 4; return BitConverter.Int32BitsToSingle(value); } public double GetDouble() { long value = BinaryPrimitives.ReadInt64LittleEndian(_data.Span.Slice(_position)); _position += 8; return BitConverter.Int64BitsToDouble(value); } public byte? GetNullableByte() { if (!GetBool()) { return null; } return GetByte(); } public int? GetNullableInt() { if (!GetBool()) { return null; } return GetInt(); } public float? GetNullableFloat() { if (!GetBool()) { return null; } return GetFloat(); } public Vector3 GetVector3() { //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_0069: Unknown result type (might be due to invalid IL or missing references) ReadOnlySpan source = _data.Span.Slice(_position); float num = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(source)); float num2 = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(source.Slice(4))); float num3 = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(source.Slice(8))); _position += 12; return new Vector3(num, num2, num3); } public Quaternion GetQuaternion() { //IL_0077: 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_0080: Unknown result type (might be due to invalid IL or missing references) ReadOnlySpan source = _data.Span.Slice(_position); float num = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(source)); float num2 = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(source.Slice(4))); float num3 = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(source.Slice(8))); float num4 = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(source.Slice(12))); _position += 16; return new Quaternion(num, num2, num3, num4); } public string GetString() { int @int = GetInt(); if (@int <= 0) { return string.Empty; } if (@int > AvailableBytes) { throw new Exception("String length out of range"); } string @string = Encoding.UTF8.GetString(_data.Span.Slice(_position, @int)); _position += @int; return @string; } public ReadOnlySpan GetBytes() { int @int = GetInt(); ReadOnlySpan result = _data.Span.Slice(_position, @int); _position += @int; return result; } public ReadOnlyMemory GetMemory() { int @int = GetInt(); ReadOnlyMemory result = _data.Slice(_position, @int); _position += @int; return result; } public Dictionary GetStringByteDict() { int @int = GetInt(); Dictionary dictionary = new Dictionary(); for (int i = 0; i < @int; i++) { string @string = GetString(); byte @byte = GetByte(); dictionary[@string] = @byte; } return dictionary; } public List GetStringList() { List list = new List(); int @int = GetInt(); for (int i = 0; i < @int; i++) { list.Add(GetString()); } return list; } public T Get() where T : INetworkSerializable, new() { T result = new T(); result.Deserialize(this); return result; } public void GetOut(out T value) where T : struct, INetworkSerializable { value = default(T); value.Deserialize(this); } public void GetRef(ref T value) where T : struct, INetworkSerializable { value.Deserialize(this); } public List GetList() where T : INetworkSerializable, new() { int @int = GetInt(); if (@int <= 0) { return new List(0); } List list = new List(@int); for (int i = 0; i < @int; i++) { T item = new T(); item.Deserialize(this); list.Add(item); } return list; } public void GetList(List existingList) where T : INetworkSerializable, new() { int @int = GetInt(); existingList.Clear(); for (int i = 0; i < @int; i++) { T item = new T(); item.Deserialize(this); existingList.Add(item); } } } public class DataWriter : IDisposable { private byte[] _buffer; private int _position; private readonly ArrayPool _pool; public ArraySegment Data => new ArraySegment(_buffer, 0, _position); public DataWriter(int initialCapacity = 1024) { _pool = ArrayPool.Shared; _buffer = _pool.Rent(initialCapacity); _position = 0; } public byte[] ToArray() { byte[] array = new byte[_position]; Array.Copy(_buffer, 0, array, 0, _position); return array; } public void CopyDataTo(byte[] target, int targetOffset = 0) { if (target.Length - targetOffset < _position) { throw new ArgumentException("Target buffer is too small"); } Array.Copy(_buffer, 0, target, targetOffset, _position); } public void Reset() { _position = 0; } public DataWriter Put(bool value) { EnsureCapacity(1); _buffer[_position] = (byte)(value ? 1u : 0u); _position++; return this; } public DataWriter Put(byte value) { EnsureCapacity(1); _buffer[_position] = value; _position++; return this; } public DataWriter Put(short value) { EnsureCapacity(2); BinaryPrimitives.WriteInt16LittleEndian(_buffer.AsSpan(_position), value); _position += 2; return this; } public DataWriter Put(ushort value) { EnsureCapacity(2); BinaryPrimitives.WriteUInt16LittleEndian(_buffer.AsSpan(_position), value); _position += 2; return this; } public DataWriter Put(int value) { EnsureCapacity(4); BinaryPrimitives.WriteInt32LittleEndian(_buffer.AsSpan(_position), value); _position += 4; return this; } public DataWriter Put(uint value) { EnsureCapacity(4); BinaryPrimitives.WriteUInt32LittleEndian(_buffer.AsSpan(_position), value); _position += 4; return this; } public DataWriter Put(long value) { EnsureCapacity(8); BinaryPrimitives.WriteInt64LittleEndian(_buffer.AsSpan(_position), value); _position += 8; return this; } public DataWriter Put(ulong value) { EnsureCapacity(8); BinaryPrimitives.WriteUInt64LittleEndian(_buffer.AsSpan(_position), value); _position += 8; return this; } public DataWriter Put(float value) { EnsureCapacity(4); int value2 = BitConverter.SingleToInt32Bits(value); BinaryPrimitives.WriteInt32LittleEndian(_buffer.AsSpan(_position), value2); _position += 4; return this; } public DataWriter Put(double value) { EnsureCapacity(8); long value2 = BitConverter.DoubleToInt64Bits(value); BinaryPrimitives.WriteInt64LittleEndian(_buffer.AsSpan(_position), value2); _position += 8; return this; } public DataWriter Put(byte? value) { if (!value.HasValue) { Put(value: false); } else { Put(value: true); Put(value.Value); } return this; } public DataWriter Put(int? value) { if (!value.HasValue) { Put(value: false); } else { Put(value: true); Put(value.Value); } return this; } public DataWriter Put(float? value) { if (!value.HasValue) { Put(value: false); } else { Put(value: true); Put(value.Value); } return this; } public DataWriter Put(byte[] value) { if (value == null) { return Put(0); } return Put(value, 0, value.Length); } public DataWriter Put(byte[] value, int offset, int length) { if (value == null) { EnsureCapacity(4); BinaryPrimitives.WriteInt32LittleEndian(_buffer.AsSpan(_position), 0); _position += 4; return this; } Put(length); EnsureCapacity(length); Array.Copy(value, offset, _buffer, _position, length); _position += length; return this; } public DataWriter Put(ReadOnlySpan value) { Put(value.Length); EnsureCapacity(value.Length); value.CopyTo(_buffer.AsSpan(_position)); _position += value.Length; return this; } public DataWriter Put(string value) { if (string.IsNullOrEmpty(value)) { Put(0); return this; } int maxByteCount = Encoding.UTF8.GetMaxByteCount(value.Length); EnsureCapacity(maxByteCount + 4); int position = _position; _position += 4; int bytes = Encoding.UTF8.GetBytes(value, 0, value.Length, _buffer, _position); BinaryPrimitives.WriteInt32LittleEndian(_buffer.AsSpan(position), bytes); _position += bytes; return this; } public DataWriter Put(Vector3 value) { //IL_001d: 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_004f: Unknown result type (might be due to invalid IL or missing references) EnsureCapacity(12); Span destination = _buffer.AsSpan(_position); BinaryPrimitives.WriteInt32LittleEndian(destination, BitConverter.SingleToInt32Bits(value.x)); BinaryPrimitives.WriteInt32LittleEndian(destination.Slice(4), BitConverter.SingleToInt32Bits(value.y)); BinaryPrimitives.WriteInt32LittleEndian(destination.Slice(8), BitConverter.SingleToInt32Bits(value.z)); _position += 12; return this; } public DataWriter Put(Quaternion value) { //IL_001d: 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_004f: 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) EnsureCapacity(16); Span destination = _buffer.AsSpan(_position); BinaryPrimitives.WriteInt32LittleEndian(destination, BitConverter.SingleToInt32Bits(value.x)); BinaryPrimitives.WriteInt32LittleEndian(destination.Slice(4), BitConverter.SingleToInt32Bits(value.y)); BinaryPrimitives.WriteInt32LittleEndian(destination.Slice(8), BitConverter.SingleToInt32Bits(value.z)); BinaryPrimitives.WriteInt32LittleEndian(destination.Slice(12), BitConverter.SingleToInt32Bits(value.w)); _position += 16; return this; } public DataWriter Put(Dictionary dict) { if (dict == null) { Put(0); return this; } Put(dict.Count); foreach (KeyValuePair item in dict) { Put(item.Key).Put(item.Value); } return this; } public DataWriter Put(IReadOnlyList strings) { if (strings == null) { Put(0); return this; } Put(strings.Count); foreach (string @string in strings) { Put(@string); } return this; } public DataWriter Put(T obj) where T : INetworkSerializable { obj.Serialize(this); return this; } public DataWriter PutIn(in T obj) where T : struct, INetworkSerializable { obj.Serialize(this); return this; } public DataWriter Put(IReadOnlyList list) where T : INetworkSerializable { if (list == null || list.Count == 0) { Put(0); return this; } Put(list.Count); foreach (T item in list) { item.Serialize(this); } return this; } public void EnsureCapacity(int additional) { if (_position + additional > _buffer.Length) { byte[] array = _pool.Rent((_position + additional) * 2); Array.Copy(_buffer, 0, array, 0, _position); _pool.Return(_buffer); _buffer = array; } } public void Dispose() { if (_buffer != null) { _pool.Return(_buffer); _buffer = null; _position = 0; } } } public interface INetworkSerializable { void Serialize(DataWriter writer); void Deserialize(DataReader reader); } } namespace WKMPMod.Component { public class LookAt : MonoBehaviour { private Camera? mainCamera; [Header("锁定大小")] public bool maintainScreenSize = true; [Header("初始缩放比例")] public float baseScale = 0.1f; [Header("用户设置缩放比例")] public float userScale = 1f; private void LateUpdate() { //IL_0044: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mainCamera == (Object)null) { mainCamera = Camera.main; if ((Object)(object)mainCamera == (Object)null) { return; } } ((Component)this).transform.rotation = ((Component)mainCamera).transform.rotation; if (maintainScreenSize) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)mainCamera).transform.position); float num2 = ((!(num < 10f)) ? num : (0.8f * num + 2f)); float num3 = num2 * baseScale * userScale; ((Component)this).transform.localScale = new Vector3(num3, num3, num3); } } } public class ObjectIdentity : MonoBehaviour { public string FactoryKey = ""; } public class RemoteHand : MonoBehaviour { [CompilerGenerated] private sealed class d__10 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RemoteHand <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this._isTeleporting = false; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [Header("左右手")] public HandType hand; [Header("距离设置")] [Tooltip("当当前位置与目标位置超过此距离时直接瞬移")] public float teleportThreshold = 50f; [Tooltip("平滑移动的最大距离限制")] public float maxSmoothDistance = 10f; private bool _isTeleporting = false; private Vector3 _targetPosition; private Vector3 _velocity = Vector3.zero; private void LateUpdate() { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) if (_isTeleporting) { return; } float num = Vector3.Distance(((Component)this).transform.position, _targetPosition); if (num > teleportThreshold) { Teleport(_targetPosition); } else if (((Component)this).transform.position != _targetPosition) { float num2 = CalculateSmoothTime(num); ((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, _targetPosition, ref _velocity, num2, float.MaxValue, Time.deltaTime); if (((Vector3)(ref _velocity)).magnitude < 0.5f && num > 0.05f) { Vector3 val = _targetPosition - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; _velocity = normalized * 0.5f; } } } private float CalculateSmoothTime(float distance) { if (distance > maxSmoothDistance) { return Mathf.Clamp(Mathf.Log(distance) * 0.1f, 0.05f, 0.3f); } return Mathf.Clamp(distance / 10f, 0.05f, 0.1f); } public void UpdateFromHandData(ref PlayerData.HandData handData) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) _isTeleporting = false; _targetPosition = handData.Position; } public void Teleport(Vector3 position) { //IL_000e: 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_0017: 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_0022: Unknown result type (might be due to invalid IL or missing references) _isTeleporting = true; ((Component)this).transform.position = position; _targetPosition = position; _velocity = Vector3.zero; ((MonoBehaviour)this).StartCoroutine(ResetTeleportFlag()); } [IteratorStateMachine(typeof(d__10))] private IEnumerator ResetTeleportFlag() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { <>4__this = this }; } } public class RemotePlayer : MonoBehaviour { [CompilerGenerated] private sealed class d__10 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RemotePlayer <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this._isTeleporting = false; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [Header("距离设置")] [Tooltip("当当前位置与目标位置超过此距离时直接瞬移")] public float teleportThreshold = 50f; [Tooltip("平滑移动的最大距离限制")] public float maxSmoothDistance = 10f; private bool _isTeleporting = false; private Vector3 _targetPosition; private Vector3 _velocity = Vector3.zero; private void LateUpdate() { //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_0056: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_00d2: 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_00e7: 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_00f0: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if (_isTeleporting) { return; } float num = Vector3.Distance(((Component)this).transform.position, _targetPosition); if (num > teleportThreshold) { Teleport(_targetPosition); } else if (((Component)this).transform.position != _targetPosition) { float num2 = CalculateSmoothTime(num); ((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, _targetPosition, ref _velocity, num2, float.MaxValue, Time.deltaTime); if (((Vector3)(ref _velocity)).magnitude < 0.5f && num > 0.05f) { Vector3 val = _targetPosition - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; _velocity = normalized * 0.5f; } } } private float CalculateSmoothTime(float distance) { if (distance > maxSmoothDistance) { return Mathf.Clamp(Mathf.Log(distance) * 0.1f, 0.05f, 0.3f); } return Mathf.Clamp(distance / 10f, 0.05f, 0.1f); } public void UpdateFromPlayerData(Vector3 position, Quaternion rotation) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) _isTeleporting = false; _targetPosition = position; ((Component)this).transform.rotation = rotation; } public void UpdateFromPlayerData(ref PlayerData playerData) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _isTeleporting = false; _targetPosition = playerData.Position; ((Component)this).transform.rotation = playerData.Rotation; } public void Teleport(Vector3 position, Quaternion? rotation = null) { //IL_000e: 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_0017: 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_0022: 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) _isTeleporting = true; ((Component)this).transform.position = position; _targetPosition = position; _velocity = Vector3.zero; if (rotation.HasValue) { ((Component)this).transform.rotation = rotation.Value; } ((MonoBehaviour)this).StartCoroutine(ResetTeleportFlag()); } [IteratorStateMachine(typeof(d__10))] private IEnumerator ResetTeleportFlag() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { <>4__this = this }; } } public class RemoteTag : MonoBehaviour { [CompilerGenerated] private sealed class d__20 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RemoteTag <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(15f); <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this._message = ""; <>4__this.RefreshName(); <>4__this._messageTimeoutCoroutine = null; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Transform? _cameraTransform; private TextMeshPro? _textMeshPro; private float _lastUpdateDistance; private TickTimer updateTick = new TickTimer(1); [Header("Settings")] public const float MIN_DISTANCE_LABEL = 10f; public const float DISTANCE_CHANGE_THRESHOLD = 1f; public const float MESSAGE_TIMEOUT = 15f; [Header("Id")] public ulong PlayerId; [Header("名字")] public string PlayerName = ""; [Header("Message")] public string _message = ""; private Coroutine? _messageTimeoutCoroutine; public string Message { get { return _message; } set { string text = ((value.Length <= 15) ? value : value.Substring(0, 15)); if (!(_message == text)) { _message = text; if (_messageTimeoutCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_messageTimeoutCoroutine); } _messageTimeoutCoroutine = ((MonoBehaviour)this).StartCoroutine(MessageTimeoutRoutine()); RefreshName(); } } } private void Awake() { _textMeshPro = ((Component)this).GetComponent(); if ((Object)(object)Camera.main != (Object)null) { _cameraTransform = ((Component)Camera.main).transform; } } private void OnDestroy() { if (_messageTimeoutCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_messageTimeoutCoroutine); } } private void Update() { //IL_005f: 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) if (!updateTick.TryTick()) { return; } if ((Object)(object)_cameraTransform == (Object)null) { if (!((Object)(object)Camera.main != (Object)null)) { Debug.LogError((object)"[MP RemoteTag]No main camera found"); return; } _cameraTransform = ((Component)Camera.main).transform; } float num = Vector3.Distance(((Component)this).transform.position, _cameraTransform.position); if (Mathf.Abs(num - _lastUpdateDistance) >= 1f) { RefreshName(num); } } public void Initialize(ulong playerId, string playerName) { PlayerId = playerId; PlayerName = playerName; } public void RefreshName() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_cameraTransform == (Object)null)) { RefreshName(Vector3.Distance(((Component)this).transform.position, _cameraTransform.position)); } } private void RefreshName(float currentDistance) { _lastUpdateDistance = currentDistance; if (!((Object)(object)_textMeshPro == (Object)null)) { string text = currentDistance.ToString("F0"); if (currentDistance < 10f) { ((TMP_Text)_textMeshPro).text = (string.IsNullOrEmpty(_message) ? PlayerName : (PlayerName + "\n" + _message)); return; } ((TMP_Text)_textMeshPro).text = (string.IsNullOrEmpty(_message) ? (PlayerName + " (" + text + "m)") : (PlayerName + " (" + text + "m)\n" + _message)); } } [IteratorStateMachine(typeof(d__20))] private IEnumerator MessageTimeoutRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0) { <>4__this = this }; } } public class SimpleArmIK : MonoBehaviour { [Header("目标设置")] public Transform? target; public float originalLength = 1f; [Header("限制")] public float minScale = 0.1f; public float maxScale = 10f; private void Start() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (originalLength <= 0f && (Object)(object)target != (Object)null) { originalLength = Vector3.Distance(((Component)this).transform.position, target.position); } } private void LateUpdate() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0050: 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_0056: 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) if (!((Object)(object)target == (Object)null)) { Vector3 val = target.position - ((Component)this).transform.position; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 0.0001f)) { ((Component)this).transform.rotation = Quaternion.FromToRotation(Vector3.up, val); float num = magnitude / originalLength; num = Mathf.Clamp(num, minScale, maxScale); ((Component)this).transform.localScale = new Vector3(1f, num, 1f); } } } } }