Commit before modifying slime compression

This commit is contained in:
2026-04-20 20:14:59 +01:00
parent adae6b84f4
commit 73798ba07c
6 changed files with 21 additions and 15 deletions
+1 -1
View File
@@ -192,7 +192,7 @@ crHeight cr = case cr ^. crHP of
Avatar {} -> 25 Avatar {} -> 25
CrabCrit {} -> 25 CrabCrit {} -> 25
SlinkCrit {} -> 25 SlinkCrit {} -> 25
SlimeCrit {_slimeRad = r} -> r SlimeCrit {_slimeRad = r} -> min 15 r
BeeCrit {} -> 10 BeeCrit {} -> 10
HiveCrit {} -> 25 HiveCrit {} -> 25
_ -> error "Need to define crHeight for this crType" _ -> error "Need to define crHeight for this crType"
+6 -6
View File
@@ -48,7 +48,7 @@ drawCreature w m cr = translateSP (_crPos cr) . fallrot . rotateSP (_crDir cr) $
HoverCrit{} -> noPic $ drawHoverCrit cr HoverCrit{} -> noPic $ drawHoverCrit cr
SlinkCrit{} -> noPic $ drawSlinkCrit cr SlinkCrit{} -> noPic $ drawSlinkCrit cr
SlimeCrit{} -> noPic $ drawSlimeCrit cr SlimeCrit{} -> noPic $ drawSlimeCrit cr
BeeCrit{_beeSlime=x} -> noPic $ drawBeeCrit x BeeCrit{} -> noPic $ drawBeeCrit cr
HiveCrit{} -> drawHive HiveCrit{} -> drawHive
where where
fallrot = case cr ^? crStance . carriage . carDir of fallrot = case cr ^? crStance . carriage . carDir of
@@ -57,7 +57,7 @@ drawCreature w m cr = translateSP (_crPos cr) . fallrot . rotateSP (_crDir cr) $
drawSlimeCrit :: Creature -> Shape drawSlimeCrit :: Creature -> Shape
drawSlimeCrit cr = colorSH green drawSlimeCrit cr = colorSH green
$ upperPrismPolyHalf Medium Typical (cr ^?! crType . slimeFeedProgress + min 10 r) $ polyCirc 6 r $ upperPrismPolyHalf Medium Typical (cr ^?! crType . slimeEngulfProgress + min 15 r) $ polyCirc 6 r
& each %~ scaleAlong d s & each %~ scaleAlong d s
& each %~ scaleAlong (vNormal d) (1 / s) & each %~ scaleAlong (vNormal d) (1 / s)
& each %~ rotateV (-cr ^. crDir) & each %~ rotateV (-cr ^. crDir)
@@ -119,13 +119,13 @@ drawHoverCrit cr = colorSH (_skinHead cskin)
drawHive :: SPic drawHive :: SPic
drawHive = noPic $ upperPrismPolyHalfMI 25 $ polyCirc 6 20 drawHive = noPic $ upperPrismPolyHalfMI 25 $ polyCirc 6 20
drawBeeCrit :: Float -> Shape drawBeeCrit :: Creature -> Shape
drawBeeCrit x = colorSH yellow drawBeeCrit cr = colorSH yellow
(upperPrismPolyHalfMI 3 $ polyCirc 6 r) (upperPrismPolyHalfMI 3 $ polyCirc 6 r)
<> <>
colorSH (dark yellow) (overPosSH (Q.apply (beakpos)) $ upperPrismPolyHalfST 1 $ [V2 0 (-2), V2 4 0,V2 0 2]) colorSH (dark yellow) (overPosSH (Q.apply (beakpos)) $ upperPrismPolyHalfST 1 $ [V2 0 (-2), V2 4 0,V2 0 2])
where where
r = sqrt $ 2 ^(2::Int) + x r = cr ^. crType . to crRad
beakpos = (V3 (r-1) 0 0, Q.qid) beakpos = (V3 (r-1) 0 0, Q.qid)
drawCrabCrit :: World -> Creature -> Shape drawCrabCrit :: World -> Creature -> Shape
@@ -278,7 +278,7 @@ makeCorpse g cr = case cr ^. crType of
HoverCrit{} -> noPic $ drawHoverCrit cr HoverCrit{} -> noPic $ drawHoverCrit cr
ChaseCrit{} -> noPic $ chaseCorpse g cr ChaseCrit{} -> noPic $ chaseCorpse g cr
CrabCrit{} -> noPic $ crabCorpse g cr CrabCrit{} -> noPic $ crabCorpse g cr
BeeCrit{} -> noPic $ drawBeeCrit 0 BeeCrit{} -> noPic $ drawBeeCrit cr
_ -> _ ->
noPic noPic
. scaleSH (V3 crsize crsize crsize) . scaleSH (V3 crsize crsize crsize)
+10 -5
View File
@@ -111,7 +111,11 @@ updateBeeCrit cr cid w
, Just x <- cr ^? crType . beeSlime , Just x <- cr ^? crType . beeSlime
, x >= 15 , x >= 15
= w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction = w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
& tocr . crStance . carriage .~ Flying 1 & tocr . crStance . carriage .~ Flying 0
| Just hcr <- gethive
, Just x <- cr ^? crType . beeSlime
, x >= 15
= w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
| Nothing <- cr ^? crActionPlan . apStrategy . harvestTarget | Nothing <- cr ^? crActionPlan . apStrategy . harvestTarget
, Just tcr <- find isslime $ crsNearCirc (cr ^. crPos . _xy) 100 w = , Just tcr <- find isslime $ crsNearCirc (cr ^. crPos . _xy) 100 w =
w & tocr . crActionPlan . apStrategy .~ HarvestFrom (tcr ^. crID) w & tocr . crActionPlan . apStrategy .~ HarvestFrom (tcr ^. crID)
@@ -120,12 +124,13 @@ updateBeeCrit cr cid w
& tocr . crStance . carriage .~ Mounted ti (cr ^. crPos - tcr ^. crPos) & tocr . crStance . carriage .~ Mounted ti (cr ^. crPos - tcr ^. crPos)
| Just tid <- cr ^? crStance . carriage . mountID | Just tid <- cr ^? crStance . carriage . mountID
, Just SlimeCrit{} <- w ^? cWorld . lWorld . creatures . ix tid . crType = w , Just SlimeCrit{} <- w ^? cWorld . lWorld . creatures . ix tid . crType = w
& tocr . crType . beeSlime +~ 0.5 & tocr . crType . beeSlime +~ sspeed
& cWorld . lWorld . creatures . ix tid . crType . slimeRad %~ (sqrt . subtract 0.5 . (^(2::Int))) & cWorld . lWorld . creatures . ix tid . crType . slimeRad %~ (sqrt . subtract sspeed . (^(2::Int)))
| Just (tcr,_) <- gettarg = w | Just (tcr,_) <- gettarg = w
& tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction & tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction
| otherwise = w & tocr . crActionPlan . apStrategy .~ Search | otherwise = w & tocr . crActionPlan . apStrategy .~ Search
where where
sspeed = 0.1
gettarg = do gettarg = do
i <- cr ^? crActionPlan . apStrategy . harvestTarget i <- cr ^? crActionPlan . apStrategy . harvestTarget
tcr <- w ^? cWorld . lWorld . creatures . ix i tcr <- w ^? cWorld . lWorld . creatures . ix i
@@ -159,7 +164,7 @@ slimeCritUpdate cid w
& cWorld . lWorld . creatures . ix cid . crDamage .~ [] & cWorld . lWorld . creatures . ix cid . crDamage .~ []
& tocr %~ doSlimeRadChange & tocr %~ doSlimeRadChange
& tocr . crType . slimeSplitTimer %~ (max 0 . subtract 1) & tocr . crType . slimeSplitTimer %~ (max 0 . subtract 1)
& tocr . crType . slimeFeedProgress %~ (max 0 . subtract 0.5) & tocr . crType . slimeEngulfProgress %~ (max 0 . subtract 0.5)
where where
tocr = cWorld . lWorld . creatures . ix cid tocr = cWorld . lWorld . creatures . ix cid
cr = w ^?! cWorld . lWorld . creatures . ix cid cr = w ^?! cWorld . lWorld . creatures . ix cid
@@ -233,7 +238,7 @@ splitSlimeCrit p v cr = do
& crType . slimeRad .~ r2 & crType . slimeRad .~ r2
& crType . slimeCompression .~ rotateV (argV (-mvdir)) (V2 r2 0) & crType . slimeCompression .~ rotateV (argV (-mvdir)) (V2 r2 0)
& crDir .~ argV (-mvdir) & crDir .~ argV (-mvdir)
& crType . slimeFeedProgress .~ 0 & crType . slimeEngulfProgress .~ 0
) )
where where
cxy = cr ^. crPos . _xy cxy = cr ^. crPos . _xy
+1 -1
View File
@@ -77,7 +77,7 @@ data CreatureType
, _slimeSplitTimer :: Int , _slimeSplitTimer :: Int
, _slimeCompression :: Point2 , _slimeCompression :: Point2
, _slimeIsCompressing :: Bool , _slimeIsCompressing :: Bool
, _slimeFeedProgress :: Float , _slimeEngulfProgress :: Float
} }
| BeeCrit | BeeCrit
{ _beeSlime :: Float { _beeSlime :: Float
+1
View File
@@ -43,6 +43,7 @@ tocrs = uvWorld . cWorld . lWorld . creatures
testStringInit :: Universe -> [String] testStringInit :: Universe -> [String]
testStringInit u = u ^.. tocrs . ix 2 . crType . hiveChildren . to show testStringInit u = u ^.. tocrs . ix 2 . crType . hiveChildren . to show
<> u ^.. tocrs . ix 3 . crStance . carriage . to show
-- u ^.. tocrs . ix 1 . crPos . _xy . to show -- u ^.. tocrs . ix 1 . crPos . _xy . to show
-- <> u ^.. tocrs . ix 1 . crType . slimeCompression . to show -- <> u ^.. tocrs . ix 1 . crType . slimeCompression . to show
-- <> u ^.. tocrs . ix 1 . crType . slimeCompression . to norm . to show -- <> u ^.. tocrs . ix 1 . crType . slimeCompression . to norm . to show
+2 -2
View File
@@ -1069,8 +1069,8 @@ slimeFood cr = case cr ^. crType of
feedSlime :: Creature -> Creature -> World -> World feedSlime :: Creature -> Creature -> World -> World
feedSlime s c w = fromMaybe w $ do feedSlime s c w = fromMaybe w $ do
ch <- crHeight c ch <- crHeight c
return $ if min 10 r1 + s ^?! crType . slimeFeedProgress < max 15 (ch + 2) return $ if min 10 r1 + s ^?! crType . slimeEngulfProgress < max 15 (ch + 2)
then w & cWorld . lWorld . creatures . ix (s ^. crID) . crType . slimeFeedProgress %~ (min r1 . (+0.7)) then w & cWorld.lWorld.creatures.ix (s^.crID).crType.slimeEngulfProgress%~ (min r1.(+0.7))
& slimeSuck s c & slimeSuck s c
else else
w w