mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Work in progress
This commit is contained in:
parent
37ec8c294f
commit
db2cc49b85
@ -196,12 +196,12 @@ function CLIENT:GetDCSGroup()
|
||||
-- Now we need to resolve the bugs in DCS 1.5 ...
|
||||
-- Consult the database for the units of the Client Group. (ClientGroup:getUnits() returns nil)
|
||||
self:T3( "Bug 1.5 logic" )
|
||||
local ClientUnits = _DATABASE.Groups[self.ClientName].Units
|
||||
local ClientUnits = _DATABASE.Templates.Groups[self.ClientName].Units
|
||||
self:T3( { ClientUnits[1].name, env.getValueDictByKey(ClientUnits[1].name) } )
|
||||
for ClientUnitID, ClientUnitData in pairs( ClientUnits ) do
|
||||
self:T3( { tonumber(UnitData:getID()), ClientUnitData.unitId } )
|
||||
if tonumber(UnitData:getID()) == ClientUnitData.unitId then
|
||||
local ClientGroupTemplate = _DATABASE.Groups[self.ClientName].Template
|
||||
local ClientGroupTemplate = _DATABASE.Templates.Groups[self.ClientName].Template
|
||||
self.ClientID = ClientGroupTemplate.groupId
|
||||
self.ClientGroupUnit = UnitData
|
||||
self:T3( self.ClientName .. " : group found in bug 1.5 resolvement logic!" )
|
||||
|
||||
@ -66,6 +66,7 @@ Include.File( "Routines" )
|
||||
Include.File( "Base" )
|
||||
Include.File( "Menu" )
|
||||
Include.File( "Group" )
|
||||
Include.File( "Unit" )
|
||||
Include.File( "Event" )
|
||||
|
||||
--- DATABASE class
|
||||
@ -73,6 +74,7 @@ Include.File( "Event" )
|
||||
-- @extends Base#BASE
|
||||
DATABASE = {
|
||||
ClassName = "DATABASE",
|
||||
Templates = {},
|
||||
DCSUnits = {},
|
||||
DCSUnitsAlive = {},
|
||||
Units = {},
|
||||
@ -260,7 +262,7 @@ function DATABASE:FilterStart()
|
||||
-- OK, we have a _DATABASE
|
||||
-- Now use the different filters to build the set.
|
||||
-- We first take ALL of the Units of the _DATABASE.
|
||||
for UnitRegistrationID, UnitRegistration in pairs( _DATABASE.Units ) do
|
||||
for UnitRegistrationID, UnitRegistration in pairs( _DATABASE.Templates.Units ) do
|
||||
self:T( UnitRegistration )
|
||||
local DCSUnit = Unit.getByName( UnitRegistration.UnitName )
|
||||
if self:_IsIncludeDCSUnit( DCSUnit ) then
|
||||
@ -318,7 +320,7 @@ end
|
||||
function DATABASE:SetStatusGroup( GroupName, Status )
|
||||
self:F( Status )
|
||||
|
||||
self.Groups[GroupName].Status = Status
|
||||
self.Templates.Groups[GroupName].Status = Status
|
||||
end
|
||||
|
||||
|
||||
@ -326,8 +328,8 @@ end
|
||||
function DATABASE:GetStatusGroup( GroupName )
|
||||
self:F( Status )
|
||||
|
||||
if self.Groups[GroupName] then
|
||||
return self.Groups[GroupName].Status
|
||||
if self.Templates.Groups[GroupName] then
|
||||
return self.Templates.Groups[GroupName].Status
|
||||
else
|
||||
return ""
|
||||
end
|
||||
@ -341,9 +343,9 @@ function DATABASE:_RegisterGroup( GroupTemplate )
|
||||
|
||||
local GroupTemplateName = env.getValueDictByKey(GroupTemplate.name)
|
||||
|
||||
if not self.Groups[GroupTemplateName] then
|
||||
self.Groups[GroupTemplateName] = {}
|
||||
self.Groups[GroupTemplateName].Status = nil
|
||||
if not self.Templates.Groups[GroupTemplateName] then
|
||||
self.Templates.Groups[GroupTemplateName] = {}
|
||||
self.Templates.Groups[GroupTemplateName].Status = nil
|
||||
end
|
||||
|
||||
-- Delete the spans from the route, it is not needed and takes memory.
|
||||
@ -351,28 +353,28 @@ function DATABASE:_RegisterGroup( GroupTemplate )
|
||||
GroupTemplate.route.spans = nil
|
||||
end
|
||||
|
||||
self.Groups[GroupTemplateName].GroupName = GroupTemplateName
|
||||
self.Groups[GroupTemplateName].Template = GroupTemplate
|
||||
self.Groups[GroupTemplateName].groupId = GroupTemplate.groupId
|
||||
self.Groups[GroupTemplateName].UnitCount = #GroupTemplate.units
|
||||
self.Groups[GroupTemplateName].Units = GroupTemplate.units
|
||||
self.Templates.Groups[GroupTemplateName].GroupName = GroupTemplateName
|
||||
self.Templates.Groups[GroupTemplateName].Template = GroupTemplate
|
||||
self.Templates.Groups[GroupTemplateName].groupId = GroupTemplate.groupId
|
||||
self.Templates.Groups[GroupTemplateName].UnitCount = #GroupTemplate.units
|
||||
self.Templates.Groups[GroupTemplateName].Units = GroupTemplate.units
|
||||
|
||||
self:T( { "Group", self.Groups[GroupTemplateName].GroupName, self.Groups[GroupTemplateName].UnitCount } )
|
||||
self:T( { "Group", self.Templates.Groups[GroupTemplateName].GroupName, self.Templates.Groups[GroupTemplateName].UnitCount } )
|
||||
|
||||
for unit_num, UnitTemplate in pairs( GroupTemplate.units ) do
|
||||
|
||||
local UnitTemplateName = env.getValueDictByKey(UnitTemplate.name)
|
||||
self.Units[UnitTemplateName] = {}
|
||||
self.Units[UnitTemplateName].UnitName = UnitTemplateName
|
||||
self.Units[UnitTemplateName].Template = UnitTemplate
|
||||
self.Units[UnitTemplateName].GroupName = GroupTemplateName
|
||||
self.Units[UnitTemplateName].GroupTemplate = GroupTemplate
|
||||
self.Units[UnitTemplateName].GroupId = GroupTemplate.groupId
|
||||
self.Templates.Units[UnitTemplateName] = {}
|
||||
self.Templates.Units[UnitTemplateName].UnitName = UnitTemplateName
|
||||
self.Templates.Units[UnitTemplateName].Template = UnitTemplate
|
||||
self.Templates.Units[UnitTemplateName].GroupName = GroupTemplateName
|
||||
self.Templates.Units[UnitTemplateName].GroupTemplate = GroupTemplate
|
||||
self.Templates.Units[UnitTemplateName].GroupId = GroupTemplate.groupId
|
||||
if UnitTemplate.skill and (UnitTemplate.skill == "Client" or UnitTemplate.skill == "Player") then
|
||||
self.ClientsByName[UnitTemplateName] = UnitTemplate
|
||||
self.ClientsByID[UnitTemplate.unitId] = UnitTemplate
|
||||
self.Templates.ClientsByName[UnitTemplateName] = UnitTemplate
|
||||
self.Templates.ClientsByID[UnitTemplate.unitId] = UnitTemplate
|
||||
end
|
||||
self:E( { "Unit", self.Units[UnitTemplateName].UnitName } )
|
||||
self:E( { "Unit", self.Templates.Units[UnitTemplateName].UnitName } )
|
||||
end
|
||||
end
|
||||
|
||||
@ -439,7 +441,7 @@ function DATABASE:ForEachAliveUnit( IteratorFunction, ... )
|
||||
end
|
||||
end
|
||||
|
||||
timer.scheduleFunction( Schedule, {}, timer.getTime() + 1 )
|
||||
timer.scheduleFunction( Schedule, {}, timer.getTime() + 0.001 )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -1084,7 +1084,7 @@ end
|
||||
function GROUP:GetTaskMission()
|
||||
self:F( self.GroupName )
|
||||
|
||||
return routines.utils.deepCopy( _DATABASE.Groups[self.GroupName].Template )
|
||||
return routines.utils.deepCopy( _DATABASE.Templates.Groups[self.GroupName].Template )
|
||||
end
|
||||
|
||||
--- Return the mission route of the group.
|
||||
@ -1093,7 +1093,7 @@ end
|
||||
function GROUP:GetTaskRoute()
|
||||
self:F( self.GroupName )
|
||||
|
||||
return routines.utils.deepCopy( _DATABASE.Groups[self.GroupName].Template.route.points )
|
||||
return routines.utils.deepCopy( _DATABASE.Templates.Groups[self.GroupName].Template.route.points )
|
||||
end
|
||||
|
||||
--- Return the route of a group by using the @{Database#DATABASE} class.
|
||||
@ -1117,7 +1117,7 @@ function GROUP:CopyRoute( Begin, End, Randomize, Radius )
|
||||
|
||||
self:T( { GroupName } )
|
||||
|
||||
local Template = _DATABASE.Groups[GroupName].Template
|
||||
local Template = _DATABASE.Templates.Groups[GroupName].Template
|
||||
|
||||
if Template then
|
||||
if not Begin then
|
||||
|
||||
@ -47,7 +47,7 @@ function MISSILETRAINER:_EventShot( Event )
|
||||
local TrainerTargetDCSUnitName = Unit.getName( TrainerTargetDCSUnit )
|
||||
local TrainerTargetDCSGroup = TrainerTargetDCSUnit:getGroup()
|
||||
local TrainerTargetDCSGroupName = TrainerTargetDCSGroup:getName()
|
||||
local TrainerTargetSkill = _DATABASE.Units[TrainerTargetDCSUnitName].Template.skill
|
||||
local TrainerTargetSkill = _DATABASE.Templates.Units[TrainerTargetDCSUnitName].Template.skill
|
||||
|
||||
self:T( TrainerTargetSkill )
|
||||
|
||||
|
||||
@ -1737,7 +1737,7 @@ function routines.getGroupRoute(groupIdent, task) -- same as getGroupPoints bu
|
||||
-- refactor to search by groupId and allow groupId and groupName as inputs
|
||||
local gpId = groupIdent
|
||||
if type(groupIdent) == 'string' and not tonumber(groupIdent) then
|
||||
gpId = _DATABASE.Groups[groupIdent].groupId
|
||||
gpId = _DATABASE.Templates.Groups[groupIdent].groupId
|
||||
end
|
||||
|
||||
for coa_name, coa_data in pairs(env.mission.coalition) do
|
||||
|
||||
@ -67,7 +67,7 @@ function SEAD:EventShot( Event )
|
||||
local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon))
|
||||
local _targetMimgroupName = _targetMimgroup:getName()
|
||||
local _targetMimcont= _targetMimgroup:getController()
|
||||
local _targetskill = _DATABASE.Units[_targetMimname].Template.skill
|
||||
local _targetskill = _DATABASE.Templates.Units[_targetMimname].Template.skill
|
||||
self:T( self.SEADGroupPrefixes )
|
||||
self:T( _targetMimgroupName )
|
||||
local SEADGroupFound = false
|
||||
|
||||
@ -954,7 +954,7 @@ function SPAWN:_GetTemplate( SpawnTemplatePrefix )
|
||||
|
||||
local SpawnTemplate = nil
|
||||
|
||||
SpawnTemplate = routines.utils.deepCopy( _DATABASE.Groups[SpawnTemplatePrefix].Template )
|
||||
SpawnTemplate = routines.utils.deepCopy( _DATABASE.Templates.Groups[SpawnTemplatePrefix].Template )
|
||||
|
||||
if SpawnTemplate == nil then
|
||||
error( 'No Template returned for SpawnTemplatePrefix = ' .. SpawnTemplatePrefix )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user