Add bee random movement
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
|
||||
module Dodge.Creature.Impulse (followImpulse) where
|
||||
|
||||
import RandomHelp
|
||||
import Control.Applicative
|
||||
import Control.Monad.Trans.State.Lazy
|
||||
--import Control.Monad.Trans.State.Lazy
|
||||
--import Control.Monad.State -- moving from mtl to transformers
|
||||
import Data.Maybe
|
||||
import Dodge.Creature.Impulse.Movement
|
||||
@@ -19,7 +20,7 @@ import Dodge.SoundLogic
|
||||
import Geometry
|
||||
import LensHelp
|
||||
import Linear
|
||||
import System.Random
|
||||
--import System.Random
|
||||
|
||||
-- note SwitchToItem doesn't necessarily update the root item correctly
|
||||
followImpulse :: Int -> World -> Impulse -> World
|
||||
@@ -75,6 +76,7 @@ followImpulse cid w = \case
|
||||
MvTurnToward p ->
|
||||
crup $
|
||||
mvTurnToward p (turnRad $ safeAngleVV (p -.- cpos) (unitVectorAtAngle cdir))
|
||||
SetBeeRandomMovement -> w & setBeeRandomMovement cid
|
||||
where
|
||||
clens = cWorld . lWorld . creatures . ix cid
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||
@@ -97,3 +99,14 @@ followImpulse cid w = \case
|
||||
<>~ [Blunt 100 (posFromID i) (posFromID i - cpos) (CrMeleeO cid)
|
||||
, Inertial 0 (posFromID i) (50 * unitVectorAtAngle (cr ^. crDir + a)) (CrMeleeO cid)
|
||||
]
|
||||
|
||||
setBeeRandomMovement :: Int -> World -> World
|
||||
setBeeRandomMovement cid w = fromMaybe w $ do
|
||||
mff <- w ^? cWorld . lWorld . creatures . ix cid . crType . beeRandomMovement
|
||||
return $ case mff of
|
||||
Just _ -> w & cWorld . lWorld . creatures . ix cid . crType . beeRandomMovement .~ Nothing
|
||||
Nothing -> w & cWorld . lWorld . creatures . ix cid . crType . beeRandomMovement .~ x
|
||||
& randGen .~ g
|
||||
where
|
||||
(x,g) = runState (takeOne [Nothing,Just LeftForward,Just RightForward]) (w ^. randGen)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user