Fix wall zoning
This commit is contained in:
+16
-9
@@ -6,19 +6,26 @@ import Dodge.Zone
|
||||
import Dodge.Base
|
||||
|
||||
import Control.Lens
|
||||
import Data.Foldable
|
||||
--import Data.Foldable
|
||||
import Streaming
|
||||
import qualified Streaming.Prelude as S
|
||||
|
||||
zoneOfWall :: Wall -> [(Int,Int)]
|
||||
zoneOfWall wl
|
||||
| uncurry dist wlline <= 2*zoneSize = [zoneOfPoint $ uncurry midPoint wlline ]
|
||||
| otherwise = map zoneOfPoint $ uncurry (divideLine zoneSize) wlline
|
||||
where
|
||||
wlline = _wlLine wl
|
||||
zoneOfWall :: Wall -> Stream (Of (V2 Int)) Identity ()
|
||||
zoneOfWall = uncurry zoneOfLineStream . _wlLine
|
||||
-- | uncurry dist wlline <= 2*zoneSize = [zoneOfPoint $ uncurry midPoint wlline ]
|
||||
-- | otherwise = map zoneOfPoint $ uncurry (divideLine zoneSize) wlline
|
||||
-- where
|
||||
-- wlline = _wlLine wl
|
||||
|
||||
insertWallInZones :: Wall -> World -> World
|
||||
insertWallInZones wl = wallsZone . znObjects
|
||||
%~ flip (foldl' (flip $ \(a,b) -> insertIMInZone a b (_wlID wl) wl)) (zoneOfWall wl)
|
||||
%~ (runIdentity . (\wlzns -> S.fold_ doinsert wlzns id (zoneOfWall wl)))
|
||||
where
|
||||
doinsert wlzns (V2 x y) = insertIMInZone x y (_wlID wl) wl wlzns
|
||||
|
||||
deleteWallFromZones :: Wall -> World -> World
|
||||
deleteWallFromZones wl = wallsZone . znObjects
|
||||
%~ flip (foldl' (flip $ \(a,b) -> deleteIMInZone a b (_wlID wl))) (zoneOfWall wl)
|
||||
%~ (runIdentity . (\wlzns -> S.fold_ dodelete wlzns id (zoneOfWall wl)))
|
||||
where
|
||||
dodelete wlzns (V2 x y) = deleteIMInZone x y (_wlID wl) wlzns
|
||||
-- %~ flip (foldl' (flip $ \(a,b) -> deleteIMInZone a b (_wlID wl))) (zoneOfWall wl)
|
||||
|
||||
Reference in New Issue
Block a user