Cleanup, redo damage direction

This commit is contained in:
2025-06-08 20:40:58 +01:00
parent 5b1e4fba4e
commit 70c78824f3
12 changed files with 105 additions and 147 deletions
+6
View File
@@ -11,6 +11,7 @@ module Dodge.Zoning.Base
, zonesAroundPoint
, xIntercepts
, yIntercepts'
, updateInt2Map
) where
import Control.Lens
@@ -78,6 +79,7 @@ yIntercepts' s sp ep = map f $ xIntercepts s (f sp) (f ep)
where
f (V2 x y) = V2 y x
-- consider using: at x . non mempty . at y . non mempty <>~ a
zoneMonoid :: Semigroup m => Int2 -> m -> IM.IntMap (IM.IntMap m) -> IM.IntMap (IM.IntMap m)
{-# INLINE zoneMonoid #-}
zoneMonoid (V2 !x !y) a = IM.insertWith f x $! IM.singleton y a
@@ -87,6 +89,10 @@ zoneMonoid (V2 !x !y) a = IM.insertWith f x $! IM.singleton y a
deZoneIX :: Int -> IM.IntMap (IM.IntMap IS.IntSet) -> Int2 -> IM.IntMap (IM.IntMap IS.IntSet)
deZoneIX i im (V2 x y) = im & ix x . ix y %~ IS.delete i
updateInt2Map :: (Eq a,Monoid a) =>
(a -> a) -> Int2 -> IM.IntMap (IM.IntMap a) -> IM.IntMap (IM.IntMap a)
updateInt2Map f (V2 x y) = at x . non mempty . at y . non mempty %~ f
zonesAroundPoint :: Float -> Point2 -> [Int2]
zonesAroundPoint s p = [V2 a b | a <- [x -1 .. x + 1], b <- [y -1 .. y + 1]]
where