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
+21 -18
View File
@@ -1,24 +1,26 @@
module Dodge.TractorBeam.Update
where
import Geometry
import Dodge.Data
import qualified IntMapHelp as IM
module Dodge.TractorBeam.Update where
import Control.Lens
import Dodge.Data.World
import Geometry
import qualified IntMapHelp as IM
updateTractorBeam :: World -> TractorBeam -> (World, Maybe TractorBeam)
updateTractorBeam w pj
| _tbTime pj <= 0 = (w, Nothing)
| otherwise = (w
& cWorld . creatures %~ IM.map (tractCr pullVel pos outpos)
& cWorld . floorItems %~ IM.map (tractFlIt pullVel pos outpos)
, Just (pj & tbTime -~ 1))
where
| otherwise =
( w
& cWorld . creatures %~ IM.map (tractCr pullVel pos outpos)
& cWorld . floorItems %~ IM.map (tractFlIt pullVel pos outpos)
, Just (pj & tbTime -~ 1)
)
where
pullVel = _tbVel pj
pos = _tbPos pj
outpos = _tbStartPos pj
pos = _tbPos pj
outpos = _tbStartPos pj
tractFlIt :: Point2 -> Point2 -> Point2 -> FloorItem -> FloorItem
tractFlIt q p1 outpos it
tractFlIt q p1 outpos it
| segOnCirc p1 outpos (_flItPos it) 10 = it & flItPos %~ tractorPullPos q p1
| otherwise = it
@@ -28,13 +30,15 @@ tractCr q p1 outpos cr
| otherwise = cr
tractorPullPos :: Point2 -> Point2 -> Point2 -> Point2
tractorPullPos q p1 p = p -.- m *.* (0.3/ x' *.* q +.+ g y *.* p4)
tractorPullPos q p1 p = p -.- m *.* (0.3 / x' *.* q +.+ g y *.* p4)
where
x' = abs y + 1
y = errorClosestPointOnLineParam 1 p1 p3 p
m | dist p p1 < 350 = 1
| otherwise = (400 - dist p p1) / 50
g x | x > 5 = (10 - x) / 250
m
| dist p p1 < 350 = 1
| otherwise = (400 - dist p p1) / 50
g x
| x > 5 = (10 - x) / 250
| x > 1 = 0.02
| x > -1 = x * 0.02
| x > -5 = -0.02
@@ -42,4 +46,3 @@ tractorPullPos q p1 p = p -.- m *.* (0.3/ x' *.* q +.+ g y *.* p4)
--p4 = vNormal p5
p4 = vNormal $ squashNormalizeV q
p3 = p1 +.+ p4