Move towards simplifying impulses
This commit is contained in:
+1
-1
@@ -102,7 +102,7 @@ updateRenderSplit :: Universe -> IO Universe
|
|||||||
updateRenderSplit u = do
|
updateRenderSplit u = do
|
||||||
let preData = _preloadData u
|
let preData = _preloadData u
|
||||||
updateUniverse u `par` void (doDrawing (_renderData preData) u)
|
updateUniverse u `par` void (doDrawing (_renderData preData) u)
|
||||||
return (updateUniverse u)
|
return $! updateUniverse u
|
||||||
|
|
||||||
playSoundUnlessRewinding :: Universe -> IO (M.Map SoundOrigin Sound)
|
playSoundUnlessRewinding :: Universe -> IO (M.Map SoundOrigin Sound)
|
||||||
playSoundUnlessRewinding u
|
playSoundUnlessRewinding u
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
module Dodge.Creature.Impulse (
|
module Dodge.Creature.Impulse (
|
||||||
impulsiveAIBefore,
|
impulsiveAIBefore,
|
||||||
followThenClearImpulses,
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
@@ -20,17 +19,6 @@ import qualified IntMapHelp as IM
|
|||||||
import LensHelp
|
import LensHelp
|
||||||
import System.Random
|
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 ::
|
impulsiveAIBefore ::
|
||||||
(World -> Creature -> Creature) ->
|
(World -> Creature -> Creature) ->
|
||||||
Creature ->
|
Creature ->
|
||||||
@@ -38,17 +26,7 @@ impulsiveAIBefore ::
|
|||||||
World
|
World
|
||||||
impulsiveAIBefore f cr w = g w & cWorld . creatures . ix (_crID cr) .~ cr'
|
impulsiveAIBefore f cr w = g w & cWorld . creatures . ix (_crID cr) .~ cr'
|
||||||
where
|
where
|
||||||
(g, cr') = impulsiveAI f cr w
|
(g, cr') = followImpulses w $ f w cr
|
||||||
|
|
||||||
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 .~ [])
|
|
||||||
|
|
||||||
followImpulses :: World -> Creature -> (World -> World, Creature)
|
followImpulses :: World -> Creature -> (World -> World, Creature)
|
||||||
followImpulses w cr = foldr f (id, cr) (_apImpulse $ _crActionPlan cr)
|
followImpulses w cr = foldr f (id, cr) (_apImpulse $ _crActionPlan cr)
|
||||||
|
|||||||
Reference in New Issue
Block a user