Child Nodes and Reflection

My Behaviour Tree editor is getting interesting. I can now add child Composite or Decorator nodes. The nodes are identified through reflection. Here’s a simple utility code to populate a list with all the subclasses of the specified type:

        public static void PopulateSubclassList(List<Type> typeList, Type parentType) {
            Type[] types = Assembly.GetAssembly(parentType).GetTypes();
            foreach(Type type in types) {
                if(type.IsSubclassOf(parentType)) {

This is what I used to collect all Composite nodes and Decorator nodes. Now I can do something like this:

Right click, then poof!
Right click, then poof!

I could clearly see my next tasks from here.

  • Color coding of different types of nodes
  • A separate Action nodes window where all available action classes would be collected
  • XML Serialization
  • Delete node
  • An inspector panel where a node can be renamed and variables can be added

I don’t have some kind of design document for this project so I just go along and see what works. Now that I think about it, I don’t create such documents with my other projects, either. Someone would probably scold me for this.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s