Move GenWorld update of placements into product type
This commit is contained in:
@@ -149,7 +149,7 @@ spanLSLightI ls h a b = ps0j (PutLS $ ls & lsParam . lsPos .~ V3 x y h)
|
||||
V2 x y = 0.5 *.* (a +.+ b)
|
||||
|
||||
spanLS :: LightSource -> Point2 -> Point2 -> Placement
|
||||
spanLS ls a b = Placement (PS (V2 x y) 0) (PutLS ls) Nothing
|
||||
spanLS ls a b = Placement (PS (V2 x y) 0) (PutLS ls) Nothing Nothing
|
||||
$ const $ Just $ sps0 $ PutShape $ thinHighBar h a b
|
||||
where
|
||||
V3 _ _ h = _lsPos (_lsParam ls) + 5
|
||||
|
||||
@@ -17,7 +17,7 @@ import Shape
|
||||
import Data.Maybe
|
||||
|
||||
putTerminal :: (GenParams -> TerminalParams) -> Placement
|
||||
putTerminal f = PlacementGenUpdate g $ ps0PushPS (PutButton thebutton)
|
||||
putTerminal f = plGenUpdate ?~ g $ ps0PushPS (PutButton thebutton)
|
||||
$ \pl -> Just $ pt0 (PutMachine terminalColor (reverse $ square 10) defaultMachine
|
||||
{ _mcDraw = drawTerminal
|
||||
, _mcHP = 100
|
||||
@@ -27,7 +27,9 @@ putTerminal f = PlacementGenUpdate g $ ps0PushPS (PutButton thebutton)
|
||||
})
|
||||
$ const Nothing
|
||||
where
|
||||
g gp pl = (gp, pl & plType . pstPutButton . btTerminalParams .~ f gp)
|
||||
g gp pl = (gp, pl & plType . pstPutButton . btTerminalParams .~ f gp
|
||||
& plGenUpdate .~ Nothing
|
||||
)
|
||||
thebutton = Button
|
||||
{ _btPict = const mempty
|
||||
, _btPos = 0
|
||||
|
||||
@@ -33,14 +33,14 @@ import Data.Bifunctor
|
||||
-- to the placement
|
||||
placeSpot :: (GenWorld,Room) -> Placement -> ( (GenWorld,Room), [Placement] )
|
||||
placeSpot (w,rm) plmnt = case plmnt of
|
||||
pl@Placement{_plGenUpdate = Just f} -> let (gp,pl') = f (_gParams w) pl
|
||||
in placeSpot (w & gParams .~ gp,rm) pl'
|
||||
Placement{_plSpot = PSRoomRand i f} -> placeSpotRoomRand rm i f plmnt w
|
||||
Placement{_plSpot = PSPos extract eff fallback} -> placeSpotUsingLink w rm plmnt extract eff fallback
|
||||
Placement{} -> placePlainPSSpot w rm plmnt shift
|
||||
PlacementUsingPos p subpl -> placeSpot (w,rm) (subpl (shiftPoint3By shift p))
|
||||
RandomPlacement rplmnt -> placeRandomPlacement rplmnt w rm
|
||||
PickOnePlacement i pl -> ((placePickOne i pl rm w, rm), [])
|
||||
PlacementGenUpdate f pl -> let (gp,pl') = f (_gParams w) pl
|
||||
in placeSpot (w & gParams .~ gp,rm) pl'
|
||||
where
|
||||
shift = _rmShift rm
|
||||
|
||||
|
||||
@@ -20,4 +20,3 @@ shiftPlacement shift plmnt = case plmnt of
|
||||
(fmap (shiftPlacement shift) f)
|
||||
RandomPlacement rpl -> RandomPlacement $ fmap (shiftPlacement shift) rpl
|
||||
PickOnePlacement i pl -> PickOnePlacement i (shiftPlacement shift pl)
|
||||
PlacementGenUpdate f pl -> PlacementGenUpdate f (shiftPlacement shift pl)
|
||||
|
||||
Reference in New Issue
Block a user