Cleanup impulses/actions
This commit is contained in:
+67
-59
@@ -4,7 +4,7 @@ import Data.Maybe
|
||||
import Linear
|
||||
import Dodge.Creature.Radius
|
||||
import Control.Lens
|
||||
import Control.Monad.Reader
|
||||
--import Control.Monad.Reader
|
||||
import Dodge.Base
|
||||
import Dodge.Data.World
|
||||
import Geometry
|
||||
@@ -208,13 +208,21 @@ flockPointTarget ::
|
||||
World ->
|
||||
Creature ->
|
||||
Creature
|
||||
flockPointTarget f targFunc w cr = case targFunc cr w of
|
||||
Nothing -> cr
|
||||
Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
where
|
||||
is = _swarm $ _crGroup cr
|
||||
crs = IM.restrictKeys (w ^. cWorld . lWorld . creatures) is
|
||||
p = f crTarg crs cr
|
||||
flockPointTarget _ _ _ = id
|
||||
--flockPointTarget ::
|
||||
-- (Creature -> IM.IntMap Creature -> Creature -> Point2) ->
|
||||
-- -- | Function for determining target
|
||||
-- (Creature -> World -> Maybe Creature) ->
|
||||
-- World ->
|
||||
-- Creature ->
|
||||
-- Creature
|
||||
--flockPointTarget f targFunc w cr = case targFunc cr w of
|
||||
-- Nothing -> cr
|
||||
-- Just crTarg -> cr & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
-- where
|
||||
-- is = _swarm $ _crGroup cr
|
||||
-- crs = IM.restrictKeys (w ^. cWorld . lWorld . creatures) is
|
||||
-- p = f crTarg crs cr
|
||||
|
||||
--flockToPointUsing ::
|
||||
-- (Creature -> Point2 -> Creature -> Point2) ->
|
||||
@@ -229,60 +237,60 @@ flockPointTarget f targFunc w cr = case targFunc cr w of
|
||||
-- -- crGroupCenter $ _creatureGroups (_cWorld w) IM.! _crGroupID (_crGroup cr)
|
||||
-- ptarg = pf tcr cenp cr
|
||||
|
||||
flockToPointUsing' ::
|
||||
(Creature -> Point2 -> Creature -> Point2) ->
|
||||
(Point2 -> Creature -> Creature -> [Impulse]) ->
|
||||
World ->
|
||||
Creature ->
|
||||
Creature
|
||||
flockToPointUsing' pf mvf w cr = fromMaybe cr $ do
|
||||
i <- _targetCr $ _crIntention cr
|
||||
tcr <- w ^? cWorld . lWorld . creatures . ix i
|
||||
let ptarg = pf tcr cenp cr
|
||||
return $ cr -- & crActionPlan . apImpulse .~ mvf ptarg cr tcr
|
||||
where
|
||||
cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
|
||||
--flockToPointUsing' ::
|
||||
-- (Creature -> Point2 -> Creature -> Point2) ->
|
||||
-- (Point2 -> Creature -> Creature -> [Impulse]) ->
|
||||
-- World ->
|
||||
-- Creature ->
|
||||
-- Creature
|
||||
--flockToPointUsing' pf mvf w cr = fromMaybe cr $ do
|
||||
-- i <- _targetCr $ _crIntention cr
|
||||
-- tcr <- w ^? cWorld . lWorld . creatures . ix i
|
||||
-- let ptarg = pf tcr cenp cr
|
||||
-- return $ cr -- & crActionPlan . apImpulse .~ mvf ptarg cr tcr
|
||||
-- where
|
||||
-- cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
|
||||
|
||||
flockFunc ::
|
||||
(Creature -> Point2 -> Creature -> Point2) ->
|
||||
-- | Function for determining target
|
||||
(Creature -> World -> Maybe Creature) ->
|
||||
Creature ->
|
||||
Reader World Creature
|
||||
flockFunc f targFunc cr = reader $ \w -> case targFunc cr w of
|
||||
Nothing -> cr
|
||||
Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
where
|
||||
cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
|
||||
p = f crTarg cenp cr
|
||||
--flockFunc ::
|
||||
-- (Creature -> Point2 -> Creature -> Point2) ->
|
||||
-- -- | Function for determining target
|
||||
-- (Creature -> World -> Maybe Creature) ->
|
||||
-- Creature ->
|
||||
-- Reader World Creature
|
||||
--flockFunc f targFunc cr = reader $ \w -> case targFunc cr w of
|
||||
-- Nothing -> cr
|
||||
-- Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
-- where
|
||||
-- cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
|
||||
-- p = f crTarg cenp cr
|
||||
|
||||
flockCenterFunc ::
|
||||
(Creature -> Point2 -> Creature -> Point2) ->
|
||||
-- | Function for determining target
|
||||
(Creature -> World -> Maybe Creature) ->
|
||||
Creature ->
|
||||
Reader World Creature
|
||||
flockCenterFunc f targFunc cr = reader $ \w -> case targFunc cr w of
|
||||
Nothing -> cr
|
||||
Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
where
|
||||
cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
|
||||
p = f crTarg cenp cr
|
||||
--flockCenterFunc ::
|
||||
-- (Creature -> Point2 -> Creature -> Point2) ->
|
||||
-- -- | Function for determining target
|
||||
-- (Creature -> World -> Maybe Creature) ->
|
||||
-- Creature ->
|
||||
-- Reader World Creature
|
||||
--flockCenterFunc f targFunc cr = reader $ \w -> case targFunc cr w of
|
||||
-- Nothing -> cr
|
||||
-- Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
-- where
|
||||
-- cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
|
||||
-- p = f crTarg cenp cr
|
||||
|
||||
flockPointTargetR ::
|
||||
(Creature -> IM.IntMap Creature -> Creature -> Point2) ->
|
||||
-- | Function for determining target
|
||||
(Creature -> World -> Maybe Creature) ->
|
||||
Creature ->
|
||||
Reader World Creature
|
||||
flockPointTargetR f targFunc cr = reader $ \w -> case targFunc cr w of
|
||||
Nothing -> cr
|
||||
Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
where
|
||||
is = _swarm $ _crGroup cr
|
||||
--crs = IM.restrictKeys (_creatures (_cWorld w)) is
|
||||
crs = IM.restrictKeys (w ^. cWorld . lWorld . creatures) is
|
||||
p = f crTarg crs cr
|
||||
--flockPointTargetR ::
|
||||
-- (Creature -> IM.IntMap Creature -> Creature -> Point2) ->
|
||||
-- -- | Function for determining target
|
||||
-- (Creature -> World -> Maybe Creature) ->
|
||||
-- Creature ->
|
||||
-- Reader World Creature
|
||||
--flockPointTargetR f targFunc cr = reader $ \w -> case targFunc cr w of
|
||||
-- Nothing -> cr
|
||||
-- Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
-- where
|
||||
-- is = _swarm $ _crGroup cr
|
||||
-- --crs = IM.restrictKeys (_creatures (_cWorld w)) is
|
||||
-- crs = IM.restrictKeys (w ^. cWorld . lWorld . creatures) is
|
||||
-- p = f crTarg crs cr
|
||||
|
||||
meleeHeadingMove ::
|
||||
-- | max turn speed
|
||||
|
||||
Reference in New Issue
Block a user