Commit before door refactor

This commit is contained in:
2022-06-23 09:30:46 +01:00
parent ee47ee8e95
commit 8e3f03637d
11 changed files with 76 additions and 17 deletions
+12
View File
@@ -4,6 +4,7 @@ module Dodge.Wall.Move
, moveWallIDUnsafe
, moveWall
, moveWallIDToward
, translateWallID
, mvPs
) where
import Dodge.Data
@@ -11,6 +12,7 @@ import Dodge.Base
import Geometry
import Dodge.Wall.Zone
import Data.Maybe
import Control.Lens
import qualified Data.IntMap.Strict as IM
@@ -29,6 +31,16 @@ moveWall wlid wl wlline w = w & walls . ix wlid .~ newwl
& insertWallInZones newwl
where
newwl = wl {_wlLine = wlline}
translateWallID :: Int -> Point2 -> World -> World
translateWallID wlid p w = fromMaybe w $ do
oldwl <- w ^? walls . ix wlid
let newwl = oldwl & wlLine . each +~ p
return $ w
& 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