module Dodge.Creature.SwarmCrit
    ( swarmCrit
    )
    where
import Dodge.Data
import Dodge.Default
import Dodge.Creature.Picture
import Dodge.Creature.Boid
import Dodge.Creature.ReaderUpdate
import Dodge.Creature.Perception
import Dodge.Creature.Impulse
import Dodge.Creature.State
import Dodge.Picture.Layer
import Picture

import Control.Lens
import Control.Monad.Reader

swarmCrit :: Creature
swarmCrit = defaultCreature
    { _crUpdate = stateUpdate $ impulsiveAIR $
        flockToPointUsing (encircleDistP 100) (meleeHeadingMove 0.1 0.1 (pi/4) 3.9)
        >=> return . (crMeleeCooldown %~ max 0 . subtract 1)
        >=> perceptionUpdate [0]
        >=> doStrategyActionsR
        >=> targetYouWhenCognizantR
--        , doStrategyActions
--        , targetYouWhenCognizant
        
    , _crHP = 1
    , _crRad = 2
    , _crMass = 2
    , _crPict = basicCrPict yellow
    , _crCorpse = onLayer CorpseLayer $ color (greyN 0.5) $ circleSolid 2
    , _crFaction = ColorFaction yellow
    , _crMeleeCooldown = 0
    }

--swarmCritMoveFunc :: Creature -> Point2 -> Creature -> Point2
--swarmCritMoveFunc tcr cenp cr 
--    | targBehindCrit 
--  where
--    cpos = _crPos cr
--    ypos = _crPos tcr


