Ancient Warfare 2

Ancient Warfare 2

6M Downloads

Torque System -- Rework to a proper network graph

shadowmage45 opened this issue ยท 0 comments

commented

Rework torque power system to a proper network graph setup. Remove most of the per-tile update stuff. Have producers, transport, and consumers. Would likely require 'gearbox' tiles to convert between high/med/low, or some other method to handle different capacities on the same network. Could likely mean the removal of sided tiles; can return to auto-connections. At this point it would probably also be wise to restructure to an integer-based energy sytem.

Graph would track entry and exit points and the number of tiles making up the network. Entry points would be generators or input connections from external power APIs. Exit points would be worksites or output connections to external power APIs. Graphs would also need to track the list of chunks that they have tiles within.

Energy would be added from producers into the network every tick into a per-tile input buffer. Energy from input buffer would be added to the network every tick (up to saturation). The network would check consumers every tick to try and output any stored energy. This would maintain line saturation mechanics. Client energy would equal the highest energy state that for that tick (e.g. if 0 stored + 5 transferred, client would see 5). Energy drain would be applied to the network as a whole.

Networks would be updated from a tick handler on a per-world basis. Network IDs would be global (will likely just use a UUID for these). When power values for a network are changed, transmit the update to all players watching any chunks that the network is within. Could possibly just blanket update all players.

Could massively reduce network data use for the power system. Would only need to send data to clients regarding energy nets instead of individual tiles. Individual tiles would only need updated occasionally regarding which network id they are a part of.

Clients can have a simple network-id map for tile networks. Rendering would pull values directly from the map for rotation states for an entire network. Periodically clear the id-map, or track last-update time to clear stale values?

Largest problems to solve:

  • Adding tiles from network when placed by players
  • Removing tiles from network when broken by players or environment
  • Adding tiles from network when loaded from NBT on chunk load
  • Removing tiles from network on chunk unload

Energy graph:
List entryPoints;
List exitPoints;
List networkedTiles;
???