diff --git a/src/main/java/com/replaymod/pathing/impl/PathImpl.java b/src/main/java/com/replaymod/pathing/impl/PathImpl.java index 2547e291..df1f65cf 100644 --- a/src/main/java/com/replaymod/pathing/impl/PathImpl.java +++ b/src/main/java/com/replaymod/pathing/impl/PathImpl.java @@ -16,6 +16,7 @@ public class PathImpl implements Path { private final Timeline timeline; private Map keyframes = new TreeMap<>(); private List segments = new LinkedList<>(); + private boolean active = true; public PathImpl(Timeline timeline) { this.timeline = timeline; @@ -164,6 +165,16 @@ public class PathImpl implements Path { throw new AssertionError("No segment for keyframe found!"); } + @Override + public void setActive(boolean active) { + this.active = active; + } + + @Override + public boolean isActive() { + return active; + } + private PathSegment getSegment(long time) { for (PathSegment segment : segments) { if (segment.getStartKeyframe().getTime() <= time && segment.getEndKeyframe().getTime() >= time) { diff --git a/src/main/java/com/replaymod/pathing/impl/TimelineImpl.java b/src/main/java/com/replaymod/pathing/impl/TimelineImpl.java index 9cf3744f..1f1bcb61 100644 --- a/src/main/java/com/replaymod/pathing/impl/TimelineImpl.java +++ b/src/main/java/com/replaymod/pathing/impl/TimelineImpl.java @@ -30,9 +30,11 @@ public class TimelineImpl implements Timeline { @Override public Optional getValue(Property property, long time) { for (Path path : paths) { - Optional value = path.getValue(property, time); - if (value.isPresent()) { - return value; + if (path.isActive()) { + Optional value = path.getValue(property, time); + if (value.isPresent()) { + return value; + } } } return Optional.absent(); diff --git a/src/main/java/com/replaymod/pathing/path/Path.java b/src/main/java/com/replaymod/pathing/path/Path.java index f892b4f8..820f2165 100644 --- a/src/main/java/com/replaymod/pathing/path/Path.java +++ b/src/main/java/com/replaymod/pathing/path/Path.java @@ -99,4 +99,18 @@ public interface Path { * {@code false} if it inherits the one of the second segment */ void remove(Keyframe keyframe, boolean useFirstInterpolator); + + /** + * Set whether this path is active. + * If this path is not active, it shouldn't be applied to the game during playback. + * @param active {@code true} if active, {@code false} otherwise + */ + void setActive(boolean active); + + /** + * Returns whether this path is active. + * @return {@code true} if active, {@code false} otherwise + * @see #setActive(boolean) + */ + boolean isActive(); } diff --git a/src/main/java/com/replaymod/simplepathing/gui/GuiPathing.java b/src/main/java/com/replaymod/simplepathing/gui/GuiPathing.java index 4097dd30..8dd72215 100644 --- a/src/main/java/com/replaymod/simplepathing/gui/GuiPathing.java +++ b/src/main/java/com/replaymod/simplepathing/gui/GuiPathing.java @@ -205,6 +205,7 @@ public class GuiPathing { timePath.updateAll(); positionPath.updateAll(); + timePath.setActive(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)); player.start(timeline); } }