Work toward adding wiring

This commit is contained in:
2021-11-14 00:39:24 +00:00
parent 96c72ef578
commit 4a089ff0cc
34 changed files with 154 additions and 214 deletions
+45 -6
View File
@@ -5,6 +5,7 @@ import Dodge.Data
import Picture
import Geometry
import Shape.Data
import Data.Tile
import Control.Lens
import Control.Monad.State
@@ -33,10 +34,12 @@ data PSType = PutCrit {_unPutCrit :: Creature}
-- maybe there is a monadic implementation of this?
data PlacementSpot
= PS { _psPos :: Point2 , _psRot :: Float }
| PSLnk { _psLinkTest :: (Point2,Float) -> Bool
, _psLinkShift :: (Point2,Float) -> (Point2,Float)
, _psFallback :: Maybe Placement
}
| PSLnk
{ _psLnkTest :: (Point2,Float) -> Bool
, _psLnkShift :: (Point2,Float) -> (Point2,Float)
, _psLnkRoomEff :: (Point2,Float) -> Room -> Room
, _psLnkFallback :: Maybe Placement
}
| PSRoomRand { _psRoomRandPointNum :: Int }
data Placement = Placement
{ _plSpot :: PlacementSpot
@@ -48,11 +51,11 @@ data Placement = Placement
| RandomPlacement {_unRandomPlacement :: State StdGen Placement}
anyLnkOutPS :: PlacementSpot
anyLnkOutPS = PSLnk (const True) id Nothing
anyLnkOutPS = PSLnk (const True) id (const id) Nothing
anyLnkInPS :: Float -- ^ amount to shift inward
-> PlacementSpot
anyLnkInPS x = PSLnk (const True) f Nothing
anyLnkInPS x = PSLnk (const True) f (const id) Nothing
where
f (v,a) = (v -.- x *.* unitVectorAtAngle (a + 0.5 * pi), a+ pi)
@@ -104,6 +107,42 @@ addPlmnt pl pl2 = case pl2 of
g Nothing = Just pl
g (Just pl') = Just $ addPlmnt pl pl'
{-
The '_rmPolys' list states which polygons should be cut out to form the indestructible walls of the room.
Link pairs contain a position and rotation to attach to another room;
0 is for links going to another room to the north, pi/2 for links going to a room to the west, etc.
TODO : Explain path, does it need both directions?
Placement spots allow things to be put in the room during level generation.
Room bounds between a new room and previously placed rooms are checked during level generation,
assigning no bounds will allow rooms to overlap.
-}
data Room = Room
{ _rmPolys :: [ [Point2] ]
, _rmLinks :: [(Point2,Float)]
, _rmPos :: [RoomPos]
, _rmPath :: [(Point2, Point2)]
, _rmPmnts :: [Placement]
, _rmPartPmnt :: Maybe ([Placement] -> Placement)
, _rmExtPmnt :: Maybe Placement
, _rmBound :: [ [Point2] ]
, _rmFloor :: [Tile]
, _rmName :: String
, _rmShift :: (Point2, Float)
, _rmViewpoints :: [Point2]
, _rmRandPSs :: [State StdGen (Point2,Float)]
, _rmLabel :: Maybe Int
, _rmTakeFrom :: Maybe Int
, _rmWires :: [RoomWire]
}
data RoomWire
= RoomWire (Point2,Float) (Point2,Float)
data RoomPos
= OutLink Int Point2 Float
| InLink Point2 Float
| PosPl Point2 Float
| LabPos Int RoomPos
deriving (Eq,Ord,Show)
makeLenses ''Room
makeLenses ''PSType
makeLenses ''PlacementSpot
makeLenses ''Placement