module Dodge.Default.World
    where
import Dodge.Data
import Dodge.Base
import Dodge.Zone.Data
import Dodge.Debug.Flag.Data
import Dodge.Config.Data
import Dodge.Config.KeyConfig
import Dodge.Item.Data
import Dodge.Bounds
--import Dodge.Menu
--import Picture
import Geometry.Data
--import Picture.Texture
import Data.Preload

import System.Random
import qualified Data.IntMap.Strict as IM
import qualified Data.Map as M
import qualified Data.Set as S
import Data.Graph.Inductive.Graph hiding ((&))
--import qualified Data.Vector.Fusion.Stream.Monadic as VS
defaultWorld :: World
defaultWorld = World
    { _keys = S.empty
    , _mouseButtons = S.empty
    , _cameraCenter = V2 0 0
    , _cameraRot = 0
    , _cameraZoom = 1
    , _cameraViewFrom = V2 0 0
    , _creatures = IM.empty
    , _creaturesZone = Zone IM.empty
    , _creatureGroups = IM.empty
    , _clouds = []
    , _cloudsZone = Zone IM.empty
    , _itemPositions = IM.empty
    , _projectiles = IM.empty
    , _particles = []
    , _walls = IM.empty
    , _wallsZone = Zone IM.empty
    , _forceFields = IM.empty
    , _floorItems = IM.empty
    , _floorTiles = []
    , _randGen = mkStdGen 2
    , _mousePos = V2 0 0
    , _testString = const []
    , _yourID = 0
    , _worldEvents = id
    , _pressPlates = IM.empty
    , _buttons = IM.empty
    , _sounds = M.empty
    , _playingSounds = M.empty
    , _corpses = Zone IM.empty
    , _decorations = IM.empty
    , _storedLevel = Nothing
    , _quicksaveLevel = Nothing
    , _menuLayers = []
    , _worldState = M.empty
    , _worldTriggers = S.empty
    , _clickMousePos = V2 0 0
    , _pathGraph = Data.Graph.Inductive.Graph.empty
    , _pathGraphP = []
    , _pathPoints = IM.empty
    , _carteDisplay = False
    , _carteCenter = V2 0 0
    , _carteZoom = 0.5
    , _carteRot  = 0
    , _lightSources = IM.empty
    , _tempLightSources = [youLight]
    , _closeActiveObjects = []
    , _seenLocations        = IM.fromList 
        [(0, (_crPos . you, "CURRENT POSITION"))
        ,(1, (const (V2 0 0) , "START POSITION"))
        ]
    , _selLocation = 0
    , _keyConfig = defaultKeyConfigSDL
    , _config       = defaultConfig
    , _sideEffects  = return
    , _debugFlags = defaultDebugFlags
    , _inventoryMode = TopInventory
    , _lClickHammer = HammerUp
    , _foregroundShape = mempty
    , _radDistortion = []
    , _gameRooms = []
    , _preloadData = DummyPdata -- hack TODO remove this
    , _frameClock = 0
    , _worldBounds = defaultBounds
    }
defaultDebugFlags :: DebugFlags
defaultDebugFlags = DebugFlags
    { _noClip = False
    , _displaySecondsPerFrame = True
    }
youLight :: TempLightSource
youLight = 
    TLS { _tlsPos = V3 0 0 0
        ,_tlsRad = 300
        ,_tlsIntensity = 0.1
        --,_tlsUpdate = \w _ -> (w, Nothing)
        ,_tlsUpdate = \w _ -> Just (youLight {_tlsPos = f $ _crPos (you w)})
        ,_tlsTime = 0
        }
  where
    f (V2 x y) = V3 x y 100
