Separate out concrete part of world

This commit is contained in:
2022-07-25 12:10:50 +01:00
parent 3354d108be
commit b2efbd2b3e
134 changed files with 933 additions and 930 deletions
+6 -6
View File
@@ -17,16 +17,16 @@ import Control.Lens
import qualified IntMapHelp as IM
moveWallIDUnsafe :: Int -> (Point2,Point2) -> World -> World
moveWallIDUnsafe wlid wlline w = case w ^? walls . ix wlid of
moveWallIDUnsafe wlid wlline w = case w ^? cWorld . walls . ix wlid of
Nothing -> error "tried moving nonexistant wall"
Just wl -> moveWall wlid wl wlline w
moveWallID :: Int -> (Point2,Point2) -> World -> World
moveWallID wlid wlline w = case w ^? walls . ix wlid of
moveWallID wlid wlline w = case w ^? cWorld . walls . ix wlid of
Nothing -> w
Just wl -> moveWall wlid wl wlline w
moveWall :: Int -> Wall -> (Point2,Point2) -> World -> World
moveWall wlid wl wlline w = w & walls . ix wlid .~ newwl
moveWall wlid wl wlline w = w & cWorld . walls . ix wlid .~ newwl
& deleteWallFromZones wl
& insertWallInZones newwl
where
@@ -34,17 +34,17 @@ moveWall wlid wl wlline w = w & walls . ix wlid .~ newwl
translateWallID :: Int -> Point2 -> World -> World
translateWallID wlid p w = fromMaybe w $ do
oldwl <- w ^? walls . ix wlid
oldwl <- w ^? cWorld . walls . ix wlid
let newwl = oldwl & wlLine . each +~ p
return $ w
& walls . ix wlid .~ newwl
& cWorld . walls . ix wlid .~ newwl
& deleteWallFromZones oldwl
& insertWallInZones newwl
moveWallIDToward :: Int -> Float -> (Point2,Point2) -> World -> World
moveWallIDToward wlid speed ep w = moveWall wlid wl newwlline w
where
wl = _walls w IM.! wlid
wl = _walls (_cWorld w) IM.! wlid
newwlline = mvPs speed ep (_wlLine wl)
mvP :: Float -> Point2 -> Point2 -> Point2