Subterfuge-Revived / Remake-Core

Core repository that holds all game logic for both front end rendering and back end validation.
Creative Commons Zero v1.0 Universal
39 stars 23 forks source link

Remove Polymorphic Serialization #110

Closed QuinnBast closed 1 year ago

QuinnBast commented 1 year ago

Enhancement Description

Polymorphic serialization in the Models project is really nice for helping to allow submit various types of events while getting immediate validation on the serialization from the C# Json validation. However, it requires using the JsonSubTypes package which has a dependency on Newtonsoft.Json which clashes with Unity's built-in version.

Remove the dependency on the JsonSubTypes package and instead of using Polymorphic game events, just store the event data as a JSON string representation of the particular event.

For example:

{
    "EventDataType": "LaunchDrillerEvent",
    "SerializedEventData": "{\"sourceId\": \"asdfg\",.................}"
}

Ensure that you add validation for parsing the serialized game event data into the type of even the user claims the data to be for. Make the C# client accept the raw game event and serialize it automatically instead of making users of the client serialize their own events if possible.