Somewhat simplify RoomPos types

This commit is contained in:
2025-10-05 20:47:28 +01:00
parent 43db5a2ebc
commit 4cc5477f07
5 changed files with 17 additions and 22 deletions
+5 -12
View File
@@ -2,10 +2,9 @@
module Dodge.PlacementSpot (
atFstLnkOut,
atNthLnkOutShiftBy,
rpIsOnPath,
rpIsOnGrid,
rpIsOffPath,
rpOffPathFromEdge,
rpOnPathFromEdge,
useUnusedLnk,
psRandRanges,
useRoomPosCond,
@@ -73,16 +72,16 @@ psposAddLabel lab = psSelect %~ (\f rp r -> f rp r & _Just . _2 . rpType %~ S.in
rprBool :: (RoomPos -> Room -> Bool) -> PlacementSpot
rprBool t = PSPos (useRoomPosRoomCond (S.singleton UsedPosLow) t) (const id) Nothing
rpIsOnPath :: RoomPos -> Bool
rpIsOnPath = any f . _rpType
rpIsOnGrid :: RoomPos -> Bool
rpIsOnGrid = any f . _rpType
where
f RoomPosOnPath{} = True
f RoomPosOnGrid{} = True
f _ = False
rpIsOffPath :: RoomPos -> Bool
rpIsOffPath = any f . _rpType
where
f RoomPosOffPath{} = True
f RoomPosOffGrid{} = True
f _ = False
rpOffPathFromEdge :: PathFromEdge -> RoomPos -> Bool
@@ -90,12 +89,6 @@ rpOffPathFromEdge pe = any f . _rpType
where
f rt = maybe False (pe `elem`) (rt ^? offPathFromEdges)
-- test whether a roomPos is on the path with a given from edge value
rpOnPathFromEdge :: PathFromEdge -> RoomPos -> Bool
rpOnPathFromEdge pe = any f . _rpType
where
f rt = maybe False (pe `elem`) (rt ^? onPathFromEdges)
resetPLUse :: PlacementSpot -> PlacementSpot
resetPLUse (PSPos f g fallback) = PSPos f' g fallback
where