Add wall dust when destroying a block

This commit is contained in:
2021-11-17 11:48:20 +00:00
parent 9db091597d
commit 602d91d3a8
4 changed files with 23 additions and 6 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ wpAdd wp = rmPmnts %~ f
g x = x & plIDCont .~ flickerMod
-- TODO move this to a sensible place
-- Supposes the orginal placement is a light source, adds a flickermod
-- Supposes the orginal placement is a light source, adds a flicker
flickerMod :: Placement -> Maybe Placement
flickerMod pl = Just $ sps0 $ PutMod $ ModIDTimerPoint3Bool
{ _mdID = 0
+7
View File
@@ -16,6 +16,8 @@ import Dodge.SoundLogic
import Dodge.Inventory
import Dodge.WorldEvent.Sound
import Dodge.Wall.Delete
import Dodge.Wall.Dust
import Dodge.RandomHelp
import Geometry
import Geometry.ConvexPoly
import Geometry.Vector3D
@@ -28,6 +30,8 @@ import qualified Data.Set as S
import qualified Data.IntSet as IS
import qualified Data.IntMap.Strict as IM
import Control.Lens
import Control.Monad
import Control.Monad.State
import Data.Monoid
import System.Random
@@ -121,9 +125,12 @@ destroyBlock bl w = w
& deleteWallIDs wlids
& blocks %~ IM.delete (_blID bl)
& mkSoundBreakGlass pos
& flip (foldr (wlDustAt awl)) (map (pos +.+) ps)
where
wlids = _blWallIDs bl
awl = _walls w IM.! IS.findMin wlids
pos = fst . _wlLine $ _walls w IM.! IS.findMin wlids
ps = (replicateM 25 $ randInCirc 20) & evalState $ _randGen w
-- | Note the explict use of record syntax. Using lens created a space leak.
resetWorldEvents :: World -> World
resetWorldEvents w = w {_worldEvents = id}
+3 -5
View File
@@ -6,11 +6,10 @@ module Dodge.Wall.Damage
, damageWall
) where
import Dodge.Data
import Dodge.WorldEvent.Cloud
import Dodge.Wall.Reflect
import Dodge.Wall.Dust
import Dodge.Particle.Spark
import Geometry
import Geometry.Vector3D
import Color
import Control.Lens
@@ -26,8 +25,8 @@ wallEff :: DamageType -> Wall -> World -> World
wallEff dt wl = case dt of
Lasering _ sp p _ -> colSpark 8 lSparkCol (outTo sp p) (reflDirWall sp p wl)
Piercing _ sp p _ -> colSpark' 0.2 8 pSparkCol (outTo sp p) (reflDirWall sp p wl)
. smokeCloudAt dustcol 20 200 1 (addZ 20 (outTo sp p))
Blunt _ sp p _ -> smokeCloudAt dustcol 20 200 1 (addZ 20 (outTo sp p))
. wlDustAt wl (outTo sp p)
Blunt _ sp p _ -> wlDustAt wl (outTo sp p)
Cutting {} -> id
SparkDam {} -> id
Flaming {} -> id
@@ -38,7 +37,6 @@ wallEff dt wl = case dt of
PoisonDam {} -> id
where
outTo sp p = p +.+ safeNormalizeV (sp -.- p)
dustcol = _wlColor wl & _4 .~ 1
pSparkCol = brightX 100 1.5 white
lSparkCol = V4 20 (-5) 0 1
+12
View File
@@ -0,0 +1,12 @@
module Dodge.Wall.Dust where
import Dodge.Data
import Dodge.WorldEvent.Cloud
import Geometry
import Geometry.Vector3D
import Control.Lens
wlDustAt :: Wall -> Point2 -> World -> World
wlDustAt wl p = smokeCloudAt dustcol 20 200 1 (addZ 20 p)
where
dustcol = _wlColor wl & _4 .~ 1