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

29 lines
943 B
Haskell

module Dodge.Placement.Shift (
shiftPlacement,
shiftPSBy,
shiftRelativeToPS,
) where
import Dodge.Data.GenWorld
import Dodge.ShiftPoint
import Geometry
import LensHelp
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))
-- RandomPlacement rpl -> RandomPlacement $ fmap (shiftPlacement shift) rpl