using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using ModularWorkshop;
using OpenScripts2;
using OtherLoader;
using Sodalite.Api;
using UnityEngine;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace cityrobo.ModulLockwood300;
[BepInPlugin("cityrobo.ModulLockwood300", "ModulLockwood300", "1.2.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
[BepInDependency("h3vr.cityrobo.ModularWorkshopManager", "1.0.0")]
[BepInDependency("nrgill28.Sodalite", "1.4.1")]
public class ModulLockwood300Plugin : BaseUnityPlugin
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
LoadAssets();
}
private void LoadAssets()
{
OtherLoader.RegisterDirectLoad(BasePath, "cityrobo.ModulLockwood300", "", "", "lockwood300", "");
GameAPI.PreloadAllAssets(Path.Combine(BasePath, "mw_modullockwood300"));
}
}
public class IndependentEjectors : MonoBehaviour
{
public BreakActionWeapon BreakAction;
public Transform TopEjector;
public Transform BottomEjector;
public float EjectorSpeed = 1f;
public float EjectorClosed;
public float EjectorOpen;
public float EjectorEjected;
private bool _topIsEjecting = false;
private bool _bottomIsEjecting = false;
private bool _topHasEjected = false;
private bool _bottomHasEjected = false;
private bool _topWasUncocked = false;
private bool _bottomWasUncocked = false;
public void Update()
{
//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_014d: 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_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
if (!BreakAction.Barrels[0].m_isHammerCocked)
{
_topWasUncocked = true;
}
if (!BreakAction.Barrels[1].m_isHammerCocked)
{
_bottomWasUncocked = true;
}
if (!BreakAction.m_isLatched && ((Component)BreakAction.Hinge).transform.localEulerAngles.x >= BreakAction.HingeEjectLimit)
{
if (!_topHasEjected && _topWasUncocked)
{
((MonoBehaviour)this).StartCoroutine(TopEjectorCoroutine());
}
if (!_bottomHasEjected && _bottomWasUncocked)
{
((MonoBehaviour)this).StartCoroutine(BottomEjectorCoroutine());
}
}
else if (BreakAction.m_isLatched)
{
_topHasEjected = false;
_bottomHasEjected = false;
UnityEngineExtensions.ModifyLocalPositionAxisValue(TopEjector, (Axis)2, EjectorClosed);
UnityEngineExtensions.ModifyLocalPositionAxisValue(BottomEjector, (Axis)2, EjectorClosed);
}
if (BreakAction.Barrels[0].m_isHammerCocked && !_topIsEjecting && !BreakAction.m_isLatched && ((Component)BreakAction.Hinge).transform.localEulerAngles.x < BreakAction.HingeEjectLimit)
{
float num = Mathf.InverseLerp(0f, BreakAction.HingeEjectLimit, ((Component)BreakAction.Hinge).transform.localEulerAngles.x);
float num2 = ((!_topHasEjected) ? Mathf.Lerp(EjectorClosed, EjectorOpen, num) : Mathf.Lerp(EjectorClosed, EjectorEjected, num));
UnityEngineExtensions.ModifyLocalPositionAxisValue(TopEjector, (Axis)2, num2);
}
if (BreakAction.Barrels[1].m_isHammerCocked && !_bottomIsEjecting && !BreakAction.m_isLatched && ((Component)BreakAction.Hinge).transform.localEulerAngles.x < BreakAction.HingeEjectLimit)
{
float num3 = Mathf.InverseLerp(0f, BreakAction.HingeEjectLimit, ((Component)BreakAction.Hinge).transform.localEulerAngles.x);
float num4 = ((!_bottomHasEjected) ? Mathf.Lerp(EjectorClosed, EjectorOpen, num3) : Mathf.Lerp(EjectorClosed, EjectorEjected, num3));
UnityEngineExtensions.ModifyLocalPositionAxisValue(BottomEjector, (Axis)2, num4);
}
}
private IEnumerator TopEjectorCoroutine()
{
_topIsEjecting = true;
_topWasUncocked = false;
Vector3 targetPos = UnityEngineExtensions.ModifyAxisValue(TopEjector.localPosition, (Axis)2, EjectorEjected);
while (!Mathf.Approximately(TopEjector.localPosition.z, EjectorEjected))
{
TopEjector.localPosition = Vector3.MoveTowards(TopEjector.localPosition, targetPos, EjectorSpeed * Time.deltaTime);
yield return null;
}
_topIsEjecting = false;
_topHasEjected = true;
}
private IEnumerator BottomEjectorCoroutine()
{
_bottomIsEjecting = true;
_bottomWasUncocked = false;
Vector3 targetPos = UnityEngineExtensions.ModifyAxisValue(BottomEjector.localPosition, (Axis)2, EjectorEjected);
while (!Mathf.Approximately(BottomEjector.localPosition.z, EjectorEjected))
{
BottomEjector.localPosition = Vector3.MoveTowards(BottomEjector.localPosition, targetPos, EjectorSpeed * Time.deltaTime);
yield return null;
}
_bottomIsEjecting = false;
_bottomHasEjected = true;
}
}
public class ModularChoke : ModularBarrelExtension
{
public Vector2 ChokingVector = default(Vector2);
private static readonly Dictionary<FVRFireArm, ModularChoke> _existingChokes;
static ModularChoke()
{
_existingChokes = new Dictionary<FVRFireArm, ModularChoke>();
Harmony.CreateAndPatchAll(typeof(ModularChoke), (string)null);
}
public override void EnablePart()
{
((ModularBarrelExtension)this).EnablePart();
_existingChokes.Add(base._firearm, this);
}
public override void DisablePart()
{
_existingChokes.Remove(base._firearm);
((ModularBarrelExtension)this).DisablePart();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FVRFireArm), "Fire")]
private static bool ChokePatch(FVRFireArm __instance, FVRFireArmChamber chamber, Transform muzzle, bool doBuzz, float velMult = 1f, float rangeOverride = -1f)
{
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
if (_existingChokes.TryGetValue(__instance, out var value))
{
if (doBuzz && (Object)(object)((FVRInteractiveObject)__instance).m_hand != (Object)null)
{
((FVRInteractiveObject)__instance).m_hand.Buzz(((FVRInteractiveObject)__instance).m_hand.Buzzer.Buzz_GunShot);
if ((Object)(object)((FVRPhysicalObject)__instance).AltGrip != (Object)null && (Object)(object)((FVRInteractiveObject)((FVRPhysicalObject)__instance).AltGrip).m_hand != (Object)null)
{
((FVRInteractiveObject)((FVRPhysicalObject)__instance).AltGrip).m_hand.Buzz(((FVRInteractiveObject)__instance).m_hand.Buzzer.Buzz_GunShot);
}
}
GM.CurrentSceneSettings.OnShotFired(__instance);
if (__instance.IsSuppressed())
{
GM.CurrentPlayerBody.VisibleEvent(0.1f);
}
else
{
GM.CurrentPlayerBody.VisibleEvent(2f);
}
float chamberVelMult = AM.GetChamberVelMult(chamber.RoundType, Vector3.Distance(((Component)chamber).transform.position, muzzle.position));
float num = __instance.GetCombinedFixedDrop(__instance.AccuracyClass) * 0.0166667f;
Vector2 val = __instance.GetCombinedFixedDrift(__instance.AccuracyClass) * 0.0166667f;
for (int i = 0; i < chamber.GetRound().NumProjectiles; i++)
{
float num2 = chamber.GetRound().ProjectileSpread + __instance.m_internalMechanicalMOA + __instance.GetCombinedMuzzleDeviceAccuracy();
if ((Object)(object)chamber.GetRound().BallisticProjectilePrefab != (Object)null)
{
Vector3 val2 = muzzle.forward * 0.005f;
GameObject val3 = Object.Instantiate<GameObject>(chamber.GetRound().BallisticProjectilePrefab, muzzle.position - val2, muzzle.rotation);
Vector2 val4 = (Random.insideUnitCircle + Random.insideUnitCircle + Random.insideUnitCircle) * (1f / 3f) * num2;
val4.x *= value.ChokingVector.x;
val4.y *= value.ChokingVector.y;
val3.transform.Rotate(new Vector3(val4.x + val.y + num, val4.y + val.x, 0f));
BallisticProjectile component = val3.GetComponent<BallisticProjectile>();
component.Fire(component.MuzzleVelocityBase * chamber.ChamberVelocityMultiplier * velMult * chamberVelMult, val3.transform.forward, __instance, true);
if (rangeOverride > 0f)
{
component.ForceSetMaxDist(rangeOverride);
}
}
}
return false;
}
return true;
}
}
public class Test : MonoBehaviour
{
private void Start()
{
}
private void Update()
{
}
}