From db24b0ffa6eaf15e0c29911f51d83c71a62ccaf4 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 3 Feb 2026 13:48:15 +0000 Subject: [PATCH] Use circles instead of points for zome wall zones --- src/Dodge/Base/Collide.hs | 2 +- src/Dodge/Debug/Picture.hs | 2 +- src/Dodge/Update.hs | 4 +++- src/Dodge/Update/Camera.hs | 3 ++- src/Dodge/Update/Cloud.hs | 1 + src/Dodge/WallCreatureCollisions.hs | 2 +- src/Dodge/Zoning/Base.hs | 2 +- src/Dodge/Zoning/Creature.hs | 2 +- 8 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Dodge/Base/Collide.hs b/src/Dodge/Base/Collide.hs index 9cc734d3b..5e9f9d662 100644 --- a/src/Dodge/Base/Collide.hs +++ b/src/Dodge/Base/Collide.hs @@ -287,7 +287,7 @@ circOnSomeWall :: Point2 -> Float -> World -> Bool {-# INLINE circOnSomeWall #-} circOnSomeWall p rad = any (uncurry (circOnSeg p rad) . _wlLine) - . wlsNearPoint p + . wlsNearCirc p rad circOnAnyCr :: Point2 -> Float -> World -> Bool {-# INLINE circOnAnyCr #-} diff --git a/src/Dodge/Debug/Picture.hs b/src/Dodge/Debug/Picture.hs index 508648c48..9ff82f91f 100644 --- a/src/Dodge/Debug/Picture.hs +++ b/src/Dodge/Debug/Picture.hs @@ -223,7 +223,7 @@ drawPathBetween u = concat $ do drawWallsNearYou :: World -> Picture drawWallsNearYou w = concat $ do p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy - return $ setLayer DebugLayer $ foldMap f $ wlsNearPoint p w + return $ setLayer DebugLayer $ foldMap f $ wlsNearCirc p 30 w where f wl = color violet $ thickLine 3 [a, b] <> uncurryV translate (0.5 *^ (a + b)) (scale 0.05 0.05 . text $ show (_wlID wl)) diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 812e64404..2ea4f46f0 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -912,7 +912,9 @@ simpleCrSprings w = -- note that this may in rare cases not push creatures away from each other crSpring :: Creature -> World -> World -crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearPoint (c ^. crPos . _xy) w +--crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearPoint (c ^. crPos . _xy) w +crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearCirc (c ^. crPos . _xy) + (crRad $ c ^. crType) w crCrSpring :: Creature -> Creature -> World -> World crCrSpring c1 c2 diff --git a/src/Dodge/Update/Camera.hs b/src/Dodge/Update/Camera.hs index 154f08391..dc15c15ba 100644 --- a/src/Dodge/Update/Camera.hs +++ b/src/Dodge/Update/Camera.hs @@ -218,9 +218,10 @@ rotateToOverlappingWall w = maybe id (doWallRotate . snd) - (overlapCircWallsClosest p (crRad (cr ^. crType) + 10) (filter _wlRotateTo $ wlsNearPoint p w)) + (overlapCircWallsClosest p r (filter _wlRotateTo $ wlsNearCirc p r w)) w where + r = (crRad (cr ^. crType) + 10) cr = you w p = you w ^. crPos . _xy diff --git a/src/Dodge/Update/Cloud.hs b/src/Dodge/Update/Cloud.hs index ae8ba0983..516578e4e 100644 --- a/src/Dodge/Update/Cloud.hs +++ b/src/Dodge/Update/Cloud.hs @@ -9,6 +9,7 @@ import LensHelp import Linear cloudPoisonDamage :: Gas -> World -> World +-- should probably use crsNearCirc cloudPoisonDamage c w = foldl' (flip doDam) w (filter f $ crsNearPoint clpos w) where doDam cr = diff --git a/src/Dodge/WallCreatureCollisions.hs b/src/Dodge/WallCreatureCollisions.hs index 612bdfed8..64b9f42e8 100644 --- a/src/Dodge/WallCreatureCollisions.hs +++ b/src/Dodge/WallCreatureCollisions.hs @@ -90,7 +90,7 @@ crOnWall :: Creature -> World -> Bool crOnWall cr = any (uncurry (circOnSeg p r) . _wlLine) . filter notff - . wlsNearPoint p + . wlsNearCirc p r where notff x = x ^. wlMaterial /= ForceField p = cr ^. crPos . _xy diff --git a/src/Dodge/Zoning/Base.hs b/src/Dodge/Zoning/Base.hs index 8ff2769f0..dc81696a8 100644 --- a/src/Dodge/Zoning/Base.hs +++ b/src/Dodge/Zoning/Base.hs @@ -25,7 +25,7 @@ import qualified IntMapHelp as IM zoneOfCirc :: Float -> Point2 -> Float -> [Int2] {-# INLINE zoneOfCirc #-} -zoneOfCirc zsize p r = zoneOfRect zsize (p +.+ V2 r r) (p -.- V2 r r) +zoneOfCirc zsize p r = zoneOfRect zsize (p + V2 r r) (p - V2 r r) zoneOfRect :: Float -> Point2 -> Point2 -> [Int2] {-# INLINE zoneOfRect #-} diff --git a/src/Dodge/Zoning/Creature.hs b/src/Dodge/Zoning/Creature.hs index 842493ebb..e9232dcbb 100644 --- a/src/Dodge/Zoning/Creature.hs +++ b/src/Dodge/Zoning/Creature.hs @@ -31,7 +31,7 @@ crixsNearSeg :: Point2 -> Point2 -> World -> IS.IntSet crixsNearSeg = nearSeg crZoneSize _crZoning crIXsNearCirc :: Point2 -> Float -> World -> IS.IntSet -crIXsNearCirc p r = crsNearRect (p +.+ V2 r r) (p -.- V2 r r) +crIXsNearCirc p r = crsNearRect (p + V2 r r) (p - V2 r r) crsNearCirc :: Point2 -> Float -> World -> [Creature] crsNearCirc p r w = mapMaybe (\cid -> w ^? cWorld . lWorld . creatures . ix cid) . IS.toList