Improve placementspots
This commit is contained in:
+2
-1
@@ -128,7 +128,8 @@ doAfterPlacement pmntis gw = gRandify gw $ do
|
||||
return $ newgw & gRooms . ix i .~ rm
|
||||
|
||||
doInPlacements :: ( IM.IntMap [Placement],GenWorld) -> GenWorld
|
||||
doInPlacements (im,w) = let (gw,rms) = mapAccumR (doRoomInPlacements im) w (_gRooms w)
|
||||
doInPlacements (im,w) =
|
||||
let (gw,rms) = mapAccumR (doRoomInPlacements im) w (_gRooms w)
|
||||
in gw {_gRooms = rms}
|
||||
|
||||
doRoomInPlacements :: IM.IntMap [Placement] -> GenWorld -> Room -> (GenWorld, Room)
|
||||
|
||||
@@ -49,7 +49,6 @@ moveLSThen posf off sh = propLSThen propupdate lsupdate thels theprop
|
||||
, _prToggle = True
|
||||
}
|
||||
|
||||
|
||||
-- | mount a light source on a shape
|
||||
mntLSOn
|
||||
:: (Point2 -> Point3 -> Shape) -- ^ function describing the mount shape
|
||||
|
||||
@@ -8,6 +8,7 @@ module Dodge.PlacementSpot
|
||||
, anyUnusedSpot
|
||||
, unusedSpotAwayFromLink
|
||||
, isUnusedLnk
|
||||
, isInLnk
|
||||
, unusedLnkToPS
|
||||
, unusedSpotNearInLink
|
||||
, randDirPS
|
||||
@@ -20,6 +21,8 @@ module Dodge.PlacementSpot
|
||||
, setFallback
|
||||
, twoRoomPoss
|
||||
, isUnusedLinkType
|
||||
, roomPosRoomBoolShift
|
||||
, shiftInBy
|
||||
) where
|
||||
import Dodge.LevelGen.Data
|
||||
import Geometry
|
||||
@@ -52,6 +55,17 @@ anyUnusedSpot = roomPosBool $ \rp -> _rpLinkStatus rp == NotLink && _rpPlacement
|
||||
roomPosRoomBool :: (RoomPos -> Room -> Bool) -> PlacementSpot
|
||||
roomPosRoomBool t = PSPos (useRoomPosRoomCond t) (const id) Nothing
|
||||
|
||||
roomPosRoomBoolShift :: (RoomPos -> Room -> Bool)
|
||||
-> ((Point2,Float) -> (Point2,Float))
|
||||
-> PlacementSpot
|
||||
roomPosRoomBoolShift t shift = PSPos f (const id) Nothing
|
||||
where
|
||||
f rp r
|
||||
| t rp r = Just (PS p a, rp & rpPlacementUse +~ 1)
|
||||
| otherwise = Nothing
|
||||
where
|
||||
(p,a) = shift (_rpPos rp, _rpDir rp)
|
||||
|
||||
unusedSpotAwayFromLink :: Float -> PlacementSpot
|
||||
unusedSpotAwayFromLink x = roomPosRoomBool $ \rp r -> _rpLinkStatus rp == NotLink
|
||||
&& _rpPlacementUse rp == 0
|
||||
@@ -88,6 +102,11 @@ isUnusedLnk rp = case _rpLinkStatus rp of
|
||||
UnusedLink {} -> _rpPlacementUse rp == 0
|
||||
_ -> False
|
||||
|
||||
isInLnk :: RoomPos -> Bool
|
||||
isInLnk rp = case _rpLinkStatus rp of
|
||||
UsedInLink {} -> _rpPlacementUse rp == 0
|
||||
_ -> False
|
||||
|
||||
useUnusedLnk :: PlacementSpot
|
||||
useUnusedLnk = roomPosBool isUnusedLnk
|
||||
|
||||
@@ -99,19 +118,13 @@ isUsedLnkUnplaced rp = case _rpLinkStatus rp of
|
||||
|
||||
useRoomPosCond :: (RoomPos -> Bool) -> RoomPos -> Room -> Maybe (PlacementSpot,RoomPos)
|
||||
useRoomPosCond t rp _
|
||||
| t rp = Just (PS p a, rp & rpPlacementUse +~ 1)
|
||||
| t rp = Just (PS (_rpPos rp) (_rpDir rp), rp & rpPlacementUse +~ 1)
|
||||
| otherwise = Nothing
|
||||
where
|
||||
p = _rpPos rp
|
||||
a = _rpDir rp
|
||||
|
||||
useRoomPosRoomCond :: (RoomPos -> Room -> Bool) -> RoomPos -> Room -> Maybe (PlacementSpot,RoomPos)
|
||||
useRoomPosRoomCond t rp r
|
||||
| t rp r = Just (PS p a, rp & rpPlacementUse +~ 1)
|
||||
| t rp r = Just (PS (_rpPos rp) (_rpDir rp), rp & rpPlacementUse +~ 1)
|
||||
| otherwise = Nothing
|
||||
where
|
||||
p = _rpPos rp
|
||||
a = _rpDir rp
|
||||
|
||||
unusedLnkToPS :: RoomPos -> Room -> Maybe (PlacementSpot,RoomPos)
|
||||
unusedLnkToPS = useRoomPosCond $ \rp -> case _rpLinkStatus rp of
|
||||
@@ -172,6 +185,9 @@ atNthLnkOutShiftInward n x = atNthLnkOutShiftBy n f
|
||||
where
|
||||
f (p,a) = (p +.+ rotateV a (V2 0 (negate x)),a)
|
||||
|
||||
shiftInBy :: Float -> (Point2,Float) -> (Point2,Float)
|
||||
shiftInBy x (p,a) = (p +.+ rotateV a (V2 0 (negate x)),a)
|
||||
|
||||
--anyLnkInPS :: Float -- ^ amount to shift inward
|
||||
-- -> PlacementSpot
|
||||
--anyLnkInPS x = PSPos f (const id) Nothing
|
||||
|
||||
@@ -33,9 +33,11 @@ import System.Random
|
||||
cenLasTur :: Room
|
||||
cenLasTur = roomNgon 8 200 & rmPmnts .~
|
||||
[ putLasTurret 0.02
|
||||
, heightWall 30 (rectNSEW (-90) (-110) 20 (-20))
|
||||
, heightWallPS (roomPosRoomBoolShift (\rp _ -> isInLnk rp) (shiftInBy 100)) 30 covershape
|
||||
, mntLightLnkCond unusedLnkToPS
|
||||
]
|
||||
where
|
||||
covershape = rectNSEW 10 (-10) 20 (-20)
|
||||
|
||||
lightSensInsideDoor :: Int -> Room -> Room
|
||||
lightSensInsideDoor outplid rm = rm
|
||||
|
||||
Reference in New Issue
Block a user