mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
commit
dcd278e2a1
@ -3396,7 +3396,7 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.SpawnInitKeepUnitNames == false then
|
if self.SpawnInitKeepUnitNames == false then
|
||||||
for UnitID = 1, #SpawnTemplate.units do
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
SpawnTemplate.units[UnitID].name = string.format( SpawnTemplate.name .. '-%02d', UnitID )
|
SpawnTemplate.units[UnitID].name = string.format( SpawnTemplate.name .. '-%02d', UnitID )
|
||||||
@ -3404,9 +3404,17 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
for UnitID = 1, #SpawnTemplate.units do
|
for UnitID = 1, #SpawnTemplate.units do
|
||||||
local UnitPrefix, Rest = string.match( SpawnTemplate.units[UnitID].name, "^([^#]+)#?" ):gsub( "^%s*(.-)%s*$", "%1" )
|
local SpawnInitKeepUnitIFF = false
|
||||||
self:T( { UnitPrefix, Rest } )
|
if string.find(SpawnTemplate.units[UnitID].name,"#IFF_",1,true) then --Razbam IFF hack for F15E etc
|
||||||
|
SpawnInitKeepUnitIFF = true
|
||||||
|
end
|
||||||
|
local UnitPrefix, Rest
|
||||||
|
if SpawnInitKeepUnitIFF == false then
|
||||||
|
UnitPrefix, Rest = string.match( SpawnTemplate.units[UnitID].name, "^([^#]+)#?" ):gsub( "^%s*(.-)%s*$", "%1" )
|
||||||
|
self:T( { UnitPrefix, Rest } )
|
||||||
|
else
|
||||||
|
UnitPrefix=SpawnTemplate.units[UnitID].name
|
||||||
|
end
|
||||||
SpawnTemplate.units[UnitID].name = string.format( '%s#%03d-%02d', UnitPrefix, SpawnIndex, UnitID )
|
SpawnTemplate.units[UnitID].name = string.format( '%s#%03d-%02d', UnitPrefix, SpawnIndex, UnitID )
|
||||||
SpawnTemplate.units[UnitID].unitId = nil
|
SpawnTemplate.units[UnitID].unitId = nil
|
||||||
end
|
end
|
||||||
|
|||||||
@ -12,7 +12,8 @@
|
|||||||
-- @image Wrapper_Static.JPG
|
-- @image Wrapper_Static.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type STATIC
|
---
|
||||||
|
-- @type STATIC
|
||||||
-- @extends Wrapper.Positionable#POSITIONABLE
|
-- @extends Wrapper.Positionable#POSITIONABLE
|
||||||
|
|
||||||
--- Wrapper class to handle Static objects.
|
--- Wrapper class to handle Static objects.
|
||||||
@ -236,7 +237,7 @@ function STATIC:SpawnAt(Coordinate, Heading, Delay)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Respawn the @{Wrapper.Unit} at the same location with the same properties.
|
--- Respawn the @{Wrapper.Static} at the same location with the same properties.
|
||||||
-- This is useful to respawn a cargo after it has been destroyed.
|
-- This is useful to respawn a cargo after it has been destroyed.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param DCS#country.id CountryID (Optional) The country ID used for spawning the new static. Default is same as currently.
|
-- @param DCS#country.id CountryID (Optional) The country ID used for spawning the new static. Default is same as currently.
|
||||||
@ -248,7 +249,7 @@ function STATIC:ReSpawn(CountryID, Delay)
|
|||||||
else
|
else
|
||||||
|
|
||||||
CountryID=CountryID or self:GetCountry()
|
CountryID=CountryID or self:GetCountry()
|
||||||
|
|
||||||
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, CountryID)
|
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, CountryID)
|
||||||
|
|
||||||
SpawnStatic:Spawn(nil, self.StaticName)
|
SpawnStatic:Spawn(nil, self.StaticName)
|
||||||
@ -270,8 +271,8 @@ function STATIC:ReSpawnAt(Coordinate, Heading, Delay)
|
|||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay>0 then
|
||||||
SCHEDULER:New(nil, self.ReSpawnAt, {self, Coordinate, Heading}, Delay)
|
SCHEDULER:New(nil, self.ReSpawnAt, {self, Coordinate, Heading}, Delay)
|
||||||
else
|
else
|
||||||
|
|
||||||
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, self:GetCountry())
|
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, self:GetCountry())
|
||||||
|
|
||||||
SpawnStatic:SpawnFromCoordinate(Coordinate, Heading, self.StaticName)
|
SpawnStatic:SpawnFromCoordinate(Coordinate, Heading, self.StaticName)
|
||||||
@ -280,3 +281,52 @@ function STATIC:ReSpawnAt(Coordinate, Heading, Delay)
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Find the first(!) STATIC matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
||||||
|
-- @param #STATIC self
|
||||||
|
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_\(Regular_Expressions\)) for regular expressions in LUA.
|
||||||
|
-- @return #STATIC The STATIC.
|
||||||
|
-- @usage
|
||||||
|
-- -- Find a static with a partial static name
|
||||||
|
-- local grp = STATIC:FindByMatching( "Apple" )
|
||||||
|
-- -- will return e.g. a static named "Apple-1-1"
|
||||||
|
--
|
||||||
|
-- -- using a pattern
|
||||||
|
-- local grp = STATIC:FindByMatching( ".%d.%d$" )
|
||||||
|
-- -- will return the first static found ending in "-1-1" to "-9-9", but not e.g. "-10-1"
|
||||||
|
function STATIC:FindByMatching( Pattern )
|
||||||
|
local GroupFound = nil
|
||||||
|
|
||||||
|
for name,static in pairs(_DATABASE.STATICS) do
|
||||||
|
if string.match(name, Pattern ) then
|
||||||
|
GroupFound = static
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return GroupFound
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Find all STATIC objects matching using patterns. Note that this is **a lot** slower than `:FindByName()`!
|
||||||
|
-- @param #STATIC self
|
||||||
|
-- @param #string Pattern The pattern to look for. Refer to [LUA patterns](http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_\(Regular_Expressions\)) for regular expressions in LUA.
|
||||||
|
-- @return #table Groups Table of matching #STATIC objects found
|
||||||
|
-- @usage
|
||||||
|
-- -- Find all static with a partial static name
|
||||||
|
-- local grptable = STATIC:FindAllByMatching( "Apple" )
|
||||||
|
-- -- will return all statics with "Apple" in the name
|
||||||
|
--
|
||||||
|
-- -- using a pattern
|
||||||
|
-- local grp = STATIC:FindAllByMatching( ".%d.%d$" )
|
||||||
|
-- -- will return the all statics found ending in "-1-1" to "-9-9", but not e.g. "-10-1" or "-1-10"
|
||||||
|
function STATIC:FindAllByMatching( Pattern )
|
||||||
|
local GroupsFound = {}
|
||||||
|
|
||||||
|
for name,static in pairs(_DATABASE.STATICS) do
|
||||||
|
if string.match(name, Pattern ) then
|
||||||
|
GroupsFound[#GroupsFound+1] = static
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return GroupsFound
|
||||||
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user