mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
parent
9227bbdfca
commit
57eeefcf06
File diff suppressed because it is too large
Load Diff
@ -562,6 +562,39 @@ function ZONE_RADIUS:GetVec3( Height )
|
|||||||
end
|
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.
|
--- Returns if a location is within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param Dcs.DCSTypes#Vec2 Vec2 The location to test.
|
-- @param Dcs.DCSTypes#Vec2 Vec2 The location to test.
|
||||||
|
|||||||
@ -36,6 +36,7 @@ function PROTECT:New( ProtectZone )
|
|||||||
|
|
||||||
self.ProtectZone = ProtectZone
|
self.ProtectZone = ProtectZone
|
||||||
self.ProtectUnitSet = SET_UNIT:New()
|
self.ProtectUnitSet = SET_UNIT:New()
|
||||||
|
self.ProtectStaticSet = SET_STATIC:New()
|
||||||
self.CaptureUnitSet = SET_UNIT:New()
|
self.CaptureUnitSet = SET_UNIT:New()
|
||||||
|
|
||||||
self:SetStartState( "Idle" )
|
self:SetStartState( "Idle" )
|
||||||
@ -62,6 +63,27 @@ function PROTECT:AddProtectUnit( ProtectUnit )
|
|||||||
self.ProtectUnitSet:AddUnit( ProtectUnit )
|
self.ProtectUnitSet:AddUnit( ProtectUnit )
|
||||||
end
|
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.
|
--- Add a Capture unit to allow to capture the zone.
|
||||||
-- @param #PROTECT self
|
-- @param #PROTECT self
|
||||||
-- @param Wrapper.Unit#UNIT CaptureUnit A @{Unit} object to allow a capturing.
|
-- @param Wrapper.Unit#UNIT CaptureUnit A @{Unit} object to allow a capturing.
|
||||||
@ -98,25 +120,38 @@ function PROTECT:AreProtectUnitsAlive()
|
|||||||
return IsAlive
|
return IsAlive
|
||||||
end
|
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.
|
--- Check if there is a capture unit in the zone.
|
||||||
-- @param #PROTECT self
|
-- @param #PROTECT self
|
||||||
function PROTECT:IsCaptureUnitInZone()
|
function PROTECT:IsCaptureUnitInZone()
|
||||||
|
|
||||||
local IsInZone = false
|
|
||||||
|
|
||||||
local CaptureUnitSet = self.CaptureUnitSet
|
local CaptureUnitSet = self.CaptureUnitSet
|
||||||
CaptureUnitSet:Flush()
|
CaptureUnitSet:Flush()
|
||||||
local CaptureUnitList = CaptureUnitSet:GetSet()
|
|
||||||
|
local IsInZone = self.CaptureUnitSet:IsPartiallyInZone( self.ProtectZone )
|
||||||
|
|
||||||
for UnitID, CaptureUnit in pairs( CaptureUnitList ) do
|
self:E({IsInZone = IsInZone})
|
||||||
local IsUnitAlive = CaptureUnit:IsAlive()
|
|
||||||
if IsUnitAlive == true then
|
|
||||||
if CaptureUnit:IsInZone( self.ProtectZone ) then
|
|
||||||
IsInZone = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return IsInZone
|
return IsInZone
|
||||||
end
|
end
|
||||||
@ -136,7 +171,9 @@ end
|
|||||||
|
|
||||||
function PROTECT:onafterCheck()
|
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 )
|
self:__Check( -1 )
|
||||||
else
|
else
|
||||||
self:Capture()
|
self:Capture()
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user