This commit is contained in:
FlightControl_Master 2017-09-28 19:54:44 +02:00
parent 9227bbdfca
commit 57eeefcf06
4 changed files with 1746 additions and 27216 deletions

File diff suppressed because it is too large Load Diff

View File

@ -562,6 +562,39 @@ function ZONE_RADIUS:GetVec3( Height )
end
--- Searches the zone
-- @param #ZONE_RADIUS self
-- @param EvaluateFunction
function ZONE_RADIUS:SearchZone( EvaluateFunction )
local SearchZoneResult = true
local ZoneCoord = self:GetCoordinate()
local ZoneRadius = self:GetRadius()
self:E({ZoneCoord = ZoneCoord, ZoneRadius = ZoneRadius, ZoneCoordLL = ZoneCoord:ToStringLLDMS()})
local SphereSearch = {
id = world.VolumeType.SPHERE,
params = {
point = ZoneCoord:GetVec3(),
radius = ZoneRadius / 2,
}
}
local function EvaluateZone( DCSZoneUnit )
env.info( DCSZoneUnit:getName() )
local ZoneUnit = UNIT:Find( DCSZoneUnit )
return EvaluateFunction( ZoneUnit )
end
world.searchObjects( Object.Category.UNIT, SphereSearch, EvaluateZone )
end
--- Returns if a location is within the zone.
-- @param #ZONE_RADIUS self
-- @param Dcs.DCSTypes#Vec2 Vec2 The location to test.

View File

@ -36,6 +36,7 @@ function PROTECT:New( ProtectZone )
self.ProtectZone = ProtectZone
self.ProtectUnitSet = SET_UNIT:New()
self.ProtectStaticSet = SET_STATIC:New()
self.CaptureUnitSet = SET_UNIT:New()
self:SetStartState( "Idle" )
@ -62,6 +63,27 @@ function PROTECT:AddProtectUnit( ProtectUnit )
self.ProtectUnitSet:AddUnit( ProtectUnit )
end
--- Get the Protect unit Set.
-- @param #PROTECT self
-- @return Wrapper.Unit#UNIT The Set of capture units.
function PROTECT:GetProtectUnitSet()
return self.ProtectUnitSet
end
--- Add a static to the protection.
-- @param #PROTECT self
-- @param Wrapper.Unit#UNIT ProtectStatic A @{Static} object to protect.
function PROTECT:AddProtectStatic( ProtectStatic )
self.ProtectStaticSet:AddStatic( ProtectStatic )
end
--- Get the Protect static Set.
-- @param #PROTECT self
-- @return Wrapper.Unit#UNIT The Set of capture statics.
function PROTECT:GetProtectStaticSet()
return self.ProtectStaticSet
end
--- Add a Capture unit to allow to capture the zone.
-- @param #PROTECT self
-- @param Wrapper.Unit#UNIT CaptureUnit A @{Unit} object to allow a capturing.
@ -98,25 +120,38 @@ function PROTECT:AreProtectUnitsAlive()
return IsAlive
end
--- Check if the statics are still alive.
-- @param #PROTECT self
function PROTECT:AreProtectStaticsAlive()
local IsAlive = false
local StaticSet = self.ProtectStaticSet
StaticSet:Flush()
local StaticList = StaticSet:GetSet()
for UnitID, ProtectStatic in pairs( StaticList ) do
local IsStaticAlive = ProtectStatic:IsAlive()
if IsStaticAlive == true then
IsAlive = true
break
end
end
return IsAlive
end
--- Check if there is a capture unit in the zone.
-- @param #PROTECT self
function PROTECT:IsCaptureUnitInZone()
local IsInZone = false
local CaptureUnitSet = self.CaptureUnitSet
CaptureUnitSet:Flush()
local CaptureUnitList = CaptureUnitSet:GetSet()
local IsInZone = self.CaptureUnitSet:IsPartiallyInZone( self.ProtectZone )
for UnitID, CaptureUnit in pairs( CaptureUnitList ) do
local IsUnitAlive = CaptureUnit:IsAlive()
if IsUnitAlive == true then
if CaptureUnit:IsInZone( self.ProtectZone ) then
IsInZone = true
break
end
end
end
self:E({IsInZone = IsInZone})
return IsInZone
end
@ -136,7 +171,9 @@ end
function PROTECT:onafterCheck()
if self:AreProtectUnitsAlive() or not self:IsCaptureUnitInZone() then
if ( self.ProtectUnitSet and self:AreProtectUnitsAlive() ) or
( self.ProtectStaticSet and self:AreProtectStaticsAlive() ) or
self:IsCaptureUnitInZone() == false then
self:__Check( -1 )
else
self:Capture()

File diff suppressed because it is too large Load Diff