smoother game start

This commit is contained in:
nek0 2018-09-15 19:22:04 +02:00
parent 49aba30955
commit 687d5f5b58

View file

@ -200,12 +200,6 @@ loadMapFork ud ad future progress = do
( p + increment
, "Registering NPCs into WorldState"
)))
-- posbounds <- efor allEnts $ do
-- with pos
-- with obstacle
-- pos' <- query pos
-- bnds <- query obstacle
-- return (pos', bnds)
mapM_ (\crp -> do
fact <- liftIO $ randomRIO (0.5, 1.5)
-- fut <- liftIO newEmptyMVar
@ -234,16 +228,15 @@ loadMapFork ud ad future progress = do
)))
return mmimgmat
)) ad
-- nstate <- evalStateT
-- (runState $ yieldSystemT nws (updateNPCs mmimgmat nws rps 0)) ad
putMVar future (nws, MainData
{ mapMat = mat
, imgMat = M.fromList (nrows inter) (ncols inter) $
let retMat = M.fromList (nrows inter) (ncols inter) $
Prelude.map
(\a -> if a == Just ImgEmpty || a == Just ImgEmptyNoWalk
then Nothing
else a)
(M.toList inter)
putMVar future (nws, MainData
{ mapMat = mat
, imgMat = retMat
, reachPoints = rps
, mmImgMat = mmimgmat
})
@ -527,15 +520,18 @@ drawTile ud ctx posanims pr pc row col img =
updateMap :: Double -> Affection UserData ()
updateMap dt = do
ud <- getAffection
isFut <- liftIO $ isEmptyMVar (stateMVar ud)
if not isFut && stateData ud == None
if stateData ud == None
then do
liftIO $ logIO A.Debug "Loaded game data"
Just (nws, mendat) <- liftIO $ tryTakeMVar (stateMVar ud)
(nws, mendat) <- liftIO $ takeMVar (stateMVar ud)
putAffection ud
{ worldState = nws
, stateData = mendat
}
updateMap 0.1
updateMap 0.1
updateMap 0.1
updateMap 19
else do
(nws, _) <- yieldSystemT (worldState ud) $ do
emap allEnts $ do