As you no doubt saw in the writing of the Application class, FGF implements its own version of the XNA Framework’s component classes. The first major reason for doing so is that the builtin component classes require you to pass in a (Framework) Game object through the constructor. While this dependency can be circumvented by implementing the interfaces directly and supplying a manual workaround, the attempt is exactly that: a workaround. The second major reason for my implementation is that by controlling the interfaces and base classes, I can easily support more advanced situations such as the separation between initialization and content loading/unloading. You will see more of this later on when I modify the classes to support asynchronous content loading.
For now, the focus is being put on building a robust base for developers to start working with my framework. Because the goal is to fix the XNA Framework’s implementation, we begin with a simplification of the IGameComponent, IUpdateable and IDrawable interfaces. We combine these three into a single, multi-purpose interface, IModule.
public interface IModule
{
event EventHandler DrawOrderChanged;
event EventHandler UpdateOrderChanged;
void Initialize(IGame game);
void Draw(GameTime gameTime);
void Update(GameTime gameTime);
int DrawOrder { get; }
int UpdateOrder { get; }
bool IsVisible { get; set; }
bool IsEnabled { get; set; }
bool IsInitialized { get; set; }
IModule Parent { get; set; }
ModuleCollection Modules { get; }
}