mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-24 12:05:27 +00:00
Progress
This commit is contained in:
@@ -44,6 +44,7 @@ DATABASE = {
|
|||||||
Templates = {
|
Templates = {
|
||||||
Units = {},
|
Units = {},
|
||||||
Groups = {},
|
Groups = {},
|
||||||
|
Statics = {},
|
||||||
ClientsByName = {},
|
ClientsByName = {},
|
||||||
ClientsByID = {},
|
ClientsByID = {},
|
||||||
},
|
},
|
||||||
@@ -282,7 +283,7 @@ function DATABASE:Spawn( SpawnTemplate )
|
|||||||
SpawnTemplate.CountryID = nil
|
SpawnTemplate.CountryID = nil
|
||||||
SpawnTemplate.CategoryID = nil
|
SpawnTemplate.CategoryID = nil
|
||||||
|
|
||||||
self:_RegisterTemplate( SpawnTemplate, SpawnCoalitionID, SpawnCategoryID, SpawnCountryID )
|
self:_RegisterGroupTemplate( SpawnTemplate, SpawnCoalitionID, SpawnCategoryID, SpawnCountryID )
|
||||||
|
|
||||||
self:T3( SpawnTemplate )
|
self:T3( SpawnTemplate )
|
||||||
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
||||||
@@ -318,7 +319,7 @@ end
|
|||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #table GroupTemplate
|
-- @param #table GroupTemplate
|
||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:_RegisterTemplate( GroupTemplate, CoalitionID, CategoryID, CountryID )
|
function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionID, CategoryID, CountryID )
|
||||||
|
|
||||||
local GroupTemplateName = env.getValueDictByKey(GroupTemplate.name)
|
local GroupTemplateName = env.getValueDictByKey(GroupTemplate.name)
|
||||||
|
|
||||||
@@ -396,6 +397,54 @@ function DATABASE:GetGroupTemplate( GroupName )
|
|||||||
return GroupTemplate
|
return GroupTemplate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Private method that registers new Static Templates within the DATABASE Object.
|
||||||
|
-- @param #DATABASE self
|
||||||
|
-- @param #table GroupTemplate
|
||||||
|
-- @return #DATABASE self
|
||||||
|
function DATABASE:_RegisterStaticTemplate( StaticTemplate, CoalitionID, CategoryID, CountryID )
|
||||||
|
|
||||||
|
local TraceTable = {}
|
||||||
|
|
||||||
|
local StaticTemplateName = env.getValueDictByKey(StaticTemplate.name)
|
||||||
|
|
||||||
|
self.Templates.Statics[StaticTemplateName] = self.Templates.Statics[StaticTemplateName] or {}
|
||||||
|
|
||||||
|
StaticTemplate.CategoryID = CategoryID
|
||||||
|
StaticTemplate.CoalitionID = CoalitionID
|
||||||
|
StaticTemplate.CountryID = CountryID
|
||||||
|
|
||||||
|
self.Templates.Statics[StaticTemplateName].StaticName = StaticTemplateName
|
||||||
|
self.Templates.Statics[StaticTemplateName].GroupTemplate = StaticTemplate
|
||||||
|
self.Templates.Statics[StaticTemplateName].UnitTemplate = StaticTemplate.units[1]
|
||||||
|
self.Templates.Statics[StaticTemplateName].CategoryID = CategoryID
|
||||||
|
self.Templates.Statics[StaticTemplateName].CoalitionID = CoalitionID
|
||||||
|
self.Templates.Statics[StaticTemplateName].CountryID = CountryID
|
||||||
|
|
||||||
|
|
||||||
|
TraceTable[#TraceTable+1] = "Static"
|
||||||
|
TraceTable[#TraceTable+1] = self.Templates.Statics[StaticTemplateName].GroupName
|
||||||
|
|
||||||
|
TraceTable[#TraceTable+1] = "Coalition"
|
||||||
|
TraceTable[#TraceTable+1] = self.Templates.Statics[StaticTemplateName].CoalitionID
|
||||||
|
TraceTable[#TraceTable+1] = "Category"
|
||||||
|
TraceTable[#TraceTable+1] = self.Templates.Statics[StaticTemplateName].CategoryID
|
||||||
|
TraceTable[#TraceTable+1] = "Country"
|
||||||
|
TraceTable[#TraceTable+1] = self.Templates.Statics[StaticTemplateName].CountryID
|
||||||
|
|
||||||
|
self:E( TraceTable )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- @param #DATABASE self
|
||||||
|
function DATABASE:GetStaticUnitTemplate( StaticName )
|
||||||
|
local StaticTemplate = self.Templates.Statics[StaticName].UnitTemplate
|
||||||
|
StaticTemplate.SpawnCoalitionID = self.Templates.Statics[StaticName].CoalitionID
|
||||||
|
StaticTemplate.SpawnCategoryID = self.Templates.Statics[StaticName].CategoryID
|
||||||
|
StaticTemplate.SpawnCountryID = self.Templates.Statics[StaticName].CountryID
|
||||||
|
return StaticTemplate
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function DATABASE:GetGroupNameFromUnitName( UnitName )
|
function DATABASE:GetGroupNameFromUnitName( UnitName )
|
||||||
return self.Templates.Units[UnitName].GroupName
|
return self.Templates.Units[UnitName].GroupName
|
||||||
end
|
end
|
||||||
@@ -725,7 +774,7 @@ function DATABASE:ForEachClient( IteratorFunction, ... )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param #DATABASE self
|
||||||
function DATABASE:_RegisterTemplates()
|
function DATABASE:_RegisterTemplates()
|
||||||
self:F2()
|
self:F2()
|
||||||
|
|
||||||
@@ -781,11 +830,18 @@ function DATABASE:_RegisterTemplates()
|
|||||||
|
|
||||||
--self.Units[coa_name][countryName][category] = {}
|
--self.Units[coa_name][countryName][category] = {}
|
||||||
|
|
||||||
for group_num, GroupTemplate in pairs(obj_type_data.group) do
|
for group_num, Template in pairs(obj_type_data.group) do
|
||||||
|
|
||||||
if GroupTemplate and GroupTemplate.units and type(GroupTemplate.units) == 'table' then --making sure again- this is a valid group
|
if obj_type_name ~= "static" and Template and Template.units and type(Template.units) == 'table' then --making sure again- this is a valid group
|
||||||
self:_RegisterTemplate(
|
self:_RegisterGroupTemplate(
|
||||||
GroupTemplate,
|
Template,
|
||||||
|
CoalitionSide,
|
||||||
|
_DATABASECategory[string.lower(CategoryName)],
|
||||||
|
CountryID
|
||||||
|
)
|
||||||
|
else
|
||||||
|
self:_RegisterStaticTemplate(
|
||||||
|
Template,
|
||||||
CoalitionSide,
|
CoalitionSide,
|
||||||
_DATABASECategory[string.lower(CategoryName)],
|
_DATABASECategory[string.lower(CategoryName)],
|
||||||
CountryID
|
CountryID
|
||||||
|
|||||||
@@ -43,8 +43,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- SPAWNSTATIC Class
|
--- @type SPAWNSTATIC
|
||||||
-- @type SPAWNSTATIC
|
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
|
||||||
@@ -72,13 +71,6 @@
|
|||||||
-- * @{#SPAWNSTATIC.NewFromStatic}(): Creates a new SPAWNSTATIC object given a name that is used as the base of the naming of each spawned Static.
|
-- * @{#SPAWNSTATIC.NewFromStatic}(): Creates a new SPAWNSTATIC object given a name that is used as the base of the naming of each spawned Static.
|
||||||
-- * @{#SPAWNSTATIC.NewFromType}(): Creates a new SPAWNSTATIC object given a type name and a name to be given when spawned.
|
-- * @{#SPAWNSTATIC.NewFromType}(): Creates a new SPAWNSTATIC object given a type name and a name to be given when spawned.
|
||||||
--
|
--
|
||||||
-- ## SPAWNSTATIC **Init**ialization methods
|
|
||||||
--
|
|
||||||
-- A spawn object will behave differently based on the usage of **initialization** methods, which all start with the **Init** prefix:
|
|
||||||
--
|
|
||||||
-- * @{#SPAWNSTATIC.InitRandomizePosition}(): Randomizes the position of @{Static}s that are spawned within a **radius band**, given an Outer and Inner radius, from the point that the spawn happens.
|
|
||||||
-- * @{#SPAWNSTATIC.InitRandomizeZones}(): Randomizes the spawning between a predefined list of @{Zone}s that are declared using this function. Each zone can be given a probability factor.
|
|
||||||
--
|
|
||||||
-- ## SPAWNSTATIC **Spawn** methods
|
-- ## SPAWNSTATIC **Spawn** methods
|
||||||
--
|
--
|
||||||
-- Groups can be spawned at different times and methods:
|
-- Groups can be spawned at different times and methods:
|
||||||
@@ -142,31 +134,45 @@ end
|
|||||||
|
|
||||||
--- Creates a new @{Static} from a POINT_VEC2.
|
--- Creates a new @{Static} from a POINT_VEC2.
|
||||||
-- @param #SPAWNSTATIC self
|
-- @param #SPAWNSTATIC self
|
||||||
-- @param #string SpawnTypeName is the name of the type.
|
-- @param Core.Point#POINT_VEC2 PointVec2 The 2D coordinate where to spawn the static.
|
||||||
|
-- @param #number Heading The heading of the static, which is a number in degrees from 0 to 360.
|
||||||
|
-- @param #string (optional) The name of the new static.
|
||||||
-- @return #SPAWNSTATIC
|
-- @return #SPAWNSTATIC
|
||||||
function SPAWNSTATIC:SpawnFromPointVec2( PointVec2, BaseName )
|
function SPAWNSTATIC:SpawnFromPointVec2( PointVec2, Heading, NewName )
|
||||||
self:F( { PointVec2, BaseName } )
|
self:F( { PointVec2, Heading, NewName } )
|
||||||
|
|
||||||
local CountryName = _DATABASE.COUNTRY_NAME[self.CountryID]
|
local CountryName = _DATABASE.COUNTRY_NAME[self.CountryID]
|
||||||
|
|
||||||
local StaticTemplate
|
local StaticTemplate = _DATABASE:GetStaticUnitTemplate( self.SpawnTemplatePrefix )
|
||||||
|
|
||||||
local Tire = {
|
StaticTemplate.x = PointVec2:GetLat()
|
||||||
["country"] = CountryName,
|
StaticTemplate.y = PointVec2:GetLon()
|
||||||
["category"] = "Fortifications",
|
|
||||||
["canCargo"] = false,
|
StaticTemplate.name = NewName or string.format("%s#%05d", self.SpawnTemplatePrefix, self.SpawnIndex )
|
||||||
["shape_name"] = "H-tyre_B_WF",
|
StaticTemplate.heading = ( Heading / 180 ) * math.pi
|
||||||
["type"] = "Black_Tyre_WF",
|
|
||||||
--["unitId"] = Angle + 10000,
|
StaticTemplate.CountryID = nil
|
||||||
["y"] = Point.y,
|
StaticTemplate.CoalitionID = nil
|
||||||
["x"] = Point.x,
|
StaticTemplate.CategoryID = nil
|
||||||
["name"] = string.format( "%s-Tire #%0d", self:GetName(), Angle ),
|
|
||||||
["heading"] = 0,
|
local Static = coalition.addStaticObject( self.CountryID, StaticTemplate )
|
||||||
} -- end of ["group"]
|
|
||||||
|
self.SpawnIndex = self.SpawnIndex + 1
|
||||||
|
|
||||||
local Group = coalition.addStaticObject( CountryID, Tire )
|
return Static
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Creates a new @{Static} from a @{Zone}.
|
||||||
|
-- @param #SPAWNSTATIC self
|
||||||
|
-- @param Core.Zone#ZONE_BASE Zone The Zone where to spawn the static.
|
||||||
|
-- @param #number Heading The heading of the static, which is a number in degrees from 0 to 360.
|
||||||
|
-- @param #string (optional) The name of the new static.
|
||||||
|
-- @return #SPAWNSTATIC
|
||||||
|
function SPAWNSTATIC:SpawnFromZone( Zone, Heading, NewName )
|
||||||
|
self:F( { Zone, Heading, NewName } )
|
||||||
|
|
||||||
|
local Static = self:SpawnFromPointVec2( Zone:GetPointVec2(), Heading, NewName )
|
||||||
|
|
||||||
|
return Static
|
||||||
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -615,7 +615,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- @type ZONE
|
--- @type ZONE
|
||||||
-- @extends Core.Zone#ZONE_RADIUS
|
-- @extends Core.Zone#ZONE_RADIUS
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Core/Point.lua
|
|||||||
Core/Message.lua
|
Core/Message.lua
|
||||||
Core/Fsm.lua
|
Core/Fsm.lua
|
||||||
Core/Radio.lua
|
Core/Radio.lua
|
||||||
|
Core/SpawnStatic.lua
|
||||||
|
|
||||||
Wrapper/Object.lua
|
Wrapper/Object.lua
|
||||||
Wrapper/Identifiable.lua
|
Wrapper/Identifiable.lua
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
||||||
env.info( 'Moose Generation Timestamp: 20170405_0934' )
|
env.info( 'Moose Generation Timestamp: 20170409_0720' )
|
||||||
|
|
||||||
local base = _G
|
local base = _G
|
||||||
|
|
||||||
@@ -35,6 +35,7 @@ __Moose.Include( 'Core/Point.lua' )
|
|||||||
__Moose.Include( 'Core/Message.lua' )
|
__Moose.Include( 'Core/Message.lua' )
|
||||||
__Moose.Include( 'Core/Fsm.lua' )
|
__Moose.Include( 'Core/Fsm.lua' )
|
||||||
__Moose.Include( 'Core/Radio.lua' )
|
__Moose.Include( 'Core/Radio.lua' )
|
||||||
|
__Moose.Include( 'Core/SpawnStatic.lua' )
|
||||||
__Moose.Include( 'Wrapper/Object.lua' )
|
__Moose.Include( 'Wrapper/Object.lua' )
|
||||||
__Moose.Include( 'Wrapper/Identifiable.lua' )
|
__Moose.Include( 'Wrapper/Identifiable.lua' )
|
||||||
__Moose.Include( 'Wrapper/Positionable.lua' )
|
__Moose.Include( 'Wrapper/Positionable.lua' )
|
||||||
|
|||||||
Reference in New Issue
Block a user