[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
On 08-Oct-1998 Nolan ($nolan) said: 
> To me, some portions of the documentation for the event handler are
> unclear. Because the event handler plays a critical role in a project
> which I am working on, I would appreciate it greatly if someone with a
> good knowledge of the event system could either answer these
> questions, or modify the documentation for the handler to answer
> them. :)

One simple thing which I should probably outline in the docs: All you
need to know about for the end API is registering and receiving, and
possibly sending.  Hooking should be entirely handled internally.

As for unclarity, if you could note specific places in the docs that
are unclear I can try to clarify them.

> 1.  When an event is registered to hook when moved, does the event
> automatically unhook itself from the source of the move, then rehook
> itself into the destination?

Yes, that is the whole idea behind it :)

> 2.  If an object's relay is set to the location, does that mean that
> the location itself must send the event, or that an object within that
> location must send the event? Also with 'this, does the object itself
> need to send the event, or does something within it need to send that
> event for it to be relayed?

An object's relay isn't set--just the relay for each specific event.  
The 'relay' is the object you specify when registering an event--this 
object is the object the event is actually hooked on, when the event  
registration becomes 'active' (i.e. you login, or an object starts 
up).

I think the problem is you are still mixing too many of the subsystems
together... What it boils down to is:

  1) An event is sent to a relay point
  2) this relay point sends the event to all objects hooked to the 
     event 
  
Everything else is just added complexity to make sure the system flows
in the most efficient and clean manner possible.  The hooking system  
is an optimization (only objects who care about an event receive it), 
and the registration system is designed to cleanly manage hooking and 
unhooking events. 

> I am planning to use the event handler system extensively in
> ColdSpace, and plan to have certain aspects of the system updated per
> event type. For example, ship motion will be handled by a 'motion
> event. But, I am unclear about how to register these events, and hope
> that the answers to the above questions are helpful in that
> respect. Thanks.

You need to somehow define a region that ships will fall within, and
that region is the relay point.  For ColdCore movement this is the
room they are located in.  For space, you need to define an entirely
new paradigm because you dont want to have such a fine granularity as
ever single point in space as its own relay (you'd then get bogged
down in updating hooks for every point you move through).  An
alternative option is to perhaps define regions, and graph the regions
together (where each region covers x area of space), then override
region.send_event to extend one step beyond itself (i.e. when you send
an event to a region it goes to itself and its neighbors, but no
furhter).

This should cover most things necessary for a 'motion event--but mayhaps
not.  It depends upon what 'motion covers, you may also want to define
a 'moved event, which it sends to itself--basically saying "hey, I've
moved, imagine that".  The advantage of this is then objects which
dont quite fit into the 'motion paradigm--like a galactic wide
scanner--can just hook the objects directly and essentially cheat.

-Brandon