diff --git a/src/Dodge/Room/Start.hs b/src/Dodge/Room/Start.hs index c4cad4588..0452a4d07 100644 --- a/src/Dodge/Room/Start.hs +++ b/src/Dodge/Room/Start.hs @@ -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 diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 682123633..5c2c364bd 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -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} diff --git a/src/Dodge/Wall/Damage.hs b/src/Dodge/Wall/Damage.hs index 4fcc1e4cc..8d5fbd537 100644 --- a/src/Dodge/Wall/Damage.hs +++ b/src/Dodge/Wall/Damage.hs @@ -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 diff --git a/src/Dodge/Wall/Dust.hs b/src/Dodge/Wall/Dust.hs new file mode 100644 index 000000000..e6eb3545b --- /dev/null +++ b/src/Dodge/Wall/Dust.hs @@ -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 +