Game Development Reference
In-Depth Information
{
ActorId m_id;
public:
static const EventType sk_EventType;
explicit EvtData_Destroy_Actor(ActorId id)
: m_id(id) { }
explicit EvtData_Destroy_Actor(std::istrstream& in)
{
in >> m_id;
}
virtual const EventType& VGetEventType(void) const
{
return sk_EventType;
}
virtual IEventDataPtr VCopy(void) const
{
return IEventDataPtr(GCC_NEW EvtData_Destroy_Actor(m_id));
}
virtual void VSerialize(std::ostrstream &out) const
{
out << m_id;
}
virtual const char* GetName(void) const
{
return
“
EvtData_Destroy_Actor
“
;
}
ActorId GetId(void) const { return m_id; }
};
The event data inherits from the
BaseEventData
so it can be wired into the event
system. When an actor is destroyed, its
ActorId
is sent along with the event.
The
sk_EventType
variable is the GUID, which is initialized like this:
const EventType EvtData_Destroy_Actor::sk_EventType(0x77dd2b3a);
This is how the event is uniquely identified across the entire application. Listeners
register for events using this ID.