Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95fe7e1058 | ||
|
|
b8fe242c43 | ||
|
|
772397250f | ||
|
|
61ba4de338 | ||
|
|
674160abbf | ||
|
|
8ff25ffeb0 | ||
|
|
0a7e8ea977 | ||
|
|
96507f1d34 | ||
|
|
96ada242a4 | ||
|
|
2bce1985e2 | ||
|
|
428fe75a12 | ||
|
|
2e5a31faef |
Binary file not shown.
|
After Width: | Height: | Size: 345 KiB |
@@ -21,6 +21,9 @@
|
||||
<main>
|
||||
<div class="reference-container">
|
||||
<div class="side-nav">
|
||||
|
||||
<div id="beta-box-div"></div>
|
||||
|
||||
<h4>Quick Links</h4>
|
||||
<ul>
|
||||
<li><a href="/pages/tutorials.html" class="side-nav-h2">Tutorials</a></li>
|
||||
@@ -59,6 +62,13 @@
|
||||
<footer>
|
||||
<p>© 2025 Spearhead Project</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
if (true || window.location.hostname.toLowerCase() == 'beta.spearhead.rocks') {
|
||||
betaHtml = '<note-box type="warning" title="Beta Version">You are looking at docs that are released with the beta version.</note-box>';
|
||||
}
|
||||
document.getElementById('beta-box-div').innerHTML = betaHtml || '';
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -168,8 +168,14 @@ class Sidebar extends HTMLElement {
|
||||
}
|
||||
|
||||
render() {
|
||||
var betaHtml = '';
|
||||
if (window.location.hostname.toLowerCase() == 'beta.spearhead.rocks') {
|
||||
betaHtml = '<note-box type="warning" title="Beta Version">You are looking at docs that are released with the beta version.</note-box>';
|
||||
}
|
||||
|
||||
this.innerHTML = `
|
||||
<div class="side-nav">
|
||||
${betaHtml}
|
||||
<h4 class="side-nav-title"></h4>
|
||||
<ul>
|
||||
<!-- Navigation items will be populated automatically -->
|
||||
|
||||
@@ -99,10 +99,66 @@
|
||||
</p>
|
||||
|
||||
<h3 id="mermaid-log-example">Log Example</h3>
|
||||
<p> TODO: Show log example</p>
|
||||
<code-block>
|
||||
2026-09-01 17:53:13.213 INFO SCRIPTING (Main): [Spearhead][StageManager] ========== STAGE FLOW DIAGRAM ==========
|
||||
graph TD
|
||||
default_8["MAIN-2 (S8)"]
|
||||
b_5["West Valley (S5)"]
|
||||
default_1["MAIN-1 (S1)"]
|
||||
a_5["WEST-2 (S5)"]
|
||||
default_4["MAIN-2 (S4)"]
|
||||
default_10["MAIN-1 (S10)"]
|
||||
default_6["MAIN-2 (S6)"]
|
||||
a_4["WEST-1 (S4)"]
|
||||
default_3["MAIN-1 (S3)"]
|
||||
default_9["MAIN-3 (S9)"]
|
||||
a_7["WEST-2 (S7)"]
|
||||
a_3["WEST (S3)"]
|
||||
default_5["MAIN-3 (S5)"]
|
||||
b_6["West Valley-1 (S6)"]
|
||||
default_61["CAP-Maykop (S61)"]
|
||||
default_7["MAIN-1 (S7)"]
|
||||
default_0["START (S0)"]
|
||||
a_6["WEST-3 (S6)"]
|
||||
default_60["CAP-Nalchik (S60)"]
|
||||
default_2["MAIN (S2)"]
|
||||
a_2["WEST-1 (S2)"]
|
||||
a_2 --> a_3
|
||||
a_3 --> a_4
|
||||
a_4 --> a_5
|
||||
a_5 --> a_6
|
||||
a_6 --> a_7
|
||||
default_0 --> default_1
|
||||
default_1 --> default_2
|
||||
default_2 --> default_3
|
||||
default_3 --> default_4
|
||||
default_4 --> default_5
|
||||
default_5 --> default_6
|
||||
default_6 --> default_7
|
||||
default_7 --> default_8
|
||||
default_8 --> default_9
|
||||
default_9 --> default_10
|
||||
default_10 -->|chapter| default_60
|
||||
default_60 --> default_61
|
||||
b_5 --> b_6
|
||||
default_2 -->|unlock| a_2
|
||||
default_5 -->|unlock| b_5
|
||||
a_7 -->|gate| default_60
|
||||
b_6 -->|gate| default_60
|
||||
========== END DIAGRAM ==========
|
||||
|
||||
</code-block>
|
||||
|
||||
<h3 id="mermaid-diagram-example">Diagram Example</h3>
|
||||
<p> TODO: Show diagram example</p>
|
||||
<p>
|
||||
If you want to then copy and paste everything between the <br>
|
||||
<code-inline>========== STAGE FLOW DIAGRAM ==========</code-inline> and <br>
|
||||
<code-inline>========== END DIAGRAM ==========</code-inline> <br>
|
||||
you will be able to go to <a href="https://mermaid.live/">https://mermaid.live/</a> and paste the diagram code into the editor. <br>
|
||||
|
||||
It would look like this:
|
||||
</p>
|
||||
<img src="/img/mermaid-preview.png" alt="Example of mermaid diagram">
|
||||
|
||||
<h2 id="lane-limitations">Limitations</h2>
|
||||
<h3 class="lane-limitations-cap">CAP</h3>
|
||||
|
||||
@@ -253,6 +253,13 @@
|
||||
To make an airbase buildable add a text box inside of the trigger zone and name it: <code-inline>buildable_[freeform]</code-inline> <br/>
|
||||
Then in the text box type amount of kilo's you want to be transfered before the logistisc mission is complete. <br/>
|
||||
|
||||
<br>
|
||||
To add a custom briefing for a buildable zone, include a text box inside the trigger zone and name it: <code-inline>supplybriefing_[freeform]</code-inline>.
|
||||
<code-inline>{{coords}}</code-inline> is highly recommended so the players can easily find their landing zone.<br>
|
||||
Additionally, the amount of kilos required and delivered are always shown on the bottom, as well as a note to not land in the construction zone.
|
||||
<br/>
|
||||
|
||||
|
||||
<br>
|
||||
The base or zone will slowly build up with each crate giving both a nice view of it happening AND it's good for performance as there's not a big addition of objects at once. <br/>
|
||||
Right now a crate takes 15 seconds to unpack per 500kg. Meaning 2 crates of 1000kg will be faster than 1 crate of 2000kg. <br/>
|
||||
|
||||
@@ -4,13 +4,14 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
paths:
|
||||
- '.docs/**'
|
||||
|
||||
env:
|
||||
DOCKER_REGISTRY: registry.dutchie031.net
|
||||
DOCKER_IMAGE: spearhead-docs
|
||||
DOCKER_TAG: latest
|
||||
DOCKER_TAG: ${{ github.ref_name == 'main' && 'latest' || 'beta' }}
|
||||
|
||||
jobs:
|
||||
## Run replacements and cleanups on the docs
|
||||
@@ -36,7 +37,7 @@ jobs:
|
||||
sed -i '/@@API_CODE@@/d' .docs/web/pages/spearheadapi.html
|
||||
rm .docs/web/pages/temp_api_code.html
|
||||
|
||||
- name: Highlight API code and update HTML
|
||||
- name: Highlight Config code and update HTML
|
||||
run: |
|
||||
pygmentize -f html -l lua -O noclasses,style=monokai ./config.lua > .docs/web/pages/temp_config_code.html
|
||||
# Insert the highlighted code into the placeholder in spearheadapi.html
|
||||
@@ -105,15 +106,30 @@ jobs:
|
||||
chmod 600 $HOME/.kube/config
|
||||
cat $HOME/.kube/config
|
||||
|
||||
- name: Run Helm upgrade/install
|
||||
- name: Run Helm upgrade/install spearhead-docs (main)
|
||||
if: github.ref_name == 'main'
|
||||
run: |
|
||||
helm upgrade --install spearhead-docs .helm \
|
||||
--namespace spearhead-docs \
|
||||
--create-namespace \
|
||||
-f .helm/values.yaml \
|
||||
--set image.repository=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }} \
|
||||
--set image.tag=${{ env.DOCKER_TAG }} \
|
||||
--wait
|
||||
|
||||
- name: Run Helm upgrade/install spearhead-docs (develop)
|
||||
if: github.ref_name == 'develop'
|
||||
run: |
|
||||
helm upgrade --install spearhead-docs-beta .helm \
|
||||
--namespace spearhead-docs \
|
||||
--create-namespace \
|
||||
-f .helm/values.yaml \
|
||||
-f .helm/values.beta.yaml \
|
||||
--set image.repository=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }} \
|
||||
--set image.tag=${{ env.DOCKER_TAG }} \
|
||||
--wait
|
||||
|
||||
|
||||
# - name: 'Deploy'
|
||||
# uses: deliverybot/helm@v1
|
||||
# with:
|
||||
|
||||
@@ -14,3 +14,4 @@ sources:
|
||||
maintainers:
|
||||
- name: Spearhead Team
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ spec:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: {{ .Values.app }}
|
||||
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: {{ .Values.ports.containerPort }}
|
||||
|
||||
@@ -14,7 +14,7 @@ spec:
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ .Values.app }}-ingress
|
||||
name: "{{ .Values.app }}-ingress"
|
||||
namespace: spearhead-docs
|
||||
annotations:
|
||||
kubernetes.io/tls-acme: "true"
|
||||
@@ -22,28 +22,21 @@ metadata:
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
rules:
|
||||
- host: spearhead.dutchie031.com
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ . }}
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: {{ .Values.app }}
|
||||
name: {{ $.Values.app }}
|
||||
port:
|
||||
number: {{ .Values.ports.servicePort }}
|
||||
- host: spearhead.rocks
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: {{ .Values.app }}
|
||||
port:
|
||||
number: {{ .Values.ports.servicePort }}
|
||||
number: {{ $.Values.ports.servicePort }}
|
||||
{{- end }}
|
||||
tls:
|
||||
- hosts:
|
||||
- spearhead.dutchie031.com
|
||||
- spearhead.rocks
|
||||
secretName: spearhead-docs-tls
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- {{ . }}
|
||||
{{- end }}
|
||||
secretName: "{{ .Values.app }}-docs-tls"
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
app: spearhead-docs-beta
|
||||
|
||||
image:
|
||||
tag: "beta"
|
||||
|
||||
ingress:
|
||||
hosts:
|
||||
- beta.spearhead.rocks
|
||||
@@ -8,3 +8,8 @@ image:
|
||||
ports:
|
||||
servicePort: 80
|
||||
containerPort: 80
|
||||
|
||||
ingress:
|
||||
hosts:
|
||||
- spearhead.dutchie031.com
|
||||
- spearhead.rocks
|
||||
@@ -15,6 +15,10 @@
|
||||
These lanes can be used to create different stage progression flows and create different "side-stories".
|
||||
#40
|
||||
|
||||
- Issue: #37
|
||||
Now enabled the mission editor to add a custom briefing to the "Buildable" missions.
|
||||
#44
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
## [0.13.0] 2026-08
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "excalidraw",
|
||||
"version": 2,
|
||||
"source": "vscode-webview://1h45nhtr1vhnknf2q5n6qdd43citnkfueml5qdvamifv7pfv0our",
|
||||
"source": "vscode-webview://1hn2vaam3v69jt67pr4i27hnkafotvd70l4ao9nlb18pmrffl5dm",
|
||||
"elements": [
|
||||
{
|
||||
"id": "kJXWwZE94uUnPMEB7mBNj",
|
||||
@@ -629,11 +629,11 @@
|
||||
"type": 2
|
||||
},
|
||||
"seed": 2125327475,
|
||||
"version": 44,
|
||||
"versionNonce": 2047370396,
|
||||
"version": 46,
|
||||
"versionNonce": 342494645,
|
||||
"isDeleted": true,
|
||||
"boundElements": [],
|
||||
"updated": 1788258273370,
|
||||
"updated": 1788285477032,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"points": [
|
||||
@@ -2426,7 +2426,7 @@
|
||||
"version": 112,
|
||||
"versionNonce": 1755199388,
|
||||
"isDeleted": false,
|
||||
"boundElements": null,
|
||||
"boundElements": [],
|
||||
"updated": 1788258305636,
|
||||
"link": null,
|
||||
"locked": false
|
||||
@@ -2456,7 +2456,7 @@
|
||||
"version": 28,
|
||||
"versionNonce": 557293604,
|
||||
"isDeleted": false,
|
||||
"boundElements": null,
|
||||
"boundElements": [],
|
||||
"updated": 1788258305636,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
@@ -2598,7 +2598,7 @@
|
||||
"version": 7,
|
||||
"versionNonce": 969870492,
|
||||
"isDeleted": true,
|
||||
"boundElements": null,
|
||||
"boundElements": [],
|
||||
"updated": 1788258356227,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
@@ -2637,7 +2637,7 @@
|
||||
"version": 3,
|
||||
"versionNonce": 1886913564,
|
||||
"isDeleted": true,
|
||||
"boundElements": null,
|
||||
"boundElements": [],
|
||||
"updated": 1788258344772,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
@@ -2713,7 +2713,7 @@
|
||||
"version": 3,
|
||||
"versionNonce": 1539555236,
|
||||
"isDeleted": true,
|
||||
"boundElements": null,
|
||||
"boundElements": [],
|
||||
"updated": 1788258343223,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
|
||||
@@ -34,7 +34,7 @@ function AirGroup:New(groupName, groupType, config, logger, spawnManager)
|
||||
self._config = config
|
||||
self._logger = logger
|
||||
self._spawnManager = spawnManager
|
||||
self._routeDrawing = nil
|
||||
self._routeDrawings = {}
|
||||
|
||||
local group = Group.getByName(self._groupName)
|
||||
if group then
|
||||
|
||||
@@ -58,6 +58,7 @@ local StageDrawing = require("classes.stageClasses.drawings.StageDrawing")
|
||||
---@class BlueSamData
|
||||
---@field groups Array<string>
|
||||
---@field buildingKilos number?
|
||||
---@field briefing string?
|
||||
|
||||
---@class MissionZoneData
|
||||
---@field ZoneName string
|
||||
@@ -74,6 +75,7 @@ local StageDrawing = require("classes.stageClasses.drawings.StageDrawing")
|
||||
---@field padNames Array<string>
|
||||
---@field buildingKilos number?
|
||||
---@field supplyHubNames Array<string>
|
||||
---@field briefing string?
|
||||
|
||||
---@class Database
|
||||
---@field private _tables DatabaseTables
|
||||
@@ -616,6 +618,27 @@ function Database:loadBlueSamUnits()
|
||||
local number = tonumber(kvPair.value)
|
||||
if number and number > 0 then
|
||||
samData.buildingKilos = number
|
||||
|
||||
if env.mission.drawings and env.mission.drawings.layers then
|
||||
for i, layer in pairs(env.mission.drawings.layers) do
|
||||
if string.lower(layer.name) == "author" then
|
||||
for key, layer_object in pairs(layer.objects) do
|
||||
|
||||
local vec2 = { x = layer_object.mapX, y = layer_object.mapY }
|
||||
if triggerZone and Util.is2dPointInZone(vec2, triggerZone) then
|
||||
if layer_object.name and Util.startswith(layer_object.name, "supplybriefing_", true) then
|
||||
local description = layer_object.text
|
||||
if description and description ~= "" then
|
||||
samData.briefing = description
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
MissionEditorWarnings.Add("Buildable number for " .. blueSamZone .. " is invalid")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -750,7 +773,31 @@ function Database:loadFarpData()
|
||||
local number = tonumber(kvPair.value)
|
||||
if number and number > 0 then
|
||||
farpzoneData.buildingKilos = number
|
||||
|
||||
-- check briefings
|
||||
if env.mission.drawings and env.mission.drawings.layers then
|
||||
for i, layer in pairs(env.mission.drawings.layers) do
|
||||
if string.lower(layer.name) == "author" then
|
||||
for key, layer_object in pairs(layer.objects) do
|
||||
|
||||
local vec2 = { x = layer_object.mapX, y = layer_object.mapY }
|
||||
if triggerZone and Util.is2dPointInZone(vec2, triggerZone) then
|
||||
if layer_object.name and Util.startswith(layer_object.name, "supplybriefing_", true) then
|
||||
local description = layer_object.text
|
||||
if description and description ~= "" then
|
||||
farpzoneData.briefing = description
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
MissionEditorWarnings.Add("Buildable number for " .. farpZone .. " is invalid.")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -368,12 +368,51 @@ function GlobalStageManager:PrintMermaidStage()
|
||||
local stageIndicesByLane = {} -- Track all stage indices per lane
|
||||
local mainLaneId = "default"
|
||||
|
||||
-- Color palette for lanes (26 vibrant colors optimized for dark mode)
|
||||
local laneColors = {
|
||||
"#FF6B6B", -- 1: Red
|
||||
"#4ECDC4", -- 2: Teal
|
||||
"#45B7D1", -- 3: Blue
|
||||
"#FFA502", -- 4: Orange
|
||||
"#95E1D3", -- 5: Mint
|
||||
"#F38181", -- 6: Coral
|
||||
"#AA96DA", -- 7: Purple
|
||||
"#FCBAD3", -- 8: Pink
|
||||
"#A8E6CF", -- 9: Light green
|
||||
"#FFD3B6", -- 10: Peach
|
||||
"#FFAAA5", -- 11: Light red
|
||||
"#FF8B94", -- 12: Rose
|
||||
"#FFEAA7", -- 13: Butter
|
||||
"#DFE6E9", -- 14: Gray
|
||||
"#00B894", -- 15: Emerald
|
||||
"#0984E3", -- 16: Cobalt
|
||||
"#6C5CE7", -- 17: Indigo
|
||||
"#A29BFE", -- 18: Lavender
|
||||
"#FD79A8", -- 19: Magenta
|
||||
"#FDCB6E", -- 20: Gold
|
||||
"#6C757D", -- 21: Slate
|
||||
"#20C997", -- 22: Seafoam
|
||||
"#E74C3C", -- 23: Scarlet
|
||||
"#3498DB", -- 24: Dodger blue
|
||||
"#9B59B6", -- 25: Amethyst
|
||||
"#1ABC9C", -- 26: Turquoise
|
||||
}
|
||||
local laneColorMap = {} -- Map lane ID to color
|
||||
local colorIndex = 1
|
||||
|
||||
-- Build nodes and collect all stage indices per lane
|
||||
for _, lane in ipairs(lanes) do
|
||||
local laneId = lane:GetStageLaneIdentifier() or "default"
|
||||
local stageIndices = lane:GetAllStageIndices()
|
||||
stageIndicesByLane[laneId] = stageIndices
|
||||
|
||||
-- Assign color to this lane
|
||||
laneColorMap[laneId] = laneColors[colorIndex]
|
||||
colorIndex = colorIndex + 1
|
||||
if colorIndex > #laneColors then
|
||||
colorIndex = 1
|
||||
end
|
||||
|
||||
-- Create nodes for each stage index in this lane
|
||||
for _, stageIndex in ipairs(stageIndices) do
|
||||
local stages = lane:GetStagesAtIndex(stageIndex)
|
||||
@@ -382,7 +421,18 @@ function GlobalStageManager:PrintMermaidStage()
|
||||
for _, stage in ipairs(stages) do
|
||||
local nodeId = laneId .. "_" .. stageIndex
|
||||
local stageType = stage:GetStageType()
|
||||
local label = stage.stageName or stage.zoneName
|
||||
local stageName = stage.stageName or stage.zoneName
|
||||
|
||||
-- Generate bracket label: [1], [2] for default, [w1], [e2] for other lanes
|
||||
local bracketLabel
|
||||
if laneId == "default" then
|
||||
bracketLabel = "[" .. stageIndex .. "]"
|
||||
else
|
||||
bracketLabel = "[" .. laneId .. stageIndex .. "]"
|
||||
end
|
||||
|
||||
-- Combined label: [bracket] Name
|
||||
local label = bracketLabel .. " " .. stageName
|
||||
|
||||
-- Different node shapes for different stage types
|
||||
local nodeShape = "["
|
||||
@@ -395,8 +445,8 @@ function GlobalStageManager:PrintMermaidStage()
|
||||
nodeEnd = "]]"
|
||||
end
|
||||
|
||||
nodes[nodeId] = string.format(' %s%s"%s (S%d)"%s',
|
||||
nodeId, nodeShape, label, stageIndex, nodeEnd)
|
||||
nodes[nodeId] = string.format(' %s%s"%s"%s',
|
||||
nodeId, nodeShape, label, nodeEnd)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -435,7 +485,7 @@ function GlobalStageManager:PrintMermaidStage()
|
||||
end
|
||||
|
||||
-- Add dependencies from DEFAULT lane to SIDE lanes at chapter starts
|
||||
-- Side lanes activate when main reaches a chapter start index for that side lane
|
||||
-- Side lanes activate when main completes the stage BEFORE the chapter start
|
||||
if mainStageLane then
|
||||
for _, lane in ipairs(lanes) do
|
||||
if lane:IsDefaultStageLane() == false then
|
||||
@@ -446,9 +496,10 @@ function GlobalStageManager:PrintMermaidStage()
|
||||
for _, stageIdx in ipairs(sideIndices) do
|
||||
-- Check if this is a chapter start in the side lane
|
||||
if lane:IsChapterStart(stageIdx) then
|
||||
local fromNodeId = mainLaneId .. "_" .. stageIdx
|
||||
-- Main lane must complete (stageIdx - 1) to activate side lane at stageIdx
|
||||
local fromNodeId = mainLaneId .. "_" .. (stageIdx - 1)
|
||||
local toNodeId = sideId .. "_" .. stageIdx
|
||||
-- Side lane activates when main lane reaches this chapter start
|
||||
-- Side lane activates when main lane completes the prior stage
|
||||
table.insert(edges, string.format(' %s -->|unlock| %s', fromNodeId, toNodeId))
|
||||
end
|
||||
end
|
||||
@@ -502,13 +553,30 @@ function GlobalStageManager:PrintMermaidStage()
|
||||
|
||||
-- Build complete Mermaid diagram
|
||||
local diagramLines = {"graph TD"}
|
||||
|
||||
-- Add class definitions for each lane with colors and contrasting text
|
||||
for laneId, color in pairs(laneColorMap) do
|
||||
table.insert(diagramLines, string.format(' classDef lane_%s fill:%s,stroke:#333,stroke-width:2px,color:#000', laneId, color))
|
||||
end
|
||||
|
||||
-- Add nodes
|
||||
for _, nodeStr in pairs(nodes) do
|
||||
table.insert(diagramLines, nodeStr)
|
||||
end
|
||||
|
||||
-- Add edges
|
||||
for _, edgeStr in pairs(edges) do
|
||||
table.insert(diagramLines, edgeStr)
|
||||
end
|
||||
|
||||
-- Apply classes to nodes
|
||||
for nodeId in pairs(nodes) do
|
||||
local laneId = nodeId:match("(.+)_[0-9]+$")
|
||||
if laneId then
|
||||
table.insert(diagramLines, string.format(' class %s lane_%s', nodeId, laneId))
|
||||
end
|
||||
end
|
||||
|
||||
-- Print as single multi-line message
|
||||
local diagram = "========== STAGE FLOW DIAGRAM ==========\n" .. table.concat(diagramLines, "\n") .. "\n========== END DIAGRAM =========="
|
||||
self.logger:info(diagram)
|
||||
|
||||
@@ -89,7 +89,7 @@ function BlueSam.New(database, logger, zoneName, spawnManager)
|
||||
|
||||
local zone = DcsUtil.getZoneByName(zoneName)
|
||||
if zone then
|
||||
BuildableZone.New(self, zone, self._buildableCrateKilos or 0, "SAM_CRATE", self._blueGroups, logger, database)
|
||||
BuildableZone.New(self, zone, self._buildableCrateKilos or 0, "SAM_CRATE", self._blueGroups, logger, database, blueSamData.briefing)
|
||||
end
|
||||
|
||||
return self
|
||||
|
||||
@@ -64,7 +64,7 @@ function FarpZone.New(database, logger, zoneName, spawnManager)
|
||||
local zone = DcsUtil.getZoneByName(zoneName)
|
||||
if zone then
|
||||
self._logger:debug("Creating Buildable zone: " .. zoneName .. " with " .. (farpData.buildingKilos or "nil") .. " kilos")
|
||||
BuildableZone.New(self, zone, farpData.buildingKilos or 0, "FARP_CRATE", self._groups, logger, database)
|
||||
BuildableZone.New(self, zone, farpData.buildingKilos or 0, "FARP_CRATE", self._groups, logger, database, farpData.briefing)
|
||||
end
|
||||
end
|
||||
self:Deactivate()
|
||||
|
||||
@@ -20,7 +20,8 @@ BuildableZone.__index = BuildableZone
|
||||
---@param database Database
|
||||
---@param crateType SupplyType
|
||||
---@param logger Logger
|
||||
function BuildableZone:New(targetZone, kilosRequired, crateType, buildableGroups, logger, database)
|
||||
---@param briefing string?
|
||||
function BuildableZone:New(targetZone, kilosRequired, crateType, buildableGroups, logger, database, briefing)
|
||||
self._targetZone = targetZone
|
||||
self._requiredKilos = kilosRequired or 0
|
||||
self._buildableGroups = buildableGroups or {}
|
||||
@@ -69,7 +70,7 @@ function BuildableZone:New(targetZone, kilosRequired, crateType, buildableGroup
|
||||
|
||||
local noLandingZone = self:GetNoLandingZone()
|
||||
if kilosRequired and kilosRequired > 0 then
|
||||
self._buildableMission = BuildableMission.new(database, logger, targetZone, noLandingZone, kilosRequired, crateType)
|
||||
self._buildableMission = BuildableMission.new(database, logger, targetZone, noLandingZone, kilosRequired, crateType, briefing)
|
||||
self._buildableMission:AddOnCrateDroppedOfListener(self)
|
||||
else
|
||||
self._buildableMission = nil
|
||||
|
||||
@@ -13,6 +13,8 @@ local Events = require("classes.spearhead_events")
|
||||
local GlobalCapManager = require("classes.capClasses.GlobalCapManager")
|
||||
local CustomDrawing = require("classes.stageClasses.drawings.CustomDrawing")
|
||||
local DrawingHelper = require("classes.stageClasses.drawings.helper.DrawingHelper")
|
||||
local StageRepository = require("classes.stageClasses.StageRepository")
|
||||
local StageState = require("classes.stageClasses.Stages.BaseStage.StageState")
|
||||
|
||||
---@alias StageColor
|
||||
---| "RED"
|
||||
@@ -58,9 +60,9 @@ local DrawingHelper = require("classes.stageClasses.drawings.helper.DrawingHelpe
|
||||
--- @field protected _missionCommandsHelper MissionCommandsHelper
|
||||
--- @field protected _missionPriority MissionPriority
|
||||
--- @field protected _database Database
|
||||
--- @field protected _stageRepository StageRepository
|
||||
--- @field protected _db StageData
|
||||
--- @field protected _logger Logger
|
||||
--- @field protected _activeStage integer
|
||||
--- @field protected _stageConfig StageConfig
|
||||
--- @field protected _customDrawing CustomDrawing
|
||||
--- @field protected _spawnedGroups Array<string>
|
||||
@@ -72,14 +74,6 @@ local Stage = {}
|
||||
|
||||
Stage.__index = Stage
|
||||
|
||||
---@enum CurrentStageState
|
||||
Stage.CurrentStageState = {
|
||||
INACTIVE = 0,
|
||||
PREACTIVATED = 1,
|
||||
ACTIVE = 2,
|
||||
BLUE = 3
|
||||
}
|
||||
|
||||
Stage.StageColors = {
|
||||
INVISIBLE = { 0, 0, 0, 0 },
|
||||
RED_ACTIVE = { 1, 0, 0, 0.20 },
|
||||
@@ -100,16 +94,16 @@ Stage.StageColors = {
|
||||
function Stage:superNew(database, stageConfig, logger, initData, stageType, missionPriority, spawnManager)
|
||||
|
||||
logger:debug("[BaseStage] Initiating stage with name: " .. initData.stageZoneName)
|
||||
self._currentStageState = Stage.CurrentStageState.INACTIVE
|
||||
self._currentStageState = StageState.Inactive
|
||||
self.zoneName = initData.stageZoneName
|
||||
self.stageNumber = initData.stageNumber
|
||||
self._stageRepository = StageRepository.getInstance()
|
||||
if initData.stageLaneIdentifier then
|
||||
self._stageLaneIdentifier = string.lower(initData.stageLaneIdentifier)
|
||||
else
|
||||
self._stageLaneIdentifier = nil
|
||||
end
|
||||
self.stageName = initData.stageDisplayName
|
||||
self._currentStageState = Stage.CurrentStageState.INACTIVE
|
||||
self._stageType = stageType
|
||||
|
||||
self.OnPostStageComplete = nil
|
||||
@@ -131,7 +125,6 @@ function Stage:superNew(database, stageConfig, logger, initData, stageType, miss
|
||||
supplyHubs = {}
|
||||
}
|
||||
|
||||
self._activeStage = -99
|
||||
self._stageConfig = stageConfig or {}
|
||||
self._missionCommandsHelper = MissionCommandsHelper.getOrCreate()
|
||||
|
||||
@@ -289,7 +282,7 @@ end
|
||||
|
||||
---@return boolean
|
||||
function Stage:IsComplete()
|
||||
if self._currentStageState == Stage.CurrentStageState.BLUE then return true end
|
||||
if self._currentStageState >= StageState.Blue then return true end
|
||||
|
||||
for i, mission in pairs(self._db.sams) do
|
||||
local state = mission:getState()
|
||||
@@ -304,14 +297,12 @@ function Stage:IsComplete()
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
self._currentStageState = Stage.CurrentStageState.BLUE
|
||||
return true
|
||||
end
|
||||
|
||||
---@return boolean
|
||||
function Stage:IsActive()
|
||||
return self._currentStageState == Stage.CurrentStageState.ACTIVE
|
||||
return self._currentStageState == StageState.Activated
|
||||
end
|
||||
|
||||
---@return StageType
|
||||
@@ -429,19 +420,22 @@ end
|
||||
|
||||
---Activates all SAMS, Airbase units etc all at once.
|
||||
function Stage:PreActivate()
|
||||
if self._currentStageState == Stage.CurrentStageState.INACTIVE then
|
||||
self._currentStageState = Stage.CurrentStageState.PREACTIVATED
|
||||
for key, mission in pairs(self._db.sams) do
|
||||
if mission then
|
||||
mission:SpawnInactive()
|
||||
end
|
||||
end
|
||||
|
||||
for _, airbase in pairs(self._db.airbases) do
|
||||
airbase:ActivateRedStage()
|
||||
if self._currentStageState >= StageState.PreActivated then
|
||||
return
|
||||
end
|
||||
|
||||
self._currentStageState = StageState.PreActivated
|
||||
for key, mission in pairs(self._db.sams) do
|
||||
if mission then
|
||||
mission:SpawnInactive()
|
||||
end
|
||||
end
|
||||
|
||||
for _, airbase in pairs(self._db.airbases) do
|
||||
airbase:ActivateRedStage()
|
||||
end
|
||||
|
||||
self:MarkStage()
|
||||
|
||||
end
|
||||
@@ -455,22 +449,22 @@ function Stage:MarkStage()
|
||||
end
|
||||
|
||||
if self._stageConfig.isDrawStagesEnabled == false then return end
|
||||
if self._stageConfig.isDrawPreActivatedEnabled == false and self._currentStageState == Stage.CurrentStageState.PREACTIVATED then
|
||||
if self._stageConfig.isDrawPreActivatedEnabled == false and self._currentStageState == StageState.PreActivated then
|
||||
return
|
||||
end
|
||||
|
||||
if self._customDrawing then
|
||||
self._customDrawing:UpdateDrawingObject(function(drawingObject)
|
||||
local drawing = drawingObject --[[@as Polygon]]
|
||||
if self._currentStageState == Stage.CurrentStageState.ACTIVE then
|
||||
if self._currentStageState == StageState.Activated then
|
||||
drawing.fillColorString = DrawingHelper.ColorTableToColorString(Stage.StageColors.RED_ACTIVE)
|
||||
drawing.colorString = DrawingHelper.ColorTableToColorString(Stage.StageColors.RED_ACTIVE)
|
||||
drawing.style = "dot dash"
|
||||
elseif self._currentStageState == Stage.CurrentStageState.PREACTIVATED then
|
||||
elseif self._currentStageState == StageState.PreActivated then
|
||||
drawing.fillColorString = DrawingHelper.ColorTableToColorString(Stage.StageColors.RED_PREACTIVE)
|
||||
drawing.colorString = DrawingHelper.ColorTableToColorString(Stage.StageColors.RED_PREACTIVE)
|
||||
drawing.style = "no line"
|
||||
elseif self._currentStageState == Stage.CurrentStageState.BLUE then
|
||||
elseif self._currentStageState == StageState.Blue then
|
||||
drawing.fillColorString = DrawingHelper.ColorTableToColorString(Stage.StageColors.BLUE)
|
||||
drawing.colorString = DrawingHelper.ColorTableToColorString(Stage.StageColors.BLUE)
|
||||
drawing.style = "two dash"
|
||||
@@ -488,10 +482,13 @@ function Stage:MarkStage()
|
||||
end
|
||||
|
||||
function Stage:ActivateStage()
|
||||
self._currentStageState = Stage.CurrentStageState.ACTIVE
|
||||
|
||||
if self._currentStageState >= StageState.Activated then
|
||||
return
|
||||
end
|
||||
|
||||
self:PreActivate()
|
||||
|
||||
self._currentStageState = StageState.Activated
|
||||
pcall(function()
|
||||
self:MarkStage()
|
||||
end)
|
||||
@@ -519,6 +516,10 @@ function Stage:ActivateStage()
|
||||
end
|
||||
end
|
||||
|
||||
if self._db and self._db.stageBriefing then
|
||||
self._missionCommandsHelper:AddStageBriefing(self.zoneName, self._db.stageBriefing)
|
||||
end
|
||||
|
||||
timer.scheduleFunction(self.CheckContinuousAsync, self, timer.getTime() + 3)
|
||||
end
|
||||
|
||||
@@ -534,45 +535,57 @@ end
|
||||
---@param stageLaneIdentifier string?
|
||||
function Stage:OnStageNumberChanged(number, stageLaneIdentifier)
|
||||
|
||||
if stageLaneIdentifier ~= self._stageLaneIdentifier then
|
||||
return
|
||||
---@return boolean
|
||||
local needsPreActivation = function()
|
||||
if self._stageLaneIdentifier == stageLaneIdentifier then
|
||||
if self.stageNumber <= number + self._stageConfig.AmountPreactivateStage then
|
||||
return true
|
||||
end
|
||||
elseif self._stageLaneIdentifier == nil then
|
||||
--main lane
|
||||
--Check if this stage is a chapter stage
|
||||
if self._stageRepository:getStageLane(self._stageLaneIdentifier):IsChapterStart(self.stageNumber)
|
||||
and self.stageNumber < number + self._stageConfig.AmountPreactivateStage
|
||||
then
|
||||
return true
|
||||
end
|
||||
|
||||
if GlobalCapManager.IsCapActiveWhenZoneIsActive(self.zoneName, number) == true then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
if self._activeStage == number then --only activate once for a stage
|
||||
return
|
||||
---@return boolean
|
||||
local needsActivation = function()
|
||||
if self._stageLaneIdentifier == stageLaneIdentifier and self.stageNumber == number then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local previousActive = self._activeStage
|
||||
self._activeStage = number
|
||||
---@return boolean
|
||||
local needsBlueActivation = function()
|
||||
if self._stageLaneIdentifier == stageLaneIdentifier and self.stageNumber < number then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
if self.stageNumber - self._activeStage == self._stageConfig.AmountPreactivateStage then
|
||||
self._logger:debug("Pre-activating stage: " .. self.zoneName .. " with number: " .. number)
|
||||
self:PreActivate()
|
||||
elseif GlobalCapManager.IsCapActiveWhenZoneIsActive(self.zoneName, number) == true then
|
||||
if needsPreActivation() == true then
|
||||
self:PreActivate()
|
||||
end
|
||||
|
||||
if number == self.stageNumber then
|
||||
if needsActivation() == true then
|
||||
self:ActivateStage()
|
||||
|
||||
if self._db and self._db.stageBriefing then
|
||||
self._missionCommandsHelper:AddStageBriefing(self.zoneName, self._db.stageBriefing)
|
||||
end
|
||||
end
|
||||
|
||||
if previousActive <= self.stageNumber then
|
||||
if number > self.stageNumber then
|
||||
self:ActivateBlueStage()
|
||||
end
|
||||
if needsBlueActivation() == true then
|
||||
self:ActivateBlueStage()
|
||||
end
|
||||
|
||||
if number > self.stageNumber then
|
||||
self._missionCommandsHelper:RemoveStageBriefing(self.zoneName)
|
||||
end
|
||||
end
|
||||
|
||||
function Stage:GetBriefing()
|
||||
return "Briefing For "
|
||||
end
|
||||
|
||||
---@param self Stage
|
||||
@@ -581,7 +594,6 @@ Stage.OnMissionComplete = function(self, mission)
|
||||
self:CheckAndUpdateSelf()
|
||||
end
|
||||
|
||||
|
||||
---private use only
|
||||
function Stage:ActivateBlueGroups()
|
||||
|
||||
@@ -643,8 +655,12 @@ end
|
||||
|
||||
function Stage:ActivateBlueStage()
|
||||
|
||||
if self._currentStageState >= StageState.Blue then
|
||||
return
|
||||
end
|
||||
|
||||
self._logger:debug("Setting stage '" .. Util.toString(self.zoneName) .. "' to blue")
|
||||
self._currentStageState = Stage.CurrentStageState.BLUE
|
||||
self._currentStageState = StageState.Blue
|
||||
for _, mission in pairs(self._db.missions) do
|
||||
mission:SpawnPersistedState()
|
||||
end
|
||||
@@ -668,6 +684,8 @@ function Stage:ActivateBlueStage()
|
||||
return nil
|
||||
end
|
||||
|
||||
self._missionCommandsHelper:RemoveStageBriefing(self.zoneName)
|
||||
|
||||
timer.scheduleFunction(ActivateBlueAsync, self, timer.getTime() + 3)
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
--- StageState enumeration for the current stage state.
|
||||
--- Chronological order, meaning that higher values should represent later stages in the sequence.
|
||||
---@enum CurrentStageState
|
||||
local StageState = {
|
||||
Inactive = 0,
|
||||
PreActivated = 1,
|
||||
Activated = 2,
|
||||
Blue = 3
|
||||
}
|
||||
|
||||
return StageState
|
||||
@@ -6,7 +6,7 @@ local drawingLogger = Logger.new("CustomDrawing")
|
||||
|
||||
|
||||
---@class CustomDrawing
|
||||
---@field protected _id integer?
|
||||
---@field protected _IDs Array<integer>?
|
||||
---@field protected _name string?
|
||||
---@field protected _drawingObject DrawingObject
|
||||
local CustomDrawing = {}
|
||||
@@ -18,7 +18,7 @@ CustomDrawing.__index = CustomDrawing
|
||||
function CustomDrawing.New(drawingObject)
|
||||
local self = setmetatable({}, CustomDrawing)
|
||||
self._drawingObject = drawingObject
|
||||
self._id = nil -- initiate ID as nil, when drawn it will be set to the ID returned by DrawingHelper.Draw
|
||||
self._IDs = {} -- initiate IDs as an empty array, when drawn it will be set to the IDs returned by DrawingHelper.Draw
|
||||
self._name = drawingObject.name
|
||||
return self
|
||||
end
|
||||
@@ -110,20 +110,24 @@ function CustomDrawing:GetName()
|
||||
end
|
||||
|
||||
function CustomDrawing:Draw()
|
||||
drawingLogger:debug("Drawing custom drawing with ID " .. tostring(self._id))
|
||||
drawingLogger:debug("Drawing custom drawing with IDs " .. table.concat(self._IDs, ", "))
|
||||
|
||||
if self._id ~= nil then
|
||||
DrawingHelper.Remove(self._id)
|
||||
if self._IDs ~= nil then
|
||||
for _, id in ipairs(self._IDs) do
|
||||
DrawingHelper.Remove(id)
|
||||
end
|
||||
end
|
||||
|
||||
self._id = DrawingHelper.Draw(self._drawingObject)
|
||||
self._IDs = DrawingHelper.Draw(self._drawingObject)
|
||||
end
|
||||
|
||||
function CustomDrawing:Remove()
|
||||
if self._id ~= nil then
|
||||
drawingLogger:debug("Removing custom drawing with ID " .. tostring(self._id))
|
||||
DrawingHelper.Remove(self._id)
|
||||
self._id = nil
|
||||
if self._IDs ~= nil then
|
||||
for _, id in ipairs(self._IDs) do
|
||||
drawingLogger:debug("Removing custom drawing with ID " .. tostring(id))
|
||||
DrawingHelper.Remove(id)
|
||||
end
|
||||
self._IDs = {}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,57 +1,45 @@
|
||||
local Util = require("classes.util.Util")
|
||||
local DcsUtil = require("classes.util.DcsUtil")
|
||||
local Logger = require("classes.util.Logger")
|
||||
local GlobalConfig = require("classes.configuration.GlobalConfig")
|
||||
|
||||
---@type LogLevel
|
||||
local level = "INFO"
|
||||
if GlobalConfig:isDebugEnabled() then
|
||||
if GlobalConfig.New():isDebugEnabled() then
|
||||
level = "DEBUG"
|
||||
end
|
||||
|
||||
local drawingLogger = Logger.new("DrawingHelper", level)
|
||||
local logger = Logger.new("DrawingHelper", level)
|
||||
|
||||
---@class DrawingHelper
|
||||
local DrawingHelper = {}
|
||||
DrawingHelper.__index = DrawingHelper
|
||||
|
||||
|
||||
local customDrawingIdIncrementer = 4210
|
||||
|
||||
---@param object DrawingObject
|
||||
---@param logger Logger?
|
||||
---@return integer? id
|
||||
function DrawingHelper.Draw(object, logger)
|
||||
---@return Array<integer> id
|
||||
function DrawingHelper.Draw(object)
|
||||
if object == nil then
|
||||
if logger then
|
||||
logger:warn("DrawingHelper.Draw called with nil object")
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local id = DrawingHelper.GetAndAddId()
|
||||
|
||||
if logger then
|
||||
logger:debug("Drawing object with ID " .. tostring(id) .. " and primitive type: " .. tostring(object.primitiveType))
|
||||
return {}
|
||||
end
|
||||
|
||||
if(object.primitiveType == "Polygon") then
|
||||
DrawingHelper.DrawPolygon(object--[[@as Polygon]], id, logger)
|
||||
return DrawingHelper.DrawPolygon(object--[[@as Polygon]])
|
||||
elseif(object.primitiveType == "Line") then
|
||||
DrawingHelper.DrawLine(object--[[@as Line]], id, logger)
|
||||
return DrawingHelper.DrawLine(object--[[@as Line]])
|
||||
elseif(object.primitiveType == "TextBox") then
|
||||
DrawingHelper.DrawTextBox(object--[[@as TextBox]], id)
|
||||
return DrawingHelper.DrawTextBox(object--[[@as TextBox]])
|
||||
else
|
||||
if logger then
|
||||
logger:warn("Unknown primitive type: " .. tostring(object.primitiveType))
|
||||
end
|
||||
logger:warn("Unknown primitive type: " .. tostring(object.primitiveType))
|
||||
end
|
||||
|
||||
return id
|
||||
return {}
|
||||
end
|
||||
|
||||
function DrawingHelper.GetAndAddId()
|
||||
customDrawingIdIncrementer = customDrawingIdIncrementer + 1
|
||||
return customDrawingIdIncrementer
|
||||
return DcsUtil.GetNextDrawID()
|
||||
end
|
||||
|
||||
---@private
|
||||
@@ -62,8 +50,7 @@ end
|
||||
---@param lineColor table
|
||||
---@param lineStyle LineType
|
||||
---@param lineThickness number
|
||||
---@param logger Logger?
|
||||
local function MarkupToAll(shapeID, drawID, points, fillColor, lineColor, lineStyle, lineThickness, logger)
|
||||
local function MarkupToAll(shapeID, drawID, points, fillColor, lineColor, lineStyle, lineThickness)
|
||||
|
||||
if lineThickness == nil or lineThickness <= 0 then
|
||||
lineStyle = 0
|
||||
@@ -76,23 +63,19 @@ local function MarkupToAll(shapeID, drawID, points, fillColor, lineColor, lineS
|
||||
end
|
||||
functionString = functionString .. "{0,1,0,1}, {0,1,0,1}, " .. lineStyle .. ")"
|
||||
|
||||
if logger then
|
||||
logger:debug("Drawing complex drawing with ID " .. tostring(drawID) .. " and function string: " .. functionString)
|
||||
end
|
||||
logger:debug("Drawing complex drawing with ID " .. tostring(drawID) .. " and function string: " .. functionString)
|
||||
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
local f, err = loadstring(functionString)
|
||||
if f then
|
||||
f()
|
||||
else
|
||||
env.error("Something failed when drawing complex drawing" .. err)
|
||||
logger:error("Something failed when drawing complex drawing" .. err)
|
||||
end
|
||||
|
||||
if logger then
|
||||
logger:debug("Drawing with fill color: " .. table.concat(fillColor, ",") .. " and line color: " .. table.concat(lineColor, ",") .. " and line style: " .. tostring(lineStyle) .. " and line thickness: " .. tostring(lineThickness))
|
||||
if fillColor then
|
||||
trigger.action.setMarkupColorFill(drawID, fillColor)
|
||||
end
|
||||
|
||||
trigger.action.setMarkupColorFill(drawID, fillColor)
|
||||
trigger.action.setMarkupColor(drawID, lineColor)
|
||||
trigger.action.setMarkupTypeLine(drawID, lineStyle)
|
||||
|
||||
@@ -100,13 +83,14 @@ end
|
||||
|
||||
---@private
|
||||
---@param object Polygon
|
||||
---@param id integer
|
||||
---@param logger Logger?
|
||||
function DrawingHelper.DrawPolygon(object, id, logger)
|
||||
---@return Array<integer>
|
||||
function DrawingHelper.DrawPolygon(object)
|
||||
if object == nil then
|
||||
return
|
||||
return {}
|
||||
end
|
||||
|
||||
local id = DrawingHelper.GetAndAddId()
|
||||
|
||||
---@param circle Circle
|
||||
local function DrawCircle(circle)
|
||||
local vec3 = { x = circle.mapX, y = 0, z = circle.mapY }
|
||||
@@ -117,8 +101,8 @@ function DrawingHelper.DrawPolygon(object, id, logger)
|
||||
end
|
||||
|
||||
---@param oval Oval
|
||||
---@param logger Logger?
|
||||
local function DrawOval(oval, logger)
|
||||
---@return integer?, Array<CustomDrawing>?
|
||||
local function DrawOval(oval)
|
||||
---@type Array<Vec3>
|
||||
local points = {}
|
||||
local pointsNo = 30
|
||||
@@ -134,12 +118,11 @@ function DrawingHelper.DrawPolygon(object, id, logger)
|
||||
local y = oval.mapY + (oval.r2 * math.sin(angle))
|
||||
table.insert(points, { x = x, y = 0, z = y } )
|
||||
end
|
||||
MarkupToAll(7, id, points, fillColor, color, lineStyle, oval.thickness, logger)
|
||||
MarkupToAll(7, id, points, fillColor, color, lineStyle, oval.thickness)
|
||||
end
|
||||
|
||||
---@param free Free
|
||||
---@param logger Logger?
|
||||
local function DrawFree(free, logger)
|
||||
local function DrawFree(free)
|
||||
local fillColor = DrawingHelper.ColorToColorTable(free.fillColorString)
|
||||
local color = DrawingHelper.ColorToColorTable(free.colorString)
|
||||
local lineStyle = DrawingHelper.ToLineStyleInteger(free.style)
|
||||
@@ -163,7 +146,7 @@ function DrawingHelper.DrawPolygon(object, id, logger)
|
||||
end
|
||||
end
|
||||
|
||||
MarkupToAll(7, id, points, fillColor, color, lineStyle, free.thickness, logger)
|
||||
MarkupToAll(7, id, points, fillColor, color, lineStyle, free.thickness)
|
||||
end
|
||||
|
||||
---@param rect Rect
|
||||
@@ -175,19 +158,16 @@ function DrawingHelper.DrawPolygon(object, id, logger)
|
||||
local pointA = { x = rect.mapX, y = 0, z = rect.mapY }
|
||||
local pointB = { x = rect.mapX + rect.width, y = 0, z = rect.mapY + rect.height }
|
||||
trigger.action.rectToAll(-1, id, pointA, pointB, color, fillColor, lineStyle, true)
|
||||
|
||||
end
|
||||
|
||||
---@param arrow Arrow
|
||||
---@param logger Logger?
|
||||
local function DrawArrow(arrow, logger)
|
||||
local function DrawArrow(arrow)
|
||||
local fillColor = DrawingHelper.ColorToColorTable(arrow.fillColorString)
|
||||
local color = DrawingHelper.ColorToColorTable(arrow.colorString)
|
||||
local lineStyle = DrawingHelper.ToLineStyleInteger(arrow.style)
|
||||
|
||||
if logger then
|
||||
logger:debug("Drawing arrow with start point: " .. tostring(arrow.mapX) .. ", " .. tostring(arrow.mapY) .. " and angle: " .. tostring(arrow.angle) .. " and length: " .. tostring(arrow.length))
|
||||
end
|
||||
logger:debug("Drawing arrow with start point: " .. tostring(arrow.mapX) .. ", " .. tostring(arrow.mapY) .. " and angle: " .. tostring(arrow.angle) .. " and length: " .. tostring(arrow.length))
|
||||
|
||||
|
||||
local endPoint = { x = arrow.mapX, y = 0, z = arrow.mapY }
|
||||
local rad = math.rad(arrow.angle or 0)
|
||||
@@ -203,44 +183,56 @@ function DrawingHelper.DrawPolygon(object, id, logger)
|
||||
if object.polygonMode == "circle" then
|
||||
DrawCircle(object--[[@as Circle]])
|
||||
elseif object.polygonMode == "oval" then
|
||||
DrawOval(object--[[@as Oval]], logger)
|
||||
DrawOval(object--[[@as Oval]])
|
||||
elseif object.polygonMode == "free" then
|
||||
DrawFree(object--[[@as Free]], logger)
|
||||
DrawFree(object--[[@as Free]])
|
||||
elseif object.polygonMode == "rect" then
|
||||
DrawRect(object--[[@as Rect]])
|
||||
elseif object.polygonMode == "arrow" then
|
||||
DrawArrow(object--[[@as Arrow]], logger)
|
||||
DrawArrow(object--[[@as Arrow]])
|
||||
end
|
||||
return {id}
|
||||
end
|
||||
|
||||
---@private
|
||||
---@param object Line
|
||||
---@param id integer
|
||||
---@param logger Logger?
|
||||
function DrawingHelper.DrawLine(object, id, logger)
|
||||
---@return Array<integer>
|
||||
function DrawingHelper.DrawLine(object)
|
||||
|
||||
---@type Array<Vec3>
|
||||
local points = {}
|
||||
local ids = {}
|
||||
|
||||
for _, point in ipairs(object.points) do
|
||||
table.insert(points, { x = point.x, y = 0, z = point.y } )
|
||||
table.insert(points, { x = object.mapX + point.x, y = 0, z = object.mapY + point.y } )
|
||||
end
|
||||
|
||||
local color = DrawingHelper.ColorToColorTable(object.colorString)
|
||||
local lineStyle = DrawingHelper.ToLineStyleInteger(object.style)
|
||||
MarkupToAll(1, id, points, color, color, lineStyle, object.thickness, logger)
|
||||
|
||||
for i = 1, #points - 1 do
|
||||
local id = DrawingHelper.GetAndAddId()
|
||||
trigger.action.lineToAll(-1, id, points[i], points[i + 1], color, lineStyle, true)
|
||||
table.insert(ids, id)
|
||||
end
|
||||
return ids
|
||||
end
|
||||
|
||||
---@private
|
||||
---@param object TextBox
|
||||
---@param id integer
|
||||
function DrawingHelper.DrawTextBox(object, id)
|
||||
---@return Array<integer>
|
||||
function DrawingHelper.DrawTextBox(object)
|
||||
|
||||
local id = DrawingHelper.GetAndAddId()
|
||||
|
||||
trigger.action.textToAll(-1, id, { x= object.mapX, y = 0, z = object.mapY },
|
||||
DrawingHelper.ColorToColorTable(object.colorString),
|
||||
DrawingHelper.ColorToColorTable(object.fillColorString),
|
||||
object.fontSize or 12,
|
||||
true,
|
||||
object.text or "")
|
||||
|
||||
return {id}
|
||||
end
|
||||
|
||||
function DrawingHelper.Remove(id)
|
||||
@@ -252,7 +244,7 @@ end
|
||||
function DrawingHelper.ColorToColorTable(hexStr)
|
||||
|
||||
if hexStr == nil then
|
||||
drawingLogger:warn("ColorToColorTable called with nil hexStr, returning default color {0, 0, 0, 0}")
|
||||
logger:warn("ColorToColorTable called with nil hexStr, returning default color {0, 0, 0, 0}")
|
||||
return { 0, 0, 0, 0 }
|
||||
end
|
||||
|
||||
@@ -270,7 +262,7 @@ end
|
||||
---@return string
|
||||
function DrawingHelper.ColorTableToColorString(rgba)
|
||||
if rgba == nil or #rgba < 4 or rgba[1] == nil or rgba[2] == nil or rgba[3] == nil or rgba[4] == nil then
|
||||
drawingLogger:warn("ColorTableToColorString called with invalid rgba table, returning default color string '0x00000000'")
|
||||
logger:warn("ColorTableToColorString called with invalid rgba table, returning default color string '0x00000000'")
|
||||
return "0x00000000"
|
||||
end
|
||||
|
||||
@@ -293,11 +285,11 @@ function DrawingHelper.ToLineStyleInteger(lineStyle)
|
||||
return 2
|
||||
elseif lineStyle == "dotted" then
|
||||
return 3
|
||||
elseif lineStyle == "dot dash" then
|
||||
elseif lineStyle == "dotdash" then
|
||||
return 4
|
||||
elseif lineStyle == "long dash" then
|
||||
elseif lineStyle == "longdash" then
|
||||
return 5
|
||||
elseif lineStyle == "two dash" then
|
||||
elseif lineStyle == "twodash" then
|
||||
return 6
|
||||
else
|
||||
return 0
|
||||
@@ -314,11 +306,11 @@ function DrawingHelper.ToLineStyleString(lineStyle)
|
||||
elseif lineStyle == 3 then
|
||||
return "dotted"
|
||||
elseif lineStyle == 4 then
|
||||
return "dot dash"
|
||||
return "dotdash"
|
||||
elseif lineStyle == 5 then
|
||||
return "long dash"
|
||||
return "longdash"
|
||||
elseif lineStyle == 6 then
|
||||
return "two dash"
|
||||
return "twodash"
|
||||
else
|
||||
return "no line"
|
||||
end
|
||||
|
||||
@@ -21,9 +21,18 @@ local DrawingHelper = require("classes.stageClasses.drawings.helper.DrawingHelpe
|
||||
---@field private _dropOffZone SpearheadTriggerZone?
|
||||
---@field private _noLandingZoneDrawing CustomDrawing?
|
||||
---@field private _dropOffZoneDrawing CustomDrawing?
|
||||
---@field private _briefing string?
|
||||
local BuildableMission = {}
|
||||
BuildableMission.__index = BuildableMission
|
||||
|
||||
|
||||
local function getDefaultBriefing(siteType, coords)
|
||||
return "We've dispatched forward units to find a proper spot for a new " .. siteType .. "." ..
|
||||
"\nYou will need to drop off supplies so they can start building." ..
|
||||
"\nThe coords are: " .. coords ..
|
||||
"\n\n"
|
||||
end
|
||||
|
||||
---@class OnCrateDroppedListener
|
||||
---@field OnCrateDroppedOff fun(self:OnCrateDroppedListener, mission:BuildableMission, kilos:number)
|
||||
|
||||
@@ -33,7 +42,8 @@ BuildableMission.__index = BuildableMission
|
||||
---@param requiredCrateType SupplyType
|
||||
---@param noLandingZone SpearheadTriggerZone?
|
||||
---@param logger Logger
|
||||
function BuildableMission.new(database, logger, targetZone, noLandingZone, requiredKilos, requiredCrateType)
|
||||
---@param briefing string?
|
||||
function BuildableMission.new(database, logger, targetZone, noLandingZone, requiredKilos, requiredCrateType, briefing)
|
||||
|
||||
setmetatable(BuildableMission, Mission)
|
||||
|
||||
@@ -43,6 +53,7 @@ function BuildableMission.new(database, logger, targetZone, noLandingZone, requi
|
||||
self._database = database
|
||||
self._requiredKilos = requiredKilos
|
||||
self._droppedKilos = 0
|
||||
self._briefing = briefing
|
||||
|
||||
self._noLandingZone = noLandingZone
|
||||
|
||||
@@ -64,7 +75,13 @@ function BuildableMission.new(database, logger, targetZone, noLandingZone, requi
|
||||
end
|
||||
|
||||
self.code = tostring(database:GetNewMissionCode())
|
||||
self.name = "Resupply"
|
||||
|
||||
local splitTargetZoneName = Util.split_string(targetZone.name, "_")
|
||||
if splitTargetZoneName and splitTargetZoneName[3] and splitTargetZoneName[3] ~= "" then
|
||||
self.name = splitTargetZoneName[3]
|
||||
else
|
||||
self.name = "Resupply"
|
||||
end
|
||||
|
||||
local type = "site"
|
||||
if requiredCrateType == "SAM_CRATE" then
|
||||
@@ -81,7 +98,6 @@ function BuildableMission.new(database, logger, targetZone, noLandingZone, requi
|
||||
self._supplyUnitsTracker = SupplyUnitsTracker.getOrCreate()
|
||||
self._state = "NEW"
|
||||
|
||||
|
||||
self.location = targetZone.location
|
||||
|
||||
self.missionType = "LOGISTICS"
|
||||
@@ -116,11 +132,16 @@ function BuildableMission:ShowBriefing(groupID)
|
||||
siteType = "airbase"
|
||||
end
|
||||
|
||||
local briefingPart = self._briefing
|
||||
if briefingPart then
|
||||
briefingPart = Util.replaceString(briefingPart, "{{coords}}", coords)
|
||||
else
|
||||
briefingPart = getDefaultBriefing(siteType, coords)
|
||||
end
|
||||
|
||||
local briefing = "Mission [" .. self.code .. "] " .. self.name ..
|
||||
"\n \n" ..
|
||||
"We've dispatched forward units to find a proper spot for a new " .. siteType .. "." ..
|
||||
"\nYou will need to drop off supplies so they can start building." ..
|
||||
"\nThe coords are: " .. coords ..
|
||||
briefingPart ..
|
||||
"\n\n" ..
|
||||
"\nKilos still required: " .. self._requiredKilos - self._droppedKilos ..
|
||||
"\n\n" ..
|
||||
|
||||
@@ -18,7 +18,7 @@ local RunwayStrikeMission = {}
|
||||
---@field corners Array<Vec2>
|
||||
---@field kilosHit number
|
||||
---@field repairGroups Array<string>
|
||||
---@field drawID number?
|
||||
---@field drawID Array<number>
|
||||
|
||||
|
||||
---@param runway Runway
|
||||
@@ -172,8 +172,10 @@ function RunwayStrikeMission:Draw()
|
||||
|
||||
runwaySection.drawID = DrawingHelper.Draw(drawObject)
|
||||
else
|
||||
DcsUtil.SetFillColor(runwaySection.drawID, fillColor)
|
||||
DcsUtil.SetLineColor(runwaySection.drawID, lineColor)
|
||||
for _, drawID in pairs(runwaySection.drawID) do
|
||||
DcsUtil.SetFillColor(drawID, fillColor)
|
||||
DcsUtil.SetLineColor(drawID, lineColor)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -497,6 +499,7 @@ function RunwayStrikeMission:ToSections(runway, numSections)
|
||||
corners = corners,
|
||||
kilosHit = 0,
|
||||
repairGroups = {},
|
||||
drawID = {},
|
||||
}
|
||||
|
||||
table.insert(sections, section)
|
||||
|
||||
@@ -632,13 +632,19 @@ do -- INIT DCS_UTIL
|
||||
---@field b number
|
||||
---@field a number
|
||||
|
||||
local drawID = 4210
|
||||
|
||||
function DCS_UTIL.GetNextDrawID()
|
||||
drawID = drawID + 1
|
||||
return drawID
|
||||
end
|
||||
|
||||
---@param groupID number
|
||||
---@param text string
|
||||
---@param location Vec3
|
||||
---@return number markID
|
||||
function DCS_UTIL.AddMarkToGroup(groupID, text, location)
|
||||
drawID = drawID + 1
|
||||
local drawID = DCS_UTIL.GetNextDrawID()
|
||||
trigger.action.markToGroup(drawID, text, location, groupID, true, nil)
|
||||
return drawID
|
||||
end
|
||||
@@ -648,7 +654,7 @@ do -- INIT DCS_UTIL
|
||||
---@param location Vec3
|
||||
---@return integer
|
||||
function DCS_UTIL.AddMarkToAll(text, location)
|
||||
drawID = drawID + 1
|
||||
local drawID = DCS_UTIL.GetNextDrawID()
|
||||
trigger.action.markToAll(drawID, text, location, true, nil)
|
||||
return drawID
|
||||
end
|
||||
@@ -677,6 +683,10 @@ do -- INIT DCS_UTIL
|
||||
---@param drawID number
|
||||
---@param fillColor DrawColor
|
||||
function DCS_UTIL.SetFillColor(drawID, fillColor)
|
||||
if fillColor == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local lineColorMapped = {
|
||||
fillColor.r or 0,
|
||||
fillColor.g or 0,
|
||||
|
||||
Reference in New Issue
Block a user