using System;
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.SentryGun;
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("SentryGunScripts")]
[assembly: AssemblyTitle("SentryGunScripts")]
[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.SentryGun
{
public class SentryGun : MonoBehaviour
{
public enum State
{
Idle,
OutOfAmmo,
Buildup,
Shooting,
Reloading,
Inactive,
Searching,
Aiming,
Firing
}
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 muzzleFlashPrefab;
public Transform gunTrigger;
internal HurtCollider hurtCollider;
public Sound targetLock;
public Sound OutOfPower;
public Sound Activate;
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;
private RoomVolumeCheck roomVolumeCheck;
internal float stateTimer;
internal float stateTimeMax;
internal State stateCurrent;
private State statePrev;
private bool stateStart;
private ItemEquippable itemEquippable;
public GameObject gunSection;
public GameObject laserRef;
public GameObject enabledColliders;
public GameObject disabledColliders;
public float SentryRange;
private bool lastState = true;
private Transform currentTarget;
private List<EnemyRigidbody> enemiesInVision = new List<EnemyRigidbody>();
private Animator animControl;
public float listUpdateTime = 1f;
private float listUpdateTimer = 0f;
private float resetTimer = 0f;
private float stateChangeTimer = 0f;
public Transform gunDefaultPosition;
public LineRenderer triggerLine;
public ParticleSystem lineParticles;
private float turretRotationTimer = 0f;
private void Start()
{
roomVolumeCheck = ((Component)this).GetComponent<RoomVolumeCheck>();
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>();
animControl = ((Component)this).GetComponent<Animator>();
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 List<EnemyRigidbody> enemiesInRangeCheck()
{
//IL_0024: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: 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_0093: Unknown result type (might be due to invalid IL or missing references)
List<EnemyRigidbody> list = new List<EnemyRigidbody>();
EnemyRigidbody[] array = Object.FindObjectsOfType<EnemyRigidbody>();
EnemyRigidbody[] array2 = array;
Ray val3 = default(Ray);
RaycastHit val4 = default(RaycastHit);
foreach (EnemyRigidbody val in array2)
{
Vector3 val2 = ((Component)val).transform.position - gunSection.transform.position;
if (!(((Vector3)(ref val2)).magnitude > SentryRange))
{
((Ray)(ref val3))..ctor(gunSection.transform.position, ((Component)val).transform.position - gunSection.transform.position);
if (Physics.Raycast(val3, ref val4, SentryRange, LayerMask.GetMask(new string[2] { "PhysGrabObject", "Default" })) && ((Component)((Component)((RaycastHit)(ref val4)).collider).transform.parent).tag == "Enemy")
{
list.Add(val);
}
}
}
return list;
}
private void TriggerLineVisuals()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (itemToggle.toggleState)
{
((Renderer)triggerLine).material.SetTextureOffset("_MainTex", new Vector2((0f - Time.time) * 2f, 0f));
if (!((Renderer)triggerLine).enabled)
{
((Renderer)triggerLine).enabled = true;
lineParticles.Play();
}
triggerLine.widthMultiplier = Mathf.Lerp(triggerLine.widthMultiplier, 1f, Time.deltaTime * 4f);
}
else if (((Renderer)triggerLine).enabled)
{
triggerLine.widthMultiplier = Mathf.Lerp(triggerLine.widthMultiplier, 0f, Time.deltaTime * 8f);
if (triggerLine.widthMultiplier < 0.01f)
{
((Renderer)triggerLine).enabled = false;
lineParticles.Stop();
}
}
}
private void turretCheck()
{
//IL_008a: 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_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
if (itemToggle.toggleState == lastState)
{
return;
}
lastState = itemToggle.toggleState;
if (itemToggle.toggleState)
{
num = 2;
if (itemBattery.batteryLifeInt > 0)
{
StateSet(State.Searching);
}
else
{
StateSet(State.OutOfAmmo);
}
}
else
{
gunSection.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
num = 1;
StateSet(State.Inactive);
}
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("GunColliderChangeRPC", (RpcTarget)0, Array.Empty<object>());
photonView.RPC("ChangeAnimations", (RpcTarget)0, new object[1] { num });
photonView.RPC("PlaySFXRPC", (RpcTarget)0, new object[1] { 2 });
}
else
{
GunColliderChangeRPC();
ChangeAnimations(num);
PlaySFXRPC(2);
}
}
}
private Transform getClosestTarget()
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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)
Transform val = null;
if (enemiesInVision.Count <= 0)
{
return gunDefaultPosition;
}
foreach (EnemyRigidbody item in enemiesInVision)
{
if ((Object)(object)val == (Object)null)
{
val = ((Component)item).transform;
}
else if (Vector3.Distance(((Component)item).transform.position, gunMuzzle.position) < Vector3.Distance(val.position, gunMuzzle.position))
{
val = ((Component)item).transform;
}
}
return val;
}
private void turretRotation(bool _firing)
{
//IL_0073: 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)
currentTarget = getClosestTarget();
turretRotationTimer += Time.deltaTime;
if (!((double)turretRotationTimer > 0.0625))
{
return;
}
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("turretRotationRPC", (RpcTarget)0, new object[1] { _firing });
}
else
{
turretRotationRPC(_firing);
}
}
turretRotationTimer = 0f;
}
[PunRPC]
private void turretRotationRPC(bool firing, PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: 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_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: 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_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: 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_0165: 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_0189: 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_0038: 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)
if (!SemiFunc.MasterOnlyRPC(_info))
{
return;
}
if (stateCurrent == State.Aiming)
{
Ray val = default(Ray);
((Ray)(ref val))..ctor(gunMuzzle.position, gunMuzzle.forward);
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(val, ref val2, SentryRange, LayerMask.GetMask(new string[2] { "PhysGrabObject", "Default" })) && ((Component)((Component)((RaycastHit)(ref val2)).collider).transform.parent).tag == "Enemy" && !firing)
{
ShootLogic();
}
}
Vector3 position = gunSection.transform.position;
Vector3 forward = gunSection.transform.forward;
Vector3 val3 = gunSection.transform.position - currentTarget.position;
Vector3 val4 = position + forward * ((Vector3)(ref val3)).magnitude;
Vector3 val5 = val4 + (currentTarget.position - val4) / 10f;
gunSection.transform.forward = Vector3.Normalize(val5 - gunSection.transform.position);
gunSection.transform.localEulerAngles = new Vector3(gunSection.transform.localEulerAngles.x, gunSection.transform.localEulerAngles.y, 0f);
}
private void Update()
{
//IL_016c: 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)
if ((Object)(object)itemEquippable == (Object)null || (Object)(object)physGrabObject == (Object)null || (Object)(object)itemToggle == (Object)null || (Object)(object)itemBattery == (Object)null || (Object)(object)photonView == (Object)null || (Object)(object)impactDetector == (Object)null || triggerAnimationCurve == null)
{
return;
}
TriggerLineVisuals();
turretCheck();
if (itemToggle.toggleState)
{
((Component)this).GetComponent<Rigidbody>().mass = 15f;
listUpdateTimer += Time.deltaTime;
if (listUpdateTimer >= listUpdateTime)
{
listUpdateTimer = 0f;
enemiesInVision = enemiesInRangeCheck();
}
}
else
{
((Component)this).GetComponent<Rigidbody>().mass = 1f;
}
StateMachine(_fixedUpdate: false);
if (!physGrabObject.grabbed || physGrabObject.grabbedLocal)
{
}
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);
physGrabObject.OverrideExtraTorqueStrengthDisable(0.1f);
physGrabObject.OverrideExtraGrabStrengthDisable(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 (!roomVolumeCheck.inTruck && !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.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;
}
[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_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: 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_020e: 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_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: 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_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: 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_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: 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_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
if (!SemiFunc.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)
{
EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, investigateRadius, false);
}
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 endPosition = 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" })))
{
endPosition = ((RaycastHit)(ref val4)).point;
hit = true;
}
else
{
flag = true;
}
if (flag)
{
endPosition = gunMuzzle.position + gunMuzzle.forward * gunRange;
hit = true;
}
ShootBullet(endPosition, hit);
}
}
private void ShootBullet(Vector3 _endPosition, 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] { _endPosition, _hit });
}
else
{
ShootBulletRPC(_endPosition, _hit);
}
}
}
[PunRPC]
public void ShootBulletRPC(Vector3 _endPosition, bool _hit, PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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_0097: 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)
if (!SemiFunc.MasterOnlyRPC(_info))
{
return;
}
if (physGrabObject.playerGrabbing.Count > 1)
{
foreach (PhysGrabber item in physGrabObject.playerGrabbing)
{
item.OverrideGrabRelease();
}
}
ItemGunBullet component = Object.Instantiate<GameObject>(bulletPrefab, gunMuzzle.position, gunMuzzle.rotation).GetComponent<ItemGunBullet>();
component.hitPosition = _endPosition;
component.bulletHit = _hit;
hurtCollider = ((Component)component).GetComponentInChildren<HurtCollider>();
soundHit.Play(_endPosition, 1f, 1f, 1f, 1f);
component.shootLineWidthCurve = shootLineWidthCurve;
component.ActivateAll();
}
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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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)
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (itemBattery.batteryLifeInt <= 0)
{
soundNoAmmoClick.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
StartTriggerAnimation();
physGrabObject.rb.AddForceAtPosition(-gunMuzzle.forward * 1f, gunMuzzle.position, (ForceMode)1);
}
else
{
Shoot();
}
}
}
[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 (SemiFunc.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;
case State.Searching:
StateSearching(_fixedUpdate);
break;
case State.Inactive:
StateInactive(_fixedUpdate);
break;
case State.Aiming:
StateAiming(_fixedUpdate);
break;
}
}
private void StateIdle(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
stateStart = false;
prevToggleState = itemToggle.toggleState;
}
if (!_fixedUpdate && hasIdleUpdate)
{
onStateIdleUpdate.Invoke();
}
if (_fixedUpdate && hasIdleFixedUpdate)
{
onStateIdleFixedUpdate.Invoke();
}
}
private void StateOutOfAmmo(bool _fixedUpdate)
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
if (stateStart && !_fixedUpdate)
{
laserRef.SetActive(false);
if (onStateOutOfAmmoStart != null)
{
onStateOutOfAmmoStart.Invoke();
}
stateStart = false;
prevToggleState = itemToggle.toggleState;
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("PlaySFXRPC", (RpcTarget)0, new object[1] { 1 });
}
else
{
PlaySFXRPC(1);
}
}
}
if (!_fixedUpdate)
{
if (itemBattery.batteryLifeInt > 0)
{
StateSet(State.Idle);
return;
}
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)
{
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
if (stateStart && !_fixedUpdate)
{
stateStart = false;
turretRotation(_firing: true);
if (!hasOneShot)
{
stateTimeMax = shootTime;
stateTimer = 0f;
investigateCooldown = 0f;
}
else
{
stateTimer = 0.001f;
}
if (itemBattery.batteryLifeInt > 0)
{
itemBattery.RemoveFullBar(1);
}
}
if (!_fixedUpdate)
{
if (enemiesInVision.Count > 0)
{
turretRotation(_firing: true);
}
else
{
StateSet(State.Aiming);
}
if (investigateRadius > 0f)
{
if (investigateCooldown <= 0f)
{
EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, investigateRadius, false);
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;
turretRotation(_firing: true);
if (onStateReloadingStart != null)
{
onStateReloadingStart.Invoke();
}
stateTimeMax = shootCooldown;
stateTimer = 0f;
}
if (!_fixedUpdate)
{
if (enemiesInVision.Count > 0)
{
turretRotation(_firing: true);
}
else
{
StateSet(State.Aiming);
}
stateTimer += Time.deltaTime;
if (stateTimer >= stateTimeMax)
{
if (itemBattery.batteryLifeInt > 0)
{
StateSet(State.Aiming);
}
else
{
StateSet(State.OutOfAmmo);
}
}
if (hasReloadingUpdate)
{
onStateReloadingUpdate.Invoke();
}
}
if (_fixedUpdate && hasReloadingFixedUpdate)
{
onStateReloadingFixedUpdate.Invoke();
}
}
private void StateInactive(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
stateStart = false;
}
if (_fixedUpdate)
{
}
}
private void StateSearching(bool _fixedUpdate)
{
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
if (stateStart && !_fixedUpdate)
{
stateStart = false;
if (enemiesInVision.Count > 0)
{
StateSet(State.Aiming);
}
}
if (_fixedUpdate)
{
return;
}
if (stateChangeTimer > 0f)
{
stateChangeTimer -= Time.deltaTime;
return;
}
((Behaviour)animControl).enabled = false;
if (enemiesInVision.Count > 0)
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("PlaySFXRPC", (RpcTarget)0, new object[1] { 0 });
}
else
{
PlaySFXRPC(0);
}
}
StateSet(State.Aiming);
}
if (resetTimer < 1f)
{
turretRotation(_firing: true);
}
if (resetTimer <= 0f)
{
resetTimer = 1.5f;
gunDefaultPosition.localPosition = new Vector3(0f - gunDefaultPosition.localPosition.x, gunDefaultPosition.localPosition.y, gunDefaultPosition.localPosition.z);
}
if (resetTimer >= 0f)
{
resetTimer -= Time.deltaTime;
}
}
private void StateAiming(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
stateStart = false;
turretRotation(_firing: false);
}
if (!_fixedUpdate)
{
if (enemiesInVision.Count > 0)
{
turretRotation(_firing: false);
return;
}
resetTimer = 4f;
StateSet(State.Searching);
}
}
private void StateFiring(bool _fixedUpdate)
{
if (stateStart && !_fixedUpdate)
{
stateStart = false;
stateTimeMax = shootTime;
stateTimer = 0f;
}
if (_fixedUpdate)
{
}
}
[PunRPC]
private void GunColliderChangeRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: 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 (SemiFunc.MasterOnlyRPC(_info))
{
if (itemToggle.toggleState)
{
enabledColliders.SetActive(true);
disabledColliders.SetActive(false);
gunSection.transform.localPosition = new Vector3(gunSection.transform.localPosition.x, 0.6f, gunSection.transform.localPosition.z);
}
else
{
((Component)this).GetComponent<Rigidbody>().mass = 1f;
enabledColliders.SetActive(false);
disabledColliders.SetActive(true);
gunSection.transform.localPosition = new Vector3(gunSection.transform.localPosition.x, 0f, gunSection.transform.localPosition.z);
}
}
}
[PunRPC]
private void PlaySFXRPC(int soundIndex, PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: 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)
if (SemiFunc.MasterOnlyRPC(_info))
{
if (targetLock != null)
{
targetLock.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
switch (soundIndex)
{
case 0:
targetLock.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
break;
case 1:
OutOfPower.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
break;
case 2:
Activate.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
break;
}
}
}
[PunRPC]
private void ChangeAnimations(int givenAnim, PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.MasterOnlyRPC(_info))
{
((Behaviour)animControl).enabled = true;
stateChangeTimer = 1f;
switch (givenAnim)
{
case 0:
animControl.Play("InActive");
break;
case 1:
animControl.Play("TearDown");
laserRef.SetActive(false);
break;
case 2:
animControl.Play("SetUp");
laserRef.SetActive(true);
break;
}
}
}
}
}
namespace SentryGunScripts
{
[HarmonyPatch(typeof(PlayerController))]
internal static class ExamplePlayerControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
private static void Start_Prefix(PlayerController __instance)
{
SentryGunScripts.Logger.LogDebug((object)$"{__instance} Start Prefix");
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerController __instance)
{
SentryGunScripts.Logger.LogDebug((object)$"{__instance} Start Postfix");
}
}
[BepInPlugin("SammyCadian.SentryGunScripts", "SentryGunScripts", "1.0")]
public class SentryGunScripts : BaseUnityPlugin
{
internal static SentryGunScripts Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
internal SentryGun? sentryGunInstance { get; private set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
sentryGunInstance = ((Component)this).gameObject.AddComponent<SentryGun>();
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()
{
}
}
}