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
+49 -50
View File
@@ -1,64 +1,63 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DeriveGeneric #-}
module Dodge.Data.Wall where
import GHC.Generics
import Data.Aeson
import Dodge.Data.Material
import Geometry
{-# LANGUAGE TemplateHaskell #-}
module Dodge.Data.Wall (
module Dodge.Data.Wall,
module Dodge.Data.Material,
) where
import Color
import Control.Lens
data Wall = Wall
{ _wlLine :: (Point2,Point2)
, _wlID :: Int
, _wlColor :: Color
, _wlSeen :: Bool
, _wlOpacity :: Opacity
, _wlPathable :: Bool
, _wlPenetrable :: Bool
, _wlBouncy :: Bool
, _wlWalkable :: Bool
, _wlTouchThrough :: Bool
, _wlFireThrough :: Bool
, _wlReflect :: Bool
, _wlUnshadowed :: Bool
, _wlRotateTo :: Bool
, _wlStructure :: WallStructure
, _wlHeight :: Float
, _wlMaterial :: Material
import Data.Aeson
import Data.Aeson.TH
import Dodge.Data.Material
import Geometry
data Wall = Wall
{ _wlLine :: (Point2, Point2)
, _wlID :: Int
, _wlColor :: Color
, _wlSeen :: Bool
, _wlOpacity :: Opacity
, _wlPathable :: Bool
, _wlPenetrable :: Bool
, _wlBouncy :: Bool
, _wlWalkable :: Bool
, _wlTouchThrough :: Bool
, _wlFireThrough :: Bool
, _wlReflect :: Bool
, _wlUnshadowed :: Bool
, _wlRotateTo :: Bool
, _wlStructure :: WallStructure
, _wlHeight :: Float
, _wlMaterial :: Material
}
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON Wall where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Wall
deriving (Eq, Ord, Show, Read)
data Opacity
= SeeThrough
| SeeAbove
| DrawnWall {_opDraw :: WallDraw } -- Wall -> SPic
| DrawnWall {_opDraw :: WallDraw} -- Wall -> SPic
| Opaque
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON Opacity where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Opacity
deriving (Eq, Ord, Show, Read)
data WallDraw = DrawForceField
deriving (Eq,Ord,Show,Read,Enum,Bounded,Generic)
instance ToJSON WallDraw where
toEncoding = genericToEncoding defaultOptions
instance FromJSON WallDraw
data WallStructure
deriving (Eq, Ord, Show, Read, Enum, Bounded)
data WallStructure
= StandaloneWall
| DoorPart { _wsDoor :: Int }
| MachinePart { _wsMachine :: Int }
| BlockPart { _wsBlock :: Int }
| CreaturePart
{ _wlStCreature :: Int
-- , _wlStDamCreature :: Damage -> Wall -> Int -> World -> World
| DoorPart {_wsDoor :: Int}
| MachinePart {_wsMachine :: Int}
| BlockPart {_wsBlock :: Int}
| CreaturePart
{ _wlStCreature :: Int
}
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON WallStructure where
toEncoding = genericToEncoding defaultOptions
instance FromJSON WallStructure
deriving (Eq, Ord, Show, Read)
makeLenses ''Wall
makeLenses ''Opacity
makeLenses ''WallStructure
deriveJSON defaultOptions ''Wall
deriveJSON defaultOptions ''Opacity
deriveJSON defaultOptions ''WallDraw
deriveJSON defaultOptions ''WallStructure