Add generic derivations and To/FromJSON instances
This commit is contained in:
+15
-5
@@ -1,20 +1,27 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.Door where
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
import Dodge.Data.PathGraph
|
||||
import Dodge.Data.MountedObject
|
||||
import Geometry.Data
|
||||
import Dodge.Data.WorldEffect
|
||||
import qualified Data.IntSet as IS
|
||||
import Control.Lens
|
||||
|
||||
data DoorStatus = DoorOpen | DoorClosed | DoorHalfway | DoorInt Int
|
||||
deriving (Eq, Ord, Show,Read)
|
||||
|
||||
deriving (Eq, Ord, Show,Read,Generic)
|
||||
instance ToJSON DoorStatus where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON DoorStatus
|
||||
data PushSource = PushesItself
|
||||
| PushedBy Int
|
||||
| NotPushed
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON PushSource where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON PushSource
|
||||
data Door = Door
|
||||
{ _drID :: Int
|
||||
, _drWallIDs :: IS.IntSet
|
||||
@@ -33,5 +40,8 @@ data Door = Door
|
||||
, _drObstructs :: [(Int,Int,PathEdge)]
|
||||
, _drObstacleType :: EdgeObstacle
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON Door where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON Door
|
||||
makeLenses ''Door
|
||||
|
||||
Reference in New Issue
Block a user