Refactor, try to limit dependencies

This commit is contained in:
2022-07-28 00:59:56 +01:00
parent 8aa5c17ab9
commit 160560af5f
418 changed files with 15104 additions and 13342 deletions
+39 -34
View File
@@ -1,45 +1,50 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Data.Block where
import GHC.Generics
import Data.Aeson
import Shape.Data
{-# LANGUAGE TemplateHaskell #-}
module Dodge.Data.Block (
module Dodge.Data.Block,
module Dodge.Data.Material,
module Dodge.Data.PathGraph,
) where
import Color
import Control.Lens
import Data.Aeson
import Data.Aeson.TH
import qualified Data.IntSet as IS
import Dodge.Data.Material
import Dodge.Data.PathGraph
import Geometry
import Control.Lens
import qualified Data.IntSet as IS
import Shape.Data
data Block = Block
{ _blID :: Int
, _blWallIDs :: IS.IntSet
, _blHP :: Int
, _blShadows :: [Int] -- a list of blocks/walls? that are not shown when this block exists
, _blFootprint :: [Point2]
, _blPos :: Point2
, _blDir :: Float
, _blHeight :: Float
, _blMaterial :: Material
, _blDraw :: BlockDraw --Block -> SPic
, _blObstructs :: [(Int,Int,PathEdge)]
{ _blID :: Int
, _blWallIDs :: IS.IntSet
, _blHP :: Int
, _blShadows :: [Int] -- a list of blocks/walls? that are not shown when this block exists
, _blFootprint :: [Point2]
, _blPos :: Point2
, _blDir :: Float
, _blHeight :: Float
, _blMaterial :: Material
, _blDraw :: BlockDraw --Block -> SPic
, _blObstructs :: [(Int, Int, PathEdge)]
}
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON Block where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Block
data BlockDraw = BlockDrawMempty
deriving (Eq, Ord, Show, Read)
data BlockDraw
= BlockDrawMempty
| BlockDrawBlSh BlSh
| BlockDraws [BlockDraw]
| BlockDrawColHeightPoss Color Float [Point2]
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON BlockDraw where
toEncoding = genericToEncoding defaultOptions
instance FromJSON BlockDraw
data BlSh = BlShMempty
| BlockDrawColHeightPoss Color Float [Point2]
deriving (Eq, Ord, Show, Read)
data BlSh
= BlShMempty
| BlShConst Shape
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON BlSh where
toEncoding = genericToEncoding defaultOptions
instance FromJSON BlSh
deriving (Eq, Ord, Show, Read)
makeLenses ''Block
deriveJSON defaultOptions ''Block
deriveJSON defaultOptions ''BlockDraw
deriveJSON defaultOptions ''BlSh