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
+8 -15
View File
@@ -1033,11 +1033,8 @@ crCrSpring c1 c2
| otherwise = cWorld . lWorld . creatures %~ ( olap c1 c2 . olap' c2 c1)
where
z c = c ^. crPos . _z
h c = fmap (+ z c) (crHeight c)
diffheight = fromMaybe True $ do
h1 <- h c1
h2 <- h c2
return $ z c1 > h2 || z c2 > h1
h c = crHeight c + z c
diffheight = z c1 > h c2 || z c2 > h c1
olap a b = ix (a ^. crID) . crPos . _xy +~ overlap b
olap' a b = ix (a ^. crID) . crPos . _xy -~ overlap b
id1 = _crID c1
@@ -1080,22 +1077,18 @@ slimeFood cr = case cr ^. crType of
_ -> False
feedSlime :: Creature -> Creature -> World -> World
feedSlime s c w = fromMaybe w $ do
ch <- crHeight c
return $ if min 10 r1 + s ^?! crType . slimeEngulfProgress < max 15 (ch + 2)
feedSlime s c w = if min 10 r1 + s ^?! crType . slimeEngulfProgress < max 15 (ch + 2)
then w & cWorld.lWorld.creatures.ix (s^.crID).crType.slimeEngulfProgress%~ (min r1.(+0.7))
& slimeSuck s c
else
w
else w
& cWorld . lWorld . creatures . at (c ^. crID) %~ destroyCreature
& cWorld . lWorld . creatures . ix (s ^. crID) %~ f
& cWorld . lWorld . creatures . ix (s ^. crID) . crType . slimeSlime +~ x
& cWorld . lWorld . creatures . ix (s ^. crID) . crType . slimeSlimeChange +~ x
& slimeEatSound (s ^. crID) (s ^. crPos . _xy)
where
f cr = cr
& crType . slimeSlime +~ round (r2^(2::Int) * 100)
& crType . slimeSlimeChange +~ round (r2^(2::Int) * 100)
ch = crHeight c
x = round $ (c^.crType.to crRad)^(2::Int) * 100
r1 = s ^?! crType . slimeSlime . to slimeToRad
r2 = c ^. crType . to crRad
fuseSlimes :: Creature -> Creature -> World -> World
fuseSlimes c1 c2 = (cWorld . lWorld . creatures . ix mini .~ c)