It's been a while since I've said anything about Decal so today I've decided to share some things about the next public release of Decal. We've come a long way with Adapter and our new rendering code so this upcoming release will likely be the last time you guys see the old view system. You can also expect a few other components to be completely redone and at least one to be gone forever.
There are two new features in Adapter that will be the focus of today's article. One will make life easier for devs, the other will make things much more interesting for them. Firstly, to make development and maintenance easier, I've added another code hook-up attribute to the system, BaseEvent. The purpose of BaseEvent is very much like that of ControlEvent. It works on the protected 'system' events that exist as part of PluginBase (which mostly come from ACHooks in the Decal core). When applied to an event handler, these attributes will automatically hook up and tear down the connection to that event.
public class Test : PluginBase
protected override void Startup()
// Network events
// this is the old way of doing it
//this.ServerDispatch += new EventHandler<NetworkMessageEventArgs>(Test_ServerDispatch);
void Test_ServerDispatch(object sender, NetworkMessageEventArgs e)
throw new Exception("The method or operation is not implemented.");
protected override void Shutdown()
// old tear down
//this.ServerDispatch -= this.Test_ServerDispatch;
This may not look like much since once you add the attribute, you only save one line of code. What it does for you, is guarantee proper shutdown of all of your events. I've found many times in my code where my tear-down code missed several events.
Now for the more interesting stuff. Plugin devs often want to share the functionality of their plugin with others. They also sometimes want to get information from other plugins. This can't always be implemented to suit all (depending on language/knowledge/etc) so we've added a message notification system to Adapter to help things along. With the next release of Decal, all Adapter plugins will be able to consume a single event "AdapterMessage", and they will be notified of all messages sent between plugins. Sending a message is very simple as well, you just derive an object from AdapterMessageEventArgs, add in the information you want to share, and call SendAdapterMessage.
I'll talk a bit more about messages tomorrow, along with some examples on how to use it.