Start adding pulseLasers

This commit is contained in:
2025-07-19 22:05:46 +01:00
parent 27ce087e33
commit 8b17ec56ad
13 changed files with 475 additions and 454 deletions
+27
View File
@@ -7,6 +7,7 @@ Description : Simulation update
-}
module Dodge.Update (updateUniverse) where
import Dodge.Item.Weapon.LaserPath
import Dodge.Cloud
import Dodge.Creature.Radius
import Dodge.Creature.Mass
@@ -274,6 +275,7 @@ functionalUpdate u =
. over uvWorld updateRadarBlips
-- . over uvWorld updateBeams
. over uvWorld updateLasers
. over uvWorld updatePulseLasers
. over uvWorld updateTeslaArcs
. over uvWorld updateTractorBeams
. over uvWorld (updateIMl' (_linearShockwaves . _lWorld . _cWorld) updateLinearShockwave)
@@ -443,6 +445,11 @@ updateLasers w = w' & cWorld . lWorld . flares <>~ concat ls
(w & cWorld . lWorld . lasers .~ [])
(w ^. cWorld . lWorld . lasers)
updatePulseLasers :: World -> World
updatePulseLasers w = f w & cWorld . lWorld . pulseLasers .~ pzs
where
(Endo f, pzs) = foldMap updatePulseLaser (w ^. cWorld . lWorld . pulseLasers)
zoneClouds :: World -> World
zoneClouds w = w & clZoning .~ foldl' (flip zoneCloud) mempty (w ^. cWorld . lWorld . clouds)
@@ -585,6 +592,26 @@ updateTeslaArc w pt
| ArcStep lp' ld' _ <- last thearc = (lp', rp ld')
damthings (ArcStep _ _ crwl) = damageCrWlID [Electrical 50] crwl
updatePulseLaser :: PulseLaser -> (Endo World, [PulseLaser])
updatePulseLaser pz = case pz ^. pzTimer of
i | i <= 0 -> (Endo id,[])
5 -> (Endo f,[pz & pzTimer -~ 1])
_ -> (Endo g,[pz & pzTimer -~ 1])
where
f w = damThingHitWith
(\p2 -> Lasering (pz ^. pzDamage) p2 (xp - sp))
thHit w
& cWorld . lWorld . flares <>~ drawLaser cyan (sp: ps)
where
(thHit, ps) = reflectLaserAlong phasev sp xp w
phasev = _pzPhaseV pz
sp = _pzPos pz
dir = _pzDir pz
xp = sp +.+ 800 *.* unitVectorAtAngle dir
g w = w & cWorld . lWorld . flares <>~ drawLaser cyan (sp: ps)
where
(_, ps) = reflectLaserAlong phasev sp xp w
randWallReflect :: RandomGen g => Float -> Wall -> State g Float
randWallReflect a wl = randPeaked a1 outa a2
where