Simplify bee harvesting

This commit is contained in:
2026-05-05 09:43:17 +01:00
parent 1ec855c2fc
commit 62a9f34a26
+19 -22
View File
@@ -163,25 +163,12 @@ updateCalmBee cr cid w
, x < 0.5
, Just hcr <- gethive
, distance (cr ^. crPos . _xy) (hcr ^. crPos . _xy) < 30
, Just ReturnToHive <- cr ^? crActionPlan . apStrategy
= w & tocr . crActionPlan . apStrategy .~ Search
& tocr . crActionPlan . apAction .~ NoAction
| Just hcr <- gethive
, Just _ <- cr ^? crStance . carriage . mountID
, Just x <- cr ^? crType . beeSlime
, x >= 15
= w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
& tocr . crStance . carriage .~ Flying 0
& tocr . crActionPlan . apStrategy .~ ReturnToHive
, Just ReturnToHive <- cr ^? crActionPlan . apStrategy = startsearch
| Just ReturnToHive <- cr ^? crActionPlan . apStrategy = w
| Just x <- cr ^? crType . beeSlime
, x >= 15 = starthivereturn
| Just mid <- cr ^? crStance . carriage . mountID
, mountshakeoff mid = w
& tocr . crStance . carriage .~ Flying 0
& tocr . crActionPlan . apStrategy .~ Search
| Just hcr <- gethive
, Just x <- cr ^? crType . beeSlime
, x >= 15
= w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
& tocr . crActionPlan . apStrategy .~ ReturnToHive
, mountshakeoff mid = startsearch
| Nothing <- cr ^? crActionPlan . apStrategy . harvestTarget
, xs@(_:_) <- IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w
, (tcr,g') <- runState (takeOne xs) (w ^. randGen) =
@@ -200,15 +187,25 @@ updateCalmBee cr cid w
& tocr . crActionPlan . apAction .~ NoAction
| Just (tcr,_) <- gettarg = w
& tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction
| Just (SearchTimed 0) <- cr ^? crActionPlan . apStrategy
= w & tocr . crActionPlan . apStrategy .~ ReturnToHive
| Just (SearchTimed 0) <- cr ^? crActionPlan . apStrategy = starthivereturn
| Just PathTo{} <- cr ^? crActionPlan . apAction = w
& tocr . crActionPlan . apStrategy . searchTimer %~ (max 0 . subtract 1)
| otherwise = w
| otherwise = startsearch
where
starthivereturn = fromMaybe w $ do
hcr <- gethive
return $ w
& tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
& tocr . crActionPlan . apStrategy .~ ReturnToHive
& tocr . crStance . carriage %~ dounmount
dounmount x = case x of
Flying{} -> x
_ -> Flying 0
startsearch = w
& tocr . crActionPlan . apAction .~ PathTo (cxy + p) NoAction
& tocr . crStance . carriage %~ dounmount
& randGen .~ g
& tocr . crActionPlan . apStrategy .~ SearchTimed 200
where
(p,g) = runState (randOnCirc 200) (w ^. randGen)
cxy = cr ^. crPos . _xy
mountshakeoff mid = fromMaybe True $ do