mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-30 22:18:02 +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
|
||||
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 } )
|
||||
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
||||
self.AliveUnits = self.AliveUnits + 1
|
||||
self:T( "Alive Units: " .. self.AliveUnits )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1616,12 +1618,14 @@ function SPAWN:_OnDeadOrCrash( EventData )
|
||||
|
||||
if SpawnGroup then
|
||||
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 } )
|
||||
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
||||
self.AliveUnits = self.AliveUnits - 1
|
||||
self:T( "Alive Units: " .. self.AliveUnits )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Will detect AIR Units taking off... When the event takes place, the spawned Group is registered as airborne...
|
||||
@@ -1634,12 +1638,14 @@ function SPAWN:_OnTakeOff( EventData )
|
||||
local SpawnGroup = EventData.IniGroup
|
||||
if SpawnGroup then
|
||||
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 } )
|
||||
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
||||
self:T( "self.Landed = false" )
|
||||
SpawnGroup:SetState( SpawnGroup, "Spawn_Landed", false )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Will detect AIR Units landing... When the event takes place, the spawned Group is registered as landed.
|
||||
@@ -1652,6 +1658,7 @@ function SPAWN:_OnLand( EventData )
|
||||
local SpawnGroup = EventData.IniGroup
|
||||
if SpawnGroup then
|
||||
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 } )
|
||||
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.
|
||||
@@ -1663,6 +1670,7 @@ function SPAWN:_OnLand( EventData )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Will detect AIR Units shutting down their engines ...
|
||||
@@ -1676,6 +1684,7 @@ function SPAWN:_OnEngineShutDown( EventData )
|
||||
local SpawnGroup = EventData.IniGroup
|
||||
if SpawnGroup then
|
||||
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 } )
|
||||
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) then
|
||||
-- todo: test if on the runway
|
||||
@@ -1687,6 +1696,7 @@ function SPAWN:_OnEngineShutDown( EventData )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- This function is called automatically by the Spawning scheduler.
|
||||
|
||||
Reference in New Issue
Block a user