Decompiled source of Simple Multi Player v1.8.5
WKMultiPlayerMod.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Buffers; using System.Buffers.Binary; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DG.Tweening; using DarkMachine.AI; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Steamworks; using Steamworks.Data; using TMPro; using Unity.VisualScripting; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; using UnityEngine.UI; using WKMPMod.Asset; using WKMPMod.Components; using WKMPMod.Core; using WKMPMod.Data; using WKMPMod.MK_Component; using WKMPMod.NetWork; using WKMPMod.Patch; using WKMPMod.RemotePlayers; using WKMPMod.Team; using WKMPMod.UI; using WKMPMod.Util; using WKMPMod.World; using WKMPModa.Shared.Component; using WKMPModa.Shared.Data; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("WKMultiPlayerMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.8.5.0")] [assembly: AssemblyInformationalVersion("1.8.5.0+cd7e3ca4316705ad2066b11ded8d7a0c1b4cc77e")] [assembly: AssemblyProduct("WKMultiPlayerMod")] [assembly: AssemblyTitle("WKMultiPlayerMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.8.5.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } [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; } } } public class SubTransformSyncFeature : IStateSyncFeature, ISyncFeature, IFrameUpdateFeature { private readonly NetworkedGameEntity _netEntity; private Transform _subTransform; private Vector3 _lastLocalPos; private Quaternion _lastLocalRot; private Vector3 _targetLocalPos; private Quaternion _targetLocalRot; private const float PosEpsilonSqr = 0.001f; private const float LERP_SPEED = 15f; public string FeatureId => "SubTransform"; public byte StateIndex { get; set; } public bool IsDirty { get { //IL_0014: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) if ((Object)(object)_subTransform != (Object)null) { Vector3 val = _subTransform.localPosition - _lastLocalPos; if (!(((Vector3)(ref val)).sqrMagnitude > 0.001f)) { return Quaternion.Angle(_subTransform.localRotation, _lastLocalRot) > 0.5f; } return true; } return false; } } public byte InitialIndex { get; set; } public SubTransformSyncFeature(Transform subTransform, NetworkedGameEntity netEntity) { //IL_0020: 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) //IL_0026: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) _subTransform = subTransform; _netEntity = netEntity; if ((Object)(object)subTransform != (Object)null) { _lastLocalPos = (_targetLocalPos = subTransform.localPosition); _lastLocalRot = (_targetLocalRot = subTransform.localRotation); } } public void OnReset() { //IL_0011: 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_0018: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0032: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_subTransform == (Object)null)) { _lastLocalPos = (_targetLocalPos = Vector3.zero); _lastLocalRot = (_targetLocalRot = Quaternion.identity); } } public void OnDestroy() { _subTransform = null; } public void WriteState(DataWriter writer) { //IL_0016: 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) //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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_subTransform == (Object)null)) { _lastLocalPos = _subTransform.localPosition; _lastLocalRot = _subTransform.localRotation; writer.Put(_lastLocalPos); writer.Put(_lastLocalRot); } } public void ReadState(DataReader reader) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) _targetLocalPos = reader.GetVector3(); _targetLocalRot = reader.GetQuaternion(); } public void OnUpdate(float deltaTime) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0042: 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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (_netEntity.IsNetworkControlled) { _subTransform.localPosition = Vector3.Lerp(_subTransform.localPosition, _targetLocalPos, deltaTime * 15f); _subTransform.localRotation = Quaternion.Slerp(_subTransform.localRotation, _targetLocalRot, deltaTime * 15f); } } public void WriteInitialState(DataWriter writer) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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) if ((Object)(object)_subTransform == (Object)null) { writer.Put(Vector3.zero); writer.Put(Quaternion.identity); } else { writer.Put(_subTransform.localPosition); writer.Put(_subTransform.localRotation); } } public void ReadInitialState(DataReader reader) { //IL_0011: 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_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_002e: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_subTransform == (Object)null)) { _targetLocalPos = reader.GetVector3(); _targetLocalRot = reader.GetQuaternion(); _subTransform.localPosition = _targetLocalPos; _subTransform.localRotation = _targetLocalRot; _lastLocalPos = _targetLocalPos; _lastLocalRot = _targetLocalRot; } } } [HarmonyPatch(typeof(Projectile))] public static class Patch_Projectile { public static readonly FieldRef<Projectile, Vector3> velocityField = AccessTools.FieldRefAccess<Projectile, Vector3>("velocity"); public static readonly FieldRef<Projectile, Vector3> startPosField = AccessTools.FieldRefAccess<Projectile, Vector3>("startPos"); public static readonly FieldRef<Projectile, float> velocityMultiplierField = AccessTools.FieldRefAccess<Projectile, float>("velMult"); public static readonly FieldRef<Projectile, int> bouncesField = AccessTools.FieldRefAccess<Projectile, int>("bounces"); public static readonly FieldRef<Projectile, bool> hasHitSurfaceField = AccessTools.FieldRefAccess<Projectile, bool>("hasHitSurface"); public static readonly FieldRef<Projectile, bool> hasSpawnedTracerField = AccessTools.FieldRefAccess<Projectile, bool>("hasSpawnedTracer"); private static readonly Type[] InitializeArguments = new Type[3] { typeof(Vector3), typeof(GameEntity), typeof(Item) }; [HarmonyPatch("Initialize")] [HarmonyPostfix] private static void Patch_Initialize(Projectile __instance) { Singleton<ProjectileSyncModule>.Instance?.OnInitialize(__instance); } [HarmonyPatch("CollisionCheck")] [HarmonyPrefix] private static bool Patch_CollisionCheck(Projectile __instance) { return Singleton<ProjectileSyncModule>.Instance.CollisionCheck(__instance); } [HarmonyPatch("OnRichochet")] [HarmonyPostfix] private static void Patch_Richochet(Projectile __instance) { Singleton<ProjectileSyncModule>.Instance?.OnRichochet(__instance); } [HarmonyPatch("CreateHitEffect")] [HarmonyPrefix] private static void CreateHitEffectPrefix(Projectile __instance, RaycastHit hit) { if (!__instance.HasHitSurface()) { Singleton<ProjectileSyncModule>.Instance?.OnCreateHitEffect(__instance, ref hit); } } } public abstract class Singleton<T> where T : Singleton<T> { private static readonly Lazy<T> _instance = new Lazy<T>(CreateInstance, isThreadSafe: true); public static T Instance => _instance.Value; public static bool IsCreated => _instance.IsValueCreated; private static T CreateInstance() { try { ConstructorInfo? constructor = typeof(T).GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (constructor == null) { throw new InvalidOperationException("Singleton<" + typeof(T).Name + ">: Type must have a parameterless constructor"); } return (T)constructor.Invoke(null); } catch (Exception innerException) { throw new InvalidOperationException("Singleton<" + typeof(T).Name + ">: Failed to create instance", innerException); } } protected Singleton() { if (_instance.IsValueCreated) { throw new InvalidOperationException("Singleton<" + typeof(T).Name + ">: Instance already exists. Use " + typeof(T).Name + ".Instance instead."); } } } namespace WKMPMod.World { public enum PitonSyncAction : byte { Create, Update, Remove, HammerIn, Weaken, BreakRequest, Break, CreateChunkRequest, CreateChunk } public class ClimbableSyncModule : Singleton<ClimbableSyncModule>, ISyncModule { private static readonly FieldRef<Projectile, GameEntity> _sourceEntityField = AccessTools.FieldRefAccess<Projectile, GameEntity>("sourceEntity"); private static readonly Action<M_Level, GameObject> _addPlacedObjectMethod = AccessTools.MethodDelegate<Action<M_Level, GameObject>>(AccessTools.Method(typeof(M_Level), "AddPlacedObject", (Type[])null, (Type[])null), (object)null, true); private static readonly FieldRef<CL_Handhold, List<Hand>> _handsField = AccessTools.FieldRefAccess<CL_Handhold, List<Hand>>("hands"); private static readonly FieldRef<CL_Handhold, UT_SoftParent> _softParentField = AccessTools.FieldRefAccess<CL_Handhold, UT_SoftParent>("softParent"); private static readonly FieldRef<CL_Handhold, float> _offsetAmountField = AccessTools.FieldRefAccess<CL_Handhold, float>("offsetAmount"); private readonly Dictionary<ulong, ClimbableData> _globalPersistentTable = new Dictionary<ulong, ClimbableData>(); private readonly Dictionary<ulong, Coroutine> _sendRoutines = new Dictionary<ulong, Coroutine>(); private const int ChunkItemsPerFrame = 10; private static List<GameObject> _capturedPitons = new List<GameObject>(); private readonly Dictionary<ulong, NetworkedClimable> _handhold = new Dictionary<ulong, NetworkedClimable>(); private readonly Dictionary<ulong, NetworkedClimable> _localHandhold = new Dictionary<ulong, NetworkedClimable>(); private readonly List<(NetworkedClimable Identity, float LastTime)> _holdingList = new List<(NetworkedClimable, float)>(); private static readonly Dictionary<CL_Handhold, NetworkedClimable> _handholdLookup = new Dictionary<CL_Handhold, NetworkedClimable>(); private ulong _nextLocalId = 1uL; private static readonly List<(ulong id, GameObject obj)> _breakItemObject = new List<(ulong, GameObject)>(); private Coroutine _rebuildClimbable; private const float PeriodicUpdateInterval = 0.1f; private int _maxScanPerFrame = 50; private int _maxSyncPerFrame = 10; private float _timer; private bool _isScanning; private int _scanIndex; private bool _isSweeping; private int _sweepIndex; private readonly List<NetworkedClimable> _sweepQueue = new List<NetworkedClimable>(); private readonly List<NetworkedClimable> _batchBuffer = new List<NetworkedClimable>(); private readonly List<ulong> _localKeysCache = new List<ulong>(); private readonly List<ulong> _pendingRemoveKeys = new List<ulong>(); public string ModuleName => "ClimbableSync"; public bool IsEnabled { get; set; } = true; public bool ApplyingRemoteState { get; private set; } public void OnResetMap() { ResetState(); if ((Object)(object)MonoSingleton<WorldSyncManager>.Instance != (Object)null) { _rebuildClimbable = ((MonoBehaviour)MonoSingleton<WorldSyncManager>.Instance).StartCoroutine(RebuildClimbable()); } } public void OnLeave() { _globalPersistentTable.Clear(); if ((Object)(object)MonoSingleton<WorldSyncManager>.Instance != (Object)null) { foreach (Coroutine value in _sendRoutines.Values) { if (value != null) { ((MonoBehaviour)MonoSingleton<WorldSyncManager>.Instance).StopCoroutine(value); } } } _sendRoutines.Clear(); _nextLocalId = 1uL; ResetState(); } public void OnEnd() { OnLeave(); } private void ResetSweepState() { _timer = 0f; _isScanning = false; _scanIndex = 0; _isSweeping = false; _sweepIndex = 0; _sweepQueue.Clear(); _batchBuffer.Clear(); _localKeysCache.Clear(); _pendingRemoveKeys.Clear(); } public void ResetState() { ResetSweepState(); _capturedPitons.Clear(); _handhold.Clear(); _localHandhold.Clear(); _holdingList.Clear(); _handholdLookup.Clear(); _breakItemObject.Clear(); ApplyingRemoteState = false; if (_rebuildClimbable != null && (Object)(object)MonoSingleton<WorldSyncManager>.Instance != (Object)null) { ((MonoBehaviour)MonoSingleton<WorldSyncManager>.Instance).StopCoroutine(_rebuildClimbable); _rebuildClimbable = null; } } public static void SaveCapturedPiton(GameObject go) { if ((Object)(object)((go != null) ? go.GetComponentInChildren<CL_Handhold>(true) : null) != (Object)null) { _capturedPitons.Add(go); } } public void RegisterNewLocalPiton() { if (_capturedPitons.Count == 0) { return; } if (!MPCore.IsReady || ApplyingRemoteState) { _capturedPitons.Clear(); return; } foreach (GameObject capturedPiton in _capturedPitons) { GameObject climbableRoot = GetClimbableRoot(capturedPiton); if (!((Object)(object)climbableRoot == (Object)null)) { RegisterLocalClimbable(climbableRoot); } } _capturedPitons.Clear(); } public void RegisterNewLocalProjectileClimbable(Projectile source, RaycastHit hit) { if (_capturedPitons.Count == 0) { return; } if (!MPCore.IsReady || ApplyingRemoteState || (Object)(object)source == (Object)null || !IsLocalProjectile(source)) { _capturedPitons.Clear(); return; } foreach (GameObject capturedPiton in _capturedPitons) { GameObject climbableRoot = GetClimbableRoot(capturedPiton); if (!((Object)(object)climbableRoot == (Object)null)) { RegisterLocalClimbable(climbableRoot); } } _capturedPitons.Clear(); } public void OnLocalHandholdGrabbed(NetworkedClimable identity) { if ((Object)(object)identity == (Object)null || _localHandhold.ContainsKey(identity.NetworkId)) { return; } for (int i = 0; i < _holdingList.Count; i++) { if ((Object)(object)_holdingList[i].Identity == (Object)(object)identity) { return; } } _holdingList.Add((identity, Time.time)); } public void OnLocalHandholdReleased(NetworkedClimable identity) { if ((Object)(object)identity == (Object)null || _localHandhold.ContainsKey(identity.NetworkId)) { return; } for (int num = _holdingList.Count - 1; num >= 0; num--) { if ((Object)(object)_holdingList[num].Identity == (Object)(object)identity) { List<Hand> obj = _handsField.Invoke(identity.Handhold); if (obj != null && obj.Count == 0) { float weakenTime = Time.time - _holdingList[num].LastTime; SendWeaken(identity, weakenTime); _holdingList.RemoveAt(num); } break; } } } public static void CreateBreakObject(GameObject gameObject, CL_Handhold handhold) { if (TryGetNetworkIdentity(handhold, out NetworkedClimable identity) && identity.IsValid) { Singleton<ClimbableSyncModule>.Instance?._globalPersistentTable.Remove(identity.NetworkId); } Singleton<ClimbableSyncModule>.Instance?.SendBreakRequest(gameObject, handhold); } public void OnSyncUpdate(float deltaTime) { if (!MPCore.CanSync || !IsEnabled) { ResetSweepState(); return; } if (!_isScanning && !_isSweeping) { _timer += deltaTime; if (_timer >= 0.1f) { _timer = Mathf.Max(0f, _timer - 0.1f); StartNewScanCycle(); HoldWeaken(); } } if (_isScanning) { StepScan(); } if (_isSweeping) { FlushNextBatch(); } } private void StartNewScanCycle() { _sweepQueue.Clear(); _scanIndex = 0; _localKeysCache.Clear(); _localKeysCache.AddRange(_localHandhold.Keys); if (_localKeysCache.Count > 0) { _isScanning = true; } } private void StepScan() { int num = 0; while (_scanIndex < _localKeysCache.Count && num < _maxScanPerFrame) { ulong num2 = _localKeysCache[_scanIndex]; _scanIndex++; num++; if (_localHandhold.TryGetValue(num2, out NetworkedClimable value) && !((Object)(object)value == (Object)null)) { if ((Object)(object)((Component)value).gameObject == (Object)null || !((Component)value).gameObject.activeInHierarchy) { _pendingRemoveKeys.Add(num2); } else if (value.HasMeaningfulChange) { _sweepQueue.Add(value); } } } if (_pendingRemoveKeys.Count > 0) { for (int i = 0; i < _pendingRemoveKeys.Count; i++) { if (_pendingRemoveKeys[i] != 0L) { BroadcastRemove(_pendingRemoveKeys[i]); } } _pendingRemoveKeys.Clear(); } if (_scanIndex >= _localKeysCache.Count) { _isScanning = false; _localKeysCache.Clear(); if (_sweepQueue.Count > 0) { _isSweeping = true; _sweepIndex = 0; } } } private void FlushNextBatch() { _batchBuffer.Clear(); while (_sweepIndex < _sweepQueue.Count && _batchBuffer.Count < _maxSyncPerFrame) { NetworkedClimable networkedClimable = _sweepQueue[_sweepIndex]; _sweepIndex++; if ((Object)(object)networkedClimable != (Object)null && (Object)(object)((Component)networkedClimable).gameObject != (Object)null && ((Component)networkedClimable).gameObject.activeInHierarchy) { _batchBuffer.Add(networkedClimable); } } if (_batchBuffer.Count > 0) { BroadcastUpdate(_batchBuffer); } if (_sweepIndex >= _sweepQueue.Count) { _isSweeping = false; _sweepQueue.Clear(); } } private void HoldWeaken() { float time = Time.time; for (int num = _holdingList.Count - 1; num >= 0; num--) { var (networkedClimable, num2) = _holdingList[num]; if (!((Object)(object)networkedClimable == (Object)null) && !((Object)(object)networkedClimable.Handhold == (Object)null)) { List<Hand> obj = _handsField.Invoke(networkedClimable.Handhold); if (obj == null || obj.Count != 0) { float weakenTime = time - num2; _holdingList[num] = (networkedClimable, time); SendWeaken(networkedClimable, weakenTime); continue; } } _holdingList.RemoveAt(num); } } private IEnumerator SendCreateChunksRoutine(ulong clientId) { List<ClimbableData> itemsToSend = new List<ClimbableData>(); foreach (KeyValuePair<ulong, ClimbableData> item in _globalPersistentTable) { if (item.Value != null) { itemsToSend.Add(item.Value); } } int index = 0; while (index < itemsToSend.Count) { int num = Mathf.Min(10, itemsToSend.Count - index); DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, clientId, PacketType.ClimbableSync); writer.Put((byte)8); writer.Put((ushort)num); for (int i = 0; i < num; i++) { writer.Put<ClimbableData>(itemsToSend[index + i]); } MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(clientId), writer, (SendType)8, 0); index += num; yield return null; } _sendRoutines.Remove(clientId); } private void RegisterLocalClimbable(GameObject root) { string text = MPUtil.CleanCloneName(((Object)root).name); if (!((Object)(object)root == (Object)null) && !string.IsNullOrEmpty(text)) { NetworkedClimable orCreateIdentity = GetOrCreateIdentity(root); if (!orCreateIdentity.IsValid) { orCreateIdentity.data.networkId = MPUtil.Hash64($"{MPSteamworks.UserSteamId}:{_nextLocalId++}".AsSpan()); orCreateIdentity.data.ownerId = MPSteamworks.UserSteamId; orCreateIdentity.data.prefabKey = text; orCreateIdentity.RememberState(); } _handhold[orCreateIdentity.NetworkId] = orCreateIdentity; _localHandhold[orCreateIdentity.NetworkId] = orCreateIdentity; _globalPersistentTable[orCreateIdentity.NetworkId] = orCreateIdentity.data; BroadcastCreate(orCreateIdentity); } } private GameObject GetClimbableRoot(GameObject obj) { if ((Object)(object)obj == (Object)null) { return null; } Transform val = (WorldLoader.initialized ? WorldLoader.GetCurrentLevelParentRoot() : null); Transform val2 = obj.transform; while ((Object)(object)val2.parent != (Object)null && (Object)(object)val2.parent != (Object)(object)val) { val2 = val2.parent; } return ((Component)val2).gameObject; } private void CreateNetworkClimbable(ClimbableData data) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (_handhold.TryGetValue(data.networkId, out NetworkedClimable value) && (Object)(object)value != (Object)null) { value.BindData(data); return; } GameObject handholdPrefab = MPAssetManager.GetHandholdPrefab(data.prefabKey); if ((Object)(object)handholdPrefab == (Object)null) { MPMain.LogError($"[MP ClimbableSync] Could not resolve prefab '{data.prefabKey}' for {data.networkId}.", "CreateNetworkClimbable", 557, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\ClimbableSyncModule.cs"); return; } GameObject val = Object.Instantiate<GameObject>(handholdPrefab, data.position, data.rotation); TryAddPlacedObjectToLevel(val); NetworkedClimable orCreateIdentity = GetOrCreateIdentity(val); if (!orCreateIdentity.IsValid) { orCreateIdentity.data = data; } _handhold[data.networkId] = orCreateIdentity; _globalPersistentTable[data.networkId] = data; } private IEnumerator RebuildClimbable() { yield return null; yield return (object)new WaitUntil((Func<bool>)(() => WorldLoader.isLoaded || (Object)(object)WorldLoader.instance == (Object)null)); yield return null; foreach (var (_, climbableData2) in _globalPersistentTable) { if (_handhold.TryGetValue(climbableData2.networkId, out NetworkedClimable value) && (Object)(object)value != (Object)null) { value.BindData(climbableData2); continue; } GameObject handholdPrefab = MPAssetManager.GetHandholdPrefab(climbableData2.prefabKey); if ((Object)(object)handholdPrefab == (Object)null) { MPMain.LogError($"[MP ClimbableSync] Could not resolve prefab '{climbableData2.prefabKey}' for {climbableData2.networkId}.", "RebuildClimbable", 591, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\ClimbableSyncModule.cs"); continue; } GameObject val = Object.Instantiate<GameObject>(handholdPrefab, climbableData2.position, climbableData2.rotation); TryAddPlacedObjectToLevel(val); NetworkedClimable orCreateIdentity = GetOrCreateIdentity(val); if (!orCreateIdentity.IsValid) { orCreateIdentity.data = climbableData2; } _handhold[climbableData2.networkId] = orCreateIdentity; } } public static void RegisterLookup(CL_Handhold handhold, NetworkedClimable identity) { if ((Object)(object)handhold != (Object)null && (Object)(object)identity != (Object)null) { _handholdLookup[handhold] = identity; } } public static void UnregisterLookup(CL_Handhold handhold) { if ((Object)(object)handhold != (Object)null) { _handholdLookup.Remove(handhold); } } public static bool TryGetNetworkIdentity(CL_Handhold handhold, out NetworkedClimable identity) { return _handholdLookup.TryGetValue(handhold, out identity); } public void BroadcastCreate(NetworkedClimable identity) { if (MPCore.CanSync && !((Object)(object)identity == (Object)null) && identity.IsValid) { ClimbableData data = identity.data; DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.ClimbableSync); writer.Put((byte)0); writer.Put<ClimbableData>(data); MonoSingleton<MPSteamworks>.Instance.Broadcast(writer, (SendType)8, 0); } } public void BroadcastUpdate(List<NetworkedClimable> batch) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!IsEnabled || batch == null || batch.Count == 0) { return; } DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.ClimbableSync); writer.Put((byte)1); writer.Put((byte)batch.Count); for (int i = 0; i < batch.Count; i++) { NetworkedClimable networkedClimable = batch[i]; networkedClimable.RememberState(); if (_globalPersistentTable.TryGetValue(networkedClimable.NetworkId, out ClimbableData value)) { value.BindData(((Component)networkedClimable).transform.position, ((Component)networkedClimable).transform.rotation, networkedClimable.data.secureAmount, networkedClimable.data.secure); } writer.Put(networkedClimable.NetworkId); writer.Put(((Component)networkedClimable).transform.position); writer.Put(((Component)networkedClimable).transform.rotation); writer.Put(networkedClimable.data.secureAmount); writer.Put(networkedClimable.data.secure); } MonoSingleton<MPSteamworks>.Instance.Broadcast(writer, (SendType)1, 0); } public void BroadcastRemove(ulong networkId) { DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.ClimbableSync); writer.Put((byte)2); writer.Put(networkId); MonoSingleton<MPSteamworks>.Instance.Broadcast(writer, (SendType)8, 0); _handhold.Remove(networkId); _localHandhold.Remove(networkId); } public void SendBreakRequest(GameObject gameObject, CL_Handhold handhold) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (!MPCore.CanSync || ApplyingRemoteState || (Object)(object)handhold == (Object)null || (Object)(object)gameObject == (Object)null || !TryGetNetworkIdentity(handhold, out NetworkedClimable identity) || !identity.IsValid) { return; } if (!_localHandhold.ContainsKey(identity.NetworkId) && identity.data.ownerId != MPSteamworks.UserSteamId) { Item_Object val = default(Item_Object); if (gameObject.TryGetComponent<Item_Object>(ref val)) { _breakItemObject.Add((identity.NetworkId, gameObject)); } DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, identity.data.ownerId, PacketType.ClimbableSync); writer.Put((byte)5); writer.Put(identity.NetworkId); MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(identity.data.ownerId), writer, (SendType)8, 0); } else { Item_Object itemObject = default(Item_Object); if (gameObject.TryGetComponent<Item_Object>(ref itemObject)) { Singleton<DroppedItemModule>.Instance.SyncAndBroadcast(itemObject); } BroadcastBreak(identity); } } public void BroadcastBreak(NetworkedClimable identity) { DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.ClimbableSync); writer.Put((byte)6); writer.Put(identity.NetworkId); MonoSingleton<MPSteamworks>.Instance.Broadcast(writer, (SendType)8, 0); _handhold.Remove(identity.NetworkId); _localHandhold.Remove(identity.NetworkId); _globalPersistentTable.Remove(identity.NetworkId); } public void BroadcastHammerIn(CL_Handhold handhold, float amount) { //IL_0032: 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_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) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if (TryGetNetworkIdentity(handhold, out NetworkedClimable identity) && identity.IsValid) { if (_globalPersistentTable.TryGetValue(identity.NetworkId, out ClimbableData value) && value != null) { value.position = ((Component)handhold).transform.position; value.rotation = ((Component)handhold).transform.rotation; value.secureAmount = identity.Handhold.secureAmount; value.secure = identity.Handhold.secure; } if (MPCore.CanSync && !ApplyingRemoteState && !((Object)(object)handhold == (Object)null) && !_localHandhold.ContainsKey(identity.NetworkId)) { DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, identity.data.ownerId, PacketType.ClimbableSync); writer.Put((byte)3); writer.Put(identity.NetworkId); writer.Put(amount); MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(identity.data.ownerId), writer, (SendType)8, 0); } } } public void SendChunkRequest() { if (!MPSteamworks.IsHost && IsEnabled) { DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, MonoSingleton<MPSteamworks>.Instance.HostSteamId, PacketType.ClimbableSync); writer.Put((byte)7); MonoSingleton<MPSteamworks>.Instance.SendToHost(writer, (SendType)8, 0); } } public void SendWeaken(NetworkedClimable identity, float weakenTime) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (identity.data.ownerId != MPSteamworks.UserSteamId) { DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, identity.data.ownerId, PacketType.ClimbableSync); writer.Put((byte)4); writer.Put(identity.NetworkId); writer.Put(weakenTime); MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(identity.data.ownerId), writer, (SendType)8, 0); } } public void HandleCreate(ulong senderId, DataReader reader) { ClimbableData data = reader.Get<ClimbableData>(); CreateNetworkClimbable(data); } public void HandleUpdate(DataReader reader) { //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_0021: 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_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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) byte b = reader.GetByte(); ApplyingRemoteState = true; try { for (int i = 0; i < b; i++) { ulong uLong = reader.GetULong(); Vector3 vector = reader.GetVector3(); Quaternion quaternion = reader.GetQuaternion(); float secureAmount = reader.GetFloat(); bool secure = reader.GetBool(); if (_handhold.TryGetValue(uLong, out NetworkedClimable value) && (Object)(object)value != (Object)null) { ApplyState(value, vector, quaternion, secureAmount, secure); } if (_globalPersistentTable.TryGetValue(uLong, out ClimbableData value2)) { value2?.BindData(vector, quaternion, secureAmount, secure); } } } finally { ApplyingRemoteState = false; } } public void HandleRemove(DataReader reader) { ulong uLong = reader.GetULong(); if (_handhold.TryGetValue(uLong, out NetworkedClimable _)) { _handhold.Remove(uLong); } } public void HandlePitonHammerIn(DataReader reader) { ulong uLong = reader.GetULong(); float num = reader.GetFloat(); if (!_localHandhold.TryGetValue(uLong, out NetworkedClimable value) || (Object)(object)value == (Object)null) { return; } ApplyingRemoteState = true; try { value.Handhold.HammerIn(num); value.data.secureAmount = value.Handhold.secureAmount; value.data.secure = value.Handhold.secure; if (_globalPersistentTable.TryGetValue(uLong, out ClimbableData value2) && value2 != null) { value2.secureAmount = value.Handhold.secureAmount; value2.secure = value.Handhold.secure; } } finally { ApplyingRemoteState = false; } } public void HandlePitonBreak(DataReader reader) { ulong uLong = reader.GetULong(); for (int i = 0; i < _breakItemObject.Count; i++) { if (_breakItemObject[i].id == uLong) { Object.Destroy((Object)(object)_breakItemObject[i].obj); _breakItemObject.RemoveAt(i); i--; } } if (!_handhold.TryGetValue(uLong, out NetworkedClimable value) || (Object)(object)value == (Object)null) { return; } if ((Object)(object)((Component)value).gameObject != (Object)null) { if ((Object)(object)value.Handhold != (Object)null) { List<Hand> list = _handsField.Invoke(value.Handhold); while (list != null && list.Count > 0) { list[0].DropHand(false); } } Object.Destroy((Object)(object)((Component)value).gameObject); } _handhold.Remove(uLong); _localHandhold.Remove(uLong); _globalPersistentTable.Remove(uLong); } public void HandlePitonBreakRequest(DataReader reader) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) ulong uLong = reader.GetULong(); if (!_localHandhold.TryGetValue(uLong, out NetworkedClimable value) || (Object)(object)value == (Object)null) { return; } if ((Object)(object)((Component)value).gameObject != (Object)null && (Object)(object)value.Handhold != (Object)null) { CL_Handhold handhold = value.Handhold; List<Hand> list = _handsField.Invoke(handhold); while (list != null && list.Count > 0) { list[0].DropHand(false); } Item_Object itemObject = default(Item_Object); if (Object.Instantiate<GameObject>(handhold.breakObject, ((Component)handhold).transform.position, ((Component)handhold).transform.rotation).TryGetComponent<Item_Object>(ref itemObject)) { Singleton<DroppedItemModule>.Instance.SyncAndBroadcast(itemObject); } BroadcastBreak(value); Object.Destroy((Object)(object)((Component)value).gameObject); } _handhold.Remove(uLong); _localHandhold.Remove(uLong); _globalPersistentTable.Remove(uLong); } public void HandleCreateChunk(DataReader reader) { ushort uShort = reader.GetUShort(); for (int i = 0; i < uShort; i++) { ClimbableData data = reader.Get<ClimbableData>(); CreateNetworkClimbable(data); } } public void HandleChunkRequest(ulong senderId) { if (MPCore.CanSync && MPSteamworks.IsHost && !((Object)(object)MonoSingleton<WorldSyncManager>.Instance == (Object)null) && senderId != 0L && senderId != MPSteamworks.UserSteamId) { if (_sendRoutines.TryGetValue(senderId, out Coroutine value) && value != null) { ((MonoBehaviour)MonoSingleton<WorldSyncManager>.Instance).StopCoroutine(value); } _sendRoutines[senderId] = ((MonoBehaviour)MonoSingleton<WorldSyncManager>.Instance).StartCoroutine(SendCreateChunksRoutine(senderId)); } } public void HandleWeaken(DataReader reader) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_0093: 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_0115: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) ulong uLong = reader.GetULong(); float num = reader.GetFloat(); if (!_localHandhold.TryGetValue(uLong, out NetworkedClimable value) || (Object)(object)value == (Object)null) { return; } CL_Handhold handhold = value.Handhold; if ((Object)(object)handhold == (Object)null || handhold.secure) { return; } ApplyingRemoteState = true; try { handhold.secureAmount -= num * 0.115f; float num2 = num * 0.05f; Vector3 val = ((Component)handhold).transform.forward * num2; UT_SoftParent val2 = _softParentField.Invoke(handhold); if ((Object)(object)val2 != (Object)null) { val2.SoftMove(val); } else { Transform transform = ((Component)handhold).transform; transform.position += val; } _offsetAmountField.Invoke(handhold) += num2; value.data.secureAmount = handhold.secureAmount; value.data.position = ((Component)handhold).transform.position; if (_globalPersistentTable.TryGetValue(uLong, out ClimbableData value2) && value2 != null) { value2.secureAmount = handhold.secureAmount; value2.position = ((Component)handhold).transform.position; } if (handhold.secureAmount < 0f) { List<Hand> list = _handsField.Invoke(handhold); while (list != null && list.Count > 0) { list[0].DropHand(false); } Object.Instantiate<GameObject>(handhold.breakObject, ((Component)handhold).transform.position, ((Component)handhold).transform.rotation); _handhold.Remove(uLong); _localHandhold.Remove(uLong); _globalPersistentTable.Remove(uLong); Object.Destroy((Object)(object)((Component)handhold).gameObject); } } finally { ApplyingRemoteState = false; } } public void HandlePitonState(ulong senderId, DataReader reader) { switch ((PitonSyncAction)reader.GetByte()) { case PitonSyncAction.Create: HandleCreate(senderId, reader); break; case PitonSyncAction.Update: HandleUpdate(reader); break; case PitonSyncAction.Remove: HandleRemove(reader); break; case PitonSyncAction.HammerIn: HandlePitonHammerIn(reader); break; case PitonSyncAction.Weaken: HandleWeaken(reader); break; case PitonSyncAction.BreakRequest: HandlePitonBreakRequest(reader); break; case PitonSyncAction.Break: HandlePitonBreak(reader); break; case PitonSyncAction.CreateChunkRequest: HandleChunkRequest(senderId); break; case PitonSyncAction.CreateChunk: HandleCreateChunk(reader); break; } } private void ApplyState(NetworkedClimable identity, Vector3 position, Quaternion rotation, float secureAmount, bool secure) { //IL_0006: 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_0039: 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) ((Component)identity).transform.SetPositionAndRotation(position, rotation); CL_Handhold handhold = identity.Handhold; if ((Object)(object)handhold != (Object)null) { handhold.Initialize(); handhold.secureAmount = secureAmount; handhold.secure = secure; } identity.data.BindData(position, rotation, secureAmount, secure); } private bool IsLocalProjectile(Projectile projectile) { ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)projectile == (Object)null || (Object)(object)player == (Object)null) { return false; } return (Object)(object)_sourceEntityField.Invoke(projectile) == (Object)(object)player; } private void TryAddPlacedObjectToLevel(GameObject climbableObject) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!WorldLoader.initialized || (Object)(object)climbableObject == (Object)null) { return; } try { M_Level level = WorldLoader.GetClosestLevelToPosition(climbableObject.transform.position).GetLevel(); if ((Object)(object)level != (Object)null) { climbableObject.transform.SetParent(level.GetParentRoot()); _addPlacedObjectMethod(level, climbableObject); } } catch (Exception ex) { MPMain.LogWarning("[MP ClimbableSync] Could not register remote climbable as placed object: " + ex.Message); } } private NetworkedClimable GetOrCreateIdentity(GameObject obj) { return obj.GetComponent<NetworkedClimable>() ?? obj.AddComponent<NetworkedClimable>(); } } public readonly struct GroupKey<T> : IEquatable<GroupKey<T>> where T : struct { private readonly T[] _array; private readonly int _length; private readonly int _hashCode; public ReadOnlySpan<T> Span => new ReadOnlySpan<T>(_array, 0, _length); public GroupKey(T[] array, int length, int hashCode) { _array = array; _length = length; _hashCode = hashCode; } public bool Equals(GroupKey<T> other) { if (_length != other._length) { return false; } for (int i = 0; i < _length; i++) { if (!EqualityComparer<T>.Default.Equals(_array[i], other._array[i])) { return false; } } return true; } public override bool Equals(object obj) { if (obj is GroupKey<T> other) { return Equals(other); } return false; } public override int GetHashCode() { return _hashCode; } } public class CollectionGroupingManager<K, V> : IDisposable where K : struct, IEquatable<K>, IComparable<K> { public struct Enumerator : IEnumerator<KeyValuePair<GroupKey<K>, List<V>>>, IEnumerator, IDisposable { private Dictionary<GroupKey<K>, List<V>>.Enumerator _inner; public KeyValuePair<GroupKey<K>, List<V>> Current => _inner.Current; object IEnumerator.Current => Current; public Enumerator(Dictionary<GroupKey<K>, List<V>>.Enumerator inner) { _inner = inner; } public bool MoveNext() { return _inner.MoveNext(); } public void Reset() { ((IEnumerator)_inner).Reset(); } public void Dispose() { _inner.Dispose(); } } private Dictionary<GroupKey<K>, List<V>> _groupedData; private readonly List<K[]> _rentedArrays = new List<K[]>(); private readonly Stack<List<V>> _listPool = new Stack<List<V>>(); public int Count => _groupedData.Count; public CollectionGroupingManager(int capacity = 32) { _groupedData = new Dictionary<GroupKey<K>, List<V>>(capacity); } public void Clear() { foreach (KeyValuePair<GroupKey<K>, List<V>> groupedDatum in _groupedData) { List<V> value = groupedDatum.Value; value.Clear(); if (_listPool.Count < 1024) { _listPool.Push(value); } } _groupedData.Clear(); foreach (K[] rentedArray in _rentedArrays) { ArrayPool<K>.Shared.Return(rentedArray); } _rentedArrays.Clear(); } public void Dispose() { Clear(); _groupedData = null; _listPool.Clear(); } public void Record(V entityId, HashSet<K> subscribers) { if (subscribers != null && subscribers.Count != 0) { int count = subscribers.Count; K[] array = ArrayPool<K>.Shared.Rent(count); subscribers.CopyTo(array, 0); Array.Sort(array, 0, count); int num = 17; for (int i = 0; i < count; i++) { num = num * 31 + array[i].GetHashCode(); } _rentedArrays.Add(array); GroupKey<K> key = new GroupKey<K>(array, count, num); if (!_groupedData.TryGetValue(key, out List<V> value)) { value = ((_listPool.Count <= 0) ? new List<V>() : _listPool.Pop()); _groupedData[key] = value; } value.Add(entityId); } } public Enumerator GetEnumerator() { return new Enumerator(_groupedData.GetEnumerator()); } public bool TryGetValue(GroupKey<K> key, out List<V> valueList) { return _groupedData.TryGetValue(key, out valueList); } } public enum EnemySyncAction : byte { OwnerRequest = 1, OwnerResponse = 2, OwnerAbandon = 3, SubscriptionRequest = 4, UnsubscriptionRequest = 5, SnapshotRequest = 6, SnapshotChunk = 7, StateBatch = 10, Damage = 11, Kill = 12, Create = 13, CustomFeature = 14, CustomFeatureReply = 15, InitialStateBatch = 16 } public class EnemySyncModule : Singleton<EnemySyncModule>, ISyncModule { private readonly Dictionary<ulong, string> _diedEntities = new Dictionary<ulong, string>(); private readonly Dictionary<ulong, ulong> _entityOwners = new Dictionary<ulong, ulong>(); private readonly Dictionary<ulong, Coroutine> _snapshotSyncRoutines = new Dictionary<ulong, Coroutine>(); private const int ChunkItemsPerFrame = 20; private readonly Dictionary<ulong, HashSet<ulong>> _entitySubscribers = new Dictionary<ulong, HashSet<ulong>>(); public readonly Dictionary<ulong, NetworkedGameEntity> enemies = new Dictionary<ulong, NetworkedGameEntity>(); private readonly Dictionary<int, NetworkedGameEntity> _byInstanceId = new Dictionary<int, NetworkedGameEntity>(); private readonly Dictionary<ulong, List<ulong>> _pendingSubscriptions = new Dictionary<ulong, List<ulong>>(); private float _syncInterval = 0.2f; private int _maxScanPerFrame = 50; private int _maxSyncPerFrame = 20; private float _timer; private bool _isScanning; private int _scanIndex; private bool _isSweeping; private int _groupIndex; private int _entityIndexWithinGroup; private readonly List<NetworkedGameEntity> _batchBuffer; private readonly List<ulong> _localKeysCache = new List<ulong>(); private readonly List<NetworkedGameEntity> _pendingAbandonList = new List<NetworkedGameEntity>(); private readonly CollectionGroupingManager<ulong, NetworkedGameEntity> _groupManager = new CollectionGroupingManager<ulong, NetworkedGameEntity>(); private readonly List<GroupKey<ulong>> _activeGroupKeys = new List<GroupKey<ulong>>(); private readonly Dictionary<NetworkedGameEntity, bool> _pendingEntityChanges = new Dictionary<NetworkedGameEntity, bool>(); public string ModuleName => "EnemySync"; public bool IsEnabled { get; set; } public bool ApplyingRemoteState { get; private set; } public void OnResetMap() { ResetState(); } public void OnLeave() { _diedEntities.Clear(); if ((Object)(object)MonoSingleton<WorldSyncManager>.Instance != (Object)null) { foreach (Coroutine value in _snapshotSyncRoutines.Values) { if (value != null) { ((MonoBehaviour)MonoSingleton<WorldSyncManager>.Instance).StopCoroutine(value); } } } _snapshotSyncRoutines.Clear(); ResetState(); } public void OnEnd() { OnLeave(); } private void ResetSweepState() { _timer = 0f; _isScanning = false; _scanIndex = 0; _isSweeping = false; _groupIndex = 0; _entityIndexWithinGroup = 0; _batchBuffer.Clear(); _localKeysCache.Clear(); _pendingAbandonList.Clear(); _groupManager.Clear(); _activeGroupKeys.Clear(); } private EnemySyncModule() { IsEnabled = MPConfig.EnemySync; _syncInterval = Mathf.Max(0.016f, 1f / ((MPConfig.EnemySendFrequency > 0) ? ((float)MPConfig.EnemySendFrequency) : 5f)); _maxSyncPerFrame = MPConfig.MaxEnemySendCount; _batchBuffer = new List<NetworkedGameEntity>(_maxSyncPerFrame); MPEventBusNet.OnLobbyMemberLeave += HandleOwnerLeave; } public void ResetState() { ResetSweepState(); enemies.Clear(); _entitySubscribers.Clear(); _byInstanceId.Clear(); ApplyingRemoteState = false; BroadcastOwnerAbandon(Array.Empty<ulong>(), abandonAll: true); } public void OnEntityEnabled(GameEntity entity) { if (!((Object)(object)entity == (Object)null) && MPCore.IsReady && IsEnabled && IsSyncableEnemy(entity)) { ((Object)((Component)entity).gameObject).GetInstanceID(); NetworkedGameEntity networkedGameEntity = EnsureIdentity(entity); if ((Object)(object)networkedGameEntity != (Object)null) { TogglePendingEntityChange(networkedGameEntity, isEnable: true); } } } public void OnEntityDisabled(GameEntity entity) { if (!((Object)(object)entity == (Object)null) && MPCore.IsReady && IsEnabled) { int instanceID = ((Object)((Component)entity).gameObject).GetInstanceID(); if (_byInstanceId.TryGetValue(instanceID, out NetworkedGameEntity value)) { RemoveEnemyRecord(value); TogglePendingEntityChange(value, isEnable: false); } } } public void OnEntityKill(GameEntity entity, string type) { if (!((Object)(object)entity == (Object)null)) { NetworkedGameEntity networkedGameEntity = default(NetworkedGameEntity); if (((Component)entity).TryGetComponent<NetworkedGameEntity>(ref networkedGameEntity) && !_diedEntities.ContainsKey(networkedGameEntity.networkId) && networkedGameEntity.IsOwnedByMe) { _diedEntities[networkedGameEntity.networkId] = type; BroadcastKill(networkedGameEntity, type); } int instanceID = ((Object)((Component)entity).gameObject).GetInstanceID(); if (_byInstanceId.TryGetValue(instanceID, out NetworkedGameEntity value)) { RemoveEnemyRecord(value); AbandonOwnerOrUnsubscribe(value); } } } private void TogglePendingEntityChange(NetworkedGameEntity identity, bool isEnable) { if ((Object)(object)identity == (Object)null || identity.networkId == 0L) { return; } if (_pendingEntityChanges.TryGetValue(identity, out var value)) { if (value != isEnable) { _pendingEntityChanges.Remove(identity); } } else { _pendingEntityChanges.Add(identity, isEnable); } } [MPPacketHandler(PacketType.EnemySync)] public static void HandleEnemyState(ulong senderId, DataReader reader) { EnemySyncAction enemySyncAction = (EnemySyncAction)reader.GetByte(); try { switch (enemySyncAction) { case EnemySyncAction.OwnerRequest: MPMain.LogDebug("HandleOwnerRequest", "HandleEnemyState", 470, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleOwnerRequest(senderId, reader); break; case EnemySyncAction.OwnerResponse: MPMain.LogDebug("HandleOwnerResponse", "HandleEnemyState", 474, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleOwnerResponse(reader); break; case EnemySyncAction.OwnerAbandon: MPMain.LogDebug("HandleOwnerAbandon", "HandleEnemyState", 478, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleOwnerAbandon(senderId, reader); break; case EnemySyncAction.SubscriptionRequest: MPMain.LogDebug("HandleSubscriptionRequest", "HandleEnemyState", 482, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleSubscriptionRequest(senderId, reader); break; case EnemySyncAction.UnsubscriptionRequest: MPMain.LogDebug("HandleUnsubscriptionRequest", "HandleEnemyState", 486, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleUnsubscriptionRequest(senderId, reader); break; case EnemySyncAction.StateBatch: Singleton<EnemySyncModule>.Instance.HandleState(senderId, reader); break; case EnemySyncAction.Damage: MPMain.LogDebug("HandleDamage", "HandleEnemyState", 493, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleDamage(senderId, reader); break; case EnemySyncAction.Kill: MPMain.LogDebug("HandleKill", "HandleEnemyState", 497, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleKill(reader); break; case EnemySyncAction.SnapshotRequest: MPMain.LogDebug("HandleSnapshotRequest", "HandleEnemyState", 501, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleSnapshotRequest(senderId); break; case EnemySyncAction.SnapshotChunk: MPMain.LogDebug("HandleSnapshotChunk", "HandleEnemyState", 505, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleSnapshotChunk(reader); break; case EnemySyncAction.CustomFeature: MPMain.LogDebug("HandleCustomFeature", "HandleEnemyState", 509, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleCustomFeature(senderId, reader); break; case EnemySyncAction.CustomFeatureReply: MPMain.LogDebug("HandleCustomFeatureReply", "HandleEnemyState", 513, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleCustomFeatureReply(senderId, reader); break; case EnemySyncAction.InitialStateBatch: MPMain.LogDebug("HandleInitialStateBatch", "HandleEnemyState", 517, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); Singleton<EnemySyncModule>.Instance.HandleInitialStateBatch(senderId, reader); break; default: MPMain.LogWarning($"[MP EnemySync] Unknown action: {enemySyncAction}"); break; } } catch (Exception ex) { MPMain.LogError($"[MP EnemySync] Failed to apply {enemySyncAction}: {ex.Message}", "HandleEnemyState", 525, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); } } public void OnReadyUpdate(float deltaTime) { FlushEntityChanges(); } public void OnSyncUpdate(float deltaTime) { if (!MPCore.CanSync || !IsEnabled) { ResetSweepState(); return; } if (!_isScanning && !_isSweeping) { _timer += deltaTime; if (_timer >= _syncInterval) { _timer = Mathf.Max(0f, _timer - _syncInterval); StartNewScanCycle(); } } if (_isScanning) { StepScan(); } FlushAbandonBuffer(); if (_isSweeping) { FlushNextBatch(); } } private void StartNewScanCycle() { _scanIndex = 0; _localKeysCache.Clear(); _groupManager.Clear(); _localKeysCache.AddRange(from kvp in _entitySubscribers where kvp.Value != null select kvp.Key); if (_localKeysCache.Count > 0) { _isScanning = true; } } private void StepScan() { int num = 0; while (_scanIndex < _localKeysCache.Count && num < _maxScanPerFrame) { ulong key = _localKeysCache[_scanIndex]; _scanIndex++; num++; if (enemies.TryGetValue(key, out NetworkedGameEntity value)) { HashSet<ulong> value2; if ((Object)(object)value == (Object)null) { enemies.Remove(key); } else if (value.IsRemoved()) { RemoveEnemyRecord(value); _pendingAbandonList.Add(value); } else if (value.HasMeaningfulChange && _entitySubscribers.TryGetValue(value.networkId, out value2)) { _groupManager.Record(value, value2); } } } if (_scanIndex < _localKeysCache.Count) { return; } _isScanning = false; _localKeysCache.Clear(); _activeGroupKeys.Clear(); foreach (KeyValuePair<GroupKey<ulong>, List<NetworkedGameEntity>> item in _groupManager) { if (item.Value != null && item.Value.Count > 0) { _activeGroupKeys.Add(item.Key); } } if (_activeGroupKeys.Count > 0) { _isSweeping = true; _groupIndex = 0; _entityIndexWithinGroup = 0; } } private void FlushAbandonBuffer() { if (_pendingAbandonList.Count > 0) { MPMain.LogError("FlushAbandonBuffer", "FlushAbandonBuffer", 633, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); AbandonOwnerOrUnsubscribe(_pendingAbandonList); } _pendingAbandonList.Clear(); } private void FlushEntityChanges() { if (_pendingEntityChanges.Count == 0) { return; } List<NetworkedGameEntity> list = new List<NetworkedGameEntity>(); List<NetworkedGameEntity> list2 = new List<NetworkedGameEntity>(); foreach (var (networkedGameEntity2, flag2) in _pendingEntityChanges) { if (!((Object)(object)networkedGameEntity2 == (Object)null)) { if (flag2) { list.Add(networkedGameEntity2); } else { list2.Add(networkedGameEntity2); } } } _pendingEntityChanges.Clear(); if (list.Count > 0) { RequestOwnerOrSubscription(list); } if (list2.Count > 0) { AbandonOwnerOrUnsubscribe(list2); } } private void FlushNextBatch() { _batchBuffer.Clear(); int num = _maxSyncPerFrame; bool flag = false; while (_groupIndex < _activeGroupKeys.Count) { GroupKey<ulong> groupKey = _activeGroupKeys[_groupIndex]; if (!_groupManager.TryGetValue(groupKey, out List<NetworkedGameEntity> valueList) || valueList == null || valueList.Count == 0) { _groupIndex++; _entityIndexWithinGroup = 0; continue; } int num2 = valueList.Count - _entityIndexWithinGroup; if (num >= num2) { for (int i = _entityIndexWithinGroup; i < valueList.Count; i++) { NetworkedGameEntity networkedGameEntity = valueList[i]; if ((Object)(object)networkedGameEntity != (Object)null && (Object)(object)((Component)networkedGameEntity).gameObject != (Object)null && ((Component)networkedGameEntity).gameObject.activeInHierarchy) { _batchBuffer.Add(networkedGameEntity); } } if (_batchBuffer.Count > 0) { BroadcastStateBatch(groupKey, _batchBuffer); flag = true; } num -= num2; _groupIndex++; _entityIndexWithinGroup = 0; _batchBuffer.Clear(); continue; } if (flag) { break; } int num3 = _entityIndexWithinGroup + num; for (int j = _entityIndexWithinGroup; j < num3; j++) { NetworkedGameEntity networkedGameEntity2 = valueList[j]; if ((Object)(object)networkedGameEntity2 != (Object)null && (Object)(object)((Component)networkedGameEntity2).gameObject != (Object)null && ((Component)networkedGameEntity2).gameObject.activeInHierarchy) { _batchBuffer.Add(networkedGameEntity2); } } if (_batchBuffer.Count > 0) { BroadcastStateBatch(groupKey, _batchBuffer); } _entityIndexWithinGroup = num3; _batchBuffer.Clear(); break; } if (_groupIndex >= _activeGroupKeys.Count) { _isSweeping = false; _activeGroupKeys.Clear(); _groupManager.Clear(); _groupIndex = 0; _entityIndexWithinGroup = 0; } } private IEnumerator SendSnapshotRoutine(ulong clientId) { List<KeyValuePair<ulong, ulong>> ownerList = new List<KeyValuePair<ulong, ulong>>(_entityOwners); int ownerTotal = ownerList.Count; int ownerIndex = 0; while (ownerIndex < ownerTotal) { int num = Mathf.Min(20, ownerTotal - ownerIndex); DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, clientId, PacketType.EnemySync); writer.Put((byte)7); writer.Put((byte)0); writer.Put(num); for (int i = 0; i < num; i++) { KeyValuePair<ulong, ulong> keyValuePair = ownerList[ownerIndex + i]; writer.Put(keyValuePair.Key); writer.Put(keyValuePair.Value); } MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(clientId), writer, (SendType)8, 0); ownerIndex += num; yield return null; } List<KeyValuePair<ulong, string>> diedList = new List<KeyValuePair<ulong, string>>(_diedEntities); int diedTotal = diedList.Count; int diedIndex = 0; while (diedIndex < diedTotal) { int num2 = Mathf.Min(20, diedTotal - diedIndex); DataWriter writer2 = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, clientId, PacketType.EnemySync); writer2.Put((byte)7); writer2.Put((byte)1); writer2.Put(num2); for (int j = 0; j < num2; j++) { KeyValuePair<ulong, string> keyValuePair2 = diedList[diedIndex + j]; writer2.Put(keyValuePair2.Key); writer2.Put(keyValuePair2.Value ?? string.Empty); } MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(clientId), writer2, (SendType)8, 0); diedIndex += num2; yield return null; } _snapshotSyncRoutines.Remove(clientId); } private NetworkedGameEntity EnsureIdentity(GameEntity entity) { Transform transform = ((Component)entity).transform; if ((Object)(object)transform == (Object)null) { return null; } int instanceID = ((Object)((Component)entity).gameObject).GetInstanceID(); if (_byInstanceId.TryGetValue(instanceID, out NetworkedGameEntity value) && (Object)(object)value != (Object)null) { return value; } NetworkedGameEntity networkedGameEntity = ((Component)transform).GetComponent<NetworkedGameEntity>() ?? ComponentHolderProtocol.AddComponent<NetworkedGameEntity>((Object)(object)transform); if (networkedGameEntity.networkId == 0L) { ulong num; for (num = BuildStableNetworkId(transform); enemies.ContainsKey(num); num++) { } networkedGameEntity.Initialize(num); MPMain.LogDebug($"hash: {num}", "EnsureIdentity", 804, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); } if (_diedEntities.TryGetValue(networkedGameEntity.networkId, out string value2)) { if (string.IsNullOrEmpty(value2)) { entity.Kill("diedSync"); } else { entity.Kill(value2); } entity.health = 0f; return networkedGameEntity; } if (_entityOwners.TryGetValue(networkedGameEntity.networkId, out var value3)) { networkedGameEntity.CurrentOwnerId = value3; } _byInstanceId[((Object)((Component)networkedGameEntity).gameObject).GetInstanceID()] = networkedGameEntity; enemies[networkedGameEntity.networkId] = networkedGameEntity; return networkedGameEntity; } private void RemoveEnemyRecord(NetworkedGameEntity identity) { if (!((Object)(object)identity == (Object)null)) { if (identity.networkId != 0L) { enemies.Remove(identity.networkId); } _byInstanceId.Remove(((Object)((Component)identity).gameObject).GetInstanceID()); } } private ulong BuildStableNetworkId(Transform transform) { string text = (MPGameModeManager.IsCampaignMode ? MPUtil.BuildNamePath(transform) : MPUtil.BuildFullPath(transform)); MPMain.LogDebug("NetworkId: " + text, "BuildStableNetworkId", 839, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); return MPUtil.Hash64(text.AsSpan()); } private bool SetEntityOwner(ulong networkId, ulong newOwnerId) { if (networkId == 0L || newOwnerId == 0L) { return false; } bool flag = newOwnerId == MPSteamworks.UserSteamId; _entityOwners[networkId] = newOwnerId; if (!enemies.TryGetValue(networkId, out NetworkedGameEntity value) || (Object)(object)value == (Object)null) { if (flag) { return false; } return true; } value.CurrentOwnerId = newOwnerId; if (flag) { if (!_entitySubscribers.TryGetValue(networkId, out HashSet<ulong> value2)) { value2 = new HashSet<ulong>(); _entitySubscribers[networkId] = value2; } if (_pendingSubscriptions.TryGetValue(networkId, out List<ulong> value3)) { LinqUtility.AddRange<ulong>((ICollection<ulong>)value2, (IEnumerable<ulong>)value3); _pendingSubscriptions.Remove(networkId); MPMain.LogTest($"[EnemySync] SetEntityOwner. Processed buffered subscriptions for entity {networkId}."); BroadcastInitialStateBatch(value3, new List<NetworkedGameEntity> { value }); } } else { _entitySubscribers.Remove(networkId); } return true; } public void ClearEntityOwner(IReadOnlyList<ulong> networkIds) { if (networkIds == null || networkIds.Count == 0) { return; } List<NetworkedGameEntity> list = ReusableCollectionPool.RentList<NetworkedGameEntity>(networkIds.Count); foreach (ulong networkId in networkIds) { _entityOwners.Remove(networkId); if (enemies.TryGetValue(networkId, out NetworkedGameEntity value) && (Object)(object)value != (Object)null) { value.CurrentOwnerId = 0uL; list.Add(value); } } if (list.Count > 0) { RequestOwnerOrSubscription(list); } ReusableCollectionPool.ReturnList(list); } public void AbandonOwnership(IReadOnlyList<NetworkedGameEntity> identities) { if (identities == null) { return; } List<ulong> list = ReusableCollectionPool.RentList<ulong>(); foreach (NetworkedGameEntity identity in identities) { if ((Object)(object)identity != (Object)null && identity.IsOwnedByMe) { identity.CurrentOwnerId = 0uL; list.Add(identity.networkId); _entityOwners.Remove(identity.networkId); _entitySubscribers.Remove(identity.networkId); _pendingSubscriptions.Remove(identity.networkId); } } if (list.Count > 0) { BroadcastOwnerAbandon(list); } ReusableCollectionPool.ReturnList(list); } public void RequestOwnerOrSubscription(NetworkedGameEntity identity) { if (IsEnabled && !((Object)(object)identity == (Object)null) && identity.networkId != 0L && !identity.IsOwnedByMe) { if (identity.HasOwner && MPSteamworks.ContainsMemberID(identity.CurrentOwnerId)) { SendSubscriptionRequest(new ulong[1] { identity.networkId }, identity.CurrentOwnerId); } else if (MPSteamworks.IsHost) { SetEntityOwner(identity.networkId, MPSteamworks.UserSteamId); BroadcastOwnerResponse(new ulong[1] { identity.networkId }, MPSteamworks.UserSteamId); } else { identity.CurrentOwnerId = 0uL; SendOwnerRequest(new ulong[1] { identity.networkId }); } } } public void RequestOwnerOrSubscription(IReadOnlyList<NetworkedGameEntity> identities) { if (!IsEnabled || identities == null || identities.Count == 0) { return; } List<ulong> list = ReusableCollectionPool.RentList<ulong>(); List<ulong> list2 = ReusableCollectionPool.RentList<ulong>(); Dictionary<ulong, List<ulong>> dictionary = ReusableCollectionPool.RentDictionary<ulong, List<ulong>>(); foreach (NetworkedGameEntity identity in identities) { if ((Object)(object)identity == (Object)null || identity.networkId == 0L || identity.IsOwnedByMe) { continue; } if (identity.HasOwner && MPSteamworks.ContainsMemberID(identity.CurrentOwnerId)) { if (!dictionary.TryGetValue(identity.CurrentOwnerId, out var value)) { value = (dictionary[identity.CurrentOwnerId] = ReusableCollectionPool.RentList<ulong>()); } value.Add(identity.networkId); } else if (MPSteamworks.IsHost) { if (SetEntityOwner(identity.networkId, MPSteamworks.UserSteamId)) { list2.Add(identity.networkId); } } else { identity.CurrentOwnerId = 0uL; list.Add(identity.networkId); } } if (list.Count > 0) { SendOwnerRequest(list); } foreach (KeyValuePair<ulong, List<ulong>> item in dictionary) { SendSubscriptionRequest(item.Value, item.Key); } if (list2.Count > 0) { BroadcastOwnerResponse(list2, MPSteamworks.UserSteamId); } foreach (KeyValuePair<ulong, List<ulong>> item2 in dictionary) { ReusableCollectionPool.ReturnList(item2.Value); } ReusableCollectionPool.ReturnDictionary(dictionary); ReusableCollectionPool.ReturnList(list2); ReusableCollectionPool.ReturnList(list); } public void AbandonOwnerOrUnsubscribe(NetworkedGameEntity identity) { if (!((Object)(object)identity == (Object)null) && identity.networkId != 0L) { if (identity.IsOwnedByMe) { AbandonOwnership(new NetworkedGameEntity[1] { identity }); } else if (identity.HasOwner) { SendUnsubscriptionRequest(new ulong[1] { identity.networkId }, identity.CurrentOwnerId); } } } public void AbandonOwnerOrUnsubscribe(IReadOnlyList<NetworkedGameEntity> identities) { if (identities == null || identities.Count == 0) { return; } List<NetworkedGameEntity> list = ReusableCollectionPool.RentList<NetworkedGameEntity>(); Dictionary<ulong, List<ulong>> dictionary = ReusableCollectionPool.RentDictionary<ulong, List<ulong>>(); foreach (NetworkedGameEntity identity in identities) { if ((Object)(object)identity == (Object)null || identity.networkId == 0L) { continue; } if (identity.IsOwnedByMe) { list.Add(identity); } else if (identity.HasOwner) { if (!dictionary.TryGetValue(identity.CurrentOwnerId, out var value)) { value = (dictionary[identity.CurrentOwnerId] = ReusableCollectionPool.RentList<ulong>()); } value.Add(identity.networkId); } } if (list.Count > 0) { AbandonOwnership(list); } foreach (KeyValuePair<ulong, List<ulong>> item in dictionary) { SendUnsubscriptionRequest(item.Value, item.Key); } foreach (KeyValuePair<ulong, List<ulong>> item2 in dictionary) { ReusableCollectionPool.ReturnList(item2.Value); } ReusableCollectionPool.ReturnDictionary(dictionary); ReusableCollectionPool.ReturnList(list); } private void AddSubscriber(IReadOnlyList<ulong> networkIds, ulong subscriberId) { List<NetworkedGameEntity> list = ReusableCollectionPool.RentList<NetworkedGameEntity>(); foreach (ulong networkId in networkIds) { if (!_entitySubscribers.TryGetValue(networkId, out HashSet<ulong> value)) { value = new HashSet<ulong>(); _entitySubscribers[networkId] = value; } if (value.Add(subscriberId) && enemies.TryGetValue(networkId, out NetworkedGameEntity value2) && (Object)(object)value2 != (Object)null) { list.Add(value2); } } BroadcastInitialStateBatch(new List<ulong> { subscriberId }, list); ReusableCollectionPool.ReturnList(list); } private void HandleOwnerLeave(Friend friend) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) if (!MPCore.CanSync || !IsEnabled) { return; } List<ulong> networkIds = (from pair in _entityOwners where pair.Value == SteamId.op_Implicit(friend.Id) select pair.Key).ToList(); ClearEntityOwner(networkIds); List<ulong> list = new List<ulong>(); foreach (var (item, hashSet2) in _entitySubscribers) { hashSet2.Remove(SteamId.op_Implicit(friend.Id)); if (hashSet2.Count == 0) { list.Add(item); } } foreach (ulong item2 in list) { _entitySubscribers.Remove(item2); } foreach (List<ulong> value in _pendingSubscriptions.Values) { value.RemoveAll((ulong id) => id == SteamId.op_Implicit(friend.Id)); } } public void SendEnemyDamage(GameEntity entity, DamageInfo info) { //IL_00c7: 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_00f2: Unknown result type (might be due to invalid IL or missing references) if (MPCore.CanSync && IsEnabled && !ApplyingRemoteState && info != null) { int instanceID = ((Object)((Component)entity).gameObject).GetInstanceID(); if (_byInstanceId.TryGetValue(instanceID, out NetworkedGameEntity value) && !((Object)(object)value == (Object)null) && value.networkId != 0L && value.HasOwner && !value.IsOwnedByMe) { bool flag = (Object)(object)info.sourceEntity != (Object)null && info.sourceEntity is ENT_Player; DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.EnemySync); writer.Put((byte)11); writer.Put(value.networkId); writer.Put(info.amount); writer.Put(info.type); writer.Put((IReadOnlyList<string>)info.tags); writer.Put(info.position); writer.Put(info.force); writer.Put(flag); MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(value.CurrentOwnerId), writer, (SendType)8, 0); } } } private void BroadcastStateBatch(GroupKey<ulong> subGroup, List<NetworkedGameEntity> batch) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if (!IsEnabled || batch == null || batch.Count == 0) { return; } DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.EnemySync); writer.Put((byte)10); writer.Put((byte)batch.Count); for (int i = 0; i < batch.Count; i++) { NetworkedGameEntity networkedGameEntity = batch[i]; writer.Put(networkedGameEntity.networkId); int position = writer.Position; writer.Put((ushort)0); int position2 = writer.Position; networkedGameEntity.WriteSyncState(writer); ushort num = (ushort)(writer.Position - position2); if (num > ushort.MaxValue) { MPMain.LogError($"InitialState payload too large: {networkedGameEntity.networkId}, {num}", "BroadcastStateBatch", 1125, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); return; } writer.PutUShortAt(position, num); } ReadOnlySpan<ulong> span = subGroup.Span; for (int j = 0; j < span.Length; j++) { ulong num2 = span[j]; MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(num2), writer, (SendType)1, 0); } } private void BroadcastKill(NetworkedGameEntity identity, string type) { if (MPCore.CanSync && IsEnabled) { DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.EnemySync); writer.Put((byte)12); writer.Put(identity.networkId); writer.Put(type); MonoSingleton<MPSteamworks>.Instance.Broadcast(writer, (SendType)8, 0); } } public void SendSnapshotRequest() { if (!MPSteamworks.IsHost && IsEnabled) { DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, MonoSingleton<MPSteamworks>.Instance.HostSteamId, PacketType.EnemySync); writer.Put((byte)6); MonoSingleton<MPSteamworks>.Instance.SendToHost(writer, (SendType)8, 0); } } public void SendOwnerRequest(IReadOnlyList<ulong> networkIds) { if (!MPCore.CanSync || !IsEnabled || MPSteamworks.IsHost) { return; } List<ulong> list = networkIds.Where((ulong id) => id != 0).Distinct().ToList(); if (list.Count == 0) { return; } DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, MonoSingleton<MPSteamworks>.Instance.HostSteamId, PacketType.EnemySync); writer.Put((byte)1); writer.Put(list.Count); foreach (ulong item in list) { writer.Put(item); } MonoSingleton<MPSteamworks>.Instance.SendToHost(writer, (SendType)8, 0); } public void BroadcastOwnerResponse(IReadOnlyList<ulong> networkIds, ulong ownerId) { if (!MPCore.CanSync || !IsEnabled || !MPSteamworks.IsHost || ownerId == 0L || networkIds == null) { return; } List<ulong> list = networkIds.Where((ulong id) => id != 0).Distinct().ToList(); if (list.Count == 0) { return; } DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.EnemySync); writer.Put((byte)2); writer.Put(list.Count); foreach (ulong item in list) { writer.Put(item); writer.Put(ownerId); } MonoSingleton<MPSteamworks>.Instance.Broadcast(writer, (SendType)8, 0); } public void SendOwnerResponse(IReadOnlyList<ulong> networkIds, ulong ownerId, ulong targetId) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (!MPCore.CanSync || !IsEnabled || !MPSteamworks.IsHost || ownerId == 0L || targetId == 0L || networkIds == null) { return; } List<ulong> list = networkIds.Where((ulong id) => id != 0).Distinct().ToList(); if (list.Count == 0) { return; } DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, targetId, PacketType.EnemySync); writer.Put((byte)2); writer.Put(list.Count); foreach (ulong item in list) { writer.Put(item); writer.Put(ownerId); } MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(targetId), writer, (SendType)8, 0); } public void BroadcastOwnerAbandon(IReadOnlyList<ulong> networkIds, bool abandonAll = false) { if (!MPCore.CanSync || !IsEnabled) { return; } List<ulong> list = (networkIds ?? Array.Empty<ulong>()).Where((ulong id) => id != 0).Distinct().ToList(); DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.EnemySync); writer.Put((byte)3); writer.Put(abandonAll); writer.Put(list.Count); foreach (ulong item in list) { writer.Put(item); } MonoSingleton<MPSteamworks>.Instance.Broadcast(writer, (SendType)8, 0); } public void SendSubscriptionRequest(IReadOnlyList<ulong> networkIds, ulong ownerId) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) if (ownerId == 0L || networkIds == null) { return; } List<ulong> list = networkIds.Where((ulong id) => id != 0).Distinct().ToList(); if (list.Count == 0) { return; } DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, ownerId, PacketType.EnemySync); writer.Put((byte)4); writer.Put(list.Count); foreach (ulong item in list) { writer.Put(item); } MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(ownerId), writer, (SendType)8, 0); } public void SendUnsubscriptionRequest(IReadOnlyList<ulong> networkIds, ulong ownerId) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) if (ownerId == 0L || networkIds == null) { return; } List<ulong> list = networkIds.Where((ulong id) => id != 0).Distinct().ToList(); if (list.Count == 0) { return; } DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, ownerId, PacketType.EnemySync); writer.Put((byte)5); writer.Put(list.Count); foreach (ulong item in list) { writer.Put(item); } MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(ownerId), writer, (SendType)8, 0); } public void SendCustomFeature(ulong targetId, ulong networkId, byte customIndex, Action<DataWriter> action, bool needReply = false) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (networkId != 0L && action != null) { DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.EnemySync); writer.Put((byte)14); writer.Put(networkId); writer.Put(customIndex); writer.Put(needReply); action(writer); MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(targetId), writer, (SendType)8, 0); } } public void BroadcastCustomFeature(ulong networkId, byte customIndex, Action<DataWriter> action, bool needReply = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (networkId == 0L || action == null || !_entitySubscribers.TryGetValue(networkId, out HashSet<ulong> value) || value.Count == 0) { return; } DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.EnemySync); writer.Put((byte)14); writer.Put(networkId); writer.Put(customIndex); writer.Put(needReply); action(writer); foreach (ulong item in value) { MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(item), writer, (SendType)8, 0); } } private void SendCustomFeatureReply(ulong targetId, ulong networkId, byte customIndex) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, targetId, PacketType.EnemySync); writer.Put((byte)15); writer.Put(networkId); writer.Put(customIndex); MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(targetId), writer, (SendType)8, 0); } private void BroadcastInitialStateBatch(List<ulong> subGroup, List<NetworkedGameEntity> batch) { //IL_0101: Unknown result type (might be due to invalid IL or missing references) if (!IsEnabled || subGroup == null || subGroup.Count == 0 || batch == null || batch.Count == 0) { return; } DataWriter writer = MPWriterPool.GetWriter(MPSteamworks.UserSteamId, 0uL, PacketType.EnemySync); writer.Put((byte)16); writer.Put((byte)batch.Count); for (int i = 0; i < batch.Count; i++) { NetworkedGameEntity networkedGameEntity = batch[i]; if (!((Object)(object)networkedGameEntity == (Object)null)) { writer.Put(networkedGameEntity.networkId); int position = writer.Position; writer.Put((ushort)0); int position2 = writer.Position; networkedGameEntity.WriteInitialSync(writer); int num = writer.Position - position2; if (num > 65535) { MPMain.LogError($"InitialState payload too large: {networkedGameEntity.networkId}, {num}", "BroadcastInitialStateBatch", 1337, "D:\\DevelopmentPortfolio\\c#\\WKMultiPlayerMod\\src\\Core\\World\\EnemySyncModule.cs"); return; } writer.PutUShortAt(position, (ushort)num); } } foreach (ulong item in subGroup) { MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(item), writer, (SendType)9, 0); } } private void HandleDamage(ulong senderId, DataReader reader) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00ad: 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) ulong uLong = reader.GetULong(); float num = reader.GetFloat(); string text = reader.GetString(); List<string> stringList = reader.GetStringList(); Vector3 vector = reader.GetVector3(); Vector3 vector2 = reader.GetVector3(); bool flag = reader.GetBool(); if (!enemies.TryGetValue(uLong, out NetworkedGameEntity value) || (Object)(object)value == (Object)null) { return; } GameEntity component = ((Component)value).GetComponent<GameEntity>(); if ((Object)(object)component == (Object)null) { return; } RPContainer value2; GameEntity val = (GameEntity)(object)((flag && Singleton<RPManager>.Instance.Players.TryGetValue(senderId, out value2) && (Object)(object)value2.remotePlayer != (Object)null) ? value2.remotePlayer : null); DamageInfo val2 = DamageInfo.CreateDamageInfo(num, text, stringList, val); val2.position = vector; val2.force = vector2; ApplyingRemoteState = true; try { component.Damage(val2); } finally { ApplyingRemoteState = false; } } private void HandleState(ulong senderId, DataReader reader) { byte b = reader.GetByte(); List<ulong> list = ReusableCollectionPool.RentList<ulong>(); ApplyingRemoteState = true; try { for (int i = 0; i < b; i++) { ulong uLong = reader.GetULong(); ushort uShort = reader.GetUShort(); if (enemies.TryGetValue(uLong, out NetworkedGameEntity value) && (Object)(object)value != (Object)null) { int position = reader.Position; value.ReadSyncState(reader); if (reader.Position - position != uShort) { reader.Position = position + uShort; } } else { reader.Skip((int)uShort); list.Add(uLong); } } } finally { ApplyingRemoteState = false; SendUnsubscriptionRequest(list, senderId); ReusableCollectionPool.ReturnList(list); } } private void HandleKill(DataReader reader) { if (MPSteamworks.IsHost) { return; } ulong uLong = reader.GetULong(); string text = reader.GetString(); if (string.IsNullOrEmpty(text)) { text = "diedSync"; } if (enemies.TryGetValue(uLong, out NetworkedGameEntity value) && !((Object)(object)value == (Object)null)) { GameEntity component = ((Component)value).GetComponent<GameEntity>(); if (component != null) { component.Kill(text); } } } public void HandleSnapshotRequest(ulong senderId) { if (MPCore.CanSync && IsEnabled && MPSteamworks.IsHost && senderId != 0L && senderId != MPSteamworks.UserSteamId) { if (_snapshotSyncRoutines.TryGetValue(senderId, out Coroutine value) && value != null) { ((MonoBehaviour)MonoSingleton<WorldSyncManager>.Instance).StopCoroutine(value); } _snapshotSyncRoutines[senderId] = ((MonoBehaviour)MonoSingleton<WorldSyncManager>.Instance).StartCoroutine(SendSnapshotRoutine(senderId)); } } private void HandleSnapshotChunk(DataReader reader) { if (MPSteamworks.IsHost) { return; } switch (reader.GetByte()) { case 0: { int num2 = reader.GetInt(); for (int j = 0; j < num2; j++) { ulong uLong2 = reader.GetULong(); ulong uLong3 = reader.GetULong(); _entityOwners[uLong2] = uLong3; if (enemies.TryGetValue(uLong2, out NetworkedGameEntity value2) && (Object)(object)value2 != (Object)null) { value2.CurrentOwnerId = uLong3; RequestOwnerOrSubscription(value2); } } break; } case 1: { int num = reader.GetInt(); GameEntity val = default(GameEntity); for (int i = 0; i < num; i++) { ulong uLong = reader.GetULong(); string text = reader.GetString(); _diedEntities[uLong] = text; if (enemies.TryGetValue(uLong, out NetworkedGameEntity value) && (Object)(object)value != (Object)null && ((Component)value).TryGetComponent<GameEntity>(ref val)) { if (string.IsNullOrEmpty(text)) { val.Kill("diedSync"); } else { val.Kill(text); } } } break; } } } private void HandleOwnerRequest(ulong senderId, DataReader reader) { if (!MPCore.CanSync || !IsEnabled || !MPSteamworks.IsHost) { return; } int num = reader.GetInt(); if (num <= 0 || num > 4096) { return; } List<ulong> list = ReusableCollectionPool.RentList<ulong>(); Dictionary<ulong, List<ulong>> dictionary = ReusableCollectionPool.RentDictionary<ulong, List<ulong>>(); ulong num2 = 0uL; ulong value = 0uL; for (int i = 0; i < num; i++) { num2 = reader.GetULong(); if (num2 == 0L) { continue; } if (!_entityOwners.TryGetValue(num2, out value) || (value != MPSteamworks.UserSteamId && !MPSteamworks.ContainsMemberID(value))) { if (SetEntityOwner(num2, senderId)) { list.Add(num2); } else if (_entityOwners.TryGetValue(num2, out value)) { if (!dictionary.TryGetValue(value, out var value2)) { value2 = (dictionary[value] = ReusableCollectionPool.RentList<ulong>()); } value2.Add(num2); } } else { if (!dictionary.TryGetValue(value, out var value3)) { value3 = (dictionary[value] = ReusableCollectionPool.RentList<ulong>()); } value3.Add(num2); } } if (list.Count > 0) { BroadcastOwnerResponse(list, senderId); } foreach (KeyValuePair<ulong, List<ulong>> item in dictionary) { SendOwnerResponse(item.Value, item.Key, senderId); } foreach (KeyValuePair<ulong, List<ulong>> item2 in dictionary) { ReusableCollectionPool.ReturnList(item2.Value); } ReusableCollectionPool.ReturnDictionary(dictionary); ReusableCollectionPool.ReturnList(list); } private void HandleOwnerResponse(DataReader reader) { if (!MPCore.CanSync || !IsEnabled) { return; } int num = reader.GetInt(); if (num <= 0 || num > 4096) { return; } List<ulong> list = ReusableCollectionPool.RentList<ulong>(); Dictionary<ulong, List<ulong>> dictionary = ReusableCollectionPool.RentDictionary<ulong, List<ulong>>(); for (int i = 0; i < num; i++) { ulong uLong = reader.GetULong(); ulong uLong2 = reader.GetULong(); if (uLong == 0L || uLong2 == 0L) { continue; } if (!SetEntityOwner(uLong, uLong2) && uLong != 0L) { MPMain.LogWarning($"[MP EnemySync] Failed to apply owner {uLong2} for entity {uLong}."); list.Add(uLong); } else if (uLong2 != MPSteamworks.UserSteamId && enemies.ContainsKey(uLong)) { if (!dictionary.TryGetValue(uLong2, out var value)) { value = (dictionary[uLong2] = ReusableCollectionPool.RentList<ulong>()); } value.Add(uLong); } } BroadcastOwnerAbandon(list); foreach (KeyValuePair<ulong, List<ulong>> item in dictionary) { SendSubscriptionRequest(item.Value, item.Key); } foreach (KeyValuePair<ulong, List<ulong>> item2 in dictionary) { ReusableCollectionPool.ReturnList(item2.Value); } ReusableCollectionPool.ReturnDictionary(dictionary); ReusableCollectionPool.ReturnList(list); } private void HandleOwnerAbandon(ulong senderId, DataReader reader) { if (!MPCore.CanSync || !IsEnabled) { return; } bool flag = reader.GetBool(); int num = reader.GetInt(); if (num < 0 || num > 4096) { return; } List<ulong> list = ReusableCollectionPool.RentList<ulong>(); for (int i = 0; i < num; i++) { ulong uLong = reader.GetULong(); if (uLong != 0L) { list.Add(uLong); } } if (flag) { foreach (var (item, num4) in _entityOwners) { if (num4 == senderId) { list.Add(item); } } } else { for (int num5 = list.Count - 1; num5 >= 0; num5--) { ulong key = list[num5]; if (!_entityOwners.TryGetValue(key, out var value) || value != senderId) { list.RemoveAt(num5); } } } ClearEntityOwner(list); ReusableCollectionPool.ReturnList(list); } private void HandleSubscriptionRequest(ulong senderId, DataReader reader) { if (!MPCore.CanSync || !IsEnabled || senderId == 0L) { return; } int num = reader.GetInt(); if (num <= 0 || num > 4096) { return; } List<ulong> list = ReusableCollectionPool.RentList<ulong>(); for (int i = 0; i < num; i++) { ulong uLong = reader.GetULong(); if (uLong == 0L) { continue; } List<ulong> value2; if (_entityOwners.TryGetValue(uLong, out var value)) { if (value == MPSteamworks.UserSteamId) { list.Add(uLong); } } else if (!_pendingSubscriptions.TryGetValue(uLong, out value2)) { value2 = (_pendingSubscriptions[uLong] = new List<ulong>()); if (!value2.Contains(senderId)) { value2.Add(senderId); } } } AddSubscriber(list, senderId); } private void HandleUnsubscriptionRequest(ulong senderId, DataReader reader) { if (!MPCore.CanSync || !IsEnabled || senderId == 0L) { return; } int num = reader.GetInt(); if (num <= 0 || num > 4096) { return; } for (int i = 0; i < num; i++) { ulong uLong = reader.GetULong(); if (_entitySubscribers.TryGetValue(uLong, out HashSet<ulong> value)) { value.Remove(senderId); } if (_pendingSubscriptions.TryGetValue(uLong, out List<ulong> value2)) { value2.Remove(senderId); if (value2.Count == 0) { _pendingSubscriptions.Remove(uLong); } } } } private void HandleCustomFeature(ulong senderId, DataReader reader) { ulong uLong = reader.GetULong(); byte b = reader.GetByte(); bool flag = reader.GetBool(); if (!enemies.TryGetValue(uLong, out NetworkedGameEntity value) || (Object)(object)value == (Object)null || !value.TryGetCustomFeature(b, out ICustomSyncFeature feature)) { if (flag) { SendCustomFeatureReply(senderId, uLong, b); } return; } ApplyingRemoteState = true; try { feature.HandleCustomMessage(senderId, reader, flag); } finally { ApplyingRemoteState = false; } } private void HandleCustomFeatureReply(ulong senderId, DataReader reader) { ulong uLong = reader.GetULong(); byte index = reader.GetByte(); if (enemies.TryGetValue(uLong, out NetworkedGameEntity value) && !((Object)(object)value == (Object)null) && value.TryGetCustomFeature(index, out ICustomSyncFeature feature)) { feature.HandleCustomReply(senderId); } } private void HandleInitialStateBatch(ulong senderId, DataReader reader) { byte b = reader.GetByte(); List<ulong> list = ReusableCollectionPool.RentList<ulong>(); ApplyingRemoteState = true; try { for (int i = 0; i < b; i++) { ulong uLong = reader.GetULong(); ushort uShort = reader.GetUShort(); if (enemies.TryGetValue(uLong, out NetworkedGameEntity value) && (Object)(object)value != (Object)null) { int position = reader.Position; value.ReadInitialSync(reader); if (reader.Position - position != uShort) { reader.Position = position + uShort; } } else { reader.Skip((int)uShort); list.Add(uLong); } } } finally { ApplyingRemoteState = false; if (list.Count > 0) { SendUnsubscriptionRequest(list, senderId); } ReusableCollectionPool.ReturnList(list); } } private bool IsSyncableEnemy(GameEntity entity) { if ((Object)(object)entity == (Object)null || (Object)(object)((Component)entity).gameObject == (Object)null) { return false; } if ((entity is ENT_Player || entity is RemotePlayer || entity is DEN_DeathFloor || entity is DEN_Roach || entity is CL_Prop) ? true : false) { return false; } if ((Object)(object)((Component)entity).GetComponent<NetworkedGameEntity>() != (Object)null) { return true; } if ((Object)(object)((Component)entity).GetComponent<Item_Object>() != (Object)null) { return false; } if ((Object)(object)((Component)entity).GetComponent<RPContainerRef>() != (Object)null) { return false; } if (entity is Denizen || entity is AIGameEntity) { return true; } ObjectTagger component = ((Component)entity).GetComponent<ObjectTagger>(); if ((Object)(object)component != (Object)null && component.tags.Contains("Creature")) { return true; } string name = ((Object)entity).name; if (!name.StartsWith("Denizen_", StringComparison.OrdinalIgnoreCase)) { return name.StartsWith("DEN_", StringComparison.OrdinalIgnoreCase); } return true; } } public enum SceneItemSyncAction : byte { Create, Remove, RemoveChunk, RemoveChunkRequest, SceneToDropped } public enum DroppedItemSyncAction : byte { Create, PickupRequest, Remove, PickupReject, UpdateTransform, TransferRequest, TransferConfirm, TransferReject } public enum ItemType : byte { NoneItem, SceneItem, DroppedItem } public class SceneItemModule : Singleton<SceneItemModule>, ISyncModule { private const int TombstonesPerChunk = 20; private HashSet<ulong> _sceneTombstones = new HashSet<ulong>(); private Dictionary<ulong, Item_Ob
WKMultiPlayerMod.Shared.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Buffers; using System.Buffers.Binary; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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.Util; using WKMPModa.Shared.Component; using WKMPModa.Shared.Data; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("WKMultiPlayerMod.Shared")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+cd7e3ca4316705ad2066b11ded8d7a0c1b4cc77e")] [assembly: AssemblyProduct("WKMultiPlayerMod.Shared")] [assembly: AssemblyTitle("WKMultiPlayerMod.Shared")] [assembly: AssemblyVersion("1.0.0.0")] 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 WKMPMod.Util { public static class DictionaryExtensions { public static List<ulong> FindByKeySuffix(IEnumerable<ulong> dictionary, ulong suffix) { List<ulong> list = new List<ulong>(); if (dictionary == null) { return list; } ulong num = CalculateDivisor(suffix); foreach (ulong item in dictionary) { if (item % num == suffix) { list.Add(item); } } return list; } private static ulong CalculateDivisor(ulong suffix) { if (suffix == 0L) { return 10uL; } ulong num; for (num = 1uL; num <= suffix; num *= 10) { } return num; } public static Dictionary<K, byte> SetDifference<K>(Dictionary<K, byte> minuend, Dictionary<K, byte> subtrahend) { Dictionary<K, byte> dictionary = new Dictionary<K, byte>(); 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; private bool _useUnscaledTime; public bool UseUnscaledTime { get { return _useUnscaledTime; } set { if (_useUnscaledTime != value) { float num = CurrentTime - _lastTickTime; _useUnscaledTime = value; _lastTickTime = CurrentTime - num; } } } private float CurrentTime { get { if (!_useUnscaledTime) { return Time.time; } return Time.unscaledTime; } } public float Progress => Mathf.Clamp01((CurrentTime - _lastTickTime) / _interval); public float TimeRemaining => Mathf.Max(0f, _interval - (CurrentTime - _lastTickTime)); public bool IsTickReached => CurrentTime - _lastTickTime >= _interval; public TickTimer(float tick, bool useUnscaledTime = false) { _useUnscaledTime = useUnscaledTime; _interval = tick; _lastTickTime = CurrentTime - _interval; } public TickTimer(int hz, bool useUnscaledTime = false) { _useUnscaledTime = useUnscaledTime; _interval = 1f / (float)hz; _lastTickTime = CurrentTime - _interval; } public void SetInterval(float tick) { _interval = tick; } public void SetFrequency(float hz) { _interval = 1f / hz; } public void Reset() { _lastTickTime = CurrentTime; } public bool TryTick() { if (CurrentTime - _lastTickTime >= _interval) { _lastTickTime = CurrentTime; return true; } return false; } public void ForceTick() { _lastTickTime = CurrentTime; } } } 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_ENT_Hitbox : MonoBehaviour { public MK_RemotePlayer entity; public List<string> passTags; public List<DamageEffectData> damageEffects; } [Serializable] public class DamageEffectData { public string id; public List<string> requiredTags; public float damageMultiplier = 1f; public UnityEvent damageEvent; } public class MK_ObjectTagger : MonoBehaviour { public List<string> tags = new List<string>(); } public class MK_RemoteHand : MonoBehaviour { [Header("左右手")] public byte hand; [Header("距离设置")] [Tooltip("当当前位置与目标位置超过此距离时直接瞬移")] public float teleportThreshold = 50f; [Tooltip("平滑移动的最大距离限制")] public float fastSmoothDistance = 10f; [Header("拉拽参数")] public float basePullStrength = 0.2f; [Header("肩膀 Transform")] public Transform shoulderTransform; [Header("身体 Transform")] public Transform bodyTransform; public void Teleport(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; } } public class MK_RemotePlayer : MonoBehaviour { public ulong playerId; [Header("距离设置")] [Tooltip("当当前位置与目标位置超过此距离时直接瞬移")] public float teleportThreshold = 50f; [Tooltip("平滑移动的最大距离限制")] public float maxSmoothDistance = 10f; } public class MK_RemoteProp : MonoBehaviour { public MK_RemotePlayer entity; } } namespace WKMPMod.RemotePlayers { public class DefaultModelExtension : ICustomModelExtension { private const string DISTANCE_FIELD_OVERLAY_SHADER = "assets/textmesh pro/shaders/tmp_sdf overlay.shader"; private const string GAME_TMP_FONT_ASSET = "Ticketing SDF"; public string ModelId => "default"; public string PrefabAssetName => "CapsulePlayerPrefab"; public string SpawnEffectAssetName => null; public string DeathEffectAssetName => null; public string DamageEffectAssetName => null; public void OnPrefabLoaded(GameObject prefabTemplate, IAssetHelper assetHelper) { FixTMPComponent(prefabTemplate, assetHelper); DefaultModelBehaviour component = prefabTemplate.GetComponent<DefaultModelBehaviour>(); if ((Object)(object)component != (Object)null) { component.OnPrefabLoaded(); } } public void OnPlayerInstanceCreated(GameObject playerInstance) { } private void FixTMPComponent(GameObject prefab, IAssetHelper assetHelper) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown if ((Object)(object)prefab == (Object)null) { return; } TMP_FontAsset val = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == "Ticketing SDF")); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"SlugcatFactory.FontAssetNotFound: Ticketing SDF"); return; } Shader customAsset = assetHelper.GetCustomAsset<Shader>("assets/textmesh pro/shaders/tmp_sdf overlay.shader"); if ((Object)(object)customAsset == (Object)null) { Debug.LogError((object)"DefaultFactory.UnableToLoadShader: assets/textmesh pro/shaders/tmp_sdf overlay.shader"); } TMP_Text[] componentsInChildren = prefab.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val2 in componentsInChildren) { Debug.Log((object)("DefaultFactory.SpecializingTMPComponent: " + ((Object)val2).name)); val2.font = val; if ((Object)(object)customAsset != (Object)null) { Material val3 = new Material(((TMP_Asset)val).material); val3.shader = customAsset; val2.fontSharedMaterial = val3; Debug.Log((object)("DefaultFactory.ImplementOverlayViaShader: " + ((Object)val2).name)); } } } } public interface ICustomModelExtension { string ModelId { get; } string PrefabAssetName { get; } string SpawnEffectAssetName { get; } string DeathEffectAssetName { get; } string DamageEffectAssetName { get; } void OnPrefabLoaded(GameObject prefab, IAssetHelper assetHelper); void OnPlayerInstanceCreated(GameObject playerInstance); } public interface IAssetHelper { T GetCustomAsset<T>(string assetName) where T : Object; } public class SlugcatModelExtension : ICustomModelExtension { private const string DISTANCE_FIELD_OVERLAY_SHADER = "assets/textmesh pro/shaders/tmp_sdf overlay.shader"; private const string GAME_TMP_FONT_ASSET = "Ticketing SDF"; public string ModelId => "slugcat"; public string PrefabAssetName => "SlugcatPlayerPrefab"; public string SpawnEffectAssetName => null; public string DeathEffectAssetName => null; public string DamageEffectAssetName => null; public void OnPrefabLoaded(GameObject prefabTemplate, IAssetHelper assetHelper) { FixTMPComponent(prefabTemplate, assetHelper); SlugcatModelBehaviour component = prefabTemplate.GetComponent<SlugcatModelBehaviour>(); if ((Object)(object)component != (Object)null) { component.OnPrefabLoaded(); } } public void OnPlayerInstanceCreated(GameObject playerInstance) { } private void FixTMPComponent(GameObject prefab, IAssetHelper assetHelper) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown if ((Object)(object)prefab == (Object)null) { return; } TMP_FontAsset val = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == "Ticketing SDF")); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"SlugcatFactory.FontAssetNotFound: Ticketing SDF"); return; } Shader customAsset = assetHelper.GetCustomAsset<Shader>("assets/textmesh pro/shaders/tmp_sdf overlay.shader"); if ((Object)(object)customAsset == (Object)null) { Debug.LogError((object)"SlugcatFactory.UnableToLoadShader: assets/textmesh pro/shaders/tmp_sdf overlay.shader"); } TMP_Text[] componentsInChildren = prefab.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val2 in componentsInChildren) { Debug.Log((object)("SlugcatFactory.SpecializingTMPComponent: " + ((Object)val2).name)); val2.font = val; if ((Object)(object)customAsset != (Object)null) { Material val3 = new Material(((TMP_Asset)val).material); val3.shader = customAsset; val2.fontSharedMaterial = val3; Debug.Log((object)("SlugcatFactory.ImplementOverlayViaShader: " + ((Object)val2).name)); } } } } } namespace WKMPMod.Data { public class DataReader { private ReadOnlyMemory<byte> _data; private int _position; public int AvailableBytes => _data.Length - _position; public int Length => _data.Length; public int Position { get { return _position; } set { if (value < 0 || value > _data.Length) { throw new ArgumentOutOfRangeException("value", "Position set out of bounds."); } _position = value; } } public void SetSource(ArraySegment<byte> 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<byte>(source, offset, length); _position = 0; } public void Skip(int byteCount) { if (byteCount > 0) { _position = Math.Min(_position + byteCount, _data.Length); } } 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_005c: Unknown result type (might be due to invalid IL or missing references) ReadOnlySpan<byte> 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_0072: Unknown result type (might be due to invalid IL or missing references) ReadOnlySpan<byte> 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 num = GetInt(); if (num <= 0) { return string.Empty; } if (num > AvailableBytes) { throw new Exception("String length out of range"); } string result = Encoding.UTF8.GetString(_data.Span.Slice(_position, num)); _position += num; return result; } public ReadOnlySpan<byte> GetBytes() { int num = GetInt(); ReadOnlySpan<byte> result = _data.Span.Slice(_position, num); _position += num; return result; } public ReadOnlyMemory<byte> GetMemory() { int num = GetInt(); ReadOnlyMemory<byte> result = _data.Slice(_position, num); _position += num; return result; } public Dictionary<string, byte> GetStringByteDict() { int num = GetInt(); Dictionary<string, byte> dictionary = new Dictionary<string, byte>(); for (int i = 0; i < num; i++) { string key = GetString(); byte value = GetByte(); dictionary[key] = value; } return dictionary; } public List<string> GetStringList() { List<string> list = new List<string>(); int num = GetInt(); for (int i = 0; i < num; i++) { list.Add(GetString()); } return list; } public Dictionary<string, string> GetStringStringDict() { int num = GetInt(); Dictionary<string, string> dictionary = new Dictionary<string, string>(); for (int i = 0; i < num; i++) { string key = GetString(); string value = GetString(); dictionary[key] = value; } return dictionary; } public T Get<T>() where T : INetworkSerializable, new() { T result = new T(); result.Deserialize(this); return result; } public void GetOut<T>(out T value) where T : struct, INetworkSerializable { value = default(T); value.Deserialize(this); } public void GetRef<T>(ref T value) where T : struct, INetworkSerializable { value.Deserialize(this); } public List<T> GetList<T>() where T : INetworkSerializable, new() { int num = GetInt(); if (num <= 0) { return new List<T>(0); } List<T> list = new List<T>(num); for (int i = 0; i < num; i++) { T item = new T(); item.Deserialize(this); list.Add(item); } return list; } public void GetList<T>(List<T> existingList) where T : INetworkSerializable, new() { int num = GetInt(); existingList.Clear(); for (int i = 0; i < num; i++) { T item = new T(); item.Deserialize(this); existingList.Add(item); } } public ulong GetIDType() { ulong result = BinaryPrimitives.ReadUInt64LittleEndian(_data.Span.Slice(_position)); _position += 8; return result; } } public class DataWriter : IDisposable { private byte[] _buffer; private int _position; private readonly ArrayPool<byte> _pool; public ArraySegment<byte> Data => new ArraySegment<byte>(_buffer, 0, _position); public int Position { get { return _position; } set { _position = value; } } public int Length => _position; public DataWriter(int initialCapacity = 1024) { _pool = ArrayPool<byte>.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] = (value ? ((byte)1) : ((byte)0)); _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 void PutUShortAt(int offset, ushort value) { if (offset < 0 || offset + 2 > _position) { throw new ArgumentOutOfRangeException("offset", "Offset out of buffer bounds."); } BinaryPrimitives.WriteUInt16LittleEndian(_buffer.AsSpan(offset), value); } public void PutIntAt(int offset, int value) { if (offset < 0 || offset + 4 > _position) { throw new ArgumentOutOfRangeException("offset", "Offset out of buffer bounds."); } BinaryPrimitives.WriteInt32LittleEndian(_buffer.AsSpan(offset), value); } public DataWriter PutRaw(byte[] value, int offset, int length) { if (value == null || length <= 0) { return this; } EnsureCapacity(length); Array.Copy(value, offset, _buffer, _position, length); _position += length; 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<byte> 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_001b: 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_004b: Unknown result type (might be due to invalid IL or missing references) EnsureCapacity(12); Span<byte> 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_001b: 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_004b: 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) EnsureCapacity(16); Span<byte> 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<string, byte> dict) { if (dict == null) { Put(0); return this; } Put(dict.Count); foreach (KeyValuePair<string, byte> item in dict) { Put(item.Key).Put(item.Value); } return this; } public DataWriter Put(IReadOnlyList<string> strings) { if (strings == null) { Put(0); return this; } Put(strings.Count); foreach (string @string in strings) { Put(@string); } return this; } public DataWriter Put(Dictionary<string, string> dict) { if (dict == null) { Put(0); return this; } Put(dict.Count); foreach (KeyValuePair<string, string> item in dict) { Put(item.Key).Put(item.Value); } return this; } public DataWriter Put<T>(T obj) where T : INetworkSerializable { obj.Serialize(this); return this; } public DataWriter PutIn<T>(in T obj) where T : struct, INetworkSerializable { obj.Serialize(this); return this; } public DataWriter Put<T>(IReadOnlyList<T> 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); } [Serializable] public struct PlayerData : INetworkSerializable { [Serializable] public struct HandData : INetworkSerializable { public byte handType; public byte interactState; public float PosX; public float PosY; public float PosZ; public bool handItemUpdate; public string itemPrefabName; public ulong targetId; public float desiredPosX; public float desiredPosY; public float desiredPosZ; 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_0001: 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_0019: Unknown result type (might be due to invalid IL or missing references) PosX = value.x; PosY = value.y; PosZ = value.z; } } public Vector3 DesiredPosition { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(desiredPosX, desiredPosY, desiredPosZ); } set { //IL_0001: 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_0019: Unknown result type (might be due to invalid IL or missing references) desiredPosX = value.x; desiredPosY = value.y; desiredPosZ = value.z; } } public void Serialize(DataWriter writer) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) writer.Put(handType); writer.Put(Position); writer.Put(interactState); switch (interactState) { case 0: writer.Put(handItemUpdate); if (handItemUpdate) { writer.Put(itemPrefabName); } break; case 2: writer.Put(targetId); writer.Put(DesiredPosition); break; case 4: writer.Put(targetId); break; case 1: case 3: break; } } public void Deserialize(DataReader reader) { //IL_000e: 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) handType = reader.GetByte(); Position = reader.GetVector3(); interactState = reader.GetByte(); switch (interactState) { case 0: handItemUpdate = reader.GetBool(); if (handItemUpdate) { itemPrefabName = reader.GetString(); } else { itemPrefabName = null; } break; case 2: targetId = reader.GetULong(); DesiredPosition = reader.GetVector3(); break; case 4: targetId = reader.GetULong(); break; case 1: case 3: break; } } public bool IsBeGrabbing(ulong targetPlayerId) { if (interactState == 2) { return targetId == targetPlayerId; } return false; } public bool IsBeHanging(ulong targetPlayerId) { if (interactState == 4) { return targetId == targetPlayerId; } return false; } public static bool operator ==(HandData left, HandData right) { if (left.handType != right.handType || left.interactState != right.interactState) { return false; } float num = left.PosX - right.PosX; float num2 = left.PosY - right.PosY; float num3 = left.PosZ - right.PosZ; if (num * num + num2 * num2 + num3 * num3 >= 0.0025f) { return false; } switch (left.interactState) { case 0: return left.itemPrefabName == right.itemPrefabName; case 2: { if (left.targetId != right.targetId) { return false; } float num4 = left.desiredPosX - right.desiredPosX; float num5 = left.desiredPosY - right.desiredPosY; float num6 = left.desiredPosZ - right.desiredPosZ; return num4 * num4 + num5 * num5 + num6 * num6 < 0.0025f; } case 4: return left.targetId == right.targetId; default: return true; } } public static bool operator !=(HandData left, HandData right) { return !(left == right); } } private const float POSITION_CHANGE_THRESHOLD_SQR = 0.0025f; private const float ROTATION_CHANGE_THRESHOLD_DEG = 0.5f; 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_0001: 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_0019: 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_0001: 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_0019: 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) RotX = value.x; RotY = value.y; RotZ = value.z; RotW = value.w; } } public void Serialize(DataWriter writer) { //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) writer.Put(playId).Put(TimestampTicks); writer.Put(Position).Put(Rotation); writer.PutIn(in LeftHand).PutIn(in RightHand); writer.Put(IsTeleport); } public void Deserialize(DataReader reader) { //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) playId = reader.GetULong(); TimestampTicks = reader.GetLong(); Position = reader.GetVector3(); Rotation = reader.GetQuaternion(); reader.GetRef(ref LeftHand); reader.GetRef(ref RightHand); IsTeleport = reader.GetBool(); } public bool UpdateIfChanged(in PlayerData newData, bool forceUpdate = false) { //IL_004c: 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) if (forceUpdate) { this = newData; return true; } float num = PosX - newData.PosX; float num2 = PosY - newData.PosY; float num3 = PosZ - newData.PosZ; if (num * num + num2 * num2 + num3 * num3 >= 0.0025f || !IsRotationSimilar(Rotation, newData.Rotation, 0.5f) || LeftHand != newData.LeftHand || RightHand != newData.RightHand) { this = newData; return true; } return false; } private static bool IsRotationSimilar(Quaternion a, Quaternion b, float thresholdDegrees) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Cos(thresholdDegrees * (MathF.PI / 180f) * 0.5f); return Mathf.Abs(Quaternion.Dot(a, b)) > num; } } } namespace WKMPMod.Components { 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00d5: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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) 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 = Mathf.Max(num, 0.8f * num + 2f) * baseScale * userScale; Vector3 val = (((Object)(object)((Component)this).transform.parent != (Object)null) ? ((Component)this).transform.parent.lossyScale : Vector3.one); float num3 = ((Mathf.Abs(val.x) > 0.0001f) ? val.x : 1f); float num4 = ((Mathf.Abs(val.y) > 0.0001f) ? val.y : 1f); float num5 = ((Mathf.Abs(val.z) > 0.0001f) ? val.z : 1f); ((Component)this).transform.localScale = new Vector3(num2 / num3, num2 / num4, num2 / num5); } } } public class RemoteTag : MonoBehaviour { private Transform? _cameraTransform; private TextMeshPro? _textMeshPro; private float _lastUpdateDistance; private TickTimer updateTick; [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() { updateTick = new TickTimer(1); _textMeshPro = ((Component)this).GetComponent<TextMeshPro>(); 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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)); } } private IEnumerator MessageTimeoutRoutine() { yield return (object)new WaitForSeconds(15f); _message = ""; RefreshName(); _messageTimeoutCoroutine = null; } } 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_0022: 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) if (originalLength <= 0f && (Object)(object)target != (Object)null) { originalLength = Vector3.Distance(((Component)this).transform.position, target.position); } } private void LateUpdate() { //IL_0020: 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) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_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_006a: 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) if (!((Object)(object)target == (Object)null)) { Vector3 val = ((Component)this).transform.parent.InverseTransformPoint(((Component)this).transform.position); Vector3 val2 = ((Component)this).transform.parent.InverseTransformPoint(target.position) - val; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude < 0.0001f)) { ((Component)this).transform.localRotation = Quaternion.FromToRotation(Vector3.up, val2); float num = magnitude / originalLength; num = Mathf.Clamp(num, minScale, maxScale); ((Component)this).transform.localScale = new Vector3(1f, num, 1f); } } } } } namespace WKMPModa.Shared.Data { [Serializable] public struct ItemPoseData { [Header("物品相对于手的 Transform")] public Vector3 itemPosition; public Quaternion itemRotation; public Vector3 itemScale; [Header("拿持该物品时手部的姿态偏置")] public Quaternion handRotationOffset; public static ItemPoseData Default => new ItemPoseData(Vector3.zero, Quaternion.identity, Vector3.one, Quaternion.identity); public ItemPoseData(Vector3 pos, Quaternion rot, Vector3 scale, Quaternion handRot) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0010: 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_0018: Unknown result type (might be due to invalid IL or missing references) itemPosition = pos; itemRotation = rot; itemScale = scale; handRotationOffset = handRot; } } } namespace WKMPModa.Shared.Component { public abstract class CustomModelBehaviour : MonoBehaviour { public virtual Dictionary<string, ItemPoseData> HandItemTransform { get; } public virtual void OnPrefabLoaded() { } public virtual void ApplyPlayerColor(Color32 color) { } public virtual void SetCrouching(bool isCrouching) { } public virtual void HandlePlayerData(Dictionary<string, string> playerData) { } } public class DefaultModelBehaviour : CustomModelBehaviour { private static Dictionary<string, ItemPoseData> _handItemTransform; public static readonly Quaternion HAND_ROT; public static readonly ItemPoseData HAMMER_TRANSFROM; public static readonly ItemPoseData BARNACLE_HOOK_TRANSFROM; public static readonly ItemPoseData HANDGUN_TRANSFROM; public static readonly ItemPoseData BOXED_FOOD_TRANSFROM; public static readonly ItemPoseData BEANS_TRANSFROM; public static readonly ItemPoseData FOOD_TRANSFROM; public static readonly ItemPoseData COCOA_TRANSFROM; public static readonly ItemPoseData REBAR_TRANSFROM; public static readonly ItemPoseData PITON_TRANSFROM; public static readonly ItemPoseData BLINK_EYE_TRANSFROM; public static readonly ItemPoseData ROACH_TRANSFROM; public static readonly ItemPoseData GRUB_TRANSFROM; public static readonly ItemPoseData FLOPPY_TRANSFROM; public static readonly ItemPoseData NOTE_TRANSFROM; private static readonly string[] TintColorProperties; [SerializeField] internal Renderer[] _tintRenderers; public override Dictionary<string, ItemPoseData> HandItemTransform => _handItemTransform; static DefaultModelBehaviour() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00cd: 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_0109: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_06ca: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_0727: Unknown result type (might be due to invalid IL or missing references) //IL_072c: Unknown result type (might be due to invalid IL or missing references) //IL_0731: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0769: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Unknown result type (might be due to invalid IL or missing references) //IL_0797: Unknown result type (might be due to invalid IL or missing references) //IL_07ab: Unknown result type (might be due to invalid IL or missing references) //IL_07b0: Unknown result type (might be due to invalid IL or missing references) //IL_07ba: Unknown result type (might be due to invalid IL or missing references) //IL_07bf: Unknown result type (might be due to invalid IL or missing references) //IL_07e3: Unknown result type (might be due to invalid IL or missing references) //IL_07f7: Unknown result type (might be due to invalid IL or missing references) //IL_07fc: Unknown result type (might be due to invalid IL or missing references) //IL_0801: Unknown result type (might be due to invalid IL or missing references) //IL_0825: Unknown result type (might be due to invalid IL or missing references) //IL_0839: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_0848: Unknown result type (might be due to invalid IL or missing references) //IL_084d: Unknown result type (might be due to invalid IL or missing references) //IL_0871: Unknown result type (might be due to invalid IL or missing references) //IL_0885: Unknown result type (might be due to invalid IL or missing references) //IL_088a: Unknown result type (might be due to invalid IL or missing references) //IL_088f: Unknown result type (might be due to invalid IL or missing references) //IL_08d3: Unknown result type (might be due to invalid IL or missing references) //IL_08e7: Unknown result type (might be due to invalid IL or missing references) //IL_08ec: Unknown result type (might be due to invalid IL or missing references) //IL_08f1: Unknown result type (might be due to invalid IL or missing references) //IL_0915: Unknown result type (might be due to invalid IL or missing references) //IL_0929: Unknown result type (might be due to invalid IL or missing references) //IL_092e: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Unknown result type (might be due to invalid IL or missing references) //IL_0957: Unknown result type (might be due to invalid IL or missing references) //IL_096b: Unknown result type (might be due to invalid IL or missing references) //IL_0970: Unknown result type (might be due to invalid IL or missing references) //IL_0975: Unknown result type (might be due to invalid IL or missing references) //IL_0999: Unknown result type (might be due to invalid IL or missing references) //IL_09ad: Unknown result type (might be due to invalid IL or missing references) //IL_09b2: Unknown result type (might be due to invalid IL or missing references) //IL_09b7: Unknown result type (might be due to invalid IL or missing references) //IL_09db: Unknown result type (might be due to invalid IL or missing references) //IL_09ef: Unknown result type (might be due to invalid IL or missing references) //IL_09f4: Unknown result type (might be due to invalid IL or missing references) //IL_09f9: Unknown result type (might be due to invalid IL or missing references) //IL_0a1d: Unknown result type (might be due to invalid IL or missing references) //IL_0a31: Unknown result type (might be due to invalid IL or missing references) //IL_0a36: Unknown result type (might be due to invalid IL or missing references) //IL_0a40: Unknown result type (might be due to invalid IL or missing references) //IL_0a45: Unknown result type (might be due to invalid IL or missing references) //IL_0a69: Unknown result type (might be due to invalid IL or missing references) //IL_0a7d: Unknown result type (might be due to invalid IL or missing references) //IL_0a82: Unknown result type (might be due to invalid IL or missing references) //IL_0a87: Unknown result type (might be due to invalid IL or missing references) //IL_0b9b: Unknown result type (might be due to invalid IL or missing references) //IL_0baf: Unknown result type (might be due to invalid IL or missing references) //IL_0bb4: Unknown result type (might be due to invalid IL or missing references) //IL_0bb9: Unknown result type (might be due to invalid IL or missing references) //IL_0bfd: Unknown result type (might be due to invalid IL or missing references) //IL_0c11: Unknown result type (might be due to invalid IL or missing references) //IL_0c16: Unknown result type (might be due to invalid IL or missing references) //IL_0c1b: Unknown result type (might be due to invalid IL or missing references) //IL_0c3f: Unknown result type (might be due to invalid IL or missing references) //IL_0c53: Unknown result type (might be due to invalid IL or missing references) //IL_0c58: Unknown result type (might be due to invalid IL or missing references) //IL_0c5d: Unknown result type (might be due to invalid IL or missing references) //IL_0c72: Unknown result type (might be due to invalid IL or missing references) //IL_0c86: Unknown result type (might be due to invalid IL or missing references) //IL_0c8b: Unknown result type (might be due to invalid IL or missing references) //IL_0c95: Unknown result type (might be due to invalid IL or missing references) //IL_0c9a: Unknown result type (might be due to invalid IL or missing references) //IL_0cbe: Unknown result type (might be due to invalid IL or missing references) //IL_0cd2: Unknown result type (might be due to invalid IL or missing references) //IL_0cd7: Unknown result type (might be due to invalid IL or missing references) //IL_0cdc: Unknown result type (might be due to invalid IL or missing references) //IL_0d30: Unknown result type (might be due to invalid IL or missing references) //IL_0d44: Unknown result type (might be due to invalid IL or missing references) //IL_0d58: Unknown result type (might be due to invalid IL or missing references) //IL_0d5d: Unknown result type (might be due to invalid IL or missing references) //IL_0d81: Unknown result type (might be due to invalid IL or missing references) //IL_0d95: Unknown result type (might be due to invalid IL or missing references) //IL_0d9a: Unknown result type (might be due to invalid IL or missing references) //IL_0d9f: Unknown result type (might be due to invalid IL or missing references) //IL_0dc3: Unknown result type (might be due to invalid IL or missing references) //IL_0dd7: Unknown result type (might be due to invalid IL or missing references) //IL_0ddc: Unknown result type (might be due to invalid IL or missing references) //IL_0de1: Unknown result type (might be due to invalid IL or missing references) //IL_0e05: Unknown result type (might be due to invalid IL or missing references) //IL_0e19: Unknown result type (might be due to invalid IL or missing references) //IL_0e1e: Unknown result type (might be due to invalid IL or missing references) //IL_0e23: Unknown result type (might be due to invalid IL or missing references) //IL_0e47: Unknown result type (might be due to invalid IL or missing references) //IL_0e5b: Unknown result type (might be due to invalid IL or missing references) //IL_0e60: Unknown result type (might be due to invalid IL or missing references) //IL_0e65: Unknown result type (might be due to invalid IL or missing references) //IL_0e99: Unknown result type (might be due to invalid IL or missing references) //IL_0ead: Unknown result type (might be due to invalid IL or missing references) //IL_0eb2: Unknown result type (might be due to invalid IL or missing references) //IL_0eb7: Unknown result type (might be due to invalid IL or missing references) //IL_0edb: Unknown result type (might be due to invalid IL or missing references) //IL_0eef: Unknown result type (might be due to invalid IL or missing references) //IL_0ef4: Unknown result type (might be due to invalid IL or missing references) //IL_0ef9: Unknown result type (might be due to invalid IL or missing references) //IL_0f1d: Unknown result type (might be due to invalid IL or missing references) //IL_0f31: Unknown result type (might be due to invalid IL or missing references) //IL_0f36: Unknown result type (might be due to invalid IL or missing references) //IL_0f3b: Unknown result type (might be due to invalid IL or missing references) //IL_0f6f: Unknown result type (might be due to invalid IL or missing references) //IL_0f83: Unknown result type (might be due to invalid IL or missing references) //IL_0f97: Unknown result type (might be due to invalid IL or missing references) //IL_0f9c: Unknown result type (might be due to invalid IL or missing references) //IL_0fc0: Unknown result type (might be due to invalid IL or missing references) //IL_0fd4: Unknown result type (might be due to invalid IL or missing references) //IL_0fd9: Unknown result type (might be due to invalid IL or missing references) //IL_0fde: Unknown result type (might be due to invalid IL or missing references) //IL_1002: Unknown result type (might be due to invalid IL or missing references) //IL_1016: Unknown result type (might be due to invalid IL or missing references) //IL_101b: Unknown result type (might be due to invalid IL or missing references) //IL_1020: Unknown result type (might be due to invalid IL or missing references) //IL_1044: Unknown result type (might be due to invalid IL or missing references) //IL_1058: Unknown result type (might be due to invalid IL or missing references) //IL_105d: Unknown result type (might be due to invalid IL or missing references) //IL_1062: Unknown result type (might be due to invalid IL or missing references) //IL_1086: Unknown result type (might be due to invalid IL or missing references) //IL_109a: Unknown result type (might be due to invalid IL or missing references) //IL_10ae: Unknown result type (might be due to invalid IL or missing references) //IL_10b3: Unknown result type (might be due to invalid IL or missing references) //IL_10d7: Unknown result type (might be due to invalid IL or missing references) //IL_10eb: Unknown result type (might be due to invalid IL or missing references) //IL_10f0: Unknown result type (might be due to invalid IL or missing references) //IL_10f5: Unknown result type (might be due to invalid IL or missing references) HAND_ROT = Quaternion.Euler(0f, 315f, 0f); HAMMER_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 90f, 0f), Vector3.one, HAND_ROT); BARNACLE_HOOK_TRANSFROM = new ItemPoseData(new Vector3(0f, 0f, 0.1f), Quaternion.identity, Vector3.one, HAND_ROT); HANDGUN_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0.2f), Quaternion.Euler(0f, 180f, 90f), Vector3.one, HAND_ROT); BOXED_FOOD_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(0f, 45f, 0f), Vector3.one, HAND_ROT); BEANS_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(0f, 225f, 0f), Vector3.one, HAND_ROT); FOOD_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 0f, 0f), Vector3.one, HAND_ROT); COCOA_TRANSFROM = new ItemPoseData(new Vector3(-0.2f, 0f, 0f), Quaternion.Euler(0f, 180f, 0f), Vector3.one, HAND_ROT); REBAR_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.3f, 0f), Quaternion.Euler(90f, 270f, 0f), Vector3.one, HAND_ROT); PITON_TRANSFROM = new ItemPoseData(Vector3.zero, Quaternion.Euler(270f, 180f, 0f), Vector3.one * 1.2f, HAND_ROT); BLINK_EYE_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(0f, 180f, 0f), Vector3.one, HAND_ROT); ROACH_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.1f, 0.1f), Quaternion.Euler(315f, 0f, 0f), Vector3.one, HAND_ROT); GRUB_TRANSFROM = new ItemPoseData(new Vector3(-0.1f, 0.1f, 0f), Quaternion.Euler(0f, 0f, 270f), Vector3.one, HAND_ROT); FLOPPY_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 0f, 0f), Vector3.one, HAND_ROT); NOTE_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.3f, 0f), Quaternion.Euler(270f, 0f, 0f), Vector3.one, HAND_ROT); TintColorProperties = new string[3] { "_BaseColor", "_Color", "_MainColor" }; _handItemTransform = new Dictionary<string, ItemPoseData> { { "None", new ItemPoseData(new Vector3(0f, 0.4f, 0f), Quaternion.Euler(45f, 45f, 45f), Vector3.one, HAND_ROT) }, { "Item_Hammer", HAMMER_TRANSFROM }, { "Item_BanHammer", HAMMER_TRANSFROM }, { "Item_Pipewrench", HAMMER_TRANSFROM }, { "Item_Hammer_Cosmetic_Wrench", HAMMER_TRANSFROM }, { "Item_BarnacleHook", BARNACLE_HOOK_TRANSFROM }, { "Item_BarnacleHook_Infinite", BARNACLE_HOOK_TRANSFROM }, { "Item_Handgun", HANDGUN_TRANSFROM }, { "Item_Handgun_Debug", HANDGUN_TRANSFROM }, { "Item_10mm_Ammo", new ItemPoseData(new Vector3(0f, 0.3f, 0f), Quaternion.Euler(270f, 270f, 0f), Vector3.one, HAND_ROT) }, { "Item_Injector", new ItemPoseData(new Vector3(0f, -0.1f, 0f), Quaternion.Euler(270f, 90f, 0f), Vector3.one * 1.3f, HAND_ROT) }, { "Item_Pillbottle", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 0f, 0f), Vector3.one, HAND_ROT) }, { "Item_Food_Fruit", new ItemPoseData(new Vector3(0.2f, 0f, 0f), Quaternion.Euler(0f, 90f, 270f), Vector3.one, HAND_ROT) }, { "Item_Food_Meat", new ItemPoseData(Vector3.zero, Quaternion.Euler(0f, 90f, 270f), Vector3.one, HAND_ROT) }, { "Item_Wine", BOXED_FOOD_TRANSFROM }, { "Item_Wine_Empty", BOXED_FOOD_TRANSFROM }, { "Item_Milk", BOXED_FOOD_TRANSFROM }, { "Item_Milk_Empty", BOXED_FOOD_TRANSFROM }, { "Item_Milk_Rho", BOXED_FOOD_TRANSFROM }, { "Item_Beans", BEANS_TRANSFROM }, { "Item_Beans_Eaten", BEANS_TRANSFROM }, { "Item_Beans_Periphery", BEANS_TRANSFROM }, { "Item_Food_Bar", FOOD_TRANSFROM }, { "Item_Food_Cookie", FOOD_TRANSFROM }, { "Item_Cocoa_Full", COCOA_TRANSFROM }, { "Item_Cocoa_Empty", COCOA_TRANSFROM }, { "Item_Rebar_Explosive", REBAR_TRANSFROM }, { "Item_RebarRope", REBAR_TRANSFROM }, { "Item_RebarRope_Holiday", REBAR_TRANSFROM }, { "Item_Rebar", REBAR_TRANSFROM }, { "Item_Rebar_Holiday", REBAR_TRANSFROM }, { "Item_Rebar_Bone", REBAR_TRANSFROM }, { "Item_AutoPiton", new ItemPoseData(new Vector3(0f, 0f, 0.2f), Quaternion.Euler(0f, 180f, 0f), Vector3.one, HAND_ROT) }, { "Item_Piton", PITON_TRANSFROM }, { "Item_Piton_Holiday", PITON_TRANSFROM }, { "Item_Rubble", new ItemPoseData(new Vector3(0f, 0.15f, 0f), Quaternion.Euler(90f, 0f, 0f), Vector3.one, HAND_ROT) }, { "Item_Flaregun", new ItemPoseData(new Vector3(0f, 0.1f, 0.1f), Quaternion.Euler(90f, 0f, 0f), Vector3.one, HAND_ROT) }, { "Item_Flaregun_Ammo", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(90f, 90f, 0f), Vector3.one * 1.2f, HAND_ROT) }, { "Item_Flashlight", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(90f, 0f, 0f), Vector3.one, HAND_ROT) }, { "Item_RhoStone", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 0f, 0f), Vector3.one * 1.2f, HAND_ROT) }, { "Item_Cleaver", new ItemPoseData(new Vector3(0f, 0.4f, 0.1f), Quaternion.Euler(270f, 270f, 0f), Vector3.one, HAND_ROT) }, { "Item_BlinkEye", BLINK_EYE_TRANSFROM }, { "Item_BlinkEye_Marionette", BLINK_EYE_TRANSFROM }, { "Item_Artifact_Translocator", new ItemPoseData(new Vector3(0f, 0.1f, 0.3f), Quaternion.Euler(270f, 0f, 0f), Vector3.one, HAND_ROT) }, { "Item_Artifact_Rapier", new ItemPoseData(new Vector3(0f, 0.1f, 0f), Quaternion.Euler(270f, 90f, 0f), Vector3.one, HAND_ROT) }, { "Item_Artifact_Rebar_Return", new ItemPoseData(new Vector3(0f, 0.3f, 0f), Quaternion.Euler(270f, 180f, 0f), Vector3.one, HAND_ROT) }, { "Item_Artifact_Timepiece", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 0f, 0f), Vector3.one, HAND_ROT) }, { "Item_Artifact_Remote", new ItemPoseData(new Vector3(0f, 0.15f, 0.15f), Quaternion.Euler(315f, 0f, 0f), Vector3.one, HAND_ROT) }, { "Item_Artifact_EVAGlove", new ItemPoseData(new Vector3(0f, 0f, -0.2f), Quaternion.Euler(0f, 0f, 0f), Vector3.one * 1.2f, Quaternion.identity) }, { "Denizen_Roach_Flying_Ruby", new ItemPoseData(new Vector3(0f, 0.1f, 0.1f), Quaternion.Euler(0f, 180f, 0f), Vector3.one, HAND_ROT) }, { "Denizen_Roach_Platinum", ROACH_TRANSFROM }, { "Denizen_Roach_Platinum_Navmesh", ROACH_TRANSFROM }, { "Denizen_Roach_Gold", ROACH_TRANSFROM }, { "Denizen_Roach_Gold_Navmesh", ROACH_TRANSFROM }, { "Denizen_Roach_Lemon", ROACH_TRANSFROM }, { "Denizen_SlugGrub", GRUB_TRANSFROM }, { "Denizen_SlugGrub_Christmas", GRUB_TRANSFROM }, { "Denizen_SlugGrub_Sam", GRUB_TRANSFROM }, { "Item_Floppy_T1", FLOPPY_TRANSFROM }, { "Item_Floppy_T2", FLOPPY_TRANSFROM }, { "Item_Floppy_T3", FLOPPY_TRANSFROM }, { "Item_Floppy_Variant", FLOPPY_TRANSFROM }, { "Item_Floppy_Test", FLOPPY_TRANSFROM }, { "Item_Floppy_T1_Notes", FLOPPY_TRANSFROM }, { "Item_Floppy_Lost", FLOPPY_TRANSFROM }, { "Item_EntityScanner", new ItemPoseData(new Vector3(0f, 0f, 0.25f), Quaternion.Euler(90f, 90f, 0f), Vector3.one, HAND_ROT) }, { "Item_CandyCauldron", BLINK_EYE_TRANSFROM }, { "Item_CandyCauldron_Empty", BLINK_EYE_TRANSFROM }, { "Item_Cryogun", new ItemPoseData(new Vector3(0f, 0.1f, 0.2f), Quaternion.Euler(270f, 180f, 0f), Vector3.one, HAND_ROT) }, { "Item_Powercell", new ItemPoseData(new Vector3(0f, 0f, 0.1f), Quaternion.Euler(270f, 90f, 0f), Vector3.one, HAND_ROT) }, { "Item_Inoculator", new ItemPoseData(Vector3.zero, Quaternion.Euler(270f, 90f, 0f), Vector3.one * 1.3f, HAND_ROT) }, { "Item_Bandage", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(0f, 90f, 90f), Vector3.one, HAND_ROT) }, { "Item_Note_01", NOTE_TRANSFROM }, { "Item_Note_03_Torn", NOTE_TRANSFROM }, { "Item_Note_02_Bloody", NOTE_TRANSFROM }, { "Item_Radio", new ItemPoseData(new Vector3(0f, 0.3f, 0f), Quaternion.Euler(270f, 0f, 0f), new Vector3(-1f, 1f, 1f), HAND_ROT) }, { "Item_Rope", new ItemPoseData(new Vector3(0f, 0.1f, 0f), Quaternion.Euler(0f, 45f, 0f), Vector3.one, HAND_ROT) }, { "Item_Temp", new ItemPoseData(new Vector3(0f, 0.4f, 0f), Quaternion.Euler(45f, 45f, 45f), Vector3.one, HAND_ROT) }, { "Item_Trinket_Base", new ItemPoseData(new Vector3(0f, 0.4f, 0f), Quaternion.Euler(45f, 45f, 45f), Vector3.one, HAND_ROT) }, { "Item_Trinket_Helmet", new ItemPoseData(new Vector3(-0.2f, 0.1f, 0.3f), Quaternion.Euler(270f, 180f, 0f), Vector3.one, HAND_ROT) }, { "Item_Trinket_CalmingBuddy", FLOPPY_TRANSFROM }, { "Item_Trinket_Nugget", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(0f, 90f, 0f), Vector3.one, HAND_ROT) }, { "Item_Trinket_Carabiner", new ItemPoseData(new Vector3(0f, 0.15f, 0f), Quaternion.Euler(0f, 0f, 0f), Vector3.one, HAND_ROT) }, { "Item_Trinket_PhotoOfHome", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 180f, 0f), Vector3.one, HAND_ROT) }, { "Item_Trinket_EmployeeID", FLOPPY_TRANSFROM }, { "Item_Trinket_Chalk", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(315f, 0f, 0f), new Vector3(-1f, 1f, 1f), HAND_ROT) }, { "Item_Trinket_Headlamp", new ItemPoseData(new Vector3(0f, 0.15f, 0f), Quaternion.Euler(315f, 180f, 0f), Vector3.one, HAND_ROT) }, { "Item_Trinket_MassDamper", new ItemPoseData(new Vector3(0f, 0.15f, -0.1f), Quaternion.Euler(0f, 270f, 0f), Vector3.one, HAND_ROT) }, { "Item_Trinket_MoonRock", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 270f, 0f), Vector3.one, HAND_ROT) }, { "Item_Trinket_Beta", new ItemPoseData(new Vector3(-0.1f, 0.2f, 0f), Quaternion.Euler(270f, 0f, 0f), new Vector3(-1f, 1f, 1f), HAND_ROT) }, { "Item_Trinket_ClimbingShoes", new ItemPoseData(new Vector3(0f, 0.1f, 0f), Quaternion.Euler(0f, 0f, 90f), Vector3.one, HAND_ROT) } }; } public override void OnPrefabLoaded() { List<Renderer> list = new List<Renderer>(); Renderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)((Component)val).GetComponent<TMP_Text>())) { list.Add(val); } } _tintRenderers = list.ToArray(); } public override void ApplyPlayerColor(Color32 color) { //IL_0030: 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_0028: 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_003b: 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_0081: 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_008d: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) Renderer[] tintRenderers = _tintRenderers; foreach (Renderer obj in tintRenderers) { Color val = (((Object)((Component)obj).gameObject).name.StartsWith("Eyes") ? GetContrastColor(Color32.op_Implicit(color)) : Color32.op_Implicit(color)); Material[] materials = obj.materials; foreach (Material val2 in materials) { if ((Object)(object)val2 == (Object)null) { continue; } string[] tintColorProperties = TintColorProperties; foreach (string text in tintColorProperties) { if (val2.HasProperty(text)) { Color color2 = val2.GetColor(text); val2.SetColor(text, new Color(val.r, val.g, val.b, (float)(int)(byte)Mathf.Clamp(Mathf.RoundToInt(color2.a * 255f), 0, 255))); } } } } } private static Color GetContrastColor(Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0033: 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) if (!(0.299f * color.r + 0.587f * color.g + 0.114f * color.b > 0.5f)) { return Color.white; } return Color.black; } public override void SetCrouching(bool isCrouching) { } public override void HandlePlayerData(Dictionary<string, string> playerData) { } } public class SlugcatModelBehaviour : CustomModelBehaviour { private static Dictionary<string, ItemPoseData> _handItemTransform; public static readonly Quaternion HAND_ROT; public static readonly ItemPoseData HAMMER_TRANSFROM; public static readonly ItemPoseData BARNACLE_HOOK_TRANSFROM; public static readonly ItemPoseData HANDGUN_TRANSFROM; public static readonly ItemPoseData BOXED_FOOD_TRANSFROM; public static readonly ItemPoseData BEANS_TRANSFROM; public static readonly ItemPoseData FOOD_TRANSFROM; public static readonly ItemPoseData COCOA_TRANSFROM; public static readonly ItemPoseData REBAR_TRANSFROM; public static readonly ItemPoseData PITON_TRANSFROM; public static readonly ItemPoseData BLINK_EYE_TRANSFROM; public static readonly ItemPoseData ROACH_TRANSFROM; public static readonly ItemPoseData GRUB_TRANSFROM; public static readonly ItemPoseData FLOPPY_TRANSFROM; public static readonly ItemPoseData NOTE_TRANSFROM; private static readonly string[] TintColorProperties; [SerializeField] internal GameObject _gasMask; [SerializeField] internal GameObject _gearedUp; internal Dictionary<string, List<GameObject>> _itemGroups = new Dictionary<string, List<GameObject>>(); [SerializeField] internal Renderer[] _tintRenderers; public override Dictionary<string, ItemPoseData> HandItemTransform => _handItemTransform; static SlugcatModelBehaviour() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00cd: 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_0109: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_06ca: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_0727: Unknown result type (might be due to invalid IL or missing references) //IL_072c: Unknown result type (might be due to invalid IL or missing references) //IL_0731: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0769: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Unknown result type (might be due to invalid IL or missing references) //IL_0797: Unknown result type (might be due to invalid IL or missing references) //IL_07ab: Unknown result type (might be due to invalid IL or missing references) //IL_07b0: Unknown result type (might be due to invalid IL or missing references) //IL_07ba: Unknown result type (might be due to invalid IL or missing references) //IL_07bf: Unknown result type (might be due to invalid IL or missing references) //IL_07e3: Unknown result type (might be due to invalid IL or missing references) //IL_07f7: Unknown result type (might be due to invalid IL or missing references) //IL_07fc: Unknown result type (might be due to invalid IL or missing references) //IL_0801: Unknown result type (might be due to invalid IL or missing references) //IL_0825: Unknown result type (might be due to invalid IL or missing references) //IL_0839: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_0848: Unknown result type (might be due to invalid IL or missing references) //IL_084d: Unknown result type (might be due to invalid IL or missing references) //IL_0871: Unknown result type (might be due to invalid IL or missing references) //IL_0885: Unknown result type (might be due to invalid IL or missing references) //IL_088a: Unknown result type (might be due to invalid IL or missing references) //IL_088f: Unknown result type (might be due to invalid IL or missing references) //IL_08d3: Unknown result type (might be due to invalid IL or missing references) //IL_08e7: Unknown result type (might be due to invalid IL or missing references) //IL_08ec: Unknown result type (might be due to invalid IL or missing references) //IL_08f1: Unknown result type (might be due to invalid IL or missing references) //IL_0915: Unknown result type (might be due to invalid IL or missing references) //IL_0929: Unknown result type (might be due to invalid IL or missing references) //IL_092e: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Unknown result type (might be due to invalid IL or missing references) //IL_0957: Unknown result type (might be due to invalid IL or missing references) //IL_096b: Unknown result type (might be due to invalid IL or missing references) //IL_0970: Unknown result type (might be due to invalid IL or missing references) //IL_0975: Unknown result type (might be due to invalid IL or missing references) //IL_0999: Unknown result type (might be due to invalid IL or missing references) //IL_09ad: Unknown result type (might be due to invalid IL or missing references) //IL_09b2: Unknown result type (might be due to invalid IL or missing references) //IL_09b7: Unknown result type (might be due to invalid IL or missing references) //IL_09db: Unknown result type (might be due to invalid IL or missing references) //IL_09ef: Unknown result type (might be due to invalid IL or missing references) //IL_09f4: Unknown result type (might be due to invalid IL or missing references) //IL_09f9: Unknown result type (might be due to invalid IL or missing references) //IL_0a1d: Unknown result type (might be due to invalid IL or missing references) //IL_0a31: Unknown result type (might be due to invalid IL or missing references) //IL_0a36: Unknown result type (might be due to invalid IL or missing references) //IL_0a40: Unknown result type (might be due to invalid IL or missing references) //IL_0a45: Unknown result type (might be due to invalid IL or missing references) //IL_0a69: Unknown result type (might be due to invalid IL or missing references) //IL_0a7d: Unknown result type (might be due to invalid IL or missing references) //IL_0a82: Unknown result type (might be due to invalid IL or missing references) //IL_0a87: Unknown result type (might be due to invalid IL or missing references) //IL_0b9b: Unknown result type (might be due to invalid IL or missing references) //IL_0baf: Unknown result type (might be due to invalid IL or missing references) //IL_0bb4: Unknown result type (might be due to invalid IL or missing references) //IL_0bb9: Unknown result type (might be due to invalid IL or missing references) //IL_0bfd: Unknown result type (might be due to invalid IL or missing references) //IL_0c11: Unknown result type (might be due to invalid IL or missing references) //IL_0c16: Unknown result type (might be due to invalid IL or missing references) //IL_0c1b: Unknown result type (might be due to invalid IL or missing references) //IL_0c3f: Unknown result type (might be due to invalid IL or missing references) //IL_0c53: Unknown result type (might be due to invalid IL or missing references) //IL_0c58: Unknown result type (might be due to invalid IL or missing references) //IL_0c5d: Unknown result type (might be due to invalid IL or missing references) //IL_0c72: Unknown result type (might be due to invalid IL or missing references) //IL_0c86: Unknown result type (might be due to invalid IL or missing references) //IL_0c8b: Unknown result type (might be due to invalid IL or missing references) //IL_0c95: Unknown result type (might be due to invalid IL or missing references) //IL_0c9a: Unknown result type (might be due to invalid IL or missing references) //IL_0cbe: Unknown result type (might be due to invalid IL or missing references) //IL_0cd2: Unknown result type (might be due to invalid IL or missing references) //IL_0cd7: Unknown result type (might be due to invalid IL or missing references) //IL_0cdc: Unknown result type (might be due to invalid IL or missing references) //IL_0d30: Unknown result type (might be due to invalid IL or missing references) //IL_0d44: Unknown result type (might be due to invalid IL or missing references) //IL_0d58: Unknown result type (might be due to invalid IL or missing references) //IL_0d5d: Unknown result type (might be due to invalid IL or missing references) //IL_0d81: Unknown result type (might be due to invalid IL or missing references) //IL_0d95: Unknown result type (might be due to invalid IL or missing references) //IL_0d9a: Unknown result type (might be due to invalid IL or missing references) //IL_0d9f: Unknown result type (might be due to invalid IL or missing references) //IL_0dc3: Unknown result type (might be due to invalid IL or missing references) //IL_0dd7: Unknown result type (might be due to invalid IL or missing references) //IL_0ddc: Unknown result type (might be due to invalid IL or missing references) //IL_0de1: Unknown result type (might be due to invalid IL or missing references) //IL_0e05: Unknown result type (might be due to invalid IL or missing references) //IL_0e19: Unknown result type (might be due to invalid IL or missing references) //IL_0e1e: Unknown result type (might be due to invalid IL or missing references) //IL_0e23: Unknown result type (might be due to invalid IL or missing references) //IL_0e47: Unknown result type (might be due to invalid IL or missing references) //IL_0e5b: Unknown result type (might be due to invalid IL or missing references) //IL_0e60: Unknown result type (might be due to invalid IL or missing references) //IL_0e65: Unknown result type (might be due to invalid IL or missing references) //IL_0e99: Unknown result type (might be due to invalid IL or missing references) //IL_0ead: Unknown result type (might be due to invalid IL or missing references) //IL_0eb2: Unknown result type (might be due to invalid IL or missing references) //IL_0eb7: Unknown result type (might be due to invalid IL or missing references) //IL_0edb: Unknown result type (might be due to invalid IL or missing references) //IL_0eef: Unknown result type (might be due to invalid IL or missing references) //IL_0ef4: Unknown result type (might be due to invalid IL or missing references) //IL_0ef9: Unknown result type (might be due to invalid IL or missing references) //IL_0f1d: Unknown result type (might be due to invalid IL or missing references) //IL_0f31: Unknown result type (might be due to invalid IL or missing references) //IL_0f36: Unknown result type (might be due to invalid IL or missing references) //IL_0f3b: Unknown result type (might be due to invalid IL or missing references) //IL_0f6f: Unknown result type (might be due to invalid IL or missing references) //IL_0f83: Unknown result type (might be due to invalid IL or missing references) //IL_0f97: Unknown result type (might be due to invalid IL or missing references) //IL_0f9c: Unknown result type (might be due to invalid IL or missing references) //IL_0fc0: Unknown result type (might be due to invalid IL or missing references) //IL_0fd4: Unknown result type (might be due to invalid IL or missing references) //IL_0fd9: Unknown result type (might be due to invalid IL or missing references) //IL_0fde: Unknown result type (might be due to invalid IL or missing references) //IL_1002: Unknown result type (might be due to invalid IL or missing references) //IL_1016: Unknown result type (might be due to invalid IL or missing references) //IL_101b: Unknown result type (might be due to invalid IL or missing references) //IL_1020: Unknown result type (might be due to invalid IL or missing references) //IL_1044: Unknown result type (might be due to invalid IL or missing references) //IL_1058: Unknown result type (might be due to invalid IL or missing references) //IL_105d: Unknown result type (might be due to invalid IL or missing references) //IL_1062: Unknown result type (might be due to invalid IL or missing references) //IL_1086: Unknown result type (might be due to invalid IL or missing references) //IL_109a: Unknown result type (might be due to invalid IL or missing references) //IL_10ae: Unknown result type (might be due to invalid IL or missing references) //IL_10b3: Unknown result type (might be due to invalid IL or missing references) //IL_10d7: Unknown result type (might be due to invalid IL or missing references) //IL_10eb: Unknown result type (might be due to invalid IL or missing references) //IL_10f0: Unknown result type (might be due to invalid IL or missing references) //IL_10f5: Unknown result type (might be due to invalid IL or missing references) HAND_ROT = Quaternion.Euler(0f, 330f, 0f); HAMMER_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 90f, 0f), Vector3.one, HAND_ROT); BARNACLE_HOOK_TRANSFROM = new ItemPoseData(new Vector3(0f, 0f, 0.1f), Quaternion.identity, Vector3.one, HAND_ROT); HANDGUN_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0.2f), Quaternion.Euler(0f, 180f, 90f), Vector3.one, HAND_ROT); BOXED_FOOD_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(0f, 45f, 0f), Vector3.one, HAND_ROT); BEANS_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(0f, 225f, 0f), Vector3.one, HAND_ROT); FOOD_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 0f, 0f), Vector3.one, HAND_ROT); COCOA_TRANSFROM = new ItemPoseData(new Vector3(-0.2f, 0f, 0f), Quaternion.Euler(0f, 180f, 0f), Vector3.one, HAND_ROT); REBAR_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.3f, 0f), Quaternion.Euler(90f, 270f, 0f), Vector3.one, HAND_ROT); PITON_TRANSFROM = new ItemPoseData(Vector3.zero, Quaternion.Euler(270f, 180f, 0f), Vector3.one * 1.2f, HAND_ROT); BLINK_EYE_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(0f, 180f, 0f), Vector3.one, HAND_ROT); ROACH_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.1f, 0.1f), Quaternion.Euler(315f, 0f, 0f), Vector3.one, HAND_ROT); GRUB_TRANSFROM = new ItemPoseData(new Vector3(-0.1f, 0.1f, 0f), Quaternion.Euler(0f, 0f, 270f), Vector3.one, HAND_ROT); FLOPPY_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 0f, 0f), Vector3.one, HAND_ROT); NOTE_TRANSFROM = new ItemPoseData(new Vector3(0f, 0.3f, 0f), Quaternion.Euler(270f, 0f, 0f), Vector3.one, HAND_ROT); TintColorProperties = new string[3] { "_BaseColor", "_Color", "_MainColor" }; _handItemTransform = new Dictionary<string, ItemPoseData> { { "None", new ItemPoseData(new Vector3(0f, 0.4f, 0f), Quaternion.Euler(45f, 45f, 45f), Vector3.one, HAND_ROT) }, { "Item_Hammer", HAMMER_TRANSFROM }, { "Item_BanHammer", HAMMER_TRANSFROM }, { "Item_Pipewrench", HAMMER_TRANSFROM }, { "Item_Hammer_Cosmetic_Wrench", HAMMER_TRANSFROM }, { "Item_BarnacleHook", BARNACLE_HOOK_TRANSFROM }, { "Item_BarnacleHook_Infinite", BARNACLE_HOOK_TRANSFROM }, { "Item_Handgun", HANDGUN_TRANSFROM }, { "Item_Handgun_Debug", HANDGUN_TRANSFROM }, { "Item_10mm_Ammo", new ItemPoseData(new Vector3(0f, 0.3f, 0f), Quaternion.Euler(270f, 270f, 0f), Vector3.one, HAND_ROT) }, { "Item_Injector", new ItemPoseData(new Vector3(0f, -0.1f, 0f), Quaternion.Euler(270f, 90f, 0f), Vector3.one * 1.3f, HAND_ROT) }, { "Item_Pillbottle", new ItemPoseData(new Vector3(0f, 0.2f, 0f), Quaternion.Euler(270f, 0f, 0f), Vector3.one, HAND_ROT) }, { "Item_Food_Fruit", new ItemPoseData(new Vector3(0.2f, 0f, 0f), Quaternion.Euler(0f, 90f, 270f), Vector3.one, HAND_ROT) }, { "Item_Food_Meat", new ItemPoseData(Vector3.zero, Quaternion.Euler(0f, 90f, 270f), Vector3.one, HAND_ROT) }, { "Item_Wine", BOXED_FOOD_TRANSFROM }, { "Item_Wine_Empty", BOXED_FOOD_TRANSFROM }, { "Item_Milk", BOXED_FOOD_TRANSFROM }, { "Item_Milk_Empty", BOXED_FOOD_TRANSFROM }, { "Item_Milk_Rho", BOXED_FOOD_TRANSFROM }, { "Item_Beans", BEANS_TRANSFROM }, { "Item_Beans_Eaten", BEANS_TRANSFROM }, { "Item_Beans_Periphery", BEANS_TRANSFROM }, { "Item_Food_Bar", FOOD_TRANSFROM }, { "Item_Food_Cookie", FOOD_TRANSFROM }, { "Item_Cocoa_Full", COCOA_TRANSFROM }, { "Item_Cocoa_Empty", COCOA_TRANSFROM }, { "Item_Rebar_Explosive", REBAR_TRANSFROM }, { "Item_RebarRope", REBAR_TRANSFROM }, { "Item_RebarRope_Holiday", REBAR_TRANSFROM }, { "Item_Rebar", REBAR_TRANSFROM }, { "Item_Rebar_Holiday", REBAR_TRANSFROM }, { "Item_Rebar_Bone", REBAR_TRANSFROM }, { "Item_AutoPiton", new ItemPoseData(new Vector3(0f, 0f, 0.2f), Quaternion.Euler(0f, 180f, 0f), Vector3.one, HAND_ROT) }, { "Item_Piton", PITON_TRANSFROM }, { "Item_Piton_Holiday", PITON_TRANSFROM }, { "Item_Rubble",