Separate out concrete part of world

This commit is contained in:
2022-07-25 12:10:50 +01:00
parent 3354d108be
commit b2efbd2b3e
134 changed files with 933 additions and 930 deletions
+3 -3
View File
@@ -68,7 +68,7 @@ addGibsAtDir dir minh maxh col p w = foldl' (flip $ addGib4 p col) w (zip4 vels
addGib4 :: Point2 -> Color -> (Point2, Float, Q.Quaternion Float, Float)
-> World -> World
addGib4 p col (v,zs,q,h) = plNew props prID (aGib & prPos .~ p +.+ (5 *.* normalizeV v)
addGib4 p col (v,zs,q,h) = plNew (cWorld . props) prID (aGib & prPos .~ p +.+ (5 *.* normalizeV v)
& prColor .~ col
& prVel .~ v
& prQuatSpin .~ Q.axisAngle (vNormal v `v2z` 0) (-0.1)
@@ -79,7 +79,7 @@ addGib4 p col (v,zs,q,h) = plNew props prID (aGib & prPos .~ p +.+ (5 *.* normal
addGibAt :: Float -> Color -> Point2 -> World -> World
addGibAt h col p w = w
& plNew props prID gib
& plNew (cWorld . props) prID gib
& randGen .~ newg
where
(gib,newg) = runState f $ _randGen w
@@ -100,7 +100,7 @@ addGibAt h col p w = w
addGibAtDir :: Float -> Float -> Color -> Point2 -> World -> World
addGibAtDir dir h col p w = w
& plNew props prID gib
& plNew (cWorld . props) prID gib
& randGen .~ newg
where
(gib,newg) = runState f $ _randGen w
+3 -3
View File
@@ -9,12 +9,12 @@ import LensHelp
fallSmallBounceDamage :: Prop -> World -> World
fallSmallBounceDamage pr w = w
& dodamage
& props . ix (_prID pr) %~ fallSmallBounce' w
& cWorld . props . ix (_prID pr) %~ fallSmallBounce' w
where
p = _prPos pr
v = _prVel pr
dodamage
| _prPosZ pr < 25 = creatures %~ fmap dodamage'
| _prPosZ pr < 25 = cWorld . creatures %~ fmap dodamage'
| otherwise = id
dodamage' cr
| dist (_crPos cr) p < _crRad cr + 5 = cr & crState . csDamage
@@ -23,7 +23,7 @@ fallSmallBounceDamage pr w = w
fallSmallBounce :: Prop -> World -> World
fallSmallBounce pr w = w
& props . ix (_prID pr) %~ fallSmallBounce' w
& cWorld . props . ix (_prID pr) %~ fallSmallBounce' w
fallSmallBounce' :: World -> Prop -> Prop
fallSmallBounce' w pr
+5 -5
View File
@@ -17,7 +17,7 @@ updateProp pr = case _prUpdate pr of
PropRotate x -> rotateProp x pr
PropSetToggleAnd wb pu -> propSetToggleAnd wb pu pr
PropUpdates pus -> doPropUpdates pr pus
PropUpdateLS lsid x -> \w -> w & lightSources . ix lsid %~ doPrWdLsLs x pr w
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]
@@ -32,8 +32,8 @@ propUpdateIf wb x y pr w
propUpdatePosition :: WdP2f -> Prop -> World -> World
propUpdatePosition x pr w = w
& props . ix (_prID pr) . prPos .~ fst (doWdP2f x w)
& props . ix (_prID pr) . prRot .~ snd (doWdP2f x 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
@@ -45,9 +45,9 @@ propSetToggleAnd wb pu pr = setToggle (doWdBl wb) pr . updateProp (pr & prUpdate
-- fugly
setToggle :: (World -> Bool) -> Prop -> World -> World
setToggle cond pr w = w & props . ix (_prID pr) . prToggle .~ cond w
setToggle cond pr w = w & cWorld . props . ix (_prID pr) . prToggle .~ cond w
rotateProp :: Float -> Prop -> World -> World
rotateProp rotAmount pr w = w
& props . ix (_prID pr) . prRot +~ rotAmount
& cWorld . props . ix (_prID pr) . prRot +~ rotAmount