Allow slimes to recombine

This commit is contained in:
2026-04-12 13:44:05 +01:00
parent d075880248
commit f0da9b5f8c
5 changed files with 46 additions and 10 deletions
+19
View File
@@ -1000,6 +1000,9 @@ crCrSpring c1 c2
| vec == V2 0 0 = id
| diff >= comRad = id
| diffheight = id
| SlimeCrit{} <- c1 ^. crType
, SlimeCrit{} <- c2 ^. crType
, id2 > id1 = fuseSlimes c1 c2
| otherwise = cWorld . lWorld . creatures %~ ( olap c1 c2 . olap' c2 c1)
where
z c = c ^. crPos . _z
@@ -1018,6 +1021,22 @@ crCrSpring c1 c2
overlap c = ((comRad - diff) * crMass (_crType c) * 0.5 / massT) *^ signorm vec
massT = crMass (_crType c1) + crMass (_crType c2)
fuseSlimes :: Creature -> Creature -> World -> World
fuseSlimes c1 c2 = (cWorld . lWorld . creatures . ix i1 .~ c)
. (cWorld . lWorld . creatures . at i2 .~ Nothing)
where
i1 = c1 ^. crID
i2 = c2 ^. crID
c = c1 & crType . slimeRad .~ r
& crType . slimeCompression .~ V2 r 0
& crPos . _xy .~ (r1/(r1+r2)) *^ xy1 + (r2/(r1+r2)) *^ xy2
xy1 = c1 ^. crPos . _xy
xy2 = c2 ^. crPos . _xy
r1 = c1 ^?! crType . slimeRad
r2 = c2 ^?! crType . slimeRad
r = sqrt (r1*r1 + r2*r2)
updateDelayedEvents :: World -> World
updateDelayedEvents w =
let (neww, newde) = mapAccumR f w (w ^. cWorld . lWorld . delayedEvents)