Class EnergyNetwork

java.lang.Object
com.github.darksoulq.abyssallib.common.energy.EnergyNetwork

public final class EnergyNetwork extends Object
Central manager responsible for handling all energy node interactions.

This includes:

  • Registration and lifecycle management of nodes
  • Energy distribution across connected graphs
  • Persistence and restoration of node state

The distribution system uses a breadth-first traversal to locate valid sinks and distribute energy evenly across them.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.fasterxml.jackson.databind.ObjectMapper
    Shared JSON mapper used for persistence.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Performs energy distribution across the network.
    static Set<EnergyNode>
     
    static void
    Initializes the network scheduler and database.
    static void
    Loads nodes from persistent storage.
    static void
    Updates whether a node should be considered active.
    static void
    Registers a node into the network.
    static void
    Saves all nodes asynchronously to the database.
    static void
    Unregisters a node and disconnects it from all neighbors.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • JSON_MAPPER

      public static final com.fasterxml.jackson.databind.ObjectMapper JSON_MAPPER
      Shared JSON mapper used for persistence.
  • Method Details

    • init

      public static void init()
      Initializes the network scheduler and database.
    • register

      public static void register(EnergyNode node)
      Registers a node into the network.
      Parameters:
      node - the node to register
    • unregister

      public static void unregister(EnergyNode node)
      Unregisters a node and disconnects it from all neighbors.
      Parameters:
      node - the node to remove
    • getNodes

      public static Set<EnergyNode> getNodes()
      Returns:
      all registered nodes
    • markActive

      public static void markActive(EnergyNode node)
      Updates whether a node should be considered active.
      Parameters:
      node - the node to evaluate
    • distribute

      public static void distribute()
      Performs energy distribution across the network.

      Uses BFS traversal to locate sinks and evenly distribute energy.

    • save

      public static void save()
      Saves all nodes asynchronously to the database.
    • load

      public static void load()
      Loads nodes from persistent storage.