/// <summary> /// Callback when the ability tries to be stopped. Start the dismount. /// </summary> public override void WillTryStopAbility() { if (m_RideState != RideState.Ride) { return; } // The character may not have space to dismount. if (!m_Rideable.CanDismount(ref m_LeftMount)) { return; } if (m_CharacterLocomotion.ItemEquipVerifierAbility != null) { // Don't allow a dismount if the character is equipping an item just after mounting. if (m_CharacterLocomotion.ItemEquipVerifierAbility.IsActive) { return; } // If an item is equipped then it should first be unequipped before dismounting. if (m_CharacterLocomotion.ItemEquipVerifierAbility.TryToggleItem(this, true)) { m_RideState = RideState.WaitForItemUnequip; return; } } StartDismount(); }
/// <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(); }
public Ride(string id, string driverID, DateTime date, string time, string sourceId, string destinationId, string viaPointIds) { this.Id = id; this.DriverId = driverID; this.Date = date; this.Time = time; this.SourceId = sourceId; this.DestinationId = destinationId; this.ViaPointIds = viaPointIds; this.RideState = RideState.Active; }
/// <summary> /// The ability has started. /// </summary> protected override void AbilityStarted() { base.AbilityStarted(); m_LeftMount = m_Rideable.Transform.InverseTransformPoint(m_Transform.position).x < 0; m_Rideable.Mount(this); // The character will look independently of the rotation. EventHandler.ExecuteEvent(m_GameObject, "OnCharacterForceIndependentLook", true); m_RideState = RideState.Mount; m_CharacterLocomotion.UpdateAbilityAnimatorParameters(); // Update the rideable object's parameters as well so it can stay synchronized to the ride obejct. m_Rideable.CharacterLocomotion.UpdateAbilityAnimatorParameters(); if (!m_MountEvent.WaitForAnimationEvent) { m_MountDismountEvent = Scheduler.Schedule(m_MountEvent.Duration, OnMount); } }
/// <summary> /// Mounts the character on the object. /// </summary> private void OnMount() { m_RideState = RideState.Ride; m_CharacterLocomotion.ForceRootMotionPosition = false; m_CharacterLocomotion.AllowRootMotionPosition = false; m_CharacterLocomotion.UpdateLocation = m_StartUpdateLocation; m_CharacterLocomotion.UpdateAbilityAnimatorParameters(); m_Rideable.OnCharacterMount(); // The item was unequipped when mounting - it may need to be reequiped again. if (m_CharacterLocomotion.ItemEquipVerifierAbility != null) { if (m_ReequipItemAfterMount) { m_CharacterLocomotion.ItemEquipVerifierAbility.TryToggleItem(this, false); } else { m_CharacterLocomotion.ItemEquipVerifierAbility.Reset(); } } }
/// <summary> /// Starts to dismount from the RideableObject. /// </summary> private void StartDismount() { m_RideState = RideState.Dismount; m_CharacterLocomotion.ForceRootMotionPosition = true; m_CharacterLocomotion.AllowRootMotionPosition = true; m_CharacterLocomotion.UpdateAbilityAnimatorParameters(); // Update the rideable object's parameters as well so it can stay synchronized to the ride obejct. m_Rideable.CharacterLocomotion.UpdateAbilityAnimatorParameters(); m_Rideable.StartDismount(); // If the ability is active then it should also be stopped. var aimAbility = m_CharacterLocomotion.GetAbility <Items.Aim>(); if (aimAbility != null) { aimAbility.StopAbility(); } if (!m_DismountEvent.WaitForAnimationEvent) { m_MountDismountEvent = Scheduler.Schedule(m_DismountEvent.Duration, OnDismount); } }
/// <summary> /// The ability has started. /// </summary> protected override void AbilityStarted() { base.AbilityStarted(); m_StartUpdateLocation = m_CharacterLocomotion.UpdateLocation; // Used FixedUpdate so the root motion location is accurate when getting on the Rideable object. m_CharacterLocomotion.UpdateLocation = KinematicObjectManager.UpdateLocation.FixedUpdate; m_LeftMount = m_Rideable.Transform.InverseTransformPoint(m_Transform.position).x < 0; m_Rideable.Mount(this); m_CharacterLocomotion.SetPlatform(m_Rideable.Transform); // The character will look independently of the rotation. EventHandler.ExecuteEvent(m_GameObject, "OnCharacterForceIndependentLook", true); m_RideState = RideState.Mount; m_CharacterLocomotion.UpdateAbilityAnimatorParameters(); // Update the rideable object's parameters as well so it can stay synchronized to the ride obejct. m_Rideable.CharacterLocomotion.UpdateAbilityAnimatorParameters(); if (!m_MountEvent.WaitForAnimationEvent) { m_MountDismountEvent = SchedulerBase.Schedule(m_MountEvent.Duration, OnMount); } }
public Ride() { _state = new CreatedState(this); }