Refactor crPos to be a V3
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
module Dodge.Creature.Update (updateCreature) where
|
||||
|
||||
import Linear
|
||||
import NewInt
|
||||
import Color
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
@@ -31,8 +32,8 @@ import ShapePicture.Data
|
||||
updateCreature :: Creature -> World -> World
|
||||
updateCreature cr
|
||||
| null (cr ^? crHP . _HP) = id
|
||||
| _crZ cr < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr
|
||||
| _crZ cr < 0 = (tocr . crZVel -~ 0.5) . (tocr . crZ +~ _crZVel cr)
|
||||
| cr ^. crPos . _z < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr
|
||||
| cr ^. crPos . _z < 0 = (tocr . crZVel -~ 0.5) . (tocr . crPos . _z +~ _crZVel cr)
|
||||
| otherwise = updateCreature' cr
|
||||
where
|
||||
tocr = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
@@ -131,16 +132,16 @@ dropAll cr w = foldl' (flip (dropItem cr)) w . reverse . IM.keys . _unNIntMap $
|
||||
chasmTest :: Creature -> World -> World
|
||||
chasmTest cr w
|
||||
| _crZVel cr < 0 = w & tocr . crZVel -~ 0.5
|
||||
& tocr . crZ +~ _crZVel cr
|
||||
& tocr . crPos . _z +~ _crZVel cr
|
||||
| Just (x, y) <- List.find g (foldMap loopPairs $ w ^. cWorld . chasms) = w
|
||||
& soundContinue (CrChasm (_crID cr)) (_crPos cr) debrisS (Just 100)
|
||||
& tocr . crPos -~ normalizeV (vNormal (x - y))
|
||||
& soundContinue (CrChasm (_crID cr)) (cr ^. crPos . _xy) debrisS (Just 100)
|
||||
& tocr . crPos . _xy -~ normalizeV (vNormal (x - y))
|
||||
| any f (w ^. cWorld . chasms) = w & tocr . crZVel -~ 0.5
|
||||
| otherwise = w
|
||||
where
|
||||
tocr = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
g = uncurry $ circOnSeg (_crPos cr) (crRad $ cr ^. crType)
|
||||
f = circInPolygon (_crPos cr) (crRad $ cr ^. crType)
|
||||
g = uncurry $ circOnSeg (cr ^. crPos . _xy) (crRad $ cr ^. crType)
|
||||
f = circInPolygon (cr ^. crPos . _xy) (crRad $ cr ^. crType)
|
||||
|
||||
updatePulse :: Pulse -> Pulse
|
||||
updatePulse PulseStatus{_pulseRate = pr, _pulseProgress = pp}
|
||||
|
||||
Reference in New Issue
Block a user