mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Updates and fixes
- Replaced range test for unit to range test for players. - Ensure that players database is properly populated. - Fixed some documentation. - Removed smoke from trigger. - Fixed name of RandomPointVec2 to RandomVec2 and fixed in all usages.
This commit is contained in:
@@ -8,12 +8,12 @@
|
||||
--
|
||||
-- * UNITS
|
||||
-- * GROUPS
|
||||
-- * players
|
||||
-- * alive players
|
||||
-- * CLIENTS
|
||||
-- * alive CLIENTS
|
||||
-- * AIRPORTS
|
||||
-- * PLAYERSJOINED
|
||||
-- * PLAYERS
|
||||
--
|
||||
-- On top, for internal MOOSE administration purposes, the DATBASE administers the Unit and Gruop templates as defined within the Mission Editor.
|
||||
-- On top, for internal MOOSE administration purposes, the DATBASE administers the Unit and Group TEMPLATES as defined within the Mission Editor.
|
||||
--
|
||||
-- Moose will automatically create one instance of the DATABASE class into the **global** object _DATABASE.
|
||||
-- Moose refers to _DATABASE within the framework extensively, but you can also refer to the _DATABASE object within your missions if required.
|
||||
@@ -26,11 +26,13 @@
|
||||
--
|
||||
-- * @{#DATABASE.ForEachUnit}: Calls a function for each @{UNIT} it finds within the DATABASE.
|
||||
-- * @{#DATABASE.ForEachGroup}: Calls a function for each @{GROUP} it finds within the DATABASE.
|
||||
-- * @{#DATABASE.ForEachPlayer}: Calls a function for each player it finds within the DATABASE.
|
||||
-- * @{#DATABASE.ForEachPlayerAlive}: Calls a function for each alive player it finds within the DATABASE.
|
||||
-- * @{#DATABASE.ForEachPlayer}: Calls a function for each alive player it finds within the DATABASE.
|
||||
-- * @{#DATABASE.ForEachPlayerJoined}: Calls a function for each joined player it finds within the DATABASE.
|
||||
-- * @{#DATABASE.ForEachClient}: Calls a function for each @{CLIENT} it finds within the DATABASE.
|
||||
-- * @{#DATABASE.ForEachClientAlive}: Calls a function for each alive @{CLIENT} it finds within the DATABASE.
|
||||
--
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- @module Database
|
||||
-- @author FlightControl
|
||||
|
||||
@@ -49,9 +51,8 @@ DATABASE = {
|
||||
STATICS = {},
|
||||
GROUPS = {},
|
||||
PLAYERS = {},
|
||||
PLAYERSALIVE = {},
|
||||
PLAYERSJOINED = {},
|
||||
CLIENTS = {},
|
||||
CLIENTSALIVE = {},
|
||||
AIRBASES = {},
|
||||
NavPoints = {},
|
||||
}
|
||||
@@ -238,9 +239,8 @@ function DATABASE:AddPlayer( UnitName, PlayerName )
|
||||
|
||||
if PlayerName then
|
||||
self:E( { "Add player for unit:", UnitName, PlayerName } )
|
||||
self.PLAYERS[PlayerName] = PlayerName
|
||||
self.PLAYERSALIVE[PlayerName] = PlayerName
|
||||
self.CLIENTSALIVE[PlayerName] = self:FindClient( UnitName )
|
||||
self.PLAYERS[PlayerName] = UNIT:FindByName( UnitName )
|
||||
self.PLAYERSJOINED[PlayerName] = PlayerName
|
||||
end
|
||||
end
|
||||
|
||||
@@ -250,8 +250,7 @@ function DATABASE:DeletePlayer( PlayerName )
|
||||
|
||||
if PlayerName then
|
||||
self:E( { "Clean player:", PlayerName } )
|
||||
self.PLAYERSALIVE[PlayerName] = nil
|
||||
self.CLIENTSALIVE[PlayerName] = nil
|
||||
self.PLAYERS[PlayerName] = nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -547,10 +546,10 @@ end
|
||||
function DATABASE:_EventOnPlayerEnterUnit( Event )
|
||||
self:F2( { Event } )
|
||||
|
||||
if Event.IniDCSUnit then
|
||||
local PlayerName = Event.IniDCSUnit:getPlayerName()
|
||||
if not self.PLAYERSALIVE[PlayerName] then
|
||||
self:AddPlayer( Event.IniDCSUnitName, PlayerName )
|
||||
if Event.IniUnit then
|
||||
local PlayerName = Event.IniUnit:GetPlayerName()
|
||||
if not self.PLAYERS[PlayerName] then
|
||||
self:AddPlayer( Event.IniUnitName, PlayerName )
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -562,9 +561,9 @@ end
|
||||
function DATABASE:_EventOnPlayerLeaveUnit( Event )
|
||||
self:F2( { Event } )
|
||||
|
||||
if Event.IniDCSUnit then
|
||||
local PlayerName = Event.IniDCSUnit:getPlayerName()
|
||||
if self.PLAYERSALIVE[PlayerName] then
|
||||
if Event.IniUnit then
|
||||
local PlayerName = Event.IniUnit:GetPlayerName()
|
||||
if self.PLAYERS[PlayerName] then
|
||||
self:DeletePlayer( PlayerName )
|
||||
end
|
||||
end
|
||||
@@ -644,7 +643,7 @@ function DATABASE:ForEachGroup( IteratorFunction, ... )
|
||||
end
|
||||
|
||||
|
||||
--- Iterate the DATABASE and call an iterator function for each player, providing the player name and optional parameters.
|
||||
--- Iterate the DATABASE and call an iterator function for each **ALIVE** player, providing the player name and optional parameters.
|
||||
-- @param #DATABASE self
|
||||
-- @param #function IteratorFunction The function that will be called when there is an player in the database. The function needs to accept the player name.
|
||||
-- @return #DATABASE self
|
||||
@@ -657,14 +656,14 @@ function DATABASE:ForEachPlayer( IteratorFunction, ... )
|
||||
end
|
||||
|
||||
|
||||
--- Iterate the DATABASE and call an iterator function for each **alive** player, providing the Unit of the player and optional parameters.
|
||||
--- Iterate the DATABASE and call an iterator function for each player who has joined the mission, providing the Unit of the player and optional parameters.
|
||||
-- @param #DATABASE self
|
||||
-- @param #function IteratorFunction The function that will be called when there is an alive player in the database. The function needs to accept a UNIT parameter.
|
||||
-- @param #function IteratorFunction The function that will be called when there is was a player in the database. The function needs to accept a UNIT parameter.
|
||||
-- @return #DATABASE self
|
||||
function DATABASE:ForEachPlayerAlive( IteratorFunction, ... )
|
||||
function DATABASE:ForEachPlayerJoined( IteratorFunction, ... )
|
||||
self:F2( arg )
|
||||
|
||||
self:ForEach( IteratorFunction, arg, self.PLAYERSALIVE )
|
||||
self:ForEach( IteratorFunction, arg, self.PLAYERSJOINED )
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -681,18 +680,6 @@ function DATABASE:ForEachClient( IteratorFunction, ... )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Iterate the DATABASE and call an iterator function for each **ALIVE** CLIENT, providing the CLIENT to the function and optional parameters.
|
||||
-- @param #DATABASE self
|
||||
-- @param #function IteratorFunction The function that will be called when there is an alive CLIENT in the database. The function needs to accept a CLIENT parameter.
|
||||
-- @return #DATABASE self
|
||||
function DATABASE:ForEachClientAlive( IteratorFunction, ... )
|
||||
self:F2( arg )
|
||||
|
||||
self:ForEach( IteratorFunction, arg, self.CLIENTSALIVE )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
function DATABASE:_RegisterTemplates()
|
||||
self:F2()
|
||||
|
||||
Reference in New Issue
Block a user