Use placement as continutation
This commit is contained in:
@@ -9,6 +9,7 @@ import Shape.Data
|
||||
import Control.Lens
|
||||
import Control.Monad.State
|
||||
import System.Random
|
||||
import Data.Maybe
|
||||
data PSType = PutCrit {_unPutCrit :: Creature}
|
||||
| PutMachine Color [Point2] Machine
|
||||
| PutLS LightSource
|
||||
@@ -39,8 +40,8 @@ data PlacementSpot
|
||||
data Placement = Placement
|
||||
{ _plSpot :: PlacementSpot
|
||||
, _plType :: PSType
|
||||
, _plID :: Maybe Int
|
||||
, _plIDCont :: Int -> Maybe Placement
|
||||
, _plMID :: Maybe Int
|
||||
, _plIDCont :: Placement -> Maybe Placement
|
||||
}
|
||||
| PlacementUsingPos Point3 (Point3 -> Placement) -- allows a placement to use a shifted position
|
||||
| RandomPlacement {_unRandomPlacement :: State StdGen Placement}
|
||||
@@ -48,6 +49,9 @@ data Placement = Placement
|
||||
spNoID :: PlacementSpot -> PSType -> Placement
|
||||
spNoID ps pst = Placement ps pst Nothing (const Nothing)
|
||||
|
||||
pContID :: PlacementSpot -> PSType -> (Int -> Maybe Placement) -> Placement
|
||||
pContID ps pt = Placement ps pt Nothing . intPlPlPl
|
||||
|
||||
sPS :: Point2 -> Float -> PSType -> Placement
|
||||
sPS p a pt = Placement (PS p a) pt Nothing (const Nothing)
|
||||
|
||||
@@ -67,10 +71,13 @@ jsps0J :: PSType -> Placement -> Maybe Placement
|
||||
jsps0J pst plm = Just $ Placement (PS (V2 0 0) 0) pst Nothing $ \_ -> Just plm
|
||||
|
||||
ps0 :: PSType -> (Int -> Maybe Placement) -> Placement
|
||||
ps0 pst = Placement (PS (V2 0 0) 0) pst Nothing
|
||||
ps0 pst = Placement (PS (V2 0 0) 0) pst Nothing . intPlPlPl
|
||||
|
||||
intPlPlPl :: (Int -> Maybe Placement) -> Placement -> (Maybe Placement)
|
||||
intPlPlPl f = f . fromJust . _plMID
|
||||
|
||||
jps0 :: PSType -> (Int -> Maybe Placement) -> Maybe Placement
|
||||
jps0 pst = Just . Placement (PS (V2 0 0) 0) pst Nothing
|
||||
jps0 pst = Just . Placement (PS (V2 0 0) 0) pst Nothing . intPlPlPl
|
||||
|
||||
ps0j :: PSType -> Placement -> Placement
|
||||
ps0j pst plmnt = Placement (PS (V2 0 0) 0) pst Nothing (const $ Just plmnt)
|
||||
|
||||
Reference in New Issue
Block a user