Game Development Community

TGEA Hidden Gem?

by Ben Sparks - Warspawn · 08/20/2008 (10:27 pm) · 8 comments

So I was going to try and implement the Subscription Based Message Router Resource in TGEA 1.7.1 and I noticed that GG seems to have snuck this one in already. It's different than the resource's implementation, but I believe that it provides the same (if not better) functionality. (please, someone correct me if I'm wrong)

Here are the docs: www.garagegames.com/docs/tgea/official/content/documentation/Engine%20Reference/...

or for the un-tabbed here's the important stuff...
// Create the EventManager.
 $MyEventManager = new EventManager() { queue = "MyEventManager"; };
 
 // Create an event.
 $MyEventManager.registerEvent( "SomeCoolEvent" );
 
 // Create a listener and subscribe.
 $MyListener = new ScriptMsgListener() { class = MyListener; };
 $MyEventManager.subscribe( $MyListener, "SomeCoolEvent" );
 
 function MyListener::onSomeCoolEvent( %this, %data )
 {
    echo( "onSomeCoolEvent Triggered" );
 }
 
 // Trigger the event.
 $MyEventManager.postEvent( "SomeCoolEvent", "Data" );

It doesn't seem to really even be used by anything at the moment, only one file I found that has to do with Projects in the editor (perhaps the start of TGB integration?) Anyway, I created a test scenario and it works.

I decided to post this information as a .plan because I don't think anyone knows that this is in there (besides GG), and to quote Thomas "Man of Ice" Lund : "you can use this in your game. Its almost guaranteed."

My plan for this is to create some sweet AI agents that all answer to one AIManager. The AIManager that is scripted usually only takes care of spawning agents (and in AFX it also handles the resurrects which I guess is really spawning so...). Instead I think that rather than having each AIPlayer run a think loop, I'll just have the AIManager run a think loop. It will subscribe to a AIEventQueue and when different things happen to agents they will post an event into the queue, then the manager will tell them what to do (perhaps via messages even in the same queue).

So I'll be working on that, but I'm hoping that now that everyone knows it's there we can see some cool resources pop-up that use it.

#1
08/20/2008 (11:19 pm)
Great post, Ben!

You know by chance i came across this class myself today.

It looks cool... i think it was added from the merge of TGB into TGEA... so it might be in TGB as well.
#2
08/20/2008 (11:27 pm)
Cool :-)
#3
08/21/2008 (4:33 am)
This is great - I need this all the time.
#4
08/21/2008 (8:15 am)
Cool concept. Keep us updated on how you use it.

Side note: w00t, first person to link to the new online docs =)
#5
08/21/2008 (10:03 am)
I totally beat you to finding that, heres the proof from May '-)
www.garagegames.com/mg/forums/result.thread.php?qt=74833
#6
08/21/2008 (10:15 am)
hehe oh well, I found it for TGEA :P

guess that pretty much confirms that it's part of the TGB integration though :)
#7
08/21/2008 (3:15 pm)
I have two thoughts about this:
1. I need to get TGEA...
2. or I need to start pestering for TGE 1.7 =P

Thanks for pointing that out, I'll use it when one of my thoughts happen.
#8
08/22/2008 (7:23 am)
Thanks for highlighting that! Very useful utility that completely went under the radar :P