Separate out concrete part of world
This commit is contained in:
@@ -38,11 +38,11 @@ import qualified SDL
|
||||
autoEffect :: (Item -> Creature -> World -> World) -> Int -> SoundID -> Item -> Creature -> World -> World
|
||||
autoEffect eff t sid itm cr w
|
||||
| _eparamInt (_eqParams (_eqEq $ _itUse itm)) < 1 = eff itm cr w
|
||||
& creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itPos itm)
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itPos itm)
|
||||
. itUse . eqEq . eqParams . eparamInt .~ t
|
||||
& soundStart OnceSound (_crPos cr) sid Nothing
|
||||
| otherwise = w
|
||||
& creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itPos itm)
|
||||
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itPos itm)
|
||||
. itUse . eqEq . eqParams . eparamInt -~ 1
|
||||
|
||||
{- | Automatically send out radar pulses that detect walls. -}
|
||||
@@ -83,7 +83,7 @@ targetRBCreatureUp it cr w t
|
||||
& tgPos .~ Nothing
|
||||
& tgActive .~ False
|
||||
)
|
||||
| SDL.ButtonRight `M.member` _mouseButtons w && isJust (t ^? tgID . _Just)
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_cWorld w) && isJust (t ^? tgID . _Just)
|
||||
&& canSeeTarget = (w, t & updatePos
|
||||
& tgActive .~ True
|
||||
)
|
||||
@@ -99,10 +99,10 @@ targetRBCreatureUp it cr w t
|
||||
mwp = mouseWorldPos w
|
||||
updatePos t' = t' & tgPos .~ posFromMaybeID (_tgID t')
|
||||
posFromMaybeID Nothing = Nothing
|
||||
posFromMaybeID (Just i) = w ^? creatures . ix i . crPos
|
||||
posFromMaybeID (Just i) = w ^? cWorld . creatures . ix i . crPos
|
||||
canSeeTarget = fromMaybe False $ do
|
||||
cid <- t ^? tgID . _Just
|
||||
cpos <- w ^? creatures . ix cid . crPos
|
||||
cpos <- w ^? cWorld . creatures . ix cid . crPos
|
||||
Just $ hasLOS cpos (_crPos cr) w
|
||||
|
||||
targetUpdateWith :: (World -> Targeting -> Targeting)
|
||||
@@ -113,7 +113,7 @@ targetUpdateWith f it _ w t
|
||||
|
||||
targetCursorUpdate :: World -> Targeting -> Targeting
|
||||
targetCursorUpdate w t
|
||||
| SDL.ButtonRight `M.member` _mouseButtons w = t
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_cWorld w) = t
|
||||
& tgPos . _Just .~ mouseWorldPos w
|
||||
& tgActive .~ True
|
||||
| otherwise = t & tgPos %~ const Nothing
|
||||
@@ -121,7 +121,7 @@ targetCursorUpdate w t
|
||||
|
||||
targetRBPressUpdate :: World -> Targeting -> Targeting
|
||||
targetRBPressUpdate w t
|
||||
| SDL.ButtonRight `M.member` _mouseButtons w = t
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_cWorld w) = t
|
||||
& tgPos %~ maybe (Just $ mouseWorldPos w) Just
|
||||
& tgActive .~ True
|
||||
| otherwise = t & tgPos %~ const Nothing
|
||||
@@ -140,7 +140,7 @@ targetLaserUpdate _ cr w t
|
||||
(mp, _) = reflectLaserAlong 0.2 sp ep w
|
||||
sp = _crPos cr +.+ 15 *.* unitVectorAtAngle (_crDir cr)
|
||||
ep = sp +.+ 5000 *.* normalizeV (mouseWorldPos w -.- sp)
|
||||
addLaserPic = lasers .:~ LaserStart
|
||||
addLaserPic = cWorld . lasers .:~ LaserStart
|
||||
{ _lpPhaseV = 1
|
||||
, _lpDir = _crDir cr
|
||||
, _lpPos = sp
|
||||
|
||||
Reference in New Issue
Block a user