First implementation of creatures detecting sounds
This commit is contained in:
@@ -10,7 +10,7 @@ import Dodge.Creature.Memory.Data
|
||||
import Dodge.Base.Collide
|
||||
import Geometry.Vector
|
||||
--import Geometry.Data
|
||||
--import Sound.Data
|
||||
import Sound.Data
|
||||
--import StrictHelp
|
||||
|
||||
import Data.Maybe
|
||||
@@ -88,12 +88,11 @@ awakeLevelPerception cr = case _crAwakeLevel $ _crPerception cr of
|
||||
Overstrung -> 10000
|
||||
|
||||
newSounds :: World -> [(Point2,Float)]
|
||||
newSounds = mapMaybe f . M.elems . _sounds
|
||||
newSounds = mapMaybe f . M.elems . _playingSounds
|
||||
where
|
||||
f s = Just (_soundPos s, _soundVolume s)
|
||||
-- f s | _soundStatus s == JustStartedPlaying
|
||||
-- = Just (_soundPos s, _soundVolume s)
|
||||
-- | otherwise = Nothing
|
||||
f s | _soundStatus s == JustStartedPlaying
|
||||
= Just (_soundPos s, _soundVolume s)
|
||||
| otherwise = Nothing
|
||||
|
||||
rememberSounds :: Creature -> Reader World Creature
|
||||
rememberSounds cr = do
|
||||
@@ -102,4 +101,4 @@ rememberSounds cr = do
|
||||
-- return $ cr & crMemory . soundsToInvestigate .~ [V2 0 0]
|
||||
|
||||
soundIsClose :: Creature -> (Point2,Float) -> Bool
|
||||
soundIsClose cr (pos,vol) = True -- vol > (_auDist . _crAudition $ _crPerception cr) (dist pos (_crPos cr))
|
||||
soundIsClose cr (pos,vol) = vol > (_auDist . _crAudition $ _crPerception cr) (dist pos (_crPos cr))
|
||||
|
||||
@@ -66,7 +66,7 @@ creatureDisplayText w cr
|
||||
(V2 x y) = campos +.+ v +.+ _crRad cr *.* normalizeV v
|
||||
|
||||
creatureDisplayString :: Creature -> String
|
||||
creatureDisplayString cr = show . _soundsToInvestigate $ _crMemory cr
|
||||
creatureDisplayString cr = show . take 1 . _soundsToInvestigate $ _crMemory cr
|
||||
-- | isAsleep = "Z"
|
||||
-- | isSuspicious = "?"
|
||||
-- | otherwise = ""
|
||||
|
||||
@@ -47,7 +47,9 @@ tryMeleeAttack cr tcr
|
||||
setMvPos :: Creature -> Reader World Creature
|
||||
setMvPos cr = pure $ cr & crMvTarget .~ mpos
|
||||
where
|
||||
mpos = (_crPos <$> _crTarget cr) <|> listToMaybe (_soundsToInvestigate $ _crMemory cr)
|
||||
mpos = (_crPos <$> _crTarget cr)
|
||||
<|> _crMvTarget cr
|
||||
<|> listToMaybe (_soundsToInvestigate $ _crMemory cr)
|
||||
|
||||
setTargetMv
|
||||
:: (Creature -> Reader World (Maybe Creature)) -- ^ Function for determining target
|
||||
|
||||
Reference in New Issue
Block a user