Refactor damages
This commit is contained in:
+13
-21
@@ -4,10 +4,10 @@ module Dodge.Flame (
|
||||
updateFlame,
|
||||
) where
|
||||
|
||||
import Dodge.Creature.Radius
|
||||
import Dodge.Data.World
|
||||
import Data.Foldable
|
||||
import Data.Tuple
|
||||
import Dodge.Creature.Radius
|
||||
import Dodge.Data.World
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.WorldEvent.Cloud
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
@@ -38,34 +38,26 @@ aFlameParticle t pos vel =
|
||||
, _flOriginalVel = vel
|
||||
}
|
||||
|
||||
simpleDamFL :: DamageType -> Int -> Flame -> Point2 -> [Damage]
|
||||
simpleDamFL dt amount bt p = [Damage dt amount sp p ep]
|
||||
where
|
||||
sp = _flPos bt
|
||||
bulVel = _flVel bt
|
||||
ep = sp +.+ bulVel
|
||||
|
||||
expireAndDamageFL ::
|
||||
(Flame -> Point2 -> [Damage]) ->
|
||||
Flame ->
|
||||
[(Point2, Either Creature Wall)] ->
|
||||
World ->
|
||||
(World, Maybe Flame)
|
||||
expireAndDamageFL fdm bt things w = case List.safeHead things of
|
||||
expireAndDamageFL bt things w = case List.safeHead things of
|
||||
Nothing -> (w, Just $ bt & flTimer -~ 1)
|
||||
Just x -> (doDamagesFL fdm x bt w, Nothing)
|
||||
Just x -> (doDamagesFL x bt w, Nothing)
|
||||
|
||||
doDamagesFL ::
|
||||
(Flame -> Point2 -> [Damage]) ->
|
||||
(Point2, Either Creature Wall) ->
|
||||
Flame ->
|
||||
World ->
|
||||
World
|
||||
doDamagesFL fdm (p, thhit) bt = case thhit of
|
||||
Left cr -> cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage .++~ dams
|
||||
Right wl -> cWorld . lWorld . wallDamages %~ IM.insertWith (++) (_wlID wl) dams
|
||||
where
|
||||
dams = fdm bt p
|
||||
doDamagesFL (p, thhit) bt = case thhit of
|
||||
Left cr ->
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage
|
||||
.:~ Flaming 1
|
||||
--Right wl -> cWorld . lWorld . wallDamages %~ IM.insertWith (++) (_wlID wl) dams
|
||||
Right wl -> cWorld . lWorld . wallDamages . ix (_wlID wl) .:~ Flaming 1
|
||||
|
||||
{- TODO: add generalised area damage particles/hiteffects. -}
|
||||
updateFlame :: World -> Flame -> (World, Maybe Flame)
|
||||
@@ -112,21 +104,21 @@ flDamageInArea :: (Creature -> Bool) -> (Wall -> Bool) -> Flame -> World -> Worl
|
||||
flDamageInArea crt wlt pt w = damwls damcrs
|
||||
where
|
||||
p = _flPos pt
|
||||
damcrs = foldl' (flip $ \cr -> fst . hiteff [(p, Left cr)]) w $ IM.filter crt $ w ^. cWorld . lWorld . creatures--_creatures (_cWorld w)
|
||||
damcrs = foldl' (flip $ \cr -> fst . hiteff [(p, Left cr)]) w $ IM.filter crt $ w ^. cWorld . lWorld . creatures --_creatures (_cWorld w)
|
||||
damwls w' =
|
||||
foldl'
|
||||
(flip $ \wl -> fst . hiteff [(p, Right wl)])
|
||||
w'
|
||||
. filter wlt
|
||||
$ wlsNearPoint p w'
|
||||
hiteff = expireAndDamageFL (simpleDamFL FLAMING 1) pt
|
||||
hiteff = expireAndDamageFL pt
|
||||
|
||||
flFlicker :: Flame -> World -> World
|
||||
flFlicker pt
|
||||
| _flTimer pt `mod` 7 == 0 =
|
||||
cWorld . lWorld . lights
|
||||
.:~ LSParam (addZ 10 $ _flPos pt) 70 (0.5 *.*.* xyzV4 (_flColor pt))
|
||||
-- .:~ tlsTimeRadColPos 1 70 (0.5 *.*.* xyzV4 (_flColor pt)) (addZ 10 $ _flPos pt)
|
||||
-- .:~ tlsTimeRadColPos 1 70 (0.5 *.*.* xyzV4 (_flColor pt)) (addZ 10 $ _flPos pt)
|
||||
| otherwise = id
|
||||
|
||||
makeFlame :: Point2 -> Point2 -> World -> World
|
||||
|
||||
Reference in New Issue
Block a user