Generalise link effects
This commit is contained in:
+8
-4
@@ -1409,10 +1409,14 @@ assigning no bounds will allow rooms to overlap. -}
|
|||||||
data Room = Room
|
data Room = Room
|
||||||
{ _rmPolys :: [ [Point2] ]
|
{ _rmPolys :: [ [Point2] ]
|
||||||
, _rmLinks :: [RoomLink]
|
, _rmLinks :: [RoomLink]
|
||||||
--, _rmOutLinks :: [RoomLink]
|
-- the Int is the number of previous outlinks that have been assigned
|
||||||
--, _rmInLinks :: [RoomLink]
|
, _rmLinkEff
|
||||||
-- update the room when assigning the next link to an adjacent room with the head of of this list, return the tail
|
:: RoomLink -- ^ child link
|
||||||
, _rmLinkEff :: [RoomLink -> Room -> Room]
|
-> Room -- ^ child room
|
||||||
|
-> Int -- ^ child number
|
||||||
|
-> RoomLink -- ^ parent link
|
||||||
|
-> Room -- ^ parent room
|
||||||
|
-> Room
|
||||||
, _rmPos :: [RoomPos]
|
, _rmPos :: [RoomPos]
|
||||||
, _rmPath :: [(Point2, Point2)]
|
, _rmPath :: [(Point2, Point2)]
|
||||||
, _rmPmnts :: [Placement]
|
, _rmPmnts :: [Placement]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ defaultRoom :: Room
|
|||||||
defaultRoom = Room
|
defaultRoom = Room
|
||||||
{ _rmPolys = []
|
{ _rmPolys = []
|
||||||
, _rmLinks = []
|
, _rmLinks = []
|
||||||
, _rmLinkEff = []
|
, _rmLinkEff = const . const . const . const id
|
||||||
, _rmPos = []
|
, _rmPos = []
|
||||||
, _rmPath = []
|
, _rmPath = []
|
||||||
, _rmPmnts = []
|
, _rmPmnts = []
|
||||||
|
|||||||
@@ -42,9 +42,10 @@ sensorRoom senseType n = do
|
|||||||
rm <- takeOne [roomNgon 8 200, roomRectAutoLinks 200 200]
|
rm <- takeOne [roomNgon 8 200, roomRectAutoLinks 200 200]
|
||||||
cenroom <- shuffleLinks $ sensInsideDoor senseType n rm
|
cenroom <- shuffleLinks $ sensInsideDoor senseType n rm
|
||||||
let doorroom = triggerDoorRoom n
|
let doorroom = triggerDoorRoom n
|
||||||
return $ treeFromPost [PassDown door,PassDown $ cenroom & rmLinkEff .~ [f,f],PassDown doorroom] (UseAll door)
|
return $ treeFromPost [PassDown door,PassDown $ cenroom & rmLinkEff .~ f,PassDown doorroom] (UseAll door)
|
||||||
where
|
where
|
||||||
f rl rm = rm & rmLinks %~ map (g (_rlPos rl) (_rlDir rl))
|
f _ _ 0 rl rm = rm & rmLinks %~ map (g (_rlPos rl) (_rlDir rl))
|
||||||
|
f _ _ _ _ rm = rm
|
||||||
g p d rl
|
g p d rl
|
||||||
| isclose = rl & rlType . at BlockedLink ?~ ()
|
| isclose = rl & rlType . at BlockedLink ?~ ()
|
||||||
| otherwise = rl
|
| otherwise = rl
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ posRms prs parenti@(parent,_) ( (numChild,t@(Node childi _) ):its) tseq = do
|
|||||||
where
|
where
|
||||||
newBounds = map pointsToPoly . _rmBound . doRoomShift . fst $ rootLabel shiftedt
|
newBounds = map pointsToPoly . _rmBound . doRoomShift . fst $ rootLabel shiftedt
|
||||||
clipping = or (convexPolysOverlap <$> newBounds <*> _prBounds prs)
|
clipping = or (convexPolysOverlap <$> newBounds <*> _prBounds prs)
|
||||||
updateparent rm = doLnkEff outlnk $ rm
|
updateparent rm = _rmLinkEff rm il child numChild outlnk rm
|
||||||
& rmLinks %~ delete outlnk
|
& rmLinks %~ delete outlnk
|
||||||
& rmPos .:~ RoomPos
|
& rmPos .:~ RoomPos
|
||||||
{ _rpPos = fst (lnkPosDir outlnk)
|
{ _rpPos = fst (lnkPosDir outlnk)
|
||||||
@@ -151,7 +151,7 @@ printInfoCheckNum (parentrm,parenti) childn (childrm,childi) = printPartialColum
|
|||||||
0 -> _rmName parentrm ++ "-" ++ show parenti
|
0 -> _rmName parentrm ++ "-" ++ show parenti
|
||||||
_ -> ""
|
_ -> ""
|
||||||
|
|
||||||
doLnkEff :: RoomLink -> Room -> Room
|
--doLnkEff :: RoomLink -> Room -> Room
|
||||||
doLnkEff x rm = case _rmLinkEff rm of
|
--doLnkEff x rm = case _rmLinkEff rm of
|
||||||
(eff:effs) -> eff x $ rm & rmLinkEff .~ effs
|
-- (eff:effs) -> eff x $ rm & rmLinkEff .~ effs
|
||||||
_ -> rm
|
-- _ -> rm
|
||||||
|
|||||||
Reference in New Issue
Block a user