Simplify props (should they be removed?)
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
module Dodge.Prop.Update (updateProp) where
|
||||
|
||||
import Control.Lens
|
||||
import Data.Foldable
|
||||
import Dodge.Data.World
|
||||
import Dodge.WdP2f
|
||||
import Dodge.WorldBool
|
||||
|
||||
updateProp :: Prop -> World -> World
|
||||
updateProp pr = case _prUpdate pr of
|
||||
PropUpdateId -> id
|
||||
PropUpdates pus -> doPropUpdates pr pus
|
||||
PropUpdatePosition x -> propUpdatePosition x pr
|
||||
PropUpdateWhen t x -> propUpdateIf t x PropUpdateId pr
|
||||
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
|
||||
|
||||
propUpdatePosition :: WdP2f -> Prop -> World -> World
|
||||
propUpdatePosition x pr w =
|
||||
w
|
||||
& cWorld . lWorld . props . ix (_prID pr) . prPos .~ fst (doWdP2f x w)
|
||||
& cWorld . lWorld . props . ix (_prID pr) . prRot .~ snd (doWdP2f x w)
|
||||
|
||||
doPropUpdates :: Prop -> [PropUpdate] -> World -> World
|
||||
doPropUpdates pr pus w = foldl' f w pus
|
||||
where
|
||||
f w' pu = updateProp (pr & prUpdate .~ pu) w'
|
||||
Reference in New Issue
Block a user