mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Client
This commit is contained in:
parent
f725039da5
commit
787151597c
@ -468,6 +468,8 @@ end
|
|||||||
|
|
||||||
--- Adds a CLIENT based on the ClientName in the DATABASE.
|
--- Adds a CLIENT based on the ClientName in the DATABASE.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
|
-- @param #string ClientName Name of the Client unit.
|
||||||
|
-- @return Wrapper.Client#CLIENT The client object.
|
||||||
function DATABASE:AddClient( ClientName )
|
function DATABASE:AddClient( ClientName )
|
||||||
|
|
||||||
if not self.CLIENTS[ClientName] then
|
if not self.CLIENTS[ClientName] then
|
||||||
@ -863,7 +865,7 @@ end
|
|||||||
function DATABASE:_RegisterClients()
|
function DATABASE:_RegisterClients()
|
||||||
|
|
||||||
for ClientName, ClientTemplate in pairs( self.Templates.ClientsByName ) do
|
for ClientName, ClientTemplate in pairs( self.Templates.ClientsByName ) do
|
||||||
self:I(string.format("Register Client %s", tostring(ClientName)))
|
self:I(string.format("Register Client: %s", tostring(ClientName)))
|
||||||
self:AddClient( ClientName )
|
self:AddClient( ClientName )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -968,16 +970,28 @@ function DATABASE:_EventOnBirth( Event )
|
|||||||
Event.IniUnit = self:FindUnit( Event.IniDCSUnitName )
|
Event.IniUnit = self:FindUnit( Event.IniDCSUnitName )
|
||||||
Event.IniGroup = self:FindGroup( Event.IniDCSGroupName )
|
Event.IniGroup = self:FindGroup( Event.IniDCSGroupName )
|
||||||
|
|
||||||
|
-- TODO: create event ClientAlive
|
||||||
|
local client=self.CLIENTS[Event.IniDCSUnitName] --Wrapper.Client#CLIENT
|
||||||
|
|
||||||
|
if client then
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-- Get player name.
|
-- Get player name.
|
||||||
local PlayerName = Event.IniUnit:GetPlayerName()
|
local PlayerName = Event.IniUnit:GetPlayerName()
|
||||||
|
|
||||||
if PlayerName then
|
if PlayerName then
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(string.format("Player %s joint unit %s of group %s", tostring(PlayerName), tostring(Event.IniDCSUnitName), tostring(Event.IniDCSGroupName)))
|
self:I(string.format("Player '%s' joint unit '%s' of group '%s'", tostring(PlayerName), tostring(Event.IniDCSUnitName), tostring(Event.IniDCSGroupName)))
|
||||||
|
|
||||||
-- Add client.
|
-- Add client in case it does not exist already.
|
||||||
self:AddClient( Event.IniDCSUnitName )
|
if not client then
|
||||||
|
client=self:AddClient(Event.IniDCSUnitName)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add player.
|
||||||
|
client:AddPlayer(PlayerName)
|
||||||
|
|
||||||
-- Add player.
|
-- Add player.
|
||||||
if not self.PLAYERS[PlayerName] then
|
if not self.PLAYERS[PlayerName] then
|
||||||
@ -988,10 +1002,9 @@ function DATABASE:_EventOnBirth( Event )
|
|||||||
local Settings = SETTINGS:Set( PlayerName )
|
local Settings = SETTINGS:Set( PlayerName )
|
||||||
Settings:SetPlayerMenu(Event.IniUnit)
|
Settings:SetPlayerMenu(Event.IniUnit)
|
||||||
|
|
||||||
end
|
-- Create an event.
|
||||||
|
|
||||||
if PlayerName or self.CLIENTS[Event.IniDCSUnitName] then
|
|
||||||
self:CreateEventPlayerEnterAircraft(Event.IniUnit)
|
self:CreateEventPlayerEnterAircraft(Event.IniUnit)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -67,6 +67,7 @@ CLIENT = {
|
|||||||
_Menus = {},
|
_Menus = {},
|
||||||
_Tasks = {},
|
_Tasks = {},
|
||||||
Messages = {},
|
Messages = {},
|
||||||
|
Players = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -146,11 +147,6 @@ function CLIENT:Register( ClientName )
|
|||||||
self.MessageSwitch = true
|
self.MessageSwitch = true
|
||||||
self.ClientAlive2 = false
|
self.ClientAlive2 = false
|
||||||
|
|
||||||
--self.AliveCheckScheduler = routines.scheduleFunction( self._AliveCheckScheduler, { self }, timer.getTime() + 1, 5 )
|
|
||||||
self.AliveCheckScheduler = SCHEDULER:New( self, self._AliveCheckScheduler, { "Client Alive " .. ClientName }, 1, 5, 0.5 )
|
|
||||||
self.AliveCheckScheduler:NoTrace()
|
|
||||||
|
|
||||||
self:F( self )
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -159,29 +155,68 @@ end
|
|||||||
-- @param #CLIENT self
|
-- @param #CLIENT self
|
||||||
-- @return #CLIENT self
|
-- @return #CLIENT self
|
||||||
function CLIENT:Transport()
|
function CLIENT:Transport()
|
||||||
self:F()
|
|
||||||
|
|
||||||
self.ClientTransport = true
|
self.ClientTransport = true
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- AddBriefing adds a briefing to a CLIENT when a player joins a mission.
|
--- Adds a briefing to a CLIENT when a player joins a mission.
|
||||||
-- @param #CLIENT self
|
-- @param #CLIENT self
|
||||||
-- @param #string ClientBriefing is the text defining the Mission briefing.
|
-- @param #string ClientBriefing is the text defining the Mission briefing.
|
||||||
-- @return #CLIENT self
|
-- @return #CLIENT self
|
||||||
function CLIENT:AddBriefing( ClientBriefing )
|
function CLIENT:AddBriefing( ClientBriefing )
|
||||||
self:F( ClientBriefing )
|
|
||||||
self.ClientBriefing = ClientBriefing
|
self.ClientBriefing = ClientBriefing
|
||||||
self.ClientBriefingShown = false
|
self.ClientBriefingShown = false
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add player name.
|
||||||
|
-- @param #CLIENT self
|
||||||
|
-- @param #string PlayerName Name of the player.
|
||||||
|
-- @return #CLIENT self
|
||||||
|
function CLIENT:AddPlayer(PlayerName)
|
||||||
|
|
||||||
|
table.insert(self.Players, PlayerName)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get player name(s).
|
||||||
|
-- @param #CLIENT self
|
||||||
|
-- @return #table List of player names.
|
||||||
|
function CLIENT:GetPlayers()
|
||||||
|
return self.Players
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get name of player.
|
||||||
|
-- @param #CLIENT self
|
||||||
|
-- @return #
|
||||||
|
function CLIENT:GetPlayer()
|
||||||
|
return self.Players[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Remove player.
|
||||||
|
-- @param #CLIENT self
|
||||||
|
-- @param #string PlayerName Name of the player.
|
||||||
|
-- @return #CLIENT self
|
||||||
|
function CLIENT:RemovePlayer(PlayerName)
|
||||||
|
|
||||||
|
for i,playername in pairs(self.Players) do
|
||||||
|
if PlayerName==playername then
|
||||||
|
table.remove(self.Players, i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Show the briefing of a CLIENT.
|
--- Show the briefing of a CLIENT.
|
||||||
-- @param #CLIENT self
|
-- @param #CLIENT self
|
||||||
-- @return #CLIENT self
|
-- @return #CLIENT self
|
||||||
function CLIENT:ShowBriefing()
|
function CLIENT:ShowBriefing()
|
||||||
self:F( { self.ClientName, self.ClientBriefingShown } )
|
|
||||||
|
|
||||||
if not self.ClientBriefingShown then
|
if not self.ClientBriefingShown then
|
||||||
self.ClientBriefingShown = true
|
self.ClientBriefingShown = true
|
||||||
@ -252,6 +287,9 @@ function CLIENT:Alive( CallBackFunction, ... )
|
|||||||
self.ClientCallBack = CallBackFunction
|
self.ClientCallBack = CallBackFunction
|
||||||
self.ClientParameters = arg
|
self.ClientParameters = arg
|
||||||
|
|
||||||
|
self.AliveCheckScheduler = SCHEDULER:New( self, self._AliveCheckScheduler, { "Client Alive " .. self.ClientName }, 0.1, 5, 0.5 )
|
||||||
|
self.AliveCheckScheduler:NoTrace()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -259,6 +297,8 @@ end
|
|||||||
function CLIENT:_AliveCheckScheduler( SchedulerName )
|
function CLIENT:_AliveCheckScheduler( SchedulerName )
|
||||||
self:F3( { SchedulerName, self.ClientName, self.ClientAlive2, self.ClientBriefingShown, self.ClientCallBack } )
|
self:F3( { SchedulerName, self.ClientName, self.ClientAlive2, self.ClientBriefingShown, self.ClientCallBack } )
|
||||||
|
|
||||||
|
env.info("FF client alive scheduler")
|
||||||
|
|
||||||
if self:IsAlive() then
|
if self:IsAlive() then
|
||||||
if self.ClientAlive2 == false then
|
if self.ClientAlive2 == false then
|
||||||
self:ShowBriefing()
|
self:ShowBriefing()
|
||||||
@ -388,11 +428,13 @@ function CLIENT:GetClientGroupUnit()
|
|||||||
local ClientDCSUnit = Unit.getByName( self.ClientName )
|
local ClientDCSUnit = Unit.getByName( self.ClientName )
|
||||||
|
|
||||||
self:T( self.ClientDCSUnit )
|
self:T( self.ClientDCSUnit )
|
||||||
if ClientDCSUnit and ClientDCSUnit:isExist() then
|
|
||||||
|
if ClientDCSUnit then -- and ClientDCSUnit:isExist() then
|
||||||
local ClientUnit=_DATABASE:FindUnit( self.ClientName )
|
local ClientUnit=_DATABASE:FindUnit( self.ClientName )
|
||||||
self:T2( ClientUnit )
|
|
||||||
return ClientUnit
|
return ClientUnit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the DCSUnit of the CLIENT.
|
--- Returns the DCSUnit of the CLIENT.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user