2018-02-07 00:18:16 +00:00
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
|
|
|
|
module StateMachine where
|
|
|
|
|
|
|
|
import Affection
|
|
|
|
|
|
|
|
import Types
|
|
|
|
|
2018-06-08 23:17:03 +00:00
|
|
|
import Load
|
2018-02-17 01:36:06 +00:00
|
|
|
import Test
|
|
|
|
|
2018-02-07 00:18:16 +00:00
|
|
|
instance StateMachine State UserData where
|
2018-02-17 01:36:06 +00:00
|
|
|
smLoad Menu = loadMap
|
2018-02-07 00:18:16 +00:00
|
|
|
|
2018-06-08 23:17:03 +00:00
|
|
|
smLoad Load = loadLoad
|
|
|
|
|
2018-02-24 14:33:46 +00:00
|
|
|
smUpdate Menu = updateMap
|
2018-02-07 00:18:16 +00:00
|
|
|
|
2018-06-08 23:17:03 +00:00
|
|
|
smUpdate Load = updateLoad
|
|
|
|
|
2018-02-17 01:36:06 +00:00
|
|
|
smDraw Menu = drawMap
|
2018-02-07 00:18:16 +00:00
|
|
|
|
2018-06-08 23:17:03 +00:00
|
|
|
smDraw Load = drawLoad
|
|
|
|
|
2018-02-07 00:18:16 +00:00
|
|
|
smEvent _ evs = do
|
|
|
|
Subsystems w m <- subsystems <$> getAffection
|
|
|
|
_ <- consumeSDLEvents w =<< consumeSDLEvents m evs
|
|
|
|
return ()
|
|
|
|
|
|
|
|
smClean _ = do
|
|
|
|
ud <- getAffection
|
|
|
|
let Subsystems w m = subsystems ud
|
|
|
|
toClean = uuid ud
|
|
|
|
mapM_ (\u -> do
|
|
|
|
partUnSubscribe w u
|
|
|
|
partUnSubscribe m u
|
|
|
|
) toClean
|
|
|
|
putAffection ud
|
|
|
|
{ uuid = []
|
|
|
|
}
|