Files
loop/src/Dodge/Placement/Shift.hs
T

28 lines
1.1 KiB
Haskell

module Dodge.Placement.Shift
( shiftPlacement
, shiftPSBy
, shiftRelativeToPS
) where
--import Dodge.LevelGen.Data
import Dodge.Data
import Dodge.ShiftPoint
import LensHelp
import Geometry
shiftPSBy :: (Point2,Float) -> PlacementSpot -> PlacementSpot
shiftPSBy (pos,rot) ps = ps
& psPos %~ shiftPointBy (pos,rot)
& psRot +~ rot
shiftRelativeToPS :: Point2 -> PlacementSpot -> PlacementSpot
shiftRelativeToPS p ps = ps & psPos .+.+~ rotateV (_psRot ps) p
shiftPlacement :: (Point2,Float) -> Placement -> Placement
shiftPlacement shift plmnt = case plmnt of
-- slightly messy NoShiftCont, necessary to stop interference with ps0jPushPS
Placement {_plSpot = PSNoShiftCont {}} -> plmnt & plSpot %~ shiftPSBy shift
Placement {} -> plmnt & plSpot %~ shiftPSBy shift
& plIDCont %~ fmap (fmap (fmap $ shiftPlacement shift))
PlacementUsingPos p f -> PlacementUsingPos (shiftPoint3By shift p)
(fmap (shiftPlacement shift) f)
RandomPlacement rpl -> RandomPlacement $ fmap (shiftPlacement shift) rpl
PickOnePlacement i pl -> PickOnePlacement i (shiftPlacement shift pl)