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
+19 -20
View File
@@ -1,13 +1,12 @@
module Dodge.Prop.Update
where
import Dodge.WdP2f
import Dodge.PrWdLsLs
import Dodge.WorldBool
import Dodge.Data
import Dodge.Prop.Moving
module Dodge.Prop.Update where
import Data.Foldable
import Control.Lens
import Data.Foldable
import Dodge.Data.World
import Dodge.PrWdLsLs
import Dodge.Prop.Moving
import Dodge.WdP2f
import Dodge.WorldBool
updateProp :: Prop -> World -> World
updateProp pr = case _prUpdate pr of
@@ -20,20 +19,19 @@ updateProp pr = case _prUpdate pr of
PropUpdateLS lsid x -> \w -> w & cWorld . lightSources . ix lsid %~ doPrWdLsLs x pr w
PropUpdatePosition x -> propUpdatePosition x pr
PropUpdateWhen t x -> propUpdateIf t x PropUpdateId pr
PropUpdateAnd x y -> doPropUpdates pr [x,y]
PropUpdateAnd x y -> doPropUpdates pr [x, y]
PropUpdateIf t x y -> propUpdateIf t x y pr
propUpdateIf :: WdBl -> PropUpdate -> PropUpdate -> Prop -> World -> World
propUpdateIf wb x y pr w
| doWdBl wb w = updateProp (pr & prUpdate .~ x) w
| otherwise = updateProp (pr & prUpdate .~ y) w
| doWdBl wb w = updateProp (pr & prUpdate .~ x) w
| otherwise = updateProp (pr & prUpdate .~ y) w
propUpdatePosition :: WdP2f -> Prop -> World -> World
propUpdatePosition x pr w = w
& cWorld . props . ix (_prID pr) . prPos .~ fst (doWdP2f x w)
& cWorld . props . ix (_prID pr) . prRot .~ snd (doWdP2f x w)
propUpdatePosition x pr w =
w
& cWorld . props . ix (_prID pr) . prPos .~ fst (doWdP2f x w)
& cWorld . props . ix (_prID pr) . prRot .~ snd (doWdP2f x w)
doPropUpdates :: Prop -> [PropUpdate] -> World -> World
doPropUpdates pr pus w = foldl' f w pus
@@ -42,12 +40,13 @@ doPropUpdates pr pus w = foldl' f w pus
propSetToggleAnd :: WdBl -> PropUpdate -> Prop -> World -> World
propSetToggleAnd wb pu pr = setToggle (doWdBl wb) pr . updateProp (pr & prUpdate .~ pu)
-- fugly
-- fugly
setToggle :: (World -> Bool) -> Prop -> World -> World
setToggle cond pr w = w & cWorld . props . ix (_prID pr) . prToggle .~ cond w
rotateProp :: Float -> Prop -> World -> World
rotateProp rotAmount pr w = w
& cWorld . props . ix (_prID pr) . prRot +~ rotAmount
rotateProp rotAmount pr w =
w
& cWorld . props . ix (_prID pr) . prRot +~ rotAmount