Debug Mananger

 Posted by at 11:52 pm  XNA DotA
Mar 112011

Debug Manager is a service I added to XNADotA. It’s primary function is to allow objects to register with it, through the use of delegates easy access is allowed to the debug functions within each object.


The Debug Manager depends on DebugDelegateAndName class. This class is just a simple method of storing an object’s given name and the delegate that points function to be called

The Debug Manager is instantiated within the game main call, registering itself as a only as a service with

DebugManager debugManager = new DebugManager();
            Services.AddService(typeof(DebugManager), debugManager);

Objects at any point, generally within the object’s Initialize method, can register with the Debug Manager with

 ((DebugManager)Game.Services.GetService(typeof(DebugManager))).RegisterObjectString("Object>Branch>Name>LeafName", DebugInformation);

where the method DebugInformation is a method that returns a string and has no calling parameters. Such as

public string DebugInformation()
    return "This is a string with debug information about the object.";

Voided methods follow the same method as above, but can be acted upon by the Debug Manager, generally used for toggling boolean values for various draw animations in XNADotA.

Notice the “Object>Branch>Name>LeafName”, for each ‘>” a new debug branch is created dropping in the final “LeafName” into the last named branch, this is useful as I can add any function into the Debug Manager under a very specific category, allowing for easy grouping such as grouping all actor objects together. Each branch allows for easy navigation in the debug menus.