|
57 | 57 | */ |
58 | 58 | public class VirtualInput { |
59 | 59 |
|
| 60 | + /** |
| 61 | + * The container where all inputs get stored during recording or stored and ready to be played back |
| 62 | + */ |
60 | 63 | private InputContainer container = new InputContainer(); |
61 | 64 |
|
62 | 65 | // ===========================Keyboard================================= |
63 | 66 |
|
| 67 | + /** |
| 68 | + * The state of the keyboard recognized by the game. Updated on a tick basis <br> |
| 69 | + * See also: {@link VirtualInput} |
| 70 | + */ |
64 | 71 | private VirtualKeyboard currentKeyboard = new VirtualKeyboard(); |
65 | 72 |
|
| 73 | + /** |
| 74 | + * The state of the keyboard which will replace {@linkplain VirtualInput#currentKeyboard} in the next tick. Updated every frame<br> |
| 75 | + * See also: {@link VirtualInput} |
| 76 | + */ |
66 | 77 | private VirtualKeyboard nextKeyboard = new VirtualKeyboard(); |
67 | 78 |
|
68 | 79 | private List<VirtualKeyboardEvent> currentKeyboardEvents = new ArrayList<VirtualKeyboardEvent>(); |
@@ -209,7 +220,7 @@ public List<String> getNextKeyboardPresses() { |
209 | 220 |
|
210 | 221 | private VirtualMouse currentMouse = new VirtualMouse(); |
211 | 222 |
|
212 | | - public VirtualMouse nextMouse = new VirtualMouse(); |
| 223 | + private VirtualMouse nextMouse = new VirtualMouse(); |
213 | 224 |
|
214 | 225 | private List<VirtualMouseEvent> currentMouseEvents = new ArrayList<VirtualMouseEvent>(); |
215 | 226 | private Iterator<VirtualMouseEvent> currentMouseEventIterator = currentMouseEvents.iterator(); |
@@ -349,19 +360,31 @@ public float getSubtickYaw() { |
349 | 360 | return currentSubtick.getYaw(); |
350 | 361 | } |
351 | 362 |
|
| 363 | + // =====================================Container=========================================== |
| 364 | + |
352 | 365 | public InputContainer getContainer() { |
353 | 366 | return container; |
354 | 367 | } |
355 | 368 |
|
| 369 | + /** |
| 370 | + * Updates the input container and the {@link #nextKeyboard} as well as {@link #nextMouse}<br> |
| 371 | + * Gets executed each game tick |
| 372 | + */ |
356 | 373 | public void updateContainer() { |
357 | 374 | nextKeyboard = container.addKeyboardToContainer(nextKeyboard); |
358 | 375 | nextMouse = container.addMouseToContainer(nextMouse); |
359 | 376 | } |
360 | 377 |
|
| 378 | + /** |
| 379 | + * Replaces the {@link #container}, used in |
| 380 | + * @param container to replace the current one |
| 381 | + */ |
361 | 382 | public void setContainer(InputContainer container) { |
362 | 383 | this.container = container; |
363 | 384 | } |
364 | 385 |
|
| 386 | + // =====================================Savestates=========================================== |
| 387 | + |
365 | 388 | public void loadSavestate(InputContainer container) { |
366 | 389 | if (this.container.isPlayingback()) { |
367 | 390 | preloadInput(this.container, container.size() - 1); |
|
0 commit comments