Add sound queue when on chasm edge
This commit is contained in:
@@ -2,6 +2,12 @@ module Dodge.Creature.Update (
|
||||
updateCreature,
|
||||
) where
|
||||
|
||||
import Picture.Base
|
||||
import LensHelp
|
||||
import Geometry
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.Creature.Radius
|
||||
import Geometry.Polygon
|
||||
import Control.Lens
|
||||
import Dodge.Creature.YourControl
|
||||
import Dodge.Creature.State
|
||||
@@ -9,9 +15,10 @@ import Dodge.Barreloid
|
||||
import Dodge.Data.World
|
||||
import Dodge.Humanoid
|
||||
import Dodge.Lampoid
|
||||
import qualified Data.List as List
|
||||
|
||||
updateCreature :: Creature -> World -> World
|
||||
updateCreature cr = case _crType cr of
|
||||
updateCreature cr = chasmTest cr . case _crType cr of
|
||||
Avatar{} -> (cWorld . lWorld . creatures . ix 0 . crType . avatarPulse %~ updatePulse)
|
||||
. crUpdate yourControl cr
|
||||
LampCrit{} -> updateLampoid cr
|
||||
@@ -19,6 +26,19 @@ updateCreature cr = case _crType cr of
|
||||
AvatarDead -> id
|
||||
_ -> updateHumanoid cr
|
||||
|
||||
chasmTest :: Creature -> World -> World
|
||||
chasmTest cr w
|
||||
| _crZVel cr < 0 = w & cWorld . lWorld . creatures . ix (_crID cr) . crZVel -~ 1
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crZ +~ (_crZVel cr)
|
||||
| Just (x,y) <- List.find g (foldMap loopPairs $ w ^. cWorld . chasms) = w
|
||||
& soundContinue (CrChasm (_crID cr)) (_crPos cr) debrisS (Just 100)
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crPos -~ normalizeV (vNormal (x-y))
|
||||
| any f (w ^. cWorld . chasms) = w & cWorld . lWorld . creatures . ix (_crID cr) . crZVel -~ 1
|
||||
| otherwise = w
|
||||
where
|
||||
g = uncurry $ circOnSeg (_crPos cr) (crRad $ cr ^. crType)
|
||||
f = circInPolygon (_crPos cr) (crRad $ cr ^. crType)
|
||||
|
||||
updatePulse :: Pulse -> Pulse
|
||||
updatePulse PulseStatus {_pulseRate = pr, _pulseProgress = pp}
|
||||
| pp >= pr = PulseStatus pr 0
|
||||
|
||||
Reference in New Issue
Block a user