Jump to content
  • Advertisement
Sign in to follow this  
Capoeirista

[answered] Component objects with data driven design

This topic is 1516 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey folks,

 

I'm messing around with a small project in my spare time (a 2D editor using Monogame), and am in the process of designing a data driven component-object system.

 

So the basic idea is that at runtime the editor parses all JSON files in a project's data directory, adding each Object to a content library. Users in the editor will be able open up the content browser and drag/drop objects in to the game world... all fairly simple stuff.

 

The objects in my engine are component based. The engine defines a set of fairly common components (graphic/physics/audio) but what I'd like to be able to do is have the JSON files define components that are unique to the Game... class types that the editor isn't aware of.

 

As an example :

{
 "class" : "Object",
 "Name" : "Jim",
 "Health" : "50",
 "Components" : [
    {
      "class" : "GraphicComponent",  // defined by Engine
      "image" : "jim.png"
    },
    {
      "class" : "PlayerController",  // defined by Game
    }
  ]
}

So my question comes down to how to handle this in the editor when I'm deserializing this Object... obviously the editor isn't going to know what to do with the PlayerController class, and I don't want to throw a bunch of exceptions when trying to load an object.

 

I'm looking at using JSON.NET, and was wondering if it's possible to build a custom deserializer so I can just ignore any class types that the editor doesn't know about?

 

Thanks for the advice!

Edited by Orangeatang

Share this post


Link to post
Share on other sites
Advertisement

Ah, looks like you can do partial JSON deserialization in JSON.NET. That took all of two minutes to research... sorry for wasting your time!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!