using System;
using System.Collections.Generic;
using System.Diagnostics;
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 DualAction;
using DualAction.Fusion;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSystem;
using LabFusion.Entities;
using LabFusion.Network;
using LabFusion.Player;
using LabFusion.SDK.Modules;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "DualAction", "1.3.5", "Zer0Bytes", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonOptionalDependencies(new string[] { "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DualAction")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DualAction")]
[assembly: AssemblyTitle("DualAction")]
[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 DualAction
{
public class Belt
{
private static Dictionary<Hand, float> m_Timeouts = new Dictionary<Hand, float>();
private static float m_TimeoutDuration = 1.2f;
public static void OnBeltAwake(RigManager __instance)
{
if (Logic.m_BeltReload || !((Object)(object)__instance == (Object)(object)Logic.GetRigManager()))
{
SecondBelt_Reload(__instance);
}
}
public static void OnBeltUpdate(RigManager __instance)
{
if (!Logic.m_BeltReload && (Object)(object)__instance == (Object)(object)Logic.GetRigManager())
{
return;
}
Il2CppArrayBase<InventoryAmmoReceiver> componentsInChildren = ((Component)__instance).GetComponentsInChildren<InventoryAmmoReceiver>();
if (componentsInChildren.Length < 2)
{
return;
}
SecondBelt_Update(__instance);
PhysicsRig physicsRig = __instance.physicsRig;
if ((Object)(object)physicsRig == (Object)null || (Object)(object)physicsRig.leftHand == (Object)null || (Object)(object)physicsRig.rightHand == (Object)null)
{
return;
}
GameObject objectInHand = Player.GetObjectInHand(physicsRig.leftHand);
GameObject objectInHand2 = Player.GetObjectInHand(physicsRig.rightHand);
if ((Object)(object)objectInHand == (Object)null && (Object)(object)objectInHand2 == (Object)null)
{
return;
}
Gun val = ((objectInHand != null) ? objectInHand.GetComponentInParent<Gun>() : null);
Gun val2 = ((objectInHand2 != null) ? objectInHand2.GetComponentInParent<Gun>() : null);
if ((Object)(object)val == (Object)(object)val2)
{
return;
}
bool num = (Object)(object)objectInHand2 != (Object)null && (Object)(object)val != (Object)null && (Object)(object)objectInHand2.GetComponentInParent<Magazine>() == (Object)null;
bool flag = (Object)(object)objectInHand != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)objectInHand.GetComponentInParent<Magazine>() == (Object)null;
InventoryAmmoReceiver assignedBelt = null;
if (num)
{
InventoryAmmoReceiver val3 = GetClosestBelt(physicsRig.leftHand, Il2CppArrayBase<InventoryAmmoReceiver>.op_Implicit(componentsInChildren), null);
if ((Object)(object)val3 != (Object)null)
{
assignedBelt = val3;
HandleHand(physicsRig.leftHand, val, val3);
}
}
if (flag)
{
InventoryAmmoReceiver val4 = GetClosestBelt(physicsRig.rightHand, Il2CppArrayBase<InventoryAmmoReceiver>.op_Implicit(componentsInChildren), assignedBelt);
if ((Object)(object)val4 != (Object)null)
{
HandleHand(physicsRig.rightHand, val2, val4);
}
}
static InventoryAmmoReceiver GetClosestBelt(Hand hand, InventoryAmmoReceiver[] belts, InventoryAmmoReceiver AssignedBelt)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
InventoryAmmoReceiver result = null;
float num2 = float.MaxValue;
foreach (InventoryAmmoReceiver val5 in belts)
{
if (!((Object)(object)AssignedBelt != (Object)null) || !((Object)(object)AssignedBelt == (Object)(object)val5))
{
float num3 = Vector3.Distance(((Component)hand).transform.position, ((Component)val5).transform.position);
if (num3 < num2)
{
num2 = num3;
result = val5;
}
}
}
return result;
}
}
public static void SecondBelt_Reload(RigManager __instance)
{
m_Timeouts.Clear();
SecondBelt_Cleanup(__instance);
SecondBelt_Init(__instance);
}
public static void SecondBelt_Update(RigManager __instance)
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_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_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_00b2: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
Il2CppArrayBase<InventoryAmmoReceiver> componentsInChildren = ((Component)__instance).GetComponentsInChildren<InventoryAmmoReceiver>();
if (componentsInChildren.Length >= 2)
{
InventoryAmmoReceiver obj = componentsInChildren[0];
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
Transform parent = ((Component)obj).transform.parent;
obj2 = ((parent != null) ? ((Component)parent).gameObject : null);
}
GameObject val = (GameObject)obj2;
InventoryAmmoReceiver obj3 = componentsInChildren[1];
object obj4;
if (obj3 == null)
{
obj4 = null;
}
else
{
Transform parent2 = ((Component)obj3).transform.parent;
obj4 = ((parent2 != null) ? ((Component)parent2).gameObject : null);
}
GameObject val2 = (GameObject)obj4;
if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
{
Vector3 localPosition = val.transform.localPosition;
val2.transform.localPosition = new Vector3(0f - localPosition.x, localPosition.y, localPosition.z);
Quaternion localRotation = val.transform.localRotation;
val2.transform.localRotation = Quaternion.Euler(((Quaternion)(ref localRotation)).eulerAngles.x, 0f - ((Quaternion)(ref localRotation)).eulerAngles.y, 0f - ((Quaternion)(ref localRotation)).eulerAngles.z);
val2.transform.localScale = val.transform.lossyScale;
}
}
}
public static void SecondBelt_Init(RigManager __instance)
{
if (!Logic.m_BeltReload && (Object)(object)__instance == (Object)(object)Logic.GetRigManager())
{
return;
}
Il2CppArrayBase<InventoryAmmoReceiver> componentsInChildren = ((Component)__instance).GetComponentsInChildren<InventoryAmmoReceiver>(true);
object obj;
if (componentsInChildren.Length <= 0)
{
obj = null;
}
else
{
InventoryAmmoReceiver obj2 = componentsInChildren[0];
if (obj2 == null)
{
obj = null;
}
else
{
Transform parent = ((Component)obj2).transform.parent;
obj = ((parent != null) ? ((Component)parent).gameObject : null);
}
}
GameObject val = (GameObject)obj;
if ((Object)(object)val != (Object)null && componentsInChildren.Length < 2)
{
GameObject obj3 = Object.Instantiate<GameObject>(val, val.transform.parent);
((Object)obj3).name = "BeltRt1";
Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(obj3.GetComponentsInChildren<Collider>());
foreach (Collider val2 in array)
{
if (!val2.isTrigger)
{
val2.enabled = false;
}
}
}
SecondBelt_Update(__instance);
}
public static void SecondBelt_Cleanup(RigManager __instance)
{
Il2CppArrayBase<InventoryAmmoReceiver> componentsInChildren = ((Component)__instance).GetComponentsInChildren<InventoryAmmoReceiver>(true);
if (componentsInChildren.Length > 1)
{
Object.Destroy((Object)(object)((Component)componentsInChildren[1]).gameObject);
}
}
private static void HandleHand(Hand Hand, Gun Weapon, InventoryAmmoReceiver Belt)
{
if ((Object)(object)Belt == (Object)null || (Object)(object)Weapon == (Object)null || (m_Timeouts.TryGetValue(Hand, out var value) && Time.time < value))
{
return;
}
if (m_Timeouts.ContainsKey(Hand))
{
m_Timeouts.Remove(Hand);
}
if (!((Object)(object)Weapon.defaultMagazine == (Object)null) && !Logic.IsFiring(Weapon))
{
if ((Object)(object)Weapon.defaultMagazine != (Object)null && (Object)(object)Weapon.defaultCartridge != (Object)null && (Object)(object)Belt._selectedMagazineData != (Object)(object)Weapon.defaultMagazine)
{
Belt.SwitchMagazine(Weapon.defaultMagazine, Weapon.defaultCartridge);
}
if (HandleBelt(((Component)Belt).gameObject, ((Component)Hand).gameObject))
{
Logic.HandleWeapon_BeltReload(Weapon, Logic.m_BeltRechamber);
m_Timeouts[Hand] = Time.time + m_TimeoutDuration;
}
}
}
private static bool HandleBelt(GameObject Belt, GameObject Hand)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_0019: 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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = Belt.transform.position;
Vector3 position2 = Hand.transform.position;
if (Vector3.Distance(position, position2) <= Logic.m_BeltRadius)
{
Rigidbody component = Hand.GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
Vector3 val = position - position2;
Vector3 normalized = ((Vector3)(ref val)).normalized;
if (Vector3.Dot(component.velocity, normalized) >= Logic.m_BeltVelocity)
{
return true;
}
}
}
return false;
}
}
public class Core : MelonMod
{
public static bool m_Fusion = false;
private static MelonPreferences_Category MainCategory = null;
private static uint m_ConfigVersion = 1u;
public static bool m_Connected
{
get
{
if (m_Fusion)
{
return LocalPlayer.GetNetworkPlayer() != null;
}
return false;
}
}
public static bool m_Host => PlayerIdManager.LocalSmallId == 0;
public override void OnInitializeMelon()
{
((MelonBase)this).LoggerInstance.Msg("Initialized.");
if (MelonBase.FindMelon("LabFusion", "Lakatrazz") != null)
{
LoadModule();
m_Fusion = true;
}
SetupConfig();
Logic.Init();
}
private static void LoadModule()
{
ModuleManager.RegisterModule<DualActionModule>();
}
public override void OnUpdate()
{
}
private static void SetupConfig()
{
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: 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_0283: 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_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
MainCategory = MelonPreferences.CreateCategory("DualAction");
MelonPreferences_Entry<uint> obj = MainCategory.CreateEntry<uint>("Version", 0u, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
MelonPreferences_Entry<bool> MelonPrefEnabled = MainCategory.CreateEntry<bool>("Enabled", Logic.m_RechamberEnabled, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
MelonPreferences_Entry<float> MelonPrefSlideRadius = MainCategory.CreateEntry<float>("SlideRadius", Logic.m_SlideRadius, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
MelonPreferences_Entry<float> MelonPrefSlideVelocity = MainCategory.CreateEntry<float>("SlideVelocity", Logic.m_SlideVelocity, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
MelonPreferences_Entry<bool> MelonPrefBeltReload = MainCategory.CreateEntry<bool>("BeltReload", Logic.m_BeltReload, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
MelonPreferences_Entry<bool> MelonPrefBeltRechamber = MainCategory.CreateEntry<bool>("BeltRechamber", Logic.m_BeltRechamber, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
MelonPreferences_Entry<float> MelonPrefBeltRadius = MainCategory.CreateEntry<float>("BeltRadius", Logic.m_BeltRadius, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
MelonPreferences_Entry<float> MelonPrefBeltVelocity = MainCategory.CreateEntry<float>("BeltVelocity", Logic.m_BeltVelocity, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
if (obj.Value >= m_ConfigVersion)
{
Logic.m_RechamberEnabled = MelonPrefEnabled.Value;
Logic.m_SlideRadius = MelonPrefSlideRadius.Value;
Logic.m_SlideVelocity = MelonPrefSlideVelocity.Value;
Logic.m_BeltReload = MelonPrefBeltReload.Value;
Logic.m_BeltRechamber = MelonPrefBeltRechamber.Value;
Logic.m_BeltRadius = MelonPrefBeltRadius.Value;
Logic.m_BeltVelocity = MelonPrefBeltVelocity.Value;
}
else
{
ResetConfig();
}
UpdatePreferenceAndSave(obj, m_ConfigVersion);
Page val = Page.Root.CreatePage("Dual Action", Color.cyan, 0, true);
BoolElement VarEnabled = null;
VarEnabled = val.CreateBool("Slide Rechamber", Logic.m_RechamberEnabled ? Color.green : Color.red, Logic.m_RechamberEnabled, (Action<bool>)delegate(bool value)
{
//IL_0016: 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)
Logic.m_RechamberEnabled = value;
((Element)VarEnabled).ElementColor = (value ? Color.green : Color.red);
UpdatePreferenceAndSave(MelonPrefEnabled, value);
});
val.CreateFloat("Slide Rechamber Radius", Color.cyan, Logic.m_SlideRadius, 0.05f, 0.05f, 3.5f, (Action<float>)delegate(float value)
{
Logic.m_SlideRadius = value;
UpdatePreferenceAndSave(MelonPrefSlideRadius, value);
});
val.CreateFloat("Slice Rechamber Velocity", Color.white, Logic.m_SlideVelocity, 0.05f, 0.05f, 2f, (Action<float>)delegate(float value)
{
Logic.m_SlideVelocity = value;
UpdatePreferenceAndSave(MelonPrefSlideVelocity, value);
});
val.CreateFunction("---------", Color.white, (Action)null);
BoolElement VarBeltReloadEnabled = null;
VarBeltReloadEnabled = val.CreateBool("Belt Reload", Logic.m_BeltReload ? Color.green : Color.red, Logic.m_BeltReload, (Action<bool>)delegate(bool value)
{
//IL_0016: 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)
Logic.m_BeltReload = value;
((Element)VarBeltReloadEnabled).ElementColor = (value ? Color.green : Color.red);
UpdatePreferenceAndSave(MelonPrefBeltReload, value);
if (value)
{
Belt.SecondBelt_Init(Logic.GetRigManager());
}
else
{
Belt.SecondBelt_Cleanup(Logic.GetRigManager());
}
});
BoolElement VarBeltAutoRechamberEnabled = null;
VarBeltAutoRechamberEnabled = val.CreateBool("Belt Auto Rechamber", Logic.m_BeltRechamber ? Color.green : Color.red, Logic.m_BeltRechamber, (Action<bool>)delegate(bool value)
{
//IL_0016: 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)
Logic.m_BeltRechamber = value;
((Element)VarBeltAutoRechamberEnabled).ElementColor = (value ? Color.green : Color.red);
UpdatePreferenceAndSave(MelonPrefBeltRechamber, value);
});
val.CreateFloat("Belt Activate Radius", Color.cyan, Logic.m_BeltRadius, 0.05f, 0.05f, 2f, (Action<float>)delegate(float value)
{
Logic.m_BeltRadius = value;
UpdatePreferenceAndSave(MelonPrefBeltRadius, value);
});
val.CreateFloat("Belt Activate Velocity", Color.white, Logic.m_BeltVelocity, 0.05f, 0.05f, 4f, (Action<float>)delegate(float value)
{
Logic.m_BeltVelocity = value;
UpdatePreferenceAndSave(MelonPrefBeltVelocity, value);
});
void ResetConfig()
{
UpdatePreferenceAndSave(MelonPrefSlideRadius, Logic.m_SlideRadius);
UpdatePreferenceAndSave(MelonPrefSlideVelocity, Logic.m_SlideVelocity);
UpdatePreferenceAndSave(MelonPrefBeltReload, Logic.m_BeltReload);
UpdatePreferenceAndSave(MelonPrefBeltRechamber, Logic.m_BeltRechamber);
UpdatePreferenceAndSave(MelonPrefBeltRadius, Logic.m_BeltRadius);
UpdatePreferenceAndSave(MelonPrefBeltVelocity, Logic.m_BeltVelocity);
}
}
private static void UpdatePreferenceAndSave<T>(MelonPreferences_Entry<T> preference, T value)
{
preference.Value = value;
MainCategory.SaveToFile(false);
}
}
public class Logic : MonoBehaviour
{
public static bool m_RechamberEnabled = true;
public static float m_SlideRadius = 3f;
public static float m_SlideVelocity = 0.55f;
public static bool m_BeltReload = true;
public static bool m_BeltRechamber = false;
public static float m_BeltRadius = 0.15f;
public static float m_BeltVelocity = 1.95f;
private static RigManager GetRigManager_Fision()
{
NetworkPlayer networkPlayer = LocalPlayer.GetNetworkPlayer();
if (networkPlayer != null && networkPlayer.RigRefs.IsValid)
{
return networkPlayer.RigRefs.RigManager;
}
return Player.RigManager;
}
public static RigManager GetRigManager()
{
if (Core.m_Fusion)
{
return GetRigManager_Fision();
}
return Player.RigManager;
}
public static void Init()
{
Hooking.CreateHook(typeof(Gun).GetMethod("OnCollisionEnter", AccessTools.all), typeof(Manual).GetMethod("OnCollisionEnter", AccessTools.all), true);
Hooking.CreateHook(typeof(RigManager).GetMethod("Update", AccessTools.all), typeof(Belt).GetMethod("OnBeltUpdate", AccessTools.all), true);
Hooking.CreateHook(typeof(RigManager).GetMethod("Awake", AccessTools.all), typeof(Belt).GetMethod("OnBeltAwake", AccessTools.all), false);
Hooking.OnLevelLoaded += OnLevelInfo;
}
public static void OnLevelInfo(LevelInfo _Info)
{
}
public static void OnMagazineInserted(Gun __instance)
{
}
public static bool IsFiring(Gun Weapon)
{
//IL_000b: 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_0011: 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)
//IL_0015: Invalid comparison between Unknown and I4
//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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
if (!Weapon.isFiring)
{
return false;
}
AnimationStates animationState = Weapon.animationState;
if (animationState - 8 <= 1)
{
return true;
}
SlideStates slideState = Weapon.slideState;
if ((int)slideState == 1 || (int)slideState == 4)
{
return false;
}
return true;
}
public static void HandleWeapon_ManualRechamber(Gun Weapon)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)Weapon.slideState == 4)
{
Weapon.SlideRelease();
}
Weapon.hammerState = (HammerStates)1;
}
public static void HandleWeapon_BeltReload(Gun Weapon, bool SlideRelease = false)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
bool bSlideReturned = (int)Weapon.slideState == 1;
if (Weapon.HasMagazine())
{
if (Weapon.MagazineState.AmmoCount <= 0)
{
Weapon.MagazineState.Refill();
OnMagLoaded();
}
return;
}
Transform parent = ((Component)Weapon.ammoSocket).transform.parent;
object obj;
if (parent == null)
{
obj = null;
}
else
{
GameObject gameObject = ((Component)parent).gameObject;
if (gameObject == null)
{
obj = null;
}
else
{
Transform parent2 = gameObject.transform.parent;
obj = ((parent2 != null) ? ((Component)parent2).gameObject : null);
}
}
GameObject val = (GameObject)obj;
if ((Object)(object)val != (Object)null && !val.active)
{
val.active = true;
}
Weapon.ammoSocket.ForceLoadAsync(Weapon.defaultMagazine).GetAwaiter().OnCompleted(Action.op_Implicit((Action)OnMagLoaded));
void OnMagLoaded()
{
Weapon.OnMagazineInserted();
Weapon.SlideRelease();
Weapon.SlideLocked();
if (SlideRelease || bSlideReturned)
{
Weapon.SlideRelease();
}
Weapon.hammerState = (HammerStates)1;
}
}
public static void HandleWeapon_Fusion(Gun Weapon, DualActionMessage.GunAction Action, bool BeltSlideRelease = false)
{
if (!((Object)(object)Weapon == (Object)null))
{
switch (Action)
{
case DualActionMessage.GunAction.ManualRechamber:
HandleWeapon_ManualRechamber(Weapon);
break;
case DualActionMessage.GunAction.BeltRechamber:
HandleWeapon_BeltReload(Weapon, BeltSlideRelease);
break;
case DualActionMessage.GunAction.None:
break;
}
}
}
}
public class Manual
{
private static void OnCollisionEnter(Gun __instance, Collision collision)
{
if (Logic.m_RechamberEnabled)
{
GameObject gameObject = collision.gameObject;
if (!((Object)(object)gameObject == (Object)null) && (Object)(object)gameObject.GetComponent<Gun>() != (Object)null)
{
HandleGunCollision(__instance, collision);
}
}
}
private static void HandleGunCollision(Gun __instance, Collision collision)
{
//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_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_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_0037: 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_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: 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_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: 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)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: 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_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Invalid comparison between Unknown and I4
SlideVirtualController slideVirtualController = __instance.slideVirtualController;
if ((Object)(object)slideVirtualController == (Object)null || Logic.IsFiring(__instance))
{
return;
}
Transform firePointTransform = __instance.firePointTransform;
Vector3 forward = firePointTransform.forward;
Vector3 relativeVelocity = collision.relativeVelocity;
if (Vector3.Dot(((Vector3)(ref relativeVelocity)).normalized, -forward) < 0.65f)
{
return;
}
Grip val = null;
float num = float.MaxValue;
foreach (Grip item in (Il2CppArrayBase<Grip>)(object)((VirtualControllerOverride)slideVirtualController).primaryGrips)
{
if (!((Object)(object)item == (Object)null))
{
float num2 = Vector3.Distance(((Component)item).transform.position, firePointTransform.position);
if (num2 < num)
{
num = num2;
val = item;
}
}
}
if ((Object)(object)val == (Object)null)
{
return;
}
foreach (Collider item2 in (Il2CppArrayBase<Collider>)(object)val.gripColliders)
{
foreach (ContactPoint item3 in (Il2CppArrayBase<ContactPoint>)(object)collision.contacts)
{
ContactPoint current3 = item3;
if (!(Vector3.Distance(((ContactPoint)(ref current3)).point, item2.ClosestPoint(((ContactPoint)(ref current3)).point)) <= Logic.m_SlideRadius))
{
continue;
}
Vector3 right = firePointTransform.right;
Vector3 forward2 = firePointTransform.forward;
Vector3 up = firePointTransform.up;
Gun componentInParent = collision.gameObject.GetComponentInParent<Gun>();
if ((Object)(object)componentInParent == (Object)null)
{
continue;
}
Vector3 forward3 = ((Component)componentInParent.firePointTransform).transform.forward;
Vector3 up2 = ((Component)componentInParent.firePointTransform).transform.up;
if (Vector3.Dot(forward2, forward3) > -0.8f || Vector3.Dot(up, up2) > -0.7f)
{
continue;
}
Vector3 val2 = Vector3.ProjectOnPlane(collision.relativeVelocity, right);
if (Vector3.Dot(((Vector3)(ref val2)).normalized, -forward) > 0.65f && ((Vector3)(ref val2)).magnitude > Logic.m_SlideVelocity)
{
if ((int)__instance.slideState == 4)
{
Logic.HandleWeapon_ManualRechamber(__instance);
}
return;
}
}
}
}
}
}
namespace DualAction.Fusion
{
public class DualActionMessage : ModuleMessageHandler
{
public enum GunAction : ushort
{
None,
ManualRechamber,
BeltRechamber
}
public static void Send(Gun Weapon, GunAction _Action)
{
FusionWriter val = FusionWriter.Create();
try
{
if (Serialize(val, Weapon, _Action))
{
FusionMessage val2 = FusionMessage.ModuleCreate<DualActionMessage>(val);
try
{
if (Core.m_Host)
{
MessageSender.BroadcastMessage((NetworkChannel)0, val2);
}
else
{
MessageSender.SendToServer((NetworkChannel)0, val2);
}
}
finally
{
if (val2 != null)
{
val2.Dispose();
}
}
}
if (val != null)
{
val.Dispose();
}
}
finally
{
((IDisposable)val)?.Dispose();
}
}
private static bool Serialize(FusionWriter Writer, Gun Weapon, GunAction _Action)
{
NetworkEntity val = GunExtender.Cache.Get(Weapon);
if (val == null || !val.IsOwner)
{
return false;
}
Writer.Write<PlayerId>(PlayerIdManager.LocalId);
Writer.Write(val.Id);
Writer.Write((ushort)_Action);
Writer.Write(Logic.m_BeltRechamber);
return true;
}
private static bool Deserialize(FusionReader Reader)
{
PlayerIdManager.GetPlayerId(Reader.ReadByte());
ushort key = Reader.ReadUInt16();
GunAction action = (GunAction)Reader.ReadUInt16();
bool beltSlideRelease = Reader.ReadBoolean();
if (NetworkEntityManager.IdManager.RegisteredEntities.IdEntityLookup.TryGetValue(key, out var value))
{
GunExtender extender = value.GetExtender<GunExtender>();
if (extender != null)
{
if (((EntityComponentArrayExtender<Gun>)(object)extender).Components == null || ((EntityComponentArrayExtender<Gun>)(object)extender).Components.Length == 0)
{
if (Reader != null)
{
Reader.Dispose();
}
return false;
}
Gun[] components = ((EntityComponentArrayExtender<Gun>)(object)extender).Components;
for (int i = 0; i < components.Length; i++)
{
Logic.HandleWeapon_Fusion(components[i], action, beltSlideRelease);
}
}
}
if (Reader != null)
{
Reader.Dispose();
}
return true;
}
public override void HandleMessage(byte[] bytes, bool isServerHandled = false)
{
FusionReader val = FusionReader.Create(bytes);
try
{
if (Deserialize(val) && isServerHandled)
{
MessageSender.BroadcastMessageExceptSelf((NetworkChannel)0, FusionMessage.ModuleCreate<DualActionMessage>(bytes));
}
}
finally
{
((IDisposable)val)?.Dispose();
}
}
}
public class DualActionModule : Module
{
public override string Name => "DualAction";
public override string Author => "Zer0Bytes";
public override Version Version => new Version(1, 3, 5);
public override ConsoleColor Color => ConsoleColor.Cyan;
protected override void OnModuleRegistered()
{
}
protected override void OnModuleUnregistered()
{
}
}
}