Pressing shift when playing path ignores time keyframes
This commit is contained in:
@@ -16,6 +16,7 @@ public class PathImpl implements Path {
|
||||
private final Timeline timeline;
|
||||
private Map<Long, Keyframe> keyframes = new TreeMap<>();
|
||||
private List<PathSegment> 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) {
|
||||
|
||||
@@ -30,9 +30,11 @@ public class TimelineImpl implements Timeline {
|
||||
@Override
|
||||
public <T> Optional<T> getValue(Property<T> property, long time) {
|
||||
for (Path path : paths) {
|
||||
Optional<T> value = path.getValue(property, time);
|
||||
if (value.isPresent()) {
|
||||
return value;
|
||||
if (path.isActive()) {
|
||||
Optional<T> value = path.getValue(property, time);
|
||||
if (value.isPresent()) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Optional.absent();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -205,6 +205,7 @@ public class GuiPathing {
|
||||
timePath.updateAll();
|
||||
positionPath.updateAll();
|
||||
|
||||
timePath.setActive(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT));
|
||||
player.start(timeline);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user