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
_ -> do
dt <- getDelta
(_, (playerPos, posanims, posActions)) <- yieldSystemT (worldState ud) $ do
pc <- efor allEnts $ do
with player
(_, dat) <- yieldSystemT (worldState ud) $ do
efor allEnts $ do
with pos
query pos
posanims <- efor allEnts $ do
with anim
with pos
stat <- query anim
pos' <- query pos
player <- queryMaybe player
stat <- queryMaybe anim
mbnds <- queryMaybe obstacle
return (pos', stat, mbnds)
posActions <- efor allEnts $ do
with objType
with objState
with objStateTime
with objPlayerActivated
with pos
pos' <- query pos
t <- query objType
s <- query objState
pa <- query objPlayerActivated
let maxt = actionTime t s
ttl <- query objStateTime
return (pos', pa, realToFrac (1 - ttl / maxt))
return (head pc, posanims, posActions)
let V2 pr pc = playerPos
t <- queryMaybe objType
s <- queryMaybe objState
pa <- queryMaybe objPlayerActivated
ttl <- queryMaybe objStateTime
let maxt = fromMaybe 1 (actionTime <$> t <*> s)
first = if isJust player
then Just
pos'
else Nothing
secnd = if isJust stat
then Just
( pos'
, fromJust stat
, mbnds
)
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
seekGraph = Types.connects (head gr) ++ tail gr
room = Prelude.filter (inBounds (fmap floor playerPos) . bounds) seekGraph