-
Notifications
You must be signed in to change notification settings - Fork 3
Pipe Mechanics
Every pipe can connect on all 6 sides. The multipart-versions check for occlusion or covers/panels/slabs on the connecting side. Hollow covers and similar can be used to cover holes while still allowing the pipe to connect through the hole.
Pipes adjacent to "regular" machines that support handling fluids, i.e. implement IFluidHandler, are wrapped internally in a passive pipe end - pressure is determined as if it was a regular pipe. Multiple pipe ends for the same IFluidHandler are calculated separately and do NOT share pressure. Pipes only connect if there is at least one tank info reported for the side. (Dev Note: If this causes issues in the future, this might change!)
Taam machines provide pipe ends to connect to the pipe network. Usually they are also visible in the world as flanges on the side of the machine. Pipe ends bridge from the pipe network to the inner workings of a machine, e.g. an internal tank or another connected pipe end.
There are active and passive pipe ends. Active ones have their pressure and suction actively controlled by the machine, passive ones participate as regular pipes in the network and have their pressure calculated. Some specific pipe ends, e.g. used in the pump, come in pairs and share the same fluid content but have different prevvure values. This way, the pump itself does not need to actively transfer fluid, as that will be handled by the default transfer logic.
Every pipe (and pipe end) has a pressure and a suction value. These values are either set fixed, using active pipe ends, or calculated using the connected pipes. When calculated, pressure is the maximum connected pressure minus one, suction is the maximum connected suction minus two.
Doing this calculation every tick implies that pressure will not simply vanish when not maintained, but rather drop to zero within a few seconds (depending on the pressure, of course). Neither pressure nor suction should ever be lower than zero - there might be side effects if such a phenomenon should ever occur.
When talking about pressure, one usually refers to the effective pressure - calculated by subtracting the suction from the pressure value. The resulting pressure is not stored permanently, as calculating is rather cheap, but rather the pressure and suction values.
Fluid is always transferred from higher to lower (effective) pressure. The default logic transfers one third of the fluid content of a pipe to every connected pipe with a lower effective pressure, or as much as can fit into the respective pipe. Transfer always starts with the oldest fluid in the pipe (the fluid amount that was above 0 for the longest period). Zero-Amount fluid stacks are cleaned after the transfer. If not handled with care, this can get fluid stuck if multiple fluids are in the same pipe.
The pipes are chosen by fetching internal connections first. Internal connections are defined by the pipe (or pipe end) and is used for the wrapped IFluidHandlers for example. After that, all regular connections on the six sides are checked, given the pipe can connect to that side, in the order [TODO: EnumFacing order].