Reorganisation of light source placements and fittings

This commit is contained in:
2021-11-17 12:04:03 +00:00
parent 602d91d3a8
commit bcdf0e643c
8 changed files with 149 additions and 137 deletions
+3 -3
View File
@@ -1,9 +1,9 @@
--{-# LANGUAGE TupleSections #-}
{- | Rooms containing long doors, probably with a big reveal behind them.
-}
module Dodge.Room.LongDoor
where
module Dodge.Room.LongDoor where
import Dodge.Data
import Dodge.Base
import Dodge.Default.Room
import Dodge.LevelGen.Data
import Dodge.Placement.Instance
@@ -51,7 +51,7 @@ twinSlowDoorRoom w h x = defaultRoom
}
where
wlSpeed = 0.5
addColorChange lsid drid' = over pjUpdate $ chain $ const f
addColorChange lsid drid' = over pjUpdate $ dbArgChain $ const f
where
f w' | _drStatus (_doors w' IM.! drid') == DoorHalfway
= w' & lightSources . ix lsid . lsIntensity .~ V3 8 0 0
+1 -29
View File
@@ -24,8 +24,7 @@ import Data.Tree
import Control.Monad.State
import Control.Lens
import System.Random
import Data.Maybe
import qualified Data.IntMap.Strict as IM
--import qualified Data.IntMap.Strict as IM
rezBox :: LightSource -> Room
rezBox ls = roomRect 40 60 1 1
@@ -54,33 +53,6 @@ wpAdd wp = rmPmnts %~ f
f _ = [sPS (V2 15 30) 1 (PutFlIt wp)]
g x = x & plIDCont .~ flickerMod
-- TODO move this to a sensible place
-- Supposes the orginal placement is a light source, adds a flicker
flickerMod :: Placement -> Maybe Placement
flickerMod pl = Just $ sps0 $ PutMod $ ModIDTimerPoint3Bool
{ _mdID = 0
, _mdExternalID = fromJust $ _plMID pl
, _mdUpdate = flickerUpdate
, _mdTimer = 10
, _mdPoint3 = 0.8
, _mdBool = True
}
flickerUpdate :: Modification -> World -> World
flickerUpdate md w
| _mdTimer md > 0 = w & modifications . ix mdid . mdTimer -~ 1
| otherwise = w & lightSources . ix lsid . lsIntensity .~ mdcol
& modifications . ix mdid
%~ ( (mdTimer .~ newtime) . (mdPoint3 .~ lscol) . (mdBool %~ not) )
where
mdcol = _mdPoint3 md
lscol = _lsIntensity $ _lightSources w IM.! lsid
lsid = _mdExternalID md
mdid = _mdID md
timerange
| _mdBool md = (2,10)
| otherwise = (2,30)
(newtime,_) = randomR timerange $ _randGen w
rezBoxesThenWeaponRoom :: RandomGen g => State g (Tree (Either Room Room))
rezBoxesThenWeaponRoom = do