Remove creature records

This commit is contained in:
2025-06-06 13:36:18 +01:00
parent 73c79f2f4d
commit 0f55257bff
48 changed files with 621 additions and 610 deletions
+4 -3
View File
@@ -36,6 +36,7 @@ module Dodge.Base.Collide (
) where
--import qualified Data.IntMap.Strict as IM
import Dodge.Creature.Radius
import Control.Lens
import qualified Data.IntSet as IS
import Data.List (sortOn)
@@ -64,7 +65,7 @@ overlapSegCrs ::
{-# INLINE overlapSegCrs #-}
overlapSegCrs sp ep =
mapMaybe
(\cr -> (,cr) <$> listToMaybe (intersectCircSeg (_crPos cr) (_crRad cr) sp ep))
(\cr -> (,cr) <$> listToMaybe (intersectCircSeg (_crPos cr) (crRad $ cr ^. crType) sp ep))
doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2, Point2)
{-# INLINE doBounce #-}
@@ -197,7 +198,7 @@ circOnAnyCr :: Point2 -> Float -> World -> Bool
{-# INLINE circOnAnyCr #-}
circOnAnyCr p r w = IS.foldr f False $ crIXsNearPoint p w
where
f cid bl = maybe False (\cr -> dist p (_crPos cr) < r + _crRad cr) (w ^? cWorld . lWorld . creatures . ix cid) || bl
f cid bl = maybe False (\cr -> dist p (_crPos cr) < r + crRad (cr ^. crType)) (w ^? cWorld . lWorld . creatures . ix cid) || bl
-- | More general collision tests follow
hasLOS :: Point2 -> Point2 -> World -> Bool
@@ -253,7 +254,7 @@ anythingHitCirc rad sp ep w = hitCr || circHitWall sp ep rad w
f cid bl =
maybe
False
(\cr -> intersectCircSegTest (_crPos cr) (rad + _crRad cr) sp ep)
(\cr -> intersectCircSegTest (_crPos cr) (rad + crRad (cr ^. crType)) sp ep)
(w ^? cWorld . lWorld . creatures . ix cid)
|| bl