From fa0d076a09d203e1a83ad4f17765b88f303463c1 Mon Sep 17 00:00:00 2001 From: dogjutsu <49013203+dogjutsu@users.noreply.github.com> Date: Thu, 1 Sep 2022 21:19:50 -0700 Subject: [PATCH] Dogjutsu/develop/feature/zone properties (#1774) * Fixed some typos of forms of the word 'strategy'. * Retrieve Zone 'properties' with ZONE_BASE. * Extraneous comment cleanup. Co-authored-by: dogjutsu --- Moose Development/Moose/Core/Database.lua | 11 +++++++++ Moose Development/Moose/Core/Zone.lua | 27 +++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index 4006b4a2a..e80f36558 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -326,6 +326,17 @@ do -- Zones -- Store zone ID. Zone.ZoneID=ZoneData.zoneId + -- Store zone properties (if any) + local ZoneProperties = ZoneData.properties or nil + Zone.Properties = {} + if ZoneName and ZoneProperties then + for _,ZoneProp in ipairs(ZoneProperties) do + if ZoneProp.key then + Zone.Properties[ZoneProp.key] = ZoneProp.value + end + end + end + -- Store in DB. self.ZONENAMES[ZoneName] = ZoneName diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 0a94fdc04..5529ca9ec 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -62,6 +62,7 @@ -- @field #table FillColor Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value. -- @field #number drawCoalition Draw coalition. -- @field #number ZoneID ID of zone. Only zones defined in the ME have an ID! +-- @field #table Table of any trigger zone properties from the ME. The key is the Name of the property, and the value is the property's Value. -- @field #number Surface Type of surface. Only determined at the center of the zone! -- @extends Core.Fsm#FSM @@ -106,6 +107,11 @@ -- * @{#ZONE_BASE.SmokeZone}(): Smokes the zone boundaries in a color. -- * @{#ZONE_BASE.FlareZone}(): Flares the zone boundaries in a color. -- +-- ## A zone might have additional Properties created in the DCS Mission Editor, which can be accessed: +-- +-- *@{#ZONE_BASE.GetProperty}(): Returns the Value of the zone with the given PropertyName, or nil if no matching property exists. +-- *@{#ZONE_BASE.GetAllProperties}(): Returns the zone Properties table. +-- -- @field #ZONE_BASE ZONE_BASE = { ClassName = "ZONE_BASE", @@ -114,6 +120,7 @@ ZONE_BASE = { DrawID=nil, Color={}, ZoneID=nil, + Properties={}, Sureface=nil, } @@ -557,6 +564,26 @@ function ZONE_BASE:GetZoneMaybe() end end +-- Returns the Value of the zone with the given PropertyName, or nil if no matching property exists. +-- @param #ZONE_BASE self +-- @param #string PropertyName The name of a the TriggerZone Property to be retrieved. +-- @return #string The Value of the TriggerZone Property with the given PropertyName, or nil if absent. +-- @usage +-- +-- local PropertiesZone = ZONE:FindByName("Properties Zone") +-- local Property = "ExampleProperty" +-- local PropertyValue = PropertiesZone:GetProperty(PropertyName) +-- +function ZONE_BASE:GetProperty(PropertyName) + return self.Properties[PropertyName] +end + +-- Returns the zone Properties table. +-- @param #ZONE_BASE self +-- @return #table The Key:Value table of TriggerZone properties of the zone. +function ZONE_BASE:GetAllProperties() + return self.Properties +end --- The ZONE_RADIUS class, defined by a zone name, a location and a radius. -- @type ZONE_RADIUS