mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-23 19:45:29 +00:00
Event prefix can be nil, if the event occurs on a non-spawned group with no # tag.
This commit is contained in:
@@ -1595,12 +1595,14 @@ function SPAWN:_OnBirth( EventData )
|
|||||||
|
|
||||||
if SpawnGroup then
|
if SpawnGroup then
|
||||||
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
||||||
|
if EventPrefix then -- EventPrefix can be nil if no # is found, which means, no spawnable group!
|
||||||
self:T( { "Birth Event:", EventPrefix, self.SpawnTemplatePrefix } )
|
self:T( { "Birth Event:", EventPrefix, self.SpawnTemplatePrefix } )
|
||||||
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
||||||
self.AliveUnits = self.AliveUnits + 1
|
self.AliveUnits = self.AliveUnits + 1
|
||||||
self:T( "Alive Units: " .. self.AliveUnits )
|
self:T( "Alive Units: " .. self.AliveUnits )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1616,6 +1618,7 @@ function SPAWN:_OnDeadOrCrash( EventData )
|
|||||||
|
|
||||||
if SpawnGroup then
|
if SpawnGroup then
|
||||||
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
||||||
|
if EventPrefix then -- EventPrefix can be nil if no # is found, which means, no spawnable group!
|
||||||
self:T( { "Dead event: " .. EventPrefix } )
|
self:T( { "Dead event: " .. EventPrefix } )
|
||||||
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
||||||
self.AliveUnits = self.AliveUnits - 1
|
self.AliveUnits = self.AliveUnits - 1
|
||||||
@@ -1623,6 +1626,7 @@ function SPAWN:_OnDeadOrCrash( EventData )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Will detect AIR Units taking off... When the event takes place, the spawned Group is registered as airborne...
|
--- Will detect AIR Units taking off... When the event takes place, the spawned Group is registered as airborne...
|
||||||
-- This is needed to ensure that Re-SPAWNing only is done for landed AIR Groups.
|
-- This is needed to ensure that Re-SPAWNing only is done for landed AIR Groups.
|
||||||
@@ -1634,6 +1638,7 @@ function SPAWN:_OnTakeOff( EventData )
|
|||||||
local SpawnGroup = EventData.IniGroup
|
local SpawnGroup = EventData.IniGroup
|
||||||
if SpawnGroup then
|
if SpawnGroup then
|
||||||
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
||||||
|
if EventPrefix then -- EventPrefix can be nil if no # is found, which means, no spawnable group!
|
||||||
self:T( { "TakeOff event: " .. EventPrefix } )
|
self:T( { "TakeOff event: " .. EventPrefix } )
|
||||||
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
||||||
self:T( "self.Landed = false" )
|
self:T( "self.Landed = false" )
|
||||||
@@ -1641,6 +1646,7 @@ function SPAWN:_OnTakeOff( EventData )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Will detect AIR Units landing... When the event takes place, the spawned Group is registered as landed.
|
--- Will detect AIR Units landing... When the event takes place, the spawned Group is registered as landed.
|
||||||
-- This is needed to ensure that Re-SPAWNing is only done for landed AIR Groups.
|
-- This is needed to ensure that Re-SPAWNing is only done for landed AIR Groups.
|
||||||
@@ -1652,6 +1658,7 @@ function SPAWN:_OnLand( EventData )
|
|||||||
local SpawnGroup = EventData.IniGroup
|
local SpawnGroup = EventData.IniGroup
|
||||||
if SpawnGroup then
|
if SpawnGroup then
|
||||||
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
||||||
|
if EventPrefix then -- EventPrefix can be nil if no # is found, which means, no spawnable group!
|
||||||
self:T( { "Land event: " .. EventPrefix } )
|
self:T( { "Land event: " .. EventPrefix } )
|
||||||
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
||||||
-- TODO: Check if this is the last unit of the group that lands.
|
-- TODO: Check if this is the last unit of the group that lands.
|
||||||
@@ -1664,6 +1671,7 @@ function SPAWN:_OnLand( EventData )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Will detect AIR Units shutting down their engines ...
|
--- Will detect AIR Units shutting down their engines ...
|
||||||
-- When the event takes place, and the method @{RepeatOnEngineShutDown} was called, the spawned Group will Re-SPAWN.
|
-- When the event takes place, and the method @{RepeatOnEngineShutDown} was called, the spawned Group will Re-SPAWN.
|
||||||
@@ -1676,6 +1684,7 @@ function SPAWN:_OnEngineShutDown( EventData )
|
|||||||
local SpawnGroup = EventData.IniGroup
|
local SpawnGroup = EventData.IniGroup
|
||||||
if SpawnGroup then
|
if SpawnGroup then
|
||||||
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
local EventPrefix = self:_GetPrefixFromGroup( SpawnGroup )
|
||||||
|
if EventPrefix then -- EventPrefix can be nil if no # is found, which means, no spawnable group!
|
||||||
self:T( { "EngineShutdown event: " .. EventPrefix } )
|
self:T( { "EngineShutdown event: " .. EventPrefix } )
|
||||||
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
||||||
-- todo: test if on the runway
|
-- todo: test if on the runway
|
||||||
@@ -1688,6 +1697,7 @@ function SPAWN:_OnEngineShutDown( EventData )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- This function is called automatically by the Spawning scheduler.
|
--- This function is called automatically by the Spawning scheduler.
|
||||||
-- It is the internal worker method SPAWNing new Groups on the defined time intervals.
|
-- It is the internal worker method SPAWNing new Groups on the defined time intervals.
|
||||||
|
|||||||
Reference in New Issue
Block a user