using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BamPlush;
using FieldInjector;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::BamPlush.BamPlush), "BamPlush", "1.0.0", "MrBugo", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BamPlush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BamPlush")]
[assembly: AssemblyTitle("BamPlush")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace BamPlush
{
public class BamPlushController : MonoBehaviour
{
public Transform handPoint;
public InteractableHost plushHost;
private Action<InteractableHost, Hand> onAttachedDelegate;
private Hand[] attachedHands;
private Transform gunPositioner;
private Gun? _gun;
private ConfigurableJoint? _joint;
public void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
onAttachedDelegate = Action<InteractableHost, Hand>.op_Implicit((Action<InteractableHost, Hand>)OnSlottedGunAttach);
gunPositioner = new GameObject("gunPositioner").transform;
gunPositioner.SetParent(handPoint);
}
public void FireSemi()
{
if (!((Object)(object)_gun == (Object)null))
{
_gun.Fire();
_gun.CeaseFire();
}
}
public void OnTriggerEnter(Collider col)
{
Gun componentInParent = ((Component)col).GetComponentInParent<Gun>();
if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)_gun)
{
SlotGun(componentInParent);
}
}
private void SlotGun(Gun gun)
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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 (!((Object)(object)_gun != (Object)null))
{
_gun = gun;
MarrowBody anchorBody = _gun.entity.AnchorBody;
anchorBody._rigidbody.isKinematic = true;
InteractableHost val = default(InteractableHost);
if (((Component)anchorBody).TryGetComponent<InteractableHost>(ref val))
{
val.ForceDetach(false);
InteractableHost obj = val;
obj.onHandAttachedDelegate += onAttachedDelegate;
}
Transform transform = ((Component)_gun.triggerGrip).transform;
gunPositioner.position = transform.position;
gunPositioner.rotation = transform.rotation;
((Component)_gun).transform.SetParent(gunPositioner);
gunPositioner.SetParent(handPoint);
gunPositioner.localPosition = Vector3.zero;
gunPositioner.localRotation = Quaternion.identity;
_joint = ((Component)_gun).gameObject.AddComponent<ConfigurableJoint>();
((Joint)_joint).connectedBody = plushHost.Rb;
LockJoint(_joint);
anchorBody._rigidbody.isKinematic = false;
}
}
private void UnslotGun()
{
if (!((Object)(object)_gun == (Object)null))
{
MarrowBody anchorBody = _gun.entity.AnchorBody;
InteractableHost val = default(InteractableHost);
if (((Component)anchorBody).TryGetComponent<InteractableHost>(ref val))
{
val.EnableInteraction();
InteractableHost obj = val;
obj.onHandAttachedDelegate -= onAttachedDelegate;
}
((Component)_gun).transform.SetParent((Transform)null);
Object.Destroy((Object)(object)_joint);
MonoBehaviour.InvokeDelayed((MonoBehaviour)(object)this, "RemoveGun", 1f, 0f);
}
}
private void RemoveGun()
{
if ((Object)(object)_gun != (Object)null)
{
_gun = null;
}
}
private void Update()
{
//IL_002e: 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_0034: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Invalid comparison between Unknown and I4
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Invalid comparison between Unknown and I4
if ((Object)(object)plushHost == (Object)null || (Object)(object)_gun == (Object)null)
{
return;
}
FireMode fireMode = _gun.fireMode;
FireMode val = fireMode;
if ((int)val != 1)
{
if ((int)val != 2)
{
return;
}
Enumerator<Hand> enumerator = plushHost._hands.GetEnumerator();
while (enumerator.MoveNext())
{
Hand current = enumerator.Current;
if (current._indexButton)
{
_gun.Fire();
}
}
return;
}
Enumerator<Hand> enumerator2 = plushHost._hands.GetEnumerator();
while (enumerator2.MoveNext())
{
Hand current2 = enumerator2.Current;
if (current2._indexButtonDown)
{
FireSemi();
}
}
}
private void OnSlottedGunAttach(InteractableHost host, Hand hand)
{
UnslotGun();
}
private void LockJoint(ConfigurableJoint joint)
{
joint.angularXMotion = (ConfigurableJointMotion)0;
joint.angularYMotion = (ConfigurableJointMotion)0;
joint.angularZMotion = (ConfigurableJointMotion)0;
joint.xMotion = (ConfigurableJointMotion)0;
joint.yMotion = (ConfigurableJointMotion)0;
joint.zMotion = (ConfigurableJointMotion)0;
}
public BamPlushController(IntPtr ptr)
: base(ptr)
{
}
}
public static class BuildInfo
{
public const string Name = "BamPlush";
public const string Author = "MrBugo";
public const string Company = null;
public const string Version = "1.0.0";
public const string DownloadLink = null;
}
public class BamPlush : MelonMod
{
public override void OnInitializeMelon()
{
SerialisationHandler.Inject<BamPlushController>(0);
}
}
}