Continue placement refactor

This commit is contained in:
2021-09-28 15:44:32 +01:00
parent b8af2ce9d8
commit 6b937b115e
10 changed files with 46 additions and 78 deletions
+2 -10
View File
@@ -1,17 +1,8 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Room.Data
( Room (..)
, rmPolys
, rmLinks
, rmPath
, rmPS
, rmBound
, rmFloor
, rmName
) where
where
import Dodge.LevelGen.Data
--import Geometry
import Geometry.Data
import Data.Tile
@@ -33,5 +24,6 @@ data Room = Room
, _rmBound :: [ [Point2] ]
, _rmFloor :: [Tile]
, _rmName :: String
, _rmShift :: (Point2, Float)
}
makeLenses ''Room
+2 -2
View File
@@ -63,14 +63,14 @@ shiftRoomToLink l r
r
where
(p,a) = last $ _rmLinks r
-- NOTE placements are shifted by the room shift
shiftRoomBy :: (Point2,Float) -> Room -> Room
shiftRoomBy shift r = r
& rmPolys %~ fmap (map (shiftPointBy shift))
& rmLinks %~ fmap (shiftLinkBy shift)
& rmPath %~ map (shiftPathPointBy shift)
& rmPS %~ fmap (shiftPSBy shift)
& rmBound %~ fmap (map (shiftPointBy shift))
& rmShift %~ shiftLinkBy shift
& rmFloor %~ map
( (tilePoly %~ map (shiftPointBy shift))
. (tileZero %~ shiftPointBy shift )
+2 -2
View File
@@ -24,7 +24,7 @@ import Control.Lens
import Control.Monad.State
import Data.Tree
import qualified Data.Map as M
import qualified Data.IntMap as IM
--import qualified Data.IntMap as IM
twinSlowDoorRoom
:: Int -- ^ Door id
@@ -56,7 +56,7 @@ twinSlowDoorRoom drid w h x = defaultRoom
, _rmName = "twinSlowDoorRoom"
}
where
drmoving w' = True -- DoorHalfway == _drStatus (_doors w' IM.! drid)
drmoving _ = True -- DoorHalfway == _drStatus (_doors w' IM.! drid)
lampHeight = 41
ps =
[rectNSWE h 0 (-w) w
+8 -8
View File
@@ -30,33 +30,33 @@ Places a line of blocks between two points.
Width 9, also extends out from each point by 9.
-}
blockLine :: Point2 -> Point2 -> Placement
blockLine a b = SimplePlacement $ PS
blockLine a b = Placement PS
{ _psPos = V2 0 0
, _psRot = 0
, _psType = PutLineBlock baseBlockPane 9 9 a b
}
} (const Nothing)
{-
Places an breakable window between two points.
Width 8, also extends out from each point by 8.
-}
windowLine :: Point2 -> Point2 -> Placement
windowLine a b = SimplePlacement $ PS
windowLine a b = Placement PS
{ _psPos = V2 0 0
, _psRot = 0
, _psType = PutLineBlock baseWindowPane 8 8 a b
}
} (const Nothing)
{-
Places an unbreakable window between two points.
Width 7, also extends out from each point by 7.
-}
crystalLine :: Point2 -> Point2 -> Placement
crystalLine a b = SimplePlacement $ PS
crystalLine a b = Placement PS
{ _psPos = V2 0 0
, _psRot = 0
, _psType = PutWall ps defaultCrystalWall
}
} (const Nothing)
where
ps =
[ a +.+ left +.+ up
@@ -70,11 +70,11 @@ crystalLine a b = SimplePlacement $ PS
Depth 15, does not extend wider than points.
-}
wallLine :: Point2 -> Point2 -> Placement
wallLine a b = SimplePlacement $ PS
wallLine a b = Placement PS
{ _psPos = V2 0 0
, _psRot = 0
, _psType = PutWall ps defaultWall
}
} (const Nothing)
where
ps =
[ a +.+ up
+1 -1
View File
@@ -180,7 +180,7 @@ fillNothingPlacement :: PSType -> Room -> Room
fillNothingPlacement pst r =
r & rmPS %~ replaceNothingWith pst
where
replaceNothingWith x (SimplePlacement (PS p rot PutNothing): pss) = sPS p rot x : pss
replaceNothingWith x (Placement (PS p rot PutNothing) _: pss) = sPS p rot x : pss
replaceNothingWith x (ps:pss) = ps : replaceNothingWith x pss
replaceNothingWith _ [] = []
{- | Successively fill 'PutNothing' placements with a list of given 'PSType's.