Add generic derivations and To/FromJSON instances

This commit is contained in:
2022-07-25 22:49:18 +01:00
parent f5604ef429
commit b8e8413daa
99 changed files with 1406 additions and 517 deletions
+19 -6
View File
@@ -1,10 +1,12 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Data.Beam where
import GHC.Generics
import Data.Aeson
import Geometry.Data
import Color
import Control.Lens
{- | Linear beams. Last only one frame.
- Can interact with one another in a limited manner
- can probably be moved to a separate file
@@ -22,22 +24,33 @@ data Beam = Beam
, _bmOrigin :: Maybe Int
, _bmType :: BeamType
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON Beam where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Beam
data BeamDraw = BasicBeamDraw
| BeamDrawColor Color
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON BeamDraw where
toEncoding = genericToEncoding defaultOptions
instance FromJSON BeamDraw
data BeamCombineType = FlameBeamCombine
| LasBeamCombine
| TeslaBeamCombine
| SplitBeamCombine
| NoBeamCombine
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON BeamCombineType where
toEncoding = genericToEncoding defaultOptions
instance FromJSON BeamCombineType
data BeamType
= BeamCombine
{ _beamCombine :: BeamCombineType -- (Point2 , (Point2,Point2,Beam) , (Point2,Point2,Beam)) -> World -> World
}
| BeamSimple
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON BeamType where
toEncoding = genericToEncoding defaultOptions
instance FromJSON BeamType
makeLenses ''BeamType
makeLenses ''Beam