SPAWNSTATIC class reworked

**SPAWNSTATIC**
- Added option to link statics to units, e.g. carriers.
- Fixed SpawnFromType function.
- Added :InitXYZ functions to set parameters.
- Removed ReSpawn functions. Pointless here. Use Respawn of STATIC class instead.
- Updated docs.

**COORDINATE**
- Added optional parameter to IsDay() and IsNight() functions to check on specific time.

**STATIC**
- Fixed Respawn functions so that statics do not appear on top of each other.

**UTILS**
- Added optional parameter to GetMissionDay and GetMissionDayOfYear functions.

**AIRBOSS**
- Adjusted recovery turn time interval back to 5 min in :SetRecoveryTurnTime() function.
This commit is contained in:
Frank
2020-05-27 22:18:18 +02:00
parent 61bb59d8b3
commit 833d4f7b65
6 changed files with 411 additions and 248 deletions

View File

@@ -194,7 +194,7 @@ end
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
-- @param #number Heading The heading of the static respawn in degrees. Default is 0 deg.
-- @param #number Delay Delay in seconds before the static is spawned.
function STATIC:SpawnAt( Coordinate, Heading, Delay )
function STATIC:SpawnAt(Coordinate, Heading, Delay)
Heading=Heading or 0
@@ -202,51 +202,58 @@ function STATIC:SpawnAt( Coordinate, Heading, Delay )
SCHEDULER:New(nil, self.SpawnAt, {self, Coordinate, Heading}, Delay)
else
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName )
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName)
SpawnStatic:SpawnFromPointVec2( Coordinate, Heading, self.StaticName )
end
return self
end
--- Respawn the @{Wrapper.Unit} at the same location with the same properties.
-- This is useful to respawn a cargo after it has been destroyed.
-- @param #STATIC self
-- @param DCS#country.id countryid The country ID used for spawning the new static. Default is same as currently.
-- @param #number Delay Delay in seconds before static is respawned.
function STATIC:ReSpawn(countryid, Delay)
countryid=countryid or self:GetCountry()
-- @param DCS#country.id CountryID (Optional) The country ID used for spawning the new static. Default is same as currently.
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default now.
function STATIC:ReSpawn(CountryID, Delay)
if Delay and Delay>0 then
SCHEDULER:New(nil, self.ReSpawn, {self, countryid}, Delay)
SCHEDULER:New(nil, self.ReSpawn, {self, CountryID}, Delay)
else
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName, countryid )
CountryID=CountryID or self:GetCountry()
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, CountryID)
SpawnStatic:ReSpawn()
SpawnStatic:Spawn(nil, self.StaticName)
end
return self
end
--- Respawn the @{Wrapper.Unit} at a defined Coordinate with an optional heading.
-- @param #STATIC self
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
-- @param #number Heading The heading of the static respawn in degrees. Default is 0 deg.
-- @param #number Delay Delay in seconds before static is respawned.
function STATIC:ReSpawnAt( Coordinate, Heading, Delay )
-- @param #number Heading (Optional) The heading of the static respawn in degrees. Default the current heading.
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default now.
function STATIC:ReSpawnAt(Coordinate, Heading, Delay)
Heading=Heading or 0
--Heading=Heading or 0
if Delay and Delay>0 then
SCHEDULER:New(nil, self.ReSpawnAt, {self, Coordinate, Heading}, Delay)
else
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName )
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, self:GetCountry())
SpawnStatic:SpawnFromCoordinate(Coordinate, Heading, self.StaticName)
SpawnStatic:ReSpawnAt( Coordinate, Heading )
end
return self
end