diff --git a/Moose Development/Moose/Core/Event.lua b/Moose Development/Moose/Core/Event.lua index 5a390985e..86a95d76d 100644 --- a/Moose Development/Moose/Core/Event.lua +++ b/Moose Development/Moose/Core/Event.lua @@ -152,6 +152,10 @@ -- -- @module Event + + + + --- The EVENT structure -- @type EVENT -- @field #EVENT.Events Events @@ -1137,3 +1141,18 @@ function EVENT:onEvent( Event ) end end +--- The EVENTHANDLER structure +-- @type EVENTHANDLER +-- @extends Core.Base#BASE +EVENTHANDLER = { + ClassName = "EVENTHANDLER", + ClassID = 0, +} + +--- The EVENTHANDLER constructor +-- @param #EVENTHANDLER self +-- @return #EVENTHANDLER +function EVENTHANDLER:New() + self = BASE:Inherit( self, BASE:New() ) -- #EVENTHANDLER + return self +end diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index 03f3fe9d8..cee744b93 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170214_1049' ) +env.info( 'Moose Generation Timestamp: 20170214_1314' ) local base = _G Include = {} @@ -4173,6 +4173,10 @@ end -- -- @module Event + + + + --- The EVENT structure -- @type EVENT -- @field #EVENT.Events Events @@ -5158,6 +5162,21 @@ function EVENT:onEvent( Event ) end end +--- The EVENTHANDLER structure +-- @type EVENTHANDLER +-- @extends Core.Base#BASE +EVENTHANDLER = { + ClassName = "EVENTHANDLER", + ClassID = 0, +} + +--- The EVENTHANDLER constructor +-- @param #EVENTHANDLER self +-- @return #EVENTHANDLER +function EVENTHANDLER:New() + self = BASE:Inherit( self, BASE:New() ) -- #EVENTHANDLER + return self +end --- This module contains the MENU classes. -- -- === diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 03f3fe9d8..cee744b93 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170214_1049' ) +env.info( 'Moose Generation Timestamp: 20170214_1314' ) local base = _G Include = {} @@ -4173,6 +4173,10 @@ end -- -- @module Event + + + + --- The EVENT structure -- @type EVENT -- @field #EVENT.Events Events @@ -5158,6 +5162,21 @@ function EVENT:onEvent( Event ) end end +--- The EVENTHANDLER structure +-- @type EVENTHANDLER +-- @extends Core.Base#BASE +EVENTHANDLER = { + ClassName = "EVENTHANDLER", + ClassID = 0, +} + +--- The EVENTHANDLER constructor +-- @param #EVENTHANDLER self +-- @return #EVENTHANDLER +function EVENTHANDLER:New() + self = BASE:Inherit( self, BASE:New() ) -- #EVENTHANDLER + return self +end --- This module contains the MENU classes. -- -- === diff --git a/Moose Test Missions/EVT - Event Handling/EVT-401 - Generic OnEventHit Example/EVT-401 - Generic OnEventHit Example.lua b/Moose Test Missions/EVT - Event Handling/EVT-401 - Generic OnEventHit Example/EVT-401 - Generic OnEventHit Example.lua new file mode 100644 index 000000000..4d5946aba --- /dev/null +++ b/Moose Test Missions/EVT - Event Handling/EVT-401 - Generic OnEventHit Example/EVT-401 - Generic OnEventHit Example.lua @@ -0,0 +1,34 @@ +--- +-- Name: EVT-401 - Generic OnEventHit Example +-- Author: FlightControl +-- Date Created: 15 February 2017 +-- +-- # Situation: +-- +-- Ground targets are shooting each other. +-- +-- # Test cases: +-- +-- 1. Observe the ground forces shooting each other. +-- 2. Observe when a tank receives a hit, a dcs.log entry is written in the logging. +-- 3. The generic EventHandler objects should receive the hit events. + +local CC = COMMANDCENTER:New( UNIT:FindByName( "HQ" ), "HQ" ) + +local EventHandler1 = EVENTHANDLER:New() +local EventHandler2 = EVENTHANDLER:New() + +EventHandler1:HandleEvent( EVENTS.Hit ) +EventHandler2:HandleEvent( EVENTS.Hit ) + +function EventHandler1:OnEventHit( EventData ) + self:E("hello 1") + CC:GetPositionable():MessageToAll( "I just got hit!", 15 , "Alert!" ) +end + +function EventHandler2:OnEventHit( EventData ) + self:E("hello 2") + CC:GetPositionable():MessageToAll( "I just got hit!", 15, "Alert!" ) +end + + diff --git a/Moose Test Missions/EVT - Event Handling/EVT-401 - Generic OnEventHit Example/EVT-401 - Generic OnEventHit Example.miz b/Moose Test Missions/EVT - Event Handling/EVT-401 - Generic OnEventHit Example/EVT-401 - Generic OnEventHit Example.miz new file mode 100644 index 000000000..ae9d5d910 Binary files /dev/null and b/Moose Test Missions/EVT - Event Handling/EVT-401 - Generic OnEventHit Example/EVT-401 - Generic OnEventHit Example.miz differ