more optimization
This commit is contained in:
parent
a68b186fd0
commit
aed0732d3e
2 changed files with 25 additions and 17 deletions
|
@ -520,10 +520,12 @@ 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
|
||||||
|
Just (nws, mendat) -> do
|
||||||
putAffection ud
|
putAffection ud
|
||||||
{ worldState = nws
|
{ worldState = nws
|
||||||
, stateData = mendat
|
, stateData = mendat
|
||||||
|
@ -532,6 +534,8 @@ updateMap dt = do
|
||||||
updateMap 0.1
|
updateMap 0.1
|
||||||
updateMap 0.1
|
updateMap 0.1
|
||||||
updateMap 19
|
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
|
||||||
|
|
14
src/Util.hs
14
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)
|
map snd (filter (\(V2 br bc, _) -> floor br == r + rr && floor bc == c + cc)
|
||||||
animBounds)))
|
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