mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-23 19:45:29 +00:00
Added GROUP, ZONE classes to handle Tasks and Zones
GROUP will be a class abstraction for the DCS Group class, incorporating the Controller for tasks. ZONE will be a class abstraction for a trigger zone. Each of these classes will have properties to further emulate tasks, and execute all kind of actions on the object.
This commit is contained in:
@@ -0,0 +1,85 @@
|
|||||||
|
--- GROUP Classes
|
||||||
|
-- @classmod GROUP
|
||||||
|
|
||||||
|
Include.File( "Routines" )
|
||||||
|
Include.File( "Base" )
|
||||||
|
Include.File( "Message" )
|
||||||
|
|
||||||
|
GROUPS = {}
|
||||||
|
|
||||||
|
|
||||||
|
GROUP = {
|
||||||
|
ClassName="GROUP",
|
||||||
|
}
|
||||||
|
|
||||||
|
function GROUP:New( _Group )
|
||||||
|
trace.f( self.ClassName, _Group:getName() )
|
||||||
|
|
||||||
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
|
|
||||||
|
self._Group = _Group
|
||||||
|
self.GroupName = _Group:getName()
|
||||||
|
self.GroupID = _Group:getID()
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function GROUP:Land( Point, Duration )
|
||||||
|
trace.f( self.ClassName, { self.GroupName, Point, Duration } )
|
||||||
|
|
||||||
|
local Controller = self:_GetController()
|
||||||
|
|
||||||
|
if Duration and Duration > 0 then
|
||||||
|
Controller:pushTask( { id = 'Land', params = { point = Point, durationFlag = true, duration = Duration } } )
|
||||||
|
else
|
||||||
|
Controller:pushTask( { id = 'Land', params = { point = Point, durationFlag = false } } )
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function GROUP:Embarking( Point, Duration, EmbarkingGroup )
|
||||||
|
trace.f( self.ClassName, { self.GroupName, Point, Duration, EmbarkingGroup._Group } )
|
||||||
|
|
||||||
|
local Controller = self:_GetController()
|
||||||
|
|
||||||
|
trace.i( self.ClassName, EmbarkingGroup.GroupID )
|
||||||
|
trace.i( self.ClassName, EmbarkingGroup._Group:getID() )
|
||||||
|
trace.i( self.ClassName, EmbarkingGroup._Group.id )
|
||||||
|
|
||||||
|
Controller:pushTask( { id = 'Embarking',
|
||||||
|
params = { x = Point.x,
|
||||||
|
y = Point.y,
|
||||||
|
duration = Duration,
|
||||||
|
groupsForEmbarking = { EmbarkingGroup.GroupID },
|
||||||
|
durationFlag = true,
|
||||||
|
distributionFlag = false,
|
||||||
|
distribution = {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function GROUP:EmbarkToTransport( Point, Radius )
|
||||||
|
trace.f( self.ClassName, { self.GroupName, Point, Radius } )
|
||||||
|
|
||||||
|
local Controller = self:_GetController()
|
||||||
|
|
||||||
|
Controller:pushTask( { id = 'EmbarkToTransport',
|
||||||
|
params = { x = Point.x,
|
||||||
|
y = Point.y,
|
||||||
|
zoneRadius = Radius,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function GROUP:_GetController()
|
||||||
|
|
||||||
|
return self._Group:getController()
|
||||||
|
|
||||||
|
end
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
-- @parent TASK
|
-- @parent TASK
|
||||||
|
|
||||||
Include.File("Task")
|
Include.File("Task")
|
||||||
|
Include.File("Cargo")
|
||||||
|
|
||||||
PICKUPTASK = {
|
PICKUPTASK = {
|
||||||
ClassName = "PICKUPTASK",
|
ClassName = "PICKUPTASK",
|
||||||
|
|||||||
+25
-8
@@ -5,6 +5,8 @@
|
|||||||
Include.File( "Routines" )
|
Include.File( "Routines" )
|
||||||
Include.File( "Base" )
|
Include.File( "Base" )
|
||||||
Include.File( "Database" )
|
Include.File( "Database" )
|
||||||
|
Include.File( "Group" )
|
||||||
|
|
||||||
|
|
||||||
SPAWN = {
|
SPAWN = {
|
||||||
ClassName = "SPAWN",
|
ClassName = "SPAWN",
|
||||||
@@ -375,14 +377,14 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Will return the SpawnGroupName either with with a specific count number or without any count.
|
--- Will return the SpawnGroupName either with with a specific count number or without any count.
|
||||||
-- @tparam number SpawnNumber is the number of the Group that is to be SPAWNed.
|
-- @tparam number SpawnIndex is the number of the Group that is to be SPAWNed.
|
||||||
-- @treturn string SpawnGroupName
|
-- @treturn string SpawnGroupName
|
||||||
function SPAWN:SpawnGroupName( SpawnNumber )
|
function SPAWN:SpawnGroupName( SpawnIndex )
|
||||||
trace.f("Spawn", SpawnNumber )
|
trace.f("Spawn", SpawnIndex )
|
||||||
|
|
||||||
if SpawnNumber then
|
if SpawnIndex then
|
||||||
trace.i( self.ClassName, string.format( '%s#%03d', self.SpawnPrefix, SpawnNumber ) )
|
trace.i( self.ClassName, string.format( '%s#%03d', self.SpawnPrefix, SpawnIndex ) )
|
||||||
return string.format( '%s#%03d', self.SpawnPrefix, SpawnNumber )
|
return string.format( '%s#%03d', self.SpawnPrefix, SpawnIndex )
|
||||||
else
|
else
|
||||||
trace.i( self.ClassName, self.SpawnPrefix )
|
trace.i( self.ClassName, self.SpawnPrefix )
|
||||||
return self.SpawnPrefix
|
return self.SpawnPrefix
|
||||||
@@ -390,6 +392,21 @@ trace.f("Spawn", SpawnNumber )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function SPAWN:GetLastIndex()
|
||||||
|
|
||||||
|
return self.SpawnCount
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function SPAWN:GetLastGroup()
|
||||||
|
trace.f( self.ClassName )
|
||||||
|
|
||||||
|
local LastGroupName = self:SpawnGroupName( self:GetLastIndex() )
|
||||||
|
|
||||||
|
return GROUP:New( Group.getByName( LastGroupName ) )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Will SPAWN a Group within a given ZoneName.
|
--- Will SPAWN a Group within a given ZoneName.
|
||||||
-- @tparam string ZonePrefix is the name of the zone where the Group is to be SPAWNed.
|
-- @tparam string ZonePrefix is the name of the zone where the Group is to be SPAWNed.
|
||||||
-- @treturn SpawnTemplate
|
-- @treturn SpawnTemplate
|
||||||
@@ -528,8 +545,8 @@ trace.f( self.ClassName )
|
|||||||
for u = 1, SpawnUnits do
|
for u = 1, SpawnUnits do
|
||||||
SpawnTemplate.units[u].name = string.format( SpawnTemplate.name .. '-%02d', u )
|
SpawnTemplate.units[u].name = string.format( SpawnTemplate.name .. '-%02d', u )
|
||||||
SpawnTemplate.units[u].unitId = nil
|
SpawnTemplate.units[u].unitId = nil
|
||||||
SpawnTemplate.units[u].x = SpawnTemplate.route.points[1].x
|
SpawnTemplate.units[u].x = SpawnTemplate.route.points[1].x + math.random( -50, 50 )
|
||||||
SpawnTemplate.units[u].y = SpawnTemplate.route.points[1].y
|
SpawnTemplate.units[u].y = SpawnTemplate.route.points[1].y + math.random( -50, 50 )
|
||||||
end
|
end
|
||||||
|
|
||||||
trace.r( self.ClassName, "", SpawnTemplate.name )
|
trace.r( self.ClassName, "", SpawnTemplate.name )
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
--- ZONE Classes
|
||||||
|
-- @classmod ZONE
|
||||||
|
|
||||||
|
Include.File( "Routines" )
|
||||||
|
Include.File( "Base" )
|
||||||
|
Include.File( "Message" )
|
||||||
|
|
||||||
|
ZONES = {}
|
||||||
|
|
||||||
|
|
||||||
|
ZONE = {
|
||||||
|
ClassName="ZONE",
|
||||||
|
}
|
||||||
|
|
||||||
|
function ZONE:New( ZoneName )
|
||||||
|
trace.f( self.ClassName, ZoneName )
|
||||||
|
|
||||||
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
|
|
||||||
|
local Zone = trigger.misc.getZone( ZoneName )
|
||||||
|
|
||||||
|
if not Zone then
|
||||||
|
error( "Zone " .. ZoneName .. " does not exist." )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
self.Zone = Zone
|
||||||
|
self.ZoneName = ZoneName
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function ZONE:GetRandomPoint()
|
||||||
|
trace.f( self.ClassName, self.ZoneName )
|
||||||
|
|
||||||
|
local Point = {}
|
||||||
|
|
||||||
|
local Zone = trigger.misc.getZone( self.ZoneName )
|
||||||
|
|
||||||
|
Point.x = Zone.point.x + math.random( Zone.radius * -1, Zone.radius )
|
||||||
|
Point.y = Zone.point.z + math.random( Zone.radius * -1, Zone.radius )
|
||||||
|
|
||||||
|
trace.i( self.ClassName, { Zone } )
|
||||||
|
trace.i( self.ClassName, { Point } )
|
||||||
|
|
||||||
|
return Point
|
||||||
|
end
|
||||||
|
|
||||||
|
function ZONE:GetRadius()
|
||||||
|
trace.f( self.ClassName, self.ZoneName )
|
||||||
|
|
||||||
|
local Zone = trigger.misc.getZone( self.ZoneName )
|
||||||
|
|
||||||
|
trace.i( self.ClassName, { Zone } )
|
||||||
|
|
||||||
|
return Zone.radius
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user