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
+51 -44
View File
@@ -1,51 +1,58 @@
module Dodge.WorldEvent.Cloud
( makeFlamerSmokeAt
, smokeCloudAt
, makeThinSmokeAt
, makeThickSmokeAt
, shellTrailCloud
, spawnSmokeAtCursor
, makeStartCloudAt
) where
import Dodge.Data
import Dodge.Base
import Geometry.Data
import Picture
import LensHelp
module Dodge.WorldEvent.Cloud (
makeFlamerSmokeAt,
smokeCloudAt,
makeThinSmokeAt,
makeThickSmokeAt,
shellTrailCloud,
spawnSmokeAtCursor,
makeStartCloudAt,
) where
import Dodge.Base
import Dodge.Data.World
import Geometry.Data
import LensHelp
import Picture
--import qualified Streaming.Prelude as S
--import Control.Lens
import System.Random
makeCloudAt
:: CloudDraw
-> Float -- ^ radius
-> Int -- ^ timer
-> Float -- ^ resting altitude
-> Point3 -- start position
-> World
-> World
makeCloudAt drawFunc rad t alt p = cWorld . clouds .:~ Cloud
--makeCloudAt drawFunc rad t alt p = clouds %~ S.cons Cloud
{ _clPos = p
, _clVel = V3 0 0 0
, _clPict = drawFunc
, _clRad = rad
, _clAlt = alt
, _clTimer = t
, _clType = SmokeCloud
}
smokeCloudAt
:: Color
-> Float -- ^ radius
-> Int -- ^ timer
-> Float -- ^ resting altitude
-> Point3 -- start position
-> World
-> World
smokeCloudAt col = makeCloudAt (CloudColor (4/3) 800 col)
makeCloudAt ::
CloudDraw ->
-- | radius
Float ->
-- | timer
Int ->
-- | resting altitude
Float ->
Point3 -> -- start position
World ->
World
makeCloudAt drawFunc rad t alt p =
cWorld . clouds
.:~ Cloud
{ --makeCloudAt drawFunc rad t alt p = clouds %~ S.cons Cloud
_clPos = p
, _clVel = V3 0 0 0
, _clPict = drawFunc
, _clRad = rad
, _clAlt = alt
, _clTimer = t
, _clType = SmokeCloud
}
smokeCloudAt ::
Color ->
-- | radius
Float ->
-- | timer
Int ->
-- | resting altitude
Float ->
Point3 -> -- start position
World ->
World
smokeCloudAt col = makeCloudAt (CloudColor (4 / 3) 800 col)
makeThickSmokeAt :: Point3 -> World -> World
makeThickSmokeAt = makeCloudAt (CloudColor 4 50 black) 3 50 30
@@ -57,12 +64,12 @@ makeStartCloudAt :: Point3 -> World -> World
makeStartCloudAt = makeCloudAt (CloudColor 2 800 white) 10 400 5
shellTrailCloud :: Point3 -> World -> World
shellTrailCloud = makeCloudAt (CloudColor (4/3) 800 (greyN 0.5)) 15 400 40
shellTrailCloud = makeCloudAt (CloudColor (4 / 3) 800 (greyN 0.5)) 15 400 40
makeFlamerSmokeAt :: Point3 -> World -> World
makeFlamerSmokeAt p w = makeCloudAt (CloudColor 4 300 (greyN x)) 6 200 40 p w
where
x = fst $ randomR (0.5,0.8) (_randGen w)
x = fst $ randomR (0.5, 0.8) (_randGen w)
spawnSmokeAtCursor :: World -> World
spawnSmokeAtCursor w = shellTrailCloud (V3 x y 20) w