Make falling creatures land on cliff corners
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
module Dodge.Creature.State.WalkCycle (updateCarriage) where
|
||||
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Geometry.Polygon
|
||||
import Data.Maybe
|
||||
import Dodge.Creature.HandPos
|
||||
@@ -38,7 +39,9 @@ updateCarriage' cid cr w = \case
|
||||
Falling {} ->
|
||||
let v = 0.95 *^ (cr ^. crOldPos - oop & _z -~ 0.5)
|
||||
ep = cr ^. crPos + v
|
||||
in if ep ^. _z < 0 && not (any (pointInPoly (ep ^. _xy)) (w ^. cWorld . chasms))
|
||||
in if ep ^. _z < 0 &&
|
||||
(not (any (pointInPoly (ep ^. _xy)) (w ^. cWorld . chasms))
|
||||
|| any (uncurry $ crOnSeg cr) (w ^. cWorld . cliffs))
|
||||
then w & tocr . crPos .~ (ep & _z .~ 0)
|
||||
& cWorld . lWorld . creatures . ix cid . crStance . carriage .~ OnGround
|
||||
else w & cWorld . lWorld . creatures . ix cid . crPos .~ ep
|
||||
|
||||
Reference in New Issue
Block a user