(Interaction... actions)
| 456 | } |
| 457 | |
| 458 | public Actions tick(Interaction... actions) { |
| 459 | // All actions must be for a unique source. |
| 460 | Set<InputSource> seenSources = new HashSet<>(); |
| 461 | for (Interaction action : actions) { |
| 462 | boolean freshlyAdded = seenSources.add(action.getSource()); |
| 463 | if (!freshlyAdded) { |
| 464 | throw new IllegalStateException( |
| 465 | String.format( |
| 466 | "You may only add one action per input source per tick: %s", |
| 467 | Arrays.toString(actions))); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | // Add all actions to sequences |
| 472 | for (Interaction action : actions) { |
| 473 | Sequence sequence = getSequence(action.getSource()); |
| 474 | sequence.addAction(action); |
| 475 | } |
| 476 | |
| 477 | // And now pad the remaining sequences with a pause. |
| 478 | Set<InputSource> unseen = new HashSet<>(sequences.keySet()); |
| 479 | unseen.removeAll(seenSources); |
| 480 | for (InputSource source : unseen) { |
| 481 | getSequence(source).addAction(new Pause(source, Duration.ZERO)); |
| 482 | } |
| 483 | |
| 484 | return this; |
| 485 | } |
| 486 | |
| 487 | public Actions setActiveKeyboard(String name) { |
| 488 | InputSource inputSource = |
no test coverage detected