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 :: Double -> Affection UserData ()
|
||||||
updateMap dt = do
|
updateMap dt = do
|
||||||
ud <- getAffection
|
ud <- getAffection
|
||||||
if stateData ud == None
|
-- empty <- liftIO $ isEmptyMVar (stateMVar ud)
|
||||||
|
if stateData ud == None -- && empty
|
||||||
then do
|
then do
|
||||||
liftIO $ logIO A.Debug "Loaded game data"
|
mstart <- liftIO $ tryTakeMVar (stateMVar ud)
|
||||||
(nws, mendat) <- liftIO $ takeMVar (stateMVar ud)
|
case mstart of
|
||||||
putAffection ud
|
Just (nws, mendat) -> do
|
||||||
{ worldState = nws
|
putAffection ud
|
||||||
, stateData = mendat
|
{ worldState = nws
|
||||||
}
|
, stateData = mendat
|
||||||
updateMap 0.1
|
}
|
||||||
updateMap 0.1
|
updateMap 0.1
|
||||||
updateMap 0.1
|
updateMap 0.1
|
||||||
updateMap 19
|
updateMap 0.1
|
||||||
|
updateMap 19
|
||||||
|
liftIO $ logIO A.Debug "Loaded game data"
|
||||||
|
Nothing -> return ()
|
||||||
else do
|
else do
|
||||||
(nws, _) <- yieldSystemT (worldState ud) $ do
|
(nws, _) <- yieldSystemT (worldState ud) $ do
|
||||||
emap allEnts $ do
|
emap allEnts $ do
|
||||||
|
|
16
src/Util.hs
16
src/Util.hs
|
@ -11,6 +11,8 @@ import Data.Graph.AStar
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
|
||||||
|
import Control.Monad (join)
|
||||||
|
|
||||||
import qualified SDL
|
import qualified SDL
|
||||||
import qualified Graphics.Rendering.OpenGL as GL hiding (get)
|
import qualified Graphics.Rendering.OpenGL as GL hiding (get)
|
||||||
|
|
||||||
|
@ -164,7 +166,8 @@ naviGraph imgmat animBounds (V2 r c) =
|
||||||
(\acc (rr, cc) ->
|
(\acc (rr, cc) ->
|
||||||
if null
|
if null
|
||||||
(maybe [] collisionObstacle
|
(maybe [] collisionObstacle
|
||||||
(M.safeGet (r + rr) (c + cc) imgmat) ++
|
(join $ M.safeGet (r + rr) (c + cc) imgmat)
|
||||||
|
++
|
||||||
map snd (filter
|
map snd (filter
|
||||||
(\(V2 br bc, _) -> floor br == r + rr && floor bc == c + cc)
|
(\(V2 br bc, _) -> floor br == r + rr && floor bc == c + cc)
|
||||||
animBounds))
|
animBounds))
|
||||||
|
@ -177,14 +180,15 @@ naviGraph imgmat animBounds (V2 r c) =
|
||||||
foldl
|
foldl
|
||||||
(\acc (rr, cc) ->
|
(\acc (rr, cc) ->
|
||||||
if null
|
if null
|
||||||
(maybe [] (collisionObstacle <$>)
|
(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)))
|
map snd (filter (\(V2 br bc, _) -> floor br == r + rr && floor bc == c + cc)
|
||||||
|
animBounds))
|
||||||
&& all null
|
&& all null
|
||||||
(map
|
(map
|
||||||
(\(oor, ooc) -> (maybe [] collisionObstacle
|
(\(oor, ooc) -> (maybe [] collisionObstacle
|
||||||
(M.safeGet (r + oor) (c + ooc) imgmat)) ++
|
(join $ M.safeGet (r + oor) (c + ooc) imgmat)) ++
|
||||||
map snd (filter
|
map snd (filter
|
||||||
(\(V2 br bc, _) -> floor br == r + oor && floor bc == c + ooc)
|
(\(V2 br bc, _) -> floor br == r + oor && floor bc == c + ooc)
|
||||||
animBounds))
|
animBounds))
|
||||||
|
|
Loading…
Reference in a new issue