COMMANDCENTER class added, Event handlers added, HQs working with missions

- Handling menus
- Reporting missions
- ...
This commit is contained in:
FlightControl
2016-11-25 14:08:06 +01:00
parent c27b6efe12
commit 28802ba276
18 changed files with 525 additions and 60 deletions

View File

@@ -231,6 +231,84 @@ function BASE:EventRemoveAll()
return self
end
--- Subscribe to a S_EVENT_SHOT event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnShot( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOT )
return self
end
--- Subscribe to a S_EVENT_HIT event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnHit( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_HIT )
return self
end
--- Subscribe to a S_EVENT_TAKEOFF event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnTakeOff( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_TAKEOFF )
return self
end
--- Subscribe to a S_EVENT_LAND event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnLand( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_LAND )
return self
end
--- Subscribe to a S_EVENT_CRASH event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnCrash( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_CRASH )
return self
end
--- Subscribe to a S_EVENT_EJECTION event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnEjection( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_EJECTION )
return self
end
--- Subscribe to a S_EVENT_REFUELING event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnRefueling( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_REFUELING )
return self
end
--- Subscribe to a S_EVENT_DEAD event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
@@ -242,6 +320,171 @@ function BASE:EventOnDead( EventFunction )
return self
end
--- Subscribe to a S_EVENT_PILOT_DEAD event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnPilotDead( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PILOT_DEAD )
return self
end
--- Subscribe to a S_EVENT_BASE_CAPTURED event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnBaseCaptured( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_BASE_CAPTURED )
return self
end
--- Subscribe to a S_EVENT_MISSION_START event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnMissionStart( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_MISSION_START )
return self
end
--- Subscribe to a S_EVENT_MISSION_END event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnPlayerMissionEnd( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_MISSION_END )
return self
end
--- Subscribe to a S_EVENT_TOOK_CONTROL event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnTookControl( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_TOOK_CONTROL )
return self
end
--- Subscribe to a S_EVENT_REFUELING_STOP event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnRefuelingStop( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_REFUELING_STOP )
return self
end
--- Subscribe to a S_EVENT_BIRTH event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnBirth( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_BIRTH )
return self
end
--- Subscribe to a S_EVENT_HUMAN_FAILURE event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnHumanFailure( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_HUMAN_FAILURE )
return self
end
--- Subscribe to a S_EVENT_ENGINE_STARTUP event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnEngineStartup( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_ENGINE_STARTUP )
return self
end
--- Subscribe to a S_EVENT_ENGINE_SHUTDOWN event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnEngineShutdown( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_ENGINE_SHUTDOWN )
return self
end
--- Subscribe to a S_EVENT_PLAYER_ENTER_UNIT event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnPlayerEnterUnit( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_ENTER_UNIT )
return self
end
--- Subscribe to a S_EVENT_PLAYER_LEAVE_UNIT event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnPlayerLeaveUnit( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_LEAVE_UNIT )
return self
end
--- Subscribe to a S_EVENT_PLAYER_COMMENT event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnPlayerComment( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_COMMENT )
return self
end
--- Subscribe to a S_EVENT_SHOOTING_START event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnShootingStart( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOOTING_START )
return self
end
--- Subscribe to a S_EVENT_SHOOTING_END event.
-- @param #BASE self
-- @param #function EventFunction The function to be called when the event occurs for the unit.
-- @return #BASE
function BASE:EventOnShootingEnd( EventFunction )
_EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOOTING_END )
return self
end

View File

@@ -45,13 +45,13 @@ local _EVENTCODES = {
-- @field weapon
-- @field IniDCSUnit
-- @field IniDCSUnitName
-- @field Unit#UNIT IniUnit
-- @field Wrapper.Unit#UNIT IniUnit
-- @field #string IniUnitName
-- @field IniDCSGroup
-- @field IniDCSGroupName
-- @field TgtDCSUnit
-- @field TgtDCSUnitName
-- @field Unit#UNIT TgtUnit
-- @field Wrapper.Unit#UNIT TgtUnit
-- @field #string TgtUnitName
-- @field TgtDCSGroup
-- @field TgtDCSGroupName

View File

@@ -54,7 +54,11 @@ function MESSAGE:New( MessageText, MessageDuration, MessageCategory )
-- When no MessageCategory is given, we don't show it as a title...
if MessageCategory and MessageCategory ~= "" then
self.MessageCategory = MessageCategory .. ": "
if MessageCategory:sub(-1) ~= "\n" then
self.MessageCategory = MessageCategory .. ": "
else
self.MessageCategory = MessageCategory:sub( 1, -2 ) .. ":\n"
end
else
self.MessageCategory = ""
end

View File

@@ -720,7 +720,7 @@ end
--- SET_GROUP class
-- @type SET_GROUP
-- @extends Set#SET_BASE
-- @extends #SET_BASE
SET_GROUP = {
ClassName = "SET_GROUP",
Filter = {

View File

@@ -40,29 +40,29 @@ function STATEMACHINE:New( options )
--setmetatable( self, MT )
--self.__index = self
self.options = options
self.options = options or {}
self.options.subs = self.options.subs or {}
self.current = options.initial or 'none'
self.current = self.options.initial or 'none'
self.events = {}
self.subs = {}
self.endstates = {}
for _, event in pairs(options.events or {}) do
for _, event in pairs( self.options.events or {}) do
self:T3({ "events", event })
self:_eventmap( self.events, event )
end
for name, callback in pairs(options.callbacks or {}) do
for name, callback in pairs( self.options.callbacks or {}) do
self:T3("callbacks")
self[name] = callback
end
for name, sub in pairs( options.subs or {} ) do
for name, sub in pairs( self.options.subs or {} ) do
self:T3("sub")
self:_submap( self.subs, sub, name )
end
for name, endstate in pairs( options.endstates or {} ) do
for name, endstate in pairs( self.options.endstates or {} ) do
self:T3("endstate")
self.endstates[endstate] = endstate
end
@@ -104,7 +104,7 @@ function STATEMACHINE:AddProcess( From, Event, Process, ReturnEvents )
self:_submap( self.subs, sub, nil )
self:AddAction( From, Event, "*" )
self:AddAction( From, Event, From )
return Process
end