whoward69
DLL Minion
Lua classes, methods and functions to determine if two plots are connected by a river - see here for the general discussion
A River is one or more contiguous RiverSegments.
A river has a "known" headwaters and outflow (which may not be the actual headwaters/outflow if tiles have not been revealed)
A river flows from the headwaters to the outflow, it may have upstream branches (tributaries) and downstream branches (typically, but not necessarily, in deltas)
A RiverSegment is a single section of a River that flows between two adjacent tiles
A segment has both a primary tile (the one it is attached to) and an adjacent segment (which may be null if off the edge of the map)
A segment has a flow direction and can ascertain the next segment(s) both downstream and upstream.
A segment with no (known) upstream segment(s) is a headwater, one with no (known) downstream segment(s) is an outflow
A lake is treated as having a river flowing clockwise around its shoreline
Rivers and lakes are assumed to be immutable, users of IGE take note!!!
(use riverManager:rescanMap() after editing terrain/features/rivers to update the internal cache)
Sample usage
A River is one or more contiguous RiverSegments.
A river has a "known" headwaters and outflow (which may not be the actual headwaters/outflow if tiles have not been revealed)
A river flows from the headwaters to the outflow, it may have upstream branches (tributaries) and downstream branches (typically, but not necessarily, in deltas)
A RiverSegment is a single section of a River that flows between two adjacent tiles
A segment has both a primary tile (the one it is attached to) and an adjacent segment (which may be null if off the edge of the map)
A segment has a flow direction and can ascertain the next segment(s) both downstream and upstream.
A segment with no (known) upstream segment(s) is a headwater, one with no (known) downstream segment(s) is an outflow
A lake is treated as having a river flowing clockwise around its shoreline
Rivers and lakes are assumed to be immutable, users of IGE take note!!!
(use riverManager:rescanMap() after editing terrain/features/rivers to update the internal cache)
Sample usage
Code:
-- Get the river manager, only caring about passable terrain,
-- not if the player can actually traverse the plot
local riverManager = RiverManager:new(isPlotPassableTerrain)
-- Get the common rivers to the start and end plots
local rivers = riverManager:getCommonRivers(iStartX, iStartY, iEndX, iEndY)
-- If the start and end plots share at least one common river ...
if (#rivers > 0) then
-- ... get the route between the plots on the first river
local route = riverManager:getRiverRoute(rivers[1], iStartX, iStartY, iEndX, iEndY)
-- If there is a route ...
if (#route > 0) then
-- ... get the traversable plots along the bank of the shortest route
-- from the start to end plot. (If there are more than one river
-- between the plots, this may not be on the first river.)
local bankPlots = riverManager:getRiverBankRoute(iStartX, iStartY, iEndX, iEndY)
end
end