2018-02-07 00:18:16 +00:00
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
|
|
|
|
module StateMachine where
|
|
|
|
|
|
|
|
import Affection
|
|
|
|
|
|
|
|
import Types
|
|
|
|
|
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
|
|
|
|
|
|
|
smUpdate Menu = const $ return ()
|
|
|
|
|
2018-02-17 01:36:06 +00:00
|
|
|
smDraw Menu = drawMap
|
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 = []
|
|
|
|
}
|