using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.VFX;
using LabFusion.Entities;
using LabFusion.Network;
using LabFusion.Player;
using LabFusion.Representation;
using LabFusion.SDK.Modules;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using Spiderman;
using Spiderman.Data;
using Spiderman.Fusion;
using Spiderman.MonoBehaviours;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Manager), "OGSpiderman", "1.0.0", "Lakatrazz (ported by trev)", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonOptionalDependencies(new string[] { "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("OGSpiderman")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OGSpiderman")]
[assembly: AssemblyTitle("OGSpiderman")]
[assembly: NeutralResourcesLanguage("en-US")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Spiderman
{
public class Manager : MelonMod
{
public static Action<Vector3, GameObject> OnWebShootLeft;
public static Action<Vector3, Vector3> OnWebUpdateLeft;
public static Action<Vector3, GameObject> OnWebReleaseLeft;
public static Action<Vector3, GameObject> OnWebShootRight;
public static Action<Vector3, Vector3> OnWebUpdateRight;
public static Action<Vector3, GameObject> OnWebReleaseRight;
public static AssetBundle spiderBundle;
public static GameObject webShooter_FX;
public static GameObject webRelease_FX;
public static GameObject webRenderer_FX;
public static GameObject webHint_FX;
private static bool _isFusion;
public override void OnInitializeMelon()
{
ClassInjector.RegisterTypeInIl2Cpp<WebShooter>();
LoadAssetBundles();
ModOptions.CreateUI();
Hooking.OnLevelLoaded += Hooking_OnLevelLoaded;
if (MelonBase.FindMelon("LabFusion", "Lakatrazz") != null)
{
_isFusion = true;
LoadModule();
}
}
public override void OnUpdate()
{
if (_isFusion)
{
ModuleUpdate();
}
}
private static void LoadModule()
{
ModuleManager.RegisterModule<SpidermanModule>();
}
private static void ModuleSceneLoad()
{
foreach (SpidermanInstance value in SpidermanModule.instances.Values)
{
value.OnSceneWasLoaded();
}
}
private static void ModuleUpdate()
{
if (SpidermanModule.prevRepCount == PlayerIdManager.PlayerCount)
{
return;
}
foreach (SpidermanInstance value in SpidermanModule.instances.Values)
{
value.OnDestroy();
}
SpidermanModule.instances.Clear();
foreach (PlayerId playerId in PlayerIdManager.PlayerIds)
{
SpidermanModule.instances.Add(playerId.LongId, new SpidermanInstance(playerId));
}
SpidermanModule.prevRepCount = PlayerIdManager.PlayerCount;
}
private void Hooking_OnLevelLoaded(LevelInfo obj)
{
ModOptions.Cleanup();
((Component)Player.LeftHand).gameObject.AddComponent<WebShooter>().isLeft = true;
((Component)Player.RightHand).gameObject.AddComponent<WebShooter>().isLeft = false;
ModOptions.ApplySettings();
if (_isFusion)
{
ModuleSceneLoad();
}
}
private static void LoadAssetBundles()
{
spiderBundle = EmbeddedAssetBundle.LoadFromAssembly(((MelonBase)Melon<Manager>.Instance).MelonAssembly.Assembly, "Spiderman.Resources.spiderfx.sres");
if ((Object)(object)spiderBundle == (Object)null)
{
throw new NullReferenceException("spiderBundle is null! Did you forget to compile the fx bundle into the dll?");
}
webShooter_FX = spiderBundle.LoadAsset<GameObject>("SpiderSFX_Shoot");
webRelease_FX = spiderBundle.LoadAsset<GameObject>("SpiderSFX_WebRelease");
webRenderer_FX = spiderBundle.LoadAsset<GameObject>("SpiderWeb_Renderer");
webHint_FX = spiderBundle.LoadAsset<GameObject>("SpiderHint");
((Object)webShooter_FX).hideFlags = (HideFlags)32;
((Object)webRelease_FX).hideFlags = (HideFlags)32;
((Object)webRenderer_FX).hideFlags = (HideFlags)32;
((Object)webHint_FX).hideFlags = (HideFlags)32;
spiderBundle.Unload(false);
}
}
public static class ModOptions
{
public enum WebControls
{
DoubleB,
DoubleGrip,
Gesture,
Touchpad
}
public const string categoryName = "Spiderman";
public static MelonPreferences_Category _PrefsCategory;
public static ModPref<WebControls> _Controls = new ModPref<WebControls>("Spiderman", "Binding", WebControls.DoubleB);
public static ModPref<bool> _WebSlinging = new ModPref<bool>("Spiderman", "Webs", defaultValue: true);
public static ModPref<bool> _PullyRopes = new ModPref<bool>("Spiderman", "Pully", defaultValue: true);
public static ModPref<float> _WebPullStrength = new ModPref<float>("Spiderman", "PullStrength", 1f);
public static ModPref<float> _ArmPullStrength = new ModPref<float>("Spiderman", "ArmStrength", 1f);
public static ModPref<bool> _WebHint = new ModPref<bool>("Spiderman", "Crosshair", defaultValue: true);
public static Action _OnSettingsApplied;
public static void Cleanup()
{
_OnSettingsApplied = null;
}
public static void CreateUI()
{
//IL_0014: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
InitializePrefs();
LoadPrefs();
Page obj = Page.Root.CreatePage("Spiderman", Color.red, 0, true);
obj.CreateEnum("Web Binding", Color.yellow, (Enum)(WebControls)_Controls, (Action<Enum>)delegate(Enum value)
{
_Controls.SetEntryValue((WebControls)(object)value);
_PrefsCategory.SaveToFile(true);
});
obj.CreateFunction("Web Hold: Gripping", Color.yellow, (Action)delegate
{
});
obj.CreateBool("Web Slinging", Color.white, (bool)_WebSlinging, (Action<bool>)delegate(bool value)
{
_WebSlinging.SetEntryValue(value);
_PrefsCategory.SaveToFile(true);
});
obj.CreateBool("Pully Webs", Color.white, (bool)_PullyRopes, (Action<bool>)delegate(bool value)
{
_PullyRopes.SetEntryValue(value);
_PrefsCategory.SaveToFile(true);
});
obj.CreateFloat("Web Pull Strength", Color.white, (float)_WebPullStrength, 0.5f, 0f, 10f, (Action<float>)delegate(float value)
{
_WebPullStrength.SetEntryValue(value);
_PrefsCategory.SaveToFile(true);
});
obj.CreateFloat("Arm Pull Strength", Color.white, (float)_ArmPullStrength, 0.5f, 1f, 10f, (Action<float>)delegate(float value)
{
_ArmPullStrength.SetEntryValue(value);
_PrefsCategory.SaveToFile(true);
});
obj.CreateBool("Web Crosshair", Color.white, (bool)_WebHint, (Action<bool>)delegate(bool value)
{
_WebHint.SetEntryValue(value);
_PrefsCategory.SaveToFile(true);
});
obj.CreateFunction("Apply Bite!", Color.red, (Action)ApplySettings);
}
public static void InitializePrefs()
{
_PrefsCategory = MelonPreferences.CreateCategory("Spiderman");
_Controls.CreateEntry(_PrefsCategory);
_WebSlinging.CreateEntry(_PrefsCategory);
_PullyRopes.CreateEntry(_PrefsCategory);
_WebPullStrength.CreateEntry(_PrefsCategory);
_ArmPullStrength.CreateEntry(_PrefsCategory);
_WebHint.CreateEntry(_PrefsCategory);
}
public static void LoadPrefs()
{
_Controls.LoadEntry();
_WebSlinging.LoadEntry();
_PullyRopes.LoadEntry();
_WebPullStrength.LoadEntry();
_ArmPullStrength.LoadEntry();
_WebHint.LoadEntry();
}
public static void ApplySettings()
{
try
{
_OnSettingsApplied?.Invoke();
}
catch
{
}
}
}
}
namespace Spiderman.MonoBehaviours
{
public class WebShooter : MonoBehaviour
{
public bool isLeft;
public Hand _Hand;
public BaseController _Controller;
public Transform _WebPos;
public Transform _WebHint;
public AudioSource _WebShootSource;
public AudioSource _WebReleaseSource;
public DrawLine2Points _LineRenderer;
public ConfigurableJoint _WebJoint;
public float _TimeSinceWeb = 1f;
public float _LowestLimit = float.PositiveInfinity;
public bool _WasGripping;
public Collider _WebbedCollider;
public const float _WaitTime = 0.4f;
public const float _WebCastRadius = 0.07f;
public bool _HintActive
{
get
{
if ((bool)ModOptions._WebSlinging && (bool)ModOptions._WebHint)
{
return !Object.op_Implicit((Object)(object)_Hand.AttachedReceiver);
}
return false;
}
}
public WebShooter(IntPtr intPtr)
: base(intPtr)
{
}
public void Start()
{
_Hand = ((Component)this).GetComponent<Hand>();
_Controller = _Hand.Controller;
_WebHint = Object.Instantiate<GameObject>(Manager.webHint_FX).transform;
_WebShootSource = Object.Instantiate<GameObject>(Manager.webShooter_FX, ((Component)this).transform, false).GetComponent<AudioSource>();
_WebReleaseSource = Object.Instantiate<GameObject>(Manager.webRelease_FX, ((Component)this).transform, false).GetComponent<AudioSource>();
_LineRenderer = Object.Instantiate<GameObject>(Manager.webRenderer_FX, ((Component)this).transform, false).AddComponent<DrawLine2Points>();
_LineRenderer.Point1 = ((Component)((Component)_LineRenderer).transform.Find("Origin")).gameObject;
_LineRenderer.Point2 = ((Component)((Component)_LineRenderer).transform.Find("Target")).gameObject;
_LineRenderer.Liner = ((Component)_LineRenderer).GetComponent<LineRenderer>();
((Component)_LineRenderer).gameObject.SetActive(false);
((Component)_WebHint).gameObject.SetActive(false);
}
public void Update()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0059: 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_0080: 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_0092: 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_0094: 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_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: 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_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
_WebHint.rotation = Quaternion.LookRotation(((Rig)Player.ControllerRig).m_head.forward);
if (Object.op_Implicit((Object)(object)_WebJoint))
{
Vector3 worldConnected = GetWorldConnected(_WebJoint);
Vector3 worldAnchor = GetWorldAnchor(_WebJoint);
_LineRenderer.Point1.transform.position = worldAnchor;
_LineRenderer.Point2.transform.position = worldConnected;
TriggerAction(Manager.OnWebUpdateLeft, Manager.OnWebUpdateRight, worldAnchor, worldConnected);
_LineRenderer.UpdateLines();
Vector3 val = worldConnected - worldAnchor;
float magnitude = ((Vector3)(ref val)).magnitude;
if (magnitude < _LowestLimit)
{
SetLinearLimit(_WebJoint, magnitude, 1f);
}
if (!GetGripped() || !Object.op_Implicit((Object)(object)_WebbedCollider) || !((Component)_WebbedCollider).gameObject.activeInHierarchy)
{
DestroyJoint();
}
}
else
{
if (!ModOptions._WebSlinging)
{
return;
}
Vector3 position = ((Component)_Hand.Skeleton).transform.position;
Vector3 forward = ((Component)this).transform.forward;
RaycastHit hitInfo = default(RaycastHit);
if (Physics.SphereCast(position, 0.07f, forward, ref hitInfo, 99999f, 200212023, (QueryTriggerInteraction)1))
{
((Component)_WebHint).transform.position = ((RaycastHit)(ref hitInfo)).point;
((Component)_WebHint).gameObject.SetActive(_HintActive);
if (CanWeb())
{
CreateJoint(hitInfo);
_WebbedCollider = ((RaycastHit)(ref hitInfo)).collider;
}
}
else
{
((Component)_WebHint).gameObject.SetActive(false);
}
}
}
public bool GetSpiderGesture()
{
float indexCurlAxis = _Controller.GetIndexCurlAxis();
float middleCurlAxis = _Controller.GetMiddleCurlAxis();
float ringCurlAxis = _Controller.GetRingCurlAxis();
float pinkyCurlAxis = _Controller.GetPinkyCurlAxis();
if (indexCurlAxis <= 0.2f && pinkyCurlAxis <= 0.2f && middleCurlAxis >= 0.6f)
{
return ringCurlAxis >= 0.6f;
}
return false;
}
public bool GetBButton()
{
return _Controller.GetBButtonDown();
}
public bool GetTouchpad()
{
return _Controller._touchPad;
}
public void TriggerAction<T>(Action<T> leftAction, Action<T> rightAction, T param)
{
if (isLeft)
{
leftAction?.Invoke(param);
}
else
{
rightAction?.Invoke(param);
}
}
public void TriggerAction<T, N>(Action<T, N> leftAction, Action<T, N> rightAction, T param1, N param2)
{
if (isLeft)
{
leftAction?.Invoke(param1, param2);
}
else
{
rightAction?.Invoke(param1, param2);
}
}
public bool GetSpiderInput()
{
switch (ModOptions._Controls.value)
{
case ModOptions.WebControls.DoubleGrip:
{
bool gripped = GetGripped();
bool result = gripped && !_WasGripping;
_WasGripping = gripped;
return result;
}
case ModOptions.WebControls.Gesture:
return GetSpiderGesture();
case ModOptions.WebControls.Touchpad:
return GetTouchpad();
default:
return GetBButton();
}
}
public bool GetGripped()
{
if (_Controller.GetGrabbedState())
{
return !Object.op_Implicit((Object)(object)_Hand.AttachedReceiver);
}
return false;
}
public bool CanWeb()
{
bool spiderInput = GetSpiderInput();
ModOptions.WebControls webControls = ModOptions._Controls;
if (webControls != 0 && webControls != ModOptions.WebControls.DoubleGrip)
{
if (spiderInput)
{
return GetGripped();
}
return false;
}
_TimeSinceWeb += Time.deltaTime;
if (spiderInput)
{
if (_TimeSinceWeb <= 0.4f)
{
_TimeSinceWeb = 1.4f;
return GetGripped();
}
_TimeSinceWeb = 0f;
}
return false;
}
public void CreateJoint(RaycastHit hitInfo)
{
//IL_0065: 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_019a: Unknown result type (might be due to invalid IL or missing references)
_WebJoint = ((Component)this).gameObject.AddComponent<ConfigurableJoint>();
Rigidbody val = ((!Object.op_Implicit((Object)(object)((RaycastHit)(ref hitInfo)).rigidbody) || ((RaycastHit)(ref hitInfo)).rigidbody.isKinematic) ? null : ((RaycastHit)(ref hitInfo)).rigidbody);
if (Object.op_Implicit((Object)(object)((RaycastHit)(ref hitInfo)).rigidbody))
{
((Joint)_WebJoint).connectedBody = ((RaycastHit)(ref hitInfo)).rigidbody;
}
SetWorldAnchor(_WebJoint, ((Component)this).transform.position);
SetWorldConnected(_WebJoint, ((RaycastHit)(ref hitInfo)).point);
SetLinearMotion(_WebJoint, (ConfigurableJointMotion)1);
SetLinearLimit(_WebJoint, ((RaycastHit)(ref hitInfo)).distance, 1f);
float num = (Object.op_Implicit((Object)(object)val) ? (Mathf.Max(1f, val.mass) * 10f) : 10f);
float num2 = (ModOptions._PullyRopes ? (500f * (float)ModOptions._WebPullStrength) : 1f);
SetSpringLimit(_WebJoint, 500000000f, 500000f * num * (float)ModOptions._WebPullStrength);
SetSpringDrive(_WebJoint, 50f * num2, 500f, 1000f);
((Joint)_WebJoint).enableCollision = true;
_WebShootSource.pitch = Random.Range(0.87f, 1.1f);
_WebShootSource.Play();
((Component)_LineRenderer).gameObject.SetActive(true);
((Component)_WebHint).gameObject.SetActive(false);
TriggerAction(Manager.OnWebShootLeft, Manager.OnWebShootRight, ((Component)_WebShootSource).transform.position, ((Component)((RaycastHit)(ref hitInfo)).collider).gameObject);
_LowestLimit = ((RaycastHit)(ref hitInfo)).distance;
}
public void DestroyJoint()
{
//IL_0022: 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)
if (Object.op_Implicit((Object)(object)_WebJoint))
{
((Component)_WebReleaseSource).transform.position = GetWorldConnected(_WebJoint);
_WebReleaseSource.pitch = Random.Range(0.87f, 1.1f);
_WebReleaseSource.Play();
((Component)_LineRenderer).gameObject.SetActive(false);
TriggerAction(Manager.OnWebReleaseLeft, Manager.OnWebReleaseRight, ((Component)_WebReleaseSource).transform.position, Object.op_Implicit((Object)(object)_WebbedCollider) ? ((Component)_WebbedCollider).gameObject : null);
Object.Destroy((Object)(object)_WebJoint);
}
}
public void SetSpringDrive(ConfigurableJoint joint, float spring, float damper, float max)
{
//IL_0002: 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_0029: 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)
JointDrive val = default(JointDrive);
((JointDrive)(ref val)).positionSpring = spring;
((JointDrive)(ref val)).positionDamper = damper;
((JointDrive)(ref val)).maximumForce = max;
joint.xDrive = val;
joint.yDrive = val;
joint.zDrive = val;
}
public void SetSpringLimit(ConfigurableJoint joint, float spring, float damper)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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)
SoftJointLimitSpring linearLimitSpring = joint.linearLimitSpring;
((SoftJointLimitSpring)(ref linearLimitSpring)).spring = spring;
((SoftJointLimitSpring)(ref linearLimitSpring)).damper = damper;
joint.linearLimitSpring = linearLimitSpring;
}
public void SetLinearLimit(ConfigurableJoint joint, float limit, float bounce)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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)
SoftJointLimit linearLimit = joint.linearLimit;
((SoftJointLimit)(ref linearLimit)).limit = limit;
((SoftJointLimit)(ref linearLimit)).bounciness = bounce;
joint.linearLimit = linearLimit;
if (limit < _LowestLimit)
{
_LowestLimit = limit;
}
}
public void SetLinearMotion(ConfigurableJoint joint, ConfigurableJointMotion motion)
{
//IL_0001: 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_000f: Unknown result type (might be due to invalid IL or missing references)
joint.xMotion = motion;
joint.yMotion = motion;
joint.zMotion = motion;
}
public void SetWorldAnchor(ConfigurableJoint joint, Vector3 anchor)
{
//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)
((Joint)joint).anchor = ((Component)joint).transform.InverseTransformPoint(anchor);
}
public void SetWorldConnected(ConfigurableJoint joint, Vector3 anchor)
{
//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)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
((Joint)joint).autoConfigureConnectedAnchor = false;
((Joint)joint).connectedAnchor = (Object.op_Implicit((Object)(object)((Joint)joint).connectedBody) ? ((Component)((Joint)joint).connectedBody).transform.InverseTransformPoint(anchor) : anchor);
}
public Vector3 GetWorldAnchor(ConfigurableJoint joint)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return ((Component)joint).transform.TransformPoint(((Joint)joint).anchor);
}
public Vector3 GetWorldConnected(ConfigurableJoint joint)
{
//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_000e: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)((Joint)joint).connectedBody))
{
return ((Joint)joint).connectedAnchor;
}
return ((Component)((Joint)joint).connectedBody).transform.TransformPoint(((Joint)joint).connectedAnchor);
}
}
}
namespace Spiderman.Fusion
{
public class SpidermanMessage : ModuleMessageHandler
{
public byte mode;
public ulong userId;
public byte instanceId;
public Vector3 point1;
public Vector3 point2;
public override void HandleMessage(byte[] bytes, bool isServerHandled = false)
{
//IL_003f: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
if (bytes.Length == 0)
{
throw new IndexOutOfRangeException();
}
if (!Player.HandsExist)
{
return;
}
FusionReader val = FusionReader.Create(bytes);
try
{
mode = val.ReadByte();
userId = val.ReadUInt64();
instanceId = val.ReadByte();
point1 = val.ReadVector3();
point2 = Vector3.zero;
if (mode == 2)
{
point2 = val.ReadVector3();
}
if (SpidermanModule.instances.ContainsKey(userId))
{
SpidermanInstance spidermanInstance = SpidermanModule.instances[userId];
switch (mode)
{
default:
spidermanInstance.webs[instanceId].OnWebReceived(point1);
break;
case 1:
spidermanInstance.webs[instanceId].OnWebReleased(point1);
break;
case 2:
spidermanInstance.webs[instanceId].OnWebUpdate(point1, point2);
break;
}
}
if (isServerHandled)
{
MessageSender.BroadcastMessageExceptSelf((NetworkChannel)0, FusionMessage.ModuleCreate<SpidermanMessage>(bytes));
}
}
finally
{
((IDisposable)val)?.Dispose();
}
}
}
public class SpidermanInstance
{
public WebInstance[] webs = new WebInstance[2];
public SpidermanInstance(PlayerId rep)
{
webs = new WebInstance[2];
webs[0] = new WebInstance(rep, isLeft: true);
webs[1] = new WebInstance(rep, isLeft: false);
}
public void OnDestroy()
{
webs[0].OnDestroy();
webs[1].OnDestroy();
}
public void OnSceneWasLoaded()
{
webs[0].OnSceneWasLoaded();
webs[1].OnSceneWasLoaded();
}
}
public class SpidermanModule : Module
{
public static Dictionary<ulong, SpidermanInstance> instances = new Dictionary<ulong, SpidermanInstance>();
public static long prevRepCount = 0L;
public override string Name => "OGSpiderman Module";
public override string Author => "Lakatrazz (ported by trev)";
public override Version Version => new Version(1, 0, 0);
public override ConsoleColor Color => ConsoleColor.Red;
protected override void OnModuleRegistered()
{
((Module)this).LoggerInstance.Log("Loading Spiderman Sync Handlers!", ConsoleColor.White);
ModuleMessageHandler.RegisterHandler<SpidermanMessage>();
Manager.OnWebShootLeft = (Action<Vector3, GameObject>)Delegate.Combine(Manager.OnWebShootLeft, (Action<Vector3, GameObject>)delegate(Vector3 v, GameObject g)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
OnWebShoot(v, g, 0);
});
Manager.OnWebReleaseLeft = (Action<Vector3, GameObject>)Delegate.Combine(Manager.OnWebReleaseLeft, (Action<Vector3, GameObject>)delegate(Vector3 v, GameObject g)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
OnWebRelease(v, g, 0);
});
Manager.OnWebUpdateLeft = (Action<Vector3, Vector3>)Delegate.Combine(Manager.OnWebUpdateLeft, (Action<Vector3, Vector3>)delegate(Vector3 v1, Vector3 v2)
{
//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)
OnWebUpdate(v1, v2, 0);
});
Manager.OnWebShootRight = (Action<Vector3, GameObject>)Delegate.Combine(Manager.OnWebShootRight, (Action<Vector3, GameObject>)delegate(Vector3 v, GameObject g)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
OnWebShoot(v, g, 1);
});
Manager.OnWebReleaseRight = (Action<Vector3, GameObject>)Delegate.Combine(Manager.OnWebReleaseRight, (Action<Vector3, GameObject>)delegate(Vector3 v, GameObject g)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
OnWebRelease(v, g, 1);
});
Manager.OnWebUpdateRight = (Action<Vector3, Vector3>)Delegate.Combine(Manager.OnWebUpdateRight, (Action<Vector3, Vector3>)delegate(Vector3 v1, Vector3 v2)
{
//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)
OnWebUpdate(v1, v2, 1);
});
}
public void OnWebShoot(Vector3 point, GameObject hit, byte instanceId)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (LocalPlayer.GetNetworkPlayer() == null)
{
return;
}
FusionWriter val = FusionWriter.Create();
try
{
val.Write(0);
val.Write(PlayerIdManager.LocalId.LongId);
val.Write(instanceId);
val.Write(point);
FusionMessage val2 = FusionMessage.ModuleCreate<SpidermanMessage>(val);
try
{
MessageSender.SendToServer((NetworkChannel)0, val2);
}
finally
{
((IDisposable)val2)?.Dispose();
}
}
finally
{
((IDisposable)val)?.Dispose();
}
}
public void OnWebRelease(Vector3 point, GameObject hit, byte instanceId)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (LocalPlayer.GetNetworkPlayer() == null)
{
return;
}
FusionWriter val = FusionWriter.Create();
try
{
val.Write(1);
val.Write(PlayerIdManager.LocalId.LongId);
val.Write(instanceId);
val.Write(point);
FusionMessage val2 = FusionMessage.ModuleCreate<SpidermanMessage>(val);
try
{
MessageSender.SendToServer((NetworkChannel)0, val2);
}
finally
{
((IDisposable)val2)?.Dispose();
}
}
finally
{
((IDisposable)val)?.Dispose();
}
}
public void OnWebUpdate(Vector3 point1, Vector3 point2, byte instanceId)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (LocalPlayer.GetNetworkPlayer() == null)
{
return;
}
FusionWriter val = FusionWriter.Create();
try
{
val.Write(2);
val.Write(PlayerIdManager.LocalId.LongId);
val.Write(instanceId);
val.Write(point1);
val.Write(point2);
FusionMessage val2 = FusionMessage.ModuleCreate<SpidermanMessage>(val);
try
{
MessageSender.SendToServer((NetworkChannel)0, val2);
}
finally
{
((IDisposable)val2)?.Dispose();
}
}
finally
{
((IDisposable)val)?.Dispose();
}
}
}
public class WebInstance
{
public PlayerId rep;
public bool isLeft;
public AudioSource _WebShootSource;
public AudioSource _WebReleaseSource;
public DrawLine2Points _LineRenderer;
public WebInstance(PlayerId rep, bool isLeft)
{
this.rep = rep;
this.isLeft = isLeft;
if (Player.HandsExist)
{
OnSceneWasLoaded();
}
}
public void OnSceneWasLoaded()
{
RigRefs val = default(RigRefs);
if (rep != null && PlayerRepUtilities.TryGetReferences(rep.SmallId, ref val) && (Object)(object)val.Head != (Object)null)
{
_WebShootSource = Object.Instantiate<GameObject>(Manager.webShooter_FX, ((Component)val.Head).transform, false).GetComponent<AudioSource>();
_WebReleaseSource = Object.Instantiate<GameObject>(Manager.webRelease_FX, ((Component)val.Head).transform, false).GetComponent<AudioSource>();
_LineRenderer = Object.Instantiate<GameObject>(Manager.webRenderer_FX, ((Component)val.Head).transform, false).AddComponent<DrawLine2Points>();
((Component)_LineRenderer).gameObject.SetActive(false);
}
}
public void OnWebReceived(Vector3 point)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)_LineRenderer) && Object.op_Implicit((Object)(object)_WebShootSource))
{
((Component)_WebShootSource).transform.position = point;
_WebShootSource.pitch = Random.Range(0.87f, 1.1f);
_WebShootSource.Play();
((Component)_LineRenderer).gameObject.SetActive(true);
}
}
public void OnWebReleased(Vector3 point)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)_LineRenderer) && Object.op_Implicit((Object)(object)_WebReleaseSource))
{
((Component)_WebReleaseSource).transform.position = point;
_WebReleaseSource.pitch = Random.Range(0.87f, 1.1f);
_WebReleaseSource.Play();
((Component)_LineRenderer).gameObject.SetActive(false);
}
}
public void OnWebUpdate(Vector3 start, Vector3 end)
{
//IL_001d: 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)
if (Object.op_Implicit((Object)(object)_LineRenderer))
{
_LineRenderer.Point1.transform.position = start;
_LineRenderer.Point2.transform.position = end;
_LineRenderer.UpdateLines();
}
}
public void OnDestroy()
{
if (Object.op_Implicit((Object)(object)_WebShootSource))
{
Object.Destroy((Object)(object)_WebShootSource);
}
if (Object.op_Implicit((Object)(object)_WebReleaseSource))
{
Object.Destroy((Object)(object)_WebReleaseSource);
}
if (Object.op_Implicit((Object)(object)_LineRenderer))
{
Object.Destroy((Object)(object)_LineRenderer);
}
}
}
}
namespace Spiderman.Data
{
public static class EmbeddedAssetBundle
{
public static AssetBundle LoadFromAssembly(Assembly assembly, string name)
{
name = ((!HelperMethods.IsAndroid()) ? (name + ".pc") : (name + ".android"));
if (assembly.GetManifestResourceNames().Contains(name))
{
MelonLogger.Msg(ConsoleColor.DarkCyan, "Loading embedded bundle " + name + "...");
byte[] array;
using (Stream stream = assembly.GetManifestResourceStream(name))
{
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
array = memoryStream.ToArray();
}
MelonLogger.Msg(ConsoleColor.DarkCyan, "Done!");
return AssetBundle.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(array));
}
return null;
}
}
public class ModPref<T>
{
private string categoryName { get; set; }
private string entryName { get; set; }
private MelonPreferences_Category parentCategory { get; set; }
private MelonPreferences_Entry<T> entry { get; set; }
public T value { get; private set; }
public T defaultValue { get; }
public ModPref(string categoryName, string entryName, T defaultValue = default(T))
{
this.categoryName = categoryName;
this.entryName = entryName;
value = defaultValue;
this.defaultValue = defaultValue;
}
public static implicit operator T(ModPref<T> pref)
{
return pref.value;
}
public void CreateEntry()
{
parentCategory = MelonPreferences.GetCategory(categoryName);
CreateEntry(parentCategory);
}
public void CreateEntry(MelonPreferences_Category parentCategory)
{
entry = parentCategory.CreateEntry<T>(entryName, value, (string)null, (string)null, false, false, (ValueValidator)null);
}
public void LoadEntry()
{
value = MelonPreferences.GetEntryValue<T>(categoryName, entryName);
}
public void SetEntryValue(T value)
{
if (value != null)
{
this.value = value;
MelonPreferences.SetEntryValue<T>(categoryName, entryName, value);
((MelonPreferences_Entry)entry).Save();
}
}
public void SaveEntryValue()
{
SetEntryValue(value);
}
public void ResetEntryValue()
{
SetEntryValue(defaultValue);
}
public void ModifyEntryValue(Action action)
{
action?.Invoke();
SaveEntryValue();
}
}
}