Make zoning more universal

This commit is contained in:
2022-06-28 19:04:31 +01:00
parent 4965934502
commit b1a7e1bf35
16 changed files with 152 additions and 97 deletions
+7 -8
View File
@@ -5,20 +5,19 @@ import Geometry
import Dodge.Zone
import Dodge.Base
import qualified Data.IntMap.Strict as IM
import Control.Lens
--import Data.Foldable
--import Streaming
import qualified Streaming.Prelude as S
insertWallInZones :: Wall -> World -> World
insertWallInZones wl = wallsZone . znObjects
%~ (runIdentity . (\wlzns -> S.fold_ doinsert wlzns id (zoneOfWall wl)))
where
doinsert wlzns (V2 x y) = insertIMInZone x y (_wlID wl) wl wlzns
insertWallInZones wl = wlZoning %~ insertInZoning (IM.insert (_wlID wl)) wl
--insertWallInZones wl = wlZoning . znObjects
-- %~ (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
%~ (runIdentity . (\wlzns -> S.fold_ dodelete wlzns id (zoneOfWall wl)))
where
dodelete wlzns (V2 x y) = deleteIMInZone x y (_wlID wl) wlzns
deleteWallFromZones wl = wlZoning %~ insertInZoning (const $ IM.delete (_wlID wl)) wl
-- %~ flip (foldl' (flip $ \(a,b) -> deleteIMInZone a b (_wlID wl))) (zoneOfWall wl)