Class PlayerManagerComponent

java.lang.Object
org.ngengine.player.PlayerManagerComponent
All Implemented Interfaces:
Component<Object>, AssetLoadingFragment, Fragment

public class PlayerManagerComponent extends Object implements Component<Object>, AssetLoadingFragment
  • Field Details

    • DEFAULT_ID_RELAYS

      public static final List<String> DEFAULT_ID_RELAYS
    • connectToRelays

      protected Collection<String> connectToRelays
    • nostrPool

      protected org.ngengine.nostr4j.NostrPool nostrPool
    • externalPool

      protected boolean externalPool
    • players

      protected Map<org.ngengine.nostr4j.keypair.NostrPublicKey,Player> players
    • localPlayers

      protected Map<org.ngengine.nostr4j.keypair.NostrPublicKey,LocalPlayer> localPlayers
    • runner

      protected Runner runner
    • assetManager

      protected AssetManager assetManager
  • Constructor Details

    • PlayerManagerComponent

      public PlayerManagerComponent()
    • PlayerManagerComponent

      public PlayerManagerComponent(Collection<String> idRelays)
    • PlayerManagerComponent

      public PlayerManagerComponent(org.ngengine.platform.VStore dataStore, org.ngengine.nostr4j.NostrPool pool)
  • Method Details

    • enqueueToRenderThread

      public void enqueueToRenderThread(Runnable act)
    • getPool

      public org.ngengine.nostr4j.NostrPool getPool()
    • onEnable

      public void onEnable(ComponentManager mng, Runner runner, DataStoreProvider dataStoreProvider, boolean firstTime, Object slot)
      Description copied from interface: Component
      Called when the component is enabled. This is the most important method of the component lifecycle, where the component's main logic is implemented.

      This method is called when the component is enabled, all its dependencies are satisfied, the fragments are initialized, and the resources are loaded.

      Specified by:
      onEnable in interface Component<Object>
      Parameters:
      mng - - the ComponentManager to which this component is attached
      runner - - the Runner that executes the logic
      dataStoreProvider - - the DataStoreProvider for storing and retrieving data and caches
      firstTime - - whether this is the first time the component is being enabled
      slot - - an argument that can be passed when enabling this component, can be null
    • onDisable

      public void onDisable(ComponentManager mng, Runner runner, DataStoreProvider dataStoreProvider)
      Description copied from interface: Component
      Called when the component is disabled.

      This should undo anything that was done in Component.onEnable(org.ngengine.components.ComponentManager, org.ngengine.runner.Runner, org.ngengine.store.DataStoreProvider, boolean, T) and reset the component state to allow future re-enabling.

      This method is called when the component is explicitly disabled or when one of its dependencies is disabled.

      If $

      invalid reference
      #onDetach
      is not implemented, this method should take care of cleaning up all resources to prevent leaks.

      It is always called before an enabled component is detached from the ComponentManager.

      Specified by:
      onDisable in interface Component<Object>
      Parameters:
      mng -
      runner -
      dataStoreProvider -
    • loadAssets

      public void loadAssets(AssetManager assetManager)
      Description copied from interface: AssetLoadingFragment
      Load assets using the provided AssetManager. The reference to the AssetManager can be stored and used later in the component logic.
      Specified by:
      loadAssets in interface AssetLoadingFragment
      Parameters:
      assetManager - the AssetManager instance
    • getAssetManager

      public AssetManager getAssetManager()
    • onAttached

      public void onAttached(ComponentManager mng, Runner runner, DataStoreProvider dataStoreProvider)
      Description copied from interface: Component
      Called immediately when the component is attached to a ComponentManager and a Runner.

      This method can be overridden to perform initialization tasks when the component is attached.

      Specified by:
      onAttached in interface Component<Object>
      Parameters:
      mng - the ComponentManager to which this component is attached
      runner - the Runner associated with this component
      dataStoreProvider - the DataStoreProvider for accessing shared data
    • getPlayer

      public Player getPlayer(org.ngengine.nostr4j.keypair.NostrPublicKey pubkey)
    • getPlayer

      public LocalPlayer getPlayer(org.ngengine.nostr4j.signer.NostrSigner signer)
    • getPlayer

      public Player getPlayer(RemotePeer peer)
    • getPlayer

      public LocalPlayer getPlayer(P2PChannel chan)
    • getPlayer

      public Player getPlayer(HostedConnection conn)