From 84f32efad4ff6d358fdeb985b3b4ac408e753b78 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Fri, 3 Jan 2020 18:28:43 -0500 Subject: Track entity collision in the Entity class Rather than having a single function in the Game.Lenses module for determining what collision type if any an entity has, track it in the Entity typeclass itself. This is both more extensible and a better separation of concerns and gets rid of one of the two needs for a circular import. Yay! As part of this, I realized nothing was being done to prevent doors from being placed on tiles that already had walls (since now that was properly causing a collision!) so I've fixed that as well. --- src/Xanthous/AI/Gormlak.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Xanthous/AI/Gormlak.hs') diff --git a/src/Xanthous/AI/Gormlak.hs b/src/Xanthous/AI/Gormlak.hs index 031262533d21..8040fea35b8d 100644 --- a/src/Xanthous/AI/Gormlak.hs +++ b/src/Xanthous/AI/Gormlak.hs @@ -27,7 +27,7 @@ import qualified Xanthous.Entities.RawTypes as Raw import Xanthous.Entities.RawTypes (CreatureType) import Xanthous.Game.State import Xanthous.Game.Lenses - ( Collision(..), entityCollision, collisionAt + ( Collision(..), entitiesCollision, collisionAt , character, characterPosition ) import Xanthous.Data.EntityMap.Graphics (linesOfSight, canSee) @@ -90,7 +90,7 @@ stepGormlak ticks pe@(Positioned pos creature) = do then attackCharacter $> pos' else pure $ pos' `stepTowards` charPos else do - lines <- map (takeWhile (isNothing . entityCollision . map snd . snd) + lines <- map (takeWhile (isNothing . entitiesCollision . map snd . snd) -- the first item on these lines is always the creature itself . fromMaybe mempty . tailMay) . linesOfSight pos' (visionRadius creature') -- cgit 1.4.1