diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 780dc31c8..9a5409bdf 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -2855,7 +2855,7 @@ do -- Route methods -- @param Core.Zone#ZONE Zone The zone where to route to. -- @param #boolean Randomize Defines whether to target point gets randomized within the Zone. -- @param #number Speed The speed in m/s. Default is 5.555 m/s = 20 km/h. - -- @param Core.Base#FORMATION Formation The formation string. + -- @param DCS#FORMATION Formation The formation string. function CONTROLLABLE:TaskRouteToZone( Zone, Randomize, Speed, Formation ) self:F2( Zone ) @@ -2915,7 +2915,7 @@ do -- Route methods -- @param #CONTROLLABLE self -- @param DCS#Vec2 Vec2 The Vec2 where to route to. -- @param #number Speed The speed in m/s. Default is 5.555 m/s = 20 km/h. - -- @param Core.Base#FORMATION Formation The formation string. + -- @param DCS#FORMATION Formation The formation string. function CONTROLLABLE:TaskRouteToVec2( Vec2, Speed, Formation ) local DCSControllable = self:GetDCSObject() diff --git a/Moose Development/Moose/Wrapper/DynamicCargo.lua b/Moose Development/Moose/Wrapper/DynamicCargo.lua index 8c4987f72..76a874198 100644 --- a/Moose Development/Moose/Wrapper/DynamicCargo.lua +++ b/Moose Development/Moose/Wrapper/DynamicCargo.lua @@ -534,7 +534,10 @@ function DYNAMICCARGO:_UpdatePosition() --------------- -- REMOVED Cargo --------------- - if self.timer and self.timer:IsRunning() then self.timer:Stop() end + if self.timer and self.timer:IsRunning() then + self.timer:Stop() + self.timer=nil + end self:T(self.lid.." dead! " ..self.CargoState.."-> REMOVED") self.CargoState = DYNAMICCARGO.State.REMOVED _DATABASE:CreateEventDynamicCargoRemoved(self) @@ -542,6 +545,24 @@ function DYNAMICCARGO:_UpdatePosition() return self end +--- [USER] Destroy a DYNAMICCARGO object. +-- @param #DYNAMICCARGO self +-- @param #boolean GenerateEvent Set to false to remove an item silently. Defaults to true. +-- @return #boolean Return Returns nil if the object could not be found, else returns true. +function DYNAMICCARGO:Destroy(GenerateEvent) + local DCSObject = self:GetDCSObject() + if DCSObject then + local GenerateEvent = (GenerateEvent ~= nil and GenerateEvent == false) and false or true + if GenerateEvent and GenerateEvent == true then + self:CreateEventDead( timer.getTime(), DCSObject ) + end + DCSObject:destroy() + self:_UpdatePosition() + return true + end + return nil +end + --- [Internal] Track helos for loaded/unloaded decision making. -- @param Wrapper.Client#CLIENT client -- @return #boolean IsIn diff --git a/Moose Development/Moose/Wrapper/Static.lua b/Moose Development/Moose/Wrapper/Static.lua index 7c2436641..eb0899a5f 100644 --- a/Moose Development/Moose/Wrapper/Static.lua +++ b/Moose Development/Moose/Wrapper/Static.lua @@ -64,6 +64,9 @@ function STATIC:Register( StaticName ) else self:E(string.format("Static object %s does not exist!", tostring(self.StaticName))) end + + -- Cache position + self._vec3 = self:GetVec3() return self end @@ -86,6 +89,30 @@ function STATIC:GetLife() return nil end +--- Get the position of the STATIC even if it is not alive. +-- @param #STATIC self +-- @return DCS#Vec2 The 2D point vector of the POSITIONABLE. +-- @return #nil The position was not cached. +function STATIC:GetVec2Cached() + local vec2 = self:GetVec2() + if not vec2 and self._vec3 then + vec2 = {x = self._vec3.x, y = self._vec3.z } + end + return vec2 +end + +--- Get the position of the STATIC even if it is not alive. +-- @param #STATIC self +-- @return DCS#Vec3 The 3D point vector of the POSITIONABLE. +-- @return #nil The position was not cached. +function STATIC:GetVec3Cached() + local vec3 = self:GetVec3() + if not vec3 and self._vec3 then + vec3 = self._vec3 + end + return vec3 +end + --- Finds a STATIC from the _DATABASE using a DCSStatic object. -- @param #STATIC self -- @param DCS#StaticObject DCSStatic An existing DCS Static object reference. @@ -232,6 +259,8 @@ function STATIC:SpawnAt(Coordinate, Heading, Delay) local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName) SpawnStatic:SpawnFromPointVec2( Coordinate, Heading, self.StaticName ) + -- Cache position + self._vec3 = self:GetVec3() end @@ -255,6 +284,8 @@ function STATIC:ReSpawn(CountryID, Delay) local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, CountryID) SpawnStatic:Spawn(nil, self.StaticName) + -- Cache position + self._vec3 = self:GetVec3() end @@ -278,6 +309,8 @@ function STATIC:ReSpawnAt(Coordinate, Heading, Delay) local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, self:GetCountry()) SpawnStatic:SpawnFromCoordinate(Coordinate, Heading, self.StaticName) + -- Cache position + self._vec3 = self:GetVec3() end