diff --git a/Moose/CleanUp.lua b/Moose/CleanUp.lua index 1e0c902c5..5b564ca58 100644 --- a/Moose/CleanUp.lua +++ b/Moose/CleanUp.lua @@ -264,7 +264,7 @@ function CLEANUP:_CleanUpScheduler() local CleanUpUnitName = UnitData.CleanUpUnitName if CleanUpUnit then self:T( { "CleanUp Scheduler", "Checking:", CleanUpUnitName } ) - if _Database:GetStatusGroup( CleanUpGroupName ) ~= "ReSpawn" then + if _DATABASE:GetStatusGroup( CleanUpGroupName ) ~= "ReSpawn" then local CleanUpUnitVec3 = CleanUpUnit:getPoint() --self:T( CleanUpUnitVec3 ) local CleanUpUnitVec2 = {} diff --git a/Moose/Client.lua b/Moose/Client.lua index 5cb17fba3..bc444e5c5 100644 --- a/Moose/Client.lua +++ b/Moose/Client.lua @@ -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.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.Groups[self.ClientName].Template self.ClientID = ClientGroupTemplate.groupId self.ClientGroupUnit = UnitData self:T3( self.ClientName .. " : group found in bug 1.5 resolvement logic!" ) diff --git a/Moose/Database.lua b/Moose/Database.lua index 492dfc4e2..31437191d 100644 --- a/Moose/Database.lua +++ b/Moose/Database.lua @@ -24,6 +24,30 @@ DATABASE = { AlivePlayers = {}, ClientsByName = {}, ClientsByID = {}, + Filter = { + Coalition = { + Red = false, + Blue = false, + }, + Category = { + Air = false, + Plane = false, + Helicopter = false, + Ground = false, + Ship = false, + }, + Group = { + Prefix = { + }, + }, + Unit = { + Type = { + }, + Prefix = { + }, + Player = false, + }, + }, } local _DATABASECoalition = @@ -51,13 +75,60 @@ function DATABASE:New() -- Inherits from BASE local self = BASE:Inherit( self, BASE:New() ) + + _EVENTDISPATCHER:OnBirth( self._EventBirth, self ) _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self ) _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self ) + return self end +function DATABASE:Red() + self.Filter.Coalition.Red = true +end + +function DATABASE:Blue() + self.Filter.Coalition.Blue = true +end + +function DATABASE:GroupPrefixes( Prefixes ) + for PrefixID, PrefixName in pairs( Prefixes ) do + self.Filter.Group.Prefix[#self.Filter.Group.Prefix+1] = PrefixName + end +end + +function DATABASE:Air() + self.Filter.Air = true +end + +function DATABASE:AirPlane() + self.Filter.Plane = true +end + +function DATABASE:Helicopter() + self.Filter.Helicopter = true +end + +function DATABASE:Ground() + self.Filter.Ground = true +end + +function DATABASE:Ship() + self.Filter.Ship = true +end + +function DATABASE:UnitPrefixes( Prefixes ) + for PrefixID, PrefixName in pairs( Prefixes ) do + self.Filter.Group.Prefix[#self.Filter.Unit.Prefix+1] = PrefixName + end +end + +function DATABASE:Filter() + +end + function DATABASE:ScanEnvironment() self.Navpoints = {} diff --git a/Moose/Group.lua b/Moose/Group.lua index 8e4ddc502..c7f9faa4b 100644 --- a/Moose/Group.lua +++ b/Moose/Group.lua @@ -999,7 +999,7 @@ end function GROUP:GetTaskMission() self:F( self.GroupName ) - return routines.utils.deepCopy( _Database.Groups[self.GroupName].Template ) + return routines.utils.deepCopy( _DATABASE.Groups[self.GroupName].Template ) end --- Return the mission route of the group. @@ -1008,7 +1008,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.Groups[self.GroupName].Template.route.points ) end --- Return the route of a group by using the @{Database#DATABASE} class. @@ -1032,7 +1032,7 @@ function GROUP:CopyRoute( Begin, End, Randomize, Radius ) self:T( { GroupName } ) - local Template = _Database.Groups[GroupName].Template + local Template = _DATABASE.Groups[GroupName].Template if Template then if not Begin then diff --git a/Moose/Mission.lua b/Moose/Mission.lua index 1c8f713ca..2420ff755 100644 --- a/Moose/Mission.lua +++ b/Moose/Mission.lua @@ -474,7 +474,7 @@ function MISSIONSCHEDULER.Scheduler() if Mission.GoalFunction ~= nil then Mission.GoalFunction( Mission, Client ) end - _Database:_AddMissionTaskScore( Client:GetClientGroupDCSUnit(), Mission.Name, 25 ) + _DATABASE:_AddMissionTaskScore( Client:GetClientGroupDCSUnit(), Mission.Name, 25 ) -- if not Mission:IsCompleted() then -- end @@ -497,7 +497,7 @@ function MISSIONSCHEDULER.Scheduler() if MissionComplete then Mission:Completed() - _Database:_AddMissionScore( Mission.Name, 100 ) + _DATABASE:_AddMissionScore( Mission.Name, 100 ) else if TaskComplete then -- Reset for new tasking of active client diff --git a/Moose/Moose.lua b/Moose/Moose.lua index 796f51990..2e5b5a762 100644 --- a/Moose/Moose.lua +++ b/Moose/Moose.lua @@ -7,7 +7,7 @@ Include.File( "Event" ) --- Declare the main database object, which is used internally by the MOOSE classes. -_Database = DATABASE:New():ScanEnvironment() -- Database#DATABASE +_DATABASE = DATABASE:New():ScanEnvironment() -- Database#DATABASE --- Declare the event dispatcher based on the EVENT class _EVENTDISPATCHER = EVENT:New() -- #EVENT \ No newline at end of file diff --git a/Moose/Routines.lua b/Moose/Routines.lua index 14f840d55..f91e24e45 100644 --- a/Moose/Routines.lua +++ b/Moose/Routines.lua @@ -1696,7 +1696,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.Groups[groupIdent].groupId end for coa_name, coa_data in pairs(env.mission.coalition) do @@ -1746,6 +1746,7 @@ function routines.getGroupRoute(groupIdent, task) -- same as getGroupPoints bu end --if coa_name == 'red' or coa_name == 'blue' and type(coa_data) == 'table' then end --for coa_name, coa_data in pairs(mission.coalition) do end + routines.ground.patrolRoute = function(vars) diff --git a/Moose/Sead.lua b/Moose/Sead.lua index f30459de2..d89c47cf0 100644 --- a/Moose/Sead.lua +++ b/Moose/Sead.lua @@ -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.Units[_targetMimname].Template.skill self:T( self.SEADGroupPrefixes ) self:T( _targetMimgroupName ) local SEADGroupFound = false diff --git a/Moose/Spawn.lua b/Moose/Spawn.lua index ad8575e9a..645b69693 100644 --- a/Moose/Spawn.lua +++ b/Moose/Spawn.lua @@ -384,7 +384,7 @@ function SPAWN:Array( SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY ) _EVENTDISPATCHER:OnEngineShutDownForTemplate( self.SpawnGroups[SpawnGroupID].SpawnTemplate, self._OnEngineShutDown, self ) end - self.SpawnGroups[SpawnGroupID].Group = _Database:Spawn( self.SpawnGroups[SpawnGroupID].SpawnTemplate ) + self.SpawnGroups[SpawnGroupID].Group = _DATABASE:Spawn( self.SpawnGroups[SpawnGroupID].SpawnTemplate ) SpawnX = SpawnXIndex * SpawnDeltaX SpawnY = SpawnYIndex * SpawnDeltaY @@ -456,7 +456,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex ) _EVENTDISPATCHER:OnEngineShutDownForTemplate( self.SpawnGroups[self.SpawnIndex].SpawnTemplate, self._OnEngineShutDown, self ) end - self.SpawnGroups[self.SpawnIndex].Group = _Database:Spawn( self.SpawnGroups[self.SpawnIndex].SpawnTemplate ) + self.SpawnGroups[self.SpawnIndex].Group = _DATABASE:Spawn( self.SpawnGroups[self.SpawnIndex].SpawnTemplate ) -- If there is a SpawnFunction hook defined, call it. if self.SpawnFunctionHook then @@ -464,7 +464,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex ) end -- TODO: Need to fix this by putting an "R" in the name of the group when the group repeats. --if self.SpawnRepeat then - -- _Database:SetStatusGroup( SpawnTemplate.name, "ReSpawn" ) + -- _DATABASE:SetStatusGroup( SpawnTemplate.name, "ReSpawn" ) --end end @@ -968,7 +968,7 @@ function SPAWN:_GetTemplate( SpawnTemplatePrefix ) local SpawnTemplate = nil - SpawnTemplate = routines.utils.deepCopy( _Database.Groups[SpawnTemplatePrefix].Template ) + SpawnTemplate = routines.utils.deepCopy( _DATABASE.Groups[SpawnTemplatePrefix].Template ) if SpawnTemplate == nil then error( 'No Template returned for SpawnTemplatePrefix = ' .. SpawnTemplatePrefix ) @@ -1125,7 +1125,7 @@ function SPAWN:_GetSpawnIndex( SpawnIndex ) end --- TODO Need to delete this... _Database does this now ... +-- TODO Need to delete this... _DATABASE does this now ... function SPAWN:_OnBirth( event ) if timer.getTime0() < timer.getAbsTime() then -- dont need to add units spawned in at the start of the mission if mist is loaded in init line @@ -1143,7 +1143,7 @@ function SPAWN:_OnBirth( event ) end --- Obscolete --- @todo Need to delete this... _Database does this now ... +-- @todo Need to delete this... _DATABASE does this now ... function SPAWN:_OnDeadOrCrash( event ) self:F( self.SpawnTemplatePrefix, event )