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
+19 -16
View File
@@ -97,11 +97,12 @@ functionalUpdate cfig w = checkEndGame
$ updateCloseObjects w
zoneClouds :: World -> World
zoneClouds w = w & set cloudsZone (foldl' (flip cloudInZone) (Zoning mempty) (_clouds w))
where
cloudInZone cl = insertInZoneWith p (++) [cl]
where
p = clZoneOfPoint $ stripZ $ _clPos cl
zoneClouds w = w & clZoning %~ \zn ->
foldl' (flip $ insertInZoning (:)) (zn & znObjects .~ mempty) (_clouds w)
-- where
-- cloudInZone cl = insertInZoneWith p (++) [cl]
-- where
-- p = clZoneOfPoint $ stripZ $ _clPos cl
updateWorldSelect :: World -> World
updateWorldSelect w = case w ^? mouseButtons . ix ButtonLeft of
@@ -148,17 +149,19 @@ doRewind w = case _maybeWorld w of
Nothing' -> w & timeFlow .~ NormalTimeFlow
zoneCreatures :: World -> World
zoneCreatures w = w
& creaturesZone . znObjects .~
IM.foldl' zoneCreature IM.empty (_creatures w)
-- runIdentity (S.fold_ zoneCreature IM.empty id (S.each $ _creatures w))
zoneCreature :: IM.IntMap (IM.IntMap (IM.IntMap Creature))
-> Creature
-> IM.IntMap (IM.IntMap (IM.IntMap Creature))
zoneCreature m cr = runIdentity $ S.fold_ doinsert m id (zoneOfCreature cr)
where
doinsert m' (V2 x y) = insertIMInZone x y (_crID cr) cr m'
zoneCreatures w = w & crZoning %~ \zn ->
foldl' (flip $ insertInZoning (\cr -> IM.insert (_crID cr) cr))
(zn & znObjects .~ mempty) (_creatures w)
-- . znObjects .~
-- IM.foldl' zoneCreature IM.empty (_creatures w)
---- runIdentity (S.fold_ zoneCreature IM.empty id (S.each $ _creatures w))
--
--zoneCreature :: IM.IntMap (IM.IntMap (IM.IntMap Creature))
-- -> Creature
-- -> IM.IntMap (IM.IntMap (IM.IntMap Creature))
--zoneCreature m cr = runIdentity $ S.fold_ doinsert m id (zoneOfCreature cr)
-- where
-- doinsert m' (V2 x y) = insertIMInZone x y (_crID cr) cr m'
-- IM.foldl' (flip creatureInZone) IM.empty (_creatures w)
-- where