Cleanup
This commit is contained in:
+8
-31
@@ -1,10 +1,4 @@
|
||||
--{-# LANGUAGE BangPatterns #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
{- |
|
||||
Module : Dodge.Update
|
||||
Description : Simulation update
|
||||
-}
|
||||
module Dodge.Update (updateUniverse) where
|
||||
|
||||
import Color
|
||||
@@ -37,7 +31,6 @@ import Dodge.Laser.Update
|
||||
import Dodge.LinearShockwave.Update
|
||||
import Dodge.ListDisplayParams
|
||||
import Dodge.Machine.Update
|
||||
--import Dodge.Menu
|
||||
import Dodge.ModificationEffect
|
||||
import Dodge.PressPlate
|
||||
import Dodge.Projectile.Update
|
||||
@@ -161,18 +154,14 @@ updateUniverseLast u =
|
||||
updateUniverseMid :: Universe -> Universe
|
||||
updateUniverseMid u = case _uvScreenLayers u of
|
||||
(OptionScreen{_scOptionFlag = LoadingScreen} : _) -> u
|
||||
-- (sl@OptionScreen{_scOptionFlag = GameOverOptions} : _) -> u & updateUseInputOnScreen sl
|
||||
(sl : _) -> u & uvWorld . unpauseClock .~ 0 & updateUseInputOnScreen sl
|
||||
[] ->
|
||||
(uvWorld . unpauseClock +~ 1)
|
||||
. timeFlowUpdate
|
||||
. updateUseInputInGame
|
||||
. over
|
||||
uvWorld
|
||||
(updateMouseInGame (u ^. uvConfig))
|
||||
$ over
|
||||
uvWorld
|
||||
(updateCamera (u ^. uvConfig))
|
||||
(updateMouseInGame (u ^. uvConfig) . (updateCamera (u ^. uvConfig)))
|
||||
u
|
||||
|
||||
timeFlowUpdate :: Universe -> Universe
|
||||
@@ -184,12 +173,11 @@ timeFlowUpdate u = case u ^. uvWorld . timeFlow of
|
||||
over uvWorld (doTimeScroll smoothing) u
|
||||
CameraScrollTimeFlow{} -> u
|
||||
RewindLeftClick 0 _ -> u & uvWorld . timeFlow .~ NormalTimeFlow
|
||||
RewindLeftClick _ _ -> over uvWorld scrollTimeBack u -- & uvWorld . cWorld . timeFlow .~ NormalTimeFlow
|
||||
RewindLeftClick _ _ -> over uvWorld scrollTimeBack u
|
||||
RespawnDelay{} -> functionalUpdate u
|
||||
PausedTimeFlow _ itmloc -> over uvWorld (pauseTime itmloc) u
|
||||
|
||||
pauseTime :: NewInt ItmInt -> World -> World
|
||||
--pauseTime itmloc w
|
||||
pauseTime _ w
|
||||
-- | justPressedButtonLeft || outofcharge = w & timeFlow .~ NormalTimeFlow
|
||||
| justPressedButtonLeft = w & timeFlow .~ NormalTimeFlow
|
||||
@@ -228,16 +216,10 @@ scrollTimeBack w = case w ^? pastWorlds . _head of
|
||||
& mupdateitem x
|
||||
_ -> w
|
||||
where
|
||||
--mupdateitem x = fromMaybe id $ do
|
||||
mupdateitem _ = fromMaybe id $ do
|
||||
--i <- w ^? timeFlow . scrollItemID . unNInt
|
||||
_ <- w ^? timeFlow . scrollItemID . unNInt
|
||||
-- let pointituse = pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse
|
||||
return id
|
||||
|
||||
-- (pointituse . leftConsumption . wpCharge .~ (x -1))
|
||||
-- . (pointituse . leftHammer .~ HammerDown)
|
||||
|
||||
scrollTimeForward :: World -> World
|
||||
scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of
|
||||
Nothing -> w
|
||||
@@ -250,9 +232,8 @@ scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of
|
||||
where
|
||||
ramount = (w ^?! timeFlow . reverseAmount) + 1
|
||||
mupdateitem = fromMaybe id $ do
|
||||
--i <- w ^? timeFlow . scrollItemID . unNInt
|
||||
_ <- w ^? timeFlow . scrollItemID . unNInt
|
||||
return id -- pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ ramount
|
||||
return id
|
||||
|
||||
-- | The update step.
|
||||
functionalUpdate :: Universe -> Universe
|
||||
@@ -477,7 +458,8 @@ pbFlicker pt =
|
||||
d = 4 * fromIntegral (10 + abs ((_pbTimer pt `mod` 20) - 10))
|
||||
|
||||
zoneClouds :: World -> World
|
||||
zoneClouds w = w & clZoning .~ foldl' (flip zoneCloud) mempty (w ^. cWorld . lWorld . clouds)
|
||||
zoneClouds w = w
|
||||
& clZoning .~ foldl' (flip zoneCloud) mempty (w ^. cWorld . lWorld . clouds)
|
||||
|
||||
zoneDusts :: World -> World
|
||||
zoneDusts w = w & dsZoning .~ foldl' (flip zoneDust) mempty (w ^. cWorld . lWorld . dusts)
|
||||
@@ -533,13 +515,9 @@ updateCreatureSoundPositions w =
|
||||
updateIMl :: (World -> IM.IntMap a) -> (a -> a -> World -> World) -> World -> World
|
||||
updateIMl fim fup w = alaf Endo foldMap (dbArg fup) (fim w) w
|
||||
|
||||
--updateIMl fim fup w = foldl' (flip $ dbArg fup) w (fim w)
|
||||
|
||||
updateIMl' :: (World -> IM.IntMap a) -> (a -> World -> World) -> World -> World
|
||||
updateIMl' fim fup w = alaf Endo foldMap fup (fim w) w
|
||||
|
||||
--updateIMl' fim fup w = foldl' (flip fup) w (fim w)
|
||||
|
||||
updateCreatureGroups :: World -> World
|
||||
updateCreatureGroups w =
|
||||
w & cWorld . lWorld . creatureGroups
|
||||
@@ -867,13 +845,12 @@ dustSpringVel a v b
|
||||
radDist = 10
|
||||
|
||||
simpleCrSprings :: World -> World
|
||||
simpleCrSprings w = IM.foldl' (flip crSpring) w $ IM.filter (\cr -> _crZ cr >= 0) $ w ^. cWorld . lWorld . creatures
|
||||
simpleCrSprings w = IM.foldl' (flip crSpring) w
|
||||
$ IM.filter (\cr -> _crZ cr >= 0) $ w ^. cWorld . lWorld . creatures
|
||||
|
||||
-- note that this may in rare cases not push creatures away from each other
|
||||
crSpring :: Creature -> World -> World
|
||||
crSpring c w = foldl' (flip $ crCrSpring c) w cs
|
||||
where
|
||||
cs = crsNearPoint (_crPos c) w
|
||||
crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearPoint (_crPos c) w
|
||||
|
||||
crCrSpring :: Creature -> Creature -> World -> World
|
||||
crCrSpring c1 c2
|
||||
|
||||
Reference in New Issue
Block a user