Commit before moving configuration outside of world

This commit is contained in:
2021-11-28 20:31:04 +00:00
parent 5cbe394e08
commit 98e44f0eee
5 changed files with 23 additions and 21 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ data Configuration = Configuration
, _debug_noclip :: Bool
, _debug_cr_status :: Bool
, _debug_view_boundaries :: Bool
, _debug_pathing :: Bool
, _debug_pathing :: Bool
}
deriving (Generic, Show)
makeLenses ''Configuration
+1 -1
View File
@@ -108,7 +108,7 @@ data World = World
, _carteRot :: !Float
, _lightSources :: !(IM.IntMap LightSource)
, _tempLightSources :: ![TempLightSource]
, _closeObjects :: [Either FloorItem Button]
, _closeObjects :: [Either FloorItem Button]
, _seenLocations :: IM.IntMap (World -> Point2,String)
, _selLocation :: Int
, _sideEffects :: Universe -> IO Universe
+1 -1
View File
@@ -303,7 +303,7 @@ modClock n chainEff eff it cr w
| otherwise = eff it cr w
withMuzFlareI :: ChainEffect
withMuzFlareI f it cr w = makeTLight 3 100 (V3 1 1 0.5) flashPos
withMuzFlareI f it cr w = makeTlsTimeRadColPos 3 100 (V3 1 1 0.5) flashPos
. muzFlareAt (V4 5 5 0 2) flarePos dir
$ f it cr w
where
+15 -13
View File
@@ -21,14 +21,15 @@ import Dodge.Creature.State.Data
import Dodge.Data
import Geometry
import Color
import LensHelp
import Control.Lens
--import Control.Lens
import System.Random
import qualified Data.IntMap.Strict as IM
createBarrelSpark :: Point2 -> Float -> Maybe Int -> Int -> Int -> World -> World
createBarrelSpark pos dir maycid time colid w
= over worldEvents (( over particles (spark :) . sparkFlashAt pos') . ) w
createBarrelSpark pos dir maycid time colid w = w
& worldEvents %~ (( over particles (spark :) . sparkFlashAt pos') . )
where
spark = BulletPt
{ _ptDraw = drawBul
@@ -43,16 +44,17 @@ createBarrelSpark pos dir maycid time colid w
}
x = fst $ randomR (0,20) $ _randGen w
pos' = pos +.+ rotateV dir (V2 x 0)
sparkEff bt p cr = over (creatures . ix (_crID cr) . crState . crDamage)
((:) $ SparkDam 1 sp p ep)
where sp = head (_btTrail' bt)
ep = sp +.+ _btVel' bt
sparkEff bt p cr = creatures . ix (_crID cr) . crState . crDamage .:~ SparkDam 1 sp p ep
where
sp = head (_btTrail' bt)
ep = sp +.+ _btVel' bt
damCrsOnLine :: Int -> Point2 -> Point2 -> World -> World
damCrsOnLine dam p1 p2 = over creatures (IM.map damIfOnLine)
where damIfOnLine cr | circOnSeg p1 p2 (_crPos cr) (_crRad cr)
= over crHP (\hp -> hp - dam) cr
| otherwise = cr
damCrsOnLine dam p1 p2 = creatures %~ IM.map damIfOnLine
where
damIfOnLine cr
| circOnSeg p1 p2 (_crPos cr) (_crRad cr) = cr & crHP -~ dam
| otherwise = cr
makeTLight :: Int -> Float -> Point3 -> Point3 -> World -> World
makeTLight i rad (V3 r g b) p = tempLightSources %~ (tlsTimeRadColPos i rad (V3 r g b) p :)
makeTlsTimeRadColPos :: Int -> Float -> Point3 -> Point3 -> World -> World
makeTlsTimeRadColPos i rad (V3 r g b) p = tempLightSources .:~ tlsTimeRadColPos i rad (V3 r g b) p
+5 -5
View File
@@ -22,8 +22,8 @@ import Dodge.WorldEvent.HelperParticle
--import Dodge.Default
import Picture
import Geometry
import LensHelp
import Control.Lens
import System.Random
{- Cyan flash. -}
@@ -35,7 +35,7 @@ laserGunFlashAt :: Point3 -> World -> World
laserGunFlashAt = flareCircleAt yellow 0.2
muzFlareAt :: Color -> Point3 -> Float -> World -> World
muzFlareAt col tranv dir w = w & particles %~ (theFlare :)
muzFlareAt col tranv dir w = w & particles .:~ theFlare
where
theFlare = Particle
{ _ptDraw = const $ setLayer 1 . translate3 tranv $ theShape
@@ -49,7 +49,7 @@ muzFlareAt col tranv dir w = w & particles %~ (theFlare :)
(a:b:c:d:_) = randomRs (2,20) (_randGen w)
flareCircleAt :: Color -> Float -> Point3 -> World -> World
flareCircleAt col alphax tranv = particles %~ (theFlareCircle :)
flareCircleAt col alphax tranv = particles .:~ theFlareCircle
where
theFlareCircle = Particle
{ _ptDraw = const . setLayer 1 . translate3 tranv
@@ -58,7 +58,7 @@ flareCircleAt col alphax tranv = particles %~ (theFlareCircle :)
}
explosionFlashAt :: Point2 -> World -> World
explosionFlashAt p = tempLightSources %~ (tlsTimeRadFunPos 20 150 intensityFunc (addZ 20 p) :)
explosionFlashAt p = tempLightSources .:~ tlsTimeRadFunPos 20 150 intensityFunc (addZ 20 p)
where
intensityFunc x
| x < 10 = 1 / (10 - fromIntegral x)
@@ -69,7 +69,7 @@ sparkFlashAt _ = id
flameFlicker :: Particle -> World -> World
flameFlicker pt
| _btTimer' pt `mod` 5 == 0 = tempLightSources %~ (theLight :)
| _btTimer' pt `mod` 5 == 0 = tempLightSources .:~ theLight
| otherwise = id
where
V2 x y = _btPos' pt