Event Handling Optimization

-- Created a HandleEvent method
-- Created an UnHandleEvent method
This commit is contained in:
FlightControl
2017-02-07 13:33:29 +01:00
parent 154f729788
commit 3db8062583
95 changed files with 63884 additions and 43 deletions
@@ -33,4 +33,8 @@ function Tank2:OnEventDead( EventData )
self:SmokeBlue()
end
function Tank2:OnEventCrash(EventData)
end
@@ -0,0 +1,25 @@
---
-- Name: EVT-100 - OnEventShot Example
-- Author: FlightControl
-- Date Created: 7 February 2017
--
-- # Situation:
--
-- A plane is flying in the air and shoots an missile to a ground target.
--
-- # Test cases:
--
-- 1. Observe the plane shooting the missile.
-- 2. Observe when the plane shoots the missile, a dcs.log entry is written in the logging.
-- 3. Check the contents of the fields of the S_EVENT_SHOT entry.
local Plane = UNIT:FindByName( "Plane" )
Plane:HandleEvent( EVENTS.Shot )
function Plane:OnEventShot( EventData )
Plane:MessageToAll( "I just fired a missile!", 15, "Alert!" )
end
@@ -0,0 +1,32 @@
---
-- Name: EVT-101 - OnEventHit Example
-- Author: FlightControl
-- Date Created: 7 February 2017
--
-- # Situation:
--
-- A plane is flying in the air and shoots an missile to a ground target.
--
-- # Test cases:
--
-- 1. Observe the plane shooting the missile.
-- 2. Observe when the missile hits the target, a dcs.log entry is written in the logging.
-- 3. Check the contents of the fields of the S_EVENT_HIT entry.
local Plane = UNIT:FindByName( "Plane" )
local Tank = UNIT:FindByName( "Tank" )
Plane:HandleEvent( EVENTS.Hit )
Tank:HandleEvent( EVENTS.Hit )
function Plane:OnEventHit( EventData )
Plane:MessageToAll( "I just got hit!", 15, "Alert!" )
end
function Tank:OnEventHit( EventData )
Tank:MessageToAll( "I just got hit!", 15, "Alert!" )
end
@@ -0,0 +1,33 @@
---
-- Name: EVT-102 - OnEventTakeoff Example
-- Author: FlightControl
-- Date Created: 7 February 2017
--
-- # Situation:
--
-- A human plane and an AI plane are taking off from an airfield.
--
-- # Test cases:
--
-- 1. Take-Off the planes from the runway.
-- 2. When the planes take-off, observe the message being sent.
-- 3. Check the contents of the fields of the S_EVENT_TAKEOFF entry in the dcs.log file.
local PlaneAI = UNIT:FindByName( "PlaneAI" )
local PlaneHuman = UNIT:FindByName( "PlaneHuman" )
PlaneAI:HandleEvent( EVENTS.Takeoff )
PlaneHuman:HandleEvent( EVENTS.Takeoff )
function PlaneAI:OnEventTakeoff( EventData )
PlaneHuman:MessageToAll( "AI Taking Off", 15, "Alert!" )
end
function PlaneHuman:OnEventTakeoff( EventData )
PlaneHuman:MessageToAll( "Player " .. PlaneHuman:GetPlayerName() .. " is Taking Off", 15, "Alert!" )
end
Binary file not shown.