Refactor, try to limit dependencies

This commit is contained in:
2022-07-28 00:59:56 +01:00
parent 8aa5c17ab9
commit 160560af5f
418 changed files with 15104 additions and 13342 deletions
+56 -44
View File
@@ -1,50 +1,62 @@
module Dodge.WorldEvent.Shockwave
( makeShockwaveAt
, inverseShockwaveAt
) where
import Dodge.Data
module Dodge.WorldEvent.Shockwave (
makeShockwaveAt,
inverseShockwaveAt,
) where
import Dodge.Data.World
import Geometry
import Picture
import LensHelp
import Picture
-- currently very effective against walls
makeShockwaveAt
:: [Int] -- ^ IDs of invulnerable creatures.
-> Point2 -- ^ Center of shockwave.
-> Float -- ^ Maximal radius.
-> Int -- ^ Damage caused per frame.
-> Float -- ^ Amount of pushback per frame.
-> Color -- ^ Color of shockwave.
-> World -- ^ Start world.
-> World
makeShockwaveAt is p rad dam push col = cWorld . shockwaves .:~ Shockwave
{ _swInvulnerableCrs = is
, _swDirection = OutwardShockwave
, _swColor = col
, _swPos = p
, _swRad = rad
, _swDam = dam
, _swPush = push
, _swMaxTime = 10
, _swTimer = 10
}
makeShockwaveAt ::
-- | IDs of invulnerable creatures.
[Int] ->
-- | Center of shockwave.
Point2 ->
-- | Maximal radius.
Float ->
-- | Damage caused per frame.
Int ->
-- | Amount of pushback per frame.
Float ->
-- | Color of shockwave.
Color ->
-- | Start world.
World ->
World
makeShockwaveAt is p rad dam push col =
cWorld . shockwaves
.:~ Shockwave
{ _swInvulnerableCrs = is
, _swDirection = OutwardShockwave
, _swColor = col
, _swPos = p
, _swRad = rad
, _swDam = dam
, _swPush = push
, _swMaxTime = 10
, _swTimer = 10
}
{- Create a shockwave going from an outside circle into a center point. -}
inverseShockwaveAt
:: Point2 -- Center position
-> Float -- Radius
-> Int -- Damage
-> Float -- Push amount
-> World
-> World
inverseShockwaveAt p rad dam push = cWorld . shockwaves .:~ Shockwave
{ _swDirection = InwardShockwave
, _swInvulnerableCrs = []
, _swColor = cyan
, _swPos = p
, _swRad = rad
, _swDam = dam
, _swPush = push
, _swMaxTime = 10
, _swTimer = 10
}
inverseShockwaveAt ::
Point2 -> -- Center position
Float -> -- Radius
Int -> -- Damage
Float -> -- Push amount
World ->
World
inverseShockwaveAt p rad dam push =
cWorld . shockwaves
.:~ Shockwave
{ _swDirection = InwardShockwave
, _swInvulnerableCrs = []
, _swColor = cyan
, _swPos = p
, _swRad = rad
, _swDam = dam
, _swPush = push
, _swMaxTime = 10
, _swTimer = 10
}