flowable_node_registry.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. -- registry of flowable node behaviours in new flow logic
  2. -- written 2017 by thetaepsilon
  3. -- the actual registration functions which edit these tables can be found in flowable_node_registry_install.lua
  4. -- this is because the ABM code needs to inspect these tables,
  5. -- but the registration code needs to reference said ABM code.
  6. -- so those functions were split out to resolve a circular dependency.
  7. pipeworks.flowables = {}
  8. pipeworks.flowables.list = {}
  9. pipeworks.flowables.list.all = {}
  10. -- pipeworks.flowables.list.nodenames = {}
  11. -- simple flowables - balance pressure in any direction
  12. pipeworks.flowables.list.simple = {}
  13. pipeworks.flowables.list.simple_nodenames = {}
  14. -- directional flowables - can only flow on certain sides
  15. -- format per entry is a table with the following fields:
  16. -- neighbourfn: function(node),
  17. -- called to determine which nodes to consider as neighbours.
  18. -- can be used to e.g. inspect the node's param values for facedir etc.
  19. -- returns: array of vector offsets to look for possible neighbours in
  20. -- directionfn: function(node, vector):
  21. -- can this node flow in this direction?
  22. -- called in the context of another node to check the matching entry returned by neighbourfn.
  23. -- for every offset vector returned by neighbourfn,
  24. -- the node at that absolute position is checked.
  25. -- if that node is also a directional flowable,
  26. -- then that node's vector is passed to that node's directionfn
  27. -- (inverted, so that directionfn sees a vector pointing out from it back to the origin node).
  28. -- if directionfn agrees that the neighbour node can currently flow in that direction,
  29. -- the neighbour is to participate in pressure balancing.
  30. pipeworks.flowables.list.directional = {}
  31. -- simple intakes - try to absorb any adjacent water nodes
  32. pipeworks.flowables.inputs = {}
  33. pipeworks.flowables.inputs.list = {}
  34. pipeworks.flowables.inputs.nodenames = {}
  35. -- outputs - takes pressure from pipes and update world to do something with it
  36. pipeworks.flowables.outputs = {}
  37. pipeworks.flowables.outputs.list = {}
  38. -- not currently any nodenames arraylist for this one as it's not currently needed.
  39. -- nodes with registered node transitions
  40. -- nodes will be switched depending on pressure level
  41. pipeworks.flowables.transitions = {}
  42. pipeworks.flowables.transitions.list = {} -- master list
  43. pipeworks.flowables.transitions.simple = {} -- nodes that change based purely on pressure
  44. pipeworks.flowables.transitions.mesecons = {} -- table of mesecons rules to apply on transition