Add generic derivations and To/FromJSON instances
This commit is contained in:
+15
-5
@@ -1,14 +1,18 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.Cloud where
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
import Geometry
|
||||
import Color
|
||||
import Control.Lens
|
||||
|
||||
data CloudDraw = CloudColor Float Float Color -- radius-multiply fade-time color
|
||||
| DrawGasCloud Color
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON CloudDraw where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON CloudDraw
|
||||
data Cloud = Cloud
|
||||
{ _clPos :: Point3
|
||||
, _clVel :: Point3
|
||||
@@ -18,9 +22,15 @@ data Cloud = Cloud
|
||||
, _clTimer :: Int
|
||||
, _clType :: CloudType
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON Cloud where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON Cloud
|
||||
data CloudType
|
||||
= SmokeCloud
|
||||
| GasCloud
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON CloudType where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON CloudType
|
||||
makeLenses ''Cloud
|
||||
|
||||
Reference in New Issue
Block a user