From 5c6e50e7f9422fb35ee1e0f6905260f16d5dbc76 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 11 Jun 2020 23:44:19 +0200 Subject: [PATCH] Update SpawnStatic.lua - Fixed #1335 --- Moose Development/Moose/Core/SpawnStatic.lua | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Moose Development/Moose/Core/SpawnStatic.lua b/Moose Development/Moose/Core/SpawnStatic.lua index d1ef5b3da..815eef099 100644 --- a/Moose Development/Moose/Core/SpawnStatic.lua +++ b/Moose Development/Moose/Core/SpawnStatic.lua @@ -52,6 +52,8 @@ -- @field #string InitStaticName Name of the static. -- @field Core.Point#COORDINATE InitStaticCoordinate Coordinate where to spawn the static. -- @field #boolean InitDead Set static to be dead if true. +-- @field #boolean InitCargo If true, static can act as cargo. +-- @field #number InitCargoMass Mass of cargo in kg. -- @extends Core.Base#BASE @@ -126,6 +128,8 @@ SPAWNSTATIC = { -- @field #number unitId Unit ID. -- @field #number groupId Group ID. -- @field #table offsets Offset parameters when linked to a unit. +-- @field #number mass Cargo mass in kg. +-- @field #boolean canCargo Static can be a cargo. --- Creates the main object to spawn a @{Static} defined in the mission editor (ME). -- @param #SPAWNSTATIC self @@ -237,6 +241,24 @@ function SPAWNSTATIC:InitShape(StaticShape) return self end +--- Initialize cargo mass. +-- @param #SPAWNSTATIC self +-- @param #number Mass Mass of the cargo in kg. +-- @return #SPAWNSTATIC self +function SPAWNSTATIC:InitCargoMass(Mass) + self.InitCargoMass=Mass + return self +end + +--- Initialize as cargo. +-- @param #SPAWNSTATIC self +-- @param #boolean IsCargo If true, this static can act as cargo. +-- @return #SPAWNSTATIC self +function SPAWNSTATIC:InitCargo(IsCargo) + self.InitCargo=IsCargo + return self +end + --- Initialize country of the spawned static. This determines the category. -- @param #SPAWNSTATIC self -- @param #string CountryID The country ID, e.g. country.id.USA. @@ -385,6 +407,10 @@ function SPAWNSTATIC:_SpawnStatic(Template, CountryID) Template.dead=self.InitDead end + if self.InitCargo~=nil then + Template.isCargo=self.InitCargo + end + if self.InitLinkUnit then Template.linkUnit=self.InitLinkUnit:GetID() Template.linkOffset=true @@ -402,12 +428,14 @@ function SPAWNSTATIC:_SpawnStatic(Template, CountryID) -- Register the new static. --_DATABASE:_RegisterStaticTemplate(Template, self.CoalitionID, self.CategoryID, CountryID) + _DATABASE:AddStatic(Template.name) -- Debug output. self:T(Template) -- Add static to the game. local Static=coalition.addStaticObject(CountryID, Template) + return _DATABASE:FindStatic(Static:getName()) end