Move towards simplifying impulses

This commit is contained in:
2022-08-23 08:33:14 +01:00
parent faf75f4fe7
commit 12ce2365c2
2 changed files with 2 additions and 24 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ updateRenderSplit :: Universe -> IO Universe
updateRenderSplit u = do
let preData = _preloadData u
updateUniverse u `par` void (doDrawing (_renderData preData) u)
return (updateUniverse u)
return $! updateUniverse u
playSoundUnlessRewinding :: Universe -> IO (M.Map SoundOrigin Sound)
playSoundUnlessRewinding u
+1 -23
View File
@@ -2,7 +2,6 @@
module Dodge.Creature.Impulse (
impulsiveAIBefore,
followThenClearImpulses,
) where
import Control.Monad.State
@@ -20,17 +19,6 @@ import qualified IntMapHelp as IM
import LensHelp
import System.Random
impulsiveAIBeforeAfter ::
(World -> Creature -> Creature) ->
(World -> Creature -> Creature) ->
Creature ->
World ->
World
impulsiveAIBeforeAfter startup endup cr w = w' & cWorld . creatures . ix (_crID cr) .~ endup w' cr'
where
w' = g w
(g, cr') = impulsiveAI startup cr w
impulsiveAIBefore ::
(World -> Creature -> Creature) ->
Creature ->
@@ -38,17 +26,7 @@ impulsiveAIBefore ::
World
impulsiveAIBefore f cr w = g w & cWorld . creatures . ix (_crID cr) .~ cr'
where
(g, cr') = impulsiveAI f cr w
impulsiveAI ::
(World -> Creature -> Creature) ->
Creature ->
World ->
(World -> World, Creature)
impulsiveAI f cr w = followImpulses w $ f w cr
followThenClearImpulses :: Creature -> World -> World
followThenClearImpulses = impulsiveAIBeforeAfter (const id) (const $ crActionPlan . apImpulse .~ [])
(g, cr') = followImpulses w $ f w cr
followImpulses :: World -> Creature -> (World -> World, Creature)
followImpulses w cr = foldr f (id, cr) (_apImpulse $ _crActionPlan cr)