I examined the Actor class, and realized that there is no way to "subscribe" to an event, like the Touch event in a "delegate" fashion. Unless you're creating a subclass, which is not an option for me, the class will call only the Kismet events.
I want to avoid Kismet as much as possible, so I though I could create a subclass for the event, and use it to internally catch the activations, and offer a "delegate" way to subscribe with other classes. Unfortunately all the methods of the kismet events are FINAL (THANKS UDK), so no luck...
So I thought of creating a Fake Kismet event which would mimic the Touch event, but contain an internal Kismet touch event. I manually linked the internal event to my fake event. When my fake event is activated, all I'd have to do is to trigger my delegates...
BUT then when I tried to compile my code.. and it failed at mActor.GeneratedEvents.AddItem, because the array is CONST. Hooray, I didn't notice that little detail. It looks like GeneratedEvents is populated by the editor. I thought that if what was done by the editor, we could do it manually... Nothing is less sure, I haven't found a way to add my event to the actor. Any idea how I do this? The Kismet action AttachEventToActor does that, I hope I won't need to instantiate that class just to do that simple job...
Any other idea?
I want to avoid Kismet as much as possible, so I though I could create a subclass for the event, and use it to internally catch the activations, and offer a "delegate" way to subscribe with other classes. Unfortunately all the methods of the kismet events are FINAL (THANKS UDK), so no luck...
So I thought of creating a Fake Kismet event which would mimic the Touch event, but contain an internal Kismet touch event. I manually linked the internal event to my fake event. When my fake event is activated, all I'd have to do is to trigger my delegates...
Code:
class ActorTouchedSubscriber extends SequenceAction;
[...]
// Kismet Event.
var SeqEvent_Touch mSeqEvent_Touch;
// Kismet Links.
var SeqOpOutputInputLink mLink_Touched;
var SeqOpOutputInputLink mLink_UnTouched;
var SeqOpOutputInputLink mLink_Empty;
// Kismet Variables.
var SeqVar_Object mSeqVar_Instigator;
// Subscribed Actor.
var Actor mActor;
function SubscribeToActor(Actor iActor)
{
// Subscribe to the output links.
mLink_Touched.LinkedOp = self;
mLink_Touched.InputLinkIdx = 0;
mSeqEvent_Touch.OutputLinks[0].Links.AddItem(mLink_Touched);
mLink_UnTouched.LinkedOp = self;
mLink_UnTouched.InputLinkIdx = 1;
mSeqEvent_Touch.OutputLinks[1].Links.AddItem(mLink_UnTouched);
mLink_Empty.LinkedOp = self;
mLink_Empty.InputLinkIdx = 2;
mSeqEvent_Touch.OutputLinks[2].Links.AddItem(mLink_Empty);
// Add a variable to the
mSeqEvent_Touch.VariableLinks[0].LinkedVariables.AddItem(self.mSeqVar_Instigator);
// Add the event to the actor.
mActor = iActor;
[COLOR="Red"][B]mActor.GeneratedEvents.AddItem(self.mSeqEvent_Touch);[/B][/COLOR]
}
event Activated()
{
// Sort which input was triggered, and call the delegates...
}
Defaultproperties
{
ObjName="ActorTouchedSubscriber"
ObjCategory="Don't Use"
InputLinks.Empty
InputLinks(0)=(LinkDesc="Touched")
InputLinks(1)=(LinkDesc="UnTouched")
InputLinks(2)=(LinkDesc="Empty")
VariableLinks.Empty
VariableLinks(0)=(ExpectedType=class'SeqVar_Object',LinkDesc="Instigator",PropertyName=mInstigator)
}
BUT then when I tried to compile my code.. and it failed at mActor.GeneratedEvents.AddItem, because the array is CONST. Hooray, I didn't notice that little detail. It looks like GeneratedEvents is populated by the editor. I thought that if what was done by the editor, we could do it manually... Nothing is less sure, I haven't found a way to add my event to the actor. Any idea how I do this? The Kismet action AttachEventToActor does that, I hope I won't need to instantiate that class just to do that simple job...
Any other idea?
Last edited: