little optimization

This commit is contained in:
Nek0 - 2019-02-21 17:22:38 +01:00
parent 5464b3e8bf
commit fc57805889

View File

@ -556,33 +556,47 @@ drawMap = do
drawLoadScreen ud progress drawLoadScreen ud progress
_ -> do _ -> do
dt <- getDelta dt <- getDelta
(_, (playerPos, posanims, posActions)) <- yieldSystemT (worldState ud) $ do (_, dat) <- yieldSystemT (worldState ud) $ do
pc <- efor allEnts $ do efor allEnts $ do
with player
with pos with pos
query pos
posanims <- efor allEnts $ do
with anim
with pos
stat <- query anim
pos' <- query pos pos' <- query pos
player <- queryMaybe player
stat <- queryMaybe anim
mbnds <- queryMaybe obstacle mbnds <- queryMaybe obstacle
return (pos', stat, mbnds) t <- queryMaybe objType
posActions <- efor allEnts $ do s <- queryMaybe objState
with objType pa <- queryMaybe objPlayerActivated
with objState ttl <- queryMaybe objStateTime
with objStateTime let maxt = fromMaybe 1 (actionTime <$> t <*> s)
with objPlayerActivated first = if isJust player
with pos then Just
pos' <- query pos pos'
t <- query objType else Nothing
s <- query objState secnd = if isJust stat
pa <- query objPlayerActivated then Just
let maxt = actionTime t s ( pos'
ttl <- query objStateTime , fromJust stat
return (pos', pa, realToFrac (1 - ttl / maxt)) , mbnds
return (head pc, posanims, posActions) )
let V2 pr pc = playerPos else Nothing
third = if isJust t && isJust s
then Just
( pos'
, fromMaybe False pa
, realToFrac (1 - fromMaybe 0 ttl / maxt)
)
else Nothing
return (first, secnd, third)
let ((playerPos:_), posanims, posActions) = Prelude.foldl
(\(amppo, ampan, ampac) (mppo, mpan, mpac) ->
( if isJust mppo then fromJust mppo : amppo else amppo
, if isJust mpan then fromJust mpan : ampan else ampan
, if isJust mpac then fromJust mpac : ampac else ampac
)
)
([], [], [])
dat
V2 pr pc = playerPos
MainData _ _ _ _ gr = stateData ud MainData _ _ _ _ gr = stateData ud
seekGraph = Types.connects (head gr) ++ tail gr seekGraph = Types.connects (head gr) ++ tail gr
room = Prelude.filter (inBounds (fmap floor playerPos) . bounds) seekGraph room = Prelude.filter (inBounds (fmap floor playerPos) . bounds) seekGraph