Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Web Swing v1.0.0
WebSwing.dll
Decompiled 3 months agousing 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 BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c574138cfea486cfa7104eae1a6f135c166daf8b")] [assembly: AssemblyProduct("WebSwing")] [assembly: AssemblyTitle("WebSwing")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 SpiderHookMod { [BepInPlugin("com.empress.spiderhook", "Web Swing", "1.3.0")] public class SpiderHookMod : BaseUnityPlugin, IOnEventCallback { private class RemoteGrappleData { public GameObject visualObj; public LineRenderer line; public Vector3 targetPoint; public PlayerAvatar avatar; } public const byte GrappleStartEvent = 120; public const byte GrappleEndEvent = 121; private ConfigEntry<float> configGrappleSpeed; private ConfigEntry<KeyCode> configKey; private ConfigEntry<float> configColorR; private ConfigEntry<float> configColorG; private ConfigEntry<float> configColorB; private float maxDistance = 40f; private float stopDistance = 1.5f; private bool isGrappling = false; private Vector3 localGrapplePoint; private GameObject localHookObj; private LineRenderer localLine; private PlayerAvatar localPlayer; private PlayerController localController; private bool callbacksRegistered = false; private Dictionary<int, RemoteGrappleData> remoteGrapples = new Dictionary<int, RemoteGrappleData>(); private void Awake() { configKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Web Swing Settings", "WebSwingKey", (KeyCode)118, "Key to use the Web Swing"); configGrappleSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Web Swing Settings", "WebSwingSpeed", 35f, "How fast the Web Swing pulls you"); configColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "ColorR", 0f, "Red amount (0-1)"); configColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "ColorG", 1f, "Green amount (0-1)"); configColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "ColorB", 1f, "Blue amount (0-1)"); } private void OnDisable() { if (callbacksRegistered) { PhotonNetwork.RemoveCallbackTarget((object)this); callbacksRegistered = false; } } private bool IsGameReady() { if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { return false; } if (SemiFunc.MenuLevel()) { return false; } if (!SemiFunc.LevelGenDone()) { return false; } if ((Object)(object)SemiFunc.PlayerAvatarLocal() == (Object)null) { return false; } return true; } private void Update() { if (IsGameReady()) { if (!callbacksRegistered) { PhotonNetwork.AddCallbackTarget((object)this); callbacksRegistered = true; } HandleLocalPlayer(); UpdateRemoteVisuals(); } else if (callbacksRegistered) { PhotonNetwork.RemoveCallbackTarget((object)this); callbacksRegistered = false; remoteGrapples.Clear(); } } private void HandleLocalPlayer() { //IL_005a: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)localPlayer == (Object)null) { localPlayer = SemiFunc.PlayerAvatarLocal(); if ((Object)(object)localPlayer != (Object)null) { localController = PlayerController.instance; } return; } if ((Object)(object)localLine == (Object)null) { CreateLocalVisuals(); } if (Input.GetKeyDown(configKey.Value) && TryStartLocalGrapple()) { SendGrappleEvent(120, localGrapplePoint); } if (Input.GetKey(configKey.Value) && isGrappling) { ApplyLocalPhysics(); UpdateLocalVisuals(); } if (Input.GetKeyUp(configKey.Value) && isGrappling) { StopLocalGrapple(); SendGrappleEvent(121, Vector3.zero); } } private void CreateLocalVisuals() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)localHookObj != (Object)null) { Object.Destroy((Object)(object)localHookObj); } localHookObj = new GameObject("SpiderHookLocal"); localHookObj.transform.parent = null; ((Object)localHookObj).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)localHookObj); localLine = localHookObj.AddComponent<LineRenderer>(); Color col = default(Color); ((Color)(ref col))..ctor(configColorR.Value, configColorG.Value, configColorB.Value); SetupLineRenderer(localLine, col); ((Renderer)localLine).enabled = false; } private bool TryStartLocalGrapple() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Camera.main == (Object)null) { return false; } RaycastHit val = default(RaycastHit); if (Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref val, maxDistance, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()))) { isGrappling = true; localGrapplePoint = ((RaycastHit)(ref val)).point; ((Renderer)localLine).enabled = true; Color val2 = default(Color); ((Color)(ref val2))..ctor(configColorR.Value, configColorG.Value, configColorB.Value); SetupLineRenderer(localLine, val2); SemiFunc.UIFocusText("WEB SWING!", val2, Color.white, 0.5f); if ((Object)(object)AssetManager.instance != (Object)null) { AssetManager.instance.PhysImpactEffect(localGrapplePoint); } return true; } return false; } private void ApplyLocalPhysics() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0076: 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) //IL_0087: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)localController == (Object)null) && !((Object)(object)localController.rb == (Object)null)) { float num = Vector3.Distance(((Component)localPlayer).transform.position, localGrapplePoint); if (!(num < stopDistance)) { Vector3 val = localGrapplePoint - ((Component)localPlayer).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; localController.rb.AddForce(normalized * configGrappleSpeed.Value, (ForceMode)5); localController.rb.AddForce(Vector3.up * 15f, (ForceMode)5); localController.CollisionGrounded.Grounded = false; } } } private void UpdateLocalVisuals() { //IL_0030: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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) if (!((Object)(object)localLine == (Object)null) && !((Object)(object)Camera.main == (Object)null)) { Vector3 val = ((Component)Camera.main).transform.position + ((Component)Camera.main).transform.right * 0.3f - Vector3.up * 0.2f; localLine.SetPosition(0, val); localLine.SetPosition(1, localGrapplePoint); ((Renderer)localLine).material.mainTextureOffset = new Vector2((0f - Time.time) * 5f, 0f); } } private void StopLocalGrapple() { isGrappling = false; if ((Object)(object)localLine != (Object)null) { ((Renderer)localLine).enabled = false; } } private void SendGrappleEvent(byte eventCode, Vector3 pos) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (PhotonNetwork.IsConnected) { object[] array = ((eventCode != 120) ? new object[1] { localPlayer.photonView.ViewID } : new object[5] { localPlayer.photonView.ViewID, pos, configColorR.Value, configColorG.Value, configColorB.Value }); RaiseEventOptions val = new RaiseEventOptions { Receivers = (ReceiverGroup)0 }; PhotonNetwork.RaiseEvent(eventCode, (object)array, val, SendOptions.SendReliable); } } public void OnEvent(EventData photonEvent) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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 (photonEvent.Code == 120) { object[] array = (object[])photonEvent.CustomData; int viewID = (int)array[0]; Vector3 target = (Vector3)array[1]; float num = (float)array[2]; float num2 = (float)array[3]; float num3 = (float)array[4]; Color color = default(Color); ((Color)(ref color))..ctor(num, num2, num3); StartRemoteGrapple(viewID, target, color); } else if (photonEvent.Code == 121) { object[] array2 = (object[])photonEvent.CustomData; int viewID2 = (int)array2[0]; StopRemoteGrapple(viewID2); } } private void StartRemoteGrapple(int viewID, Vector3 target, Color color) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_006a: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) StopRemoteGrapple(viewID); PhotonView val = PhotonView.Find(viewID); if ((Object)(object)val == (Object)null) { return; } PlayerAvatar component = ((Component)val).GetComponent<PlayerAvatar>(); if (!((Object)(object)component == (Object)null)) { GameObject val2 = new GameObject($"SpiderHook_Remote_{viewID}"); ((Object)val2).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val2); LineRenderer val3 = val2.AddComponent<LineRenderer>(); SetupLineRenderer(val3, color); ((Renderer)val3).enabled = true; RemoteGrappleData value = new RemoteGrappleData { visualObj = val2, line = val3, targetPoint = target, avatar = component }; remoteGrapples[viewID] = value; if ((Object)(object)AssetManager.instance != (Object)null) { AssetManager.instance.PhysImpactEffect(target); } } } private void StopRemoteGrapple(int viewID) { if (remoteGrapples.ContainsKey(viewID)) { if ((Object)(object)remoteGrapples[viewID].visualObj != (Object)null) { Object.Destroy((Object)(object)remoteGrapples[viewID].visualObj); } remoteGrapples.Remove(viewID); } } private void UpdateRemoteVisuals() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00ad: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) List<int> list = new List<int>(); foreach (KeyValuePair<int, RemoteGrappleData> remoteGrapple in remoteGrapples) { RemoteGrappleData value = remoteGrapple.Value; if ((Object)(object)value.avatar == (Object)null || (Object)(object)value.line == (Object)null) { list.Add(remoteGrapple.Key); continue; } Vector3 position = value.avatar.PlayerVisionTarget.VisionTransform.position; position += ((Component)value.avatar).transform.right * 0.3f - Vector3.up * 0.4f; value.line.SetPosition(0, position); value.line.SetPosition(1, value.targetPoint); ((Renderer)value.line).material.mainTextureOffset = new Vector2((0f - Time.time) * 5f, 0f); } foreach (int item in list) { StopRemoteGrapple(item); } } private void SetupLineRenderer(LineRenderer line, Color col) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0018: 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_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_0037: Unknown result type (might be due to invalid IL or missing references) ((Renderer)line).material = new Material(Shader.Find("Sprites/Default")); line.startColor = col; line.endColor = new Color(col.r, col.g, col.b, 0f); line.startWidth = 0.1f; line.endWidth = 0.05f; line.positionCount = 2; } } }