Files
ZeroVR/ZeroPacientVR/Assets/HurricaneVR/Framework/Scripts/Weapons/HVRAmmoReleaseAction.cs
T
2022-04-18 19:17:20 +03:00

51 lines
1.4 KiB
C#

using System;
using HurricaneVR.Framework.ControllerInput;
using HurricaneVR.Framework.Core;
using HurricaneVR.Framework.Core.Grabbers;
using HurricaneVR.Framework.Shared;
using HurricaneVR.Framework.Weapons.Guns;
using UnityEngine;
namespace HurricaneVR.Framework.Weapons
{
public class HVRAmmoReleaseAction : HVRInputAction
{
public HVRRayCastGun HVRRayCastGun { get; private set; }
public HVRGunBase Gun { get; private set; }
protected override void Awake()
{
base.Awake();
HVRRayCastGun = GetComponent<HVRRayCastGun>();
Gun = GetComponent<HVRGunBase>();
}
protected override void CheckInput(HVRController controller)
{
var release = false;
if (controller.ControllerType == HVRControllerType.WMR)
{
release = controller.Side == HVRHandSide.Right ? controller.TrackPadLeft.JustActivated : controller.TrackPadRight.JustActivated;
}
else if (controller.ControllerType == HVRControllerType.Vive)
{
release = HVRInputManager.Instance.RightController.TrackPadDown.JustActivated;
}
else
{
release = controller.PrimaryButtonState.JustActivated;
}
if (release)
{
HVRRayCastGun?.ReleaseAmmo();
Gun?.ReleaseAmmo();
}
}
}
}