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 UnityEngine;
[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("Wakaura")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TheSniperRifle")]
[assembly: AssemblyTitle("TheSniperRifle")]
[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 TheSniperRifle
{
public class SniperLaserDot : MonoBehaviour
{
public enum ToggleMode
{
standard,
force,
reset
}
private bool requirementPassed = false;
internal int playerGrabberPhotonID;
private PhotonView? photonView;
private PlayerAvatar? theGrabber;
private PhysGrabObject? physGrabObject;
private ItemEquippable? itemEquippable;
private Transform? laserOrigin;
private GameObject? laserDot;
private ItemBattery? itemBattery;
private float batteryMinimumDrainAmount = 0.5f;
private float drainRate = 0.1f;
public bool isEnabled = false;
public float maxDistance = 100f;
public LayerMask hitLayers = LayerMask.op_Implicit(0);
public Sound? soundToggleEnable;
public Sound? soundToggleDisable;
private bool isCoolDown = false;
private static readonly float toggleCoolDownSetter = 0.5f;
private float toggleCoolDown = 0f;
private bool isEquipped => (Object)(object)itemEquippable != (Object)null && itemEquippable.IsEquipped();
private bool isGrabbedByLocalPlayer => (Object)(object)physGrabObject != (Object)null && !SemiFunc.IsMultiplayer() && physGrabObject.playerGrabbing.Count > 0;
private bool isGrabbedByMeInMultiplayer
{
get
{
if (!SemiFunc.IsMultiplayer() || (Object)(object)physGrabObject == (Object)null || physGrabObject.playerGrabbing.Count < 1)
{
return false;
}
if (physGrabObject.grabbed)
{
foreach (PhysGrabber item in physGrabObject.playerGrabbing)
{
if (item.photonView.IsMine)
{
return true;
}
}
}
return false;
}
}
private bool hasBatteryPower => (Object)(object)itemBattery == (Object)null || ((Object)(object)itemBattery != (Object)null && itemBattery.batteryLife > 0f);
private void ActiveCoolDownTimer()
{
toggleCoolDown = toggleCoolDownSetter;
}
private void TryDrainBattery(bool state)
{
if (hasBatteryPower)
{
itemBattery.Drain(drainRate);
}
}
private void UpdateLaserDot()
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_00ad: 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_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: 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_012e: Unknown result type (might be due to invalid IL or missing references)
if (!requirementPassed)
{
return;
}
if (!isEnabled)
{
if (((Component)laserOrigin).gameObject.activeSelf)
{
((Component)laserOrigin).gameObject.SetActive(false);
}
}
else
{
if (!isEnabled)
{
return;
}
if (!((Component)laserOrigin).gameObject.activeSelf)
{
((Component)laserOrigin).gameObject.SetActive(true);
}
Ray val = default(Ray);
((Ray)(ref val))..ctor(laserOrigin.position, laserOrigin.forward);
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(val, ref val2, maxDistance, LayerMask.op_Implicit(hitLayers)))
{
if (!laserDot.gameObject.activeSelf)
{
laserDot.gameObject.SetActive(true);
}
laserDot.transform.position = ((RaycastHit)(ref val2)).point + ((RaycastHit)(ref val2)).normal * 0.01f;
laserDot.transform.rotation = Quaternion.LookRotation(((RaycastHit)(ref val2)).normal);
}
else
{
laserDot.SetActive(false);
}
}
}
private void ToggleLaserDotLogic(int t)
{
switch (t)
{
case 0:
isEnabled = hasBatteryPower && !isEnabled;
break;
case 1:
if (!isEnabled)
{
isEnabled = (hasBatteryPower ? true : false);
}
break;
case 2:
if (isEnabled)
{
isEnabled = false;
}
break;
}
TSRHelperFunc.ToggleSound(isEnabled, (Sound[])(object)new Sound[2] { soundToggleDisable, soundToggleEnable }, ((Component)this).gameObject);
}
[PunRPC]
private void ToggleLaserDotRPC(int t)
{
ToggleLaserDotLogic(t);
}
public void ToggleLaserDot(ToggleMode t = ToggleMode.standard)
{
if ((t != ToggleMode.reset || isEnabled) && (t != ToggleMode.force || !isEnabled))
{
ActiveCoolDownTimer();
if (SemiFunc.IsMultiplayer() && (Object)(object)photonView != (Object)null)
{
photonView.RPC("ToggleLaserDotRPC", (RpcTarget)0, new object[1] { (int)t });
}
else
{
ToggleLaserDotLogic((int)t);
}
}
}
private void Awake()
{
laserOrigin = ((Component)this).transform.Find("Laser Dot");
Transform? obj = laserOrigin;
laserDot = ((obj != null) ? ((Component)((Component)obj).transform.GetChild(0)).gameObject : null);
itemBattery = ((Component)this).GetComponent<ItemBattery>();
photonView = ((Component)this).GetComponent<PhotonView>();
physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
if ((Object)(object)laserDot != (Object)null && (Object)(object)laserOrigin != (Object)null && (Object)(object)photonView != (Object)null && (Object)(object)physGrabObject != (Object)null && (Object)(object)itemEquippable != (Object)null)
{
requirementPassed = true;
}
}
private void Update()
{
if (requirementPassed)
{
isCoolDown = TSRHelperFunc.CountDown(ref toggleCoolDown);
if (isEquipped && isEnabled)
{
ToggleLaserDot(ToggleMode.reset);
}
if ((isGrabbedByLocalPlayer || isGrabbedByMeInMultiplayer) && Input.GetKeyDown((KeyCode)120) && !isCoolDown)
{
ToggleLaserDot();
}
TryDrainBattery(isEnabled);
UpdateLaserDot();
}
}
}
public class ItemSniperGun : MonoBehaviour
{
private enum ZoomToggleMode
{
standard,
reset,
force
}
private Dictionary<string, (string message, bool printed)> debugMessages = new Dictionary<string, (string, bool)>
{
{
"SniperReady",
("Sniper Rifle is ready.", false)
},
{
"SkipSpreadAdjustment",
("This weapon has no random spread; the suppression will be skipped.", false)
},
{
"PenetrateBullet",
("Penetrating bullet can only be shoot in the zoom mode.", false)
}
};
private bool requirementPassed = false;
private float cameraZoom_FOV1_min = 5f;
private float cameraZoom_FOV1_ori = 10f;
private float[] cameraZoom_FOV = new float[2] { 70f, 10f };
private ItemGun? itemGun;
public int AdditionalTarget = 1;
private ItemEquippable? itemEquippable;
private ItemBattery? itemBattery;
private Rigidbody? physGrabObjectCompRb;
private SniperLaserDot? laserDot;
internal int playerGrabberPhotonID;
private PhotonView? photonView;
private PlayerAvatar? theGrabber;
private CameraZoom? cameraZoom;
private PhysGrabObject? physGrabObject;
private bool hasNewGrabber = false;
private MapToolController? mapToolController;
private GameObject? reloadingIndicator;
private GameObject? zoomTarget;
private GameObject? mesh;
private List<GameObject> toggledObjectList = new List<GameObject>();
public bool zoomMode = false;
private float aimVerticalAdjust = -5.4f;
private float aimVerticalOffset_ori = -1f;
private float torqueMultiplierAdjust = 2f;
private float torqueMultiplier_ori = 1f;
private float gunRandomSpread_ori = -1f;
private int[] enemyHurtDamage = new int[2] { 250, 355 };
private bool rb_overrided = false;
[Range(0f, 1f)]
public float gunRandomSpreadSurpress = 0f;
public Sound? soundToggleZoomModeEnable;
public Sound? soundToggleZoomModeDisable;
public Sound? soundToggleZoomModeUnavailable;
public Sound? soundTuning;
private bool isEquipped => (Object)(object)itemEquippable != (Object)null && itemEquippable.IsEquipped();
private bool hasBatteryPower => (Object)(object)itemBattery == (Object)null || ((Object)(object)itemBattery != (Object)null && itemBattery.batteryLife > 0f);
private bool isGrabbedByLocalPlayer => (Object)(object)physGrabObject != (Object)null && !SemiFunc.IsMultiplayer() && physGrabObject.playerGrabbing.Count > 0;
private bool isGrabbedByMultiple => (Object)(object)physGrabObject != (Object)null && physGrabObject.playerGrabbing.Count > 1;
private bool isGrabbedByMeOnly => (Object)(object)physGrabObject != (Object)null && (Object)(object)theGrabber != (Object)null && theGrabber.photonView.IsMine && !isGrabbedByMultiple;
private bool hasGrabberInfo => (Object)(object)theGrabber != (Object)null && (Object)(object)mapToolController != (Object)null && (Object)(object)cameraZoom != (Object)null;
private bool hasMultiplayerGrabberInfo => hasGrabberInfo && playerGrabberPhotonID != -1;
private bool isGrabberMapActive => (Object)(object)mapToolController != (Object)null && TSRHelperFunc.GetFieldValueAsBool(mapToolController, "Active");
public bool IsReloading
{
get
{
if ((Object)(object)itemGun == (Object)null)
{
return false;
}
string fieldValueAsString = TSRHelperFunc.GetFieldValueAsString(itemGun, "stateCurrent");
if (fieldValueAsString == null)
{
return false;
}
return fieldValueAsString == "Reloading";
}
}
public bool EnterReloading
{
get
{
if ((Object)(object)itemGun == (Object)null)
{
return false;
}
string fieldValueAsString = TSRHelperFunc.GetFieldValueAsString(itemGun, "stateCurrent");
string fieldValueAsString2 = TSRHelperFunc.GetFieldValueAsString(itemGun, "statePrev");
if (fieldValueAsString == null || fieldValueAsString2 == null)
{
return false;
}
return fieldValueAsString != fieldValueAsString2 && fieldValueAsString == "Reloading";
}
}
private void PrintOneTimeMessages(string key)
{
(string, bool) tuple = debugMessages[key];
if (!tuple.Item2)
{
debugMessages[key] = (tuple.Item1, true);
Debug.Log((object)tuple.Item1);
}
}
public void ShootPiercingBullet()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: 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_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_00ba: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: 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)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)itemGun == (Object)null)
{
return;
}
if (zoomMode && AdditionalTarget > 0)
{
Vector3[] array = (Vector3[])(object)new Vector3[1] { itemGun.gunMuzzle.position };
bool flag = false;
bool flag2 = false;
Vector3 val = itemGun.gunMuzzle.forward;
if (itemGun.gunRandomSpread > 0f)
{
float num = Random.Range(0f, itemGun.gunRandomSpread / 2f);
float num2 = Random.Range(0f, 360f);
Vector3 val2 = Vector3.Cross(val, Random.onUnitSphere);
Vector3 normalized = ((Vector3)(ref val2)).normalized;
Quaternion val3 = Quaternion.AngleAxis(num, normalized);
val2 = Quaternion.AngleAxis(num2, val) * val3 * val;
val = ((Vector3)(ref val2)).normalized;
}
int num3 = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "Enemy" });
Ray val4 = default(Ray);
((Ray)(ref val4))..ctor(itemGun.gunMuzzle.position, val);
RaycastHit[] array2 = Physics.RaycastAll(val4, itemGun.gunRange, num3);
Array.Sort(array2, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
if (array2.Length > 1)
{
int num4 = ((AdditionalTarget + 1 > array2.Length) ? array2.Length : (AdditionalTarget + 1));
array = (Vector3[])(object)new Vector3[num4];
for (int i = 1; i < num4; i++)
{
array[i] = ((RaycastHit)(ref array2[i])).point;
}
flag = true;
}
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
if (SemiFunc.IsMultiplayer())
{
for (int j = 1; j < array.Length; j++)
{
photonView.RPC("ShootBulletRPC", (RpcTarget)0, new object[2]
{
array[j],
flag
});
}
}
else
{
for (int k = 1; k < array.Length; k++)
{
itemGun.ShootBulletRPC(array[k], flag, default(PhotonMessageInfo));
}
}
}
else if (!zoomMode && AdditionalTarget > 0)
{
PrintOneTimeMessages("PenetrateBullet");
}
}
private void OverrideFOV()
{
if ((Object)(object)cameraZoom != (Object)null)
{
cameraZoom.OverrideZoomSet(cameraZoom_FOV[1], 0.05f, 2f, 2f, zoomTarget ?? ((Component)this).gameObject, 50);
}
}
private void HideMesh(bool state)
{
if (!((Object)(object)mesh == (Object)null))
{
if (mesh.activeSelf && state)
{
mesh.SetActive(false);
}
else
{
mesh.SetActive(true);
}
}
}
private void ToggleGameObjectLogic(bool state, int index)
{
if (toggledObjectList != null && !((Object)(object)toggledObjectList[index] == (Object)null))
{
toggledObjectList[index].SetActive(state);
}
}
[PunRPC]
private void ToggleGameObjectRPC(bool state, int index)
{
ToggleGameObjectLogic(state, index);
}
private void ToggleGameObject(bool state, int index, bool globalSignal = false)
{
if (toggledObjectList != null && !((Object)(object)toggledObjectList[index] == (Object)null))
{
if (globalSignal && SemiFunc.IsMultiplayer() && (Object)(object)photonView != (Object)null)
{
photonView.RPC("ToggleGameObjectRPC", (RpcTarget)0, new object[2] { state, index });
}
else
{
ToggleGameObjectLogic(state, index);
}
}
}
private void UpdateBulletPrefabHurtDamage(bool increased)
{
if (!((Object)(object)itemGun == (Object)null))
{
HurtCollider component = ((Component)itemGun.bulletPrefab.transform.Find("Hurt Collider")).GetComponent<HurtCollider>();
component.enemyDamage = (increased ? enemyHurtDamage[1] : enemyHurtDamage[0]);
component.playerDamage = (increased ? enemyHurtDamage[1] : enemyHurtDamage[0]);
}
}
private void ApplyFocusMode(bool state)
{
if (!((Object)(object)itemGun == (Object)null))
{
float gunRandomSpread = itemGun.gunRandomSpread;
float aimVerticalOffset = itemGun.aimVerticalOffset;
float torqueMultiplier = itemGun.torqueMultiplier;
if (gunRandomSpread > 0f)
{
StateChooser(state, gunRandomSpread, new float[2]
{
gunRandomSpread_ori,
gunRandomSpread_ori * gunRandomSpreadSurpress
}, ref itemGun.gunRandomSpread);
}
else
{
PrintOneTimeMessages("SkipSpreadAdjustment");
}
StateChooser(state, aimVerticalOffset, new float[2] { aimVerticalOffset_ori, aimVerticalAdjust }, ref itemGun.aimVerticalOffset);
StateChooser(state, torqueMultiplier, new float[2] { torqueMultiplier_ori, torqueMultiplierAdjust }, ref itemGun.torqueMultiplier);
}
static void StateChooser(bool b, float v_cur, float[] v, ref float v_toAssign)
{
if (b && v_cur != v[1])
{
v_toAssign = v[1];
}
else if (!b && v_cur != v[0])
{
v_toAssign = v[0];
}
}
}
private void ApplyStableGrab(bool state)
{
//IL_0054: 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_0078: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)physGrabObject == (Object)null)
{
return;
}
if (state)
{
if (!SemiFunc.IsMultiplayer() || isGrabbedByMeOnly)
{
if ((Object)(object)physGrabObjectCompRb != (Object)null)
{
physGrabObjectCompRb.rotation = Quaternion.Slerp(physGrabObjectCompRb.rotation, TSRHelperFunc.GetFieldValueAsQuaternion(PlayerController.instance.cameraAim, "playerAim"), 10f * Time.fixedDeltaTime);
physGrabObjectCompRb.constraints = (RigidbodyConstraints)80;
}
physGrabObject.OverrideMass(Mathf.Max(SemiFunc.PlayerAvatarLocal().physGrabber.grabStrength / 2f, 0.5f), 0.1f);
physGrabObject.OverrideGrabStrength(2f, 0.1f);
physGrabObject.OverrideTorqueStrength(5f, 0.1f);
physGrabObject.OverrideDrag(2f, 0.1f);
physGrabObject.OverrideAngularDrag(10f, 0.1f);
}
}
else if ((Object)(object)physGrabObjectCompRb != (Object)null)
{
physGrabObjectCompRb.constraints = (RigidbodyConstraints)0;
rb_overrided = false;
}
}
private void ClearGrabberInfo()
{
if (!((Object)(object)mapToolController == (Object)null) || !((Object)(object)cameraZoom == (Object)null) || !((Object)(object)theGrabber == (Object)null))
{
cameraZoom = null;
mapToolController = null;
theGrabber = null;
}
}
private void UpdateGrabberInfo()
{
if ((Object)(object)physGrabObject == (Object)null || physGrabObject.playerGrabbing.Count < 1)
{
return;
}
if (isGrabbedByLocalPlayer)
{
TryAssignNewGrabber(physGrabObject.playerGrabbing[physGrabObject.playerGrabbing.Count - 1].playerAvatar);
return;
}
PlayerAvatar playerAvatar = physGrabObject.playerGrabbing[physGrabObject.playerGrabbing.Count - 1].playerAvatar;
if (!((Object)(object)playerAvatar == (Object)null))
{
TryAssignNewGrabber(playerAvatar);
}
bool SetGrabberInfo(PlayerAvatar g)
{
if ((Object)(object)g != (Object)null)
{
theGrabber = g;
mapToolController = theGrabber?.mapToolController;
cameraZoom = CameraZoom.Instance;
playerGrabberPhotonID = (SemiFunc.IsMultiplayer() ? g.photonView.ViewID : (-1));
return true;
}
return false;
}
bool TryAssignNewGrabber(PlayerAvatar grabber)
{
if ((Object)(object)grabber == (Object)null)
{
return false;
}
if (!SemiFunc.IsMultiplayer())
{
if (hasGrabberInfo)
{
return false;
}
if (!hasGrabberInfo)
{
return SetGrabberInfo(grabber);
}
}
else if ((hasMultiplayerGrabberInfo && grabber.photonView.ViewID != playerGrabberPhotonID) || !hasGrabberInfo)
{
hasNewGrabber = true;
return SetGrabberInfo(grabber);
}
return false;
}
}
private bool IsBeingGrabbed()
{
if ((Object)(object)physGrabObject == (Object)null)
{
return false;
}
bool grabbed = physGrabObject.grabbed;
if (grabbed)
{
UpdateGrabberInfo();
}
if (!grabbed)
{
ClearGrabberInfo();
}
return grabbed;
}
private void ResetTargetFOV()
{
if (cameraZoom_FOV[1] != cameraZoom_FOV1_ori)
{
cameraZoom_FOV[1] = cameraZoom_FOV1_ori;
}
}
private void UpdateTargetFOV(float v)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
float num = cameraZoom_FOV[1] + v;
cameraZoom_FOV[1] = ((!(num < cameraZoom_FOV1_min)) ? num : ((num > cameraZoom_FOV[0]) ? cameraZoom_FOV[0] : num));
Sound? obj = soundTuning;
if (obj != null)
{
obj.Play(((Component)this).gameObject.transform.position, 1f, 1f, 1f, 1f);
}
}
private int GetMouseScrollEvent()
{
float axis = Input.GetAxis("Mouse ScrollWheel");
return (axis > 0f) ? 1 : ((axis < 0f) ? (-1) : 0);
}
private void MonitorMouseScrollEvent()
{
if (!SemiFunc.IsMultiplayer() || isGrabbedByMeOnly)
{
if (GetMouseScrollEvent() == 1)
{
UpdateTargetFOV(-0.1f);
}
if (GetMouseScrollEvent() == -1)
{
UpdateTargetFOV(0.1f);
}
}
}
private void MoniterReloadingState()
{
if ((Object)(object)reloadingIndicator != (Object)null)
{
if (IsReloading && !reloadingIndicator.activeSelf)
{
reloadingIndicator.SetActive(true);
}
if (!IsReloading && reloadingIndicator.activeSelf)
{
reloadingIndicator.SetActive(false);
}
}
}
private bool CheckPassees()
{
bool flag = (Object)(object)itemGun != (Object)null;
bool flag2 = (Object)(object)itemEquippable != (Object)null;
bool flag3 = (Object)(object)physGrabObject != (Object)null && (Object)(object)physGrabObjectCompRb != (Object)null;
bool flag4 = (Object)(object)photonView != (Object)null;
requirementPassed = flag && flag2 && flag3 && flag4;
return requirementPassed;
}
private void ToggleZoom(ZoomToggleMode z = ZoomToggleMode.standard)
{
if (!SemiFunc.IsMultiplayer() || isGrabbedByMeOnly)
{
ToggleZoomLogic(z);
}
else if (z == ZoomToggleMode.reset)
{
ToggleZoomLogic(z);
}
void ToggleZoomLogic(ZoomToggleMode z = ZoomToggleMode.standard)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
switch (z)
{
case ZoomToggleMode.standard:
if (hasBatteryPower)
{
toggle(!zoomMode);
}
else
{
zoomMode = false;
if (soundToggleZoomModeUnavailable != null)
{
soundToggleZoomModeUnavailable.Play(((Component)this).gameObject.transform.position, 1f, 1f, 1f, 1f);
}
}
break;
case ZoomToggleMode.reset:
if (zoomMode)
{
toggle(t: false);
}
break;
case ZoomToggleMode.force:
if (!zoomMode)
{
toggle(t: true);
}
break;
}
if (hasNewGrabber)
{
hasNewGrabber = false;
}
}
void toggle(bool t)
{
if (zoomMode != t)
{
zoomMode = t;
ApplyFocusMode(t);
UpdateBulletPrefabHurtDamage(t);
HideMesh(t);
ToggleGameObject(t, 0, globalSignal: true);
if (!t)
{
ResetTargetFOV();
}
TSRHelperFunc.ToggleSound(t, (Sound[])(object)new Sound[2] { soundToggleZoomModeDisable, soundToggleZoomModeEnable }, ((Component)this).gameObject);
}
}
}
private void Awake()
{
laserDot = ((Component)this).GetComponent<SniperLaserDot>();
itemGun = ((Component)this).GetComponent<ItemGun>();
itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
itemBattery = ((Component)this).GetComponent<ItemBattery>();
photonView = ((Component)this).GetComponent<PhotonView>();
if ((Object)(object)laserDot != (Object)null)
{
laserDot.maxDistance = (((Object)(object)itemGun == (Object)null) ? laserDot.maxDistance : itemGun.gunRange);
}
if ((Object)(object)itemGun != (Object)null)
{
gunRandomSpread_ori = itemGun.gunRandomSpread;
aimVerticalOffset_ori = itemGun.aimVerticalOffset;
torqueMultiplier_ori = itemGun.torqueMultiplier;
}
if ((Object)(object)physGrabObject != (Object)null)
{
physGrabObjectCompRb = physGrabObject.rb;
}
zoomTarget = ((Component)((Component)this).gameObject.transform.Find("Focus Object")).gameObject;
reloadingIndicator = ((Component)((Component)this).transform.Find("Item Reloading")).gameObject;
mesh = ((Component)((Component)this).gameObject.transform.Find("Mesh")).gameObject;
toggledObjectList.Add(((Component)((Component)this).gameObject.transform.Find("Scope Light")).gameObject);
if (CheckPassees())
{
PrintOneTimeMessages("SniperReady");
}
}
private void FixedUpdate()
{
if (requirementPassed)
{
ApplyStableGrab(zoomMode);
}
}
private void Update()
{
if (!requirementPassed)
{
return;
}
MoniterReloadingState();
bool flag = IsBeingGrabbed();
if (!flag && zoomMode)
{
ToggleZoom(ZoomToggleMode.reset);
}
else
{
if (!flag)
{
return;
}
if (hasNewGrabber || isGrabbedByMultiple)
{
ToggleZoom(ZoomToggleMode.reset);
return;
}
if (zoomMode)
{
if (SemiFunc.InputDown((InputKey)2))
{
ShootPiercingBullet();
}
if (SemiFunc.InputDown((InputKey)8) || isEquipped || isGrabberMapActive || !hasBatteryPower)
{
ToggleZoom(ZoomToggleMode.reset);
return;
}
MonitorMouseScrollEvent();
OverrideFOV();
}
if (Input.GetKeyDown((KeyCode)122))
{
ToggleZoom();
}
}
}
}
[BepInPlugin("Wakaura.TheSniperRifle", "TheSniperRifle", "1.0")]
public class TheSniperRifle : BaseUnityPlugin
{
internal static TheSniperRifle Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
internal ItemSniperGun? ItemSniperRifle { get; private set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
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()
{
}
}
public static class TSRHelperFunc
{
public static (Component, Type)? CollectComponent(GameObject g, string compName)
{
Component component = g.GetComponent(compName);
if ((Object)(object)component != (Object)null)
{
return (component, ((object)component).GetType());
}
return null;
}
public static (GameObject, Type)? TryGetByType(string monobehaviour)
{
Type type = Type.GetType(monobehaviour);
if (type == null)
{
Debug.LogWarning((object)("Type " + monobehaviour + " not found."));
return null;
}
Object val = Object.FindObjectOfType(type);
if (val != (Object)null)
{
MonoBehaviour val2 = (MonoBehaviour)(object)((val is MonoBehaviour) ? val : null);
if (val2 != null)
{
GameObject gameObject = ((Component)val2).gameObject;
Debug.Log((object)(monobehaviour + " instance found via reflection."));
return (gameObject, ((object)val).GetType());
}
}
Debug.LogWarning((object)("No instance of " + monobehaviour + " found in the scene."));
return null;
}
public static object? GetFieldValue(object o, string fieldname)
{
FieldInfo field = o.GetType().GetField(fieldname, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field == null)
{
return null;
}
object value = field.GetValue(o);
if (value == null)
{
return null;
}
return value;
}
public static string? GetFieldValueAsString(object o, string fieldname)
{
object fieldValue = GetFieldValue(o, fieldname);
if (fieldValue == null)
{
return null;
}
return fieldValue?.ToString();
}
public static bool GetFieldValueAsBool(object o, string fieldname)
{
object fieldValue = GetFieldValue(o, fieldname);
if (fieldValue == null)
{
return false;
}
return (bool)fieldValue;
}
public static Quaternion GetFieldValueAsQuaternion(object o, string fieldname)
{
//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_0021: 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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
object fieldValue = GetFieldValue(o, fieldname);
if (fieldValue == null)
{
return Quaternion.identity;
}
return (Quaternion)fieldValue;
}
public static void ToggleSound(bool state, Sound[] sounds, GameObject playLoc)
{
//IL_001d: 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)
if (sounds != null)
{
if (!state)
{
sounds[0].Play(playLoc.transform.position, 1f, 1f, 1f, 1f);
}
else if (state)
{
sounds[1].Play(playLoc.transform.position, 1f, 1f, 1f, 1f);
}
}
}
public static bool CountDown(ref float t)
{
if (t > 0f)
{
t -= Time.deltaTime;
return true;
}
if (t < 0f)
{
t = 0f;
return false;
}
return false;
}
}
}