Optimized the detection intervals + fixed bugs with player detection.

This commit is contained in:
FlightControl 2019-08-11 09:45:28 +02:00
parent d3c76da7a2
commit e770af9fc9
3 changed files with 7 additions and 5 deletions

View File

@ -1819,7 +1819,7 @@ do -- COORDINATE
--- Returns if a Coordinate is in a certain Radius of this Coordinate in 2D plane using the X and Z axis. --- Returns if a Coordinate is in a certain Radius of this Coordinate in 2D plane using the X and Z axis.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE ToCoordinate The coordinate that will be tested if it is in the radius of this coordinate. -- @param #COORDINATE Coordinate The coordinate that will be tested if it is in the radius of this coordinate.
-- @param #number Radius The radius of the circle on the 2D plane around this coordinate. -- @param #number Radius The radius of the circle on the 2D plane around this coordinate.
-- @return #boolean true if in the Radius. -- @return #boolean true if in the Radius.
function COORDINATE:IsInRadius( Coordinate, Radius ) function COORDINATE:IsInRadius( Coordinate, Radius )

View File

@ -564,10 +564,12 @@ do -- DETECTION_BASE
-- Count alive(!) groups only. Solves issue #1173 https://github.com/FlightControl-Master/MOOSE/issues/1173 -- Count alive(!) groups only. Solves issue #1173 https://github.com/FlightControl-Master/MOOSE/issues/1173
self.DetectionCount = self:CountAliveRecce() self.DetectionCount = self:CountAliveRecce()
local DetectionInterval = self.DetectionCount / ( self.RefreshTimeInterval - 1 )
self:ForEachAliveRecce( self:ForEachAliveRecce(
function( DetectionGroup ) function( DetectionGroup )
self:__Detection( DetectDelay, DetectionGroup, DetectionTimeStamp ) -- Process each detection asynchronously. self:__Detection( DetectDelay, DetectionGroup, DetectionTimeStamp ) -- Process each detection asynchronously.
DetectDelay = DetectDelay + 1 DetectDelay = DetectDelay + DetectionInterval
end end
) )
@ -1430,14 +1432,14 @@ do -- DETECTION_BASE
world.searchObjects( Object.Category.UNIT, SphereSearch, FindNearByFriendlies, TargetData ) world.searchObjects( Object.Category.UNIT, SphereSearch, FindNearByFriendlies, TargetData )
DetectedItem.PlayersNearBy = nil DetectedItem.PlayersNearBy = nil
local DetectionZone = ZONE_UNIT:New( "DetectionPlayers", DetectedUnit, self.FriendliesRange )
_DATABASE:ForEachPlayer( _DATABASE:ForEachPlayer(
--- @param Wrapper.Unit#UNIT PlayerUnit --- @param Wrapper.Unit#UNIT PlayerUnit
function( PlayerUnitName ) function( PlayerUnitName )
local PlayerUnit = UNIT:FindByName( PlayerUnitName ) local PlayerUnit = UNIT:FindByName( PlayerUnitName )
if PlayerUnit and PlayerUnit:IsInZone(DetectionZone) then if PlayerUnit and PlayerUnit:GetCoordinate():IsInRadius( DetectedUnitCoord, self.FriendliesRange ) then
--if PlayerUnit and PlayerUnit:IsInZone(DetectionZone) then
local PlayerUnitCategory = PlayerUnit:GetDesc().category local PlayerUnitCategory = PlayerUnit:GetDesc().category

View File

@ -63,7 +63,7 @@ POSITIONABLE.__.Cargo = {}
-- @param #string PositionableName The POSITIONABLE name -- @param #string PositionableName The POSITIONABLE name
-- @return #POSITIONABLE self -- @return #POSITIONABLE self
function POSITIONABLE:New( PositionableName ) function POSITIONABLE:New( PositionableName )
local self = BASE:Inherit( self, IDENTIFIABLE:New( PositionableName ) ) local self = BASE:Inherit( self, IDENTIFIABLE:New( PositionableName ) ) -- #POSITIONABLE
self.PositionableName = PositionableName self.PositionableName = PositionableName
return self return self