Track slime amount using ints

This commit is contained in:
2026-05-06 15:40:31 +01:00
parent e927de6508
commit b76148ae2a
12 changed files with 203 additions and 147 deletions
+12 -6
View File
@@ -1076,6 +1076,7 @@ slimeFood cr = case cr ^. crType of
Avatar{} -> True
ChaseCrit{} -> True
CrabCrit {} -> True
BeeCrit{} | CrIsCorpse{} <- cr ^. crHP -> True
_ -> False
feedSlime :: Creature -> Creature -> World -> World
@@ -1090,10 +1091,12 @@ feedSlime s c w = fromMaybe w $ do
& cWorld . lWorld . creatures . ix (s ^. crID) %~ f
& slimeEatSound (s ^. crID) (s ^. crPos . _xy)
where
f cr = cr & crType . slimeRad .~ r
f cr = cr -- & crType . slimeRad .~ r
& crType . slimeSlime .~ round (r^(2::Int) * 100)
& crType . slimeRadWobble +~ r - r1
& crType . slimeCompression %~ ((r/r1) *^)
r1 = s ^?! crType . slimeRad
--r1 = s ^?! crType . slimeRad
r1 = s ^?! crType . slimeSlime . to slimeToRad
r2 = c ^. crType . to crRad
r = sqrt (r1*r1 + r2*r2)
@@ -1102,18 +1105,21 @@ fuseSlimes c1 c2 = (cWorld . lWorld . creatures . ix mini .~ c)
. (cWorld . lWorld . creatures . at maxi .~ Nothing)
. slimeEatSound i1 (c ^. crPos . _xy)
where
c' | c1 ^?! crType . slimeRad > c2 ^?! crType . slimeRad = c1
--c' | c1 ^?! crType . slimeRad > c2 ^?! crType . slimeRad = c1
c' | c1 ^?! crType . slimeSlime > c2 ^?! crType . slimeSlime = c1
| otherwise = c2
mini = min i1 i2
maxi = max i1 i2
i1 = c1 ^. crID
i2 = c2 ^. crID
c = c' & crType . slimeRad .~ r
c = c' & crType . slimeSlime .~ round (r^(2::Int) * 100)
& crType . slimeRadWobble +~ r - max r1 r2
& crType . slimeCompression %~ ((r/max r1 r2) *^)
& crID .~ mini
r1 = c1 ^?! crType . slimeRad
r2 = c2 ^?! crType . slimeRad
-- r1 = c1 ^?! crType . slimeRad
-- r2 = c2 ^?! crType . slimeRad
r1 = c1 ^?! crType . slimeSlime . to slimeToRad
r2 = c2 ^?! crType . slimeSlime . to slimeToRad
r = sqrt (r1*r1 + r2*r2)
slimeEatSound :: Int -> Point2 -> World -> World