Move debug flags to config, various perf improvements

This commit is contained in:
2021-09-24 13:25:24 +01:00
parent 899cf6ef81
commit 7da1a8bc45
17 changed files with 112 additions and 265 deletions
+9 -12
View File
@@ -30,7 +30,6 @@ import Data.Maybe
import Data.Function
import qualified Data.Set as S
import qualified Data.IntMap.Lazy as IM
import qualified Data.Map as M
import Control.Lens
import Data.Monoid
import System.Random
@@ -50,8 +49,7 @@ functionalUpdate w = case _menuLayers w of
(OptionScreen {_scOptionFlag = GameOverOptions} : _) -> updateParticles
. updateProjectiles
. updateLightSources
. updateClouds
$ updateSoundQueue
$ updateClouds
w
(_ : _) -> w
[] -> checkEndGame
@@ -75,9 +73,9 @@ functionalUpdate w = case _menuLayers w of
. updateCreatureGroups
. updateBlocks
. updateSeenWalls
. updateSoundQueue
$ updateCloseObjects w
where
--updatedLightSources = mapMaybe (\b -> _tlsUpdate b w b) $ _tempLightSources w
zoneCreatures = set (creaturesZone . znObjects)
(IM.foldl' (flip creatureInZone) IM.empty (_creatures w))
creatureInZone cr = insertIMInZone x y cid cr
@@ -119,9 +117,6 @@ updateTriggers w
where
cr = _creatures w IM.! 0 & crPos .~ V2 0 0
updateSoundQueue :: World -> World
updateSoundQueue = set sounds M.empty
updateLightSources :: World -> World
updateLightSources w = set tempLightSources tlss w
where
@@ -156,7 +151,7 @@ ppEvents :: World -> World
ppEvents w = IM.foldl' (flip $ \pp w' -> _ppEvent pp pp w') w $ _pressPlates w
updateSeenWalls :: World -> World
updateSeenWalls w = foldl' (flip markSeen) w wallsToUpdate
updateSeenWalls w = foldr markSeen w wallsToUpdate
where
vPos = _cameraViewFrom w
wallsToUpdate = concatMap (\p -> visibleWalls vPos (vPos +.+p) $ wallsAlongLine vPos (vPos +.+ p) w)
@@ -229,10 +224,10 @@ clClSpringVel a v b
radDist = (_clRad a + _clRad b) / 2
simpleCrSprings :: World -> World
simpleCrSprings w = IM.foldl' (flip crSpring) w $ _creatures w
simpleCrSprings w = IM.foldr crSpring w $ _creatures w
crSpring :: Creature -> World -> World
crSpring c w = IM.foldl' (flip $ crCrSpring c) w cs
crSpring c w = IM.foldr (crCrSpring c) w cs
where
cs = creaturesNearPoint (_crPos c) w
@@ -241,8 +236,10 @@ crCrSpring c1 c2 w
| id1 == id2 = w
| vec == V2 0 0 = w
| diff >= comRad = w
| otherwise = over (creatures . ix id1 . crPos) (+.+ overlap1)
$ over (creatures . ix id2 . crPos) (-.- overlap2) w
| otherwise = over creatures
( over (ix id1 . crPos) (+.+ overlap1)
. over (ix id2 . crPos) (-.- overlap2)
) w
where
id1 = _crID c1
id2 = _crID c2