Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ac866d64a0 | |||
| 5620347ffe | |||
| 4a3500fdc0 | |||
| dedb0213c7 | |||
| ad96018c0a | |||
| efb2f20e58 | |||
| 29b047abaf | |||
| 814f8c7e83 | |||
| f28e68db62 | |||
| 63972995a1 | |||
| 5ad6ea8ad9 | |||
| 657d8f16c6 | |||
| e7c00267b1 | |||
| 5f07027faa | |||
| 4761ae7d70 | |||
| afe320786d | |||
| 733dc07863 | |||
| 5860c5009f | |||
| cd3c4ed76d | |||
| 31d967b036 | |||
| 1a693763fd | |||
| 557346548a | |||
| 38e515dea9 | |||
| 57a5426e65 | |||
| ccc3e20902 |
@@ -1,7 +1,7 @@
|
||||
# На каждый пуш: только мод (.hmod, один для всех ОС) и релиз build-<номер> с ним.
|
||||
# Раннер живёт на одной машине с Gitea и другими сервисами (2 ядра, 4 ГБ): сборка мода лёгкая —
|
||||
# один поток компиляции, низший приоритет, без системных пакетов и без кэша target.
|
||||
# Игра-форк собирается отдельно и только вручную: game.yml (Linux) и desktop.yml (macOS/Windows).
|
||||
# Игра-форк здесь не собирается: только по тегу версии (release.yml, Windows) и вручную (game.yml Linux, desktop.yml macOS).
|
||||
name: build
|
||||
|
||||
on:
|
||||
@@ -20,6 +20,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Rust
|
||||
run: |
|
||||
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --target wasm32-unknown-unknown
|
||||
@@ -28,8 +30,18 @@ jobs:
|
||||
# падало по таймауту, а сохранение вешало «Complete job» на пару минут. Инструмент собирается заново.
|
||||
- name: Форк Horizon
|
||||
run: nice -n 19 python3 tools/airdef.py fork
|
||||
# Чистая симуляция тестируется нативно (хост-таргет раннера, без WASM): регрессии из sim/regress.rs
|
||||
# и сценарии tests/scenarios.rs (NaN, налёт кончается, ТЗМ не зависают). Нужен форк: SDK подключён путём.
|
||||
- name: Проверка закреплённого checkout
|
||||
run: python3 -m unittest discover -s tools -p test_engine_checkout.py
|
||||
- name: Проверка generated assets
|
||||
run: |
|
||||
python3 -m pip install --user -r tools/requirements.txt
|
||||
python3 tools/gen_models.py --check
|
||||
python3 -m unittest discover -s tools -p test_model_bounds.py
|
||||
- name: Тесты ядра без SDK
|
||||
working-directory: airdef-core
|
||||
run: |
|
||||
HOST=$(rustc -vV | sed -n 's/^host: //p')
|
||||
nice -n 19 cargo test --target "$HOST"
|
||||
- name: Тесты мода
|
||||
working-directory: airdef-mod
|
||||
run: |
|
||||
@@ -46,8 +58,10 @@ jobs:
|
||||
SHA: ${{ github.sha }}
|
||||
run: |
|
||||
set -e
|
||||
mkdir -p out && cp airdef-mod/target/horizon-mod/airdef.hmod out/airdef.hmod
|
||||
BODY=$(printf 'Сборка %s (%s).\n\n- airdef.hmod — мод, для всех ОС.\n\nИгра-форк Horizon (нужна для мода): собрать у себя — python3 tools/airdef.py all, или запустить вручную workflow game (Linux) / desktop (macOS, Windows) с этим тегом.\nКак запускать: docs/INSTALL.md.' "$TAG" "$SHA")
|
||||
mkdir -p out
|
||||
cp airdef-mod/target/horizon-mod/airdef.hmod out/airdef.hmod
|
||||
cp airdef-mod/target/horizon-mod/build-identity.json out/build-identity.json
|
||||
BODY=$(printf 'Сборка %s (%s).\n\n- airdef.hmod — мод, для всех ОС.\n\nИгра-форк Horizon (нужна для мода): собрать у себя — python3 tools/airdef.py all, или скачать из большого релиза v* (Windows), или запустить вручную workflow game (Linux) / desktop (macOS) с этим тегом.\nКак запускать: docs/INSTALL.md.' "$TAG" "$SHA")
|
||||
DATA=$(BODY="$BODY" python3 -c 'import json,os;print(json.dumps({"tag_name":os.environ["TAG"],"target_commitish":os.environ["SHA"],"name":os.environ["TAG"],"body":os.environ["BODY"]}))')
|
||||
if [ -z "$TOKEN" ]; then echo "::error::нет токена: добавь секрет RELEASE_TOKEN"; exit 1; fi
|
||||
CODE=$(curl -sS -o release.json -w '%{http_code}' -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" "$API/releases" -d "$DATA")
|
||||
@@ -57,3 +71,4 @@ jobs:
|
||||
fi
|
||||
ID=$(python3 -c 'import json;print(json.load(open("release.json"))["id"])')
|
||||
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@out/airdef.hmod" "$API/releases/$ID/assets?name=airdef.hmod" > /dev/null
|
||||
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@out/build-identity.json" "$API/releases/$ID/assets?name=build-identity.json" > /dev/null
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Сборки игры-форка для macOS и Windows: запускаются вручную (Actions → desktop → Run workflow)
|
||||
# с тегом готового релиза (build-N) и дописывают свои архивы в него. Нужны раннеры с метками
|
||||
# macos-latest / windows-latest (например, act_runner в режиме host на своём Маке или ПК).
|
||||
# Сборка игры-форка для macOS: запускается вручную (Actions → desktop → Run workflow) с тегом готового
|
||||
# релиза (build-N) и дописывает свой архив в него. Нужен раннер с меткой macos-latest (например, act_runner
|
||||
# в режиме host на своём Маке). Windows собирается на сервере по тегу версии: release.yml.
|
||||
name: desktop
|
||||
|
||||
on:
|
||||
@@ -9,17 +9,12 @@ on:
|
||||
tag:
|
||||
description: Тег релиза, например build-3
|
||||
required: true
|
||||
os:
|
||||
description: macos, windows или both
|
||||
required: true
|
||||
default: both
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: never
|
||||
|
||||
jobs:
|
||||
game-macos:
|
||||
if: inputs.os == 'macos' || inputs.os == 'both'
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Проверка релиза
|
||||
@@ -46,6 +41,7 @@ jobs:
|
||||
PY
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: refs/tags/${{ inputs.tag }}
|
||||
- name: Проверка коммита
|
||||
env:
|
||||
@@ -74,6 +70,10 @@ jobs:
|
||||
D=airdef-macos-arm64
|
||||
mkdir -p "$D"
|
||||
cp horizon/target/fast/horizon-client horizon/target/fast/horizon-ctl out/airdef.hmod dist/play.sh docs/INSTALL.md "$D/"
|
||||
cp airdef-mod/target/horizon-mod/build-identity.json "$D/"
|
||||
cp -R docs/licenses "$D/"
|
||||
cp horizon/THIRD_PARTY_NOTICES.md "$D/licenses/HORIZON-THIRD-PARTY-NOTICES.md"
|
||||
cp horizon/crates/horizon-client/src/acoustics/THIRD_PARTY_SPR.md "$D/licenses/THIRD_PARTY_SPR.md"
|
||||
tar czf "out/$D.tar.gz" "$D"
|
||||
- name: В релиз
|
||||
env:
|
||||
@@ -83,70 +83,3 @@ jobs:
|
||||
set -e
|
||||
# RELEASE_ID взят в шаге «Проверка релиза» (релиз build-N, созданный build.yml)
|
||||
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@out/airdef-macos-arm64.tar.gz" "$API/releases/$RELEASE_ID/assets?name=airdef-macos-arm64.tar.gz" > /dev/null
|
||||
|
||||
game-windows:
|
||||
if: inputs.os == 'windows' || inputs.os == 'both'
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: pwsh
|
||||
steps:
|
||||
- name: Проверка релиза
|
||||
env:
|
||||
TOKEN: ${{ secrets.RELEASE_TOKEN || gitea.token }}
|
||||
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||
TAG: ${{ inputs.tag }}
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if ($env:TAG -notmatch '^build-\d+$') { Write-Output "::error::тег '$env:TAG' не похож на build-N"; exit 1 }
|
||||
$h = @{ Authorization = "token $env:TOKEN" }
|
||||
try { $r = Invoke-RestMethod -Headers $h "$env:API/releases/tags/$env:TAG" }
|
||||
catch { Write-Output "::error::релиза с тегом $env:TAG нет: сначала дождись сборки build.yml на main"; exit 1 }
|
||||
$assets = @($r.assets | ForEach-Object { $_.name })
|
||||
if ($r.tag_name -ne $env:TAG -or $r.name -ne $env:TAG -or ($assets -notcontains 'airdef.hmod')) {
|
||||
Write-Output "::error::релиз $env:TAG не создан build.yml (нужны имя = тег и вложение airdef.hmod): чужой релиз не трогаем"; exit 1
|
||||
}
|
||||
"RELEASE_ID=$($r.id)" | Out-File -Append -Encoding utf8 $env:GITHUB_ENV
|
||||
"RELEASE_SHA=$($r.target_commitish)" | Out-File -Append -Encoding utf8 $env:GITHUB_ENV
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: refs/tags/${{ inputs.tag }}
|
||||
- name: Проверка коммита
|
||||
env:
|
||||
TAG: ${{ inputs.tag }}
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$head = git rev-parse HEAD
|
||||
if ($env:RELEASE_SHA -match '^[0-9a-f]{40}$' -and $head -ne $env:RELEASE_SHA) { Write-Output "::error::тег $env:TAG указывает на $head, а релиз создан из $env:RELEASE_SHA"; exit 1 }
|
||||
Write-Output "собираю $env:TAG = $head"
|
||||
- name: Rust
|
||||
run: |
|
||||
if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
|
||||
Invoke-WebRequest https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
|
||||
.\rustup-init.exe -y --profile minimal
|
||||
}
|
||||
"$env:USERPROFILE\.cargo\bin" | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
|
||||
- name: Форк Horizon
|
||||
run: python tools/airdef.py fork
|
||||
- name: Игра
|
||||
run: python tools/airdef.py game
|
||||
- name: Мод
|
||||
run: |
|
||||
rustup target add wasm32-unknown-unknown
|
||||
python tools/airdef.py mod
|
||||
New-Item -ItemType Directory -Force out | Out-Null
|
||||
Copy-Item airdef-mod\target\horizon-mod\airdef.hmod out\
|
||||
- name: Архив
|
||||
run: |
|
||||
$D = "airdef-windows-x86_64"
|
||||
New-Item -ItemType Directory -Force $D | Out-Null
|
||||
Copy-Item horizon\target\fast\horizon-client.exe, horizon\target\fast\horizon-ctl.exe, out\airdef.hmod, dist\play.bat, docs\INSTALL.md $D
|
||||
Compress-Archive -Path $D -DestinationPath "out\$D.zip" -Force
|
||||
- name: В релиз
|
||||
env:
|
||||
TOKEN: ${{ secrets.RELEASE_TOKEN || gitea.token }}
|
||||
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||
run: |
|
||||
# RELEASE_ID взят в шаге «Проверка релиза» (релиз build-N, созданный build.yml)
|
||||
curl.exe -sf -X POST -H "Authorization: token $env:TOKEN" -F "attachment=@out\airdef-windows-x86_64.zip" "$env:API/releases/$env:RELEASE_ID/assets?name=airdef-windows-x86_64.zip"
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ jobs:
|
||||
PY
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: refs/tags/${{ inputs.tag }}
|
||||
- name: Проверка коммита
|
||||
env:
|
||||
@@ -82,6 +83,10 @@ jobs:
|
||||
D=airdef-linux-x86_64
|
||||
mkdir -p "$D" out
|
||||
cp horizon/target/fast/horizon-client horizon/target/fast/horizon-ctl airdef-mod/target/horizon-mod/airdef.hmod dist/play.sh docs/INSTALL.md "$D/"
|
||||
cp airdef-mod/target/horizon-mod/build-identity.json "$D/"
|
||||
cp -R docs/licenses "$D/"
|
||||
cp horizon/THIRD_PARTY_NOTICES.md "$D/licenses/HORIZON-THIRD-PARTY-NOTICES.md"
|
||||
cp horizon/crates/horizon-client/src/acoustics/THIRD_PARTY_SPR.md "$D/licenses/THIRD_PARTY_SPR.md"
|
||||
tar czf "out/$D.tar.gz" "$D"
|
||||
# RELEASE_ID взят в шаге «Проверка релиза» (релиз build-N, созданный build.yml)
|
||||
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@out/$D.tar.gz" "$API/releases/$RELEASE_ID/assets?name=$D.tar.gz" > /dev/null
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
# Большой релиз: только по тегу vX.Y.Z (git tag v0.3.0 && git push origin v0.3.0) или вручную с готовым тегом.
|
||||
# Игра-форк для Windows собирается на Linux-сервере кросс-компиляцией (x86_64-pc-windows-gnu), без Windows-раннера.
|
||||
# Сервер общий (2 ядра, 4 ГБ, Gitea и боты), поэтому контейнер ограничен: при нехватке памяти убивается сборка, а не
|
||||
# сервисы. Замер 2026-10-30: 20,5 минуты, 2 ГБ памяти постоянно в потолке, у сервера не меньше 726 МБ свободно.
|
||||
# Обычные коммиты сюда не попадают: build.yml собирает только мод.
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: Существующий тег, например v0.3.0
|
||||
required: true
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: never
|
||||
CARGO_BUILD_JOBS: "1"
|
||||
CARGO_INCREMENTAL: "0"
|
||||
CARGO_PROFILE_FAST_INCREMENTAL: "false"
|
||||
CARGO_PROFILE_FAST_DEBUG: "false"
|
||||
CARGO_PROFILE_FAST_STRIP: "true"
|
||||
TAG: ${{ inputs.tag || github.ref_name }}
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
options: --memory=2g --memory-swap=4500m --cpus=1.5 --cpu-shares=128 --blkio-weight=100 --oom-score-adj=800
|
||||
steps:
|
||||
- name: Место на диске
|
||||
run: |
|
||||
FREE=$(df --output=avail -BG / | tail -1 | tr -dc 0-9)
|
||||
echo "свободно: ${FREE} ГБ"
|
||||
if [ "$FREE" -lt 12 ]; then echo "::error::на сервере свободно ${FREE} ГБ, нужно хотя бы 12"; exit 1; fi
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: refs/tags/${{ inputs.tag || github.ref_name }}
|
||||
- name: Инструменты
|
||||
run: |
|
||||
SUDO=$(command -v sudo || true)
|
||||
$SUDO apt-get update -qq
|
||||
$SUDO apt-get install -y -qq --no-install-recommends gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 zip
|
||||
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
# Версия Rust берётся из rust-toolchain.toml.
|
||||
- name: Цели Rust
|
||||
run: rustup target add x86_64-pc-windows-gnu wasm32-unknown-unknown
|
||||
- name: Форк Horizon
|
||||
run: nice -n 19 python3 tools/airdef.py fork
|
||||
- name: Мод
|
||||
run: nice -n 19 python3 tools/airdef.py mod
|
||||
- name: Игра для Windows
|
||||
working-directory: horizon
|
||||
run: |
|
||||
# Сторож: сервер важнее сборки. Память контейнера ограничена, это на случай, если её съело что-то ещё.
|
||||
( while sleep 10; do
|
||||
AVAIL=$(awk '/MemAvailable/{print int($2/1024)}' /proc/meminfo)
|
||||
DISK=$(df --output=avail -BG / | tail -1 | tr -dc 0-9)
|
||||
if [ "$AVAIL" -lt 250 ] || [ "$DISK" -lt 6 ]; then
|
||||
echo "::error::сборка остановлена: свободно ${AVAIL} МБ памяти и ${DISK} ГБ диска"
|
||||
pkill -9 cargo; pkill -9 rustc; exit 1
|
||||
fi
|
||||
done ) &
|
||||
WATCH=$!
|
||||
nice -n 19 ionice -c3 cargo build --profile fast -p horizon-client --features mods --target x86_64-pc-windows-gnu
|
||||
kill "$WATCH"
|
||||
- name: Архив
|
||||
run: |
|
||||
set -e
|
||||
D=airdef-windows-x86_64
|
||||
T=horizon/target/x86_64-pc-windows-gnu/fast
|
||||
mkdir -p "$D" out
|
||||
cp "$T/horizon-client.exe" "$T/horizon-ctl.exe" airdef-mod/target/horizon-mod/airdef.hmod dist/play.bat docs/INSTALL.md "$D/"
|
||||
cp airdef-mod/target/horizon-mod/build-identity.json "$D/"
|
||||
cp -R docs/licenses "$D/"
|
||||
cp horizon/THIRD_PARTY_NOTICES.md "$D/licenses/HORIZON-THIRD-PARTY-NOTICES.md"
|
||||
cp horizon/crates/horizon-client/src/acoustics/THIRD_PARTY_SPR.md "$D/licenses/THIRD_PARTY_SPR.md"
|
||||
zip -qr "out/$D.zip" "$D"
|
||||
cp airdef-mod/target/horizon-mod/airdef.hmod out/
|
||||
- name: Релиз
|
||||
env:
|
||||
TOKEN: ${{ secrets.RELEASE_TOKEN || gitea.token }}
|
||||
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||
run: |
|
||||
set -e
|
||||
if [ -z "$TOKEN" ]; then echo "::error::нет токена: добавь секрет RELEASE_TOKEN"; exit 1; fi
|
||||
# Тег с дефисом (v0.3.0-rc1) выходит как предварительный релиз; уже созданный релиз тега дополняется.
|
||||
DATA=$(python3 -c 'import json,os;t=os.environ["TAG"];print(json.dumps({"tag_name":t,"name":t,"prerelease":"-" in t,"body":"Windows: распакуй airdef-windows-x86_64.zip и запусти play.bat. Нужен Minecraft Java 26.3 и лаунчер Horizon, запущенный один раз. Подробнее: docs/INSTALL.md.\n\nmacOS: сборка из исходников, python3 tools/airdef.py all."}))')
|
||||
CODE=$(curl -sS -o release.json -w '%{http_code}' -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG")
|
||||
if [ "$CODE" != "200" ]; then
|
||||
CODE=$(curl -sS -o release.json -w '%{http_code}' -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" "$API/releases" -d "$DATA")
|
||||
if [ "$CODE" != "201" ]; then echo "::error::Gitea не создала релиз (HTTP $CODE): $(cat release.json)"; exit 1; fi
|
||||
fi
|
||||
ID=$(python3 -c 'import json;print(json.load(open("release.json"))["id"])')
|
||||
for F in airdef-windows-x86_64.zip airdef.hmod; do
|
||||
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@out/$F" "$API/releases/$ID/assets?name=$F" > /dev/null
|
||||
done
|
||||
@@ -0,0 +1,20 @@
|
||||
# Heavy sandbox runtime is opt-in on the shared 2-core runner.
|
||||
name: wasm-contract
|
||||
on:
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CARGO_BUILD_JOBS: "1"
|
||||
CARGO_INCREMENTAL: "0"
|
||||
jobs:
|
||||
contract:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Rust
|
||||
run: |
|
||||
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --target wasm32-unknown-unknown
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
- name: Actual WASM contract
|
||||
run: nice -n 19 python3 tools/airdef.py test-wasm
|
||||
@@ -1,7 +1,7 @@
|
||||
/horizon/
|
||||
run-home/
|
||||
.horizon-cache/
|
||||
airdef-mod/target/
|
||||
airdef-core/target/
|
||||
__pycache__/
|
||||
/out/
|
||||
.DS_Store
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "horizon"]
|
||||
path = horizon
|
||||
url = https://gitea.maoniao.team/chexit/horizon-airdef.git
|
||||
@@ -1 +0,0 @@
|
||||
b6c936f82b08798057161bdfa577e3aac53fb91e
|
||||
@@ -3,7 +3,8 @@
|
||||
Мод для Horizon (Minecraft 26.3 на Rust): Шахед-136, Герань-3, Patriot и Гепард с 3D-моделями,
|
||||
наведением ракет, слежением башен, падением сбитых дронов и эффектами взрывов.
|
||||
|
||||
Работает на **своём форке Horizon** (`horizon/`, ветка `airdef`): в нём добавлен API отрисовки
|
||||
Работает на **[своём форке Horizon](https://gitea.maoniao.team/chexit/horizon-airdef)**
|
||||
(`horizon/` — сабмодуль, закреплённый SHA): в нём добавлен API отрисовки
|
||||
3D-моделей, которого нет в основном Horizon.
|
||||
|
||||

|
||||
@@ -16,7 +17,8 @@
|
||||
Коротко, из исходников:
|
||||
|
||||
```bash
|
||||
python3 tools/airdef.py all # скачать Horizon, наложить патчи форка, собрать игру и мод, установить мод
|
||||
git submodule update --init --recursive # также выполняется командой all
|
||||
python3 tools/airdef.py all # получить закреплённый движок, собрать игру и мод, установить мод
|
||||
python3 tools/airdef.py play # запустить (аргументы игры — после: --world "Имя мира")
|
||||
```
|
||||
|
||||
@@ -55,7 +57,8 @@ CI: `.gitea/workflows/build.yml` на каждый пуш собирает то
|
||||
- *умный противник* — планировщик знает, где стоят комплексы и что видят их РЛС: ведёт дроны и крылатые ракеты
|
||||
маршрутами в обход зон поражения, низко, за рельефом и через мёртвые зоны; «Герберы» прилетают на 15 с раньше,
|
||||
чтобы оттянуть ракеты; «Ланцеты» идут по Гепардам и Панцирям, Х-22/Циркон и часть баллистики — по дальнобойным
|
||||
комплексам; всё остальное стартует со сдвигом так, чтобы прилететь одновременно.
|
||||
комплексам; на каждую РЛС дальнего обнаружения идут 2–3 быстрых ударника (Х-22, Циркон, Искандер, Кинжал, затем Х-101,
|
||||
Герань-3, Ланцет, Шахед; не больше четверти налёта); всё остальное стартует со сдвигом так, чтобы прилететь одновременно.
|
||||
|
||||
После налёта приходит отчёт: сколько сбито и прорвалось, ракет ПВО потрачено, комплексов потеряно, урон объектам.
|
||||
|
||||
@@ -72,7 +75,7 @@ CI: `.gitea/workflows/build.yml` на каждый пуш собирает то
|
||||
**Сохранение.** Комплексы, объекты, их повреждения и настройки сохраняются отдельно для каждого мира (и для каждого
|
||||
сервера); уничтоженный комплекс остаётся остовом и после перезахода, пока его не отремонтируют.
|
||||
|
||||
**Сеть ПВО.** Каждая единица делится целями со всеми в радиусе 1,5 км (линия связи): РЛС дальнего обнаружения
|
||||
**Сеть ПВО.** Каждая единица делится целями со всеми в радиусе 2,25 км (линия связи): РЛС дальнего обнаружения
|
||||
даёт раннее предупреждение всем, пусковая без своей РЛС (P1-SUN) стреляет по чужим данным. Пушкам (Гепард,
|
||||
пушки Панциря) нужна своя цель: они стреляют только по тому, что видят сами. Уничтоженная РЛС — дыра в сети.
|
||||
|
||||
@@ -96,7 +99,8 @@ CI: `.gitea/workflows/build.yml` на каждый пуш собирает то
|
||||
перенацеливает ещё не взлетевшие Ланцеты и Шахеды на них; если цель-комплекс уничтожен, дроны идут к
|
||||
следующему известному. Дроны под обстрелом прижимаются к земле.
|
||||
|
||||
**Ночь.** Ночью пушки попадают втрое хуже, если цель не освещена. Освещают **прожекторы** (луч ведёт ближайшую
|
||||
**Ночь.** Исправные пушки с собственным свежим радарным сопровождением не теряют точность из-за темноты.
|
||||
Цели освещают **прожекторы** (луч ведёт ближайшую
|
||||
цель из сети, приоритет — цели пушек) и **осветительные ракеты**: пушечные комплексы пускают их сами (раз в
|
||||
25 с на цель в темноте), игрок — **осветительным пистолетом** или `/airdef flare`. Ракета висит ~30 с и
|
||||
освещает всё вокруг на ~60–90 м.
|
||||
@@ -149,13 +153,17 @@ API мода `render.set-lights` (до 512, плавно интерполиру
|
||||
Клавиши N, K, J, R и U можно переназначить в «Настройки → Моды».
|
||||
|
||||
Команды:
|
||||
- `/airdef wave <тип> [кол-во] [дальность]` — налёт на ближайшую цель. Типы: `shahed`, `geran3`, `lancet`, `gerbera`, `kh101`, `kalibr`, `kh22`, `zircon`, `iskander`, `kinzhal`, `oreshnik` и `mix` (комбинированный удар двумя секторами: «Герберы», шахеды, Герани-3, Х-101, «Калибры», Х-22, Циркон, «Искандер», «Кинжал», при 30+ — «Орешник»);
|
||||
- `/airdef wave <тип> [кол-во] [дальность]` — налёт на ближайшую цель. Дальность старта — от 60 до 4000 блоков (в меню: 200–4000); землю для площадок, которой нет в загруженных чанках, игра подгружает сама (API 22, `render.load-chunks`, пока идёт поиск), а где подгрузить нельзя (сервер) или нет пригодного места, дроны всё равно стартуют: «за картой», с высоты полёта на заказанной дальности, без площадки. Типы: `shahed`, `geran3`, `lancet`, `gerbera`, `kh101`, `kalibr`, `kh22`, `zircon`, `iskander`, `kinzhal`, `oreshnik` и `mix` (комбинированный удар двумя секторами: «Герберы», шахеды, Герани-3, Х-101, «Калибры», Х-22, Циркон, «Искандер», «Кинжал», при 30+ — «Орешник»);
|
||||
- `/airdef replay [map|full|reel|stop]` — повтор последнего налёта;
|
||||
- `/airdef replay film [best|all|N]` — фильм режиссёра: для каждого перехвата/прилёта несколько планов (комплекс, пуск, погоня за ракетой, взгляд с цели, замедленный крупный план поражения, общий план после), склейки, плавные движения камеры, камера не уходит под землю; играется в максимальном качестве (HD, мир в полном разрешении, больше шагов облаков и тумана; настройки возвращаются после);
|
||||
- `/airdef replay export [имя] [best|all|N] [fps=60] [size=1920x1080] [crf=14] [sec=N] [noaudio]` — тот же фильм кадр за кадром с фиксированным шагом (скорость компьютера не важна) в MP4 с звуком: `<HORIZON_HOME>/airdef-films/<имя>.mp4` (нужен `ffmpeg` в PATH или `HORIZON_FFMPEG`; без него — PNG-последовательность и готовая команда ffmpeg). Прогресс в чате, отмена — `/airdef replay stop`. Окно игры держите в фокусе (пауза останавливает съёмку); чат попадает в кадр.
|
||||
- `/airdef import` — перенести в текущий мир комплексы и цели из старой версии мода (до 0.2.x они были общими для всех миров);
|
||||
- `/airdef raid` — налёт, настроенный в меню; `/airdef target here` — отметить объект под ногами; `/airdef repair` — ремонт;
|
||||
- `/airdef lastchance <on|off>` — «последний шанс»: комплекс стреляет и по классу вне ролей, если цель вот-вот попадёт (по умолчанию вкл; сохраняется);
|
||||
- `/airdef sites` — известные пусковые площадки (ПУ). РЛС с прямой видимостью может заметить сам пуск и получить неточную позицию; несколько наблюдённых пусков уточняют её. Обнаруженный позже дрон даёт только слабое предположение об обратном курсе: скрытые координаты площадки и время невидимого старта не используются. Повторные треки одного полёта не создают ложную точность.
|
||||
- `/airdef strike <номер ПУ>` — ручной приказ, **пока недоступен**: для текущей техники ещё не реализован подтверждённый совместимый боеприпас и режим удара по координатам (#118). Приказ объясняет причину, не запускает ракету от игрока и не тратит общий запас. Старые поля запаса сохраняются для совместимости формата; автоматически он больше не пополняется. Случайный перехват несуществующим «ПВО площадки» удалён. Механика полёта/коллизий/записи сохранена и проверяется отдельными тестовыми пусками. Следующий этап — физический носитель, поштучный совместимый боекомплект, подготовка пуска и снабжение; наземный режим не назначается всем зенитным ракетам по умолчанию.
|
||||
- `/airdef roles` — показать, по каким классам целей работает каждый комплекс; `/airdef roles <patriot|gepard|pantsir|s400|s500|all> <классы|default>` — задать (классы через запятую: `drone`, `jet`, `cruise`, `supersonic`, `ballistic` или `all`), например `/airdef roles s400 cruise,ballistic`;
|
||||
- `/airdef doctrine` — доктрины комплексов (#47; в меню N: «Доктрины…»): `/airdef doctrine <номер|all> reserve <K>` — держать K ракет для срочных целей (баллистика или до удара меньше 12 с); `salvo eco|normal|heavy` — сколько перехватчиков на цель (только базовые / как обычно / на один больше); `sector <центр°> <полуширина°>` или `sector off` — сектор ответственности (0° — север); `guard <объект№>[,<№>]` или `guard off` — стрелять только по тому, что идёт на охраняемые объекты (отметка: `/airdef target here`). По умолчанию ограничений нет; последний шанс сильнее доктрины; `/airdef why <номер>` называет, какая настройка остановила или разрешила пуск; сохраняется с миром и сценариями. Карта охраны и пробелов в ней — вместе с картой (#48).
|
||||
- `/airdef deploy <patriot|gepard|pantsir|s400|s500>` — поставить комплекс в 8 блоках перед собой;
|
||||
- `/airdef hold on|off` — запретить или разрешить ПВО огонь, удобно для съёмки ударов;
|
||||
- `/airdef damage on|off` — разрушать ли ландшафт взрывами (через TNT, нужны читы);
|
||||
@@ -192,25 +200,34 @@ API мода `render.set-lights` (до 512, плавно интерполиру
|
||||
|
||||
| ПВО | Вооружение | Дальность |
|
||||
|---|---|---|
|
||||
| Patriot | 4 × PAC-3, пусковая разворачивается на цель | 10–300 |
|
||||
| Гепард | 2 × 35 мм, башня и стволы со слежением и упреждением, 160 очередей | 90 (слежение с 130) |
|
||||
| Панцирь-С1 | 12 × 57Э6 и 2 × 30 мм; модуль поворачивается, пакеты и стволы поднимаются | ракеты 25–150, пушки 60 |
|
||||
| С-400 | 4 × 48Н6, вертикальный холодный старт, РЛС обзора на прицепе | 30–480 |
|
||||
| С-500 | 4 × 77Н6, холодный старт, самые быстрые ракеты | 40–700 |
|
||||
| IRIS-T SLM | 8 ракет, вертикальный пуск, быстрые и манёвренные | 15–400 |
|
||||
| NASAMS | 6 × AMRAAM, наводимая пусковая на прицепе | 10–300 |
|
||||
| Бук-М2 | 4 × 9М317 на направляющих, башня с РЛС подсвета | 20–450 |
|
||||
| Тор-М2 | 8 × 9М338 вертикально из башни, быстрая реакция против дронов | 8–160 |
|
||||
| P1-SUN | 8 дронов-перехватчиков против Шахедов и Герань; своей РЛС нет — стреляет по данным сети | 5–450 |
|
||||
| Patriot | 4 × PAC-3, пусковая разворачивается на цель | 10–450 |
|
||||
| Гепард | 2 × 35 мм, башня и стволы со слежением и упреждением, 160 очередей | 135 (слежение с 195) |
|
||||
| Панцирь-С1 | 12 × 57Э6 и 2 × 30 мм; модуль поворачивается, пакеты и стволы поднимаются | ракеты 25–225, пушки 90 |
|
||||
| С-400 | 4 × 48Н6, вертикальный холодный старт, РЛС обзора на прицепе | 30–720 |
|
||||
| С-500 | 4 × 77Н6, холодный старт, самые быстрые ракеты | 40–1050 |
|
||||
| IRIS-T SLM | 8 ракет, вертикальный пуск, быстрые и манёвренные | 15–600 |
|
||||
| NASAMS | 6 × AMRAAM, наводимая пусковая на прицепе | 10–450 |
|
||||
| Бук-М2 | 4 × 9М317 на направляющих, башня с РЛС подсвета | 20–675 |
|
||||
| Тор-М2 | 8 × 9М338 вертикально из башни, быстрая реакция против дронов | 8–240 |
|
||||
| P1-SUN | 8 дронов-перехватчиков против Шахедов и Герань; своей РЛС нет — стреляет по данным сети | 5–675 |
|
||||
|
||||
Обслуживающая техника (тоже пультами или `/airdef deploy <ключ>`): **РЛС дальнего обнаружения** (`radar`,
|
||||
видит на 1,7 км с высокой мачты, хуже прячутся за рельефом), **склад боеприпасов** (`depot`), **ТЗМ** (`tzm`),
|
||||
видит на 2,5 км с высокой мачты, хуже прячутся за рельефом), **склад боеприпасов** (`depot`), **ТЗМ** (`tzm`),
|
||||
**станция РЭБ** (`ew`), **прожектор** (`light`). Новые комплексы: `irist`, `nasams`, `buk`, `tor`, `p1sun`.
|
||||
|
||||
**Согласование огня.** Комплексы делят цели между собой: на обычную цель идёт одна ракета, на баллистическую две,
|
||||
пушки расходятся по разным целям. Первыми бьют по самым опасным (быстрым и тяжёлым) целям, при этом ложные
|
||||
**Согласование огня.** Комплексы делят цели между собой: на обычную цель идёт одна ракета, на баллистическую две; чем ближе цель к своей точке попадания,
|
||||
тем больше перехватчиков разрешено на неё сразу (за ~12 с до удара ещё один, за ~5 с — ещё один). Комплекс, у которого кончились ракеты
|
||||
или идёт перезарядка, цель не держит; тот, кто не смог навестись за ~2 с, отпускает её другим. Пушки расходятся по разным целям. Первыми бьют по самым опасным (быстрым и тяжёлым) целям, при этом ложные
|
||||
«Герберы» выглядят для них как настоящие. Шанс поражения падает, если цель быстрее перехватчика.
|
||||
|
||||
**Последний шанс** (`/airdef lastchance on|off`, по умолчанию вкл). Комплекс стреляет и по классу целей вне своих ролей
|
||||
(С-400, С-500 и Patriot по умолчанию не бьют дроны), если цель долетит до своей точки меньше чем за 10 с и на ней ещё нет
|
||||
ничьего перехватчика. Комплексу с пустыми ролями (огонь запрещён) это не касается. `/airdef why` пишет «последний шанс».
|
||||
|
||||
**Дальний пуск по РЛС.** С-400, С-500 и Patriot могут стрелять дальше своей дальности (до 1,6×) по цели, которую держит
|
||||
свежим треком РЛС дальнего обнаружения в радиусе связи: не чаще раза в 15 с, при не менее чем половине боезапаса, только по
|
||||
своим ролям и только пока в обычной дальности нет цели; шанс поражения на краю вдвое ниже. `/airdef why`: «дальний пуск по РЛС».
|
||||
|
||||
**Роли по умолчанию** (в сводке в квадратных скобках: Д — дроны, Г — реактивные, К — крылатые, С — сверхзвуковые,
|
||||
Б — баллистика): Гепард ДГК, Панцирь ДГКС, Patriot ГКСБ, С-400 ГКСБ, С-500 СБ. Сбитый дрон падает с остатком скорости, и его боевая часть
|
||||
может сдетонировать на земле.
|
||||
@@ -252,9 +269,8 @@ API мода `render.set-lights` (до 512, плавно интерполиру
|
||||
## Устройство
|
||||
|
||||
```
|
||||
HORIZON_COMMIT коммит апстрима Horizon, на который накладываются патчи
|
||||
horizon-patches/ изменения форка (git format-patch); tools/airdef.py fork собирает из них horizon/
|
||||
horizon/ форк (не в репозитории; ветка airdef). Что в нём меняется:
|
||||
.gitmodules URL отдельного репозитория движка
|
||||
horizon/ git submodule: точный SHA форка Horizon. Что в нём меняется:
|
||||
crates/horizon-mod-sdk/wit/horizon.wit render.set-models, spawn-particles, play-sound,
|
||||
query-ground / ground
|
||||
crates/horizon-mods/src/runtime.rs хост этих функций
|
||||
@@ -289,3 +305,5 @@ run-home/ тестовая игровая папка (для пров
|
||||
- Мод клиентский: дроны и ПВО видит только тот, у кого он стоит. Мультиплеер не поддерживается.
|
||||
- Окно Horizon на macOS не рисует кадры, пока оно перекрыто другими окнами (это поведение движка).
|
||||
- Шейдер работает, только если не включён шейдер-пак Horizon (они взаимоисключающие).
|
||||
|
||||
Разработка и обновление закреплённого движка: [docs/ENGINE.md](docs/ENGINE.md).
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "airdef-core"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"glam",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glam"
|
||||
version = "0.30.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19fc433e8437a212d1b6f1e68c7824af3aed907da60afa994e7f542d18d12aa9"
|
||||
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "airdef-core"
|
||||
version = "0.2.0"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
glam = "0.30"
|
||||
|
||||
[features]
|
||||
test-fixtures = []
|
||||
|
||||
[workspace]
|
||||
@@ -0,0 +1,13 @@
|
||||
# AirDef headless simulation
|
||||
|
||||
This package compiles the same `airdef-mod/src/sim` source as the game adapter, with `glam` as its only dependency. A checkout does not need the Horizon submodule to build or run it:
|
||||
|
||||
```sh
|
||||
cargo test --manifest-path airdef-core/Cargo.toml
|
||||
cargo run --manifest-path airdef-core/Cargo.toml --release --example sim_run -- --list
|
||||
cargo run --manifest-path airdef-core/Cargo.toml --release --example sim_run -- --scenario big-smart
|
||||
```
|
||||
|
||||
The shared scenario harness runs for both packages. Adapter integration tests for layout and smoke stay in `airdef-mod`; `core_boundary` verifies the public type facade and deterministic combat trace.
|
||||
|
||||
This is an incremental boundary: the simulation still produces rendering and audio declarations and formats some UI text. Moving those outputs and diagnostics to adapters, remain follow-up work. The mod re-exports `airdef_core::sim` as its existing public facade.
|
||||
@@ -0,0 +1,8 @@
|
||||
//! Run the same native scenario CLI without building the Horizon SDK.
|
||||
extern crate airdef_core as airdef;
|
||||
#[path = "../../airdef-mod/examples/sim_run/main.rs"]
|
||||
mod runner;
|
||||
|
||||
fn main() {
|
||||
runner::main();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//! SDK-independent build of the same simulation used by the AirDef adapter.
|
||||
//!
|
||||
//! The source remains shared while the domain/presentation boundary is extracted;
|
||||
//! no generated copy can drift from the mod's simulation.
|
||||
#[path = "../../airdef-mod/src/sim/mod.rs"]
|
||||
pub mod sim;
|
||||
@@ -0,0 +1,37 @@
|
||||
//! The mod's headless scenarios run against the SDK-independent package too.
|
||||
extern crate airdef_core as airdef;
|
||||
#[path = "../../airdef-mod/examples/sim_run/harness.rs"]
|
||||
mod harness;
|
||||
|
||||
fn check(sc: harness::Scenario) -> harness::Report {
|
||||
let r = harness::run(&sc);
|
||||
let problems = r.problems();
|
||||
assert!(problems.is_empty(), "scenario {} failed: {problems:?}\n{}", r.name, r.text());
|
||||
assert!(r.launched > 0);
|
||||
r
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn big_smart_raid_on_61_systems() {
|
||||
let r = check(harness::big_smart());
|
||||
assert_eq!(r.units, 61);
|
||||
assert!(r.fired > 0 && r.ground_queries > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn logistics_trucks_depot_and_raid() {
|
||||
let r = check(harness::logistics());
|
||||
assert!(r.truck_busy_ticks > 0 && r.fired > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ew_and_adaptive_enemy_over_three_raids() {
|
||||
assert_eq!(check(harness::ew_adaptive()).raids_ended, 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn same_seed_same_result() {
|
||||
let a = harness::run(&harness::logistics());
|
||||
let b = harness::run(&harness::logistics());
|
||||
assert_eq!((a.ticks_run, a.launched, a.kills, a.hits, a.fired, a.ground_queries), (b.ticks_run, b.launched, b.kills, b.hits, b.fired, b.ground_queries));
|
||||
}
|
||||
@@ -6,10 +6,18 @@ version = 4
|
||||
name = "airdef"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"airdef-core",
|
||||
"glam",
|
||||
"horizon-mod-sdk",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "airdef-core"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"glam",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.104"
|
||||
|
||||
@@ -9,9 +9,13 @@ description = "AirDef: long-range drones and air defence for the AirDef fork of
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
airdef-core = { path = "../airdef-core" }
|
||||
horizon-mod-sdk = { path = "../horizon/crates/horizon-mod-sdk" }
|
||||
glam = "0.30"
|
||||
|
||||
[dev-dependencies]
|
||||
airdef-core = { path = "../airdef-core", features = ["test-fixtures"] }
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
lto = true
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
"flecktarn": "airdef:block/flecktarn",
|
||||
"radar_face": "airdef:block/radar_face",
|
||||
"metal": "airdef:block/metal",
|
||||
"mk_de": "airdef:block/mk_de",
|
||||
"bare_antenna": "airdef:block/bare_antenna",
|
||||
"dark_metal": "airdef:block/dark_metal",
|
||||
"mk_de": "airdef:block/mk_de",
|
||||
"particle": "airdef:block/flecktarn_s21"
|
||||
},
|
||||
"elements": [
|
||||
@@ -15,11 +14,11 @@
|
||||
"from": [
|
||||
-4.0,
|
||||
0.0,
|
||||
-6.0
|
||||
-5.0
|
||||
],
|
||||
"to": [
|
||||
20.0,
|
||||
12.0,
|
||||
5.0,
|
||||
16.0
|
||||
],
|
||||
"faces": {
|
||||
@@ -28,7 +27,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
12.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_s21"
|
||||
},
|
||||
@@ -37,7 +36,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
12.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_s21"
|
||||
},
|
||||
@@ -46,7 +45,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
12.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
@@ -55,7 +54,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
12.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
@@ -81,14 +80,14 @@
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-2.0,
|
||||
12.0,
|
||||
-2.0
|
||||
-2.5,
|
||||
5.0,
|
||||
-5.0
|
||||
],
|
||||
"to": [
|
||||
18.0,
|
||||
14.0,
|
||||
14.0
|
||||
18.5,
|
||||
12.0,
|
||||
15.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
@@ -96,7 +95,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
2.0
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
@@ -105,7 +104,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
2.0
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
@@ -114,7 +113,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
2.0
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
@@ -123,7 +122,75 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
2.0
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-2.0,
|
||||
12.0,
|
||||
-2.0
|
||||
],
|
||||
"to": [
|
||||
18.0,
|
||||
13.0,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
@@ -218,7 +285,7 @@
|
||||
{
|
||||
"from": [
|
||||
7.0,
|
||||
14.0,
|
||||
13.0,
|
||||
10.0
|
||||
],
|
||||
"to": [
|
||||
@@ -232,7 +299,7 @@
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
4.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
},
|
||||
@@ -241,7 +308,7 @@
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
4.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
},
|
||||
@@ -250,7 +317,7 @@
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
4.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
},
|
||||
@@ -259,7 +326,7 @@
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
4.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
},
|
||||
@@ -285,150 +352,168 @@
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
20.0,
|
||||
3.0,
|
||||
-5.5
|
||||
-4.7,
|
||||
4.8,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
20.119999999999997,
|
||||
6.5,
|
||||
1.5
|
||||
-2.5,
|
||||
10.7,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.5
|
||||
2.2,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.5
|
||||
2.2,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
7.0,
|
||||
3.5
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
7.0,
|
||||
3.5
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
7.0
|
||||
2.2,
|
||||
16
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
7.0
|
||||
2.2,
|
||||
16
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
}
|
||||
},
|
||||
"rotation": {
|
||||
"angle": 22.5,
|
||||
"axis": "z",
|
||||
"origin": [
|
||||
-3.6,
|
||||
7.75,
|
||||
5.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-4.119999999999997,
|
||||
3.0,
|
||||
-5.5
|
||||
18.5,
|
||||
4.8,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
-4.0,
|
||||
6.5,
|
||||
1.5
|
||||
20.7,
|
||||
10.7,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.5
|
||||
2.1999999999999993,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.5
|
||||
2.1999999999999993,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
7.0,
|
||||
3.5
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
7.0,
|
||||
3.5
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
7.0
|
||||
2.1999999999999993,
|
||||
16
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
7.0
|
||||
2.1999999999999993,
|
||||
16
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
"texture": "#flecktarn"
|
||||
}
|
||||
},
|
||||
"rotation": {
|
||||
"angle": -22.5,
|
||||
"axis": "z",
|
||||
"origin": [
|
||||
19.6,
|
||||
7.75,
|
||||
5.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
5.5,
|
||||
14.0,
|
||||
0.0,
|
||||
13.05,
|
||||
2.0
|
||||
],
|
||||
"to": [
|
||||
10.5,
|
||||
14.8,
|
||||
7.0
|
||||
5.0,
|
||||
13.7,
|
||||
8.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
@@ -436,143 +521,75 @@
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.8000000000000007
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#metal"
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.8000000000000007
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#metal"
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.8000000000000007
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#metal"
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.8000000000000007
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#metal"
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
5.0
|
||||
6.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
5.0
|
||||
6.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
"texture": "#dark_metal"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
2.0,
|
||||
14.0,
|
||||
5.0
|
||||
],
|
||||
"to": [
|
||||
3.0,
|
||||
16.0,
|
||||
6.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
2.0
|
||||
],
|
||||
"texture": "#bare_antenna"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
2.0
|
||||
],
|
||||
"texture": "#bare_antenna"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
2.0
|
||||
],
|
||||
"texture": "#bare_antenna"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
2.0
|
||||
],
|
||||
"texture": "#bare_antenna"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"texture": "#bare_antenna"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"texture": "#bare_antenna"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-4.800000000000001,
|
||||
7.0,
|
||||
-5.0
|
||||
],
|
||||
"to": [
|
||||
-4.0,
|
||||
10.0,
|
||||
-2.0
|
||||
13.05,
|
||||
2.0
|
||||
],
|
||||
"to": [
|
||||
15.0,
|
||||
13.7,
|
||||
8.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
@@ -580,8 +597,8 @@
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
@@ -589,8 +606,8 @@
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
3.0,
|
||||
3.0
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
@@ -598,8 +615,8 @@
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
3.0,
|
||||
3.0
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
@@ -607,8 +624,8 @@
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
@@ -616,8 +633,8 @@
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
}
|
||||
@@ -625,207 +642,139 @@
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
20.0,
|
||||
7.0,
|
||||
-5.0
|
||||
18.5,
|
||||
6.0,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
20.8,
|
||||
10.0,
|
||||
-2.0
|
||||
18.619999999999997,
|
||||
9.0,
|
||||
2.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
3.0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
3.0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-4.800000000000001,
|
||||
7.0,
|
||||
-1.5
|
||||
-2.6199999999999974,
|
||||
6.0,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
-4.0,
|
||||
10.0,
|
||||
0.5
|
||||
-2.5,
|
||||
9.0,
|
||||
2.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
2.0
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
2.0
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
20.0,
|
||||
7.0,
|
||||
-1.5
|
||||
],
|
||||
"to": [
|
||||
20.8,
|
||||
10.0,
|
||||
0.5
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
2.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
2.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
"texture": "#mk_de"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
"flecktarn_b": "airdef:block/flecktarn_b",
|
||||
"radar_face_b": "airdef:block/radar_face_b",
|
||||
"metal_b": "airdef:block/metal_b",
|
||||
"mk_de_b": "airdef:block/mk_de_b",
|
||||
"bare_antenna_b": "airdef:block/bare_antenna_b",
|
||||
"dark_metal_b": "airdef:block/dark_metal_b",
|
||||
"mk_de_b": "airdef:block/mk_de_b",
|
||||
"particle": "airdef:block/flecktarn_s21_b"
|
||||
},
|
||||
"elements": [
|
||||
@@ -15,11 +14,11 @@
|
||||
"from": [
|
||||
-4.0,
|
||||
0.0,
|
||||
-6.0
|
||||
-5.0
|
||||
],
|
||||
"to": [
|
||||
20.0,
|
||||
12.0,
|
||||
5.0,
|
||||
16.0
|
||||
],
|
||||
"faces": {
|
||||
@@ -28,7 +27,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
12.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_s21_b"
|
||||
},
|
||||
@@ -37,7 +36,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
12.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_s21_b"
|
||||
},
|
||||
@@ -46,7 +45,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
12.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
@@ -55,7 +54,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
12.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
@@ -81,14 +80,14 @@
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-2.0,
|
||||
12.0,
|
||||
-2.0
|
||||
-2.5,
|
||||
5.0,
|
||||
-5.0
|
||||
],
|
||||
"to": [
|
||||
18.0,
|
||||
14.0,
|
||||
14.0
|
||||
18.5,
|
||||
12.0,
|
||||
15.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
@@ -96,7 +95,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
2.0
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
@@ -105,7 +104,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
2.0
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
@@ -114,7 +113,7 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
2.0
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
@@ -123,7 +122,75 @@
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
2.0
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-2.0,
|
||||
12.0,
|
||||
-2.0
|
||||
],
|
||||
"to": [
|
||||
18.0,
|
||||
13.0,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
@@ -218,7 +285,7 @@
|
||||
{
|
||||
"from": [
|
||||
7.0,
|
||||
14.0,
|
||||
13.0,
|
||||
10.0
|
||||
],
|
||||
"to": [
|
||||
@@ -232,7 +299,7 @@
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
4.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal_b"
|
||||
},
|
||||
@@ -241,7 +308,7 @@
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
4.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal_b"
|
||||
},
|
||||
@@ -250,7 +317,7 @@
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
4.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal_b"
|
||||
},
|
||||
@@ -259,7 +326,7 @@
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
4.0
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal_b"
|
||||
},
|
||||
@@ -285,226 +352,244 @@
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
20.0,
|
||||
3.0,
|
||||
-5.5
|
||||
-4.7,
|
||||
4.8,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
20.119999999999997,
|
||||
6.5,
|
||||
1.5
|
||||
-2.5,
|
||||
10.7,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.5
|
||||
2.2,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.5
|
||||
2.2,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
7.0,
|
||||
3.5
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
7.0,
|
||||
3.5
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
7.0
|
||||
2.2,
|
||||
16
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
7.0
|
||||
2.2,
|
||||
16
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
}
|
||||
},
|
||||
"rotation": {
|
||||
"angle": 22.5,
|
||||
"axis": "z",
|
||||
"origin": [
|
||||
-3.6,
|
||||
7.75,
|
||||
5.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-4.119999999999997,
|
||||
3.0,
|
||||
-5.5
|
||||
18.5,
|
||||
4.8,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
-4.0,
|
||||
6.5,
|
||||
1.5
|
||||
20.7,
|
||||
10.7,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.5
|
||||
2.1999999999999993,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.5
|
||||
2.1999999999999993,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
7.0,
|
||||
3.5
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
7.0,
|
||||
3.5
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
7.0
|
||||
2.1999999999999993,
|
||||
16
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
7.0
|
||||
2.1999999999999993,
|
||||
16
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
"texture": "#flecktarn_b"
|
||||
}
|
||||
},
|
||||
"rotation": {
|
||||
"angle": -22.5,
|
||||
"axis": "z",
|
||||
"origin": [
|
||||
19.6,
|
||||
7.75,
|
||||
5.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
2.0,
|
||||
14.0,
|
||||
5.0
|
||||
0.0,
|
||||
13.05,
|
||||
2.0
|
||||
],
|
||||
"to": [
|
||||
3.0,
|
||||
16.0,
|
||||
6.0
|
||||
5.0,
|
||||
13.7,
|
||||
8.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
2.0
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#bare_antenna_b"
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
2.0
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#bare_antenna_b"
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
2.0
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#bare_antenna_b"
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
2.0
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#bare_antenna_b"
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
1.0
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#bare_antenna_b"
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
1.0
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#bare_antenna_b"
|
||||
"texture": "#dark_metal_b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-4.800000000000001,
|
||||
7.0,
|
||||
-5.0
|
||||
],
|
||||
"to": [
|
||||
-4.0,
|
||||
10.0,
|
||||
-2.0
|
||||
13.05,
|
||||
2.0
|
||||
],
|
||||
"to": [
|
||||
15.0,
|
||||
13.7,
|
||||
8.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
@@ -512,8 +597,8 @@
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
@@ -521,8 +606,8 @@
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
3.0,
|
||||
3.0
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
@@ -530,8 +615,8 @@
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
3.0,
|
||||
3.0
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
@@ -539,8 +624,8 @@
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
@@ -548,8 +633,8 @@
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
}
|
||||
@@ -557,139 +642,71 @@
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
20.0,
|
||||
7.0,
|
||||
-5.0
|
||||
-2.6199999999999974,
|
||||
6.0,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
20.8,
|
||||
10.0,
|
||||
-2.0
|
||||
-2.5,
|
||||
9.0,
|
||||
2.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
"texture": "#mk_de_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
"texture": "#mk_de_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
3.0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
"texture": "#mk_de_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
3.0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
"texture": "#mk_de_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
"texture": "#mk_de_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-4.800000000000001,
|
||||
7.0,
|
||||
-1.5
|
||||
],
|
||||
"to": [
|
||||
-4.0,
|
||||
10.0,
|
||||
0.5
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
2.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.8000000000000007,
|
||||
2.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
"texture": "#mk_de_b"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ fn parse_layout(path: &str) -> Vec<Unit> {
|
||||
units
|
||||
}
|
||||
|
||||
fn main() {
|
||||
pub fn main() {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
let mut name = "big-smart".to_string();
|
||||
let mut i = 0;
|
||||
|
||||
@@ -0,0 +1,573 @@
|
||||
61d8c0b90973a3f1398d4db914b1fc9c39ff5ac4316085d7cc05d070ea62d15f assets/airdef/blockstates/amraam_missile.json
|
||||
7f8fe0d11f6c8929e48c136b2f34d1c653f060511957a32fe4988377fc61d62c assets/airdef/blockstates/barge.json
|
||||
dc5d543e28c50474df938163495a70fb81becd0814dc59d516493adb7c087110 assets/airdef/blockstates/beam.json
|
||||
b2cc12fe02e4ccba502f47085046defe6a51e22be3fd739c4678677ed977c312 assets/airdef/blockstates/buk_chassis.json
|
||||
8e2fe3bce22d718a9384a3805034691ee0ea068aad81d10aededa20da20afb9a assets/airdef/blockstates/buk_chassis_burnt.json
|
||||
035b3898bfee5c0dfeed946e64e9365ad111c6e017ce0222e6455ee860f8d8cf assets/airdef/blockstates/buk_rails.json
|
||||
b8ff32da42179af8d3762b5bddd3f33df7172fbef5352fbf51ddd1a8d5899c21 assets/airdef/blockstates/buk_rails_burnt.json
|
||||
a4b1563f2c4578014b48778177d1e7032cc3f23afa99a715d4c9b08a67397b9e assets/airdef/blockstates/buk_turret.json
|
||||
413edabb0c8db5b5f39f10f91ace49ee658036a00ba53db7d4ffc20615f70814 assets/airdef/blockstates/buk_turret_burnt.json
|
||||
3b3145ddb3dad08986aeebacee5a389aea74e6ae7f2c778da52201fd8f24f2f4 assets/airdef/blockstates/debris.json
|
||||
254aaebdf2c9c63d0c3bd95093368ebd6466cbb768d31ede32f07fc4fef5e808 assets/airdef/blockstates/depot.json
|
||||
4062e069929859ea7fb18487b42953ac43cb9bd6e90d349e3ae49afbd29426c6 assets/airdef/blockstates/depot_burnt.json
|
||||
d02848bd8df8af516fd12c3412636457e4f62577e221082a8627f041b714609c assets/airdef/blockstates/ew_truck.json
|
||||
6921ae900410d3415aa5357d008c9ef122891082f1f71d11dfda01b145e2127e assets/airdef/blockstates/ew_truck_burnt.json
|
||||
3cd4de622d0c8e43caf42f22547df388dbb78ff55ac868d9cfad37a23d37800f assets/airdef/blockstates/fireball.json
|
||||
7355433bd94843c5c0d7848f1a5afb810ef08221b3f0389c0061e50970b5d92f assets/airdef/blockstates/flame.json
|
||||
840655b48624534badc6367d88cc1472d748c989ff8c7082ecacaf79f54cc2e5 assets/airdef/blockstates/flare.json
|
||||
0654962121ca92b60cf95beced4b062fb377cb2776ad1ff08f44d92624d59a08 assets/airdef/blockstates/flash.json
|
||||
2453542113245c015b7c54971fd57184b80beb970eaefb420e7adab3618da005 assets/airdef/blockstates/gepard_dish.json
|
||||
0a3fe2f20da19c69744f304cf769e3ce3ef236a6d251afee380477e2b5276292 assets/airdef/blockstates/gepard_guns.json
|
||||
4645e4959fa2b126dc913e710dd15babbb30c139f8450d86cdb3676ec590ea0f assets/airdef/blockstates/gepard_guns_burnt.json
|
||||
477ce5eb4b76da642c6b758098715c20d0fbb7c114177fceb705f3bbe97b5c59 assets/airdef/blockstates/gepard_hull.json
|
||||
7b18a4ba743d64e554529efa25c881ab3ea7a500aa3390fca4a98c5691724380 assets/airdef/blockstates/gepard_hull_burnt.json
|
||||
ca3e0e913af91bfffc6d9910a557b3acb1e01cfa497e3452ad37e935be491697 assets/airdef/blockstates/gepard_turret.json
|
||||
80c3bfd8b7fc2252110ccd54b3ae8118ddf3100d7b983ce326aa6b1fcc6e6d97 assets/airdef/blockstates/gepard_turret_burnt.json
|
||||
41108d18eda14c14e6259e3c68d3894d86aee8ac10cccec33fe271e0345e9202 assets/airdef/blockstates/geran3.json
|
||||
4f0737d7739bee31106845b4062dc65336ae49bde0f310a3bbccc74c17f31ad5 assets/airdef/blockstates/geran3_flame.json
|
||||
b6fe8c5937cf30957d0ad01f7313146760beb3958d8f25a8586021b5a8ed3c8f assets/airdef/blockstates/gerbera.json
|
||||
2c270b14b4130c4831eda0ea9acc378e4f720e42f4adab5babea25662d7500ef assets/airdef/blockstates/irist_chassis.json
|
||||
22f2e998245f414f789ca3929d43d73d66b03bf95334ad41c2c5ce768e6b23b4 assets/airdef/blockstates/irist_chassis_burnt.json
|
||||
16a21bd9b4051a1087b64e9c606541d098ee3074e492aedb6142e6f16eac4c58 assets/airdef/blockstates/irist_missile.json
|
||||
e6e1cb2e1aa92837a187016cc1d6238f962fb1a256c168395aeb15fc2dbb8efc assets/airdef/blockstates/irist_tubes.json
|
||||
204d6cb12a261672f190d8b7958837fe9eb5efd960b891accb68fc61b46a110b assets/airdef/blockstates/irist_tubes_burnt.json
|
||||
1d1fdd506878e5ad8fdbb64bb1608179c4dc247f7369b8e0ffd85835d05a8685 assets/airdef/blockstates/iskander.json
|
||||
c62e1d8ffaeaf14e3b57ecf1e161cec6bcb13a9aee36dca3e88442584f1dd155 assets/airdef/blockstates/kalibr.json
|
||||
c09ae784b9bc87e969a845975294f0d4880b9a90692f57c79e2de04c5a650146 assets/airdef/blockstates/kh101.json
|
||||
0d30bb49f1227ac4c78a9f05babfcf6856b17d8ba059e00669a4d27a558ff519 assets/airdef/blockstates/kh22.json
|
||||
f37a2c415049fe1579bc71cb8caa14b05c6e96c17e6a2f9760bc83a97b93c4a4 assets/airdef/blockstates/kinzhal.json
|
||||
88b47dffffe1d95cf2c5981ef67837e597f6be06d417177d4967451bb55b3b8c assets/airdef/blockstates/lancet.json
|
||||
83f736f00a673c90c0c1dcf726dd8a7350ab1d1efa37dcd85eacd8dfe94383f8 assets/airdef/blockstates/launch_ramp.json
|
||||
de0bc51183c7a8379dddab26952f063a4a4a4b51b8dd862bc061989ec89681d7 assets/airdef/blockstates/launcher_truck.json
|
||||
5352e83f412ea524aba1519367f0f9a921958a5d4caefe17d509a5b7e04a1cbe assets/airdef/blockstates/m48n6.json
|
||||
64bc9d9193ca5f20a2bbb189bf6216211c167e051cc63c297a72655d711cfe67 assets/airdef/blockstates/m57e6.json
|
||||
dc55ec1579702d9d48c01e5268dfae7097d0ece87d85b1a469222134f962f4b1 assets/airdef/blockstates/m77n6.json
|
||||
2331d3c3c614e38d39d67d8d85c4b16030ed7ecab37bfaa9da938379534f57cd assets/airdef/blockstates/nasams_launcher.json
|
||||
f05bb84135b39bc469fadbc4f144e0f69d203b1887396a0b20adac59e549c1ed assets/airdef/blockstates/nasams_launcher_burnt.json
|
||||
9fa63fdb0fe84521f00326dad6955af6adb3dea1093f42404e6e07770cd9bcf5 assets/airdef/blockstates/nasams_trailer.json
|
||||
640b83fc5b43f6fce1d13106016e9b14c0150603035a6d9b19ad6f0598511959 assets/airdef/blockstates/nasams_trailer_burnt.json
|
||||
446bd55fb9bacd7828c6a7028595de64e26cc5cbe3ef4280713c3d9f1cdf850e assets/airdef/blockstates/p1sun.json
|
||||
9e2e00e75afb10c38684b1994688ea11bcc2faace46ff551967e1e05ae08ec85 assets/airdef/blockstates/p1sun_launcher.json
|
||||
02f9474f5f459e33096931887b71b515d957b7a1be14ccb81a0bba36af551ec9 assets/airdef/blockstates/p1sun_launcher_burnt.json
|
||||
da5130347d961fe0ca0df11d31b250dc1fa268cacfeed184662fe22901b6ebd7 assets/airdef/blockstates/pac3.json
|
||||
f5674075063a8dbd897394de194b980a426e08faf7803ec10b8117070a579a78 assets/airdef/blockstates/pantsir_dish.json
|
||||
365f6ca767ad9dd9cc724ea859f41ea6879f0d0ba88d6aaaab2ae7d5fe34acd8 assets/airdef/blockstates/pantsir_pack.json
|
||||
53af2cf24abb2df609f02d41e711ba49e38be4b6a9a0a6e1d8cf395dde3b58a5 assets/airdef/blockstates/pantsir_pack_burnt.json
|
||||
6a93f7b1eee7b8ff02567c38c05196f8326d66b319cc5d69c942902986bed946 assets/airdef/blockstates/pantsir_truck.json
|
||||
81804b614abfd0776e1513c9f759d1cc22952346cbbc980b006fd367b68792a2 assets/airdef/blockstates/pantsir_truck_burnt.json
|
||||
c274aaf1c5e81683c540c784bf0eb7de15ac8522a5e4d7397cd7b181367c7e83 assets/airdef/blockstates/pantsir_turret.json
|
||||
05c3dd4f66c8cd7332654e19aeb60115f00e246c8f57f4eef2c300f1ddb97a2a assets/airdef/blockstates/pantsir_turret_burnt.json
|
||||
c96640ff19099af66c2da0a9a7561b847d6355ab2de8bbfbe03f2daf38b89ff3 assets/airdef/blockstates/patriot_launcher.json
|
||||
c3b0b6f1d9b7da434c95f2794b97b9e2c05c62ccbce9f0884df071e4ec28a468 assets/airdef/blockstates/patriot_launcher_burnt.json
|
||||
83058657f466b769c9140f5d6c4a5079f9567f9cb13ece7a453da191aee5b89d assets/airdef/blockstates/patriot_radar.json
|
||||
3ecae997dc4fe1939848fc60347979c02075396a164b31dec3995a2e907a8447 assets/airdef/blockstates/patriot_trailer.json
|
||||
31fecc6476129990a7d368f6d7cdb954b13e777b28d1396a68168770024112ce assets/airdef/blockstates/patriot_trailer_burnt.json
|
||||
183d0b2ae9c24c94c3d83f2819e1167b5e2d134cc7889e0e3bda12aa784c7baa assets/airdef/blockstates/patriot_truck.json
|
||||
37714e19e555cc50a9f195e1a8845a28c9985c27ed38b577c0813f4629b66fcb assets/airdef/blockstates/radar_panel.json
|
||||
95fe14b9d3e30597f5505aa93f31c3357cebea6117596bd9f5a5bc840ab22415 assets/airdef/blockstates/radar_trailer.json
|
||||
a95a1b8731d6bedda7d8b352ff3c448ea8be691b0ead01f14acab39234590c45 assets/airdef/blockstates/radar_truck.json
|
||||
332e6f39c40063ca690064e13a1a256ef215fc2bb96985b842d9dda58abee2eb assets/airdef/blockstates/radar_truck_burnt.json
|
||||
67b93302bea867248b6fa0109a4b5af2065e5c857d4a5c7e088bc9849fe624de assets/airdef/blockstates/reentry.json
|
||||
7f3e952f5de83880549012945827f8469883355b0a3dd966e7f03c44aee532ab assets/airdef/blockstates/s400_chassis.json
|
||||
411d0a0ac102b21016bf48d30482e073a7e8054c2775d8fd5a7c91364a2cb1f7 assets/airdef/blockstates/s400_chassis_burnt.json
|
||||
3ffc2edef1362f318d6c087a20cd730feda6f35f7381942cfc8012f06f4dc174 assets/airdef/blockstates/s400_tubes.json
|
||||
e570e68b27a7554e3aa8b63b30108a2f4e2c3bec6e91cd3cff7509e3d7eb3400 assets/airdef/blockstates/s400_tubes_burnt.json
|
||||
eb8061c3cb198600ad8f587738e8a676d9ef114ed171764bc905f4730eb3a0ba assets/airdef/blockstates/s500_chassis.json
|
||||
f0cf8bafdf7053ae757e5b0baee92accb984a24bfbc18d65e1e824384e09180c assets/airdef/blockstates/s500_chassis_burnt.json
|
||||
2b7bd3099ec300184a185e2beb48dd748004af869696f4a26793032bf9675439 assets/airdef/blockstates/s500_tubes.json
|
||||
3d6fc384684a24218888e871ba0efc72d15ce29de84cf45e3adffc5f7f98a45c assets/airdef/blockstates/s500_tubes_burnt.json
|
||||
3af7b3f01780265cbff35e20aa149691bceb8de10a6991129b32046c753c6f8b assets/airdef/blockstates/searchlight.json
|
||||
8e530da837dba9ec426651efa136c3389c4f9f9e8baf453b9055b4d260b5900f assets/airdef/blockstates/searchlight_burnt.json
|
||||
48b14bddcb967c4a4933a827568c0b66d9e6c9e2d3a62c63b6ca55ddab8764dd assets/airdef/blockstates/searchlight_head.json
|
||||
bc57f94b431786c60a6b204ea54126c9d2b363427673c39a45ce0a53336ee7c8 assets/airdef/blockstates/searchlight_head_burnt.json
|
||||
9c25df8f750763b5e3011557a6aa59289e9a41efa1811c18c30522747473dde6 assets/airdef/blockstates/shahed.json
|
||||
ab6d7a96cda417cf70fa31aca6f6c7bcdaaf4f8d413b079386f97ecef6d33709 assets/airdef/blockstates/shahed_prop.json
|
||||
137dc0f2bc5723534dc2e4f44f1706d589c0dd85318d17c207f2f6772d98d989 assets/airdef/blockstates/target.json
|
||||
e766e18158d00f0480f6dfe32dfe142890b8d452bc493b7474fda0984cc2dd4c assets/airdef/blockstates/tor_chassis.json
|
||||
ff125150e206ada5a7fb47394e809039d338c22a843207a32352e9ee59e278a3 assets/airdef/blockstates/tor_chassis_burnt.json
|
||||
04a5fb931f419086995791c1defd9486b36b3c725581bf5a10191a2c71c69984 assets/airdef/blockstates/tor_turret.json
|
||||
fdcbe36a0f4968005e8c6588f2fa5d8196c55da3183cf89760ea221a5c4cb431 assets/airdef/blockstates/tor_turret_burnt.json
|
||||
cf7c26abeb1d8f7d84106bd83b84bf541a3d11369b7745a77802b7e51dcdf447 assets/airdef/blockstates/tracer.json
|
||||
8b547ccbc890fa53b613cdb2cf55ceaa5833348479b0863651c6df01a9f778b3 assets/airdef/blockstates/tzm_truck.json
|
||||
11fca31a88e658c819954fbb86b53d7709b66b971af8747a5edda24be34e5dbb assets/airdef/blockstates/tzm_truck_burnt.json
|
||||
4a74928eae32adeaf6e0e5d964ccbda97be0a2208961772848f109c59a9c6c1f assets/airdef/blockstates/zircon.json
|
||||
48aeeb65e6be762ef975540826b2b3303a2df5378c3181e5e99826206df370e4 assets/airdef/items/cam_geran3.json
|
||||
e6d0a3b45670cda451ebe4689323b269de22afb7d99b341510a711a22db75c85 assets/airdef/items/cam_gerbera.json
|
||||
e22e53fbfadaa018ec8091213406b57eee49b39341e029daf96d7915f500e50a assets/airdef/items/cam_iskander.json
|
||||
a3174ebb0b1720b803316c3bdce3abf09146d2c1a2b78bb6c091aa4a363716ec assets/airdef/items/cam_kalibr.json
|
||||
f357a1510ead55131a7f93bfe43d46c3e0c229deb25cfe82bfecfa84caba543e assets/airdef/items/cam_kh101.json
|
||||
65625082b0ca6b0835b9a7bb04657b83b76103a25f263d85254835e0d29f6725 assets/airdef/items/cam_kh22.json
|
||||
16fe2fa4cfa528878261fde9c3a9923989608ffc2ebbdc770cdda2b9098b0287 assets/airdef/items/cam_kinzhal.json
|
||||
f4d13fcb599d8fed03ab4fa5a95900df6a0c766d29b3095d32fe9dc2f06d3554 assets/airdef/items/cam_lancet.json
|
||||
ed5405e2cd20da02053d8b614a630ef5c32f476c08dabccbbeaaf0b261823956 assets/airdef/items/cam_reentry.json
|
||||
7654d42382b9f072ea8a0f348c30e78c147921f5bf95723fe08bfe23b1b28c1a assets/airdef/items/cam_shahed.json
|
||||
adb65d10541f62f8e0a4c0b9da63a9e7bf4581f44672d2542d11bb16f89e75fc assets/airdef/items/cam_zircon.json
|
||||
0c5fd99e7447602834eae3296026031fc7419ba6126b507132503925b01af1e4 assets/airdef/items/deploy_buk.json
|
||||
b5c9bbceb576dcf3e4ddc3d01f6e3743d67f087ab98a24966c506585aaa67b2b assets/airdef/items/deploy_depot.json
|
||||
b50fe5804cbbe10df992ebbc7e095a32ce8b73fc35159fa19889640681e408e9 assets/airdef/items/deploy_ew.json
|
||||
728e5e8bfb4c351f11db6be872834e4a07a9b04fb6be63d9bb1ad42495bb57d3 assets/airdef/items/deploy_gepard.json
|
||||
0c9c5ee3fc87e2dc6d716bdb0bb5f30d3b265268bfd5083462b4861a8da65f0f assets/airdef/items/deploy_irist.json
|
||||
09e46a6c4b59f66c24060ac627e6a287bf6797c7b1e32a9ec6c9d9662fdc3de3 assets/airdef/items/deploy_light.json
|
||||
6983561b3558aee16662aa83d2d9af760fb6236cc7dbe79ba20802f8a2ff15b9 assets/airdef/items/deploy_nasams.json
|
||||
d8ac6a9258e2fc2e0791bbce18a3a07a72e471fbc72b6be7b5ca545c53f8d633 assets/airdef/items/deploy_p1sun.json
|
||||
e2353c70f6e5053864ab2fdf51df886d72c03e5c34db84fef8f3fff9c84a7ae4 assets/airdef/items/deploy_pantsir.json
|
||||
68dd9b1382b2dd6ad23d0f507a8cfcdcfa18ef5c4203e69c61f6ade9cfbf238e assets/airdef/items/deploy_patriot.json
|
||||
d93b6bf77de4aed1f1955e76353661729f06445788ad7a6654ed6af1a67fc48d assets/airdef/items/deploy_radar.json
|
||||
0b9445f3b54a9e958da0b9bd4243a41d85fc8f12b5c4e56bbc070edb8f1bf618 assets/airdef/items/deploy_s400.json
|
||||
dd7478f447d87dcad42e1a7e6dcb5fae555c832e933a3722022d0e10e2de011e assets/airdef/items/deploy_s500.json
|
||||
14e9a20dcddee5a6262ef624783900576dac2bd16e5079e731cf6115f13c76ec assets/airdef/items/deploy_tor.json
|
||||
d4ff57f630ca92bf52ba228d8c6fd5292928b685d6bb5a9c9b9dc0c3d586fc2e assets/airdef/items/deploy_tzm.json
|
||||
044fc626ad99ff8be6db0800f96dc743fc80606d813bd59abad531396bf9d8ce assets/airdef/items/designator.json
|
||||
5a07f4adb780e52b920d1c8ca5296e43e84f44897b0f6afe258a8c2c7712f83c assets/airdef/items/flare_gun.json
|
||||
25fc0a8ac7b5e01c6de19c86584e5bfc2dd9cbfa8e7ffb0468db82cb89f5585a assets/airdef/items/launch_geran3.json
|
||||
5dd3ca665c44c43bef0c4c25361b9a4d45d0b2a7b01d2c8e66cefbf62ee38180 assets/airdef/items/launch_iskander.json
|
||||
106695745868cf5ed80534ca35d81944a9fc40a74d30d4d4fdf43d716dc5b28b assets/airdef/items/launch_kalibr.json
|
||||
5c45ad03265b1331ee73b8085cfc33a8538339c9fd1c9916c3f5471bb2ed0bfb assets/airdef/items/launch_kh101.json
|
||||
ed9356cb86466025eab00d4283a72adfd1cf6aa9549f051c5e6088c72078263c assets/airdef/items/launch_kh22.json
|
||||
8af907c3597963f6332c2cd677d5236e41dc9584d816fdbbd820ddb99217fdf1 assets/airdef/items/launch_kinzhal.json
|
||||
54045e7d6cb53e92700accb04f6caf68e229d71cba6038669c425e9c109b904d assets/airdef/items/launch_lancet.json
|
||||
4a007ad0f768a53c605236476667178e981e47980baf04a973fefde2bd4b20c3 assets/airdef/items/launch_oreshnik.json
|
||||
b4d98a938486d49db28c6c7a608ca3b6ab0c9c3eac266ecf12c7dd931cc28f93 assets/airdef/items/launch_shahed.json
|
||||
489799dcb5b441e9d4be8bfb3d73a6ebd5fdf2b5ee614b62f38b85bb2fbfad75 assets/airdef/items/launch_zircon.json
|
||||
6b6da5887aa8d9bc987b2c181c243bc2afdd5846a869818f699b59204e559929 assets/airdef/items/mover.json
|
||||
177f7535e4c52ed975d6f737c2b2acb7741b7a928955c8899aced85211443bbf assets/airdef/items/remover.json
|
||||
9c54b89d2840841494bdfb2161c038385b23e41a42a87a24e95d485a1a541a82 assets/airdef/lang/en_us.json
|
||||
9c54b89d2840841494bdfb2161c038385b23e41a42a87a24e95d485a1a541a82 assets/airdef/lang/ru_ru.json
|
||||
b9b5b5bec33a77e944552c225ee2f526ab9820fa8fca4b3ccf311f2a325925ee assets/airdef/models/block/amraam_missile.json
|
||||
c54e6b24ab69e9d9a2dbbbc63fe2ac60fa37735bf644500ddd5c3de0b91908cf assets/airdef/models/block/barge.json
|
||||
a4198ff647de5866919f9b82a3d53e6486fc56cc9f175f7907951d063a6f4526 assets/airdef/models/block/beam.json
|
||||
050bc585d82f48b39fee175ba795fafb642fc2658c932901549d8907e5d63401 assets/airdef/models/block/buk_chassis.json
|
||||
384ef97ea938470c82e68ab9659b9cb67cb69494fe3b9eb14357107bc6ad416b assets/airdef/models/block/buk_chassis_burnt.json
|
||||
e2b031f4edbfd8395ff04311bca5bb3c4a2fd5cd7022d1070c8c7f67a6aa7177 assets/airdef/models/block/buk_rails.json
|
||||
a76b58dd0c282353b9101beb48774d5619369303e0665fc821458a47cd3d0402 assets/airdef/models/block/buk_rails_burnt.json
|
||||
bdbb639071f3ff18fd624f3179aeb5dcd1216828b599e976617c13e5c77d115b assets/airdef/models/block/buk_turret.json
|
||||
7f1248fe849972d51a37c4162d92991b5567487b5415e2e9ea2cf43644bb500b assets/airdef/models/block/buk_turret_burnt.json
|
||||
684edfac71d15f328b92aee2f2cc508532f6654d5a664ac78c13b6868c3307ba assets/airdef/models/block/debris.json
|
||||
aef93931af7ed7bf71eca89070adaf52af9e0d8894d3d4e36c926b219e196e02 assets/airdef/models/block/depot.json
|
||||
107aec61d1dcbbfc6ec9203cf8590c23cde3cb22e8debc121b6ea30d675e6401 assets/airdef/models/block/depot_burnt.json
|
||||
89ea90f53a06814d71cec4d8e89a43d7dbbc4536a8104d099b743332cabafedd assets/airdef/models/block/ew_truck.json
|
||||
b7cd8f04aaf8a6c5b7021a59dc7f6c60e29b1159237ba666d7eeefb91254f348 assets/airdef/models/block/ew_truck_burnt.json
|
||||
c00df220e46a265c5a33e68df1cf407dc1fd25bb70978b6b8d850d7826044f3c assets/airdef/models/block/fireball.json
|
||||
fd5ca8c85d054580e6f95cb88bfed6216c9b41ddab9efec2eb4a642ad408c17c assets/airdef/models/block/flame.json
|
||||
3962ad6a9bfd88ed4638dd72d27ddbd0933583e7f0d40b808ddabfd6e3a35399 assets/airdef/models/block/flare.json
|
||||
6bf4a388b9a38a5359053be38cf09f1c86d0ea47d61e5de0016b2b1c7f7dbb4a assets/airdef/models/block/flash.json
|
||||
9fa54aaabfc0dd1b6af4fdd1fd4ac9a4248c4837801a7d74e441627f565a18fa assets/airdef/models/block/gepard_dish.json
|
||||
993b426346250e248abea70a461a7e9343d264585997adee252d8f803d635acd assets/airdef/models/block/gepard_guns.json
|
||||
9f5b572110c02fbae42a1aff8db716094d198b209d19dfc2e6a72430378fc179 assets/airdef/models/block/gepard_guns_burnt.json
|
||||
b1ee075e7ec6c4d044ae45ae488995371e6128fa5d38bdc6babdbae9f746a752 assets/airdef/models/block/gepard_hull.json
|
||||
37179a4c80b8e440c9be9e94e28f3d4852af77831aca0e1d17f6db22dec43905 assets/airdef/models/block/gepard_hull_burnt.json
|
||||
d2da35d3023db04251a73030f7baca7f448b2a341315c1a3d9a7d9ec8dfb5c6d assets/airdef/models/block/gepard_turret.json
|
||||
0d2f0217c9e9e9d0305c990576f86ac5665738db5eead729750836e9e371aa85 assets/airdef/models/block/gepard_turret_burnt.json
|
||||
d43f9cda780b1821a6e778555a1be5bd112a1d9655ff96d35acebec61cf11e0b assets/airdef/models/block/geran3.json
|
||||
83cf0a42e59f6aee1039925f849398960334f2545558409e7ccd7173ac841d73 assets/airdef/models/block/geran3_flame.json
|
||||
ac93e872743844465f0688162dddd7433352e8710612dd391a1e92b7f36e6b0d assets/airdef/models/block/gerbera.json
|
||||
8c273c2e02dd1884012f5597a6ad2022a0cfcf56c9c5b23043729d3c34635783 assets/airdef/models/block/irist_chassis.json
|
||||
417c68e386d715da987c2d2e9fe86d25dcf0d923546b602d5f01c1eba1d25543 assets/airdef/models/block/irist_chassis_burnt.json
|
||||
db7b914b2d027b8ebde485b940951244e4bc4cb614eb2eefc49ccf0b26c98bdd assets/airdef/models/block/irist_missile.json
|
||||
89453602195bc437ecb70885ad4475bc04ee300eff377682321bc3cd1113e9d7 assets/airdef/models/block/irist_tubes.json
|
||||
c8cb7d80202b72070e955015d4abeffb33586c9fa94a3ca29311ae68cfd7ca9a assets/airdef/models/block/irist_tubes_burnt.json
|
||||
be87037b84cd45b2c53d7fde6653f51769e782eea1b8586383afcfababf19ab6 assets/airdef/models/block/iskander.json
|
||||
98d488ca797fb3d0193957b8a93a82f48376a89f8e091032e6365d1845016a90 assets/airdef/models/block/kalibr.json
|
||||
be9eb1389e169a76732f16e604499260b147b524b4c929d2a4e77b580a032fb7 assets/airdef/models/block/kh101.json
|
||||
ea7c9af888f1285502b2ca51114f226573311be6fb90b8d449b9f75cfbb6b885 assets/airdef/models/block/kh22.json
|
||||
7b73015e33d85d4cef31660ef874ba8dcd6e07ae3a95416d0ead1d325bd0cb6c assets/airdef/models/block/kinzhal.json
|
||||
911e55de28058e1723a61d15de80676789e57ab15bfc09fd75757cc85095fbcb assets/airdef/models/block/lancet.json
|
||||
15c9884ce51311cf4b9b9d106e142e33d72c5ba18dc9236c5b51da01232f8e44 assets/airdef/models/block/launch_ramp.json
|
||||
159fa5e3b6a096a1872dec2a550bfa30575d57519654a860607e20dab8f35f53 assets/airdef/models/block/launcher_truck.json
|
||||
2069198ba24a932816f504fb52f53dc4bc740cacaf45637698a17d9175da851c assets/airdef/models/block/m48n6.json
|
||||
61968f4d63adb6dfebd5770ce5225f4cf5610a7d7ef863c4665875e82abb4f25 assets/airdef/models/block/m57e6.json
|
||||
238ed59a5dfa261272c0a4dabbda3ee62d2c1c7b9829cced644bf8b2322d4bfc assets/airdef/models/block/m77n6.json
|
||||
e8786fdbf6feb21f4819015c7faaf87983f4a7ed88c6f7917bd49d1b14eb9140 assets/airdef/models/block/nasams_launcher.json
|
||||
574e069129ff20e6137b469740cb279e16e70beeafd1e933c22cd7dca583d74d assets/airdef/models/block/nasams_launcher_burnt.json
|
||||
56a0a41e54b5056689525909179651dd5ec0fe551c06bd2bd2b1edb63c369aec assets/airdef/models/block/nasams_trailer.json
|
||||
79b26bc489f644afbff7a9f616481b81034fb13a0590e88ca1753601eca4f3ea assets/airdef/models/block/nasams_trailer_burnt.json
|
||||
ce9f0dc61bd07cfcb3be5cadf12df0d2ef1b3167aa2260bc4b42414dc3825b58 assets/airdef/models/block/p1sun.json
|
||||
b5346ab109ffb8c259592574b091a47bd396de34b0fe96e684b672316cee6b86 assets/airdef/models/block/p1sun_launcher.json
|
||||
4457a527977ad5c7d381991ca1c9d304cac0b7074f632a04328e836bfd83f784 assets/airdef/models/block/p1sun_launcher_burnt.json
|
||||
2e11e64942baaf057ccc60f42dc629f7519eb3892198c1906c22fcfa95584e7b assets/airdef/models/block/pac3.json
|
||||
ba90d89595c3c5d6d5a30f1041540f50504676bc64df5cf34038f8682307bd3e assets/airdef/models/block/pantsir_dish.json
|
||||
622c6f537f6adb99b1a536e38eb0a5d30c05c62f671997365ff0b2e9fa9e6562 assets/airdef/models/block/pantsir_pack.json
|
||||
5413c0a546ee6b82dcf3e782d6cdab4e7080642b71bbb08a4b800a9105f39216 assets/airdef/models/block/pantsir_pack_burnt.json
|
||||
52aacf44022a6826bd88fb161bce81966033de89f67b9d505c1b649bcf294eb0 assets/airdef/models/block/pantsir_truck.json
|
||||
53e0a5c2bec25e3a52eb52bb098c9aa186f737fff7d6c5b2ccf927c313416e1e assets/airdef/models/block/pantsir_truck_burnt.json
|
||||
84857ebb50b8e98796e3907d8ce4eeb8427c29de9f81aec7a8bd8d9ba4ca516e assets/airdef/models/block/pantsir_turret.json
|
||||
fc3555a87f290805ad723607f034d90645799cd8d9ef3ba42fedee2a50248059 assets/airdef/models/block/pantsir_turret_burnt.json
|
||||
33884253bc3ab463d15a7fe952187b1f9fb3b78632e825e1fabc85ca5335b543 assets/airdef/models/block/patriot_launcher.json
|
||||
3fed073655020b72dd515dca7eb362f642af50251b473012429a5ca946426f8d assets/airdef/models/block/patriot_launcher_burnt.json
|
||||
2a8ca10c933e236270810ce9de40c83dfd8016b0f0d32413433e3a5f8622329f assets/airdef/models/block/patriot_radar.json
|
||||
eb9a8af98374220657fa722a281bc18f6d884d51c5869975d43eeabcb171677b assets/airdef/models/block/patriot_trailer.json
|
||||
428fbe50bea9dbca55bc4933b15ccecf57164dc915e661ec9ae610151810a50a assets/airdef/models/block/patriot_trailer_burnt.json
|
||||
4c3dcfe38527de677cc1d56f6fdf17980604b93ce24f4337b3f825a2f446620b assets/airdef/models/block/patriot_truck.json
|
||||
e5733ece9b976998c9c6a6c968b17cada868b62d9e2a7bc67e1272e333e35399 assets/airdef/models/block/radar_panel.json
|
||||
b0ae344fbad3b982e7821cd1b26f9922e2a5713b38107521ddc5a5b2abd9e39c assets/airdef/models/block/radar_trailer.json
|
||||
088f42bb17f4d6099c16adf6cc0426b6d04ff9a43abdf125476a3571e924fcbd assets/airdef/models/block/radar_truck.json
|
||||
4cd60dfb1e598efbd127894b0ad1b1737569dfc0fc5c9b193034f9125daa9c15 assets/airdef/models/block/radar_truck_burnt.json
|
||||
f102765390762d45954b26405b6acdde845df7f0a319bac53d25508e768957b5 assets/airdef/models/block/reentry.json
|
||||
87085a7ac475dec2abcd5b1ff6443e2847614726219ca522b199bc70a5c10f2e assets/airdef/models/block/s400_chassis.json
|
||||
f10710d0387edc746380287edbb987341cb88c95d974f89a48b19543cef737dc assets/airdef/models/block/s400_chassis_burnt.json
|
||||
7b2cac0485b4242534e99bbfc0406ee393d508ca971d4d88caf3f13892b473c1 assets/airdef/models/block/s400_tubes.json
|
||||
973e02b2058c0b3d59c156f2ac94fbba4ac90a97736e8a4cc9be177b5e0f19a9 assets/airdef/models/block/s400_tubes_burnt.json
|
||||
088f42bb17f4d6099c16adf6cc0426b6d04ff9a43abdf125476a3571e924fcbd assets/airdef/models/block/s500_chassis.json
|
||||
3e35ed19ea22c8309ac7c0ccc9c12e31b2387de97c6b72ba519bae34f681c58c assets/airdef/models/block/s500_chassis_burnt.json
|
||||
6ce00881e2a5107874e82e94a243fcd95c3eb6e9a24e8839c11227c8e330485f assets/airdef/models/block/s500_tubes.json
|
||||
88109407ec749d6f45a4a38a9a43fd1594ac6190d7f08433b07da572c040458d assets/airdef/models/block/s500_tubes_burnt.json
|
||||
536928e90a907c50b078a488bad49061f79aafe12479f58a2b2ce79aaad5adda assets/airdef/models/block/searchlight.json
|
||||
0e3cbae5029377886325aedc43705d9975cb1dc889a37613b92a97bdf36b4db7 assets/airdef/models/block/searchlight_burnt.json
|
||||
2d790e8845598e8cf7ae577492632ef52e075d590011e66fa8ab686096cda313 assets/airdef/models/block/searchlight_head.json
|
||||
f0f9ec6cefc0750e4d6cb330c21df8c2bcf02b1b7408f90f40ebb35a572a13cb assets/airdef/models/block/searchlight_head_burnt.json
|
||||
0d9aa1bc000619e0151c2263e847c81967ab1b7662464525cd42118f5d1d82f4 assets/airdef/models/block/shahed.json
|
||||
d5b9ed76b1744d0c93a809b6a4c16bc3dfa7ff4784e3cb9968aa36b12fc30484 assets/airdef/models/block/shahed_prop.json
|
||||
465e6aa2a8ac3c563b1e546fc844a0520fc89f3ce528d49f193aa6c21e19308f assets/airdef/models/block/target.json
|
||||
69c5c103c228abe6162f2e1252139689b768ff8dd3f835f8f79ce7d324c3f124 assets/airdef/models/block/tor_chassis.json
|
||||
81e66314bfcd4786950ab4c23c6ede79ff9b30687b44f23e2b7b9be233fe380f assets/airdef/models/block/tor_chassis_burnt.json
|
||||
b2d2f856a4004853cb799785c0a586d605c623759d5a099dc70e19ba6a67b100 assets/airdef/models/block/tor_turret.json
|
||||
e95be4a89de1384038df47861705b934b0091f61f7b135c9ea6933fe2197f31f assets/airdef/models/block/tor_turret_burnt.json
|
||||
b2380510f56dc60e914919cb6e20b82e3613a9d62b08a1c81740f960569c3425 assets/airdef/models/block/tracer.json
|
||||
447d237b290255f01c7ce51047df3de1b9261cb75cfeb83ab190f6abe914747d assets/airdef/models/block/tzm_truck.json
|
||||
1954ece9e339d89a6ce63b78d255637011b3661572fdfe051ea4814a891746ce assets/airdef/models/block/tzm_truck_burnt.json
|
||||
b85d09a73a1c251bbc76945aa8f99b5e7e606ed41e1d120f811a435f441b1e96 assets/airdef/models/block/zircon.json
|
||||
8360c341dbe0aac6c485bf0d2c9ace49378173f1749f5b52793a79b98697685b assets/airdef/models/item/cam_geran3.json
|
||||
5b35d42715fa9c4afe8d0bccf5060380a8b5216edc9509ba0d859e8e953232d7 assets/airdef/models/item/cam_gerbera.json
|
||||
f06af8a128e76975bdf3178e7db1453d01a888f06b2b5e9f997fbc43e0b1266a assets/airdef/models/item/cam_iskander.json
|
||||
300ef4f62f89aff9b59567da8ea32749abec2966c77041846835953b2dca0d0e assets/airdef/models/item/cam_kalibr.json
|
||||
8e7b91623d1d3e72dab4e701b506eb1de6c87ab774d3f6e6ed9ab76a4d82270b assets/airdef/models/item/cam_kh101.json
|
||||
5ea688448ece076431da2d4539806211825c2a63b816d00416f946351b92f509 assets/airdef/models/item/cam_kh22.json
|
||||
c6977e576991ba245796d82caa87a0ae87105bae7067ae2bf33d933779bfcaa5 assets/airdef/models/item/cam_kinzhal.json
|
||||
56400ae5307d0f02273ebf919f12f7263e5fe410a3e1833b83a5f19d32ddb9d5 assets/airdef/models/item/cam_lancet.json
|
||||
ee660fe4736f801646f944d54144f72a777048c269d828d1b71239c8732b0730 assets/airdef/models/item/cam_reentry.json
|
||||
99637f9ce3aa4ba3517b682890bbf7e35835145df666a9f74f53302684ecd1ba assets/airdef/models/item/cam_shahed.json
|
||||
182acfb9fb1d8f42741378a0bf17484c89a757118ffd7bd3bdd9bda2941906b9 assets/airdef/models/item/cam_zircon.json
|
||||
c6cba2497f834e0a0e0dbc7604afeb1f1106e0c64e2a1b497a66e932db0ce073 assets/airdef/models/item/deploy_buk.json
|
||||
43ad086ad7cff44263c30b2404bb6266834f36310ed044e661537bf665f12150 assets/airdef/models/item/deploy_depot.json
|
||||
5047028c52687c2c789be9d339f97d520619e595ea7a33b589ea6ef45d41f067 assets/airdef/models/item/deploy_ew.json
|
||||
a5d0450da8d6757b9b45f86e6b36977894dd9e3e1278c3668b99a8acab36f399 assets/airdef/models/item/deploy_gepard.json
|
||||
e80ee81085241b9712e024bbef73ef744ef5493eebb88770f4912d8aae138fe6 assets/airdef/models/item/deploy_irist.json
|
||||
637b9bfe426ee50045f8fcbfd4f25dfbc1d819ce36dedbd60abdac63c274f088 assets/airdef/models/item/deploy_light.json
|
||||
3398844e90203f97ee73e35619684c775d1856c8ca3399b5ed682786170d9327 assets/airdef/models/item/deploy_nasams.json
|
||||
76019c05d070cf1141cdf95b744b3d6198ab99469dba1f88a6903de1de303bde assets/airdef/models/item/deploy_p1sun.json
|
||||
8b1af688bc83be5a8065673bca7054deee86ca425f0bfd1fb4ffb491844e90bf assets/airdef/models/item/deploy_pantsir.json
|
||||
d0091d809816350c648e532a90ae59a3c5c9b94f837b2a46b5695e7f985a00f9 assets/airdef/models/item/deploy_patriot.json
|
||||
332f9de8c88658a562748fc7a6de7ec37847273ac0cd0733e23c0dff4b44418c assets/airdef/models/item/deploy_radar.json
|
||||
9ee1dfa7d2c2587c85a8f73554962a02a06f1969a9a56c56110162dd93db7301 assets/airdef/models/item/deploy_s400.json
|
||||
55f1dae5cd7f0126533825c9da3ed3ee316e74d4be8f9bb217a3ebc6f827d24d assets/airdef/models/item/deploy_s500.json
|
||||
aca5ea765ca0d84ed12444bf433c024b57d6ea9b9b7cf06449dfbd6892a66ae6 assets/airdef/models/item/deploy_tor.json
|
||||
67912cc711c2f1514e6e2f8f17aa340fa9a99534fbbaeb2b8e319aa6ef80f38d assets/airdef/models/item/deploy_tzm.json
|
||||
d0976d990130c6398f4adf5d3086e9cf50e5a2adbec081e4682e810af368c332 assets/airdef/models/item/designator.json
|
||||
b20ec2241060123a208ef66e86183261a7514611206b1b4389d2ababf40b6ca8 assets/airdef/models/item/flare_gun.json
|
||||
4fc1487d0ea8634bd164c01b54833d243933fd4dd8e40029d3c662f6c0afe9d8 assets/airdef/models/item/launch_geran3.json
|
||||
a5685a17b3169165faa53b27357933388fcc46ce55ae73049360ca0deee58c64 assets/airdef/models/item/launch_iskander.json
|
||||
ea86f852034e540430bd7c624fec49072eb775fee4263e48f22e722387393fd3 assets/airdef/models/item/launch_kalibr.json
|
||||
8954e2d7de8f39b2702e5aec20b10f39cfc4911acb4f7bb438fee76948040487 assets/airdef/models/item/launch_kh101.json
|
||||
6a27d903c35b802c6a755e4fb24af5bd38421b0dab9f6e39425cc7b5236a3d2b assets/airdef/models/item/launch_kh22.json
|
||||
148e92840c1884c4915cb14316f6018fbc96ad4cd701f3871407753e5bc4ecd9 assets/airdef/models/item/launch_kinzhal.json
|
||||
8a2a008a9b58913120acb044a72403679e57c1daa55e9e115676576e7f7ad217 assets/airdef/models/item/launch_lancet.json
|
||||
dc99bbddf69f5666530f35bd5d92b0e01999afaa69e007f00f03c06bcad8065f assets/airdef/models/item/launch_oreshnik.json
|
||||
f2fae6baddbb09d9c1889657a58bf9b31d012e357118108c3f8ff45120e31a2a assets/airdef/models/item/launch_shahed.json
|
||||
45f5442bc6b47c15955f2c080c28db7cccd7485c9fa70fc4f3e9ed976b74ff95 assets/airdef/models/item/launch_zircon.json
|
||||
0528d0a362eb44e43ef26771e2527ba14eb6f59bc7e71a6b7dd40a908e469b0c assets/airdef/models/item/mover.json
|
||||
0be54b1273d2a3ab75fd4c643004a753643a423db0ad099b80f4bff66a6b9b4c assets/airdef/models/item/remover.json
|
||||
b68f4a6564e4a76d66502c9f765d967d80b66f0f8672309dddee5b7928d2ebeb assets/airdef/textures/block/antenna.png
|
||||
8123e74fd56c6fa211b7490373625756e8792b3d17bb050d0a8ed81689bb2ad3 assets/airdef/textures/block/bare_antenna.png
|
||||
09a2dd50acbaa8bcd08c9063730898e9601c74661446279c3c2cc10a373a1f1c assets/airdef/textures/block/bare_antenna_b.png
|
||||
048e8d01ddffd59665e07c1954a6e2d725089dd9ac84933ecf85f093d048751d assets/airdef/textures/block/bare_barrel.png
|
||||
0decb34bef6baf602616899053ead3378dbe798282ab2f6c931f20c98aa67820 assets/airdef/textures/block/bare_barrel_b.png
|
||||
dcf8d38a0275fd73c1c1592384962fbe0f0327103414fc8a00c41e8758af113f assets/airdef/textures/block/bare_dish.png
|
||||
3b5cc50eaf6d3eaf6f6fcc7d7f28935980420fa2a5f8ad680a4790d09f58313f assets/airdef/textures/block/bare_lamp.png
|
||||
fcb6a151da7c25d755c012629ad5f8b55e2de951ce745c2d7b3b2f0d191babb1 assets/airdef/textures/block/bare_lamp_b.png
|
||||
de9acb4f73b59d80a4bcc6d0569dfb286d627991c40c1643d7c3c4535a02ac56 assets/airdef/textures/block/bare_nozzle.png
|
||||
b83bf9da366623e9060981ad77909398ecec55c2f0a7a0aefc941070db961c5b assets/airdef/textures/block/bare_nozzle_b.png
|
||||
070ce486efc729c756072e19e0f469763e1401289889c302800e45c68d1fb92a assets/airdef/textures/block/barrel.png
|
||||
b3dfaf452ffe4569477fa270e73d57e16eaed0e7639276336a0ffa4050b53507 assets/airdef/textures/block/beam.png
|
||||
510a01548a0dce9d3caf767f1a9f172045b253be4f3b3e98e367a281f550ec55 assets/airdef/textures/block/booster.png
|
||||
7de5699fd66a82395d03e389d2ba0b2aed87d7a52c4f7bcfbcf9a6fdb34ca301 assets/airdef/textures/block/booster_b.png
|
||||
2d9d72a90bee81630131ecf60f84b74691f6f16e8a7427fef62e2fa7923e5334 assets/airdef/textures/block/canister.png
|
||||
909b3acf5ac784c4917acba2e1e5c290d412c71fae5457e3916a770c9b20809a assets/airdef/textures/block/canister_b.png
|
||||
082e2d3fd7df0d548c294c410a6a7643b54d482d76643e0737bae1dcc54736fe assets/airdef/textures/block/canister_front.png
|
||||
53adaaade4d845d87ec3535adddfba8c0fc84ce373e9722650508ddc0fec7420 assets/airdef/textures/block/canister_front_b.png
|
||||
2248649b97f906d44208c5d83be7482867e1439d7bdab3e974b0b63af5224249 assets/airdef/textures/block/concrete.png
|
||||
e43d62b61bb7a5cf7973be9bbe197218c63924c87274852a46c1deb7713c5f30 assets/airdef/textures/block/concrete_b.png
|
||||
68a21931d31f90f74f1101047ba307b9587ef2cd13139b03fb13cd1119f5d551 assets/airdef/textures/block/crate.png
|
||||
5fbef49d433c12ff76842d66d8b6bcc9aaeab0e7d47305523f97d12842b2ff0c assets/airdef/textures/block/crate_b.png
|
||||
331cacfccc1c61b16a986b33e422d751e57cd8d07cb064a012f762105bfca93d assets/airdef/textures/block/dark_metal.png
|
||||
d262dfab6a1e4bde719f85493246c2ccecdd367a5240d8e7a25cf0eaef2bda7a assets/airdef/textures/block/dark_metal_b.png
|
||||
deee51e051cb1fdf7495a8dc1fa05bf9a166df9cb5e7e446bf3d29cea856efb3 assets/airdef/textures/block/dish.png
|
||||
698c9095df8f6b48c260759655797e67df35b390791ceba3e7ce2eb3cce3f8ab assets/airdef/textures/block/fire.png
|
||||
8532e81c8d5056db50100d963c84522205b6ee698081081a1888f1ee48b7bf08 assets/airdef/textures/block/flame.png
|
||||
b5b75b2380ed2a12a7ae1b0618efe17358e3a9ebcb9af5de46adf5195dbba271 assets/airdef/textures/block/flecktarn.png
|
||||
6be4508463644978a41aa426cf9fb547ba2c313e22140b6cb898dd1f54e7446e assets/airdef/textures/block/flecktarn_b.png
|
||||
b9d5beda0383b16f3f52bafad020768929f0910d0cfd5555b58d176c2bcbf3a7 assets/airdef/textures/block/flecktarn_s13.png
|
||||
52ca49f3c196de9b7216a1a40b359942a2da3204a39aa0716b085a67dfc073cf assets/airdef/textures/block/flecktarn_s13_b.png
|
||||
e6b307c552e008962695052a7136cc9037ca8c524a697d8450eb591cd7518e78 assets/airdef/textures/block/flecktarn_s21.png
|
||||
979c60d195732ac97352408a7e42aa645de153dbf1c55bbb3d72ccf65f8fe695 assets/airdef/textures/block/flecktarn_s21_b.png
|
||||
1aa7201611114554ce054a9d46a60da566f9c571f2a4ff4ebd4133258c0bbcfb assets/airdef/textures/block/flecktarn_s23.png
|
||||
7439316183817ce23322367cbd51c80602f0e1537977c78b410671dbbab166bd assets/airdef/textures/block/flecktarn_s23_b.png
|
||||
5517a43554b08fbbf5cccec8e537ecb23965e1472323e5ae4ad1420a12fcdd4a assets/airdef/textures/block/flecktarn_s31.png
|
||||
5c44f0f17d55077549982690bab313711543fd706ee944207759262c76e00cb8 assets/airdef/textures/block/flecktarn_s31_b.png
|
||||
007b3b806bc431be1c84dfca31f2f81fb4c2f9d5a522e40ce0d03f5d3716b106 assets/airdef/textures/block/foam.png
|
||||
7f8f88fff7d9f4b872ab7bbdc3e976e782730d91355941c7837ef2f7685730f4 assets/airdef/textures/block/geran.png
|
||||
014374b3428ffe8c438c0df2806c3edd9215c707ec3fd4e18edefd304b9d49cb assets/airdef/textures/block/geran_engine.png
|
||||
d44f6059ac51c7d707dcb8152036f87fe83af63cdece0c06f88370b5db56a5e0 assets/airdef/textures/block/glass.png
|
||||
5f733a261a5e8c8eb6a7837ab1e6e28d058410d7cca16e124d7b315f032c3ebc assets/airdef/textures/block/glass_cab.png
|
||||
b1a6096232481d08c710ff4133547badd1e0061676d6fc4f8e110e691c5e2e0e assets/airdef/textures/block/glass_cab_b.png
|
||||
3c836747774bc6c5f037eb5f6f581e9b9913c365747251f702164690ec3241e7 assets/airdef/textures/block/glow_ember.png
|
||||
8f2a9c7485d8b56c7bcf26ee3823f9efdea7ffdb5e3d770f991228cf883eab30 assets/airdef/textures/block/hub.png
|
||||
0b9e2514e1ff4832ade4ce231e4f1fda0ad50c16ebe7ae726ad749e454e07e1c assets/airdef/textures/block/hub_b.png
|
||||
216ec5f36c0ff06a55fef95691190eedb0d3ca7af5c42b97c7b901eed91fd1e8 assets/airdef/textures/block/intake.png
|
||||
d76e4cecd7bedde37dd5d7f84fa2ff6c2b690bcc6e3d9fe905589e24849c045a assets/airdef/textures/block/kh101.png
|
||||
3413594a1f8ef3e91fd85660114f81c36f3db54a03dc645d030b545d1ba16e4e assets/airdef/textures/block/kh101_belly.png
|
||||
b52ffbc21c7d5f7cb4d48b5b379e09e92656c5677b8aa66116483521fb3cb7e1 assets/airdef/textures/block/lamp.png
|
||||
d6f46d3018b98fd8d5f36df9ca11c07f77e5983e05db24bbc59e10916dd6efcd assets/airdef/textures/block/lamp_b.png
|
||||
e25bd88852f4a50609487eea13bbf58f397c54926f0bc9d02e9d596b17e058e1 assets/airdef/textures/block/lancet.png
|
||||
d76ebbd51a689233c256776b2c55893268f40567b2c059c9805e3cfc323307ec assets/airdef/textures/block/metal.png
|
||||
b8f411252cbce0a9e08cccfb4788aad721f6d7aa76c05a40a1c25757c27404d8 assets/airdef/textures/block/metal_b.png
|
||||
ca2f6efebc39b27cc2a3f974b3ea6b4d9f64929a8355ce4ec1d96ce44fa3dca2 assets/airdef/textures/block/missile.png
|
||||
898c77bf0dca8c5242468969ad9ae96d13a36d0cfe2c12798f9f51804244a840 assets/airdef/textures/block/missile_grey.png
|
||||
bf63b80d2b4e9c2f229fccf4e1162dafe738e5522c4784d5262f89afb3eab2cb assets/airdef/textures/block/missile_ru.png
|
||||
b3c7d5fd6518311f7d22f5b98c9edf230814716f5ec33e5ef84747f49cc7a639 assets/airdef/textures/block/missile_ru_b.png
|
||||
22730d3a16bf4793e7a2b0cedde24fa015312f6cd91d00d6cd7767faf82f6a06 assets/airdef/textures/block/mk_de.png
|
||||
9089911e06b239c2f782268c4d637a96e75e0a1eb48a1228f09201245ccc7c9c assets/airdef/textures/block/mk_de_b.png
|
||||
b8c28ed48383b17725d1d4229e52db9a153bbbcce114e6cfabe6ac86dca86f18 assets/airdef/textures/block/mk_ru.png
|
||||
7cc8d37e381e965b44cbb53e82626a2d52692a3085ea142c0ec9faa77cf99690 assets/airdef/textures/block/mk_ru2.png
|
||||
812fee3fc8c346e8eeed2ad30e1caab80c0f6bcb5e94a33ee6d47a6732cb4ddb assets/airdef/textures/block/mk_ru2_b.png
|
||||
e6a89c73305fc2429df0a7a3fab1b6e6c2d1eb2de48251f1d556dc9a8476a14f assets/airdef/textures/block/mk_ru_b.png
|
||||
a9de0c4e228fd2adaa996d0ca6123b6d8195fc5c1719201ae741c4979882f1d5 assets/airdef/textures/block/mk_star.png
|
||||
0b2017578093f28b49994c7d120fa19ec4fa07d137f5b8d30c58326aad00164c assets/airdef/textures/block/mk_star_b.png
|
||||
8526c1439d9723d1592c3c7c06da8bb8ac2f44cbd5310aaa689019e583a1cc19 assets/airdef/textures/block/mk_us.png
|
||||
65c308e09a0ba82cdffb87d334ff5bb517a27c2d60d6244cfd53cd9bff1c5080 assets/airdef/textures/block/nato_green.png
|
||||
5bf07917f3ac31f74ccffd1ae381e8d62f58fd4748bce7b16bfb135850c9bd74 assets/airdef/textures/block/nato_green_b.png
|
||||
66eb485456876d3aea75cd5e3afb676998d3315056041ee04220b7708ced7856 assets/airdef/textures/block/nato_green_s21.png
|
||||
76174f752b5e96040e0edb0454b4fcd354182d95786033e396e2bab29e57f2e1 assets/airdef/textures/block/nato_green_s21_b.png
|
||||
09af19d2003a7ef61c83cb4d4ce4ad544ca760d98c2cb60a881ee9039cf39d65 assets/airdef/textures/block/nato_green_s22.png
|
||||
6559a12b24829a933b05b21a4bb673878e53bdfa5d7f87a8810c6e9e27ea3d00 assets/airdef/textures/block/nato_green_s22_b.png
|
||||
28737c6592a187f4b542c18084dfa26ef5e2a5ef0424b94fa5fc1db06825f0e8 assets/airdef/textures/block/nato_green_s23.png
|
||||
d5aa425480264085dd0a5654e97be78620a28b0adb2e17ad952d6faadcf5a168 assets/airdef/textures/block/nato_green_s23_b.png
|
||||
491f3e54e771764a9a3a345a577838bb5c2d4bdf80a827d05ff6e8d98f229551 assets/airdef/textures/block/nato_green_s31.png
|
||||
dd8c9056df254fe788a6848c96af4e56c5951f08717b25ebaa8815d1fb823751 assets/airdef/textures/block/nato_green_s31_b.png
|
||||
311932fa43f0b513342e8f3746208bd845b936f883f6f5c8d453fd4ef6d315dc assets/airdef/textures/block/nato_tan.png
|
||||
6a1289cfba0b17732cedfadceb6522b0b9f847f754dd56975716b3e2e21e777a assets/airdef/textures/block/nose_dark.png
|
||||
a8c0d707e86dedb7591b7e89f07ffd2df85ab0763e903a4c4c9ea17c97c4baee assets/airdef/textures/block/nozzle.png
|
||||
3f908df37b1456884d840e346f2da60ccce5b61bd226317de9ca24430bd59a8c assets/airdef/textures/block/prop.png
|
||||
98442b32c81dd7523c8d38bc6ae9810d8e0295474c814533b7fbde33f4910e3b assets/airdef/textures/block/radar_big.png
|
||||
5dff7780ae2f934bc05bb58742f1965b7cf06ad28459d6dd63b574a0a327f949 assets/airdef/textures/block/radar_face.png
|
||||
83a012f282bf709a4628530632fac3e0e3227325e931d7774747d7b95401d3d3 assets/airdef/textures/block/radar_face_b.png
|
||||
144ce90863430c724243ba27bfb212ab1e4e5ff58650d0ec884b14d47232ddeb assets/airdef/textures/block/rm_dark.png
|
||||
46a86ef31a44a7672c9f5d4e8c0605b78964ccbe1131127dd94d9c4bb307695e assets/airdef/textures/block/rm_dark_t.png
|
||||
5e37e431975e5816388bf8906cd8d32e41b6ee44760f355983ca9c26cc004932 assets/airdef/textures/block/rm_grey.png
|
||||
a0d4a601d1d29b1988e73b74c1198c9b6fde7cbfccceb3057465b22124959fd2 assets/airdef/textures/block/rm_grey_t.png
|
||||
0d21b93c78581892e08f31ca8e4f01c9edf7793f61bca78c8ee72cb0bfa2e40f assets/airdef/textures/block/rm_khaki.png
|
||||
e832c1bbff632eac6c9b62be8d68981a62a7837499437c0b85f9fb51a4506550 assets/airdef/textures/block/rm_khaki_t.png
|
||||
4a8e048b9219e04b143da3ae9214f12fa96c68b4e33201b9ec248d65c9eb7f7f assets/airdef/textures/block/rm_pac3.png
|
||||
08c9ad4315458bc7c59632aba8bc65de051639b2039dc9d252b79917dce15f7a assets/airdef/textures/block/rm_pac3_t.png
|
||||
a4280a067f3c3068b3ba47dcf4881e091e70a269685e192e19dd025bf7532843 assets/airdef/textures/block/rm_ru.png
|
||||
7992de763ec57589788eedb01bfb656cec49e73d3dbc15b13aab8a65506c6f5b assets/airdef/textures/block/rm_ru_t.png
|
||||
c9abfcb99b86708b009270d96a563036c4a539c7f7cfa734c94a97c05b3f36ac assets/airdef/textures/block/rm_white.png
|
||||
f336ac70e704bbb2977ef36ce6c6ce853ad57e3970cc44ee16eabb9554485707 assets/airdef/textures/block/rm_white_t.png
|
||||
b92c1817d1b25d626b03998762d8ae29900f6ef41d883be35191877edd4bfd93 assets/airdef/textures/block/ru_green.png
|
||||
4c932c1c226af577ed1b77c6846d1f1ce95e5da053bda1723e7ddb3442d78959 assets/airdef/textures/block/ru_green_b.png
|
||||
c3cea9d7709650d88515a7fbfaeec719eb3395687d10cfd92ce374c8b1687e4d assets/airdef/textures/block/ru_green_s12.png
|
||||
b8cdde5132e534c46c7521a3612b490656221e7549045990edf881f9c2e5e388 assets/airdef/textures/block/ru_green_s12_b.png
|
||||
bc82211cc1a25e52672452dcd5cd533e818821c79b06a705402d2aff36d48286 assets/airdef/textures/block/ru_green_s13.png
|
||||
4ca0d50c73cbb661c6c86da9dc2add011da52de185f844dd7dfb515c26b9db72 assets/airdef/textures/block/ru_green_s13_b.png
|
||||
58729c9509463a4858dddd7fa0964de696e265f6c409a77fae732a73a177542b assets/airdef/textures/block/ru_green_s21.png
|
||||
167683d721a45aa4a104edeafdf231b0eecfc70442b59e190460009bee3b2e89 assets/airdef/textures/block/ru_green_s21_b.png
|
||||
7795c2ef19789d465b9b1420ca3aacf1201b0904414b7e39610172c84049c0c1 assets/airdef/textures/block/ru_green_s22.png
|
||||
5d92c96f896314e390711b66c07922c832a443c3c56e1daec2890195960de47a assets/airdef/textures/block/ru_green_s22_b.png
|
||||
1c53b3d9cecaa5ed932bf1d58a864e77481e515729c7a72c4032a734897e0b34 assets/airdef/textures/block/ru_green_s23.png
|
||||
c1424132a342f0245430fa165a1b2d18b6660580cf4ae100fcc19dd3feb2e20d assets/airdef/textures/block/ru_green_s23_b.png
|
||||
ba4511238d904460c91a55af88781560eac6272de937ed57d54714590f0a3907 assets/airdef/textures/block/ru_green_s31.png
|
||||
c7425dcb7916bb5ec48bfa57def2a8d6a44a88600fc2651392e9fae8b2fe4888 assets/airdef/textures/block/ru_green_s31_b.png
|
||||
934ea2bc2623e42310adc0dd67e01916cd21dd32dd691ed759bd681cac958525 assets/airdef/textures/block/ru_khaki.png
|
||||
abab312510b9d18ca5561c8424aa0ad33feab2575b8d5dfe42b0a6bf31430bd3 assets/airdef/textures/block/ru_khaki_b.png
|
||||
055fdbc8ed3b808e263a13f694cce5444c4fada440994cd443103d308d54fd20 assets/airdef/textures/block/ru_khaki_s13.png
|
||||
a53ae1e5fd32671e28d74a090ab3828e2dc34ef223b4c71a1b6f535c0e999a9e assets/airdef/textures/block/ru_khaki_s13_b.png
|
||||
8df45cca0a57f01efeb85da2c76544c2b103fc474387aa76215d093e998242d9 assets/airdef/textures/block/ru_khaki_s21.png
|
||||
06dc7f90bdf077097534322435be402f08e5ee9bc34135e410809a8892b940e8 assets/airdef/textures/block/ru_khaki_s21_b.png
|
||||
194d9a3bca192f65b4f2e808b21c28346dc85d96e923e4bebe2138bc5a0b4927 assets/airdef/textures/block/ru_khaki_s22.png
|
||||
5f8a6dfed6add932e9b4d0cee17adc4c811cba85433877fcbf0f7dfd9773cb1b assets/airdef/textures/block/ru_khaki_s22_b.png
|
||||
6d0aa0dcc1702486c764120f49fc3e2ae6f17c953b8c06f53b395a645463a666 assets/airdef/textures/block/ru_khaki_s23.png
|
||||
cea69d4094324363c2088e1f186927f8dabab4e7eb34a97add85587ea144fda4 assets/airdef/textures/block/ru_khaki_s23_b.png
|
||||
898405a1bb59a934a499409431003f3dc44a5f3f1874f41e28750f2c4331befc assets/airdef/textures/block/ru_khaki_s31.png
|
||||
dddcaf43fdf7f5d4e2433c72e5267548e3cb7d65c745082be0a60b14367810b0 assets/airdef/textures/block/ru_khaki_s31_b.png
|
||||
76b33dc7f36d1a67cb07f9e65b5dbda1e07ddbc41fbc75ad974654aa1ebacb57 assets/airdef/textures/block/ru_khaki_s33.png
|
||||
3e81c65d26070613c59fc6e363f0e0772c376bea5ab86c37b6cb19431a816535 assets/airdef/textures/block/shahed.png
|
||||
36e55b26a48838c8c25ec6d1660cfcdfcb1fc7e430dda0ac8908709c0c05f9b4 assets/airdef/textures/block/shahed_nose.png
|
||||
29a415d359ee6eb0b4b85a18edb38b77e852b5f6a441abbeb9485d1068726e35 assets/airdef/textures/block/target.png
|
||||
c047457ac99436c8a69bfc7fa755fa55e842ae3261890965df09a2011b8e6201 assets/airdef/textures/block/tire.png
|
||||
97bd7e7731bd1ad8e4eb582e9acd44981ac4fc47a51a1a5ec4e39d9873a42079 assets/airdef/textures/block/tire_b.png
|
||||
4edb1f39d7ffeb69257098023b6c3e4709014e5d54cd306ef0930e54257ee93a assets/airdef/textures/block/tracer.png
|
||||
564d4e443a0270a09cc2e7202ca73e40ffb00422c68a9842b19c10d4c2c184b9 assets/airdef/textures/block/tracer_hot.png
|
||||
e1da001ded920abd57814b7301d0388a04db72b0eeac51f73d67b6287d56ef43 assets/airdef/textures/block/track.png
|
||||
337e60bf5be059e10649e78da7fc98f1f12cc47ae8dddeb85f733535d3fa0c48 assets/airdef/textures/block/track_b.png
|
||||
68b9407648c541ea0a167e731340358b4ef45862be13ee5a582f7e088818cfaf assets/airdef/textures/block/track_side.png
|
||||
fa2848684a76002a17932aae6a0eead4af19ac594be39e1f7f995d2a239d6c6c assets/airdef/textures/block/track_side_s31.png
|
||||
02fa231c4ba6ba4d42c254fe815d1e0d74308a7f8fc1735cec5f955b494c9970 assets/airdef/textures/block/track_side_s31_b.png
|
||||
7a83f09a9c4feca1eb1dbde5abefa770b3623d5e491666d6835d2272d70d3709 assets/airdef/textures/block/tube.png
|
||||
137d90569624d7b164c16bf5d8dec2e9c4aed8096e3ec0d96f9e3661df90ee63 assets/airdef/textures/block/tube_b.png
|
||||
03570f9d5963c5fd61472d10cb68d56c26a7fd5806ccc86b86c5095476966b58 assets/airdef/textures/block/tube_cap.png
|
||||
e622dfd1caabbfde83081c89447fe49c13301f4edb92efe149402e110cbcb64e assets/airdef/textures/block/tube_cap_b.png
|
||||
bfd57114127057959dc3d46c60b1234e27dcdb35387a5e2b4f045ceb676ca09f assets/airdef/textures/block/tubes6.png
|
||||
4a229d23538c8f22c812633362f70ee4d887e515ef1d798fcd8a26c28f715696 assets/airdef/textures/block/tubes6_b.png
|
||||
92c449cdceb109949b31d49ff5627173cc0a33daf2c610748aef709623dcef23 assets/airdef/textures/block/white.png
|
||||
fb41e5b003f0c16308bc819fd632828d21fe1855ad9cd32283e02de3defb67fe assets/airdef/textures/item/deploy_buk.png
|
||||
0c06c682684abbf03e01d5ce7d8d2a4ece2ddc96e96bf87d7597bb0247ce3806 assets/airdef/textures/item/deploy_depot.png
|
||||
d0a6911668824195a4630a60f2b618958a134dada220a269a1c1c8faf2b77922 assets/airdef/textures/item/deploy_ew.png
|
||||
303c3352b21762b59eb23f2402dcb59f77983e5d2db08711414be99624695364 assets/airdef/textures/item/deploy_gepard.png
|
||||
a3dd2f7ad102f84be1df0182e22f2c2189bb872a8dcf3ddb7136ac05434c6abc assets/airdef/textures/item/deploy_irist.png
|
||||
805e883f86175f4f16ac8e43488f0db469f8c7d4bf0545c80439440517ea4685 assets/airdef/textures/item/deploy_light.png
|
||||
e7e303005314c70ec142e69ca6511d7dd1d6daba909563ecf6e3cbd6d146a9a8 assets/airdef/textures/item/deploy_nasams.png
|
||||
cfe4373e86a9e2f268e0623279da6498b4327afbbeec3b7cef0b1775f6007c73 assets/airdef/textures/item/deploy_p1sun.png
|
||||
e7522f1c583dae4cdf313a0ddbf22aae837dc34e5ec36a46daa5d7cb459d59fb assets/airdef/textures/item/deploy_pantsir.png
|
||||
2cffed28123c0e4eb828eb314e7ea65ced2576bb158913e0a837b96f0fb67730 assets/airdef/textures/item/deploy_patriot.png
|
||||
8b015f6480fbd7d9c1078efc73f3097fe32832fb5bbd6b8fe45307cd545a3026 assets/airdef/textures/item/deploy_radar.png
|
||||
37ad7777de7034487d3c53f5224eca34b5dac6de41aeb2080fdbd112ec7eae0e assets/airdef/textures/item/deploy_s400.png
|
||||
4cfb6250543f00b37fdb9e09e63c3107f7d88beeeaf72838150f9f301284cdd8 assets/airdef/textures/item/deploy_s500.png
|
||||
c473b97913fe7afab44d84768c80e11b752645b8bf9de9ffe5a026d3eb4d8e9c assets/airdef/textures/item/deploy_tor.png
|
||||
483c40bf24d5dae5ffad872c1b1df719cebcfb1f36c1153c2a5790981588d493 assets/airdef/textures/item/deploy_tzm.png
|
||||
3be70aa7d5210da09a910701605dcf8b2b4dbc5c43ef2d2c77ce36a7f2029012 assets/airdef/textures/item/designator.png
|
||||
f336d25be27818f3b0f4b2fc7c6f7b3e8be9050c9f9231f5703056a4bd8c1685 assets/airdef/textures/item/flare_gun.png
|
||||
51d28156b180efa780ad91dc7b5d0b5d89880ae3a35a5f228d3dc8ca1ec80938 assets/airdef/textures/item/launch_geran3.png
|
||||
f6165a2f251c61a6b89711e493da86ec0facb422f6b1e0364a8b7e707d641bf5 assets/airdef/textures/item/launch_iskander.png
|
||||
748f050d5229d70414e81ef204f66f075f659e78117c40818bc51cb728d73180 assets/airdef/textures/item/launch_kalibr.png
|
||||
925224a3deffa75f32207bd4324f8c06a6e1c08739126a96ab83b327902e55bf assets/airdef/textures/item/launch_kh101.png
|
||||
dc6e92e3386badb8b3b8fc17dffe93f19ae9a406e4e2275141d6313743d8ed4c assets/airdef/textures/item/launch_kh22.png
|
||||
0e81d738ddf1d7eb1db828f27e88e45066c413fd2ade293561d9c08965232908 assets/airdef/textures/item/launch_kinzhal.png
|
||||
41586acc732102fbc07a5183d91dd614a622aaecf3fed6de795e34e59af41fe6 assets/airdef/textures/item/launch_lancet.png
|
||||
f446b6d8b37f5be99390bd77e4e36752547085f004b98520359b3f3e80edfdea assets/airdef/textures/item/launch_oreshnik.png
|
||||
7e0643346b7ad04caa4f234c793dd671abdbb9dbc5138a3836d867aebec95a48 assets/airdef/textures/item/launch_shahed.png
|
||||
a1439f23a2d368f3d3ebd1b7d26d44af27c05797c3aad76a30878a79e225cce9 assets/airdef/textures/item/launch_zircon.png
|
||||
60332733e12c2c0d346db2f3b8108d0083167cfc75e8b1e0c76a52c495b95924 assets/airdef/textures/item/mover.png
|
||||
e43175307463d0946562f21d44ec5393c2605537820708dae3687065d3284aa1 assets/airdef/textures/item/remover.png
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/amraam_missile.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/barge.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/beam.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/buk_chassis.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/buk_chassis_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/buk_rails.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/buk_rails_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/buk_turret.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/buk_turret_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/debris.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/depot.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/depot_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/ew_truck.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/ew_truck_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/fireball.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/flame.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/flare.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/flash.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/gepard_dish.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/gepard_guns.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/gepard_guns_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/gepard_hull.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/gepard_hull_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/gepard_turret.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/gepard_turret_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/geran3.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/geran3_flame.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/gerbera.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/irist_chassis.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/irist_chassis_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/irist_missile.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/irist_tubes.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/irist_tubes_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/iskander.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/kalibr.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/kh101.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/kh22.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/kinzhal.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/lancet.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/launch_ramp.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/launcher_truck.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/m48n6.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/m57e6.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/m77n6.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/nasams_launcher.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/nasams_launcher_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/nasams_trailer.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/nasams_trailer_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/p1sun.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/p1sun_launcher.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/p1sun_launcher_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/pac3.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/pantsir_dish.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/pantsir_pack.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/pantsir_pack_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/pantsir_truck.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/pantsir_truck_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/pantsir_turret.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/pantsir_turret_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/patriot_launcher.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/patriot_launcher_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/patriot_radar.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/patriot_trailer.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/patriot_trailer_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/patriot_truck.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/radar_panel.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/radar_trailer.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/radar_truck.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/radar_truck_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/reentry.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/s400_chassis.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/s400_chassis_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/s400_tubes.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/s400_tubes_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/s500_chassis.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/s500_chassis_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/s500_tubes.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/s500_tubes_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/searchlight.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/searchlight_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/searchlight_head.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/searchlight_head_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/shahed.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/shahed_prop.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/target.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/tor_chassis.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/tor_chassis_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/tor_turret.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/tor_turret_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/tracer.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/tzm_truck.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/tzm_truck_burnt.json
|
||||
cc0877f40434365b45b03429222926aa0cf135e504017311be53263fd27c5f8f data/airdef/horizon/block/zircon.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_geran3.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_gerbera.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_iskander.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_kalibr.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_kh101.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_kh22.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_kinzhal.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_lancet.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_reentry.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_shahed.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/cam_zircon.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_buk.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_depot.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_ew.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_gepard.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_irist.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_light.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_nasams.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_p1sun.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_pantsir.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_patriot.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_radar.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_s400.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_s500.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_tor.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/deploy_tzm.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/designator.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/flare_gun.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/launch_geran3.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/launch_iskander.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/launch_kalibr.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/launch_kh101.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/launch_kh22.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/launch_kinzhal.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/launch_lancet.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/launch_oreshnik.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/launch_shahed.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/launch_zircon.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/mover.json
|
||||
2a3912a7c9d5bb8025b1ac16a1a1d6b5eff0360bb3184e810d319e498255bf97 data/airdef/horizon/item/remover.json
|
||||
8182bfca0dc64498eb620ffafe33c0e773d633f126f2194459a97f495ffe2ba1 src/sim/generated_bounds.rs
|
||||
@@ -0,0 +1,15 @@
|
||||
# Authored source assets
|
||||
|
||||
Place artist-authored overrides under `assets/airdef/` in this directory, preserving the runtime-relative path.
|
||||
For example, an authored icon at `source-assets/assets/airdef/textures/item/deploy_gepard.png` replaces the
|
||||
procedural icon at the generated runtime path while the source copy remains untouched. The asset generator
|
||||
copies this tree into its temporary staging tree, validates the merged runtime assets, then installs them using
|
||||
the generated manifest. Do not edit generated files under `airdef-mod/assets/` directly; an untracked or
|
||||
hand-edited output is treated as a conflict and left untouched.
|
||||
|
||||
This directory is intentionally kept separate from runtime and generated output. The initial art pilots are
|
||||
S-400 chassis/canisters, Gepard hull/turret and Shahed, including burnt variants for the ground vehicles.
|
||||
The JSON is editable directly. `python tools/pilot_models.py` is an optional authoring helper that overwrites
|
||||
only those named pilot JSONs; the normal regeneration never invokes it. After editing, run
|
||||
`python tools/gen_models.py` to validate and install the authored models. `generated_bounds.rs` is derived
|
||||
from the final staged geometry, including overrides and element rotation, for chassis navigation.
|
||||
@@ -0,0 +1,780 @@
|
||||
{
|
||||
"ambientocclusion": false,
|
||||
"textures": {
|
||||
"flecktarn_s21": "airdef:block/flecktarn_s21",
|
||||
"flecktarn": "airdef:block/flecktarn",
|
||||
"radar_face": "airdef:block/radar_face",
|
||||
"metal": "airdef:block/metal",
|
||||
"dark_metal": "airdef:block/dark_metal",
|
||||
"mk_de": "airdef:block/mk_de",
|
||||
"particle": "airdef:block/flecktarn_s21"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [
|
||||
-4.0,
|
||||
0.0,
|
||||
-5.0
|
||||
],
|
||||
"to": [
|
||||
20.0,
|
||||
5.0,
|
||||
16.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_s21"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_s21"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_s21"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_s21"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-2.5,
|
||||
5.0,
|
||||
-5.0
|
||||
],
|
||||
"to": [
|
||||
18.5,
|
||||
12.0,
|
||||
15.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-2.0,
|
||||
12.0,
|
||||
-2.0
|
||||
],
|
||||
"to": [
|
||||
18.0,
|
||||
13.0,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
3.0,
|
||||
4.0,
|
||||
-10.0
|
||||
],
|
||||
"to": [
|
||||
13.0,
|
||||
12.0,
|
||||
-6.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
10.0,
|
||||
8.0
|
||||
],
|
||||
"texture": "#radar_face"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
10.0,
|
||||
8.0
|
||||
],
|
||||
"texture": "#radar_face"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
4.0,
|
||||
8.0
|
||||
],
|
||||
"texture": "#radar_face"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
4.0,
|
||||
8.0
|
||||
],
|
||||
"texture": "#radar_face"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
10.0,
|
||||
4.0
|
||||
],
|
||||
"texture": "#radar_face"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
10.0,
|
||||
4.0
|
||||
],
|
||||
"texture": "#radar_face"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
7.0,
|
||||
13.0,
|
||||
10.0
|
||||
],
|
||||
"to": [
|
||||
9.0,
|
||||
18.0,
|
||||
12.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
2.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
2.0
|
||||
],
|
||||
"texture": "#metal"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-4.7,
|
||||
4.8,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
-2.5,
|
||||
10.7,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.2,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.2,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.2,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.2,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
}
|
||||
},
|
||||
"rotation": {
|
||||
"angle": 22.5,
|
||||
"axis": "z",
|
||||
"origin": [
|
||||
-3.6,
|
||||
7.75,
|
||||
5.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
18.5,
|
||||
4.8,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
20.7,
|
||||
10.7,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.1999999999999993,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.1999999999999993,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.1999999999999993,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.1999999999999993,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn"
|
||||
}
|
||||
},
|
||||
"rotation": {
|
||||
"angle": -22.5,
|
||||
"axis": "z",
|
||||
"origin": [
|
||||
19.6,
|
||||
7.75,
|
||||
5.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
0.0,
|
||||
13.05,
|
||||
2.0
|
||||
],
|
||||
"to": [
|
||||
5.0,
|
||||
13.7,
|
||||
8.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
10.0,
|
||||
13.05,
|
||||
2.0
|
||||
],
|
||||
"to": [
|
||||
15.0,
|
||||
13.7,
|
||||
8.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
18.5,
|
||||
6.0,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
18.619999999999997,
|
||||
9.0,
|
||||
2.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-2.6199999999999974,
|
||||
6.0,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
-2.5,
|
||||
9.0,
|
||||
2.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#mk_de"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,712 @@
|
||||
{
|
||||
"ambientocclusion": false,
|
||||
"textures": {
|
||||
"flecktarn_s21_b": "airdef:block/flecktarn_s21_b",
|
||||
"flecktarn_b": "airdef:block/flecktarn_b",
|
||||
"radar_face_b": "airdef:block/radar_face_b",
|
||||
"metal_b": "airdef:block/metal_b",
|
||||
"dark_metal_b": "airdef:block/dark_metal_b",
|
||||
"mk_de_b": "airdef:block/mk_de_b",
|
||||
"particle": "airdef:block/flecktarn_s21_b"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [
|
||||
-4.0,
|
||||
0.0,
|
||||
-5.0
|
||||
],
|
||||
"to": [
|
||||
20.0,
|
||||
5.0,
|
||||
16.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_s21_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_s21_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_s21_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_s21_b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-2.5,
|
||||
5.0,
|
||||
-5.0
|
||||
],
|
||||
"to": [
|
||||
18.5,
|
||||
12.0,
|
||||
15.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
7.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-2.0,
|
||||
12.0,
|
||||
-2.0
|
||||
],
|
||||
"to": [
|
||||
18.0,
|
||||
13.0,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
1.0
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
3.0,
|
||||
4.0,
|
||||
-10.0
|
||||
],
|
||||
"to": [
|
||||
13.0,
|
||||
12.0,
|
||||
-6.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
10.0,
|
||||
8.0
|
||||
],
|
||||
"texture": "#radar_face_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
10.0,
|
||||
8.0
|
||||
],
|
||||
"texture": "#radar_face_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
4.0,
|
||||
8.0
|
||||
],
|
||||
"texture": "#radar_face_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
4.0,
|
||||
8.0
|
||||
],
|
||||
"texture": "#radar_face_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
10.0,
|
||||
4.0
|
||||
],
|
||||
"texture": "#radar_face_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
10.0,
|
||||
4.0
|
||||
],
|
||||
"texture": "#radar_face_b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
7.0,
|
||||
13.0,
|
||||
10.0
|
||||
],
|
||||
"to": [
|
||||
9.0,
|
||||
18.0,
|
||||
12.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
5.0
|
||||
],
|
||||
"texture": "#metal_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
2.0
|
||||
],
|
||||
"texture": "#metal_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
2.0
|
||||
],
|
||||
"texture": "#metal_b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-4.7,
|
||||
4.8,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
-2.5,
|
||||
10.7,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.2,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.2,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.2,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.2,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
}
|
||||
},
|
||||
"rotation": {
|
||||
"angle": 22.5,
|
||||
"axis": "z",
|
||||
"origin": [
|
||||
-3.6,
|
||||
7.75,
|
||||
5.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
18.5,
|
||||
4.8,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
20.7,
|
||||
10.7,
|
||||
14.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.1999999999999993,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.1999999999999993,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
5.8999999999999995
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.1999999999999993,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
2.1999999999999993,
|
||||
16
|
||||
],
|
||||
"texture": "#flecktarn_b"
|
||||
}
|
||||
},
|
||||
"rotation": {
|
||||
"angle": -22.5,
|
||||
"axis": "z",
|
||||
"origin": [
|
||||
19.6,
|
||||
7.75,
|
||||
5.0
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
0.0,
|
||||
13.05,
|
||||
2.0
|
||||
],
|
||||
"to": [
|
||||
5.0,
|
||||
13.7,
|
||||
8.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
10.0,
|
||||
13.05,
|
||||
2.0
|
||||
],
|
||||
"to": [
|
||||
15.0,
|
||||
13.7,
|
||||
8.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
0.6499999999999986
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
5.0,
|
||||
6.0
|
||||
],
|
||||
"texture": "#dark_metal_b"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
-2.6199999999999974,
|
||||
6.0,
|
||||
-4.0
|
||||
],
|
||||
"to": [
|
||||
-2.5,
|
||||
9.0,
|
||||
2.0
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
},
|
||||
"south": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
},
|
||||
"east": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
},
|
||||
"west": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
3.0
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
},
|
||||
"up": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
},
|
||||
"down": {
|
||||
"uv": [
|
||||
0,
|
||||
0,
|
||||
0.25,
|
||||
6.0
|
||||
],
|
||||
"texture": "#mk_de_b"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -58,6 +58,8 @@ pub fn tree() -> Tree {
|
||||
]),
|
||||
Node::lit("why").runs().then(Node::arg("номер", Value::int_from(1)).runs()),
|
||||
Node::lit("raid").runs(),
|
||||
Node::lit("sites").runs(),
|
||||
Node::lit("strike").then(Node::arg("номер", Value::int_from(1)).runs()),
|
||||
Node::lit("repair").runs(),
|
||||
Node::lit("import").runs(),
|
||||
toggle("ew"),
|
||||
@@ -68,7 +70,7 @@ pub fn tree() -> Tree {
|
||||
Node::lit("deploy").then(Node::arg("комплекс", Value::choice(deploy_kinds)).runs()),
|
||||
Node::lit("wave").then(
|
||||
Node::arg("тип", Value::choice(wave_kinds)).runs().then(
|
||||
Node::arg("кол-во", Value::int(1, 80)).runs().then(Node::arg("дальность", Value::number(60.0, 800.0)).runs()),
|
||||
Node::arg("кол-во", Value::int(1, 80)).runs().then(Node::arg("дальность", Value::number(60.0, 4000.0)).runs()),
|
||||
),
|
||||
),
|
||||
Node::lit("clear").runs(),
|
||||
@@ -77,6 +79,7 @@ pub fn tree() -> Tree {
|
||||
toggle("truth"),
|
||||
Node::lit("shader").then(Node::arg("режим", Value::choice(["on", "off", "hd"])).runs()),
|
||||
toggle("hold"),
|
||||
toggle("lastchance"),
|
||||
Node::lit("roles").runs().then(
|
||||
Node::arg("комплекс", Value::choice(armed)).then(
|
||||
Node::arg(
|
||||
@@ -86,6 +89,16 @@ pub fn tree() -> Tree {
|
||||
.runs(),
|
||||
),
|
||||
),
|
||||
Node::lit("doctrine").runs().then(Node::arg("номер", Value::word()).with([
|
||||
Node::lit("reserve").then(Node::arg("K", Value::int(0, 64)).runs()),
|
||||
Node::lit("salvo").then(Node::arg("залп", Value::choice(["eco", "normal", "heavy"])).runs()),
|
||||
Node::lit("sector").with([
|
||||
Node::lit("off").runs(),
|
||||
Node::arg("центр°", Value::number(-720.0, 720.0)).then(Node::arg("полуширина°", Value::number(0.0, 180.0)).runs()),
|
||||
]),
|
||||
Node::lit("guard").with([Node::lit("off").runs(), Node::arg("объекты", Value::word()).runs()]),
|
||||
Node::lit("reset").runs(),
|
||||
])),
|
||||
Node::lit("stats").runs(),
|
||||
])
|
||||
}
|
||||
@@ -148,9 +161,9 @@ mod tests {
|
||||
"replay export mine all fps=30 size=1280x720 crf=18 sec=12.5 noaudio", "replay export fps=60", "replay stop",
|
||||
"scenario save a", "scenario save a fresh", "scenario load a", "scenario load a force", "scenario list",
|
||||
"scenario delete a", "why", "why 2", "ew on", "ew off", "move 4", "target here", "targets clear",
|
||||
"deploy patriot", "deploy light", "deploy s400", "wave mix", "wave shahed", "wave shahed 20", "wave kh101 80 800",
|
||||
"wave oreshnik 1 60", "damage on", "damage off", "truth on", "shader hd", "shader off", "shader on", "hold on",
|
||||
"roles all default", "roles patriot drone,jet", "roles pantsir all", "roles tor ballistic",
|
||||
"sites", "strike 3", "deploy patriot", "deploy light", "deploy s400", "wave mix", "wave shahed", "wave shahed 20", "wave kh101 80 800", "wave shahed 20 4000",
|
||||
"wave oreshnik 1 60", "damage on", "damage off", "truth on", "shader hd", "shader off", "shader on", "hold on", "lastchance on", "lastchance off",
|
||||
"roles all default", "doctrine", "doctrine 1 reserve 4", "doctrine all salvo eco", "doctrine 2 sector 90 45", "doctrine 2 sector off", "doctrine 1 guard 1,2", "doctrine 1 reset", "roles patriot drone,jet", "roles pantsir all", "roles tor ballistic",
|
||||
] {
|
||||
ok(line);
|
||||
}
|
||||
@@ -174,7 +187,7 @@ mod tests {
|
||||
assert_eq!(bad_at("wave shahed 0"), 12);
|
||||
assert_eq!(bad_at("wave shahed 81"), 12);
|
||||
assert_eq!(bad_at("wave shahed 5 59"), 14);
|
||||
assert_eq!(bad_at("wave shahed 5 801"), 14);
|
||||
assert_eq!(bad_at("wave shahed 5 4001"), 14);
|
||||
assert_eq!(bad_at("wave shahed x"), 12);
|
||||
assert_eq!(bad_at("wave scud"), 5);
|
||||
assert_eq!(bad_at("wave"), 4);
|
||||
@@ -186,6 +199,9 @@ mod tests {
|
||||
assert_eq!(bad_at("why x"), 4);
|
||||
assert_eq!(bad_at("move"), 4);
|
||||
assert_eq!(bad_at("move 0"), 5);
|
||||
assert_eq!(bad_at("strike"), 6);
|
||||
assert_eq!(bad_at("strike 0"), 7);
|
||||
assert_eq!(bad_at("sites 1"), 6);
|
||||
assert_eq!(bad_at("scenario"), 8);
|
||||
assert_eq!(bad_at("scenario load"), 13);
|
||||
assert_eq!(bad_at("scenario wipe"), 9);
|
||||
@@ -218,10 +234,10 @@ mod tests {
|
||||
fn completion_offers_the_next_word_only() {
|
||||
let top = complete("", &[]);
|
||||
for w in ["menu", "monitor", "grid", "replay", "scenario", "why", "raid", "repair", "import", "ew", "flare", "move",
|
||||
"target", "give", "deploy", "wave", "clear", "targets", "damage", "truth", "shader", "hold", "roles", "stats"] {
|
||||
"target", "give", "deploy", "wave", "clear", "targets", "damage", "truth", "shader", "hold", "lastchance", "roles", "doctrine", "stats", "sites", "strike"] {
|
||||
assert!(top.contains(&w.to_string()), "{w} in {top:?}");
|
||||
}
|
||||
assert_eq!(top.len(), 24);
|
||||
assert_eq!(top.len(), 28);
|
||||
assert_eq!(complete("rep", &[]), ["repair", "replay"]);
|
||||
assert_eq!(complete("replay ", &[]), ["export", "film", "full", "map", "reel", "stop"]);
|
||||
assert_eq!(complete("replay film ", &[]), ["all", "best"]);
|
||||
|
||||
@@ -22,20 +22,7 @@ const MAX: usize = 128;
|
||||
/// change what is heard, so it stays off; the game bounds it to 12% anyway.
|
||||
pub const DOPPLER: f32 = 0.0;
|
||||
|
||||
/// An engine that sounds this tick.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Decl {
|
||||
/// The entity: a drone's id, a missile's with a high bit, a replay track's with another.
|
||||
pub key: u32,
|
||||
pub event: &'static str,
|
||||
pub at: DVec3,
|
||||
/// Blocks a second.
|
||||
pub vel: DVec3,
|
||||
pub gain: f32,
|
||||
pub pitch: f32,
|
||||
/// Shot down: the engine dies away.
|
||||
pub damaged: bool,
|
||||
}
|
||||
pub use crate::sim::EngineDecl as Decl;
|
||||
|
||||
/// What a source is asked to be.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
//! raid, so the same film comes out every time. The land is asked for before the film starts (the
|
||||
//! planner needs the heights under every camera and along every line of sight); each shot has a
|
||||
//! few candidate placements, and the one the land hides least is kept; the camera is lifted over
|
||||
//! the ground wherever it would dip into it. Only what the recording knows is shown: a launch is
|
||||
//! the interceptor's first point, a kill the recorded event; no lock-on or detection is invented.
|
||||
//! the ground wherever it would dip into it. Only what the recording knows is shown: launches use the recorded transition where available (older tracks use their first point);
|
||||
//! no lock-on or detection is invented.
|
||||
use crate::replay::{interest, title};
|
||||
use crate::sim::record::{EventKind, Recording, STEP};
|
||||
use crate::sim::Ground;
|
||||
@@ -309,7 +309,8 @@ fn plan_event(rec: &Recording, i: usize, floor: f64) -> Vec<Shot> {
|
||||
};
|
||||
match e.kind {
|
||||
EventKind::Kill { drone, kind, sam, sam_kind, sam_index, missile, outcome } => {
|
||||
let sp = rec.sam(sam).map_or(pos - DVec3::new(150.0, 0.0, 0.0), |s| s.1);
|
||||
let launch_tick = missile.and_then(|m| rec.missile_launch(m).map(|e| e.at as f64)).unwrap_or(te);
|
||||
let sp = rec.sam_at(sam, launch_tick).map_or(pos - DVec3::new(150.0, 0.0, 0.0), |s| s.1);
|
||||
let name = format!("{} №{}", sam_kind.name(), sam_index + 1);
|
||||
let how = match outcome {
|
||||
crate::sim::outcome::Outcome::DisabledFalling => "",
|
||||
@@ -317,7 +318,7 @@ fn plan_event(rec: &Recording, i: usize, floor: f64) -> Vec<Shot> {
|
||||
crate::sim::outcome::Outcome::AirDetonation => ": детонация в воздухе",
|
||||
};
|
||||
let sub = format!("Перехват «{}»{how}", kind.spec().name);
|
||||
let mt = missile.and_then(|m| rec.track(m).map(|t| (m, t.first as f64)));
|
||||
let mt = missile.and_then(|m| rec.track(m).map(|t| (m, rec.missile_launch(m).map_or(t.first as f64, |e| e.at as f64))));
|
||||
match mt {
|
||||
Some((m, tl)) => {
|
||||
// The facts, in order: the launcher waits, the interceptor leaves it at `tl`, it
|
||||
@@ -454,6 +455,8 @@ fn plan_event(rec: &Recording, i: usize, floor: f64) -> Vec<Shot> {
|
||||
});
|
||||
add(Shot::new(a, b, &[(a, 1.0), (te - 4.0, 0.3), (te + 40.0, 1.0)], variants, &title(rec, i), "", i));
|
||||
}
|
||||
// A strike on a launch site (#101) is in the event list and on the map, not in the auto-camera's films.
|
||||
EventKind::Strike { .. } => {}
|
||||
}
|
||||
shots
|
||||
}
|
||||
|
||||
@@ -30,11 +30,17 @@ pub struct Layout {
|
||||
pub sams: Vec<SamRec>,
|
||||
pub targets: Vec<(DVec3, f64)>,
|
||||
pub damage: Option<bool>,
|
||||
pub last_chance: Option<bool>,
|
||||
pub seed: Option<u64>,
|
||||
pub wave: Option<Vec<String>>,
|
||||
pub far: Option<bool>,
|
||||
pub acoustics: Option<bool>,
|
||||
pub effects: Option<(bool, bool)>,
|
||||
pub roles: Vec<(SamKind, u8)>,
|
||||
/// Fire doctrines by the system's place in the file (#47).
|
||||
pub doctrines: Vec<(usize, sim::doctrine::Doctrine)>,
|
||||
/// Strike missiles in stock and ticks towards the next (#101).
|
||||
pub strikes: Option<(u32, u32)>,
|
||||
}
|
||||
|
||||
/// One line's words, with the line number for the messages.
|
||||
@@ -122,7 +128,10 @@ impl Layout {
|
||||
out.targets.push((pos, hp));
|
||||
}
|
||||
"damage" => out.damage = l.flag(1, "значение")?,
|
||||
"lastchance" => out.last_chance = l.flag(1, "значение")?,
|
||||
"strikes" => out.strikes = Some((l.need(1, "запас", 0.0, COUNT)? as u32, l.num(2, "до следующей", 0.0, COUNT)?.map_or(0, |v| v as u32))),
|
||||
"far" => out.far = l.flag(1, "значение")?,
|
||||
"acoustics" => out.acoustics = l.flag(1, "значение")?,
|
||||
"effects" => out.effects = Some((l.flag(1, "шейдер")?.unwrap_or(true), l.flag(2, "HD")?.unwrap_or(false))),
|
||||
"seed" => {
|
||||
let v = l.w.get(1).ok_or_else(|| l.bad("значение", "строка оборвана"))?;
|
||||
@@ -132,6 +141,16 @@ impl Layout {
|
||||
crate::wave::WaveConfig::default().check(&l.w[1..]).map_err(|e| l.bad("налёт", &e))?;
|
||||
out.wave = Some(l.w[1..].iter().map(|s| s.to_string()).collect());
|
||||
}
|
||||
"doctrine" => {
|
||||
// doctrine <system> <salvo> <reserve> <sector centre|-> <half|-> <guards> [x y z]...
|
||||
let at = l.need(1, "комплекс", 0.0, MAX_UNITS as f64)? as usize;
|
||||
let salvo = l.w.get(2).and_then(|v| sim::doctrine::Salvo::from_key(v)).ok_or_else(|| l.bad("залп", "eco, normal или heavy"))?;
|
||||
let reserve = l.need(3, "резерв", 0.0, sim::doctrine::MAX_RESERVE as f64)? as u32;
|
||||
let sector = if l.w.get(4) == Some(&"-") { None } else { Some((l.need(4, "центр сектора", -1.0e6, 1.0e6)?, l.need(5, "полуширина", 0.0, 7.0)?)) };
|
||||
let n = l.need(6, "число объектов", 0.0, 64.0)? as usize;
|
||||
let guards = (0..n).map(|k| l.xyz(7 + 3 * k, "охраняемый объект")).collect::<Result<Vec<_>, _>>()?;
|
||||
out.doctrines.push((at, sim::doctrine::Doctrine { guards, sector, reserve, salvo }));
|
||||
}
|
||||
"roles" => {
|
||||
let kind = l.kind(1)?;
|
||||
out.roles.push((kind, l.need(2, "роли", 0.0, 255.0)? as u8));
|
||||
@@ -194,8 +213,25 @@ mod tests {
|
||||
assert_eq!(l.sams[3].comps.len(), 6);
|
||||
assert_eq!((l.damage, l.far, l.effects, l.seed), (Some(false), Some(true), Some((true, false)), Some(123456789)));
|
||||
assert_eq!(l.roles.len(), 1);
|
||||
// Saves without strikes load as before; with them, the stock is read (and refused when wrong).
|
||||
assert_eq!(l.strikes, None);
|
||||
assert_eq!(Layout::parse("strikes 2 3500\n").unwrap().strikes, Some((2, 3500)));
|
||||
assert!(Layout::parse("strikes -1 0\n").is_err() && Layout::parse("strikes x\n").is_err());
|
||||
// What the build writes now reads back (a wave line from the menu's own text).
|
||||
let w = crate::wave::WaveConfig::default().text();
|
||||
assert!(Layout::parse(&format!("wave {w}\n")).is_ok(), "{w}");
|
||||
}
|
||||
#[test]
|
||||
fn the_save_line_is_what_the_layout_reads() {
|
||||
let mut d = crate::sim::doctrine::Doctrine { salvo: crate::sim::doctrine::Salvo::Economy, reserve: 3, ..Default::default() };
|
||||
d.sector = Some((1.5, 0.5));
|
||||
d.guards = vec![DVec3::new(1.0, 2.0, 3.0)];
|
||||
let text = format!("sam {} 0 70 0 0\ndoctrine 0 {}\n", SamKind::Patriot.key(), d.save_text());
|
||||
let l = crate::layout::Layout::parse(&text).unwrap();
|
||||
assert_eq!(l.doctrines, vec![(0, d)]);
|
||||
assert!(crate::layout::Layout::parse("doctrine 0 loud 1 - - 0\n").is_err());
|
||||
assert!(crate::layout::Layout::parse("doctrine 0 eco 1 - - 2 1 2 3\n").is_err(), "guards cut short");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The summary panel (top right): the alert, what is in the air, each
|
||||
//! air-defence system's state and the score.
|
||||
use crate::sim::{Drone, DroneKind, Sim};
|
||||
use crate::sim::{AirPicture, DroneKind, Sim};
|
||||
use glam::DVec3;
|
||||
use horizon_mod_sdk::hud::Line;
|
||||
|
||||
@@ -13,28 +13,28 @@ const GREEN: u32 = 0x80FF90;
|
||||
/// The most lines the summary holds (the HUD's room).
|
||||
const MAX_LINES: usize = 16;
|
||||
|
||||
/// Metres (a block is a metre) as a short distance.
|
||||
pub fn distance(m: f64) -> String {
|
||||
if m >= 1000.0 { format!("{:.1} км", m / 1000.0) } else { format!("{:.0} м", m) }
|
||||
}
|
||||
pub use crate::sim::distance;
|
||||
|
||||
/// Blocks a tick as km/h.
|
||||
fn kmh(v: DVec3) -> f64 {
|
||||
v.length() * 20.0 * 3.6
|
||||
}
|
||||
|
||||
pub fn summary(sim: &Sim, air: &[&Drone], player: DVec3) -> Vec<Line> {
|
||||
/// The panel reads the air picture only (#93): what the network holds, with the age of a forecast. The sandbox's
|
||||
/// `truth` adds one marked line of the real figures; it changes nothing else.
|
||||
pub fn summary(sim: &Sim, pic: &AirPicture, player: DVec3) -> Vec<Line> {
|
||||
let mut lines = Vec::new();
|
||||
let line = |text: String, color: u32| Line { text, color };
|
||||
if air.is_empty() {
|
||||
let now = pic.now;
|
||||
if pic.tracks.is_empty() {
|
||||
lines.push(line("Небо чистое".into(), GREEN));
|
||||
} else {
|
||||
let blink = (sim.tick / 10) % 2 == 0;
|
||||
lines.push(line(format!("ВОЗДУШНАЯ ТРЕВОГА — целей: {}", air.len()), if blink { RED } else { PINK }));
|
||||
// By type.
|
||||
lines.push(line(format!("ВОЗДУШНАЯ ТРЕВОГА — целей: {}", pic.tracks.len()), if blink { RED } else { PINK }));
|
||||
// By type, as the radars classed them.
|
||||
let mut by_type = String::new();
|
||||
for kind in DroneKind::ALL {
|
||||
let n = air.iter().filter(|d| d.kind == kind).count();
|
||||
let n = pic.tracks.iter().filter(|t| t.kind == kind).count();
|
||||
if n > 0 {
|
||||
if !by_type.is_empty() {
|
||||
by_type += ", ";
|
||||
@@ -43,29 +43,34 @@ pub fn summary(sim: &Sim, air: &[&Drone], player: DVec3) -> Vec<Line> {
|
||||
}
|
||||
}
|
||||
lines.push(line(by_type, PINK));
|
||||
// The nearest threat to the player.
|
||||
if let Some(d) = air.iter().min_by(|a, b| a.pos.distance(player).total_cmp(&b.pos.distance(player))) {
|
||||
// The nearest track to the player: where it was last measured (a forecast says so, with its age).
|
||||
if let Some(t) = pic.nearest(player) {
|
||||
let e = t.est(now);
|
||||
let mark = if t.forecast(now) { format!(" ~{}с", t.age(now) / 20) } else { String::new() };
|
||||
lines.push(line(
|
||||
format!(
|
||||
"Ближ.: {} {} выс.{:.0} {:.0}км/ч",
|
||||
d.kind.spec().name,
|
||||
distance(d.pos.distance(player)),
|
||||
d.pos.y - player.y,
|
||||
kmh(d.vel)
|
||||
),
|
||||
format!("Ближ.: {} {} выс.{:.0} {:.0}км/ч{mark}", t.kind.spec().name, distance(e.distance(player)), e.y - player.y, kmh(t.vel)),
|
||||
PINK,
|
||||
));
|
||||
}
|
||||
}
|
||||
if sim.planning() {
|
||||
lines.push(line("Противник планирует налёт…".into(), YELLOW));
|
||||
if sim.truth {
|
||||
let real = sim.drones.iter().filter(|d| d.alive()).count();
|
||||
let unseen = sim.drones.iter().filter(|d| d.alive() && pic.get(d.id).is_none()).count();
|
||||
let mut text = format!("ИСТИНА: в воздухе {real}, вне картины {unseen}, взлетает {}", sim.queue.len());
|
||||
if sim.planning() {
|
||||
text += ", противник планирует налёт";
|
||||
}
|
||||
lines.push(line(text, YELLOW));
|
||||
}
|
||||
if !sim.queue.is_empty() {
|
||||
lines.push(line(format!("Ещё взлетает: {}", sim.queue.len()), PINK));
|
||||
}
|
||||
let hidden = air.iter().filter(|d| !sim.sams.is_empty() && !sim.tracked(d.id)).count();
|
||||
if hidden > 0 {
|
||||
lines.push(line(format!("Вне видимости РЛС: {hidden}"), GREY));
|
||||
// The launch sites found, and the strike missiles (#101).
|
||||
if !sim.strikes.known.is_empty() || !sim.strikes.flights.is_empty() {
|
||||
let st = &sim.strikes;
|
||||
let live = st.known.iter().filter(|k| !matches!(k.state, crate::sim::strike::SiteState::Destroyed(_))).count();
|
||||
let mut text = format!("Известных ПУ: {live} · ударных ракет: {}", st.stock);
|
||||
if let Some(f) = st.flights.iter().map(|f| f.arrive.saturating_sub(sim.tick)).min() {
|
||||
text += &format!(" · в полёте {} (до цели {} с)", st.flights.len(), f / 20);
|
||||
}
|
||||
lines.push(line(text, YELLOW));
|
||||
}
|
||||
if !sim.target_health.is_empty() {
|
||||
let list: Vec<String> = sim.target_health.iter().map(|h| format!("{h:.0}%")).collect();
|
||||
@@ -93,8 +98,8 @@ pub fn summary(sim: &Sim, air: &[&Drone], player: DVec3) -> Vec<Line> {
|
||||
} else {
|
||||
sam.status()
|
||||
};
|
||||
if let Some(t) = sam.gun_target.or(sam.target).and_then(|t| sim.drones.iter().find(|d| d.id == t)) {
|
||||
text += &format!(" > {} {}", t.kind.spec().name, distance(t.pos.distance(sam.pos)));
|
||||
if let Some(t) = sam.gun_target.or(sam.target).and_then(|t| pic.get(t)) {
|
||||
text += &format!(" > {} {}", t.kind.spec().name, distance(t.est(now).distance(sam.pos)));
|
||||
}
|
||||
if sam.kills > 0 {
|
||||
text += &format!(" ({})", sam.kills);
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
//! Presentation playback ownership and lifecycle transitions.
|
||||
|
||||
/// The one active presentation mode. Export owns its playback so it cannot outlive its film.
|
||||
pub enum State<P, E> {
|
||||
Live,
|
||||
Replay(P),
|
||||
Export { playback: P, export: E },
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum ExitCause {
|
||||
UserStop,
|
||||
WorldChange,
|
||||
Replaced,
|
||||
Finished,
|
||||
Failed,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct Cleanup {
|
||||
pub was_export: bool,
|
||||
pub cancel_capture: bool,
|
||||
}
|
||||
|
||||
pub struct Session<P, E> {
|
||||
state: State<P, E>,
|
||||
}
|
||||
|
||||
impl<P, E> Default for Session<P, E> {
|
||||
fn default() -> Self {
|
||||
Self { state: State::Live }
|
||||
}
|
||||
}
|
||||
|
||||
impl<P, E> Session<P, E> {
|
||||
pub fn is_live(&self) -> bool {
|
||||
matches!(self.state, State::Live)
|
||||
}
|
||||
|
||||
pub fn is_exporting(&self) -> bool {
|
||||
matches!(self.state, State::Export { .. })
|
||||
}
|
||||
|
||||
pub fn playback(&self) -> Option<&P> {
|
||||
match &self.state {
|
||||
State::Live => None,
|
||||
State::Replay(player)
|
||||
| State::Export {
|
||||
playback: player, ..
|
||||
} => Some(player),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn playback_mut(&mut self) -> Option<&mut P> {
|
||||
match &mut self.state {
|
||||
State::Live => None,
|
||||
State::Replay(player)
|
||||
| State::Export {
|
||||
playback: player, ..
|
||||
} => Some(player),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replay(&mut self, playback: P) {
|
||||
assert!(
|
||||
self.is_live(),
|
||||
"end the current presentation before replacing it"
|
||||
);
|
||||
self.state = State::Replay(playback);
|
||||
}
|
||||
|
||||
pub fn export(&mut self, playback: P, export: E) {
|
||||
assert!(
|
||||
self.is_live(),
|
||||
"end the current presentation before starting export"
|
||||
);
|
||||
self.state = State::Export { playback, export };
|
||||
}
|
||||
|
||||
/// Temporarily move the active state out while a tick mutates the player and export together.
|
||||
pub fn take(&mut self) -> State<P, E> {
|
||||
std::mem::replace(&mut self.state, State::Live)
|
||||
}
|
||||
|
||||
pub fn restore(&mut self, state: State<P, E>) {
|
||||
assert!(self.is_live(), "restore only into a detached live session");
|
||||
self.state = state;
|
||||
}
|
||||
|
||||
/// Every exit converges here; a completed capture is already drained and must not be cancelled.
|
||||
pub fn end(&mut self, cause: ExitCause) -> Cleanup {
|
||||
let was_export = self.is_exporting();
|
||||
self.state = State::Live;
|
||||
Cleanup {
|
||||
was_export,
|
||||
cancel_capture: was_export && cause != ExitCause::Finished,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{ExitCause, Session, State};
|
||||
|
||||
#[test]
|
||||
fn export_always_owns_its_playback_and_user_stop_cleans_capture() {
|
||||
let mut session = Session::<u8, &str>::default();
|
||||
session.export(7, "capture");
|
||||
assert!(matches!(
|
||||
session.take(),
|
||||
State::Export {
|
||||
playback: 7,
|
||||
export: "capture"
|
||||
}
|
||||
));
|
||||
session.export(7, "capture");
|
||||
assert_eq!(session.end(ExitCause::UserStop).cancel_capture, true);
|
||||
assert!(session.is_live());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn world_change_and_failure_share_cleanup_while_success_drains() {
|
||||
for cause in [ExitCause::WorldChange, ExitCause::Failed] {
|
||||
let mut session = Session::<(), ()>::default();
|
||||
session.export((), ());
|
||||
assert_eq!(session.end(cause).cancel_capture, true);
|
||||
assert!(session.is_live());
|
||||
}
|
||||
let mut session = Session::<(), ()>::default();
|
||||
session.export((), ());
|
||||
assert_eq!(session.end(ExitCause::Finished).cancel_capture, false);
|
||||
assert!(session.is_live());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replay_replacement_is_not_an_export_and_stop_is_idempotent() {
|
||||
let mut session = Session::<u8, ()>::default();
|
||||
session.replay(1);
|
||||
assert!(session.playback().is_some());
|
||||
assert_eq!(session.end(ExitCause::Replaced).was_export, false);
|
||||
assert_eq!(session.end(ExitCause::UserStop).was_export, false);
|
||||
assert!(session.is_live());
|
||||
}
|
||||
}
|
||||
@@ -107,37 +107,70 @@ pub fn draw(sim: &Sim, player: DVec3, yaw: f32) -> Vec<Shape> {
|
||||
s.push(square(x, y, 1.0, 0xFFFFE060));
|
||||
}
|
||||
}
|
||||
let mut far = 0;
|
||||
// The air picture is what the systems' radars hold, as they last measured it (a track older than a second
|
||||
// is a forecast, dimmer); with no system deployed, everything as it is.
|
||||
let any = !sim.sams.is_empty();
|
||||
let picture = sim.picture();
|
||||
let now = sim.tick;
|
||||
for d in sim.drones.iter().filter(|d| !any || !d.alive() || picture.contains_key(&d.id)) {
|
||||
let track = picture.get(&d.id).filter(|_| any && d.alive());
|
||||
let (pos, vel) = track.map_or((d.pos, d.vel), |t| (t.est(now), t.vel));
|
||||
match scope(pos) {
|
||||
Some((x, y, bearing)) => {
|
||||
if d.alive() {
|
||||
// Fresh: bright and red; a forecast: orange, fading as it ages towards the track's drop.
|
||||
let (a, color) = match track {
|
||||
Some(t) if t.forecast(now) => ((1.0 - t.age(now) as f64 / t.ttl.max(1) as f64 * 0.7).max(0.3), 0xFFB040),
|
||||
Some(_) => (1.0, 0xFF4040),
|
||||
None => (fade(bearing), 0xFF4040),
|
||||
};
|
||||
s.push(square(x, y, 1.8, alpha(color, a)));
|
||||
// Its heading, a short tail.
|
||||
let v = vel.normalize_or_zero();
|
||||
s.push(quad(pt(x, y), pt(x + 0.6, y), pt(x - v.x as f32 * 6.0 + 0.6, y - v.z as f32 * 6.0), pt(x - v.x as f32 * 6.0, y - v.z as f32 * 6.0), alpha(color, a * 0.6)));
|
||||
} else {
|
||||
s.push(square(x, y, 1.2, alpha(0x909090, fade(bearing))));
|
||||
// Launch sites the radars found: a diamond where the place is known (with the circle of its error), and a mark on
|
||||
// the rim along the bearing when it is beyond the scope or only the bearing is known.
|
||||
for k in &sim.strikes.known {
|
||||
let Some(e) = &k.est else { continue };
|
||||
let gone = matches!(k.state, crate::sim::strike::SiteState::Destroyed(_));
|
||||
let color = if gone { 0xFF707070 } else { 0xFFFFA040 };
|
||||
let inside = e.fix.then(|| scope(DVec3::new(e.pos.x, player.y, e.pos.y))).flatten();
|
||||
if let Some((x, y, _)) = inside {
|
||||
let q = 3.0;
|
||||
s.push(quad(pt(x, y - q), pt(x + q, y), pt(x, y + q), pt(x - q, y), color));
|
||||
let rad = (e.radius / RANGE) as f32 * r;
|
||||
if rad > 3.5 {
|
||||
for i in 0..SEGMENTS {
|
||||
let (a0, a1) = (i as f32 / SEGMENTS as f32 * tau, (i + 1) as f32 / SEGMENTS as f32 * tau);
|
||||
if i % 2 == 0 {
|
||||
let p = |a: f32, rr: f32| pt(x + a.sin() * rr, y - a.cos() * rr);
|
||||
s.push(quad(p(a0, rad - 0.4), p(a0, rad + 0.4), p(a1, rad + 0.4), p(a1, rad - 0.4), alpha(color, 0.5)));
|
||||
}
|
||||
}
|
||||
}
|
||||
None if d.alive() => far += 1,
|
||||
None => {}
|
||||
s.push(text(k.site.to_string(), x + 5.0, y - 9.0, color, false));
|
||||
} else {
|
||||
// On the rim, along the bearing (compass: north up, east right).
|
||||
let a = e.bearing as f32;
|
||||
let (x, y) = (cx + a.sin() * (r - 3.0), cy - a.cos() * (r - 3.0));
|
||||
let q = if e.fix { 3.0 } else { 2.0 };
|
||||
s.push(quad(pt(x, y - q), pt(x + q, y), pt(x, y + q), pt(x - q, y), color));
|
||||
s.push(text(format!("{}{}", k.site, if e.fix { "" } else { "?" }), x - a.sin() * 8.0, y + a.cos() * -8.0 - 4.0, color, true));
|
||||
}
|
||||
// The true place, when asked for: a white dot beside the track, to see how far the picture is off.
|
||||
if sim.truth && d.alive() && any {
|
||||
}
|
||||
// Strike missiles in flight, on the same footing: a small bright dot where the scope reaches, else nothing.
|
||||
for f in &sim.strikes.flights {
|
||||
if let Some((x, y, _)) = scope(f.pos) {
|
||||
s.push(square(x, y, 1.5, 0xFFFFFFA0));
|
||||
}
|
||||
}
|
||||
let mut far = 0;
|
||||
// The air picture is what the systems' radars hold, as they last measured it (a track older than a second
|
||||
// is a forecast, dimmer); with no system deployed, the sky as it is. Nothing else is read (#93).
|
||||
let pic = sim.air_picture();
|
||||
let now = pic.now;
|
||||
for t in &pic.tracks {
|
||||
let (pos, vel) = (t.est(now), t.vel);
|
||||
match scope(pos) {
|
||||
Some((x, y, bearing)) => {
|
||||
// Fresh: bright and red; a forecast: orange, fading as it ages towards the track's drop.
|
||||
let (a, color) = if pic.unaided {
|
||||
(fade(bearing), 0xFF4040)
|
||||
} else if t.forecast(now) {
|
||||
((1.0 - t.age(now) as f64 / t.ttl.max(1) as f64 * 0.7).max(0.3), 0xFFB040)
|
||||
} else {
|
||||
(1.0, 0xFF4040)
|
||||
};
|
||||
s.push(square(x, y, 1.8, alpha(color, a)));
|
||||
// Its heading, a short tail.
|
||||
let v = vel.normalize_or_zero();
|
||||
s.push(quad(pt(x, y), pt(x + 0.6, y), pt(x - v.x as f32 * 6.0 + 0.6, y - v.z as f32 * 6.0), pt(x - v.x as f32 * 6.0, y - v.z as f32 * 6.0), alpha(color, a * 0.6)));
|
||||
}
|
||||
None => far += 1,
|
||||
}
|
||||
}
|
||||
// The true places, when the sandbox asks for them: a white dot beside the track, to see how far the picture is off.
|
||||
if sim.truth && !pic.unaided {
|
||||
for d in sim.drones.iter().filter(|d| d.alive()) {
|
||||
if let Some((x, y, _)) = scope(d.pos) {
|
||||
s.push(square(x, y, 0.8, 0xFFFFFFFF));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
use crate::film::{self, Film};
|
||||
use crate::panel::distance;
|
||||
use crate::sim::Ground;
|
||||
use crate::sim::record::{EventKind, Recording, STEP, What};
|
||||
use crate::sim::record::{EventKind, Recording, STEP, StrikeResult, What};
|
||||
use std::cell::Cell;
|
||||
use crate::sim::{Class, DroneKind, Out, Sim};
|
||||
use glam::DVec3;
|
||||
@@ -137,6 +137,18 @@ fn outcome_note(outcome: crate::sim::outcome::Outcome) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
/// How a strike on a launch site ended, in words.
|
||||
fn strike_word(result: StrikeResult) -> &'static str {
|
||||
match result {
|
||||
StrikeResult::Destroyed => "площадка уничтожена",
|
||||
StrikeResult::Stunned => "площадка подавлена",
|
||||
StrikeResult::Missed => "промах",
|
||||
StrikeResult::Intercepted => "ракета сбита ПВО противника",
|
||||
StrikeResult::Halted => "пуски прекращены (вне карты)",
|
||||
StrikeResult::Blocked => "разбилась о рельеф",
|
||||
}
|
||||
}
|
||||
|
||||
/// What an event was, in a line.
|
||||
pub fn title(rec: &Recording, i: usize) -> String {
|
||||
let e = &rec.events[i];
|
||||
@@ -151,6 +163,7 @@ pub fn title(rec: &Recording, i: usize) -> String {
|
||||
EventKind::SamLost { kind, index, .. } => format!("{} №{} уничтожен", kind.name(), index + 1),
|
||||
EventKind::Split { .. } => "«Орешник»: разделение боевых блоков".into(),
|
||||
EventKind::Crash { kind, .. } => format!("«{}» разбивается о препятствие", kind.spec().name),
|
||||
EventKind::Strike { site, result } => format!("Удар по ПУ №{site}: {}", strike_word(result)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +180,7 @@ pub fn row(rec: &Recording, i: usize) -> String {
|
||||
EventKind::SamLost { kind, index, .. } => format!("{}-{} уничтожен", kind.name(), index + 1),
|
||||
EventKind::Split { .. } => "Орешник: разделение".into(),
|
||||
EventKind::Crash { kind, .. } => format!("{}: о рельеф", kind.spec().name),
|
||||
EventKind::Strike { site, result } => format!("ПУ {site}: {}", strike_word(result)),
|
||||
};
|
||||
format!("{} {what}", clock(e.at as f64))
|
||||
}
|
||||
@@ -199,6 +213,7 @@ pub fn interest(rec: &Recording, i: usize) -> f64 {
|
||||
}
|
||||
EventKind::SamLost { .. } => 12.0,
|
||||
EventKind::Crash { power, .. } => power as f64,
|
||||
EventKind::Strike { .. } => 0.0,
|
||||
EventKind::Split { drone } => {
|
||||
// The bus's split, not each block's.
|
||||
let first = rec.events.iter().position(|o| matches!(o.kind, EventKind::Split { .. }));
|
||||
@@ -216,6 +231,7 @@ fn clip(rec: &Recording, i: usize) -> Clip {
|
||||
EventKind::SamLost { .. } => (80.0, 90.0),
|
||||
EventKind::Split { .. } => (40.0, 170.0),
|
||||
EventKind::Crash { .. } => (120.0, 60.0),
|
||||
EventKind::Strike { .. } => (60.0, 80.0),
|
||||
};
|
||||
Clip { event: i, from: (at - before).max(0.0), to: (at + after).min(rec.len as f64) }
|
||||
}
|
||||
@@ -481,11 +497,17 @@ impl Player {
|
||||
}
|
||||
}
|
||||
What::Missile(kind, _) => {
|
||||
if self.t - tr.first as f64 > kind.lit_after() as f64 {
|
||||
if rec.missile_is_lit(tr, self.t, kind.lit_after()) {
|
||||
let (event, gain, pitch) = kind.engine_voice();
|
||||
out.engine(key, event, at, vel, gain, pitch, false);
|
||||
}
|
||||
}
|
||||
What::Strike => {
|
||||
// A counter-strike's motor from its launch, as the live flight has it (#109).
|
||||
if let Some((event, pitch)) = DroneKind::Kalibr.engine_voice() {
|
||||
out.engine(key, event, at, vel, 0.8, pitch, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -499,6 +521,12 @@ impl Player {
|
||||
EventKind::Hit { power, .. } | EventKind::Crash { power, .. } => ["airdef:blast.air", "airdef:blast.medium", "airdef:blast.big", "airdef:blast.heavy", "airdef:blast.huge"][(power as usize).min(4)],
|
||||
EventKind::SamLost { .. } => "airdef:blast.big",
|
||||
EventKind::Split { .. } => "airdef:boom.sonic",
|
||||
EventKind::Strike { result: StrikeResult::Halted, .. } => continue,
|
||||
EventKind::Strike { result, .. } => ["airdef:blast.air", "airdef:blast.medium", "airdef:blast.big", "airdef:blast.heavy", "airdef:blast.huge"][match result {
|
||||
StrikeResult::Destroyed => 4,
|
||||
StrikeResult::Intercepted => 0,
|
||||
_ => 3,
|
||||
}],
|
||||
};
|
||||
let gain = if let EventKind::Kill { kind, outcome, .. } = e.kind { crate::sim::outcome::look(kind, outcome).2 } else { 1.0 };
|
||||
out.sound(event, heard(e.pos), gain, 1.0);
|
||||
@@ -506,11 +534,27 @@ impl Player {
|
||||
out.sound("airdef:boom.sonic", heard(e.pos), 0.8, 1.2);
|
||||
}
|
||||
}
|
||||
// New recordings carry the exact launch and ignition sounds and their actual positions.
|
||||
if let Some(scene) = &rec.scene {
|
||||
for e in scene.events().iter().filter(|e| (self.heard..self.t).contains(&(e.at as f64))) {
|
||||
match e.kind {
|
||||
crate::sim::record::SceneKind::MissileLaunch { sound, pitch, .. } => out.sound(sound, heard(e.pos), 1.0, pitch),
|
||||
crate::sim::record::SceneKind::MotorIgnition { sound: Some(sound), .. } => out.sound(sound, heard(e.pos), 1.0, 1.0),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
for tr in rec.tracks.iter().filter(|tr| (self.heard..self.t).contains(&(tr.first as f64))) {
|
||||
if let What::Missile(kind, _) = tr.what
|
||||
let event = match tr.what {
|
||||
What::Missile(kind, _) if rec.missile_launch(tr.id).is_none() => Some(kind.launch_sound()),
|
||||
What::Missile(..) => None,
|
||||
What::Strike => Some(DroneKind::Kalibr.launch_sound()),
|
||||
What::Drone(_) => None,
|
||||
};
|
||||
if let Some(event) = event
|
||||
&& let Some(p) = tr.at(rec.origin, tr.first as f64)
|
||||
{
|
||||
out.sound(kind.launch_sound(), heard(p), 1.0, 1.0);
|
||||
out.sound(event, heard(p), 1.0, 1.0);
|
||||
}
|
||||
}
|
||||
self.heard = self.t;
|
||||
@@ -694,7 +738,7 @@ impl Player {
|
||||
let look = rec.track(drone).and_then(|tr| tr.at(o, t)).filter(|_| t < te).unwrap_or(e.pos);
|
||||
(eye, look, 50.0, 1)
|
||||
}
|
||||
EventKind::SamLost { .. } => (side(e.pos, o + DVec3::new(300.0, 0.0, 0.0), 45.0), e.pos, 50.0, 0),
|
||||
EventKind::SamLost { .. } | EventKind::Strike { .. } => (side(e.pos, o + DVec3::new(300.0, 0.0, 0.0), 45.0), e.pos, 50.0, 0),
|
||||
EventKind::Split { .. } => {
|
||||
let ground = DVec3::new(e.pos.x, o.y, e.pos.z);
|
||||
let eye = ground + DVec3::new(170.0, 8.0, 40.0);
|
||||
@@ -909,6 +953,7 @@ impl Player {
|
||||
What::Drone(kind) if kind.spec().decoy => (0x70A0A0A0, 0xFFC0C0C0),
|
||||
What::Drone(_) => (0x90FF4040, 0xFFFF6060),
|
||||
What::Missile(..) => (0x90FFD040, 0xFFFFE070),
|
||||
What::Strike => (0x90FFA040, 0xFFFFC060),
|
||||
};
|
||||
let upto = ((self.t - tr.first as f64) / STEP as f64).floor();
|
||||
if upto < 0.0 {
|
||||
@@ -953,6 +998,7 @@ impl Player {
|
||||
}
|
||||
EventKind::SamLost { .. } => s.push(fill(x - 4.0, y - 4.0, 8.0, 8.0, 0xFF200000)),
|
||||
EventKind::Split { .. } => s.push(fill(x - 2.0, y - 2.0, 4.0, 4.0, 0xFFFF9020)),
|
||||
EventKind::Strike { .. } => s.push(fill(x - 3.0, y - 3.0, 6.0, 6.0, 0xFFFFA040)),
|
||||
}
|
||||
}
|
||||
// Header, legend, time line.
|
||||
@@ -983,6 +1029,7 @@ impl Player {
|
||||
EventKind::Crash { .. } => 0xFF903020,
|
||||
EventKind::SamLost { .. } => 0xFFFF00FF,
|
||||
EventKind::Split { .. } => 0xFFFF9020,
|
||||
EventKind::Strike { .. } => 0xFFFFA040,
|
||||
};
|
||||
s.push(fill(x, ty - 2.0, 1.0, 7.0, c));
|
||||
}
|
||||
@@ -1071,6 +1118,57 @@ mod engine_tests {
|
||||
let _ = rec;
|
||||
p
|
||||
}
|
||||
#[test]
|
||||
fn recorded_launch_and_ignition_sounds_use_exact_events_without_duplicates() {
|
||||
use crate::sim::record::{SceneEvent, SceneJournal, SceneKind};
|
||||
let mut rec = Recording::blank(100);
|
||||
rec.straight(2, What::Missile(MissileKind::M48n6, 5), 20, 80, DVec3::new(0.0, 66.0, 0.0), DVec3::new(0.0, 70.0, 300.0));
|
||||
let mut journal = SceneJournal::default();
|
||||
journal.fixture_push(SceneEvent { at: 19, pos: DVec3::new(2.0, 66.0, 0.0), kind: SceneKind::MissileLaunch { missile: 2, sam: 5, target: 1, kind: MissileKind::M48n6, sound: "airdef:launch.s400_eject", pitch: 1.0 } });
|
||||
journal.fixture_push(SceneEvent { at: 24, pos: DVec3::new(2.0, 75.0, 0.0), kind: SceneKind::MotorIgnition { missile: 2, kind: MissileKind::M48n6, sound: Some("airdef:launch.s400") } });
|
||||
rec.scene = Some(journal);
|
||||
let mut p = player(&rec);
|
||||
let mut out = Out::default();
|
||||
p.heard = 18.0;
|
||||
p.t = 21.0;
|
||||
p.sounds(&rec, DVec3::ZERO, &mut out);
|
||||
assert_eq!(out.sounds.len(), 1, "the first track sample must not repeat the launch");
|
||||
assert_eq!(out.sounds[0].0, "airdef:launch.s400_eject");
|
||||
out.sounds.clear();
|
||||
p.t = 25.0;
|
||||
p.sounds(&rec, DVec3::ZERO, &mut out);
|
||||
assert_eq!(out.sounds.len(), 1);
|
||||
assert_eq!(out.sounds[0].0, "airdef:launch.s400");
|
||||
assert!(!rec.missile_is_lit(&rec.tracks[0], 23.0, 5));
|
||||
assert!(rec.missile_is_lit(&rec.tracks[0], 24.0, 5));
|
||||
out.sounds.clear();
|
||||
p.heard = 18.0;
|
||||
p.t = 25.0;
|
||||
p.sounds(&rec, DVec3::ZERO, &mut out);
|
||||
assert_eq!(out.sounds.iter().map(|s| s.0).collect::<Vec<_>>(), vec!["airdef:launch.s400_eject", "airdef:launch.s400"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn counter_strike_launch_is_heard_once_and_can_be_replayed_after_seek() {
|
||||
let mut rec = Recording::blank(100);
|
||||
rec.straight(1, What::Strike, 10, 70, DVec3::ZERO, DVec3::new(300.0, 70.0, 0.0));
|
||||
let mut p = player(&rec);
|
||||
p.heard = 9.0;
|
||||
p.t = 11.0;
|
||||
let mut out = Out::default();
|
||||
p.sounds(&rec, DVec3::ZERO, &mut out);
|
||||
assert_eq!(out.sounds.len(), 1);
|
||||
assert_eq!(out.sounds[0].0, DroneKind::Kalibr.launch_sound());
|
||||
out.sounds.clear();
|
||||
p.t = 12.0;
|
||||
p.sounds(&rec, DVec3::ZERO, &mut out);
|
||||
assert!(out.sounds.is_empty(), "the loop engine must not repeat the launch");
|
||||
p.heard = 9.0; // seek/cut resets the one-shot cursor
|
||||
p.t = 11.0;
|
||||
p.sounds(&rec, DVec3::ZERO, &mut out);
|
||||
assert_eq!(out.sounds.len(), 1);
|
||||
}
|
||||
|
||||
/// A host that remembers which sources run.
|
||||
#[derive(Default)]
|
||||
struct Host(std::collections::BTreeMap<u32, [f64; 3]>);
|
||||
|
||||
@@ -61,7 +61,7 @@ impl AirDef {
|
||||
}
|
||||
// The whole body is read and checked before anything is touched (#86).
|
||||
let layout = layout::Layout::parse(text).map_err(|e| format!("Сценарий не загружен, сцена осталась прежней: {e}"))?;
|
||||
if self.replay.is_some() {
|
||||
if self.presentation.playback().is_some() {
|
||||
self.stop_replay();
|
||||
}
|
||||
// Everything of the last layout goes: its systems with their jobs and targets, the sky,
|
||||
@@ -71,6 +71,7 @@ impl AirDef {
|
||||
self.sim.targets.clear();
|
||||
self.sim.target_health.clear();
|
||||
self.sim.roles.clear();
|
||||
self.sim.last_chance = true;
|
||||
self.sim.kills = 0;
|
||||
self.sim.hits = 0;
|
||||
self.sim.launched = 0;
|
||||
|
||||
@@ -0,0 +1,579 @@
|
||||
//! Balance measurements: a whole raid on flat land, flown headlessly against a cluster of systems.
|
||||
//! The `#[ignore]`d tests print tables (`cargo test --release balance -- --ignored --nocapture`);
|
||||
//! the others assert the cheap invariants. The tables are what the air defence's tuning is judged by.
|
||||
use super::*;
|
||||
|
||||
/// The ten armed kinds in the order a cluster takes them (long-range heavy ones spread evenly).
|
||||
const MIX: [SamKind; 10] = [
|
||||
SamKind::Patriot,
|
||||
SamKind::IrisT,
|
||||
SamKind::S400,
|
||||
SamKind::Pantsir,
|
||||
SamKind::Nasams,
|
||||
SamKind::Tor,
|
||||
SamKind::S500,
|
||||
SamKind::Buk,
|
||||
SamKind::Gepard,
|
||||
SamKind::P1sun,
|
||||
];
|
||||
|
||||
/// What one drone went through, for saying why it got through.
|
||||
#[derive(Default, Clone)]
|
||||
struct Hist {
|
||||
kind: Option<DroneKind>,
|
||||
/// Ticks any system held a track of it.
|
||||
seen: u32,
|
||||
/// Ticks some loaded launcher with the class in its roles had it in range (`cover`), and held its track too (`reach`).
|
||||
cover: u32,
|
||||
reach: u32,
|
||||
/// Distinct interceptors sent at it.
|
||||
shots: std::collections::HashSet<u32>,
|
||||
dead: bool,
|
||||
last: (DVec3, DVec3),
|
||||
/// Ticks to the aim when first covered, first tracked by a covering launcher, first shot at.
|
||||
ttg: (f64, f64, f64),
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub(super) struct Result {
|
||||
pub launched: u32,
|
||||
pub kills: u32,
|
||||
pub leaked: u32,
|
||||
pub missiles: u32,
|
||||
pub ticks: u64,
|
||||
/// Leaks by cause.
|
||||
pub unseen: u32,
|
||||
pub no_cover: u32,
|
||||
pub untracked: u32,
|
||||
pub hits: u32,
|
||||
pub crashes: u32,
|
||||
/// Interceptors lost against the land, and ones that blew up short of a ridge.
|
||||
pub blocked: u32,
|
||||
pub scrubbed: u32,
|
||||
pub unshot: u32,
|
||||
pub missed: u32,
|
||||
/// Missiles fired by the heavy systems (S-400, S-500, Patriot).
|
||||
pub heavy: u32,
|
||||
pub by_kind: Vec<(DroneKind, u32, u32)>,
|
||||
pub tally: String,
|
||||
/// Drones that vanished short of their aim without being shot down: kind, where, how far from the aim.
|
||||
pub crashed: Vec<(DroneKind, DVec3, f64)>,
|
||||
/// Chunk tickets the sim asked for.
|
||||
pub tickets: usize,
|
||||
pub scrubs: Vec<(MissileKind, u32, f64, f64, DVec3, f64, f64)>,
|
||||
}
|
||||
|
||||
pub(super) struct Setup {
|
||||
pub systems: usize,
|
||||
pub smart: bool,
|
||||
pub seed: u64,
|
||||
pub size: u32,
|
||||
pub radars: usize,
|
||||
pub objects: usize,
|
||||
/// Called on the sim before the raid (a test sets its switches).
|
||||
pub tweak: fn(&mut Sim),
|
||||
/// Hilly land instead of flat (`hills`).
|
||||
pub hilly: bool,
|
||||
/// Only a disc of this radius round the player (the origin) is loaded, as in the game; beyond it the land is not
|
||||
/// there (`Void`) unless a chunk ticket was asked for (loaded after a delay, for a while).
|
||||
pub disc: Option<f64>,
|
||||
/// Mountains on top of the hills (ridges of up to 150 blocks, 600-900 blocks apart).
|
||||
pub mountains: bool,
|
||||
/// How far out the raid launches (the order's distance).
|
||||
pub dist: f64,
|
||||
/// Systems and objects sunk this far into the land (a player who stood inside it).
|
||||
pub bury: f64,
|
||||
/// How steep the hills are (1 is the usual), and whether a forest's canopy stands on them (the game's height map shows the leaves).
|
||||
pub steep: f64,
|
||||
pub trees: bool,
|
||||
}
|
||||
|
||||
/// Rolling hills: ridges of 20-35 blocks over a plain at 64, wavelengths of 90-250 blocks.
|
||||
pub(super) fn hills(x: i32, z: i32) -> i32 {
|
||||
hills_k(x, z, 1.0)
|
||||
}
|
||||
|
||||
/// `hills` with its ridges `k` times as steep (higher and closer together).
|
||||
pub(super) fn hills_k(x: i32, z: i32, k: f64) -> i32 {
|
||||
let (x, z) = (f64::from(x) * k, f64::from(z) * k);
|
||||
let n = (x / 53.0 + (z / 91.0).sin() * 1.7).sin() * 0.5 + (z / 41.0 - (x / 77.0).cos()).sin() * 0.35 + ((x + z) / 130.0).sin() * 0.4 + ((x - 2.0 * z) / 29.0).sin() * 0.12;
|
||||
64 + (n * 28.0 * k + 14.0).max(-4.0) as i32
|
||||
}
|
||||
|
||||
/// Mountains: broad ridges over the hills, nothing within about 300 blocks of the origin.
|
||||
pub(super) fn mountains(x: i32, z: i32) -> i32 {
|
||||
let (x, z) = (f64::from(x), f64::from(z));
|
||||
let r = (x * x + z * z).sqrt();
|
||||
let ridge = ((x / 410.0 + 0.7).sin() * (z / 530.0 - 0.4).sin() + (x / 700.0 - z / 610.0).sin() * 0.6).max(0.0);
|
||||
(ridge * 150.0 * ((r - 300.0) / 400.0).clamp(0.0, 1.0)) as i32
|
||||
}
|
||||
|
||||
/// The game's view of the land: all of it, or a disc round the player and the chunks asked for.
|
||||
pub(super) struct Loader {
|
||||
pub hilly: bool,
|
||||
pub mountains: bool,
|
||||
pub disc: Option<f64>,
|
||||
steep: f64,
|
||||
trees: bool,
|
||||
asked: std::cell::RefCell<HashMap<(i32, i32), (u64, u64)>>,
|
||||
pub tickets: usize,
|
||||
}
|
||||
const TICKET_DELAY: u64 = 40;
|
||||
const TICKET_LIFE: u64 = 400;
|
||||
|
||||
impl Loader {
|
||||
pub fn new(s: &Setup) -> Self {
|
||||
Loader { hilly: s.hilly, mountains: s.mountains, disc: s.disc, steep: s.steep, trees: s.trees, asked: Default::default(), tickets: 0 }
|
||||
}
|
||||
/// The land without the forest on it.
|
||||
pub fn bare(&self, x: i32, z: i32) -> f64 {
|
||||
f64::from(hills_k(x, z, self.steep) + if self.mountains { mountains(x, z) } else { 0 })
|
||||
}
|
||||
pub fn height(&self, x: i32, z: i32) -> i32 {
|
||||
if !self.hilly {
|
||||
return 64;
|
||||
}
|
||||
// A forest: a quarter of the 3x3 patches carry a canopy 8 blocks over the ground (the game's height map shows the leaves).
|
||||
let canopy = if self.trees && ((x.div_euclid(3).wrapping_mul(73856093) ^ z.div_euclid(3).wrapping_mul(19349663)) as u32 >> 3) % 4 == 0 { 8 } else { 0 };
|
||||
hills_k(x, z, self.steep) + canopy + if self.mountains { mountains(x, z) } else { 0 }
|
||||
}
|
||||
fn loaded(&self, c: (i32, i32), now: u64) -> Option<bool> {
|
||||
let Some(r) = self.disc else { return Some(true) };
|
||||
let (x, z) = (f64::from(c.0 * 16 + 8), f64::from(c.1 * 16 + 8));
|
||||
if (x * x + z * z).sqrt() <= r {
|
||||
return Some(true);
|
||||
}
|
||||
match self.asked.borrow().get(&c) {
|
||||
Some(&(since, until)) if now < until => Some(now >= since + TICKET_DELAY),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub fn serve(&mut self, ground: &mut Ground, now: u64) {
|
||||
for c in ground.take_chunks() {
|
||||
self.tickets += 1;
|
||||
if std::env::var("NOTICKETS").is_err() {
|
||||
let mut asked = self.asked.borrow_mut();
|
||||
let e = asked.entry(c).or_insert((now, now));
|
||||
if now >= e.1 {
|
||||
*e = (now, now);
|
||||
}
|
||||
e.1 = now + TICKET_DELAY + TICKET_LIFE;
|
||||
}
|
||||
}
|
||||
let cols = ground
|
||||
.take_wanted()
|
||||
.into_iter()
|
||||
.map(|(x, z)| {
|
||||
let y = match self.loaded((x >> 4, z >> 4), now) {
|
||||
Some(true) => self.height(x, z),
|
||||
Some(false) => PENDING,
|
||||
None => -64,
|
||||
};
|
||||
(x, z, y)
|
||||
})
|
||||
.collect();
|
||||
ground.answer(cols, now);
|
||||
let secs = ground.world.take_wanted(now);
|
||||
let view = Seen { l: self, now };
|
||||
ground.world.serve(&view, secs, now);
|
||||
}
|
||||
}
|
||||
struct Seen<'a> {
|
||||
l: &'a Loader,
|
||||
now: u64,
|
||||
}
|
||||
impl world::WorldSource for Seen<'_> {
|
||||
fn solid(&self, x: i32, y: i32, z: i32) -> Option<bool> {
|
||||
self.l.loaded((x >> 4, z >> 4), self.now).filter(|&l| l).map(|_| y < self.l.height(x, z))
|
||||
}
|
||||
}
|
||||
|
||||
impl Setup {
|
||||
pub fn new(systems: usize, smart: bool, seed: u64) -> Self {
|
||||
Setup { systems, smart, seed, size: 36, radars: (systems / 10).max(1), objects: 36, tweak: |_| {}, hilly: false, bury: 0.0, disc: None, mountains: false, dist: 500.0, steep: std::env::var("STEEP").ok().and_then(|v| v.parse().ok()).unwrap_or(1.0), trees: std::env::var("TREES").is_ok() }
|
||||
}
|
||||
}
|
||||
|
||||
/// The cluster: `objects` in a grid, systems of the mix scattered round them, radars among them.
|
||||
pub(super) fn cluster(sim: &mut Sim, s: &Setup) {
|
||||
let l = Loader::new(s);
|
||||
let y = |x: f64, z: f64| if s.hilly { l.bare(x as i32, z as i32) - s.bury } else { 70.0 };
|
||||
let mut rng = Rng::new(s.seed.wrapping_mul(977) + 5);
|
||||
let side = (s.objects as f64).sqrt().ceil() as usize;
|
||||
for k in 0..s.objects {
|
||||
let (px, pz) = (((k % side) as f64 - side as f64 / 2.0) * 70.0, ((k / side) as f64 - side as f64 / 2.0) * 70.0);
|
||||
let p = DVec3::new(px, if s.hilly { y(px, pz) + 6.0 + s.bury } else { 70.0 }, pz);
|
||||
sim.targets.push(p);
|
||||
sim.target_health.push(100.0);
|
||||
}
|
||||
let objects = sim.targets.clone();
|
||||
for i in 0..s.systems {
|
||||
let at = objects[(rng.f() * objects.len() as f64) as usize % objects.len()];
|
||||
let a = rng.f() * TAU;
|
||||
let r = 30.0 + rng.f() * 110.0;
|
||||
let id = sim.id();
|
||||
let (px, pz) = (at.x + a.sin() * r, at.z + a.cos() * r);
|
||||
sim.sams.push(Sam::new(id, MIX[i % MIX.len()], DVec3::new(px, y(px, pz), pz), rng.f() * TAU));
|
||||
}
|
||||
for _ in 0..s.radars {
|
||||
let a = rng.f() * TAU;
|
||||
let r = rng.f() * 220.0;
|
||||
let id = sim.id();
|
||||
let (px, pz) = (a.sin() * r, a.cos() * r);
|
||||
sim.sams.push(Sam::new(id, SamKind::Radar, DVec3::new(px, if s.hilly { y(px, pz) } else { 70.0 }, pz), 0.0));
|
||||
}
|
||||
}
|
||||
|
||||
/// Flies one raid to its end and counts.
|
||||
pub(super) fn fly(s: &Setup) -> Result {
|
||||
let mut sim = Sim::new(s.seed);
|
||||
cluster(&mut sim, s);
|
||||
(s.tweak)(&mut sim);
|
||||
let mut ground = Ground::default();
|
||||
let mut land = Loader::new(s);
|
||||
let mut out = Out::default();
|
||||
for _ in 0..200 {
|
||||
land.serve(&mut ground, sim.tick);
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
}
|
||||
let mut order = RaidOrder::mix(s.size, s.dist);
|
||||
// The Oreshnik's blocks are a raid of their own; this measures the ordinary mass raid.
|
||||
order.kinds.retain(|k| k.0 != DroneKind::Oreshnik);
|
||||
if s.smart {
|
||||
order.aim = raid::Aim::Smart;
|
||||
order.approach = raid::Approach::AllSides;
|
||||
}
|
||||
let targets = sim.targets.clone();
|
||||
let fired0: u32 = sim.sams.iter().map(|m| m.fired).sum();
|
||||
sim.order_raid(&order, &targets, &mut out);
|
||||
let mut hist: HashMap<u32, Hist> = HashMap::new();
|
||||
let mut result = Result::default();
|
||||
let start = sim.tick;
|
||||
let mut gone_unkilled: Vec<Hist> = Vec::new();
|
||||
for _ in 0..9000 {
|
||||
land.serve(&mut ground, sim.tick);
|
||||
out = Out::default();
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
let now = sim.tick;
|
||||
for d in &sim.drones {
|
||||
let h = hist.entry(d.id).or_default();
|
||||
h.kind = Some(d.kind);
|
||||
h.last = (d.pos, d.target);
|
||||
if !d.alive() {
|
||||
h.dead = true;
|
||||
continue;
|
||||
}
|
||||
if sim.sams.iter().any(|m| m.seen.contains(&d.id)) {
|
||||
h.seen += 1;
|
||||
}
|
||||
let class = d.kind.spec().class.bit();
|
||||
let covers = |m: &&Sam| {
|
||||
m.alive() && m.roles & class != 0 && m.missiles > 0 && m.kind.spec().missile.as_ref().is_some_and(|l| (l.min..l.max).contains(&m.pos.distance(d.pos)))
|
||||
};
|
||||
let ttg = why::arrival(d);
|
||||
if h.cover == 0 && sim.sams.iter().filter(covers).next().is_some() {
|
||||
h.ttg.0 = ttg;
|
||||
}
|
||||
if h.reach == 0 && sim.sams.iter().filter(covers).any(|m| m.seen.contains(&d.id)) {
|
||||
h.ttg.1 = ttg;
|
||||
}
|
||||
h.cover += u32::from(sim.sams.iter().filter(covers).next().is_some());
|
||||
h.reach += u32::from(sim.sams.iter().filter(covers).any(|m| m.seen.contains(&d.id)));
|
||||
}
|
||||
for m in &sim.missiles {
|
||||
if let Some(h) = hist.get_mut(&m.target) {
|
||||
if h.shots.is_empty() {
|
||||
h.ttg.2 = h.last.0.distance(h.last.1) / h.kind.map_or(1.0, |k| k.spec().speed);
|
||||
}
|
||||
h.shots.insert(m.id);
|
||||
}
|
||||
}
|
||||
// Drones gone from the sky that were never brought down arrived (or crashed).
|
||||
let here: std::collections::HashSet<u32> = sim.drones.iter().map(|d| d.id).collect();
|
||||
let queued: std::collections::HashSet<u32> = sim.queue.iter().map(|q| q.1.id).collect();
|
||||
let vanished: Vec<u32> = hist.iter().filter(|(id, h)| !here.contains(id) && !queued.contains(id) && !h.dead && h.kind.is_some()).map(|(id, _)| *id).collect();
|
||||
for id in vanished {
|
||||
if let Some(h) = hist.remove(&id) {
|
||||
// Gone from the sky near its aim: arrived. (A kill that detonates or breaks up removes the drone too.)
|
||||
let k = h.kind.unwrap();
|
||||
if !k.spec().decoy && h.last.0.distance(h.last.1) < 2.0 * k.spec().speed + 12.0 {
|
||||
if std::env::var("LEAKS").is_ok() {
|
||||
eprintln!(" leak {k:?} seen {} cover {} reach {} shots {} ttg cover/track/shot {:.0}/{:.0}/{:.0}", h.seen, h.cover, h.reach, h.shots.len(), h.ttg.0, h.ttg.1, h.ttg.2);
|
||||
}
|
||||
gone_unkilled.push(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Dead ones that have landed are forgotten.
|
||||
hist.retain(|id, h| !(h.dead && !here.contains(id)));
|
||||
if now - start > 300 && sim.queue.is_empty() && !sim.planning() && !sim.drones.iter().any(|d| d.alive()) && sim.missiles.is_empty() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
result.tickets = land.tickets;
|
||||
result.scrubs = sim.scrubs.clone();
|
||||
result.crashed = sim.crashed.iter().map(|c| (c.0, c.1, c.1.distance(c.2))).collect();
|
||||
result.ticks = sim.tick - start;
|
||||
result.launched = sim.launched;
|
||||
result.kills = sim.kills;
|
||||
result.missiles = sim.sams.iter().map(|m| m.fired).sum::<u32>() - fired0;
|
||||
result.heavy = sim.sams.iter().filter(|m| matches!(m.kind, SamKind::S400 | SamKind::S500 | SamKind::Patriot)).map(|m| m.fired).sum();
|
||||
result.hits = sim.hits;
|
||||
result.crashes = sim.crashes;
|
||||
result.blocked = sim.tally.blocked;
|
||||
result.scrubbed = sim.tally.scrubbed;
|
||||
result.leaked = sim.hits;
|
||||
let mut kinds: HashMap<DroneKind, (u32, u32)> = HashMap::new();
|
||||
for h in &gone_unkilled {
|
||||
let k = h.kind.unwrap();
|
||||
kinds.entry(k).or_default().0 += 1;
|
||||
if h.seen == 0 {
|
||||
result.unseen += 1;
|
||||
} else if h.cover == 0 {
|
||||
result.no_cover += 1;
|
||||
} else if h.reach == 0 {
|
||||
result.untracked += 1;
|
||||
} else if h.shots.is_empty() {
|
||||
result.unshot += 1;
|
||||
} else {
|
||||
result.missed += 1;
|
||||
}
|
||||
}
|
||||
result.by_kind = kinds.into_iter().map(|(k, v)| (k, v.0, v.1)).collect();
|
||||
result.by_kind.sort_by_key(|k| k.0 as u8);
|
||||
result.tally = sim.tally.text();
|
||||
result
|
||||
}
|
||||
|
||||
pub(super) fn table(title: &str, smart: bool, size: u32, systems: &[usize], seeds: &[u64], tweak: fn(&mut Sim)) -> Vec<(usize, f64)> {
|
||||
table_on(title, smart, size, systems, seeds, tweak, std::env::var("HILLS").is_ok())
|
||||
}
|
||||
|
||||
pub(super) fn table_on(title: &str, smart: bool, size: u32, systems: &[usize], seeds: &[u64], tweak: fn(&mut Sim), hilly: bool) -> Vec<(usize, f64)> {
|
||||
let mut means = Vec::new();
|
||||
eprintln!("== {title} ({} raid{})", if smart { "smart" } else { "mix" }, if hilly { ", hills" } else { "" });
|
||||
eprintln!("{:>4} {:>4} {:>5} {:>5} {:>5} {:>6} {:>6} | leaks: unseen nocover untrk unshot missed hits crash blkd scrub", "sams", "seed", "sent", "kills", "leak", "missil", "heavy");
|
||||
for &n in systems {
|
||||
let (mut total, mut missiles, mut heavy, mut clean, mut crashes, mut blocked) = (0, 0, 0, 0, 0, 0);
|
||||
for &seed in seeds {
|
||||
let mut s = Setup::new(n, smart, seed);
|
||||
s.tweak = tweak;
|
||||
s.size = size;
|
||||
s.hilly = hilly;
|
||||
let r = fly(&s);
|
||||
total += r.leaked;
|
||||
clean += u32::from(r.leaked == 0);
|
||||
crashes += r.crashes;
|
||||
blocked += r.blocked + r.scrubbed;
|
||||
missiles += r.missiles;
|
||||
heavy += r.heavy;
|
||||
if std::env::var("ROWS").is_ok() { eprintln!("{n:>4} {seed:>4} {:>5} {:>5} {:>5} {:>6} {:>6} | {:>12} {:>7} {:>5} {:>6} {:>6} {:>4} {:>5} {:>4} {:>5} {:?}", r.launched, r.kills, r.leaked, r.missiles, r.heavy, r.unseen, r.no_cover, r.untracked, r.unshot, r.missed, r.hits, r.crashes, r.blocked, r.scrubbed, r.by_kind.iter().map(|k| format!("{:?}:{}", k.0, k.1)).collect::<Vec<_>>()); }
|
||||
if seed == seeds[0] && std::env::var("ROWS").is_ok() {
|
||||
eprintln!(" tally: {}", r.tally);
|
||||
}
|
||||
}
|
||||
let mean = total as f64 / seeds.len() as f64;
|
||||
let k = seeds.len() as f64;
|
||||
eprintln!("{n:>4} mean leaks {mean:.1} (clean seeds {clean}/{}), missiles {:.0}, of them heavy {:.0}, drone crashes {:.1}, interceptors lost to land {:.1}", seeds.len(), missiles as f64 / k, heavy as f64 / k, crashes as f64 / k, blocked as f64 / k);
|
||||
means.push((n, mean));
|
||||
}
|
||||
means
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn buried_table() {
|
||||
for n in [20usize, 150] {
|
||||
for seed in 1..=4u64 {
|
||||
let mut s = Setup::new(n, false, seed);
|
||||
s.hilly = true;
|
||||
s.bury = 7.0;
|
||||
let r = fly(&s);
|
||||
eprintln!("buried {n} seed {seed}: sent {} kills {} leaked {} crashes {} blocked {} missiles {}", r.launched, r.kills, r.leaked, r.crashes, r.blocked, r.missiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn hills_table() {
|
||||
table_on("hills", false, 36, &[20, 50, 150], &[1, 2, 3, 4, 5, 6], |_| {}, true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn raid_table() {
|
||||
for smart in [false, true] {
|
||||
table("current", smart, 36, &[20, 50, 150], &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], |_| {});
|
||||
}
|
||||
}
|
||||
|
||||
/// A raid of 80 (about 100 drones): 20 systems clearly lose, 150 hold (a loose bound, one seed).
|
||||
#[test]
|
||||
fn a_small_cluster_loses_and_a_big_one_holds() {
|
||||
let mut s = Setup::new(20, false, 2);
|
||||
s.size = 80;
|
||||
let small = fly(&s);
|
||||
let mut s = Setup::new(150, false, 2);
|
||||
s.size = 80;
|
||||
let big = fly(&s);
|
||||
eprintln!("20 systems: {small:?}\n150 systems: {big:?}");
|
||||
assert!(small.launched >= 80, "the raid was not launched: {small:?}");
|
||||
assert!(small.leaked >= 10, "20 systems should clearly lose, leaked {}", small.leaked);
|
||||
assert!(big.leaked <= 5, "150 systems leaked {}", big.leaked);
|
||||
}
|
||||
|
||||
/// The same on rolling hills: 150 systems still hold about as on flat land, drones do not fly into the land on
|
||||
/// their own, and the interceptors do not routinely strike it (a few that blow up short of a ridge are allowed).
|
||||
#[test]
|
||||
fn on_hills_a_big_cluster_holds_and_nothing_routinely_hits_the_land() {
|
||||
let mut s = Setup::new(150, false, 2);
|
||||
s.size = 80;
|
||||
s.hilly = true;
|
||||
let big = fly(&s);
|
||||
let mut s = Setup::new(20, false, 2);
|
||||
s.size = 80;
|
||||
s.hilly = true;
|
||||
let small = fly(&s);
|
||||
eprintln!("hills, 20 systems: {small:?}\nhills, 150 systems: {big:?}");
|
||||
assert!(small.leaked >= 10, "20 systems should clearly lose on hills too, leaked {}", small.leaked);
|
||||
assert!(big.leaked <= 6, "150 systems on hills leaked {}", big.leaked);
|
||||
assert!(big.crashes <= 2, "drones flew into the hills: {}", big.crashes);
|
||||
assert!(big.blocked * 20 <= big.missiles, "interceptors struck the land: {} of {}", big.blocked, big.missiles);
|
||||
}
|
||||
|
||||
/// A raid from 2500 blocks over mountains, with only a disc round the player known (and chunks that load on request):
|
||||
/// the flights do not fly into the land by themselves (a rare one that cannot climb a ridge in time is allowed).
|
||||
#[test]
|
||||
fn far_raids_over_mountains_do_not_crash_into_them() {
|
||||
let (mut flown, mut crashed) = (0, 0);
|
||||
for seed in [3u64, 4, 8] {
|
||||
for smart in [false, true] {
|
||||
let mut s = Setup::new(50, smart, seed);
|
||||
s.hilly = true;
|
||||
s.mountains = true;
|
||||
s.dist = 2500.0;
|
||||
s.disc = Some(300.0);
|
||||
let r = fly(&s);
|
||||
eprintln!("seed {seed} smart {smart}: {} crashed of {}: {:?}", r.crashed.len(), r.launched, r.crashed.iter().map(|c| c.0).collect::<Vec<_>>());
|
||||
flown += r.launched;
|
||||
crashed += r.crashed.len() as u32;
|
||||
}
|
||||
}
|
||||
assert!(crashed * 40 <= flown, "{crashed} of {flown} flew into the land");
|
||||
}
|
||||
|
||||
/// Steep forested hills: an interceptor that is fired is one the land lets through. The launch check asks the same
|
||||
/// of a shot as the flight does (the margin over the land, the loft), so few blow up short of a ridge.
|
||||
#[test]
|
||||
fn on_steep_forested_hills_few_interceptors_are_scrubbed() {
|
||||
let (mut fired, mut scrubbed) = (0, 0);
|
||||
for seed in 1..=3u64 {
|
||||
let mut s = Setup::new(15, false, seed);
|
||||
s.radars = 2;
|
||||
s.objects = 4;
|
||||
s.hilly = true;
|
||||
s.steep = 1.6;
|
||||
s.trees = true;
|
||||
let r = fly(&s);
|
||||
fired += r.missiles;
|
||||
scrubbed += r.scrubbed;
|
||||
}
|
||||
eprintln!("scrubbed {scrubbed} of {fired}");
|
||||
assert!(scrubbed * 100 <= fired * 10, "{scrubbed} of {fired} interceptors blew up short of a ridge");
|
||||
}
|
||||
|
||||
/// What each of the new rules adds, one at a time (the raid of 36 and a heavier one of 80).
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn rules_one_by_one() {
|
||||
for size in [36, 80] {
|
||||
for smart in [false, true] {
|
||||
table(&format!("size {size}: roles only"), smart, size, &[20, 50, 150], &[1, 2, 3, 4, 5, 6], |s| {
|
||||
s.last_chance = false;
|
||||
s.far_shots = false;
|
||||
});
|
||||
table(&format!("size {size}: + last chance"), smart, size, &[20, 50, 150], &[1, 2, 3, 4, 5, 6], |s| s.far_shots = false);
|
||||
table(&format!("size {size}: + last chance + long shots"), smart, size, &[20, 50, 150], &[1, 2, 3, 4, 5, 6], |_| {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One raid in detail, for hunting a leak: `LEAKS=1 cargo test --release one_raid -- --ignored --nocapture`.
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn one_raid() {
|
||||
let n: usize = std::env::var("SAMS").ok().and_then(|v| v.parse().ok()).unwrap_or(150);
|
||||
let smart = std::env::var("SMART").is_ok();
|
||||
let size: u32 = std::env::var("SIZE").ok().and_then(|v| v.parse().ok()).unwrap_or(36);
|
||||
for seed in 1..=12 {
|
||||
let mut s = Setup::new(n, smart, seed);
|
||||
s.size = size;
|
||||
let r = fly(&s);
|
||||
eprintln!("seed {seed}: sent {} kills {} leaked {} missiles {} ticks {}", r.launched, r.kills, r.leaked, r.missiles, r.ticks);
|
||||
}
|
||||
}
|
||||
|
||||
/// Far launches over mountains where only a disc round the player is known: who crashes, where and how often.
|
||||
/// `cargo test --release far_table -- --ignored --nocapture` (DISC=300 sets the radius, 0 for all known).
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn far_table() {
|
||||
let disc: f64 = std::env::var("DISC").ok().and_then(|v| v.parse().ok()).unwrap_or(300.0);
|
||||
let dist: f64 = std::env::var("DIST").ok().and_then(|v| v.parse().ok()).unwrap_or(2500.0);
|
||||
let mut by_kind: HashMap<DroneKind, (u32, u32)> = HashMap::new();
|
||||
let (mut launched, mut kills, mut leaked, mut tickets) = (0, 0, 0, 0);
|
||||
for seed in std::env::var("SEED").ok().and_then(|v| v.parse::<u64>().ok()).map_or(1..=8u64, |v| v..=v) {
|
||||
let mut s = Setup::new(50, std::env::var("SMART").is_ok(), seed);
|
||||
s.hilly = true;
|
||||
s.mountains = true;
|
||||
s.dist = dist;
|
||||
s.disc = (disc > 0.0).then_some(disc);
|
||||
let r = fly(&s);
|
||||
launched += r.launched;
|
||||
kills += r.kills;
|
||||
leaked += r.leaked;
|
||||
tickets += r.tickets;
|
||||
for c in &r.crashed {
|
||||
by_kind.entry(c.0).or_default().0 += 1;
|
||||
if std::env::var("ROWS").is_ok() {
|
||||
let (x, z) = (c.1.x as i32, c.1.z as i32);
|
||||
eprintln!(" seed {seed} {:?} crashed at {:.0},{:.0},{:.0} ({:.0} from origin, land {}), {:.0} from its aim", c.0, c.1.x, c.1.y, c.1.z, c.1.x.hypot(c.1.z), Loader::new(&s).height(x, z), c.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut v: Vec<_> = by_kind.into_iter().collect();
|
||||
v.sort_by_key(|k| k.0 as u8);
|
||||
eprintln!("disc {disc} dist {dist}: launched {launched} kills {kills} leaked {leaked} chunk tickets {tickets}; crashed by kind {:?}", v.iter().map(|k| (k.0.clone(), k.1.0)).collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
/// Interceptors that blew up short of a ridge (`STEEP=1.6`, `SAMS=15`, `HILLS=0` for flat): by kind, and what the target was doing.
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn scrub_table() {
|
||||
let n: usize = std::env::var("SAMS").ok().and_then(|v| v.parse().ok()).unwrap_or(15);
|
||||
let hilly = std::env::var("HILLS").map_or(true, |v| v != "0");
|
||||
let (mut fired, mut scrubbed, mut kills, mut launched, mut leaked) = (0, 0, 0, 0, 0);
|
||||
let mut by: HashMap<String, (u32, u32)> = HashMap::new();
|
||||
let (mut near, mut low) = (0, 0);
|
||||
for seed in 1..=8u64 {
|
||||
let mut s = Setup::new(n, false, seed);
|
||||
s.radars = 2;
|
||||
s.objects = 4;
|
||||
s.hilly = hilly;
|
||||
let r = fly(&s);
|
||||
fired += r.missiles;
|
||||
scrubbed += r.scrubbed;
|
||||
kills += r.kills;
|
||||
launched += r.launched;
|
||||
leaked += r.leaked;
|
||||
for c in &r.scrubs {
|
||||
by.entry(format!("{:?}", c.0)).or_default().0 += 1;
|
||||
near += u32::from(c.2 < 150.0);
|
||||
low += u32::from(c.3 < 30.0);
|
||||
}
|
||||
}
|
||||
let mut v: Vec<_> = by.into_iter().collect();
|
||||
v.sort();
|
||||
eprintln!("sams {n} hilly {hilly}: launched {launched} kills {kills} leaked {leaked} missiles {fired} scrubbed {scrubbed} (target within 150: {near}, target under 30 over land: {low}) by kind {:?}", v.iter().map(|k| (k.0.clone(), k.1.0)).collect::<Vec<_>>());
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
//! Stable identities and availability for the existing simulation content.
|
||||
//!
|
||||
//! Balance and rendering remain in `DroneSpec` and `SamSpec`: the catalog
|
||||
//! refers to those typed definitions instead of copying their values. The
|
||||
//! first eleven drone entries retain the historical positional wave-save order.
|
||||
use super::{DroneKind, SamKind};
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Aircraft {
|
||||
pub kind: DroneKind,
|
||||
/// Inventory item, when this type has a player launch item.
|
||||
pub launch_item: Option<&'static str>,
|
||||
/// May appear as a selectable type in the raid menu.
|
||||
pub raid: bool,
|
||||
}
|
||||
|
||||
impl Aircraft {
|
||||
/// Existing save/command key; changing it requires an explicit migration.
|
||||
pub fn id(self) -> &'static str { self.kind.spec().key }
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum GroundStrike {
|
||||
/// The game has no confirmed compatible ground-attack loadout for this unit.
|
||||
/// This is a content limitation, not a claim about the real equipment.
|
||||
Unavailable { reason: &'static str },
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Unit {
|
||||
pub kind: SamKind,
|
||||
pub deploy_item: &'static str,
|
||||
}
|
||||
|
||||
impl Unit {
|
||||
pub fn id(self) -> &'static str { self.kind.spec().key }
|
||||
pub fn ground_strike(self) -> GroundStrike {
|
||||
GroundStrike::Unavailable { reason: "Для этой техники не задан подтверждённый профиль удара по координатам" }
|
||||
}
|
||||
}
|
||||
|
||||
use DroneKind::*;
|
||||
/// The raid entries come first, in the order stored by existing scenario files.
|
||||
pub const AIRCRAFT: &[Aircraft] = &[
|
||||
Aircraft { kind: Gerbera, launch_item: None, raid: true },
|
||||
Aircraft { kind: Shahed, launch_item: Some("airdef:launch_shahed"), raid: true },
|
||||
Aircraft { kind: Geran3, launch_item: Some("airdef:launch_geran3"), raid: true },
|
||||
Aircraft { kind: Lancet, launch_item: Some("airdef:launch_lancet"), raid: true },
|
||||
Aircraft { kind: Kh101, launch_item: Some("airdef:launch_kh101"), raid: true },
|
||||
Aircraft { kind: Kalibr, launch_item: Some("airdef:launch_kalibr"), raid: true },
|
||||
Aircraft { kind: Kh22, launch_item: Some("airdef:launch_kh22"), raid: true },
|
||||
Aircraft { kind: Zircon, launch_item: Some("airdef:launch_zircon"), raid: true },
|
||||
Aircraft { kind: Iskander, launch_item: Some("airdef:launch_iskander"), raid: true },
|
||||
Aircraft { kind: Kinzhal, launch_item: Some("airdef:launch_kinzhal"), raid: true },
|
||||
Aircraft { kind: Oreshnik, launch_item: Some("airdef:launch_oreshnik"), raid: true },
|
||||
Aircraft { kind: OreshnikBlock, launch_item: None, raid: false },
|
||||
Aircraft { kind: OreshnikSub, launch_item: None, raid: false },
|
||||
];
|
||||
|
||||
macro_rules! units {
|
||||
($( $kind:ident => $item:literal ),+ $(,)?) => {
|
||||
pub const UNITS: &[Unit] = &[$(Unit { kind: SamKind::$kind, deploy_item: $item }),+];
|
||||
};
|
||||
}
|
||||
units! {
|
||||
Patriot => "airdef:deploy_patriot", Gepard => "airdef:deploy_gepard",
|
||||
Pantsir => "airdef:deploy_pantsir", S400 => "airdef:deploy_s400",
|
||||
S500 => "airdef:deploy_s500", IrisT => "airdef:deploy_irist",
|
||||
Nasams => "airdef:deploy_nasams", Buk => "airdef:deploy_buk",
|
||||
Tor => "airdef:deploy_tor", P1sun => "airdef:deploy_p1sun",
|
||||
Radar => "airdef:deploy_radar", Depot => "airdef:deploy_depot",
|
||||
Tzm => "airdef:deploy_tzm", Ew => "airdef:deploy_ew", Light => "airdef:deploy_light",
|
||||
}
|
||||
|
||||
/// Existing positional serialization makes the first entries' order part of the save format.
|
||||
const fn raid_count() -> usize {
|
||||
let mut i = 0;
|
||||
let mut count = 0;
|
||||
while i < AIRCRAFT.len() {
|
||||
if AIRCRAFT[i].raid { count += 1; }
|
||||
i += 1;
|
||||
}
|
||||
count
|
||||
}
|
||||
pub const RAID_COUNT: usize = raid_count();
|
||||
const fn raid_kinds() -> [DroneKind; RAID_COUNT] {
|
||||
let mut result = [Gerbera; RAID_COUNT];
|
||||
let mut i = 0;
|
||||
let mut out = 0;
|
||||
while i < AIRCRAFT.len() {
|
||||
if AIRCRAFT[i].raid { result[out] = AIRCRAFT[i].kind; out += 1; }
|
||||
i += 1;
|
||||
}
|
||||
result
|
||||
}
|
||||
pub const RAID_KINDS: [DroneKind; RAID_COUNT] = raid_kinds();
|
||||
|
||||
pub const UNIT_COUNT: usize = UNITS.len();
|
||||
const fn unit_kinds() -> [SamKind; UNIT_COUNT] {
|
||||
let mut result = [SamKind::Patriot; UNIT_COUNT];
|
||||
let mut i = 0;
|
||||
while i < result.len() { result[i] = UNITS[i].kind; i += 1; }
|
||||
result
|
||||
}
|
||||
pub const UNIT_KINDS: [SamKind; UNIT_COUNT] = unit_kinds();
|
||||
|
||||
pub fn unit(kind: SamKind) -> &'static Unit {
|
||||
UNITS.iter().find(|entry| entry.kind == kind).expect("unit kind missing from catalog")
|
||||
}
|
||||
|
||||
/// Inventory ordering is stable for existing remotes, while availability comes from the same entries as raids.
|
||||
const fn inventory_count() -> usize {
|
||||
let mut n = UNIT_COUNT + 4;
|
||||
let mut i = 0;
|
||||
while i < AIRCRAFT.len() {
|
||||
if AIRCRAFT[i].launch_item.is_some() { n += 1; }
|
||||
i += 1;
|
||||
}
|
||||
n
|
||||
}
|
||||
pub const INVENTORY_COUNT: usize = inventory_count();
|
||||
const fn inventory_items() -> [&'static str; INVENTORY_COUNT] {
|
||||
let mut out = [""; INVENTORY_COUNT];
|
||||
out[0] = "airdef:designator";
|
||||
let mut n = 1;
|
||||
let mut i = 0;
|
||||
while i < AIRCRAFT.len() {
|
||||
if let Some(item) = AIRCRAFT[i].launch_item { out[n] = item; n += 1; }
|
||||
i += 1;
|
||||
}
|
||||
i = 0;
|
||||
while i < UNITS.len() { out[n] = UNITS[i].deploy_item; n += 1; i += 1; }
|
||||
out[n] = "airdef:mover";
|
||||
out[n + 1] = "airdef:flare_gun";
|
||||
out[n + 2] = "airdef:remover";
|
||||
out
|
||||
}
|
||||
pub const INVENTORY: [&str; INVENTORY_COUNT] = inventory_items();
|
||||
|
||||
pub fn launch_item(id: &str) -> Option<DroneKind> {
|
||||
AIRCRAFT.iter().find(|entry| entry.launch_item == Some(id)).map(|entry| entry.kind)
|
||||
}
|
||||
pub fn deploy_item(id: &str) -> Option<SamKind> {
|
||||
UNITS.iter().find(|entry| entry.deploy_item == id).map(|entry| entry.kind)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::collections::HashSet;
|
||||
use super::super::units::Muzzle;
|
||||
|
||||
#[test]
|
||||
fn identities_cover_the_simulation_and_raid_order_is_compatible() {
|
||||
let mut ids = HashSet::new();
|
||||
let mut kinds = HashSet::new();
|
||||
let mut items = HashSet::new();
|
||||
for (i, e) in AIRCRAFT.iter().enumerate() {
|
||||
assert!(ids.insert(e.id()), "duplicate aircraft ID {}", e.id());
|
||||
assert!(kinds.insert(e.kind), "duplicate aircraft kind {:?}", e.kind);
|
||||
if i < 11 { assert!(e.raid); }
|
||||
if let Some(item) = e.launch_item {
|
||||
assert!(items.insert(item), "duplicate item {item}");
|
||||
assert_eq!(item, format!("airdef:launch_{}", e.id()));
|
||||
}
|
||||
}
|
||||
assert_eq!(kinds, DroneKind::ALL.into_iter().collect());
|
||||
let mut kinds = HashSet::new();
|
||||
for e in UNITS {
|
||||
assert!(ids.insert(e.id()), "duplicate unit ID {}", e.id());
|
||||
assert!(kinds.insert(e.kind), "duplicate unit kind {:?}", e.kind);
|
||||
assert!(items.insert(e.deploy_item), "duplicate item {}", e.deploy_item);
|
||||
assert_eq!(e.deploy_item, format!("airdef:deploy_{}", e.id()));
|
||||
let spec = e.kind.spec();
|
||||
assert!(spec.sensor.is_finite() && spec.sensor >= 0.0);
|
||||
match (&spec.missile, spec.muzzle) {
|
||||
(Some(_), Muzzle::None) => panic!("{} has missiles but no muzzle", e.id()),
|
||||
(_, Muzzle::Grid(cols, rows, size)) => assert!(cols > 0 && rows > 0 && size.is_finite() && size > 0.0),
|
||||
(_, Muzzle::Rails(xs)) => assert!(!xs.is_empty() && xs.iter().all(|v| v.is_finite())),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
}
|
||||
assert_eq!(kinds, SamKind::ALL.into_iter().collect());
|
||||
assert_eq!(&RAID_KINDS[..11], &[Gerbera, Shahed, Geran3, Lancet, Kh101, Kalibr, Kh22, Zircon, Iskander, Kinzhal, Oreshnik]);
|
||||
}
|
||||
}
|
||||
@@ -186,6 +186,21 @@ impl DroneKind {
|
||||
}
|
||||
|
||||
impl Sim {
|
||||
/// Apply combat consequences first, independently of whether a recorder is active.
|
||||
pub(super) fn emit_combat_event(&mut self, pos: DVec3, kind: record::EventKind) {
|
||||
match kind {
|
||||
record::EventKind::Crash { power, .. } => self.ignite(pos, power, None),
|
||||
record::EventKind::Hit { power, sam, .. } => {
|
||||
let host = sam.and_then(|(_, i)| self.sams.get(i)).map(|s| s.id);
|
||||
self.ignite(pos, power.max(1), host)
|
||||
}
|
||||
record::EventKind::SamLost { sam, .. } => self.ignite(pos, 2, Some(sam)),
|
||||
record::EventKind::Strike { result, .. } if record::strike_power(result) > 0 => self.ignite(pos, record::strike_power(result), None),
|
||||
_ => {}
|
||||
}
|
||||
self.record_event(pos, kind);
|
||||
}
|
||||
|
||||
/// The aim error of a new strike: drawn once from the seed, the drone keeps it for its whole flight.
|
||||
pub(super) fn aim_error(&mut self, kind: DroneKind) -> DVec3 {
|
||||
let (cep, gross) = kind.accuracy();
|
||||
@@ -330,7 +345,7 @@ impl Sim {
|
||||
let tnt = if charge > 4.0 && self.rng.chance(0.4) { 2 } else { 1 };
|
||||
self.later.push((when, at, tnt, true));
|
||||
}
|
||||
self.log(pos, record::EventKind::SamLost { sam: id, kind, index: i });
|
||||
self.emit_combat_event(pos, record::EventKind::SamLost { sam: id, kind, index: i });
|
||||
// Shells pop in strings.
|
||||
for k in 0..(bursts / 12).min(14) {
|
||||
let when = now + 10 + (k as u64) * 6 + (self.rng.f() * 8.0) as u64;
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
//! Fire doctrine (#47): what a system is told about its job beyond the roles. Protected objects (it fires
|
||||
//! only at what threatens them), a sector of responsibility, a reserve of missiles held back for what
|
||||
//! matters, and how many interceptors it asks for on one target. The predicates are shared by `step_sams`
|
||||
//! (through `why::basis`) and the diagnostic; the default doctrine blocks nothing and changes nothing.
|
||||
//! Everything is judged on the system's track (its forecast), never on the drone's true place.
|
||||
use super::*;
|
||||
|
||||
/// How many interceptors a system asks for on one target: the base shoot-look-shoot only, as now, or one more.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
|
||||
pub enum Salvo {
|
||||
Economy,
|
||||
#[default]
|
||||
Normal,
|
||||
Heavy,
|
||||
}
|
||||
|
||||
impl Salvo {
|
||||
pub fn name(self) -> &'static str {
|
||||
match self {
|
||||
Salvo::Economy => "экономный",
|
||||
Salvo::Normal => "обычный",
|
||||
Salvo::Heavy => "усиленный",
|
||||
}
|
||||
}
|
||||
pub fn key(self) -> &'static str {
|
||||
match self {
|
||||
Salvo::Economy => "eco",
|
||||
Salvo::Normal => "normal",
|
||||
Salvo::Heavy => "heavy",
|
||||
}
|
||||
}
|
||||
pub fn from_key(s: &str) -> Option<Salvo> {
|
||||
[Salvo::Economy, Salvo::Normal, Salvo::Heavy].into_iter().find(|v| v.key() == s)
|
||||
}
|
||||
pub fn next(self) -> Salvo {
|
||||
match self {
|
||||
Salvo::Economy => Salvo::Normal,
|
||||
Salvo::Normal => Salvo::Heavy,
|
||||
Salvo::Heavy => Salvo::Economy,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A system's doctrine. `Default` is the sandbox: no guards, no sector, no reserve, the usual salvo.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct Doctrine {
|
||||
/// Protected objects (their places): when any, the system fires only at what threatens one of them.
|
||||
pub guards: Vec<DVec3>,
|
||||
/// Sector of responsibility: centre (a yaw as `heading_of`, radians) and half-width.
|
||||
pub sector: Option<(f64, f64)>,
|
||||
/// Missiles held back: below this many, only what matters is shot at.
|
||||
pub reserve: u32,
|
||||
pub salvo: Salvo,
|
||||
}
|
||||
|
||||
/// Where a track counts as threatening an object: within this many blocks of it, or flying at it.
|
||||
pub const GUARD_R: f64 = 120.0;
|
||||
/// Most missiles one can reserve.
|
||||
pub const MAX_RESERVE: u32 = 64;
|
||||
|
||||
pub(super) const OUT_SECTOR: u8 = 1;
|
||||
pub(super) const NO_THREAT: u8 = 2;
|
||||
pub(super) const RESERVE: u8 = 4;
|
||||
|
||||
impl Doctrine {
|
||||
pub fn is_default(&self) -> bool {
|
||||
*self == Doctrine::default()
|
||||
}
|
||||
|
||||
/// Whether the track is within the sector (judged from the system's place).
|
||||
pub fn in_sector(&self, pos: DVec3, at: DVec3) -> bool {
|
||||
self.sector.is_none_or(|(centre, half)| {
|
||||
let to = at - pos;
|
||||
to.x.hypot(to.z) < 30.0 || angle_diff(centre, heading_of(to)).abs() <= half
|
||||
})
|
||||
}
|
||||
|
||||
/// The first protected object the track threatens (its index in `guards`): near it, or flying towards it.
|
||||
pub fn threatens(&self, track: &Track, now: u64) -> Option<usize> {
|
||||
let at = track.est(now);
|
||||
let slack = GUARD_R + track.uncertainty(now);
|
||||
self.guards.iter().position(|g| {
|
||||
let (dx, dz) = (g.x - at.x, g.z - at.z);
|
||||
let near = dx.hypot(dz);
|
||||
if near <= slack {
|
||||
return true;
|
||||
}
|
||||
let (vx, vz) = (track.vel.x, track.vel.z);
|
||||
let speed = vx.hypot(vz);
|
||||
// Closing, and the line of flight passes the object within the slack.
|
||||
speed > 1e-3 && vx * dx + vz * dz > 0.0 && (vx * dz - vz * dx).abs() / speed <= slack
|
||||
})
|
||||
}
|
||||
|
||||
/// Why the area (sector, protected objects) rules the track out; 0 is a pass.
|
||||
pub fn area_blocks(&self, pos: DVec3, track: &Track, now: u64) -> u8 {
|
||||
(if self.in_sector(pos, track.est(now)) { 0 } else { OUT_SECTOR }) | (if self.guards.is_empty() || self.threatens(track, now).is_some() { 0 } else { NO_THREAT })
|
||||
}
|
||||
|
||||
/// What matters enough to spend the reserve: a ballistic missile, or anything about to hit.
|
||||
pub fn matters(d: &Drone) -> bool {
|
||||
d.kind.spec().class == Class::Ballistic || why::arrival(d) < why::URGENT
|
||||
}
|
||||
|
||||
/// The reserve holds the launch back: the magazine is at the reserve and the target doesn't matter.
|
||||
pub fn reserve_blocks(&self, missiles: u32, d: &Drone) -> u8 {
|
||||
if self.reserve > 0 && missiles <= self.reserve && !Self::matters(d) { RESERVE } else { 0 }
|
||||
}
|
||||
|
||||
/// Interceptors this doctrine asks for on `d`: `why::needed` by default, the base only when economical, one more when heavy.
|
||||
pub fn needed(&self, d: &Drone) -> u32 {
|
||||
let base = if d.kind.spec().class == Class::Ballistic { 2 } else { 1 };
|
||||
match self.salvo {
|
||||
Salvo::Economy => base,
|
||||
Salvo::Normal => why::needed(d),
|
||||
Salvo::Heavy => why::needed(d) + 1,
|
||||
}
|
||||
}
|
||||
|
||||
/// The sector in words (`90±45°`); degrees on the same scale as `/airdef doctrine ... sector`.
|
||||
pub fn sector_text(&self) -> String {
|
||||
match self.sector {
|
||||
Some((c, h)) => format!("{:.0}±{:.0}°", c.to_degrees().rem_euclid(360.0), h.to_degrees()),
|
||||
None => "круговой".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The doctrine as the player reads it, empty for the default.
|
||||
pub fn text(&self, targets: &[DVec3]) -> String {
|
||||
if self.is_default() {
|
||||
return "обычная (без ограничений)".to_string();
|
||||
}
|
||||
let guards = if self.guards.is_empty() {
|
||||
"нет".to_string()
|
||||
} else {
|
||||
self.guards.iter().map(|g| object_name(targets, *g)).collect::<Vec<_>>().join(", ")
|
||||
};
|
||||
format!("охрана: {guards}; сектор: {}; резерв: {}; залп: {}", self.sector_text(), self.reserve, self.salvo.name())
|
||||
}
|
||||
|
||||
/// One line of the save: `salvo reserve sector-centre sector-half guards x y z ...` (`-` for no sector).
|
||||
pub fn save_text(&self) -> String {
|
||||
let sector = self.sector.map_or("- -".to_string(), |(c, h)| format!("{c} {h}"));
|
||||
let mut s = format!("{} {} {sector} {}", self.salvo.key(), self.reserve, self.guards.len());
|
||||
for g in &self.guards {
|
||||
s += &format!(" {} {} {}", g.x, g.y, g.z);
|
||||
}
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
/// An object by number in the world's list ("объект №2"), else by place.
|
||||
pub fn object_name(targets: &[DVec3], g: DVec3) -> String {
|
||||
match targets.iter().position(|t| t.distance(g) < 16.0) {
|
||||
Some(i) => format!("объект №{}", i + 1),
|
||||
None => format!("точка {:.0} {:.0}", g.x, g.z),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn track(pos: DVec3, vel: DVec3) -> Track {
|
||||
Track { id: 1, kind: DroneKind::Shahed, pos, vel, tick: 0, own_tick: 0, ttl: 100, hits: 3, locked: false }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_default_doctrine_blocks_nothing() {
|
||||
let d = Doctrine::default();
|
||||
let t = track(DVec3::new(500.0, 100.0, 0.0), DVec3::ZERO);
|
||||
assert_eq!(d.area_blocks(DVec3::ZERO, &t, 0), 0);
|
||||
assert!(d.is_default());
|
||||
assert_eq!(Doctrine::default().save_text(), "normal 0 - - 0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_sector_and_guards_rule_targets_out_by_their_tracks() {
|
||||
let mut d = Doctrine::default();
|
||||
// North is yaw 0 (towards -z): a sector of 45 degrees either side of north.
|
||||
d.sector = Some((0.0, 45f64.to_radians()));
|
||||
let north = track(DVec3::new(0.0, 100.0, -800.0), DVec3::ZERO);
|
||||
let south = track(DVec3::new(0.0, 100.0, 800.0), DVec3::ZERO);
|
||||
assert_eq!(d.area_blocks(DVec3::ZERO, &north, 0), 0);
|
||||
assert_eq!(d.area_blocks(DVec3::ZERO, &south, 0), OUT_SECTOR);
|
||||
d.sector = None;
|
||||
d.guards = vec![DVec3::new(1000.0, 70.0, 0.0)];
|
||||
// Flying at the object from afar threatens it; flying past, or away, doesn't.
|
||||
let at = track(DVec3::new(-2000.0, 100.0, 10.0), DVec3::new(2.0, 0.0, 0.0));
|
||||
let past = track(DVec3::new(-2000.0, 100.0, 900.0), DVec3::new(2.0, 0.0, 0.0));
|
||||
let away = track(DVec3::new(-2000.0, 100.0, 0.0), DVec3::new(-2.0, 0.0, 0.0));
|
||||
assert_eq!(d.area_blocks(DVec3::ZERO, &at, 0), 0);
|
||||
assert_eq!(d.area_blocks(DVec3::ZERO, &past, 0), NO_THREAT);
|
||||
assert_eq!(d.area_blocks(DVec3::ZERO, &away, 0), NO_THREAT);
|
||||
}
|
||||
|
||||
use super::sites::testland::{Land, serve};
|
||||
|
||||
/// One Patriot against one Shahed flying in from the north at its aim, the doctrine set before the raid:
|
||||
/// the missiles it fired, the Shahed's ticks to its aim at the first launch, and the `why` lines at the end.
|
||||
fn fire(doc: Doctrine) -> (u32, Option<f64>, Vec<String>) {
|
||||
let mut sim = Sim::new(5);
|
||||
let id = sim.id();
|
||||
sim.sams.push(Sam::new(id, SamKind::Buk, DVec3::new(0.0, 70.0, 0.0), 0.0));
|
||||
sim.sams[0].roles = 0xFF;
|
||||
sim.sams[0].doctrine = doc;
|
||||
sim.add_drone(DroneKind::Shahed, DVec3::new(0.0, 75.0, -600.0), DVec3::Z, DVec3::new(0.0, 70.0, -80.0));
|
||||
let (mut ground, land, mut out) = (Ground::default(), Land(|_, _| 64), Out::default());
|
||||
let mut first = None;
|
||||
let mut lines: Vec<String> = Vec::new();
|
||||
for _ in 0..900 {
|
||||
serve(&mut ground, &land, sim.tick);
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
if first.is_none() && sim.sams[0].fired > 0 {
|
||||
first = sim.drones.first().map(why::arrival);
|
||||
}
|
||||
if sim.drones.iter().all(|d| !d.alive()) {
|
||||
break;
|
||||
}
|
||||
// The explanation while the target is in the sky: all the lines it gave then.
|
||||
if sim.tick % 10 == 0 {
|
||||
lines.extend(sim.why(0).into_iter().map(|c| c.text));
|
||||
}
|
||||
}
|
||||
(sim.sams[0].fired, first, lines)
|
||||
}
|
||||
|
||||
// #47: the defaults fire as before; each setting changes the decision and `why` names it
|
||||
#[test]
|
||||
fn each_setting_changes_the_shot_and_why_says_which() {
|
||||
let (base, first, w) = fire(Doctrine::default());
|
||||
assert!(base > 0, "the baseline never fired: {w:?}");
|
||||
let first = first.unwrap();
|
||||
assert!(first > why::URGENT, "the baseline fires late: {first}");
|
||||
let has = |text: &[String], what: &str| text.iter().any(|l| l.contains(what));
|
||||
// The raid comes from the north (yaw 0): a sector round north holds it, one round south does not.
|
||||
let sector = |c: f64| Doctrine { sector: Some((f64::to_radians(c), f64::to_radians(40.0))), ..Default::default() };
|
||||
assert_eq!(fire(sector(0.0)).0, base, "a sector that holds the raid changes nothing");
|
||||
let (n, _, why) = fire(sector(180.0));
|
||||
assert_eq!(n, 0);
|
||||
assert!(has(&why, "вне сектора"), "{why:?}");
|
||||
// A reserve above the magazine holds the shot until the target is urgent.
|
||||
let (n, late, _) = fire(Doctrine { reserve: 64, ..Default::default() });
|
||||
assert!(n > 0 && late.unwrap() < why::URGENT, "{n} {late:?}");
|
||||
// An object far off the raid's line is no one's to guard here; the one it flies at is.
|
||||
let (n, _, why) = fire(Doctrine { guards: vec![DVec3::new(0.0, 70.0, 50000.0)], ..Default::default() });
|
||||
assert_eq!(n, 0);
|
||||
assert!(has(&why, "не угрожает"), "{why:?}");
|
||||
let (n, _, why) = fire(Doctrine { guards: vec![DVec3::new(0.0, 70.0, -80.0)], ..Default::default() });
|
||||
assert_eq!(n, base);
|
||||
assert!(has(&why, "прикрывает"), "{why:?}");
|
||||
// Economical asks for no more interceptors than the usual, heavy no fewer.
|
||||
let (eco, _, _) = fire(Doctrine { salvo: Salvo::Economy, ..Default::default() });
|
||||
let (heavy, _, _) = fire(Doctrine { salvo: Salvo::Heavy, ..Default::default() });
|
||||
assert!(eco <= base && base <= heavy, "{eco} {base} {heavy}");
|
||||
}
|
||||
}
|
||||
@@ -145,6 +145,12 @@ impl Sim {
|
||||
out
|
||||
}
|
||||
|
||||
/// Whether the enemy has this unit in its intelligence: a radar emits, so it is known; the rest only once
|
||||
/// they gave themselves away (a launch, jamming) and are in `known`.
|
||||
pub(super) fn enemy_knows(s: &Sam, known: &[(u32, DVec3)]) -> bool {
|
||||
s.alive() && (s.kind == SamKind::Radar || known.iter().any(|k| k.0 == s.id))
|
||||
}
|
||||
|
||||
/// During a smart raid: its drones not yet launched go for what just gave itself away (a jamming station
|
||||
/// first, then systems that fired), and drones whose system target is gone pick another.
|
||||
pub(super) fn adapt(&mut self) {
|
||||
|
||||
@@ -84,6 +84,9 @@ impl Fires {
|
||||
}
|
||||
|
||||
impl Fire {
|
||||
/// The observed surface for recording; None means it has not been resolved.
|
||||
pub(super) fn surface_is_water(&self) -> Option<bool> { self.land.map(|land| !land) }
|
||||
|
||||
fn take_blocks(self) -> Vec<String> {
|
||||
self.blocks
|
||||
.into_iter()
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
// Generated by tools/gen_models.py from the final staged models; do not edit.
|
||||
pub fn bounds(id: &str) -> Option<([f64; 3], [f64; 3])> {
|
||||
Some(match id {
|
||||
"airdef:amraam_missile" => ([0.97, 0.97, -16.0], [15.03, 15.03, 25.9]),
|
||||
"airdef:barge" => ([-16.0, 0.0, -16.0], [32.0, 6.5, 32.0]),
|
||||
"airdef:beam" => ([6.5, 6.5, -16.0], [9.5, 9.5, 32.0]),
|
||||
"airdef:buk_chassis" => ([-14.5, 0.0, -16.0], [30.5, 17.4, 32.0]),
|
||||
"airdef:buk_chassis_burnt" => ([-14.5, 0.0, -16.0], [30.5, 17.4, 32.0]),
|
||||
"airdef:buk_rails" => ([-12.0, 0.0, -16.0], [28.0, 7.5, 27.0]),
|
||||
"airdef:buk_rails_burnt" => ([-12.0, 0.0, -16.0], [28.0, 7.5, 27.0]),
|
||||
"airdef:buk_turret" => ([-4.0, 0.0, -10.0], [20.0, 14.0, 20.0]),
|
||||
"airdef:buk_turret_burnt" => ([-4.0, 0.0, -10.0], [20.0, 14.0, 20.0]),
|
||||
"airdef:debris" => ([2.0, 6.0, 3.0], [14.0, 9.0, 13.0]),
|
||||
"airdef:depot" => ([-14.0, 0.0, -14.0], [30.0, 17.0, 30.0]),
|
||||
"airdef:depot_burnt" => ([-14.0, 0.0, -14.0], [30.0, 17.0, 30.0]),
|
||||
"airdef:ew_truck" => ([-9.0, -1.379664, -16.0], [25.0, 32.0, 33.379664]),
|
||||
"airdef:ew_truck_burnt" => ([-9.0, -1.379664, -16.0], [25.0, 22.0, 33.379664]),
|
||||
"airdef:fireball" => ([0.0, 0.0, 0.0], [16.0, 16.0, 16.0]),
|
||||
"airdef:flame" => ([5.625, 5.625, -8.0], [10.375, 10.375, 26.0]),
|
||||
"airdef:flare" => ([6.5, 6.5, 6.5], [9.5, 16.0, 9.5]),
|
||||
"airdef:flash" => ([-4.0, -4.0, -4.0], [20.0, 20.0, 20.0]),
|
||||
"airdef:gepard_dish" => ([-4.0, 0.0, 6.0], [20.0, 14.0, 8.0]),
|
||||
"airdef:gepard_guns" => ([-9.0, 3.5, -16.0], [25.0, 9.0, 14.0]),
|
||||
"airdef:gepard_guns_burnt" => ([-9.0, 3.5, -16.0], [25.0, 9.0, 14.0]),
|
||||
"airdef:gepard_hull" => ([-14.5, 0.0, -15.0], [30.5, 17.2, 31.0]),
|
||||
"airdef:gepard_hull_burnt" => ([-14.5, 0.0, -15.0], [30.5, 17.2, 31.0]),
|
||||
"airdef:gepard_turret" => ([-5.745184, 0.0, -10.0], [21.745184, 18.0, 16.0]),
|
||||
"airdef:gepard_turret_burnt" => ([-5.745184, 0.0, -10.0], [21.745184, 18.0, 16.0]),
|
||||
"airdef:geran3" => ([-10.0, 4.341543, -16.0], [26.0, 17.005161, 29.9]),
|
||||
"airdef:geran3_flame" => ([6.15, 6.15, 6.0], [9.85, 9.85, 24.0]),
|
||||
"airdef:gerbera" => ([-9.0, 3.0, -15.0], [25.0, 13.0, 24.5]),
|
||||
"airdef:irist_chassis" => ([-10.5, -1.379664, -16.379664], [26.5, 22.0, 32.0]),
|
||||
"airdef:irist_chassis_burnt" => ([-10.5, -1.379664, -16.379664], [26.5, 22.0, 32.0]),
|
||||
"airdef:irist_missile" => ([1.47, 1.47, -16.0], [14.53, 14.53, 23.9]),
|
||||
"airdef:irist_tubes" => ([-2.5, 0.0, -16.0], [18.5, 9.0, 32.0]),
|
||||
"airdef:irist_tubes_burnt" => ([-2.5, 0.0, -16.0], [18.5, 9.0, 32.0]),
|
||||
"airdef:iskander" => ([-1.74, -1.74, -16.0], [17.74, 17.74, 29.9]),
|
||||
"airdef:kalibr" => ([-6.0, 1.52, -16.0], [22.0, 14.48, 29.9]),
|
||||
"airdef:kh101" => ([-12.5, 3.2, -16.0], [28.5, 16.0, 28.4]),
|
||||
"airdef:kh22" => ([-10.0, -1.2, -16.0], [26.0, 17.2, 29.9]),
|
||||
"airdef:kinzhal" => ([-3.06, -3.06, -16.0], [19.06, 19.06, 29.9]),
|
||||
"airdef:lancet" => ([-1.40452, -1.40452, -16.0], [17.40452, 17.40452, 24.5]),
|
||||
"airdef:launch_ramp" => ([1.0, 0.0, -12.708033], [15.0, 19.342915, 32.0]),
|
||||
"airdef:launcher_truck" => ([-10.5, -1.379664, -16.379664], [26.5, 31.288582, 32.0]),
|
||||
"airdef:m48n6" => ([0.09, 0.09, -16.0], [15.91, 15.91, 27.9]),
|
||||
"airdef:m57e6" => ([1.47, 1.47, -16.0], [14.53, 14.53, 26.9]),
|
||||
"airdef:m77n6" => ([0.82, 0.82, -16.0], [15.18, 15.18, 29.9]),
|
||||
"airdef:nasams_launcher" => ([0.0, 0.0, -16.0], [16.0, 9.0, 32.0]),
|
||||
"airdef:nasams_launcher_burnt" => ([0.0, 0.0, -16.0], [16.0, 9.0, 32.0]),
|
||||
"airdef:nasams_trailer" => ([-9.0, -1.379664, -16.0], [25.0, 13.0, 26.0]),
|
||||
"airdef:nasams_trailer_burnt" => ([-9.0, -1.379664, -16.0], [25.0, 13.0, 26.0]),
|
||||
"airdef:p1sun" => ([-0.5, -0.5, -14.0], [16.5, 16.5, 10.0]),
|
||||
"airdef:p1sun_launcher" => ([-0.5, 0.0, -16.0], [16.5, 7.0, 32.0]),
|
||||
"airdef:p1sun_launcher_burnt" => ([-0.5, 0.0, -16.0], [16.5, 7.0, 32.0]),
|
||||
"airdef:pac3" => ([1.47, 1.47, -16.0], [14.53, 14.53, 25.9]),
|
||||
"airdef:pantsir_dish" => ([-6.5, -8.0, 7.0], [22.5, 16.5, 10.0]),
|
||||
"airdef:pantsir_pack" => ([-11.0, 2.0, -16.0], [27.0, 15.0, 12.0]),
|
||||
"airdef:pantsir_pack_burnt" => ([-11.0, 2.0, -16.0], [27.0, 15.0, 12.0]),
|
||||
"airdef:pantsir_truck" => ([-10.5, -1.379664, -16.0], [26.5, 21.0, 33.379664]),
|
||||
"airdef:pantsir_truck_burnt" => ([-10.5, -1.379664, -16.0], [26.5, 21.0, 33.379664]),
|
||||
"airdef:pantsir_turret" => ([-2.12, 0.0, -11.0], [18.12, 17.0, 16.0]),
|
||||
"airdef:pantsir_turret_burnt" => ([-2.12, 0.0, -11.0], [18.0, 17.0, 16.0]),
|
||||
"airdef:patriot_launcher" => ([-8.0, 0.0, -14.0], [24.0, 19.0, 30.0]),
|
||||
"airdef:patriot_launcher_burnt" => ([-8.0, 0.0, -14.0], [24.0, 19.0, 30.0]),
|
||||
"airdef:patriot_radar" => ([-9.0, -1.410323, -10.0], [25.0, 30.0, 26.0]),
|
||||
"airdef:patriot_trailer" => ([-10.0, -1.410323, -16.0], [26.0, 16.0, 33.010323]),
|
||||
"airdef:patriot_trailer_burnt" => ([-10.0, -1.410323, -16.0], [26.0, 16.0, 33.010323]),
|
||||
"airdef:patriot_truck" => ([-9.0, -1.410323, -16.0], [25.0, 25.0, 33.010323]),
|
||||
"airdef:radar_panel" => ([-10.5, -6.0, 7.0], [26.5, 26.5, 12.0]),
|
||||
"airdef:radar_trailer" => ([-9.0, -1.379664, -12.0], [25.0, 18.0, 26.379664]),
|
||||
"airdef:radar_truck" => ([-10.5, -1.379664, -16.379664], [26.5, 22.0, 32.0]),
|
||||
"airdef:radar_truck_burnt" => ([-10.5, -1.379664, -16.379664], [26.5, 22.0, 32.0]),
|
||||
"airdef:reentry" => ([6.5, 6.5, -16.0], [9.5, 9.5, 32.0]),
|
||||
"airdef:s400_chassis" => ([-10.5, 0.0, -16.460181], [26.5, 22.0, 32.0]),
|
||||
"airdef:s400_chassis_burnt" => ([-10.5, 0.0, -16.460181], [26.5, 19.5, 32.0]),
|
||||
"airdef:s400_tubes" => ([-0.5, 0.0, -16.0], [16.5, 15.0, 32.0]),
|
||||
"airdef:s400_tubes_burnt" => ([-0.5, 0.0, -16.0], [16.5, 15.0, 32.0]),
|
||||
"airdef:s500_chassis" => ([-10.5, -1.379664, -16.379664], [26.5, 22.0, 32.0]),
|
||||
"airdef:s500_chassis_burnt" => ([-10.5, -1.379664, -16.379664], [26.5, 22.0, 32.0]),
|
||||
"airdef:s500_tubes" => ([-3.0, 0.0, -16.0], [19.0, 9.5, 32.0]),
|
||||
"airdef:s500_tubes_burnt" => ([-3.0, 0.0, -16.0], [19.0, 9.5, 32.0]),
|
||||
"airdef:searchlight" => ([2.0, 0.0, 2.0], [14.0, 12.0, 14.0]),
|
||||
"airdef:searchlight_burnt" => ([2.0, 0.0, 2.0], [14.0, 12.0, 14.0]),
|
||||
"airdef:searchlight_head" => ([3.0, 3.0, -2.5], [13.0, 13.0, 14.0]),
|
||||
"airdef:searchlight_head_burnt" => ([3.0, 3.0, -2.5], [13.0, 13.0, 14.0]),
|
||||
"airdef:shahed" => ([-13.0, 4.73352, -16.0], [29.0, 13.2, 28.0]),
|
||||
"airdef:shahed_prop" => ([-4.0, -4.0, 7.0], [20.0, 20.0, 9.5]),
|
||||
"airdef:target" => ([2.0, -8.0, 2.0], [14.0, 24.0, 14.0]),
|
||||
"airdef:tor_chassis" => ([-14.5, 0.0, -16.0], [30.5, 17.4, 32.0]),
|
||||
"airdef:tor_chassis_burnt" => ([-14.5, 0.0, -16.0], [30.5, 17.4, 32.0]),
|
||||
"airdef:tor_turret" => ([-4.0, 0.0, -11.0], [20.0, 17.5, 22.0]),
|
||||
"airdef:tor_turret_burnt" => ([-4.0, 0.0, -11.0], [20.0, 17.5, 22.0]),
|
||||
"airdef:tracer" => ([7.3, 7.3, -16.0], [8.7, 8.7, 32.0]),
|
||||
"airdef:tzm_truck" => ([-9.0, -1.379664, -16.0], [25.0, 26.0, 33.379664]),
|
||||
"airdef:tzm_truck_burnt" => ([-9.0, -1.379664, -16.0], [25.0, 26.0, 33.379664]),
|
||||
"airdef:zircon" => ([0.16, 0.16, -16.0], [15.84, 15.84, 29.9]),
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Night fighting: guns aim by sight, and at night they hit far less unless
|
||||
//! the target is lit. Searchlights follow the network's tracks with their
|
||||
//! Night fighting: darkness penalizes aiming without fresh radar fire control,
|
||||
//! unless the target is lit. Searchlights follow the network's tracks with their
|
||||
//! beams; illumination flares (fired by the guns on their own, or by the
|
||||
//! player) hang over the sky for half a minute and light everything round.
|
||||
use super::*;
|
||||
@@ -15,6 +15,8 @@ pub const BEAM_INNER: f64 = 0.03;
|
||||
pub const BEAM_OUTER: f64 = 0.075;
|
||||
/// A target is lit once the axis is this close to it (inside the cone's soft edge).
|
||||
const LIT_ANGLE: f64 = 0.05;
|
||||
/// Most lamps on one target.
|
||||
const MAX_LAMPS: u32 = 2;
|
||||
/// Ticks between casts of the beam's axis against the land.
|
||||
const CAST_EVERY: u64 = 4;
|
||||
/// Guns' hits at night on an unlit target.
|
||||
@@ -22,6 +24,11 @@ pub const DARK_HITS: f64 = 0.4;
|
||||
/// Ticks between a gun's own flares.
|
||||
const FLARE_EVERY: u32 = 500;
|
||||
|
||||
/// Night only reduces a gun's hit chance when it has to aim by sight.
|
||||
pub(super) fn hit_factor(night: bool, lit: bool, radar_fire_control: bool) -> f64 {
|
||||
if night && !lit && !radar_fire_control { DARK_HITS } else { 1.0 }
|
||||
}
|
||||
|
||||
pub struct Flare {
|
||||
id: u32,
|
||||
pub pos: DVec3,
|
||||
@@ -75,6 +82,10 @@ impl Sim {
|
||||
self.flares = keep;
|
||||
// What the network tracks, for the searchlights.
|
||||
let tracked: Vec<u32> = self.sams.iter().flat_map(|s| s.seen.iter().copied()).collect();
|
||||
// A lamp holds a target only while fewer than two others do; the sky is swept only while
|
||||
// something flies in it.
|
||||
let mut held: HashMap<u32, u32> = HashMap::new();
|
||||
let anything = self.drones.iter().any(|d| d.alive());
|
||||
let gun_targets: Vec<u32> = self.sams.iter().filter_map(|s| s.gun_target).collect();
|
||||
for i in 0..self.sams.len() {
|
||||
if self.sams[i].kind != SamKind::Light || !self.sams[i].alive() || self.sams[i].moving() {
|
||||
@@ -93,12 +104,20 @@ impl Sim {
|
||||
let target = self
|
||||
.drones
|
||||
.iter()
|
||||
.filter(|d| d.alive() && tracked.contains(&d.id) && d.pos.distance(pos) < BEAM)
|
||||
.filter(|d| d.alive() && tracked.contains(&d.id) && d.pos.distance(pos) < BEAM && held.get(&d.id).copied().unwrap_or(0) < MAX_LAMPS)
|
||||
.min_by(|a, b| {
|
||||
let key = |d: &Drone| d.pos.distance(pos) * if gun_targets.contains(&d.id) { 0.3 } else { 1.0 };
|
||||
key(a).total_cmp(&key(b))
|
||||
})
|
||||
.map(|d| (d.id, d.pos));
|
||||
if let Some((t, _)) = target {
|
||||
*held.entry(t).or_insert(0) += 1;
|
||||
} else if !anything {
|
||||
let sam = &mut self.sams[i];
|
||||
sam.target = None;
|
||||
sam.beam_on = false;
|
||||
continue;
|
||||
}
|
||||
let sam = &mut self.sams[i];
|
||||
let (head, _) = sam.mount();
|
||||
let (want_yaw, want_pitch, reach) = match target {
|
||||
|
||||
@@ -54,6 +54,7 @@ impl Sim {
|
||||
continue;
|
||||
}
|
||||
let at = truck.pos;
|
||||
let truck_id = truck.id;
|
||||
// Where it was going: hand over, or load up.
|
||||
if let Some(job) = truck.job
|
||||
&& let Some(j) = self.sams.iter().position(|s| s.id == job)
|
||||
@@ -73,7 +74,7 @@ impl Sim {
|
||||
// Stopped short of it (it drove off meanwhile): on to where it stands now.
|
||||
let to = self.sams[j].pos;
|
||||
let side = horizontal(at - to).normalize_or(DVec3::X) * (HANDOVER * 0.6);
|
||||
self.order_move(t, to + side);
|
||||
self.order_move_near(t, to + side, 3.5);
|
||||
continue;
|
||||
} else {
|
||||
self.sams[t].job = None;
|
||||
@@ -84,7 +85,7 @@ impl Sim {
|
||||
let next = if self.sams[t].cargo > 0 {
|
||||
self.sams
|
||||
.iter()
|
||||
.filter(|s| s.empty && s.alive() && !s.moving() && !taken.contains(&s.id))
|
||||
.filter(|s| s.empty && s.alive() && !s.moving() && !taken.contains(&s.id) && !self.routes.out_of_reach(truck_id, s.id, now))
|
||||
.min_by(|a, b| a.pos.distance(at).total_cmp(&b.pos.distance(at)))
|
||||
.map(|s| (s.id, s.pos))
|
||||
} else {
|
||||
@@ -95,7 +96,7 @@ impl Sim {
|
||||
.then(|| {
|
||||
self.sams
|
||||
.iter()
|
||||
.filter(|d| d.kind == SamKind::Depot && d.alive() && d.cargo > 0)
|
||||
.filter(|d| d.kind == SamKind::Depot && d.alive() && d.cargo > 0 && !self.routes.out_of_reach(truck_id, d.id, now))
|
||||
.min_by(|a, b| a.pos.distance(at).total_cmp(&b.pos.distance(at)))
|
||||
.map(|d| (d.id, d.pos))
|
||||
})
|
||||
@@ -106,7 +107,7 @@ impl Sim {
|
||||
// Stop beside it, not on it.
|
||||
let side = horizontal(at - to).normalize_or(DVec3::X) * (HANDOVER * 0.6);
|
||||
if to.distance(at) > HANDOVER {
|
||||
self.order_move(t, to + side);
|
||||
self.order_move_near(t, to + side, 3.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,14 @@
|
||||
use glam::{DQuat, DVec3};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub mod catalog;
|
||||
mod generated_bounds;
|
||||
mod damage;
|
||||
pub mod doctrine;
|
||||
pub mod fires;
|
||||
mod raid;
|
||||
pub mod sites;
|
||||
pub mod strike;
|
||||
pub mod record;
|
||||
mod sight;
|
||||
mod terrain;
|
||||
@@ -20,18 +24,21 @@ mod ew;
|
||||
pub mod lights;
|
||||
mod logistics;
|
||||
mod orders;
|
||||
mod route;
|
||||
mod voices;
|
||||
pub mod outcome;
|
||||
mod units;
|
||||
mod why;
|
||||
pub mod world;
|
||||
#[cfg(test)]
|
||||
mod balance;
|
||||
#[cfg(test)]
|
||||
mod regress;
|
||||
#[cfg(test)]
|
||||
mod sensor_tests;
|
||||
pub use ew::EW_RADIUS;
|
||||
pub use damage::{Comps, Part, PartState};
|
||||
pub use sight::{Ident, Track};
|
||||
pub use sight::{AirPicture, Ident, LowSensor, Track, RIM_RAYS};
|
||||
use damage::dice;
|
||||
use outcome::{Impact, Outcome};
|
||||
pub use units::{Family, SamKind};
|
||||
@@ -64,6 +71,25 @@ pub struct Particle {
|
||||
pub scale: f32,
|
||||
}
|
||||
|
||||
/// Sound source description produced by the simulation and consumed by the audio adapter.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct EngineDecl {
|
||||
pub key: u32,
|
||||
pub event: &'static str,
|
||||
pub at: DVec3,
|
||||
/// Blocks per second.
|
||||
pub vel: DVec3,
|
||||
pub gain: f32,
|
||||
pub pitch: f32,
|
||||
pub damaged: bool,
|
||||
}
|
||||
|
||||
/// Shared distance text used by existing diagnostics and the HUD.
|
||||
/// Moving diagnostic text to the presentation adapter is a separate migration.
|
||||
pub fn distance(m: f64) -> String {
|
||||
if m >= 1000.0 { format!("{:.1} км", m / 1000.0) } else { format!("{:.0} м", m) }
|
||||
}
|
||||
|
||||
/// A blast the post-processing shader draws as a fireball, flash and shock.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Blast {
|
||||
@@ -84,7 +110,7 @@ pub struct Out {
|
||||
pub sounds: Vec<(&'static str, DVec3, f32, f32)>,
|
||||
/// The engines sounding this tick (persistent sources, `crate::engines`), and whether the
|
||||
/// picture cut (a replay seek or a new shot): every engine then starts afresh.
|
||||
pub engines: Vec<crate::engines::Decl>,
|
||||
pub engines: Vec<EngineDecl>,
|
||||
pub engine_cut: bool,
|
||||
pub commands: Vec<String>,
|
||||
/// Camera jolt (strength, seconds), the strongest this tick.
|
||||
@@ -116,7 +142,7 @@ impl Out {
|
||||
}
|
||||
/// An engine that sounds: `vel` is the simulation's, blocks a tick.
|
||||
pub fn engine(&mut self, key: u32, event: &'static str, at: DVec3, vel: DVec3, gain: f32, pitch: f32, damaged: bool) {
|
||||
self.engines.push(crate::engines::Decl { key, event, at, vel: vel * 20.0, gain, pitch, damaged });
|
||||
self.engines.push(EngineDecl { key, event, at, vel: vel * 20.0, gain, pitch, damaged });
|
||||
}
|
||||
fn jolt(&mut self, strength: f32, seconds: f32) {
|
||||
if self.shake.is_none_or(|(s, _)| s < strength) {
|
||||
@@ -229,14 +255,38 @@ pub struct Ground {
|
||||
known: HashMap<(i32, i32), (i32, u64)>,
|
||||
wanted: Vec<(i32, i32)>,
|
||||
asked: std::collections::HashSet<(i32, i32)>,
|
||||
/// Columns whose chunk the game is loading (it answered `PENDING`), and the tick it said so: not asked
|
||||
/// again for a few ticks.
|
||||
loading: HashMap<(i32, i32), u64>,
|
||||
/// Chunks the search wants loaded (`render.load-chunks`), taken every tick.
|
||||
chunks: Vec<(i32, i32)>,
|
||||
/// The game has answered "loading" at least once: it loads chunks on request (a server doesn't).
|
||||
pub loads: bool,
|
||||
/// The tick of the last full clean-up (a big cache would otherwise be scanned on every answer).
|
||||
swept: u64,
|
||||
/// The tick of the last answer round: what the heights' ages are measured against.
|
||||
now: u64,
|
||||
/// The world's epoch when the last questions went out: an answer to them is of that world or dimension, or of none.
|
||||
asked_epoch: Option<u32>,
|
||||
/// The blocks themselves (issues #42, #43): what stops a flight.
|
||||
pub world: world::WorldCache,
|
||||
}
|
||||
|
||||
/// What `render.ground` answers where the chunk is not loaded (and never will be, unless asked for).
|
||||
pub const NO_LAND: i32 = -64;
|
||||
/// A height the game answered as a land height: none where it had no chunk. The one place that reads `NO_LAND`.
|
||||
pub(crate) fn land_height(y: i32) -> Option<f64> {
|
||||
(y > NO_LAND).then_some(f64::from(y))
|
||||
}
|
||||
|
||||
/// What `render.ground` answers (`i32::MIN`) for a column whose chunk it is loading for the mod.
|
||||
pub const PENDING: i32 = i32::MIN;
|
||||
/// Ticks before a column that was loading is asked about again.
|
||||
const LOAD_RECHECK: u64 = 6;
|
||||
/// The chunks asked to load at once (the game holds 64).
|
||||
const CHUNKS_MAX: usize = 48;
|
||||
/// Ticks a strike drone may fly before it is lost: a Shahed at 0.6 blocks a tick needs 6700 for 4000 blocks.
|
||||
const MAX_FLIGHT: u32 = 24_000;
|
||||
/// The `when` of a height reported changed: due to be asked again.
|
||||
const STALE: u64 = u64::MAX;
|
||||
/// Ticks after which a land height used by the flights' look-ahead is asked again (#64), changes told of or not.
|
||||
@@ -259,7 +309,7 @@ impl Ground {
|
||||
if (when == STALE || now.saturating_sub(when) > 200) && self.wanted.len() < 64 && self.asked.insert(key) {
|
||||
self.wanted.push(key);
|
||||
}
|
||||
(y > -64).then_some(f64::from(y))
|
||||
land_height(y)
|
||||
}
|
||||
None => {
|
||||
if self.wanted.len() < 256 && self.asked.insert(key) {
|
||||
@@ -269,12 +319,37 @@ impl Ground {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// The game's answers to the questions of `take_wanted`. Each is a height (`land_height`), "no land" or
|
||||
/// "loading"; one to a question of another world or dimension than the one open now is dropped (it is
|
||||
/// asked again when needed), not taken as this one's.
|
||||
pub fn answer(&mut self, answers: Vec<(i32, i32, i32)>, now: u64) {
|
||||
self.now = now;
|
||||
let answers = match self.asked_epoch.take() {
|
||||
Some(e) if e != 0 && e != self.world.epoch() => {
|
||||
self.world.stats.late_dropped += answers.len() as u64;
|
||||
Vec::new()
|
||||
}
|
||||
_ => answers,
|
||||
};
|
||||
for (x, z, y) in answers {
|
||||
if y == PENDING {
|
||||
self.loading.insert((x, z), now);
|
||||
self.loads = true;
|
||||
continue;
|
||||
}
|
||||
self.loading.remove(&(x, z));
|
||||
self.known.insert((x, z), (y, now));
|
||||
}
|
||||
if self.loading.len() > 4096 {
|
||||
self.loading.retain(|_, t| now.saturating_sub(*t) < 400);
|
||||
}
|
||||
self.age_heights();
|
||||
// Blasts the game did not report in the blocks: the land there is looked at again.
|
||||
for at in self.world.overdue_blasts(now) {
|
||||
let how = if self.peek(at).is_some() { world::Settled::Unchanged } else { world::Settled::Unloaded };
|
||||
self.world.note_settled(how);
|
||||
self.forget(at, 8);
|
||||
}
|
||||
if self.known.len() > 300_000 && now.saturating_sub(self.swept) >= SWEEP_EVERY {
|
||||
self.swept = now;
|
||||
self.known.retain(|_, (_, when)| now.saturating_sub(*when) < 2000);
|
||||
@@ -283,6 +358,13 @@ impl Ground {
|
||||
/// Heights over blocks that changed (the block cache's notes of changes, chunk replacements and a new world)
|
||||
/// are marked old (`when` = STALE): still used, asked again within the budget. #64.
|
||||
fn age_heights(&mut self) {
|
||||
// Another world or dimension: nothing known, asked or loading belongs to this one.
|
||||
if std::mem::take(&mut self.world.epoch_reset) {
|
||||
self.known.clear();
|
||||
self.loading.clear();
|
||||
self.wanted.clear();
|
||||
self.asked.clear();
|
||||
}
|
||||
let all = std::mem::take(&mut self.world.changed_all);
|
||||
let cols = std::mem::take(&mut self.world.changed_cols);
|
||||
if !all && cols.is_empty() {
|
||||
@@ -318,8 +400,43 @@ impl Ground {
|
||||
fn due(&self, when: u64) -> bool {
|
||||
when == STALE || self.now.saturating_sub(when) > HEIGHT_TTL
|
||||
}
|
||||
/// Asks the game to load the chunk (chunk x, z) for a while, if there is room; whether it did.
|
||||
pub fn want_chunk(&mut self, c: (i32, i32)) -> bool {
|
||||
if self.chunks.contains(&c) {
|
||||
return true;
|
||||
}
|
||||
if self.chunks.len() >= CHUNKS_MAX {
|
||||
return false;
|
||||
}
|
||||
self.chunks.push(c);
|
||||
// What was answered as "no chunk" there is asked again: the chunk is being loaded now.
|
||||
for x in c.0 * 16..c.0 * 16 + 16 {
|
||||
for z in c.1 * 16..c.1 * 16 + 16 {
|
||||
if self.known.get(&(x, z)).is_some_and(|v| land_height(v.0).is_none()) {
|
||||
self.known.remove(&(x, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
for x in (c.0 * 16..c.0 * 16 + 16).step_by(8) {
|
||||
for z in (c.1 * 16..c.1 * 16 + 16).step_by(8) {
|
||||
if self.known.get(&(x + 4, z + 4)).is_some_and(|v| land_height(v.0).is_none()) {
|
||||
self.known.remove(&(x + 4, z + 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
/// How many chunks are wanted so far this tick.
|
||||
pub fn chunks_wanted(&self) -> usize {
|
||||
self.chunks.len()
|
||||
}
|
||||
/// The chunks to ask the game to load this tick.
|
||||
pub fn take_chunks(&mut self) -> Vec<(i32, i32)> {
|
||||
std::mem::take(&mut self.chunks)
|
||||
}
|
||||
pub fn take_wanted(&mut self) -> Vec<(i32, i32)> {
|
||||
self.asked.clear();
|
||||
self.asked_epoch = Some(self.world.epoch());
|
||||
std::mem::take(&mut self.wanted)
|
||||
}
|
||||
/// The first solid block on the way from `a` to `b` (the real blocks, not the height of the land).
|
||||
@@ -524,6 +641,16 @@ pub struct DroneSpec {
|
||||
pub ballistic: Option<f64>,
|
||||
}
|
||||
|
||||
impl DroneSpec {
|
||||
/// The registered visual model for this profile.
|
||||
pub fn model(&self) -> &'static str { self.model }
|
||||
|
||||
/// Its size, for how thick its smoke is.
|
||||
pub fn trail_scale(&self) -> f32 {
|
||||
self.scale as f32
|
||||
}
|
||||
}
|
||||
|
||||
impl DroneKind {
|
||||
pub const ALL: [DroneKind; 13] = [
|
||||
DroneKind::Shahed,
|
||||
@@ -856,6 +983,40 @@ pub struct Drone {
|
||||
err: DVec3,
|
||||
/// Ticks held at the edge of blocks the game has not told of (#61); reset by a clear step.
|
||||
hold: u16,
|
||||
/// Its progress towards the aim: a flight that stops getting nearer runs out of fuel (see `Pace`).
|
||||
pace: Pace,
|
||||
}
|
||||
|
||||
/// Ticks a cruise flight may go without getting nearer its aim or passing a route point before it is out of fuel:
|
||||
/// long enough for a detour round a radar, far short of `MAX_FLIGHT`. It stops a drone circling an aim it
|
||||
/// cannot turn onto, or one that holds for an answer that never comes, from loitering over the map for ever.
|
||||
pub const STALL_TICKS: u32 = 3600;
|
||||
/// How much nearer counts as getting nearer (blocks).
|
||||
const STALL_GAIN: f64 = 10.0;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct Pace {
|
||||
/// The least distance to the aim so far, the age it was reached at, and the route points left then.
|
||||
best: f64,
|
||||
at: u32,
|
||||
route: usize,
|
||||
}
|
||||
|
||||
impl Default for Pace {
|
||||
fn default() -> Self {
|
||||
Pace { best: f64::INFINITY, at: 0, route: usize::MAX }
|
||||
}
|
||||
}
|
||||
|
||||
impl Pace {
|
||||
/// One tick: true when the flight has gone `STALL_TICKS` without progress.
|
||||
fn stalled(&mut self, age: u32, distance: f64, route: usize) -> bool {
|
||||
if distance + STALL_GAIN < self.best || route < self.route {
|
||||
*self = Pace { best: distance.min(self.best), at: age, route };
|
||||
return false;
|
||||
}
|
||||
age.saturating_sub(self.at) > STALL_TICKS
|
||||
}
|
||||
}
|
||||
|
||||
/// A drone's terrain following: refreshed every few ticks, used every one.
|
||||
@@ -865,11 +1026,14 @@ struct Nav {
|
||||
need: f64,
|
||||
/// The height from which a straight dive on its target clears the land (unknown: -inf).
|
||||
dive: f64,
|
||||
/// The land ahead is not known (a chunk the game does not have, or not yet): it keeps a transit height
|
||||
/// above anything it could meet and comes down only once the land ahead is told of.
|
||||
blind: bool,
|
||||
}
|
||||
|
||||
impl Default for Nav {
|
||||
fn default() -> Self {
|
||||
Nav { need: f64::NEG_INFINITY, dive: f64::NEG_INFINITY }
|
||||
Nav { need: f64::NEG_INFINITY, dive: f64::NEG_INFINITY, blind: false }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -924,6 +1088,11 @@ struct MissileSpec {
|
||||
}
|
||||
|
||||
impl MissileKind {
|
||||
/// How thick its motor smoke is (its size); `None` for an electric one.
|
||||
pub fn trail_scale(self) -> Option<f32> {
|
||||
let s = self.spec();
|
||||
(s.flame > 0.0).then_some(s.scale as f32)
|
||||
}
|
||||
/// The sound of its launch.
|
||||
pub fn launch_sound(self) -> &'static str {
|
||||
match self {
|
||||
@@ -1199,6 +1368,11 @@ pub struct Sam {
|
||||
pub bursts: u32,
|
||||
cooldown: u32,
|
||||
gun_cooldown: u32,
|
||||
/// Ticks until the system may take another long shot on a big radar's cue (`why::basis`).
|
||||
far_cooldown: u32,
|
||||
/// Ticks it has held its present missile target without launching, and a target it gave up (id, until when).
|
||||
held: u32,
|
||||
shy: Option<(u32, u64)>,
|
||||
pub reloading: u32,
|
||||
/// What its missiles are after, and what its guns track.
|
||||
pub target: Option<u32>,
|
||||
@@ -1210,6 +1384,8 @@ pub struct Sam {
|
||||
pub fired: u32,
|
||||
/// The classes of target it engages (`Class::bit`s).
|
||||
pub roles: u8,
|
||||
/// Its fire doctrine (#47): protected objects, sector, reserve, salvo.
|
||||
pub doctrine: doctrine::Doctrine,
|
||||
/// 1 whole, 0 destroyed: a damaged system turns slower, sees less and hits worse.
|
||||
pub health: f64,
|
||||
/// Ticks its wreck still burns.
|
||||
@@ -1270,6 +1446,9 @@ impl Sam {
|
||||
bursts: spec.gun.as_ref().map_or(0, |g| g.bursts),
|
||||
cooldown: 40,
|
||||
gun_cooldown: 0,
|
||||
far_cooldown: 0,
|
||||
held: 0,
|
||||
shy: None,
|
||||
reloading: 0,
|
||||
target: None,
|
||||
gun_target: None,
|
||||
@@ -1279,6 +1458,7 @@ impl Sam {
|
||||
kills: 0,
|
||||
fired: 0,
|
||||
roles: spec.roles,
|
||||
doctrine: doctrine::Doctrine::default(),
|
||||
state: SamState::Search,
|
||||
launched: 0,
|
||||
health: 1.0,
|
||||
@@ -1421,6 +1601,16 @@ pub struct Sim {
|
||||
pub hits: u32,
|
||||
/// Drones that struck the land or a building short of their aim.
|
||||
pub crashes: u32,
|
||||
/// Cruise flights that ran out of fuel for making no headway (`STALL_TICKS`).
|
||||
pub stalled: u32,
|
||||
/// Systems just deployed by hand and not yet checked for standing in the land: (id, until tick).
|
||||
settling: Vec<(u32, u64)>,
|
||||
/// What crashed, where, and its aim (balance measurements only).
|
||||
#[cfg(test)]
|
||||
pub crashed: Vec<(DroneKind, DVec3, DVec3)>,
|
||||
/// Interceptors that blew up short of a ridge: kind, age, distance to the target, the target's height over the land under it (balance measurements only).
|
||||
#[cfg(test)]
|
||||
pub scrubs: Vec<(MissileKind, u32, f64, f64, DVec3, f64, f64)>,
|
||||
pub launched: u32,
|
||||
/// Explosions damage the land (primed TNT through commands).
|
||||
pub damage: bool,
|
||||
@@ -1432,6 +1622,10 @@ pub struct Sim {
|
||||
pub shader: bool,
|
||||
/// Air defence holds fire.
|
||||
pub hold: bool,
|
||||
/// Last chance (`/airdef lastchance`): a system fires at a class outside its roles when it is about to hit.
|
||||
pub last_chance: bool,
|
||||
/// The heavy systems take long shots on the big radar's cue (a switch for the balance tests).
|
||||
pub far_shots: bool,
|
||||
/// What the land hides round each system's radar, by system id.
|
||||
horizons: HashMap<u32, sight::Horizon>,
|
||||
/// Blasts to come: (tick, where, TNT, small) — a magazine cooking off.
|
||||
@@ -1440,8 +1634,12 @@ pub struct Sim {
|
||||
pub queue: Vec<(u64, Drone)>,
|
||||
/// The raid's launch sites and their jobs (#100).
|
||||
pub sites: sites::Sites,
|
||||
/// Launch sites found by the radars, and the counter-strikes on them (#101).
|
||||
pub strikes: strike::Strikes,
|
||||
/// A raid being planned.
|
||||
plan: Option<raid::Plan>,
|
||||
/// The vehicles' ground routes, and the jobs the trucks found out of reach (#94).
|
||||
routes: route::Routes,
|
||||
/// Each marked object's health, 0 to 100 (`targets`' order).
|
||||
pub target_health: Vec<f64>,
|
||||
/// The raid in progress, for its report.
|
||||
@@ -1499,17 +1697,27 @@ impl Sim {
|
||||
kills: 0,
|
||||
hits: 0,
|
||||
crashes: 0,
|
||||
stalled: 0,
|
||||
settling: Vec::new(),
|
||||
#[cfg(test)]
|
||||
crashed: Vec::new(),
|
||||
#[cfg(test)]
|
||||
scrubs: Vec::new(),
|
||||
launched: 0,
|
||||
damage: true,
|
||||
seed: seed.wrapping_mul(0x2545_F491_4F6C_DD1D) | 1,
|
||||
truth: false,
|
||||
shader: false,
|
||||
hold: false,
|
||||
last_chance: true,
|
||||
far_shots: true,
|
||||
horizons: HashMap::new(),
|
||||
later: Vec::new(),
|
||||
queue: Vec::new(),
|
||||
sites: sites::Sites::default(),
|
||||
strikes: strike::Strikes::new(),
|
||||
plan: None,
|
||||
routes: Default::default(),
|
||||
target_health: Vec::new(),
|
||||
wave: None,
|
||||
rec: None,
|
||||
@@ -1624,12 +1832,44 @@ impl Sim {
|
||||
self.fires.extinguish();
|
||||
}
|
||||
|
||||
/// A system just put down by the player is looked at for a few seconds: one standing inside the land (a player
|
||||
/// who fell into a chunk that had not loaded) is brought up to the surface. Buried, its interceptors would
|
||||
/// strike the dirt above it and the raid's aim at it would lie under the land. Only a spot whose block is known
|
||||
/// solid and whose land height is known is moved, to that height.
|
||||
pub fn settle(&mut self, id: u32) {
|
||||
self.settling.push((id, self.tick + 100));
|
||||
}
|
||||
|
||||
fn step_settling(&mut self, ground: &mut Ground) {
|
||||
let now = self.tick;
|
||||
let sams = &mut self.sams;
|
||||
self.settling.retain(|&(id, until)| {
|
||||
let Some(sam) = sams.iter_mut().find(|s| s.id == id) else { return false };
|
||||
let p = sam.pos;
|
||||
let (x, y, z) = (p.x.floor() as i32, p.y.floor() as i32, p.z.floor() as i32);
|
||||
if ground.world.is_known_open(x, y, z, now) {
|
||||
return false;
|
||||
}
|
||||
if ground.world.is_known_solid(x, y, z, now) {
|
||||
if let Some(g) = ground.at(p, now) {
|
||||
if g > p.y + 1.5 && g < p.y + 96.0 {
|
||||
sam.pos.y = g;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
now < until
|
||||
});
|
||||
}
|
||||
|
||||
/// One game tick.
|
||||
pub fn step(&mut self, ground: &mut Ground, player: Option<DVec3>, out: &mut Out) {
|
||||
self.tick += 1;
|
||||
self.plan_step(Some(&mut *ground), out);
|
||||
self.adapt();
|
||||
self.release_queue(out);
|
||||
self.step_settling(ground);
|
||||
self.release_queue(ground, out);
|
||||
self.begin_recording_if_active();
|
||||
self.step_drones(ground, player, out);
|
||||
self.step_later(ground, player, out);
|
||||
self.step_moves(ground, out);
|
||||
@@ -1639,6 +1879,7 @@ impl Sim {
|
||||
self.step_lights(ground, out);
|
||||
self.step_sams(ground, out);
|
||||
self.step_missiles(ground, out);
|
||||
self.step_strikes(ground, player, out);
|
||||
self.step_fx(ground, out);
|
||||
self.draw_targets(out);
|
||||
self.draw_sites(out);
|
||||
@@ -1670,11 +1911,12 @@ impl Sim {
|
||||
let from = d.pos;
|
||||
ground.ahead(d.pos, d.vel, (120.0 / d.vel.length().max(0.05)).max(20.0), now);
|
||||
// Near its aim it looks at the land there again: a platform or hilltop blown away
|
||||
// meanwhile, it goes for what is left below, not for the air where it stood.
|
||||
// meanwhile, it goes for what is left below, not for the air where it stood; an aim inside the land (a mark
|
||||
// set from a spot the player stood in the ground) is the surface over it, else the strike counts as a crash.
|
||||
if d.flight != Flight::Falling
|
||||
&& horizontal(d.target - d.pos).length() < 250.0
|
||||
&& let Some(g) = ground.at(d.target, now)
|
||||
&& g < d.target.y - 1.5
|
||||
&& (g < d.target.y - 1.5 || (g > d.target.y + 1.5 && !spec.decoy && spec.ballistic.is_none() && g < d.target.y + 96.0))
|
||||
{
|
||||
d.target.y = g;
|
||||
}
|
||||
@@ -1736,6 +1978,10 @@ impl Sim {
|
||||
// Into the land or a building short of its aim: a crash, not a hit.
|
||||
if landed && d.pos.distance(d.target) >= speed.max(2.0) + 6.0 {
|
||||
crashes.push((d.id, d.kind, d.pos, spec.warhead));
|
||||
#[cfg(test)]
|
||||
{
|
||||
self.crashed.push((d.kind, d.pos, d.target));
|
||||
}
|
||||
removed.push(d.id);
|
||||
continue;
|
||||
}
|
||||
@@ -1798,6 +2044,15 @@ impl Sim {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Out of fuel: no nearer its aim for a long time (it circles, or waits for what never comes): it falls
|
||||
// where it is, a wreck like any other, and the raid is not held open by it.
|
||||
if d.pace.stalled(d.age, d.pos.distance(d.target), d.route.len()) {
|
||||
d.flight = Flight::Falling;
|
||||
d.age = 0;
|
||||
d.vel *= 0.35;
|
||||
self.stalled += 1;
|
||||
continue;
|
||||
}
|
||||
// An interceptor coming: drones drop to the treetops (radars lose them sooner).
|
||||
if d.engaged > 0 && matches!(spec.class, Class::Drone | Class::Jet) {
|
||||
d.low = true;
|
||||
@@ -1837,7 +2092,9 @@ impl Sim {
|
||||
lines.push(((heading + towards).normalize_or_zero(), reach));
|
||||
}
|
||||
}
|
||||
d.nav.need = terrain::required_height(ground, d.pos, &lines, spec.clearance, &climb).unwrap_or(f64::NEG_INFINITY);
|
||||
let (need, blind) = terrain::required_height(ground, d.pos, &lines, spec.clearance, &climb);
|
||||
d.nav.need = need.unwrap_or(f64::NEG_INFINITY);
|
||||
d.nav.blind = blind;
|
||||
d.nav.dive = if to_target < dive_at * 3.0 {
|
||||
terrain::dive_height(ground, d.pos, d.target, terrain::DIVE_MARGIN).unwrap_or(f64::NEG_INFINITY)
|
||||
} else {
|
||||
@@ -1870,13 +2127,18 @@ impl Sim {
|
||||
} else {
|
||||
let heading = horizontal(way - d.pos).normalize_or(horizontal(old).normalize_or(DVec3::NEG_Z));
|
||||
// Cruise height over the target; as low as the land lets it when under the radars.
|
||||
let base = if d.low { d.target.y + 4.0 } else { d.target.y + spec.cruise };
|
||||
let base = if d.low && !d.nav.blind { d.target.y + 4.0 } else { d.target.y + spec.cruise };
|
||||
let own = below.map_or(f64::NEG_INFINITY, |g| g + spec.clearance);
|
||||
let need = d.nav.need.max(own);
|
||||
let safe = if need.is_finite() { need + 2.0 } else { d.target.y + spec.clearance };
|
||||
let height = base.max(safe).max(d.nav.dive + 1.0);
|
||||
let mut height = base.max(safe).max(d.nav.dive + 1.0);
|
||||
// Blind: it does not come down over land nobody has told of; it holds the height it has.
|
||||
if d.nav.blind && d.low && to_target > 300.0 {
|
||||
height = height.max(d.pos.y);
|
||||
}
|
||||
let full = climb.pitch.tan();
|
||||
let urgent = need.is_finite() && d.pos.y < need;
|
||||
// Blind (land ahead unknown): to the transit height at once, not at the gentle slope of a descent plan.
|
||||
let urgent = (need.is_finite() && d.pos.y < need) || (d.nav.blind && d.pos.y < base - 2.0);
|
||||
let slope = if urgent {
|
||||
full
|
||||
} else {
|
||||
@@ -1907,12 +2169,16 @@ impl Sim {
|
||||
}
|
||||
let at_target = d.pos.distance(d.target) < speed.max(1.5);
|
||||
let in_ground = sweep.hit().is_some() || ground.ground_hit(below, d.pos, 0.2, &sweep, now);
|
||||
if at_target || in_ground || d.age > 8000 {
|
||||
if at_target || in_ground || d.age > MAX_FLIGHT {
|
||||
boom.push((d.pos, spec.warhead, spec.decoy));
|
||||
// Into the land or a building short of its aim: a crash, not a hit.
|
||||
if in_ground && d.pos.distance(d.target) >= speed.max(1.5) + 3.0 {
|
||||
if !spec.decoy {
|
||||
crashes.push((d.id, d.kind, d.pos, spec.warhead));
|
||||
#[cfg(test)]
|
||||
{
|
||||
self.crashed.push((d.kind, d.pos, d.target));
|
||||
}
|
||||
}
|
||||
removed.push(d.id);
|
||||
continue;
|
||||
@@ -1929,7 +2195,7 @@ impl Sim {
|
||||
let back = d.pos - d.vel.normalize_or_zero() * 1.5 * spec.scale;
|
||||
match spec.engine {
|
||||
Engine::Prop(..) => {
|
||||
if d.age % 2 == 0 {
|
||||
if d.age % 10 == 0 {
|
||||
out.particles("minecraft:smoke", back, 0.05, DVec3::ZERO, 0.01, 1);
|
||||
}
|
||||
}
|
||||
@@ -1945,7 +2211,7 @@ impl Sim {
|
||||
}
|
||||
}
|
||||
for (drone, pos) in splits {
|
||||
self.log(pos, record::EventKind::Split { drone });
|
||||
self.emit_combat_event(pos, record::EventKind::Split { drone });
|
||||
}
|
||||
for (drone, kind, pos, tnt) in crashes {
|
||||
self.crashes += 1;
|
||||
@@ -1956,7 +2222,7 @@ impl Sim {
|
||||
6 | 7 => 3,
|
||||
_ => 4,
|
||||
};
|
||||
self.log(pos, record::EventKind::Crash { drone, kind, power });
|
||||
self.emit_combat_event(pos, record::EventKind::Crash { drone, kind, power });
|
||||
}
|
||||
for (drone, kind, pos, tnt) in impacts {
|
||||
if let Some(sector) = self.drones.iter().find(|x| x.id == drone).map(|x| x.sector as usize) {
|
||||
@@ -1971,7 +2237,7 @@ impl Sim {
|
||||
};
|
||||
let object = self.targets.iter().position(|t| t.distance(pos) < 16.0);
|
||||
let sam = self.sams.iter().enumerate().find(|(_, s)| s.alive() && s.pos.distance(pos) < 12.0).map(|(i, s)| (s.kind, i));
|
||||
self.log(pos, record::EventKind::Hit { drone, kind, power, object, sam });
|
||||
self.emit_combat_event(pos, record::EventKind::Hit { drone, kind, power, object, sam });
|
||||
let vel = self.drones.iter().find(|x| x.id == drone).map_or(DVec3::ZERO, |x| x.vel);
|
||||
self.direct_hit(pos, vel, tnt, out);
|
||||
}
|
||||
@@ -2000,6 +2266,7 @@ impl Sim {
|
||||
nav: Nav::default(),
|
||||
err: DVec3::ZERO,
|
||||
hold: 0,
|
||||
pace: Pace::default(),
|
||||
});
|
||||
}
|
||||
for d in &self.drones {
|
||||
@@ -2093,6 +2360,7 @@ impl Sim {
|
||||
));
|
||||
}
|
||||
ground.forget(pos, 8);
|
||||
ground.world.expect_blast(pos, 8.0, self.tick);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2140,7 +2408,7 @@ impl Sim {
|
||||
if let Some((i, s)) = self.sams.iter().enumerate().find(|(_, s)| s.id == by) {
|
||||
let (drone, kind, pos) = (self.drones[idx].id, dkind, self.drones[idx].pos);
|
||||
let kill = record::EventKind::Kill { drone, kind, sam: by, sam_kind: s.kind, sam_index: i, missile, outcome };
|
||||
self.log(pos, kill);
|
||||
self.emit_combat_event(pos, kill);
|
||||
}
|
||||
let d = &mut self.drones[idx];
|
||||
let before = d.vel;
|
||||
@@ -2241,6 +2509,7 @@ impl Sim {
|
||||
let sam = &mut self.sams[i];
|
||||
sam.cooldown = sam.cooldown.saturating_sub(1);
|
||||
sam.gun_cooldown = sam.gun_cooldown.saturating_sub(1);
|
||||
sam.far_cooldown = sam.far_cooldown.saturating_sub(1);
|
||||
sam.flash = sam.flash.saturating_sub(1);
|
||||
sam.recoil *= 0.6;
|
||||
if sam.radar_up() {
|
||||
@@ -2287,18 +2556,32 @@ impl Sim {
|
||||
// the forecast of the last measurement, never the true place.
|
||||
let drone = |tr: &Track| drone_at.get(&tr.id).map(|&k| &self.drones[k]);
|
||||
let claimed = |d: &Drone| why::claimed(d, &missile_on, had_target);
|
||||
let needed = why::needed;
|
||||
let doc = &me.doctrine;
|
||||
let needed = |d: &Drone| doc.needed(d);
|
||||
let opts = why::Opts { last_chance: self.last_chance, far_shots: self.far_shots };
|
||||
let target = spec.missile.as_ref().map(|load| {
|
||||
let ok = |tr: &Track, k: f64| {
|
||||
drone(tr).is_some_and(|d| why::allowed(roles, tr, now, d) && open(tr.id) && why::in_reach(load.min, load.max, k, pos, tr.est(now)))
|
||||
// A launcher with nothing to fire (reloading, empty, failed) claims no target: others take it.
|
||||
if me.missiles == 0 || me.reloading > 0 || me.part(Part::Launcher) <= 0.0 {
|
||||
return None;
|
||||
}
|
||||
let radars: Vec<&Sam> = if me.kind.far_shooter() && opts.far_shots { self.sams.iter().filter(|s| s.kind == SamKind::Radar).collect() } else { Vec::new() };
|
||||
let cued = |id: u32| !radars.is_empty() && why::radar_cue(me, &radars, id, now);
|
||||
let basis = |tr: &Track, k: f64, role_in_reach: bool| {
|
||||
drone(tr).filter(|_| open(tr.id)).and_then(|d| why::basis(me, load, tr, d, now, claimed(d), k, opts, cued(tr.id), role_in_reach))
|
||||
};
|
||||
let keep = had_target.filter(|t| tracks.iter().any(|tr| tr.id == *t && ok(tr, 1.1)));
|
||||
// A target held too long without a launch (the mount can't lay on it, the land) is let go,
|
||||
// and not taken again for a while: another system gets it.
|
||||
let shy = |id: u32| me.shy.is_some_and(|(s, until)| s == id && until > now);
|
||||
let stuck = me.held > why::HOLD_MAX;
|
||||
let keep = had_target.filter(|t| !stuck && tracks.iter().any(|tr| tr.id == *t && basis(tr, 1.1, false).is_some()));
|
||||
keep.or_else(|| {
|
||||
let free = |tr: &Track| drone(tr).is_some_and(|d| claimed(d) < needed(d));
|
||||
// Long shots only while nothing of the system's roles is in its normal reach.
|
||||
let role_in_reach = !radars.is_empty() && tracks.iter().any(|tr| free(tr) && basis(tr, 1.0, true) == Some(why::Basis::Role));
|
||||
tracks
|
||||
.iter()
|
||||
.filter(|tr| ok(tr, 1.0))
|
||||
.filter(|tr| free(tr) && !shy(tr.id) && basis(tr, 1.0, role_in_reach).is_some())
|
||||
.filter_map(|tr| drone(tr).map(|d| (tr, d)))
|
||||
.filter(|(_, d)| claimed(d) < needed(d))
|
||||
.max_by(|a, b| a.1.threat_at(pos, a.0.est(now)).total_cmp(&b.1.threat_at(pos, b.0.est(now))))
|
||||
.map(|(_, d)| d.id)
|
||||
})
|
||||
@@ -2311,7 +2594,7 @@ impl Sim {
|
||||
tracks
|
||||
.iter()
|
||||
.filter_map(|tr| drone(tr).map(|d| (tr, d)))
|
||||
.filter(|(tr, d)| why::gun_candidate(roles, tr, now, gun.track, pos, d))
|
||||
.filter(|(tr, d)| why::gun_candidate(roles, doc, tr, now, gun.track, pos, d))
|
||||
.map(|(tr, d)| {
|
||||
let busy = 1.0 + 2.0 * on_it(d) + if d.engaged > 0 { 1.5 } else { 0.0 };
|
||||
(tr.est(now).distance(pos) * busy, d.id)
|
||||
@@ -2330,7 +2613,16 @@ impl Sim {
|
||||
tracks_lost += 1;
|
||||
}
|
||||
retarget(&mut missile_on, had_target, target);
|
||||
self.sams[i].target = target;
|
||||
let sam = &mut self.sams[i];
|
||||
if target.is_some() && target == had_target {
|
||||
sam.held += 1;
|
||||
} else {
|
||||
if let (Some(h), true) = (had_target, sam.held > why::HOLD_MAX) {
|
||||
sam.shy = Some((h, now + why::SHY_TICKS));
|
||||
}
|
||||
sam.held = 0;
|
||||
}
|
||||
sam.target = target;
|
||||
}
|
||||
if let Some(gun_target) = gun_target {
|
||||
retarget(&mut guns_on, had_gun, gun_target);
|
||||
@@ -2364,8 +2656,24 @@ impl Sim {
|
||||
} else {
|
||||
SamState::Search
|
||||
};
|
||||
// Back to the rest position, under the drive's limits like any other turn.
|
||||
sam.aim_towards(sam.heading, Some(spec.rest_pitch));
|
||||
// Nothing to fire at: the mount watches the nearest track of its classes (a reaction a turn
|
||||
// shorter), else it goes back to the rest position, under the drive's limits like any other turn.
|
||||
let (mount, _) = sam.mount();
|
||||
let watch = sam
|
||||
.tracks
|
||||
.iter()
|
||||
.filter(|tr| tr.age(now) <= sight::MISSILE_AGE && drone_at.get(&tr.id).is_some_and(|&k| roles & self.drones[k].kind.spec().class.bit() != 0 && self.drones[k].alive()))
|
||||
.min_by(|a, b| a.est(now).distance(mount).total_cmp(&b.est(now).distance(mount)))
|
||||
.map(|tr| why::aim_wants(mount, tr.est(now), tr.vel, spec.gun.as_ref().map_or(5.0, |g| g.shell)));
|
||||
match (watch, spec.family) {
|
||||
(Some((_, yaw, pitch)), Family::Trainable) => {
|
||||
let _ = pitch;
|
||||
sam.aim_towards(yaw, None)
|
||||
}
|
||||
(Some((_, yaw, _)), Family::Vertical) if matches!(spec.muzzle, Muzzle::Cells) => sam.aim_towards(yaw, None),
|
||||
(Some((_, yaw, pitch)), Family::Gun | Family::Turret) => sam.aim_towards(yaw, Some(pitch)),
|
||||
_ => sam.aim_towards(sam.heading, Some(spec.rest_pitch)),
|
||||
}
|
||||
continue;
|
||||
};
|
||||
let (mount, _) = sam.mount();
|
||||
@@ -2445,8 +2753,11 @@ impl Sim {
|
||||
let event = if sam.kind == SamKind::Pantsir { "airdef:gun.pantsir" } else { "airdef:gun.gepard" };
|
||||
out.sound(event, mount, 1.0, 0.95 + self.vis.f() as f32 * 0.1);
|
||||
}
|
||||
// At night a gun sees what is lit (a searchlight, a flare) and little else.
|
||||
let dark = if self.night && !self.lit.contains(&t.id) { lights::DARK_HITS } else { 1.0 };
|
||||
// A fresh working own-radar fire-control track does not depend on seeing the target.
|
||||
// Guns without that radar picture still take the darkness penalty unless illuminated.
|
||||
let radar_fire_control = sam.radar_up()
|
||||
&& sam.track(gt).is_some_and(|tr| tr.own_within(now, sight::GUN_AGE));
|
||||
let dark = lights::hit_factor(self.night, self.lit.contains(&t.id), radar_fire_control);
|
||||
// The aim point is the track's forecast: the farther it is from the truth, the more shells miss.
|
||||
let off = est.distance(t.pos);
|
||||
let p = gun.p * sam.gun_fit() * dark / (t.kind.spec().stealth * (1.0 + (off / 8.0).powi(2))) * (1.0 - dist / (gun.range * 1.3)).max(0.35);
|
||||
@@ -2496,6 +2807,10 @@ impl Sim {
|
||||
retarget(&mut missile_on, Some(mt), None);
|
||||
sam.target = None;
|
||||
} else if ready && aligned {
|
||||
// Past its normal reach: a long shot, and the next waits.
|
||||
if sam.kind.far_shooter() && t.is_some_and(|t| t.distance(sam.pos) >= load.max) {
|
||||
sam.far_cooldown = why::FAR_COOLDOWN;
|
||||
}
|
||||
launches.push((load.kind, muzzle, dir, mt, sam.id));
|
||||
// Its missile is on it from now, so the systems after this one this tick see
|
||||
// the target taken; this one's next launch looks for another.
|
||||
@@ -2544,12 +2859,17 @@ impl Sim {
|
||||
out.particles("minecraft:cloud", muzzle, 0.6, dir * 0.05, 0.05, 30);
|
||||
let event = if kind == MissileKind::M77n6 { "airdef:launch.s500_eject" } else { "airdef:launch.s400_eject" };
|
||||
out.sound(event, muzzle, 1.0, 1.0);
|
||||
self.scene_event(muzzle, record::SceneKind::MissileLaunch { missile: id, sam, target, kind, sound: event, pitch: 1.0 });
|
||||
} else {
|
||||
out.particles("minecraft:flash", muzzle, 0.0, DVec3::ZERO, 0.0, 1);
|
||||
out.particles("minecraft:cloud", muzzle - dir * 2.0, 1.4, DVec3::new(0.0, 0.02, 0.0), 0.06, 70);
|
||||
out.particles("minecraft:campfire_cosy_smoke", muzzle - dir * 3.0, 1.2, DVec3::ZERO, 0.02, 20);
|
||||
if spec.flame > 0.0 {
|
||||
out.particles("minecraft:cloud", muzzle - dir * 2.0, 1.4, DVec3::new(0.0, 0.02, 0.0), 0.06, 70);
|
||||
out.particles("minecraft:campfire_cosy_smoke", muzzle - dir * 3.0, 1.2, DVec3::ZERO, 0.02, 20);
|
||||
}
|
||||
let event = if kind == MissileKind::M57e6 { "airdef:launch.pantsir" } else { "airdef:launch.patriot" };
|
||||
out.sound(event, muzzle, 1.0, 0.95 + self.vis.f() as f32 * 0.1);
|
||||
let pitch = 0.95 + self.vis.f() as f32 * 0.1;
|
||||
out.sound(event, muzzle, 1.0, pitch);
|
||||
self.scene_event(muzzle, record::SceneKind::MissileLaunch { missile: id, sam, target, kind, sound: event, pitch });
|
||||
}
|
||||
}
|
||||
for (id, pos, vel, life) in tracers {
|
||||
@@ -2572,7 +2892,12 @@ impl Sim {
|
||||
let mut done: Vec<(u32, Option<u32>, bool, u32)> = Vec::new(); // (missile, target, kill, sam)
|
||||
let (mut missed, mut expired, mut orphaned) = (0u32, 0u32, 0u32);
|
||||
let (mut blocked, mut scrubbed) = (0u32, 0u32);
|
||||
let mut ignitions = Vec::new();
|
||||
#[cfg(test)]
|
||||
let mut scrub_log = Vec::new();
|
||||
let sams_fit: HashMap<u32, f64> = self.sams.iter().map(|s| (s.id, 1.0 - 0.3 * (1.0 - s.health.clamp(0.0, 1.0)))).collect();
|
||||
// Where each launcher stands and how far its missiles reach: a hit past that is less likely (`why::reach_fit`).
|
||||
let launchers: HashMap<u32, (DVec3, f64)> = self.sams.iter().filter_map(|s| Some((s.id, (s.pos, s.kind.spec().missile.as_ref()?.max)))).collect();
|
||||
// The data link (#66): the track the firing system holds of each missile's target, if it is up.
|
||||
let links: HashMap<(u32, u32), Track> = self
|
||||
.missiles
|
||||
@@ -2630,9 +2955,19 @@ impl Sim {
|
||||
let closing = (speed - vel.dot(los)).max(1.0);
|
||||
let tgo = at.distance(m.pos) / closing;
|
||||
// Over the land in the way: lofted as far as the missile can, else it blows up before the ridge.
|
||||
let (want, fail) = terrain::steer(ground, m.kind, m.pos, speed, at + vel * tgo);
|
||||
let (want, fail) = terrain::steer(ground, m.kind, m.pos, speed, at + vel * tgo, now);
|
||||
if fail {
|
||||
scrubbed += 1;
|
||||
#[cfg(test)]
|
||||
{
|
||||
let over = target.and_then(|t| ground.at(t.pos, now).map(|g| t.pos.y - g)).unwrap_or(f64::NAN);
|
||||
let dist = target.map_or(f64::NAN, |t| t.pos.distance(m.pos));
|
||||
let mover = ground.at(m.pos, now).map_or(f64::NAN, |g| m.pos.y - g);
|
||||
let from = launchers.get(&m.sam).map_or(0.0, |l| m.pos.distance(l.0));
|
||||
if scrub_log.len() < 30 {
|
||||
scrub_log.push((m.kind, m.age, dist, over, m.pos, mover, from));
|
||||
}
|
||||
}
|
||||
done.push((m.id, target.map(|t| t.id), false, m.sam));
|
||||
continue;
|
||||
}
|
||||
@@ -2680,7 +3015,7 @@ impl Sim {
|
||||
if (rel0 + delta * k).length() < spec.fuse && world.map(|w| w.0).or(waiting).is_none_or(|w| k <= w) {
|
||||
// A target faster than the interceptor is hard to hit.
|
||||
let ratio = (spec.speed / t.vel.length().max(0.1)).min(1.0).powf(1.5);
|
||||
let fit = sams_fit.get(&m.sam).copied().unwrap_or(1.0);
|
||||
let fit = sams_fit.get(&m.sam).copied().unwrap_or(1.0) * launchers.get(&m.sam).map_or(1.0, |(at, max)| why::reach_fit(*max, at.distance(m.pos)));
|
||||
let kill = self.rng.chance(spec.pk * fit * ratio / t.kind.spec().stealth.sqrt());
|
||||
missed += u32::from(!kill);
|
||||
done.push((m.id, Some(t.id), kill, m.sam));
|
||||
@@ -2704,6 +3039,10 @@ impl Sim {
|
||||
done.push((m.id, None, false, m.sam));
|
||||
continue;
|
||||
}
|
||||
if lit && m.age == spec.cold + 1 {
|
||||
let sound = (spec.cold > 0 && spec.flame > 0.0).then_some(if m.kind == MissileKind::M77n6 { "airdef:launch.s500" } else { "airdef:launch.s400" });
|
||||
ignitions.push((m.pos, m.id, m.kind, sound));
|
||||
}
|
||||
if lit {
|
||||
// The motor is one source that follows the missile from ignition on (#95).
|
||||
let (event, gain, pitch) = m.kind.engine_voice();
|
||||
@@ -2722,6 +3061,11 @@ impl Sim {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (pos, missile, kind, sound) in ignitions {
|
||||
self.scene_event(pos, record::SceneKind::MotorIgnition { missile, kind, sound });
|
||||
}
|
||||
#[cfg(test)]
|
||||
self.scrubs.extend(scrub_log);
|
||||
self.note(|t| {
|
||||
t.missed += missed;
|
||||
t.expired += expired;
|
||||
|
||||
@@ -38,11 +38,18 @@ impl Sam {
|
||||
impl Sim {
|
||||
/// Orders unit `i` to drive to `to`. False for one that can't (a depot, a wreck, failed running gear).
|
||||
pub fn order_move(&mut self, i: usize, to: DVec3) -> bool {
|
||||
self.order_move_near(i, to, 0.0)
|
||||
}
|
||||
|
||||
/// The same, where arriving within `slack` blocks of `to` will do (a truck stops beside its job).
|
||||
pub fn order_move_near(&mut self, i: usize, to: DVec3, slack: f64) -> bool {
|
||||
let Some(sam) = self.sams.get_mut(i) else { return false };
|
||||
if !sam.alive() || !sam.kind.mobile() || sam.drive_speed() <= 0.0 {
|
||||
return false;
|
||||
}
|
||||
sam.dest = Some(to);
|
||||
let route = route::Route::new(sam.pos, to, slack, sam.kind, self.tick);
|
||||
self.routes.map.insert(sam.id, route);
|
||||
sam.target = None;
|
||||
sam.gun_target = None;
|
||||
if sam.state != SamState::Moving {
|
||||
@@ -52,11 +59,17 @@ impl Sim {
|
||||
true
|
||||
}
|
||||
|
||||
/// Packing, driving and deploying, once a tick.
|
||||
/// Packing, driving and deploying, once a tick. The way is searched on the ground the game has told of (a
|
||||
/// few hundred cells a tick for all the vehicles); a vehicle stands while it waits, and stops with a word
|
||||
/// when there is no way.
|
||||
pub(super) fn step_moves(&mut self, ground: &mut Ground, out: &mut Out) {
|
||||
let now = self.tick;
|
||||
for sam in &mut self.sams {
|
||||
let planners = self.routes.map.values().filter(|r| r.searching()).count().max(1);
|
||||
let share = route::WORK_PER_TICK / planners;
|
||||
let Sim { sams, routes, .. } = self;
|
||||
for (n, sam) in sams.iter_mut().enumerate() {
|
||||
if !sam.alive() {
|
||||
routes.map.remove(&sam.id);
|
||||
continue;
|
||||
}
|
||||
let spec = sam.kind.spec();
|
||||
@@ -66,12 +79,16 @@ impl Sim {
|
||||
}
|
||||
match sam.state {
|
||||
SamState::Packing => {
|
||||
// The launcher comes down for the march.
|
||||
// The launcher comes down for the march; the way is searched meanwhile.
|
||||
sam.pitch += (0.0 - sam.pitch) * 0.06;
|
||||
sam.yaw = slew(sam.yaw, sam.heading, 0.04);
|
||||
sam.march = sam.march.saturating_sub(1);
|
||||
if sam.march == 0 {
|
||||
sam.state = SamState::Moving;
|
||||
} else if let Some(r) = routes.map.get_mut(&sam.id)
|
||||
&& r.searching()
|
||||
{
|
||||
let _ = r.drive(ground, now, sam.pos, share);
|
||||
}
|
||||
}
|
||||
SamState::Moving => {
|
||||
@@ -80,14 +97,43 @@ impl Sim {
|
||||
sam.dest = None;
|
||||
}
|
||||
let Some(to) = sam.dest else {
|
||||
routes.map.remove(&sam.id);
|
||||
sam.state = SamState::Deploying;
|
||||
sam.march = sam.kind.march_ticks();
|
||||
continue;
|
||||
};
|
||||
let flat = horizontal(to - sam.pos);
|
||||
if flat.length() < SPEED * 2.0 {
|
||||
sam.pos = DVec3::new(to.x, sam.pos.y, to.z);
|
||||
let route = routes.map.entry(sam.id).or_insert_with(|| route::Route::new(sam.pos, to, 0.0, sam.kind, now));
|
||||
let (go, last) = match route.drive(ground, now, sam.pos, share) {
|
||||
route::Drive::Wait(why) => {
|
||||
if route.waited(now) > 40 && !route.told {
|
||||
route.told = true;
|
||||
out.messages.push(format!("{} №{}: {}", sam.kind.name(), n + 1, why.text()));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
route::Drive::Fail(why) => {
|
||||
out.messages.push(format!("{} №{}: {}", sam.kind.name(), n + 1, why.text()));
|
||||
// A truck leaves that job alone for a while, and takes another.
|
||||
if let Some(job) = sam.job.take() {
|
||||
routes.unreachable.insert((sam.id, job), now + route::UNREACHABLE_FOR);
|
||||
}
|
||||
routes.map.remove(&sam.id);
|
||||
sam.dest = None;
|
||||
sam.state = SamState::Deploying;
|
||||
sam.march = sam.kind.march_ticks();
|
||||
continue;
|
||||
}
|
||||
route::Drive::Go(p, last) => (p, last),
|
||||
};
|
||||
let flat = horizontal(go - sam.pos);
|
||||
if last && flat.length() < SPEED * 2.0 {
|
||||
let partial = route.partial;
|
||||
sam.pos = DVec3::new(go.x, sam.pos.y, go.z);
|
||||
sam.dest = None;
|
||||
routes.map.remove(&sam.id);
|
||||
if partial {
|
||||
out.messages.push(format!("{} №{}: {}", sam.kind.name(), n + 1, route::Why::Partial.text()));
|
||||
}
|
||||
sam.state = SamState::Deploying;
|
||||
sam.march = sam.kind.march_ticks();
|
||||
out.sound("minecraft:block.piston.contract", sam.pos, 2.0, 0.6);
|
||||
@@ -99,8 +145,42 @@ impl Sim {
|
||||
let turning = angle_diff(sam.heading, heading_of(flat)).abs();
|
||||
let step = SPEED * sam.drive_speed() * (1.0 - turning / std::f64::consts::PI).max(0.2);
|
||||
let next = sam.pos + ahead * step;
|
||||
let y = ground.at(next, now).unwrap_or(sam.pos.y);
|
||||
sam.pos = DVec3::new(next.x, sam.pos.y + (y - sam.pos.y).clamp(-0.5, 0.5), next.z);
|
||||
// The column and chassis clearance ahead: a wall, low ceiling or a change after planning
|
||||
// turns the vehicle back to the planner. Unknown voxels remain a wait, never a drive.
|
||||
let Some(y) = ground.at(next, now) else {
|
||||
if route.wait_ahead() {
|
||||
out.messages.push(format!("{} №{}: {}", sam.kind.name(), n + 1, route::Why::NoMap.text()));
|
||||
routes.map.remove(&sam.id);
|
||||
sam.dest = None;
|
||||
sam.state = SamState::Deploying;
|
||||
sam.march = sam.kind.march_ticks();
|
||||
}
|
||||
continue;
|
||||
};
|
||||
match route.clearance(ground, next, now) {
|
||||
route::Clearance::Clear => {}
|
||||
route::Clearance::Pending => {
|
||||
if route.wait_ahead() {
|
||||
out.messages.push(format!("{} №{}: {}", sam.kind.name(), n + 1, route::Why::NoMap.text()));
|
||||
routes.map.remove(&sam.id);
|
||||
sam.dest = None;
|
||||
sam.state = SamState::Deploying;
|
||||
sam.march = sam.kind.march_ticks();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
route::Clearance::Blocked => {
|
||||
route.blocked_ahead(next, sam.pos);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
route.ahead_ok();
|
||||
let rise = y - sam.pos.y;
|
||||
if rise > route::STEP_UP || rise < -route::STEP_DOWN {
|
||||
route.blocked_ahead(next, sam.pos);
|
||||
continue;
|
||||
}
|
||||
sam.pos = DVec3::new(next.x, sam.pos.y + rise.clamp(-0.5, 0.5), next.z);
|
||||
sam.yaw = sam.heading;
|
||||
if now % 4 == 0 {
|
||||
out.particles("minecraft:campfire_cosy_smoke", sam.pos - ahead * 2.0 * spec.scale, 0.3, DVec3::new(0.0, 0.03, 0.0), 0.01, 1);
|
||||
|
||||
@@ -60,6 +60,29 @@ pub struct RaidOrder {
|
||||
pub aim: Aim,
|
||||
}
|
||||
|
||||
impl RaidOrder {
|
||||
/// A combined strike of about `n`, as `/airdef wave mix n` orders it.
|
||||
pub fn mix(n: u32, dist: f64) -> RaidOrder {
|
||||
let n = n.max(4);
|
||||
let mut kinds = vec![
|
||||
(DroneKind::Gerbera, n / 4 + 1),
|
||||
(DroneKind::Shahed, n / 3 + 1),
|
||||
(DroneKind::Geran3, n / 8 + 1),
|
||||
(DroneKind::Kh101, n / 8 + 1),
|
||||
(DroneKind::Kalibr, n / 10 + 1),
|
||||
(DroneKind::Kh22, n / 16),
|
||||
(DroneKind::Zircon, n / 20),
|
||||
(DroneKind::Iskander, n / 12 + 1),
|
||||
(DroneKind::Kinzhal, n / 16),
|
||||
];
|
||||
if n >= 30 {
|
||||
kinds.push((DroneKind::Oreshnik, 1));
|
||||
}
|
||||
kinds.retain(|k| k.1 > 0);
|
||||
RaidOrder { kinds, approach: Approach::TwoSectors, dist, aim: Aim::Objects }
|
||||
}
|
||||
}
|
||||
|
||||
/// A drone of a raid being planned.
|
||||
struct Item {
|
||||
d: Drone,
|
||||
@@ -87,6 +110,8 @@ pub(super) struct Plan {
|
||||
wants: Vec<sites::Want>,
|
||||
sited: bool,
|
||||
site_wait: u32,
|
||||
/// The player has been told the enemy is still preparing.
|
||||
said: bool,
|
||||
smart: bool,
|
||||
approach: Approach,
|
||||
total: u32,
|
||||
@@ -115,6 +140,9 @@ pub(super) struct WaveStats {
|
||||
pub(super) const CELL: f64 = 16.0;
|
||||
pub(super) const CELLS: i32 = 140;
|
||||
/// The planner's work a tick (cells priced and opened): a raid takes a few ticks to plan, never a long one.
|
||||
/// The longest a drone of a raid that arrives together waits to take off (ticks): a Shahed at 0.6 blocks a tick
|
||||
/// takes 6700 of them to fly 4000 blocks, and the fastest missile must wait for it.
|
||||
const LONGEST_WAIT: f64 = 12_000.0;
|
||||
pub(super) const WORK_PER_TICK: usize = 40_000;
|
||||
|
||||
/// The planner's grid over a raid: its corner, its cells' size and how many a side.
|
||||
@@ -232,6 +260,9 @@ impl PartialOrd for Open {
|
||||
}
|
||||
}
|
||||
|
||||
/// Ticks an air start waits for the land under it to be told of.
|
||||
const AIR_START_WAIT: u32 = 120;
|
||||
|
||||
impl Sim {
|
||||
/// Orders a raid on `objects` (at least one point). A smart raid is planned over the next ticks
|
||||
/// (each route found in full, a few a tick) and launched when its plan is ready.
|
||||
@@ -258,6 +289,9 @@ impl Sim {
|
||||
let cell = CELL.max(2.0 * span / CELLS as f64);
|
||||
let grid = Grid { min: centre - DVec3::new(span, 0.0, span), cell, size: (2.0 * span / cell) as i32 + 1 };
|
||||
let mut items = Vec::new();
|
||||
// A smart raid goes for the radars too (a few strikers each); the others pick as they always did.
|
||||
let radar_jobs = if smart { self.radar_strikes(&order.kinds) } else { Vec::new() };
|
||||
let mut index = 0usize;
|
||||
for (group, &(kind, count)) in order.kinds.iter().enumerate() {
|
||||
let spec = kind.spec();
|
||||
for _ in 0..count {
|
||||
@@ -268,7 +302,12 @@ impl Sim {
|
||||
};
|
||||
let a = sides[side];
|
||||
let object = objects[(self.rng.f() * objects.len() as f64) as usize % objects.len()];
|
||||
let (target, at_sam) = self.choose_target(kind, object, order.aim);
|
||||
let job = radar_jobs.get(index).copied().flatten();
|
||||
index += 1;
|
||||
let (target, at_sam) = match job {
|
||||
Some((at, id)) => (at, Some(id)),
|
||||
None => self.choose_target(kind, object, order.aim),
|
||||
};
|
||||
let aim = target + DVec3::new(self.rng.s() * 4.0, 0.0, self.rng.s() * 4.0);
|
||||
let dist = spec.ballistic.map_or(order.dist, |far| far.max(order.dist)) + self.rng.f() * 50.0;
|
||||
let height = if spec.ballistic.is_some() { 10.0 } else if spec.cruise > 0.0 { spec.cruise } else { 25.0 };
|
||||
@@ -298,6 +337,7 @@ impl Sim {
|
||||
wants,
|
||||
sited: false,
|
||||
site_wait: 0,
|
||||
said: false,
|
||||
smart,
|
||||
approach: order.approach,
|
||||
total,
|
||||
@@ -356,7 +396,8 @@ impl Sim {
|
||||
}
|
||||
});
|
||||
plan.waited += 1;
|
||||
if plan.unanswered.is_empty() || plan.waited >= 40 {
|
||||
// The game answers 512 columns a tick: a big grid (a long range) gets the time its cells take.
|
||||
if plan.unanswered.is_empty() || plan.waited >= 40 + (n * n) as u32 / 300 {
|
||||
plan.mapped = true;
|
||||
} else {
|
||||
self.plan = Some(plan);
|
||||
@@ -437,7 +478,7 @@ impl Sim {
|
||||
if site != 0 {
|
||||
self.sites.job(d.id, site);
|
||||
}
|
||||
self.queue.push((now + wait.clamp(0.0, 2400.0) as u64, d));
|
||||
self.queue.push((now + wait.clamp(0.0, LONGEST_WAIT) as u64, d));
|
||||
}
|
||||
self.wave = Some(WaveStats {
|
||||
kills: self.kills,
|
||||
@@ -494,9 +535,35 @@ impl Sim {
|
||||
nav: Nav::default(),
|
||||
err,
|
||||
hold: 0,
|
||||
pace: Pace::default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The strikes a smart raid sends at the radars (they emit, so the enemy knows them whether or not they
|
||||
/// fired): for the drones of `kinds` in order, the radar's place and id for those that go for one. Each radar
|
||||
/// gets two or three, the fast strikers first, and all together no more than about a quarter of the raid.
|
||||
pub(super) fn radar_strikes(&self, kinds: &[(DroneKind, u32)]) -> Vec<Option<(DVec3, u32)>> {
|
||||
let mut radars: Vec<&Sam> = self.sams.iter().filter(|s| s.alive() && s.kind == SamKind::Radar).collect();
|
||||
radars.sort_by_key(|s| s.id);
|
||||
let flat: Vec<DroneKind> = kinds.iter().flat_map(|&(k, n)| std::iter::repeat_n(k, n as usize)).collect();
|
||||
let mut jobs = vec![None; flat.len()];
|
||||
if radars.is_empty() {
|
||||
return jobs;
|
||||
}
|
||||
// Fast ones first (a stable sort keeps the raid's order among equals).
|
||||
const RANK: [DroneKind; 8] =
|
||||
[DroneKind::Kh22, DroneKind::Zircon, DroneKind::Iskander, DroneKind::Kinzhal, DroneKind::Kh101, DroneKind::Geran3, DroneKind::Lancet, DroneKind::Shahed];
|
||||
let mut ranked: Vec<(usize, usize)> = flat.iter().enumerate().filter_map(|(i, k)| Some((RANK.iter().position(|r| r == k)?, i))).collect();
|
||||
ranked.sort_by_key(|r| r.0);
|
||||
let want = if flat.len() >= 24 { 3 } else { 2 };
|
||||
let cap = (flat.len() / 4).max(1);
|
||||
for (n, &(_, i)) in ranked.iter().take((radars.len() * want).min(cap)).enumerate() {
|
||||
let radar = radars[n % radars.len()];
|
||||
jobs[i] = Some((radar.pos, radar.id));
|
||||
}
|
||||
jobs
|
||||
}
|
||||
|
||||
/// What a drone goes for: an object, or (by its kind and the raid's aim) a system. Returns the
|
||||
/// point and the system's id.
|
||||
fn choose_target(&mut self, kind: DroneKind, object: DVec3, aim: Aim) -> (DVec3, Option<u32>) {
|
||||
@@ -517,17 +584,20 @@ impl Sim {
|
||||
}
|
||||
// Smart: each kind at what it is good against; what gave itself away first (a jamming
|
||||
// station, a radar, a system that fired).
|
||||
// The planner has only what the enemy knows (#93): the radars (they emit) and the units that gave
|
||||
// themselves away; the rest of the player's layout is not in its hands.
|
||||
let known = self.known_units();
|
||||
let known_ew: Vec<&Sam> = alive.iter().copied().filter(|s| s.kind == SamKind::Ew && known.iter().any(|k| k.0 == s.id)).collect();
|
||||
let alive: Vec<&Sam> = alive.iter().copied().filter(|s| Self::enemy_knows(s, &known)).collect();
|
||||
let known_ew: Vec<&Sam> = alive.iter().copied().filter(|s| s.kind == SamKind::Ew).collect();
|
||||
if matches!(kind, DroneKind::Lancet | DroneKind::Kh22) && !known_ew.is_empty() && roll < 0.6 {
|
||||
let s = known_ew[(r * known_ew.len() as f64) as usize % known_ew.len()];
|
||||
return (s.pos, Some(s.id));
|
||||
}
|
||||
// Short-range systems (guns, Tor, P1-SUN) for the Lancets; long-range ones and the radars
|
||||
// that feed them for the fast missiles.
|
||||
let guns: Vec<&Sam> = alive.iter().copied().filter(|s| s.kind.armed() && s.kind.range() <= 200.0).collect();
|
||||
let guns: Vec<&Sam> = alive.iter().copied().filter(|s| s.kind.armed() && s.kind.range() <= 300.0).collect();
|
||||
let long: Vec<&Sam> =
|
||||
alive.iter().copied().filter(|s| s.kind.range() >= 300.0 || s.kind == SamKind::Radar).collect();
|
||||
alive.iter().copied().filter(|s| s.kind.range() >= 450.0 || s.kind == SamKind::Radar).collect();
|
||||
let choice = match kind {
|
||||
DroneKind::Lancet if roll < 0.75 => pick(&guns, r).or_else(|| pick(&alive, r)),
|
||||
DroneKind::Kh22 | DroneKind::Zircon if roll < 0.45 => pick(&long, r),
|
||||
@@ -550,6 +620,7 @@ impl Sim {
|
||||
let mut cost = 0;
|
||||
let spec = kind.spec();
|
||||
let height = spec.clearance.max(6.0);
|
||||
let known_now = self.known_units();
|
||||
let n = grid.size;
|
||||
let mut prices = vec![1.0f32; (n * n) as usize];
|
||||
// Known jamming stations: drones that navigate by satellite keep away.
|
||||
@@ -567,7 +638,8 @@ impl Sim {
|
||||
}
|
||||
}
|
||||
}
|
||||
for s in self.sams.iter().filter(|s| s.alive() && s.roles & spec.class.bit() != 0) {
|
||||
// Only the systems the enemy knows of are priced in (#93): a hidden one is flown into.
|
||||
for s in self.sams.iter().filter(|s| s.alive() && s.roles & spec.class.bit() != 0 && Self::enemy_knows(s, &known_now)) {
|
||||
let sp = s.kind.spec();
|
||||
let (lo, hi) = sp.missile.as_ref().map_or((0.0, 0.0), |m| (m.min, m.max));
|
||||
let gun = sp.gun.as_ref().map_or(0.0, |g| g.range);
|
||||
@@ -609,8 +681,11 @@ impl Sim {
|
||||
(prices, cost)
|
||||
}
|
||||
|
||||
/// A planned raid's drones take off when their time comes.
|
||||
pub(super) fn release_queue(&mut self, out: &mut Out) {
|
||||
/// Ticks an air start waits for the land under it to be told of.
|
||||
const AIR_START_WAIT: u32 = 120;
|
||||
|
||||
/// A planned raid's drones take off when their time comes.
|
||||
pub(super) fn release_queue(&mut self, ground: &mut Ground, out: &mut Out) {
|
||||
let now = self.tick;
|
||||
if self.queue.iter().all(|q| q.0 > now) {
|
||||
return;
|
||||
@@ -618,10 +693,41 @@ impl Sim {
|
||||
let (go, wait): (Vec<_>, Vec<_>) = std::mem::take(&mut self.queue).into_iter().partition(|q| q.0 <= now);
|
||||
self.queue = wait;
|
||||
let mut cancelled = 0;
|
||||
for (t, d) in go {
|
||||
for (t, mut d) in go {
|
||||
// A site's job leaves its site one at a time, from its stock; a destroyed or empty site cancels it.
|
||||
match self.site_slot(d.id) {
|
||||
let from_site = self.sites.site_of(d.id);
|
||||
// An air start (an off-map site's drone) was planned over land nobody had read. It waits (a second or
|
||||
// two) for the land under it to be known, and begins above it if that is higher than the start: else it
|
||||
// is born inside a hill and crashes at once.
|
||||
let air = from_site.is_some_and(|id| self.sites.list.iter().any(|s| s.id == id && s.offmap));
|
||||
if air {
|
||||
let clear = if d.kind.spec().ballistic.is_some() { 10.0 } else { d.kind.spec().clearance };
|
||||
match ground.at(d.pos, now) {
|
||||
None if d.age < AIR_START_WAIT => {
|
||||
// The game has no chunk there: it is asked to load the ones round the start (and kept a while).
|
||||
let c = ((d.pos.x.floor() as i32) >> 4, (d.pos.z.floor() as i32) >> 4);
|
||||
for (dx, dz) in [(0, 0), (1, 0), (-1, 0), (0, 1), (0, -1)] {
|
||||
ground.want_chunk((c.0 + dx, c.1 + dz));
|
||||
}
|
||||
d.age += 1;
|
||||
self.queue.push((t, d));
|
||||
continue;
|
||||
}
|
||||
Some(g) if d.pos.y < g + clear => d.pos.y = g + clear,
|
||||
_ => {}
|
||||
}
|
||||
d.age = 0;
|
||||
}
|
||||
let slot = self.site_slot(d.id);
|
||||
if let (Some(site), sites::Slot::Go | sites::Slot::Air) = (from_site, &slot) {
|
||||
self.scout_launch(d.id, site, d.kind, d.pos);
|
||||
}
|
||||
match slot {
|
||||
// Free: not a site's job. Air: an off-map site's drone, already in flight position.
|
||||
sites::Slot::Free => {}
|
||||
// The air start was planned over land nobody had read; if it is read by now and the land there is
|
||||
// higher than the start, it begins above it (else it is born inside a hill and crashes at once).
|
||||
sites::Slot::Air => {}
|
||||
sites::Slot::Busy => {
|
||||
self.queue.push((t, d));
|
||||
continue;
|
||||
@@ -631,6 +737,14 @@ impl Sim {
|
||||
continue;
|
||||
}
|
||||
sites::Slot::Go => {
|
||||
// On a slope the pad's side or the muzzle's far end can stand in the land that rises there: the
|
||||
// drone leaves from above the land at its own column, not from inside the hill.
|
||||
if let Some(g) = ground.at(d.pos, now)
|
||||
&& d.pos.y < g + 1.5
|
||||
&& g < d.pos.y + 40.0
|
||||
{
|
||||
d.pos.y = g + 1.5;
|
||||
}
|
||||
let dir = d.vel.normalize_or_zero();
|
||||
out.sound(d.kind.launch_sound(), d.pos, 1.0, 1.0);
|
||||
out.particles("minecraft:flame", d.pos - dir * 1.5, 0.15, -dir * 0.1, 0.02, 4);
|
||||
@@ -645,9 +759,8 @@ impl Sim {
|
||||
}
|
||||
}
|
||||
|
||||
/// Looks for the raid's launch sites. Returns whether they are settled (placed, or given up: drones whose
|
||||
/// side has no suitable ground go to another side's site, or are cancelled with a message; a raid left with
|
||||
/// nothing is cancelled whole).
|
||||
/// Looks for the raid's launch sites. Returns whether they are settled (placed, or off the map: a side with
|
||||
/// no suitable ground still launches, from the air at the ordered range; nothing is cancelled).
|
||||
fn settle_sites(&mut self, plan: &mut Plan, ground: &mut Ground, out: &mut Out) -> bool {
|
||||
plan.site_wait += 1;
|
||||
let mut keep: Vec<DVec3> = self.sams.iter().filter(|s| s.alive()).map(|s| s.pos).collect();
|
||||
@@ -655,46 +768,19 @@ impl Sim {
|
||||
keep.push(plan.centre);
|
||||
let last = plan.site_wait >= sites::SEARCH_TICKS;
|
||||
if !sites::search(&mut plan.wants, ground, plan.centre, &keep, self.tick, last) {
|
||||
// The game loads the land of the places looked at; the player hears the enemy is preparing.
|
||||
if !plan.said && plan.site_wait >= 40 {
|
||||
plan.said = true;
|
||||
out.messages.push("Противник готовит налёт: ищет площадки, местность подгружается".into());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
use sites::Search;
|
||||
// A side that found nothing hands its drones to a site of the same class and range on another side.
|
||||
let mut moved = 0;
|
||||
let mut dropped = 0;
|
||||
let found: Vec<usize> = (0..plan.wants.len()).filter(|&i| plan.wants[i].state == Search::Found).collect();
|
||||
let mut keep_items = Vec::new();
|
||||
for mut it in std::mem::take(&mut plan.items) {
|
||||
let w = &plan.wants[it.want];
|
||||
if w.state != Search::Found {
|
||||
let (class, range) = (w.class, w.ordered);
|
||||
let near = |x: &sites::Want| x.class == class && (x.ordered - range).abs() < range * 0.35 + 30.0;
|
||||
match found.iter().copied().find(|&i| near(&plan.wants[i])) {
|
||||
Some(i) => {
|
||||
it.want = i;
|
||||
moved += 1;
|
||||
}
|
||||
None => {
|
||||
dropped += 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
keep_items.push(it);
|
||||
}
|
||||
plan.items = keep_items;
|
||||
if moved + dropped > 0 {
|
||||
out.messages.push(format!(
|
||||
"Нет пригодной земли для части площадок: {moved} целей ушли с другой стороны, {dropped} отменено"
|
||||
));
|
||||
}
|
||||
plan.total -= dropped;
|
||||
if plan.items.is_empty() {
|
||||
out.messages.push("Налёт отменён: нет пригодной известной земли для пусковых площадок".into());
|
||||
return false;
|
||||
}
|
||||
// A side that found nothing is not given up (no raid is cancelled for it): its site is off the map.
|
||||
// The pads, and the sites themselves; the old raid's sites go unless they still have jobs to fly.
|
||||
let queued: Vec<u32> = self.queue.iter().map(|q| q.1.id).collect();
|
||||
self.sites.retire(&queued);
|
||||
let refs = self.site_refs();
|
||||
self.sites.retire(&queued, &refs);
|
||||
for w in plan.wants.iter_mut() {
|
||||
w.jobs = 0;
|
||||
}
|
||||
@@ -703,12 +789,18 @@ impl Sim {
|
||||
plan.wants[it.want].jobs += 1;
|
||||
}
|
||||
let mut shortened = false;
|
||||
for w in plan.wants.iter_mut().filter(|w| w.state == Search::Found && w.jobs > 0) {
|
||||
let mut pos = w.found.unwrap_or_default();
|
||||
for w in plan.wants.iter_mut().filter(|w| w.jobs > 0) {
|
||||
let offmap = w.state != Search::Found;
|
||||
let mut pos = if offmap {
|
||||
// At the ordered range over the raid's centre height: nothing stands there.
|
||||
plan.centre + DVec3::new(w.bearing.sin(), 0.0, w.bearing.cos()) * w.ordered
|
||||
} else {
|
||||
w.found.unwrap_or_default()
|
||||
};
|
||||
if w.water {
|
||||
pos.y += sites::DECK;
|
||||
}
|
||||
shortened |= w.range < w.ordered - if w.class == sites::SiteClass::Battery { 1.0 } else { 75.0 };
|
||||
shortened |= !offmap && w.range < w.ordered - if w.class == sites::SiteClass::Battery { 1.0 } else { 75.0 };
|
||||
w.site = self.sites.add(sites::LaunchSite {
|
||||
id: 0,
|
||||
side: w.side as u8,
|
||||
@@ -716,12 +808,13 @@ impl Sim {
|
||||
bearing: w.bearing,
|
||||
class: w.class,
|
||||
pos,
|
||||
range: w.range,
|
||||
range: if offmap { w.ordered } else { w.range },
|
||||
water: w.water,
|
||||
stock: w.jobs,
|
||||
planned: w.jobs,
|
||||
alive: true,
|
||||
next_free: 0,
|
||||
offmap,
|
||||
});
|
||||
}
|
||||
if shortened {
|
||||
@@ -731,6 +824,11 @@ impl Sim {
|
||||
for it in plan.items.iter_mut() {
|
||||
let w = &plan.wants[it.want];
|
||||
let Some(site) = self.sites.get(w.site) else { continue };
|
||||
// Off the map: it starts where the plan put it, cruising.
|
||||
if site.offmap {
|
||||
it.d.sector = site.sector;
|
||||
continue;
|
||||
}
|
||||
let from = site.muzzle(it.pad);
|
||||
let spec = it.d.kind.spec();
|
||||
it.from = from;
|
||||
@@ -746,9 +844,16 @@ impl Sim {
|
||||
}
|
||||
it.d.sector = site.sector;
|
||||
}
|
||||
let n = self.sites.list.iter().filter(|s| plan.wants.iter().any(|w| w.site == s.id)).count();
|
||||
let barges = self.sites.list.iter().filter(|s| s.water && plan.wants.iter().any(|w| w.site == s.id)).count();
|
||||
out.messages.push(format!("Пусковые площадки противника: {n}{}", if barges > 0 { format!(" (на баржах: {barges})") } else { String::new() }));
|
||||
let mine = |s: &&sites::LaunchSite| plan.wants.iter().any(|w| w.site == s.id);
|
||||
let n = self.sites.list.iter().filter(mine).filter(|s| !s.offmap).count();
|
||||
let off = self.sites.list.iter().filter(mine).filter(|s| s.offmap).count();
|
||||
let barges = self.sites.list.iter().filter(mine).filter(|s| s.water).count();
|
||||
if n > 0 {
|
||||
out.messages.push(format!("Пусковые площадки противника: {n}{}", if barges > 0 { format!(" (на баржах: {barges})") } else { String::new() }));
|
||||
}
|
||||
if off > 0 {
|
||||
out.messages.push(format!("Площадок за пределами загруженной карты: {off}: оттуда пуск без площадки, с высоты полёта"));
|
||||
}
|
||||
// Where they are is the enemy's secret, unless the sandbox's true picture is on.
|
||||
if self.truth {
|
||||
for site in self.sites.list.iter().filter(|s| plan.wants.iter().any(|w| w.site == s.id)) {
|
||||
@@ -789,6 +894,13 @@ impl Sim {
|
||||
if !why.is_empty() {
|
||||
out.messages.push(format!("Неудачи ПВО: {why}"));
|
||||
}
|
||||
// What the counter-strikes did to the raid (#101): the launches that never happened.
|
||||
let cut: u32 = self.strikes.cancelled.iter().map(|c| c.1).sum();
|
||||
if cut > 0 {
|
||||
let sites: Vec<String> = self.strikes.cancelled.iter().filter(|c| c.1 > 0).map(|c| format!("№{}", c.0)).collect();
|
||||
out.messages.push(format!("Налёт сорван ударами по ПУ ({}): не взлетело {cut} из заявленных {}", sites.join(", "), w.size));
|
||||
}
|
||||
self.strikes.cancelled.clear();
|
||||
self.wave = None;
|
||||
}
|
||||
}
|
||||
@@ -848,6 +960,63 @@ mod tests {
|
||||
eprintln!("4000 ticks in {:?}, kills {} hits {}", t.elapsed(), sim.kills, sim.hits);
|
||||
assert!(sim.queue.is_empty() && !sim.drones.iter().any(|d| d.alive()), "the raid never ended");
|
||||
}
|
||||
/// How many of the live and queued drones are aimed at each point (the drone's own aim: its target less its navigation error).
|
||||
fn aimed_at(sim: &Sim, p: DVec3) -> Vec<DroneKind> {
|
||||
sim.drones.iter().chain(sim.queue.iter().map(|q| &q.1)).filter(|d| d.alive() && (d.target - d.err).distance(p) < 6.0).map(|d| d.kind).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_smart_raid_goes_for_every_radar_and_the_enemys_adapting_does_not_turn_it_away() {
|
||||
let mut sim = Sim::new(21);
|
||||
let mut radars = Vec::new();
|
||||
for (i, at) in [(-300.0, -200.0), (250.0, -250.0), (50.0, 300.0)].into_iter().enumerate() {
|
||||
let id = sim.id();
|
||||
let p = DVec3::new(at.0, 70.0, at.1);
|
||||
sim.sams.push(Sam::new(id, SamKind::Radar, p, i as f64));
|
||||
radars.push((id, p));
|
||||
}
|
||||
let ew = sim.id();
|
||||
sim.sams.push(Sam::new(ew, SamKind::Ew, DVec3::new(0.0, 70.0, 0.0), 0.0));
|
||||
sim.targets.push(DVec3::new(0.0, 70.0, 0.0));
|
||||
sim.target_health.push(100.0);
|
||||
let mut ground = Ground::default();
|
||||
let land = Land(|_, _| 64);
|
||||
let mut out = Out::default();
|
||||
for _ in 0..20 {
|
||||
serve(&mut ground, &land, sim.tick);
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
}
|
||||
let mut order = RaidOrder::mix(36, 500.0);
|
||||
order.aim = Aim::Smart;
|
||||
order.approach = Approach::AllSides;
|
||||
let total: u32 = order.kinds.iter().map(|k| k.1).sum();
|
||||
sim.order_raid(&order, &sim.targets.clone(), &mut out);
|
||||
while sim.planning() {
|
||||
serve(&mut ground, &land, sim.tick);
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
}
|
||||
let check = |sim: &Sim, when: &str| {
|
||||
let mut all = 0;
|
||||
for (i, (_, p)) in radars.iter().enumerate() {
|
||||
let kinds = aimed_at(sim, *p);
|
||||
all += kinds.len();
|
||||
assert!(kinds.len() >= 2, "{when}: radar {i} has only {kinds:?} aimed at it");
|
||||
}
|
||||
all
|
||||
};
|
||||
let planned = check(&sim, "planned");
|
||||
assert!(planned as u32 <= total / 4 + 6, "{planned} of {total} at the radars (the EW station and the rest may add a few)");
|
||||
// The first strikers are the fast ones.
|
||||
assert!(radars.iter().any(|(_, p)| aimed_at(&sim, *p).iter().any(|k| matches!(k, DroneKind::Kh22 | DroneKind::Zircon | DroneKind::Iskander | DroneKind::Kinzhal))));
|
||||
// The enemy has learnt of the jamming station and re-aims what it can: not these.
|
||||
sim.intel.revealed.push((ew, DVec3::new(0.0, 70.0, 0.0), sim.tick));
|
||||
for _ in 0..160 {
|
||||
serve(&mut ground, &land, sim.tick);
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
}
|
||||
check(&sim, "after adapting");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn systems_ready_together_send_one_missile_at_a_drone() {
|
||||
let mut sim = Sim::new(3);
|
||||
@@ -898,13 +1067,15 @@ mod big {
|
||||
serve(&mut ground, &land, sim.tick);
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
}
|
||||
let mut w = crate::wave::WaveConfig::default();
|
||||
w.counts = [10, 12, 6, 6, 6, 6, 4, 4, 6, 4, 1];
|
||||
w.aim = Aim::Smart;
|
||||
w.approach = Approach::AllSides;
|
||||
w.dist = 800.0;
|
||||
let order = RaidOrder {
|
||||
kinds: [DroneKind::Gerbera, DroneKind::Shahed, DroneKind::Geran3, DroneKind::Lancet,
|
||||
DroneKind::Kh101, DroneKind::Kalibr, DroneKind::Kh22, DroneKind::Zircon,
|
||||
DroneKind::Iskander, DroneKind::Kinzhal, DroneKind::Oreshnik]
|
||||
.into_iter().zip([10, 12, 6, 6, 6, 6, 4, 4, 6, 4, 1]).collect(),
|
||||
aim: Aim::Smart, approach: Approach::AllSides, dist: 800.0,
|
||||
};
|
||||
let t = std::time::Instant::now();
|
||||
sim.order_raid(&w.order(), &sim.targets.clone(), &mut out);
|
||||
sim.order_raid(&order, &sim.targets.clone(), &mut out);
|
||||
let mut ticks = 0;
|
||||
let mut slowest = std::time::Duration::ZERO;
|
||||
while sim.planning() {
|
||||
|
||||
@@ -20,6 +20,9 @@ pub struct SamKey {
|
||||
dish: f32,
|
||||
/// A searchlight's beam: how far it runs free (to 8 blocks), 0 when it is off.
|
||||
beam: f32,
|
||||
/// Hull and component health at the sampled tick.
|
||||
health: f32,
|
||||
parts: [f32; 6],
|
||||
}
|
||||
|
||||
impl SamKey {
|
||||
@@ -33,6 +36,8 @@ impl SamKey {
|
||||
pitch: sam.pitch as f32,
|
||||
dish: sam.dish as f32,
|
||||
beam: if sam.beam_on { ((sam.beam_free / 8.0).round() * 8.0).max(8.0) as f32 } else { 0.0 },
|
||||
health: sam.health as f32,
|
||||
parts: sam.comps.0.map(|v| v as f32),
|
||||
}
|
||||
}
|
||||
/// The same pose (to within what could be seen).
|
||||
@@ -44,6 +49,8 @@ impl SamKey {
|
||||
&& near(self.pitch, o.pitch, 0.002)
|
||||
&& near(self.dish, o.dish, 0.002)
|
||||
&& self.beam == o.beam
|
||||
&& self.health == o.health
|
||||
&& self.parts == o.parts
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +91,8 @@ impl SamTrack {
|
||||
pitch: l(a.pitch, b.pitch),
|
||||
dish: turn(a.dish, b.dish, f),
|
||||
beam: a.beam,
|
||||
health: a.health,
|
||||
parts: a.parts,
|
||||
})
|
||||
}
|
||||
/// The system as it stood at `t`, as a ghost to draw with the ids from `id`.
|
||||
@@ -96,15 +105,16 @@ impl SamTrack {
|
||||
sam.dish = k.dish as f64;
|
||||
sam.beam_on = k.beam > 0.0;
|
||||
sam.beam_free = k.beam as f64;
|
||||
sam.health = if self.lost.is_some_and(|l| t >= l as f64) { 0.0 } else { 1.0 };
|
||||
sam.health = if self.lost.is_some_and(|l| t >= l as f64) { 0.0 } else { k.health as f64 };
|
||||
sam.comps = Comps(k.parts.map(|v| v as f64));
|
||||
Some(sam)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(any(test, feature = "test-fixtures"))]
|
||||
impl Recording {
|
||||
/// A recording of `len` ticks with nothing in it (for the planner's tests).
|
||||
pub(crate) fn blank(len: u32) -> Self {
|
||||
pub fn blank(len: u32) -> Self {
|
||||
Recording {
|
||||
number: 1,
|
||||
origin: DVec3::ZERO,
|
||||
@@ -112,6 +122,7 @@ impl Recording {
|
||||
tracks: Vec::new(),
|
||||
index: HashMap::new(),
|
||||
events: Vec::new(),
|
||||
scene: None,
|
||||
tally: Tally::default(),
|
||||
sams: Vec::new(),
|
||||
objects: Vec::new(),
|
||||
@@ -123,7 +134,7 @@ impl Recording {
|
||||
}
|
||||
}
|
||||
/// A straight track from `from` to `to` over the ticks `first..=last` (every `STEP`).
|
||||
pub(crate) fn straight(&mut self, id: u32, what: What, first: u32, last: u32, from: DVec3, to: DVec3) {
|
||||
pub fn straight(&mut self, id: u32, what: What, first: u32, last: u32, from: DVec3, to: DVec3) {
|
||||
let n = ((last - first) / STEP).max(1) as usize;
|
||||
let points = (0..=n).map(|k| {
|
||||
let p = from.lerp(to, k as f64 / n as f64);
|
||||
@@ -153,6 +164,8 @@ pub enum What {
|
||||
Drone(DroneKind),
|
||||
/// An interceptor and the system that fired it.
|
||||
Missile(MissileKind, u32),
|
||||
/// A counter-strike missile on its way to a launch site (#109).
|
||||
Strike,
|
||||
}
|
||||
|
||||
pub struct Track {
|
||||
@@ -179,6 +192,24 @@ pub enum EventKind {
|
||||
Split { drone: u32 },
|
||||
/// A drone's warhead went off against the land or a building short of its aim.
|
||||
Crash { drone: u32, kind: DroneKind, power: u32 },
|
||||
/// A counter-strike on a launch site landed (#101): where it landed and how it ended. Launch sites themselves are
|
||||
/// not drawn in a replay.
|
||||
Strike { site: u32, result: StrikeResult },
|
||||
}
|
||||
|
||||
/// How a strike on a launch site ended.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub enum StrikeResult {
|
||||
Destroyed,
|
||||
/// The site was stunned for a while.
|
||||
Stunned,
|
||||
Missed,
|
||||
/// Shot down by the enemy's cover.
|
||||
Intercepted,
|
||||
/// Off the map: its launches ended, nothing to see.
|
||||
Halted,
|
||||
/// It met the land or a building short of its aim (#106): it went off there.
|
||||
Blocked,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
@@ -188,6 +219,61 @@ pub struct Event {
|
||||
pub kind: EventKind,
|
||||
}
|
||||
|
||||
/// Measured scene transitions. These are facts, not inferred cinematic beats.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum SceneKind {
|
||||
MissileLaunch { missile: u32, sam: u32, target: u32, kind: MissileKind, sound: &'static str, pitch: f32 },
|
||||
MotorIgnition { missile: u32, kind: MissileKind, sound: Option<&'static str> },
|
||||
TrackAcquired { sam: u32, target: u32, ever_own: bool },
|
||||
TrackLost { sam: u32, target: u32 },
|
||||
TrackSource { sam: u32, target: u32, ever_own: bool },
|
||||
TrackLock { sam: u32, target: u32, locked: bool },
|
||||
FireStarted { fire: u32, age: u32, life: u32, size: f32, quiet: bool, shown: bool, water: Option<bool> },
|
||||
FireChanged { fire: u32, age: u32, life: u32, size: f32, quiet: bool, shown: bool, water: Option<bool> },
|
||||
FireEnded { fire: u32 },
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct SceneEvent {
|
||||
pub at: u32,
|
||||
pub pos: DVec3,
|
||||
pub kind: SceneKind,
|
||||
}
|
||||
|
||||
/// At most this many scene transitions per recording; overflow is explicitly marked.
|
||||
const MAX_SCENE_EVENTS: usize = 65_536;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct SceneJournal {
|
||||
events: Vec<SceneEvent>,
|
||||
pub truncated: bool,
|
||||
tracks: HashMap<(u32, u32), (bool, bool, DVec3)>,
|
||||
fires: HashMap<u32, (DVec3, u32, f32, bool, bool, Option<bool>)>,
|
||||
fire_events: Vec<usize>,
|
||||
launches: HashMap<u32, usize>,
|
||||
ignitions: HashMap<u32, usize>,
|
||||
}
|
||||
|
||||
impl SceneJournal {
|
||||
/// Read-only transitions in chronological order.
|
||||
pub fn events(&self) -> &[SceneEvent] { &self.events }
|
||||
|
||||
#[cfg(feature = "test-fixtures")]
|
||||
pub fn fixture_push(&mut self, event: SceneEvent) { self.push(event); }
|
||||
|
||||
fn push(&mut self, event: SceneEvent) {
|
||||
if self.events.len() >= MAX_SCENE_EVENTS { self.truncated = true; return; }
|
||||
let index = self.events.len();
|
||||
match event.kind {
|
||||
SceneKind::MissileLaunch { missile, .. } => { self.launches.insert(missile, index); }
|
||||
SceneKind::MotorIgnition { missile, .. } => { self.ignitions.insert(missile, index); }
|
||||
SceneKind::FireStarted { .. } | SceneKind::FireChanged { .. } | SceneKind::FireEnded { .. } => self.fire_events.push(index),
|
||||
_ => {}
|
||||
}
|
||||
self.events.push(event);
|
||||
}
|
||||
}
|
||||
|
||||
/// Why interceptors and systems failed, as far as it was counted: only these are known.
|
||||
#[derive(Clone, Copy, Default, PartialEq, Debug)]
|
||||
pub struct Tally {
|
||||
@@ -247,6 +333,8 @@ pub struct Recording {
|
||||
pub tracks: Vec<Track>,
|
||||
index: HashMap<u32, usize>,
|
||||
pub events: Vec<Event>,
|
||||
/// None is the legacy event/track-only format.
|
||||
pub scene: Option<SceneJournal>,
|
||||
/// The failures counted during the raid.
|
||||
pub tally: Tally,
|
||||
/// The systems and objects as they stood: (id, kind, where).
|
||||
@@ -325,6 +413,11 @@ pub struct ReplayFire {
|
||||
pub start: u32,
|
||||
pub life: u32,
|
||||
pub size: f32,
|
||||
/// Age already accumulated before recording began.
|
||||
pub age_offset: u32,
|
||||
pub quiet: bool,
|
||||
pub shown: bool,
|
||||
pub water: Option<bool>,
|
||||
/// The event that lit it (the models' ids).
|
||||
pub key: usize,
|
||||
}
|
||||
@@ -336,6 +429,16 @@ pub fn kill_look(kind: DroneKind) -> (f32, u32, f32) {
|
||||
(size, life, gain)
|
||||
}
|
||||
|
||||
/// The fire a strike's end leaves (0: none): the wreck of a site burns long, a crater a while.
|
||||
pub fn strike_power(result: StrikeResult) -> u32 {
|
||||
match result {
|
||||
StrikeResult::Destroyed => 3,
|
||||
StrikeResult::Stunned => 2,
|
||||
StrikeResult::Missed | StrikeResult::Blocked => 1,
|
||||
StrikeResult::Intercepted | StrikeResult::Halted => 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// A blast's look for an event: (fireball radius, ticks it burns). The live blasts use the same.
|
||||
pub fn blast_spec(kind: EventKind) -> (f32, u32) {
|
||||
const SIZE: [f32; 5] = [2.5, 4.5, 7.0, 10.0, 13.0];
|
||||
@@ -351,6 +454,12 @@ pub fn blast_spec(kind: EventKind) -> (f32, u32) {
|
||||
}
|
||||
EventKind::SamLost { .. } => (8.0, 18 * 9),
|
||||
EventKind::Split { .. } => (2.0, 7 * 9),
|
||||
EventKind::Strike { result, .. } => match result {
|
||||
StrikeResult::Destroyed => (SIZE[4], LIFE[4] * 9),
|
||||
StrikeResult::Stunned | StrikeResult::Missed | StrikeResult::Blocked => (SIZE[3], LIFE[3] * 9),
|
||||
StrikeResult::Intercepted => (SIZE[0], LIFE[0] * 9),
|
||||
StrikeResult::Halted => (0.0, 0),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,6 +482,24 @@ pub fn replay_blasts(rec: &Recording, t: f64) -> Vec<Blast> {
|
||||
/// feed it (the greater size, the longer life), as `Sim::ignite` does; those after it died light
|
||||
/// a new one. A pure function of `t`.
|
||||
pub fn replay_fires(rec: &Recording, t: f64) -> Vec<ReplayFire> {
|
||||
if let Some(scene) = rec.scene.as_ref().filter(|s| !s.truncated) {
|
||||
let mut active: HashMap<u32, ReplayFire> = HashMap::new();
|
||||
for &index in &scene.fire_events {
|
||||
let e = &scene.events[index];
|
||||
if e.at as f64 > t { break; }
|
||||
match e.kind {
|
||||
SceneKind::FireStarted { fire, age, life, size, quiet, shown, water }
|
||||
| SceneKind::FireChanged { fire, age, life, size, quiet, shown, water } => {
|
||||
active.insert(fire, ReplayFire { at: e.pos, start: e.at.saturating_sub(age), age_offset: age.saturating_sub(e.at), life, size, quiet, shown, water, key: fire as usize });
|
||||
}
|
||||
SceneKind::FireEnded { fire } => { active.remove(&fire); }
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut fires: Vec<_> = active.into_values().filter(|f| t - f.start as f64 + (f.age_offset as f64) < f.life as f64).collect();
|
||||
fires.sort_by_key(|f| f.key);
|
||||
return fires;
|
||||
}
|
||||
let mut fires: Vec<ReplayFire> = Vec::new();
|
||||
for (k, e) in rec.events.iter().enumerate() {
|
||||
if e.at as f64 > t {
|
||||
@@ -382,6 +509,7 @@ pub fn replay_fires(rec: &Recording, t: f64) -> Vec<ReplayFire> {
|
||||
EventKind::Crash { power, .. } => power,
|
||||
EventKind::Hit { power, .. } => power.max(1),
|
||||
EventKind::SamLost { .. } => 2,
|
||||
EventKind::Strike { result, .. } => strike_power(result),
|
||||
_ => continue,
|
||||
};
|
||||
let (size, life) = (fires::size_for(power), fires::life_for(power));
|
||||
@@ -390,7 +518,7 @@ pub fn replay_fires(rec: &Recording, t: f64) -> Vec<ReplayFire> {
|
||||
f.size = f.size.max(size);
|
||||
f.life = f.life.max(e.at - f.start + life);
|
||||
} else {
|
||||
fires.push(ReplayFire { at: e.pos, start: e.at, life, size, key: k });
|
||||
fires.push(ReplayFire { at: e.pos, start: e.at, life, size, age_offset: 0, quiet: false, shown: true, water: None, key: k });
|
||||
}
|
||||
}
|
||||
fires.retain(|f| t < (f.start + f.life) as f64);
|
||||
@@ -407,6 +535,7 @@ impl Recording {
|
||||
tracks: Vec::new(),
|
||||
index: HashMap::new(),
|
||||
events: Vec::new(),
|
||||
scene: Some(SceneJournal::default()),
|
||||
tally: Tally::default(),
|
||||
sams: sim.sams.iter().map(|s| (s.id, s.kind, s.pos)).collect(),
|
||||
objects: sim.targets.clone(),
|
||||
@@ -439,6 +568,74 @@ impl Recording {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Actual launch, if observed during this recording. Missing is not proof of no launch:
|
||||
/// the recording may have started late or the bounded journal may have filled.
|
||||
pub fn missile_launch(&self, missile: u32) -> Option<&SceneEvent> {
|
||||
let scene = self.scene.as_ref()?;
|
||||
scene.events.get(*scene.launches.get(&missile)?)
|
||||
}
|
||||
|
||||
/// Actual motor ignition, when it was recorded.
|
||||
pub fn missile_ignition(&self, missile: u32) -> Option<&SceneEvent> {
|
||||
let scene = self.scene.as_ref()?;
|
||||
scene.events.get(*scene.ignitions.get(&missile)?)
|
||||
}
|
||||
|
||||
/// Recorded ignition takes precedence; older/incomplete tracks retain their original fallback.
|
||||
pub fn missile_is_lit(&self, tr: &Track, t: f64, cold: u32) -> bool {
|
||||
if let Some(event) = self.missile_ignition(tr.id) { return t >= event.at as f64; }
|
||||
if self.missile_launch(tr.id).is_some() && self.scene.as_ref().is_some_and(|s| !s.truncated) { return false; }
|
||||
t - tr.first as f64 > cold as f64
|
||||
}
|
||||
|
||||
fn note_tracks(&mut self, sams: &[Sam]) {
|
||||
let Some(journal) = &mut self.scene else { return };
|
||||
let mut current = HashMap::new();
|
||||
for sam in sams {
|
||||
for track in &sam.tracks {
|
||||
let key = (sam.id, track.id);
|
||||
let state = (track.own_tick > 0, track.locked, track.pos);
|
||||
let old = journal.tracks.get(&key).copied();
|
||||
if old.is_none() {
|
||||
journal.push(SceneEvent { at: self.len, pos: track.pos, kind: SceneKind::TrackAcquired { sam: sam.id, target: track.id, ever_own: state.0 } });
|
||||
} else if old.is_some_and(|old| old.0 != state.0) {
|
||||
journal.push(SceneEvent { at: self.len, pos: track.pos, kind: SceneKind::TrackSource { sam: sam.id, target: track.id, ever_own: state.0 } });
|
||||
}
|
||||
if (old.is_none() && state.1) || old.is_some_and(|old| old.1 != state.1) {
|
||||
journal.push(SceneEvent { at: self.len, pos: track.pos, kind: SceneKind::TrackLock { sam: sam.id, target: track.id, locked: state.1 } });
|
||||
}
|
||||
current.insert(key, state);
|
||||
}
|
||||
}
|
||||
let mut lost: Vec<_> = journal.tracks.iter().filter(|(key, _)| !current.contains_key(key)).map(|(key, state)| (*key, state.2)).collect();
|
||||
lost.sort_by_key(|(key, _)| *key);
|
||||
for ((sam, target), pos) in lost {
|
||||
journal.push(SceneEvent { at: self.len, pos, kind: SceneKind::TrackLost { sam, target } });
|
||||
}
|
||||
journal.tracks = current;
|
||||
}
|
||||
|
||||
/// Sample actual fire state after the simulation update, including existing fires at start.
|
||||
fn note_fires(&mut self, fires: &[fires::Fire], now: u64) {
|
||||
let Some(journal) = &mut self.scene else { return };
|
||||
let mut current = HashMap::new();
|
||||
for fire in fires {
|
||||
let state = (fire.at, fire.life, fire.size, fire.quiet, fire.shown, fire.surface_is_water());
|
||||
let age = now.saturating_sub(fire.start).min(u32::MAX as u64) as u32;
|
||||
let kind = match journal.fires.get(&fire.id) {
|
||||
None => Some(SceneKind::FireStarted { fire: fire.id, age, life: fire.life, size: fire.size, quiet: fire.quiet, shown: fire.shown, water: state.5 }),
|
||||
Some(old) if *old != state => Some(SceneKind::FireChanged { fire: fire.id, age, life: fire.life, size: fire.size, quiet: fire.quiet, shown: fire.shown, water: state.5 }),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(kind) = kind { journal.push(SceneEvent { at: self.len, pos: fire.at, kind }); }
|
||||
current.insert(fire.id, state);
|
||||
}
|
||||
let mut ended: Vec<_> = journal.fires.iter().filter(|(id, _)| !current.contains_key(id)).map(|(id, state)| (*id, state.0)).collect();
|
||||
ended.sort_by_key(|(id, _)| *id);
|
||||
for (fire, pos) in ended { journal.push(SceneEvent { at: self.len, pos, kind: SceneKind::FireEnded { fire } }); }
|
||||
journal.fires = current;
|
||||
}
|
||||
|
||||
/// The game's tick at the recording's tick `t` (fractional), if it was known: the samples run
|
||||
/// on at the pace of the ticks between them (a pause or a gap is a step).
|
||||
pub fn world_tick(&self, t: f64) -> Option<u64> {
|
||||
@@ -487,6 +684,15 @@ impl Recording {
|
||||
pub fn track(&self, id: u32) -> Option<&Track> {
|
||||
self.index.get(&id).map(|&i| &self.tracks[i])
|
||||
}
|
||||
/// Sampled pose at the replay time, falling back to the old static snapshot.
|
||||
pub fn sam_at(&self, id: u32, t: f64) -> Option<(SamKind, DVec3)> {
|
||||
if let Some(track) = self.sam_tracks.iter().find(|s| s.id == id) {
|
||||
let pose = track.pose(t)?;
|
||||
return Some((track.kind, self.origin + DVec3::new(pose.pos[0] as f64, pose.pos[1] as f64, pose.pos[2] as f64)));
|
||||
}
|
||||
self.sam(id)
|
||||
}
|
||||
|
||||
/// The system with this id as it stood.
|
||||
pub fn sam(&self, id: u32) -> Option<(SamKind, DVec3)> {
|
||||
self.sams.iter().find(|s| s.0 == id).map(|s| (s.1, s.2))
|
||||
@@ -509,17 +715,17 @@ impl Sim {
|
||||
}
|
||||
}
|
||||
|
||||
/// Something worth a replay happened.
|
||||
pub(super) fn log(&mut self, pos: DVec3, kind: EventKind) {
|
||||
match kind {
|
||||
EventKind::Crash { power, .. } => self.ignite(pos, power, None),
|
||||
EventKind::Hit { power, sam, .. } => {
|
||||
let host = sam.and_then(|(_, i)| self.sams.get(i)).map(|s| s.id);
|
||||
self.ignite(pos, power.max(1), host)
|
||||
/// Record an actual transition without modifying gameplay or random state.
|
||||
pub(super) fn scene_event(&mut self, pos: DVec3, kind: SceneKind) {
|
||||
if let Some(r) = &mut self.rec {
|
||||
if let Some(journal) = &mut r.scene {
|
||||
journal.push(SceneEvent { at: r.len, pos, kind });
|
||||
}
|
||||
EventKind::SamLost { sam, .. } => self.ignite(pos, 2, Some(sam)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Append an already-applied fact. This never changes the live world.
|
||||
pub(super) fn record_event(&mut self, pos: DVec3, kind: EventKind) {
|
||||
if let Some(r) = &mut self.rec {
|
||||
let at = r.len;
|
||||
if let EventKind::Kill { drone, .. } = kind
|
||||
@@ -536,20 +742,24 @@ impl Sim {
|
||||
}
|
||||
}
|
||||
|
||||
/// Once a tick: starts a recording with the first drone, adds the tracks' points, ends it
|
||||
/// when the sky has been clear 5 s.
|
||||
pub(super) fn record(&mut self) {
|
||||
// Wrecks still falling (far off they fall a long while) don't keep it going.
|
||||
let busy = self.drones.iter().any(|d| d.alive()) || !self.missiles.is_empty() || !self.queue.is_empty();
|
||||
if self.rec.is_none() {
|
||||
// It starts with the first drone in the sky (not with a raid's drones still waiting).
|
||||
if !self.drones.iter().any(|d| d.alive()) {
|
||||
return;
|
||||
}
|
||||
/// Open before the combat update so transitions on the first active tick are not lost.
|
||||
pub(super) fn begin_recording_if_active(&mut self) {
|
||||
if self.rec.is_none() && (self.drones.iter().any(|d| d.alive()) || !self.strikes.flights.is_empty()) {
|
||||
self.recordings += 1;
|
||||
self.rec = Some(Recording::new(self.recordings, self));
|
||||
}
|
||||
}
|
||||
|
||||
/// Once a tick: starts a recording with the first drone or counter-strike in the air, adds the tracks' points,
|
||||
/// ends it when the sky has been clear 5 s.
|
||||
pub(super) fn record(&mut self) {
|
||||
// Wrecks still falling (far off they fall a long while) don't keep it going. A counter-strike is a recorded
|
||||
// object in its own right (#109): it holds the recording open until it lands, whatever the sky is doing.
|
||||
let busy = self.drones.iter().any(|d| d.alive()) || !self.missiles.is_empty() || !self.queue.is_empty() || !self.strikes.flights.is_empty();
|
||||
self.begin_recording_if_active();
|
||||
let Some(r) = &mut self.rec else { return };
|
||||
r.note_tracks(&self.sams);
|
||||
r.note_fires(&self.fires.list, self.tick);
|
||||
if r.len % TIME_STEP == 0 {
|
||||
if let Some(dt) = self.day_time {
|
||||
r.times.push((r.len, dt));
|
||||
@@ -565,13 +775,20 @@ impl Sim {
|
||||
for m in &self.missiles {
|
||||
r.point(m.id, What::Missile(m.kind, m.sam), m.pos);
|
||||
}
|
||||
for f in &self.strikes.flights {
|
||||
r.point(f.track(), What::Strike, f.pos);
|
||||
}
|
||||
}
|
||||
r.len += 1;
|
||||
r.quiet = if busy { 0 } else { r.quiet + 1 };
|
||||
if r.quiet >= 100 || r.len >= LONGEST {
|
||||
let mut done = self.rec.take().unwrap();
|
||||
if let Some(scene) = &mut done.scene {
|
||||
scene.tracks = HashMap::new();
|
||||
scene.fires = HashMap::new();
|
||||
}
|
||||
done.len = done.len.saturating_sub(done.quiet.saturating_sub(40));
|
||||
if !done.events.is_empty() {
|
||||
if !done.events.is_empty() || done.scene.as_ref().is_some_and(|s| !s.events.is_empty()) {
|
||||
self.replays.push(done);
|
||||
if self.replays.len() > KEPT {
|
||||
self.replays.remove(0);
|
||||
@@ -626,11 +843,21 @@ impl Sim {
|
||||
let spec = kind.spec();
|
||||
let rot = look(dir, 0.0) * DQuat::from_rotation_z(t * 0.3);
|
||||
out.model(id, spec.model, pos, rot, spec.scale, false);
|
||||
if t - tr.first as f64 > spec.cold as f64 && spec.flame > 0.0 {
|
||||
if rec.missile_is_lit(tr, t, spec.cold) && spec.flame > 0.0 {
|
||||
let back = (spec.rear - 8.0) / 16.0 * spec.scale + spec.flame;
|
||||
out.model(id + 1, "airdef:flame", pos + rot * DVec3::new(0.0, 0.0, back), rot, spec.flame, true);
|
||||
}
|
||||
}
|
||||
What::Strike => {
|
||||
// The same model, flame and turn the live flight drew (#106, #109).
|
||||
let spec = DroneKind::Kalibr.spec();
|
||||
let rot = look(dir, 0.0);
|
||||
out.model(id, spec.model, pos, rot, spec.scale, false);
|
||||
if let Engine::Jet(up, back, size) = spec.engine {
|
||||
let flicker = 0.7 + 0.3 * (t * 1.7).sin().abs();
|
||||
out.model(id + 1, "airdef:geran3_flame", pos + rot * DVec3::new(0.0, up * spec.scale, back * spec.scale), rot, spec.scale * size * flicker, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// The air-defence systems as they stood: where, which way, the launcher or turret where it
|
||||
@@ -651,8 +878,10 @@ impl Sim {
|
||||
// Fires: what the events left burning (the flames dim and the smoke thickens with time),
|
||||
// out when their life ends.
|
||||
for f in replay_fires(rec, t) {
|
||||
let age = t - f.start as f64;
|
||||
let (flame, smoke) = fires::replay_fire_of(f.size, f.life, age);
|
||||
let age = t - f.start as f64 + f.age_offset as f64;
|
||||
let (mut flame, mut smoke) = fires::replay_fire_of(f.size, f.life, age);
|
||||
if f.water == Some(true) { flame = 0.0; smoke *= 0.5; }
|
||||
if f.quiet || !f.shown { flame = 0.0; }
|
||||
let id = base + 0x00c0_0000 + f.key as u32 * PARTS;
|
||||
if flame > 0.05 {
|
||||
let wob = 1.0 + 0.15 * (age * 0.9 + f.key as f64).sin();
|
||||
@@ -729,6 +958,7 @@ mod tests {
|
||||
tracks: Vec::new(),
|
||||
index: HashMap::new(),
|
||||
events: Vec::new(),
|
||||
scene: None,
|
||||
tally: Tally::default(),
|
||||
sams: Vec::new(),
|
||||
objects: Vec::new(),
|
||||
@@ -759,6 +989,155 @@ mod tests {
|
||||
assert!((pose(100.0).pos[0] - 4.0).abs() < 1e-6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recorder_is_passive_and_combat_effects_do_not_depend_on_it() {
|
||||
let kind = EventKind::Crash { drone: 1, kind: DroneKind::Shahed, power: 2 };
|
||||
let mut recording = Sim::new(4);
|
||||
recording.rec = Some(Recording::new(1, &recording));
|
||||
recording.record_event(DVec3::ZERO, kind);
|
||||
assert!(recording.fires.list.is_empty(), "recording a fact must not ignite the live world");
|
||||
assert_eq!(recording.rec.as_ref().unwrap().events.len(), 1);
|
||||
let mut without = Sim::new(4);
|
||||
without.emit_combat_event(DVec3::ZERO, kind);
|
||||
assert_eq!(without.fires.list.len(), 1, "the domain effect must run without a recorder");
|
||||
let mut with = Sim::new(4);
|
||||
with.rec = Some(Recording::new(1, &with));
|
||||
with.emit_combat_event(DVec3::ZERO, kind);
|
||||
assert_eq!(with.fires.list.len(), 1);
|
||||
assert_eq!(with.rec.as_ref().unwrap().events.len(), 1);
|
||||
assert_eq!(with.fires.list[0].size, without.fires.list[0].size);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recorded_sam_health_and_parts_are_stepwise_and_seekable() {
|
||||
let mut r = recording();
|
||||
let mut sam = Sam::new(7, SamKind::Patriot, DVec3::ZERO, 0.0);
|
||||
r.note_sams(std::slice::from_ref(&sam), 0);
|
||||
sam.health = 0.4;
|
||||
sam.comps.0[Part::Sensor as usize] = 0.25;
|
||||
r.note_sams(std::slice::from_ref(&sam), 10);
|
||||
let st = &r.sam_tracks[0];
|
||||
let before = st.ghost(r.origin, 9.0, 7).unwrap();
|
||||
let damaged = st.ghost(r.origin, 10.0, 7).unwrap();
|
||||
assert_eq!(before.health, 1.0);
|
||||
assert!((damaged.health - 0.4).abs() < 1e-6);
|
||||
assert_eq!(damaged.comps.get(Part::Sensor), 0.25);
|
||||
assert_eq!(st.ghost(r.origin, 10.0, 7).unwrap().comps, damaged.comps);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sampled_track_and_fire_transitions_follow_real_changes() {
|
||||
let mut sim = Sim::new(3);
|
||||
let id = sim.id();
|
||||
sim.sams.push(Sam::new(id, SamKind::Patriot, DVec3::ZERO, 0.0));
|
||||
let mut r = Recording::new(1, &sim);
|
||||
let tr = sight::Track { id: 77, kind: DroneKind::Shahed, pos: DVec3::Z * 100.0, vel: -DVec3::Z, tick: 1, own_tick: 1, ttl: 10, hits: 1, locked: false };
|
||||
sim.sams[0].tracks.push(tr);
|
||||
r.note_tracks(&sim.sams);
|
||||
r.len = 1;
|
||||
sim.sams[0].tracks[0].locked = true;
|
||||
r.note_tracks(&sim.sams);
|
||||
r.len = 2;
|
||||
sim.sams[0].tracks.clear();
|
||||
r.note_tracks(&sim.sams);
|
||||
let events = &r.scene.as_ref().unwrap().events;
|
||||
assert!(matches!(events[0].kind, SceneKind::TrackAcquired { sam, target: 77, ever_own: true } if sam == id));
|
||||
assert!(matches!(events[1].kind, SceneKind::TrackLock { sam, target: 77, locked: true } if sam == id));
|
||||
assert!(matches!(events[2].kind, SceneKind::TrackLost { sam, target: 77 } if sam == id));
|
||||
|
||||
sim.ignite(DVec3::ZERO, 1, None);
|
||||
let fire = sim.fires.list[0].id;
|
||||
r.note_fires(&sim.fires.list, sim.tick);
|
||||
assert_eq!(replay_fires(&r, 2.0)[0].size, 1.0);
|
||||
sim.ignite(DVec3::ZERO, 4, None);
|
||||
r.len += 1;
|
||||
r.note_fires(&sim.fires.list, sim.tick);
|
||||
assert_eq!(replay_fires(&r, 3.0)[0].size, 3.0);
|
||||
assert_eq!(replay_fires(&r, 2.0)[0].size, 1.0, "seeking back uses old fire state");
|
||||
sim.fires.extinguish();
|
||||
r.len += 1;
|
||||
r.note_fires(&sim.fires.list, sim.tick);
|
||||
assert!(replay_fires(&r, 4.0).is_empty());
|
||||
let events = &r.scene.as_ref().unwrap().events;
|
||||
assert!(events.iter().any(|e| matches!(e.kind, SceneKind::FireStarted { fire: id, .. } if id == fire)));
|
||||
assert!(events.iter().any(|e| matches!(e.kind, SceneKind::FireChanged { fire: id, size, .. } if id == fire && size == 3.0)));
|
||||
assert!(events.iter().any(|e| matches!(e.kind, SceneKind::FireEnded { fire: id } if id == fire)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replay_fire_uses_sampled_existing_age_water_and_end() {
|
||||
let mut r = recording();
|
||||
let mut scene = SceneJournal::default();
|
||||
scene.push(SceneEvent { at: 0, pos: DVec3::X, kind: SceneKind::FireStarted { fire: 7, age: 50, life: 100, size: 1.0, quiet: false, shown: true, water: Some(true) } });
|
||||
scene.push(SceneEvent { at: 10, pos: DVec3::X, kind: SceneKind::FireEnded { fire: 7 } });
|
||||
r.scene = Some(scene);
|
||||
let a = replay_fires(&r, 5.0);
|
||||
assert_eq!(a.len(), 1);
|
||||
assert_eq!((a[0].start, a[0].age_offset, a[0].water), (0, 50, Some(true)));
|
||||
assert!(replay_fires(&r, 11.0).is_empty());
|
||||
let b = replay_fires(&r, 5.0);
|
||||
assert_eq!((a[0].start, a[0].age_offset, a[0].water), (b[0].start, b[0].age_offset, b[0].water));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scene_journal_is_bounded_and_incomplete_is_marked() {
|
||||
let mut j = SceneJournal::default();
|
||||
for i in 0..=MAX_SCENE_EVENTS {
|
||||
j.push(SceneEvent { at: i as u32, pos: DVec3::ZERO, kind: SceneKind::FireEnded { fire: i as u32 } });
|
||||
}
|
||||
assert_eq!(j.events.len(), MAX_SCENE_EVENTS);
|
||||
assert!(j.truncated);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ten_minute_transition_stream_is_bounded() {
|
||||
let started = std::time::Instant::now();
|
||||
let mut sim = Sim::new(5);
|
||||
for _ in 0..4 {
|
||||
let id = sim.id();
|
||||
let mut sam = Sam::new(id, SamKind::Patriot, DVec3::ZERO, 0.0);
|
||||
for target in 1..=4 {
|
||||
sam.tracks.push(sight::Track { id: target, kind: DroneKind::Shahed, pos: DVec3::Z, vel: DVec3::ZERO, tick: 1, own_tick: 1, ttl: 1, hits: 1, locked: false });
|
||||
}
|
||||
sim.sams.push(sam);
|
||||
}
|
||||
let mut r = Recording::new(1, &sim);
|
||||
for t in 0..12_000 {
|
||||
r.len = t;
|
||||
for sam in &mut sim.sams { for tr in &mut sam.tracks { tr.locked = t % 2 == 0; } }
|
||||
r.note_tracks(&sim.sams);
|
||||
}
|
||||
let scene = r.scene.as_ref().unwrap();
|
||||
assert_eq!(scene.events.len(), MAX_SCENE_EVENTS);
|
||||
assert!(scene.truncated);
|
||||
eprintln!("scene stress: 12000 ticks, {} events, event storage {:.2} MiB, elapsed {:?}", scene.events.len(), scene.events.capacity() * std::mem::size_of::<SceneEvent>() / (1024 * 1024), started.elapsed());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn real_launch_and_ignition_are_recorded_with_ids_and_sound() {
|
||||
let mut sim = Sim::new(0x87);
|
||||
let sam = sim.id();
|
||||
sim.sams.push(Sam::new(sam, SamKind::Patriot, DVec3::new(0.0, 64.0, 0.0), 0.0));
|
||||
let mut out = Out::default();
|
||||
for (i, kind) in [DroneKind::Shahed, DroneKind::Kh101, DroneKind::Iskander].into_iter().enumerate() {
|
||||
sim.launch(kind, DVec3::new(i as f64 * 100.0, 110.0, 800.0), -DVec3::Z, DVec3::new(0.0, 64.0, 0.0), &mut out);
|
||||
}
|
||||
let mut ground = Ground::default();
|
||||
for _ in 0..600 {
|
||||
let wanted = ground.take_wanted();
|
||||
ground.answer(wanted.into_iter().map(|(x, z)| (x, z, 64)).collect(), sim.tick);
|
||||
out = Out::default();
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
if sim.rec.as_ref().and_then(|r| r.scene.as_ref()).is_some_and(|j| j.events.iter().any(|e| matches!(e.kind, SceneKind::MotorIgnition { .. }))) { break; }
|
||||
}
|
||||
let r = sim.rec.as_ref().expect("recording");
|
||||
let launch = r.scene.as_ref().unwrap().events.iter().find(|e| matches!(e.kind, SceneKind::MissileLaunch { .. })).expect("actual launch");
|
||||
let missile = match launch.kind { SceneKind::MissileLaunch { missile, sam: source, sound, .. } => { assert_eq!(source, sam); assert_eq!(sound, "airdef:launch.patriot"); missile }, _ => unreachable!() };
|
||||
let ignition = r.missile_ignition(missile).expect("actual ignition");
|
||||
assert!(ignition.at >= launch.at);
|
||||
assert_eq!(r.missile_launch(missile).unwrap().pos, launch.pos);
|
||||
}
|
||||
|
||||
// #76: a replay's searchlights point where the recording had them, from the recorded pose.
|
||||
#[test]
|
||||
fn a_replay_has_the_recorded_searchlight_beams() {
|
||||
|
||||
@@ -51,6 +51,10 @@ fn network_launcher_must_contribute_to_route_risk() {
|
||||
let id=sim.id();sim.sams.push(Sam::new(id,SamKind::P1sun,DVec3::new(0.,70.,0.),0.));
|
||||
let id=sim.id();sim.sams.push(Sam::new(id,SamKind::Radar,DVec3::new(0.,70.,0.),0.));
|
||||
let grid=Grid{min:DVec3::new(-160.,0.,-160.),cell:16.,size:20};
|
||||
// #93: the planner prices only what the enemy knows; the radar emits, the launcher is not known until it gives itself away.
|
||||
let (prices,_)=sim.price_grid(&grid,DroneKind::Shahed);
|
||||
assert!(prices.iter().all(|p|*p==1.),"an unknown launcher must not be priced");
|
||||
sim.intel.revealed.push((sim.sams[0].id,DVec3::new(0.,70.,0.),0));
|
||||
let (prices,_)=sim.price_grid(&grid,DroneKind::Shahed);
|
||||
assert!(prices.iter().any(|p|*p>1.),"armed launcher with a network radar is invisible to route risk");
|
||||
}
|
||||
@@ -234,6 +238,8 @@ fn armed_strike_on_a_system_destroys_it_at_once() {
|
||||
let mut destroyed = 0;
|
||||
for seed in 1..=40 {
|
||||
let mut sim = Sim::new(seed);
|
||||
// The strike itself is under test: the Patriot does not shoot the Lancet down on a last chance.
|
||||
sim.last_chance = false;
|
||||
let id = sim.id();
|
||||
sim.sams.push(Sam::new(id, SamKind::Patriot, centre, 0.0));
|
||||
let mut ground = Ground::default();
|
||||
@@ -618,6 +624,8 @@ fn replay_fires_and_blasts_follow_the_recording() {
|
||||
let mut out = Out::default();
|
||||
sim.step(&mut g, None, &mut out);
|
||||
let mut rec = sim.rec.take().unwrap();
|
||||
// Legacy recordings reconstruct fire from combat events; new journals record actual fire state.
|
||||
rec.scene = None;
|
||||
let at = DVec3::new(5.0, 70.0, 5.0);
|
||||
let crash = |power| EventKind::Crash { drone: 1, kind: DroneKind::Geran3, power };
|
||||
let life = fires::life_for(1);
|
||||
@@ -657,45 +665,6 @@ fn replay_fires_and_blasts_follow_the_recording() {
|
||||
// #78: a replay's smoke is rebuilt from the recording as a function of its time: trails behind
|
||||
// what flew (clearing the fog), a column over the fire, billows that outlive the fireball; a seek
|
||||
// shows what playing through shows, and the live Sim is not touched.
|
||||
#[test]
|
||||
fn replay_smoke_has_trails_and_fire_columns_and_is_a_function_of_time() {
|
||||
use record::{Event, EventKind};
|
||||
let mut sim = Sim::new(1);
|
||||
sim.add_drone(DroneKind::Geran3, DVec3::new(0.0, 80.0, 0.0), DVec3::Z, DVec3::new(0.0, 70.0, 2000.0));
|
||||
sim.add_drone(DroneKind::Geran3, DVec3::new(30.0, 80.0, 0.0), DVec3::Z, DVec3::new(30.0, 70.0, 2000.0));
|
||||
let mut g = Ground::default();
|
||||
let mut out = Out::default();
|
||||
for _ in 0..160 {
|
||||
sim.step(&mut g, None, &mut out);
|
||||
}
|
||||
let mut rec = sim.rec.take().unwrap();
|
||||
assert_eq!(rec.tracks.len(), 2);
|
||||
rec.events = vec![Event { at: 40, pos: DVec3::new(5.0, 70.0, 5.0), kind: EventKind::Hit { drone: 1, kind: DroneKind::Geran3, power: 2, object: None, sam: None } }];
|
||||
let live_tick = sim.tick;
|
||||
let live_fires = sim.fires.list.len();
|
||||
let t = 130.0;
|
||||
let a = crate::smoke::replay_smoke(&rec, t);
|
||||
let trails = a.iter().filter(|s| s.clear > 0.0).count();
|
||||
let columns = a.iter().filter(|s| s.soot > 0.8).count();
|
||||
let billows = a.iter().filter(|s| s.soot == 0.55).count();
|
||||
assert!(trails > 0, "trails of both tracks: {trails}");
|
||||
assert!(columns > 0, "a column over the fire: {columns}");
|
||||
assert!(billows > 0, "the blast's billows");
|
||||
// Seeking away and back, or forward from nothing, gives the same smoke.
|
||||
let _ = crate::smoke::replay_smoke(&rec, 10.0);
|
||||
let _ = crate::smoke::replay_smoke(&rec, 155.0);
|
||||
let b = crate::smoke::replay_smoke(&rec, t);
|
||||
assert_eq!(a.iter().map(|s| (s.id, s.born as u64)).collect::<Vec<_>>(), b.iter().map(|s| (s.id, s.born as u64)).collect::<Vec<_>>());
|
||||
// Nothing from the future; before the raid, nothing.
|
||||
assert!(a.iter().all(|s| s.born <= t));
|
||||
assert!(crate::smoke::replay_smoke(&rec, -5.0).is_empty());
|
||||
// The billows go on long after the short fireball is out.
|
||||
let late = crate::smoke::replay_smoke(&rec, 400.0);
|
||||
assert!(late.iter().any(|s| s.soot == 0.55));
|
||||
// The live state is not touched.
|
||||
assert_eq!((sim.tick, sim.fires.list.len()), (live_tick, live_fires));
|
||||
}
|
||||
|
||||
// #76: the protected objects of a replay are the recording's, not the live marks.
|
||||
#[test]
|
||||
fn a_replay_draws_the_recorded_objects_not_the_live_ones() {
|
||||
@@ -1592,3 +1561,209 @@ fn mass_strikes_keep_fires_effects_and_lights_bounded() {
|
||||
assert!(sim.fires.is_empty(), "fires burn for ever");
|
||||
let _ = commands;
|
||||
}
|
||||
|
||||
/// A system put down inside the land (the player stood in the ground) is brought up to the surface, and its
|
||||
/// interceptors then leave the launcher; one on the surface or in the open air is left where it is.
|
||||
#[test]
|
||||
fn a_system_deployed_inside_the_land_comes_up() {
|
||||
let land = sites::testland::Land(|_, _| 63);
|
||||
let mut sim = Sim::new(1);
|
||||
let mut ground = Ground::default();
|
||||
let mut out = Out::default();
|
||||
let buried = sim.id();
|
||||
sim.sams.push(Sam::new(buried, SamKind::Patriot, DVec3::new(20.0, 56.0, 17.0), 0.0));
|
||||
sim.settle(buried);
|
||||
let open = sim.id();
|
||||
sim.sams.push(Sam::new(open, SamKind::S400, DVec3::new(60.0, 63.0, 17.0), 0.0));
|
||||
sim.settle(open);
|
||||
let air = sim.id();
|
||||
sim.sams.push(Sam::new(air, SamKind::Tor, DVec3::new(90.0, 70.0, 17.0), 0.0));
|
||||
sim.settle(air);
|
||||
for _ in 0..60 {
|
||||
sites::testland::step(&mut sim, &mut ground, &land, &mut out);
|
||||
}
|
||||
let y = |id| sim.sams.iter().find(|s| s.id == id).unwrap().pos.y;
|
||||
assert_eq!(y(buried), 63.0, "a buried system comes up to the surface");
|
||||
assert_eq!(y(open), 63.0);
|
||||
assert_eq!(y(air), 70.0, "one in the open air is not moved");
|
||||
}
|
||||
|
||||
/// An aim point inside the land (an object marked where the player stood in the ground) is the surface over it:
|
||||
/// a drone that arrives is a hit, not a crash into the land short of its aim.
|
||||
#[test]
|
||||
fn a_drone_at_an_aim_under_the_land_hits() {
|
||||
let (mut ground, land) = (Ground::default(), sites::testland::Land(|_, _| 63));
|
||||
let mut sim = Sim::new(5);
|
||||
sim.targets.push(DVec3::new(0.0, 56.0, 0.0));
|
||||
sim.target_health.push(100.0);
|
||||
let d = sim.make_drone(DroneKind::Geran3, DVec3::new(-400.0, 100.0, 0.0), DVec3::X, DVec3::new(0.0, 56.0, 0.0));
|
||||
sim.drones.push(d);
|
||||
let mut out = Out::default();
|
||||
for _ in 0..1200 {
|
||||
sites::testland::step(&mut sim, &mut ground, &land, &mut out);
|
||||
if sim.drones.is_empty() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert_eq!((sim.hits, sim.crashes), (1, 0), "hits {} crashes {}", sim.hits, sim.crashes);
|
||||
}
|
||||
|
||||
/// Over land the game has not told of, a low-flying drone does not hug the height of its aim: it holds the transit
|
||||
/// height (the cruise height over the aim) and comes down only once the land ahead is known.
|
||||
#[test]
|
||||
fn over_unknown_land_a_low_flight_holds_its_transit_height() {
|
||||
let aim = DVec3::new(0.0, 64.0, 3000.0);
|
||||
let fly = |known: bool| {
|
||||
let mut sim = Sim::new(4);
|
||||
let mut d = sim.make_drone(DroneKind::Kh101, DVec3::new(0.0, 70.0, 0.0), DVec3::Z, aim);
|
||||
d.low = true;
|
||||
d.route = vec![aim];
|
||||
sim.drones.push(d);
|
||||
let (mut ground, land) = (Ground::default(), sites::testland::Land(|_, _| 64));
|
||||
let mut out = Out::default();
|
||||
for _ in 0..300 {
|
||||
if known {
|
||||
sites::testland::step(&mut sim, &mut ground, &land, &mut out);
|
||||
} else {
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
}
|
||||
}
|
||||
sim.drones[0].pos.y
|
||||
};
|
||||
let spec = DroneKind::Kh101.spec();
|
||||
let blind = fly(false);
|
||||
let seen = fly(true);
|
||||
assert!(blind > aim.y + spec.cruise - 8.0, "blind and low: {blind}");
|
||||
assert!(seen < aim.y + 20.0, "over land it knows it keeps hugging it: {seen}");
|
||||
}
|
||||
|
||||
/// The height map is a coarse upper bound (a forest's canopy shows as land): an interceptor under it, with the blocks
|
||||
/// around it open, is not blown up for "no way over"; it is blown up only before blocks that are really there.
|
||||
#[test]
|
||||
fn an_interceptor_under_the_canopy_is_not_scrubbed_before_open_air() {
|
||||
let blocks = sites::testland::Land(|_, _| 64);
|
||||
let steer = |solid_to: i32| {
|
||||
let mut ground = Ground::default();
|
||||
let land = sites::testland::Land(move |_, _| solid_to);
|
||||
let kind = MissileKind::M57e6;
|
||||
let pos = DVec3::new(0.0, 66.0, 0.0);
|
||||
let mut fail = false;
|
||||
for t in 0..30 {
|
||||
// The heights say 76 (the canopy); the blocks are solid only up to `solid_to`.
|
||||
let cols = ground.take_wanted().into_iter().map(|(x, z)| (x, z, 76)).collect();
|
||||
ground.answer(cols, t);
|
||||
let secs = ground.world.take_wanted(t);
|
||||
ground.world.serve(&land, secs, t);
|
||||
fail = terrain::steer(&mut ground, kind, pos, kind.spec().speed, DVec3::new(0.0, 70.0, 200.0), t).1;
|
||||
}
|
||||
fail
|
||||
};
|
||||
let _ = blocks;
|
||||
assert!(!steer(64), "open air under the canopy");
|
||||
assert!(steer(80), "real blocks ahead");
|
||||
}
|
||||
|
||||
/// A flight that is high over land nobody has told of does not come down towards the height of its aim.
|
||||
#[test]
|
||||
fn over_unknown_land_a_flight_does_not_descend() {
|
||||
let aim = DVec3::new(0.0, 64.0, 3000.0);
|
||||
let mut sim = Sim::new(4);
|
||||
let mut d = sim.make_drone(DroneKind::Kh101, DVec3::new(0.0, 250.0, 0.0), DVec3::Z, aim);
|
||||
d.low = true;
|
||||
d.route = vec![aim];
|
||||
sim.drones.push(d);
|
||||
let (mut ground, mut out) = (Ground::default(), Out::default());
|
||||
for _ in 0..150 {
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
}
|
||||
assert!(sim.drones[0].pos.y > 245.0, "it came down over unknown land: {}", sim.drones[0].pos.y);
|
||||
}
|
||||
|
||||
/// #90: a cruise flight that stops getting nearer its aim (a turn circle wider than the distance, a hold that
|
||||
/// never ends) falls out of the sky after `STALL_TICKS`, so a raid is not held open by it.
|
||||
#[test]
|
||||
fn a_flight_that_makes_no_headway_runs_out_of_fuel() {
|
||||
let mut pace = Pace::default();
|
||||
// Nearer and nearer: never stalled.
|
||||
for age in 1..10_000u32 {
|
||||
assert!(!pace.stalled(age, 5000.0 - f64::from(age) * 0.5, 1), "a flight under way stalled at {age}");
|
||||
}
|
||||
// Circling at 40 blocks from the aim.
|
||||
let mut pace = Pace::default();
|
||||
let mut ended = None;
|
||||
for age in 1..10_000u32 {
|
||||
if pace.stalled(age, 40.0 + f64::from(age % 7), 1) {
|
||||
ended = Some(age);
|
||||
break;
|
||||
}
|
||||
}
|
||||
let ended = ended.expect("a circling flight never ran out of fuel");
|
||||
assert!((STALL_TICKS..STALL_TICKS + 20).contains(&ended), "{ended}");
|
||||
// Passing a route point is progress, however far off the aim the way goes.
|
||||
let mut pace = Pace::default();
|
||||
for age in 1..10_000u32 {
|
||||
assert!(!pace.stalled(age, 3000.0, 10 - (age / 1000) as usize), "route points passed, still stalled at {age}");
|
||||
}
|
||||
}
|
||||
|
||||
/// #90: the same in the simulation: a drone that gets no nearer its aim (here the aim keeps its distance, as one
|
||||
/// does that it cannot turn onto) ends, falling, within the stall time, and the raid is not held open by it.
|
||||
#[test]
|
||||
fn a_drone_that_never_arrives_ends_the_raid() {
|
||||
let mut sim = Sim::new(4);
|
||||
let mut d = sim.make_drone(DroneKind::Kh101, DVec3::new(0.0, 400.0, 0.0), DVec3::X, DVec3::new(3000.0, 400.0, 0.0));
|
||||
d.low = false;
|
||||
sim.drones.push(d);
|
||||
let (mut ground, mut out) = (Ground::default(), Out::default());
|
||||
let mut ended = None;
|
||||
for t in 0..STALL_TICKS + 400 {
|
||||
if let Some(d) = sim.drones.first_mut() {
|
||||
d.target = d.pos + DVec3::X * 3000.0;
|
||||
}
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
if !sim.drones.iter().any(|d| d.alive()) {
|
||||
ended = Some(t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
let ended = ended.expect("still airborne after the stall time");
|
||||
assert!(ended >= STALL_TICKS, "ended early: {ended}");
|
||||
assert_eq!(sim.stalled, 1);
|
||||
}
|
||||
|
||||
/// #90: an answer says which world it is of. Heights of another dimension are not this one's, and an answer to a
|
||||
/// question asked before the world changed is dropped, not read as the new world's.
|
||||
#[test]
|
||||
fn heights_of_another_world_are_void_and_late_answers_are_dropped() {
|
||||
let mut ground = Ground::default();
|
||||
ground.world.changed_rev(1, 0, false, &[]);
|
||||
ground.answer(vec![(4, 4, 70), (12, 4, NO_LAND)], 1);
|
||||
assert_eq!(ground.land_state(DVec3::new(4.5, 80.0, 4.5)), Some(Some(70.0)));
|
||||
assert_eq!(ground.land_state(DVec3::new(12.5, 80.0, 4.5)), Some(None), "no land is an answer too");
|
||||
// A question goes out in world 1; the dimension changes before the answer comes.
|
||||
let _ = ground.land(DVec3::new(100.5, 80.0, 100.5));
|
||||
assert_eq!(ground.take_wanted().len(), 1);
|
||||
ground.world.changed_rev(2, 0, false, &[]);
|
||||
ground.answer(vec![(100, 100, 55)], 2);
|
||||
assert_eq!(ground.world.stats.late_dropped, 1);
|
||||
assert_eq!(ground.land_state(DVec3::new(4.5, 80.0, 4.5)), None, "the old dimension's height is gone, asked again");
|
||||
assert_eq!(ground.land_state(DVec3::new(100.5, 80.0, 100.5)), None, "the late answer was not taken");
|
||||
}
|
||||
|
||||
/// #90: a blast asked of the game in the blocks is confirmed by the game's own report of blocks changed there; one
|
||||
/// that is not reported is told apart by whether the land was there.
|
||||
#[test]
|
||||
fn a_blast_in_the_blocks_waits_for_the_games_word() {
|
||||
let mut ground = Ground::default();
|
||||
ground.answer(vec![(4, 4, 70)], 1);
|
||||
let near = DVec3::new(4.5, 70.0, 4.5);
|
||||
let far = DVec3::new(900.5, 70.0, 900.5);
|
||||
ground.world.expect_blast(near, 8.0, 1);
|
||||
ground.world.expect_blast(near + DVec3::X * 200.0, 8.0, 1);
|
||||
ground.world.expect_blast(far, 8.0, 1);
|
||||
ground.world.changed_rev(1, 1, false, &[(0, 4, 0)]);
|
||||
assert_eq!(ground.world.stats.blasts_confirmed, 1);
|
||||
ground.answer(vec![], 1 + world::CONFIRM_TICKS);
|
||||
let s = ground.world.stats;
|
||||
assert_eq!((s.blasts_asked, s.blasts_confirmed, s.blasts_unchanged, s.blasts_unloaded), (3, 1, 0, 2));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,715 @@
|
||||
//! Ground routes for the vehicles (#94): a march is no longer a straight line through the relief. A bounded
|
||||
//! A* over a coarse grid of the land the game has told of finds a way that avoids cliffs, water and walls; it
|
||||
//! is worked on a few hundred cells a tick, shared by all the vehicles, and it keeps its state between ticks.
|
||||
//! Land the game has not answered yet is waited for (the search parks those edges and goes on elsewhere), and
|
||||
//! after a while the vehicle goes as far as the known land; a place nobody can reach is refused with a reason.
|
||||
//! While driving, the column ahead is checked once more (a wall the grid missed, a drop): the cell is marked bad
|
||||
//! and the way is searched again.
|
||||
use super::*;
|
||||
use std::collections::{BinaryHeap, HashSet};
|
||||
|
||||
/// Cells opened a tick, all vehicles together.
|
||||
pub(super) const WORK_PER_TICK: usize = 600;
|
||||
/// Cells opened for one route before it settles for the nearest it got.
|
||||
const MAX_NODES: usize = 24_000;
|
||||
/// Ticks the search waits for land the game has not told of, before the vehicle goes as far as is known.
|
||||
const WAIT_MAP: u64 = 300;
|
||||
/// Ticks a driver waits for the column ahead.
|
||||
const WAIT_AHEAD: u32 = 200;
|
||||
/// Searches again, after a way was found blocked on the march, before giving up.
|
||||
const REPLANS: u32 = 16;
|
||||
/// The tallest step a vehicle climbs between two columns, and the deepest drop it takes.
|
||||
pub(super) const STEP_UP: f64 = 1.5;
|
||||
pub(super) const STEP_DOWN: f64 = 3.5;
|
||||
/// Ticks a truck keeps away from a job it found unreachable.
|
||||
pub(super) const UNREACHABLE_FOR: u64 = 3600;
|
||||
|
||||
/// Why a vehicle waits or stops.
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
pub enum Why {
|
||||
/// Waiting for the game's answers about the land.
|
||||
Map,
|
||||
/// The place itself can't be driven to (cliff, water, wall).
|
||||
Goal,
|
||||
/// No way there over the known land.
|
||||
NoWay,
|
||||
/// The way was found blocked on the march, again and again.
|
||||
Stuck,
|
||||
/// The map did not come.
|
||||
NoMap,
|
||||
/// It drove as far as the land is known.
|
||||
Partial,
|
||||
}
|
||||
|
||||
impl Why {
|
||||
pub fn text(self) -> &'static str {
|
||||
match self {
|
||||
Why::Map => "ждёт карту местности",
|
||||
Why::Goal => "туда не проехать: обрыв, вода или стена в точке назначения",
|
||||
Why::NoWay => "прохода нет: путь перекрыт обрывами, водой или стенами",
|
||||
Why::Stuck => "путь перекрыт на марше, объезда нет",
|
||||
Why::NoMap => "карта местности не пришла, остался на месте",
|
||||
Why::Partial => "дальше карта неизвестна: остановился на краю известного",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What the route says a vehicle does this tick.
|
||||
pub(super) enum Drive {
|
||||
/// Stand: for the land, or the planner.
|
||||
Wait(Why),
|
||||
/// Drive at this point; whether it is the last, and the route ends short of the order.
|
||||
Go(DVec3, bool),
|
||||
/// Stop here, and say why.
|
||||
Fail(Why),
|
||||
}
|
||||
|
||||
/// Result of checking the vehicle's clearance at its next position.
|
||||
pub(super) enum Clearance {
|
||||
Clear,
|
||||
Blocked,
|
||||
Pending,
|
||||
}
|
||||
|
||||
/// Conservative chassis envelope. The circular footprint is the circumscribed plan-view of the
|
||||
/// folded vehicle; it makes turns safe without adding heading to the bounded A* state.
|
||||
#[derive(Clone, Copy)]
|
||||
struct Chassis {
|
||||
radius: f64,
|
||||
height: f64,
|
||||
}
|
||||
|
||||
impl Chassis {
|
||||
fn for_kind(kind: SamKind) -> Self {
|
||||
let (radius, height): (f64, f64) = match kind.spec().family {
|
||||
Family::Trainable => (2.25, 3.0),
|
||||
Family::Gun => (1.75, 3.0),
|
||||
Family::Turret => (2.0, 3.25),
|
||||
Family::Vertical => (2.75, 3.5),
|
||||
Family::Static => (2.0, 3.0),
|
||||
Family::Truck => (1.75, 2.75),
|
||||
Family::Light => (1.25, 2.5),
|
||||
};
|
||||
// Rendered geometry may extend past the nominal family envelope (rotated wheels too).
|
||||
// Read the generated bounds of the exact body rather than letting art silently shrink clearance.
|
||||
let (radius, height) = match super::generated_bounds::bounds(kind.spec().parts.body) {
|
||||
Some((lo, hi)) => {
|
||||
let scale = kind.spec().scale / 16.0;
|
||||
let half_x = (lo[0] - 8.0).abs().max((hi[0] - 8.0).abs()) * scale;
|
||||
let half_z = (lo[2] - 8.0).abs().max((hi[2] - 8.0).abs()) * scale;
|
||||
(radius.max(half_x.hypot(half_z) + 0.125), height.max(hi[1] * scale))
|
||||
}
|
||||
None => (radius, height), // Content validation rejects missing models before packaging.
|
||||
};
|
||||
Self { radius, height }
|
||||
}
|
||||
|
||||
/// Every voxel whose square intersects the conservative footprint, including grazing corners.
|
||||
fn samples(self) -> Vec<(i32, i32)> {
|
||||
let r = self.radius.ceil() as i32;
|
||||
(-r..=r).flat_map(|x| (-r..=r).filter_map(move |z| {
|
||||
let dx = (f64::from(x.abs()) - 0.5).max(0.0);
|
||||
let dz = (f64::from(z.abs()) - 0.5).max(0.0);
|
||||
(dx * dx + dz * dz <= self.radius * self.radius).then_some((x, z))
|
||||
})).collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct Info {
|
||||
h: f32,
|
||||
ok: bool,
|
||||
}
|
||||
|
||||
enum Eval {
|
||||
Ok(f32),
|
||||
Bad,
|
||||
Pending,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct Open(f32, (i32, i32));
|
||||
impl Eq for Open {}
|
||||
impl Ord for Open {
|
||||
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||
other.0.total_cmp(&self.0)
|
||||
}
|
||||
}
|
||||
impl PartialOrd for Open {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum Phase {
|
||||
Search,
|
||||
Follow,
|
||||
}
|
||||
|
||||
/// One vehicle's way to its destination.
|
||||
pub(super) struct Route {
|
||||
dest: DVec3,
|
||||
/// How near the destination counts (a truck stops beside its job); 0: the place itself.
|
||||
slack: f64,
|
||||
cell: i32,
|
||||
slope: f64,
|
||||
chassis: Chassis,
|
||||
start: (i32, i32),
|
||||
lo: (i32, i32),
|
||||
hi: (i32, i32),
|
||||
cells: HashMap<(i32, i32), Info>,
|
||||
bad: HashSet<(i32, i32)>,
|
||||
g: HashMap<(i32, i32), f32>,
|
||||
came: HashMap<(i32, i32), (i32, i32)>,
|
||||
open: BinaryHeap<Open>,
|
||||
/// Edges waiting for a cell the game has not answered.
|
||||
parked: Vec<((i32, i32), (i32, i32))>,
|
||||
retry_at: u64,
|
||||
stuck_since: Option<u64>,
|
||||
/// The cell opened that is nearest the destination.
|
||||
near: ((i32, i32), f64),
|
||||
expanded: usize,
|
||||
goal_checked: bool,
|
||||
phase: Phase,
|
||||
pts: Vec<DVec3>,
|
||||
next: usize,
|
||||
pub(super) partial: bool,
|
||||
replans: u32,
|
||||
ahead_wait: u32,
|
||||
began: u64,
|
||||
pub(super) told: bool,
|
||||
failed: Option<Why>,
|
||||
}
|
||||
|
||||
impl Route {
|
||||
pub(super) fn new(pos: DVec3, dest: DVec3, slack: f64, kind: SamKind, now: u64) -> Self {
|
||||
let dist = horizontal(dest - pos).length();
|
||||
let cell = if dist <= 400.0 { 4 } else if dist <= 900.0 { 6 } else { 8 };
|
||||
let mut r = Self {
|
||||
dest,
|
||||
slack,
|
||||
cell,
|
||||
slope: kind.climbs(),
|
||||
chassis: Chassis::for_kind(kind),
|
||||
start: (0, 0),
|
||||
lo: (0, 0),
|
||||
hi: (0, 0),
|
||||
cells: HashMap::new(),
|
||||
bad: HashSet::new(),
|
||||
g: HashMap::new(),
|
||||
came: HashMap::new(),
|
||||
open: BinaryHeap::new(),
|
||||
parked: Vec::new(),
|
||||
retry_at: 0,
|
||||
stuck_since: None,
|
||||
near: ((0, 0), f64::MAX),
|
||||
expanded: 0,
|
||||
goal_checked: slack > 0.0,
|
||||
phase: Phase::Search,
|
||||
pts: Vec::new(),
|
||||
next: 0,
|
||||
partial: false,
|
||||
replans: 0,
|
||||
ahead_wait: 0,
|
||||
began: now,
|
||||
told: false,
|
||||
failed: None,
|
||||
};
|
||||
r.restart(pos);
|
||||
r
|
||||
}
|
||||
|
||||
fn cell_of(&self, p: DVec3) -> (i32, i32) {
|
||||
((p.x.floor() as i32).div_euclid(self.cell), (p.z.floor() as i32).div_euclid(self.cell))
|
||||
}
|
||||
fn centre(&self, c: (i32, i32)) -> DVec3 {
|
||||
let k = f64::from(self.cell);
|
||||
DVec3::new((f64::from(c.0) + 0.5) * k, 0.0, (f64::from(c.1) + 0.5) * k)
|
||||
}
|
||||
fn to_goal(&self, c: (i32, i32)) -> f64 {
|
||||
horizontal(self.centre(c) - self.dest).length()
|
||||
}
|
||||
fn is_goal(&self, c: (i32, i32)) -> bool {
|
||||
if self.slack > 0.0 { self.to_goal(c) <= self.slack } else { c == self.cell_of(self.dest) }
|
||||
}
|
||||
|
||||
/// Searches afresh from `pos`, keeping the cells found bad.
|
||||
fn restart(&mut self, pos: DVec3) {
|
||||
self.start = self.cell_of(pos);
|
||||
let goal = self.cell_of(self.dest);
|
||||
let margin = (((self.start.0 - goal.0).abs().max((self.start.1 - goal.1).abs()) / 2).max(16)).min(64);
|
||||
self.lo = (self.start.0.min(goal.0) - margin, self.start.1.min(goal.1) - margin);
|
||||
self.hi = (self.start.0.max(goal.0) + margin, self.start.1.max(goal.1) + margin);
|
||||
self.g.clear();
|
||||
self.came.clear();
|
||||
self.open.clear();
|
||||
self.parked.clear();
|
||||
self.pts.clear();
|
||||
self.next = 0;
|
||||
self.phase = Phase::Search;
|
||||
self.stuck_since = None;
|
||||
self.expanded = 0;
|
||||
self.near = (self.start, f64::MAX);
|
||||
self.partial = false;
|
||||
self.cells.insert(self.start, Info { h: pos.y as f32, ok: true });
|
||||
self.g.insert(self.start, 0.0);
|
||||
let h = self.heur(self.start);
|
||||
self.open.push(Open(h, self.start));
|
||||
}
|
||||
|
||||
fn heur(&self, c: (i32, i32)) -> f32 {
|
||||
(self.to_goal(c) * 1.1) as f32
|
||||
}
|
||||
|
||||
fn eval(&mut self, ground: &mut Ground, now: u64, c: (i32, i32)) -> Eval {
|
||||
if let Some(i) = self.cells.get(&c) {
|
||||
return if i.ok { Eval::Ok(i.h) } else { Eval::Bad };
|
||||
}
|
||||
if self.bad.contains(&c) {
|
||||
return Eval::Bad;
|
||||
}
|
||||
let p = self.centre(c);
|
||||
let (x, z) = (p.x.floor() as i32, p.z.floor() as i32);
|
||||
let verdict = match ground.column(x, z, 1024) {
|
||||
None => return Eval::Pending,
|
||||
Some(None) => Info { h: 0.0, ok: false },
|
||||
Some(Some(h)) => {
|
||||
// The height is the top of what blocks motion or holds a fluid: water has nothing solid under it.
|
||||
let top = DVec3::new(f64::from(x) + 0.5, h, f64::from(z) + 0.5);
|
||||
match ground.world.sweep(top + DVec3::Y * 0.5, top - DVec3::Y * 0.5, false, now) {
|
||||
world::Sweep::Hit { .. } => Info { h: h as f32, ok: true },
|
||||
world::Sweep::Clear => Info { h: h as f32, ok: false },
|
||||
world::Sweep::Unknown { pending: true, .. } | world::Sweep::Wait { .. } => return Eval::Pending,
|
||||
world::Sweep::Unknown { .. } => Info { h: h as f32, ok: false },
|
||||
}
|
||||
}
|
||||
};
|
||||
if verdict.ok {
|
||||
match self.clearance_at(ground, DVec3::new(f64::from(x) + 0.5, f64::from(verdict.h), f64::from(z) + 0.5), now) {
|
||||
Clearance::Clear => {}
|
||||
Clearance::Blocked => {
|
||||
let blocked = Info { h: verdict.h, ok: false };
|
||||
self.cells.insert(c, blocked);
|
||||
return Eval::Bad;
|
||||
}
|
||||
Clearance::Pending => return Eval::Pending,
|
||||
}
|
||||
}
|
||||
self.cells.insert(c, verdict);
|
||||
if verdict.ok { Eval::Ok(verdict.h) } else { Eval::Bad }
|
||||
}
|
||||
|
||||
/// Check a chassis-sized footprint against sampled support columns and voxel headroom.
|
||||
/// Unknown columns or sections are pending so neither search nor motion assumes they are open.
|
||||
fn clearance_at(&self, ground: &mut Ground, pos: DVec3, now: u64) -> Clearance {
|
||||
let base = pos.y;
|
||||
let mut pending = false;
|
||||
for (dx, dz) in self.chassis.samples() {
|
||||
let x = pos.x.floor() as i32 + dx;
|
||||
let z = pos.z.floor() as i32 + dz;
|
||||
let Some(column) = ground.column(x, z, 1024) else { pending = true; continue };
|
||||
let Some(h) = column else { return Clearance::Blocked };
|
||||
let dh = h - base;
|
||||
if dh > STEP_UP || dh < -STEP_DOWN {
|
||||
return Clearance::Blocked;
|
||||
}
|
||||
let top = DVec3::new(f64::from(x) + 0.5, h + 0.05, f64::from(z) + 0.5);
|
||||
match ground.world.sweep(top, top + DVec3::Y * self.chassis.height, false, now) {
|
||||
world::Sweep::Clear => {}
|
||||
world::Sweep::Unknown { pending: true, .. } | world::Sweep::Wait { .. } => pending = true,
|
||||
world::Sweep::Unknown { .. } | world::Sweep::Hit { .. } => return Clearance::Blocked,
|
||||
}
|
||||
}
|
||||
if pending { Clearance::Pending } else { Clearance::Clear }
|
||||
}
|
||||
|
||||
/// Recheck the envelope at the live position, since obstacles may change after planning.
|
||||
pub(super) fn clearance(&self, ground: &mut Ground, pos: DVec3, now: u64) -> Clearance {
|
||||
self.clearance_at(ground, pos, now)
|
||||
}
|
||||
|
||||
/// Relaxes the edge from the opened cell `c` to `nb`; parks it when the land between isn't known yet.
|
||||
fn relax(&mut self, ground: &mut Ground, now: u64, c: (i32, i32), nb: (i32, i32)) {
|
||||
if nb.0 < self.lo.0 || nb.1 < self.lo.1 || nb.0 > self.hi.0 || nb.1 > self.hi.1 {
|
||||
return;
|
||||
}
|
||||
let (di, dj) = (nb.0 - c.0, nb.1 - c.1);
|
||||
let len = if di != 0 && dj != 0 { std::f64::consts::SQRT_2 } else { 1.0 };
|
||||
let dist = len * f64::from(self.cell);
|
||||
let Some(h0) = self.cells.get(&c).map(|i| f64::from(i.h)) else { return };
|
||||
let h1 = match self.eval(ground, now, nb) {
|
||||
Eval::Ok(h) => f64::from(h),
|
||||
Eval::Bad => return,
|
||||
Eval::Pending => return self.park(c, nb),
|
||||
};
|
||||
// A diagonal doesn't cut a corner of something in the way.
|
||||
if di != 0 && dj != 0 {
|
||||
for side in [(c.0 + di, c.1), (c.0, c.1 + dj)] {
|
||||
match self.eval(ground, now, side) {
|
||||
Eval::Ok(h) if (f64::from(h) - h0).abs() <= (self.slope * f64::from(self.cell)).max(STEP_UP) => {}
|
||||
Eval::Pending => return self.park(c, nb),
|
||||
_ => return,
|
||||
}
|
||||
}
|
||||
}
|
||||
// Between the centres: a wall one block thick or a ditch there is what the centres don't show.
|
||||
let (a, b) = (self.centre(c), self.centre(nb));
|
||||
let mid = (a + b) * 0.5;
|
||||
let hm = match ground.column(mid.x.floor() as i32, mid.z.floor() as i32, 1024) {
|
||||
None => return self.park(c, nb),
|
||||
Some(None) => return,
|
||||
Some(Some(h)) => h,
|
||||
};
|
||||
let half = dist * 0.5;
|
||||
let allow = |l: f64| (self.slope * l).max(STEP_UP);
|
||||
if (hm - h0).abs() > allow(half) || (h1 - hm).abs() > allow(half) || hm - h0 < -STEP_DOWN * (half / 2.0).max(1.0) {
|
||||
return;
|
||||
}
|
||||
let dh = (h1 - h0).abs();
|
||||
if dh > allow(dist) {
|
||||
return;
|
||||
}
|
||||
let cost = (dist + 2.0 * dh) as f32;
|
||||
let ng = self.g.get(&c).copied().unwrap_or(0.0) + cost;
|
||||
if self.g.get(&nb).is_none_or(|&g| ng < g) {
|
||||
self.g.insert(nb, ng);
|
||||
self.came.insert(nb, c);
|
||||
self.open.push(Open(ng + self.heur(nb), nb));
|
||||
}
|
||||
}
|
||||
|
||||
fn park(&mut self, c: (i32, i32), nb: (i32, i32)) {
|
||||
if self.parked.len() < 4096 {
|
||||
self.parked.push((c, nb));
|
||||
}
|
||||
}
|
||||
|
||||
/// Works on the search: at most `budget` cells.
|
||||
fn search(&mut self, ground: &mut Ground, now: u64, mut budget: usize) {
|
||||
if !self.goal_checked {
|
||||
match self.eval(ground, now, self.cell_of(self.dest)) {
|
||||
Eval::Bad => {
|
||||
self.failed = Some(Why::Goal);
|
||||
return;
|
||||
}
|
||||
Eval::Ok(_) => self.goal_checked = true,
|
||||
Eval::Pending => {}
|
||||
}
|
||||
}
|
||||
if now >= self.retry_at && !self.parked.is_empty() {
|
||||
self.retry_at = now + 1;
|
||||
let parked = std::mem::take(&mut self.parked);
|
||||
for (k, &(c, nb)) in parked.iter().enumerate() {
|
||||
// The game loads the chunk of the first few, if it loads on request.
|
||||
if k < 6 {
|
||||
let p = self.centre(nb);
|
||||
ground.want_chunk(((p.x.floor() as i32) >> 4, (p.z.floor() as i32) >> 4));
|
||||
}
|
||||
self.relax(ground, now, c, nb);
|
||||
}
|
||||
}
|
||||
let before = self.expanded;
|
||||
while budget > 0 {
|
||||
let Some(Open(f, c)) = self.open.pop() else { break };
|
||||
let g = self.g.get(&c).copied().unwrap_or(f32::INFINITY);
|
||||
if f > g + self.heur(c) + 1e-3 {
|
||||
continue;
|
||||
}
|
||||
budget -= 1;
|
||||
self.expanded += 1;
|
||||
if self.is_goal(c) {
|
||||
self.finish(c, false);
|
||||
return;
|
||||
}
|
||||
let d = self.to_goal(c);
|
||||
if d < self.near.1 {
|
||||
self.near = (c, d);
|
||||
}
|
||||
for (di, dj) in [(1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1)] {
|
||||
self.relax(ground, now, c, (c.0 + di, c.1 + dj));
|
||||
}
|
||||
// Let pending footprint queries settle before opening a broad, less useful frontier.
|
||||
// Otherwise three trucks can saturate the shared world budget without ever moving.
|
||||
if self.expanded >= MAX_NODES {
|
||||
self.settle(now);
|
||||
return;
|
||||
}
|
||||
if !self.parked.is_empty() { break; }
|
||||
}
|
||||
if self.expanded > before {
|
||||
self.stuck_since = None;
|
||||
}
|
||||
if self.open.is_empty() {
|
||||
if self.parked.is_empty() {
|
||||
let goal = self.cell_of(self.dest);
|
||||
self.failed = Some(if self.slack == 0.0 && !self.cells.get(&goal).is_none_or(|i| i.ok) { Why::Goal } else { Why::NoWay });
|
||||
} else {
|
||||
let since = *self.stuck_since.get_or_insert(now);
|
||||
if now.saturating_sub(since) > WAIT_MAP {
|
||||
self.settle(now);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.stuck_since = None;
|
||||
}
|
||||
}
|
||||
|
||||
/// The land stays unknown (or the search is too big): the way to the nearest cell it got to.
|
||||
fn settle(&mut self, _now: u64) {
|
||||
let (c, d) = self.near;
|
||||
let here = self.to_goal(self.start);
|
||||
if c == self.start || here - d < f64::from(self.cell) * 2.0 {
|
||||
self.failed = Some(Why::NoMap);
|
||||
} else {
|
||||
self.finish(c, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// The way to cell `c`, as points with the straight stretches dropped.
|
||||
fn finish(&mut self, c: (i32, i32), partial: bool) {
|
||||
let mut cells = vec![c];
|
||||
let mut k = c;
|
||||
while let Some(&p) = self.came.get(&k) {
|
||||
cells.push(p);
|
||||
k = p;
|
||||
if cells.len() > 100_000 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
cells.reverse();
|
||||
let mut pts: Vec<DVec3> = Vec::new();
|
||||
for w in 1..cells.len() {
|
||||
let dir = (cells[w].0 - cells[w - 1].0, cells[w].1 - cells[w - 1].1);
|
||||
let last = w + 1 == cells.len();
|
||||
let turns = !last && (cells[w + 1].0 - cells[w].0, cells[w + 1].1 - cells[w].1) != dir;
|
||||
if last || turns {
|
||||
pts.push(self.centre(cells[w]));
|
||||
}
|
||||
}
|
||||
let end = if partial || self.slack > 0.0 { self.centre(c) } else { self.dest };
|
||||
match pts.last_mut() {
|
||||
Some(l) => *l = end,
|
||||
None => pts.push(end),
|
||||
}
|
||||
self.pts = pts;
|
||||
self.next = 0;
|
||||
self.partial = partial;
|
||||
self.phase = Phase::Follow;
|
||||
}
|
||||
|
||||
/// The column ahead stopped the vehicle: mark it, and search again from here.
|
||||
pub(super) fn blocked_ahead(&mut self, at: DVec3, pos: DVec3) {
|
||||
let c = self.cell_of(at);
|
||||
if c != self.cell_of(pos) {
|
||||
self.bad.insert(c);
|
||||
self.cells.insert(c, Info { h: 0.0, ok: false });
|
||||
} else {
|
||||
// In the cell itself: the stretch ahead, one cell on.
|
||||
let d = horizontal(at - pos).normalize_or(DVec3::X) * f64::from(self.cell);
|
||||
let c = self.cell_of(pos + d);
|
||||
self.bad.insert(c);
|
||||
self.cells.insert(c, Info { h: 0.0, ok: false });
|
||||
}
|
||||
self.replans += 1;
|
||||
if self.replans > REPLANS {
|
||||
self.failed = Some(Why::Stuck);
|
||||
} else {
|
||||
self.restart(pos);
|
||||
}
|
||||
}
|
||||
|
||||
/// Ticks the vehicle has waited for the land ahead; true when it has waited too long.
|
||||
pub(super) fn wait_ahead(&mut self) -> bool {
|
||||
self.ahead_wait += 1;
|
||||
self.ahead_wait > WAIT_AHEAD
|
||||
}
|
||||
pub(super) fn ahead_ok(&mut self) {
|
||||
self.ahead_wait = 0;
|
||||
}
|
||||
pub(super) fn waited(&self, now: u64) -> u64 {
|
||||
now.saturating_sub(self.began)
|
||||
}
|
||||
|
||||
/// What the vehicle at `pos` does: works the search on its share of the tick, then follows the way.
|
||||
pub(super) fn drive(&mut self, ground: &mut Ground, now: u64, pos: DVec3, budget: usize) -> Drive {
|
||||
if self.phase == Phase::Search && self.failed.is_none() {
|
||||
self.search(ground, now, budget);
|
||||
}
|
||||
if let Some(why) = self.failed {
|
||||
return Drive::Fail(why);
|
||||
}
|
||||
if self.phase == Phase::Search {
|
||||
return Drive::Wait(Why::Map);
|
||||
}
|
||||
let reach = f64::from(self.cell) * 0.7;
|
||||
while self.next + 1 < self.pts.len() && horizontal(self.pts[self.next] - pos).length() < reach {
|
||||
self.next += 1;
|
||||
}
|
||||
Drive::Go(self.pts[self.next], self.next + 1 >= self.pts.len())
|
||||
}
|
||||
|
||||
pub(super) fn searching(&self) -> bool {
|
||||
self.phase == Phase::Search && self.failed.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
/// The routes of the vehicles that drive, by system id, and the jobs a truck found out of reach.
|
||||
#[derive(Default)]
|
||||
pub(super) struct Routes {
|
||||
pub map: HashMap<u32, Route>,
|
||||
/// (truck id, the job's id) and until when the truck leaves it alone.
|
||||
pub unreachable: HashMap<(u32, u32), u64>,
|
||||
}
|
||||
|
||||
impl Routes {
|
||||
pub(super) fn out_of_reach(&self, truck: u32, job: u32, now: u64) -> bool {
|
||||
self.unreachable.get(&(truck, job)).is_some_and(|&t| t > now)
|
||||
}
|
||||
}
|
||||
|
||||
impl SamKind {
|
||||
/// The steepest slope (rise a block) it drives: trucks the least.
|
||||
pub(super) fn climbs(self) -> f64 {
|
||||
match self.spec().family {
|
||||
Family::Truck => 0.5,
|
||||
_ => 0.6,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn gun_chassis_cannot_use_the_old_one_point_seven_five_block_radius() {
|
||||
// The rendered Gepard hull alone is wider/longer than that nominal family circle.
|
||||
assert!(Chassis::for_kind(SamKind::Gepard).radius > 2.5);
|
||||
for kind in SamKind::ALL {
|
||||
assert!(super::super::generated_bounds::bounds(kind.spec().parts.body).is_some(), "{kind:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn footprint_checks_voxels_grazed_between_their_centres() {
|
||||
let cells = Chassis { radius: 2.75, height: 3.0 }.samples();
|
||||
assert!(cells.contains(&(3, 1)), "the body reaches the near corner of this voxel");
|
||||
assert!(cells.contains(&(-3, -1)));
|
||||
assert!(!cells.contains(&(3, 3)));
|
||||
}
|
||||
|
||||
/// The land as the game would tell it: the height map, and under it the blocks that are solid.
|
||||
struct Src<H: Fn(i32, i32) -> i32, B: Fn(i32, i32) -> i32> {
|
||||
height: H,
|
||||
floor: B,
|
||||
}
|
||||
impl<H: Fn(i32, i32) -> i32, B: Fn(i32, i32) -> i32> world::WorldSource for Src<H, B> {
|
||||
fn solid(&self, x: i32, y: i32, z: i32) -> Option<bool> {
|
||||
Some(y < (self.floor)(x, z))
|
||||
}
|
||||
}
|
||||
|
||||
fn answer<H: Fn(i32, i32) -> i32, B: Fn(i32, i32) -> i32>(ground: &mut Ground, src: &Src<H, B>, now: u64) {
|
||||
let columns = ground.take_wanted().into_iter().map(|(x, z)| (x, z, (src.height)(x, z))).collect();
|
||||
ground.answer(columns, now);
|
||||
let sections = ground.world.take_wanted(now);
|
||||
ground.world.serve(src, sections, now);
|
||||
}
|
||||
|
||||
/// Drives a Patriot from the origin to `to` over land of the given heights (water: a height over a lower floor).
|
||||
fn march_kind<H: Fn(i32, i32) -> i32, B: Fn(i32, i32) -> i32>(kind: SamKind, height: H, floor: B, to: DVec3, ticks: u32) -> (Sim, Out, u32) {
|
||||
let src = Src { height, floor };
|
||||
let mut sim = Sim::new(3);
|
||||
sim.damage = false;
|
||||
let mut ground = Ground::default();
|
||||
let id = sim.id();
|
||||
sim.sams.push(Sam::new(id, kind, DVec3::new(0.5, 64.0, 0.5), 0.0));
|
||||
let mut out = Out::default();
|
||||
for _ in 0..3 {
|
||||
sim.tick += 1;
|
||||
answer(&mut ground, &src, sim.tick);
|
||||
}
|
||||
assert!(sim.order_move(0, to));
|
||||
let mut used = 0;
|
||||
let mut worst = 0usize;
|
||||
for _ in 0..ticks {
|
||||
sim.tick += 1;
|
||||
sim.step_moves(&mut ground, &mut out);
|
||||
answer(&mut ground, &src, sim.tick);
|
||||
used += 1;
|
||||
let p = sim.sams[0].pos;
|
||||
let (x, z) = (p.x.floor() as i32, p.z.floor() as i32);
|
||||
assert!(((src.height)(x, z) as f64) <= p.y + 2.5, "inside the land at {p:?}");
|
||||
assert!((src.floor)(x, z) >= (src.height)(x, z), "drove onto water at {p:?}");
|
||||
worst = worst.max(sim.routes.map.values().filter(|r| r.searching()).count());
|
||||
if !sim.sams[0].moving() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let _ = worst;
|
||||
(sim, out, used)
|
||||
}
|
||||
|
||||
fn march<H: Fn(i32, i32) -> i32, B: Fn(i32, i32) -> i32>(height: H, floor: B, to: DVec3, ticks: u32) -> (Sim, Out, u32) {
|
||||
march_kind(SamKind::Patriot, height, floor, to, ticks)
|
||||
}
|
||||
|
||||
// A wall across the way, with a gap far to one side: the vehicle goes round and arrives.
|
||||
#[test]
|
||||
fn a_wall_with_a_gap_is_driven_round() {
|
||||
let wall = |x: i32, z: i32| if (40..44).contains(&x) && (-60..=40).contains(&z) { 90 } else { 64 };
|
||||
let (sim, _, _) = march(wall, wall, DVec3::new(120.0, 64.0, 0.5), 6000);
|
||||
let s = &sim.sams[0];
|
||||
assert!(!s.moving() && s.pos.distance(DVec3::new(120.0, 64.0, 0.5)) < 3.0, "ended at {:?} {:?}", s.pos, s.state);
|
||||
}
|
||||
|
||||
// A closed pocket: refused with a reason, no teleport and no drive into the wall.
|
||||
#[test]
|
||||
fn an_unreachable_place_is_refused() {
|
||||
let walls = |x: i32, z: i32| if (60..64).contains(&x) && (-300..300).contains(&z) { 100 } else { 64 };
|
||||
let (sim, out, _) = march(walls, walls, DVec3::new(120.0, 64.0, 0.5), 6000);
|
||||
let s = &sim.sams[0];
|
||||
assert!(!s.moving() && s.pos.x < 62.0, "{:?}", s.pos);
|
||||
assert!(out.messages.iter().any(|m| m.contains("прохода нет") || m.contains("перекрыт") || m.contains("карта")), "{:?}", out.messages);
|
||||
}
|
||||
|
||||
// A lake (height 64 over a floor of 50) is no road: it is gone round, and a destination in it is refused.
|
||||
#[test]
|
||||
fn a_lake_is_not_a_road() {
|
||||
let floor = |x: i32, z: i32| if (50..90).contains(&x) && z.abs() < 40 { 50 } else { 64 };
|
||||
let (sim, _, _) = march(|_, _| 64, floor, DVec3::new(130.0, 64.0, 0.5), 6000);
|
||||
let s = &sim.sams[0];
|
||||
assert!(!s.moving() && s.pos.distance(DVec3::new(130.0, 64.0, 0.5)) < 3.0, "{:?}", s.pos);
|
||||
let (sim, out, _) = march(|_, _| 64, floor, DVec3::new(70.0, 64.0, 0.5), 3000);
|
||||
assert!(!sim.sams[0].moving() && sim.sams[0].pos.x < 10.0, "{:?}", sim.sams[0].pos);
|
||||
assert!(out.messages.iter().any(|m| m.contains("не проехать")), "{:?}", out.messages);
|
||||
}
|
||||
|
||||
// Open ground: straight on, arrives.
|
||||
#[test]
|
||||
fn open_ground_is_driven_straight() {
|
||||
let (sim, out, _) = march(|_, _| 64, |_, _| 64, DVec3::new(100.0, 64.0, 30.5), 1500);
|
||||
let s = &sim.sams[0];
|
||||
let route = sim.routes.map.get(&s.id).map(|r| (r.expanded, r.parked.len(), r.open.len(), r.cells.len()));
|
||||
assert!(!s.moving() && s.pos.distance(DVec3::new(100.0, 64.0, 30.5)) < 3.0, "pos={:?} state={:?} messages={:?} route={route:?}", s.pos, s.state, out.messages);
|
||||
}
|
||||
|
||||
// A point-column route fits through this one-block slit, but the S-400 chassis does not.
|
||||
#[test]
|
||||
fn s400_rejects_a_one_block_corridor() {
|
||||
let walls = |x: i32, z: i32| if (-500..500).contains(&x) && z != 0 { 96 } else { 64 };
|
||||
let (sim, out, _) = march_kind(SamKind::S400, walls, walls, DVec3::new(60.5, 64.0, 0.5), 4000);
|
||||
assert!(!sim.sams[0].moving(), "{:?}", sim.sams[0].state);
|
||||
assert!(sim.sams[0].pos.x < 20.0, "narrow passage was traversed: {:?}", sim.sams[0].pos);
|
||||
assert!(out.messages.iter().any(|m| m.contains("прохода нет") || m.contains("не проехать")), "{:?}", out.messages);
|
||||
}
|
||||
|
||||
// A broad, level lane remains driveable for the same large vehicle.
|
||||
#[test]
|
||||
fn s400_uses_a_wide_corridor() {
|
||||
let walls = |x: i32, z: i32| if (-500..500).contains(&x) && !(-6..=6).contains(&z) { 96 } else { 64 };
|
||||
let (sim, _, _) = march_kind(SamKind::S400, walls, walls, DVec3::new(60.5, 64.0, 0.5), 5000);
|
||||
assert!(!sim.sams[0].moving() && sim.sams[0].pos.distance(DVec3::new(60.5, 64.0, 0.5)) < 3.0, "pos={:?} state={:?}", sim.sams[0].pos, sim.sams[0].state);
|
||||
}
|
||||
}
|
||||
@@ -181,6 +181,34 @@ fn a_close_blast_can_leave_a_firing_but_immobile_system() {
|
||||
assert!(found, "no seed left it firing but immobile");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fresh_own_radar_track_keeps_gun_hits_equal_day_and_night() {
|
||||
fn firing(seed: u64, night: bool) -> (u32, u32) {
|
||||
let mut sim = Sim::new(seed);
|
||||
let (mut ground, mut out) = flat();
|
||||
let gun = radar_at(&mut sim, SamKind::Gepard, 0.0);
|
||||
sim.night = night;
|
||||
sim.add_drone(
|
||||
DroneKind::Shahed,
|
||||
DVec3::new(0.0, 95.0, 35.0),
|
||||
DVec3::ZERO,
|
||||
DVec3::new(5000.0, 95.0, 35.0),
|
||||
);
|
||||
let starting_bursts = sim.sams[gun].bursts;
|
||||
for _ in 0..240 {
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
}
|
||||
(starting_bursts - sim.sams[gun].bursts, sim.sams[gun].kills)
|
||||
}
|
||||
|
||||
for seed in 0..32 {
|
||||
let day = firing(seed, false);
|
||||
let night = firing(seed, true);
|
||||
assert!(day.0 > 0, "seed {seed} did not fire");
|
||||
assert_eq!(night, day, "seed {seed}: radar gun changed its fire or kills at night");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_parts_block_what_they_serve_and_repair_restores_them() {
|
||||
let mut sim = Sim::new(2);
|
||||
|
||||
@@ -20,7 +20,7 @@ use super::*;
|
||||
const RAYS: usize = 48;
|
||||
const STEP: f64 = 16.0;
|
||||
/// How far units share their tracks (the network's data links).
|
||||
pub(super) const LINK: f64 = 1500.0;
|
||||
pub(super) const LINK: f64 = 2250.0;
|
||||
/// A launcher fires on a track no older than this (ticks); a gun needs its own radar's, newer than `GUN_AGE`.
|
||||
pub(super) const MISSILE_AGE: u64 = 120;
|
||||
pub(super) const GUN_AGE: u64 = 3;
|
||||
@@ -93,6 +93,97 @@ pub(super) fn reach(sam: &Sam, kind: DroneKind, height: f64) -> f64 {
|
||||
radar.min(horizon).max(NEAR)
|
||||
}
|
||||
|
||||
/// The low flyer the command map shows the radars' coverage for: a Shahed over the land.
|
||||
const LOW_KIND: DroneKind = DroneKind::Shahed;
|
||||
|
||||
/// A radar as the command map sees it: where its antenna is and how far it reaches a low flyer.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct LowSensor {
|
||||
pub id: u32,
|
||||
pub ant: DVec3,
|
||||
/// The ground under the unit (a place whose land is unknown is taken as level with it).
|
||||
pub base: f64,
|
||||
pub reach: f64,
|
||||
/// Its horizon is known: the land hides what it hides.
|
||||
pub terrain: bool,
|
||||
}
|
||||
|
||||
/// Rays of `Sim::low_rim`.
|
||||
pub const RIM_RAYS: usize = RAYS;
|
||||
|
||||
impl Ground {
|
||||
/// The land's height at `p` from what the game has already answered; asks for nothing.
|
||||
pub fn peek(&self, p: DVec3) -> Option<f64> {
|
||||
const LAT: i32 = super::terrain::LATTICE;
|
||||
let k = (p.x.floor() as i32, p.z.floor() as i32);
|
||||
let hit = self.known.get(&k).or_else(|| {
|
||||
self.known.get(&(k.0.div_euclid(LAT) * LAT + LAT / 2, k.1.div_euclid(LAT) * LAT + LAT / 2))
|
||||
});
|
||||
hit.and_then(|&(y, _)| land_height(y))
|
||||
}
|
||||
}
|
||||
|
||||
impl Sim {
|
||||
/// A radar for a unit of `kind` at `pos` as the map draws it; `id`: the unit it is (its parts and horizon), None for a ghost.
|
||||
pub fn low_sensor(&self, kind: SamKind, pos: DVec3, id: Option<u32>) -> Option<LowSensor> {
|
||||
let spec = kind.spec();
|
||||
if spec.sensor <= 0.0 {
|
||||
return None;
|
||||
}
|
||||
let fit = id.and_then(|i| self.sams.iter().find(|s| s.id == i)).map_or(1.0, |s| s.radar_fit());
|
||||
let height = LOW_KIND.spec().clearance;
|
||||
let radar = spec.sensor * fit * LOW_KIND.rcs().powf(0.25);
|
||||
let reach = radar.min(HORIZON * (spec.mast.sqrt() + height.sqrt())).max(NEAR);
|
||||
let terrain = id.is_some_and(|i| self.horizons.contains_key(&i));
|
||||
Some(LowSensor { id: id.unwrap_or(u32::MAX), ant: pos + DVec3::Y * spec.mast, base: pos.y, reach, terrain })
|
||||
}
|
||||
|
||||
/// The radars that are up now.
|
||||
pub fn low_sensors(&self) -> Vec<LowSensor> {
|
||||
self.sams.iter().filter(|s| s.radar_up()).filter_map(|s| self.low_sensor(s.kind, s.pos, Some(s.id))).collect()
|
||||
}
|
||||
|
||||
/// Whether the radar sees a low flyer (over the land) at the column (`x`, `z`): in its reach and not behind the land.
|
||||
pub fn low_sees(&self, ground: &Ground, s: &LowSensor, x: f64, z: f64) -> bool {
|
||||
let (dx, dz) = (x - s.ant.x, z - s.ant.z);
|
||||
let d2 = dx * dx + dz * dz;
|
||||
if d2 > s.reach * s.reach {
|
||||
return false;
|
||||
}
|
||||
if !s.terrain || d2 <= NEAR * NEAR {
|
||||
return true;
|
||||
}
|
||||
let Some(h) = self.horizons.get(&s.id) else { return true };
|
||||
let g = ground.peek(DVec3::new(x, 0.0, z)).unwrap_or(s.base);
|
||||
!h.hides(s.ant, DVec3::new(x, g + LOW_KIND.spec().clearance, z))
|
||||
}
|
||||
|
||||
/// Per ray round the radar, how far a low flyer is seen before the land first hides it (at most the reach).
|
||||
pub fn low_rim(&self, ground: &Ground, s: &LowSensor) -> Vec<f32> {
|
||||
let mut out = vec![s.reach as f32; RAYS];
|
||||
let Some(h) = self.horizons.get(&s.id).filter(|_| s.terrain) else { return out };
|
||||
let steps = ((s.reach / STEP) as usize).min(h.rays[0].len());
|
||||
let height = LOW_KIND.spec().clearance;
|
||||
for (r, o) in out.iter_mut().enumerate() {
|
||||
let a = r as f64 / RAYS as f64 * TAU;
|
||||
let (sx, sz) = (a.sin(), a.cos());
|
||||
for k in 1..=steps {
|
||||
let d = k as f64 * STEP;
|
||||
if d <= NEAR {
|
||||
continue;
|
||||
}
|
||||
let p = DVec3::new(s.ant.x + sx * d, 0.0, s.ant.z + sz * d);
|
||||
let y = ground.peek(p).unwrap_or(s.base) + height - s.ant.y;
|
||||
if ((y / d) as f32) < h.rays[r][k - 1] {
|
||||
*o = (d - STEP).max(NEAR) as f32;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
/// How a kind's radar looks round.
|
||||
pub(super) struct Scan {
|
||||
/// Ticks for the beam to go round.
|
||||
@@ -144,6 +235,8 @@ impl Ident {
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Track {
|
||||
pub id: u32,
|
||||
/// What the radar made of it when it measured (the class the picture shows).
|
||||
pub kind: DroneKind,
|
||||
/// Where it was and how it went when last measured (blocks, blocks a tick).
|
||||
pub pos: DVec3,
|
||||
pub vel: DVec3,
|
||||
@@ -157,6 +250,24 @@ pub struct Track {
|
||||
pub locked: bool,
|
||||
}
|
||||
|
||||
/// What the player's side knows of the air: the network's tracks as last measured, never the drones themselves.
|
||||
pub struct AirPicture {
|
||||
pub now: u64,
|
||||
pub tracks: Vec<Track>,
|
||||
/// No system is deployed: the tracks are the sky as it is.
|
||||
pub unaided: bool,
|
||||
}
|
||||
|
||||
impl AirPicture {
|
||||
pub fn get(&self, id: u32) -> Option<&Track> {
|
||||
self.tracks.iter().find(|t| t.id == id)
|
||||
}
|
||||
/// The track nearest to a point, by its forecast place.
|
||||
pub fn nearest(&self, to: DVec3) -> Option<&Track> {
|
||||
self.tracks.iter().min_by(|a, b| a.est(self.now).distance(to).total_cmp(&b.est(self.now).distance(to)))
|
||||
}
|
||||
}
|
||||
|
||||
impl Track {
|
||||
pub fn age(&self, now: u64) -> u64 {
|
||||
now.saturating_sub(self.tick)
|
||||
@@ -305,6 +416,7 @@ impl Sim {
|
||||
let noise = DVec3::new(dice(seed, now, key, 1) - 0.5, (dice(seed, now, key, 2) - 0.5) * 0.5, dice(seed, now, key, 3) - 0.5) * 2.0 * sigma;
|
||||
fresh.push(Track {
|
||||
id: d.id,
|
||||
kind: d.kind,
|
||||
pos: d.pos + noise,
|
||||
vel: d.vel,
|
||||
tick: now,
|
||||
@@ -356,6 +468,25 @@ impl Sim {
|
||||
self.sams.iter().any(|s| s.seen.contains(&id))
|
||||
}
|
||||
|
||||
/// The air picture as the player's panel and radar read it (the only thing they read).
|
||||
pub fn air_picture(&self) -> AirPicture {
|
||||
let now = self.tick;
|
||||
// With no system deployed there is no radar to be blind: the sky as it is (the same fallback the screens
|
||||
// always had); a network's picture is only what it holds.
|
||||
let unaided = self.sams.is_empty();
|
||||
let mut tracks: Vec<Track> = if unaided {
|
||||
self.drones
|
||||
.iter()
|
||||
.filter(|d| d.alive())
|
||||
.map(|d| Track { id: d.id, kind: d.kind, pos: d.pos, vel: d.vel, tick: now, own_tick: now, ttl: 1, hits: 3, locked: false })
|
||||
.collect()
|
||||
} else {
|
||||
self.picture().into_values().collect()
|
||||
};
|
||||
tracks.sort_by_key(|t| t.id);
|
||||
AirPicture { now, tracks, unaided }
|
||||
}
|
||||
|
||||
/// The freshest track of each drone any system holds: the air picture.
|
||||
pub fn picture(&self) -> HashMap<u32, Track> {
|
||||
let mut best: HashMap<u32, Track> = HashMap::new();
|
||||
@@ -367,3 +498,74 @@ impl Sim {
|
||||
best
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod low_view_tests {
|
||||
use super::*;
|
||||
|
||||
/// A radar on level land (70) with a hill east of it (140 high, x 128..160): the east ray is cut at the hill, the others are not.
|
||||
fn world() -> (Sim, Ground, u32) {
|
||||
let mut sim = Sim::new(3);
|
||||
let id = sim.id();
|
||||
sim.sams.push(Sam::new(id, SamKind::Buk, DVec3::new(0.0, 70.0, 0.0), 0.0));
|
||||
let mut ground = Ground::default();
|
||||
let cols: Vec<(i32, i32, i32)> = (-60..60).map(|k| (k * 16, 0, if (128..160).contains(&(k * 16)) { 140 } else { 70 })).collect();
|
||||
ground.answer(cols, 0);
|
||||
let h = Horizon::build(antenna(&sim.sams[0]), sim.sams[0].kind.spec().sensor, &mut ground, 0);
|
||||
sim.horizons.insert(id, h);
|
||||
(sim, ground, id)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_land_cuts_the_coverage_edge_behind_a_hill() {
|
||||
let (sim, ground, id) = world();
|
||||
let ls = sim.low_sensor(SamKind::Buk, DVec3::new(0.0, 70.0, 0.0), Some(id)).unwrap();
|
||||
assert!(ls.terrain && ls.reach > 200.0, "{}", ls.reach);
|
||||
let rim = sim.low_rim(&ground, &ls);
|
||||
let east = rim[RIM_RAYS / 4];
|
||||
assert!((128.0..=176.0).contains(&east), "east edge {east}");
|
||||
// Rays whose land is unknown hide nothing: the whole reach.
|
||||
assert_eq!(rim[0], ls.reach as f32);
|
||||
assert_eq!(rim[RIM_RAYS * 3 / 4], ls.reach as f32);
|
||||
assert!(sim.low_sees(&ground, &ls, -200.0, 0.0));
|
||||
assert!(sim.low_sees(&ground, &ls, 100.0, 0.0));
|
||||
assert!(!sim.low_sees(&ground, &ls, 200.0, 0.0), "behind the hill");
|
||||
assert!(!sim.low_sees(&ground, &ls, ls.reach + 50.0, 0.0), "out of reach");
|
||||
// A ghost (no horizon) sees the whole circle.
|
||||
let ghost = sim.low_sensor(SamKind::Buk, DVec3::new(0.0, 70.0, 0.0), None).unwrap();
|
||||
assert!(sim.low_sees(&ground, &ghost, 200.0, 0.0));
|
||||
}
|
||||
|
||||
// The map's tint asks `low_sees` for a cell of a coarse grid at every radar that reaches it, and the edges
|
||||
// ask `low_rim`: with a Polygon's worth of systems both stay cheap (native time, a few ms; wasm is a few times that).
|
||||
#[test]
|
||||
fn coverage_of_128_systems_is_cheap() {
|
||||
let (mut sim, mut ground, _) = world();
|
||||
for i in 0..127 {
|
||||
let id = sim.id();
|
||||
let pos = DVec3::new((i % 16) as f64 * 40.0 - 300.0, 70.0, (i / 16) as f64 * 40.0 - 150.0);
|
||||
sim.sams.push(Sam::new(id, SamKind::Buk, pos, 0.0));
|
||||
let k = sim.sams.len() - 1;
|
||||
let h = Horizon::build(antenna(&sim.sams[k]), sim.sams[k].kind.spec().sensor, &mut ground, 0);
|
||||
sim.horizons.insert(id, h);
|
||||
}
|
||||
let sensors = sim.low_sensors();
|
||||
assert_eq!(sensors.len(), 128);
|
||||
let t = std::time::Instant::now();
|
||||
let mut seen = 0;
|
||||
for cy in 0..28 {
|
||||
for cx in 0..36 {
|
||||
let (x, z) = (cx as f64 * 30.0 - 500.0, cy as f64 * 30.0 - 400.0);
|
||||
// Worst case for the early exit: a cell no radar sees is tested against all that reach it.
|
||||
if sensors.iter().any(|s| sim.low_sees(&ground, s, x, z)) {
|
||||
seen += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
let tint = t.elapsed();
|
||||
let t = std::time::Instant::now();
|
||||
let rims: usize = sensors.iter().take(3).map(|s| sim.low_rim(&ground, s).len()).sum();
|
||||
eprintln!("tint of 1008 cells: {tint:?} ({seen} seen); 3 rims: {:?} ({rims})", t.elapsed());
|
||||
assert!(seen > 0 && tint.as_millis() < 100, "{tint:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,23 @@
|
||||
//! looks for suitable ground on each side (only land the game has told of: flat, open to the sky, clear in
|
||||
//! front, away from the defence), and sets up a site there: a ramp for the drones, a launcher vehicle for the
|
||||
//! cruise missiles, a battery for the ballistic ones (at their own range). The raid's drones are jobs of the
|
||||
//! sites: each one leaves its site, one at a time, from the stock the site holds. Ground nobody has told of is
|
||||
//! never suitable, and nothing is force-loaded: a side without suitable ground waits for the game's answers
|
||||
//! for a few seconds, and is then given up with a message.
|
||||
//! sites: each one leaves its site, one at a time, from the stock the site holds.
|
||||
//!
|
||||
//! The land beyond the render distance is not there until the game loads it, so the search asks for the chunks
|
||||
//! of the places it is looking at (`render.load-chunks`, API 22: a few, never a ring; the game generates or reads
|
||||
//! them on its workers and keeps them some seconds) and waits for them: a column the game is loading is neither
|
||||
//! land nor sea, it is pending. Where nothing can be loaded (a server) or nothing suitable is found within
|
||||
//! `SEARCH_TICKS`, the raid is never cancelled for it: the side's site is *off the map* (`offmap`): no kit is drawn,
|
||||
//! nothing can be destroyed, and its drones start in the air at the ordered range, cruising over whatever is there.
|
||||
use super::*;
|
||||
|
||||
/// The most candidate places tried for one site, and how long (ticks) a raid waits for the game's answers.
|
||||
pub const MAX_TRIES: usize = 90;
|
||||
pub const SEARCH_TICKS: u32 = 300;
|
||||
pub const SEARCH_TICKS: u32 = 400;
|
||||
/// Candidates asked about ahead of the one being waited for.
|
||||
const PREFETCH: usize = 3;
|
||||
/// Prefetched candidates ask for their chunks only while fewer than this many are wanted.
|
||||
const PREFETCH_CHUNKS: usize = 24;
|
||||
/// The footprint's samples (offsets in blocks), the most the ground may differ over it, and how far from
|
||||
/// the defence and the objects a site must be.
|
||||
const FOOTPRINT: [(f64, f64); 9] = [(0.0, 0.0), (8.0, 0.0), (-8.0, 0.0), (0.0, 8.0), (0.0, -8.0), (6.0, 6.0), (6.0, -6.0), (-6.0, 6.0), (-6.0, -6.0)];
|
||||
@@ -47,9 +54,9 @@ impl SiteClass {
|
||||
/// Ticks between two launches from one site.
|
||||
pub fn cadence(self) -> u64 {
|
||||
match self {
|
||||
SiteClass::Ramp => 3,
|
||||
SiteClass::Launcher => 8,
|
||||
SiteClass::Battery => 20,
|
||||
SiteClass::Ramp => 15,
|
||||
SiteClass::Launcher => 25,
|
||||
SiteClass::Battery => 50,
|
||||
}
|
||||
}
|
||||
fn slots(self) -> u32 {
|
||||
@@ -123,6 +130,9 @@ pub struct LaunchSite {
|
||||
pub planned: u32,
|
||||
pub alive: bool,
|
||||
pub next_free: u64,
|
||||
/// Off the map: no land to stand on was found (or none can be loaded), so there is no kit; the drones
|
||||
/// start in the air at `pos`'s range.
|
||||
pub offmap: bool,
|
||||
}
|
||||
|
||||
impl LaunchSite {
|
||||
@@ -154,6 +164,10 @@ pub struct Sites {
|
||||
pub list: Vec<LaunchSite>,
|
||||
next: u32,
|
||||
jobs: Vec<(u32, u32)>,
|
||||
/// Sites a new wave kept for something still in the air (#108): their kit stays until that is gone.
|
||||
holding: Vec<u32>,
|
||||
/// Drones that left a site and are still in the air: (drone, site), so their site is not taken away under them.
|
||||
flying: Vec<(u32, u32)>,
|
||||
}
|
||||
|
||||
/// What a site says about a drone due to leave.
|
||||
@@ -161,6 +175,8 @@ pub(super) enum Slot {
|
||||
/// Not a site's job (a manual launch, an old save): off it goes.
|
||||
Free,
|
||||
Go,
|
||||
/// An off-map site's drone: it starts in the air, without a launch.
|
||||
Air,
|
||||
/// The site launched a moment ago.
|
||||
Busy,
|
||||
/// The site is gone or empty: the job is cancelled.
|
||||
@@ -182,6 +198,8 @@ impl Sites {
|
||||
pub fn clear(&mut self) {
|
||||
self.list.clear();
|
||||
self.jobs.clear();
|
||||
self.holding.clear();
|
||||
self.flying.clear();
|
||||
}
|
||||
pub(super) fn add(&mut self, mut site: LaunchSite) -> u32 {
|
||||
self.next += 1;
|
||||
@@ -193,11 +211,34 @@ impl Sites {
|
||||
pub(super) fn job(&mut self, drone: u32, site: u32) {
|
||||
self.jobs.push((drone, site));
|
||||
}
|
||||
/// The old raid's sites go, but not those with jobs still to fly.
|
||||
pub(super) fn retire(&mut self, queued: &[u32]) {
|
||||
/// The old raid's sites go, but not those with jobs still to fly, nor those something in the air still came
|
||||
/// from or is flying to (#108: a missile on its way is not left shooting at a vanished base).
|
||||
pub(super) fn retire(&mut self, queued: &[u32], refs: &[u32]) {
|
||||
self.jobs.retain(|j| queued.contains(&j.0));
|
||||
let jobs = &self.jobs;
|
||||
self.list.retain(|s| jobs.iter().any(|j| j.1 == s.id));
|
||||
let mut list = std::mem::take(&mut self.list);
|
||||
list.retain(|s| jobs.iter().any(|j| j.1 == s.id) || refs.contains(&s.id));
|
||||
self.list = list;
|
||||
// What only the references hold: let go once they are gone, so no old bases pile up.
|
||||
self.holding = self.list.iter().filter(|s| !jobs.iter().any(|j| j.1 == s.id)).map(|s| s.id).collect();
|
||||
}
|
||||
/// Drops the sites `retire` held only for a flight, a drone or a scout link that is now gone.
|
||||
pub(super) fn prune(&mut self, refs: &[u32]) {
|
||||
if self.holding.is_empty() {
|
||||
return;
|
||||
}
|
||||
let live = |id: &u32| refs.contains(id) || self.jobs.iter().any(|j| j.1 == *id);
|
||||
let gone: Vec<u32> = self.holding.iter().copied().filter(|id| !live(id)).collect();
|
||||
if gone.is_empty() {
|
||||
return;
|
||||
}
|
||||
self.holding.retain(|id| live(id));
|
||||
self.list.retain(|s| !gone.contains(&s.id));
|
||||
}
|
||||
/// Sites drones still in the air left: (drone, site) for those alive in the list, forgetting the others.
|
||||
pub(super) fn flying_sites(&mut self, alive: &[u32]) -> Vec<u32> {
|
||||
self.flying.retain(|(d, _)| alive.contains(d));
|
||||
self.flying.iter().map(|f| f.1).collect()
|
||||
}
|
||||
fn take(&mut self, drone: u32, now: u64) -> Slot {
|
||||
let Some(j) = self.jobs.iter().position(|j| j.0 == drone) else { return Slot::Free };
|
||||
@@ -215,8 +256,11 @@ impl Sites {
|
||||
}
|
||||
s.stock -= 1;
|
||||
s.next_free = now + s.class.cadence();
|
||||
let air = s.offmap;
|
||||
self.jobs.swap_remove(j);
|
||||
Slot::Go
|
||||
// A drone in the air still belongs to its site: a new wave must not take the pad from under it (#108).
|
||||
self.flying.push((drone, site));
|
||||
if air { Slot::Air } else { Slot::Go }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,6 +304,13 @@ pub(super) struct Want {
|
||||
pub site: u32,
|
||||
}
|
||||
|
||||
impl Want {
|
||||
/// Whether the search has nothing to show for it: the site is off the map.
|
||||
pub fn offmap(&self) -> bool {
|
||||
self.state == Search::Failed
|
||||
}
|
||||
}
|
||||
|
||||
/// The want of this side, class and range, made if there is none yet.
|
||||
pub(super) fn want_index(wants: &mut Vec<Want>, centre: DVec3, side: usize, bearing: f64, class: SiteClass, range: f64, lo: f64) -> usize {
|
||||
if let Some(i) = wants.iter().position(|w| w.side == side && w.class == class && (w.range - range).abs() < 1.0) {
|
||||
@@ -269,16 +320,19 @@ pub(super) fn want_index(wants: &mut Vec<Want>, centre: DVec3, side: usize, bear
|
||||
let lat = DVec3::new(bearing.cos(), 0.0, -bearing.sin());
|
||||
// In order: known land at the ordered range (round it for most, the ordered range for a ballistic battery),
|
||||
// known land nearer in steps, then a barge on open water at the ordered range, then on water nearer.
|
||||
// A long range retreats in steps of at most 100 blocks and tries wider rings, not a few huge gaps.
|
||||
let near = |from: f64| -> Vec<f64> {
|
||||
let min = if class == SiteClass::Battery { lo.min(from).max(80.0) } else { (from * 0.3).max(80.0) };
|
||||
let min = if class == SiteClass::Battery { lo.min(from).max(80.0) } else { (from * 0.3).max(80.0).max(from - 600.0) };
|
||||
(1..=6).map(|i| from - (from - min) * f64::from(i) / 6.0).collect()
|
||||
};
|
||||
let wide = (range / 500.0).clamp(1.0, 3.0);
|
||||
let round: Vec<f64> = if class == SiteClass::Battery {
|
||||
vec![range]
|
||||
} else {
|
||||
[0.0, 24.0, -24.0, 48.0, -48.0, 72.0, -72.0].iter().map(|d| (range + d).max(KEEP_OUT)).collect()
|
||||
[0.0, 24.0, -24.0, 48.0, -48.0, 72.0, -72.0].iter().map(|d| (range + d * wide).max(KEEP_OUT)).collect()
|
||||
};
|
||||
let laterals: &[f64] = &[0.0, 20.0, -20.0];
|
||||
// A battery may stand where another site of the side does (its range is its own): wider to the sides.
|
||||
let laterals: &[f64] = if class == SiteClass::Battery { &[0.0, 20.0, -20.0, 60.0, -60.0] } else { &[0.0, 20.0, -20.0] };
|
||||
let mut cands = Vec::new();
|
||||
for water in [false, true] {
|
||||
for r in round.iter().copied().chain(near(range)) {
|
||||
@@ -300,9 +354,25 @@ enum Verdict {
|
||||
Good(DVec3, bool),
|
||||
}
|
||||
|
||||
/// The chunks a site at `p` needs: its footprint and the way ahead, up to 14 blocks.
|
||||
fn chunks_of(p: DVec3, inward: DVec3) -> Vec<(i32, i32)> {
|
||||
let mut out: Vec<(i32, i32)> = Vec::with_capacity(6);
|
||||
for (dx, dz) in FOOTPRINT {
|
||||
for k in [0.0, 14.0] {
|
||||
let c = (((p.x + dx + inward.x * k).floor() as i32) >> 4, ((p.z + dz + inward.z * k).floor() as i32) >> 4);
|
||||
if !out.contains(&c) {
|
||||
out.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Whether a site fits at `p` (x, z): every sample of its footprint is land the game told of and within
|
||||
/// `FLAT` blocks of the others, the sky above is open, the way ahead is clear, and nothing of the defence is near.
|
||||
fn judge(ground: &mut Ground, p: DVec3, inward: DVec3, keep: &[DVec3], now: u64) -> Verdict {
|
||||
/// A column or chunk the game is still loading makes it `Pending`, and the chunks are asked for (unless this is
|
||||
/// a look ahead at a later candidate, `ahead`, and many are wanted already).
|
||||
fn judge(ground: &mut Ground, p: DVec3, inward: DVec3, keep: &[DVec3], now: u64, ahead: bool) -> Verdict {
|
||||
if p.x.abs() > 29_000_000.0 || p.z.abs() > 29_000_000.0 || keep.iter().any(|k| horizontal(*k - p).length() < KEEP_OUT) {
|
||||
return Verdict::Bad;
|
||||
}
|
||||
@@ -318,6 +388,22 @@ fn judge(ground: &mut Ground, p: DVec3, inward: DVec3, keep: &[DVec3], now: u64)
|
||||
}
|
||||
}
|
||||
}
|
||||
// The way ahead must be loaded too before it is swept (an unknown stretch is answered "no chunk" and kept
|
||||
// for a while): a column in the middle of each chunk it needs says so.
|
||||
let chunks = chunks_of(p, inward);
|
||||
if !pending {
|
||||
for &(cx, cz) in &chunks {
|
||||
pending |= ground.column(cx * 16 + 8, cz * 16 + 8, 256).is_none();
|
||||
}
|
||||
}
|
||||
if pending {
|
||||
if !ahead || ground.chunks_wanted() < PREFETCH_CHUNKS {
|
||||
for c in chunks {
|
||||
ground.want_chunk(c);
|
||||
}
|
||||
}
|
||||
return Verdict::Pending;
|
||||
}
|
||||
if pending {
|
||||
return Verdict::Pending;
|
||||
}
|
||||
@@ -334,7 +420,9 @@ fn judge(ground: &mut Ground, p: DVec3, inward: DVec3, keep: &[DVec3], now: u64)
|
||||
match ground.world.sweep(c + DVec3::Y * 0.5, c - DVec3::Y * 0.5, false, now) {
|
||||
world::Sweep::Hit { .. } => solid += 1,
|
||||
world::Sweep::Clear => {}
|
||||
world::Sweep::Unknown { pending: true, .. } | world::Sweep::Wait { .. } => return Verdict::Pending,
|
||||
world::Sweep::Unknown { pending: true, .. } | world::Sweep::Wait { .. } => {
|
||||
return Verdict::Pending;
|
||||
}
|
||||
world::Sweep::Unknown { .. } => return Verdict::Bad,
|
||||
}
|
||||
}
|
||||
@@ -346,7 +434,9 @@ fn judge(ground: &mut Ground, p: DVec3, inward: DVec3, keep: &[DVec3], now: u64)
|
||||
for s in [up, ahead] {
|
||||
match s {
|
||||
world::Sweep::Clear => {}
|
||||
world::Sweep::Unknown { pending: true, .. } | world::Sweep::Wait { .. } => return Verdict::Pending,
|
||||
world::Sweep::Unknown { pending: true, .. } | world::Sweep::Wait { .. } => {
|
||||
return Verdict::Pending;
|
||||
}
|
||||
world::Sweep::Unknown { .. } | world::Sweep::Hit { .. } => return Verdict::Bad,
|
||||
}
|
||||
}
|
||||
@@ -373,7 +463,7 @@ pub(super) fn search(wants: &mut [Want], ground: &mut Ground, centre: DVec3, kee
|
||||
break;
|
||||
}
|
||||
let (cand, water) = w.cands[w.cursor];
|
||||
match judge(ground, cand, inward, &keep, now) {
|
||||
match judge(ground, cand, inward, &keep, now, false) {
|
||||
Verdict::Bad => w.cursor += 1,
|
||||
// Land when land was asked for, a barge when water was.
|
||||
Verdict::Good(_, got) if got != water => w.cursor += 1,
|
||||
@@ -387,7 +477,7 @@ pub(super) fn search(wants: &mut [Want], ground: &mut Ground, centre: DVec3, kee
|
||||
Verdict::Pending => {
|
||||
for k in 1..=PREFETCH {
|
||||
if let Some(&(c, _)) = w.cands.get(w.cursor + k) {
|
||||
let _ = judge(ground, c, inward, &keep, now);
|
||||
let _ = judge(ground, c, inward, &keep, now, true);
|
||||
}
|
||||
}
|
||||
if last {
|
||||
@@ -414,7 +504,18 @@ impl Sim {
|
||||
/// Takes site `id` out of play (destroyed): its stock is gone and its queued jobs are cancelled. Returns how
|
||||
/// many. (The counter-strike, #101, uses this.)
|
||||
pub fn destroy_site(&mut self, id: u32) -> u32 {
|
||||
let Some(s) = self.sites.list.iter_mut().find(|s| s.id == id) else { return 0 };
|
||||
// An off-map site is nowhere to be found: nothing to destroy.
|
||||
self.end_site(id, false)
|
||||
}
|
||||
|
||||
/// Ends a site's launches wherever it is, off the map too (a strike that would have hit it): the same as
|
||||
/// destroying it, without anything to draw.
|
||||
pub fn halt_site(&mut self, id: u32) -> u32 {
|
||||
self.end_site(id, true)
|
||||
}
|
||||
|
||||
fn end_site(&mut self, id: u32, offmap: bool) -> u32 {
|
||||
let Some(s) = self.sites.list.iter_mut().find(|s| s.id == id && (offmap || !s.offmap)) else { return 0 };
|
||||
s.alive = false;
|
||||
s.stock = 0;
|
||||
let ids: Vec<u32> = self.sites.jobs.iter().filter(|j| j.1 == id).map(|j| j.0).collect();
|
||||
@@ -431,7 +532,7 @@ impl Sim {
|
||||
|
||||
/// Draws every site's kit: a ramp or launcher per pad in use, turned to the way the launches go.
|
||||
pub(super) fn draw_sites(&self, out: &mut Out) {
|
||||
for s in self.sites.list.iter().filter(|s| s.alive) {
|
||||
for s in self.sites.list.iter().filter(|s| s.alive && !s.offmap) {
|
||||
let rot = DQuat::from_rotation_y(heading_of(s.inward()));
|
||||
let sc = s.class.scale();
|
||||
if s.water {
|
||||
@@ -651,6 +752,7 @@ mod tests {
|
||||
planned: 5,
|
||||
alive: true,
|
||||
next_free: 0,
|
||||
offmap: false,
|
||||
});
|
||||
for i in 0..5 {
|
||||
let site = sim.sites.get(id).unwrap().clone();
|
||||
@@ -689,9 +791,16 @@ mod tests {
|
||||
assert_eq!(sim.launched as usize + n, 14);
|
||||
}
|
||||
|
||||
/// Runs the sim `ticks` without the game answering anything, and counts what left.
|
||||
fn run_blind(sim: &mut Sim, out: &mut Out, ground: &mut Ground, ticks: u32) {
|
||||
for _ in 0..ticks {
|
||||
sim.step(ground, None, out);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_suitable_ground_means_a_clear_refusal() {
|
||||
// Never answered: unknown ground is not suitable, and nothing is launched.
|
||||
fn no_suitable_ground_means_the_raid_launches_off_the_map() {
|
||||
// Never answered: unknown ground is not suitable, but nothing is cancelled: every side starts off the map.
|
||||
let (mut ground, mut out) = (Ground::default(), Out::default());
|
||||
let mut sim = Sim::new(3);
|
||||
sim.order_raid(&order(Approach::TwoSectors, 300.0), &[DVec3::new(0.0, 70.0, 0.0)], &mut out);
|
||||
@@ -701,20 +810,165 @@ mod tests {
|
||||
n += 1;
|
||||
assert!(n <= SEARCH_TICKS + 5, "a raid waits for ever");
|
||||
}
|
||||
assert!(sim.queue.is_empty() && sim.sites.list.is_empty());
|
||||
assert!(out.messages.iter().any(|m| m.contains("площад")), "{:?}", out.messages);
|
||||
assert!(!sim.drones.iter().any(|d| d.alive()));
|
||||
// A cliff face everywhere (too steep to stand on) is refused as well, and a sea (no land) too.
|
||||
assert_eq!(sim.queue.len() + sim.launched as usize, 14);
|
||||
assert!(!sim.sites.list.is_empty() && sim.sites.list.iter().all(|s| s.offmap), "{:?}", sim.sites.list);
|
||||
let said: Vec<_> = out.messages.iter().filter(|m| m.contains("за пределами")).collect();
|
||||
assert_eq!(said.len(), 1, "{:?}", out.messages);
|
||||
assert!(!out.messages.iter().any(|m| m.contains("отмен")), "{:?}", out.messages);
|
||||
run_blind(&mut sim, &mut out, &mut ground, 400);
|
||||
assert_eq!(sim.launched, 14, "{:?}", out.messages);
|
||||
assert!(sim.queue.is_empty());
|
||||
// No kit, and nothing to destroy.
|
||||
let mut o2 = Out::default();
|
||||
sim.draw_sites(&mut o2);
|
||||
assert!(o2.models.is_empty());
|
||||
let id = sim.sites.list[0].id;
|
||||
assert_eq!(sim.destroy_site(id), 0);
|
||||
// A cliff face everywhere (too steep to stand on) and a sea (no land) launch off the map as well.
|
||||
for steep in [true, false] {
|
||||
let land = Land(move |x, _| if steep { x * 4 } else { -100 });
|
||||
let (mut ground, mut out) = (Ground::default(), Out::default());
|
||||
let mut sim = Sim::new(3);
|
||||
plan(&mut sim, &mut ground, &land, &order(Approach::Sector, 300.0), &mut out);
|
||||
assert!(sim.queue.is_empty() && sim.sites.list.is_empty(), "steep {steep}");
|
||||
assert!(out.messages.iter().any(|m| m.contains("площад")));
|
||||
assert!(!sim.sites.list.is_empty() && sim.sites.list.iter().all(|s| s.offmap), "steep {steep}");
|
||||
assert_eq!(sim.queue.len() + sim.launched as usize, 14, "steep {steep}");
|
||||
assert!(!out.messages.iter().any(|m| m.contains("отмен")), "{:?}", out.messages);
|
||||
}
|
||||
}
|
||||
|
||||
/// An off-map site's drones start in the air at the height planned over land nobody had read; if the land
|
||||
/// turns out higher there by the time they leave, they start above it instead of being born inside the hill.
|
||||
#[test]
|
||||
fn an_off_map_start_over_a_hill_begins_above_it() {
|
||||
let (mut ground, mut out) = (Ground::default(), Out::default());
|
||||
let mut sim = Sim::new(3);
|
||||
sim.order_raid(&order(Approach::TwoSectors, 300.0), &[DVec3::new(0.0, 70.0, 0.0)], &mut out);
|
||||
while sim.planning() {
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
}
|
||||
assert!(sim.sites.list.iter().all(|s| s.offmap));
|
||||
let land = Land(|x, z| if x * x + z * z > 200 * 200 { 150 } else { 64 });
|
||||
for _ in 0..500 {
|
||||
step(&mut sim, &mut ground, &land, &mut out);
|
||||
assert!(sim.drones.iter().all(|d| d.age > 3 || d.pos.y > 148.0 || d.flight == Flight::Ballistic), "a drone started inside the hill");
|
||||
}
|
||||
assert!(sim.launched > 0);
|
||||
}
|
||||
|
||||
/// Chunks that load on request: a column of a chunk asked for answers `PENDING` until `delay` ticks
|
||||
/// after the first request, and a chunk never asked for is not there (-64).
|
||||
struct Lazy {
|
||||
height: i32,
|
||||
delay: u64,
|
||||
asked: std::cell::RefCell<HashMap<(i32, i32), u64>>,
|
||||
most: usize,
|
||||
}
|
||||
impl Lazy {
|
||||
fn loaded(&self, c: (i32, i32), now: u64) -> Option<bool> {
|
||||
self.asked.borrow().get(&c).map(|&t| now >= t + self.delay)
|
||||
}
|
||||
fn tick(&mut self, ground: &mut Ground, now: u64) {
|
||||
let chunks = ground.take_chunks();
|
||||
self.most = self.most.max(chunks.len());
|
||||
for c in chunks {
|
||||
self.asked.borrow_mut().entry(c).or_insert(now);
|
||||
}
|
||||
let cols = ground
|
||||
.take_wanted()
|
||||
.into_iter()
|
||||
.map(|(x, z)| {
|
||||
let y = match self.loaded((x >> 4, z >> 4), now) {
|
||||
Some(true) => self.height,
|
||||
Some(false) => PENDING,
|
||||
None => -64,
|
||||
};
|
||||
(x, z, y)
|
||||
})
|
||||
.collect();
|
||||
ground.answer(cols, now);
|
||||
let secs = ground.world.take_wanted(now);
|
||||
let view = Seen { lazy: self, now };
|
||||
ground.world.serve(&view, secs, now);
|
||||
}
|
||||
}
|
||||
struct Seen<'a> {
|
||||
lazy: &'a Lazy,
|
||||
now: u64,
|
||||
}
|
||||
impl world::WorldSource for Seen<'_> {
|
||||
fn solid(&self, x: i32, y: i32, z: i32) -> Option<bool> {
|
||||
self.lazy.loaded((x >> 4, z >> 4), self.now).filter(|&l| l).map(|_| y < self.lazy.height)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_column_pending_for_chunk_load_waits_then_finds_a_site() {
|
||||
let (mut ground, mut out) = (Ground::default(), Out::default());
|
||||
let mut lazy = Lazy { height: 64, delay: 50, asked: Default::default(), most: 0 };
|
||||
let mut sim = Sim::new(21);
|
||||
sim.order_raid(&order(Approach::TwoSectors, 1500.0), &[DVec3::new(0.0, 70.0, 0.0)], &mut out);
|
||||
let mut n = 0;
|
||||
while sim.planning() {
|
||||
lazy.tick(&mut ground, sim.tick);
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
n += 1;
|
||||
assert!(n < SEARCH_TICKS + 5, "never settled");
|
||||
}
|
||||
assert!(n > 50, "settled in {n} ticks, before any chunk could be there");
|
||||
assert!(sim.sites.list.iter().all(|s| !s.offmap), "{:?} {:?}", sim.sites.list, out.messages);
|
||||
assert!(!sim.sites.list.is_empty());
|
||||
assert!(lazy.most <= 48 && lazy.most > 0, "{} chunks wanted at once", lazy.most);
|
||||
assert!(out.messages.iter().any(|m| m.contains("готовит")), "{:?}", out.messages);
|
||||
assert!(!out.messages.iter().any(|m| m.contains("отмен") || m.contains("за пределами")), "{:?}", out.messages);
|
||||
// Far ones stand where the raid was ordered (1500 out), not nearer.
|
||||
assert!(sim.sites.list.iter().any(|s| s.range > 1400.0), "{:?}", sim.sites.list.iter().map(|s| s.range).collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_game_that_never_loads_gets_the_same_launch_off_the_map() {
|
||||
// The game answers "no chunk" (-64) for what was not asked about, and never loads what was (a server).
|
||||
let (mut ground, mut out) = (Ground::default(), Out::default());
|
||||
let mut sim = Sim::new(5);
|
||||
sim.order_raid(&order(Approach::Sector, 2500.0), &[DVec3::new(0.0, 70.0, 0.0)], &mut out);
|
||||
let mut n = 0;
|
||||
while sim.planning() {
|
||||
let _ = ground.take_chunks();
|
||||
let cols = ground.take_wanted().into_iter().map(|(x, z)| (x, z, -64)).collect();
|
||||
ground.answer(cols, sim.tick);
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
n += 1;
|
||||
assert!(n < SEARCH_TICKS + 5);
|
||||
}
|
||||
assert!(sim.sites.list.iter().all(|s| s.offmap));
|
||||
assert_eq!(sim.queue.len() + sim.launched as usize, 14);
|
||||
// Where they start: at the ordered range, not at the player.
|
||||
assert!(sim.queue.iter().all(|q| horizontal(q.1.pos - DVec3::new(0.0, 70.0, 0.0)).length() > 2400.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_raid_ordered_4000_out_reaches_its_target() {
|
||||
let (land, mut ground, mut out) = (flat(), Ground::default(), Out::default());
|
||||
let mut sim = Sim::new(9);
|
||||
let o = RaidOrder { kinds: vec![(DroneKind::Shahed, 2), (DroneKind::Kh101, 1), (DroneKind::Iskander, 1)], approach: Approach::Sector, dist: 4000.0, aim: Aim::Objects };
|
||||
let target = DVec3::new(0.0, 70.0, 0.0);
|
||||
sim.order_raid(&o, &[target], &mut out);
|
||||
let mut closest = [f64::MAX; 4];
|
||||
for _ in 0..16_000 {
|
||||
step(&mut sim, &mut ground, &land, &mut out);
|
||||
for d in sim.drones.iter().filter(|d| d.alive()) {
|
||||
let k = match d.kind {
|
||||
DroneKind::Shahed => 0,
|
||||
DroneKind::Kh101 => 1,
|
||||
_ => 2,
|
||||
};
|
||||
closest[k] = closest[k].min(horizontal(d.pos - target).length());
|
||||
}
|
||||
}
|
||||
assert_eq!(sim.launched, 4, "{:?}", out.messages);
|
||||
assert!(closest.iter().take(3).all(|&c| c < 120.0), "closest approaches {closest:?}");
|
||||
assert!(sim.drones.iter().all(|d| !d.alive()), "still flying");
|
||||
}
|
||||
|
||||
/// Land inside a radius of the origin (surface 64), open water outside it (surface 63 over a floor at 50):
|
||||
/// the game's height over water is the surface, and the blocks under it are not solid.
|
||||
struct Island(f64);
|
||||
@@ -829,4 +1083,112 @@ mod tests {
|
||||
};
|
||||
assert_eq!(run(false), run(true));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- #108: what holds a site beyond its wave
|
||||
|
||||
/// A site with the radars' fix on it, and no launches left: a strike can be sent at it without any drone flying.
|
||||
fn fixed_site(sim: &mut Sim, pos: DVec3) -> u32 {
|
||||
let id = sim.sites.add(LaunchSite {
|
||||
id: 0,
|
||||
side: 0,
|
||||
sector: 0,
|
||||
bearing: 0.0,
|
||||
class: SiteClass::Ramp,
|
||||
pos,
|
||||
range: pos.z,
|
||||
water: false,
|
||||
stock: 0,
|
||||
planned: 0,
|
||||
alive: true,
|
||||
next_free: 0,
|
||||
offmap: false,
|
||||
});
|
||||
sim.strikes.known.push(super::super::strike::Known {
|
||||
site: id,
|
||||
class: SiteClass::Ramp,
|
||||
obs: Vec::new(),
|
||||
est: Some(super::super::strike::Estimate {
|
||||
pos: glam::DVec2::new(pos.x, pos.z),
|
||||
radius: 5.0,
|
||||
fix: true,
|
||||
bearing: 0.0,
|
||||
bearing_err: 0.01,
|
||||
origin: glam::DVec2::ZERO,
|
||||
}),
|
||||
launches: 1,
|
||||
last: 0,
|
||||
state: super::super::strike::SiteState::Active,
|
||||
aimed: false,
|
||||
});
|
||||
id
|
||||
}
|
||||
#[test]
|
||||
fn a_wave_keeps_the_site_a_strike_is_still_flying_to() {
|
||||
let mut sim = Sim::new(11);
|
||||
let id = fixed_site(&mut sim, DVec3::new(0.0, 64.0, 300.0));
|
||||
let mut ground = Ground::default();
|
||||
let mut out = Out::default();
|
||||
sim.order_test_strike(id, DVec3::new(0.0, 64.0, 0.0), &mut out).unwrap();
|
||||
// The next wave is planned while the missile is in the air: its housekeeping must not take the target away.
|
||||
let refs = sim.site_refs();
|
||||
assert!(refs.contains(&id), "the flight is no reference to its site");
|
||||
sim.sites.retire(&[], &refs);
|
||||
assert!(sim.sites.get(id).is_some(), "a new wave took the site a missile was flying to");
|
||||
// The missile lands: the site is hit, and nothing keeps it afterwards.
|
||||
for _ in 0..300 {
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
if sim.strikes.flights.is_empty() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert!(sim.strikes.flights.is_empty());
|
||||
assert_eq!(sim.strikes.fired, 1);
|
||||
assert_eq!(sim.strikes.destroyed + sim.strikes.stunned + sim.strikes.missed, 1, "{:?}", out.messages);
|
||||
assert!(sim.sites.get(id).is_none(), "the old base stays on the map for ever");
|
||||
assert!(sim.strikes.flights.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_wave_keeps_the_site_a_drone_left_from_until_that_is_gone() {
|
||||
let mut sim = Sim::new(11);
|
||||
let id = sim.sites.add(LaunchSite {
|
||||
id: 0,
|
||||
side: 0,
|
||||
sector: 0,
|
||||
bearing: 0.0,
|
||||
class: SiteClass::Ramp,
|
||||
pos: DVec3::new(0.0, 64.0, 300.0),
|
||||
range: 300.0,
|
||||
water: false,
|
||||
stock: 1,
|
||||
planned: 1,
|
||||
alive: true,
|
||||
next_free: 0,
|
||||
offmap: false,
|
||||
});
|
||||
let site = sim.sites.get(id).unwrap().clone();
|
||||
let d = sim.make_drone(DroneKind::Shahed, site.muzzle(0), -DVec3::Z, DVec3::new(0.0, 70.0, 0.0));
|
||||
sim.sites.job(d.id, id);
|
||||
sim.queue.push((1, d));
|
||||
let (mut ground, mut out) = (Ground::default(), Out::default());
|
||||
// Let the drone leave the ramp.
|
||||
let mut left = false;
|
||||
for _ in 0..200 {
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
left |= sim.drones.iter().any(|d| d.alive());
|
||||
if left {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert!(left, "the drone never left");
|
||||
let refs = sim.site_refs();
|
||||
assert!(refs.contains(&id), "a drone in the air is no reference to the site it left");
|
||||
sim.sites.retire(&[], &refs);
|
||||
assert!(sim.sites.get(id).is_some(), "the site of a flying drone was taken away");
|
||||
// Once the drone is gone, the site is let go: no old bases pile up.
|
||||
sim.drones.clear();
|
||||
let refs = sim.site_refs();
|
||||
sim.sites.prune(&refs);
|
||||
assert!(sim.sites.get(id).is_none(), "an old base stays after its last drone");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
use super::*;
|
||||
|
||||
/// Land heights are sampled at the centres of cells this wide.
|
||||
const LATTICE: i32 = 8;
|
||||
pub(super) const LATTICE: i32 = 8;
|
||||
/// Land questions waiting at once: flights ask for more than a tick can send, and wait.
|
||||
const ASK_MAX: usize = 192;
|
||||
|
||||
@@ -57,7 +57,7 @@ impl Ground {
|
||||
if self.due(when) && self.wanted.len() < ASK_MAX / 2 && self.asked.insert(key) {
|
||||
self.wanted.push(key);
|
||||
}
|
||||
if y > -64 { Rise::At(f64::from(y)) } else { Rise::Void }
|
||||
land_height(y).map_or(Rise::Void, Rise::At)
|
||||
}
|
||||
None => {
|
||||
if self.wanted.len() < ASK_MAX && self.asked.insert(key) {
|
||||
@@ -76,10 +76,12 @@ impl Ground {
|
||||
if self.due(when) && self.wanted.len() < cap / 2 && self.asked.insert((x, z)) {
|
||||
self.wanted.push((x, z));
|
||||
}
|
||||
Some((y > -64).then_some(f64::from(y)))
|
||||
Some(land_height(y))
|
||||
}
|
||||
None => {
|
||||
if self.wanted.len() < cap && self.asked.insert((x, z)) {
|
||||
// A chunk the game is loading is asked about again in a few ticks, not every one.
|
||||
let loading = self.loading.get(&(x, z)).is_some_and(|&t| self.now.saturating_sub(t) < LOAD_RECHECK);
|
||||
if !loading && self.wanted.len() < cap && self.asked.insert((x, z)) {
|
||||
self.wanted.push((x, z));
|
||||
}
|
||||
None
|
||||
@@ -166,6 +168,9 @@ pub(super) fn clamp_pitch(v: DVec3, lo: f64, hi: f64, level: DVec3) -> DVec3 {
|
||||
horizontal(v).normalize_or(level) * pitch.cos() + DVec3::Y * pitch.sin()
|
||||
}
|
||||
|
||||
/// Chunks a tick the flights' look-ahead may ask the game to load (the rest of the budget is the launch-site search's).
|
||||
const CHUNK_BUDGET: usize = 46;
|
||||
|
||||
/// Distances ahead where the land is sampled.
|
||||
const REACH: [f64; 21] = [
|
||||
0.0, 8.0, 16.0, 24.0, 32.0, 44.0, 56.0, 72.0, 90.0, 112.0, 136.0, 164.0, 196.0, 232.0, 272.0, 316.0, 366.0, 424.0, 500.0, 600.0,
|
||||
@@ -175,8 +180,10 @@ const REACH: [f64; 21] = [
|
||||
/// The height a flight must be at *now* to clear the land along each of `lines` (a unit horizontal direction and
|
||||
/// how far out to look) by `clear`, given what it can climb: the greatest over the samples of the land's height plus clearance
|
||||
/// less the height it can gain on the way. `None` when nothing is known.
|
||||
pub(super) fn required_height(ground: &mut Ground, pos: DVec3, lines: &[(DVec3, f64)], clear: f64, climb: &Climb) -> Option<f64> {
|
||||
pub(super) fn required_height(ground: &mut Ground, pos: DVec3, lines: &[(DVec3, f64)], clear: f64, climb: &Climb) -> (Option<f64>, bool) {
|
||||
let mut need: Option<f64> = None;
|
||||
// Land nobody has told of within the first half of the look-ahead: the flight is blind there.
|
||||
let mut blind = false;
|
||||
for &(dir, len) in lines {
|
||||
for &s in REACH.iter().chain(&[900.0]) {
|
||||
if s > len {
|
||||
@@ -185,10 +192,20 @@ pub(super) fn required_height(ground: &mut Ground, pos: DVec3, lines: &[(DVec3,
|
||||
if let Some(g) = ground.land(pos + dir * s) {
|
||||
let h = g + clear - climb.gain(s);
|
||||
need = Some(need.map_or(h, |n: f64| n.max(h)));
|
||||
} else {
|
||||
if s <= len * 0.5 {
|
||||
blind = true;
|
||||
}
|
||||
// Land the game has not told of ahead: its chunk is asked for (it loads in a couple of seconds, a flight
|
||||
// is that far from it), so the pull-up starts from the first known column and not at the ridge.
|
||||
if ground.chunks_wanted() < CHUNK_BUDGET {
|
||||
let p = pos + dir * s;
|
||||
ground.want_chunk(((p.x.floor() as i32) >> 4, (p.z.floor() as i32) >> 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
need
|
||||
(need, blind)
|
||||
}
|
||||
|
||||
/// The least height to start from, over here, so that the straight line down to `target` stays `margin` over the
|
||||
@@ -337,7 +354,7 @@ pub(super) const VERDICT_AGE: u64 = 20;
|
||||
|
||||
/// Which way an interceptor steers to keep clear of the land: `aim` is where it would go; the result is a direction
|
||||
/// (unit) raised as far as its loft allows, and whether the land is in the way beyond that.
|
||||
pub(super) fn steer(ground: &mut Ground, kind: MissileKind, pos: DVec3, speed: f64, aim: DVec3) -> (DVec3, bool) {
|
||||
pub(super) fn steer(ground: &mut Ground, kind: MissileKind, pos: DVec3, speed: f64, aim: DVec3, now: u64) -> (DVec3, bool) {
|
||||
let spec = kind.spec();
|
||||
let want = (aim - pos).normalize_or(DVec3::Y);
|
||||
let flat = horizontal(want);
|
||||
@@ -355,10 +372,12 @@ pub(super) fn steer(ground: &mut Ground, kind: MissileKind, pos: DVec3, speed: f
|
||||
// No way over, and the land close enough ahead that the next ticks will end in it: blow up before.
|
||||
let mut fail = false;
|
||||
if slope > cap + 0.02 && at < (speed * 6.0).max(40.0) {
|
||||
// The heights are a coarse upper bound (the canopy of a forest, the roof of a building): it blows up only before
|
||||
// blocks that are really there, not before what the height map says is higher than the missile.
|
||||
fail = (1..=4).any(|k| {
|
||||
let p = pos + raised * speed * f64::from(k);
|
||||
ground.land(p).is_some_and(|g| g + 2.0 > p.y)
|
||||
});
|
||||
}) && matches!(ground.world.probe(pos, pos + raised * speed * 4.0, now), world::Sweep::Hit { .. });
|
||||
}
|
||||
(raised, fail)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,383 @@
|
||||
//! Flights and the land. Strike drones follow the terrain with a look-ahead worth several seconds of flight
|
||||
//! (what they can still climb is a question of their speed and turn rate), dive only down a clear line, and
|
||||
//! interceptors keep a safety height over the land ahead, loft over a ridge when the line is blocked, and
|
||||
//! blow up high when there is no way over. The launch predicates (`why`) ask the same questions of a
|
||||
//! shot before it is fired, so a system doesn't spend missiles on targets behind a hill.
|
||||
//!
|
||||
//! The land comes from `Ground::land`: heights sampled on a coarse lattice, so many flights share columns and
|
||||
//! the questions to the game stay few; what the heights miss (trees, buildings, overhangs) is caught by a
|
||||
//! probe through the block cache.
|
||||
use super::*;
|
||||
|
||||
/// Land heights are sampled at the centres of cells this wide.
|
||||
pub(super) const LATTICE: i32 = 8;
|
||||
/// Land questions waiting at once: flights ask for more than a tick can send, and wait.
|
||||
const ASK_MAX: usize = 192;
|
||||
|
||||
/// What the game has said of the land at a place.
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
pub(super) enum Rise {
|
||||
/// Not yet: asked.
|
||||
Pending,
|
||||
/// There is no land to tell of (no chunk).
|
||||
Void,
|
||||
/// One above the highest solid block.
|
||||
At(f64),
|
||||
}
|
||||
|
||||
impl Ground {
|
||||
/// One above the highest solid block at the lattice cell holding `p`, if known; asked for when it isn't.
|
||||
/// Like `at` it asks again for a column that is old or was reported changed (#64), and it leaves room for the questions that matter more.
|
||||
pub fn land(&mut self, p: DVec3) -> Option<f64> {
|
||||
match self.rise(p) {
|
||||
Rise::At(g) => Some(g),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// For a planner: None while the game has not answered, Some(None) where it has no land to
|
||||
/// tell of, else Some(Some(height)).
|
||||
pub fn land_state(&mut self, p: DVec3) -> Option<Option<f64>> {
|
||||
match self.rise(p) {
|
||||
Rise::Pending => None,
|
||||
Rise::Void => Some(None),
|
||||
Rise::At(g) => Some(Some(g)),
|
||||
}
|
||||
}
|
||||
|
||||
/// The same, saying whether the game has not answered yet or has no land there to tell of.
|
||||
pub(super) fn rise(&mut self, p: DVec3) -> Rise {
|
||||
let key = (
|
||||
(p.x.floor() as i32).div_euclid(LATTICE) * LATTICE + LATTICE / 2,
|
||||
(p.z.floor() as i32).div_euclid(LATTICE) * LATTICE + LATTICE / 2,
|
||||
);
|
||||
match self.known.get(&key) {
|
||||
Some(&(y, when)) => {
|
||||
// Old or reported changed: still used, asked again with the questions to spare.
|
||||
if self.due(when) && self.wanted.len() < ASK_MAX / 2 && self.asked.insert(key) {
|
||||
self.wanted.push(key);
|
||||
}
|
||||
if y > -64 { Rise::At(f64::from(y)) } else { Rise::Void }
|
||||
}
|
||||
None => {
|
||||
if self.wanted.len() < ASK_MAX && self.asked.insert(key) {
|
||||
self.wanted.push(key);
|
||||
}
|
||||
Rise::Pending
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The land's height at a column for the raid planner: `None` while the game hasn't answered, `Some(None)`
|
||||
/// where it has no land to tell of. Asks, up to `cap` questions waiting.
|
||||
pub(super) fn column(&mut self, x: i32, z: i32, cap: usize) -> Option<Option<f64>> {
|
||||
match self.known.get(&(x, z)) {
|
||||
Some(&(y, when)) => {
|
||||
if self.due(when) && self.wanted.len() < cap / 2 && self.asked.insert((x, z)) {
|
||||
self.wanted.push((x, z));
|
||||
}
|
||||
Some((y > -64).then_some(f64::from(y)))
|
||||
}
|
||||
None => {
|
||||
// A chunk the game is loading is asked about again in a few ticks, not every one.
|
||||
let loading = self.loading.get(&(x, z)).is_some_and(|&t| self.now.saturating_sub(t) < LOAD_RECHECK);
|
||||
if !loading && self.wanted.len() < cap && self.asked.insert((x, z)) {
|
||||
self.wanted.push((x, z));
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What a flight can do about a rise ahead.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(super) struct Climb {
|
||||
/// Radius of its tightest pull-up (blocks).
|
||||
pub radius: f64,
|
||||
/// The steepest climb it holds (radians).
|
||||
pub pitch: f64,
|
||||
}
|
||||
|
||||
impl Climb {
|
||||
/// How much height it can have gained by the time it has gone `s` blocks on, starting level.
|
||||
pub fn gain(&self, s: f64) -> f64 {
|
||||
let arc = self.radius * self.pitch.sin();
|
||||
if s <= arc {
|
||||
self.radius - (self.radius * self.radius - s * s).max(0.0).sqrt()
|
||||
} else {
|
||||
self.radius * (1.0 - self.pitch.cos()) + (s - arc) * self.pitch.tan()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DroneKind {
|
||||
/// The steepest climb it holds in cruise (radians): cruise missiles are the shallowest.
|
||||
pub(super) fn climb_pitch(self) -> f64 {
|
||||
match self {
|
||||
DroneKind::Kh101 | DroneKind::Kalibr => 0.45,
|
||||
DroneKind::Lancet => 0.7,
|
||||
DroneKind::Geran3 | DroneKind::Kh22 => 0.6,
|
||||
_ => 0.5,
|
||||
}
|
||||
}
|
||||
pub(super) fn climb(self) -> Climb {
|
||||
let s = self.spec();
|
||||
Climb { radius: (s.speed / s.turn.max(0.01) * 1.15).max(12.0), pitch: self.climb_pitch() }
|
||||
}
|
||||
/// Blocks it looks ahead: eight seconds of flight, at least a pull-up and a climb over a hill.
|
||||
pub(super) fn look_len(self) -> f64 {
|
||||
let s = self.spec();
|
||||
(s.speed * 160.0).clamp(160.0, 900.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// A flight's new heading: it turns in yaw towards `heading` and in pitch towards a climb of `slope`, together
|
||||
/// at most `rate` radians a tick, so a turn on to a new course doesn't dip or climb by itself (a great-circle
|
||||
/// turn between nearly opposite headings can go either way). With `climb` set the pitch comes first and the
|
||||
/// yaw gets what is left of the rate.
|
||||
pub(super) fn fly_towards(old: DVec3, heading: DVec3, slope: f64, rate: f64, climb: bool) -> DVec3 {
|
||||
let (old_yaw, old_pitch) = (old.x.atan2(old.z), old.y.clamp(-1.0, 1.0).asin());
|
||||
let want_yaw = heading.x.atan2(heading.z);
|
||||
let mut yaw = angle_diff(old_yaw, want_yaw);
|
||||
let mut pitch = slope.atan() - old_pitch;
|
||||
if climb {
|
||||
pitch = pitch.clamp(-rate, rate);
|
||||
yaw = yaw.clamp(-(rate * rate - pitch * pitch).max(0.0).sqrt(), (rate * rate - pitch * pitch).max(0.0).sqrt());
|
||||
} else {
|
||||
let total = yaw.hypot(pitch);
|
||||
if total > rate {
|
||||
yaw *= rate / total;
|
||||
pitch *= rate / total;
|
||||
}
|
||||
}
|
||||
let (yaw, pitch) = (old_yaw + yaw, old_pitch + pitch);
|
||||
DVec3::new(yaw.sin() * pitch.cos(), pitch.sin(), yaw.cos() * pitch.cos())
|
||||
}
|
||||
|
||||
/// How far over the land a dive's line passes.
|
||||
pub(super) const DIVE_MARGIN: f64 = 8.0;
|
||||
|
||||
/// `v` with its pitch held between `lo` and `hi` (radians); `level` is the way it faces if it points straight up or down.
|
||||
pub(super) fn clamp_pitch(v: DVec3, lo: f64, hi: f64, level: DVec3) -> DVec3 {
|
||||
let pitch = v.y.clamp(-1.0, 1.0).asin();
|
||||
if (lo..=hi).contains(&pitch) {
|
||||
return v;
|
||||
}
|
||||
let pitch = pitch.clamp(lo, hi);
|
||||
horizontal(v).normalize_or(level) * pitch.cos() + DVec3::Y * pitch.sin()
|
||||
}
|
||||
|
||||
/// Chunks a tick the flights' look-ahead may ask the game to load (the rest of the budget is the launch-site search's).
|
||||
const CHUNK_BUDGET: usize = 46;
|
||||
|
||||
/// Distances ahead where the land is sampled.
|
||||
const REACH: [f64; 21] = [
|
||||
0.0, 8.0, 16.0, 24.0, 32.0, 44.0, 56.0, 72.0, 90.0, 112.0, 136.0, 164.0, 196.0, 232.0, 272.0, 316.0, 366.0, 424.0, 500.0, 600.0,
|
||||
720.0,
|
||||
];
|
||||
|
||||
/// The height a flight must be at *now* to clear the land along each of `lines` (a unit horizontal direction and
|
||||
/// how far out to look) by `clear`, given what it can climb: the greatest over the samples of the land's height plus clearance
|
||||
/// less the height it can gain on the way. `None` when nothing is known.
|
||||
pub(super) fn required_height(ground: &mut Ground, pos: DVec3, lines: &[(DVec3, f64)], clear: f64, climb: &Climb) -> (Option<f64>, bool) {
|
||||
let mut need: Option<f64> = None;
|
||||
// Land nobody has told of within the first half of the look-ahead: the flight is blind there.
|
||||
let mut blind = false;
|
||||
for &(dir, len) in lines {
|
||||
for &s in REACH.iter().chain(&[900.0]) {
|
||||
if s > len {
|
||||
break;
|
||||
}
|
||||
if let Some(g) = ground.land(pos + dir * s) {
|
||||
let h = g + clear - climb.gain(s);
|
||||
need = Some(need.map_or(h, |n: f64| n.max(h)));
|
||||
} else {
|
||||
if s <= len * 0.5 {
|
||||
blind = true;
|
||||
}
|
||||
// Land the game has not told of ahead: its chunk is asked for (it loads in a couple of seconds, a flight
|
||||
// is that far from it), so the pull-up starts from the first known column and not at the ridge.
|
||||
if ground.chunks_wanted() < CHUNK_BUDGET {
|
||||
let p = pos + dir * s;
|
||||
ground.want_chunk(((p.x.floor() as i32) >> 4, (p.z.floor() as i32) >> 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(need, blind)
|
||||
}
|
||||
|
||||
/// The least height to start from, over here, so that the straight line down to `target` stays `margin` over the
|
||||
/// land (the last stretch before the aim is the target's own business). `None` when the land isn't known.
|
||||
pub(super) fn dive_height(ground: &mut Ground, pos: DVec3, target: DVec3, margin: f64) -> Option<f64> {
|
||||
let flat = horizontal(target - pos);
|
||||
let total = flat.length();
|
||||
if total < 20.0 {
|
||||
return None;
|
||||
}
|
||||
let dir = flat / total;
|
||||
let mut need: Option<f64> = None;
|
||||
let n = ((total - 14.0) / 12.0).clamp(1.0, 40.0) as i32;
|
||||
for k in 0..=n {
|
||||
let s = (total - 14.0) * f64::from(k) / f64::from(n);
|
||||
if let Some(g) = ground.land(pos + dir * s) {
|
||||
let f = s / total;
|
||||
let y = (g + margin - target.y * f) / (1.0 - f);
|
||||
need = Some(need.map_or(y, |m: f64| m.max(y)));
|
||||
}
|
||||
}
|
||||
need
|
||||
}
|
||||
|
||||
/// The slope (rise a block) a flight at `from` must hold to clear the land by `margin` on its way towards
|
||||
/// `to`, with a pull-up of `radius` for the climb to begin early, ignoring the last `skip` blocks before `to`.
|
||||
/// Returns the slope and how far away the land that asks for it is; `None` when nothing is in the way or known.
|
||||
pub(super) fn rope(ground: &mut Ground, from: DVec3, to: DVec3, margin: f64, radius: f64, (near, reach, skip): (f64, f64, f64), pending: &mut bool) -> Option<(f64, f64)> {
|
||||
let flat = horizontal(to - from);
|
||||
let total = flat.length();
|
||||
if total < 1.0 {
|
||||
return None;
|
||||
}
|
||||
let dir = flat / total;
|
||||
let end = (total - skip).min(reach);
|
||||
let mut best: Option<(f64, f64)> = None;
|
||||
let mut s = near;
|
||||
while s <= end {
|
||||
match ground.rise(from + dir * s) {
|
||||
Rise::At(g) => {
|
||||
let slope = (g + margin - from.y) / (s - radius * 0.6).max(6.0);
|
||||
if best.is_none_or(|b| slope > b.0) {
|
||||
best = Some((slope, s));
|
||||
}
|
||||
}
|
||||
Rise::Pending => *pending = true,
|
||||
Rise::Void => {}
|
||||
}
|
||||
s += if s < 64.0 { 8.0 } else { 16.0 };
|
||||
}
|
||||
best
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- interceptors
|
||||
|
||||
impl MissileKind {
|
||||
/// The steepest climb it flies to get over land (radians): long-range missiles loft, short-range ones don't.
|
||||
pub(super) fn loft(self) -> f64 {
|
||||
match self {
|
||||
MissileKind::M77n6 => 1.25,
|
||||
MissileKind::M48n6 => 1.1,
|
||||
MissileKind::Pac3 | MissileKind::IrisT | MissileKind::Amraam => 0.9,
|
||||
MissileKind::M9m317 => 0.8,
|
||||
MissileKind::P1sun => 0.5,
|
||||
MissileKind::M57e6 | MissileKind::M9m338 => 0.3,
|
||||
}
|
||||
}
|
||||
/// Whether it lofts over a ridge to a target behind it.
|
||||
pub(super) fn lofts(self) -> bool {
|
||||
self.loft() >= 0.5
|
||||
}
|
||||
}
|
||||
|
||||
/// How high above the land an interceptor keeps.
|
||||
pub(super) const MISSILE_MARGIN: f64 = 8.0;
|
||||
|
||||
/// What keeps an interceptor from being launched at a target for the land in the way.
|
||||
pub(super) const MASKED: u8 = 1;
|
||||
pub(super) const PATH_BLOCKED: u8 = 2;
|
||||
/// The land under the line of fire has been asked for and not answered: the shot waits a tick or two.
|
||||
pub(super) const WAIT: u8 = 4;
|
||||
/// Ticks a shot waits for the land to be answered before it is judged on what is known.
|
||||
pub(super) const WAIT_TICKS: u64 = 30;
|
||||
|
||||
/// Whether a shot from `muzzle` (launcher at `antenna`) at a target forecast at `est` moving at `vel` may be
|
||||
/// fired for the land: the intercept point must not be behind a hill from the launcher, unless the missile
|
||||
/// lofts, and the path the missile would fly must be clear.
|
||||
pub(super) fn launch_blocks(ground: &mut Ground, kind: MissileKind, muzzle: DVec3, antenna: DVec3, est: DVec3, vel: DVec3) -> u8 {
|
||||
let spec = kind.spec();
|
||||
// Where it meets the target: the forecast carried on for the flight time.
|
||||
let mut at = est;
|
||||
for _ in 0..2 {
|
||||
let tgo = muzzle.distance(at) / (spec.speed * 0.8);
|
||||
at = est + vel * tgo;
|
||||
}
|
||||
let flat = horizontal(at - antenna);
|
||||
let total = flat.length();
|
||||
if total < 40.0 {
|
||||
return 0;
|
||||
}
|
||||
let dir = flat / total;
|
||||
// The line of sight from the launcher: any rise of the land over the line to the intercept point masks it.
|
||||
let mut masked = false;
|
||||
let mut waiting = false;
|
||||
let mut s = 12.0;
|
||||
while s < total - 12.0 {
|
||||
match ground.rise(antenna + dir * s) {
|
||||
Rise::At(g) if g + 1.0 > antenna.y + (at.y - antenna.y) * s / total => {
|
||||
masked = true;
|
||||
break;
|
||||
}
|
||||
Rise::Pending => waiting = true,
|
||||
_ => {}
|
||||
}
|
||||
s += 16.0;
|
||||
}
|
||||
if !masked && waiting {
|
||||
return WAIT;
|
||||
}
|
||||
if !masked {
|
||||
return 0;
|
||||
}
|
||||
if !kind.lofts() {
|
||||
return MASKED;
|
||||
}
|
||||
// A lofted path: climbs at the slope the highest land in the way asks for, and comes down on the target.
|
||||
let radius = spec.speed / spec.turn.max(0.05);
|
||||
let mut pending = false;
|
||||
let path = rope(ground, muzzle, at, MISSILE_MARGIN, radius, (32.0, total, 24.0), &mut pending);
|
||||
match path {
|
||||
Some((slope, _)) if slope > kind.loft().tan() => PATH_BLOCKED,
|
||||
_ if pending => WAIT,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
impl Sam {
|
||||
/// What the land said of a shot at `target` when it was last judged, if lately.
|
||||
pub(super) fn terrain_verdict(&self, target: u32, now: u64) -> Option<u8> {
|
||||
self.terrain.get(&target).filter(|(when, _)| now.saturating_sub(*when) <= VERDICT_AGE).map(|(_, bits)| *bits)
|
||||
}
|
||||
}
|
||||
|
||||
/// Ticks a launch verdict (the land in the way) is kept before the shot is judged again.
|
||||
pub(super) const VERDICT_AGE: u64 = 20;
|
||||
|
||||
/// Which way an interceptor steers to keep clear of the land: `aim` is where it would go; the result is a direction
|
||||
/// (unit) raised as far as its loft allows, and whether the land is in the way beyond that.
|
||||
pub(super) fn steer(ground: &mut Ground, kind: MissileKind, pos: DVec3, speed: f64, aim: DVec3, now: u64) -> (DVec3, bool) {
|
||||
let spec = kind.spec();
|
||||
let want = (aim - pos).normalize_or(DVec3::Y);
|
||||
let flat = horizontal(want);
|
||||
let flat_len = flat.length();
|
||||
let reach = (speed * 18.0).clamp(60.0, 320.0);
|
||||
let radius = speed / spec.turn.max(0.05);
|
||||
let Some((slope, at)) = rope(ground, pos, aim, MISSILE_MARGIN, radius, (8.0, reach, 20.0), &mut false) else { return (want, false) };
|
||||
let wanted = if flat_len > 1e-6 { want.y / flat_len } else { f64::INFINITY };
|
||||
if slope <= wanted {
|
||||
return (want, false);
|
||||
}
|
||||
let cap = kind.loft().tan();
|
||||
let dir = flat.normalize_or(DVec3::X);
|
||||
let raised = (dir + DVec3::Y * slope.min(cap)).normalize();
|
||||
// No way over, and the land close enough ahead that the next ticks will end in it: blow up before.
|
||||
let mut fail = false;
|
||||
if slope > cap + 0.02 && at < (speed * 6.0).max(40.0) {
|
||||
// The heights are a coarse upper bound (the canopy of a forest, the roof of a building): it blows up only before
|
||||
// blocks that are really there, not before what the height map says is higher than the missile.
|
||||
fail = (1..=4).any(|k| {
|
||||
let p = pos + raised * speed * f64::from(k);
|
||||
ground.land(p).is_some_and(|g| g + 2.0 > p.y)
|
||||
}) && matches!(ground.world.probe(pos, pos + raised * speed * 4.0, now), world::Sweep::Hit { .. });
|
||||
}
|
||||
(raised, fail)
|
||||
}
|
||||
@@ -156,23 +156,7 @@ const BATTERY_SPINNER: Option<(&str, f64, f64, f64, f64)> = Some(("airdef:radar_
|
||||
const TUBE_PIVOT: DVec3 = DVec3::new(0.0, -0.5, 1.5);
|
||||
|
||||
impl SamKind {
|
||||
pub const ALL: [SamKind; 15] = [
|
||||
SamKind::Patriot,
|
||||
SamKind::Gepard,
|
||||
SamKind::Pantsir,
|
||||
SamKind::S400,
|
||||
SamKind::S500,
|
||||
SamKind::IrisT,
|
||||
SamKind::Nasams,
|
||||
SamKind::Buk,
|
||||
SamKind::Tor,
|
||||
SamKind::P1sun,
|
||||
SamKind::Radar,
|
||||
SamKind::Depot,
|
||||
SamKind::Tzm,
|
||||
SamKind::Ew,
|
||||
SamKind::Light,
|
||||
];
|
||||
pub const ALL: [SamKind; super::catalog::UNIT_COUNT] = super::catalog::UNIT_KINDS;
|
||||
/// The ones that shoot (the roles menu lists these).
|
||||
pub const ARMED: [SamKind; 10] = [
|
||||
SamKind::Patriot,
|
||||
@@ -192,7 +176,7 @@ impl SamKind {
|
||||
const S: SamSpec = SamSpec {
|
||||
name: "Patriot",
|
||||
key: "patriot",
|
||||
missile: Some(MissileLoad { kind: MissileKind::Pac3, magazine: 4, min: 10.0, max: 300.0, interval: 16 }),
|
||||
missile: Some(MissileLoad { kind: MissileKind::Pac3, magazine: 4, min: 10.0, max: 450.0, interval: 16 }),
|
||||
gun: None,
|
||||
reload: 220,
|
||||
scale: 1.3,
|
||||
@@ -208,7 +192,7 @@ impl SamKind {
|
||||
mount: (0.69, 1.2),
|
||||
pivot: DVec3::new(0.0, -0.5, 1.375),
|
||||
muzzle: Muzzle::Patriot,
|
||||
sensor: 390.0,
|
||||
sensor: 585.0,
|
||||
mast: 5.0,
|
||||
};
|
||||
&S
|
||||
@@ -218,7 +202,7 @@ impl SamKind {
|
||||
name: "Гепард",
|
||||
key: "gepard",
|
||||
missile: None,
|
||||
gun: Some(GunSpec { range: 90.0, track: 130.0, p: 0.3, bursts: 160, shell: 10.0, slew: (0.22, 0.16) }),
|
||||
gun: Some(GunSpec { range: 135.0, track: 195.0, p: 0.3, bursts: 160, shell: 10.0, slew: (0.22, 0.16) }),
|
||||
reload: 160,
|
||||
scale: 1.25,
|
||||
rest_pitch: 0.0,
|
||||
@@ -234,7 +218,7 @@ impl SamKind {
|
||||
mount: (1.55, 0.25),
|
||||
pivot: DVec3::ZERO,
|
||||
muzzle: Muzzle::None,
|
||||
sensor: 170.0,
|
||||
sensor: 255.0,
|
||||
mast: 3.0,
|
||||
};
|
||||
&S
|
||||
@@ -243,8 +227,8 @@ impl SamKind {
|
||||
const S: SamSpec = SamSpec {
|
||||
name: "Панцирь-С1",
|
||||
key: "pantsir",
|
||||
missile: Some(MissileLoad { kind: MissileKind::M57e6, magazine: 12, min: 25.0, max: 150.0, interval: 14 }),
|
||||
gun: Some(GunSpec { range: 60.0, track: 90.0, p: 0.25, bursts: 140, shell: 9.0, slew: (0.25, 0.18) }),
|
||||
missile: Some(MissileLoad { kind: MissileKind::M57e6, magazine: 12, min: 25.0, max: 225.0, interval: 14 }),
|
||||
gun: Some(GunSpec { range: 90.0, track: 135.0, p: 0.25, bursts: 140, shell: 9.0, slew: (0.25, 0.18) }),
|
||||
reload: 280,
|
||||
scale: 1.3,
|
||||
rest_pitch: 0.0,
|
||||
@@ -260,7 +244,7 @@ impl SamKind {
|
||||
mount: (1.35, 0.69),
|
||||
pivot: DVec3::ZERO,
|
||||
muzzle: Muzzle::Pantsir,
|
||||
sensor: 195.0,
|
||||
sensor: 292.0,
|
||||
mast: 4.0,
|
||||
};
|
||||
&S
|
||||
@@ -269,7 +253,7 @@ impl SamKind {
|
||||
const S: SamSpec = SamSpec {
|
||||
name: "С-400",
|
||||
key: "s400",
|
||||
missile: Some(MissileLoad { kind: MissileKind::M48n6, magazine: 4, min: 30.0, max: 480.0, interval: 20 }),
|
||||
missile: Some(MissileLoad { kind: MissileKind::M48n6, magazine: 4, min: 30.0, max: 720.0, interval: 20 }),
|
||||
gun: None,
|
||||
reload: 420,
|
||||
scale: 1.5,
|
||||
@@ -286,7 +270,7 @@ impl SamKind {
|
||||
mount: (0.7, 1.45),
|
||||
pivot: TUBE_PIVOT,
|
||||
muzzle: Muzzle::Grid(2, 2, 7.0),
|
||||
sensor: 624.0,
|
||||
sensor: 936.0,
|
||||
mast: 5.0,
|
||||
};
|
||||
&S
|
||||
@@ -295,7 +279,7 @@ impl SamKind {
|
||||
const S: SamSpec = SamSpec {
|
||||
name: "С-500",
|
||||
key: "s500",
|
||||
missile: Some(MissileLoad { kind: MissileKind::M77n6, magazine: 4, min: 40.0, max: 700.0, interval: 20 }),
|
||||
missile: Some(MissileLoad { kind: MissileKind::M77n6, magazine: 4, min: 40.0, max: 1050.0, interval: 20 }),
|
||||
gun: None,
|
||||
reload: 520,
|
||||
scale: 1.6,
|
||||
@@ -312,7 +296,7 @@ impl SamKind {
|
||||
mount: (0.7, 1.45),
|
||||
pivot: TUBE_PIVOT,
|
||||
muzzle: Muzzle::Grid(2, 1, 9.5),
|
||||
sensor: 910.0,
|
||||
sensor: 1365.0,
|
||||
mast: 5.0,
|
||||
};
|
||||
&S
|
||||
@@ -321,7 +305,7 @@ impl SamKind {
|
||||
const S: SamSpec = SamSpec {
|
||||
name: "IRIS-T SLM",
|
||||
key: "irist",
|
||||
missile: Some(MissileLoad { kind: MissileKind::IrisT, magazine: 8, min: 15.0, max: 400.0, interval: 10 }),
|
||||
missile: Some(MissileLoad { kind: MissileKind::IrisT, magazine: 8, min: 15.0, max: 600.0, interval: 10 }),
|
||||
gun: None,
|
||||
reload: 300,
|
||||
scale: 1.4,
|
||||
@@ -338,7 +322,7 @@ impl SamKind {
|
||||
mount: (0.7, 1.45),
|
||||
pivot: TUBE_PIVOT,
|
||||
muzzle: Muzzle::Grid(4, 2, 4.0),
|
||||
sensor: 520.0,
|
||||
sensor: 780.0,
|
||||
mast: 5.0,
|
||||
};
|
||||
&S
|
||||
@@ -347,7 +331,7 @@ impl SamKind {
|
||||
const S: SamSpec = SamSpec {
|
||||
name: "NASAMS",
|
||||
key: "nasams",
|
||||
missile: Some(MissileLoad { kind: MissileKind::Amraam, magazine: 6, min: 10.0, max: 300.0, interval: 14 }),
|
||||
missile: Some(MissileLoad { kind: MissileKind::Amraam, magazine: 6, min: 10.0, max: 450.0, interval: 14 }),
|
||||
gun: None,
|
||||
reload: 260,
|
||||
scale: 1.3,
|
||||
@@ -364,7 +348,7 @@ impl SamKind {
|
||||
mount: (0.62, 0.4),
|
||||
pivot: TUBE_PIVOT,
|
||||
muzzle: Muzzle::Grid(3, 2, 4.0),
|
||||
sensor: 390.0,
|
||||
sensor: 585.0,
|
||||
mast: 5.0,
|
||||
};
|
||||
&S
|
||||
@@ -373,7 +357,7 @@ impl SamKind {
|
||||
const S: SamSpec = SamSpec {
|
||||
name: "Бук-М2",
|
||||
key: "buk",
|
||||
missile: Some(MissileLoad { kind: MissileKind::M9m317, magazine: 4, min: 20.0, max: 450.0, interval: 18 }),
|
||||
missile: Some(MissileLoad { kind: MissileKind::M9m317, magazine: 4, min: 20.0, max: 675.0, interval: 18 }),
|
||||
gun: None,
|
||||
reload: 400,
|
||||
scale: 1.4,
|
||||
@@ -389,7 +373,7 @@ impl SamKind {
|
||||
mount: (1.55, 0.2),
|
||||
pivot: DVec3::ZERO,
|
||||
muzzle: Muzzle::Rails(&[-9.0, -3.0, 13.0, 19.0]),
|
||||
sensor: 585.0,
|
||||
sensor: 878.0,
|
||||
mast: 4.0,
|
||||
};
|
||||
&S
|
||||
@@ -398,7 +382,7 @@ impl SamKind {
|
||||
const S: SamSpec = SamSpec {
|
||||
name: "Тор-М2",
|
||||
key: "tor",
|
||||
missile: Some(MissileLoad { kind: MissileKind::M9m338, magazine: 8, min: 8.0, max: 160.0, interval: 8 }),
|
||||
missile: Some(MissileLoad { kind: MissileKind::M9m338, magazine: 8, min: 8.0, max: 240.0, interval: 8 }),
|
||||
gun: None,
|
||||
reload: 300,
|
||||
scale: 1.3,
|
||||
@@ -409,7 +393,7 @@ impl SamKind {
|
||||
mount: (1.5, 0.0),
|
||||
pivot: DVec3::ZERO,
|
||||
muzzle: Muzzle::Cells,
|
||||
sensor: 210.0,
|
||||
sensor: 315.0,
|
||||
mast: 3.5,
|
||||
};
|
||||
&S
|
||||
@@ -418,7 +402,7 @@ impl SamKind {
|
||||
const S: SamSpec = SamSpec {
|
||||
name: "P1-SUN",
|
||||
key: "p1sun",
|
||||
missile: Some(MissileLoad { kind: MissileKind::P1sun, magazine: 8, min: 5.0, max: 450.0, interval: 12 }),
|
||||
missile: Some(MissileLoad { kind: MissileKind::P1sun, magazine: 8, min: 5.0, max: 675.0, interval: 12 }),
|
||||
gun: None,
|
||||
reload: 240,
|
||||
scale: 1.1,
|
||||
@@ -454,7 +438,7 @@ impl SamKind {
|
||||
mount: (0.0, 0.0),
|
||||
pivot: DVec3::ZERO,
|
||||
muzzle: Muzzle::None,
|
||||
sensor: 1700.0,
|
||||
sensor: 2550.0,
|
||||
mast: 16.0,
|
||||
};
|
||||
&S
|
||||
|
||||
@@ -45,15 +45,125 @@ pub(super) fn claimed(d: &Drone, missile_on: &HashMap<u32, u32>, had_target: Opt
|
||||
d.engaged + on
|
||||
}
|
||||
|
||||
/// Ballistic missiles get a pair; anything else one.
|
||||
/// Ticks until the target reaches its aim at its present speed.
|
||||
pub(super) fn arrival(d: &Drone) -> f64 {
|
||||
d.pos.distance(d.target) / d.vel.length().max(0.1)
|
||||
}
|
||||
|
||||
/// Shoot-look-shoot that grows with urgency: ballistic missiles get a pair, anything else one; a target
|
||||
/// this close to its aim (ticks) has one more interceptor allowed on it at once, closer still another, and in the last seconds a fourth.
|
||||
pub(super) const URGENT: f64 = 240.0;
|
||||
pub(super) const DESPERATE: f64 = 110.0;
|
||||
pub(super) const FINAL: f64 = 60.0;
|
||||
|
||||
pub(super) fn needed(d: &Drone) -> u32 {
|
||||
if d.kind.spec().class == Class::Ballistic { 2 } else { 1 }
|
||||
let base = if d.kind.spec().class == Class::Ballistic { 2 } else { 1 };
|
||||
let t = arrival(d);
|
||||
base + u32::from(t < URGENT) + u32::from(t < DESPERATE) + u32::from(t < FINAL)
|
||||
}
|
||||
|
||||
/// Ticks a launcher may hold a target without launching before it lets go, and how long it then keeps away from it.
|
||||
pub(super) const HOLD_MAX: u32 = 24;
|
||||
pub(super) const SHY_TICKS: u64 = 120;
|
||||
|
||||
// ---------------------------------------------------------------- the grounds to launch on
|
||||
|
||||
/// Last chance (`/airdef lastchance`): a target of a class the system does not engage that is about to
|
||||
/// hit, with nobody's interceptor on it, is shot at anyway; a system told to hold fire (no roles) keeps to it.
|
||||
pub(super) const LAST_CHANCE_TICKS: f64 = 200.0;
|
||||
|
||||
pub(super) fn last_chance(on: bool, roles: u8, d: &Drone, claimed: u32) -> bool {
|
||||
on && roles != 0 && roles & d.kind.spec().class.bit() == 0 && claimed == 0 && arrival(d) < LAST_CHANCE_TICKS
|
||||
}
|
||||
|
||||
/// The big radar's cue (heavy systems only): they may fire out to `FAR_K` × max at a target the radar holds.
|
||||
pub(super) const FAR_K: f64 = 1.6;
|
||||
/// Ticks between one system's long shots; the share of the magazine it keeps for them; the radar track's age.
|
||||
pub(super) const FAR_COOLDOWN: u32 = 300;
|
||||
pub(super) const FAR_RADAR_AGE: u64 = 150;
|
||||
|
||||
impl SamKind {
|
||||
/// Whether the kind takes long shots on a big radar's data.
|
||||
pub(super) fn far_shooter(self) -> bool {
|
||||
matches!(self, SamKind::S400 | SamKind::S500 | SamKind::Patriot)
|
||||
}
|
||||
}
|
||||
|
||||
/// A live big radar in data-link reach of `sam` that measured `id` recently.
|
||||
pub(super) fn radar_cue(sam: &Sam, radars: &[&Sam], id: u32, now: u64) -> bool {
|
||||
radars.iter().any(|r| {
|
||||
r.alive()
|
||||
&& !r.moving()
|
||||
&& r.radar_up()
|
||||
&& r.pos.distance(sam.pos) <= r.link_range().min(sam.link_range())
|
||||
&& r.track(id).is_some_and(|t| t.own_tick > 0 && t.age(now) <= FAR_RADAR_AGE)
|
||||
})
|
||||
}
|
||||
|
||||
/// The ground beyond `max`: a long shot is allowed (the system, its launcher and magazine, the flag, a cue).
|
||||
pub(super) fn far_blocks(on: bool, sam: &Sam, load: &units::MissileLoad, cued: bool, in_reach_of_any: bool) -> u8 {
|
||||
(if on && sam.kind.far_shooter() { 0 } else { FAR_OFF })
|
||||
| (if cued { 0 } else { FAR_NO_CUE })
|
||||
| (if sam.far_cooldown == 0 { 0 } else { FAR_WAIT })
|
||||
| (if sam.missiles * 2 >= load.magazine { 0 } else { FAR_LOW })
|
||||
| (if in_reach_of_any { FAR_BUSY } else { 0 })
|
||||
}
|
||||
pub(super) const FAR_OFF: u8 = 1;
|
||||
pub(super) const FAR_NO_CUE: u8 = 2;
|
||||
pub(super) const FAR_WAIT: u8 = 4;
|
||||
pub(super) const FAR_LOW: u8 = 8;
|
||||
pub(super) const FAR_BUSY: u8 = 16;
|
||||
|
||||
/// Why a system may launch at a target: its role, the last chance, or a long shot on the radar's cue.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub(super) enum Basis {
|
||||
Role,
|
||||
LastChance,
|
||||
FarShot,
|
||||
}
|
||||
|
||||
/// What is switched on beyond the roles (the sim's settings).
|
||||
#[derive(Clone, Copy)]
|
||||
pub(super) struct Opts {
|
||||
pub last_chance: bool,
|
||||
pub far_shots: bool,
|
||||
}
|
||||
|
||||
/// Whether, and on what basis, `sam` may launch at `d` on `track`: `k` stretches the reach (a held target
|
||||
/// may stray); `claimed` is the interceptors others have on it; `cued` that a big radar holds it; and
|
||||
/// `role_in_reach` that the system has a target of its roles in range anyway (no long shots then).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(super) fn basis(sam: &Sam, load: &units::MissileLoad, track: &Track, d: &Drone, now: u64, claimed: u32, k: f64, opts: Opts, cued: bool, role_in_reach: bool) -> Option<Basis> {
|
||||
let blocks = target_blocks(sam.roles, Some(track), now, d);
|
||||
if blocks & !ROLE != 0 {
|
||||
return None;
|
||||
}
|
||||
let est = track.est(now);
|
||||
let reach = reach_blocks(load.min, load.max, k, sam.pos, est);
|
||||
if blocks & ROLE == 0 {
|
||||
// The doctrine (sector, protected objects, reserve) rules over the role's shots and the long ones; the last chance is past it.
|
||||
if sam.doctrine.area_blocks(sam.pos, track, now) | sam.doctrine.reserve_blocks(sam.missiles, d) != 0 {
|
||||
return None;
|
||||
}
|
||||
if reach == 0 {
|
||||
return Some(Basis::Role);
|
||||
}
|
||||
let far = reach == TOO_FAR && reach_blocks(load.min, load.max, FAR_K, sam.pos, est) == 0;
|
||||
return (far && far_blocks(opts.far_shots, sam, load, cued, role_in_reach) == 0).then_some(Basis::FarShot);
|
||||
}
|
||||
(reach == 0 && last_chance(opts.last_chance, sam.roles, d, claimed)).then_some(Basis::LastChance)
|
||||
}
|
||||
|
||||
/// The kill chance of an interceptor that met its target `dist` from the launcher whose reach is `max`:
|
||||
/// whole up to `max`, falling linearly to half at `FAR_K` × max.
|
||||
pub(super) fn reach_fit(max: f64, dist: f64) -> f64 {
|
||||
1.0 - 0.5 * ((dist - max) / (max * (FAR_K - 1.0))).clamp(0.0, 1.0)
|
||||
}
|
||||
|
||||
/// A gun's candidates: measured by the system's own radar a moment ago and within the gun's tracking range
|
||||
/// (by the track's forecast, not the target's true place).
|
||||
pub(super) fn gun_candidate(roles: u8, track: &Track, now: u64, gun_track: f64, pos: DVec3, d: &Drone) -> bool {
|
||||
allowed(roles, track, now, d) && track.own_within(now, sight::GUN_PICK_AGE) && track.est(now).distance(pos) < gun_track
|
||||
pub(super) fn gun_candidate(roles: u8, doc: &doctrine::Doctrine, track: &Track, now: u64, gun_track: f64, pos: DVec3, d: &Drone) -> bool {
|
||||
allowed(roles, track, now, d) && doc.area_blocks(pos, track, now) == 0 && track.own_within(now, sight::GUN_PICK_AGE) && track.est(now).distance(pos) < gun_track
|
||||
}
|
||||
|
||||
/// How many systems have each drone as their missile target and as their gun target.
|
||||
@@ -209,8 +319,12 @@ impl Sim {
|
||||
let subject = sam.target.or(sam.gun_target).and_then(drone_at).or_else(|| {
|
||||
self.drones
|
||||
.iter()
|
||||
.filter(|d| d.alive() && sam.roles & d.kind.spec().class.bit() != 0)
|
||||
.max_by(|a, b| a.threat(sam.pos).total_cmp(&b.threat(sam.pos)))
|
||||
.filter(|d| d.alive() && (sam.roles & d.kind.spec().class.bit() != 0 || last_chance(self.last_chance, sam.roles, d, claimed(d, &missile_on, sam.target))))
|
||||
.max_by(|a, b| {
|
||||
// What the doctrine lets the system shoot at comes first; then the most threatening.
|
||||
let area = |d: &Drone| sam.track(d.id).is_none_or(|tr| sam.doctrine.area_blocks(sam.pos, tr, self.tick) == 0);
|
||||
area(a).cmp(&area(b)).then(a.threat(sam.pos).total_cmp(&b.threat(sam.pos)))
|
||||
})
|
||||
});
|
||||
let Some(t) = subject else {
|
||||
v.push(check(false, format!("нет целей классов [{}]", roles_text(sam.roles))));
|
||||
@@ -220,17 +334,51 @@ impl Sim {
|
||||
let dist = sam.track(t.id).map_or(t.pos, |tr| tr.est(self.tick)).distance(sam.pos);
|
||||
v.push(check(
|
||||
true,
|
||||
format!("цель: {} {}, {}", t.kind.spec().name, if held { "(сопровождается)" } else { "(самая опасная)" }, crate::panel::distance(dist)),
|
||||
format!("цель: {} {}, {}", t.kind.spec().name, if held { "(сопровождается)" } else { "(самая опасная)" }, super::distance(dist)),
|
||||
));
|
||||
let track = sam.track(t.id);
|
||||
let blocks = target_blocks(sam.roles, track, now, t);
|
||||
// Where the system believes the target is: its track's forecast (the true place only when it has no track).
|
||||
let est = track.map_or(t.pos, |tr| tr.est(now));
|
||||
let evel = track.map_or(t.vel, |tr| tr.vel);
|
||||
v.push(check(
|
||||
blocks & ROLE == 0,
|
||||
format!("роль: {} {} [{}]", t.kind.spec().class.name(), if blocks & ROLE == 0 { "в ролях" } else { "не в ролях" }, roles_text(sam.roles)),
|
||||
));
|
||||
let first_claim = claimed(t, &missile_on, sam.target);
|
||||
let chance = blocks & ROLE != 0 && last_chance(self.last_chance, sam.roles, t, first_claim);
|
||||
let role_text = if blocks & ROLE == 0 {
|
||||
format!("роль: {} в ролях [{}]", t.kind.spec().class.name(), roles_text(sam.roles))
|
||||
} else if chance {
|
||||
format!(
|
||||
"последний шанс: {} не в ролях [{}], но до цели {:.0} с, перехватчиков на ней нет",
|
||||
t.kind.spec().class.name(),
|
||||
roles_text(sam.roles),
|
||||
arrival(t) / 20.0
|
||||
)
|
||||
} else {
|
||||
format!("роль: {} не в ролях [{}]", t.kind.spec().class.name(), roles_text(sam.roles))
|
||||
};
|
||||
v.push(check(blocks & ROLE == 0 || chance, role_text));
|
||||
// The doctrine: which of its settings let the shot through or stopped it. The last chance is past them.
|
||||
let doc = &sam.doctrine;
|
||||
let area = track.map_or(0, |tr| doc.area_blocks(sam.pos, tr, now));
|
||||
let held_back = if spec.missile.is_some() { doc.reserve_blocks(sam.missiles, t) } else { 0 };
|
||||
if !doc.is_default() {
|
||||
v.push(check(true, format!("доктрина: {}", doc.text(&self.targets))));
|
||||
}
|
||||
if area & doctrine::OUT_SECTOR != 0 {
|
||||
let bearing = heading_of(est - sam.pos).to_degrees().rem_euclid(360.0);
|
||||
v.push(check(chance, format!("вне сектора {}: цель на {bearing:.0}°{}", doc.sector_text(), if chance { " — последний шанс сильнее" } else { "" })));
|
||||
} else if doc.sector.is_some() {
|
||||
v.push(check(true, format!("в секторе {}", doc.sector_text())));
|
||||
}
|
||||
if area & doctrine::NO_THREAT != 0 {
|
||||
v.push(check(chance, format!("не угрожает охраняемым объектам ({}){}", doc.guards.iter().map(|g| doctrine::object_name(&self.targets, *g)).collect::<Vec<_>>().join(", "), if chance { " — последний шанс сильнее" } else { "" })));
|
||||
} else if let Some(g) = track.and_then(|tr| doc.threatens(tr, now)) {
|
||||
v.push(check(true, format!("прикрывает {}: цель идёт на него", doctrine::object_name(&self.targets, doc.guards[g]))));
|
||||
}
|
||||
if held_back != 0 {
|
||||
v.push(check(chance, format!("сохраняет резерв {}: ракет {}, цель не срочная{}", doc.reserve, sam.missiles, if chance { " — последний шанс сильнее" } else { "" })));
|
||||
} else if doc.reserve > 0 && sam.missiles <= doc.reserve {
|
||||
v.push(check(true, format!("резерв {} открыт: цель срочная (до удара {:.0} с)", doc.reserve, arrival(t) / 20.0)));
|
||||
}
|
||||
let detect = match (track, sam.own.contains(&t.id)) {
|
||||
(Some(tr), own) => {
|
||||
let kind = if own { "своей РЛС" } else { "по сети (стволы не стреляют)" };
|
||||
@@ -277,19 +425,33 @@ impl Sim {
|
||||
let mut fires = false;
|
||||
if let Some(load) = &spec.missile {
|
||||
let reach = reach_blocks(load.min, load.max, 1.0, sam.pos, est);
|
||||
v.push(check(
|
||||
reach == 0,
|
||||
format!(
|
||||
"ракеты: дальность {}–{}, цель на {}{}",
|
||||
crate::panel::distance(load.min),
|
||||
crate::panel::distance(load.max),
|
||||
crate::panel::distance(dist),
|
||||
if reach & TOO_CLOSE != 0 { " — слишком близко" } else if reach & TOO_FAR != 0 { " — слишком далеко" } else { "" }
|
||||
),
|
||||
));
|
||||
let free = claimed(t, &missile_on, sam.target);
|
||||
let need = needed(t);
|
||||
v.push(check(free < need, format!("цель занята перехватчиками: {free} из {need}{}", if free < need { "" } else { " — другие уже на ней" })));
|
||||
// Beyond the normal reach, a heavy system may fire on a big radar's cue.
|
||||
let radars: Vec<&Sam> = self.sams.iter().filter(|s| s.kind == SamKind::Radar).collect();
|
||||
let cued = sam.kind.far_shooter() && radar_cue(sam, &radars, t.id, now);
|
||||
let role_in_reach = self.drones.iter().any(|o| {
|
||||
sam.track(o.id).is_some_and(|tr| allowed(sam.roles, tr, now, o) && in_reach(load.min, load.max, 1.0, sam.pos, tr.est(now)) && sam.doctrine.area_blocks(sam.pos, tr, now) | sam.doctrine.reserve_blocks(sam.missiles, o) == 0 && claimed(o, &missile_on, sam.target) < sam.doctrine.needed(o))
|
||||
});
|
||||
let far = reach == TOO_FAR && reach_blocks(load.min, load.max, FAR_K, sam.pos, est) == 0;
|
||||
let far_ok = far && track.is_some_and(|tr| basis(sam, load, tr, t, now, 0, 1.0, Opts { last_chance: self.last_chance, far_shots: self.far_shots }, cued, role_in_reach) == Some(Basis::FarShot));
|
||||
if far {
|
||||
let fb = far_blocks(self.far_shots, sam, load, cued, role_in_reach);
|
||||
let mut no = Vec::new();
|
||||
for (bit, name) in [
|
||||
(FAR_OFF, "не для этого комплекса"),
|
||||
(FAR_NO_CUE, "нет свежего трека большой РЛС"),
|
||||
(FAR_WAIT, "дальний пуск уже был недавно"),
|
||||
(FAR_LOW, "меньше половины боезапаса"),
|
||||
(FAR_BUSY, "есть цель в обычной дальности"),
|
||||
] {
|
||||
if fb & bit != 0 {
|
||||
no.push(name);
|
||||
}
|
||||
}
|
||||
v.push(check(far_ok, if far_ok { format!("дальний пуск по РЛС: цель на {} дальше обычных {}", super::distance(dist), super::distance(load.max)) } else { format!("дальний пуск по РЛС не разрешён: {}", no.join(", ")) }));
|
||||
}
|
||||
let free = first_claim;
|
||||
let need = sam.doctrine.needed(t);
|
||||
v.push(check(free < need, format!("цель занята перехватчиками: {free} из {need} (залп {}){}", doc.salvo.name(), if free < need { "" } else { " — другие уже на ней" })));
|
||||
let mb = missile_blocks(sam);
|
||||
let mut why = Vec::new();
|
||||
if mb & COOLDOWN != 0 {
|
||||
@@ -320,17 +482,19 @@ impl Sim {
|
||||
},
|
||||
));
|
||||
}
|
||||
fires |= reach == 0 && free < need && mb == 0 && aligned && blocks == 0 && land == 0;
|
||||
let doc_ok = chance || area | held_back == 0;
|
||||
let grounds = blocks & !ROLE == 0 && (blocks & ROLE == 0 || chance) && doc_ok && (reach == 0 || far_ok);
|
||||
fires |= grounds && free < need && mb == 0 && aligned && land == 0;
|
||||
}
|
||||
if let Some(gun) = &spec.gun {
|
||||
let on_it = guns_on.get(&t.id).copied().unwrap_or(0) - u32::from(sam.gun_target == Some(t.id));
|
||||
let cand = track.is_some_and(|tr| gun_candidate(sam.roles, tr, now, gun.track, sam.pos, t));
|
||||
let cand = track.is_some_and(|tr| gun_candidate(sam.roles, &sam.doctrine, tr, now, gun.track, sam.pos, t));
|
||||
v.push(check(
|
||||
cand,
|
||||
format!(
|
||||
"орудие: сопровождение до {}, цель на {}, других орудий на ней {on_it}{}",
|
||||
crate::panel::distance(gun.track),
|
||||
crate::panel::distance(dist),
|
||||
super::distance(gun.track),
|
||||
super::distance(dist),
|
||||
if cand { "" } else { " — вне сопровождения (нужна своя РЛС)" }
|
||||
),
|
||||
));
|
||||
@@ -338,7 +502,7 @@ impl Sim {
|
||||
let mut why = Vec::new();
|
||||
for (bit, name) in [
|
||||
(AIM_ERROR, format!("орудие ещё наводится ({:.0}°)", err.to_degrees())),
|
||||
(OUT_OF_RANGE, format!("дальше {}", crate::panel::distance(gun.range))),
|
||||
(OUT_OF_RANGE, format!("дальше {}", super::distance(gun.range))),
|
||||
(COOLDOWN, "пауза между очередями".to_string()),
|
||||
(RELOADING, "перезарядка".to_string()),
|
||||
(NO_ROUNDS, "нет снарядов".to_string()),
|
||||
@@ -379,4 +543,175 @@ mod tests {
|
||||
sim.sams[0].roles = 0xFF;
|
||||
assert!(sim.why(0).iter().any(|c| c.text.starts_with("роль")));
|
||||
}
|
||||
|
||||
use super::sites::testland::{Land, serve};
|
||||
|
||||
fn setup(kind: SamKind) -> (Sim, Ground, Land<fn(i32, i32) -> i32>, Out) {
|
||||
let mut sim = Sim::new(5);
|
||||
let id = sim.id();
|
||||
sim.sams.push(Sam::new(id, kind, DVec3::new(0.0, 70.0, 0.0), 0.0));
|
||||
(sim, Ground::default(), Land(|_, _| 64), Out::default())
|
||||
}
|
||||
|
||||
/// Steps `ticks` or until something is fired; returns the drone's ticks to its aim at the first launch.
|
||||
fn until_fired(sim: &mut Sim, ground: &mut Ground, land: &Land<fn(i32, i32) -> i32>, out: &mut Out, ticks: u32) -> Option<f64> {
|
||||
for _ in 0..ticks {
|
||||
serve(ground, land, sim.tick);
|
||||
sim.step(ground, None, out);
|
||||
if sim.sams[0].fired > 0 {
|
||||
return sim.drones.first().map(arrival);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// A Shahed `blocks` short of its aim, which is `80` out from the system, coming in along z.
|
||||
fn shahed_at(sim: &mut Sim, blocks: f64) {
|
||||
sim.add_drone(DroneKind::Shahed, DVec3::new(0.0, 75.0, -80.0 - blocks), DVec3::Z, DVec3::new(0.0, 70.0, -80.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn last_chance_fires_at_a_class_out_of_roles_only_when_it_is_about_to_hit() {
|
||||
// The S-400 does not engage drones by default.
|
||||
assert_eq!(SamKind::S400.spec().roles & Class::Drone.bit(), 0);
|
||||
let (mut sim, mut ground, land, mut out) = setup(SamKind::S400);
|
||||
shahed_at(&mut sim, 60.0);
|
||||
let at = until_fired(&mut sim, &mut ground, &land, &mut out, 140).expect("the S-400 never fired on a Shahed about to hit");
|
||||
assert!(at < LAST_CHANCE_TICKS, "fired with {at:.0} ticks to go");
|
||||
// The diagnostic names why: the last chance.
|
||||
let (mut sim, mut ground, land, mut out) = setup(SamKind::S400);
|
||||
shahed_at(&mut sim, 100.0);
|
||||
for _ in 0..30 {
|
||||
serve(&mut ground, &land, sim.tick);
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
}
|
||||
let w = sim.why(0);
|
||||
assert!(w.iter().any(|c| c.ok && c.text.starts_with("последний шанс")), "{:?}", w.iter().map(|c| &c.text).collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn last_chance_waits_for_a_target_far_from_its_aim() {
|
||||
let (mut sim, mut ground, land, mut out) = setup(SamKind::S400);
|
||||
// In plain view 120 blocks off, but flying away from its aim, 480 blocks (800 ticks) ahead.
|
||||
sim.add_drone(DroneKind::Shahed, DVec3::new(0.0, 75.0, -120.0), DVec3::NEG_Z, DVec3::new(0.0, 70.0, -600.0));
|
||||
assert!(until_fired(&mut sim, &mut ground, &land, &mut out, 150).is_none(), "fired at a Shahed far from its aim");
|
||||
let w = sim.why(0);
|
||||
// Still named as the role block it was: no target of its classes.
|
||||
assert!(w.last().is_some_and(|c| !c.ok) && w.iter().any(|c| c.text.contains("нет целей классов")), "{:?}", w.iter().map(|c| &c.text).collect::<Vec<_>>());
|
||||
assert!(!w.iter().any(|c| c.text.starts_with("последний шанс")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn last_chance_is_off_when_switched_off_and_with_no_roles() {
|
||||
for (off, roles) in [(true, 30u8), (false, 0u8)] {
|
||||
let (mut sim, mut ground, land, mut out) = setup(SamKind::S400);
|
||||
sim.last_chance = !off;
|
||||
sim.sams[0].roles = roles;
|
||||
shahed_at(&mut sim, 60.0);
|
||||
assert!(until_fired(&mut sim, &mut ground, &land, &mut out, 140).is_none(), "fired with last chance off={off}, roles {roles}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn last_chance_leaves_a_target_that_already_has_an_interceptor_on_it() {
|
||||
let (mut sim, mut ground, land, mut out) = setup(SamKind::S400);
|
||||
shahed_at(&mut sim, 60.0);
|
||||
// Another system's interceptor is on it.
|
||||
let id = sim.drones[0].id;
|
||||
sim.drones[0].engaged = 1;
|
||||
assert!(until_fired(&mut sim, &mut ground, &land, &mut out, 40).is_none(), "fired at {id} that is claimed");
|
||||
}
|
||||
|
||||
/// A Kh101 `dist` from the origin on the far side, at height, coming in along z; a radar beside the system.
|
||||
fn far_setup(radar: bool, dist: f64) -> (Sim, Ground, Land<fn(i32, i32) -> i32>, Out) {
|
||||
let (mut sim, ground, land, out) = setup(SamKind::S400);
|
||||
if radar {
|
||||
let id = sim.id();
|
||||
sim.sams.push(Sam::new(id, SamKind::Radar, DVec3::new(40.0, 70.0, 0.0), 0.0));
|
||||
}
|
||||
sim.add_drone(DroneKind::Kh101, DVec3::new(0.0, 300.0, -dist), DVec3::Z, DVec3::new(0.0, 70.0, 0.0));
|
||||
(sim, ground, land, out)
|
||||
}
|
||||
|
||||
/// The radar's measurement of every live drone, fresh this tick (as if its beam had just passed).
|
||||
fn radar_sees(sim: &mut Sim) {
|
||||
let now = sim.tick;
|
||||
let tracks: Vec<Track> = sim
|
||||
.drones
|
||||
.iter()
|
||||
.filter(|d| d.alive())
|
||||
.map(|d| Track { id: d.id, kind: d.kind, pos: d.pos, vel: d.vel, tick: now, own_tick: now, ttl: 400, hits: 3, locked: false })
|
||||
.collect();
|
||||
for r in sim.sams.iter_mut().filter(|s| s.kind == SamKind::Radar) {
|
||||
for t in &tracks {
|
||||
r.tracks.retain(|o| o.id != t.id);
|
||||
r.tracks.push(*t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fire_far(sim: &mut Sim, ground: &mut Ground, land: &Land<fn(i32, i32) -> i32>, out: &mut Out, ticks: u32) -> u32 {
|
||||
for _ in 0..ticks {
|
||||
radar_sees(sim);
|
||||
serve(ground, land, sim.tick);
|
||||
sim.step(ground, None, out);
|
||||
}
|
||||
sim.sams[0].fired
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn heavy_systems_shoot_far_on_a_radars_cue_but_not_without_one() {
|
||||
let max = SamKind::S400.spec().missile.as_ref().unwrap().max;
|
||||
let (mut sim, mut ground, land, mut out) = far_setup(true, max * 1.4);
|
||||
assert!(fire_far(&mut sim, &mut ground, &land, &mut out, 80) >= 1, "no long shot at 1.4 x max with a radar");
|
||||
let w = sim.why(0);
|
||||
assert!(w.iter().any(|c| c.text.starts_with("дальний пуск по РЛС")), "{:?}", w.iter().map(|c| &c.text).collect::<Vec<_>>());
|
||||
// No radar, no shot (the system's own radar may well see it: that is not a cue).
|
||||
let (mut sim, mut ground, land, mut out) = far_setup(false, max * 1.4);
|
||||
assert_eq!(fire_far(&mut sim, &mut ground, &land, &mut out, 80), 0, "a long shot with no radar");
|
||||
// And a kind that is not a heavy one never does.
|
||||
let (mut sim, mut ground, land, mut out) = far_setup(true, max * 1.4);
|
||||
sim.far_shots = false;
|
||||
assert_eq!(fire_far(&mut sim, &mut ground, &land, &mut out, 80), 0, "a long shot with them switched off");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_long_shot_waits_out_its_cooldown_and_for_nothing_closer() {
|
||||
let max = SamKind::S400.spec().missile.as_ref().unwrap().max;
|
||||
// Two far targets: one long shot, the second waits its 300 ticks.
|
||||
let (mut sim, mut ground, land, mut out) = far_setup(true, max * 1.4);
|
||||
sim.add_drone(DroneKind::Kh101, DVec3::new(0.0, 300.0, max * 1.4), DVec3::NEG_Z, DVec3::new(0.0, 70.0, 0.0));
|
||||
assert_eq!(fire_far(&mut sim, &mut ground, &land, &mut out, 70), 1, "not exactly one long shot in the cooldown");
|
||||
// A closer target in normal reach: the far one is not fired at while it stands.
|
||||
let (mut sim, mut ground, land, mut out) = far_setup(true, max * 1.4);
|
||||
let far = sim.drones[0].id;
|
||||
sim.add_drone(DroneKind::Kh101, DVec3::new(300.0, 120.0, 0.0), DVec3::NEG_X, DVec3::new(0.0, 70.0, 0.0));
|
||||
for _ in 0..40 {
|
||||
radar_sees(&mut sim);
|
||||
serve(&mut ground, &land, sim.tick);
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
assert!(!sim.missiles.iter().any(|m| m.target == far), "a long shot while a closer target was in reach");
|
||||
}
|
||||
assert!(sim.sams[0].fired > 0, "the closer target was not fired at");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_kill_chance_falls_to_half_at_the_far_end() {
|
||||
assert_eq!(reach_fit(100.0, 80.0), 1.0);
|
||||
assert_eq!(reach_fit(100.0, 100.0), 1.0);
|
||||
assert!((reach_fit(100.0, 130.0) - 0.75).abs() < 1e-9);
|
||||
assert!((reach_fit(100.0, 160.0) - 0.5).abs() < 1e-9);
|
||||
assert!((reach_fit(100.0, 400.0) - 0.5).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_interceptor_lives_long_enough_to_fly_its_reach() {
|
||||
// Life × top speed must cover the far end of a heavy system's reach with room to chase; the rest their plain reach.
|
||||
for kind in SamKind::ARMED {
|
||||
let Some(load) = kind.spec().missile.as_ref() else { continue };
|
||||
let m = load.kind.spec();
|
||||
let reach = load.max * if kind.far_shooter() { FAR_K } else { 1.0 };
|
||||
assert!(m.life as f64 * m.speed > reach * 1.2, "{}: {} x {} does not cover {reach}", kind.name(), m.life, m.speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,13 @@ pub struct WorldStats {
|
||||
/// Sections dropped or re-read for a chunk's unload or replacement, or for age (#62).
|
||||
pub aged: u64,
|
||||
pub columns_changed: u64,
|
||||
/// Blasts asked in the blocks, and what became of them (`Settled`).
|
||||
pub blasts_asked: u64,
|
||||
pub blasts_confirmed: u64,
|
||||
pub blasts_unchanged: u64,
|
||||
pub blasts_unloaded: u64,
|
||||
/// Answers dropped for being to a question of another world or dimension.
|
||||
pub late_dropped: u64,
|
||||
}
|
||||
|
||||
/// What the game's exact ray said of a flight's step, once it answered (#63).
|
||||
@@ -182,9 +189,37 @@ pub struct WorldCache {
|
||||
/// Columns (section x, z) where blocks changed since the land heights last looked (#64); `all`: too many to say.
|
||||
pub(super) changed_cols: HashSet<(i32, i32)>,
|
||||
pub(super) changed_all: bool,
|
||||
/// Another world or dimension opened since the land heights last looked: they are all void.
|
||||
pub(super) epoch_reset: bool,
|
||||
/// Blasts the mod asked the game to make in the blocks (`Out.commands`), waiting for the game's word that
|
||||
/// blocks changed there. The game's damage (the simulation's own) and the geometry the game confirms
|
||||
/// are two things: this is the second (#90). Singleplayer: the client's world is the authority.
|
||||
expected: Vec<Expected>,
|
||||
pub stats: WorldStats,
|
||||
}
|
||||
|
||||
/// A blast asked for: the sections it reaches (lowest, highest) and the tick it was asked.
|
||||
struct Expected {
|
||||
lo: Sec,
|
||||
hi: Sec,
|
||||
at: DVec3,
|
||||
since: u64,
|
||||
}
|
||||
|
||||
/// Ticks the game has to report a block changed after a blast was asked for (the fuse is 0; commands run 64 a tick).
|
||||
pub const CONFIRM_TICKS: u64 = 100;
|
||||
|
||||
/// What became of a blast asked for in the blocks.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Settled {
|
||||
/// The game reported blocks changed in the sections it reaches.
|
||||
Confirmed,
|
||||
/// The chunk was there and nothing changed: nothing to break, a rule or the server's rights said no.
|
||||
Unchanged,
|
||||
/// There was no chunk to change.
|
||||
Unloaded,
|
||||
}
|
||||
|
||||
fn sec_of(x: i32, y: i32, z: i32) -> Sec {
|
||||
(x >> 4, y >> 4, z >> 4)
|
||||
}
|
||||
@@ -207,7 +242,7 @@ impl WorldCache {
|
||||
pub fn text(&self) -> String {
|
||||
let s = &self.stats;
|
||||
format!(
|
||||
"мир: {} секций ({} КБ), запросов {}, неизвестно {}, лучей {} (ударов {}, неизв. {}), клеток {}",
|
||||
"мир: {} секций ({} КБ), запросов {}, неизвестно {}, лучей {} (ударов {}, неизв. {}), клеток {}; взрывы в блоках: {} (подтверждено {}, без перемен {}, нет чанка {}), чужих ответов {}",
|
||||
self.len(),
|
||||
self.bytes() / 1024,
|
||||
s.sections_asked,
|
||||
@@ -215,7 +250,12 @@ impl WorldCache {
|
||||
s.sweeps,
|
||||
s.hits,
|
||||
s.unknown_sweeps,
|
||||
s.cells
|
||||
s.cells,
|
||||
s.blasts_asked,
|
||||
s.blasts_confirmed,
|
||||
s.blasts_unchanged,
|
||||
s.blasts_unloaded,
|
||||
s.late_dropped
|
||||
)
|
||||
}
|
||||
|
||||
@@ -241,6 +281,8 @@ impl WorldCache {
|
||||
if epoch != self.epoch {
|
||||
self.rays = RayDesk { next: self.rays.next, ..RayDesk::default() };
|
||||
if self.epoch != 0 {
|
||||
self.epoch_reset = true;
|
||||
self.expected.clear();
|
||||
self.secs.clear();
|
||||
self.urgent.clear();
|
||||
self.ahead.clear();
|
||||
@@ -264,6 +306,11 @@ impl WorldCache {
|
||||
let set: HashSet<Sec> = sections.iter().copied().collect();
|
||||
self.drop_rays(|b| set.contains(&sec_of(b[0], b[1], b[2])));
|
||||
}
|
||||
if !self.expected.is_empty() {
|
||||
let before = self.expected.len();
|
||||
self.expected.retain(|e| !sections.iter().any(|s| (e.lo.0..=e.hi.0).contains(&s.0) && (e.lo.1..=e.hi.1).contains(&s.1) && (e.lo.2..=e.hi.2).contains(&s.2)));
|
||||
self.stats.blasts_confirmed += (before - self.expected.len()) as u64;
|
||||
}
|
||||
for s in sections {
|
||||
self.note_column(s.0, s.2);
|
||||
if let Some(e) = self.secs.get_mut(s) {
|
||||
@@ -274,6 +321,37 @@ impl WorldCache {
|
||||
self.stats.world_changes += sections.len() as u64;
|
||||
}
|
||||
|
||||
/// The game's epoch as last told: another world or dimension opening changes it.
|
||||
pub fn epoch(&self) -> u32 {
|
||||
self.epoch
|
||||
}
|
||||
|
||||
/// A blast of `radius` blocks was asked of the game at `at`: expect the game to report blocks changed there.
|
||||
pub fn expect_blast(&mut self, at: DVec3, radius: f64, now: u64) {
|
||||
let (lo, hi) = (at - DVec3::splat(radius), at + DVec3::splat(radius));
|
||||
let sec = |p: DVec3| sec_of(p.x.floor() as i32, p.y.floor() as i32, p.z.floor() as i32);
|
||||
if self.expected.len() < 256 {
|
||||
self.expected.push(Expected { lo: sec(lo), hi: sec(hi), at, since: now });
|
||||
}
|
||||
self.stats.blasts_asked += 1;
|
||||
}
|
||||
|
||||
/// The blasts that the game did not report in `CONFIRM_TICKS`, taken: where each was.
|
||||
pub fn overdue_blasts(&mut self, now: u64) -> Vec<DVec3> {
|
||||
let (late, keep): (Vec<_>, Vec<_>) = std::mem::take(&mut self.expected).into_iter().partition(|e| now.saturating_sub(e.since) >= CONFIRM_TICKS);
|
||||
self.expected = keep;
|
||||
late.into_iter().map(|e| e.at).collect()
|
||||
}
|
||||
|
||||
/// What became of a blast that was not reported.
|
||||
pub fn note_settled(&mut self, how: Settled) {
|
||||
match how {
|
||||
Settled::Confirmed => self.stats.blasts_confirmed += 1,
|
||||
Settled::Unchanged => self.stats.blasts_unchanged += 1,
|
||||
Settled::Unloaded => self.stats.blasts_unloaded += 1,
|
||||
}
|
||||
}
|
||||
|
||||
fn note_column(&mut self, sx: i32, sz: i32) {
|
||||
if self.changed_cols.len() >= 4096 {
|
||||
self.changed_all = true;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! derives everything from a segment's age, so the columns and blasts are a pure function of the
|
||||
//! tick (nothing grows twice when a frame is shown again); trails are the only state, and they are
|
||||
//! cut back when the tick goes backwards.
|
||||
use crate::sim::{Class, Sim};
|
||||
use crate::sim::{Class, DroneKind, Sim};
|
||||
use glam::DVec3;
|
||||
use horizon_mod_sdk::render::SmokeSegment;
|
||||
use std::collections::HashMap;
|
||||
@@ -99,30 +99,48 @@ fn blast_billows(out: &mut Vec<SmokeSegment>, blasts: &[crate::sim::Blast], tick
|
||||
}
|
||||
}
|
||||
|
||||
fn style_drone(s: &mut SmokeSegment, class: Class) {
|
||||
let (r0, r1, dens, heat, soot, clear, life): (f32, f32, f32, f32, f32, f32, f32) = match class {
|
||||
Class::Drone => (0.9, 5.0, 2.0, 0.0, 0.45, 3.0, 1200.0),
|
||||
Class::Jet | Class::Cruise => (1.1, 7.0, 2.5, 0.15, 0.35, 4.0, 1300.0),
|
||||
Class::Supersonic => (1.4, 9.0, 3.2, 0.5, 0.2, 5.0, 1300.0),
|
||||
Class::Ballistic => (2.0, 13.0, 4.0, 0.7, 0.15, 7.0, 1500.0),
|
||||
};
|
||||
s.radius_start = r0;
|
||||
s.radius_end = r1;
|
||||
s.density = dens;
|
||||
s.heat = heat;
|
||||
s.soot = soot;
|
||||
s.clear = clear;
|
||||
s.life = life;
|
||||
/// How one kind of trail looks. One rule by engine: a propeller leaves a faint short grey haze,
|
||||
/// a jet or a cruise missile a thin grey line, a rocket (supersonic, ballistic, interceptor) a white
|
||||
/// line as thick as the missile is big. No trail has heat: the flame at the nozzle is separate.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct Look {
|
||||
r0: f32,
|
||||
r1: f32,
|
||||
density: f32,
|
||||
soot: f32,
|
||||
clear: f32,
|
||||
life: f32,
|
||||
}
|
||||
|
||||
fn style_missile(s: &mut SmokeSegment) {
|
||||
s.radius_start = 0.6;
|
||||
s.radius_end = 5.0;
|
||||
s.density = 3.0;
|
||||
s.heat = 0.8;
|
||||
s.soot = 0.05;
|
||||
s.clear = 3.0;
|
||||
s.life = 1000.0;
|
||||
/// A rocket's white line, thicker for a bigger missile (`scale`: Pantsir 0.85, S-500 1.7).
|
||||
fn rocket(scale: f32, density: f32, life: f32) -> Look {
|
||||
let scale = scale.min(2.0);
|
||||
Look { r0: 0.25 * scale, r1: 1.2 + 1.6 * scale, density, soot: 0.02, clear: 0.8 + 1.2 * scale, life: life + 250.0 * scale }
|
||||
}
|
||||
|
||||
fn drone_look(class: Class, scale: f32) -> Look {
|
||||
match class {
|
||||
Class::Drone => Look { r0: 0.4, r1: 1.8, density: 0.15, soot: 0.3, clear: 0.3, life: 250.0 },
|
||||
Class::Jet => Look { r0: 0.5, r1: 2.5, density: 0.5, soot: 0.25, clear: 1.5, life: 500.0 },
|
||||
Class::Cruise => Look { r0: 0.6, r1: 3.0, density: 0.6, soot: 0.3, clear: 2.0, life: 600.0 },
|
||||
Class::Supersonic => rocket(scale, 0.9, 400.0),
|
||||
Class::Ballistic => rocket(scale, 1.1, 500.0),
|
||||
}
|
||||
}
|
||||
|
||||
/// `None`: no motor smoke at all (the electric P1-SUN).
|
||||
fn missile_look(kind: crate::sim::MissileKind) -> Option<Look> {
|
||||
kind.trail_scale().map(|k| rocket(k, 0.8, 250.0))
|
||||
}
|
||||
|
||||
fn style(s: &mut SmokeSegment, l: Look) {
|
||||
s.radius_start = l.r0;
|
||||
s.radius_end = l.r1;
|
||||
s.density = l.density;
|
||||
s.heat = 0.0;
|
||||
s.soot = l.soot;
|
||||
s.clear = l.clear;
|
||||
s.life = l.life;
|
||||
}
|
||||
|
||||
/// Points between a replay trail segment's ends (a segment every `TRAIL_GRID * STEP` ticks).
|
||||
@@ -138,15 +156,17 @@ pub fn replay_smoke(rec: &crate::sim::record::Recording, t: f64) -> Vec<SmokeSeg
|
||||
let mut out: Vec<SmokeSegment> = Vec::new();
|
||||
let stride = (TRAIL_GRID as u32 * STEP) as f64;
|
||||
for (n, tr) in rec.tracks.iter().enumerate() {
|
||||
let (life, style): (f64, Box<dyn Fn(&mut SmokeSegment)>) = match tr.what {
|
||||
let look = match tr.what {
|
||||
What::Drone(kind) => {
|
||||
let class = kind.spec().class;
|
||||
let mut probe = seg(0, DVec3::ZERO, DVec3::ZERO, 0, 0);
|
||||
style_drone(&mut probe, class);
|
||||
(probe.life as f64, Box::new(move |s| style_drone(s, class)))
|
||||
let spec = kind.spec();
|
||||
Some(drone_look(spec.class, spec.trail_scale()))
|
||||
}
|
||||
What::Missile(..) => (1000.0, Box::new(style_missile)),
|
||||
What::Missile(kind, _) => missile_look(kind),
|
||||
// A counter-strike leaves the trail of the cruise missile it is (#109).
|
||||
What::Strike => Some(drone_look(Class::Cruise, DroneKind::Kalibr.spec().trail_scale())),
|
||||
};
|
||||
let Some(look) = look else { continue };
|
||||
let life = look.life as f64;
|
||||
// The segments whose end point has been reached and whose life is not over.
|
||||
let lo = (((t - life - tr.first as f64) / stride).floor().max(0.0)) as usize;
|
||||
let hi = (((t - tr.first as f64) / stride).floor().max(0.0)) as usize;
|
||||
@@ -157,7 +177,7 @@ pub fn replay_smoke(rec: &crate::sim::record::Recording, t: f64) -> Vec<SmokeSeg
|
||||
continue;
|
||||
}
|
||||
let mut s = seg(0x2000_0000 | ((n as u32).wrapping_mul(7919) ^ g as u32) & 0x0fff_ffff, a, b, born, 1200);
|
||||
style(&mut s);
|
||||
style(&mut s, look);
|
||||
if (tick as f64) < born as f64 + s.life as f64 {
|
||||
out.push(s);
|
||||
}
|
||||
@@ -173,7 +193,11 @@ pub fn replay_smoke(rec: &crate::sim::record::Recording, t: f64) -> Vec<SmokeSeg
|
||||
fires.sort_by(|a, b| b.size.total_cmp(&a.size).then(a.start.cmp(&b.start)));
|
||||
for (rank, f) in fires.iter().enumerate() {
|
||||
let life = f.life as f64;
|
||||
fire_column(&mut out, 0x1000_0000 | f.key as u32, f.at, f.start as u64, f.size, rank < crate::sim::fires::MAX, tick, &|k| crate::sim::fires::level(k.saturating_sub(f.start as u64) as f64, life));
|
||||
fire_column(&mut out, 0x1000_0000 | f.key as u32, f.at, f.start as u64, f.size, f.shown && rank < crate::sim::fires::MAX, tick, &|k| {
|
||||
let (mut flame, mut smoke) = crate::sim::fires::level(k.saturating_sub(f.start as u64) as f64 + f.age_offset as f64, life);
|
||||
if f.water == Some(true) { flame = 0.0; smoke *= 0.5; }
|
||||
(flame, smoke)
|
||||
});
|
||||
}
|
||||
// Blasts keep their billows long after the fireball is out.
|
||||
let blasts: Vec<crate::sim::Blast> = rec
|
||||
@@ -192,7 +216,7 @@ pub fn replay_smoke(rec: &crate::sim::record::Recording, t: f64) -> Vec<SmokeSeg
|
||||
}
|
||||
|
||||
impl Smoke {
|
||||
fn trail(&mut self, key: (u8, u32), at: DVec3, tick: u64, style: impl Fn(&mut SmokeSegment)) {
|
||||
fn trail(&mut self, key: (u8, u32), at: DVec3, tick: u64, look: Look) {
|
||||
let Some(&(from, when)) = self.last.get(&key) else {
|
||||
self.last.insert(key, (at, tick));
|
||||
return;
|
||||
@@ -204,7 +228,7 @@ impl Smoke {
|
||||
if at.distance(from) < 400.0 {
|
||||
self.next = self.next.wrapping_add(1);
|
||||
let mut s = seg(self.next, from, at, tick, 1200);
|
||||
style(&mut s);
|
||||
style(&mut s, look);
|
||||
self.trails.push(Trail { seg: s });
|
||||
}
|
||||
self.last.insert(key, (at, tick));
|
||||
@@ -219,11 +243,16 @@ impl Smoke {
|
||||
}
|
||||
self.last_tick = tick;
|
||||
for d in &sim.drones {
|
||||
let class = d.kind.spec().class;
|
||||
self.trail((0, d.id), d.pos, tick, |s| style_drone(s, class));
|
||||
let spec = d.kind.spec();
|
||||
self.trail((0, d.id), d.pos, tick, drone_look(spec.class, spec.trail_scale()));
|
||||
}
|
||||
for m in &sim.missiles {
|
||||
self.trail((1, m.id), m.pos, tick, style_missile);
|
||||
if let Some(look) = missile_look(m.kind) {
|
||||
self.trail((1, m.id), m.pos, tick, look);
|
||||
}
|
||||
}
|
||||
for f in &sim.strikes.flights {
|
||||
self.trail((2, f.id), f.pos, tick, drone_look(Class::Cruise, crate::sim::DroneKind::Kalibr.spec().trail_scale()));
|
||||
}
|
||||
// Forget what is gone.
|
||||
if tick % 100 == 0 {
|
||||
@@ -232,6 +261,7 @@ impl Smoke {
|
||||
.iter()
|
||||
.map(|d| (0, d.id))
|
||||
.chain(sim.missiles.iter().map(|m| (1, m.id)))
|
||||
.chain(sim.strikes.flights.iter().map(|f| (2, f.id)))
|
||||
.collect();
|
||||
self.last.retain(|k, _| alive.contains(k));
|
||||
}
|
||||
@@ -258,3 +288,95 @@ impl Smoke {
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::sim::{DroneKind, MissileKind};
|
||||
|
||||
#[test]
|
||||
fn replay_smoke_has_trails_and_fire_columns_and_is_a_function_of_time() {
|
||||
use crate::sim::record::{Event, EventKind, Recording, What};
|
||||
let sim = Sim::new(1);
|
||||
let mut rec = Recording::blank(160);
|
||||
for id in 1..=2 {
|
||||
let x = (id - 1) as f64 * 30.0;
|
||||
rec.straight(id, What::Drone(DroneKind::Geran3), 0, 160,
|
||||
DVec3::new(x, 80.0, 0.0), DVec3::new(x, 80.0, 500.0));
|
||||
}
|
||||
assert_eq!(rec.tracks.len(), 2);
|
||||
rec.events = vec![Event { at: 40, pos: DVec3::new(5.0, 70.0, 5.0), kind: EventKind::Hit { drone: 1, kind: DroneKind::Geran3, power: 2, object: None, sam: None } }];
|
||||
let live_state = (sim.tick, sim.fires.list.len());
|
||||
let t = 130.0;
|
||||
let a = replay_smoke(&rec, t);
|
||||
assert!(a.iter().any(|s| s.clear > 0.0), "trails of both tracks");
|
||||
assert!(a.iter().any(|s| s.soot > 0.8), "a column over the fire");
|
||||
assert!(a.iter().any(|s| s.soot == 0.55), "the blast's billows");
|
||||
let _ = replay_smoke(&rec, 10.0);
|
||||
let _ = replay_smoke(&rec, 155.0);
|
||||
let b = replay_smoke(&rec, t);
|
||||
assert_eq!(a.iter().map(|s| (s.id, s.born as u64)).collect::<Vec<_>>(), b.iter().map(|s| (s.id, s.born as u64)).collect::<Vec<_>>());
|
||||
assert!(a.iter().all(|s| s.born <= t));
|
||||
assert!(replay_smoke(&rec, -5.0).is_empty());
|
||||
assert!(replay_smoke(&rec, 400.0).iter().any(|s| s.soot == 0.55));
|
||||
assert_eq!((sim.tick, sim.fires.list.len()), live_state);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn live_counter_strike_leaves_a_trail_and_releases_its_source() {
|
||||
use crate::sim::sites::{LaunchSite, SiteClass};
|
||||
use crate::sim::strike::{Estimate, Known, SiteState};
|
||||
use glam::DVec2;
|
||||
let mut sim = Sim::new(11);
|
||||
let id = 1;
|
||||
sim.sites.list.push(LaunchSite {
|
||||
id, side: 0, sector: 0, bearing: 0.0, class: SiteClass::Ramp,
|
||||
pos: DVec3::new(0.0, 64.0, 300.0), range: 300.0, water: false,
|
||||
stock: 0, planned: 0, alive: true, next_free: 0, offmap: false,
|
||||
});
|
||||
sim.strikes.known.push(Known {
|
||||
site: id, class: SiteClass::Ramp, obs: Vec::new(),
|
||||
est: Some(Estimate { pos: DVec2::new(0.0, 300.0), radius: 5.0, fix: true,
|
||||
bearing: 0.0, bearing_err: 0.01, origin: DVec2::ZERO }),
|
||||
launches: 1, last: 0, state: SiteState::Active, aimed: false,
|
||||
});
|
||||
sim.order_test_strike(id, DVec3::new(0.0, 64.0, 0.0), &mut crate::sim::Out::default()).unwrap();
|
||||
let mut smoke = Smoke::default();
|
||||
sim.tick = 1;
|
||||
smoke.update(&sim);
|
||||
let from = sim.strikes.flights[0].pos;
|
||||
sim.tick = 2;
|
||||
sim.strikes.flights[0].pos += DVec3::Z * 8.0;
|
||||
smoke.update(&sim);
|
||||
let segments = smoke.segments(&sim);
|
||||
assert_eq!(segments.len(), 1, "a live strike must emit the cruise trail also seen in replay");
|
||||
assert_eq!(segments[0].az, from.z);
|
||||
assert_eq!(segments[0].bz, from.z + 8.0);
|
||||
let expected = drone_look(Class::Cruise, DroneKind::Kalibr.spec().trail_scale());
|
||||
assert_eq!(segments[0].density, expected.density);
|
||||
sim.strikes.flights.clear();
|
||||
sim.tick = 100;
|
||||
smoke.update(&sim);
|
||||
assert!(smoke.last.is_empty(), "finished strikes must not leave source bookkeeping behind");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trails_follow_one_rule() {
|
||||
assert!(missile_look(MissileKind::P1sun).is_none());
|
||||
let rocket_look = missile_look(MissileKind::M77n6).unwrap();
|
||||
let pantsir = missile_look(MissileKind::M57e6).unwrap();
|
||||
assert!(pantsir.r1 < rocket_look.r1);
|
||||
let mut s = seg(0, DVec3::ZERO, DVec3::ZERO, 0, 0);
|
||||
for class in [Class::Drone, Class::Jet, Class::Cruise, Class::Supersonic, Class::Ballistic] {
|
||||
style(&mut s, drone_look(class, 1.0));
|
||||
assert_eq!(s.heat, 0.0);
|
||||
}
|
||||
for k in [MissileKind::Pac3, MissileKind::M57e6, MissileKind::M77n6, MissileKind::Amraam] {
|
||||
style(&mut s, missile_look(k).unwrap());
|
||||
assert_eq!(s.heat, 0.0);
|
||||
}
|
||||
let spec = DroneKind::Shahed.spec();
|
||||
let shahed = drone_look(Class::Drone, spec.trail_scale());
|
||||
assert!(shahed.density * 4.0 < rocket_look.density);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,24 +2,15 @@
|
||||
//! where, how far out and at what; and ready-made raids to start from.
|
||||
use crate::sim::{Aim, Approach, DroneKind, RaidOrder};
|
||||
|
||||
/// The kinds a raid can have, in the menu's order.
|
||||
pub const KINDS: [DroneKind; 11] = [
|
||||
DroneKind::Gerbera,
|
||||
DroneKind::Shahed,
|
||||
DroneKind::Geran3,
|
||||
DroneKind::Lancet,
|
||||
DroneKind::Kh101,
|
||||
DroneKind::Kalibr,
|
||||
DroneKind::Kh22,
|
||||
DroneKind::Zircon,
|
||||
DroneKind::Iskander,
|
||||
DroneKind::Kinzhal,
|
||||
DroneKind::Oreshnik,
|
||||
];
|
||||
/// The historical raid order is owned by the shared content catalog.
|
||||
pub use crate::sim::catalog::RAID_KINDS as KINDS;
|
||||
|
||||
/// What a click on a kind's row steps its number through.
|
||||
const STEPS: [u32; 12] = [0, 1, 2, 3, 4, 6, 8, 10, 15, 20, 30, 40];
|
||||
pub const DISTANCES: [f64; 4] = [200.0, 300.0, 500.0, 800.0];
|
||||
pub const DISTANCES: [f64; 7] = [200.0, 300.0, 500.0, 800.0, 1500.0, 2500.0, 4000.0];
|
||||
/// The nearest and farthest start a raid may be ordered at (blocks).
|
||||
pub const DIST_MIN: f64 = 60.0;
|
||||
pub const DIST_MAX: f64 = 4000.0;
|
||||
|
||||
pub struct Preset {
|
||||
pub name: &'static str,
|
||||
@@ -147,7 +138,7 @@ impl WaveConfig {
|
||||
self.approach = *a;
|
||||
}
|
||||
if let Some(d) = w.get(2).and_then(|v| v.parse::<f64>().ok()) {
|
||||
self.dist = d.clamp(60.0, 800.0);
|
||||
self.dist = d.clamp(DIST_MIN, DIST_MAX);
|
||||
}
|
||||
if let Some(a) = w.get(3).and_then(|v| v.parse::<usize>().ok()).and_then(|i| Aim::ALL.get(i)) {
|
||||
self.aim = *a;
|
||||
@@ -174,22 +165,65 @@ impl WaveConfig {
|
||||
}
|
||||
/// A combined strike of about `n`, as `/airdef wave mix n` orders it.
|
||||
pub fn mix(n: u32, dist: f64) -> RaidOrder {
|
||||
let n = n.max(4);
|
||||
let mut kinds = vec![
|
||||
(DroneKind::Gerbera, n / 4 + 1),
|
||||
(DroneKind::Shahed, n / 3 + 1),
|
||||
(DroneKind::Geran3, n / 8 + 1),
|
||||
(DroneKind::Kh101, n / 8 + 1),
|
||||
(DroneKind::Kalibr, n / 10 + 1),
|
||||
(DroneKind::Kh22, n / 16),
|
||||
(DroneKind::Zircon, n / 20),
|
||||
(DroneKind::Iskander, n / 12 + 1),
|
||||
(DroneKind::Kinzhal, n / 16),
|
||||
];
|
||||
if n >= 30 {
|
||||
kinds.push((DroneKind::Oreshnik, 1));
|
||||
}
|
||||
kinds.retain(|k| k.1 > 0);
|
||||
RaidOrder { kinds, approach: Approach::TwoSectors, dist, aim: Aim::Objects }
|
||||
RaidOrder::mix(n, dist)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod catalog_tests {
|
||||
use super::*;
|
||||
use crate::sim::catalog::{AIRCRAFT, UNITS};
|
||||
|
||||
fn assets() -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("assets/airdef")
|
||||
}
|
||||
fn item_exists(item: &str) {
|
||||
let name = item.strip_prefix("airdef:").expect("item namespace");
|
||||
for path in [format!("items/{name}.json"), format!("models/item/{name}.json"), format!("textures/item/{name}.png")] {
|
||||
assert!(assets().join(&path).is_file(), "{item}: missing {path}");
|
||||
}
|
||||
let definition = std::fs::read_to_string(assets().join(format!("items/{name}.json"))).unwrap();
|
||||
assert!(definition.contains(&format!("airdef:item/{name}")), "{item}: wrong item model");
|
||||
let model = std::fs::read_to_string(assets().join(format!("models/item/{name}.json"))).unwrap();
|
||||
assert!(model.contains(&format!("airdef:item/{name}")), "{item}: wrong icon reference");
|
||||
let png = std::fs::read(assets().join(format!("textures/item/{name}.png"))).unwrap();
|
||||
assert!(png.starts_with(b"\x89PNG\r\n\x1a\n"), "{item}: invalid PNG signature");
|
||||
}
|
||||
fn model_exists(model: &str) {
|
||||
let name = model.strip_prefix("airdef:").expect("model namespace");
|
||||
let path = assets().join(format!("models/block/{name}.json"));
|
||||
assert!(path.is_file(), "missing model {}", path.display());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_resources_exist() {
|
||||
for aircraft in AIRCRAFT {
|
||||
model_exists(aircraft.kind.spec().model());
|
||||
if let Some(item) = aircraft.launch_item { item_exists(item); }
|
||||
}
|
||||
for unit in UNITS {
|
||||
item_exists(unit.deploy_item);
|
||||
let p = &unit.kind.spec().parts;
|
||||
model_exists(p.body);
|
||||
for model in [p.launcher, p.pack, p.dish.map(|v| v.0), p.spinner.map(|v| v.0)].into_iter().flatten() { model_exists(model); }
|
||||
for (model, _, _) in p.fixed { model_exists(model); }
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inventory_entries_match_catalog_and_scenario_order_round_trips() {
|
||||
for item in AIRCRAFT.iter().filter_map(|a| a.launch_item).chain(UNITS.iter().map(|u| u.deploy_item)) {
|
||||
assert_eq!(crate::ITEMS.iter().filter(|i| **i == item).count(), 1, "{item}");
|
||||
}
|
||||
for item in crate::ITEMS.iter().filter(|i| i.starts_with("airdef:launch_") || i.starts_with("airdef:deploy_")) {
|
||||
assert!(AIRCRAFT.iter().any(|a| a.launch_item == Some(*item)) || UNITS.iter().any(|u| u.deploy_item == *item), "uncatalogued item {item}");
|
||||
}
|
||||
let mut wave = WaveConfig::default();
|
||||
for (i, count) in wave.counts.iter_mut().enumerate() { *count = i as u32; }
|
||||
let text = wave.text();
|
||||
let mut restored = WaveConfig::default();
|
||||
restored.parse(&text.split_whitespace().collect::<Vec<_>>());
|
||||
assert_eq!(restored.counts, wave.counts);
|
||||
assert_eq!(restored.order().kinds, KINDS.iter().copied().zip(wave.counts).filter(|(_, n)| *n > 0).collect::<Vec<_>>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//! The adapter re-exports the actual core types and keeps deterministic combat traces.
|
||||
use glam::DVec3;
|
||||
|
||||
macro_rules! trace {
|
||||
($sim:path) => {{
|
||||
use $sim::{DroneKind, Ground, Out, Sam, SamKind, Sim};
|
||||
let mut sim = Sim::new(0x87);
|
||||
let id = sim.id();
|
||||
sim.sams.push(Sam::new(id, SamKind::Patriot, DVec3::new(0.0, 64.0, 0.0), 0.0));
|
||||
let mut out = Out::default();
|
||||
for (i, kind) in [DroneKind::Shahed, DroneKind::Kh101, DroneKind::Iskander].into_iter().enumerate() {
|
||||
sim.launch(kind, DVec3::new(i as f64 * 100.0, 110.0, 800.0), -DVec3::Z, DVec3::new(0.0, 64.0, 0.0), &mut out);
|
||||
}
|
||||
let mut ground = Ground::default();
|
||||
let mut trace = Vec::new();
|
||||
for _ in 0..600 {
|
||||
let wanted = ground.take_wanted();
|
||||
ground.answer(wanted.into_iter().map(|(x, z)| (x, z, 64)).collect(), sim.tick);
|
||||
out = Out::default();
|
||||
sim.step(&mut ground, None, &mut out);
|
||||
trace.push(format!("{}:{}:{}:{}:{:?}:{:?}:{:?}:{:?}", sim.tick, sim.launched, sim.kills, sim.hits,
|
||||
sim.sams.iter().map(|s| (s.id, s.missiles, s.fired, s.health)).collect::<Vec<_>>(),
|
||||
sim.drones.iter().map(|d| (d.id, d.pos, d.vel)).collect::<Vec<_>>(),
|
||||
sim.missiles.iter().map(|m| (m.id, m.pos)).collect::<Vec<_>>(), out.messages));
|
||||
}
|
||||
(trace, sim.sams.iter().map(|s| s.fired).sum::<u32>())
|
||||
}};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn adapter_reexports_core_and_combat_trace_is_deterministic() {
|
||||
let _: airdef_core::sim::Sim = airdef::sim::Sim::new(1);
|
||||
let adapter = trace!(airdef::sim);
|
||||
let core = trace!(airdef_core::sim);
|
||||
assert_eq!(adapter, core);
|
||||
assert!(adapter.1 > 0, "the trace must include actual interceptor launches");
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
# Actual .hmod in the engine sandbox, with default fuel/memory limits.
|
||||
# Missing render replies exercise fallback paths, not GPU correctness.
|
||||
[[step]]
|
||||
ticks = 2
|
||||
frames = 2
|
||||
expect.commands = ["airdef"]
|
||||
|
||||
[[step]]
|
||||
command = "airdef deploy patriot"
|
||||
|
||||
[[step]]
|
||||
command = "airdef deploy s400"
|
||||
|
||||
[[step]]
|
||||
command = "airdef wave mix 40 1500"
|
||||
|
||||
[[step]]
|
||||
ticks = 240
|
||||
frames = 120
|
||||
|
||||
[[step]]
|
||||
command = "airdef clear"
|
||||
|
||||
[[step]]
|
||||
ticks = 140
|
||||
frames = 10
|
||||
|
||||
[[step]]
|
||||
command = "airdef replay stop"
|
||||
|
||||
[[step]]
|
||||
title-screen = true
|
||||
ticks = 2
|
||||
frames = 2
|
||||
|
||||
[[step]]
|
||||
player = { x = 100.5, y = 64.0, z = 100.5 }
|
||||
clock = { game-time = 500, day-time = 6000 }
|
||||
ticks = 3
|
||||
frames = 3
|
||||
|
||||
[[step]]
|
||||
reload = true
|
||||
ticks = 2
|
||||
frames = 2
|
||||
expect.commands = ["airdef"]
|
||||
@@ -1,7 +1,7 @@
|
||||
# Акустика AirDef: разбор Sound Physics Remastered и план переноса (#96, этап 1)
|
||||
# Акустика AirDef: реализация, проверки и разбор Sound Physics Remastered (#96)
|
||||
|
||||
Это результат первого этапа: чтение исходников и план. Кода движка и мода этот этап не меняет. Если код
|
||||
разойдётся с текстом, прав код.
|
||||
Сначала приведён текущий статус реализации. Разбор SPR и первоначальный план ниже сохранены как
|
||||
история решений; формулировки будущего времени в плане не заменяют текущий статус. При расхождении прав код.
|
||||
|
||||
- Изучено: https://github.com/henkelmax/sound-physics-remastered, ветка `master`, коммит
|
||||
`453654ece086f40c97712d9016baa4dee7c4f6d2` (2026-10-29), лицензия GPL-3.0 (`LICENSE`). Клон лежит только в
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
## Статус
|
||||
|
||||
**Стадия 1 (прямой звук) сделана**, включается `HORIZON_ACOUSTICS=1` (по умолчанию выключено, звук как был). Стадии 2-3
|
||||
не начаты. Коммит SPR прежний, `453654ec`; атрибуция: `horizon/crates/horizon-client/src/acoustics/THIRD_PARTY_SPR.md`.
|
||||
GPL-файл один: `acoustics/spr_occlusion.rs`; остальное (движок `acoustics.rs`, склейка `game/acoustics.rs`, DSP в `audio.rs`) наше.
|
||||
**Стадии 1 (прямой звук), 2 (отводы эха) и 3 (реверб) сделаны**, включается кнопкой мода или `HORIZON_ACOUSTICS=1` (по умолчанию выключено,
|
||||
звук как был). Коммит SPR прежний, `453654ec`; атрибуция: `horizon/crates/horizon-client/src/acoustics/THIRD_PARTY_SPR.md`.
|
||||
GPL-файлы три: `acoustics/spr_occlusion.rs`, (стадия 2) `acoustics/spr_bounce.rs` и (стадия 3) `acoustics/spr_reverb.rs`; остальное (движок `acoustics.rs`, `acoustics/room.rs`, склейка `game/acoustics.rs`, DSP в `audio.rs` и `audio/reverb.rs`) наше.
|
||||
|
||||
Что вышло и чем отличается от плана выше:
|
||||
|
||||
@@ -27,9 +27,12 @@ GPL-файл один: `acoustics/spr_occlusion.rs`; остальное (дви
|
||||
- Дальность 512 блоков (SPR: ~64), счёт клеток, не времени: 40 тыс. клеток на тик встроенно (новый звук, 1 путь, чтобы взрыв
|
||||
не начинался «ярким»), 400 тыс. на задание рабочего потока (9 путей, одно задание за раз); при съёмке всё встроенно, 600 тыс.
|
||||
клеток на тик. Порядок: по громкости, затем по id; сумма голосов в `mix` теперь тоже по id (раньше порядок HashMap делал дорожку
|
||||
недетерминированной при нескольких голосах).
|
||||
недетерминированной при нескольких голосах). При выходе за дальность/порог слышимости или потере геометрии микшеру явно
|
||||
возвращают обычные `gain=1` и воздушный `cutoff` без старой стены; посылки и эхо отзываются, при возвращении считаются заново.
|
||||
- Кеш по ячейкам 2x2x2 источника и слушателя, 4096 записей; сброс по секциям `World.sound_changes` (как `mod_changes`),
|
||||
по эпохе мира и при переполнении; результат задания, начатого до изменения в его коробке, отбрасывается.
|
||||
по эпохе мира и при переполнении; результат задания, начатого до изменения в его коробке, отбрасывается. Вставка, замена
|
||||
и выгрузка чанка меняют residency-счётчик и инвалидируют затронутые секции и старые worker-задания. Трасса, встретившая
|
||||
Unknown, пересчитывается не позднее чем через 40 тиков, поэтому приехавшая геометрия применяется без движения слушателя.
|
||||
- Воздух: `0.994^расстояние` на верха (EFX по умолчанию, не проверено по OpenAL Soft) — иначе при `acoustics=on` пропадала бы
|
||||
дальность, которую раньше давали `_far`-сэмплы.
|
||||
- Мод: API 21, `render.acoustics()`; при включённой акустике мод играет ближние варианты до 480 блоков (`ACOUSTIC_FAR`), дальше
|
||||
@@ -45,9 +48,136 @@ GPL-файл один: `acoustics/spr_occlusion.rs`; остальное (дви
|
||||
выстрел 1.5 с на 60 блоках, стена камня в 2 блока: ниже 300 Гц -5.2 дБ (SPR: gain 0.55), 300-1500 -7.4, 1500-5000 -19.7, выше 5000 -40.0 дБ.
|
||||
Тесты: `cargo test -p horizon-client --lib acoustics` (формулы, неизвестное, щель, кеш, инвалидация, детерминизм, рабочий поток) и `audio`.
|
||||
|
||||
### Стадия 2: эхо (сделано)
|
||||
|
||||
Что игрок получает: взрыв в ущелье или между домами отвечает настоящим эхо от тех стен, что там есть, с задержкой по
|
||||
настоящему пути; в чистом поле эха нет. Код: `acoustics/echo.rs` (наш, MIT), `acoustics/spr_bounce.rs` (GPL: спираль
|
||||
Фибоначчи, `energyTowardsPlayer`, таблица отражательности), отводы в `audio.rs` (`Echo`), склейка `game/acoustics.rs`
|
||||
(таблица отражательности по состояниям блоков).
|
||||
|
||||
- Метод: 32 луча от источника и 32 от слушателя (направления SPR, длина 300) находят плоскости стен (грани блоков
|
||||
осевые). Для каждой плоскости мнимый источник (зеркальное отражение источника) даёт точный путь `|образ - слушатель|`;
|
||||
отвод оставляем, если точка пересечения этой прямой с плоскостью лежит на твёрдом блоке (стена там правда есть) и пути
|
||||
источник-стена и стена-слушатель свободны (окклюзия < 0.2). Это и есть «задержка по реальному пути»: сверка с формулой
|
||||
до сэмпла.
|
||||
- Задержка отвода = (путь - прямое расстояние) / 343 с: звук играет в момент прихода прямого (задержку распространения
|
||||
держит мод). Уровень = `min(0.85, 2 * energyTowardsPlayer(refl)) * min(1, max(d,4)/путь)`, затем в микшере умножается на
|
||||
громкость голоса и `distance_gain` длины пути; срез верхов по воздуху `0.994^(лишний путь)` (однополюсник на голос-отвод).
|
||||
Окклюзия прямого звука на эхо не действует (оно приходит другим путём).
|
||||
- Срез близких отражений: отвод ближе 30 мс к прямому звуку отбрасывается, до 50 мс плавно входит (иначе стена рядом с
|
||||
игроком даёт гребёнку, а не эхо). Из найденных плоскостей берутся до 6 сильнейших не ближе 40 мс друг к другу.
|
||||
- Кому: `deserves_echo` в `audio.rs`: не петля, не относительный, громкость >= 0.5, дальность (linear) >= 96, длина 0.1-12 с,
|
||||
прошло меньше 70% звука; не более `ECHO_VOICES = 8` активных наборов (самые громкие). При смене приоритетов старый набор
|
||||
отзывается и затухает ~50 мс, поэтому во время ротации кратковременно звучат до 16, затем снова 8. Сотня двигателей эха
|
||||
не получает (петли), сотня выстрелов: восемь самых громких.
|
||||
- Планирование: счёт по клеткам, не по времени. Живьём трассировка идёт на том же рабочем потоке (в задании до 4 трасс и
|
||||
240 тыс. клеток), кеш по блочным ячейкам источника и слушателя (центры ячеек, 256 записей), сброс по секциям, которых
|
||||
касаются точки опоры отводов, и по эпохе; в съёмке трасса синхронная, 480 тыс. клеток на тик. Микшер получает отводы
|
||||
числами (`take_echoes`), новый набор входит за ~50 мс (совпавший по задержке в пределах 3 мс отвод меняет только уровень).
|
||||
Голос после конца сэмпла живёт ещё `max_delay` (хвост), потом останавливается.
|
||||
- Измерено (release, M-серия): трасса `bench_traces`: ущелье 0.054 мс (7 тыс. клеток, 2 отвода), открытое поле 0.115 мс
|
||||
(15 тыс. клеток, 0 отводов), комната 0.022 мс; всё на рабочем потоке, игровой поток платит только клонированием `Arc` и
|
||||
отправкой. Микшер: 108 голосов (100 петель + 8 одноразовых) 0.213 мс -> 0.348 мс с 8 x 6 отводами (+0.135 мс, 1.3% буфера
|
||||
512 кадров). Время игрового потока в `tick_acoustics` и эхо-трасс копится в `status` (`acoustics.tick_ms_*`,
|
||||
`acoustics.echo.ms*`); в игре не снималось.
|
||||
- Проверка без слуха: `audio::tests::export_echo_tracks` (настоящие `Acoustics` и `mix`, щелчок) +
|
||||
`python3 tools/acoustics_check.py --echo-dir папка`: ущелье даёт пики 158.9 и 242.1 мс (ожидалось 158.9 и 242.1),
|
||||
поле ничего, комната один пик 39.9 мс (боковые стены; торцы и потолок ближе 30 мс срезаны). Тесты: `--lib acoustics`
|
||||
(ущелье, поле, комната, стена у слушателя, ширма, «стены нет там, где луч её нашёл», бюджет, детерминизм, кеш, инвалидация,
|
||||
потолок голосов, рабочий поток) и `--lib audio` (отвод стоит на своём кадре до сэмпла, хвост, без щелчка, детерминизм).
|
||||
|
||||
Не слушали: громкость отводов (уровни из формул SPR и 1/r, не подстраивались), пороги `deserves_echo` (угаданы: не знаем,
|
||||
какую громкость и дальность мод ставит выстрелам), срез 30/50 мс и разнос 40 мс на слух, срез верхов отвода. Первые 1-2 тика
|
||||
эхо нового звука ещё нет (трасса на рабочем потоке): теряется только начало отводов с задержкой менее ~100 мс. Лучи стадии
|
||||
видят стены только в 32 направлениях с каждого конца: узкая далёкая стена (меньше нескольких градусов) может не найтись.
|
||||
Косые стены считаются ступеньками: на склоне горы отводов много, остаются сильнейшие с разносом 40 мс. Отводы идут только
|
||||
в мире (реплей читает те же блоки), на съёмке не прогонялось в игре.
|
||||
|
||||
Не сделано / не проверено: запуск в игре и экспорт видео с настоящей сценой (склейка `game/acoustics.rs` — таблица состояний,
|
||||
снимок чанков — компилируется, но в игре не прогонялась); влияние на кадр при налёте; жидкости; дверь как проём (считается
|
||||
ячейкой); потолок памяти снимка. Стадии 2-3 (отводы эха, шины реверба) не начаты.
|
||||
ячейкой); потолок памяти снимка.
|
||||
|
||||
### Стадия 3: реверб (сделано)
|
||||
|
||||
Что игрок получает: под крышей и в тоннеле звук звенит иначе, чем в поле; в чистом поле реверба нет. Код: `acoustics/room.rs`
|
||||
(наш: замер пространства, уровень и спад, посылки), `acoustics/spr_reverb.rs` (GPL: четыре слота SPR, `0.7*0.85`, затухание посылок
|
||||
с расстоянием), `audio/reverb.rs` (наш: DSP общей шины), посылки голосов и шина в `audio.rs` (`Channel.send`, `Mixer.reverb`),
|
||||
склейка в `acoustics.rs` (`take_sends`).
|
||||
|
||||
- Замер пространства (`room::measure`): 48 лучей по сфере Фибоначчи, берутся те, что идут вбок и вверх (пол комнаты не делает), длина 64 блока
|
||||
(столько видит и SPR). Вес попадания `1 - (d/64)^2`. Из них: **замкнутость** (сумма весов / число лучей, 0..1), **размер** (средняя
|
||||
дальность стен) и **отражательность** (средняя по таблице SPR). Слушатель замеряется по своей клетке 1x1x1 (кеш 64, сброс по секциям в
|
||||
кубе ±65 и по эпохе, на рабочем потоке; пока новый замер в пути, остаётся прежний); у звуков с эхом замеряется ещё и пространство
|
||||
источника (в той же трассе эха, свой потолок 60 тыс. клеток). Пространство звука = слушатель 60% + источник 40% (без источника: слушатель).
|
||||
- Уровень и спад (`wet_and_decay`): `wet = smoothstep(0.03, 0.4, замкнутость)`; `спад = замкнутость^2 * (0.4 + 0.1*min(размер,30)) *
|
||||
(0.6 + 0.8*отражательность)`, в пределах 0.15-4.14 с (слоты SPR). Камень (1.5) звенит дольше шерсти (0.1). Ущелье с открытым верхом
|
||||
почти не даёт реверба (его ответ - эхо стадии 2); комната и тоннель - да.
|
||||
- Посылки: спад ложится между двумя соседними слотами SPR (0.15 / 0.55 / 1.68 / 4.14 с, по логарифму) равномерной по мощности
|
||||
перекрёстной кривой (квадрат положения у длинного, иначе по Шрёдеру читается только он), каждый слот выравнен по своему `gain` из
|
||||
таблицы SPR: громкость реверба не растёт с его длиной. Посылка голоса умножается на `distance_fade` SPR (`1 - d/(1.5*дальность)`).
|
||||
- Шина (`audio/reverb.rs`): 4 слота, в каждом пред-задержка (late delay SPR), 2 allpass, 4 гребёнки с lowpass в петле (коэффициент из
|
||||
`decay_hf_ratio` SPR на 5 кГц). Левое ухо берёт гребёнки 0 и 2, правое 1 и 3 (разные хвосты), моно = среднее всех четырёх. Голос
|
||||
кладёт в шину сигнал после стены (окклюзии) и до панорамы; посылки голоса плавно (постоянная 0.3 с) идут к цели, так что вход в тоннель
|
||||
и выход из него без щелчка. Шина считается и без голосов (хвост звучит после конца хлопка), слот без входа и хвоста не считается и
|
||||
обнуляется (без денормалей), шина сбрасывается, когда затихла.
|
||||
- Выключение (`set_acoustics(false)`): посылки идут к нулю за ~1-2 с, хвост доигрывает сам; `stop_all` (и `film_begin/film_end`) шину сбрасывают.
|
||||
Съёмка: замер синхронный (счёт клеток), шина считается без случайности и от часов не зависит - дорожка та же при каждом прогоне
|
||||
(`audio::tests::reverb_rendering_is_deterministic`).
|
||||
- Измерено (release, M-серия, буфер 512 кадров = 10.67 мс): шина с четырьмя занятыми слотами 0.017 мс; 100 голосов 0.119 мс без реверба ->
|
||||
+0.04 мс с реверб-посылками (25 или 100 голосов, около 0.4% буфера); замер пространства: комната 0.0075 мс (392 клетки), тоннель
|
||||
0.0037, ущелье 0.033 (2208), поле 0.035 мс (2315); всё на рабочем потоке. Счётчики в `status`: `acoustics.reverb` (замеры, попадания
|
||||
кеша, клетки, посылки, замкнутость и спад сейчас); в игре не снимались.
|
||||
- Проверка без слуха: `audio::tests::export_reverb_tracks` (настоящие `Acoustics`, посылки, `mix`, щелчок в комнате 24x10x24, тоннеле 5x4,
|
||||
ущелье, поле) + `python3 tools/acoustics_check.py --reverb-dir папка`. Порядок **поле < ущелье < тоннель < комната** (в плане было
|
||||
«ущелье длиннее всех»; открытый верх ущелья этого не даёт):
|
||||
|
||||
| сцена | спад пространства, с | RT60 по посылкам, с | RT60 измерено, с | хвост/щелчок, дБ |
|
||||
|---|---|---|---|---|
|
||||
| поле | 0.15 | - | хвоста нет | нет |
|
||||
| ущелье | 0.15 | 0.15 | 0.10 | -47.7 |
|
||||
| тоннель | 0.79 | 0.97 | 0.87 | -11.7 |
|
||||
| комната | 1.37 | 1.67 | 1.39 | -7.7 |
|
||||
|
||||
Колонка «по посылкам» - сумма экспонент слотов по Шрёдеру (`room::effective_decay`), измеренное лежит на 10-20% ниже (lowpass в петле
|
||||
укорачивает). Каждый слот отдельно (импульс в одну шину, `reverb::tests::each_slot_decays_at_its_time`) читается в 0.5-1.15 от
|
||||
номинала. Тесты: `--lib acoustics` (замеры комната/тоннель/ущелье/поле, порядок спадов, гладкость посылок, кеш, сброс, рабочий поток)
|
||||
и `--lib audio` (хвост после конца звука и сброс шины, нулевая посылка - ровно прежний вывод, без щелчка при смене и выключении,
|
||||
детерминизм, выключение и `film_begin`).
|
||||
|
||||
Не слушали: громкость реверба (`WET = 1.6` и уровни слотов не подстраивались на слух; в комнате хвост -8 дБ от щелчка по энергии), формулы
|
||||
замкнутости/спада (пороги 0.03-0.4, веса, перекрёстная кривая - выбраны по замерам сцен, не по слуху), звучание гребёнок (металличность на
|
||||
коротких слотах, пред-задержки), окраска левого и правого, 60/40 слушатель/источник, скорость скольжения посылок 0.3 с. Замкнутость
|
||||
по 24 лучам вверх-вбок грубая: узкая щель в крыше может не найтись, деревья и листва (окклюзия 0) пространства не делают. Реверб не
|
||||
получают относительные звуки (интерфейс, музыка) и звуки дальше 512 блоков; эхо-отводы в шину не идут. `gain_hf` слотов, `density`,
|
||||
отражения слота SPR не перенесены.
|
||||
|
||||
|
||||
### Повторная проверка на закреплённом движке (2026-11-02)
|
||||
|
||||
Движок `209559080` (baseline v0.2.97), macOS arm64/Apple M5. Три ignored export fixtures
|
||||
действительно выполнены через Acoustics и Mixer, затем проверены `tools/acoustics_check.py`.
|
||||
Это процедурные тестовые сигналы без аудиоустройства, не субъективное прослушивание игры.
|
||||
|
||||
- Два блока камня: изменение энергии ниже 300 Гц **−5.2 dB**, 300–1500 **−7.4 dB**,
|
||||
1500–5000 **−19.7 dB**, выше 5000 **−40.0 dB**. Проверка spectral wall/open прошла.
|
||||
- Echo fixture: ущелье **158.9 и 242.1 ms**, комната **39.9 ms**, поле — без отражений.
|
||||
Задержки совпали с расчётными в допуске **1 ms**.
|
||||
- Reverb fixture: измеренный RT60 ущелья **0.10 s**, тоннеля **0.87 s**, комнаты **1.39 s**;
|
||||
в поле хвост не обнаружен. Для тоннеля/комнаты прогноз по sends **0.97/1.67 s**.
|
||||
Проверка использовала текущий допуск анализатора **35%**, а не целевые 15% из раннего плана.
|
||||
|
||||
Экспорт echo и reverb нужно выполнять **в разные каталоги**: оба пишут field.raw/gorge.raw/room.raw,
|
||||
иначе один эксперимент перезапишет сигналы другого. Пример (из horizon/):
|
||||
|
||||
```sh
|
||||
mkdir -p /tmp/airdef-echo
|
||||
HORIZON_ACOUSTICS_OUT=/tmp/airdef-echo cargo test -p horizon-client --lib audio::tests::export_echo_tracks -- --ignored
|
||||
# Из корня AirDef:
|
||||
python3 tools/acoustics_check.py --echo-dir /tmp/airdef-echo
|
||||
```
|
||||
|
||||
Лицензии/атрибуция включены в `docs/licenses/`; game bundle workflows копируют GPL text,
|
||||
Horizon MIT notice и THIRD_PARTY_SPR.md в архив рядом с build-identity.json.
|
||||
|
||||
## 1. Как SPR идёт от источника к результату
|
||||
|
||||
@@ -351,14 +481,15 @@ GPL-файл один: `acoustics/spr_occlusion.rs`; остальное (дви
|
||||
классов не даёт скачка; сброс при `film_begin/film_end`; лимитер не срабатывает на нормальном налёте.
|
||||
- Проверка без слуха: импульсный отклик шины из `film_mix` → RT60 по спаду (`tools/acoustics_check.py`) для четырёх
|
||||
классов сцены (поле, ущелье, комната, тоннель) — таблица в отчёте; спад должен упорядочиться
|
||||
поле < комната < тоннель < ущелье; налёт 100 источников: пиковый уровень, число срабатываний лимитера, CPU.
|
||||
поле < ущелье < тоннель < комната (у ущелья открытый верх); налёт 100 источников: пиковый уровень, число срабатываний лимитера, CPU.
|
||||
- Критерий: хвост после конца исходного хлопка длится ожидаемое RT60 и не продолжается после смены мира.
|
||||
|
||||
### Стадия 4 (по #96): движущиеся источники и интеграция с #95/cinema
|
||||
|
||||
Пересчёт по интервалам (§3.5), `acoustics=on` ⇒ мод играет близкие варианты (§3.7), категории и слушатель реплея.
|
||||
Зависит от #95 (постоянные источники): ждать его слияния, `audio.rs` сейчас правит другой агент — не начинать
|
||||
стадию 1 до него, чтобы не конфликтовать по `Channel`/`mix`.
|
||||
Постоянные источники #95 реализованы: live и replay объявляют движущиеся engine voices;
|
||||
мод передаёт их host через sound-sources, listener фильма берётся из его камеры. Общий DSP находится
|
||||
в движке. Необходимая оставшаяся приёмка — массовый живой бой, прослушивание и настоящий MP4 с
|
||||
проверкой смены listener/мира и бюджета; наличие общего кода не заменяет эти проверки.
|
||||
|
||||
## Что оказалось неверным или неточным в тексте #96
|
||||
|
||||
@@ -370,3 +501,5 @@ GPL-файл один: `acoustics/spr_occlusion.rs`; остальное (дви
|
||||
- Коммит из #96 (`76f680eb…`) не найден в недавней истории `master`; разбор сделан по `453654ec`.
|
||||
- Мод-API `query-rays` с политикой `sound` для этого недостаточно (нет материала и полупрозрачных долей), поэтому
|
||||
акустика в клиенте; мод только сообщает события (#95).
|
||||
|
||||
Включается кнопкой в меню мода (ещё → «Акустика»), сохраняется с миром. `HORIZON_ACOUSTICS=1` задаёт только начальное значение.
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# Закреплённый движок AirDef
|
||||
|
||||
Движок: https://gitea.maoniao.team/chexit/horizon-airdef, ветка `airdef`.
|
||||
AirDef хранит точный SHA как gitlink `horizon/`; новый push движка не меняет старые сборки мода.
|
||||
История upstream и всех 44 прежних патчей сохранена в форке. Старые patch-файлы и HORIZON_COMMIT
|
||||
доступны в истории AirDef и больше не являются вторым источником движка. Baseline описан в AIRDEF-FORK.md.
|
||||
|
||||
## Windows: обновление и запуск
|
||||
|
||||
```powershell
|
||||
git fetch origin
|
||||
git switch kimi-work
|
||||
git pull --ff-only
|
||||
python tools/airdef.py all
|
||||
python tools/airdef.py play
|
||||
```
|
||||
|
||||
Первое клонирование: `git clone --recurse-submodules https://gitea.maoniao.team/chexit/airdef.git`.
|
||||
Обычный clone тоже поддерживается: `python tools/airdef.py fork` или команда submodule выше.
|
||||
`all` инициализирует зависимость сам, включая переход со старой папки `horizon/`.
|
||||
Для чистого checkout можно отдельно выполнить `git submodule update --init --recursive`. Нужны Git, Python и Rust согласно INSTALL.md.
|
||||
Сборка клиента и мод устанавливаются в обычное место; ресурсы Minecraft готовятся отдельно по INSTALL.md.
|
||||
|
||||
При первом переходе со старого отдельного clone `horizon/` скрипт сохраняет его Git-историю и ветки,
|
||||
переводит в сабмодуль и получает закреплённый SHA. Если там есть изменения при другом SHA,
|
||||
обновление останавливается с объяснением: сначала закоммитьте/сохраните свои изменения.
|
||||
Скрипт не выполняет reset --hard или clean. Чистый checkout может остаться detached HEAD — это нормально для зависимости.
|
||||
|
||||
## Изменение движка
|
||||
|
||||
1. В `horizon/` создать рабочую ветку от закреплённого SHA. Проверить изменение и push в репозиторий движка.
|
||||
2. В AirDef выполнить `git add horizon`, проверить мод/игру, коммитить обновление gitlink отдельно.
|
||||
3. Push AirDef выполняется после движка. Не коммитить Git URL с токенами.
|
||||
4. Для возврата выбрать прежний commit AirDef и выполнить `git submodule update --init --recursive`.
|
||||
|
||||
Упаковщик собирается repo-local в `.horizon-cache/packer/<engine-identity>/`, глобальный
|
||||
`cargo-horizon-mod` не используется. Изменения tracked-исходников движка входят в identity.
|
||||
Рядом с airdef.hmod записывается build-identity.json: SHA AirDef, pin/identity движка,
|
||||
SHA256 WIT и артефакта. API-диагностика остаётся в `python tools/airdef.py check`.
|
||||
Нативные тесты не заменяют отдельную игровую проверку графики, звука и экспорта.
|
||||
|
||||
## Проверка настоящего WASM
|
||||
|
||||
`python tools/airdef.py test-wasm` собирает `.hmod` и запускает `tests/*.toml` в настоящем
|
||||
runtime закреплённого движка. Используется временное storage; игровые миры не нужны.
|
||||
Сценарий проверяет загрузку/регистрацию команды, два комплекса, налёт, tick/frame,
|
||||
выход из мира и перезагрузку мода. Действуют лимиты runtime: 64 MiB linear memory,
|
||||
300 млн fuel на tick, 10 млн на frame, 1 млрд на event, 2 млрд на init.
|
||||
Это проверка ABI и fallback при отсутствии render replies; она не измеряет GPU,
|
||||
не подтверждает акустику/MP4 и не заменяет максимальный боевой полигон.
|
||||
|
||||
В CI проверка assets входит в лёгкий build. Wasmtime tier вынесен в ручной workflow
|
||||
`wasm-contract`, чтобы не компилировать тяжёлый runtime на каждом push слабого общего runner.
|
||||
@@ -19,12 +19,11 @@ AirDef работает на своей сборке (форке) Horizon: в н
|
||||
|
||||
## 2а. Готовая сборка из релиза (проще)
|
||||
|
||||
В репозитории → **Releases** → последний `build-N`. В каждом релизе есть `airdef.hmod` — сам мод (один для всех
|
||||
ОС). Игру-форк сервер сборок не собирает сам: это тяжело для него. Архивы с игрой появляются в релизе, только если
|
||||
их собрали вручную:
|
||||
- `airdef-linux-x86_64.tar.gz` — Actions → **game** → Run workflow, указать тег релиза;
|
||||
- `airdef-windows-x86_64.zip`, `airdef-macos-arm64.tar.gz` — Actions → **desktop** (нужны раннеры с метками
|
||||
`windows-latest` / `macos-latest`).
|
||||
В репозитории → **Releases**. Большие релизы `vX.Y.Z` содержат готовую игру для Windows,
|
||||
`airdef-windows-x86_64.zip`: она собирается на сервере только по тегу версии (`git tag v0.3.0`, `git push origin v0.3.0`).
|
||||
Сборки `build-N` выходят на каждый коммит, в них только `airdef.hmod`, сам мод (один для всех ОС).
|
||||
Архив Linux собирается вручную: Actions → **game** → Run workflow с тегом `build-N`; macOS: Actions → **desktop**
|
||||
(нужен раннер с меткой `macos-latest`).
|
||||
|
||||
Нет архива для твоей ОС — способ 2б: игра соберётся у тебя, а мод можно взять из релиза или собрать там же.
|
||||
|
||||
@@ -77,8 +76,11 @@ python3 tools/airdef.py play # или: python3 tools/airdef.py play --world "
|
||||
|
||||
Клон по HTTPS не требует ключа. Если у тебя есть SSH-ключ в Gitea, можно и так: `git clone ssh://git@gitea.maoniao.team:2222/chexit/airdef.git`.
|
||||
|
||||
Шаги по отдельности: `fork` (скачать Horizon и наложить патчи `horizon-patches/`), `game` (собрать игру),
|
||||
Шаги по отдельности: `fork` (инициализировать закреплённый сабмодуль `horizon/`), `game` (собрать игру),
|
||||
`mod` (собрать `airdef.hmod`), `install` (положить мод в папку игры и включить), `play`.
|
||||
`check` говорит прямо, совпадают ли форк, упаковщик мода, уровень API мода с игрой и ресурсы, и подсказывает,
|
||||
что запустить, если нет (`python3 tools/airdef.py check`; Windows: `py tools\airdef.py check`). Версия Rust
|
||||
фиксирована в `rust-toolchain.toml`: rustup сам поставит её и цель wasm32 при первой сборке.
|
||||
|
||||
## 3. В игре
|
||||
|
||||
@@ -86,6 +88,7 @@ python3 tools/airdef.py play # или: python3 tools/airdef.py play --world "
|
||||
пересоберутся сами, если патчи изменились.
|
||||
- Windows: нужна видеокарта с Vulkan. Экспорт фильмов (`/airdef replay export`) требует `ffmpeg` в PATH или `HORIZON_FFMPEG`.
|
||||
- Шейдеры уровня шейдерпаков: `/airdef shader hd`. Для слабой видеокарты перед запуском: `$env:HORIZON_HD_SCALE="0.67"` (PowerShell).
|
||||
- Преграды и эхо для звука: меню мода → «Акустика».
|
||||
- Создай мир с читами (или включи их через «Открыть для сети»): мод выдаёт пульты и взрывы командами.
|
||||
- `/airdef give` — пульты, **N** — командный пункт (роли ПВО), **K** — монитор комплекса,
|
||||
`/airdef wave mix 20` — налёт. Подробнее — README.
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
# Пилотный художественный проход (#115)
|
||||
|
||||
Это промежуточные модели для оценки направления, а не завершённая переработка всего набора.
|
||||
Изменены С-400 (шасси и ТПК), Гепард (корпус и башня), Шахед. Исходный шумный камуфляж
|
||||
в основном сохранён: следующий художественный этап — спокойнее материалы, яснее крупные формы
|
||||
и плотность пикселей. Число элементов само по себе не является доказательством качества.
|
||||
|
||||
| Пилот | До | После |
|
||||
|---|---|---|
|
||||
| С-400 |  |  |
|
||||
| Гепард |  |  |
|
||||
| Шахед |  |  |
|
||||
|
||||
## Что изменено
|
||||
|
||||
- С-400: округлые ступенчатые колёса без звёздчатого пересечения двух квадратов, ступицы,
|
||||
разделённые кабины со стеклом/крышей, читаемая рама; четыре ТПК с округлым сечением и обвязкой.
|
||||
- Гепард: наклонная лобовая часть, отдельная верхняя плита, катки на непрерывной гусенице,
|
||||
скошенные стороны башни и люки. Подвижные пушки и обзорная антенна используют прежние крепления.
|
||||
- Шахед: более плавный контур носа/крыла, тоньше крыло, переработаны законцовки и задняя часть;
|
||||
пропеллер остаётся отдельной анимируемой частью. Это стилизация существующего игрового прототипа.
|
||||
- Наземные пилоты имеют соответствующие обгоревшие варианты.
|
||||
|
||||
Геометрия сделана внутри проекта; исходные игровые текстуры не заимствованы из внешних фотографий.
|
||||
Визуальные референсы: [Гепард, Bundeswehr](https://www.bundeswehr.de/de/meldungen/flugabwehrkanonenpanzer-gepard-5400072),
|
||||
[51П6, фотография автора Mike1979 Russia](https://commons.wikimedia.org/wiki/File:51P6_launcher_S-400_Triumf_Army-2022_2022-08-20_2416.jpg).
|
||||
Это ориентиры внешнего вида, не утверждение о точном воспроизведении конкретной модификации.
|
||||
|
||||
## Метод сравнения и ограничения
|
||||
|
||||
Настоящий Horizon/AirDef, macOS arm64, Apple M5/Metal, offscreen 2560×1440. Временный игровой home,
|
||||
ровный полигон, ясная погода, day_time 6000, spectator. Для пары используются одинаковые WASM,
|
||||
движок и сцена: в пакете «до» заменены только девять JSON пилотов на их версии из `4a3500f`.
|
||||
Скриншоты не ретушировались. Камера проверена по status после переноса:
|
||||
|
||||
| Пилот | Позиция камеры | yaw / pitch |
|
||||
|---|---|---|
|
||||
| С-400 | -4, 114, 25 | -30 / 12 |
|
||||
| Гепард | 20, 114, 25 | 30 / 18 |
|
||||
| Шахед | 28, 115, 27 | 35 / 30 |
|
||||
|
||||
РЛС продолжает вращаться; её угол и фаза облаков в паре могут различаться. Пилот Шахеда показан как
|
||||
статичная модель для сравнения геометрии. Здесь не проверены все ракурсы, полёт/пуск, повреждение
|
||||
в кино и массовая нагрузка. Native HDR не включался; HD — отдельный режим рендера мода.
|
||||
|
||||
[Общий вид до, HD](media/model-pilots/before-overview-hd.png) ·
|
||||
[Общий вид после, HD](media/model-pilots/after-overview-hd.png) ·
|
||||
[После ночью, HD](media/model-pilots/after-overview-night-hd.png).
|
||||
|
||||
## Бюджет и редактирование
|
||||
|
||||
| Часть | Элементов до | После |
|
||||
|---|---:|---:|
|
||||
| s400_chassis | 35 | 78 |
|
||||
| s400_tubes | 6 | 29 |
|
||||
| gepard_hull | 8 | 55 |
|
||||
| gepard_turret | 12 | 11 |
|
||||
| shahed | 26 | 29 |
|
||||
|
||||
Новые runtime IDs или отдельные части сцены не добавлены. Рост числа граней требует замера на массовом
|
||||
сценарии; отсутствие роста draw calls или сохранение FPS этим отчётом не обещается.
|
||||
|
||||
Редактируемые JSON: `airdef-mod/source-assets/assets/airdef/models/block/`.
|
||||
Необязательный экспортёр: `python tools/pilot_models.py` (перезаписывает только эти пилоты).
|
||||
Установка/валидация: `python tools/gen_models.py`. Габариты для навигации вычисляются из итоговой
|
||||
геометрии после authored overrides, включая поворот элементов. Стандартная regeneration сохраняет
|
||||
авторские исходники. Полный набор и художественная приёмка остаются в #115.
|
||||
@@ -0,0 +1,59 @@
|
||||
# Карта репозитория
|
||||
|
||||
Что здесь что: исходники, сгенерированное, архив. Порядок сборки и установки — в `README.md` и `docs/INSTALL.md`.
|
||||
|
||||
## Исходники (правим руками)
|
||||
|
||||
| Путь | Что это |
|
||||
|---|---|
|
||||
| `airdef-mod/src/`, `airdef-mod/shaders/` | Мод на Rust (WASM) для форка Horizon |
|
||||
| `airdef-mod/Cargo.toml`, `horizon-mod.toml` | Сборка мода |
|
||||
| `airdef-mod/tests/`, `airdef-mod/examples/` | Тесты и примеры |
|
||||
| `airdef-mod/NOTES-terrain-guidance.md` | Рабочие заметки по рельефу |
|
||||
| `horizon/`, `.gitmodules` | Закреплённый сабмодуль отдельного форка Horizon |
|
||||
| `tools/airdef.py` | Сборка мода и установка в папку игры |
|
||||
| `tools/gen_models.py`, `tools/gen_tex.py`, `tools/gen_sounds.py` | Генераторы контента (см. ниже) |
|
||||
| `tools/acoustics_check.py`, `tools/hd_bench.py` | Проверочные скрипты |
|
||||
| `docs/` | Документация (этот файл, `INSTALL.md`, `ACOUSTICS.md`, `HD-RENDERER.md`) |
|
||||
| `install.sh`, `play.sh`, `dist/` | Установка и запуск |
|
||||
| `run-home/`, `run-home-bench/`, `run-home-smoke/` | Тестовые игровые папки, не часть мода |
|
||||
| `screenshots/` | Скриншоты |
|
||||
|
||||
## Сгенерировано (не правим руками)
|
||||
|
||||
`tools/gen_models.py` создаёт:
|
||||
|
||||
- `airdef-mod/assets/airdef/{blockstates,models,items,lang,textures}/`
|
||||
- `airdef-mod/data/airdef/horizon/`
|
||||
|
||||
Список этих файлов с sha256 лежит в `airdef-mod/generated-manifest.txt`. Генератор пишет во временный каталог, проверяет набор (ссылки моделей, blockstate и текстур; JSON; PNG; координаты элементов; парность lang) и только потом переносит файлы. При ошибке проверки ничего не записывается. Файл, который правили вручную или который занимает путь генерируемого, останавливает запуск (`КОНФЛИКТ`).
|
||||
|
||||
Команды:
|
||||
|
||||
- `python3 -m pip install -r tools/requirements.txt` — зависимости генератора (закреплён Pillow).
|
||||
- `python3 tools/gen_models.py` — перегенерировать.
|
||||
- `python3 tools/gen_models.py --check` — только сравнить, выход 1 при различиях.
|
||||
|
||||
`tools/gen_sounds.py` создаёт `airdef-mod/assets/airdef/sounds/*.ogg` и `sounds.json`. Этот генератор не использует manifest и не входит в проверку `gen_models.py`.
|
||||
|
||||
## Архив: `legacy/`
|
||||
|
||||
Первая версия мода: датапак на командах (`legacy/airdef-datapack/`) и контент-мод (`legacy/airdef-content/`) с генератором `legacy/gen_content.py`. Ничего из текущей сборки на него не ссылается: ни скрипты в `tools/`, ни `install.sh`, ни `Cargo.toml`, ни исходники мода. Не собирается и не устанавливается. Оставлен как история. Не редактировать и не удалять без отдельного решения.
|
||||
|
||||
`legacy/airdef-content/data/` сейчас не отслеживается git и не входит в эту карту.
|
||||
|
||||
## Авторские и сгенерированные ресурсы
|
||||
|
||||
- `tools/gen_models.py` генерирует геометрию моделей и управляет сборкой набора.
|
||||
- `tools/airdef_assets/registry.py` создаёт blockstate/item registry, локализацию и data JSON.
|
||||
- `tools/airdef_assets/bounds.py` экспортирует габариты итоговых моделей для headless-навигации; authored overrides входят в расчёт.
|
||||
- `tools/gen_tex.py` отвечает за вывод процедурных текстур и иконок; переиспользуемые примитивы палитры также находятся здесь.
|
||||
- `tools/airdef_assets/texture_catalog.py` связывает стабильную палитру и процедурные функции с текстурами моделей, не смешивая каталог с геометрией.
|
||||
- `tools/airdef_assets/icons.py` содержит каталог предметов и чистую функцию рендера иконки с явными параметрами `(name, color, seed)`.
|
||||
- `tools/airdef_assets/pipeline.py` проверяет manifest, рассчитывает безопасный план обновления и откатывает записи при исключении.
|
||||
- `airdef-mod/source-assets/assets/airdef/` — источник авторских переопределений. Генератор объединяет его с процедурными ресурсами во временном дереве, проверяет ссылки/JSON/PNG, затем устанавливает runtime-файлы.
|
||||
- `airdef-mod/assets/` и `airdef-mod/data/` — упакованные generated output. Не редактируйте их вручную; добавляйте авторские исходники в `source-assets`.
|
||||
- `airdef-mod/generated-manifest.txt` хранит SHA-256 только для управляемого результата. Неизменённые старые outputs можно заменить или удалить; посторонние и вручную правленные файлы блокируют конфликтующий запуск.
|
||||
- `python3 tools/test_gen_assets.py` проверяет manifest, защиту ручных файлов, откат при ошибке записи, детерминизм и полный цикл authored icon override/validation.
|
||||
|
||||
`airdef-mod/src/sim/generated_bounds.rs` также управляется manifest: это данные геометрии, а не файл для ручного редактирования. Пилотный арт и сравнения — в `docs/MODEL-PILOTS.md`.
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Ludovic Marie and the Horizon contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,15 @@
|
||||
# Notices for the bundled Horizon AirDef fork
|
||||
|
||||
Upstream Horizon portions retain their MIT notices (HORIZON-MIT.txt).
|
||||
The fork includes SPR-derived GPL-3.0-only source files. Its existing notice explains the GPL terms
|
||||
for a combined build: `horizon/crates/horizon-client/src/acoustics/THIRD_PARTY_SPR.md`.
|
||||
Game archives also include that notice and Horizon THIRD_PARTY_NOTICES.md.
|
||||
GPL-3.0.txt is the unmodified license from Sound Physics Remastered commit
|
||||
453654ece086f40c97712d9016baa4dee7c4f6d2:
|
||||
https://github.com/henkelmax/sound-physics-remastered/blob/453654ece086f40c97712d9016baa4dee7c4f6d2/LICENSE
|
||||
|
||||
Corresponding fork source: https://gitea.maoniao.team/chexit/horizon-airdef
|
||||
AirDef source and build scripts: https://gitea.maoniao.team/chexit/airdef
|
||||
The exact engine revision is the `horizon/` gitlink; packaged build-identity.json records the pin.
|
||||
Build instructions: docs/ENGINE.md and docs/INSTALL.md in the AirDef source.
|
||||
This notice does not change the licenses of the respective source files.
|
||||
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 2.3 MiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 1.7 MiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
@@ -1,577 +0,0 @@
|
||||
From 3de7a6875140a107e28563cc44489b55f5794517 Mon Sep 17 00:00:00 2001
|
||||
From: chexit <chexit@duck.com>
|
||||
Date: Wed, 28 Oct 2026 12:37:45 +0300
|
||||
Subject: [PATCH 01/39] Mod API (AirDef fork): world models, client particles,
|
||||
sounds, ground heights
|
||||
|
||||
render.set-models draws block models with an interpolated pose per id;
|
||||
render.spawn-particles and render.play-sound act on this client only;
|
||||
render.query-ground / render.ground read the motion-blocking heightmap.
|
||||
|
||||
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||||
---
|
||||
crates/horizon-client/src/game.rs | 2 +
|
||||
crates/horizon-client/src/game/mod_models.rs | 197 +++++++++++++++++++
|
||||
crates/horizon-client/src/game/mods.rs | 24 +++
|
||||
crates/horizon-mod-sdk/wit/horizon.wit | 58 ++++++
|
||||
crates/horizon-mods/src/api_level.rs | 10 +-
|
||||
crates/horizon-mods/src/runtime.rs | 116 ++++++++++-
|
||||
6 files changed, 403 insertions(+), 4 deletions(-)
|
||||
create mode 100644 crates/horizon-client/src/game/mod_models.rs
|
||||
|
||||
diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs
|
||||
index 1d7bbbbd6..7c342cd86 100644
|
||||
--- a/crates/horizon-client/src/game.rs
|
||||
+++ b/crates/horizon-client/src/game.rs
|
||||
@@ -115,6 +115,7 @@ mod mod_input;
|
||||
#[cfg(feature = "mods")]
|
||||
mod mod_recipes;
|
||||
mod mod_render;
|
||||
+mod mod_models;
|
||||
mod mods;
|
||||
mod mount_menu;
|
||||
mod mounts;
|
||||
@@ -8232,6 +8233,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
self.mark_entity(out.len(), "");
|
||||
+ self.mod_model_geometry(camera, alpha, &mut out);
|
||||
self.moving_piston_geometry(camera, alpha, &mut out);
|
||||
self.mark_entity(out.len(), "minecraft:tnt");
|
||||
self.tnt_geometry(camera, alpha, &mut out);
|
||||
diff --git a/crates/horizon-client/src/game/mod_models.rs b/crates/horizon-client/src/game/mod_models.rs
|
||||
new file mode 100644
|
||||
index 000000000..3c7f9345c
|
||||
--- /dev/null
|
||||
+++ b/crates/horizon-client/src/game/mod_models.rs
|
||||
@@ -0,0 +1,197 @@
|
||||
+//! AirDef fork: capability `render`'s world models, client particles and
|
||||
+//! sounds. A mod sets its models once a tick (`render.set-models`); each id
|
||||
+//! keeps its last two poses and is drawn between them every frame, so models
|
||||
+//! move smoothly at any frame rate.
|
||||
+use super::Game;
|
||||
+#[cfg(feature = "mods")]
|
||||
+use {
|
||||
+ glam::{DVec3, Mat4, Quat, Vec3},
|
||||
+ horizon_client::{
|
||||
+ mesher::Vertex,
|
||||
+ particles::{ParticleOptions, ParticleType},
|
||||
+ },
|
||||
+ horizon_core::random::RandomSource,
|
||||
+ horizon_mods::ParticleSpawn,
|
||||
+ horizon_world::registry::BlockStateId,
|
||||
+ std::collections::HashMap,
|
||||
+};
|
||||
+
|
||||
+/// One model of a mod: where it was a tick ago and where it is now.
|
||||
+#[cfg(feature = "mods")]
|
||||
+struct Pose {
|
||||
+ state: BlockStateId,
|
||||
+ previous: DVec3,
|
||||
+ position: DVec3,
|
||||
+ old_rotation: Quat,
|
||||
+ rotation: Quat,
|
||||
+ old_scale: f32,
|
||||
+ scale: f32,
|
||||
+ glow: bool,
|
||||
+}
|
||||
+
|
||||
+/// The models the running mods keep, by (mod, id).
|
||||
+#[cfg(feature = "mods")]
|
||||
+#[derive(Default)]
|
||||
+pub(super) struct ModModels {
|
||||
+ poses: HashMap<(usize, u32), Pose>,
|
||||
+ /// Block states by the text mods name them, parsed once.
|
||||
+ states: HashMap<String, Option<BlockStateId>>,
|
||||
+}
|
||||
+
|
||||
+/// Full brightness: sky and block light 15, as the entity shader packs them.
|
||||
+#[cfg(feature = "mods")]
|
||||
+const GLOW: u32 = 240 | (240 << 8);
|
||||
+
|
||||
+/// A build without the `mods` feature draws no mod models.
|
||||
+#[cfg(not(feature = "mods"))]
|
||||
+impl Game<'_> {
|
||||
+ pub(super) fn mod_model_geometry(
|
||||
+ &self,
|
||||
+ _camera: glam::DVec3,
|
||||
+ _alpha: f64,
|
||||
+ _out: &mut Vec<horizon_client::mesher::Vertex>,
|
||||
+ ) {
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+#[cfg(feature = "mods")]
|
||||
+impl Game<'_> {
|
||||
+ /// After the mods' tick: each model's new pose, its last one kept to
|
||||
+ /// draw from. Ids no longer set are dropped; new ones start where they
|
||||
+ /// are.
|
||||
+ pub(super) fn update_mod_models(&mut self) {
|
||||
+ let mut seen: Vec<(usize, u32)> = Vec::new();
|
||||
+ let registry = &self.pack.assets.registry;
|
||||
+ let models = &mut self.mods.models;
|
||||
+ for (owner, m) in self.mods.mods.models() {
|
||||
+ let state = *models
|
||||
+ .states
|
||||
+ .entry(m.model.clone())
|
||||
+ .or_insert_with(|| super::render_control::parse_state(registry, &m.model).ok());
|
||||
+ let Some(state) = state else {
|
||||
+ continue;
|
||||
+ };
|
||||
+ let key = (owner, m.id);
|
||||
+ seen.push(key);
|
||||
+ let position = DVec3::new(m.x, m.y, m.z);
|
||||
+ let (x, y, z, w) = m.rotation;
|
||||
+ let rotation = Quat::from_xyzw(x, y, z, w);
|
||||
+ match models.poses.get_mut(&key) {
|
||||
+ Some(p) => {
|
||||
+ p.previous = p.position;
|
||||
+ p.old_rotation = p.rotation;
|
||||
+ p.old_scale = p.scale;
|
||||
+ p.position = position;
|
||||
+ p.rotation = rotation;
|
||||
+ p.scale = m.scale;
|
||||
+ p.state = state;
|
||||
+ p.glow = m.glow;
|
||||
+ }
|
||||
+ None => {
|
||||
+ models.poses.insert(
|
||||
+ key,
|
||||
+ Pose {
|
||||
+ state,
|
||||
+ previous: position,
|
||||
+ position,
|
||||
+ old_rotation: rotation,
|
||||
+ rotation,
|
||||
+ old_scale: m.scale,
|
||||
+ scale: m.scale,
|
||||
+ glow: m.glow,
|
||||
+ },
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if seen.len() != models.poses.len() {
|
||||
+ let seen: std::collections::HashSet<_> = seen.into_iter().collect();
|
||||
+ models.poses.retain(|k, _| seen.contains(k));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /// Draws every mod model between its last two poses, lit by the world
|
||||
+ /// (or at full brightness), its faces shaded by its own rotation.
|
||||
+ pub(super) fn mod_model_geometry(&self, camera: DVec3, alpha: f64, out: &mut Vec<Vertex>) {
|
||||
+ if self.mods.models.poses.is_empty() {
|
||||
+ return;
|
||||
+ }
|
||||
+ let t = alpha.clamp(0.0, 1.0);
|
||||
+ for p in self.mods.models.poses.values() {
|
||||
+ let at = p.previous.lerp(p.position, t);
|
||||
+ // Far models are culled by distance; the view frustum does the rest.
|
||||
+ if at.distance_squared(camera) > 512.0 * 512.0 {
|
||||
+ continue;
|
||||
+ }
|
||||
+ let rotation = p.old_rotation.slerp(p.rotation, t as f32);
|
||||
+ let scale = p.old_scale + (p.scale - p.old_scale) * t as f32;
|
||||
+ if scale <= 0.0 {
|
||||
+ continue;
|
||||
+ }
|
||||
+ let light = if p.glow {
|
||||
+ GLOW
|
||||
+ } else {
|
||||
+ let l = self.world.light(
|
||||
+ at.x.floor() as i32,
|
||||
+ at.y.floor() as i32,
|
||||
+ at.z.floor() as i32,
|
||||
+ );
|
||||
+ (u32::from(l >> 4) * 16) | ((u32::from(l & 15) * 16) << 8)
|
||||
+ };
|
||||
+ // The model's unit cube turned and scaled about its centre.
|
||||
+ let m = Mat4::from_scale_rotation_translation(
|
||||
+ Vec3::splat(scale),
|
||||
+ rotation,
|
||||
+ (at - camera).as_vec3(),
|
||||
+ ) * Mat4::from_translation(Vec3::splat(-0.5));
|
||||
+ self.block_model_vertices(p.state, 0, m, light, true, out);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /// `render.spawn-particles`: made on this client at once.
|
||||
+ pub(super) fn mod_particles(&mut self, particles: Vec<ParticleSpawn>) {
|
||||
+ for s in particles {
|
||||
+ let Some(ty) = ParticleType::from_name(&s.particle) else {
|
||||
+ continue;
|
||||
+ };
|
||||
+ let rgb = [
|
||||
+ ((s.color >> 16) & 255) as f32 / 255.0,
|
||||
+ ((s.color >> 8) & 255) as f32 / 255.0,
|
||||
+ (s.color & 255) as f32 / 255.0,
|
||||
+ ];
|
||||
+ let rgb = if s.color == 0 { [1.0; 3] } else { rgb };
|
||||
+ let options = match ty {
|
||||
+ ParticleType::Dust => ParticleOptions::dust(rgb, s.scale),
|
||||
+ ParticleType::EntityEffect | ParticleType::TintedLeaves | ParticleType::Flash => {
|
||||
+ ParticleOptions::colored(ty, [rgb[0], rgb[1], rgb[2], 1.0])
|
||||
+ }
|
||||
+ ParticleType::Block
|
||||
+ | ParticleType::FallingDust
|
||||
+ | ParticleType::DustPillar
|
||||
+ | ParticleType::BlockMarker
|
||||
+ | ParticleType::Item
|
||||
+ | ParticleType::ItemSlime
|
||||
+ | ParticleType::ItemSnowball
|
||||
+ | ParticleType::ItemCobweb => continue,
|
||||
+ _ => ParticleOptions::simple(ty),
|
||||
+ };
|
||||
+ let (sx, sy, sz) = s.spread;
|
||||
+ let (vx, vy, vz) = s.velocity;
|
||||
+ let speed = f64::from(s.speed);
|
||||
+ for _ in 0..s.count {
|
||||
+ let r = self.particles.random();
|
||||
+ let p = [
|
||||
+ s.x + r.next_gaussian() * f64::from(sx),
|
||||
+ s.y + r.next_gaussian() * f64::from(sy),
|
||||
+ s.z + r.next_gaussian() * f64::from(sz),
|
||||
+ ];
|
||||
+ let v = [
|
||||
+ f64::from(vx) + r.next_gaussian() * speed,
|
||||
+ f64::from(vy) + r.next_gaussian() * speed,
|
||||
+ f64::from(vz) + r.next_gaussian() * speed,
|
||||
+ ];
|
||||
+ self.particles.create(&options, p, v);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/crates/horizon-client/src/game/mods.rs b/crates/horizon-client/src/game/mods.rs
|
||||
index 52dc46fe0..3eef96aa3 100644
|
||||
--- a/crates/horizon-client/src/game/mods.rs
|
||||
+++ b/crates/horizon-client/src/game/mods.rs
|
||||
@@ -46,6 +46,9 @@ pub(super) struct ModsState {
|
||||
/// Capability `render`'s camera shakes.
|
||||
#[cfg(feature = "mods")]
|
||||
pub(super) shake: super::mod_render::Shake,
|
||||
+ /// Capability `render`'s world models (AirDef fork), with their last poses.
|
||||
+ #[cfg(feature = "mods")]
|
||||
+ pub(super) models: super::mod_models::ModModels,
|
||||
/// `--dev-mod PATH`: always on, reloaded when rebuilt.
|
||||
pub(super) dev: Vec<PathBuf>,
|
||||
/// When dev mods were last checked for a rebuild.
|
||||
@@ -596,9 +599,17 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
self.tick_mod_use();
|
||||
+ for (i, columns) in self.mods.mods.take_ground_queries() {
|
||||
+ let ground = columns
|
||||
+ .into_iter()
|
||||
+ .map(|(x, z)| (x, z, self.rain_height(x, z)))
|
||||
+ .collect();
|
||||
+ self.mods.mods.answer_ground(i, ground);
|
||||
+ }
|
||||
let snapshot = self.mod_snapshot();
|
||||
self.mods.mods.set_snapshot(snapshot);
|
||||
self.mods.mods.tick(self.ticks);
|
||||
+ self.update_mod_models();
|
||||
self.show_mod_output();
|
||||
}
|
||||
/// Restarts the dev mods rebuilt since the last check, once a second.
|
||||
@@ -716,6 +727,19 @@ impl Game<'_> {
|
||||
self.mods.shake.add(strength, seconds);
|
||||
continue;
|
||||
}
|
||||
+ Output::Particles { particles } => {
|
||||
+ self.mod_particles(particles);
|
||||
+ continue;
|
||||
+ }
|
||||
+ Output::Sound {
|
||||
+ event,
|
||||
+ at,
|
||||
+ volume,
|
||||
+ pitch,
|
||||
+ } => {
|
||||
+ self.audio.play(&event, Some(at), volume, pitch);
|
||||
+ continue;
|
||||
+ }
|
||||
Output::PlaceRecipe { book_id, all } => {
|
||||
self.mod_place_recipe(book_id, all);
|
||||
continue;
|
||||
diff --git a/crates/horizon-mod-sdk/wit/horizon.wit b/crates/horizon-mod-sdk/wit/horizon.wit
|
||||
index 0680cce92..89d1906a9 100644
|
||||
--- a/crates/horizon-mod-sdk/wit/horizon.wit
|
||||
+++ b/crates/horizon-mod-sdk/wit/horizon.wit
|
||||
@@ -429,6 +429,64 @@ interface render {
|
||||
/// Distance setting, when on, wins. One far terrain shows at a time: the
|
||||
/// first loaded mod's.
|
||||
set-far-terrain: func(far-terrain: option<far-terrain>);
|
||||
+ /// A block model drawn in the world (AirDef fork).
|
||||
+ record model-instance {
|
||||
+ /// Stays the same while the object lives: the game moves an id
|
||||
+ /// smoothly from where the last `set-models` put it.
|
||||
+ id: u32,
|
||||
+ /// A block state as commands write it (`airdef:shahed`,
|
||||
+ /// `minecraft:stone`, `minecraft:furnace[facing=east]`): its block
|
||||
+ /// model is drawn. An unknown one draws nothing.
|
||||
+ model: string,
|
||||
+ /// Where the model's centre is, in blocks.
|
||||
+ x: f64,
|
||||
+ y: f64,
|
||||
+ z: f64,
|
||||
+ /// Rotation about the model's centre: a quaternion (x, y, z, w).
|
||||
+ rotation: tuple<f32, f32, f32, f32>,
|
||||
+ /// Uniform scale, 1.0 a block (0 to 64).
|
||||
+ scale: f32,
|
||||
+ /// Drawn at full brightness, whatever the light where it is.
|
||||
+ glow: bool,
|
||||
+ }
|
||||
+ /// Replaces the mod's models: up to 4096, drawn with the world's
|
||||
+ /// entities until replaced. Call it once a tick: the game interpolates
|
||||
+ /// each id between its last two positions and rotations every frame.
|
||||
+ /// An empty list removes them.
|
||||
+ set-models: func(models: list<model-instance>);
|
||||
+ /// Particles to spawn on this client (AirDef fork).
|
||||
+ record particle-spawn {
|
||||
+ /// As `/particle` names the type: `minecraft:flame`, `minecraft:dust`.
|
||||
+ particle: string,
|
||||
+ x: f64,
|
||||
+ y: f64,
|
||||
+ z: f64,
|
||||
+ /// Gaussian spread round the point, per axis, in blocks.
|
||||
+ spread: tuple<f32, f32, f32>,
|
||||
+ /// Every particle's starting velocity, blocks a tick.
|
||||
+ velocity: tuple<f32, f32, f32>,
|
||||
+ /// Gaussian speed added to it per axis.
|
||||
+ speed: f32,
|
||||
+ /// 1 to 256.
|
||||
+ count: u32,
|
||||
+ /// 0xRRGGBB for dust and coloured types (0: white).
|
||||
+ color: u32,
|
||||
+ /// Dust size (0.01 to 4).
|
||||
+ scale: f32,
|
||||
+ }
|
||||
+ /// Spawns particles on this client only: no command, no server.
|
||||
+ /// At most 512 spawns a call.
|
||||
+ spawn-particles: func(particles: list<particle-spawn>);
|
||||
+ /// Plays a sound event (`minecraft:entity.generic.explode`,
|
||||
+ /// `<mod>:<name>`) at a point on this client.
|
||||
+ play-sound: func(event: string, x: f64, y: f64, z: f64, volume: f32, pitch: f32);
|
||||
+ /// Asks for the ground height of these columns (x, z): at most 512 a
|
||||
+ /// tick, answered by `ground` from the next tick on.
|
||||
+ query-ground: func(columns: list<tuple<s32, s32>>);
|
||||
+ /// The answers to the last tick's `query-ground`: (x, z, y), y one above
|
||||
+ /// the highest block that blocks motion or holds a fluid, as the motion
|
||||
+ /// blocking heightmap; -64 where the chunk isn't loaded.
|
||||
+ ground: func() -> list<tuple<s32, s32, s32>>;
|
||||
}
|
||||
|
||||
/// What the game calls. Only the hooks `init` asks for are ever called.
|
||||
diff --git a/crates/horizon-mods/src/api_level.rs b/crates/horizon-mods/src/api_level.rs
|
||||
index 045a9346b..b64792eaa 100644
|
||||
--- a/crates/horizon-mods/src/api_level.rs
|
||||
+++ b/crates/horizon-mods/src/api_level.rs
|
||||
@@ -7,13 +7,13 @@
|
||||
//! version's level so the launcher can tell before it installs.
|
||||
|
||||
/// The newest level this Horizon serves.
|
||||
-pub const LEVEL: u32 = 7;
|
||||
+pub const LEVEL: u32 = 8;
|
||||
|
||||
/// Every function the game offers mods, as `interface.function`, with its
|
||||
/// level. Level 0 is the contract of Horizon 0.2.67 to 0.2.69. A new
|
||||
/// function takes the next level and raises [`LEVEL`] (the `api_reference`
|
||||
/// test fails until it is listed here).
|
||||
-pub const FUNCTIONS: [(&str, u32); 46] = [
|
||||
+pub const FUNCTIONS: [(&str, u32); 51] = [
|
||||
("log.write", 0),
|
||||
("game.get-player", 0),
|
||||
("game.get-clock", 0),
|
||||
@@ -60,6 +60,12 @@ pub const FUNCTIONS: [(&str, u32); 46] = [
|
||||
("recipes.place", 6),
|
||||
("recipes.give", 6),
|
||||
("render.set-far-terrain", 7),
|
||||
+ // AirDef fork: world models, client particles and sounds.
|
||||
+ ("render.set-models", 8),
|
||||
+ ("render.spawn-particles", 8),
|
||||
+ ("render.play-sound", 8),
|
||||
+ ("render.query-ground", 8),
|
||||
+ ("render.ground", 8),
|
||||
];
|
||||
|
||||
/// What the game's program carries so the launcher can read its level
|
||||
diff --git a/crates/horizon-mods/src/runtime.rs b/crates/horizon-mods/src/runtime.rs
|
||||
index cff44722b..317cd4f06 100644
|
||||
--- a/crates/horizon-mods/src/runtime.rs
|
||||
+++ b/crates/horizon-mods/src/runtime.rs
|
||||
@@ -71,6 +71,7 @@ mod render_bindings {
|
||||
wasmtime::component::bindgen!({
|
||||
path: "../horizon-mod-sdk/wit",
|
||||
world: "render-host",
|
||||
+ additional_derives: [PartialEq],
|
||||
});
|
||||
}
|
||||
use render_bindings::horizon::mods::input;
|
||||
@@ -79,8 +80,8 @@ pub use render_bindings::horizon::mods::input::{Event as InputEvent, HeldItem, I
|
||||
/// What capability `render` asks the game to draw (WIT `interface render`).
|
||||
pub use render_bindings::horizon::mods::render::{
|
||||
Corner as RenderCorner, FarTerrain as ModFarTerrain, FillShape, FrameRate, ItemShape,
|
||||
- Minimap as ModMinimap, Point as RenderPoint, QuadShape, Rect as RenderRect, Shape, SpriteShape,
|
||||
- TextShape, Zoom as ModZoom,
|
||||
+ Minimap as ModMinimap, ModelInstance, ParticleSpawn, Point as RenderPoint, QuadShape,
|
||||
+ Rect as RenderRect, Shape, SpriteShape, TextShape, Zoom as ModZoom,
|
||||
};
|
||||
use render_bindings::{RenderHost, horizon::mods::render};
|
||||
/// Capability `recipes`'s imports (docs/mods.md): the game's recipes and items.
|
||||
@@ -238,6 +239,15 @@ pub enum Output {
|
||||
CloseScreen { owner: usize },
|
||||
/// `render.shake`: strength 0 to 1, fading out over `seconds` (≤ 10).
|
||||
Shake { strength: f32, seconds: f32 },
|
||||
+ /// `render.spawn-particles` (AirDef fork): particles to make on this client.
|
||||
+ Particles { particles: Vec<ParticleSpawn> },
|
||||
+ /// `render.play-sound` (AirDef fork): a sound event at a point on this client.
|
||||
+ Sound {
|
||||
+ event: String,
|
||||
+ at: [f64; 3],
|
||||
+ volume: f32,
|
||||
+ pitch: f32,
|
||||
+ },
|
||||
/// `recipes.place`: the recipe book's click on this display id, all of
|
||||
/// it when `all`.
|
||||
PlaceRecipe { book_id: i32, all: bool },
|
||||
@@ -416,6 +426,12 @@ struct State {
|
||||
minimap: Option<ModMinimap>,
|
||||
/// Capability `render`'s far terrain, when the mod draws one.
|
||||
far_terrain: Option<ModFarTerrain>,
|
||||
+ /// Capability `render`'s world models (AirDef fork), drawn until replaced.
|
||||
+ models: Vec<ModelInstance>,
|
||||
+ /// `render.query-ground`'s columns, answered before the next tick.
|
||||
+ ground_queries: Vec<(i32, i32)>,
|
||||
+ /// The game's answers to them.
|
||||
+ ground: Vec<(i32, i32, i32)>,
|
||||
input: InputState,
|
||||
browser: BrowserState,
|
||||
/// Capability `storage`'s folder; made on first `set`.
|
||||
@@ -619,6 +635,9 @@ impl Mods {
|
||||
zoom: None,
|
||||
minimap: None,
|
||||
far_terrain: None,
|
||||
+ models: Vec::new(),
|
||||
+ ground_queries: Vec::new(),
|
||||
+ ground: Vec::new(),
|
||||
input: InputState::default(),
|
||||
browser: BrowserState::default(),
|
||||
data_dir,
|
||||
@@ -1173,6 +1192,32 @@ impl Mods {
|
||||
.iter()
|
||||
.find_map(|e| e.run.as_ref()?.store.data().minimap)
|
||||
}
|
||||
+ /// Every running mod's world models (AirDef fork), with the mod's index
|
||||
+ /// so ids of different mods don't meet.
|
||||
+ pub fn models(&self) -> impl Iterator<Item = (usize, &ModelInstance)> {
|
||||
+ self.entries.iter().enumerate().flat_map(|(i, e)| {
|
||||
+ e.run
|
||||
+ .iter()
|
||||
+ .flat_map(move |r| r.store.data().models.iter().map(move |m| (i, m)))
|
||||
+ })
|
||||
+ }
|
||||
+ /// The columns each running mod asked the ground height of, taken.
|
||||
+ pub fn take_ground_queries(&mut self) -> Vec<(usize, Vec<(i32, i32)>)> {
|
||||
+ self.entries
|
||||
+ .iter_mut()
|
||||
+ .enumerate()
|
||||
+ .filter_map(|(i, e)| {
|
||||
+ let q = std::mem::take(&mut e.run.as_mut()?.store.data_mut().ground_queries);
|
||||
+ (!q.is_empty()).then_some((i, q))
|
||||
+ })
|
||||
+ .collect()
|
||||
+ }
|
||||
+ /// Mod `i`'s answers to its ground queries, for its next calls.
|
||||
+ pub fn answer_ground(&mut self, i: usize, ground: Vec<(i32, i32, i32)>) {
|
||||
+ if let Some(run) = self.entries.get_mut(i).and_then(|e| e.run.as_mut()) {
|
||||
+ run.store.data_mut().ground = ground;
|
||||
+ }
|
||||
+ }
|
||||
/// The far terrain the first running mod draws (capability `render`).
|
||||
pub fn far_terrain(&self) -> Option<ModFarTerrain> {
|
||||
self.entries
|
||||
@@ -1734,6 +1779,12 @@ const MINIMAP_SIZE: (f32, f32) = (16.0, 256.0);
|
||||
const MINIMAP_SCALE: (f32, f32) = (0.5, 4.0);
|
||||
/// `set-far-terrain`'s distance in chunks, as the LOD Distance setting's.
|
||||
const FAR_TERRAIN_DISTANCE: (u32, u32) = (64, 1024);
|
||||
+/// `set-models`' most models a mod keeps, and their largest scale.
|
||||
+const MODELS: usize = 4096;
|
||||
+const MODEL_SCALE: f32 = 64.0;
|
||||
+/// `spawn-particles`' most spawns a call and particles a spawn.
|
||||
+const PARTICLE_SPAWNS: usize = 512;
|
||||
+const PARTICLES_PER_SPAWN: u32 = 256;
|
||||
|
||||
/// A mod's corner panel: shapes in a `width` × `height` box the game
|
||||
/// places in `corner`, stacked with the other overlays.
|
||||
@@ -1851,6 +1902,67 @@ impl render::Host for State {
|
||||
self.out.push(Output::Shake { strength, seconds });
|
||||
}
|
||||
}
|
||||
+ fn set_models(&mut self, models: Vec<ModelInstance>) {
|
||||
+ let finite = |v: f64| v.is_finite() && v.abs() < 30_000_000.0;
|
||||
+ self.models = models
|
||||
+ .into_iter()
|
||||
+ .filter(|m| finite(m.x) && finite(m.y) && finite(m.z))
|
||||
+ .take(MODELS)
|
||||
+ .map(|mut m| {
|
||||
+ let (x, y, z, w) = m.rotation;
|
||||
+ let len = (x * x + y * y + z * z + w * w).sqrt();
|
||||
+ m.rotation = if len.is_finite() && len > 1e-6 {
|
||||
+ (x / len, y / len, z / len, w / len)
|
||||
+ } else {
|
||||
+ (0.0, 0.0, 0.0, 1.0)
|
||||
+ };
|
||||
+ m.scale = if m.scale.is_finite() {
|
||||
+ m.scale.clamp(0.0, MODEL_SCALE)
|
||||
+ } else {
|
||||
+ 1.0
|
||||
+ };
|
||||
+ m.model = clip(m.model);
|
||||
+ m
|
||||
+ })
|
||||
+ .collect();
|
||||
+ }
|
||||
+ fn spawn_particles(&mut self, particles: Vec<ParticleSpawn>) {
|
||||
+ let particles: Vec<ParticleSpawn> = particles
|
||||
+ .into_iter()
|
||||
+ .filter(|p| p.x.is_finite() && p.y.is_finite() && p.z.is_finite())
|
||||
+ .take(PARTICLE_SPAWNS)
|
||||
+ .map(|mut p| {
|
||||
+ p.count = p.count.clamp(1, PARTICLES_PER_SPAWN);
|
||||
+ p.particle = clip(p.particle);
|
||||
+ p
|
||||
+ })
|
||||
+ .collect();
|
||||
+ if !particles.is_empty() {
|
||||
+ self.out.push(Output::Particles { particles });
|
||||
+ }
|
||||
+ }
|
||||
+ fn query_ground(&mut self, columns: Vec<(i32, i32)>) {
|
||||
+ let room = 512usize.saturating_sub(self.ground_queries.len());
|
||||
+ self.ground_queries.extend(columns.into_iter().take(room));
|
||||
+ }
|
||||
+ fn ground(&mut self) -> Vec<(i32, i32, i32)> {
|
||||
+ self.ground.clone()
|
||||
+ }
|
||||
+ fn play_sound(&mut self, event: String, x: f64, y: f64, z: f64, volume: f32, pitch: f32) {
|
||||
+ if !(x.is_finite() && y.is_finite() && z.is_finite()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ let ok = |v: f32, max: f32| if v.is_finite() { v.clamp(0.0, max) } else { 1.0 };
|
||||
+ let sounds = self.out.iter().filter(|o| matches!(o, Output::Sound { .. })).count();
|
||||
+ if sounds < 64 {
|
||||
+ self.out.push(Output::Sound {
|
||||
+ event: clip(event),
|
||||
+ at: [x, y, z],
|
||||
+ volume: ok(volume, 16.0),
|
||||
+ pitch: ok(pitch, 2.0),
|
||||
+ });
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
impl command::Host for State {
|
||||
--
|
||||
2.54.0 (Apple Git-157)
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
From a6d64e6415bf618539af464e521091e72b72d72f Mon Sep 17 00:00:00 2001
|
||||
From: chexit <chexit@duck.com>
|
||||
Date: Wed, 28 Oct 2026 12:39:45 +0300
|
||||
Subject: [PATCH 02/39] cargo-horizon-mod: report particles and sounds
|
||||
|
||||
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||||
---
|
||||
crates/cargo-horizon-mod/src/check.rs | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/crates/cargo-horizon-mod/src/check.rs b/crates/cargo-horizon-mod/src/check.rs
|
||||
index 988ba826d..6a91fda28 100644
|
||||
--- a/crates/cargo-horizon-mod/src/check.rs
|
||||
+++ b/crates/cargo-horizon-mod/src/check.rs
|
||||
@@ -280,6 +280,10 @@ fn play(path: &Path, report: &mut Report) -> Result<(), String> {
|
||||
Output::Shake { strength, seconds } => {
|
||||
format!("shook the camera: {strength:.2} for {seconds:.1} s")
|
||||
}
|
||||
+ Output::Particles { particles } => {
|
||||
+ format!("spawned {} particle group(s)", particles.len())
|
||||
+ }
|
||||
+ Output::Sound { event, .. } => format!("played {event}"),
|
||||
});
|
||||
}
|
||||
let shapes = mods.hud_shapes().count();
|
||||
--
|
||||
2.54.0 (Apple Git-157)
|
||||
|
||||
@@ -1,603 +0,0 @@
|
||||
From ee79b3562feebe51959a01f1585a9e85bd53ccb5 Mon Sep 17 00:00:00 2001
|
||||
From: chexit <chexit@duck.com>
|
||||
Date: Wed, 28 Oct 2026 13:33:10 +0300
|
||||
Subject: [PATCH 03/39] Mod API (AirDef fork): full-screen post pass for mods
|
||||
|
||||
render.set-post compiles a mod's WGSL after a prelude (camera matrices,
|
||||
time, 256 vec4 of params, the world's colour and depth) and runs it after
|
||||
the world, before the hand and the HUD; render.set-params feeds it.
|
||||
|
||||
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||||
---
|
||||
crates/horizon-client/src/game.rs | 1 +
|
||||
crates/horizon-client/src/game/mod_models.rs | 28 ++
|
||||
crates/horizon-client/src/gfx.rs | 35 +-
|
||||
crates/horizon-client/src/gfx/mod_post.rs | 320 +++++++++++++++++++
|
||||
crates/horizon-mod-sdk/wit/horizon.wit | 13 +
|
||||
crates/horizon-mods/src/api_level.rs | 5 +-
|
||||
crates/horizon-mods/src/runtime.rs | 28 ++
|
||||
7 files changed, 428 insertions(+), 2 deletions(-)
|
||||
create mode 100644 crates/horizon-client/src/gfx/mod_post.rs
|
||||
|
||||
diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs
|
||||
index 7c342cd86..ca6a8c266 100644
|
||||
--- a/crates/horizon-client/src/game.rs
|
||||
+++ b/crates/horizon-client/src/game.rs
|
||||
@@ -11527,6 +11527,7 @@ impl Game<'_> {
|
||||
return Ok(false);
|
||||
};
|
||||
let alpha = self.clock.fraction();
|
||||
+ self.apply_mod_post(alpha as f32);
|
||||
// Camera.getCameraEntityPartialTicks: the view, the hand and the
|
||||
// player's own model stay smooth while the level is frozen.
|
||||
let camera_alpha = self.clock.camera_fraction();
|
||||
diff --git a/crates/horizon-client/src/game/mod_models.rs b/crates/horizon-client/src/game/mod_models.rs
|
||||
index 3c7f9345c..be00ea4c7 100644
|
||||
--- a/crates/horizon-client/src/game/mod_models.rs
|
||||
+++ b/crates/horizon-client/src/game/mod_models.rs
|
||||
@@ -36,6 +36,8 @@ pub(super) struct ModModels {
|
||||
poses: HashMap<(usize, u32), Pose>,
|
||||
/// Block states by the text mods name them, parsed once.
|
||||
states: HashMap<String, Option<BlockStateId>>,
|
||||
+ /// The version of the mod post pass the renderer has (0: none).
|
||||
+ post: u64,
|
||||
}
|
||||
|
||||
/// Full brightness: sky and block light 15, as the entity shader packs them.
|
||||
@@ -52,6 +54,7 @@ impl Game<'_> {
|
||||
_out: &mut Vec<horizon_client::mesher::Vertex>,
|
||||
) {
|
||||
}
|
||||
+ pub(super) fn apply_mod_post(&mut self, _partial: f32) {}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mods")]
|
||||
@@ -148,6 +151,31 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
+ /// Before each frame: the renderer gets the mod's post pass when it changed, and its
|
||||
+ /// parameters. A pass that doesn't compile is reported once; the last good one runs on.
|
||||
+ pub(super) fn apply_mod_post(&mut self, partial: f32) {
|
||||
+ let (version, source, params) = match self.mods.mods.post() {
|
||||
+ Some((v, s, p)) => (v, Some(s.to_owned()), p.to_vec()),
|
||||
+ None => (0, None, Vec::new()),
|
||||
+ };
|
||||
+ let mut error = None;
|
||||
+ let Some(renderer) = self.renderer.as_mut() else { return };
|
||||
+ if version != self.mods.models.post {
|
||||
+ self.mods.models.post = version;
|
||||
+ error = renderer.set_mod_post(source.as_deref()).err();
|
||||
+ }
|
||||
+ if version != 0 {
|
||||
+ renderer.set_mod_params(¶ms, partial);
|
||||
+ }
|
||||
+ if let Some(e) = error {
|
||||
+ log::warn!("Horizon: mod post pass refused: {e}");
|
||||
+ self.system_message(
|
||||
+ horizon_client::text::Text::literal(format!("Mod shader error: {e}"))
|
||||
+ .with_color(horizon_client::text::RED),
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/// `render.spawn-particles`: made on this client at once.
|
||||
pub(super) fn mod_particles(&mut self, particles: Vec<ParticleSpawn>) {
|
||||
for s in particles {
|
||||
diff --git a/crates/horizon-client/src/gfx.rs b/crates/horizon-client/src/gfx.rs
|
||||
index beb8b9060..4c5005615 100644
|
||||
--- a/crates/horizon-client/src/gfx.rs
|
||||
+++ b/crates/horizon-client/src/gfx.rs
|
||||
@@ -77,6 +77,7 @@ mod lod;
|
||||
mod native_material;
|
||||
mod native_pack;
|
||||
mod native_post;
|
||||
+mod mod_post;
|
||||
mod native_sky;
|
||||
mod occlusion;
|
||||
mod pack_atlas;
|
||||
@@ -543,6 +544,9 @@ pub struct Renderer {
|
||||
pack_post: Option<(i32, Option<pack_post::PackPost>)>,
|
||||
/// The post passes of one of Horizon's own shader packs; never beside `pack_post`'s.
|
||||
native: Option<native_pack::NativePack>,
|
||||
+ /// AirDef fork: a mod's post pass, its parameters and the partial tick they are for.
|
||||
+ mod_post: Option<mod_post::ModPost>,
|
||||
+ mod_params: (Vec<f32>, f32),
|
||||
/// Time the shader pack's passes on the GPU (F3, or `HORIZON_SHADER_PACK_TIMING`).
|
||||
pass_timing: bool,
|
||||
/// The entity vertices Horizon draws itself while a shader pack draws the others.
|
||||
@@ -2646,6 +2650,8 @@ impl Renderer {
|
||||
hdr_output,
|
||||
pack_post: None,
|
||||
native: None,
|
||||
+ mod_post: None,
|
||||
+ mod_params: (Vec::new(), 0.0),
|
||||
pass_timing: pack_timing::PassTiming::logging(),
|
||||
pack_entity_rest: Vec::new(),
|
||||
cloud_bindings,
|
||||
@@ -3287,6 +3293,24 @@ impl Renderer {
|
||||
report
|
||||
}
|
||||
/// Drops the running shader pack, of either kind.
|
||||
+ /// AirDef fork: runs a mod's post pass from now on (`None`: none). On an error the pass
|
||||
+ /// that ran keeps running.
|
||||
+ pub fn set_mod_post(&mut self, source: Option<&str>) -> std::result::Result<(), String> {
|
||||
+ match source {
|
||||
+ None => self.mod_post = None,
|
||||
+ Some(source) => {
|
||||
+ let format = self.config.format.remove_srgb_suffix();
|
||||
+ self.mod_post = Some(mod_post::ModPost::new(&self.device, source, format)?);
|
||||
+ }
|
||||
+ }
|
||||
+ Ok(())
|
||||
+ }
|
||||
+ /// AirDef fork: the mod post pass's parameters for the next frames.
|
||||
+ pub fn set_mod_params(&mut self, params: &[f32], partial: f32) {
|
||||
+ self.mod_params.0.clear();
|
||||
+ self.mod_params.0.extend_from_slice(¶ms[..params.len().min(mod_post::PARAMS)]);
|
||||
+ self.mod_params.1 = partial;
|
||||
+ }
|
||||
pub fn drop_shader_packs(&mut self) {
|
||||
self.pack_post = None;
|
||||
self.native = None;
|
||||
@@ -4456,7 +4480,9 @@ impl Renderer {
|
||||
.then(|| pack_timing::PassTiming::new(&self.device, &self.queue))
|
||||
.flatten();
|
||||
}
|
||||
- let pack_reads_world = pack_post || native_post;
|
||||
+ // AirDef fork: a mod's post pass reads the world target too.
|
||||
+ let mod_post = !frame.title && !pack_post && !native_post && self.mod_post.is_some();
|
||||
+ let pack_reads_world = pack_post || native_post || mod_post;
|
||||
// The pack's program reads the vertices this frame's draws bind.
|
||||
let pack_draws_terrain = pack_terrain && flat_frame == self.pack_terrain_flat;
|
||||
// The shadow camera's lists, drawn by the pack's shadow programs.
|
||||
@@ -5026,6 +5052,13 @@ impl Renderer {
|
||||
size,
|
||||
native.timing.as_mut(),
|
||||
);
|
||||
+ } else if let Some((color, depth)) = &scaled
|
||||
+ && mod_post
|
||||
+ && let Some(post) = &mut self.mod_post
|
||||
+ {
|
||||
+ let size = self.world_post.size().unwrap_or([1, 1]);
|
||||
+ post.write(&self.queue, frame, size, &self.mod_params.0, self.mod_params.1);
|
||||
+ post.run(&self.device, &mut encoder, (color, depth), &view_target);
|
||||
} else if scaled.is_some() {
|
||||
self.world_post.finish(&mut encoder, &view_target);
|
||||
}
|
||||
diff --git a/crates/horizon-client/src/gfx/mod_post.rs b/crates/horizon-client/src/gfx/mod_post.rs
|
||||
new file mode 100644
|
||||
index 000000000..497cff854
|
||||
--- /dev/null
|
||||
+++ b/crates/horizon-client/src/gfx/mod_post.rs
|
||||
@@ -0,0 +1,320 @@
|
||||
+//! AirDef fork: a mod's full-screen post pass (`render.set-post`). The mod's WGSL is put after
|
||||
+//! a prelude that declares the frame (camera matrices, time, the mod's parameters) and the
|
||||
+//! world's colour and depth; it defines `fn post(uv: vec2<f32>, pixel: vec2<f32>) -> vec4<f32>`.
|
||||
+//! The pass runs after the world and before the hand and the HUD, reading the scaled world
|
||||
+//! target and drawing onto the screen.
|
||||
+
|
||||
+use glam::Mat4;
|
||||
+
|
||||
+use super::Frame;
|
||||
+
|
||||
+/// Floats of mod parameters (256 vec4).
|
||||
+pub const PARAMS: usize = 1024;
|
||||
+
|
||||
+/// The uniform the prelude's `frame` reads.
|
||||
+#[repr(C)]
|
||||
+#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
|
||||
+struct ModFrame {
|
||||
+ view_proj: [[f32; 4]; 4],
|
||||
+ view_inverse: [[f32; 4]; 4],
|
||||
+ projection_inverse: [[f32; 4]; 4],
|
||||
+ /// xyz: the camera; w: unused.
|
||||
+ camera: [f32; 4],
|
||||
+ /// width, height, 1/width, 1/height.
|
||||
+ resolution: [f32; 4],
|
||||
+ /// seconds (wraps hourly), the partial tick, the sun's height, unused.
|
||||
+ time: [f32; 4],
|
||||
+ /// The sun's direction.
|
||||
+ sun: [f32; 4],
|
||||
+ params: [[f32; 4]; PARAMS / 4],
|
||||
+}
|
||||
+
|
||||
+pub const PRELUDE: &str = r#"
|
||||
+struct ModFrame {
|
||||
+ view_proj: mat4x4<f32>,
|
||||
+ view_inverse: mat4x4<f32>,
|
||||
+ projection_inverse: mat4x4<f32>,
|
||||
+ camera: vec4<f32>,
|
||||
+ resolution: vec4<f32>,
|
||||
+ time: vec4<f32>,
|
||||
+ sun: vec4<f32>,
|
||||
+ params: array<vec4<f32>, 256>,
|
||||
+}
|
||||
+@group(0) @binding(0) var<uniform> frame: ModFrame;
|
||||
+@group(0) @binding(1) var scene_color: texture_2d<f32>;
|
||||
+@group(0) @binding(2) var scene_depth: texture_depth_2d;
|
||||
+@group(0) @binding(3) var linear_sampler: sampler;
|
||||
+
|
||||
+struct HorizonModPostOut {
|
||||
+ @builtin(position) position: vec4<f32>,
|
||||
+ @location(0) uv: vec2<f32>,
|
||||
+}
|
||||
+
|
||||
+@vertex
|
||||
+fn horizon_mod_post_vs(@builtin(vertex_index) i: u32) -> HorizonModPostOut {
|
||||
+ let uv = vec2<f32>(f32((i << 1u) & 2u), f32(i & 2u));
|
||||
+ var out: HorizonModPostOut;
|
||||
+ out.position = vec4<f32>(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, 0.0, 1.0);
|
||||
+ out.uv = uv;
|
||||
+ return out;
|
||||
+}
|
||||
+
|
||||
+/// The world's depth at `uv` (reversed: 1 near, 0 the sky).
|
||||
+fn depth_at(uv: vec2<f32>) -> f32 {
|
||||
+ let size = vec2<f32>(textureDimensions(scene_depth));
|
||||
+ let p = vec2<i32>(clamp(uv * size, vec2<f32>(0.0), size - 1.0));
|
||||
+ return textureLoad(scene_depth, p, 0);
|
||||
+}
|
||||
+
|
||||
+/// The point the pixel at `uv` sees at `depth`, relative to the camera (world axes).
|
||||
+fn view_ray_point(uv: vec2<f32>, depth: f32) -> vec3<f32> {
|
||||
+ let ndc = vec4<f32>(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, depth, 1.0);
|
||||
+ let v = frame.projection_inverse * ndc;
|
||||
+ return (frame.view_inverse * vec4<f32>(v.xyz / v.w, 0.0)).xyz;
|
||||
+}
|
||||
+
|
||||
+/// The unit direction of the view ray through `uv`.
|
||||
+fn view_dir(uv: vec2<f32>) -> vec3<f32> {
|
||||
+ return normalize(view_ray_point(uv, 0.5));
|
||||
+}
|
||||
+
|
||||
+/// How far along the view ray the world is at `uv` (a large number for the sky).
|
||||
+fn scene_distance(uv: vec2<f32>) -> f32 {
|
||||
+ let d = depth_at(uv);
|
||||
+ if d <= 0.0 { return 1.0e6; }
|
||||
+ return length(view_ray_point(uv, d));
|
||||
+}
|
||||
+
|
||||
+/// A world point on the screen: xy in uv, z its distance (negative behind the camera).
|
||||
+fn project(world: vec3<f32>) -> vec3<f32> {
|
||||
+ let c = frame.view_proj * vec4<f32>(world - frame.camera.xyz, 1.0);
|
||||
+ let ndc = c.xyz / max(abs(c.w), 1e-5);
|
||||
+ return vec3<f32>(ndc.x * 0.5 + 0.5, 0.5 - ndc.y * 0.5, c.w);
|
||||
+}
|
||||
+
|
||||
+fn scene(uv: vec2<f32>) -> vec3<f32> {
|
||||
+ return textureSampleLevel(scene_color, linear_sampler, uv, 0.0).rgb;
|
||||
+}
|
||||
+"#;
|
||||
+
|
||||
+const ENTRY: &str = r#"
|
||||
+@fragment
|
||||
+fn horizon_mod_post_fs(in: HorizonModPostOut) -> @location(0) vec4<f32> {
|
||||
+ return post(in.uv, in.position.xy);
|
||||
+}
|
||||
+"#;
|
||||
+
|
||||
+pub struct ModPost {
|
||||
+ pipeline: wgpu::RenderPipeline,
|
||||
+ layout: wgpu::BindGroupLayout,
|
||||
+ buffer: wgpu::Buffer,
|
||||
+ sampler: wgpu::Sampler,
|
||||
+ group: Option<((wgpu::TextureView, wgpu::TextureView), wgpu::BindGroup)>,
|
||||
+ start: std::time::Instant,
|
||||
+}
|
||||
+
|
||||
+/// The mod's source with the prelude, checked by naga: errors name the mod's own lines.
|
||||
+fn compile(source: &str) -> Result<naga::Module, String> {
|
||||
+ let full = format!("{PRELUDE}\n{source}\n{ENTRY}");
|
||||
+ let module = naga::front::wgsl::parse_str(&full).map_err(|e| {
|
||||
+ let prelude_lines = PRELUDE.lines().count() + 1;
|
||||
+ let text = e.emit_to_string(&full);
|
||||
+ match e.location(&full) {
|
||||
+ Some(l) if l.line_number as usize > prelude_lines => {
|
||||
+ format!("line {}: {}", l.line_number as usize - prelude_lines, e.message())
|
||||
+ }
|
||||
+ _ => text,
|
||||
+ }
|
||||
+ })?;
|
||||
+ naga::valid::Validator::new(
|
||||
+ naga::valid::ValidationFlags::all(),
|
||||
+ naga::valid::Capabilities::default(),
|
||||
+ )
|
||||
+ .validate(&module)
|
||||
+ .map_err(|e| format!("{}", e.into_inner()))?;
|
||||
+ Ok(module)
|
||||
+}
|
||||
+
|
||||
+impl ModPost {
|
||||
+ pub fn new(device: &wgpu::Device, source: &str, format: wgpu::TextureFormat) -> Result<Self, String> {
|
||||
+ let module = compile(source)?;
|
||||
+ let texture = |binding, sample_type| wgpu::BindGroupLayoutEntry {
|
||||
+ binding,
|
||||
+ visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
+ ty: wgpu::BindingType::Texture {
|
||||
+ sample_type,
|
||||
+ view_dimension: wgpu::TextureViewDimension::D2,
|
||||
+ multisampled: false,
|
||||
+ },
|
||||
+ count: None,
|
||||
+ };
|
||||
+ let layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
+ label: Some("Mod post"),
|
||||
+ entries: &[
|
||||
+ wgpu::BindGroupLayoutEntry {
|
||||
+ binding: 0,
|
||||
+ visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
+ ty: wgpu::BindingType::Buffer {
|
||||
+ ty: wgpu::BufferBindingType::Uniform,
|
||||
+ has_dynamic_offset: false,
|
||||
+ min_binding_size: wgpu::BufferSize::new(size_of::<ModFrame>() as u64),
|
||||
+ },
|
||||
+ count: None,
|
||||
+ },
|
||||
+ texture(1, wgpu::TextureSampleType::Float { filterable: true }),
|
||||
+ texture(2, wgpu::TextureSampleType::Depth),
|
||||
+ wgpu::BindGroupLayoutEntry {
|
||||
+ binding: 3,
|
||||
+ visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
+ ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||
+ count: None,
|
||||
+ },
|
||||
+ ],
|
||||
+ });
|
||||
+ let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||
+ label: Some("Mod post"),
|
||||
+ bind_group_layouts: &[Some(&layout)],
|
||||
+ ..Default::default()
|
||||
+ });
|
||||
+ let scope = device.push_error_scope(wgpu::ErrorFilter::Validation);
|
||||
+ let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
+ label: Some("Mod post"),
|
||||
+ source: wgpu::ShaderSource::Naga(std::borrow::Cow::Owned(module)),
|
||||
+ });
|
||||
+ let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||
+ label: Some("Mod post"),
|
||||
+ layout: Some(&pipeline_layout),
|
||||
+ vertex: wgpu::VertexState {
|
||||
+ module: &shader,
|
||||
+ entry_point: Some("horizon_mod_post_vs"),
|
||||
+ compilation_options: Default::default(),
|
||||
+ buffers: &[],
|
||||
+ },
|
||||
+ primitive: Default::default(),
|
||||
+ depth_stencil: None,
|
||||
+ multisample: Default::default(),
|
||||
+ fragment: Some(wgpu::FragmentState {
|
||||
+ module: &shader,
|
||||
+ entry_point: Some("horizon_mod_post_fs"),
|
||||
+ compilation_options: Default::default(),
|
||||
+ targets: &[Some(wgpu::ColorTargetState {
|
||||
+ format,
|
||||
+ blend: None,
|
||||
+ write_mask: wgpu::ColorWrites::ALL,
|
||||
+ })],
|
||||
+ }),
|
||||
+ multiview_mask: None,
|
||||
+ cache: None,
|
||||
+ });
|
||||
+ if let Some(e) = pollster::block_on(scope.pop()) {
|
||||
+ return Err(e.to_string());
|
||||
+ }
|
||||
+ let buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
||||
+ label: Some("Mod post frame"),
|
||||
+ size: size_of::<ModFrame>() as u64,
|
||||
+ usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
|
||||
+ mapped_at_creation: false,
|
||||
+ });
|
||||
+ let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||
+ label: Some("Mod post linear"),
|
||||
+ mag_filter: wgpu::FilterMode::Linear,
|
||||
+ min_filter: wgpu::FilterMode::Linear,
|
||||
+ ..Default::default()
|
||||
+ });
|
||||
+ Ok(Self {
|
||||
+ pipeline,
|
||||
+ layout,
|
||||
+ buffer,
|
||||
+ sampler,
|
||||
+ group: None,
|
||||
+ start: std::time::Instant::now(),
|
||||
+ })
|
||||
+ }
|
||||
+
|
||||
+ /// This frame's camera and the mod's `params`, for a world of `size`.
|
||||
+ pub fn write(&self, queue: &wgpu::Queue, frame: &Frame, size: [u32; 2], params: &[f32], partial: f32) {
|
||||
+ let aspect = size[0] as f32 / size[1].max(1) as f32;
|
||||
+ let view = crate::camera::view_matrix(frame.yaw, frame.pitch);
|
||||
+ let projection =
|
||||
+ super::world_projection(frame.fov_degrees, aspect, frame.depth_far) * frame.bob * frame.spin;
|
||||
+ let a = frame.sky.sun_angle.to_radians();
|
||||
+ let sun = [-a.sin(), a.cos(), 0.0, 0.0];
|
||||
+ let mut p = [[0.0f32; 4]; PARAMS / 4];
|
||||
+ for (i, v) in params.iter().take(PARAMS).enumerate() {
|
||||
+ p[i / 4][i % 4] = *v;
|
||||
+ }
|
||||
+ let m = |m: Mat4| m.to_cols_array_2d();
|
||||
+ let inputs = ModFrame {
|
||||
+ view_proj: m(projection * view),
|
||||
+ view_inverse: m(view.inverse()),
|
||||
+ projection_inverse: m(projection.inverse()),
|
||||
+ camera: [frame.camera.x as f32, frame.camera.y as f32, frame.camera.z as f32, 0.0],
|
||||
+ resolution: [
|
||||
+ size[0] as f32,
|
||||
+ size[1] as f32,
|
||||
+ 1.0 / size[0].max(1) as f32,
|
||||
+ 1.0 / size[1].max(1) as f32,
|
||||
+ ],
|
||||
+ time: [self.start.elapsed().as_secs_f32() % 3600.0, partial, sun[1], 0.0],
|
||||
+ sun,
|
||||
+ params: p,
|
||||
+ };
|
||||
+ queue.write_buffer(&self.buffer, 0, bytemuck::bytes_of(&inputs));
|
||||
+ }
|
||||
+
|
||||
+ /// Draws the pass over the world target `world` (colour, depth) onto `screen`.
|
||||
+ pub fn run(
|
||||
+ &mut self,
|
||||
+ device: &wgpu::Device,
|
||||
+ encoder: &mut wgpu::CommandEncoder,
|
||||
+ world: (&wgpu::TextureView, &wgpu::TextureView),
|
||||
+ screen: &wgpu::TextureView,
|
||||
+ ) {
|
||||
+ if self
|
||||
+ .group
|
||||
+ .as_ref()
|
||||
+ .is_none_or(|((c, d), _)| c != world.0 || d != world.1)
|
||||
+ {
|
||||
+ let group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
+ label: Some("Mod post"),
|
||||
+ layout: &self.layout,
|
||||
+ entries: &[
|
||||
+ wgpu::BindGroupEntry { binding: 0, resource: self.buffer.as_entire_binding() },
|
||||
+ wgpu::BindGroupEntry { binding: 1, resource: wgpu::BindingResource::TextureView(world.0) },
|
||||
+ wgpu::BindGroupEntry { binding: 2, resource: wgpu::BindingResource::TextureView(world.1) },
|
||||
+ wgpu::BindGroupEntry { binding: 3, resource: wgpu::BindingResource::Sampler(&self.sampler) },
|
||||
+ ],
|
||||
+ });
|
||||
+ self.group = Some(((world.0.clone(), world.1.clone()), group));
|
||||
+ }
|
||||
+ let Some((_, group)) = &self.group else { return };
|
||||
+ let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
+ label: Some("Mod post"),
|
||||
+ color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
+ view: screen,
|
||||
+ resolve_target: None,
|
||||
+ depth_slice: None,
|
||||
+ ops: wgpu::Operations {
|
||||
+ load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
|
||||
+ store: wgpu::StoreOp::Store,
|
||||
+ },
|
||||
+ })],
|
||||
+ ..Default::default()
|
||||
+ });
|
||||
+ pass.set_pipeline(&self.pipeline);
|
||||
+ pass.set_bind_group(0, group, &[]);
|
||||
+ pass.draw(0..3, 0..1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+#[cfg(test)]
|
||||
+mod tests {
|
||||
+ #[test]
|
||||
+ fn a_shader_compiles_and_errors_name_its_line() {
|
||||
+ let ok = "fn post(uv: vec2<f32>, pixel: vec2<f32>) -> vec4<f32> { return vec4<f32>(scene(uv), 1.0); }";
|
||||
+ assert!(super::compile(ok).is_ok());
|
||||
+ let bad = "fn post(uv: vec2<f32>, pixel: vec2<f32>) -> vec4<f32> {\n return nope;\n}";
|
||||
+ let e = super::compile(bad).unwrap_err();
|
||||
+ assert!(e.starts_with("line 2"), "{e}");
|
||||
+ }
|
||||
+}
|
||||
diff --git a/crates/horizon-mod-sdk/wit/horizon.wit b/crates/horizon-mod-sdk/wit/horizon.wit
|
||||
index 89d1906a9..1b167c7f7 100644
|
||||
--- a/crates/horizon-mod-sdk/wit/horizon.wit
|
||||
+++ b/crates/horizon-mod-sdk/wit/horizon.wit
|
||||
@@ -487,6 +487,19 @@ interface render {
|
||||
/// the highest block that blocks motion or holds a fluid, as the motion
|
||||
/// blocking heightmap; -64 where the chunk isn't loaded.
|
||||
ground: func() -> list<tuple<s32, s32, s32>>;
|
||||
+ /// A full-screen post pass (AirDef fork): WGSL defining
|
||||
+ /// `fn post(uv: vec2<f32>, pixel: vec2<f32>) -> vec4<f32>`, after a prelude
|
||||
+ /// with `frame` (camera matrices, time, `params`), the world's colour and
|
||||
+ /// depth and helpers (`scene`, `depth-at`, `view-dir`, `scene-distance`,
|
||||
+ /// `project`). It runs after the world, before the hand and the HUD.
|
||||
+ /// Compile errors come back in the chat and the log; the last good pass
|
||||
+ /// keeps running.
|
||||
+ set-post: func(wgsl: string);
|
||||
+ clear-post: func();
|
||||
+ /// The pass's `frame.params` (up to 1024 floats, as 256 vec4), kept until
|
||||
+ /// replaced; call it once a tick (the pass gets the partial tick in
|
||||
+ /// `frame.time.y`).
|
||||
+ set-params: func(params: list<f32>);
|
||||
}
|
||||
|
||||
/// What the game calls. Only the hooks `init` asks for are ever called.
|
||||
diff --git a/crates/horizon-mods/src/api_level.rs b/crates/horizon-mods/src/api_level.rs
|
||||
index b64792eaa..68487e600 100644
|
||||
--- a/crates/horizon-mods/src/api_level.rs
|
||||
+++ b/crates/horizon-mods/src/api_level.rs
|
||||
@@ -13,7 +13,7 @@ pub const LEVEL: u32 = 8;
|
||||
/// level. Level 0 is the contract of Horizon 0.2.67 to 0.2.69. A new
|
||||
/// function takes the next level and raises [`LEVEL`] (the `api_reference`
|
||||
/// test fails until it is listed here).
|
||||
-pub const FUNCTIONS: [(&str, u32); 51] = [
|
||||
+pub const FUNCTIONS: [(&str, u32); 54] = [
|
||||
("log.write", 0),
|
||||
("game.get-player", 0),
|
||||
("game.get-clock", 0),
|
||||
@@ -66,6 +66,9 @@ pub const FUNCTIONS: [(&str, u32); 51] = [
|
||||
("render.play-sound", 8),
|
||||
("render.query-ground", 8),
|
||||
("render.ground", 8),
|
||||
+ ("render.set-post", 8),
|
||||
+ ("render.clear-post", 8),
|
||||
+ ("render.set-params", 8),
|
||||
];
|
||||
|
||||
/// What the game's program carries so the launcher can read its level
|
||||
diff --git a/crates/horizon-mods/src/runtime.rs b/crates/horizon-mods/src/runtime.rs
|
||||
index 317cd4f06..55c1fd13f 100644
|
||||
--- a/crates/horizon-mods/src/runtime.rs
|
||||
+++ b/crates/horizon-mods/src/runtime.rs
|
||||
@@ -432,6 +432,9 @@ struct State {
|
||||
ground_queries: Vec<(i32, i32)>,
|
||||
/// The game's answers to them.
|
||||
ground: Vec<(i32, i32, i32)>,
|
||||
+ /// `render.set-post`'s source, with a number that changes with it.
|
||||
+ post: Option<(u64, String)>,
|
||||
+ post_params: Vec<f32>,
|
||||
input: InputState,
|
||||
browser: BrowserState,
|
||||
/// Capability `storage`'s folder; made on first `set`.
|
||||
@@ -638,6 +641,8 @@ impl Mods {
|
||||
models: Vec::new(),
|
||||
ground_queries: Vec::new(),
|
||||
ground: Vec::new(),
|
||||
+ post: None,
|
||||
+ post_params: Vec::new(),
|
||||
input: InputState::default(),
|
||||
browser: BrowserState::default(),
|
||||
data_dir,
|
||||
@@ -1212,6 +1217,14 @@ impl Mods {
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
+ /// The first running mod's post pass (version, WGSL) and its parameters.
|
||||
+ pub fn post(&self) -> Option<(u64, &str, &[f32])> {
|
||||
+ self.entries.iter().find_map(|e| {
|
||||
+ let d = e.run.as_ref()?.store.data();
|
||||
+ let (v, src) = d.post.as_ref()?;
|
||||
+ Some((*v, src.as_str(), d.post_params.as_slice()))
|
||||
+ })
|
||||
+ }
|
||||
/// Mod `i`'s answers to its ground queries, for its next calls.
|
||||
pub fn answer_ground(&mut self, i: usize, ground: Vec<(i32, i32, i32)>) {
|
||||
if let Some(run) = self.entries.get_mut(i).and_then(|e| e.run.as_mut()) {
|
||||
@@ -1941,6 +1954,21 @@ impl render::Host for State {
|
||||
self.out.push(Output::Particles { particles });
|
||||
}
|
||||
}
|
||||
+ fn set_post(&mut self, wgsl: String) {
|
||||
+ static VERSION: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
|
||||
+ let v = VERSION.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
+ self.post = Some((v, clip_to(wgsl, 256 * 1024)));
|
||||
+ }
|
||||
+ fn clear_post(&mut self) {
|
||||
+ self.post = None;
|
||||
+ }
|
||||
+ fn set_params(&mut self, params: Vec<f32>) {
|
||||
+ self.post_params = params
|
||||
+ .into_iter()
|
||||
+ .take(1024)
|
||||
+ .map(|v| if v.is_finite() { v } else { 0.0 })
|
||||
+ .collect();
|
||||
+ }
|
||||
fn query_ground(&mut self, columns: Vec<(i32, i32)>) {
|
||||
let room = 512usize.saturating_sub(self.ground_queries.len());
|
||||
self.ground_queries.extend(columns.into_iter().take(room));
|
||||
--
|
||||
2.54.0 (Apple Git-157)
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
From 2b137dbbedd540daeebc7f5e387847aeb56a1355 Mon Sep 17 00:00:00 2001
|
||||
From: chexit <chexit@duck.com>
|
||||
Date: Wed, 28 Oct 2026 22:09:30 +0300
|
||||
Subject: [PATCH 04/39] Mod models: draw far models as scaled impostors past
|
||||
the far plane, cull at 4096
|
||||
|
||||
---
|
||||
crates/horizon-client/src/game/mod_models.rs | 20 ++++++++++++++++----
|
||||
1 file changed, 16 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/crates/horizon-client/src/game/mod_models.rs b/crates/horizon-client/src/game/mod_models.rs
|
||||
index be00ea4c7..6cd55afc6 100644
|
||||
--- a/crates/horizon-client/src/game/mod_models.rs
|
||||
+++ b/crates/horizon-client/src/game/mod_models.rs
|
||||
@@ -120,14 +120,26 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
let t = alpha.clamp(0.0, 1.0);
|
||||
+ // Missiles are seen from far off: past the far plane a model is drawn nearer and
|
||||
+ // smaller, the same size on screen.
|
||||
+ let depth_far = f64::from(horizon_client::camera::depth_far(
|
||||
+ self.terrain_distance(),
|
||||
+ self.settings.cloud_range,
|
||||
+ ));
|
||||
+ let reach = depth_far * 0.85;
|
||||
for p in self.mods.models.poses.values() {
|
||||
- let at = p.previous.lerp(p.position, t);
|
||||
- // Far models are culled by distance; the view frustum does the rest.
|
||||
- if at.distance_squared(camera) > 512.0 * 512.0 {
|
||||
+ let mut at = p.previous.lerp(p.position, t);
|
||||
+ let d = at.distance(camera);
|
||||
+ if d > 4096.0 {
|
||||
continue;
|
||||
}
|
||||
+ let mut shrink = 1.0f32;
|
||||
+ if d > reach {
|
||||
+ shrink = (reach / d) as f32;
|
||||
+ at = camera + (at - camera) * (reach / d);
|
||||
+ }
|
||||
let rotation = p.old_rotation.slerp(p.rotation, t as f32);
|
||||
- let scale = p.old_scale + (p.scale - p.old_scale) * t as f32;
|
||||
+ let scale = (p.old_scale + (p.scale - p.old_scale) * t as f32) * shrink;
|
||||
if scale <= 0.0 {
|
||||
continue;
|
||||
}
|
||||
--
|
||||
2.54.0 (Apple Git-157)
|
||||
|
||||
@@ -1,927 +0,0 @@
|
||||
From c8ebca6e0af68630e65211844b34d25c5b985c03 Mon Sep 17 00:00:00 2001
|
||||
From: chexit <chexit@duck.com>
|
||||
Date: Wed, 28 Oct 2026 22:31:00 +0300
|
||||
Subject: [PATCH 05/39] Mod cameras: render.set-views draws the world from
|
||||
other points into pictures that HUD view shapes show (API level 9)
|
||||
|
||||
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||||
---
|
||||
crates/horizon-client/src/game.rs | 3 +
|
||||
crates/horizon-client/src/game/mod_models.rs | 39 ++-
|
||||
crates/horizon-client/src/game/mod_render.rs | 9 +
|
||||
crates/horizon-client/src/gfx.rs | 192 ++++++++++-
|
||||
crates/horizon-client/src/gfx/mod_views.rs | 318 +++++++++++++++++++
|
||||
crates/horizon-client/src/hud.rs | 15 +
|
||||
crates/horizon-mod-sdk/wit/horizon.wit | 30 ++
|
||||
crates/horizon-mods/src/api_level.rs | 5 +-
|
||||
crates/horizon-mods/src/runtime.rs | 30 +-
|
||||
9 files changed, 624 insertions(+), 17 deletions(-)
|
||||
create mode 100644 crates/horizon-client/src/gfx/mod_views.rs
|
||||
|
||||
diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs
|
||||
index ca6a8c266..e5ffb30c4 100644
|
||||
--- a/crates/horizon-client/src/game.rs
|
||||
+++ b/crates/horizon-client/src/game.rs
|
||||
@@ -11806,7 +11806,9 @@ impl Game<'_> {
|
||||
hud.patches.append(&mut self.map_patches);
|
||||
let entity_spans = std::mem::take(self.entity_spans.get_mut());
|
||||
let glowing = std::mem::take(self.glowing_vertices.get_mut());
|
||||
+ let mod_views = self.mod_views(alpha);
|
||||
let frame = Frame {
|
||||
+ mod_views: &mod_views,
|
||||
weather: &weather,
|
||||
weather_time: horizon_client::weather::Time::new(self.world.game_time, alpha as f32),
|
||||
nether_lighting: self.dim == Dim::Nether,
|
||||
@@ -14725,6 +14727,7 @@ fn loading_renderer(
|
||||
/// A title-shaped frame: black clear and panorama, only the HUD is drawn.
|
||||
fn loading_frame(hud: &HudBatch) -> Frame<'_> {
|
||||
Frame {
|
||||
+ mod_views: &[],
|
||||
weather: &[],
|
||||
weather_time: horizon_client::weather::Time::new(0, 0.0),
|
||||
camera: glam::DVec3::new(0.5, 100.0, 0.5),
|
||||
diff --git a/crates/horizon-client/src/game/mod_models.rs b/crates/horizon-client/src/game/mod_models.rs
|
||||
index 6cd55afc6..7ae58f664 100644
|
||||
--- a/crates/horizon-client/src/game/mod_models.rs
|
||||
+++ b/crates/horizon-client/src/game/mod_models.rs
|
||||
@@ -11,7 +11,7 @@ use {
|
||||
particles::{ParticleOptions, ParticleType},
|
||||
},
|
||||
horizon_core::random::RandomSource,
|
||||
- horizon_mods::ParticleSpawn,
|
||||
+ horizon_mods::{CameraView, ParticleSpawn},
|
||||
horizon_world::registry::BlockStateId,
|
||||
std::collections::HashMap,
|
||||
};
|
||||
@@ -38,6 +38,8 @@ pub(super) struct ModModels {
|
||||
states: HashMap<String, Option<BlockStateId>>,
|
||||
/// The version of the mod post pass the renderer has (0: none).
|
||||
post: u64,
|
||||
+ /// The mods' cameras by id: a tick ago and now.
|
||||
+ views: Vec<(CameraView, CameraView)>,
|
||||
}
|
||||
|
||||
/// Full brightness: sky and block light 15, as the entity shader packs them.
|
||||
@@ -55,6 +57,9 @@ impl Game<'_> {
|
||||
) {
|
||||
}
|
||||
pub(super) fn apply_mod_post(&mut self, _partial: f32) {}
|
||||
+ pub(super) fn mod_views(&self, _alpha: f64) -> Vec<horizon_client::gfx::ModView> {
|
||||
+ Vec::new()
|
||||
+ }
|
||||
}
|
||||
|
||||
#[cfg(feature = "mods")]
|
||||
@@ -111,6 +116,38 @@ impl Game<'_> {
|
||||
let seen: std::collections::HashSet<_> = seen.into_iter().collect();
|
||||
models.poses.retain(|k, _| seen.contains(k));
|
||||
}
|
||||
+ let views: Vec<CameraView> = self.mods.mods.views().map(|(_, v)| *v).collect();
|
||||
+ let old = std::mem::take(&mut self.mods.models.views);
|
||||
+ self.mods.models.views = views
|
||||
+ .into_iter()
|
||||
+ .map(|v| {
|
||||
+ let before = old.iter().find(|(_, o)| o.id == v.id).map_or(v, |(_, o)| *o);
|
||||
+ (before, v)
|
||||
+ })
|
||||
+ .collect();
|
||||
+ }
|
||||
+
|
||||
+ /// The mods' cameras between their last two settings, for this frame.
|
||||
+ pub(super) fn mod_views(&self, alpha: f64) -> Vec<horizon_client::gfx::ModView> {
|
||||
+ let t = alpha.clamp(0.0, 1.0);
|
||||
+ let lerp = |a: f32, b: f32| a + (b - a) * t as f32;
|
||||
+ self.mods
|
||||
+ .models
|
||||
+ .views
|
||||
+ .iter()
|
||||
+ .map(|(a, b)| {
|
||||
+ // The short way round.
|
||||
+ let turn = (b.yaw - a.yaw + 540.0).rem_euclid(360.0) - 180.0;
|
||||
+ horizon_client::gfx::ModView {
|
||||
+ id: b.id,
|
||||
+ camera: DVec3::new(a.x, a.y, a.z).lerp(DVec3::new(b.x, b.y, b.z), t),
|
||||
+ yaw: a.yaw + turn * t as f32,
|
||||
+ pitch: lerp(a.pitch, b.pitch),
|
||||
+ fov: lerp(a.fov, b.fov),
|
||||
+ size: [b.width, b.height],
|
||||
+ }
|
||||
+ })
|
||||
+ .collect()
|
||||
}
|
||||
|
||||
/// Draws every mod model between its last two poses, lit by the world
|
||||
diff --git a/crates/horizon-client/src/game/mod_render.rs b/crates/horizon-client/src/game/mod_render.rs
|
||||
index 931aec641..85aae67e7 100644
|
||||
--- a/crates/horizon-client/src/game/mod_render.rs
|
||||
+++ b/crates/horizon-client/src/game/mod_render.rs
|
||||
@@ -120,6 +120,15 @@ impl Game<'_> {
|
||||
self.draw_item_model(batch, &stack, x, y);
|
||||
batch.scale_since(start, x, y, i.scale, i.scale);
|
||||
}
|
||||
+ Shape::View(v) => {
|
||||
+ let r = v.rect;
|
||||
+ batch.views.push(horizon_client::hud::HudView {
|
||||
+ at: batch.vertices.len() as u32,
|
||||
+ id: v.view,
|
||||
+ rect: [ox + r.x, oy + r.y, r.w, r.h],
|
||||
+ mode: v.mode,
|
||||
+ });
|
||||
+ }
|
||||
Shape::Text(t) => {
|
||||
let text = Text::literal(t.text.clone());
|
||||
let centre = if t.centered {
|
||||
diff --git a/crates/horizon-client/src/gfx.rs b/crates/horizon-client/src/gfx.rs
|
||||
index 4c5005615..3ad257728 100644
|
||||
--- a/crates/horizon-client/src/gfx.rs
|
||||
+++ b/crates/horizon-client/src/gfx.rs
|
||||
@@ -78,6 +78,8 @@ mod native_material;
|
||||
mod native_pack;
|
||||
mod native_post;
|
||||
mod mod_post;
|
||||
+mod mod_views;
|
||||
+pub use mod_views::ModView;
|
||||
mod native_sky;
|
||||
mod occlusion;
|
||||
mod pack_atlas;
|
||||
@@ -214,6 +216,8 @@ const SECTION_UPLOAD_CHUNK: u64 = 4 << 20;
|
||||
const SECTION_COPY_LIMIT: u64 = 64 << 20;
|
||||
pub struct Frame<'a> {
|
||||
pub camera: DVec3,
|
||||
+ /// Mods' cameras (AirDef fork), drawn into the pictures the HUD shows.
|
||||
+ pub mod_views: &'a [ModView],
|
||||
pub yaw: f32,
|
||||
pub pitch: f32,
|
||||
pub fov_degrees: f32,
|
||||
@@ -546,6 +550,7 @@ pub struct Renderer {
|
||||
native: Option<native_pack::NativePack>,
|
||||
/// AirDef fork: a mod's post pass, its parameters and the partial tick they are for.
|
||||
mod_post: Option<mod_post::ModPost>,
|
||||
+ mod_views: Option<mod_views::Views>,
|
||||
mod_params: (Vec<f32>, f32),
|
||||
/// Time the shader pack's passes on the GPU (F3, or `HORIZON_SHADER_PACK_TIMING`).
|
||||
pass_timing: bool,
|
||||
@@ -2651,6 +2656,7 @@ impl Renderer {
|
||||
pack_post: None,
|
||||
native: None,
|
||||
mod_post: None,
|
||||
+ mod_views: None,
|
||||
mod_params: (Vec::new(), 0.0),
|
||||
pass_timing: pack_timing::PassTiming::logging(),
|
||||
pack_entity_rest: Vec::new(),
|
||||
@@ -3019,6 +3025,128 @@ impl Renderer {
|
||||
self.section_uploads.finish(&encoder);
|
||||
Some(encoder.finish())
|
||||
}
|
||||
+ /// The HUD's vertices in `range`, with the mod cameras' pictures between
|
||||
+ /// them where their shapes were.
|
||||
+ fn draw_hud(
|
||||
+ &self,
|
||||
+ encoder: &mut wgpu::CommandEncoder,
|
||||
+ target: &wgpu::TextureView,
|
||||
+ batch: &crate::hud::HudBatch,
|
||||
+ range: std::ops::Range<u32>,
|
||||
+ ) {
|
||||
+ let size = [self.config.width, self.config.height];
|
||||
+ let last = batch.vertices.len() as u32;
|
||||
+ let mut at = range.start;
|
||||
+ if let Some(views) = &self.mod_views {
|
||||
+ for v in batch.views.iter().filter(|v| {
|
||||
+ v.at >= range.start && (v.at < range.end || (v.at == range.end && range.end == last))
|
||||
+ }) {
|
||||
+ self.hud.draw_range(encoder, target, &self.depth, batch, size, at..v.at);
|
||||
+ views.blit(encoder, target, size, v, batch.scale);
|
||||
+ at = v.at;
|
||||
+ }
|
||||
+ }
|
||||
+ self.hud.draw_range(encoder, target, &self.depth, batch, size, at..range.end);
|
||||
+ }
|
||||
+ /// The mod cameras due this frame, each into its picture: sky, solid
|
||||
+ /// terrain and entities, through the world's own pipelines with the
|
||||
+ /// camera's globals in the world's buffer (the player's put back after).
|
||||
+ fn draw_mod_views(
|
||||
+ &mut self,
|
||||
+ encoder: &mut wgpu::CommandEncoder,
|
||||
+ frame: &Frame,
|
||||
+ globals: &Globals,
|
||||
+ due: &[mod_views::Due],
|
||||
+ entity_quads: u32,
|
||||
+ ) {
|
||||
+ let Some(views) = &mut self.mod_views else {
|
||||
+ return;
|
||||
+ };
|
||||
+ let size = std::mem::size_of::<Globals>() as u64;
|
||||
+ self.uploads
|
||||
+ .buffer(encoder, &views.main, 0, bytemuck::bytes_of(globals));
|
||||
+ for d in due {
|
||||
+ let Some(t) = views.targets.get(&d.id) else {
|
||||
+ continue;
|
||||
+ };
|
||||
+ let own = Globals {
|
||||
+ view_proj: d.view_proj.to_cols_array_2d(),
|
||||
+ inverse_view: d.view.inverse().to_cols_array_2d(),
|
||||
+ misc: [
|
||||
+ globals.misc[0],
|
||||
+ globals.misc[1],
|
||||
+ d.aspect,
|
||||
+ (d.fov.to_radians() / 2.0).tan(),
|
||||
+ ],
|
||||
+ ..*globals
|
||||
+ };
|
||||
+ self.uploads
|
||||
+ .buffer(encoder, &t.globals, 0, bytemuck::bytes_of(&own));
|
||||
+ }
|
||||
+ let fog = globals.fog_color;
|
||||
+ let clear = wgpu::Color {
|
||||
+ r: f64::from(fog[0]),
|
||||
+ g: f64::from(fog[1]),
|
||||
+ b: f64::from(fog[2]),
|
||||
+ a: 1.0,
|
||||
+ };
|
||||
+ for d in due {
|
||||
+ let Some(t) = views.targets.get_mut(&d.id) else {
|
||||
+ continue;
|
||||
+ };
|
||||
+ t.drawn = true;
|
||||
+ encoder.copy_buffer_to_buffer(&t.globals, 0, &self.globals, 0, size);
|
||||
+ let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
+ label: Some("Mod view"),
|
||||
+ color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
+ view: &t.color,
|
||||
+ resolve_target: None,
|
||||
+ depth_slice: None,
|
||||
+ ops: wgpu::Operations {
|
||||
+ load: wgpu::LoadOp::Clear(clear),
|
||||
+ store: wgpu::StoreOp::Store,
|
||||
+ },
|
||||
+ })],
|
||||
+ depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||
+ view: &t.depth,
|
||||
+ depth_ops: Some(wgpu::Operations {
|
||||
+ load: wgpu::LoadOp::Clear(0.0),
|
||||
+ store: wgpu::StoreOp::Discard,
|
||||
+ }),
|
||||
+ stencil_ops: None,
|
||||
+ }),
|
||||
+ ..Default::default()
|
||||
+ });
|
||||
+ pass.set_bind_group(0, &self.group, &[]);
|
||||
+ if frame.skybox {
|
||||
+ pass.set_pipeline(&self.sky);
|
||||
+ pass.draw(0..3, 0..1);
|
||||
+ }
|
||||
+ pass.set_pipeline(&self.solid);
|
||||
+ pass.set_index_buffer(self.indices.slice(..), wgpu::IndexFormat::Uint32);
|
||||
+ pass.set_vertex_buffer(1, self.instances.slice(..));
|
||||
+ let mut page = None;
|
||||
+ for (k, v) in d.visible.iter().enumerate() {
|
||||
+ let s = self.sections.get(v.slot);
|
||||
+ if s.solid == 0 {
|
||||
+ continue;
|
||||
+ }
|
||||
+ if page != Some(s.page) {
|
||||
+ pass.set_vertex_buffer(0, self.arena.buffer(s.page).slice(..));
|
||||
+ page = Some(s.page);
|
||||
+ }
|
||||
+ let instance = d.first + k as u32;
|
||||
+ pass.draw_indexed(0..s.solid * 6, s.start as i32, instance..instance + 1);
|
||||
+ }
|
||||
+ if entity_quads > 0 {
|
||||
+ pass.set_pipeline(&self.entity_pipeline);
|
||||
+ pass.set_bind_group(0, &self.entity_group, &[]);
|
||||
+ pass.set_vertex_buffer(0, self.entity_buffer.slice(..));
|
||||
+ pass.draw_indexed(0..entity_quads * 6, 0, 0..1);
|
||||
+ }
|
||||
+ }
|
||||
+ encoder.copy_buffer_to_buffer(&views.main, 0, &self.globals, 0, size);
|
||||
+ }
|
||||
/// Draws `count` section draws from `first` with the arena and section
|
||||
/// origins bound: one indirect multi-draw, or a loop without it.
|
||||
/// Consecutive draws in one arena page share a vertex buffer binding,
|
||||
@@ -3827,7 +3955,46 @@ impl Renderer {
|
||||
});
|
||||
}
|
||||
self.drawn_sections = visible.len() + visible_lods.len();
|
||||
- let instances = self.drawn_sections + shadow_visible.len();
|
||||
+ // Mods' cameras: their sections round them, all of them (no occlusion), after the shadow's.
|
||||
+ let globals_size = std::mem::size_of::<Globals>() as u64;
|
||||
+ let mut views_due = Vec::new();
|
||||
+ if !frame.title && !frame.mod_views.is_empty() {
|
||||
+ let format = self.config.format.remove_srgb_suffix();
|
||||
+ let device = &self.device;
|
||||
+ let views = self
|
||||
+ .mod_views
|
||||
+ .get_or_insert_with(|| mod_views::Views::new(device, format, globals_size));
|
||||
+ let mut first = (self.drawn_sections + shadow_visible.len()) as u32;
|
||||
+ let radius = ((frame.detail_distance / 16.0) as i32).min(mod_views::RADIUS);
|
||||
+ for v in views.choose(device, frame.mod_views, globals_size) {
|
||||
+ let (view_proj, view, aspect) = mod_views::matrices(v, camera, frame.depth_far);
|
||||
+ let own = world_projection(v.fov, aspect, frame.depth_far) * view;
|
||||
+ let planes = Frustum { planes: frustum(own) };
|
||||
+ let mut seen = Vec::new();
|
||||
+ self.sections
|
||||
+ .visible(v.camera, radius, &planes, |_| true, |_, _| false, &mut seen);
|
||||
+ // Relative to the player's camera, as the rest of the frame.
|
||||
+ let shift = (v.camera - camera).as_vec3();
|
||||
+ for s in &mut seen {
|
||||
+ s.origin = [s.origin[0] + shift.x, s.origin[1] + shift.y, s.origin[2] + shift.z];
|
||||
+ }
|
||||
+ let n = seen.len() as u32;
|
||||
+ views_due.push(mod_views::Due {
|
||||
+ id: v.id,
|
||||
+ view_proj,
|
||||
+ view,
|
||||
+ aspect,
|
||||
+ fov: v.fov,
|
||||
+ visible: seen,
|
||||
+ first,
|
||||
+ });
|
||||
+ first += n;
|
||||
+ }
|
||||
+ } else if frame.mod_views.is_empty() {
|
||||
+ self.mod_views = None;
|
||||
+ }
|
||||
+ let view_sections: usize = views_due.iter().map(|d| d.visible.len()).sum();
|
||||
+ let instances = self.drawn_sections + shadow_visible.len() + view_sections;
|
||||
if instances as u64 > self.instance_capacity {
|
||||
self.instance_capacity = (instances as u64).next_power_of_two();
|
||||
self.instances = self.device.create_buffer(&wgpu::BufferDescriptor {
|
||||
@@ -3845,7 +4012,12 @@ impl Renderer {
|
||||
.iter()
|
||||
.map(|v| section_instance(v.origin))
|
||||
.chain(visible_lods.iter().map(|v| lod::instance(v.origin)))
|
||||
- .chain(shadow_visible.iter().map(|v| section_instance(v.origin))),
|
||||
+ .chain(shadow_visible.iter().map(|v| section_instance(v.origin)))
|
||||
+ .chain(
|
||||
+ views_due
|
||||
+ .iter()
|
||||
+ .flat_map(|d| d.visible.iter().map(|v| section_instance(v.origin))),
|
||||
+ ),
|
||||
);
|
||||
if !self.origins.is_empty() {
|
||||
self.uploads.buffer(
|
||||
@@ -4461,6 +4633,9 @@ impl Renderer {
|
||||
bytemuck::cast_slice(&self.draws),
|
||||
);
|
||||
}
|
||||
+ if !views_due.is_empty() {
|
||||
+ self.draw_mod_views(&mut encoder, frame, &globals, &views_due, entity_quads);
|
||||
+ }
|
||||
let view_target = target_texture.create_view(&wgpu::TextureViewDescriptor {
|
||||
format: Some(self.config.format.remove_srgb_suffix()),
|
||||
..Default::default()
|
||||
@@ -5167,14 +5342,7 @@ impl Renderer {
|
||||
.menu_blur
|
||||
.filter(|_| self.config.usage.contains(wgpu::TextureUsages::COPY_SRC));
|
||||
let blur_at = menu_blur.map_or(0, |_| frame.hud.blur_at);
|
||||
- self.hud.draw_range(
|
||||
- &mut encoder,
|
||||
- &view_target,
|
||||
- &self.depth,
|
||||
- frame.hud,
|
||||
- [self.config.width, self.config.height],
|
||||
- 0..blur_at,
|
||||
- );
|
||||
+ self.draw_hud(&mut encoder, &view_target, frame.hud, 0..blur_at);
|
||||
if let Some(radius) = menu_blur {
|
||||
let format = self.config.format;
|
||||
let device = &self.device;
|
||||
@@ -5190,12 +5358,10 @@ impl Renderer {
|
||||
radius,
|
||||
);
|
||||
}
|
||||
- self.hud.draw_range(
|
||||
+ self.draw_hud(
|
||||
&mut encoder,
|
||||
&view_target,
|
||||
- &self.depth,
|
||||
frame.hud,
|
||||
- [self.config.width, self.config.height],
|
||||
blur_at..frame.hud.vertices.len() as u32,
|
||||
);
|
||||
if culling && let Some(cull) = &mut self.cull {
|
||||
diff --git a/crates/horizon-client/src/gfx/mod_views.rs b/crates/horizon-client/src/gfx/mod_views.rs
|
||||
new file mode 100644
|
||||
index 000000000..91ae103a8
|
||||
--- /dev/null
|
||||
+++ b/crates/horizon-client/src/gfx/mod_views.rs
|
||||
@@ -0,0 +1,318 @@
|
||||
+//! AirDef fork: mods' cameras (`render.set-views`). The world is drawn from
|
||||
+//! another point into a small picture (sky, solid terrain, entities), which
|
||||
+//! the HUD's `view` shapes show. The picture's passes reuse the world's
|
||||
+//! pipelines and bind groups: its globals are copied into the world's
|
||||
+//! buffer before them and the camera's copied back after.
|
||||
+use glam::{DVec3, Mat4};
|
||||
+use std::collections::HashMap;
|
||||
+
|
||||
+/// One camera of a mod, as the game interpolated it for this frame.
|
||||
+#[derive(Clone, Copy, Debug)]
|
||||
+pub struct ModView {
|
||||
+ pub id: u32,
|
||||
+ pub camera: DVec3,
|
||||
+ /// Degrees, as the player's.
|
||||
+ pub yaw: f32,
|
||||
+ pub pitch: f32,
|
||||
+ pub fov: f32,
|
||||
+ pub size: [u32; 2],
|
||||
+}
|
||||
+
|
||||
+pub use crate::hud::HudView;
|
||||
+
|
||||
+/// The most cameras drawn a frame; the others wait their turn.
|
||||
+pub(super) const PER_FRAME: usize = 3;
|
||||
+/// Sections round a camera it draws, in chunks.
|
||||
+pub(super) const RADIUS: i32 = 12;
|
||||
+
|
||||
+pub(super) struct Target {
|
||||
+ size: [u32; 2],
|
||||
+ pub color: wgpu::TextureView,
|
||||
+ pub depth: wgpu::TextureView,
|
||||
+ pub globals: wgpu::Buffer,
|
||||
+ blit: wgpu::BindGroup,
|
||||
+ /// Drawn at least once: the HUD shows nothing before.
|
||||
+ pub drawn: bool,
|
||||
+}
|
||||
+
|
||||
+/// A camera drawn this frame.
|
||||
+pub(super) struct Due {
|
||||
+ pub id: u32,
|
||||
+ /// Camera-relative to the player's camera, as the entities and the
|
||||
+ /// world's other geometry are.
|
||||
+ pub view_proj: Mat4,
|
||||
+ pub view: Mat4,
|
||||
+ pub aspect: f32,
|
||||
+ pub fov: f32,
|
||||
+ pub visible: Vec<super::resident::Visible>,
|
||||
+ /// The instance of `visible[0]` in the section origins.
|
||||
+ pub first: u32,
|
||||
+}
|
||||
+
|
||||
+pub(super) struct Views {
|
||||
+ pub targets: HashMap<u32, Target>,
|
||||
+ /// The player's camera's globals, copied back after the pictures.
|
||||
+ pub main: wgpu::Buffer,
|
||||
+ cursor: usize,
|
||||
+ format: wgpu::TextureFormat,
|
||||
+ layout: wgpu::BindGroupLayout,
|
||||
+ sampler: wgpu::Sampler,
|
||||
+ pipeline: wgpu::RenderPipeline,
|
||||
+}
|
||||
+
|
||||
+const BLIT: &str = r#"
|
||||
+@group(0) @binding(0) var picture: texture_2d<f32>;
|
||||
+@group(0) @binding(1) var picture_sampler: sampler;
|
||||
+struct Out {
|
||||
+ @builtin(position) position: vec4<f32>,
|
||||
+ @location(0) uv: vec2<f32>,
|
||||
+ @location(1) @interpolate(flat) mode: u32,
|
||||
+}
|
||||
+@vertex
|
||||
+fn vs(@builtin(vertex_index) i: u32, @builtin(instance_index) mode: u32) -> Out {
|
||||
+ let uv = vec2<f32>(f32((i << 1u) & 2u), f32(i & 2u));
|
||||
+ var out: Out;
|
||||
+ out.position = vec4<f32>(uv * vec2<f32>(2.0, -2.0) + vec2<f32>(-1.0, 1.0), 0.0, 1.0);
|
||||
+ out.uv = uv;
|
||||
+ out.mode = mode;
|
||||
+ return out;
|
||||
+}
|
||||
+fn hash(p: vec2<f32>) -> f32 {
|
||||
+ return fract(sin(dot(p, vec2<f32>(12.9898, 78.233))) * 43758.547);
|
||||
+}
|
||||
+@fragment
|
||||
+fn fs(in: Out) -> @location(0) vec4<f32> {
|
||||
+ let c = textureSample(picture, picture_sampler, in.uv).rgb;
|
||||
+ let l = dot(c, vec3<f32>(0.299, 0.587, 0.114));
|
||||
+ let grain = (hash(in.position.xy + vec2<f32>(c.r * 91.0, c.g * 37.0)) - 0.5) * 0.06;
|
||||
+ if in.mode == 1u {
|
||||
+ // White hot: the cold sky dark, the land grey, flames and engines burning white.
|
||||
+ let warm = max(c.r - c.b, 0.0) * 2.2;
|
||||
+ let cold = max(c.b - c.r, 0.0) * 2.5;
|
||||
+ let glow = smoothstep(0.8, 1.0, max(c.r, c.g));
|
||||
+ // High gain: a thermal camera sees as well by night.
|
||||
+ let v = clamp(0.06 + pow(l, 0.4) * 0.55 + warm + glow * 0.9 - cold + grain, 0.0, 1.0);
|
||||
+ return vec4<f32>(v, v * 0.98, v * 0.94, 1.0);
|
||||
+ }
|
||||
+ if in.mode == 2u {
|
||||
+ let v = clamp(pow(l, 0.45) * 1.5 + grain, 0.0, 1.0);
|
||||
+ return vec4<f32>(v * 0.3, v, v * 0.35, 1.0);
|
||||
+ }
|
||||
+ return vec4<f32>(c, 1.0);
|
||||
+}
|
||||
+"#;
|
||||
+
|
||||
+impl Views {
|
||||
+ pub fn new(device: &wgpu::Device, format: wgpu::TextureFormat, globals_size: u64) -> Self {
|
||||
+ let layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
+ label: Some("Mod view picture"),
|
||||
+ entries: &[
|
||||
+ wgpu::BindGroupLayoutEntry {
|
||||
+ binding: 0,
|
||||
+ visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
+ ty: wgpu::BindingType::Texture {
|
||||
+ sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||
+ view_dimension: wgpu::TextureViewDimension::D2,
|
||||
+ multisampled: false,
|
||||
+ },
|
||||
+ count: None,
|
||||
+ },
|
||||
+ wgpu::BindGroupLayoutEntry {
|
||||
+ binding: 1,
|
||||
+ visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
+ ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||
+ count: None,
|
||||
+ },
|
||||
+ ],
|
||||
+ });
|
||||
+ let module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
+ label: Some("Mod view blit"),
|
||||
+ source: wgpu::ShaderSource::Wgsl(BLIT.into()),
|
||||
+ });
|
||||
+ let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||
+ label: Some("Mod view blit"),
|
||||
+ bind_group_layouts: &[Some(&layout)],
|
||||
+ ..Default::default()
|
||||
+ });
|
||||
+ let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||
+ label: Some("Mod view blit"),
|
||||
+ layout: Some(&pipeline_layout),
|
||||
+ vertex: wgpu::VertexState {
|
||||
+ module: &module,
|
||||
+ entry_point: Some("vs"),
|
||||
+ compilation_options: Default::default(),
|
||||
+ buffers: &[],
|
||||
+ },
|
||||
+ fragment: Some(wgpu::FragmentState {
|
||||
+ module: &module,
|
||||
+ entry_point: Some("fs"),
|
||||
+ compilation_options: Default::default(),
|
||||
+ targets: &[Some(wgpu::ColorTargetState {
|
||||
+ format,
|
||||
+ blend: None,
|
||||
+ write_mask: wgpu::ColorWrites::ALL,
|
||||
+ })],
|
||||
+ }),
|
||||
+ primitive: Default::default(),
|
||||
+ depth_stencil: None,
|
||||
+ multisample: Default::default(),
|
||||
+ multiview_mask: None,
|
||||
+ cache: None,
|
||||
+ });
|
||||
+ let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||
+ label: Some("Mod view picture"),
|
||||
+ mag_filter: wgpu::FilterMode::Linear,
|
||||
+ min_filter: wgpu::FilterMode::Linear,
|
||||
+ ..Default::default()
|
||||
+ });
|
||||
+ let main = device.create_buffer(&wgpu::BufferDescriptor {
|
||||
+ label: Some("Camera globals"),
|
||||
+ size: globals_size,
|
||||
+ usage: wgpu::BufferUsages::COPY_SRC | wgpu::BufferUsages::COPY_DST,
|
||||
+ mapped_at_creation: false,
|
||||
+ });
|
||||
+ Self {
|
||||
+ targets: HashMap::new(),
|
||||
+ main,
|
||||
+ cursor: 0,
|
||||
+ format,
|
||||
+ layout,
|
||||
+ sampler,
|
||||
+ pipeline,
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /// The cameras to draw this frame, in turn, at most `PER_FRAME`; their
|
||||
+ /// targets made or remade to size, the gone ones' dropped.
|
||||
+ pub fn choose<'a>(
|
||||
+ &mut self,
|
||||
+ device: &wgpu::Device,
|
||||
+ views: &'a [ModView],
|
||||
+ globals_size: u64,
|
||||
+ ) -> Vec<&'a ModView> {
|
||||
+ self.targets.retain(|id, _| views.iter().any(|v| v.id == *id));
|
||||
+ for v in views {
|
||||
+ if self.targets.get(&v.id).is_none_or(|t| t.size != v.size) {
|
||||
+ let t = self.target(device, v.size, globals_size);
|
||||
+ self.targets.insert(v.id, t);
|
||||
+ }
|
||||
+ }
|
||||
+ if views.is_empty() {
|
||||
+ return Vec::new();
|
||||
+ }
|
||||
+ let n = views.len().min(PER_FRAME);
|
||||
+ let start = self.cursor % views.len();
|
||||
+ self.cursor = self.cursor.wrapping_add(n);
|
||||
+ (0..n).map(|k| &views[(start + k) % views.len()]).collect()
|
||||
+ }
|
||||
+
|
||||
+ fn target(&self, device: &wgpu::Device, size: [u32; 2], globals_size: u64) -> Target {
|
||||
+ let extent = wgpu::Extent3d {
|
||||
+ width: size[0],
|
||||
+ height: size[1],
|
||||
+ depth_or_array_layers: 1,
|
||||
+ };
|
||||
+ let texture = |label, format, usage| {
|
||||
+ device
|
||||
+ .create_texture(&wgpu::TextureDescriptor {
|
||||
+ label: Some(label),
|
||||
+ size: extent,
|
||||
+ mip_level_count: 1,
|
||||
+ sample_count: 1,
|
||||
+ dimension: wgpu::TextureDimension::D2,
|
||||
+ format,
|
||||
+ usage,
|
||||
+ view_formats: &[],
|
||||
+ })
|
||||
+ .create_view(&Default::default())
|
||||
+ };
|
||||
+ let color = texture(
|
||||
+ "Mod view colour",
|
||||
+ self.format,
|
||||
+ wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING,
|
||||
+ );
|
||||
+ let depth = texture(
|
||||
+ "Mod view depth",
|
||||
+ wgpu::TextureFormat::Depth32Float,
|
||||
+ wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||
+ );
|
||||
+ let blit = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
+ label: Some("Mod view picture"),
|
||||
+ layout: &self.layout,
|
||||
+ entries: &[
|
||||
+ wgpu::BindGroupEntry {
|
||||
+ binding: 0,
|
||||
+ resource: wgpu::BindingResource::TextureView(&color),
|
||||
+ },
|
||||
+ wgpu::BindGroupEntry {
|
||||
+ binding: 1,
|
||||
+ resource: wgpu::BindingResource::Sampler(&self.sampler),
|
||||
+ },
|
||||
+ ],
|
||||
+ });
|
||||
+ let globals = device.create_buffer(&wgpu::BufferDescriptor {
|
||||
+ label: Some("Mod view globals"),
|
||||
+ size: globals_size,
|
||||
+ usage: wgpu::BufferUsages::COPY_SRC | wgpu::BufferUsages::COPY_DST,
|
||||
+ mapped_at_creation: false,
|
||||
+ });
|
||||
+ Target {
|
||||
+ size,
|
||||
+ color,
|
||||
+ depth,
|
||||
+ globals,
|
||||
+ blit,
|
||||
+ drawn: false,
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /// Shows a camera's picture in `rect` (framebuffer pixels) of `screen`.
|
||||
+ pub fn blit(
|
||||
+ &self,
|
||||
+ encoder: &mut wgpu::CommandEncoder,
|
||||
+ screen: &wgpu::TextureView,
|
||||
+ screen_size: [u32; 2],
|
||||
+ view: &HudView,
|
||||
+ scale: f32,
|
||||
+ ) {
|
||||
+ let Some(t) = self.targets.get(&view.id).filter(|t| t.drawn) else {
|
||||
+ return;
|
||||
+ };
|
||||
+ let [x, y, w, h] = view.rect.map(|v| v * scale);
|
||||
+ let (x0, y0) = (x.max(0.0), y.max(0.0));
|
||||
+ let x1 = (x + w).min(screen_size[0] as f32);
|
||||
+ let y1 = (y + h).min(screen_size[1] as f32);
|
||||
+ if x1 - x0 < 1.0 || y1 - y0 < 1.0 {
|
||||
+ return;
|
||||
+ }
|
||||
+ let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
+ label: Some("Mod view picture"),
|
||||
+ color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
+ view: screen,
|
||||
+ resolve_target: None,
|
||||
+ depth_slice: None,
|
||||
+ ops: wgpu::Operations {
|
||||
+ load: wgpu::LoadOp::Load,
|
||||
+ store: wgpu::StoreOp::Store,
|
||||
+ },
|
||||
+ })],
|
||||
+ ..Default::default()
|
||||
+ });
|
||||
+ pass.set_viewport(x, y, w, h, 0.0, 1.0);
|
||||
+ pass.set_scissor_rect(x0 as u32, y0 as u32, (x1 - x0) as u32, (y1 - y0) as u32);
|
||||
+ pass.set_pipeline(&self.pipeline);
|
||||
+ pass.set_bind_group(0, &t.blit, &[]);
|
||||
+ let mode = view.mode.min(2);
|
||||
+ pass.draw(0..3, mode..mode + 1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/// A camera's view and projection: the view from `camera`, moved so that
|
||||
+/// geometry relative to `eye` (the player's camera) lands right.
|
||||
+pub(super) fn matrices(v: &ModView, eye: DVec3, far: f32) -> (Mat4, Mat4, f32) {
|
||||
+ let aspect = v.size[0] as f32 / v.size[1].max(1) as f32;
|
||||
+ let view = crate::camera::view_matrix(v.yaw, v.pitch);
|
||||
+ let projection = super::world_projection(v.fov, aspect, far);
|
||||
+ let offset = (eye - v.camera).as_vec3();
|
||||
+ (projection * view * Mat4::from_translation(offset), view, aspect)
|
||||
+}
|
||||
diff --git a/crates/horizon-client/src/hud.rs b/crates/horizon-client/src/hud.rs
|
||||
index fda0094d8..41af0650e 100644
|
||||
--- a/crates/horizon-client/src/hud.rs
|
||||
+++ b/crates/horizon-client/src/hud.rs
|
||||
@@ -625,6 +625,17 @@ pub struct HudVertex {
|
||||
}
|
||||
/// The GUI Scale option (0 = auto).
|
||||
pub static GUI_SCALE: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
|
||||
+/// Where the HUD shows a mod camera's picture (AirDef fork): before its
|
||||
+/// vertex `at`, over what was drawn before.
|
||||
+#[derive(Clone, Copy, Debug)]
|
||||
+pub struct HudView {
|
||||
+ pub at: u32,
|
||||
+ pub id: u32,
|
||||
+ /// GUI pixels: x, y, width, height.
|
||||
+ pub rect: [f32; 4],
|
||||
+ /// 0 as seen, 1 thermal, 2 night vision.
|
||||
+ pub mode: u32,
|
||||
+}
|
||||
/// One frame of overlay geometry in GUI pixels.
|
||||
pub struct HudBatch {
|
||||
pub vertices: Vec<HudVertex>,
|
||||
@@ -641,6 +652,8 @@ pub struct HudBatch {
|
||||
pub glint_alpha: f32,
|
||||
/// Screen's first vertex: the preceding HUD is part of its blurred background.
|
||||
pub blur_at: u32,
|
||||
+ /// Mod cameras' pictures, in vertex order.
|
||||
+ pub views: Vec<HudView>,
|
||||
}
|
||||
/// How a run of HUD vertices blends and tests depth.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
@@ -692,6 +705,7 @@ impl HudBatch {
|
||||
end_portal: EndPortalFill::default(),
|
||||
glint_alpha: 0.75,
|
||||
blur_at: 0,
|
||||
+ views: Vec::new(),
|
||||
}
|
||||
}
|
||||
/// Draw the vertices added since `start` with the inverting blend.
|
||||
@@ -2008,6 +2022,7 @@ mod tests {
|
||||
end_portal: EndPortalFill::default(),
|
||||
glint_alpha: 0.75,
|
||||
blur_at: 0,
|
||||
+ views: Vec::new(),
|
||||
};
|
||||
for (image_width, image_height) in [(195, 136), (176, 166), (176, 222)] {
|
||||
assert_eq!(
|
||||
diff --git a/crates/horizon-mod-sdk/wit/horizon.wit b/crates/horizon-mod-sdk/wit/horizon.wit
|
||||
index 1b167c7f7..436455a19 100644
|
||||
--- a/crates/horizon-mod-sdk/wit/horizon.wit
|
||||
+++ b/crates/horizon-mod-sdk/wit/horizon.wit
|
||||
@@ -338,12 +338,21 @@ interface render {
|
||||
centered: bool,
|
||||
shadow: bool,
|
||||
}
|
||||
+ /// A picture of one of the mod's `set-views` cameras (AirDef fork).
|
||||
+ record view-shape {
|
||||
+ /// The camera's id; an unknown one draws nothing.
|
||||
+ view: u32,
|
||||
+ rect: rect,
|
||||
+ /// 0 as seen, 1 thermal (white hot), 2 night vision (green).
|
||||
+ mode: u32,
|
||||
+ }
|
||||
variant shape {
|
||||
fill(fill-shape),
|
||||
quad(quad-shape),
|
||||
sprite(sprite-shape),
|
||||
item(item-shape),
|
||||
text(text-shape),
|
||||
+ view(view-shape),
|
||||
}
|
||||
/// Replaces the mod's HUD shapes: up to 1024, drawn every frame in
|
||||
/// order over the HUD (after the hotbar, under chat and screens), hidden
|
||||
@@ -500,6 +509,27 @@ interface render {
|
||||
/// replaced; call it once a tick (the pass gets the partial tick in
|
||||
/// `frame.time.y`).
|
||||
set-params: func(params: list<f32>);
|
||||
+ /// A camera the game renders the world from besides the player's eye
|
||||
+ /// (AirDef fork): the land, the sky and the entities near the player.
|
||||
+ record camera-view {
|
||||
+ /// Stays the same while the camera lives: the game turns it smoothly
|
||||
+ /// between the last two `set-views`.
|
||||
+ id: u32,
|
||||
+ x: f64,
|
||||
+ y: f64,
|
||||
+ z: f64,
|
||||
+ /// Degrees, as the player's: yaw 0 looks south (+z), pitch 90 down.
|
||||
+ yaw: f32,
|
||||
+ pitch: f32,
|
||||
+ /// Vertical field of view, degrees (1 to 110).
|
||||
+ fov: f32,
|
||||
+ /// The picture's size in pixels (16 to 640 × 16 to 480).
|
||||
+ width: u32,
|
||||
+ height: u32,
|
||||
+ }
|
||||
+ /// Replaces the mod's cameras: up to 8. A `view` shape shows one; the
|
||||
+ /// game renders up to three a frame, in turn.
|
||||
+ set-views: func(views: list<camera-view>);
|
||||
}
|
||||
|
||||
/// What the game calls. Only the hooks `init` asks for are ever called.
|
||||
diff --git a/crates/horizon-mods/src/api_level.rs b/crates/horizon-mods/src/api_level.rs
|
||||
index 68487e600..9d15851b4 100644
|
||||
--- a/crates/horizon-mods/src/api_level.rs
|
||||
+++ b/crates/horizon-mods/src/api_level.rs
|
||||
@@ -7,13 +7,13 @@
|
||||
//! version's level so the launcher can tell before it installs.
|
||||
|
||||
/// The newest level this Horizon serves.
|
||||
-pub const LEVEL: u32 = 8;
|
||||
+pub const LEVEL: u32 = 9;
|
||||
|
||||
/// Every function the game offers mods, as `interface.function`, with its
|
||||
/// level. Level 0 is the contract of Horizon 0.2.67 to 0.2.69. A new
|
||||
/// function takes the next level and raises [`LEVEL`] (the `api_reference`
|
||||
/// test fails until it is listed here).
|
||||
-pub const FUNCTIONS: [(&str, u32); 54] = [
|
||||
+pub const FUNCTIONS: [(&str, u32); 55] = [
|
||||
("log.write", 0),
|
||||
("game.get-player", 0),
|
||||
("game.get-clock", 0),
|
||||
@@ -69,6 +69,7 @@ pub const FUNCTIONS: [(&str, u32); 54] = [
|
||||
("render.set-post", 8),
|
||||
("render.clear-post", 8),
|
||||
("render.set-params", 8),
|
||||
+ ("render.set-views", 9),
|
||||
];
|
||||
|
||||
/// What the game's program carries so the launcher can read its level
|
||||
diff --git a/crates/horizon-mods/src/runtime.rs b/crates/horizon-mods/src/runtime.rs
|
||||
index 55c1fd13f..01000dfeb 100644
|
||||
--- a/crates/horizon-mods/src/runtime.rs
|
||||
+++ b/crates/horizon-mods/src/runtime.rs
|
||||
@@ -81,7 +81,7 @@ pub use render_bindings::horizon::mods::input::{Event as InputEvent, HeldItem, I
|
||||
pub use render_bindings::horizon::mods::render::{
|
||||
Corner as RenderCorner, FarTerrain as ModFarTerrain, FillShape, FrameRate, ItemShape,
|
||||
Minimap as ModMinimap, ModelInstance, ParticleSpawn, Point as RenderPoint, QuadShape,
|
||||
- Rect as RenderRect, Shape, SpriteShape, TextShape, Zoom as ModZoom,
|
||||
+ CameraView, Rect as RenderRect, Shape, SpriteShape, TextShape, ViewShape, Zoom as ModZoom,
|
||||
};
|
||||
use render_bindings::{RenderHost, horizon::mods::render};
|
||||
/// Capability `recipes`'s imports (docs/mods.md): the game's recipes and items.
|
||||
@@ -435,6 +435,8 @@ struct State {
|
||||
/// `render.set-post`'s source, with a number that changes with it.
|
||||
post: Option<(u64, String)>,
|
||||
post_params: Vec<f32>,
|
||||
+ /// `render.set-views`' cameras (AirDef fork).
|
||||
+ views: Vec<CameraView>,
|
||||
input: InputState,
|
||||
browser: BrowserState,
|
||||
/// Capability `storage`'s folder; made on first `set`.
|
||||
@@ -643,6 +645,7 @@ impl Mods {
|
||||
ground: Vec::new(),
|
||||
post: None,
|
||||
post_params: Vec::new(),
|
||||
+ views: Vec::new(),
|
||||
input: InputState::default(),
|
||||
browser: BrowserState::default(),
|
||||
data_dir,
|
||||
@@ -1206,6 +1209,14 @@ impl Mods {
|
||||
.flat_map(move |r| r.store.data().models.iter().map(move |m| (i, m)))
|
||||
})
|
||||
}
|
||||
+ /// Every running mod's cameras (AirDef fork), with the mod's index.
|
||||
+ pub fn views(&self) -> impl Iterator<Item = (usize, &CameraView)> {
|
||||
+ self.entries.iter().enumerate().flat_map(|(i, e)| {
|
||||
+ e.run
|
||||
+ .iter()
|
||||
+ .flat_map(move |r| r.store.data().views.iter().map(move |v| (i, v)))
|
||||
+ })
|
||||
+ }
|
||||
/// The columns each running mod asked the ground height of, taken.
|
||||
pub fn take_ground_queries(&mut self) -> Vec<(usize, Vec<(i32, i32)>)> {
|
||||
self.entries
|
||||
@@ -1969,6 +1980,23 @@ impl render::Host for State {
|
||||
.map(|v| if v.is_finite() { v } else { 0.0 })
|
||||
.collect();
|
||||
}
|
||||
+ fn set_views(&mut self, views: Vec<CameraView>) {
|
||||
+ let finite = |v: f64| v.is_finite() && v.abs() < 30_000_000.0;
|
||||
+ let angle = |v: f32| if v.is_finite() { v } else { 0.0 };
|
||||
+ self.views = views
|
||||
+ .into_iter()
|
||||
+ .filter(|v| finite(v.x) && finite(v.y) && finite(v.z))
|
||||
+ .take(8)
|
||||
+ .map(|mut v| {
|
||||
+ v.yaw = angle(v.yaw);
|
||||
+ v.pitch = angle(v.pitch).clamp(-90.0, 90.0);
|
||||
+ v.fov = if v.fov.is_finite() { v.fov.clamp(1.0, 110.0) } else { 70.0 };
|
||||
+ v.width = v.width.clamp(16, 640);
|
||||
+ v.height = v.height.clamp(16, 480);
|
||||
+ v
|
||||
+ })
|
||||
+ .collect();
|
||||
+ }
|
||||
fn query_ground(&mut self, columns: Vec<(i32, i32)>) {
|
||||
let room = 512usize.saturating_sub(self.ground_queries.len());
|
||||
self.ground_queries.extend(columns.into_iter().take(room));
|
||||
--
|
||||
2.54.0 (Apple Git-157)
|
||||
|
||||