Cleanup impulses/actions
This commit is contained in:
@@ -2,14 +2,12 @@
|
||||
|
||||
module Dodge.Creature.Impulse (followImpulses) where
|
||||
|
||||
import Dodge.Creature.Action
|
||||
import Data.Maybe
|
||||
import NewInt
|
||||
import Linear
|
||||
import Dodge.Creature.MoveType
|
||||
import Data.Foldable
|
||||
import Control.Monad.State
|
||||
import Data.Foldable
|
||||
import Data.Maybe
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.Creature.Impulse.Movement
|
||||
import Dodge.Creature.MoveType
|
||||
--import Dodge.Creature.Impulse.UseItem
|
||||
import Dodge.Creature.Vocalization
|
||||
import Dodge.CreatureEffect
|
||||
@@ -19,12 +17,14 @@ import Dodge.RandImpulse
|
||||
import Dodge.SoundLogic
|
||||
import Geometry
|
||||
import LensHelp
|
||||
import Linear
|
||||
import NewInt
|
||||
import System.Random
|
||||
|
||||
followImpulses :: Int -> World -> World
|
||||
followImpulses cid w = let (is,cr) = performActions w (w ^?! cWorld . lWorld . creatures . ix cid)
|
||||
in foldl' (followImpulse cid) (w & cWorld . lWorld . creatures . ix cid .~ cr)
|
||||
(reverse is)
|
||||
followImpulses cid w =
|
||||
let (is, cr) = performActions w (w ^?! cWorld . lWorld . creatures . ix cid)
|
||||
in foldl' (followImpulse cid) (w & cWorld . lWorld . creatures . ix cid .~ cr) is
|
||||
|
||||
-- note SwitchToItem doesn't necessarily update the root item correctly
|
||||
followImpulse :: Int -> World -> Impulse -> World
|
||||
@@ -33,22 +33,26 @@ followImpulse cid w imp = case imp of
|
||||
RandomImpulse rimp ->
|
||||
let (newimp, newgen) = runState (doRandImpulse rimp) (_randGen w)
|
||||
in randGen .~ newgen $ followImpulse cid w newimp
|
||||
Bark sid -> soundStart (CrMouth cid) cpos sid Nothing
|
||||
$ w & clens %~ resetCrVocCoolDown w
|
||||
Bark sid ->
|
||||
soundStart (CrMouth cid) cpos sid Nothing $
|
||||
w & clens %~ resetCrVocCoolDown w
|
||||
Move p -> crup $ crMvBy p (w ^. cWorld . lWorld)
|
||||
MoveForward x -> crup $ crMvForward x (w ^. cWorld . lWorld)
|
||||
MoveNoStride p -> crup $ crMvByNoStride p (w ^. cWorld . lWorld)
|
||||
Turn a -> crup $ crDir +~ a
|
||||
TurnToward p a -> crup $ creatureTurnToward p a
|
||||
TurnTo p -> crup $ creatureTurnTo p
|
||||
TurnTo p -> crup $ creatureTurnTo p
|
||||
ChangePosture post -> crup $ crStance . posture .~ post
|
||||
UseItem -> undefined
|
||||
SwitchToItem i -> crup $ crManipulation . manObject .~ SelectedItem (NInt i) (NInt i) mempty
|
||||
Melee cid' ->
|
||||
hitCr cid' $ crup (
|
||||
(crMvAbsolute (w ^. cWorld . lWorld) (10 *.* normalizeV (posFromID cid' -.- cpos))) . (crType . meleeCooldown .~ 20))
|
||||
RandomTurn a -> let (aa,g) = rr a
|
||||
in (randGen .~ g) (crup (crDir +~ aa))
|
||||
hitCr cid' $
|
||||
crup
|
||||
( (crMvAbsolute (w ^. cWorld . lWorld) (10 *.* normalizeV (posFromID cid' -.- cpos))) . (crType . meleeCooldown .~ 20)
|
||||
)
|
||||
RandomTurn a ->
|
||||
let (aa, g) = rr a
|
||||
in (randGen .~ g) (crup (crDir +~ aa))
|
||||
MakeSound sid -> soundStart (CrSound (_crID cr)) (cr ^. crPos . _xy) sid Nothing w
|
||||
DropItem -> undefined
|
||||
ChangeStrategy strat -> crup $ crActionPlan . apStrategy .~ strat
|
||||
@@ -73,5 +77,5 @@ followImpulse cid w imp = case imp of
|
||||
posFromID cid' = w ^?! cWorld . lWorld . creatures . ix cid' . crPos . _xy
|
||||
rr a = randomR (- a, a) $ _randGen w
|
||||
hitCr i =
|
||||
cWorld . lWorld . creatures . ix i . crDamage
|
||||
.:~ Blunt 100 (posFromID i) (posFromID i-cpos)
|
||||
cWorld . lWorld . creatures . ix i . crDamage
|
||||
.:~ Blunt 100 (posFromID i) (posFromID i - cpos)
|
||||
|
||||
Reference in New Issue
Block a user