diff options
author | Griffin Smith <root@gws.fyi> | 2020-05-16T22·57-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2020-05-16T22·57-0400 |
commit | 15b4f0e6a73987f9afbc46f46862b5120029e715 (patch) | |
tree | 780f05b979e2d01f473ea6a75cb7fc9242cc0b68 /src/Xanthous/Game/Lenses.hs | |
parent | 34cabba896507f2b6523d6aec344ec1c88e453be (diff) |
Stop auto-moving if there's an enemy nearby
If at any point during an auto-move there's an enemy in the character's line of sight, cancel the autocommand and send a message
Diffstat (limited to 'src/Xanthous/Game/Lenses.hs')
-rw-r--r-- | src/Xanthous/Game/Lenses.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Xanthous/Game/Lenses.hs b/src/Xanthous/Game/Lenses.hs index 48b7235d2263..5d5e673c5b88 100644 --- a/src/Xanthous/Game/Lenses.hs +++ b/src/Xanthous/Game/Lenses.hs @@ -8,6 +8,7 @@ module Xanthous.Game.Lenses , characterPosition , updateCharacterVision , characterVisiblePositions + , characterVisibleEntities , getInitialState , initialStateFromSeed , entitiesAtCharacter @@ -28,7 +29,8 @@ import Xanthous.Game.State import Xanthous.Data import Xanthous.Data.Levels import qualified Xanthous.Data.EntityMap as EntityMap -import Xanthous.Data.EntityMap.Graphics (visiblePositions) +import Xanthous.Data.EntityMap.Graphics + (visiblePositions, visibleEntities) import Xanthous.Data.VectorBag import Xanthous.Entities.Character (Character, mkCharacter) import {-# SOURCE #-} Xanthous.Entities.Entities () @@ -101,6 +103,11 @@ characterVisiblePositions game = let charPos = game ^. characterPosition in visiblePositions charPos visionRadius $ game ^. entities +characterVisibleEntities :: GameState -> EntityMap.EntityMap SomeEntity +characterVisibleEntities game = + let charPos = game ^. characterPosition + in visibleEntities charPos visionRadius $ game ^. entities + entitiesCollision :: ( Functor f , forall xx. MonoFoldable (f xx) |