Working on a gernic event system for Torque
by J. Donavan Stanley · in Torque Game Engine · 06/07/2003 (11:10 am) · 42 replies
I'm currently close to being finished with a generic event notification system for Torque objects that I'll be submitting as a resource. Here's a short rundown:
The major players are:
Publisher - A mix-in class that supports "publishing" and broadcasting subscriptions.
Subscriber - Another mix-in that knows how to subscribe and receive notifications.
Subscription - The actual notification object. Mantains a pointer to it's publisher and a list of subscribers.
SimVariant - A Variant object that can represent any Torque type.
An example usage might be:
We have a item that, when equiped increases the health regen of a player. So in when the item gets equipped it does something like this: "player.subscribe( ID_HEALTH_REGEN, this );". Then each time the player object starts a health regen all of the subscribers get notified and receive a SimVariant containing the amount of health that's being regened. The item can then modify that value and it will get passed along the chain. (Or it can return false and stop the publisher from notifing any other subscribers).
Another possible usage is for when an NPC gets attacked. It can broadcast an "I'm being attacked" event and pass the attacker, the attackers location and the type of attack in a linked list of SimVariants to all NPCs within a certain range.
The reason I'm bringing this up is that when I release the resource I planned on adding a handful of subscriptions "out of the box" and leaving the rest up to the individual developers. So I thought I'd ask here if there were any particular events people were interested in.
The major players are:
Publisher - A mix-in class that supports "publishing" and broadcasting subscriptions.
Subscriber - Another mix-in that knows how to subscribe and receive notifications.
Subscription - The actual notification object. Mantains a pointer to it's publisher and a list of subscribers.
SimVariant - A Variant object that can represent any Torque type.
An example usage might be:
We have a item that, when equiped increases the health regen of a player. So in when the item gets equipped it does something like this: "player.subscribe( ID_HEALTH_REGEN, this );". Then each time the player object starts a health regen all of the subscribers get notified and receive a SimVariant containing the amount of health that's being regened. The item can then modify that value and it will get passed along the chain. (Or it can return false and stop the publisher from notifing any other subscribers).
Another possible usage is for when an NPC gets attacked. It can broadcast an "I'm being attacked" event and pass the attacker, the attackers location and the type of attack in a linked list of SimVariants to all NPCs within a certain range.
The reason I'm bringing this up is that when I release the resource I planned on adding a handful of subscriptions "out of the box" and leaving the rest up to the individual developers. So I thought I'd ask here if there were any particular events people were interested in.
#42
10/11/2003 (5:36 am)
Melv's waterblocks were designed to work against a single terrain block. So if you use them with TM the depth effects are wrong once you leave the primary block.
Torque Owner Desmond Fletcher
fletcher