Allow for random choice between placements in different rooms

This commit is contained in:
2021-11-26 12:20:20 +00:00
parent aad79bdf25
commit 123bcd2c94
27 changed files with 260 additions and 191 deletions
+19 -15
View File
@@ -21,19 +21,18 @@ data PSType = PutCrit {_unPutCrit :: Creature}
| PutButton Button
| PutProp Prop
| PutFlIt Item
| PutPressPlate PressPlate
| PutBlock BlockMaterial [Int] Wall [Point2]
| PutCoordinate Point2
| PutPPlate PressPlate
| PutBlock BlockMaterial Int [Int] Wall [Point2]
| PutCoord Point2
| PutMod Modification
| PutTrigger (World -> Bool)
| PutLineBlock Wall BlockMaterial Float Float Point2 Point2
| PutWall { _pwPoly :: [Point2] , _pwWall :: Wall }
| PutSlideDoor Bool Color (World -> Bool) Point2 Point2 Float
| PutSlideDr Bool Color (World -> Bool) Point2 Point2 Float
| PutDoor Color (World -> Bool) [(Point2,Point2)]
| RandPS (State StdGen PSType)
| PutForeground Shape
| PutShape Shape
| PutWorldUpdate (PlacementSpot -> World -> World)
| AddToPList Int PSType
| PutNothing
| PutID { _putID :: Int}
-- maybe there is a monadic implementation of this?
@@ -49,15 +48,16 @@ data PlacementSpot
{ _psRoomRandPointNum :: Int
, _psRandShift :: (Point2,Float) -> PlacementSpot
}
data Placement = Placement
{ _plSpot :: PlacementSpot
, _plType :: PSType
, _plMID :: Maybe Int
, _plIDCont :: Placement -> Maybe Placement
}
| PlacementUsingPos Point3 (Point3 -> Placement) -- allows a placement to use a shifted position
| RandomPlacement {_unRandomPlacement :: State StdGen Placement}
data Placement
= Placement
{ _plSpot :: PlacementSpot
, _plType :: PSType
, _plMID :: Maybe Int
, _plIDCont :: Placement -> Maybe Placement
}
| PlacementUsingPos Point3 (Point3 -> Placement) -- allows a placement to use a shifted position
| RandomPlacement {_unRandomPlacement :: State StdGen Placement}
| PickOnePlacement Int Placement
{- The '_rmPolys' lists 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;
@@ -89,6 +89,9 @@ data Room = Room
, _rmStartWires :: IM.IntMap RoomWire
, _rmEndWires :: IM.IntMap RoomWire
, _rmConnectsTo :: S.Set RoomLinkType
, _rmMID :: Maybe Int
, _rmMParent :: Maybe Int
, _rmChildren :: [Int]
}
data RoomLink = RoomLink
{ _rlType :: S.Set RoomLinkType
@@ -212,6 +215,7 @@ addPlmnt pl pl2 = case pl2 of
(PlacementUsingPos p f) -> PlacementUsingPos p (fmap (addPlmnt pl) f)
(RandomPlacement rp) -> RandomPlacement $ fmap (addPlmnt pl) rp
(Placement ps pt mi f) -> Placement ps pt mi (fmap g f)
PickOnePlacement {} -> error "not written how to combine PickOnePlacement with others yet"
where
g Nothing = Just pl
g (Just pl') = Just $ addPlmnt pl pl'
+8 -2
View File
@@ -12,7 +12,13 @@ import Control.Lens
data GenWorld = GenWorld
{ _gWorld :: World
, _gPlacements :: IM.IntMap [Placement]
, _gPlacements :: IM.IntMap [(Placement,Int)]
, _gRooms :: IM.IntMap Room
}
worldToGenWorld :: IM.IntMap Room -> World -> GenWorld
worldToGenWorld rms w = GenWorld
{ _gWorld = w
, _gPlacements = IM.empty
, _gRooms = rms
}
worldToGenWorld w = GenWorld w IM.empty
makeLenses ''GenWorld