Make falling creatures land on cliff corners

This commit is contained in:
2026-04-05 09:07:31 +01:00
parent b3b1fc6d87
commit 3952b2b1b7
6 changed files with 216 additions and 214 deletions
+4 -1
View File
@@ -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