more optimization
This commit is contained in:
parent
a68b186fd0
commit
aed0732d3e
2 changed files with 25 additions and 17 deletions
|
@ -520,18 +520,22 @@ drawTile ud ctx posanims pr pc row col img =
|
|||
updateMap :: Double -> Affection UserData ()
|
||||
updateMap dt = do
|
||||
ud <- getAffection
|
||||
if stateData ud == None
|
||||
-- empty <- liftIO $ isEmptyMVar (stateMVar ud)
|
||||
if stateData ud == None -- && empty
|
||||
then do
|
||||
liftIO $ logIO A.Debug "Loaded game data"
|
||||
(nws, mendat) <- liftIO $ takeMVar (stateMVar ud)
|
||||
putAffection ud
|
||||
{ worldState = nws
|
||||
, stateData = mendat
|
||||
}
|
||||
updateMap 0.1
|
||||
updateMap 0.1
|
||||
updateMap 0.1
|
||||
updateMap 19
|
||||
mstart <- liftIO $ tryTakeMVar (stateMVar ud)
|
||||
case mstart of
|
||||
Just (nws, mendat) -> do
|
||||
putAffection ud
|
||||
{ worldState = nws
|
||||
, stateData = mendat
|
||||
}
|
||||
updateMap 0.1
|
||||
updateMap 0.1
|
||||
updateMap 0.1
|
||||
updateMap 19
|
||||
liftIO $ logIO A.Debug "Loaded game data"
|
||||
Nothing -> return ()
|
||||
else do
|
||||
(nws, _) <- yieldSystemT (worldState ud) $ do
|
||||
emap allEnts $ do
|
||||
|
|
16
src/Util.hs
16
src/Util.hs
|
@ -11,6 +11,8 @@ import Data.Graph.AStar
|
|||
import Data.Maybe
|
||||
import qualified Data.Text as T
|
||||
|
||||
import Control.Monad (join)
|
||||
|
||||
import qualified SDL
|
||||
import qualified Graphics.Rendering.OpenGL as GL hiding (get)
|
||||
|
||||
|
@ -164,7 +166,8 @@ naviGraph imgmat animBounds (V2 r c) =
|
|||
(\acc (rr, cc) ->
|
||||
if null
|
||||
(maybe [] collisionObstacle
|
||||
(M.safeGet (r + rr) (c + cc) imgmat) ++
|
||||
(join $ M.safeGet (r + rr) (c + cc) imgmat)
|
||||
++
|
||||
map snd (filter
|
||||
(\(V2 br bc, _) -> floor br == r + rr && floor bc == c + cc)
|
||||
animBounds))
|
||||
|
@ -177,14 +180,15 @@ naviGraph imgmat animBounds (V2 r c) =
|
|||
foldl
|
||||
(\acc (rr, cc) ->
|
||||
if null
|
||||
(maybe [] (collisionObstacle <$>)
|
||||
([M.safeGet (r + rr) (c + cc) imgmat] ++
|
||||
map snd (filter (\(V2 br bc, _) -> floor br == r + rr && floor bc == c + cc)
|
||||
animBounds)))
|
||||
(maybe [] collisionObstacle
|
||||
(join $ M.safeGet (r + rr) (c + cc) imgmat)
|
||||
++
|
||||
map snd (filter (\(V2 br bc, _) -> floor br == r + rr && floor bc == c + cc)
|
||||
animBounds))
|
||||
&& all null
|
||||
(map
|
||||
(\(oor, ooc) -> (maybe [] collisionObstacle
|
||||
(M.safeGet (r + oor) (c + ooc) imgmat)) ++
|
||||
(join $ M.safeGet (r + oor) (c + ooc) imgmat)) ++
|
||||
map snd (filter
|
||||
(\(V2 br bc, _) -> floor br == r + oor && floor bc == c + ooc)
|
||||
animBounds))
|
||||
|
|
Loading…
Reference in a new issue