--{-# LANGUAGE TupleSections #-}
--{-# OPTIONS_GHC -Wno-unused-imports #-}
{- | The tree of rooms that make up a level. -}
module Dodge.Floor
--    ( initialRoomTree
--    ) 
    where
import Dodge.Cleat
--import Geometry.Data
--import Dodge.Data
import Dodge.LockAndKey
--import Dodge.Creature.State.Data
import Dodge.Room
--import Dodge.Data.DamageType
--import Dodge.Placement.Instance.Button
import Dodge.Tree
import Dodge.PlacementSpot
import Dodge.Annotation
--import Dodge.Placement.Instance.Sensor
import Dodge.Creature
import Dodge.Room.Warning
--import Dodge.LevelGen.Data
import Dodge.Data
--import Dodge.LevelGen.Switch
--import Dodge.Item.Weapon.Launcher
--import Dodge.PlacementSpot
--import Dodge.RoomPos
--import Dodge.Room.RunPast
--import MonadHelp
import LensHelp
import RandomHelp
--import Color
--import Dodge.Wire

import Data.List (intersperse)
--import Data.Sequence hiding (zipWith)
--import Data.Maybe
--import qualified Data.IntMap.Strict as IM

initialAnoTree :: Annotation
initialAnoTree = OnwardList 
        $ intersperse (AnTree corDoor)
    [ IntAnno $ AnTree . startRoom
    , AnRoom $ return airlock0
    , AnRoom slowDoorRoom
    , AnRoom $ roomCCrits 10
    , AnTree firstBreather
    , AnTree $ telRoomLev 1 >>= rToOnward "telRoomLev" . pure . cleatOnward
    ]

extraAnoList :: [Annotation]
extraAnoList =
--     ,  (SpecificRoom . return . tToBTree $ treePost [corridor,corridor,cleatOnward corridor])
    [ AnRoom $ roomCCrits 10
    , AnRoom $ roomCCrits 10
    , AnTree $ tToBTree "spawners" <$> spawnerRoom
    , AnRoom pistolerRoom
    , AnRoom doubleCorridorBarrels
    , IntAnno $ PassthroughLockKeyLists
        [(sensorRoomRunPast ELECTRICAL, takeOne [CRAFT STATICMODULE,SPARKGUN] )] itemRooms
    , IntAnno $ PassthroughLockKeyLists keyCardRunPastRand itemRooms
    , IntAnno $ AnTree . warningRooms
    , AnTree $ rToOnward "chaseCrit+armourChaseCrit rectRoom"
        $ return . cleatOnward $ roomRectAutoLinks 400 400 & rmPmnts .++~ 
            [ spNoID anyUnusedSpot (PutCrit invisibleChaseCrit)
            , spNoID anyUnusedSpot (PutCrit armourChaseCrit)
            ]
    , IntAnno $ AnTree . fmap (tToBTree "healthTest") . healthTest
    , AnTree (tanksRoom [] [] >>= rToOnward "empty tanksRoom" . pure . cleatOnward)
    , IntAnno $ PassthroughLockKeyLists lockRoomKeyItems itemRooms
    , AnTree randomChallenges
    , IntAnno $ AnTree . lasSensorTurretTest
--    ,[AnTree $ fmap pure roomCCrits]
--    ,[AirlockAno]
--    ,[Corridor]
------    ,[AnTree roomCCrits]
------    ,[Corridor]
------    ,[AnTree . pure . pure . useAll $ roomGlassOctogon 400 
------        & rmPS %~ ([sPS (V2 0 50) 0 $ PutCrit armourChaseCrit 
------                    ,sPS (V2 50 25) 0 $ PutCrit armourChaseCrit 
------                    ,sPS (V2 50 0) 0 $ PutCrit armourChaseCrit 
------                    ]++)
------     ]
------    --,[AnTree . pure . pure . useAll $ roomGlassOctogon 400 
------    --    & rmPS %~ ([swarmPS 0 (x,y) 0 swarmCrit | x <- [-20,-19.5.. 20] , y <- [200,202] ]++)
------    -- ]
------    ,[AnTree . pure . pure . useAll $ roomGlassOctogon 400 
------        & rmPS %~ ([sPS (V2 0 50) 0 $ PutCrit pistolCrit ]++)
------     ]
------    ,[Corridor]
----    --,[AnTree $ pure . useAll <$> twinSlowDoorChasers]
-----    ,[AnTree $ pure $ (pure . useAll) (twinSlowDoorRoom 80 200 40)]
-----    ,[DoorAno]
-----    ,[AnTree $ pure . useAll <$> centerVaultExplosiveExit]
-----    ,[AnTree blockedCorridor]
-----    ,[OrAno [[DoorAno]
-----            ,[Corridor]
-----            ,[DoorNumAno 0,AirlockAno]] 
-----            ]
-----    ,[FirstWeapon]
-----    ,[CorridorDebug]
-----    ,[AnTree $ fmap (pure . useAll) randomFourCornerRoom]
--    ,[OrAno 
--        [[AnTree $ branchRectWith $ fmap (fmap ) armouredChasers]
--        ,[BossAno $ addArmour launcherCrit & crHP +~ 800
--            & crState . crDropsOnDeath .~ DropSpecific [0] ]
--        ]
--     ]
----    ,[AnTree $ fmap (pure . useAll) armouredCorridor]
--    ,[Corridor]
--    ,[TreasureAno [addArmour autoCrit,addArmour autoCrit] [launcher]]
--    ,[Corridor]
    ,AnTree $ randomFourCornerRoom [] >>= rToOnward "randomFourCornerRoom" . pure . cleatOnward 
    ]

{- | A test level tree. -}
initialRoomTree :: State (StdGen,Int) (MetaTree Room String)
initialRoomTree = annoToRoomTree initialAnoTree
