Add generic derivations and To/FromJSON instances
This commit is contained in:
+19
-6
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user