/// <summary> /// Used to determine if the motor should activate /// </summary> /// <param name="rActiveMotor">Current active motor</param> /// <returns></returns> public virtual bool TestActivate(CameraMotor rActiveMotor) { if (!_IsEnabled) { return(false); } if (_ActionAlias.Length > 0 && RigController.InputSource != null) { if (RigController.InputSource.IsJustPressed(_ActionAlias)) { return(true); } } return(false); }
/// <summary> /// Used to determine if the motor should activate /// </summary> /// <param name="rActiveMotor">Current active motor</param> /// <returns></returns> public override bool TestActivate(CameraMotor rActiveMotor) { UpdateToggle(); if (!_IsEnabled) { return(false); } bool lActivate = false; // Priority activation if (!_LimitToStart || RigController.ActiveMotorIndex == _StartMotorIndex) { if (_ActionAlias.Length > 0 && RigController.InputSource != null) { if (_ActionAliasEventType == 0) { if (RigController.InputSource.IsJustPressed(_ActionAlias) || (mIsActionAliasInUse && !mWasActionAliasInUse)) { lActivate = true; } } else if (_ActionAliasEventType == 1) { if (RigController.InputSource.IsJustReleased(_ActionAlias) || (!mIsActionAliasInUse && mWasActionAliasInUse)) { lActivate = true; } } } } // Priority activation if (TestDistance && RigController.ActiveMotor != null) { if (DistanceCompareType == 0) { if (RigController.ActiveMotor.Distance < DistanceValue) { lActivate = true; } } else if (DistanceCompareType == 1) { if (RigController.ActiveMotor.Distance > DistanceValue) { lActivate = true; } } else { if (Mathf.Abs(RigController.ActiveMotor.Distance - DistanceValue) < 0.001f) { lActivate = true; } } } // Activation limiters if (lActivate) { if (mActorStances != null && mActorStances.Count > 0) { #if USE_ACTOR_CONTROLLER lActivate = false; com.ootii.Actors.ActorController lActorController = RigController.CharacterController as com.ootii.Actors.ActorController; if (lActorController != null) { int lStance = lActorController.State.Stance; if (mActorStances.Contains(lStance)) { lActivate = true; } } #endif } } return(lActivate); }
/// <summary> /// Called to initialize the motor. This can be done multiple times to /// reset and prepare the motor for activation. /// </summary> public override bool Initialize() { // Set the transition motors mStartMotor = null; if (_StartMotorIndex < 0) { mStartMotor = RigController.ActiveMotor; } else if (_StartMotorIndex < RigController.Motors.Count) { mStartMotor = RigController.Motors[_StartMotorIndex]; } mEndMotor = null; if (_EndMotorIndex >= 0 && _EndMotorIndex < RigController.Motors.Count) { mEndMotor = RigController.Motors[_EndMotorIndex]; } // Determine the current time float lPrevElapsedPercent = 1f; if (RigController.ActiveMotor is TransitionMotor) { TransitionMotor lMotor = RigController.ActiveMotor as TransitionMotor; lPrevElapsedPercent = (lMotor.TransitionTime > 0f ? lMotor.TransitionElapsedTime / lMotor.TransitionTime : 1f); } else if (mStartMotor is YawPitchMotor) { YawPitchMotor lMotor = mStartMotor as YawPitchMotor; if (lMotor.MaxDistance == 0) { lPrevElapsedPercent = 1f; } else { lPrevElapsedPercent = NumberHelper.SmoothStepTime(0f, lMotor.MaxDistance, lMotor.Distance); } } else if (mEndMotor is YawPitchMotor) { YawPitchMotor lMotor = mEndMotor as YawPitchMotor; if (lMotor.MaxDistance == 0) { lPrevElapsedPercent = 1f; } else { lPrevElapsedPercent = NumberHelper.SmoothStepTime(0f, lMotor.MaxDistance, lMotor.Distance); } } mTransitionElapsedTime = _TransitionTime * (1f - lPrevElapsedPercent); // Initialize the motors if (mStartMotor != null && mEndMotor != null) { mStartMotor.Initialize(); mEndMotor.Initialize(); mStartPosition = RigController._Transform.position; mStartRotation = RigController._Transform.rotation; return(base.Initialize()); } return(false); }
/// <summary> /// Called when the motor is deactivated /// </summary> public virtual void Deactivate(CameraMotor rNewMotor) { _IsActive = false; }
/// <summary> /// Used to determine if the motor should activate /// </summary> /// <param name="rActiveMotor">Current active motor</param> /// <returns></returns> public override bool TestActivate(CameraMotor rActiveMotor) { UpdateToggle(); if (!_IsEnabled) { return(false); } if (_LimitToStart && RigController.ActiveMotorIndex != _StartMotorIndex) { return(false); } bool lActivate = false; // Priority activation //if (!_LimitToStart || RigController.ActiveMotorIndex == _StartMotorIndex) { if (_ActionAlias.Length > 0 && RigController.InputSource != null) { if (_ActionAliasEventType == 0) { if (RigController.InputSource.IsJustPressed(_ActionAlias) || (mIsActionAliasInUse && !mWasActionAliasInUse)) { lActivate = true; } else if (_LimitToStart && RigController.InputSource.IsPressed(_ActionAlias)) { lActivate = true; } } else if (_ActionAliasEventType == 1) { if (RigController.InputSource.IsJustReleased(_ActionAlias) || (!mIsActionAliasInUse && mWasActionAliasInUse)) { lActivate = true; } } } } // Priority activation if (!lActivate && TestDistance && RigController.ActiveMotor != null) { if (DistanceCompareType == 0) { if (RigController.ActiveMotor.Distance < DistanceValue) { lActivate = true; } } else if (DistanceCompareType == 1) { if (RigController.ActiveMotor.Distance > DistanceValue) { lActivate = true; } } else { if (Mathf.Abs(RigController.ActiveMotor.Distance - DistanceValue) < 0.001f) { lActivate = true; } } } #if OOTII_MC // Activation limiters if (lActivate) { if (mActorStances != null && mActorStances.Count > 0 && RigController.CharacterController != null) { lActivate = false; GameObject lGameObject = RigController.CharacterController.gameObject; com.ootii.Actors.AnimationControllers.MotionController lMotionController = lGameObject.GetComponent <com.ootii.Actors.AnimationControllers.MotionController>(); if (lMotionController != null) { int lStance = lMotionController.Stance; if (mActorStances.Contains(lStance)) { lActivate = true; } } } } // See if we need to activate because we are no longer in a valid actor stance we should be in else if (_InvertVerifyActorStances && mActorStances != null && mActorStances.Count > 0 && RigController.CharacterController != null) { // Only do it if we are in the start motor //if (!_LimitToStart || RigController.ActiveMotorIndex == _StartMotorIndex) { GameObject lGameObject = RigController.CharacterController.gameObject; // Only do it if we are not in a required stance com.ootii.Actors.AnimationControllers.MotionController lMotionController = lGameObject.GetComponent <com.ootii.Actors.AnimationControllers.MotionController>(); if (lMotionController != null) { int lStance = lMotionController.Stance; if (!mActorStances.Contains(lStance)) { lActivate = true; } } } } #endif return(lActivate); }