using System;
using System.Collections;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using SammyCadian.TestGrenadeLauncherMod;
using UnityEngine;
using UnityEngine.Events;
[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("SammyCadian")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TestGrenadeLauncherMod")]
[assembly: AssemblyTitle("TestGrenadeLauncherMod")]
[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 SammyCadian.TestGrenadeLauncherMod
{
public class GrenadeLauncherScript : MonoBehaviour
{
public enum State
{
Idle,
OutOfAmmo,
Buildup,
Shooting,
Reloading
}
private PhysGrabObject physGrabObject;
private ItemToggle itemToggle;
public bool hasOneShot = true;
public float shootTime = 1f;
public bool hasBuildUp;
public float buildUpTime = 1f;
public int numberOfBullets = 1;
[Range(0f, 65f)]
public float gunRandomSpread;
public float gunRange = 50f;
public float distanceKeep = 0.8f;
public float gunRecoilForce = 1f;
public float cameraShakeMultiplier = 1f;
public float torqueMultiplier = 1f;
public float grabStrengthMultiplier = 1f;
public float shootCooldown = 1f;
public float batteryDrain = 0.1f;
public bool batteryDrainFullBar;
public int batteryDrainFullBars = 1;
[Range(0f, 100f)]
public float misfirePercentageChange = 50f;
public AnimationCurve shootLineWidthCurve;
public float grabVerticalOffset = -0.2f;
public float aimVerticalOffset = -5f;
public float investigateRadius = 20f;
private float investigateCooldown;
public Transform gunMuzzle;
public GameObject bulletPrefab;
public GameObject bombPrefab;
public GameObject muzzleFlashPrefab;
public Transform gunTrigger;
internal HurtCollider hurtCollider;
public Sound soundShoot;
public Sound soundShootGlobal;
public Sound soundNoAmmoClick;
public Sound soundHit;
private ItemBattery itemBattery;
private PhotonView photonView;
private PhysGrabObjectImpactDetector impactDetector;
private bool prevToggleState;
private AnimationCurve triggerAnimationCurve;
private float triggerAnimationEval;
private bool triggerAnimationActive;
public UnityEvent onStateIdleStart;
public UnityEvent onStateIdleUpdate;
public UnityEvent onStateIdleFixedUpdate;
[Space(20f)]
public UnityEvent onStateOutOfAmmoStart;
public UnityEvent onStateOutOfAmmoUpdate;
public UnityEvent onStateOutOfAmmoFixedUpdate;
[Space(20f)]
public UnityEvent onStateBuildupStart;
public UnityEvent onStateBuildupUpdate;
public UnityEvent onStateBuildupFixedUpdate;
[Space(20f)]
public UnityEvent onStateShootingStart;
public UnityEvent onStateShootingUpdate;
public UnityEvent onStateShootingFixedUpdate;
[Space(20f)]
public UnityEvent onStateReloadingStart;
public UnityEvent onStateReloadingUpdate;
public UnityEvent onStateReloadingFixedUpdate;
private bool hasIdleUpdate = true;
private bool hasIdleFixedUpdate = true;
private bool hasOutOfAmmoUpdate = true;
private bool hasOutOfAmmoFixedUpdate = true;
private bool hasBuildupUpdate = true;
private bool hasBuildupFixedUpdate = true;
private bool hasShootingUpdate = true;
private bool hasShootingFixedUpdate = true;
private bool hasReloadingUpdate = true;
private bool hasReloadingFixedUpdate = true;
internal float stateTimer;
internal float stateTimeMax;
internal State stateCurrent;
private State statePrev;
private bool stateStart;
private ItemEquippable itemEquippable;
private void Start()
{
itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
itemToggle = ((Component)this).GetComponent<ItemToggle>();
itemBattery = ((Component)this).GetComponent<ItemBattery>();
photonView = ((Component)this).GetComponent<PhotonView>();
impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
triggerAnimationCurve = AssetManager.instance.animationCurveClickInOut;
if (onStateIdleUpdate == null)
{
hasIdleUpdate = false;
}
if (onStateIdleFixedUpdate == null)
{
hasIdleFixedUpdate = false;
}
if (onStateOutOfAmmoUpdate == null)
{
hasOutOfAmmoUpdate = false;
}
if (onStateOutOfAmmoFixedUpdate == null)
{
hasOutOfAmmoFixedUpdate = false;
}
if (onStateBuildupUpdate == null)
{
hasBuildupUpdate = false;
}
if (onStateBuildupFixedUpdate == null)
{
hasBuildupFixedUpdate = false;
}
if (onStateShootingUpdate == null)
{
hasShootingUpdate = false;
}
if (onStateShootingFixedUpdate == null)
{
hasShootingFixedUpdate = false;
}
if (onStateReloadingUpdate == null)
{
hasReloadingUpdate = false;
}
if (onStateReloadingFixedUpdate == null)
{
hasReloadingFixedUpdate = false;
}
}
private void FixedUpdate()
{
StateMachine(_fixedUpdate: true);
}
private void Update()
{
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
StateMachine(_fixedUpdate: false);
if ((Object)(object)physGrabObject != (Object)null && physGrabObject.grabbed && physGrabObject.grabbedLocal)
{
PhysGrabber.instance.OverrideGrabDistance(distanceKeep);
}
if (triggerAnimationActive)
{
float num = 45f;
triggerAnimationEval += Time.deltaTime * 4f;
gunTrigger.localRotation = Quaternion.Euler(num * triggerAnimationCurve.Evaluate(triggerAnimationEval), 0f, 0f);
if (triggerAnimationEval >= 1f)
{
gunTrigger.localRotation = Quaternion.Euler(0f, 0f, 0f);
triggerAnimationActive = false;
triggerAnimationEval = 1f;
}
}
UpdateMaster();
}
private void UpdateMaster()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: 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_0102: Unknown result type (might be due to invalid IL or missing references)
if (!SemiFunc.IsMasterClientOrSingleplayer() || physGrabObject.playerGrabbing.Count <= 0)
{
return;
}
Quaternion val = Quaternion.Euler(aimVerticalOffset, 0f, 0f);
Quaternion val2 = Quaternion.Euler(0f, 0f, 0f);
Quaternion identity = Quaternion.identity;
bool flag = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = true;
foreach (PhysGrabber item in physGrabObject.playerGrabbing)
{
if (flag4)
{
if (item.playerAvatar.isCrouching)
{
flag2 = true;
}
if (item.playerAvatar.isCrawling)
{
flag3 = true;
}
flag4 = false;
}
if (item.isRotating)
{
flag = true;
}
}
if (!flag)
{
physGrabObject.TurnXYZ(val, val2, identity);
}
float num = grabVerticalOffset;
if (flag2)
{
num += 0.5f;
}
if (flag3)
{
num -= 0.5f;
}
physGrabObject.OverrideGrabVerticalPosition(num);
if (!flag)
{
if (stateCurrent == State.OutOfAmmo)
{
physGrabObject.OverrideTorqueStrength(0.01f, 0.1f);
}
else if (physGrabObject.grabbed)
{
physGrabObject.OverrideTorqueStrength(12f, 0.1f);
physGrabObject.OverrideAngularDrag(20f, 0.1f);
}
}
if (flag)
{
physGrabObject.OverrideTorqueStrength(2f, 0.1f);
physGrabObject.OverrideAngularDrag(20f, 0.1f);
}
}
public void Misfire()
{
if (!physGrabObject.grabbed && !physGrabObject.hasNeverBeenGrabbed && SemiFunc.IsMasterClientOrSingleplayer() && (float)Random.Range(0, 100) < misfirePercentageChange)
{
Shoot();
}
}
public void Shoot()
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
if (itemBattery.batteryLifeInt <= 0)
{
flag = true;
}
if (Random.Range(0, 10000) == 0)
{
flag = false;
}
if (flag)
{
return;
}
if (hasOneShot)
{
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("ShootRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
ShootRPC();
}
StateSet(State.Reloading);
}
else if (hasBuildUp)
{
StateSet(State.Buildup);
}
else
{
StateSet(State.Shooting);
}
}
private void MuzzleFlash()
{
//IL_000d: 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)
Object.Instantiate<GameObject>(muzzleFlashPrefab, gunMuzzle.position, gunMuzzle.rotation, gunMuzzle).GetComponent<ItemGunMuzzleFlash>().ActivateAllEffects();
}
private void StartTriggerAnimation()
{
triggerAnimationActive = true;
triggerAnimationEval = 0f;
}
private static bool MasterOnlyRPC(PhotonMessageInfo _info)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
if (!SemiFunc.IsMultiplayer() || _info.Sender == PhotonNetwork.MasterClient)
{
return true;
}
return false;
}
[PunRPC]
public void ShootRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: 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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: 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)
//IL_0119: 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_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
if (!MasterOnlyRPC(_info))
{
return;
}
float num = 3f * cameraShakeMultiplier;
float num2 = 16f * cameraShakeMultiplier;
SemiFunc.CameraShakeImpactDistance(gunMuzzle.position, 5f * cameraShakeMultiplier, 0.1f, num, num2);
SemiFunc.CameraShakeDistance(gunMuzzle.position, 0.1f * cameraShakeMultiplier, 0.1f * cameraShakeMultiplier, num, num2);
soundShoot.Play(gunMuzzle.position, 1f, 1f, 1f, 1f);
soundShootGlobal.Play(gunMuzzle.position, 1f, 1f, 1f, 1f);
MuzzleFlash();
StartTriggerAnimation();
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
if (investigateRadius > 0f)
{
}
physGrabObject.rb.AddForceAtPosition(-gunMuzzle.forward * gunRecoilForce, gunMuzzle.position, (ForceMode)1);
if (!batteryDrainFullBar)
{
ItemBattery obj = itemBattery;
obj.batteryLife -= batteryDrain;
}
else
{
itemBattery.RemoveFullBar(batteryDrainFullBars);
}
RaycastHit val4 = default(RaycastHit);
for (int i = 0; i < numberOfBullets; i++)
{
Vector3 position = gunMuzzle.position;
bool hit = false;
bool flag = false;
Vector3 val = gunMuzzle.forward;
if (gunRandomSpread > 0f)
{
float num3 = Random.Range(0f, gunRandomSpread / 2f);
float num4 = Random.Range(0f, 360f);
Vector3 val2 = Vector3.Cross(val, Random.onUnitSphere);
Vector3 normalized = ((Vector3)(ref val2)).normalized;
Quaternion val3 = Quaternion.AngleAxis(num3, normalized);
val2 = Quaternion.AngleAxis(num4, val) * val3 * val;
val = ((Vector3)(ref val2)).normalized;
}
if (Physics.Raycast(gunMuzzle.position, val, ref val4, gunRange, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "Enemy" })))
{
position = ((RaycastHit)(ref val4)).point;
hit = true;
}
else
{
flag = true;
}
if (flag)
{
position = gunMuzzle.position + gunMuzzle.forward * gunRange;
hit = true;
}
ShootBullet(gunMuzzle.forward, hit);
}
}
private void ShootBullet(Vector3 _shootDirection, bool _hit)
{
//IL_0044: 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_004e: 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)
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("ShootBulletRPC", (RpcTarget)0, new object[2] { _shootDirection, _hit });
}
else
{
ShootBulletRPC(_shootDirection, _hit);
}
}
}
[PunRPC]
public void ShootBulletRPC(Vector3 _shootDirection, bool _hit, PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
if (!MasterOnlyRPC(_info))
{
return;
}
if (physGrabObject.playerGrabbing.Count > 1)
{
foreach (PhysGrabber item in physGrabObject.playerGrabbing)
{
item.OverrideGrabRelease();
}
}
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (SemiFunc.IsMultiplayer())
{
GameObject val = PhotonNetwork.Instantiate("Items/LaunchedGrenade", ((Component)this).transform.position, Quaternion.identity, (byte)0, (object[])null);
val.GetComponent<LaunchedGrenadeScript>().Initialize();
val.GetComponent<LaunchedGrenadeScript>().ReceiveDirection(_shootDirection);
val.GetComponent<LaunchedGrenadeScript>().Spawn();
}
else
{
LaunchedGrenadeScript component = Object.Instantiate<GameObject>(bombPrefab, ((Component)this).transform.position, Quaternion.identity).GetComponent<LaunchedGrenadeScript>();
component.Initialize();
component.ReceiveDirection(_shootDirection);
component.Spawn();
}
}
}
private void StateSet(State _state)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
if (_state == stateCurrent)
{
return;
}
if (SemiFunc.IsMultiplayer())
{
if (SemiFunc.IsMasterClient())
{
photonView.RPC("StateSetRPC", (RpcTarget)0, new object[1] { (int)_state });
}
}
else
{
StateSetRPC((int)_state);
}
}
private void ShootLogic()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.IsMasterClientOrSingleplayer() && (Object)(object)itemToggle != (Object)null && itemToggle.toggleState != prevToggleState)
{
if (itemBattery.batteryLifeInt <= 0)
{
soundNoAmmoClick.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
StartTriggerAnimation();
SemiFunc.CameraShakeImpact(1f, 0.1f);
physGrabObject.rb.AddForceAtPosition(-gunMuzzle.forward * 1f, gunMuzzle.position, (ForceMode)1);
}
else
{
Shoot();
}
prevToggleState = itemToggle.toggleState;
}
}
[PunRPC]
private void StateSetRPC(int state, PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (MasterOnlyRPC(_info))
{
stateStart = true;
statePrev = stateCurrent;
stateCurrent = (State)state;
}
}
private void StateMachine(bool _fixedUpdate)
{
switch (stateCurrent)
{
case State.Idle:
StateIdle(_fixedUpdate);
break;
case State.OutOfAmmo:
StateOutOfAmmo(_fixedUpdate);
break;
case State.Buildup:
StateBuildup(_fixedUpdate);
break;
case State.Shooting:
StateShooting(_fixedUpdate);
break;
case State.Reloading:
StateReloading(_fixedUpdate);
break;
}
}
private void StateIdle(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
if (onStateIdleStart != null)
{
onStateIdleStart.Invoke();
}
stateStart = false;
prevToggleState = itemToggle.toggleState;
}
if (!_fixedUpdate)
{
ShootLogic();
if (hasIdleUpdate)
{
onStateIdleUpdate.Invoke();
}
}
if (_fixedUpdate && hasIdleFixedUpdate)
{
onStateIdleFixedUpdate.Invoke();
}
}
private void StateOutOfAmmo(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
if (onStateOutOfAmmoStart != null)
{
onStateOutOfAmmoStart.Invoke();
}
stateStart = false;
prevToggleState = itemToggle.toggleState;
}
if (!_fixedUpdate)
{
if (itemBattery.batteryLifeInt > 0)
{
StateSet(State.Idle);
return;
}
ShootLogic();
if (hasOutOfAmmoUpdate)
{
onStateOutOfAmmoUpdate.Invoke();
}
}
if (_fixedUpdate && hasOutOfAmmoFixedUpdate)
{
onStateOutOfAmmoFixedUpdate.Invoke();
}
}
private void StateBuildup(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
if (onStateBuildupStart != null)
{
onStateBuildupStart.Invoke();
}
stateTimer = 0f;
stateTimeMax = buildUpTime;
stateStart = false;
}
if (!_fixedUpdate)
{
if (hasBuildupUpdate)
{
onStateBuildupUpdate.Invoke();
}
stateTimer += Time.deltaTime;
if (Object.op_Implicit((Object)(object)itemEquippable) && itemEquippable.isEquipped)
{
StateSet(State.Idle);
}
if (stateTimer >= stateTimeMax && itemBattery.batteryLifeInt > 0)
{
StateSet(State.Shooting);
}
}
if (_fixedUpdate && hasBuildupFixedUpdate)
{
onStateBuildupFixedUpdate.Invoke();
}
}
private void StateShooting(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
stateStart = false;
if (onStateShootingStart != null)
{
onStateShootingStart.Invoke();
}
if (!hasOneShot)
{
stateTimeMax = shootTime;
stateTimer = 0f;
investigateCooldown = 0f;
}
else
{
stateTimer = 0.001f;
}
if (itemBattery.batteryLifeInt > 0)
{
itemBattery.RemoveFullBar(1);
}
}
if (!_fixedUpdate)
{
if (investigateRadius > 0f)
{
if (investigateCooldown <= 0f)
{
investigateCooldown = 0.5f;
}
else
{
investigateCooldown -= Time.deltaTime;
}
}
stateTimer += Time.deltaTime;
if (stateTimer >= stateTimeMax || (Object.op_Implicit((Object)(object)itemEquippable) && itemEquippable.isEquipped))
{
StateSet(State.Reloading);
}
if (hasShootingUpdate)
{
onStateShootingUpdate.Invoke();
}
}
if (_fixedUpdate && hasShootingFixedUpdate)
{
onStateShootingFixedUpdate.Invoke();
}
}
private void StateReloading(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
stateStart = false;
if (onStateReloadingStart != null)
{
onStateReloadingStart.Invoke();
}
stateTimeMax = shootCooldown;
stateTimer = 0f;
}
if (!_fixedUpdate)
{
stateTimer += Time.deltaTime;
if (stateTimer >= stateTimeMax)
{
if (itemBattery.batteryLifeInt > 0)
{
StateSet(State.Idle);
}
else
{
StateSet(State.OutOfAmmo);
}
}
if (hasReloadingUpdate)
{
onStateReloadingUpdate.Invoke();
}
}
if (_fixedUpdate && hasReloadingFixedUpdate)
{
onStateReloadingFixedUpdate.Invoke();
}
}
}
public class LaunchedGrenadeScript : MonoBehaviour
{
[CompilerGenerated]
private sealed class <LateSpawn>d__12 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public LaunchedGrenadeScript <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LateSpawn>d__12(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!<>4__this.physGrabObject.spawned || <>4__this.rb.isKinematic)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>4__this.itemToggle.ToggleItem(true, -1);
<>4__this.itemGrenade.tickTime = Random.Range(1.5f, 3f);
<>4__this.rb.AddForce(<>4__this.startDirection * (float)Random.Range(8, 10), (ForceMode)1);
<>4__this.rb.AddTorque(Random.insideUnitSphere * Random.Range(5f, 10f), (ForceMode)1);
<>4__this.itemGrenade.isSpawnedGrenade = true;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private ParticleScriptExplosion particleScriptExplosion;
private ItemToggle itemToggle;
private ItemGrenade itemGrenade;
private PhotonView photonView;
private PhysGrabObject physGrabObject;
private Rigidbody rb;
public Sound soundExplosion;
public Sound soundExplosionGlobal;
private Vector3 startDirection;
private void Start()
{
Initialize();
}
public void Initialize()
{
particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
itemToggle = ((Component)this).GetComponent<ItemToggle>();
itemGrenade = ((Component)this).GetComponent<ItemGrenade>();
photonView = ((Component)this).GetComponent<PhotonView>();
physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
rb = ((Component)this).GetComponent<Rigidbody>();
}
public void Spawn()
{
((MonoBehaviour)this).StartCoroutine(LateSpawn());
itemGrenade.isSpawnedGrenade = true;
}
[IteratorStateMachine(typeof(<LateSpawn>d__12))]
private IEnumerator LateSpawn()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LateSpawn>d__12(0)
{
<>4__this = this
};
}
public void ReceiveDirection(Vector3 direction)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
startDirection = ((Vector3)(ref direction)).normalized;
}
public void Explosion()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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)
Debug.Log((object)"Grenade explosion");
particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
particleScriptExplosion.Spawn(((Component)this).transform.position, 0.8f, 50, 100, 2f, false, true, 1f);
soundExplosion.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
soundExplosionGlobal.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
}
}
namespace TestGrenadeLauncherMod
{
[HarmonyPatch(typeof(PlayerController))]
internal static class ExamplePlayerControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
private static void Start_Prefix(PlayerController __instance)
{
TestGrenadeLauncherMod.Logger.LogDebug((object)$"{__instance} Start Prefix");
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerController __instance)
{
TestGrenadeLauncherMod.Logger.LogDebug((object)$"{__instance} Start Postfix");
}
}
[BepInPlugin("SammyCadian.TestGrenadeLauncherMod", "TestGrenadeLauncherMod", "1.0")]
public class TestGrenadeLauncherMod : BaseUnityPlugin
{
internal static TestGrenadeLauncherMod Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
internal GrenadeLauncherScript? grenadeLauncherScriptInstance { get; private set; }
internal LaunchedGrenadeScript? launchedGrenadeScriptInstance { get; private set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
grenadeLauncherScriptInstance = ((Component)this).gameObject.AddComponent<GrenadeLauncherScript>();
launchedGrenadeScriptInstance = ((Component)this).gameObject.AddComponent<LaunchedGrenadeScript>();
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//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_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
}