Moved capture related methods to ZONE_CAPTURE_COALITION

This commit is contained in:
FlightControl_Master
2017-10-07 22:14:05 +02:00
parent 7f04c98d61
commit 57cb31c86b
17 changed files with 1358 additions and 89286 deletions

View File

@@ -31,19 +31,9 @@ do -- ZoneGoal
-- ## 2. ZONE_GOAL_COALITION is a finite state machine (FSM).
--
-- ### 2.1 ZONE_GOAL_COALITION States
--
-- * **Captured**: The Zone has been captured by an other coalition.
-- * **Attacked**: The Zone is currently intruded by an other coalition. There are units of the owning coalition and an other coalition in the Zone.
-- * **Guarded**: The Zone is guarded by the owning coalition. There is no other unit of an other coalition in the Zone.
-- * **Empty**: The Zone is empty. There is not valid unit in the Zone.
--
-- ### 2.2 ZONE_GOAL_COALITION Events
--
-- * **Capture**: The Zone has been captured by an other coalition.
-- * **Attack**: The Zone is currently intruded by an other coalition. There are units of the owning coalition and an other coalition in the Zone.
-- * **Guard**: The Zone is guarded by the owning coalition. There is no other unit of an other coalition in the Zone.
-- * **Empty**: The Zone is empty. There is not valid unit in the Zone.
--
-- ### 2.3 ZONE_GOAL_COALITION State Machine
--
-- @field #ZONE_GOAL_COALITION
@@ -66,188 +56,6 @@ do -- ZoneGoal
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
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
end
do
--- Guarded State Handler OnLeave for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] OnLeaveGuarded
-- @param #ZONE_GOAL_COALITION self
-- @param #string From
-- @param #string Event
-- @param #string To
-- @return #boolean
--- Guarded State Handler OnEnter for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] OnEnterGuarded
-- @param #ZONE_GOAL_COALITION self
-- @param #string From
-- @param #string Event
-- @param #string To
end
do
--- Empty State Handler OnLeave for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] OnLeaveEmpty
-- @param #ZONE_GOAL_COALITION self
-- @param #string From
-- @param #string Event
-- @param #string To
-- @return #boolean
--- Empty State Handler OnEnter for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] OnEnterEmpty
-- @param #ZONE_GOAL_COALITION self
-- @param #string From
-- @param #string Event
-- @param #string To
end
self:AddTransition( "*", "Guard", "Guarded" )
--- Guard Handler OnBefore for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] OnBeforeGuard
-- @param #ZONE_GOAL_COALITION self
-- @param #string From
-- @param #string Event
-- @param #string To
-- @return #boolean
--- Guard Handler OnAfter for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] OnAfterGuard
-- @param #ZONE_GOAL_COALITION self
-- @param #string From
-- @param #string Event
-- @param #string To
--- Guard Trigger for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] Guard
-- @param #ZONE_GOAL_COALITION self
--- Guard Asynchronous Trigger for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] __Guard
-- @param #ZONE_GOAL_COALITION self
-- @param #number Delay
self:AddTransition( "*", "Empty", "Empty" )
--- Empty Handler OnBefore for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] OnBeforeEmpty
-- @param #ZONE_GOAL_COALITION self
-- @param #string From
-- @param #string Event
-- @param #string To
-- @return #boolean
--- Empty Handler OnAfter for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] OnAfterEmpty
-- @param #ZONE_GOAL_COALITION self
-- @param #string From
-- @param #string Event
-- @param #string To
--- Empty Trigger for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] Empty
-- @param #ZONE_GOAL_COALITION self
--- Empty Asynchronous Trigger for ZONE_GOAL_COALITION
-- @function [parent=#ZONE_GOAL_COALITION] __Empty
-- @param #ZONE_GOAL_COALITION self
-- @param #number Delay
self:AddTransition( { "Guarded", "Empty" }, "Attack", "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( { "Guarded", "Attacked", "Empty" }, "Capture", "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
@@ -290,137 +98,6 @@ do -- ZoneGoal
end
function ZONE_GOAL_COALITION:IsGuarded()
local IsGuarded = self.Zone:IsAllInZoneOfCoalition( self.Coalition )
self:E( { IsGuarded = IsGuarded } )
return IsGuarded
end
function ZONE_GOAL_COALITION:IsEmpty()
local IsEmpty = self.Zone:IsNoneInZone()
self:E( { IsEmpty = IsEmpty } )
return IsEmpty
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.Zone: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_COALITION 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()
@@ -430,22 +107,6 @@ do -- ZoneGoal
self.Zone:Scan()
if State ~= "Guarded" and self:IsGuarded() then
self:Guard()
end
if State ~= "Empty" and self:IsEmpty() then
self:Empty()
end
if State ~= "Attacked" and self:IsAttacked() then
self:Attack()
end
if State ~= "Captured" and self:IsCaptured() then
self:Capture()
end
end
end