PatrolPath & PatrolWaypoint

A PatrolPath is a named sequence of PatrolWaypoint positions that a citizen traverses during patrol.

package com.electro.hycitizens.models;

PatrolPath

Constructor

PatrolPath(@Nonnull String name, @Nonnull LoopMode loopMode)

LoopMode Enum

public enum LoopMode {
    LOOP,       // Restart from first waypoint after reaching last
    PING_PONG   // Reverse direction after reaching last waypoint
}

getName / setName

@Nonnull String getName()
void setName(@Nonnull String name)

The unique name of this path. Referenced by PathConfig.getPathName().

getLoopMode / setLoopMode

@Nonnull LoopMode getLoopMode()
void setLoopMode(@Nonnull LoopMode loopMode)

getWaypoints / setWaypoints

@Nonnull List<PatrolWaypoint> getWaypoints()
void setWaypoints(@Nonnull List<PatrolWaypoint> waypoints)

addWaypoint

void addWaypoint(@Nonnull PatrolWaypoint waypoint)

Appends a waypoint to the end of this path.

PatrolWaypoint

Constructor

PatrolWaypoint(double x, double y, double z, float pauseSeconds)

getX / setX, getY / setY, getZ / setZ

double getX() / void setX(double x)
double getY() / void setY(double y)
double getZ() / void setZ(double z)

World coordinates of this waypoint.

getPauseSeconds / setPauseSeconds

float getPauseSeconds()
void setPauseSeconds(float pauseSeconds)

How long the citizen pauses at this waypoint before moving on. 0 means no pause.

toVector3d

@Nonnull Vector3d toVector3d()

Returns a Vector3d of this waypoint's position for use with Hytale math APIs.

Example: Building a Patrol Path

PatrolPath path = new PatrolPath("GuardRoute", PatrolPath.LoopMode.PING_PONG);
path.addWaypoint(new PatrolWaypoint(100, 64, 200, 1.0f));
path.addWaypoint(new PatrolWaypoint(120, 64, 200, 0.0f));
path.addWaypoint(new PatrolWaypoint(120, 64, 220, 1.5f));

HyCitizensPlugin.get().getCitizensManager().registerPatrolPath(path);

// Assign the path to a citizen
PathConfig pathConfig = new PathConfig();
pathConfig.setFollowPath(true);
pathConfig.setPathName("GuardRoute");
pathConfig.setLoopMode("PING_PONG");
citizen.setPathConfig(pathConfig);