Allow for easier mounted objects on doors

This commit is contained in:
2025-10-25 18:44:34 +01:00
parent 7585531dd1
commit cbf0f47b9b
14 changed files with 263 additions and 253 deletions
+1 -17
View File
@@ -1,4 +1,4 @@
module Dodge.Prop.Update where
module Dodge.Prop.Update (updateProp) where
import Control.Lens
import Data.Foldable
@@ -11,13 +11,10 @@ import Dodge.WorldBool
updateProp :: Prop -> World -> World
updateProp pr = case _prUpdate pr of
PropUpdateId -> id
PropRotate x -> rotateProp x pr
PropSetToggleAnd wb pu -> propSetToggleAnd wb pu pr
PropUpdates pus -> doPropUpdates pr pus
PropUpdateLS lsid x -> \w -> w & cWorld . lWorld . 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]
PropUpdateIf t x y -> propUpdateIf t x y pr
propUpdateIf :: WdBl -> PropUpdate -> PropUpdate -> Prop -> World -> World
@@ -35,16 +32,3 @@ doPropUpdates :: Prop -> [PropUpdate] -> World -> World
doPropUpdates pr pus w = foldl' f w pus
where
f w' pu = updateProp (pr & prUpdate .~ pu) w'
propSetToggleAnd :: WdBl -> PropUpdate -> Prop -> World -> World
propSetToggleAnd wb pu pr = setToggle (doWdBl wb) pr . updateProp (pr & prUpdate .~ pu)
-- fugly
setToggle :: (World -> Bool) -> Prop -> World -> World
setToggle cond pr w = w & cWorld . lWorld . props . ix (_prID pr) . prToggle .~ cond w
rotateProp :: Float -> Prop -> World -> World
rotateProp rotAmount pr w =
w
& cWorld . lWorld . props . ix (_prID pr) . prRot +~ rotAmount