Make zoning more universal
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user