mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-09-01 02:22:15 +00:00
Merge branch 'master-ng' into FF/PyBridge
This commit is contained in:
@@ -188,6 +188,8 @@ function DATABASE:AddUnit( DCSUnitName, force )
|
||||
|
||||
-- Register unit
|
||||
self.UNITS[DCSunitName]=UNIT:Register(DCSunitName)
|
||||
else
|
||||
self.UNITS[DCSunitName]:ResetOptionCacheIfDCSObjectChanged()
|
||||
end
|
||||
|
||||
return self.UNITS[DCSunitName]
|
||||
@@ -804,6 +806,8 @@ function DATABASE:AddGroup( GroupName, force )
|
||||
if not self.GROUPS[GroupName] or force == true then
|
||||
self:T( { "Add GROUP:", GroupName } )
|
||||
self.GROUPS[GroupName] = GROUP:Register( GroupName )
|
||||
else
|
||||
self.GROUPS[GroupName]:ResetOptionCacheIfDCSObjectChanged()
|
||||
end
|
||||
|
||||
return self.GROUPS[GroupName]
|
||||
|
||||
@@ -278,7 +278,6 @@ EVENTS = {
|
||||
SimulationUnfreeze = world.event.S_EVENT_SIMULATION_UNFREEZE or -1,
|
||||
HumanAircraftRepairStart = world.event.S_EVENT_HUMAN_AIRCRAFT_REPAIR_START or -1,
|
||||
HumanAircraftRepairFinish = world.event.S_EVENT_HUMAN_AIRCRAFT_REPAIR_FINISH or -1,
|
||||
GroupChangeOption = world.event.S_EVENT_GROUP_CHANGE_OPTION or -1,
|
||||
-- dynamic cargo
|
||||
NewDynamicCargo = world.event.S_EVENT_NEW_DYNAMIC_CARGO or -1,
|
||||
DynamicCargoLoaded = world.event.S_EVENT_DYNAMIC_CARGO_LOADED or -1,
|
||||
@@ -292,25 +291,23 @@ EVENTS = {
|
||||
--
|
||||
-- * A (Object.Category.)UNIT : A UNIT object type is involved in the Event.
|
||||
-- * A (Object.Category.)STATIC : A STATIC object type is involved in the Event.
|
||||
-- * A GROUP : A DCS Group object is involved in the Event.
|
||||
--
|
||||
-- @type EVENTDATA
|
||||
-- @field #number id The identifier of the event.
|
||||
--
|
||||
-- @field DCS#Unit initiator (UNIT/STATIC/SCENERY/GROUP) The initiating @{DCS#Unit} or @{DCS#StaticObject}. For `S_EVENT_GROUP_CHANGE_OPTION`, this is a DCS Group.
|
||||
-- @field DCS#Unit initiator (UNIT/STATIC/SCENERY) The initiating @{DCS#Unit} or @{DCS#StaticObject}.
|
||||
-- @field DCS#Object.Category IniObjectCategory (UNIT/STATIC/SCENERY) The initiator object category ( Object.Category.UNIT or Object.Category.STATIC ).
|
||||
-- @field DCS#Unit IniDCSUnit (UNIT/STATIC) The initiating @{DCS#Unit} or @{DCS#StaticObject}.
|
||||
-- @field #string IniDCSUnitName (UNIT/STATIC) The initiating Unit name.
|
||||
-- @field Wrapper.Unit#UNIT IniUnit (UNIT/STATIC) The initiating MOOSE wrapper @{Wrapper.Unit#UNIT} of the initiator Unit object.
|
||||
-- @field #string IniUnitName (UNIT/STATIC) The initiating UNIT name (same as IniDCSUnitName).
|
||||
-- @field DCS#Group IniDCSGroup (UNIT/GROUP) The initiating @{DCS#Group}.
|
||||
-- @field #string IniDCSGroupName (UNIT/GROUP) The initiating Group name.
|
||||
-- @field Wrapper.Group#GROUP IniGroup (UNIT/GROUP) The initiating MOOSE wrapper @{Wrapper.Group#GROUP} of the initiator Group object.
|
||||
-- @field #string IniGroupName (UNIT/GROUP) The initiating GROUP name (same as IniDCSGroupName).
|
||||
-- @field DCS#Group.Category IniGroupCategory (GROUP) The category of the initiating group.
|
||||
-- @field DCS#Group IniDCSGroup (UNIT) The initiating {DCSGroup#Group}.
|
||||
-- @field #string IniDCSGroupName (UNIT) The initiating Group name.
|
||||
-- @field Wrapper.Group#GROUP IniGroup (UNIT) The initiating MOOSE wrapper @{Wrapper.Group#GROUP} of the initiator Group object.
|
||||
-- @field #string IniGroupName UNIT) The initiating GROUP name (same as IniDCSGroupName).
|
||||
-- @field #string IniPlayerName (UNIT) The name of the initiating player in case the Unit is a client or player slot.
|
||||
-- @field #string IniPlayerUCID (UNIT) The UCID of the initiating player in case the Unit is a client or player slot and on a multi-player server.
|
||||
-- @field DCS#coalition.side IniCoalition (UNIT/GROUP) The coalition of the initiator.
|
||||
-- @field DCS#coalition.side IniCoalition (UNIT) The coalition of the initiator.
|
||||
-- @field DCS#Unit.Category IniCategory (UNIT) The category of the initiator.
|
||||
-- @field #string IniTypeName (UNIT) The type name of the initiator.
|
||||
--
|
||||
@@ -737,12 +734,6 @@ local _EVENTMETA = {
|
||||
Side = "I",
|
||||
Event = "OnEventHumanAircraftRepairFinish",
|
||||
Text = "S_EVENT_HUMAN_AIRCRAFT_REPAIR_FINISH"
|
||||
},
|
||||
[EVENTS.GroupChangeOption] = {
|
||||
Order = 1,
|
||||
Side = "I",
|
||||
Event = "OnEventGroupChangeOption",
|
||||
Text = "S_EVENT_GROUP_CHANGE_OPTION"
|
||||
},
|
||||
-- dynamic cargo
|
||||
[EVENTS.NewDynamicCargo] = {
|
||||
@@ -1243,16 +1234,7 @@ function EVENT:onEvent( Event )
|
||||
|
||||
if Event.initiator then
|
||||
|
||||
if Event.id == EVENTS.GroupChangeOption then
|
||||
Event.IniDCSGroup = Event.initiator
|
||||
Event.IniDCSGroupName = Group.getName(Event.initiator)
|
||||
Event.IniGroupName = Event.IniDCSGroupName
|
||||
Event.IniGroup = GROUP:FindByName(Event.IniDCSGroupName)
|
||||
Event.IniCoalition = Group.getCoalition(Event.initiator)
|
||||
Event.IniGroupCategory = Group.getCategory(Event.initiator)
|
||||
else
|
||||
Event.IniObjectCategory = Object.getCategory(Event.initiator)
|
||||
end
|
||||
Event.IniObjectCategory = Object.getCategory(Event.initiator)
|
||||
|
||||
if Event.IniObjectCategory == Object.Category.STATIC then
|
||||
---
|
||||
@@ -1681,7 +1663,9 @@ function EVENT:onEvent( Event )
|
||||
self:T( { EventMeta.Text, Event } )
|
||||
end
|
||||
else
|
||||
self:E(string.format("WARNING: Could not get EVENTMETA data for event ID=%d! Is this an unknown/new DCS event?", tostring(Event.id)))
|
||||
if Event.id ~= 61 then --- TODO Event 61 is new, but seems to have no real data to be useable, something like option changed.
|
||||
self:E(string.format("WARNING: Could not get EVENTMETA data for event ID=%d! Is this an unknown/new DCS event?", tostring(Event.id)))
|
||||
end
|
||||
end
|
||||
|
||||
Event = nil
|
||||
|
||||
@@ -1880,6 +1880,11 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
||||
-- SpawnTemplate.uncontrolled = self.SpawnUnControlled
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
if self.BeforeTemplateSpawnFunc then
|
||||
self:BeforeTemplateSpawnFunc(SpawnTemplate, SpawnIndex)
|
||||
end
|
||||
end
|
||||
|
||||
if not NoBirth then
|
||||
@@ -1995,6 +2000,31 @@ function SPAWN:SpawnScheduleStop()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Allows to place a CallFunction hook just before spawning the group to tweak the template.
|
||||
-- The provided method will be called just before a new group is spawned, including its given parameters.
|
||||
-- The first parameter of the BeforeTemplateSpawnFunc is the raw Template used to spawn the group, the second is the SpawnIndex.
|
||||
-- @param #SPAWN self
|
||||
-- @param #function BeforeTemplateSpawnFunc The function to be called before the group spawns.
|
||||
-- @return #SPAWN
|
||||
-- @usage
|
||||
--
|
||||
-- -- Declare SpawnObject and call a function when a new Group is spawned.
|
||||
-- local SpawnObject = SPAWN:New( "SpawnObject" )
|
||||
-- :InitLimit( 2, 10 )
|
||||
-- :OnBeforeTemplateSpawnGroup( function( Spawn, SpawnTemplate, SpawnIndex )
|
||||
-- Tweaking the template units
|
||||
-- end
|
||||
-- )
|
||||
-- :SpawnScheduled( 300, 0.3 )
|
||||
--
|
||||
function SPAWN:OnBeforeTemplateSpawnGroup( BeforeTemplateSpawnFunc )
|
||||
--self:F( "OnBeforeTemplateSpawnGroup" )
|
||||
|
||||
self.BeforeTemplateSpawnFunc = BeforeTemplateSpawnFunc
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Allows to place a CallFunction hook when a new group spawns.
|
||||
-- The provided method will be called when a new group is spawned, including its given parameters.
|
||||
-- The first parameter of the SpawnFunction is the @{Wrapper.Group#GROUP} that was spawned.
|
||||
|
||||
Reference in New Issue
Block a user