Game Development Reference
In-Depth Information
Adding event handlers
We can now register our event callbacks with the AgentCommunications system
based on the event types we want to handle. After this, no other update is necessary, as the
AgentCommunications system itself will handle event processing and dispatching:
AgentSenses.lua :
function AgentSenses_InitializeSenses(userData)
local eventCallbacks = {};
eventCallbacks[
AgentCommunications.EventType.EnemySighted] =
HandleEnemySightedEvent;
eventCallbacks[
AgentCommunications.EventType.DeadEnemySighted] =
HandleDeadEnemySightedEvent;
eventCallbacks[
AgentCommunications.EventType.DeadFriendlySighted] =
HandleDeadFriendlySightedEvent;
for eventType, callback in pairs(eventCallbacks) do
AgentCommunications_AddEventCallback(
userData, eventType, callback);
end
end
Search WWH ::




Custom Search