/// <summary> /// Validates the object to ensure it is valid for the current ability. /// </summary> /// <param name="obj">The object being validated.</param> /// <param name="raycastHit">The raycast hit of the detected object. Will be null for trigger detections.</param> /// <returns>True if the object is valid. The object may not be valid if it doesn't have an ability-specific component attached.</returns> protected override bool ValidateObject(GameObject obj, RaycastHit?raycastHit) { if (!base.ValidateObject(obj, raycastHit)) { return(false); } var characterLocomotion = obj.GetCachedParentComponent <UltimateCharacterLocomotion>(); if (characterLocomotion == null) { return(false); } // A rideable object must be added to the character. var rideable = characterLocomotion.GetAbility <Rideable>(); if (rideable == null) { return(false); } m_Rideable = rideable; return(true); }
/// <summary> /// The character has dismounted - stop the ability. /// </summary> private void OnDismount() { m_RideState = RideState.DismountComplete; m_Rideable.Dismounted(); m_Rideable = null; EventHandler.ExecuteEvent(m_GameObject, "OnCharacterForceIndependentLook", false); StopAbility(); }
/// <summary> /// The character has dismounted - stop the ability. /// </summary> private void OnDismount() { m_RideState = RideState.DismountComplete; m_Rideable.Dismounted(); m_Rideable = null; m_MountDismountEvent = null; m_CharacterLocomotion.SetPlatform(null); EventHandler.ExecuteEvent(m_GameObject, "OnCharacterForceIndependentLook", false); StopAbility(); }
/// <summary> /// The ability has stopped running. /// </summary> /// <param name="force">Was the ability force stopped?</param> protected override void AbilityStopped(bool force) { base.AbilityStopped(force); if (m_MountDismountEvent != null) { Scheduler.Cancel(m_MountDismountEvent); m_MountDismountEvent = null; } // If the state isn't complete then the ability was force stopped. if (m_RideState != RideState.DismountComplete) { m_Rideable.StartDismount(); m_Rideable.Dismounted(); m_Rideable = null; EventHandler.ExecuteEvent(m_GameObject, "OnCharacterForceIndependentLook", false); } }