module Dodge.Placement.Instance.Tank 
    ( tankSquareDec
    , roundTank
    , roundTankCross
    ) where
import Dodge.Data
import Dodge.Default.Block
--import Dodge.Placement.PlaceSpot
import Dodge.LevelGen.Data
import Dodge.Room.Foreground
import Dodge.Default.Wall
--import Dodge.Placement.TopDecoration
import Geometry
import Shape
import ShapePicture
import Color
import LensHelp
--import Quaternion

tankSquareDec :: (Float -> Float -> Float -> Color -> Color -> Shape) 
    -> Color -> Color -> Placement
tankSquareDec dec = tankShape (square 20) (dec 20 20 31)

tankShape :: [Point2] -> (Color -> Color -> Shape) -> Color -> Color -> Placement
tankShape baseshape facade col col' 
    = sps0 $ PutBlock bl wl $ reverse baseshape
  where
    bl = defaultBlock
        & blDraw .~ const (noPic $ colorSH col (upperPrismPoly 31 $ reverse baseshape) <> facade col col')
        & blDeath .~ const id
    wl = defaultWall 
        & wlDraw .~ False 
        & wlColor .~ col 
        & wlRotateTo .~ False  
        & wlOpacity .~ SeeAbove
        & wlMaterial .~ Metal

--    = ps0jPushPS
--    (PutShape $ colorSH col (upperPrismPoly 31 baseshape) <> facade col col')
--    $ sps0 $ PutWall baseshape defaultWall 
--        {_wlDraw = False, _wlColor = col, _wlRotateTo = False, _wlOpacity = SeeAbove}

roundTank :: Color -> Color -> Placement
roundTank = tankShape (polyCirc 4 20) 
    $ \_ c' -> colorSH c' $ foldMap toprail (take 8 [0,pi/4..]) 
  where
    toprail a = rotateSH a $ thinHighBar 31 (V2 0 20) (rotateV (pi/4) $ V2 0 20)

roundTankCross :: Color -> Color -> Placement
roundTankCross = tankShape (polyCirc 4 20) 
    $ \_ c -> colorSH c $ thinHighBar 31 (V2 20 0) (V2 (-20) 0)
        <> thinHighBar 31 (V2 0 20) (V2 0 (-20))
