Cleanup
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
module Dodge.Creature.Impulse
|
||||
( impulsiveAIR
|
||||
-- , impulsiveAI
|
||||
, impulsiveAI
|
||||
( impulsiveAI
|
||||
, followImpulses
|
||||
) where
|
||||
import Dodge.Data
|
||||
@@ -10,27 +8,13 @@ import Dodge.Creature.Impulse.Movement
|
||||
import Dodge.Creature.Impulse.UseItem
|
||||
import Dodge.SoundLogic
|
||||
import Geometry
|
||||
import LensHelp
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import System.Random
|
||||
import Control.Lens
|
||||
import Control.Monad.Reader
|
||||
import Data.Bifunctor
|
||||
--import Data.Maybe
|
||||
|
||||
impulsiveAIR
|
||||
:: (Creature -> Reader World Creature)
|
||||
-> Creature
|
||||
-> World
|
||||
-> (World -> World , Maybe Creature)
|
||||
impulsiveAIR impf cr w = second Just $ followImpulses w . ($ w) . runReader $ impf cr
|
||||
|
||||
--impulsiveAI :: (World -> Creature -> Creature)
|
||||
-- -> Creature
|
||||
-- -> World
|
||||
-- -> (World -> World , Maybe Creature)
|
||||
--impulsiveAI impf cr w = second Just $ followImpulses w $ impf w cr
|
||||
|
||||
impulsiveAI :: (World -> Creature -> Creature)
|
||||
-> Creature
|
||||
-> World
|
||||
@@ -56,14 +40,13 @@ followImpulse cr w imp = case imp of
|
||||
ChangePosture post -> (id, cr & crStance . posture .~ post)
|
||||
UseItem -> (tryUseItem cr, cr)
|
||||
SwitchToItem i -> (id, cr & crInvSel .~ i)
|
||||
Melee cid' ->
|
||||
(hitCr cid'
|
||||
, crMvBy (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crMeleeCooldown .~ 20) -- randomise cooldown?
|
||||
Melee cid' -> (hitCr cid'
|
||||
, crMvBy (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crMeleeCooldown .~ 20)
|
||||
RandomTurn a -> (id, creatureTurn (rr a) cr)
|
||||
MakeSound sid -> ( soundStart (CrSound (_crID cr)) (_crPos cr) sid Nothing , cr )
|
||||
DropItem -> undefined
|
||||
ChangeStrategy strat -> (id, cr & crActionPlan . crStrategy .~ strat)
|
||||
AddGoal gl -> (id, cr & crActionPlan . crGoal %~ (gl :) )
|
||||
AddGoal gl -> (id, cr & crActionPlan . crGoal .:~ gl )
|
||||
ArbitraryImpulseFunction f -> (id, f w cr)
|
||||
ArbitraryImpulse f -> followImpulse cr w (f cr w)
|
||||
ImpulseUseTargetCID f -> case cr ^? crIntention . targetCr . _Just of
|
||||
|
||||
Reference in New Issue
Block a user