Event Handling

This commit is contained in:
FlightControl 2017-07-08 14:10:33 +02:00
parent cff8522922
commit 47f1b8ae66
4 changed files with 12 additions and 12 deletions

View File

@ -364,7 +364,7 @@ do -- Event Handling
-- @return #BASE -- @return #BASE
function BASE:UnHandleEvent( Event ) function BASE:UnHandleEvent( Event )
self:EventDispatcher():Remove( self, Event ) self:EventDispatcher():RemoveEvent( self, Event )
return self return self
end end

View File

@ -450,16 +450,16 @@ end
-- @param Core.Base#BASE EventClass The self instance of the class for which the event is. -- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
-- @param Dcs.DCSWorld#world.event EventID -- @param Dcs.DCSWorld#world.event EventID
-- @return #EVENT.Events -- @return #EVENT.Events
function EVENT:Remove( EventClass, EventID ) function EVENT:RemoveEvent( EventClass, EventID )
self:E( { "Removing subscription for class: ", EventClass:GetClassNameAndID() } ) self:E( { "Removing subscription for class: ", EventClass:GetClassNameAndID() } )
local EventPriority = EventClass:GetEventPriority() local EventPriority = EventClass:GetEventPriority()
self.EventsDead = self.EventsDead or {} self.Events = self.Events or {}
self.EventsDead[EventID] = self.EventsDead[EventID] or {} self.Events[EventID] = self.Events[EventID] or {}
self.EventsDead[EventID][EventPriority] = self.EventsDead[EventID][EventPriority] or {} self.Events[EventID][EventPriority] = self.Events[EventID][EventPriority] or {}
self.EventsDead[EventID][EventPriority][EventClass] = self.Events[EventID][EventPriority][EventClass] self.Events[EventID][EventPriority][EventClass] = self.Events[EventID][EventPriority][EventClass]
self.Events[EventID][EventPriority][EventClass] = nil self.Events[EventID][EventPriority][EventClass] = nil
@ -529,7 +529,7 @@ end
-- @param EventID -- @param EventID
-- @return #EVENT -- @return #EVENT
function EVENT:OnEventGeneric( EventFunction, EventClass, EventID ) function EVENT:OnEventGeneric( EventFunction, EventClass, EventID )
self:F2( { EventID } ) self:E( { EventID } )
local EventData = self:Init( EventID, EventClass ) local EventData = self:Init( EventID, EventClass )
EventData.EventFunction = EventFunction EventData.EventFunction = EventFunction
@ -923,7 +923,7 @@ function EVENT:onEvent( Event )
end end
else else
-- The EventClass is not alive anymore, we remove it from the EventHandlers... -- The EventClass is not alive anymore, we remove it from the EventHandlers...
self:Remove( EventClass, Event.id ) self:RemoveEvent( EventClass, Event.id )
end end
else else
@ -973,7 +973,7 @@ function EVENT:onEvent( Event )
end end
else else
-- The EventClass is not alive anymore, we remove it from the EventHandlers... -- The EventClass is not alive anymore, we remove it from the EventHandlers...
self:Remove( EventClass, Event.id ) self:RemoveEvent( EventClass, Event.id )
end end
else else

View File

@ -150,7 +150,7 @@ end
-- @return #CLEANUP_AIRBASE -- @return #CLEANUP_AIRBASE
function CLEANUP_AIRBASE:SetCleanMissiles( CleanMissiles ) function CLEANUP_AIRBASE:SetCleanMissiles( CleanMissiles )
if CleanMissiles or true then if CleanMissiles then
self:HandleEvent( EVENTS.Shot, self.__.OnEventShot ) self:HandleEvent( EVENTS.Shot, self.__.OnEventShot )
else else
self:UnHandleEvent( EVENTS.Shot ) self:UnHandleEvent( EVENTS.Shot )
@ -364,7 +364,7 @@ function CLEANUP_AIRBASE.__:CleanUpSchedule()
local CleanUpLandHeight = CleanUpCoordinate:GetLandHeight() local CleanUpLandHeight = CleanUpCoordinate:GetLandHeight()
local CleanUpUnitHeight = CleanUpCoordinate.y - CleanUpLandHeight local CleanUpUnitHeight = CleanUpCoordinate.y - CleanUpLandHeight
if CleanUpUnitHeight < 30 then if CleanUpUnitHeight < 100 then
self:T( { "CleanUp Scheduler", "Destroy " .. CleanUpUnitName .. " because below safe height and damaged." } ) self:T( { "CleanUp Scheduler", "Destroy " .. CleanUpUnitName .. " because below safe height and damaged." } )
self:DestroyUnit( CleanUpUnit ) self:DestroyUnit( CleanUpUnit )
end end

View File

@ -1141,7 +1141,7 @@ do -- Event Handling
-- @return #GROUP -- @return #GROUP
function GROUP:UnHandleEvent( Event ) function GROUP:UnHandleEvent( Event )
self:EventDispatcher():Remove( self, Event ) self:EventDispatcher():RemoveEvent( self, Event )
return self return self
end end