Class SailingService
- java.lang.Object
-
- com.kraken.api.service.SailingService
-
public class SailingService extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSailingService.Direction
-
Field Summary
Fields Modifier and Type Field Description static intNAVIGATING_VARBITstatic intSAILING_CONTROLS_IDstatic intSPEED_VARBIT
-
Constructor Summary
Constructors Constructor Description SailingService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddecreaseSpeed()Decreases the speed of the boat in the game.SailingService.DirectiongetDirection()Retrieves the current direction of the boat based on its angle in the game.voidincreaseSpeed()Increases the speed of the boat in the game.booleanisMoving()Checks if the boat is currently moving based on the speed state.booleanisNavigating()Determines whether the player is at the helm of the boat and navigatingbooleansetDirection(SailingService.Direction direction)Sets the sailing direction of the boat in the game.voidsetSails()Deploys the boat's sails to enable sailing control.voidunsetSails()Disables the boat's sails to bring the vessel to a halt.
-
-
-
Field Detail
-
SAILING_CONTROLS_ID
public static final int SAILING_CONTROLS_ID
- See Also:
- Constant Field Values
-
NAVIGATING_VARBIT
public static final int NAVIGATING_VARBIT
- See Also:
- Constant Field Values
-
SPEED_VARBIT
public static final int SPEED_VARBIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
setDirection
public boolean setDirection(SailingService.Direction direction)
Sets the sailing direction of the boat in the game.This method first ensures that the necessary game packets are loaded. If not, it immediately returns false. If packets are loaded, a mouse click packet is queued, followed by a request to update the boat direction using the provided
SailingService.Directionvalue.The direction is set by passing the direction's code to the sailing packet system. Directions are represented using predefined constants in the
SailingService.Directionenumeration.- Parameters:
direction- The desiredSailingService.Directionto set the boat's heading. Directions are enumerated values ranging from SOUTH(0) to SOUTH_SOUTH_EAST(15).- Returns:
- true if the direction was successfully set; false if the necessary game packets were not loaded.
-
increaseSpeed
public void increaseSpeed()
Increases the speed of the boat in the game.This method interacts with the in-game sailing controls to increment the boat's speed by one level, provided it is not already at the maximum speed setting.
-
decreaseSpeed
public void decreaseSpeed()
Decreases the speed of the boat in the game.This method interacts with the in-game sailing controls to reduce the boat's speed by one level, unless the current speed is already at the lowest setting. The speed is determined by querying the value of a specific varbit used to represent the boat's speed state.
If the boat's speed is set to the minimum value (3 in the current configuration), the method exits immediately without issuing any further actions.
-
getDirection
public SailingService.Direction getDirection()
Retrieves the current direction of the boat based on its angle in the game.This method utilizes the
SailingService.Direction.fromAngle(int)method to derive the boat's direction from the angle value provided by theVarbitID.SAILING_BOAT_SPAWNED_ANGLEvarbit. The angle is divided into predefined directional constants representing the boat's heading.- Returns:
- The
SailingService.Directionthe boat is currently facing. If no valid direction can be derived,nullis returned.
-
unsetSails
public void unsetSails()
Disables the boat's sails to bring the vessel to a halt.This method initiates the in-game action to unset the boat's sails, effectively stopping the boat's movement. It checks the current movement status of the boat by invoking
isMoving(). If the boat is stationary, the method exits immediately without issuing any commands. This safeguards against unnecessary actions when the boat is not in motion.
-
setSails
public void setSails()
Deploys the boat's sails to enable sailing control.This method triggers the in-game action to set the boat's sails, allowing the player to control the vessel. If the boat is currently in motion, the method exits immediately without performing any action to avoid conflicting states.
-
isNavigating
public boolean isNavigating()
Determines whether the player is at the helm of the boat and navigatingThis method checks the value of a specific varbit to identify if the navigation system is active. A non-zero value indicates that the boat is navigating, while a value of zero suggests it is not.
- Returns:
- true if the boat's navigation system is active; false otherwise.
-
isMoving
public boolean isMoving()
Checks if the boat is currently moving based on the speed state.This method determines the movement state by examining the value of a specific varbit linked to the boat's speed. A non-zero value indicates that the boat is in motion, while a zero value means it is stationary.
- Returns:
- true if the boat is moving; false otherwise.
-
-