Class ExtensionContext.InputKey<T>

java.lang.Object
org.openpatch.scratch.extension.ExtensionContext.InputKey<T>
Type Parameters:
T - the state kept in the slot
Enclosing interface:
ExtensionContext

public static final class ExtensionContext.InputKey<T> extends Object
A slot in the input snapshot: polled on the window thread, copied to the game thread with each batch of ticks, so no locking is needed.
  • Method Details

    • of

      public static <T> ExtensionContext.InputKey<T> of(String name, Supplier<T> factory, BiConsumer<T,T> copy)
      Type Parameters:
      T - the state
      Parameters:
      name - for messages
      factory - makes an empty state (twice: one per thread)
      copy - copies the window thread's state into the game thread's: (from, into)
      Returns:
      the key
    • create

      public T create()
      For the core: makes a state for this key.
    • copy

      public void copy(T from, T into)
      For the core: copies one state into another.
    • toString

      public String toString()
      Overrides:
      toString in class Object