Add more information to Room Positions

This commit is contained in:
2022-06-15 12:34:36 +01:00
parent bf1bfa5453
commit 62dae5bebe
12 changed files with 192 additions and 112 deletions
+16 -3
View File
@@ -1,6 +1,8 @@
--{-# LANGUAGE LambdaCase #-}
module Dodge.PlacementSpot
( atFstLnkOut
, rpIsOnPath
, rpIsOffPath
, useUnusedLnk
, psRandRanges
, useRoomPosCond
@@ -68,6 +70,17 @@ psposAddLabel lab = psSelect %~ (\f rp r -> f rp r & _Just . _2 . rpType %~ S.in
rprBool :: (RoomPos -> Room -> Bool) -> PlacementSpot
rprBool t = PSPos (useRoomPosRoomCond t) (const id) Nothing
rpIsOnPath :: RoomPos -> Bool
rpIsOnPath = any f . _rpType
where
f RoomPosOnPath {} = True
f _ = False
rpIsOffPath :: RoomPos -> Bool
rpIsOffPath = any f . _rpType
where
f RoomPosOffPath {} = True
f _ = False
resetPLUse :: PlacementSpot -> PlacementSpot
resetPLUse (PSPos f g fallback) = PSPos f' g fallback
where
@@ -109,7 +122,7 @@ unusedOffPathAwayFromLink :: Float -> PlacementSpot
--unusedOffPathAwayFromLink x = rprBool $ \rp r -> _rpLinkStatus rp == NotLink
unusedOffPathAwayFromLink x = rprBool $ \rp r -> _rpPlacementUse rp == 0
&& all ( (>x) . dist (_rpPos rp) ) (usedRoomLinkPoss r)
&& RoomPosOffPath `S.member` _rpType rp
&& rpIsOffPath rp
unusedSpotAwayFromInLink :: Float -> PlacementSpot
unusedSpotAwayFromInLink x = rprBool $ \rp r -> _rpLinkStatus rp == NotLink
@@ -123,8 +136,8 @@ twoRoomPoss :: (RoomPos -> Room -> Bool)
-> (RoomPos -> Room -> Bool)
-> (PlacementSpot -> PlacementSpot -> Placement)
-> Placement
twoRoomPoss cond1 cond2 f = Placement (rprBool cond1) PutNothing Nothing
$ \_ pl1 -> Just $ Placement (rprBool cond2) PutNothing Nothing
twoRoomPoss cond1 cond2 f = Placement 10 (rprBool cond1) PutNothing Nothing
$ \_ pl1 -> Just $ Placement 10 (rprBool cond2) PutNothing Nothing
$ \_ pl2 -> Just $ f (_plSpot pl1) (_plSpot pl2)
--isUnusedLnk :: RoomPos -> Bool