From 371a54cbd731638899592bcd1131be5285b7c579 Mon Sep 17 00:00:00 2001 From: nek0 Date: Fri, 15 Feb 2019 20:02:34 +0100 Subject: [PATCH] enable collision for doors, but exclude it from pathfinding --- src/MainGame/WorldMap.hs | 8 +++++--- src/NPC.hs | 1 + src/Types/Entity.hs | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/MainGame/WorldMap.hs b/src/MainGame/WorldMap.hs index 079e7c4..830de5b 100644 --- a/src/MainGame/WorldMap.hs +++ b/src/MainGame/WorldMap.hs @@ -292,9 +292,11 @@ loadMapFork ud ad future progress = do | head wall == V2 1 0 || head wall == V2 (-1) 0 = NW | otherwise = error ("strange wall: " ++ show wall) void $ createEntity $ newEntity - { pos = Just (fmap ((+ 0.5) . fromIntegral) coord) - , clearanceLvl = Just (maximum $ 0 : Prelude.map clearance (Prelude.map snd rooms)) - , anim = Just $ AnimState (AnimId AnimDoor0 "shut" orientation) 0 0 + { pos = Just (fmap ((+ 0.5) . fromIntegral) coord) + , clearanceLvl = Just (maximum $ 0 : Prelude.map clearance (Prelude.map snd rooms)) + , anim = Just $ AnimState (AnimId AnimDoor0 "shut" orientation) 0 0 + , obstacle = Just $ Boundaries (4/9, 0) (5/9, 1) + , ignoreObstacle = Just () } ) doors liftIO $ modifyMVar_ progress (return . (\(p, _) -> diff --git a/src/NPC.hs b/src/NPC.hs index 2733ad6..318625a 100644 --- a/src/NPC.hs +++ b/src/NPC.hs @@ -35,6 +35,7 @@ getPosBounds = do efor allEnts $ do with pos with obstacle + without ignoreObstacle pos' <- query pos bnds <- query obstacle return (pos', bnds) diff --git a/src/Types/Entity.hs b/src/Types/Entity.hs index 7662602..a58a961 100644 --- a/src/Types/Entity.hs +++ b/src/Types/Entity.hs @@ -21,6 +21,7 @@ data Entity f = Entity , velFact :: Component f 'Field Double , rot :: Component f 'Field Direction , obstacle :: Component f 'Field (Boundaries Double) + , ignoreObstacle :: Component f 'Field () , player :: Component f 'Unique () , npcMoveState :: Component f 'Field NPCMoveState , npcWorkplace :: Component f 'Field ReachPoint