Rethink damage data type, work on damage sensors
This commit is contained in:
+28
-24
@@ -13,7 +13,7 @@ import Geometry
|
||||
import Color
|
||||
import LensHelp
|
||||
|
||||
damageWall :: DamageType -> Wall -> World -> World
|
||||
damageWall :: Damage -> Wall -> World -> World
|
||||
damageWall dt wl = case _wlStructure wl of
|
||||
MachinePart mcid -> wallEff dt wl . (machines . ix mcid . mcDamage .:~ dt)
|
||||
BlockPart blid -> wallEff dt wl . (blocks . ix blid %~ damageBlockWith dt)
|
||||
@@ -21,33 +21,35 @@ damageWall dt wl = case _wlStructure wl of
|
||||
_ -> wallEff dt wl
|
||||
{- | Damage effects on indestructible walls -}
|
||||
-- TODO take into account damage amount for amount of dust/sparks?
|
||||
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 _ -> colSparkRandDir 0.2 8 pSparkCol (outTo sp p) (reflDirWall sp p wl)
|
||||
. wlDustAt wl (outTo sp p)
|
||||
Blunt _ sp p _ -> wlDustAt wl (outTo sp p)
|
||||
Explosive _ _ -> id
|
||||
Cutting {} -> id
|
||||
SparkDam {} -> id
|
||||
Flaming {} -> id
|
||||
Electrical {} -> id
|
||||
Concussive {} -> id
|
||||
TorqueDam {} -> id
|
||||
PushDam {} -> id
|
||||
PoisonDam {} -> id
|
||||
wallEff :: Damage -> Wall -> World -> World
|
||||
wallEff dm wl = case _dmType dm of
|
||||
Lasering -> colSpark 8 lSparkCol outTo (reflDirWall sp p wl)
|
||||
Piercing -> colSparkRandDir 0.2 8 pSparkCol outTo (reflDirWall sp p wl)
|
||||
. wlDustAt wl outTo
|
||||
Blunt -> wlDustAt wl outTo
|
||||
Explosive-> id
|
||||
Cutting -> id
|
||||
SparkDam -> id
|
||||
Flaming -> id
|
||||
Electrical -> id
|
||||
Concussive -> id
|
||||
TorqueDam -> id
|
||||
PushDam -> id
|
||||
PoisonDam -> id
|
||||
where
|
||||
outTo sp p = p +.+ squashNormalizeV (sp -.- p)
|
||||
sp = _dmFrom dm
|
||||
p = _dmTo dm
|
||||
outTo = p +.+ squashNormalizeV (sp -.- p)
|
||||
pSparkCol = brightX 100 1.5 white
|
||||
lSparkCol = V4 20 (-5) 0 1
|
||||
|
||||
damageBlockWith :: DamageType -> Block -> Block
|
||||
damageBlockWith dt = case dt of
|
||||
Piercing dam _ _ _ -> blHPs %~ reduceHead dam
|
||||
Blunt dam _ _ _ -> blHPs %~ reduceHead dam
|
||||
Cutting dam _ _ _ -> blHPs %~ reduceHead dam
|
||||
Explosive dam _ -> blHPs %~ reduceHead dam
|
||||
Concussive dam _ _ _ _ -> blHPs %~ reduceHead dam
|
||||
damageBlockWith :: Damage -> Block -> Block
|
||||
damageBlockWith dm = case _dmType dm of
|
||||
Piercing -> blHPs %~ reduceHead dam
|
||||
Blunt -> blHPs %~ reduceHead dam
|
||||
Cutting -> blHPs %~ reduceHead dam
|
||||
Explosive -> blHPs %~ reduceHead dam
|
||||
Concussive -> blHPs %~ reduceHead dam
|
||||
Lasering {} -> id
|
||||
SparkDam {} -> id
|
||||
Flaming {} -> id
|
||||
@@ -55,6 +57,8 @@ damageBlockWith dt = case dt of
|
||||
TorqueDam {} -> id
|
||||
PushDam {} -> id
|
||||
PoisonDam {} -> id
|
||||
where
|
||||
dam = _dmAmount dm
|
||||
|
||||
reduceHead :: Int -> [Int] -> [Int]
|
||||
reduceHead y (x:xs) = x-y:xs
|
||||
|
||||
Reference in New Issue
Block a user