Description
The OnModeEnd
method is a virtual method in the MoveMode
class, which is part of the Sandbox.Movement
namespace. This method is called when the current movement mode ends, and the system is transitioning to another movement mode. It provides an opportunity to perform any necessary cleanup or state transition logic before the new mode begins.
Usage
Override this method in a derived class to implement custom behavior that should occur when the movement mode ends. This could include resetting variables, stopping animations, or preparing the system for the next mode.
The method takes a single parameter, next
, which is of type MoveMode
. This parameter represents the next movement mode that will be activated.
Example
public class CustomMoveMode : MoveMode
{
public override void OnModeEnd(MoveMode next)
{
// Custom logic to execute when this mode ends
// For example, reset speed or stop animations
ResetSpeed();
StopCurrentAnimations();
// Optionally, log the transition
LogTransition(next);
}
private void ResetSpeed()
{
// Implementation to reset speed
}
private void StopCurrentAnimations()
{
// Implementation to stop animations
}
private void LogTransition(MoveMode next)
{
// Log the transition to the next mode
// Example: Log.Info($"Transitioning to {next.GetType().Name}");
}
}