-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Support replays from the boxcars test suite
- Loading branch information
Showing
23 changed files
with
188 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module Rattletrap.Type.Attribute.RepStatTitle where | ||
|
||
import qualified Rattletrap.BitGet as BitGet | ||
import qualified Rattletrap.BitPut as BitPut | ||
import qualified Rattletrap.Schema as Schema | ||
import qualified Rattletrap.Type.Attribute.FlaggedInt as FlaggedInt | ||
import qualified Rattletrap.Type.Str as Str | ||
import qualified Rattletrap.Type.U32 as U32 | ||
import qualified Rattletrap.Utility.Json as Json | ||
|
||
data RepStatTitle = RepStatTitle | ||
{ unknown :: Bool | ||
, name :: Str.Str | ||
, target :: FlaggedInt.FlaggedInt | ||
, value :: U32.U32 | ||
} | ||
deriving (Eq, Show) | ||
|
||
instance Json.FromJSON RepStatTitle where | ||
parseJSON = Json.withObject "RepStatTitle" $ \object -> do | ||
unknown <- Json.required object "unknown" | ||
name <- Json.required object "name" | ||
target <- Json.required object "target" | ||
value <- Json.required object "value" | ||
pure RepStatTitle { unknown, name, target, value } | ||
|
||
instance Json.ToJSON RepStatTitle where | ||
toJSON x = Json.object | ||
[ Json.pair "unknown" $ unknown x | ||
, Json.pair "name" $ name x | ||
, Json.pair "target" $ target x | ||
, Json.pair "value" $ value x | ||
] | ||
|
||
schema :: Schema.Schema | ||
schema = Schema.named "attribute-rep-stat-title" $ Schema.object | ||
[ (Json.pair "unknown" $ Schema.ref Schema.boolean, True) | ||
, (Json.pair "name" $ Schema.ref Str.schema, True) | ||
, (Json.pair "target" $ Schema.ref FlaggedInt.schema, True) | ||
, (Json.pair "value" $ Schema.ref U32.schema, True) | ||
] | ||
|
||
bitPut :: RepStatTitle -> BitPut.BitPut | ||
bitPut x = | ||
BitPut.bool (unknown x) | ||
<> Str.bitPut (name x) | ||
<> FlaggedInt.bitPut (target x) | ||
<> U32.bitPut (value x) | ||
|
||
bitGet :: BitGet.BitGet RepStatTitle | ||
bitGet = BitGet.label "RepStatTitle" $ do | ||
unknown <- BitGet.label "unknown" BitGet.bool | ||
name <- BitGet.label "name" Str.bitGet | ||
target <- BitGet.label "target" FlaggedInt.bitGet | ||
value <- BitGet.label "value" U32.bitGet | ||
pure RepStatTitle { unknown, name, target, value } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Rattletrap.Type.Attribute.Rotation where | ||
|
||
import qualified Rattletrap.BitGet as BitGet | ||
import qualified Rattletrap.BitPut as BitPut | ||
import qualified Rattletrap.Schema as Schema | ||
import qualified Rattletrap.Type.Int8Vector as Int8Vector | ||
import qualified Rattletrap.Utility.Json as Json | ||
|
||
newtype Rotation = Rotation | ||
{ value :: Int8Vector.Int8Vector | ||
} deriving (Eq, Show) | ||
|
||
instance Json.FromJSON Rotation where | ||
parseJSON = fmap Rotation . Json.parseJSON | ||
|
||
instance Json.ToJSON Rotation where | ||
toJSON = Json.toJSON . value | ||
|
||
schema :: Schema.Schema | ||
schema = Schema.named "attribute-rotation" $ Schema.ref Int8Vector.schema | ||
|
||
bitPut :: Rotation -> BitPut.BitPut | ||
bitPut = Int8Vector.bitPut . value | ||
|
||
bitGet :: BitGet.BitGet Rotation | ||
bitGet = BitGet.label "Rotation" $ do | ||
value <- BitGet.label "value" Int8Vector.bitGet | ||
pure Rotation { value } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.