Update guided help

This commit is contained in:
fullwall 2023-09-13 00:44:07 +08:00
parent 8ca064aab3
commit bec532952a
2 changed files with 28 additions and 8 deletions

View File

@ -96,17 +96,28 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
Messaging.sendTr(player, Messages.GUIDED_WAYPOINT_EDITOR_BEGIN);
}
private void createWaypointMarkers() {
for (Waypoint waypoint : waypoints()) {
createWaypointMarkerWithData(waypoint);
private void createDestinationMarker(Waypoint element) {
NPC npc = createMarker(element);
if (npc != null) {
npc.data().set(NPC.Metadata.GLOWING, true);
}
}
private void createWaypointMarkerWithData(Waypoint element) {
private NPC createMarker(Waypoint element) {
Entity entity = markers.createMarker(element, element.getLocation().clone().add(0, 1, 0));
if (entity == null)
return;
return null;
((NPCHolder) entity).getNPC().data().setPersistent("waypointhashcode", element.hashCode());
return ((NPCHolder) entity).getNPC();
}
private void createWaypointMarkers() {
for (Waypoint waypoint : guides) {
createMarker(waypoint);
}
for (Waypoint waypoint : destinations) {
createDestinationMarker(waypoint);
}
}
@Override
@ -168,7 +179,11 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
Messaging.sendTr(player, Messages.GUIDED_WAYPOINT_EDITOR_ADDED_GUIDE);
}
if (showPath) {
createWaypointMarkerWithData(element);
if (player.isSneaking()) {
createDestinationMarker(element);
} else {
createMarker(element);
}
}
rebuildTree();
}
@ -304,6 +319,7 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
private class GuidedAIGoal implements Goal {
private GuidedPlan plan;
private Waypoint target;
public void onProviderChanged() {
if (plan == null)
@ -317,11 +333,15 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
@Override
public void reset() {
plan = null;
target = null;
}
@Override
public void run(GoalSelector selector) {
if (plan == null || plan.isComplete()) {
if (plan.isComplete()) {
target.onReach(npc);
}
selector.finish();
return;
}
@ -343,7 +363,7 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
if (paused || destinations.size() == 0 || !npc.isSpawned() || npc.getNavigator().isNavigating())
return false;
Waypoint target = destinations.get(Util.getFastRandom().nextInt(destinations.size()));
this.target = destinations.get(Util.getFastRandom().nextInt(destinations.size()));
plan = ASTAR.runFully(new GuidedGoal(target), new GuidedNode(null, new Waypoint(npc.getStoredLocation())));
return plan != null;
}

View File

@ -419,7 +419,7 @@ citizens.editors.waypoints.wander.added-region=[[Added]] wanderable region at ({
citizens.editors.waypoints.wander.removed-region=[[Removed]] wanderable region at ({0}) ([[{1}]] remaining).
citizens.editors.waypoints.wander.editing-regions=Now editing regions!<br> [[Left click]] to add a new wanderable region using the xrange/yrange box centred at that block.<br> [[Right click]] an existing marker to remove that region.<br> Type [[regions]] to stop or simply exit the editor. Regions should be overlap or touch each other.
citizens.editors.waypoints.guided.end=Exited the guided waypoint editor.
citizens.editors.waypoints.guided.begin=Entered the guided waypoint editor! The NPC will randomly walk to a [[destination]] waypoint following the nearest [[guide]] point. For example, try putting guide points on a road and destinations inside houses!<br> [[Left click]] to add a guide waypoint and [[right click]] to remove an existing waypoint.<br> [[Sneak]] while left clicking to add a destination waypoint.<br> Type [[toggle path]] to toggle showing entities at waypoints.<br> Type [[clear]] to clear all waypoints.
citizens.editors.waypoints.guided.begin=Entered the guided waypoint editor! The NPC will randomly walk to a [[destination]] waypoint following the nearest [[guide]] point. For example, try putting guide points on a road and destinations inside houses!<br> [[Left click]] to add a guide waypoint and [[right click]] to remove.<br> [[Sneak]] while left clicking to add a destination waypoint.<br> Type [[toggle path]] to toggle showing entities at waypoints.<br> Type [[clear]] to clear all waypoints.<br> Type [[distance <distance>]] to adjust the pathfinding range.
citizens.editors.waypoints.guided.added-guide=Added a [[guide]] waypoint which the NPC will follow on the way to their destination.
citizens.editors.waypoints.guided.added-available=Added a [[destination]] waypoint which the NPC will randomly pathfind between.
citizens.editors.waypoints.guided.already-taken=There is already a waypoint here.