pressure logic: flowable node registry: add directionfn to directional flowable entries

This commit is contained in:
thetaepsilon-gamedev 2017-10-17 23:14:26 +01:00
parent 909b321f3c
commit 0a4d15d26e
2 changed files with 15 additions and 15 deletions

View File

@ -23,6 +23,16 @@ pipeworks.flowables.list.simple_nodenames = {}
-- called to determine which nodes to consider as neighbours.
-- can be used to e.g. inspect the node's param values for facedir etc.
-- returns: array of vector offsets to look for possible neighbours in
-- directionfn: function(node, vector):
-- can this node flow in this direction?
-- called in the context of another node to check the matching entry returned by neighbourfn.
-- for every offset vector returned by neighbourfn,
-- the node at that absolute position is checked.
-- if that node is also a directional flowable,
-- then that node's vector is passed to that node's directionfn
-- (inverted, so that directionfn sees a vector pointing out from it back to the origin node).
-- if directionfn agrees that the neighbour node can currently flow in that direction,
-- the neighbour is to participate in pressure balancing.
pipeworks.flowables.list.directional = {}
-- simple intakes - try to absorb any adjacent water nodes
@ -41,16 +51,3 @@ pipeworks.flowables.transitions = {}
pipeworks.flowables.transitions.list = {} -- master list
pipeworks.flowables.transitions.simple = {} -- nodes that change based purely on pressure
pipeworks.flowables.transitions.mesecons = {} -- table of mesecons rules to apply on transition
-- checks if a given node can flow in a given direction.
-- used to implement directional devices such as pumps,
-- which only visually connect in a certain direction.
-- node is the usual name + param structure.
-- direction is an x/y/z vector of the flow direction;
-- this function answers the question "can this node flow in this direction?"
pipeworks.flowables.flow_check = function(node, direction)
minetest.log("warning", "pipeworks.flowables.flow_check() stub!")
return true
end

View File

@ -43,9 +43,12 @@ end
-- Register a node as a directional flowable:
-- has a helper function which determines which nodes to consider valid neighbours.
register.directional = function(nodename, neighbourfn)
register.directional = function(nodename, neighbourfn, directionfn)
insertbase(nodename)
pipeworks.flowables.list.directional[nodename] = { neighbourfn = neighbourfn }
pipeworks.flowables.list.directional[nodename] = {
neighbourfn = neighbourfn,
directionfn = directionfn
}
regwarning("directional", nodename)
end