60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using Invector.vCharacterController;
|
|
using OnlyScove.Scripts;
|
|
|
|
namespace Invector.vShooter
|
|
{
|
|
[vClassHeader("Shooter Lock-On")]
|
|
public class vLockOnShooter : vLockOn
|
|
{
|
|
protected vShooterMeleeInput shooterMelee;
|
|
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
shooterMelee = this.tpInput as vShooterMeleeInput;
|
|
}
|
|
|
|
protected override void UpdateLockOn()
|
|
{
|
|
if (shooterMelee == null ||
|
|
shooterMelee.shooterManager == null ||
|
|
(shooterMelee.shooterManager.useLockOn && shooterMelee.shooterManager.rWeapon != null) ||
|
|
shooterMelee.shooterManager.useLockOnMeleeOnly && shooterMelee.shooterManager.rWeapon == null)
|
|
base.UpdateLockOn();
|
|
else if (isLockingOn && shooterMelee.shooterManager.rWeapon != null)
|
|
{
|
|
isLockingOn = false;
|
|
LockOn(false);
|
|
StopLockOn();
|
|
aimImage.transform.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
protected override void LockOnInput()
|
|
{
|
|
if (tpInput == null || tpInput.tpCamera == null || tpInput.cc == null || inputReader == null) return;
|
|
|
|
// lock the camera into a target, if there is any around
|
|
if (inputReader.ConsumeToggleView() && !tpInput.cc.customAction)
|
|
{
|
|
isLockingOn = !isLockingOn;
|
|
LockOn(isLockingOn);
|
|
}
|
|
// unlock the camera if the target is null
|
|
else if (isLockingOn && tpInput.tpCamera.lockTarget == null)
|
|
{
|
|
isLockingOn = false;
|
|
LockOn(false);
|
|
}
|
|
|
|
// choose to use lock-on with strafe of free movement
|
|
if (strafeWhileLockOn && !tpInput.cc.locomotionType.Equals(vThirdPersonMotor.LocomotionType.OnlyStrafe))
|
|
{
|
|
if (shooterMelee.isAimingByInput || (strafeWhileLockOn && isLockingOn && tpInput.tpCamera.lockTarget != null))
|
|
tpInput.cc.lockInStrafe = true;
|
|
else
|
|
tpInput.cc.lockInStrafe = false;
|
|
}
|
|
}
|
|
}
|
|
} |