-
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.
* Handle `TAGame.Car_TA:ReplicatedDemolishExtended` attribute * Fix schema name * Fix schema name again
- Loading branch information
Showing
11 changed files
with
145 additions
and
4 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
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.
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
71 changes: 71 additions & 0 deletions
71
src/lib/Rattletrap/Type/Attribute/CustomDemolishExtended.hs
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,71 @@ | ||
module Rattletrap.Type.Attribute.CustomDemolishExtended where | ||
|
||
import qualified Rattletrap.BitGet as BitGet | ||
import qualified Rattletrap.BitPut as BitPut | ||
import qualified Rattletrap.Schema as Schema | ||
import qualified Rattletrap.Type.Attribute.CustomDemolish as CustomDemolish | ||
import qualified Rattletrap.Type.ObjectTarget as ObjectTarget | ||
import qualified Rattletrap.Type.Version as Version | ||
import qualified Rattletrap.Utility.Json as Json | ||
|
||
data CustomDemolishExtended = CustomDemolishExtended | ||
{ attackerPri :: ObjectTarget.ObjectTarget, | ||
selfDemoFx :: ObjectTarget.ObjectTarget, | ||
selfDemolish :: Bool, | ||
customDemolish :: CustomDemolish.CustomDemolish | ||
} | ||
deriving (Eq, Show) | ||
|
||
instance Json.FromJSON CustomDemolishExtended where | ||
parseJSON = Json.withObject "CustomDemolishExtended" $ \object -> do | ||
attackerPri <- Json.required object "attacker_pri" | ||
selfDemoFx <- Json.required object "self_demo_fx" | ||
selfDemolish <- Json.required object "self_demolish" | ||
customDemolish <- Json.required object "custom_demolish" | ||
pure | ||
CustomDemolishExtended | ||
{ attackerPri, | ||
selfDemoFx, | ||
selfDemolish, | ||
customDemolish | ||
} | ||
|
||
instance Json.ToJSON CustomDemolishExtended where | ||
toJSON x = | ||
Json.object | ||
[ Json.pair "attacker_pri" $ attackerPri x, | ||
Json.pair "self_demo_fx" $ selfDemoFx x, | ||
Json.pair "self_demolish" $ selfDemolish x, | ||
Json.pair "custom_demolish" $ customDemolish x | ||
] | ||
|
||
schema :: Schema.Schema | ||
schema = | ||
Schema.named "attribute-custom-demolish-extended" $ | ||
Schema.object | ||
[ (Json.pair "attacker_pri" $ Schema.ref ObjectTarget.schema, True), | ||
(Json.pair "self_demo_fx" $ Schema.ref ObjectTarget.schema, True), | ||
(Json.pair "self_demolish" $ Schema.ref Schema.boolean, True), | ||
(Json.pair "custom_demolish" $ Schema.ref CustomDemolish.schema, True) | ||
] | ||
|
||
bitPut :: CustomDemolishExtended -> BitPut.BitPut | ||
bitPut demolishAttribute = | ||
ObjectTarget.bitPut (attackerPri demolishAttribute) | ||
<> ObjectTarget.bitPut (selfDemoFx demolishAttribute) | ||
<> BitPut.bool (selfDemolish demolishAttribute) | ||
<> CustomDemolish.bitPut (customDemolish demolishAttribute) | ||
|
||
bitGet :: Version.Version -> BitGet.BitGet CustomDemolishExtended | ||
bitGet version = BitGet.label "CustomDemolishExtended" $ do | ||
attackerPri <- BitGet.label "attackerPri" ObjectTarget.bitGet | ||
selfDemoFx <- BitGet.label "selfDemoFx" ObjectTarget.bitGet | ||
selfDemolish <- BitGet.label "selfDemolish" BitGet.bool | ||
customDemolish <- BitGet.label "customDemolish" $ CustomDemolish.bitGet version | ||
pure | ||
CustomDemolishExtended | ||
{ attackerPri, | ||
selfDemoFx, | ||
selfDemolish, | ||
customDemolish | ||
} |
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
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,53 @@ | ||
module Rattletrap.Type.ObjectTarget 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.Utility.Json as Json | ||
|
||
data ObjectTarget = ObjectTarget | ||
{ isActor :: Bool, | ||
targetIndex :: I32.I32 | ||
} | ||
deriving (Eq, Show) | ||
|
||
instance Json.FromJSON ObjectTarget where | ||
parseJSON = Json.withObject "ObjectTarget" $ \object -> do | ||
isActor <- Json.required object "is_actor" | ||
targetIndex <- Json.required object "target_index" | ||
pure | ||
ObjectTarget | ||
{ isActor, | ||
targetIndex | ||
} | ||
|
||
instance Json.ToJSON ObjectTarget where | ||
toJSON x = | ||
Json.object | ||
[ Json.pair "is_actor" $ isActor x, | ||
Json.pair "target_index" $ targetIndex x | ||
] | ||
|
||
schema :: Schema.Schema | ||
schema = | ||
Schema.named "object-target" $ | ||
Schema.object | ||
[ (Json.pair "is_actor" $ Schema.ref Schema.boolean, True), | ||
(Json.pair "target_index" $ Schema.ref I32.schema, True) | ||
] | ||
|
||
bitPut :: ObjectTarget -> BitPut.BitPut | ||
bitPut demolishAttribute = | ||
BitPut.bool (isActor demolishAttribute) | ||
<> I32.bitPut (targetIndex demolishAttribute) | ||
|
||
bitGet :: BitGet.BitGet ObjectTarget | ||
bitGet = BitGet.label "ObjectTarget" $ do | ||
isActor <- BitGet.label "isActor" BitGet.bool | ||
targetIndex <- BitGet.label "targetIndex" I32.bitGet | ||
pure | ||
ObjectTarget | ||
{ isActor, | ||
targetIndex | ||
} |
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