Class EnergyNetwork
java.lang.Object
com.github.darksoulq.abyssallib.common.energy.EnergyNetwork
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
FieldsModifier and TypeFieldDescriptionstatic final com.fasterxml.jackson.databind.ObjectMapperShared JSON mapper used for persistence. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidPerforms energy distribution across the network.static Set<EnergyNode> getNodes()static voidinit()Initializes the network scheduler and database.static voidload()Loads nodes from persistent storage.static voidmarkActive(EnergyNode node) Updates whether a node should be considered active.static voidregister(EnergyNode node) Registers a node into the network.static voidsave()Saves all nodes asynchronously to the database.static voidunregister(EnergyNode node) Unregisters a node and disconnects it from all neighbors.
-
Field Details
-
JSON_MAPPER
public static final com.fasterxml.jackson.databind.ObjectMapper JSON_MAPPERShared JSON mapper used for persistence.
-
-
Method Details
-
init
public static void init()Initializes the network scheduler and database. -
register
Registers a node into the network.- Parameters:
node- the node to register
-
unregister
Unregisters a node and disconnects it from all neighbors.- Parameters:
node- the node to remove
-
getNodes
- Returns:
- all registered nodes
-
markActive
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.
-