{-# LANGUAGE MultiParamTypeClasses #-} module StateMachine where import Affection import Types import Load import Menu.Connect import MainGame.WorldMap import MainGame.MindMap instance StateMachine State UserData where smLoad Load = loadLoad smLoad (Menu Connect) = loadMenu smLoad (Main _) = loadMap smUpdate Load = updateLoad smUpdate (Menu Connect) = updateMenu smUpdate (Main WorldMap) = updateMap smUpdate (Main MindMap) = updateMind smDraw Load = drawLoad smDraw (Menu Connect) = drawMenu smDraw (Main WorldMap) = drawMap smDraw (Main MindMap) = drawMind smEvent _ evs = do Subsystems w m k j _ <- subsystems <$> getAffection _ <- consumeSDLEvents j =<< consumeSDLEvents k =<< consumeSDLEvents w =<< consumeSDLEvents m evs return () smClean _ = do ud <- getAffection let Subsystems w m k j t = subsystems ud toClean = uuid ud mapM_ (\u -> do partUnSubscribe w u partUnSubscribe m u partUnSubscribe k u partUnSubscribe j u partUnSubscribe t u ) toClean putAffection ud { uuid = [] }