Cleanup, change creature height from Maybe Float to Float

This commit is contained in:
2026-05-09 19:50:53 +01:00
parent 72056e5e3e
commit dfb451c450
5 changed files with 87 additions and 103 deletions
+6 -13
View File
@@ -174,20 +174,13 @@ collide3Wall sp wl (ep, mo) = maybe (ep, mo) (,Just (n, OWall wl)) $ intersectSe
collide3Creature :: Point3 -> Creature -> (Point3, MPO) -> (Point3, MPO)
collide3Creature sp cr (ep, m) = fromMaybe (ep, m) $ do
h <- crHeight cr
(p, n) <-
fst $
intersectCylSeg
(cr ^. crPos)
(crRad $ cr ^. crType)
h
sp
ep
let h = crHeight cr
(p, n) <- fst $ intersectCylSeg (cr ^. crPos) (crRad $ cr ^. crType) h sp ep
return (p, Just (n, OCreature cr))
crHeight :: Creature -> Maybe Float
crHeight :: Creature -> Float
crHeight cr = case cr ^. crHP of
HP{} -> Just $ case cr ^. crType of
HP{} -> case cr ^. crType of
HoverCrit {} -> 10
ChaseCrit {} -> 25
Avatar {} -> 25
@@ -198,8 +191,8 @@ crHeight cr = case cr ^. crHP of
HiveCrit {} -> 25
BarrelCrit{} -> 20
_ -> error $ "Need to define crHeight for this crType:\n" <> unlines (prettyShort (cr ^. crType))
CrIsCorpse{} -> Just 5
AvatarDestroyed{} -> Nothing
CrIsCorpse{} -> 5
AvatarDestroyed{} -> 0
wallToSurface :: Wall -> (Point3, Point3, [(Point3, Point3)])
wallToSurface wl = (g x, g $ vNormal (x - y), [(g x, g (y - x)), (g y, g (x - y))])