Remove _plGenUpdate field, instead allow Placements to take World arg
This commit is contained in:
@@ -149,8 +149,8 @@ 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 Nothing
|
||||
$ const $ Just $ sps0 $ PutShape $ thinHighBar h a b
|
||||
spanLS ls a b = Placement (PS (V2 x y) 0) (PutLS ls) Nothing
|
||||
$ const $ const $ Just $ sps0 $ PutShape $ thinHighBar h a b
|
||||
where
|
||||
V3 _ _ h = _lsPos (_lsParam ls) + 5
|
||||
V2 x y = 0.5 *.* (a +.+ b)
|
||||
|
||||
@@ -35,7 +35,9 @@ putTerminal' col mcf = ps0PushPS (PutButton termButton)
|
||||
$ const Nothing
|
||||
|
||||
putTerminal :: (GenParams -> World -> TerminalParams) -> Placement
|
||||
putTerminal f = plGenUpdate ?~ g $ ps0PushPS (PutButton termButton)
|
||||
putTerminal f = ps0PushPSw PutNothing $ \w _ -> Just $
|
||||
--plGenUpdate ?~ g $ ps0PushPS (PutButton $ termButton & btTerminalParams .~ f (_genParams w))
|
||||
ps0PushPS (PutButton $ termButton & btTerminalParams .~ f (_genParams w))
|
||||
$ \pl -> Just $ pt0 (PutMachine terminalColor (reverse $ square 10) defaultMachine
|
||||
{ _mcDraw = noPic . terminalShape terminalColor
|
||||
, _mcHP = 100
|
||||
@@ -44,11 +46,6 @@ putTerminal f = plGenUpdate ?~ g $ ps0PushPS (PutButton termButton)
|
||||
. makeExplosionAt (_mcPos mc)
|
||||
})
|
||||
$ const Nothing
|
||||
where
|
||||
g gp pl = (gp,
|
||||
pl & plType . putButton . btTerminalParams .~ f gp
|
||||
& plGenUpdate .~ Nothing
|
||||
)
|
||||
termButton :: Button
|
||||
termButton = Button
|
||||
{ _btPict = const mempty
|
||||
|
||||
@@ -33,8 +33,6 @@ import Data.Bifunctor
|
||||
-- to the placement
|
||||
placeSpot :: (World,Room) -> Placement -> ( (World,Room), [Placement] )
|
||||
placeSpot (w,rm) plmnt = case plmnt of
|
||||
pl@Placement{_plGenUpdate = Just f} -> let (gp,pl') = f (_genParams w) pl
|
||||
in placeSpot (w & genParams .~ 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
|
||||
@@ -56,7 +54,7 @@ placePlainPSSpot :: World -> Room -> Placement -> DPoint2 -> ((World,Room),[Plac
|
||||
placePlainPSSpot w rm plmnt shift =
|
||||
let (i,w') = placeSpotID (shiftPSBy shift (_plSpot plmnt)) (_plType plmnt) w
|
||||
newplmnt = plmnt & plMID ?~ i
|
||||
in maybe ((w',rm),[newplmnt]) (recrPlace newplmnt w') (_plIDCont plmnt newplmnt)
|
||||
in maybe ((w',rm),[newplmnt]) (recrPlace newplmnt w') (_plIDCont plmnt w' newplmnt)
|
||||
where
|
||||
recrPlace newplmnt w' pl = let (wr,newplmnts) = placeSpot (w',rm) pl
|
||||
in (wr,newplmnt:newplmnts)
|
||||
@@ -129,7 +127,7 @@ evaluateRandPS rgen ps w = placeSpotID ps evaluatedType (set randGen g w)
|
||||
(evaluatedType, g) = runState rgen (_randGen w)
|
||||
|
||||
placeWallPoly :: [Point2] -> Wall -> World -> World
|
||||
placeWallPoly ps wl = (rmCrossPaths . over walls (addWalls ps wl))
|
||||
placeWallPoly ps wl = rmCrossPaths . over walls (addWalls ps wl)
|
||||
where
|
||||
rmCrossPaths w = foldr (uncurry removePathsCrossing) w $ loopPairs ps
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ plDoor :: Color
|
||||
-- Bumped out up and down by 9, not widened
|
||||
-> World
|
||||
-> (Int,World)
|
||||
plDoor col cond pss gw = (drid, (addWalls gw & doors %~ addDoor))
|
||||
plDoor col cond pss gw = (drid, addWalls gw & doors %~ addDoor)
|
||||
where
|
||||
drid = IM.newKey $ _doors gw
|
||||
addDoor = IM.insert drid $ Door
|
||||
@@ -108,7 +108,7 @@ plSlideDoor
|
||||
-> World
|
||||
-> (Int, World)
|
||||
plSlideDoor isPathable col cond shiftOffset a b speed gw
|
||||
= (drid, (addWalls gw & doors %~ addDoor))
|
||||
= (drid, addWalls gw & doors %~ addDoor)
|
||||
where
|
||||
drid = IM.newKey $ _doors gw
|
||||
addDoor = IM.insert drid $ Door
|
||||
|
||||
@@ -20,7 +20,7 @@ shiftPlacement shift plmnt = case plmnt of
|
||||
-- slightly messy NoShiftCont, necessary to stop interference with ps0jPushPS
|
||||
Placement {_plSpot = PSNoShiftCont {}} -> plmnt & plSpot %~ shiftPSBy shift
|
||||
Placement {} -> plmnt & plSpot %~ shiftPSBy shift
|
||||
& plIDCont %~ fmap (fmap $ shiftPlacement shift)
|
||||
& plIDCont %~ fmap (fmap (fmap $ shiftPlacement shift))
|
||||
PlacementUsingPos p f -> PlacementUsingPos (shiftPoint3By shift p)
|
||||
(fmap (shiftPlacement shift) f)
|
||||
RandomPlacement rpl -> RandomPlacement $ fmap (shiftPlacement shift) rpl
|
||||
|
||||
Reference in New Issue
Block a user