mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #241 from FlightControl-Master/master-bugfix
Added EVENTHANDLER class for generic event handling
This commit is contained in:
commit
83d07017c3
@ -152,6 +152,10 @@
|
|||||||
--
|
--
|
||||||
-- @module Event
|
-- @module Event
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- The EVENT structure
|
--- The EVENT structure
|
||||||
-- @type EVENT
|
-- @type EVENT
|
||||||
-- @field #EVENT.Events Events
|
-- @field #EVENT.Events Events
|
||||||
@ -1137,3 +1141,18 @@ function EVENT:onEvent( Event )
|
|||||||
end
|
end
|
||||||
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
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
|
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
|
||||||
env.info( 'Moose Generation Timestamp: 20170214_1049' )
|
env.info( 'Moose Generation Timestamp: 20170214_1314' )
|
||||||
local base = _G
|
local base = _G
|
||||||
|
|
||||||
Include = {}
|
Include = {}
|
||||||
@ -4173,6 +4173,10 @@ end
|
|||||||
--
|
--
|
||||||
-- @module Event
|
-- @module Event
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- The EVENT structure
|
--- The EVENT structure
|
||||||
-- @type EVENT
|
-- @type EVENT
|
||||||
-- @field #EVENT.Events Events
|
-- @field #EVENT.Events Events
|
||||||
@ -5158,6 +5162,21 @@ function EVENT:onEvent( Event )
|
|||||||
end
|
end
|
||||||
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.
|
--- This module contains the MENU classes.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
|
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
|
||||||
env.info( 'Moose Generation Timestamp: 20170214_1049' )
|
env.info( 'Moose Generation Timestamp: 20170214_1314' )
|
||||||
local base = _G
|
local base = _G
|
||||||
|
|
||||||
Include = {}
|
Include = {}
|
||||||
@ -4173,6 +4173,10 @@ end
|
|||||||
--
|
--
|
||||||
-- @module Event
|
-- @module Event
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- The EVENT structure
|
--- The EVENT structure
|
||||||
-- @type EVENT
|
-- @type EVENT
|
||||||
-- @field #EVENT.Events Events
|
-- @field #EVENT.Events Events
|
||||||
@ -5158,6 +5162,21 @@ function EVENT:onEvent( Event )
|
|||||||
end
|
end
|
||||||
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.
|
--- This module contains the MENU classes.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user