using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Il2CppSLZ.Marrow; using LabFusion.Data.Serializables; using LabFusion.Entities; using LabFusion.Network; using LabFusion.Network.Serialization; using LabFusion.Player; using LabFusion.SDK.Modules; using MelonLoader; using Microsoft.CodeAnalysis; using SpiderLab.Behaviours; using SpiderLab.Data; using SpiderlabFusionSync; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(SpiderlabFusionMod), "SpiderLab Fusion Sync Compat", "2.3.2", "notnotnotswipez; Patch 6 compatibility rebuild", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: MelonAdditionalDependencies(new string[] { "LabFusion", "SpiderLab" })] [assembly: AssemblyFileVersion("2.3.2.0")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.3.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SpiderlabFusionSync { public sealed class RepWebShooter : IDisposable { private sealed class WebVisual { public Hand Hand; public WebLine Line; public Rigidbody Body; public Vector3 Point; public bool Active; public uint Generation; public Vector3 WorldPoint { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002b: 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) if (!((Object)Body == (Object)null)) { return ((Component)Body).transform.TransformPoint(Point); } return Point; } } } private static readonly Dictionary Managers = new Dictionary(); private readonly WebVisual _left; private readonly WebVisual _right; private readonly AudioSource _audioSource; private RepWebShooter(RigManager rigManager) { _left = CreateVisual(rigManager.physicsRig.leftHand); _right = CreateVisual(rigManager.physicsRig.rightHand); _audioSource = ((Component)((Rig)rigManager.physicsRig).m_pelvis).gameObject.AddComponent(); _audioSource.playOnAwake = false; _audioSource.minDistance = 0.5f; _audioSource.spatialBlend = 1f; } public static bool TryGet(byte playerId, out RepWebShooter shooter) { return Managers.TryGetValue(playerId, out shooter); } public static void AddOrReplace(byte playerId, RigManager rigManager) { if (Managers.Remove(playerId, out var value)) { value.Dispose(); } Managers[playerId] = new RepWebShooter(rigManager); } public static void UpdateAll() { List list = null; foreach (KeyValuePair manager in Managers) { if (!NetworkPlayerManager.HasPlayer(manager.Key)) { (list ?? (list = new List())).Add(manager.Key); } else { manager.Value.Update(); } } if (list == null) { return; } foreach (byte item in list) { Managers[item].Dispose(); Managers.Remove(item); } } public static void DisposeAll() { foreach (RepWebShooter value in Managers.Values) { value.Dispose(); } Managers.Clear(); } public uint BeginWeb(byte hand) { WebVisual webVisual = Select(hand); webVisual.Generation++; return webVisual.Generation; } public void MakeWeb(byte hand, Vector3 point, Rigidbody body, uint generation) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) WebVisual webVisual = Select(hand); if (webVisual.Generation == generation) { webVisual.Body = body; webVisual.Point = point; webVisual.Active = true; webVisual.Line.SetActive(true); webVisual.Line.UpdateLine(webVisual.Hand.palmPositionTransform.position, webVisual.WorldPoint); PlayAudio(Bundles.webLineAudioHigh, Bundles.webLineAudioLow); } } public void DestroyWeb(byte hand) { WebVisual webVisual = Select(hand); webVisual.Generation++; webVisual.Active = false; webVisual.Body = null; webVisual.Line.SetActive(false); } public void Dispose() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown DestroyVisual(_left); DestroyVisual(_right); if ((Object)_audioSource != (Object)null) { Object.Destroy((Object)_audioSource); } } private void Update() { UpdateVisual(_left); UpdateVisual(_right); } private static WebVisual CreateVisual(Hand hand) { WebLine val = Object.Instantiate(Bundles.webLinePrefab, ((Component)hand).transform).AddComponent(); val.SetActive(false); return new WebVisual { Hand = hand, Line = val }; } private static void UpdateVisual(WebVisual visual) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0040: 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) if (visual.Active && !((Object)visual.Hand == (Object)null) && !((Object)visual.Line == (Object)null)) { visual.Line.UpdateLine(visual.Hand.palmPositionTransform.position, visual.WorldPoint); } } private static void DestroyVisual(WebVisual visual) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (visual != null && (Object)visual.Line != (Object)null) { Object.Destroy((Object)((Component)visual.Line).gameObject); } } private WebVisual Select(byte hand) { if (hand != 2) { return _left; } return _right; } private void PlayAudio(AudioClip high, AudioClip low) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (!((Object)high == (Object)null) && !((Object)low == (Object)null)) { _audioSource.loop = false; _audioSource.PlayOneShot((Random.value > 0.5f) ? high : low, 0.5f); } } } public sealed class SpiderlabFusionMod : MelonMod { public override void OnInitializeMelon() { if (ModuleMessageManager.GetHandlerByType(typeof(SpiderWebMessage)) == null) { ModuleMessageManager.RegisterHandler(); } if (ModuleMessageManager.GetHandlerByType(typeof(SpiderPullMessage)) == null) { ModuleMessageManager.RegisterHandler(); } NetworkPlayer.OnNetworkRigCreated += OnNetworkRigCreated; WebShooter.WebCreated += OnLocalWebCreated; WebShooter.WebDestroyed += OnLocalWebDestroyed; WebShooter.TargetPulled += OnLocalTargetPulled; foreach (NetworkPlayer player in NetworkPlayer.Players) { if (player.HasRig) { OnNetworkRigCreated(player, player.RigRefs.RigManager); } } MelonLogger.Msg("SpiderLab Fusion Sync compatibility module initialized."); } public override void OnDeinitializeMelon() { NetworkPlayer.OnNetworkRigCreated -= OnNetworkRigCreated; WebShooter.WebCreated -= OnLocalWebCreated; WebShooter.WebDestroyed -= OnLocalWebDestroyed; WebShooter.TargetPulled -= OnLocalTargetPulled; RepWebShooter.DisposeAll(); } public override void OnUpdate() { RepWebShooter.UpdateAll(); } private static void OnNetworkRigCreated(NetworkPlayer player, RigManager rigManager) { if (player != null && !((Object)(object)rigManager == (Object)null) && !player.NetworkEntity.IsOwner) { RepWebShooter.AddOrReplace(player.PlayerID.SmallID, rigManager); } } private static void OnLocalWebCreated(WebShooter shooter, RaycastHit hit) { //IL_0022: 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) if (NetworkInfo.HasServer && !((Object)(object)((shooter != null) ? shooter.Hand : null) == (Object)null)) { MessageRelay.RelayModule(SpiderWebData.CreateWeb(shooter.Hand, hit), CommonMessageRoutes.ReliableToOtherClients); } } private static void OnLocalWebDestroyed(WebShooter shooter) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (NetworkInfo.HasServer && !((Object)(object)((shooter != null) ? shooter.Hand : null) == (Object)null)) { MessageRelay.RelayModule(SpiderWebData.CreateDestroy(shooter.Hand), CommonMessageRoutes.ReliableToOtherClients); } } private static void OnLocalTargetPulled(WebShooter shooter, Rigidbody body, Vector3 velocityChange) { //IL_0026: 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_0036: Unknown result type (might be due to invalid IL or missing references) if (NetworkInfo.HasServer && !((Object)(object)((shooter != null) ? shooter.Hand : null) == (Object)null) && !((Object)(object)body == (Object)null)) { MessageRelay.RelayModule(SpiderPullData.Create(body, Vector3.ClampMagnitude(velocityChange, 50f)), CommonMessageRoutes.ReliableToOtherClients); } } } public sealed class SpiderPullData : INetSerializable { public GameObjectReference Body = new GameObjectReference(); public Vector3 VelocityChange; public int? GetSize() { return null; } public void Serialize(INetSerializer serializer) { NetSerializerExtensions.SerializeValue(serializer, ref Body); NetSerializerUnityExtensions.SerializeValue(serializer, ref VelocityChange); } public static SpiderPullData Create(Rigidbody body, Vector3 velocityChange) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0023: 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) return new SpiderPullData { Body = new GameObjectReference(((Object)(object)body == (Object)null) ? null : ((Component)body).gameObject), VelocityChange = velocityChange }; } } public sealed class SpiderPullMessage : ModuleMessageHandler { protected override void OnHandleMessage(ReceivedMessage received) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!((ReceivedMessage)(ref received)).Sender.HasValue || ((ReceivedMessage)(ref received)).Sender.Value == PlayerIDManager.LocalSmallID || !NetworkPlayerManager.HasPlayer(((ReceivedMessage)(ref received)).Sender.Value)) { return; } SpiderPullData spiderPullData = ((ReceivedMessage)(ref received)).ReadData(); Vector3 velocityChange = Vector3.ClampMagnitude(spiderPullData.VelocityChange, 50f); spiderPullData.Body.HookGameObjectFound((Action)delegate(GameObject gameObject) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) Rigidbody val = (((Object)(object)gameObject == (Object)null) ? null : gameObject.GetComponent()); if ((Object)(object)val != (Object)null && !val.isKinematic) { val.AddForce(velocityChange, (ForceMode)2); } }); } } public sealed class SpiderWebData : INetSerializable { public bool IsDestroy; public byte Hand; public GameObjectReference Body = new GameObjectReference(); public Vector3 Position; public float Distance; public int? GetSize() { return null; } public void Serialize(INetSerializer serializer) { serializer.SerializeValue(ref IsDestroy); serializer.SerializeValue(ref Hand); NetSerializerExtensions.SerializeValue(serializer, ref Body); NetSerializerUnityExtensions.SerializeValue(serializer, ref Position); serializer.SerializeValue(ref Distance); } public static SpiderWebData CreateDestroy(Hand hand) { //IL_000e: 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_0025: Expected O, but got Unknown //IL_0026: 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) return new SpiderWebData { IsDestroy = true, Hand = (byte)hand.handedness, Body = new GameObjectReference((GameObject)null), Position = Vector3.zero, Distance = 0f }; } public static SpiderWebData CreateWeb(Hand hand, RaycastHit hit) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_003f: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) Rigidbody rigidbody = ((RaycastHit)(ref hit)).rigidbody; GameObject val = (((Object)rigidbody == (Object)null) ? null : ((Component)rigidbody).gameObject); Vector3 position = (((Object)(object)val == (Object)null) ? ((RaycastHit)(ref hit)).point : val.transform.InverseTransformPoint(((RaycastHit)(ref hit)).point)); return new SpiderWebData { IsDestroy = false, Hand = (byte)hand.handedness, Body = new GameObjectReference(val), Position = position, Distance = ((RaycastHit)(ref hit)).distance }; } } public sealed class SpiderWebMessage : ModuleMessageHandler { protected override void OnHandleMessage(ReceivedMessage received) { if (!((ReceivedMessage)(ref received)).Sender.HasValue || ((ReceivedMessage)(ref received)).Sender.Value == PlayerIDManager.LocalSmallID) { return; } byte value = ((ReceivedMessage)(ref received)).Sender.Value; if (!NetworkPlayerManager.HasPlayer(value) || !RepWebShooter.TryGet(value, out var shooter)) { return; } SpiderWebData data = ((ReceivedMessage)(ref received)).ReadData(); if (data.IsDestroy) { shooter.DestroyWeb(data.Hand); return; } uint generation = shooter.BeginWeb(data.Hand); data.Body.HookGameObjectFound((Action)delegate(GameObject gameObject) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) Rigidbody body = (((Object)(object)gameObject == (Object)null) ? null : gameObject.GetComponent()); shooter.MakeWeb(data.Hand, data.Position, body, generation); }); } } }