public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (stateInfo.shortNameHash == h_Empty) { player.SmbThrow.UseMirrorThrow = false; if (animator.GetInteger(cap_Cover) == -1) { ExitCover(); } } else if (stateInfo.shortNameHash == h_ToCover) { player.SmbWeapon.TriggS.Modify(c_OverrideKey, new WeaponSystemTriggers(true, true, true, false, true, true, true, false, false)); player.SmbThrow.TriggS.Modify(c_OverrideKey, new ThrowSystemTriggers(true, true, true)); coverChecker.StopUpdateForAroundCovers = true; transform.forward = calced_CoverNormal; } else if (stateInfo.shortNameHash == h_CoverLocom) { coverChecker.StopUpdateForCameraCovers = false; userInput.GetComponent <Rigidbody>().isKinematic = true; } else if (stateInfo.tagHash == hTag_Peek) { animator.SetFloat(cap_Speed, 0 /*, 0, Time.deltaTime*/); } else if (stateInfo.tagHash == hTag_UpPeek) { animator.SetFloat(cap_Speed, 0); } else if (stateInfo.shortNameHash == h_MovingToCamCover) { ExitCover(); player.SmbLoco.OverrideLocomoteWithAgentFreeToTransform(new LocomoteWithAgentFreeToTransformParams(tempObj.transform, MoveType.Run, player.defaultLocomStyleIndex), -3, c_OverrideKey_2); } }
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { SetLayerWeights(layerIndex); if (stateInfo.shortNameHash == h_Empty) { if (UseMirrorThrow) { animator.SetBool("MirrorThrow", true); } else { animator.SetBool("MirrorThrow", false); } if (!animator.IsInTransition(layerIndex) && ThrowTrigger()) { return; } if (!animator.IsInTransition(layerIndex) && SwitchThrowableTrigger(false)) { return; } } else if (stateInfo.shortNameHash == h_PullOut) { } else if (stateInfo.shortNameHash == h_ToReady) { } else if (stateInfo.shortNameHash == h_ReadyIdle) { if (!cExploderClone && animator.GetInteger(cap_Throw) != 2) { // Unintentional Explosion IsThrowing = false; animator.SetInteger(cap_Throw, 0); CalculateNextThrowable(); Events.InvokeThrowableExit(null); return; } if (!animator.IsInTransition(layerIndex) && SwitchThrowableTrigger(true)) { return; } if (IndicatorTrigger() /* || 1 == 1*/) // uncomment to debug { Vector3 targThrowDir = Quaternion.AngleAxis(-cExploderClone.additionalThrowAngleHorizontal, userInput.cameraRig.up) * (-transform.position + refTarget.position).normalized; throwDir = targThrowDir; SetThrowDistance(); if (cExploderClone.showEstimatedRoute) { cExploderClone.lineRendEnabled = true; } cExploderClone.FireStrength = Mathf.Lerp( cExploderClone.throwForceMinMax.x, cExploderClone.throwForceMinMax.y, animator.GetFloat(cap_ThrowDistance)); cExploderClone.FireDir = throwDir; } else /*if (1 == 0)*/ // uncomment to debug { animator.SetInteger(cap_Throw, -1); cExploderClone.lineRendEnabled = false; } SetThrowDistance(); } else if (stateInfo.shortNameHash == h_Throw) { } }
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { UpdateLayerWeight(layerIndex); if (stateInfo.shortNameHash == h_Empty) { if (!animator.IsInTransition(0)) { animator.SetFloat(cap_CrouchStand, 0, CCoverProps.animParamDamp, Time.deltaTime); } if (!animator.IsInTransition(0) && CoverAroundTrigger()) { return; } } else if (stateInfo.shortNameHash == h_ToCover) { float crouchStand = CoverTargetLogic.RequestCrouch(CCoverProps.characterHeight, CCoverProps.crouchRayCheckCount, CCoverProps.crouchCheckStartHeight, CCoverProps.crouchCheckRayMaxDist, calced_GroundPoint, calced_CoverNormal ); animator.SetFloat(cap_CrouchStand, crouchStand, CCoverProps.animParamDamp, Time.deltaTime); } else if (stateInfo.shortNameHash == h_CoverLocom) { // Current Pos Check (with a fixed small distance to the opposite side) Vector3 coverNormalFromCPos = Vector3.zero; Vector3 coverGroundHitFromCPos = Vector3.zero; bool hasCoverCPos = coverChecker.RequestCover( new Ray(transform.position + Vector3.up * coverChecker.aroundPlRayStartUpHeight, -calced_CoverNormal), ref coverNormalFromCPos, ref coverGroundHitFromCPos, CCoverProps.rayLength, coverChecker.maxAllowedAngleVert, coverChecker.maxAllowedGroundNormalAngle ); if (hasCoverCPos) { calced_CoverNormal = coverNormalFromCPos; calced_GroundPoint = coverGroundHitFromCPos; } // Cover exit check & stick angle float stickAngleWorld = GetStickAngle(); if (!animator.IsInTransition(layerIndex) && (CoverCameraTrigger() || ExitCoverTrigger(stickAngleWorld, hasCoverCPos))) { return; } // Next Pos Check Ray rayNext = new Ray(coverGroundHitFromCPos + Vector3.up * coverChecker.aroundPlRayStartUpHeight + Quaternion.Euler(0, 90 * Mathf.Sign(animator.GetFloat(cap_CoverSide)), 0) * calced_CoverNormal * CCoverProps.sideRayDist, -calced_CoverNormal); Vector3 coverNormalFromNextPos = Vector3.zero; Vector3 coverGroundHitNextPos = Vector3.zero; bool hasCoverNextPos = coverChecker.RequestCover( rayNext, ref coverNormalFromNextPos, ref coverGroundHitNextPos, CCoverProps.rayLength, coverChecker.maxAllowedAngleVert, coverChecker.maxAllowedGroundNormalAngle ); // Camera look angle / Peek triggers float angle = GetAngle(); if (!animator.IsInTransition(layerIndex)) { if (animator.GetFloat(cap_CoverSide) < 0) { player.SmbThrow.UseMirrorThrow = true; } else { player.SmbThrow.UseMirrorThrow = false; } if (!hasCoverNextPos && userInput.Vertical < .1f && EdgePeekTrigger(angle)) { return; } else if (UpPeekTrigger(angle)) { return; } } SetCrouchStand(); if (MoveTrigger() && (!animator.IsInTransition(layerIndex) || animator.GetAnimatorTransitionInfo(layerIndex).nameHash == hTrans_leftSwitchToLocom || animator.GetAnimatorTransitionInfo(layerIndex).nameHash == hTrans_rightSwitchToLocom) && Mathf.Abs(stickAngleWorld) > CCoverProps.startMoveAtStickAngle) { stickAngleWorld = Mathf.Sign(stickAngleWorld); // Switch side if (stickAngleWorld != Mathf.Sign(animator.GetFloat(cap_CoverSide))) { SetSideSwitchTrigger(); return; } if (hasCoverNextPos) { animator.SetFloat(cap_Speed, Mathf.Abs(stickAngleWorld), CCoverProps.animSpeedDamp, Time.deltaTime); } else { animator.SetFloat(cap_Speed, 0, CCoverProps.animSpeedDamp, Time.deltaTime); } } else { animator.SetFloat(cap_Speed, 0, CCoverProps.animSpeedDamp, Time.deltaTime); } } else if (stateInfo.tagHash == ht_SwitchSide) { animator.SetFloat(cap_Speed, 0, CCoverProps.animSpeedDamp, Time.deltaTime); } else if (stateInfo.shortNameHash == h_ToPeek) { animator.SetFloat(cap_Speed, 0, CCoverProps.animSpeedDamp, Time.deltaTime); } else if (stateInfo.tagHash == hTag_Peek) { float angle = GetAngle(); if (UnEdgePeekTrigger(angle)) { return; } float animAngle = 0; IsAngleInBounds(angle, CCoverProps.edgePeekAngleTolerance, CCoverProps.oppositeDirMaxAngle, animator.GetFloat(cap_CoverSide) < 0, ref animAngle); if (!animator.IsInTransition(layerIndex)) { animator.SetFloat(cap_Angle, animAngle); } } else if (stateInfo.tagHash == hTag_UpPeek) { float angle = GetAngle(); UnUpPeekTrigger(angle); if (!animator.IsInTransition(layerIndex)) { animator.SetFloat(cap_Angle, angle); } if (!animator.IsInTransition(layerIndex)) { animator.SetFloat(cap_CoverSide, Mathf.Sign(angle)); } } else if (stateInfo.shortNameHash == h_MovingToCamCover) { // Exit cover completely if (!animator.IsInTransition(layerIndex) && userInput.AnyKeyDown()) { player.SmbLoco.ReleaseOverrideLocomoteType(c_OverrideKey_2); animator.SetInteger(cap_Cover, -1); LayerWeightTarget = 0; return; } if (!animator.IsInTransition(layerIndex) && animator.GetInteger(cap_Cover) > 0 && player.SmbLoco.RemainingAgentDistance < CCoverProps.toCameraCoverStopDistance) { if (coverChecker.HaveCoverAround && CoverAroundTrigger(true)) { player.SmbLoco.ReleaseOverrideLocomoteType(c_OverrideKey_2); } } } }