Cleanup warnings
This commit is contained in:
@@ -3,7 +3,7 @@ module Dodge.Creature.Rationality
|
||||
import Dodge.Data
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.Creature.Action.UseItem
|
||||
--import Dodge.Creature.Action.UseItem
|
||||
import Dodge.Creature.State.Data
|
||||
import Dodge.Creature.Stance.Data
|
||||
import Dodge.SoundLogic
|
||||
@@ -15,8 +15,6 @@ import System.Random
|
||||
import Control.Lens
|
||||
import Control.Monad.Reader
|
||||
|
||||
-- Alternatives would probably be a very good fit for actions...
|
||||
|
||||
composeInternalAIs
|
||||
:: [World -> Creature -> Creature]
|
||||
-> World
|
||||
@@ -40,13 +38,14 @@ impulsiveAI
|
||||
-> ((World -> World,StdGen), Maybe Creature)
|
||||
impulsiveAI impF w (f,g) = followImpulses w (f,g) . impF w
|
||||
|
||||
-- needs cleanup
|
||||
followImpulses
|
||||
:: World
|
||||
-> (World -> World,StdGen)
|
||||
-> Creature
|
||||
-> ((World -> World,StdGen), Maybe Creature)
|
||||
followImpulses w (f,g) cr
|
||||
= (\(f''' ,cr) -> ((f''',g'),Just cr))
|
||||
= (\(f''' ,cr') -> ((f''',g'),Just cr'))
|
||||
$ foldr
|
||||
(\imp (f' , cr') -> let (f'', cr'') = followImpulse cr' w imp in (f'' . f', cr''))
|
||||
(f, cr)
|
||||
@@ -68,9 +67,9 @@ followImpulse cr w imp = case imp of
|
||||
ChangePosture post -> (id, cr & crStance . posture .~ post)
|
||||
UseItem -> (crUseItem cr, cr)
|
||||
SwitchToItem i -> (id, cr & crInvSel .~ i)
|
||||
Melee crID ->
|
||||
(hitCr crID
|
||||
, crMvBy (10 *.* normalizeV (posFromID crID -.- cpos)) $ cr & crMeleeCooldown ?~ 20) -- randomise cooldown?
|
||||
Melee cid ->
|
||||
(hitCr cid
|
||||
, crMvBy (10 *.* normalizeV (posFromID cid -.- cpos)) $ cr & crMeleeCooldown ?~ 20) -- randomise cooldown?
|
||||
RandomTurn a -> (id, creatureTurn (rr a) cr)
|
||||
MakeSound sid -> ( soundOnceOrigin sid (CrSound (_crID cr)) (_crPos cr) , cr )
|
||||
DropItem -> undefined
|
||||
@@ -101,18 +100,6 @@ actionUpdateAI
|
||||
-> Creature
|
||||
actionUpdateAI actF w c = performActions w $ actF w c
|
||||
|
||||
performActionR :: Creature -> Reader World Creature
|
||||
performActionR cr = reader $ \w -> performActions w cr
|
||||
|
||||
watchUpdateStratR
|
||||
:: [ ((World, Creature) -> Bool, World -> Creature -> Strategy) ]
|
||||
-> Creature
|
||||
-> Reader World Creature
|
||||
watchUpdateStratR fs cr = case cr ^? crActionPlan . crStrategy of
|
||||
Just WatchAndWait -> reader $ \w -> cr
|
||||
& crActionPlan . crStrategy .~ listGuard (fs, \_ _ -> WatchAndWait) (w, cr) w cr
|
||||
_ -> reader $ \_ -> cr
|
||||
|
||||
listGuard :: ([(a -> Bool, b)] , b) -> a -> b
|
||||
listGuard ( (test,y):ps, z ) x
|
||||
| test x = y
|
||||
@@ -126,6 +113,10 @@ performActions w cr = cr
|
||||
where
|
||||
(iss, mayas) = unzip $ map (performAction cr w) $ cr ^. crActionPlan . crAction
|
||||
|
||||
performActionsR :: Creature -> Reader World Creature
|
||||
performActionsR cr = reader $ \w -> performActions w cr
|
||||
|
||||
|
||||
{- | Performing an action means that a creature has some impulses for a frame, and
|
||||
updates or deletes the action itself. -}
|
||||
performAction
|
||||
@@ -154,24 +145,24 @@ performAction cr w ac = case ac of
|
||||
DoImpulses imps -> (imps, Nothing)
|
||||
DrawWeapon -> ([ChangePosture Aiming, MakeSound pickUpSound] , Nothing)
|
||||
HolsterWeapon -> ([ChangePosture AtEase, MakeSound putDownSound] , Nothing)
|
||||
DoActionThen ac ac' -> case performAction cr w ac of
|
||||
(imps , Just ac'') -> (imps, Just (DoActionThen ac'' ac'))
|
||||
(imps , Nothing ) -> (imps, Just ac')
|
||||
DoActionWhile f ac -> performAction cr w $ DoActionWhilePartial ac f ac
|
||||
DoActionThen fsta afta -> case performAction cr w fsta of
|
||||
(imps , Just nxta) -> (imps, Just (DoActionThen nxta afta))
|
||||
(imps , Nothing ) -> (imps, Just afta)
|
||||
DoActionWhile f repa -> performAction cr w $ DoActionWhilePartial repa f repa
|
||||
DoActionWhilePartial partAc f resetAc
|
||||
| f (w,cr) -> case performAction cr w partAc of
|
||||
(imps, Just ac) -> (imps, Just $ DoActionWhilePartial ac f resetAc)
|
||||
(imps, Just nxta) -> (imps, Just $ DoActionWhilePartial nxta f resetAc)
|
||||
(imps, _) -> (imps, Just $ DoActionWhilePartial resetAc f resetAc)
|
||||
| otherwise -> performAction cr w partAc
|
||||
DoActionIf f ac
|
||||
| f (w,cr) -> performAction cr w ac
|
||||
DoActionIf f ifa
|
||||
| f (w,cr) -> performAction cr w ifa
|
||||
| otherwise -> ([],Nothing)
|
||||
DoActionIfElse ac f ac'
|
||||
| f (w,cr) -> performAction cr w ac
|
||||
| otherwise -> performAction cr w ac'
|
||||
DoActionWhileThen ac f ac'
|
||||
| f (w,cr) -> (fst $ performAction cr w ac, Just $ DoActionWhileThen ac f ac')
|
||||
| otherwise -> performAction cr w ac'
|
||||
DoActionIfElse ifa f elsea
|
||||
| f (w,cr) -> performAction cr w ifa
|
||||
| otherwise -> performAction cr w elsea
|
||||
DoActionWhileInterrupt repa f afta
|
||||
| f (w,cr) -> (fst $ performAction cr w repa, Just $ DoActionWhileInterrupt repa f afta)
|
||||
| otherwise -> performAction cr w afta
|
||||
DoActions [] -> ([], Nothing)
|
||||
DoActions acs ->
|
||||
let (imps, newAcs) = unzip $ map (performAction cr w) acs
|
||||
|
||||
Reference in New Issue
Block a user