module Rattletrap.Type.Attribute.Explosion where import qualified Rattletrap.BitGet as BitGet import qualified Rattletrap.BitPut as BitPut import qualified Rattletrap.Schema as Schema import qualified Rattletrap.Type.I32 as I32 import qualified Rattletrap.Type.Vector as Vector import qualified Rattletrap.Type.Version as Version import qualified Rattletrap.Utility.Json as Json data Explosion = Explosion { Explosion -> Bool flag :: Bool, Explosion -> I32 actorId :: I32.I32, Explosion -> Vector location :: Vector.Vector } deriving (Explosion -> Explosion -> Bool (Explosion -> Explosion -> Bool) -> (Explosion -> Explosion -> Bool) -> Eq Explosion forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Explosion -> Explosion -> Bool == :: Explosion -> Explosion -> Bool $c/= :: Explosion -> Explosion -> Bool /= :: Explosion -> Explosion -> Bool Eq, Int -> Explosion -> ShowS [Explosion] -> ShowS Explosion -> String (Int -> Explosion -> ShowS) -> (Explosion -> String) -> ([Explosion] -> ShowS) -> Show Explosion forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> Explosion -> ShowS showsPrec :: Int -> Explosion -> ShowS $cshow :: Explosion -> String show :: Explosion -> String $cshowList :: [Explosion] -> ShowS showList :: [Explosion] -> ShowS Show) instance Json.FromJSON Explosion where parseJSON :: Value -> Parser Explosion parseJSON = String -> (Object -> Parser Explosion) -> Value -> Parser Explosion forall a. String -> (Object -> Parser a) -> Value -> Parser a Json.withObject String "Explosion" ((Object -> Parser Explosion) -> Value -> Parser Explosion) -> (Object -> Parser Explosion) -> Value -> Parser Explosion forall a b. (a -> b) -> a -> b $ \Object object -> do Bool flag <- Object -> String -> Parser Bool forall value. FromJSON value => Object -> String -> Parser value Json.required Object object String "flag" I32 actorId <- Object -> String -> Parser I32 forall value. FromJSON value => Object -> String -> Parser value Json.required Object object String "actor_id" Vector location <- Object -> String -> Parser Vector forall value. FromJSON value => Object -> String -> Parser value Json.required Object object String "location" Explosion -> Parser Explosion forall a. a -> Parser a forall (f :: * -> *) a. Applicative f => a -> f a pure Explosion {Bool flag :: Bool flag :: Bool flag, I32 actorId :: I32 actorId :: I32 actorId, Vector location :: Vector location :: Vector location} instance Json.ToJSON Explosion where toJSON :: Explosion -> Value toJSON Explosion x = [(Key, Value)] -> Value Json.object [ String -> Bool -> (Key, Value) forall value e p. (ToJSON value, KeyValue e p) => String -> value -> p Json.pair String "flag" (Bool -> (Key, Value)) -> Bool -> (Key, Value) forall a b. (a -> b) -> a -> b $ Explosion -> Bool flag Explosion x, String -> I32 -> (Key, Value) forall value e p. (ToJSON value, KeyValue e p) => String -> value -> p Json.pair String "actor_id" (I32 -> (Key, Value)) -> I32 -> (Key, Value) forall a b. (a -> b) -> a -> b $ Explosion -> I32 actorId Explosion x, String -> Vector -> (Key, Value) forall value e p. (ToJSON value, KeyValue e p) => String -> value -> p Json.pair String "location" (Vector -> (Key, Value)) -> Vector -> (Key, Value) forall a b. (a -> b) -> a -> b $ Explosion -> Vector location Explosion x ] schema :: Schema.Schema schema :: Schema schema = String -> Value -> Schema Schema.named String "attribute-explosion" (Value -> Schema) -> Value -> Schema forall a b. (a -> b) -> a -> b $ [((Key, Value), Bool)] -> Value Schema.object [ (String -> Value -> (Key, Value) forall value e p. (ToJSON value, KeyValue e p) => String -> value -> p Json.pair String "flag" (Value -> (Key, Value)) -> Value -> (Key, Value) forall a b. (a -> b) -> a -> b $ Schema -> Value Schema.ref Schema Schema.boolean, Bool True), (String -> Value -> (Key, Value) forall value e p. (ToJSON value, KeyValue e p) => String -> value -> p Json.pair String "actor_id" (Value -> (Key, Value)) -> Value -> (Key, Value) forall a b. (a -> b) -> a -> b $ Schema -> Value Schema.ref Schema I32.schema, Bool True), (String -> Value -> (Key, Value) forall value e p. (ToJSON value, KeyValue e p) => String -> value -> p Json.pair String "location" (Value -> (Key, Value)) -> Value -> (Key, Value) forall a b. (a -> b) -> a -> b $ Schema -> Value Schema.ref Schema Vector.schema, Bool True) ] bitPut :: Explosion -> BitPut.BitPut bitPut :: Explosion -> BitPut bitPut Explosion explosionAttribute = Bool -> BitPut BitPut.bool (Explosion -> Bool flag Explosion explosionAttribute) BitPut -> BitPut -> BitPut forall a. Semigroup a => a -> a -> a <> I32 -> BitPut I32.bitPut (Explosion -> I32 actorId Explosion explosionAttribute) BitPut -> BitPut -> BitPut forall a. Semigroup a => a -> a -> a <> Vector -> BitPut Vector.bitPut (Explosion -> Vector location Explosion explosionAttribute) bitGet :: Version.Version -> BitGet.BitGet Explosion bitGet :: Version -> BitGet Explosion bitGet Version version = String -> BitGet Explosion -> BitGet Explosion forall a. String -> BitGet a -> BitGet a BitGet.label String "Explosion" (BitGet Explosion -> BitGet Explosion) -> BitGet Explosion -> BitGet Explosion forall a b. (a -> b) -> a -> b $ do Bool flag <- String -> BitGet Bool -> BitGet Bool forall a. String -> BitGet a -> BitGet a BitGet.label String "flag" BitGet Bool BitGet.bool I32 actorId <- String -> BitGet I32 -> BitGet I32 forall a. String -> BitGet a -> BitGet a BitGet.label String "actorId" BitGet I32 I32.bitGet Vector location <- String -> BitGet Vector -> BitGet Vector forall a. String -> BitGet a -> BitGet a BitGet.label String "location" (BitGet Vector -> BitGet Vector) -> BitGet Vector -> BitGet Vector forall a b. (a -> b) -> a -> b $ Version -> BitGet Vector Vector.bitGet Version version Explosion -> BitGet Explosion forall a. a -> Get BitString Identity a forall (f :: * -> *) a. Applicative f => a -> f a pure Explosion {Bool flag :: Bool flag :: Bool flag, I32 actorId :: I32 actorId :: I32 actorId, Vector location :: Vector location :: Vector location}