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 pos' <- query pos
query pos player <- queryMaybe player
posanims <- efor allEnts $ do stat <- queryMaybe anim
with anim mbnds <- queryMaybe obstacle
with pos t <- queryMaybe objType
stat <- query anim s <- queryMaybe objState
pos' <- query pos pa <- queryMaybe objPlayerActivated
mbnds <- queryMaybe obstacle ttl <- queryMaybe objStateTime
return (pos', stat, mbnds) let maxt = fromMaybe 1 (actionTime <$> t <*> s)
posActions <- efor allEnts $ do first = if isJust player
with objType then Just
with objState pos'
with objStateTime else Nothing
with objPlayerActivated secnd = if isJust stat
with pos then Just
pos' <- query pos ( pos'
t <- query objType , fromJust stat
s <- query objState , mbnds
pa <- query objPlayerActivated )
let maxt = actionTime t s else Nothing
ttl <- query objStateTime third = if isJust t && isJust s
return (pos', pa, realToFrac (1 - ttl / maxt)) then Just
return (head pc, posanims, posActions) ( pos'
let V2 pr pc = playerPos , 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