mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 05:50:18 +00:00
improve switching from aiming states to non-aiming states
This commit is contained in:
parent
7294320ff0
commit
8ddcb62ac8
5 changed files with 26 additions and 8 deletions
|
@ -131,6 +131,7 @@ MonoBehaviour:
|
|||
AIMWITHARM_upperArmEndRotationEulers: {x: 170, y: -90, z: -2.412}
|
||||
AIMWITHARM_maxAimAngle: 95
|
||||
AIMWITHARM_maxHeadRotationAngle: 50
|
||||
AIMWITHARM_timeUntilAbleToStopAimingBack: 0.33
|
||||
crouchSpineRotationOffset: {x: 0, y: 35, z: 90}
|
||||
crouchSpineRotationOffset2: {x: 0, y: 15, z: 90}
|
||||
projectileRaycastMask:
|
||||
|
@ -167,7 +168,11 @@ MonoBehaviour:
|
|||
revealRadius: 150
|
||||
timeToKeepRevealingAfterRemoved: 3
|
||||
minTimeToReturnToAimState: 0.33
|
||||
minTimeToReturnToNonAimStateFromAimState: 0.15
|
||||
minTimeToReturnToNonAimStateFromAimState: 0.25
|
||||
timeUntilMovementStateCanBeSwitchedToOtherMovementState: 0.166
|
||||
timeUntilMovementStateCanBeEnteredFromOtherMovementState: 0.166
|
||||
timeUntilAimMovementStateCanBeSwitchedToOtherAimMovementState: 0.166
|
||||
timeUntilAimMovementStateCanBeEnteredFromOtherAimMovementState: 0.166
|
||||
cameraDistanceFromPed: 5
|
||||
minCameraDistanceFromPed: 2
|
||||
maxCameraDistanceFromPed: 30
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
.Cast<Peds.States.IAimState>()
|
||||
.ToArray();
|
||||
this.CachedNonAimStates = _stateContainer.States
|
||||
.Where(_ => _ is not Peds.States.IAimState)
|
||||
.Where(_ => !(_ is Peds.States.IAimState))
|
||||
.ToArray();
|
||||
|
||||
this.AwakeForDamage ();
|
||||
|
|
|
@ -83,10 +83,10 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
return true;
|
||||
}
|
||||
|
||||
// wait until we start pointing gun - this is used to prevent fast state switching
|
||||
if (this.TimeSinceActivated < Mathf.Max(this.AimAnimMaxTime, PedManager.Instance.minTimeToReturnToNonAimStateFromAimState))
|
||||
// prevent fast state switching
|
||||
if (!EnoughTimePassedToSwitchToNonAimState(m_ped, Mathf.Max(this.AimAnimMaxTime, PedManager.Instance.minTimeToReturnToNonAimStateFromAimState)))
|
||||
return false;
|
||||
|
||||
|
||||
if (!m_ped.IsAimOn)
|
||||
{
|
||||
BaseMovementState.SwitchToMovementStateBasedOnInput (m_ped);
|
||||
|
@ -105,6 +105,19 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
return false;
|
||||
}
|
||||
|
||||
public static bool EnoughTimePassedToSwitchToNonAimState(Ped ped, float timeRequiredToPass)
|
||||
{
|
||||
var states = ped.CachedNonAimStates;
|
||||
|
||||
for (int i = 0; i < states.Count; i++)
|
||||
{
|
||||
if (states[i].TimeSinceDeactivated < timeRequiredToPass)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool SwitchToFiringState ()
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -26,8 +26,8 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
return true;
|
||||
}
|
||||
|
||||
// wait until we start pointing gun - this is used to prevent fast state switching
|
||||
if (this.TimeSinceActivated < Mathf.Max(this.AimAnimMaxTime, PedManager.Instance.minTimeToReturnToNonAimStateFromAimState))
|
||||
// prevent fast state switching
|
||||
if (!EnoughTimePassedToSwitchToNonAimState(m_ped, Mathf.Max(this.AimAnimMaxTime, PedManager.Instance.minTimeToReturnToNonAimStateFromAimState)))
|
||||
return false;
|
||||
|
||||
if ( !m_ped.IsAimOn )
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
public FocusPointParameters npcPedFocusPointParameters = FocusPointParameters.Default;
|
||||
|
||||
public float minTimeToReturnToAimState = 0.33f;
|
||||
public float minTimeToReturnToNonAimStateFromAimState = 0.33f;
|
||||
public float minTimeToReturnToNonAimStateFromAimState = 0.25f;
|
||||
public float timeUntilMovementStateCanBeSwitchedToOtherMovementState = 0.166f;
|
||||
public float timeUntilMovementStateCanBeEnteredFromOtherMovementState = 0.166f;
|
||||
public float timeUntilAimMovementStateCanBeSwitchedToOtherAimMovementState = 0.166f;
|
||||
|
|
Loading…
Reference in a new issue