Add stretch animation to feeding bees

This commit is contained in:
2026-04-29 20:21:20 +01:00
parent 39bc480c03
commit cfe34555b3
4 changed files with 10 additions and 30 deletions
-2
View File
@@ -12,7 +12,6 @@ module Dodge.Creature (
module Dodge.Creature.Perception, module Dodge.Creature.Perception,
module Dodge.Creature.ReaderUpdate, module Dodge.Creature.ReaderUpdate,
module Dodge.Creature.State, module Dodge.Creature.State,
module Dodge.Creature.Strategy,
module Dodge.Creature.Test, module Dodge.Creature.Test,
module Dodge.Creature.Volition, module Dodge.Creature.Volition,
module Dodge.Creature.YourControl, module Dodge.Creature.YourControl,
@@ -35,7 +34,6 @@ import Dodge.Creature.Perception
import Dodge.Creature.ReaderUpdate import Dodge.Creature.ReaderUpdate
import Dodge.Creature.SpreadGunCrit import Dodge.Creature.SpreadGunCrit
import Dodge.Creature.State import Dodge.Creature.State
import Dodge.Creature.Strategy
import Dodge.Creature.Test import Dodge.Creature.Test
import Dodge.Creature.Volition import Dodge.Creature.Volition
import Dodge.Creature.YourControl import Dodge.Creature.YourControl
+7 -1
View File
@@ -7,6 +7,7 @@ module Dodge.Creature.Picture (
drawCreature, drawCreature,
) where ) where
import Geometry.Zone
import Data.Foldable import Data.Foldable
import qualified Data.Strict.Tuple as ST import qualified Data.Strict.Tuple as ST
import RandomHelp import RandomHelp
@@ -121,7 +122,7 @@ drawHive = noPic $ upperPrismPolyHalfMI 25 $ polyCirc 6 20
drawBeeCrit :: Creature -> Shape drawBeeCrit :: Creature -> Shape
drawBeeCrit cr = colorSH col drawBeeCrit cr = colorSH col
(upperPrismPolyHalfMI 3 $ polyCirc 6 r) (f . upperPrismPolyHalfMI 3 $ polyCirc 6 r)
<> <>
colorSH (dark col) (overPosSH (Q.apply (beakpos)) $ upperPrismPolyHalfST 1 $ [V2 0 (-2), V2 4 0,V2 0 2]) colorSH (dark col) (overPosSH (Q.apply (beakpos)) $ upperPrismPolyHalfST 1 $ [V2 0 (-2), V2 4 0,V2 0 2])
where where
@@ -129,6 +130,11 @@ drawBeeCrit cr = colorSH col
beakpos = (V3 (r-1) 0 0, Q.qid) beakpos = (V3 (r-1) 0 0, Q.qid)
col | cr ^?! crType . beeAggro > 0 = red col | cr ^?! crType . beeAggro > 0 = red
| otherwise = yellow | otherwise = yellow
f | Mounted {} <- cr ^. crStance . carriage
= each . sfVs . each . _xy %~ scaleAlong (V2 0 1) (1 + g ( modTo 1 (cr ^?! crType . beeSlime)))
| otherwise = id
g x | x > 0.5 = 1 - x
| otherwise = x
drawCrabCrit :: World -> Creature -> Shape drawCrabCrit :: World -> Creature -> Shape
drawCrabCrit w cr = mconcat drawCrabCrit w cr = mconcat
-27
View File
@@ -1,27 +0,0 @@
module Dodge.Creature.Strategy (
goToPostStrat,
) where
import Data.List
import Dodge.Creature.Test
import Dodge.Creature.Volition
import Dodge.Data.Creature
goToPostStrat :: Creature -> Strategy
goToPostStrat cr = case find sentinelGoal $ _apGoal $ _crActionPlan cr of
Just (SentinelAt p _) ->
SetStrategyAction
(GetTo p)
( DoActionThen (WaitThen 150 holsterIfAiming) $
DoActionThen
(PathTo p NoAction)
NoAction
-- $ DoImpulses [ChangeStrategy WatchAndWait]
)
_ -> WatchAndWait
where
sentinelGoal (SentinelAt _ _) = True
sentinelGoal _ = False
holsterIfAiming
| crIsAiming cr = holsterWeapon
| otherwise = NoAction
+3
View File
@@ -128,10 +128,13 @@ updateAggroBee cr cid w
| Just tcr <- listToMaybe . sortOn (distance cxy . (^. crPos . _xy)) . IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w = w & tocr . crActionPlan . apStrategy .~ CloseToMelee (tcr ^. crID) | Just tcr <- listToMaybe . sortOn (distance cxy . (^. crPos . _xy)) . IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w = w & tocr . crActionPlan . apStrategy .~ CloseToMelee (tcr ^. crID)
& tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction & tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction
& tocr . crType . meleeCooldown %~ (max 0 . subtract 1) & tocr . crType . meleeCooldown %~ (max 0 . subtract 1)
| Just PathTo{} <- cr ^? crActionPlan . apAction = w & tocr . crType . beeAggro -~ 1
& tocr . crType . meleeCooldown %~ (max 0 . subtract 1)
| otherwise = w & tocr . crType . beeAggro -~ 1 | otherwise = w & tocr . crType . beeAggro -~ 1
& tocr . crActionPlan . apStrategy .~ Search & tocr . crActionPlan . apStrategy .~ Search
& tocr . crType . meleeCooldown %~ (max 0 . subtract 1) & tocr . crType . meleeCooldown %~ (max 0 . subtract 1)
where where
vdir = unitVectorAtAngle (cr ^. crDir) vdir = unitVectorAtAngle (cr ^. crDir)
cxy = cr ^. crPos . _xy cxy = cr ^. crPos . _xy
tocr = cWorld . lWorld . creatures . ix cid tocr = cWorld . lWorld . creatures . ix cid