mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
269
Moose Development/Moose/Core/Goal.lua
Normal file
269
Moose Development/Moose/Core/Goal.lua
Normal file
@@ -0,0 +1,269 @@
|
||||
--- **Core** -- Base class that models processes to achieve goals.
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- GOAL models processes that have an objective with a defined achievement. Derived classes implement the ways how the achievements can be realized.
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- ### Author: **Sven Van de Velde (FlightControl)**
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- @module Goal
|
||||
|
||||
do -- Goal
|
||||
|
||||
--- @type GOAL
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
|
||||
--- # GOAL class, extends @{Fsm#FSM}
|
||||
--
|
||||
-- GOAL models processes that have an objective with a defined achievement. Derived classes implement the ways how the achievements can be realized.
|
||||
--
|
||||
-- ## 1. GOAL constructor
|
||||
--
|
||||
-- * @{#GOAL.New}(): Creates a new GOAL object.
|
||||
--
|
||||
-- ## 2. GOAL is a finite state machine (FSM).
|
||||
--
|
||||
-- ### 2.1 GOAL States
|
||||
--
|
||||
-- * **Off**: The goal is not timely measured.
|
||||
-- * **On**: The goal is timely being measured.
|
||||
-- * **Achieved**: The objective is achieved.
|
||||
--
|
||||
-- ### 2.2 GOAL Events
|
||||
--
|
||||
-- * **@{#GOAL.Start}()**: Start Measuring the Goal.
|
||||
-- * **@{#GOAL.Stop}()**: Stop Measuring the Goal.
|
||||
-- * **@{#GOAL.IsAchieved}()**: Check if the Goal is Achieved.
|
||||
--
|
||||
-- @field #GOAL
|
||||
GOAL = {
|
||||
ClassName = "GOAL",
|
||||
}
|
||||
|
||||
--- @field #table GOAL.States
|
||||
GOAL.States = {}
|
||||
|
||||
--- GOAL Constructor.
|
||||
-- @param #GOAL self
|
||||
-- @return #GOAL
|
||||
function GOAL:New()
|
||||
|
||||
local self = BASE:Inherit( self, FSM:New() ) -- #GOAL
|
||||
self:F( {} )
|
||||
|
||||
|
||||
do
|
||||
|
||||
--- On State for GOAL
|
||||
-- @field GOAL.On
|
||||
|
||||
--- On State Handler OnLeave for GOAL
|
||||
-- @function [parent=#GOAL] OnLeaveOn
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- On State Handler OnEnter for GOAL
|
||||
-- @function [parent=#GOAL] OnEnterOn
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
GOAL.States.On = "On"
|
||||
|
||||
end
|
||||
|
||||
do
|
||||
|
||||
--- Off State for GOAL
|
||||
-- @field GOAL.Off
|
||||
|
||||
--- Off State Handler OnLeave for GOAL
|
||||
-- @function [parent=#GOAL] OnLeaveOff
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Off State Handler OnEnter for GOAL
|
||||
-- @function [parent=#GOAL] OnEnterOff
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
GOAL.States.Off = "Off"
|
||||
|
||||
end
|
||||
|
||||
--- Achieved State for GOAL
|
||||
-- @field GOAL.Achieved
|
||||
GOAL.States.Achieved = "Achieved"
|
||||
|
||||
--- Achieved State Handler OnLeave for GOAL
|
||||
-- @function [parent=#GOAL] OnLeaveAchieved
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Achieved State Handler OnEnter for GOAL
|
||||
-- @function [parent=#GOAL] OnEnterAchieved
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
|
||||
self:SetStartState( GOAL.States.Off )
|
||||
self:AddTransition( GOAL.States.Off, "Start", GOAL.States.On )
|
||||
|
||||
--- Start Handler OnBefore for GOAL
|
||||
-- @function [parent=#GOAL] OnBeforeStart
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Start Handler OnAfter for GOAL
|
||||
-- @function [parent=#GOAL] OnAfterStart
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
--- Start Trigger for GOAL
|
||||
-- @function [parent=#GOAL] Start
|
||||
-- @param #GOAL self
|
||||
|
||||
--- Start Asynchronous Trigger for GOAL
|
||||
-- @function [parent=#GOAL] __Start
|
||||
-- @param #GOAL self
|
||||
-- @param #number Delay
|
||||
|
||||
self:AddTransition( GOAL.States.On, "Stop", GOAL.States.Off )
|
||||
|
||||
--- Stop Handler OnBefore for GOAL
|
||||
-- @function [parent=#GOAL] OnBeforeStop
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Stop Handler OnAfter for GOAL
|
||||
-- @function [parent=#GOAL] OnAfterStop
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
--- Stop Trigger for GOAL
|
||||
-- @function [parent=#GOAL] Stop
|
||||
-- @param #GOAL self
|
||||
|
||||
--- Stop Asynchronous Trigger for GOAL
|
||||
-- @function [parent=#GOAL] __Stop
|
||||
-- @param #GOAL self
|
||||
-- @param #number Delay
|
||||
|
||||
|
||||
self:AddTransition( GOAL.States.On, "IsAchieved", GOAL.States.On )
|
||||
|
||||
--- IsAchieved Handler OnBefore for GOAL
|
||||
-- @function [parent=#GOAL] OnBeforeIsAchieved
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- IsAchieved Handler OnAfter for GOAL
|
||||
-- @function [parent=#GOAL] OnAfterIsAchieved
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
--- IsAchieved Trigger for GOAL
|
||||
-- @function [parent=#GOAL] IsAchieved
|
||||
-- @param #GOAL self
|
||||
|
||||
--- IsAchieved Asynchronous Trigger for GOAL
|
||||
-- @function [parent=#GOAL] __IsAchieved
|
||||
-- @param #GOAL self
|
||||
-- @param #number Delay
|
||||
|
||||
self:AddTransition( GOAL.States.On, "Achieved", GOAL.States.Achieved )
|
||||
|
||||
--- Achieved Handler OnBefore for GOAL
|
||||
-- @function [parent=#GOAL] OnBeforeAchieved
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Achieved Handler OnAfter for GOAL
|
||||
-- @function [parent=#GOAL] OnAfterAchieved
|
||||
-- @param #GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
--- Achieved Trigger for GOAL
|
||||
-- @function [parent=#GOAL] Achieved
|
||||
-- @param #GOAL self
|
||||
|
||||
--- Achieved Asynchronous Trigger for GOAL
|
||||
-- @function [parent=#GOAL] __Achieved
|
||||
-- @param #GOAL self
|
||||
-- @param #number Delay
|
||||
|
||||
|
||||
self.AchievedScheduler = nil
|
||||
|
||||
self:SetEventPriority( 5 )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- @param #GOAL self
|
||||
-- @param From
|
||||
-- @param Event
|
||||
-- @param To
|
||||
function GOAL:onafterOn( From, Event, To )
|
||||
if not self.AchievedScheduler then
|
||||
self.AchievedScheduler = self:ScheduleRepeat( 15, 15, 0, nil, self.CheckAchieved, self )
|
||||
end
|
||||
end
|
||||
|
||||
--- @param #GOAL self
|
||||
-- @param From
|
||||
-- @param Event
|
||||
-- @param To
|
||||
function GOAL:onafterOff( From, Event, To )
|
||||
self:ScheduleStop( self.CheckAchieved )
|
||||
self.ArchievedScheduler = nil
|
||||
end
|
||||
|
||||
--- @param #GOAL self
|
||||
-- @param From
|
||||
-- @param Event
|
||||
-- @param To
|
||||
function GOAL:CheckAchieved( From, Event, To )
|
||||
self:IsAchieved()
|
||||
end
|
||||
|
||||
end
|
||||
262
Moose Development/Moose/Core/ZoneGoal.lua
Normal file
262
Moose Development/Moose/Core/ZoneGoal.lua
Normal file
@@ -0,0 +1,262 @@
|
||||
--- **Core** -- Base class that models processes to achieve goals involving a Zone.
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- ZONE_GOAL models processes that have an objective with a defined achievement involving a Zone. Derived classes implement the ways how the achievements can be realized.
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- ### Author: **Sven Van de Velde (FlightControl)**
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- @module Zone
|
||||
|
||||
do -- Zone
|
||||
|
||||
--- @type ZONE_GOAL
|
||||
-- @extends Core.Goal#GOAL
|
||||
|
||||
|
||||
--- # ZONE_GOAL class, extends @{Goal#GOAL}
|
||||
--
|
||||
-- ZONE_GOAL models processes that have an objective with a defined achievement involving a Zone. Derived classes implement the ways how the achievements can be realized.
|
||||
--
|
||||
-- ## 1. ZONE_GOAL constructor
|
||||
--
|
||||
-- * @{#ZONE_GOAL.New}(): Creates a new ZONE_GOAL object.
|
||||
--
|
||||
-- ## 2. ZONE_GOAL is a finite state machine (FSM).
|
||||
--
|
||||
-- ### 2.1 ZONE_GOAL States
|
||||
--
|
||||
-- * **Empty**: The Zone is Empty.
|
||||
-- * **Guarded**: The Zone is Guarded.
|
||||
--
|
||||
-- ### 2.2 ZONE_GOAL Events
|
||||
--
|
||||
-- * **@{#ZONE_GOAL.Guard}()**: Set the Zone to Guarded.
|
||||
-- * **@{#ZONE_GOAL.Empty}()**: Set the Zone to Empty.
|
||||
--
|
||||
-- @field #ZONE_GOAL
|
||||
ZONE_GOAL = {
|
||||
ClassName = "ZONE_GOAL",
|
||||
}
|
||||
|
||||
--- @field #table ZONE_GOAL.States
|
||||
ZONE_GOAL.States = {}
|
||||
|
||||
--- ZONE_GOAL Constructor.
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param Core.Zone#ZONE_BASE Zone A @{Zone} object with the goal to be achieved.
|
||||
-- @return #ZONE_GOAL
|
||||
function ZONE_GOAL:New( Zone )
|
||||
|
||||
local self = BASE:Inherit( self, FSM:New() ) -- #ZONE_GOAL
|
||||
self:F( { Zone = Zone } )
|
||||
|
||||
self.Zone = Zone -- Core.Zone#ZONE_BASE
|
||||
self.Goal = GOAL:New():Start()
|
||||
|
||||
do
|
||||
|
||||
--- Guarded State Handler OnLeave for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] OnLeaveGuarded
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Guarded State Handler OnEnter for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] OnEnterGuarded
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
ZONE_GOAL.States.Guarded = "Guarded"
|
||||
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
|
||||
--- Empty State Handler OnLeave for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] OnLeaveEmpty
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Empty State Handler OnEnter for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] OnEnterEmpty
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
ZONE_GOAL.States.Empty = "Empty"
|
||||
|
||||
end
|
||||
|
||||
|
||||
self:AddTransition( "*", "Guard", ZONE_GOAL.States.Guarded )
|
||||
|
||||
--- Guard Handler OnBefore for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] OnBeforeGuard
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Guard Handler OnAfter for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] OnAfterGuard
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
--- Guard Trigger for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] Guard
|
||||
-- @param #ZONE_GOAL self
|
||||
|
||||
--- Guard Asynchronous Trigger for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] __Guard
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #number Delay
|
||||
|
||||
self:AddTransition( "*", "Empty", ZONE_GOAL.States.Empty )
|
||||
|
||||
--- Empty Handler OnBefore for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] OnBeforeEmpty
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Empty Handler OnAfter for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] OnAfterEmpty
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
--- Empty Trigger for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] Empty
|
||||
-- @param #ZONE_GOAL self
|
||||
|
||||
--- Empty Asynchronous Trigger for ZONE_GOAL
|
||||
-- @function [parent=#ZONE_GOAL] __Empty
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #number Delay
|
||||
|
||||
|
||||
self.SmokeTime = nil
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get the Zone
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @return Core.Zone#ZONE_BASE
|
||||
function ZONE_GOAL:GetZone()
|
||||
return self.Zone
|
||||
end
|
||||
|
||||
|
||||
--- Get the name of the ProtectZone
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @return #string
|
||||
function ZONE_GOAL:GetZoneName()
|
||||
return self.Zone:GetName()
|
||||
end
|
||||
|
||||
--- Smoke the center of theh zone.
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #SMOKECOLOR.Color SmokeColor
|
||||
function ZONE_GOAL:Smoke( SmokeColor )
|
||||
|
||||
self:F( { SmokeColor = SmokeColor} )
|
||||
|
||||
self.SmokeColor = SmokeColor
|
||||
end
|
||||
|
||||
|
||||
--- Flare the center of the zone.
|
||||
-- @param #ZONE_GOAL self
|
||||
-- @param #SMOKECOLOR.Color FlareColor
|
||||
function ZONE_GOAL:Flare( FlareColor )
|
||||
self.Zone:FlareZone( FlareColor, math.random( 1, 360 ) )
|
||||
end
|
||||
|
||||
|
||||
--- When started, check the Smoke and the Zone status.
|
||||
-- @param #ZONE_GOAL self
|
||||
function ZONE_GOAL:onafterGuard()
|
||||
|
||||
--self:GetParent( self ):onafterStart()
|
||||
|
||||
self:E("Guard")
|
||||
|
||||
--self:ScheduleRepeat( 15, 15, 0.1, nil, self.StatusZone, self )
|
||||
if not self.SmokeScheduler then
|
||||
self.SmokeScheduler = self:ScheduleRepeat( 1, 1, 0.1, nil, self.StatusSmoke, self )
|
||||
end
|
||||
end
|
||||
|
||||
function ZONE_GOAL:IsGuarded()
|
||||
|
||||
local IsGuarded = self.Zone:IsAllInZoneOfCoalition( self.Coalition )
|
||||
self:E( { IsGuarded = IsGuarded } )
|
||||
return IsGuarded
|
||||
end
|
||||
|
||||
|
||||
function ZONE_GOAL:IsEmpty()
|
||||
|
||||
local IsEmpty = self.Zone:IsNoneInZone()
|
||||
self:E( { IsEmpty = IsEmpty } )
|
||||
return IsEmpty
|
||||
end
|
||||
|
||||
|
||||
--- Check status Zone.
|
||||
-- @param #ZONE_GOAL self
|
||||
function ZONE_GOAL:StatusZone()
|
||||
|
||||
self:E( { State = self:GetState() } )
|
||||
|
||||
self.Zone:Scan()
|
||||
|
||||
if self:IsGuarded() then
|
||||
self:Guard()
|
||||
end
|
||||
|
||||
if self:IsEmpty() then
|
||||
self:Empty()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Check status Smoke.
|
||||
-- @param #ZONE_GOAL self
|
||||
function ZONE_GOAL:StatusSmoke()
|
||||
|
||||
self:F({self.SmokeTime, self.SmokeColor})
|
||||
|
||||
local CurrentTime = timer.getTime()
|
||||
|
||||
if self.SmokeTime == nil or self.SmokeTime + 300 <= CurrentTime then
|
||||
if self.SmokeColor then
|
||||
self.Zone:GetCoordinate():Smoke( self.SmokeColor )
|
||||
--self.SmokeColor = nil
|
||||
self.SmokeTime = CurrentTime
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
342
Moose Development/Moose/Core/ZoneGoalCoalition.lua
Normal file
342
Moose Development/Moose/Core/ZoneGoalCoalition.lua
Normal file
@@ -0,0 +1,342 @@
|
||||
--- **Core** -- Base class that models processes to achieve goals involving a Zone for a Coalition.
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- ZONE_GOAL_COALITION models processes that have an objective with a defined achievement involving a Zone. Derived classes implement the ways how the achievements can be realized.
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- ### Author: **Sven Van de Velde (FlightControl)**
|
||||
--
|
||||
-- ====
|
||||
--
|
||||
-- @module ZoneGoal
|
||||
|
||||
do -- ZoneGoal
|
||||
|
||||
--- @type ZONE_GOAL_COALITION
|
||||
-- @extends Core.Goal#ZONE_GOAL_COALITION
|
||||
|
||||
|
||||
--- # ZONE_GOAL_COALITION class, extends @{Goal#GOAL}
|
||||
--
|
||||
-- ZONE_GOAL_COALITION models processes that have an objective with a defined achievement involving a Zone. Derived classes implement the ways how the achievements can be realized.
|
||||
--
|
||||
-- ## 1. ZONE_GOAL_COALITION constructor
|
||||
--
|
||||
-- * @{#ZONE_GOAL_COALITION.New}(): Creates a new ZONE_GOAL_COALITION object.
|
||||
--
|
||||
-- ## 2. ZONE_GOAL_COALITION is a finite state machine (FSM).
|
||||
--
|
||||
-- ### 2.1 ZONE_GOAL_COALITION States
|
||||
--
|
||||
-- * **Off**: The goal is not timely measured.
|
||||
-- * **On**: The goal is timely being measured.
|
||||
-- * **Achieved**: The objective is achieved.
|
||||
--
|
||||
-- ### 2.2 ZONE_GOAL_COALITION Events
|
||||
--
|
||||
-- * **@{#ZONE_GOAL_COALITION.Start}()**: Start Measuring the Goal.
|
||||
-- * **@{#ZONE_GOAL_COALITION.Stop}()**: Stop Measuring the Goal.
|
||||
-- * **@{#ZONE_GOAL_COALITION.IsAchieved}()**: Check if the Goal is Achieved.
|
||||
--
|
||||
-- @field #ZONE_GOAL_COALITION
|
||||
ZONE_GOAL_COALITION = {
|
||||
ClassName = "ZONE_GOAL_COALITION",
|
||||
}
|
||||
|
||||
--- @field #table ZONE_GOAL_COALITION.States
|
||||
ZONE_GOAL_COALITION.States = {}
|
||||
|
||||
--- ZONE_GOAL_COALITION Constructor.
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param Core.Zone#ZONE Zone A @{Zone} object with the goal to be achieved.
|
||||
-- @param DCSCoalition.DCSCoalition#coalition Coalition The initial coalition owning the zone.
|
||||
-- @return #ZONE_GOAL_COALITION
|
||||
function ZONE_GOAL_COALITION:New( Zone, Coalition )
|
||||
|
||||
local self = BASE:Inherit( self, ZONE_GOAL:New( Zone ) ) -- #ZONE_GOAL_COALITION
|
||||
self:F( { Zone = Zone, Coalition = Coalition } )
|
||||
|
||||
self:SetCoalition( Coalition )
|
||||
|
||||
do
|
||||
|
||||
--- Captured State Handler OnLeave for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] OnLeaveCaptured
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Captured State Handler OnEnter for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] OnEnterCaptured
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
ZONE_GOAL_COALITION.States.Captured = "Captured"
|
||||
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
|
||||
--- Attacked State Handler OnLeave for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] OnLeaveAttacked
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Attacked State Handler OnEnter for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] OnEnterAttacked
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
ZONE_GOAL_COALITION.States.Attacked = "Attacked"
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
self:AddTransition( { ZONE_GOAL_COALITION.States.Guarded, ZONE_GOAL_COALITION.States.Empty }, "Attack", ZONE_GOAL_COALITION.States.Attacked )
|
||||
|
||||
--- Attack Handler OnBefore for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] OnBeforeAttack
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Attack Handler OnAfter for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] OnAfterAttack
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
--- Attack Trigger for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] Attack
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
|
||||
--- Attack Asynchronous Trigger for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] __Attack
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param #number Delay
|
||||
|
||||
self:AddTransition( { ZONE_GOAL_COALITION.States.Guarded, ZONE_GOAL_COALITION.States.Attacked, ZONE_GOAL_COALITION.States.Empty }, "Capture", ZONE_GOAL_COALITION.States.Captured )
|
||||
|
||||
--- Capture Handler OnBefore for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] OnBeforeCapture
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- Capture Handler OnAfter for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] OnAfterCapture
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
--- Capture Trigger for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] Capture
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
|
||||
--- Capture Asynchronous Trigger for ZONE_GOAL_COALITION
|
||||
-- @function [parent=#ZONE_GOAL_COALITION] __Capture
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param #number Delay
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set the owning coalition of the zone.
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @param DCSCoalition.DCSCoalition#coalition Coalition
|
||||
function ZONE_GOAL_COALITION:SetCoalition( Coalition )
|
||||
self.Coalition = Coalition
|
||||
end
|
||||
|
||||
|
||||
--- Get the owning coalition of the zone.
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @return DCSCoalition.DCSCoalition#coalition Coalition.
|
||||
function ZONE_GOAL_COALITION:GetCoalition()
|
||||
return self.Coalition
|
||||
end
|
||||
|
||||
|
||||
--- Get the owning coalition name of the zone.
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
-- @return #string Coalition name.
|
||||
function ZONE_GOAL_COALITION:GetCoalitionName()
|
||||
|
||||
if self.Coalition == coalition.side.BLUE then
|
||||
return "Blue"
|
||||
end
|
||||
|
||||
if self.Coalition == coalition.side.RED then
|
||||
return "Red"
|
||||
end
|
||||
|
||||
if self.Coalition == coalition.side.NEUTRAL then
|
||||
return "Neutral"
|
||||
end
|
||||
|
||||
return ""
|
||||
end
|
||||
|
||||
|
||||
function ZONE_GOAL_COALITION:IsGuarded()
|
||||
|
||||
local IsGuarded = self.Zone:IsAllInZoneOfCoalition( self.Coalition )
|
||||
self:E( { IsGuarded = IsGuarded } )
|
||||
return IsGuarded
|
||||
end
|
||||
|
||||
function ZONE_GOAL_COALITION:IsCaptured()
|
||||
|
||||
local IsCaptured = self.Zone:IsAllInZoneOfOtherCoalition( self.Coalition )
|
||||
self:E( { IsCaptured = IsCaptured } )
|
||||
return IsCaptured
|
||||
end
|
||||
|
||||
|
||||
function ZONE_GOAL_COALITION:IsAttacked()
|
||||
|
||||
local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )
|
||||
self:E( { IsAttacked = IsAttacked } )
|
||||
return IsAttacked
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Mark.
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
function ZONE_GOAL_COALITION:Mark()
|
||||
|
||||
local Coord = self.Zone:GetCoordinate()
|
||||
local ZoneName = self:GetZoneName()
|
||||
local State = self:GetState()
|
||||
|
||||
if self.MarkRed and self.MarkBlue then
|
||||
self:E( { MarkRed = self.MarkRed, MarkBlue = self.MarkBlue } )
|
||||
Coord:RemoveMark( self.MarkRed )
|
||||
Coord:RemoveMark( self.MarkBlue )
|
||||
end
|
||||
|
||||
if self.Coalition == coalition.side.BLUE then
|
||||
self.MarkBlue = Coord:MarkToCoalitionBlue( "Guard Zone: " .. ZoneName .. "\nStatus: " .. State )
|
||||
self.MarkRed = Coord:MarkToCoalitionRed( "Capture Zone: " .. ZoneName .. "\nStatus: " .. State )
|
||||
else
|
||||
self.MarkRed = Coord:MarkToCoalitionRed( "Guard Zone: " .. ZoneName .. "\nStatus: " .. State )
|
||||
self.MarkBlue = Coord:MarkToCoalitionBlue( "Capture Zone: " .. ZoneName .. "\nStatus: " .. State )
|
||||
end
|
||||
end
|
||||
|
||||
--- Bound.
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
function ZONE_GOAL_COALITION:onenterGuarded()
|
||||
|
||||
--self:GetParent( self ):onenterGuarded()
|
||||
|
||||
if self.Coalition == coalition.side.BLUE then
|
||||
--elf.ProtectZone:BoundZone( 12, country.id.USA )
|
||||
else
|
||||
--self.ProtectZone:BoundZone( 12, country.id.RUSSIA )
|
||||
end
|
||||
|
||||
self:Mark()
|
||||
|
||||
end
|
||||
|
||||
function ZONE_GOAL_COALITION:onenterCaptured()
|
||||
|
||||
--self:GetParent( self ):onenterCaptured()
|
||||
|
||||
local NewCoalition = self.ProtectZone:GetCoalition()
|
||||
self:E( { NewCoalition = NewCoalition } )
|
||||
self:SetCoalition( NewCoalition )
|
||||
|
||||
self:Mark()
|
||||
end
|
||||
|
||||
|
||||
function ZONE_GOAL_COALITION:onenterEmpty()
|
||||
|
||||
--self:GetParent( self ):onenterEmpty()
|
||||
|
||||
self:Mark()
|
||||
end
|
||||
|
||||
|
||||
function ZONE_GOAL_COALITION:onenterAttacked()
|
||||
|
||||
--self:GetParent( self ):onenterAttacked()
|
||||
|
||||
self:Mark()
|
||||
end
|
||||
|
||||
|
||||
--- When started, check the Coalition status.
|
||||
-- @param #ZONE_GOAL self
|
||||
function ZONE_GOAL_COALITION:onafterGuard()
|
||||
|
||||
--self:E({BASE:GetParent( self )})
|
||||
--BASE:GetParent( self ).onafterGuard( self )
|
||||
|
||||
if not self.SmokeScheduler then
|
||||
self.SmokeScheduler = self:ScheduleRepeat( 1, 1, 0.1, nil, self.StatusSmoke, self )
|
||||
end
|
||||
if not self.ScheduleStatusZone then
|
||||
self.ScheduleStatusZone = self:ScheduleRepeat( 15, 15, 0.1, nil, self.StatusZone, self )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function ZONE_GOAL_COALITION:IsCaptured()
|
||||
|
||||
local IsCaptured = self.Zone:IsAllInZoneOfOtherCoalition( self.Coalition )
|
||||
self:E( { IsCaptured = IsCaptured } )
|
||||
return IsCaptured
|
||||
end
|
||||
|
||||
|
||||
function ZONE_GOAL_COALITION:IsAttacked()
|
||||
|
||||
local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )
|
||||
self:E( { IsAttacked = IsAttacked } )
|
||||
return IsAttacked
|
||||
end
|
||||
|
||||
--- Check status Coalition ownership.
|
||||
-- @param #ZONE_GOAL_COALITION self
|
||||
function ZONE_GOAL_COALITION:StatusZone()
|
||||
|
||||
self:E( { State = self:GetState() } )
|
||||
|
||||
self:GetParent( self ):StatusZone()
|
||||
|
||||
if self:IsAttacked() then
|
||||
self:Attack()
|
||||
end
|
||||
|
||||
if self:IsCaptured() then
|
||||
self:Capture()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user