mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d0f564a00 | ||
|
|
effac5aaf6 | ||
|
|
25579c6c0d | ||
|
|
4cabbd03a7 | ||
|
|
d1b2c05eb4 | ||
|
|
00d7ac0c45 | ||
|
|
8ef2c946db |
No files matched your search
@@ -0,0 +1,52 @@
|
||||
root = true
|
||||
|
||||
[*.cs]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
# Match the existing Unity C# sources; keep each file's existing BOM.
|
||||
end_of_line = crlf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
csharp_indent_block_contents = true
|
||||
csharp_indent_braces = false
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_case_contents_when_block = false
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_labels = one_less_than_current
|
||||
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = none
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_before_comma = false
|
||||
csharp_space_after_comma = true
|
||||
csharp_space_before_dot = false
|
||||
csharp_space_after_dot = false
|
||||
csharp_space_before_semicolon_in_for_statement = false
|
||||
csharp_space_after_semicolon_in_for_statement = true
|
||||
csharp_space_before_open_square_brackets = false
|
||||
csharp_space_between_square_brackets = false
|
||||
csharp_space_between_empty_square_brackets = false
|
||||
csharp_preserve_single_line_statements = false
|
||||
csharp_preserve_single_line_blocks = false
|
||||
|
||||
# SDK whitespace formatting does not enforce spacing between members.
|
||||
# These targeted StyleCop rules also run through tools/CodeStyle.
|
||||
dotnet_diagnostic.SA1107.severity = warning
|
||||
dotnet_diagnostic.SA1502.severity = warning
|
||||
dotnet_diagnostic.SA1507.severity = warning
|
||||
dotnet_diagnostic.SA1516.severity = warning
|
||||
@@ -0,0 +1,50 @@
|
||||
# Continuous integration
|
||||
|
||||
GitHub Actions builds PAL3 and PAL3A with the Unity version in
|
||||
`ProjectSettings/ProjectVersion.txt`. Each variant covers Android, iOS,
|
||||
macOS, Linux, and 32-bit/64-bit Windows. The workflows run only on pull requests.
|
||||
New commits cancel superseded runs for the same pull request and workflow.
|
||||
Successful desktop/Android builds upload artifacts.
|
||||
|
||||
The README badges show each workflow's latest pull request build using
|
||||
`event=pull_request`, with no branch filter. Without the event filter, GitHub's
|
||||
badges prefer the default branch and can keep showing old push builds after a
|
||||
workflow switches to PR-only triggers. The badge links filter the build history
|
||||
to pull requests as well.
|
||||
|
||||
The separate `Code style` workflow runs the .NET CLI in `tools/CodeStyle`, using
|
||||
`.editorconfig` and the SDK pinned in `global.json`.
|
||||
It calls the SDK's `dotnet format` for whitespace and StyleCop 1.3.180 layout rules
|
||||
SA1107, SA1502, SA1507 and SA1516 to enforce separate statements, multiline blocks
|
||||
and blank lines between members. StyleCop is restored only into the temporary
|
||||
formatting project.
|
||||
It parses both PAL3 and PAL3A conditional branches without Unity or game data.
|
||||
Run `dotnet run --project tools/CodeStyle --` locally to format current changes,
|
||||
then `dotnet run --project tools/CodeStyle -- --check` to verify them.
|
||||
The formatter and its tests require no Python, Unity installation or game data.
|
||||
CI runs `dotnet test tools/CodeStyle.Tests`, then uses the SDK's
|
||||
`dotnet format whitespace --verify-no-changes` on both `tools/CodeStyle` and
|
||||
`tools/CodeStyle.Tests` to check the tool's own sources. Finally, it selects PR changes with
|
||||
`--check --base <base-sha>`; `--all` is an explicit full-source audit, not the default.
|
||||
Default and `--base` runs apply formatting only to changed lines and deletion
|
||||
boundaries, preserving existing formatting elsewhere. Explicit file/directory
|
||||
paths and `--all` format whole files. Check mode operates on temporary copies.
|
||||
This checks whitespace and layout, not semantic correctness or Unity behavior.
|
||||
See the [tool README](../tools/CodeStyle/README.md) for commands and scope.
|
||||
|
||||
Codacy is not part of this repository's CI. Its repository webhook is disabled;
|
||||
there is no Codacy workflow or Codacy-required branch protection check. Re-enabling
|
||||
that external integration would resume its checks independently of these workflows.
|
||||
|
||||
The workflows use checkout v7.0.1, cache v6.1.0, and unity-builder v6.0.0.
|
||||
The builder CLI is pinned to v0.1.73 so its behavior does not change independently
|
||||
of the workflow. Update and validate this pin together with builder upgrades.
|
||||
|
||||
Keep the committed project configured for PAL3. PAL3A workflows switch their own
|
||||
checkout before building. Do not add original game data to CI inputs.
|
||||
|
||||
When investigating a failure, inspect the failed job's Unity/build logs first.
|
||||
Retry an isolated runner or network failure after checking the log; fix reproducible
|
||||
source/build problems without bypassing the build checks. A successful CI build
|
||||
checks compilation and packaging, and does not replace device or game-data runtime
|
||||
validation.
|
||||
@@ -1,20 +0,0 @@
|
||||
# Continuous integration
|
||||
|
||||
GitHub Actions builds PAL3 and PAL3A with the Unity version in
|
||||
`ProjectSettings/ProjectVersion.txt`. Each variant covers Android, iOS,
|
||||
macOS, Linux, and 32-bit/64-bit Windows. The workflows run on pushes and pull
|
||||
requests, and successful desktop/Android builds upload artifacts.
|
||||
|
||||
Codacy is not part of this repository's CI. Its repository webhook is disabled;
|
||||
there is no Codacy workflow or Codacy-required branch protection check. Re-enabling
|
||||
that external integration would resume its checks independently of these workflows.
|
||||
|
||||
Keep the committed project configured for PAL3. PAL3A workflows switch their own
|
||||
checkout before building. Public builds reject imported private VFX and legacy Toon assets;
|
||||
do not add them or original game data to CI inputs.
|
||||
|
||||
When investigating a failure, inspect the failed job's Unity/build logs first.
|
||||
Retry an isolated runner or network failure after checking the log; fix reproducible
|
||||
source/build problems without bypassing the build checks. A successful CI build
|
||||
checks compilation and packaging, and does not replace device or game-data runtime
|
||||
validation.
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Builds - PAL3 - Mono - Android
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_pal3_mono_android:
|
||||
@@ -21,16 +25,16 @@ jobs:
|
||||
large-packages: true
|
||||
docker-images: true
|
||||
swap-storage: true
|
||||
- uses: actions/checkout@v6.0.3
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v5.0.5
|
||||
- uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v5
|
||||
- uses: game-ci/unity-builder@v6.0.0
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
@@ -39,8 +43,9 @@ jobs:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
cliVersion: v0.1.73
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
retention-days: 14
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Builds - PAL3 - Mono - iOS
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_pal3_mono_ios:
|
||||
@@ -12,16 +16,16 @@ jobs:
|
||||
targetPlatform:
|
||||
- iOS # Build an iOS player.
|
||||
steps:
|
||||
- uses: actions/checkout@v6.0.3
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v5.0.5
|
||||
- uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v5
|
||||
- uses: game-ci/unity-builder@v6.0.0
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
@@ -30,4 +34,5 @@ jobs:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
# do not upload artifacts for iOS builds
|
||||
cliVersion: v0.1.73
|
||||
# do not upload artifacts for iOS builds
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Builds - PAL3 - Mono - Linux
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_pal3_mono_linux:
|
||||
@@ -12,16 +16,16 @@ jobs:
|
||||
targetPlatform:
|
||||
- StandaloneLinux64 # Build a Linux 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v6.0.3
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v5.0.5
|
||||
- uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v5
|
||||
- uses: game-ci/unity-builder@v6.0.0
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
@@ -30,8 +34,9 @@ jobs:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
cliVersion: v0.1.73
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
retention-days: 14
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Builds - PAL3 - Mono - MacOS
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_pal3_mono_macos:
|
||||
@@ -12,16 +16,16 @@ jobs:
|
||||
targetPlatform:
|
||||
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
|
||||
steps:
|
||||
- uses: actions/checkout@v6.0.3
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v5.0.5
|
||||
- uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v5
|
||||
- uses: game-ci/unity-builder@v6.0.0
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
@@ -30,8 +34,9 @@ jobs:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
cliVersion: v0.1.73
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
retention-days: 14
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Builds - PAL3 - Mono - Windows
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_pal3_mono_windows:
|
||||
@@ -13,16 +17,16 @@ jobs:
|
||||
- StandaloneWindows # Build a Windows standalone.
|
||||
- StandaloneWindows64 # Build a Windows 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v6.0.3
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v5.0.5
|
||||
- uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v5
|
||||
- uses: game-ci/unity-builder@v6.0.0
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
@@ -31,8 +35,9 @@ jobs:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
cliVersion: v0.1.73
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
retention-days: 14
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Builds - PAL3A - Mono - Android
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_pal3a_mono_android:
|
||||
@@ -21,28 +25,27 @@ jobs:
|
||||
large-packages: true
|
||||
docker-images: true
|
||||
swap-storage: true
|
||||
- uses: actions/checkout@v6.0.3
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Switch define symbol from PAL3 to PAL3A
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "PAL3"
|
||||
replace: "PAL3A"
|
||||
include: "**ProjectSettings.asset"
|
||||
- name: Switch project settings from PAL3 to PAL3A
|
||||
run: |
|
||||
settings=ProjectSettings/ProjectSettings.asset
|
||||
sed -E 's/PAL3([^[:alnum:]_]|$)/PAL3A\1/g' "$settings" > "$settings.tmp"
|
||||
mv "$settings.tmp" "$settings"
|
||||
- name: Replace PAL3 game icon with PAL3A one
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v5.0.5
|
||||
- uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v5
|
||||
- uses: game-ci/unity-builder@v6.0.0
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
@@ -52,8 +55,9 @@ jobs:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
cliVersion: v0.1.73
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
retention-days: 14
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Builds - PAL3A - Mono - iOS
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_pal3a_mono_ios:
|
||||
@@ -12,28 +16,27 @@ jobs:
|
||||
targetPlatform:
|
||||
- iOS # Build an iOS player.
|
||||
steps:
|
||||
- uses: actions/checkout@v6.0.3
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Switch define symbol from PAL3 to PAL3A
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "PAL3"
|
||||
replace: "PAL3A"
|
||||
include: "**ProjectSettings.asset"
|
||||
- name: Switch project settings from PAL3 to PAL3A
|
||||
run: |
|
||||
settings=ProjectSettings/ProjectSettings.asset
|
||||
sed -E 's/PAL3([^[:alnum:]_]|$)/PAL3A\1/g' "$settings" > "$settings.tmp"
|
||||
mv "$settings.tmp" "$settings"
|
||||
- name: Replace PAL3 game icon with PAL3A one
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v5.0.5
|
||||
- uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v5
|
||||
- uses: game-ci/unity-builder@v6.0.0
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
@@ -43,4 +46,5 @@ jobs:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
# do not upload artifacts for iOS builds
|
||||
cliVersion: v0.1.73
|
||||
# do not upload artifacts for iOS builds
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Builds - PAL3A - Mono - Linux
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_pal3a_mono_linux:
|
||||
@@ -12,28 +16,27 @@ jobs:
|
||||
targetPlatform:
|
||||
- StandaloneLinux64 # Build a Linux 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v6.0.3
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Switch define symbol from PAL3 to PAL3A
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "PAL3"
|
||||
replace: "PAL3A"
|
||||
include: "**ProjectSettings.asset"
|
||||
- name: Switch project settings from PAL3 to PAL3A
|
||||
run: |
|
||||
settings=ProjectSettings/ProjectSettings.asset
|
||||
sed -E 's/PAL3([^[:alnum:]_]|$)/PAL3A\1/g' "$settings" > "$settings.tmp"
|
||||
mv "$settings.tmp" "$settings"
|
||||
- name: Replace PAL3 game icon with PAL3A one
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v5.0.5
|
||||
- uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v5
|
||||
- uses: game-ci/unity-builder@v6.0.0
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
@@ -43,8 +46,9 @@ jobs:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
cliVersion: v0.1.73
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
retention-days: 14
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Builds - PAL3A - Mono - MacOS
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_pal3a_mono_macos:
|
||||
@@ -12,28 +16,27 @@ jobs:
|
||||
targetPlatform:
|
||||
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
|
||||
steps:
|
||||
- uses: actions/checkout@v6.0.3
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Switch define symbol from PAL3 to PAL3A
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "PAL3"
|
||||
replace: "PAL3A"
|
||||
include: "**ProjectSettings.asset"
|
||||
- name: Switch project settings from PAL3 to PAL3A
|
||||
run: |
|
||||
settings=ProjectSettings/ProjectSettings.asset
|
||||
sed -E 's/PAL3([^[:alnum:]_]|$)/PAL3A\1/g' "$settings" > "$settings.tmp"
|
||||
mv "$settings.tmp" "$settings"
|
||||
- name: Replace PAL3 game icon with PAL3A one
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v5.0.5
|
||||
- uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v5
|
||||
- uses: game-ci/unity-builder@v6.0.0
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
@@ -43,8 +46,9 @@ jobs:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
cliVersion: v0.1.73
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
retention-days: 14
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Builds - PAL3A - Mono - Windows
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_pal3a_mono_windows:
|
||||
@@ -13,28 +17,27 @@ jobs:
|
||||
- StandaloneWindows # Build a Windows standalone.
|
||||
- StandaloneWindows64 # Build a Windows 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v6.0.3
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Switch define symbol from PAL3 to PAL3A
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "PAL3"
|
||||
replace: "PAL3A"
|
||||
include: "**ProjectSettings.asset"
|
||||
- name: Switch project settings from PAL3 to PAL3A
|
||||
run: |
|
||||
settings=ProjectSettings/ProjectSettings.asset
|
||||
sed -E 's/PAL3([^[:alnum:]_]|$)/PAL3A\1/g' "$settings" > "$settings.tmp"
|
||||
mv "$settings.tmp" "$settings"
|
||||
- name: Replace PAL3 game icon with PAL3A one
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v5.0.5
|
||||
- uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v5
|
||||
- uses: game-ci/unity-builder@v6.0.0
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
@@ -44,8 +47,9 @@ jobs:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
cliVersion: v0.1.73
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,44 @@
|
||||
name: Code style
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
csharp-format:
|
||||
name: C# formatting (PAL3 and PAL3A)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-dotnet@v5.3.0
|
||||
with:
|
||||
global-json-file: global.json
|
||||
- name: Test formatter enforcement
|
||||
run: dotnet test tools/CodeStyle.Tests
|
||||
- name: Verify .NET tool source formatting
|
||||
run: |
|
||||
dotnet format whitespace tools/CodeStyle --no-restore --verify-no-changes
|
||||
dotnet format whitespace tools/CodeStyle.Tests --no-restore --verify-no-changes
|
||||
- name: Verify changed C# formatting
|
||||
env:
|
||||
BASE_REF: ${{ github.event.pull_request.base.sha }}
|
||||
run: dotnet run --project tools/CodeStyle -- --check --base "$BASE_REF"
|
||||
|
||||
battle-rules:
|
||||
name: Battle rules (PAL3 and PAL3A)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.1
|
||||
- uses: actions/setup-dotnet@v5.3.0
|
||||
with:
|
||||
global-json-file: global.json
|
||||
- name: Run engine-independent battle tests
|
||||
run: dotnet test tools/Battle.Tests
|
||||
+15
-15
@@ -77,20 +77,20 @@ crashlytics-build.properties
|
||||
# Unity StreamingAssets folder
|
||||
/Assets/StreamingAssets
|
||||
|
||||
# 3rd party plugin/assets
|
||||
/Assets/Hovl Studio
|
||||
/Assets/Hovl Studio.meta
|
||||
/Assets/RealToon
|
||||
/Assets/RealToon.meta
|
||||
|
||||
# VFX prefabs that are using 3rd party assets
|
||||
/Assets/Resources/Prefabs/VFX/PAL3/*.prefab
|
||||
/Assets/Resources/Prefabs/VFX/PAL3/*.meta
|
||||
/Assets/Resources/Prefabs/VFX/PAL3A/*.prefab
|
||||
/Assets/Resources/Prefabs/VFX/PAL3A/*.meta
|
||||
|
||||
# Materials that are using 3rd party assets
|
||||
/Assets/Resources/Materials/
|
||||
|
||||
# VS Conde config file
|
||||
.vsconfig
|
||||
|
||||
# Local asset imports
|
||||
/Assets/Hovl Studio/
|
||||
/Assets/Hovl Studio.meta
|
||||
/Assets/RealToon/
|
||||
/Assets/RealToon.meta
|
||||
/Assets/Resources/Prefabs/VFX/
|
||||
/Assets/Resources/Prefabs/VFX.meta
|
||||
/Assets/Resources/Materials/
|
||||
/Assets/Resources/Materials.meta
|
||||
|
||||
# Standalone .NET developer tools
|
||||
/tools/**/bin/
|
||||
/tools/**/obj/
|
||||
/tools/**/TestResults/
|
||||
@@ -1,7 +1,7 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
reference: https://www.shadertoy.com/view/MsKXDh
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// Based on cician's shader from https://forum.unity3d.com/threads/simple-optimized-blur-shader.185327/#post-1267642
|
||||
// Based on RoundedCorners.shader from https://github.com/kirevdokimov/Unity-UI-Rounded-Corners
|
||||
// with some modifications
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// Based on https://www.shadertoy.com/view/4dl3R4
|
||||
|
||||
Shader "Pal3/Snow"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// See LICENSE in the project root.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#include "Pal3ToonInput.hlsl"
|
||||
|
||||
@@ -7,6 +10,8 @@ struct ToonDepthVaryings
|
||||
float4 positionCS : SV_POSITION;
|
||||
#if defined(PAL3_TOON_CUTOUT)
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 lightmapUV : TEXCOORD2;
|
||||
float4 paintedVertexColor : TEXCOORD3;
|
||||
#endif
|
||||
#if defined(PAL3_TOON_DEPTH_NORMALS)
|
||||
half3 normalWS : TEXCOORD1;
|
||||
@@ -25,6 +30,8 @@ ToonDepthVaryings ToonDepthVertex(ToonAttributes input)
|
||||
#endif
|
||||
#if defined(PAL3_TOON_CUTOUT)
|
||||
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
|
||||
output.lightmapUV = TRANSFORM_TEX(input.lightmapUV, _ShadowTex);
|
||||
output.paintedVertexColor = ToonPaintedVertexColor(input.color);
|
||||
#endif
|
||||
return output;
|
||||
}
|
||||
@@ -36,7 +43,14 @@ half ToonDepthFragment(ToonDepthVaryings input) : SV_Target
|
||||
#endif
|
||||
{
|
||||
#if defined(PAL3_TOON_CUTOUT)
|
||||
clip(SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv).a - _Threshold);
|
||||
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv);
|
||||
half alpha = color.a;
|
||||
if (_UnlitBackground > 0.5)
|
||||
{
|
||||
half4 lightmap = _HasShadowTex > 0.5 ? SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, input.lightmapUV) : 1.0;
|
||||
alpha = ToonPaintedTextureStages(color, lightmap, input.paintedVertexColor).a;
|
||||
}
|
||||
clip(alpha - _Threshold);
|
||||
#endif
|
||||
#if defined(PAL3_TOON_DEPTH_NORMALS)
|
||||
float3 normalWS = SafeNormalize(input.normalWS);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// See LICENSE in the project root.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#include "Pal3ToonInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
@@ -16,6 +19,7 @@ struct ToonVaryings
|
||||
float3 positionWS : TEXCOORD2;
|
||||
half3 normalWS : TEXCOORD3;
|
||||
float fogFactor : TEXCOORD4;
|
||||
float4 paintedVertexColor : TEXCOORD5;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
@@ -30,6 +34,7 @@ ToonVaryings ToonVertex(ToonAttributes input)
|
||||
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
|
||||
output.lightmapUV = TRANSFORM_TEX(input.lightmapUV, _ShadowTex);
|
||||
output.fogFactor = ComputeFogFactor(output.positionCS.z);
|
||||
output.paintedVertexColor = ToonPaintedVertexColor(input.color);
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -145,29 +150,53 @@ half4 ToonFragment(ToonVaryings input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv);
|
||||
half3 selectionTexture = color.rgb;
|
||||
half classificationAlpha = color.a;
|
||||
half4 lightmap = 1.0;
|
||||
if (_HasShadowTex > 0.5)
|
||||
lightmap = SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, input.lightmapUV);
|
||||
if (_UnlitBackground > 0.5)
|
||||
{
|
||||
color = ToonPaintedTextureStages(color, lightmap, input.paintedVertexColor);
|
||||
classificationAlpha = color.a;
|
||||
}
|
||||
#if defined(PAL3_TOON_CUTOUT)
|
||||
clip(color.a - _Threshold);
|
||||
clip(classificationAlpha - _Threshold);
|
||||
#elif defined(PAL3_TOON_TRANSPARENT)
|
||||
if (color.a >= _Threshold || (color.a <= 0.0 && _Threshold <= 1.0))
|
||||
if (classificationAlpha >= _Threshold || (classificationAlpha <= 0.0 && _Threshold <= 1.0))
|
||||
discard;
|
||||
#endif
|
||||
|
||||
half3 baked = 1.0;
|
||||
if (_HasShadowTex > 0.5)
|
||||
baked = SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, input.lightmapUV).rgb * _LightmapScale;
|
||||
if (_UnlitBackground > 0.5)
|
||||
{
|
||||
color.rgb *= _TintColor.rgb;
|
||||
color.rgb *= _BackgroundBrightness;
|
||||
}
|
||||
else
|
||||
{
|
||||
half3 baked = _HasShadowTex > 0.5 ? lightmap.rgb * _LightmapScale : 1.0;
|
||||
color *= _TintColor;
|
||||
#if defined(PAL3_TOON_WATER)
|
||||
// The first frame defines opacity for the full water animation.
|
||||
color.a = _Alpha;
|
||||
#endif
|
||||
#if defined(PAL3_TOON_TRANSPARENT)
|
||||
if (_ReceiveLighting < 0.5)
|
||||
color.rgb *= baked;
|
||||
else
|
||||
#endif
|
||||
color.rgb = ShadeToon(color.rgb, baked, input.positionCS, input.positionWS, SafeNormalize(input.normalWS));
|
||||
}
|
||||
|
||||
color *= _TintColor;
|
||||
#if defined(PAL3_TOON_WATER)
|
||||
// The first frame defines opacity for the full water animation.
|
||||
color.a = _Alpha;
|
||||
#if !defined(PAL3_TOON_CUTOUT) && !defined(PAL3_TOON_TRANSPARENT) && !defined(PAL3_TOON_WATER)
|
||||
// Opaque painted POL layers must remain opaque in the preview target.
|
||||
if (_UnlitBackground > 0.5)
|
||||
color.a = 1.0;
|
||||
#endif
|
||||
#if defined(PAL3_TOON_TRANSPARENT)
|
||||
if (_ReceiveLighting < 0.5)
|
||||
color.rgb *= baked;
|
||||
else
|
||||
#if !defined(PAL3_TOON_WATER)
|
||||
if (_BattleSelection >= 0)
|
||||
color.rgb = selectionTexture * _BattleSelection;
|
||||
#endif
|
||||
color.rgb = ShadeToon(color.rgb, baked, input.positionCS, input.positionWS, SafeNormalize(input.normalWS));
|
||||
|
||||
color.rgb = MixFog(color.rgb, input.fogFactor);
|
||||
return color;
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
// See LICENSE in the project root.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#ifndef PAL3_TOON_INPUT_INCLUDED
|
||||
#define PAL3_TOON_INPUT_INCLUDED
|
||||
@@ -10,16 +13,22 @@ SAMPLER(sampler_MainTex);
|
||||
TEXTURE2D(_ShadowTex);
|
||||
SAMPLER(sampler_ShadowTex);
|
||||
|
||||
float _GbVertexColor;
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainTex_ST;
|
||||
float4 _ShadowTex_ST;
|
||||
half4 _TintColor;
|
||||
half _BattleSelection;
|
||||
float _Threshold;
|
||||
float _HasShadowTex;
|
||||
float _LightmapScale;
|
||||
float _ReceiveLighting;
|
||||
float _ReceiveShadows;
|
||||
float _IsCharacter;
|
||||
float _UnlitBackground;
|
||||
float _BackgroundBrightness;
|
||||
float _SourceDiffuseAlpha;
|
||||
#if defined(PAL3_TOON_WATER)
|
||||
float _Alpha;
|
||||
#endif
|
||||
@@ -29,9 +38,27 @@ struct ToonAttributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float3 normalOS : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 lightmapUV : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
float4 ToonPaintedVertexColor(float4 vertexColor)
|
||||
{
|
||||
float4 color = _GbVertexColor > 0.5 ? vertexColor : float4(1, 1, 1, _SourceDiffuseAlpha);
|
||||
color.a *= _TintColor.a;
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 ToonPaintedTextureStages(half4 mainColor, half4 lightmap, float4 vertexColor)
|
||||
{
|
||||
// Original static POL stages. Painted surfaces remain independent of scene lights.
|
||||
vertexColor = saturate(vertexColor);
|
||||
if (_HasShadowTex > 0.5)
|
||||
return saturate(half4(lightmap.rgb * mainColor.rgb * 2,
|
||||
lightmap.a * mainColor.a * vertexColor.a * 2));
|
||||
return saturate(mainColor * vertexColor);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,7 @@
|
||||
// See LICENSE in the project root.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#include "Pal3ToonInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
// See LICENSE in the project root.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/ToonCutout"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _ReceiveLighting ("Receive Lighting", Float) = 1
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _BattleSelection ("Battle selection luminance", Float) = -1
|
||||
_TintColor ("Tint Color", Color) = (1, 1, 1, 1)
|
||||
_ShadowTex ("Baked Shadow", 2D) = "white" {}
|
||||
_HasShadowTex ("Has Baked Shadow", Float) = 0
|
||||
_LightmapScale ("Baked Light Scale", Float) = 1.666667
|
||||
_ReceiveShadows ("Receive Shadows", Float) = 1
|
||||
[HideInInspector] _IsCharacter ("Character", Float) = 0
|
||||
[HideInInspector] _UnlitBackground ("Painted background", Float) = 0
|
||||
[HideInInspector] _BackgroundBrightness ("Background brightness", Float) = 1
|
||||
[HideInInspector] _SourceDiffuseAlpha ("Original POL diffuse alpha", Float) = 1
|
||||
_Threshold ("Alpha Cutoff", Float) = 1
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
// See LICENSE in the project root.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/ToonOpaque"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _Threshold ("Alpha Cutoff", Float) = 1
|
||||
[HideInInspector] _ReceiveLighting ("Receive Lighting", Float) = 1
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _BattleSelection ("Battle selection luminance", Float) = -1
|
||||
_TintColor ("Tint Color", Color) = (1, 1, 1, 1)
|
||||
_ShadowTex ("Baked Shadow", 2D) = "white" {}
|
||||
_HasShadowTex ("Has Baked Shadow", Float) = 0
|
||||
_LightmapScale ("Baked Light Scale", Float) = 1.666667
|
||||
_ReceiveShadows ("Receive Shadows", Float) = 1
|
||||
[HideInInspector] _IsCharacter ("Character", Float) = 0
|
||||
[HideInInspector] _UnlitBackground ("Painted background", Float) = 0
|
||||
[HideInInspector] _BackgroundBrightness ("Background brightness", Float) = 1
|
||||
[HideInInspector] _SourceDiffuseAlpha ("Original POL diffuse alpha", Float) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
// See LICENSE in the project root.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/ToonTransparent"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _BattleSelection ("Battle selection luminance", Float) = -1
|
||||
_TintColor ("Tint Color", Color) = (1, 1, 1, 1)
|
||||
_ShadowTex ("Baked Shadow", 2D) = "white" {}
|
||||
_HasShadowTex ("Has Baked Shadow", Float) = 0
|
||||
_LightmapScale ("Baked Light Scale", Float) = 1.666667
|
||||
_ReceiveShadows ("Receive Shadows", Float) = 1
|
||||
[HideInInspector] _IsCharacter ("Character", Float) = 0
|
||||
[HideInInspector] _UnlitBackground ("Painted background", Float) = 0
|
||||
[HideInInspector] _BackgroundBrightness ("Background brightness", Float) = 1
|
||||
[HideInInspector] _SourceDiffuseAlpha ("Original POL diffuse alpha", Float) = 1
|
||||
_Threshold ("Alpha Cutoff", Float) = 1
|
||||
_ReceiveLighting ("Receive Lighting", Float) = 1
|
||||
[Enum(UnityEngine.Rendering.BlendMode)] _BlendSrcFactor ("Source Blend Factor", Int) = 5
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
// See LICENSE in the project root.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/ToonWater"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _Threshold ("Alpha Cutoff", Float) = 1
|
||||
[HideInInspector] _ReceiveLighting ("Receive Lighting", Float) = 1
|
||||
[HideInInspector] _IsCharacter ("Character", Float) = 0
|
||||
[HideInInspector] _BattleSelection ("Battle selection luminance", Float) = -1
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_ShadowTex ("Baked Shadow", 2D) = "white" {}
|
||||
_HasShadowTex ("Has Baked Shadow", Float) = 0
|
||||
_LightmapScale ("Baked Light Scale", Float) = 1.428571
|
||||
_Alpha ("Opacity", Range(0, 1)) = 0.5
|
||||
_ReceiveShadows ("Receive Shadows", Float) = 1
|
||||
[HideInInspector] _UnlitBackground ("Painted background", Float) = 0
|
||||
[HideInInspector] _BackgroundBrightness ("Background brightness", Float) = 1
|
||||
[HideInInspector] _SourceDiffuseAlpha ("Original POL diffuse alpha", Float) = 1
|
||||
[HideInInspector] _TintColor ("Tint Color", Color) = (1, 1, 1, 1)
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e65c4b938f18e6c4a86dc379157fac65
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,45 +0,0 @@
|
||||
因为当前特效的实现方式使用了第三方插件和素材,所以此文件夹内的所有prefab均添加进了gitignore里。
|
||||
请联系作者了解插件获取方式和特效prefab的获取方式。
|
||||
|
||||
0 => 传送法阵特效
|
||||
|
||||
15 => 单人传送特效
|
||||
98 => 重楼施法帮龙葵恢复肉身时的特效
|
||||
175 => 邪剑仙迷倒众人的特效
|
||||
224 => 丁小侠剧情狼妖受击特效
|
||||
251 => 邪剑仙变身特效
|
||||
252 => 邪剑仙传送离开时的特效
|
||||
254 => 重楼传送法术特效
|
||||
255 => 龙葵穿衣服的特效
|
||||
256 => 龙葵治疗他人特效
|
||||
257 => 治疗咒施法特效
|
||||
259 => 大型传送法施法前奏特效
|
||||
260 => 大型传送法阵特效收尾
|
||||
261 => 大型传送法阵特效开始
|
||||
262 => 重楼当剑的时候剑插入地面的火光特效
|
||||
263 => 火鬼王消失特效
|
||||
264 => 古藤精施法特效
|
||||
265 => 人物受到法术作用时候的特效
|
||||
266 => 邪剑仙施法特效
|
||||
270 => 天鬼皇复活后灵魂出窍特效
|
||||
275 => 重楼创建的用来禁锢雪见/龙葵的法阵特效
|
||||
276 => 迴魂施法结束特效
|
||||
277 => 迴魂施法完全结束特效
|
||||
278 => 迴魂施法特效
|
||||
290 => 雪见传送出现时特效
|
||||
295 => 重楼施法治疗特效
|
||||
297 => 紫萱施法召唤水灵特效
|
||||
337 => 古藤精风系法术特效
|
||||
341 => 邪剑仙给镇妖剑施法特效
|
||||
368 => 雷击单体施法特效
|
||||
369 => 雷击范围施法特效
|
||||
376 => 紫萱的土系法术特效
|
||||
389 => 紫萱给江姑娘施法特效
|
||||
452 => 花楹治疗他人特效
|
||||
453 => 人物施法蓄力时的特效
|
||||
454 => 龙葵施法让众人御剑飞行的特效
|
||||
456 => 老婆婆施法特效
|
||||
457 => 夕瑶给景天施法时的特效
|
||||
458 => 灵力溢出特效
|
||||
467 => 邪剑仙灰飞烟灭特效
|
||||
468 => 蓝龙葵变红龙葵的特效
|
||||
@@ -1,67 +0,0 @@
|
||||
因为当前特效的实现方式使用了第三方插件和素材,所以此文件夹内的所有prefab均添加进了gitignore里。
|
||||
请联系作者了解插件获取方式和特效prefab的获取方式。
|
||||
|
||||
0 => 传送法阵特效
|
||||
9 => 茅山道士封印法术特效
|
||||
40 => 单体风咒特效
|
||||
50 => 单体雷咒特效
|
||||
91 => 封印法术特效
|
||||
157 => 角色传送出现特效
|
||||
164 => 南宫煌变身狼形态时的特效
|
||||
170 => 王蓬絮变身特效
|
||||
171 => 人物施法特效
|
||||
172 => 人物受到法术作用时候的特效
|
||||
173 => 人物受到法术作用时候的特效
|
||||
174 => 治疗特效
|
||||
175 => 茅山术士打乱三杯盏特效
|
||||
176 => 南宫煌打乱三杯盏特效
|
||||
177 => 角色传送消失时的特效
|
||||
178 => 南宫煌使关桃子的笼子消失的特效
|
||||
179 => 南宫煌变出法桌的特效
|
||||
181 => 南宫煌变出小东西的特效
|
||||
182 => 南宫煌变出大东西的特效
|
||||
186 => 大石块砸下后的尘土特效
|
||||
189 => 地脉石门封印打开时的特效
|
||||
198 => 南宫煌变出东西的特效
|
||||
201 => 魁妖变小特效
|
||||
205 => 照妖镜发光的特效
|
||||
209 => 五灵轮特效
|
||||
211 => 洒金笺特效
|
||||
230 => 重楼施法消灭怪物的特效
|
||||
254 => 重楼传送特效
|
||||
257 => 隔空取物特效
|
||||
258 => 迴魂传送特效
|
||||
259 => 大型传送法施法前奏特效
|
||||
260 => 大型传送法阵特效收尾
|
||||
261 => 大型传送法阵特效开始
|
||||
281 => 角色传送消失时的特效
|
||||
282 => 雷咒特效
|
||||
283 => 物品消失时的特效
|
||||
285 => 南宫煌施法特效
|
||||
287 => 土灵珠特效
|
||||
289 => 血魂姬施法特效
|
||||
290 => 回复法阵特效
|
||||
292 => 五灵轮发光特效
|
||||
299 => 重楼传送众人特效
|
||||
314 => 倾国银弹波特效
|
||||
315 => 南宫煌切换为人形态特效
|
||||
316 => 魔物出现特效
|
||||
318 => 千凝魔艮特效
|
||||
320 => 幽娘变身特效
|
||||
322 => 幽娘吸收怨气特效
|
||||
323 => 幽娘收集怨气特效
|
||||
325 => 陆北亭变身特效
|
||||
328 => 风雅颂开心的特效
|
||||
333 => 感月出现特效
|
||||
355 => 王蓬絮治疗特效
|
||||
359 => 蝎魃消失特效
|
||||
360 => 星璇给南宫煌输入内力时的特效
|
||||
367 => 五毒珠治疗特效
|
||||
388 => 迴魂传送特效
|
||||
389 => 迴魂传送特效
|
||||
397 => 燎日变身特效
|
||||
401 => 魔尊帮星璇灵肉合一的特效
|
||||
404 => 思堂消失特效
|
||||
408 => 星璇燎日变换时特效
|
||||
424 => 王蓬絮对南宫煌施法特效
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#ifndef PAL3_GAMEBOX_NATIVE_LIGHTING_INCLUDED
|
||||
#define PAL3_GAMEBOX_NATIVE_LIGHTING_INCLUDED
|
||||
|
||||
float _GbVertexUnits;
|
||||
float _GbVertexColor;
|
||||
float _GbLightCount;
|
||||
float4 _GbLightPosition0;
|
||||
float4 _GbLightPosition1;
|
||||
float4 _GbLightDiffuse0;
|
||||
float4 _GbLightDiffuse1;
|
||||
float4 _GbLightAmbient0;
|
||||
float4 _GbLightAmbient1;
|
||||
float4 _GbLightAttenuation0;
|
||||
float4 _GbLightAttenuation1;
|
||||
float4x4 _GbSourceFromRenderer;
|
||||
|
||||
float3 GameBoxVertexLight(float3 position, float3 normal, float3 lightPosition,
|
||||
float3 diffuse, float3 ambient, float3 attenuation)
|
||||
{
|
||||
float3 delta = lightPosition - position;
|
||||
float distanceSquared = dot(delta, delta);
|
||||
float distance = sqrt(distanceSquared);
|
||||
float3 direction = delta / max(distance, 0.000001);
|
||||
float strength = rcp(max(dot(attenuation, float3(1, distance, distanceSquared)), 0.000001));
|
||||
return strength * max(dot(normal, direction), 0) * _GbMaterialDiffuse.rgb * diffuse +
|
||||
_GbMaterialAmbient.rgb * (ambient + 0.2);
|
||||
}
|
||||
|
||||
float4 GameBoxVertexColor(float3 position, float3 normal, float4 vertexColor)
|
||||
{
|
||||
if (_GbVertexColor > 0.5)
|
||||
return float4(vertexColor.rgb, vertexColor.a * (_GbNativeLighting > 0.5 ? _TintColor.a : 1));
|
||||
if (_GbNativeLighting < 0.5)
|
||||
return 1;
|
||||
float3 color = _GbMaterialAmbient.rgb * 0.2;
|
||||
// CVD geometry bakes its animated node matrix into vertex positions.
|
||||
// Undo that matrix for the original node-local light/normal calculation.
|
||||
position = mul(_GbSourceFromRenderer, float4(position, 1)).xyz * _GbVertexUnits;
|
||||
if (_GbLightCount > 0.5)
|
||||
color = GameBoxVertexLight(position, normal, _GbLightPosition0.xyz,
|
||||
_GbLightDiffuse0.rgb, _GbLightAmbient0.rgb, _GbLightAttenuation0.xyz);
|
||||
if (_GbLightCount > 1.5)
|
||||
color += GameBoxVertexLight(position, normal, _GbLightPosition1.xyz,
|
||||
_GbLightDiffuse1.rgb, _GbLightAmbient1.rgb, _GbLightAttenuation1.xyz);
|
||||
// Preserve the native, unnormalized interpolated morph normal.
|
||||
return float4(color, _GbMaterialDiffuse.a * _TintColor.a);
|
||||
}
|
||||
|
||||
half4 GameBoxTextureStages(half4 mainColor, half4 lightmap, float4 vertexColor, float hasLightmap)
|
||||
{
|
||||
if (_GbNativeLighting < 0.5)
|
||||
return mainColor;
|
||||
vertexColor = saturate(vertexColor);
|
||||
if (hasLightmap > 0.5)
|
||||
{
|
||||
half3 firstStage = lightmap.rgb;
|
||||
if (_GbLightCount > 0.5 && _GbVertexColor < 0.5)
|
||||
firstStage = saturate(firstStage + vertexColor.rgb);
|
||||
return saturate(half4(firstStage * mainColor.rgb * 2,
|
||||
lightmap.a * mainColor.a * vertexColor.a * 2));
|
||||
}
|
||||
return saturate(mainColor * vertexColor);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 506edd8164c54d5a8bbe5294ca720df5
|
||||
@@ -0,0 +1,58 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/BattleShadow"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Original shadow texture", 2D) = "white" {}
|
||||
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Source blend", Float) = 2
|
||||
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Destination blend", Float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent+1" "RenderType" = "Transparent" }
|
||||
Pass
|
||||
{
|
||||
Tags { "LightMode" = "SRPDefaultUnlit" }
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
ZTest LEqual
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
HLSLPROGRAM
|
||||
#pragma vertex Vert
|
||||
#pragma fragment Frag
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
Varyings Vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS);
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 Frag(Varyings input) : SV_Target
|
||||
{
|
||||
return SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aab071a0286c4b91a964c543ba090aee
|
||||
@@ -0,0 +1,66 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Hidden/Pal3/BattleTrail"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("History", 2D) = "black" {}
|
||||
_Diffuse ("Original diffuse", Vector) = (1, 1, 1, 1)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderPipeline" = "UniversalPipeline" }
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha One
|
||||
ZTest Always
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
HLSLPROGRAM
|
||||
#pragma vertex Vert
|
||||
#pragma fragment Frag
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainTex_TexelSize;
|
||||
float4 _Diffuse;
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
Varyings Vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
output.uv = input.uv;
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_MainTex_TexelSize.y < 0)
|
||||
output.uv.y = 1 - output.uv.y;
|
||||
#endif
|
||||
output.uv.y *= .75;
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 Frag(Varyings input) : SV_Target
|
||||
{
|
||||
return float4(SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv).rgb * _Diffuse.rgb, _Diffuse.a);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f5b735021d84bea9f91e0a6f9ef3d87
|
||||
@@ -1,7 +1,7 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Dev"
|
||||
{
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Effect"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Source blend", Float) = 1
|
||||
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Destination blend", Float) = 1
|
||||
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest ("Depth test", Float) = 4
|
||||
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", Float) = 0
|
||||
_AlphaMode ("Original alpha operation", Float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
"Queue" = "Transparent"
|
||||
"RenderType" = "Transparent"
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Tags { "LightMode" = "SRPDefaultUnlit" }
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
ZTest [_ZTest]
|
||||
ZWrite Off
|
||||
Cull [_Cull]
|
||||
HLSLPROGRAM
|
||||
#pragma vertex Vert
|
||||
#pragma fragment Frag
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float _AlphaMode;
|
||||
CBUFFER_END
|
||||
Varyings Vert(Attributes i)
|
||||
{
|
||||
Varyings o;
|
||||
o.positionCS = TransformObjectToHClip(i.positionOS);
|
||||
o.uv = i.uv;
|
||||
o.color = i.color;
|
||||
return o;
|
||||
}
|
||||
half4 Frag(Varyings i) : SV_Target
|
||||
{
|
||||
half4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
half4 col = tex * i.color;
|
||||
if (_AlphaMode > 1.5)
|
||||
{
|
||||
col.a = tex.a;
|
||||
}
|
||||
else if (_AlphaMode > 0.5)
|
||||
{
|
||||
col.a = saturate(tex.a + i.color.a);
|
||||
}
|
||||
return col;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd7af60dc97334317a8bf7d560ba0f71
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,13 +1,17 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Opaque"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _GbNativeLighting ("Original battle lighting", Float) = 0
|
||||
[HideInInspector] _GbMaterialDiffuse ("Original material diffuse", Vector) = (1, 1, 1, 1)
|
||||
[HideInInspector] _GbMaterialAmbient ("Original material ambient", Vector) = (1, 1, 1, 1)
|
||||
[HideInInspector] _BattleSelection ("Battle selection luminance", Float) = -1
|
||||
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
|
||||
|
||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||
@@ -35,6 +39,8 @@ Shader "Pal3/Opaque"
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
@@ -46,6 +52,7 @@ Shader "Pal3/Opaque"
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float fogFactor : TEXCOORD7;
|
||||
float4 nativeColor : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
@@ -55,19 +62,26 @@ Shader "Pal3/Opaque"
|
||||
SAMPLER(sampler_ShadowTex);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float _GbNativeLighting;
|
||||
float4 _GbMaterialDiffuse;
|
||||
float4 _GbMaterialAmbient;
|
||||
float4 _MainTex_ST;
|
||||
float4 _TintColor;
|
||||
float _BattleSelection;
|
||||
float _HasShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
float _LightmapScale;
|
||||
CBUFFER_END
|
||||
|
||||
#include "GameBoxNativeLighting.hlsl"
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||
o.nativeColor = GameBoxVertexColor(v.vertex.xyz, v.normal, v.color);
|
||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||
o.fogFactor = ComputeFogFactor(o.vertex.z);
|
||||
@@ -77,15 +91,28 @@ Shader "Pal3/Opaque"
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord0);
|
||||
if(_HasShadowTex > 0.5f)
|
||||
half3 selectionTexture = color.rgb;
|
||||
if (_GbNativeLighting > 0.5)
|
||||
{
|
||||
half4 lightmap = _HasShadowTex > 0.5 ? SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.texcoord1) : 1;
|
||||
color = GameBoxTextureStages(color, lightmap, i.nativeColor, _HasShadowTex);
|
||||
}
|
||||
else if (_GbVertexColor > 0.5)
|
||||
color *= i.nativeColor;
|
||||
if(_HasShadowTex > 0.5f && _GbNativeLighting < 0.5)
|
||||
{
|
||||
color.rgb *= SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.texcoord1).rgb * _LightmapScale;
|
||||
}
|
||||
color *= _TintColor;
|
||||
if (_GbNativeLighting > 0.5)
|
||||
color.rgb *= _TintColor.rgb;
|
||||
else
|
||||
color *= _TintColor;
|
||||
if (_BattleSelection >= 0)
|
||||
color.rgb = selectionTexture * _BattleSelection;
|
||||
color.rgb = MixFog(color.rgb, i.fogFactor);
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Sprite"
|
||||
{
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Transparent"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _GbNativeLighting ("Original battle lighting", Float) = 0
|
||||
[HideInInspector] _GbMaterialDiffuse ("Original material diffuse", Vector) = (1, 1, 1, 1)
|
||||
[HideInInspector] _GbMaterialAmbient ("Original material ambient", Vector) = (1, 1, 1, 1)
|
||||
[HideInInspector] _BattleSelection ("Battle selection luminance", Float) = -1
|
||||
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
|
||||
_Threshold ("Transparent Threshold", Range(0, 1)) = 1.0
|
||||
|
||||
@@ -43,6 +47,8 @@ Shader "Pal3/Transparent"
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
@@ -54,6 +60,7 @@ Shader "Pal3/Transparent"
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float fogFactor : TEXCOORD7;
|
||||
float4 nativeColor : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
@@ -63,20 +70,27 @@ Shader "Pal3/Transparent"
|
||||
SAMPLER(sampler_ShadowTex);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float _GbNativeLighting;
|
||||
float4 _GbMaterialDiffuse;
|
||||
float4 _GbMaterialAmbient;
|
||||
float4 _MainTex_ST;
|
||||
float _Threshold;
|
||||
float _HasShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
float _LightmapScale;
|
||||
float4 _TintColor;
|
||||
float _BattleSelection;
|
||||
CBUFFER_END
|
||||
|
||||
#include "GameBoxNativeLighting.hlsl"
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||
o.nativeColor = GameBoxVertexColor(v.vertex.xyz, v.normal, v.color);
|
||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||
o.fogFactor = ComputeFogFactor(o.vertex.z);
|
||||
@@ -86,20 +100,33 @@ Shader "Pal3/Transparent"
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord0);
|
||||
half3 selectionTexture = color.rgb;
|
||||
if (_GbNativeLighting > 0.5)
|
||||
{
|
||||
half4 lightmap = _HasShadowTex > 0.5 ? SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.texcoord1) : 1;
|
||||
color = GameBoxTextureStages(color, lightmap, i.nativeColor, _HasShadowTex);
|
||||
}
|
||||
else if (_GbVertexColor > 0.5)
|
||||
color *= i.nativeColor;
|
||||
if (color.a >= _Threshold || (color.a <= 0.0 && _Threshold <= 1.0))
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
if(_HasShadowTex > 0.5f)
|
||||
if(_HasShadowTex > 0.5f && _GbNativeLighting < 0.5)
|
||||
{
|
||||
color.rgb *= SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.texcoord1).rgb * _LightmapScale;
|
||||
}
|
||||
color *= _TintColor;
|
||||
if (_GbNativeLighting > 0.5)
|
||||
color.rgb *= _TintColor.rgb;
|
||||
else
|
||||
color *= _TintColor;
|
||||
if (_BattleSelection >= 0)
|
||||
color.rgb = selectionTexture * _BattleSelection;
|
||||
color.rgb = MixFog(color.rgb, i.fogFactor);
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/TransparentOpaquePart"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _GbNativeLighting ("Original battle lighting", Float) = 0
|
||||
[HideInInspector] _GbMaterialDiffuse ("Original material diffuse", Vector) = (1, 1, 1, 1)
|
||||
[HideInInspector] _GbMaterialAmbient ("Original material ambient", Vector) = (1, 1, 1, 1)
|
||||
[HideInInspector] _BattleSelection ("Battle selection luminance", Float) = -1
|
||||
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
|
||||
_Threshold ("Transparent Threshold", Range(0, 1)) = 1.0
|
||||
|
||||
@@ -37,6 +41,8 @@ Shader "Pal3/TransparentOpaquePart"
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
@@ -48,6 +54,7 @@ Shader "Pal3/TransparentOpaquePart"
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float fogFactor : TEXCOORD7;
|
||||
float4 nativeColor : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
@@ -57,20 +64,27 @@ Shader "Pal3/TransparentOpaquePart"
|
||||
SAMPLER(sampler_ShadowTex);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float _GbNativeLighting;
|
||||
float4 _GbMaterialDiffuse;
|
||||
float4 _GbMaterialAmbient;
|
||||
float4 _MainTex_ST;
|
||||
float _Threshold;
|
||||
float _HasShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
float _LightmapScale;
|
||||
float4 _TintColor;
|
||||
float _BattleSelection;
|
||||
CBUFFER_END
|
||||
|
||||
#include "GameBoxNativeLighting.hlsl"
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||
o.nativeColor = GameBoxVertexColor(v.vertex.xyz, v.normal, v.color);
|
||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||
o.fogFactor = ComputeFogFactor(o.vertex.z);
|
||||
@@ -80,17 +94,30 @@ Shader "Pal3/TransparentOpaquePart"
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord0);
|
||||
half3 selectionTexture = color.rgb;
|
||||
if (_GbNativeLighting > 0.5)
|
||||
{
|
||||
half4 lightmap = _HasShadowTex > 0.5 ? SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.texcoord1) : 1;
|
||||
color = GameBoxTextureStages(color, lightmap, i.nativeColor, _HasShadowTex);
|
||||
}
|
||||
else if (_GbVertexColor > 0.5)
|
||||
color *= i.nativeColor;
|
||||
clip(color.a - _Threshold);
|
||||
|
||||
if(_HasShadowTex > 0.5f)
|
||||
if(_HasShadowTex > 0.5f && _GbNativeLighting < 0.5)
|
||||
{
|
||||
color.rgb *= SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.texcoord1).rgb * _LightmapScale;
|
||||
}
|
||||
color *= _TintColor;
|
||||
if (_GbNativeLighting > 0.5)
|
||||
color.rgb *= _TintColor.rgb;
|
||||
else
|
||||
color *= _TintColor;
|
||||
if (_BattleSelection >= 0)
|
||||
color.rgb = selectionTexture * _BattleSelection;
|
||||
color.rgb = MixFog(color.rgb, i.fogFactor);
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Water"
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/SkyboxEffect"
|
||||
{
|
||||
Properties { _MainTex ("Sequence frame", 2D) = "black" {} }
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderPipeline"="UniversalPipeline" "Queue"="Transparent-10" "RenderType"="Transparent" }
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha One
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
|
||||
struct Attributes { float4 positionOS : POSITION; float2 uv : TEXCOORD0; };
|
||||
struct Varyings { float4 positionCS : SV_POSITION; float2 uv : TEXCOORD0; };
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
// Sky effects must remain behind all scene geometry, including
|
||||
// mountains farther away than the effect cube's actual mesh.
|
||||
#if UNITY_REVERSED_Z
|
||||
output.positionCS.z = 0.0;
|
||||
#else
|
||||
output.positionCS.z = output.positionCS.w;
|
||||
#endif
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
half4 frag(Varyings input) : SV_Target { return SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv); }
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d3ce4f585ff416caf911181f6f5dd56
|
||||
@@ -1,539 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.002
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1.3
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 112000000, guid: c9e1768594f6afd479e0380c47ec2784, type: 2}
|
||||
m_LightingSettings: {fileID: 4890085278179872738, guid: c3e8b810b348ed54ba97c7a4ee44d9eb, type: 2}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &806768031
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 806768034}
|
||||
- component: {fileID: 806768033}
|
||||
- component: {fileID: 806768032}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &806768032
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 806768031}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_MoveRepeatDelay: 0.5
|
||||
m_MoveRepeatRate: 0.1
|
||||
m_XRTrackingOrigin: {fileID: 0}
|
||||
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_DeselectOnBackgroundClick: 1
|
||||
m_PointerBehavior: 0
|
||||
--- !u!114 &806768033
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 806768031}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_FirstSelected: {fileID: 0}
|
||||
m_sendNavigationEvents: 1
|
||||
m_DragThreshold: 10
|
||||
--- !u!4 &806768034
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 806768031}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &2755888771526933938
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 2675203688159455099, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675203688159455099, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675203688159455099, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675203688159455099, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675203688159455099, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675203688159455099, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675384619832620949, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675384619832620949, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675384619832620949, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675384619832620949, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675384619832620949, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2675384619832620949, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773260843717, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: IngameDebugConsole
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280878983, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280971043, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280971043, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280971043, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280971043, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280971043, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280971043, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280980657, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280980657, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280980657, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280980657, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280980657, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773280980657, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281030725, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281030725, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281030725, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281030725, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281030725, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281030725, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281033885, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281033885, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_Pivot.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_Pivot.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMin.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281068093, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281069695, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281069695, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281069695, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281069695, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281069695, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281069695, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281072733, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281072733, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281072733, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281072733, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281072733, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2755888773281072733, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
|
||||
--- !u!1001 &6005496283450936117
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 6005496284174148228, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: startingComponent
|
||||
value:
|
||||
objectReference: {fileID: 4717529239480754811, guid: e65c4b938f18e6c4a86dc379157fac65, type: 3}
|
||||
- target: {fileID: 6005496284174148229, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Resource Initializer
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6005496284174148231, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 23121fd589eec48458b9201ba9cfc3f7, type: 3}
|
||||
@@ -1,7 +1,7 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#if UNITY_EDITOR_OSX && UNITY_IOS
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#if UNITY_EDITOR_OSX && UNITY_STANDALONE_OSX
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19e3efa591f1d44319abe806fd3ea5ff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 982b02ad3fe144eb8e3323a7990f2807
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using Battle;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed partial class BattleEditorWindow
|
||||
{
|
||||
private void DrawAiControls(BattleSession combat, BattleActorSnapshot actor)
|
||||
{
|
||||
if (combat.Definitions == null)
|
||||
return;
|
||||
GUILayout.Label("原版 AI 配置", EditorStyles.boldLabel);
|
||||
int flags = combat.GetAiProfile(actor.Id);
|
||||
string[] labels = { "普攻", "仙术", "特技", "物品", "万全", "自动" };
|
||||
int changed = flags;
|
||||
using (new EditorGUI.DisabledScope(combat.Status != BattleSessionStatus.Running))
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
for (int bit = 0; bit < labels.Length; bit++)
|
||||
{
|
||||
int mask = 1 << bit;
|
||||
bool enabled = GUILayout.Toggle((flags & mask) != 0, labels[bit]);
|
||||
changed = enabled ? changed | mask : changed & ~mask;
|
||||
}
|
||||
if (changed != flags)
|
||||
Try(() => combat.SetAiProfile(actor.Id, changed));
|
||||
if (actor.Side != BattleSide.Ally)
|
||||
return;
|
||||
using (new EditorGUI.DisabledScope(combat.Status != BattleSessionStatus.Running || combat.WaitingActor != actor.Id))
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
if (DrawerButton("F · 自动普攻"))
|
||||
Try(() =>
|
||||
{
|
||||
combat.RequestAiNormal(actor.Id);
|
||||
_session.SyncBattle();
|
||||
});
|
||||
if (DrawerButton("R · 重复上次指令"))
|
||||
Try(() =>
|
||||
{
|
||||
combat.RequestAiRepeat(actor.Id);
|
||||
_session.SyncBattle();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edfd0dc849d44594a87c2d4375ea0b87
|
||||
@@ -0,0 +1,541 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Battle;
|
||||
using Battle.Presentation;
|
||||
using Core.Contract.Enums;
|
||||
using ResourceBrowser;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed partial class BattleEditorWindow
|
||||
{
|
||||
private static readonly string[] AttributeLabels = { "精上限", "气上限", "神上限", "攻击", "防御", "速度", "幸运", "水", "火", "风", "雷", "土" };
|
||||
private readonly ResourceObjectView _dataView = new();
|
||||
private int _dataTable, _dataIndex, _equipmentSlot;
|
||||
private string _dataSearch = "";
|
||||
|
||||
private void CreateRandomExample()
|
||||
{
|
||||
if (!CanReplace())
|
||||
return;
|
||||
BattleScenario example = _session.CreateRandomExample();
|
||||
// Construct the replacement before changing the draft or its asset ownership.
|
||||
_session.Start(example);
|
||||
Undo.ClearUndo(_draft);
|
||||
_asset = null;
|
||||
_initializeTestInventory = false;
|
||||
_savedJson = BattleScenarioJson.Serialize(new BattleScenario { Variant = BattleData.Variant });
|
||||
Edit("Create random battle example", () => _draft.Scenario = example);
|
||||
_previewJson = _draftJson;
|
||||
_selected = example.Participants.FirstOrDefault()?.InstanceId;
|
||||
_drawer = WorkspaceDrawer.None;
|
||||
}
|
||||
|
||||
private void SyncHudBattle()
|
||||
{
|
||||
_session.SyncBattle();
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void SelectHudActor(string id)
|
||||
{
|
||||
_selected = id;
|
||||
_action = null;
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void DrawRoster()
|
||||
{
|
||||
GUILayout.Label("参战者", EditorStyles.boldLabel);
|
||||
_rosterScroll = EditorGUILayout.BeginScrollView(_rosterScroll, GUILayout.Height(Mathf.Min(230, 62 + Scenario.Participants.Count * 34)));
|
||||
try
|
||||
{
|
||||
foreach (BattleSide side in Enum.GetValues(typeof(BattleSide)))
|
||||
{
|
||||
GUILayout.Label(side == BattleSide.Ally ? "我方" : "敌方", EditorStyles.boldLabel);
|
||||
foreach (BattleParticipant actor in Scenario.Participants.ToArray())
|
||||
{
|
||||
if (actor.Side != side)
|
||||
continue;
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
bool selected = actor.InstanceId == _selected;
|
||||
if (GUILayout.Toggle(selected, ActorLabel(actor), Theme.Roster) != selected)
|
||||
{
|
||||
_selected = actor.InstanceId;
|
||||
_configurationPage = 1;
|
||||
_action = null;
|
||||
}
|
||||
GUILayout.Space(4);
|
||||
if (DrawerButton("×", GUILayout.Width(24)))
|
||||
Edit("Remove participant", () => Scenario.Participants.Remove(actor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
_addParticipant = Section("add-participant", "添加角色/怪物");
|
||||
if (!_addParticipant)
|
||||
return;
|
||||
_addSide = (BattleSide)EditorGUILayout.EnumPopup("加入阵营", _addSide);
|
||||
_search = EditorGUILayout.TextField("搜索 ID/名称", _search);
|
||||
if (_session.Data == null)
|
||||
{
|
||||
GUILayout.Label("请先加载原版数据。");
|
||||
return;
|
||||
}
|
||||
int[] candidates = RosterCandidates(_session.Data, _addSide, _search, Scenario.Participants);
|
||||
_addActor = Mathf.Clamp(_addActor, 0, Math.Max(0, candidates.Length - 1));
|
||||
_addActor = EditorGUILayout.Popup(_addActor, candidates.Select(id => $"{id} · {_session.Data.Database.CombatActorInfos[id].Name}").ToArray());
|
||||
using (new EditorGUI.DisabledScope(candidates.Length == 0))
|
||||
if (DrawerButton("添加到" + (_addSide == BattleSide.Ally ? "我方" : "敌方")))
|
||||
Try(() =>
|
||||
{
|
||||
if (Scenario.Participants.Count(actor => actor.Side == _addSide) >= (_addSide == BattleSide.Ally ? 4 : 6))
|
||||
throw new InvalidOperationException("当前阵营已达原版参战人数上限。");
|
||||
BattleSlot slot = Enum.GetValues(typeof(BattleSlot)).Cast<BattleSlot>().First(value => !Scenario.Participants.Any(actor => actor.Side == _addSide && actor.Slot == value));
|
||||
BattleParticipant actor = _session.Data.CreateTestParticipant(candidates[_addActor], _addSide, slot);
|
||||
Edit("Add participant", () => Scenario.Participants.Add(actor));
|
||||
_selected = actor.InstanceId;
|
||||
_configurationPage = 1;
|
||||
});
|
||||
}
|
||||
|
||||
private static int[] RosterCandidates(BattleData data, BattleSide side, string search, IEnumerable<BattleParticipant> roster)
|
||||
{
|
||||
var allyIdentities = new HashSet<int>(roster.Where(actor => actor?.Side == BattleSide.Ally)
|
||||
.Select(actor => BattleData.PlayerIdentity(actor.ActorId)));
|
||||
return data.Database.CombatActorInfos.OrderBy(pair => pair.Key)
|
||||
.Where(pair => pair.Key > 0 && data.CombatRosterDenial(pair.Key, side) == null &&
|
||||
(side == BattleSide.Enemy || !allyIdentities.Contains(BattleData.PlayerIdentity(pair.Key))) &&
|
||||
($"{pair.Key} {pair.Value.Name} {pair.Value.ModelId}").IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
.Select(pair => pair.Key).ToArray();
|
||||
}
|
||||
|
||||
private string ActorLabel(BattleParticipant actor)
|
||||
{
|
||||
string name = _session.Data?.Database.CombatActorInfos.TryGetValue(actor.ActorId, out var info) == true ? info.Name : actor.ActorId.ToString();
|
||||
return $"{name} ({actor.ActorId}) · {actor.Slot}";
|
||||
}
|
||||
|
||||
private void DrawDataCatalog()
|
||||
{
|
||||
if (_session.Data == null)
|
||||
{
|
||||
GUILayout.Label("请先加载原版数据。");
|
||||
return;
|
||||
}
|
||||
int table = DrawerTabs("tabs:catalog", _dataTable, new[] { "技能", "物品", "合击", "状态" });
|
||||
if (table != _dataTable)
|
||||
{
|
||||
_dataTable = table;
|
||||
_dataIndex = 0;
|
||||
_dataSearch = "";
|
||||
_dataView.Reset();
|
||||
}
|
||||
var database = _session.Data.Database;
|
||||
(int id, string name, object record)[] records = _dataTable switch
|
||||
{
|
||||
0 => database.SkillInfos.OrderBy(pair => pair.Key).Select(pair => (pair.Key, pair.Value.Name, (object)pair.Value)).ToArray(),
|
||||
1 => database.GameItemInfos.OrderBy(pair => pair.Key).Select(pair => (pair.Key, pair.Value.Name, (object)pair.Value)).ToArray(),
|
||||
2 => database.ComboSkillInfos.OrderBy(pair => pair.Key).Select(pair => (pair.Key, pair.Value.Name, (object)pair.Value)).ToArray(),
|
||||
_ => Enum.GetValues(typeof(ActorCombatStateType)).Cast<ActorCombatStateType>().Select(state => ((int)state, state.ToString(), (object)state)).ToArray(),
|
||||
};
|
||||
_dataSearch = EditorGUILayout.TextField("搜索 ID/名称", _dataSearch);
|
||||
records = records.Where(record => $"{record.id} {record.name}".IndexOf(_dataSearch, StringComparison.OrdinalIgnoreCase) >= 0).ToArray();
|
||||
if (records.Length == 0)
|
||||
return;
|
||||
int previous = _dataIndex;
|
||||
_dataIndex = EditorGUILayout.Popup(Mathf.Clamp(_dataIndex, 0, records.Length - 1), records.Select(record => $"{record.id} · {record.name}").ToArray());
|
||||
if (previous != _dataIndex)
|
||||
_dataView.Reset();
|
||||
var selected = records[_dataIndex];
|
||||
BattleParticipant actor = Scenario.Participants.FirstOrDefault(participant => participant.InstanceId == _selected);
|
||||
using (new EditorGUI.DisabledScope((_dataTable == 0 || _dataTable == 3) && actor == null))
|
||||
{
|
||||
if (_dataTable == 0 && selected.id > 0 && DrawerButton("加入选中角色的初始技能"))
|
||||
Edit("Add initial skill", () =>
|
||||
{
|
||||
if (actor.Skills.All(skill => skill.Id != selected.id))
|
||||
actor.Skills.Add(new BattleSkill { Id = selected.id, Mastered = true });
|
||||
});
|
||||
if (_dataTable == 3 && BattleStatusRules.SupportsInitialState((BattleState)selected.id) && DrawerButton("加入选中角色的初始状态"))
|
||||
Edit("Add initial status", () =>
|
||||
{
|
||||
if (actor.Statuses.All(state => state.Id != selected.id))
|
||||
actor.Statuses.Add(new BattleStatus { Id = selected.id });
|
||||
});
|
||||
}
|
||||
if (_dataTable == 1 && selected.id > 0)
|
||||
{
|
||||
if (DrawerButton("放入本局物品(+1)"))
|
||||
Edit("Add battle item", () =>
|
||||
{
|
||||
BattleItem item = Scenario.Items.FirstOrDefault(entry => entry.Id == selected.id);
|
||||
if (item == null)
|
||||
Scenario.Items.Add(new BattleItem { Id = selected.id });
|
||||
else if (item.Count < int.MaxValue)
|
||||
item.Count++;
|
||||
});
|
||||
_equipmentSlot = EditorGUILayout.Popup("装备槽位", _equipmentSlot, new[] { "武器", "帽子", "衣服", "鞋子", "饰品一", "饰品二" });
|
||||
using (new EditorGUI.DisabledScope(actor == null))
|
||||
if (DrawerButton("装备到选中角色(开局校验类型与适用者)"))
|
||||
Edit("Set battle equipment", () =>
|
||||
{
|
||||
if (actor.Equipment.Length != 6)
|
||||
actor.Equipment = new int[6];
|
||||
actor.Equipment[_equipmentSlot] = selected.id;
|
||||
if (_equipmentSlot == 0)
|
||||
actor.MagicSword = selected.id == BattleMagicSwordRules.WeaponId ? actor.MagicSword ?? new BattleMagicSword() : null;
|
||||
});
|
||||
}
|
||||
_dataView.Draw(selected.record, DrawerWidth - 30);
|
||||
}
|
||||
|
||||
private void DrawScenario(BattleScenario scenario)
|
||||
{
|
||||
GUILayout.Label("配置作品:" + Scenario.Variant, EditorStyles.boldLabel);
|
||||
if (_session.Data != null)
|
||||
{
|
||||
int index = Array.FindIndex(_session.Data.Scenes, name => name.Equals(Scenario.Scene, StringComparison.OrdinalIgnoreCase));
|
||||
int selected = EditorGUILayout.Popup("战斗场景", index, _session.Data.Scenes);
|
||||
if (selected >= 0 && selected != index)
|
||||
{
|
||||
Edit("Set battle scene", () =>
|
||||
{
|
||||
scenario.Scene = _session.Data.Scenes[selected];
|
||||
scenario.SceneElement = (int)_session.Data.SceneMap.CombatSceneElementTypeInfo.GetValueOrDefault(scenario.Scene);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
Field(scenario, "Scene", "战斗场景");
|
||||
ElementType element = (ElementType)EditorGUILayout.EnumPopup("场景五灵(阵位关系)", (ElementType)scenario.SceneElement);
|
||||
if ((int)element != scenario.SceneElement)
|
||||
Edit("Set scene element", () => scenario.SceneElement = (int)element);
|
||||
#if PAL3A
|
||||
ElementType fieldElement = (ElementType)EditorGUILayout.EnumPopup("初始五灵法阵", (ElementType)scenario.FiveSpiritElement);
|
||||
if ((int)fieldElement != scenario.FiveSpiritElement)
|
||||
Edit("Set five spirit element", () => scenario.FiveSpiritElement = (int)fieldElement);
|
||||
int force = EditorGUILayout.Popup("法阵所属", scenario.FiveSpiritForce, new[] { "无", "我方", "敌方" });
|
||||
if (force != scenario.FiveSpiritForce)
|
||||
Edit("Set five spirit force", () => scenario.FiveSpiritForce = force);
|
||||
#endif
|
||||
|
||||
BattleParticipant[] allies = scenario.Participants.Where(actor => actor.Side == BattleSide.Ally).ToArray();
|
||||
string[] ignoredChoices = new[] { "无" }.Concat(allies.Select(ActorLabel)).ToArray();
|
||||
int ignoredBefore = Array.FindIndex(allies, actor => actor.InstanceId == scenario.EnemyAiIgnoredActor) + 1;
|
||||
if (ignoredBefore == 0 && !string.IsNullOrEmpty(scenario.EnemyAiIgnoredActor))
|
||||
ignoredBefore = -1;
|
||||
int ignoredNext = EditorGUILayout.Popup("敌方 AI 忽略目标", ignoredBefore, ignoredChoices);
|
||||
if (ignoredNext >= 0 && ignoredNext != ignoredBefore)
|
||||
Edit("Set ignored AI actor", () => scenario.EnemyAiIgnoredActor = ignoredNext == 0 ? "" : allies[ignoredNext - 1].InstanceId);
|
||||
Field(scenario, "Encounter", "遭遇类型");
|
||||
if (Section("rules", "高级战斗规则"))
|
||||
{
|
||||
Field(scenario, "Seed", "随机种子");
|
||||
Field(scenario, "RoundLimit", "Boss 回合限制");
|
||||
GUILayout.Label("-1 不限;0 立即判定。", EditorStyles.wordWrappedMiniLabel);
|
||||
Field(scenario, "ScriptBattle", "剧情战斗");
|
||||
Field(scenario, "MustFail", "必败战斗");
|
||||
Field(scenario, "GameOverOnDefeat", "败北结束游戏");
|
||||
|
||||
#if PAL3A
|
||||
BattlePal3AState pal3A = scenario.Pal3A;
|
||||
if (pal3A?.SpiritWheel?.Charges is { Length: 5 } charges)
|
||||
{
|
||||
string[] spiritNames = { "水", "火", "风", "雷", "土" };
|
||||
for (int elementIndex = 0; elementIndex < 5; elementIndex++)
|
||||
{
|
||||
int index = elementIndex;
|
||||
int charge = EditorGUILayout.IntSlider("五灵轮 · " + spiritNames[index], charges[index], 0, 9);
|
||||
if (charge != charges[index])
|
||||
Edit("Set spirit wheel charge", () => charges[index] = charge);
|
||||
}
|
||||
Field(pal3A, "SpiritVisualSeed", "摄灵表现随机种子");
|
||||
Field(pal3A, "NangongStartsTransformed", "南宫煌开局炎兽形态");
|
||||
Field(pal3A, "PengxuStartsTransformed", "王蓬絮开局仙兽形态");
|
||||
Field(pal3A, "PreserveLiaoRiLosses", "继承燎日累计损失");
|
||||
if (pal3A.PreserveLiaoRiLosses)
|
||||
{
|
||||
Field(pal3A, "HpLoss", "累计精请求损失");
|
||||
Field(pal3A, "MpLoss", "累计神请求损失");
|
||||
}
|
||||
}
|
||||
else
|
||||
Field(scenario, "Pal3A", "问情篇初始状态");
|
||||
#endif
|
||||
}
|
||||
if (!Section("presentation", "音乐、渲染与相机"))
|
||||
return;
|
||||
GUILayout.Label("音乐留空按场景自动选择;NONE 为静音,也可填写原始曲号。", EditorStyles.wordWrappedMiniLabel);
|
||||
Field(scenario, "Music", "战斗音乐");
|
||||
int renderMode = EditorGUILayout.Popup("光影模式", scenario.ToonRendering ? 1 : 0, new[] { "原版光影", "实时光照 + Toon" });
|
||||
if ((renderMode == 1) != scenario.ToonRendering)
|
||||
Edit("Set battle render mode", () => scenario.ToonRendering = renderMode == 1);
|
||||
GUILayout.Label(scenario.ToonRendering ? "Unity 实时光照与 Toon 材质。" : "原始烘焙光影、顶点色与角色光照;关闭 Unity 实时灯。", EditorStyles.wordWrappedMiniLabel);
|
||||
Field(scenario, "MotionBlur", "原版镜头拖影");
|
||||
Field(scenario, "Camera", "相机覆盖");
|
||||
|
||||
if (_session.Preview != null && DrawerButton("将当前视角保存到配置"))
|
||||
{
|
||||
_session.Preview.View.GetCamera(out Vector3 position, out Vector3 target, out float fov);
|
||||
Edit("Capture preview camera", () => Scenario.Camera = new BattleCamera { Override = true, Position = Point(position), Target = Point(target), FieldOfView = fov });
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawParticipant(BattleParticipant actor)
|
||||
{
|
||||
GUILayout.Label(ActorLabel(actor), EditorStyles.boldLabel);
|
||||
GUILayout.Label("实例:" + actor.InstanceId, EditorStyles.wordWrappedMiniLabel);
|
||||
BattleSlot slot = (BattleSlot)EditorGUILayout.EnumPopup("阵位(占用时交换)", actor.Slot);
|
||||
if (slot != actor.Slot)
|
||||
Edit("Swap battle slots", () =>
|
||||
{
|
||||
BattleParticipant other = Scenario.Participants.FirstOrDefault(candidate => candidate != actor && candidate.Side == actor.Side && candidate.Slot == slot);
|
||||
if (other != null)
|
||||
other.Slot = actor.Slot;
|
||||
actor.Slot = slot;
|
||||
});
|
||||
|
||||
Field(actor, "Level", "等级");
|
||||
if (Section("actor-details", "成长与显示位置"))
|
||||
{
|
||||
Field(actor, "Model", "模型覆盖");
|
||||
Field(actor, "Experience", "当前经验");
|
||||
Field(actor, "Love", "好感度");
|
||||
GUILayout.Label(actor.AttributeSource switch
|
||||
{
|
||||
BattleAttributeSource.ExplicitEffective => "显式有效属性:下面的数值直接作为本局最终属性,装备不重复加成。",
|
||||
BattleAttributeSource.BaseWithEquipment => "基础属性加装备:下面提供裸装基础数值,开局按原版计算装备加成。",
|
||||
_ => "原版等级属性:按角色和等级从已核实的原版成长数据生成属性;无法核实的角色会明确拒绝。"
|
||||
}, EditorStyles.wordWrappedMiniLabel);
|
||||
Field(actor, "OverridePosition", "覆盖显示位置");
|
||||
if (actor.OverridePosition)
|
||||
Field(actor, "Position", "位置(Unity 单位)");
|
||||
else if (_session.Data != null)
|
||||
EditorGUILayout.LabelField("原始位置", _session.Data.Position(actor, Scenario.SceneElement).ToString("F2"));
|
||||
}
|
||||
if (Section("attributes", "初始属性与精气神"))
|
||||
{
|
||||
Field(actor, "AttributeSource", "属性来源");
|
||||
using (new EditorGUI.DisabledScope(actor.AttributeSource == BattleAttributeSource.LevelGrowth))
|
||||
for (int i = 0; i < (actor.Attributes?.Length ?? 0) && i < AttributeLabels.Length; i++)
|
||||
{
|
||||
int index = i;
|
||||
int value = EditorGUILayout.IntField(AttributeLabels[index], actor.Attributes[index]);
|
||||
if (value != actor.Attributes[index])
|
||||
Edit("Set initial attribute", () => actor.Attributes[index] = value);
|
||||
}
|
||||
for (int i = 0; i < (actor.Vitals?.Length ?? 0) && i < 3; i++)
|
||||
{
|
||||
int index = i;
|
||||
int value = EditorGUILayout.IntField(new[] { "当前精", "当前气", "当前神" }[index], actor.Vitals[index]);
|
||||
if (value != actor.Vitals[index])
|
||||
Edit("Set initial vitals", () => actor.Vitals[index] = value);
|
||||
}
|
||||
}
|
||||
if (Section("equipment", "装备与魔剑"))
|
||||
{
|
||||
Field(actor, "Equipment", "装备 ID");
|
||||
if (actor.Equipment is { Length: > 0 } && actor.Equipment[0] == BattleMagicSwordRules.WeaponId)
|
||||
{
|
||||
if (actor.MagicSword == null)
|
||||
{
|
||||
if (DrawerButton("建立魔剑培养快照(发布默认值)"))
|
||||
Edit("Capture magic sword defaults", () => actor.MagicSword = new BattleMagicSword());
|
||||
}
|
||||
else
|
||||
Field(actor, "MagicSword", "魔剑培养与初始能量");
|
||||
}
|
||||
else if (actor.MagicSword != null && DrawerButton("移除未装备的魔剑快照"))
|
||||
Edit("Remove unequipped magic sword snapshot", () => actor.MagicSword = null);
|
||||
}
|
||||
if (Section("skills", $"初始技能({actor.Skills.Count})"))
|
||||
Field(actor, "Skills", "技能列表");
|
||||
if (Section("statuses", $"初始状态({actor.Statuses.Count})"))
|
||||
Field(actor, "Statuses", "状态列表");
|
||||
GUILayout.Label("掌握必须显式设置;技能、状态与装备按本作原始数据及已验证的规则校验,不可用原因显示在实战指令和诊断中。", EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
|
||||
private void Field(object owner, string name, string label)
|
||||
{
|
||||
BattleScenarioTypedFields.Field(owner, name, label, Edit, Theme.Button);
|
||||
GUILayout.Space(2);
|
||||
}
|
||||
|
||||
private static BattlePoint Point(Vector3 value) => new() { X = value.x, Y = value.y, Z = value.z };
|
||||
|
||||
private void DrawCanvas(Rect available, bool newBattleKey)
|
||||
{
|
||||
BattlePreview preview = _session.Preview;
|
||||
EditorGUI.DrawRect(available, new Color(0.12f, 0.12f, 0.12f));
|
||||
if (preview == null)
|
||||
{
|
||||
DrawWelcome(available);
|
||||
return;
|
||||
}
|
||||
preview.View.ExpandReferenceFraming = _expandCamera;
|
||||
preview.DamageNumberColorMode = _damageNumberColor;
|
||||
Rect rect = _originalAspect ? BattleHudLayout.ContentRect(available) : available;
|
||||
// The game supports landscape and square canvases. A tall tool
|
||||
// window or an open drawer must not create a portrait battle HUD.
|
||||
if (rect.height > rect.width)
|
||||
rect = new Rect(rect.x, rect.center.y - rect.width / 2, rect.width, rect.width);
|
||||
preview.View.SetViewportContext(rect);
|
||||
EditorGUI.DrawRect(available, Color.black);
|
||||
if (Event.current.type == EventType.MouseMove && rect.Contains(Event.current.mousePosition))
|
||||
Repaint();
|
||||
Event inputEvent = Event.current;
|
||||
BattleSession battle = _session.Battle;
|
||||
bool coAttackBlocksHud = battle?.IsCoAttackPresentationBlockingInput == true;
|
||||
bool ownsKeyboard = GUIUtility.keyboardControl == 0 && !EditorGUIUtility.editingTextField;
|
||||
// Unity sends a separate character event for Tab. Let the key-code event
|
||||
// drive the HUD and consume the character before IMGUI assigns focus.
|
||||
bool battleOwnsTab = !DraftPending && ownsKeyboard && (battle?.Status == BattleSessionStatus.Running ||
|
||||
_session.ResultPresentation is { Completed: false });
|
||||
if (battleOwnsTab && inputEvent.type == EventType.KeyDown &&
|
||||
inputEvent.keyCode == KeyCode.None && inputEvent.character is '\t' or '\x19')
|
||||
inputEvent.Use();
|
||||
bool canReadKey = BattleHudView.CanReadBattleKey(inputEvent);
|
||||
bool clickedCanvas = inputEvent.type == EventType.MouseDown && rect.Contains(inputEvent.mousePosition);
|
||||
if (!DraftPending && _session.ResultPresentation is { Completed: false } resultInput && (canReadKey || clickedCanvas))
|
||||
{
|
||||
if (clickedCanvas)
|
||||
{
|
||||
BattleHudView.TakeGuiKeyboardFocus();
|
||||
if (inputEvent.button == 1 && resultInput.StatisticsVisible)
|
||||
resultInput.CloseStatistics();
|
||||
}
|
||||
_session.SkipResultStep();
|
||||
inputEvent.Use();
|
||||
}
|
||||
else if (!DraftPending && battle != null && (canReadKey || coAttackBlocksHud && clickedCanvas))
|
||||
{
|
||||
if (coAttackBlocksHud && clickedCanvas)
|
||||
BattleHudView.TakeGuiKeyboardFocus();
|
||||
bool skipped = battle.IsModalPresentation
|
||||
? canReadKey && inputEvent.keyCode == KeyCode.Escape && battle.SkipModalPresentation()
|
||||
: coAttackBlocksHud && (clickedCanvas || newBattleKey) && battle.SkipCoAttackPresentation();
|
||||
if (skipped)
|
||||
{
|
||||
_session.SyncBattle();
|
||||
Repaint();
|
||||
}
|
||||
if (battle.IsModalPresentation || skipped || coAttackBlocksHud)
|
||||
inputEvent.Use();
|
||||
}
|
||||
if (!DraftPending && battle?.Status == BattleSessionStatus.Running && canReadKey && !newBattleKey && BattleHudView.KeyboardIntent(inputEvent.keyCode) is { } repeated &&
|
||||
repeated.Kind is BattleHudIntentKind.Confirm or BattleHudIntentKind.Back && inputEvent.type == EventType.KeyDown)
|
||||
inputEvent.Use();
|
||||
void DrawHud()
|
||||
{
|
||||
using var input = new EditorGUI.DisabledScope(DraftPending || coAttackBlocksHud);
|
||||
_hud.Draw(_session.Battle, _session.Data, preview, rect,
|
||||
SyncHudBattle, SelectHudActor, _hudSafeInsets, Repaint, new BattleHudInteractionProfile(_touchHud));
|
||||
}
|
||||
if (_session.Battle != null && Event.current.type != EventType.Repaint)
|
||||
DrawHud();
|
||||
if (battleOwnsTab &&
|
||||
inputEvent.keyCode == KeyCode.Tab && BattleHudView.CanReadBattleKey(inputEvent))
|
||||
inputEvent.Use();
|
||||
if (_session.Battle == null && Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
string picked = preview.InstanceAt(Event.current.mousePosition, rect);
|
||||
if (picked != null)
|
||||
SelectHudActor(picked);
|
||||
}
|
||||
if (_session.Battle != null)
|
||||
_hud.PreparePointers(_session.Battle, _session.Data, preview);
|
||||
if (_session.Battle != null && BattleHudView.CanReadBattleKey(Event.current) &&
|
||||
Event.current.keyCode is KeyCode.F or KeyCode.R && rect.Contains(Event.current.mousePosition))
|
||||
Event.current.Use();
|
||||
// Native list/scrollbar controls get first refusal before the
|
||||
// battle canvas accepts any remaining pointer gesture.
|
||||
if (_session.Battle != null)
|
||||
_hud.CompleteGuiInput(Event.current, rect);
|
||||
preview.View.Draw(rect, allowCameraInput: _session.Battle == null);
|
||||
if (_session.Battle?.IsPreparingPresentation == true)
|
||||
{
|
||||
GUI.Label(rect, "正在准备战斗影片…", Theme.WelcomeText);
|
||||
return;
|
||||
}
|
||||
if (battle == null || _debugBattle && !battle.IsModalPresentation)
|
||||
preview.DrawLabels(rect, _selected);
|
||||
if (_session.Battle != null)
|
||||
preview.DrawBattleOverlay(_session.Battle, rect, _hudSafeInsets, BattleHudView.ElementWheelVisible(_session.Battle, _hud.Presenter), _hud.NavigationFocusedControl);
|
||||
if (_session.Battle != null)
|
||||
preview.DrawBattleNumbers(_session.Battle, rect, _hudSafeInsets);
|
||||
if (_session.Battle != null && Event.current.type == EventType.Repaint)
|
||||
DrawHud();
|
||||
if (_session.Battle != null)
|
||||
preview.DrawBattleMessages(_session.Battle, rect, _hudSafeInsets);
|
||||
if (_session.Battle != null)
|
||||
preview.DrawSwordSparks(rect, _hudSafeInsets);
|
||||
if (_session.Battle?.CoAttackScreenOpacity > 0)
|
||||
{
|
||||
uint value = _session.Battle.CoAttackScreenColor;
|
||||
Color color = new((value >> 16 & 255) / 255f, (value >> 8 & 255) / 255f,
|
||||
(value & 255) / 255f, _session.Battle.CoAttackScreenOpacity);
|
||||
EditorGUI.DrawRect(rect, color);
|
||||
}
|
||||
if (_session.ResultPresentation != null)
|
||||
preview.DrawResultOverlay(_session.ResultPresentation, rect, _hudSafeInsets);
|
||||
}
|
||||
|
||||
private void DrawActions(BattlePreview preview)
|
||||
{
|
||||
BattleScenario captured = _session.CapturedScenario;
|
||||
BattleParticipant actor = captured.Participants.FirstOrDefault(candidate => candidate.InstanceId == _selected);
|
||||
if (actor == null)
|
||||
{
|
||||
GUILayout.Label("选择参战者以预览动作。", EditorStyles.miniLabel);
|
||||
return;
|
||||
}
|
||||
string[] actions = _session.Data.Actions(actor).Select(action => action.ActionName).ToArray();
|
||||
int index = Array.IndexOf(actions, _action);
|
||||
if (index < 0)
|
||||
index = Math.Max(0, Array.IndexOf(actions, _session.Data.IdleAction(actor)));
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
index = EditorGUILayout.Popup("动作", index, actions, GUILayout.Height(BattleEditorTheme.ControlHeight));
|
||||
_action = actions[index];
|
||||
GUILayout.Space(6);
|
||||
if (DrawerButton("演示动作", GUILayout.Width(80)))
|
||||
Try(() =>
|
||||
{
|
||||
preview.PlayAction(actor.InstanceId, _action);
|
||||
_session.IsPlaying = true;
|
||||
});
|
||||
}
|
||||
BattleParticipant[] targets = captured.Participants.Where(candidate => candidate.Side != actor.Side).ToArray();
|
||||
int target = Math.Max(0, Array.FindIndex(targets, candidate => candidate.InstanceId == _target));
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
target = EditorGUILayout.Popup("攻击目标", target, targets.Select(ActorLabel).ToArray(), GUILayout.Height(BattleEditorTheme.ControlHeight));
|
||||
if (targets.Length > 0)
|
||||
_target = targets[target].InstanceId;
|
||||
GUILayout.Space(6);
|
||||
using (new EditorGUI.DisabledScope(targets.Length == 0))
|
||||
if (DrawerButton("普攻演示", GUILayout.Width(80)))
|
||||
Try(() =>
|
||||
{
|
||||
preview.PlayAttack(actor.InstanceId, _target);
|
||||
_session.IsPlaying = true;
|
||||
});
|
||||
}
|
||||
GUILayout.Label("动画标记(仅显示,不触发结算):" + string.Join(" · ", preview.AnimationMarkers(actor.InstanceId)), EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b86182be927449b8a97708a4755a61f
|
||||
@@ -0,0 +1,322 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Battle.Presentation;
|
||||
using UnityEditor;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Controls;
|
||||
using UnityEngine.InputSystem.LowLevel;
|
||||
|
||||
// Input actions intentionally ignore Editor updates. Use the editor's
|
||||
// existing event stream and flush once after its native input update.
|
||||
public sealed class BattleEditorGamepadInput : IDisposable
|
||||
{
|
||||
private readonly Func<bool> _canReceive;
|
||||
private readonly Action<BattleEditorGamepadIntent> _dispatch;
|
||||
private readonly Func<double> _clock;
|
||||
private readonly Action<BattleEditorGamepadIntent> _collect;
|
||||
private readonly Dictionary<int, DeviceState> _devices = new();
|
||||
private readonly List<DeviceState> _iteration = new();
|
||||
private readonly List<PendingIntent> _ready = new();
|
||||
private readonly List<PendingIntent> _deviceChangePoints = new();
|
||||
private Gamepad _pointingDevice;
|
||||
private int _suspensionVersion;
|
||||
private DeviceState _collectingState;
|
||||
private long _eventSequence;
|
||||
private bool _disposed;
|
||||
|
||||
private readonly struct PendingIntent
|
||||
{
|
||||
public readonly DeviceState State;
|
||||
public readonly BattleEditorGamepadState Policy;
|
||||
public readonly BattleEditorGamepadIntent Intent;
|
||||
public readonly Gamepad PointingDevice;
|
||||
public readonly int NavigationVersion, SuspensionVersion;
|
||||
|
||||
public PendingIntent(DeviceState state, BattleEditorGamepadIntent intent)
|
||||
{
|
||||
State = state;
|
||||
Policy = state.Policy;
|
||||
PointingDevice = null;
|
||||
Intent = intent;
|
||||
NavigationVersion = Policy.NavigationVersion;
|
||||
SuspensionVersion = Policy.SuspensionVersion;
|
||||
}
|
||||
|
||||
public PendingIntent(Gamepad device, BattleEditorGamepadIntent intent, int suspensionVersion)
|
||||
{
|
||||
State = null;
|
||||
Policy = null;
|
||||
PointingDevice = device;
|
||||
Intent = intent;
|
||||
NavigationVersion = 0;
|
||||
SuspensionVersion = suspensionVersion;
|
||||
}
|
||||
}
|
||||
|
||||
private PendingIntent PointingReset(Gamepad device)
|
||||
{
|
||||
return new PendingIntent(device, new BattleEditorGamepadIntent(BattleEditorGamepadIntentKind.Point,
|
||||
BattleHudDirection.Neutral, false, ++_eventSequence * 2,
|
||||
BattleHudDirection.Neutral), _suspensionVersion);
|
||||
}
|
||||
|
||||
private sealed class DeviceState
|
||||
{
|
||||
public readonly Gamepad Device;
|
||||
|
||||
public BattleEditorGamepadState Policy
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
private bool _baselineDirty;
|
||||
private float _stickX, _stickY;
|
||||
private bool _up, _down, _left, _right;
|
||||
private BattleEditorGamepadButtons _buttons;
|
||||
private readonly (ButtonControl Control, BattleEditorGamepadButtons Button)[] _controls;
|
||||
|
||||
public BattleEditorGamepadSnapshot Snapshot => new(_stickX, _stickY, (_right ? 1 : 0) - (_left ? 1 : 0), (_up ? 1 : 0) - (_down ? 1 : 0), _buttons);
|
||||
|
||||
public DeviceState(Gamepad device)
|
||||
{
|
||||
Device = device;
|
||||
_controls = new[]
|
||||
{
|
||||
(device.buttonSouth, BattleEditorGamepadButtons.Confirm),
|
||||
(device.buttonEast, BattleEditorGamepadButtons.Cancel),
|
||||
(device.buttonWest, BattleEditorGamepadButtons.Primary),
|
||||
(device.buttonNorth, BattleEditorGamepadButtons.Repeat),
|
||||
(device.leftShoulder, BattleEditorGamepadButtons.PreviousSection),
|
||||
(device.rightShoulder, BattleEditorGamepadButtons.NextSection),
|
||||
(device.startButton, BattleEditorGamepadButtons.Transport)
|
||||
};
|
||||
RebuildBaseline();
|
||||
}
|
||||
|
||||
public void MarkReset()
|
||||
{
|
||||
// ResetDevice notifies listeners before replacing its state,
|
||||
// so reading controls from that callback would cache old data.
|
||||
_baselineDirty = true;
|
||||
Policy.Suspend();
|
||||
}
|
||||
|
||||
public void EnsureBaseline()
|
||||
{
|
||||
if (_baselineDirty)
|
||||
RebuildBaseline();
|
||||
}
|
||||
|
||||
private void RebuildBaseline()
|
||||
{
|
||||
_stickX = Device.leftStick.x.ReadValue();
|
||||
_stickY = Device.leftStick.y.ReadValue();
|
||||
_up = Device.dpad.up.isPressed;
|
||||
_down = Device.dpad.down.isPressed;
|
||||
_left = Device.dpad.left.isPressed;
|
||||
_right = Device.dpad.right.isPressed;
|
||||
_buttons = BattleEditorGamepadButtons.None;
|
||||
foreach ((ButtonControl control, BattleEditorGamepadButtons button) in _controls)
|
||||
if (control.isPressed)
|
||||
_buttons |= button;
|
||||
Policy = new BattleEditorGamepadState(Snapshot);
|
||||
_baselineDirty = false;
|
||||
}
|
||||
|
||||
public void Read(InputEventPtr input)
|
||||
{
|
||||
// Read actual layout controls rather than assuming GPAD state
|
||||
// memory. Partial delta events retain every absent control.
|
||||
if (Device.leftStick.x.ReadValueFromEvent(input, out float x))
|
||||
_stickX = x;
|
||||
if (Device.leftStick.y.ReadValueFromEvent(input, out float y))
|
||||
_stickY = y;
|
||||
ReadButton(Device.dpad.up, input, ref _up);
|
||||
ReadButton(Device.dpad.down, input, ref _down);
|
||||
ReadButton(Device.dpad.left, input, ref _left);
|
||||
ReadButton(Device.dpad.right, input, ref _right);
|
||||
foreach ((ButtonControl control, BattleEditorGamepadButtons button) in _controls)
|
||||
if (control.ReadValueFromEvent(input, out float value))
|
||||
_buttons = control.IsValueConsideredPressed(value) ? _buttons | button : _buttons & ~button;
|
||||
}
|
||||
|
||||
private static void ReadButton(ButtonControl control, InputEventPtr input, ref bool pressed)
|
||||
{
|
||||
if (control.ReadValueFromEvent(input, out float value))
|
||||
pressed = control.IsValueConsideredPressed(value);
|
||||
}
|
||||
}
|
||||
|
||||
public BattleEditorGamepadInput(Func<bool> canReceive, Action<BattleEditorGamepadIntent> dispatch, Func<double> clock = null)
|
||||
{
|
||||
_canReceive = canReceive ?? throw new ArgumentNullException(nameof(canReceive));
|
||||
_dispatch = dispatch ?? throw new ArgumentNullException(nameof(dispatch));
|
||||
_clock = clock ?? (() => EditorApplication.timeSinceStartup);
|
||||
_collect = Collect;
|
||||
foreach (Gamepad gamepad in Gamepad.all)
|
||||
_devices[gamepad.deviceId] = new DeviceState(gamepad);
|
||||
InputSystem.onEvent += OnEvent;
|
||||
InputSystem.onAfterUpdate += OnAfterUpdate;
|
||||
InputSystem.onDeviceChange += OnDeviceChange;
|
||||
}
|
||||
|
||||
private void OnEvent(InputEventPtr input, InputDevice device)
|
||||
{
|
||||
if (_disposed || device is not Gamepad gamepad || !gamepad.enabled || !(input.IsA<StateEvent>() || input.IsA<DeltaStateEvent>()))
|
||||
return;
|
||||
if (!_devices.TryGetValue(gamepad.deviceId, out DeviceState state))
|
||||
_devices.Add(gamepad.deviceId, state = new DeviceState(gamepad));
|
||||
state.EnsureBaseline();
|
||||
BattleEditorGamepadSnapshot before = state.Snapshot;
|
||||
state.Read(input);
|
||||
BattleEditorGamepadSnapshot snapshot = state.Snapshot;
|
||||
bool canReceive = InputState.currentUpdateType == InputUpdateType.Editor && !input.handled && _canReceive();
|
||||
if (canReceive && (snapshot.Buttons & ~before.Buttons) != BattleEditorGamepadButtons.None)
|
||||
foreach (DeviceState other in _devices.Values)
|
||||
if (!ReferenceEquals(other, state))
|
||||
other.Policy.SealNavigation();
|
||||
state.Policy.Sample(snapshot, canReceive, ++_eventSequence);
|
||||
// Keep the full state event available to Unity and other tools.
|
||||
}
|
||||
|
||||
private void OnAfterUpdate()
|
||||
{
|
||||
if (_disposed || InputState.currentUpdateType != InputUpdateType.Editor)
|
||||
return;
|
||||
_iteration.Clear();
|
||||
_ready.Clear();
|
||||
foreach (DeviceState state in _devices.Values)
|
||||
_iteration.Add(state);
|
||||
double now = _clock();
|
||||
foreach (DeviceState state in _iteration)
|
||||
{
|
||||
if (_disposed)
|
||||
break;
|
||||
if (!state.Device.added || !state.Device.enabled)
|
||||
{
|
||||
state.Policy.Suspend();
|
||||
continue;
|
||||
}
|
||||
state.EnsureBaseline();
|
||||
_collectingState = state;
|
||||
state.Policy.Advance(now, _canReceive(), _collect);
|
||||
}
|
||||
_collectingState = null;
|
||||
_ready.AddRange(_deviceChangePoints);
|
||||
_deviceChangePoints.Clear();
|
||||
// Native arrival order also applies across controllers. Device
|
||||
// dictionary order must never decide which menu a Confirm sees.
|
||||
_ready.Sort((left, right) => left.Intent.Sequence.CompareTo(right.Intent.Sequence));
|
||||
foreach (PendingIntent pending in _ready)
|
||||
{
|
||||
if (_disposed)
|
||||
break;
|
||||
DeviceState state = pending.State;
|
||||
if (state == null)
|
||||
{
|
||||
if (pending.SuspensionVersion != _suspensionVersion || !_canReceive())
|
||||
continue;
|
||||
if (UpdatePointingOwner(pending.PointingDevice, pending.Intent))
|
||||
_dispatch(pending.Intent);
|
||||
continue;
|
||||
}
|
||||
if (!state.Device.added || !state.Device.enabled || !ReferenceEquals(state.Policy, pending.Policy) ||
|
||||
state.Policy.SuspensionVersion != pending.SuspensionVersion ||
|
||||
pending.Intent.IsRepeat && state.Policy.NavigationVersion != pending.NavigationVersion)
|
||||
continue;
|
||||
if (!_canReceive())
|
||||
{
|
||||
state.Policy.Suspend();
|
||||
continue;
|
||||
}
|
||||
// A preceding Confirm may have opened another page and reset
|
||||
// navigation. This later fresh gesture is still a new gesture.
|
||||
state.Policy.NotifyDispatched(pending.Intent, now);
|
||||
if (UpdatePointingOwner(state.Device, pending.Intent))
|
||||
_dispatch(pending.Intent);
|
||||
}
|
||||
}
|
||||
|
||||
private bool UpdatePointingOwner(Gamepad device, BattleEditorGamepadIntent intent)
|
||||
{
|
||||
if (intent.PointingDirection is not { } direction)
|
||||
return true;
|
||||
if (intent.IsRepeat && _pointingDevice != device)
|
||||
return false;
|
||||
if (intent.Kind != BattleEditorGamepadIntentKind.Point || direction != BattleHudDirection.Neutral)
|
||||
{
|
||||
_pointingDevice = device;
|
||||
return true;
|
||||
}
|
||||
// Releases and device resets only clear the controller that is
|
||||
// currently pointing. Another controller may have taken over.
|
||||
if (_pointingDevice != device)
|
||||
return false;
|
||||
_pointingDevice = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Collect(BattleEditorGamepadIntent intent)
|
||||
{
|
||||
if (_collectingState != null)
|
||||
_ready.Add(new PendingIntent(_collectingState, intent));
|
||||
}
|
||||
|
||||
private void OnDeviceChange(InputDevice device, InputDeviceChange change)
|
||||
{
|
||||
if (device is Gamepad gamepad && change is InputDeviceChange.Removed or InputDeviceChange.Disconnected or
|
||||
InputDeviceChange.Disabled or InputDeviceChange.SoftReset or InputDeviceChange.HardReset)
|
||||
{
|
||||
if (_canReceive() && _devices.TryGetValue(device.deviceId, out DeviceState pendingState))
|
||||
pendingState.Policy.CapturePendingPointing(intent =>
|
||||
{
|
||||
// Preserve the accepted position and its original order,
|
||||
// but never revive a command or a list step after reset.
|
||||
var point = new BattleEditorGamepadIntent(BattleEditorGamepadIntentKind.Point, intent.Direction,
|
||||
false, intent.Sequence, intent.PointingDirection);
|
||||
_deviceChangePoints.Add(new PendingIntent(gamepad, point, _suspensionVersion));
|
||||
});
|
||||
_deviceChangePoints.Add(PointingReset(gamepad));
|
||||
}
|
||||
if (change is InputDeviceChange.Removed or InputDeviceChange.Disconnected)
|
||||
_devices.Remove(device.deviceId);
|
||||
else if ((change is InputDeviceChange.Disabled or InputDeviceChange.SoftReset or InputDeviceChange.HardReset) && _devices.TryGetValue(device.deviceId, out DeviceState state))
|
||||
state.MarkReset();
|
||||
}
|
||||
|
||||
public void Suspend()
|
||||
{
|
||||
_suspensionVersion++;
|
||||
_pointingDevice = null;
|
||||
_deviceChangePoints.Clear();
|
||||
foreach (DeviceState state in _devices.Values)
|
||||
state.Policy.Suspend();
|
||||
}
|
||||
|
||||
public void ResetNavigation()
|
||||
{
|
||||
foreach (DeviceState state in _devices.Values)
|
||||
state.Policy.ResetNavigation();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
_disposed = true;
|
||||
InputSystem.onEvent -= OnEvent;
|
||||
InputSystem.onAfterUpdate -= OnAfterUpdate;
|
||||
InputSystem.onDeviceChange -= OnDeviceChange;
|
||||
_devices.Clear();
|
||||
_pointingDevice = null;
|
||||
_deviceChangePoints.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76ae6f1a2e254b688684213e5cb0aac2
|
||||
@@ -0,0 +1,350 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Battle.Presentation;
|
||||
|
||||
public enum BattleEditorGamepadIntentKind
|
||||
{
|
||||
Navigate, Confirm, Cancel, PreviousSection, NextSection, Primary, Repeat, Transport, Point
|
||||
}
|
||||
|
||||
public readonly struct BattleEditorGamepadIntent
|
||||
{
|
||||
public BattleEditorGamepadIntentKind Kind
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public BattleHudDirection Direction
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
// Null denotes an intent without a native device-position snapshot.
|
||||
public BattleHudDirection? PointingDirection
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public bool IsRepeat
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
internal long Sequence
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public BattleEditorGamepadIntent(BattleEditorGamepadIntentKind kind, BattleHudDirection direction = BattleHudDirection.Down, bool isRepeat = false, BattleHudDirection? pointingDirection = null)
|
||||
: this(kind, direction, isRepeat, 0, pointingDirection)
|
||||
{
|
||||
}
|
||||
|
||||
internal BattleEditorGamepadIntent(BattleEditorGamepadIntentKind kind, BattleHudDirection direction, bool isRepeat, long sequence, BattleHudDirection? pointingDirection = null)
|
||||
{
|
||||
Kind = kind;
|
||||
Direction = direction;
|
||||
PointingDirection = pointingDirection;
|
||||
IsRepeat = isRepeat;
|
||||
Sequence = sequence;
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum BattleEditorGamepadButtons
|
||||
{
|
||||
None = 0, Confirm = 1, Cancel = 2, PreviousSection = 4, NextSection = 8,
|
||||
Primary = 16, Repeat = 32, Transport = 64
|
||||
}
|
||||
|
||||
public readonly struct BattleEditorGamepadSnapshot
|
||||
{
|
||||
public float StickX
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public float StickY
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public int DpadX
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public int DpadY
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public BattleEditorGamepadButtons Buttons
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public BattleEditorGamepadSnapshot(float stickX = 0, float stickY = 0, int dpadX = 0, int dpadY = 0, BattleEditorGamepadButtons buttons = BattleEditorGamepadButtons.None)
|
||||
{
|
||||
StickX = stickX;
|
||||
StickY = stickY;
|
||||
DpadX = Math.Sign(dpadX);
|
||||
DpadY = Math.Sign(dpadY);
|
||||
Buttons = buttons;
|
||||
}
|
||||
}
|
||||
|
||||
// Pure UI timing and gesture policy. Simulation speed and Input System
|
||||
// settings do not affect its clock, button edges, or repeat intervals.
|
||||
public sealed class BattleEditorGamepadState
|
||||
{
|
||||
public const double RepeatDelay = .35;
|
||||
public const double RepeatInterval = .10;
|
||||
public const float StickEnter = .5f;
|
||||
public const float StickExit = .35f;
|
||||
private const double SectorWidth = Math.PI / 4;
|
||||
private const double SectorHysteresis = Math.PI / 36;
|
||||
private static readonly (BattleEditorGamepadButtons Button, BattleEditorGamepadIntentKind Intent)[] ButtonPriority =
|
||||
{
|
||||
(BattleEditorGamepadButtons.Cancel, BattleEditorGamepadIntentKind.Cancel),
|
||||
(BattleEditorGamepadButtons.Transport, BattleEditorGamepadIntentKind.Transport),
|
||||
(BattleEditorGamepadButtons.PreviousSection, BattleEditorGamepadIntentKind.PreviousSection),
|
||||
(BattleEditorGamepadButtons.NextSection, BattleEditorGamepadIntentKind.NextSection),
|
||||
(BattleEditorGamepadButtons.Primary, BattleEditorGamepadIntentKind.Primary),
|
||||
(BattleEditorGamepadButtons.Repeat, BattleEditorGamepadIntentKind.Repeat),
|
||||
(BattleEditorGamepadButtons.Confirm, BattleEditorGamepadIntentKind.Confirm)
|
||||
};
|
||||
|
||||
private readonly List<BattleEditorGamepadIntent> _pending = new();
|
||||
private readonly List<BattleEditorGamepadIntent> _draining = new();
|
||||
private BattleEditorGamepadSnapshot _snapshot;
|
||||
private BattleHudDirection? _direction;
|
||||
private BattleEditorGamepadIntent? _navigationPulse;
|
||||
private long _sequence;
|
||||
private int? _stickSector;
|
||||
private bool _navigationArmed, _pointingArmed;
|
||||
private double _nextRepeat = double.PositiveInfinity;
|
||||
private double _lastTime = double.NegativeInfinity;
|
||||
|
||||
internal int NavigationVersion
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
internal int SuspensionVersion
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public BattleEditorGamepadState(BattleEditorGamepadSnapshot initial = default)
|
||||
{
|
||||
_snapshot = initial;
|
||||
_navigationArmed = _pointingArmed = Neutral(initial);
|
||||
}
|
||||
|
||||
private static bool Neutral(BattleEditorGamepadSnapshot snapshot) => snapshot.DpadX == 0 && snapshot.DpadY == 0 &&
|
||||
snapshot.StickX * snapshot.StickX + snapshot.StickY * snapshot.StickY < StickExit * StickExit;
|
||||
|
||||
public void Sample(BattleEditorGamepadSnapshot snapshot, bool canReceive, long sequence = 0)
|
||||
{
|
||||
if (sequence <= 0)
|
||||
sequence = ++_sequence;
|
||||
else
|
||||
_sequence = Math.Max(_sequence, sequence);
|
||||
BattleHudDirection? previousDirection = ReadDirection();
|
||||
BattleEditorGamepadButtons rising = snapshot.Buttons & ~_snapshot.Buttons;
|
||||
bool buttonPressed = TryButton(rising, out BattleEditorGamepadIntentKind button);
|
||||
bool wasNeutral = Neutral(_snapshot);
|
||||
bool freshDpad = _snapshot.DpadX == 0 && _snapshot.DpadY == 0 && (snapshot.DpadX != 0 || snapshot.DpadY != 0);
|
||||
if (canReceive && (wasNeutral || freshDpad))
|
||||
_navigationArmed = _pointingArmed = true;
|
||||
_snapshot = snapshot;
|
||||
if (!canReceive)
|
||||
{
|
||||
Suspend();
|
||||
return;
|
||||
}
|
||||
BattleHudDirection? sampledDirection = ReadDirection();
|
||||
BattleHudDirection pointingDirection = sampledDirection ?? BattleHudDirection.Neutral;
|
||||
if (buttonPressed && button != BattleEditorGamepadIntentKind.Confirm)
|
||||
{
|
||||
// A button is a stream-order barrier. Earlier directions stay
|
||||
// earlier; coincident Cancel/transport wins over navigation.
|
||||
SealNavigation();
|
||||
_pending.Add(new BattleEditorGamepadIntent(button, BattleHudDirection.Down, false, sequence * 2 + 1, pointingDirection));
|
||||
ResetHeldNavigation();
|
||||
return;
|
||||
}
|
||||
if (_pointingArmed && sampledDirection != previousDirection)
|
||||
{
|
||||
// Axis components may coalesce, but a release preserves the
|
||||
// preceding list step and immediately points the wheel home.
|
||||
if (wasNeutral || !sampledDirection.HasValue)
|
||||
SealNavigation();
|
||||
BattleEditorGamepadIntentKind kind = _navigationArmed && sampledDirection.HasValue
|
||||
? BattleEditorGamepadIntentKind.Navigate : BattleEditorGamepadIntentKind.Point;
|
||||
_navigationPulse = new BattleEditorGamepadIntent(kind, pointingDirection, false, sequence * 2, pointingDirection);
|
||||
}
|
||||
if (buttonPressed)
|
||||
{
|
||||
// Direction and Confirm in one state event navigate first.
|
||||
// Separate events retain their actual order and every edge.
|
||||
SealNavigation();
|
||||
_pending.Add(new BattleEditorGamepadIntent(button, BattleHudDirection.Down, false, sequence * 2 + 1, pointingDirection));
|
||||
}
|
||||
}
|
||||
|
||||
internal void SealNavigation()
|
||||
{
|
||||
if (!_navigationPulse.HasValue)
|
||||
return;
|
||||
_pending.Add(_navigationPulse.Value);
|
||||
_navigationPulse = null;
|
||||
}
|
||||
|
||||
internal void CapturePendingPointing(Action<BattleEditorGamepadIntent> collect)
|
||||
{
|
||||
SealNavigation();
|
||||
foreach (BattleEditorGamepadIntent intent in _pending)
|
||||
if (intent.Kind is BattleEditorGamepadIntentKind.Navigate or BattleEditorGamepadIntentKind.Point)
|
||||
collect(intent);
|
||||
}
|
||||
|
||||
public void Suspend()
|
||||
{
|
||||
_pending.Clear();
|
||||
_navigationPulse = null;
|
||||
SuspensionVersion++;
|
||||
_pointingArmed = false;
|
||||
_stickSector = null;
|
||||
ResetHeldNavigation();
|
||||
}
|
||||
|
||||
public void ResetNavigation()
|
||||
{
|
||||
// A context change invalidates held repeats, not fresh events that
|
||||
// have already arrived later in the same input stream.
|
||||
SealNavigation();
|
||||
ResetHeldNavigation();
|
||||
}
|
||||
|
||||
private void ResetHeldNavigation()
|
||||
{
|
||||
_navigationArmed = false;
|
||||
_direction = null;
|
||||
_nextRepeat = double.PositiveInfinity;
|
||||
NavigationVersion++;
|
||||
}
|
||||
|
||||
internal void NotifyDispatched(BattleEditorGamepadIntent intent, double now)
|
||||
{
|
||||
if (intent.Kind == BattleEditorGamepadIntentKind.Navigate)
|
||||
{
|
||||
_navigationArmed = true;
|
||||
_direction = intent.Direction;
|
||||
_nextRepeat = now + (intent.IsRepeat ? RepeatInterval : RepeatDelay);
|
||||
}
|
||||
else if (intent.Kind is not (BattleEditorGamepadIntentKind.Confirm or BattleEditorGamepadIntentKind.Point))
|
||||
ResetHeldNavigation();
|
||||
}
|
||||
|
||||
public void Advance(double now, bool canReceive, Action<BattleEditorGamepadIntent> dispatch)
|
||||
{
|
||||
if (!double.IsFinite(now))
|
||||
throw new ArgumentOutOfRangeException(nameof(now));
|
||||
if (dispatch == null)
|
||||
throw new ArgumentNullException(nameof(dispatch));
|
||||
if (now < _lastTime)
|
||||
_nextRepeat = now + RepeatDelay;
|
||||
_lastTime = now;
|
||||
if (!canReceive)
|
||||
{
|
||||
Suspend();
|
||||
return;
|
||||
}
|
||||
if (Neutral(_snapshot))
|
||||
_navigationArmed = _pointingArmed = true;
|
||||
SealNavigation();
|
||||
_draining.Clear();
|
||||
_draining.AddRange(_pending);
|
||||
_pending.Clear();
|
||||
int suspension = SuspensionVersion;
|
||||
foreach (BattleEditorGamepadIntent intent in _draining)
|
||||
{
|
||||
if (suspension != SuspensionVersion)
|
||||
break;
|
||||
NotifyDispatched(intent, now);
|
||||
dispatch(intent);
|
||||
}
|
||||
if (suspension != SuspensionVersion)
|
||||
return;
|
||||
BattleHudDirection? direction = ReadDirection();
|
||||
if (!direction.HasValue)
|
||||
{
|
||||
_direction = null;
|
||||
_nextRepeat = double.PositiveInfinity;
|
||||
}
|
||||
else if (_draining.Count == 0 && _navigationArmed && _direction == direction && now + 1e-9 >= _nextRepeat)
|
||||
{
|
||||
// Fresh events always precede a timed repeat. Never replay a
|
||||
// backlog after a stalled editor update.
|
||||
var repeat = new BattleEditorGamepadIntent(BattleEditorGamepadIntentKind.Navigate, direction.Value, true, long.MaxValue, direction.Value);
|
||||
NotifyDispatched(repeat, now);
|
||||
dispatch(repeat);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryButton(BattleEditorGamepadButtons pressed, out BattleEditorGamepadIntentKind kind)
|
||||
{
|
||||
foreach ((BattleEditorGamepadButtons button, BattleEditorGamepadIntentKind intent) in ButtonPriority)
|
||||
if ((pressed & button) != 0)
|
||||
{
|
||||
kind = intent;
|
||||
return true;
|
||||
}
|
||||
kind = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
private BattleHudDirection? ReadDirection()
|
||||
{
|
||||
double magnitude = _snapshot.StickX * _snapshot.StickX + _snapshot.StickY * _snapshot.StickY;
|
||||
if (magnitude < StickExit * StickExit || !_stickSector.HasValue && magnitude < StickEnter * StickEnter)
|
||||
_stickSector = null;
|
||||
else
|
||||
{
|
||||
double angle = Math.Atan2(_snapshot.StickY, _snapshot.StickX);
|
||||
if (_stickSector is int previous)
|
||||
{
|
||||
double difference = Math.Atan2(Math.Sin(angle - previous * SectorWidth), Math.Cos(angle - previous * SectorWidth));
|
||||
if (Math.Abs(difference) > SectorWidth / 2 + SectorHysteresis)
|
||||
_stickSector = Sector(angle);
|
||||
}
|
||||
else
|
||||
_stickSector = Sector(angle);
|
||||
}
|
||||
int? sector = _snapshot.DpadX != 0 || _snapshot.DpadY != 0 ? Sector(Math.Atan2(_snapshot.DpadY, _snapshot.DpadX)) : _stickSector;
|
||||
return sector switch
|
||||
{
|
||||
0 => BattleHudDirection.Right,
|
||||
1 => BattleHudDirection.UpRight,
|
||||
2 => BattleHudDirection.Up,
|
||||
3 => BattleHudDirection.UpLeft,
|
||||
4 => BattleHudDirection.Left,
|
||||
5 => BattleHudDirection.DownLeft,
|
||||
6 => BattleHudDirection.Down,
|
||||
7 => BattleHudDirection.DownRight,
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
private static int Sector(double angle) => ((int)Math.Floor(angle / SectorWidth + .5) % 8 + 8) % 8;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2766a987b42441b4b733cd089bf647fb
|
||||
@@ -0,0 +1,139 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
// Local style copies preserve the host Editor skin and never mutate its
|
||||
// shared styles. All measurements are logical points; IMGUI handles Retina.
|
||||
internal sealed class BattleEditorTheme
|
||||
{
|
||||
public const float ControlHeight = 24;
|
||||
public const float CanvasTop = 32;
|
||||
public const float GroupSpacing = 8;
|
||||
|
||||
public bool ProSkin { get; } = EditorGUIUtility.isProSkin;
|
||||
|
||||
public GUIStyle Button
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle PrimaryButton
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle ToolbarButton
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle Popup
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle Tabs
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle TabLeft
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle TabMiddle
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle TabRight
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle Section
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle Title
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle Metadata
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle WelcomeTitle
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle WelcomeText
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public GUIStyle Roster
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public Color Header => ProSkin ? new Color(.18f, .18f, .18f) : new Color(.78f, .78f, .78f);
|
||||
public Color Surface => ProSkin ? new Color(.235f, .235f, .235f) : new Color(.82f, .82f, .82f);
|
||||
public Color Border => ProSkin ? new Color(.12f, .12f, .12f) : new Color(.57f, .57f, .57f);
|
||||
public Color Accent => ProSkin ? new Color(.5f, .75f, 1) : new Color(.64f, .81f, 1);
|
||||
|
||||
public BattleEditorTheme()
|
||||
{
|
||||
Button = Control(EditorStyles.miniButton);
|
||||
PrimaryButton = new GUIStyle(Button) { fontStyle = FontStyle.Bold };
|
||||
ToolbarButton = Control(EditorStyles.toolbarButton);
|
||||
Popup = Control(EditorStyles.popup);
|
||||
Popup.alignment = TextAnchor.MiddleLeft;
|
||||
Popup.padding = new RectOffset(6, 18, 0, 0);
|
||||
Tabs = Control(EditorStyles.miniButton);
|
||||
Tabs.margin = new RectOffset(0, 0, 0, 0);
|
||||
TabLeft = Control(EditorStyles.miniButtonLeft);
|
||||
TabMiddle = Control(EditorStyles.miniButtonMid);
|
||||
TabRight = Control(EditorStyles.miniButtonRight);
|
||||
Section = new GUIStyle(EditorStyles.foldoutHeader)
|
||||
{
|
||||
fixedHeight = ControlHeight,
|
||||
margin = new RectOffset(0, 0, 0, 0),
|
||||
fontSize = 11
|
||||
};
|
||||
Title = new GUIStyle(EditorStyles.boldLabel) { alignment = TextAnchor.MiddleLeft, fontSize = 12 };
|
||||
Metadata = new GUIStyle(EditorStyles.miniLabel)
|
||||
{
|
||||
alignment = TextAnchor.MiddleLeft,
|
||||
normal = { textColor = ProSkin ? new Color(.65f, .65f, .65f) : new Color(.3f, .3f, .3f) }
|
||||
};
|
||||
WelcomeTitle = new GUIStyle(EditorStyles.boldLabel) { alignment = TextAnchor.MiddleCenter, fontSize = 20, wordWrap = true };
|
||||
WelcomeText = new GUIStyle(EditorStyles.wordWrappedLabel) { alignment = TextAnchor.MiddleCenter };
|
||||
// The canvas stays dark in both Editor skins.
|
||||
WelcomeTitle.normal.textColor = new Color(.88f, .88f, .88f);
|
||||
WelcomeText.normal.textColor = new Color(.76f, .76f, .76f);
|
||||
Roster = new GUIStyle(Button) { alignment = TextAnchor.MiddleLeft, padding = new RectOffset(8, 8, 0, 0) };
|
||||
}
|
||||
|
||||
private static GUIStyle Control(GUIStyle source) => new(source)
|
||||
{
|
||||
fixedHeight = ControlHeight,
|
||||
fixedWidth = 0,
|
||||
fontSize = 11,
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
margin = new RectOffset(2, 2, 2, 2),
|
||||
padding = new RectOffset(8, 8, 0, 0)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 417d983af0594eab9f0e4107498b28ab
|
||||
@@ -0,0 +1,96 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using Battle;
|
||||
using Battle.Presentation;
|
||||
using UnityEditor;
|
||||
|
||||
public sealed partial class BattleEditorWindow
|
||||
{
|
||||
private Func<EditorWindow> _gamepadFocusedWindow = () => focusedWindow;
|
||||
private (BattleSession Battle, string Controller, BattleHudPage Page, int Category, string FormationActor, string AiActor)? _gamepadContext;
|
||||
|
||||
private bool CanReceiveGamepad() => _session != null && _gamepadFocusedWindow() == this && !DraftPending &&
|
||||
!EditorApplication.isPlayingOrWillChangePlaymode && !EditorGUIUtility.editingTextField;
|
||||
|
||||
private (BattleSession Battle, string Controller, BattleHudPage Page, int Category, string FormationActor, string AiActor) CurrentGamepadContext() =>
|
||||
(_session.Battle, _session.Battle?.WaitingActor, _hud.Presenter.Page, _hud.Presenter.Category, _hud.Presenter.FormationActor, _hud.Presenter.AiActor);
|
||||
|
||||
private bool GamepadPresentationBlocksHud => _session?.Battle is { } battle &&
|
||||
(battle.IsModalPresentation || battle.IsCoAttackPresentationBlockingInput);
|
||||
|
||||
private void ReceiveGamepad(BattleEditorGamepadIntent input)
|
||||
{
|
||||
if (!CanReceiveGamepad())
|
||||
return;
|
||||
if (_session.IsReplaying)
|
||||
{
|
||||
if (input.Kind == BattleEditorGamepadIntentKind.Cancel)
|
||||
{
|
||||
_session.CancelReplay();
|
||||
Repaint();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (input.Kind == BattleEditorGamepadIntentKind.Transport)
|
||||
{
|
||||
// Start never opens an OS dialog or applies an authoring draft.
|
||||
if (PrimaryAction() is WorkspaceAction.Start or WorkspaceAction.Pause or WorkspaceAction.Resume or WorkspaceAction.Restart)
|
||||
{
|
||||
RunPrimaryAction();
|
||||
_gamepadContext = null;
|
||||
_gamepadInput?.ResetNavigation();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_session.ResultPresentation is { Completed: false } result)
|
||||
{
|
||||
if (input.Kind is BattleEditorGamepadIntentKind.Confirm or BattleEditorGamepadIntentKind.Cancel)
|
||||
{
|
||||
if (input.Kind == BattleEditorGamepadIntentKind.Cancel && result.StatisticsVisible)
|
||||
result.CloseStatistics();
|
||||
_session.SkipResultStep();
|
||||
_gamepadInput?.ResetNavigation();
|
||||
Repaint();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (GamepadPresentationBlocksHud)
|
||||
{
|
||||
BattleSession battle = _session.Battle;
|
||||
if ((input.Kind is BattleEditorGamepadIntentKind.Confirm or BattleEditorGamepadIntentKind.Cancel) &&
|
||||
(battle.IsModalPresentation ? battle.SkipModalPresentation() : battle.SkipCoAttackPresentation()))
|
||||
{
|
||||
_session.SyncBattle();
|
||||
Repaint();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_session.Battle?.Status != BattleSessionStatus.Running)
|
||||
return;
|
||||
_hud.BindBattle(_session.Battle, _session.Data, _session.Preview, SyncHudBattle, SelectHudActor, Repaint);
|
||||
var before = CurrentGamepadContext();
|
||||
bool contextChanged = _gamepadContext.HasValue && _gamepadContext.Value != before;
|
||||
if (contextChanged)
|
||||
_gamepadInput?.ResetNavigation();
|
||||
_gamepadContext = before;
|
||||
// A repeat from the previous actor or mouse-selected page must not
|
||||
// move the new page. A fresh button edge remains fully usable.
|
||||
if (contextChanged && input.IsRepeat)
|
||||
return;
|
||||
_hud.TakeGamepadInput(_session.Battle);
|
||||
before = CurrentGamepadContext();
|
||||
_hud.SendGamepadIntent(input);
|
||||
var after = CurrentGamepadContext();
|
||||
if (after != before)
|
||||
_gamepadInput?.ResetNavigation();
|
||||
_gamepadContext = after;
|
||||
Repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e7ef64cd7124fbeb743fa35348935e6
|
||||
@@ -0,0 +1,667 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Battle;
|
||||
using Battle.Presentation;
|
||||
using Engine.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public sealed partial class BattleEditorWindow : EditorWindow
|
||||
{
|
||||
[SerializeField] private BattleScenarioAsset _draft;
|
||||
[SerializeField] private BattleScenarioAsset _asset;
|
||||
[SerializeField] private string _draftJson = "";
|
||||
[SerializeField] private string _savedJson = "";
|
||||
[SerializeField] private string _root = "";
|
||||
[SerializeField] private string _authoringVariant = "";
|
||||
[SerializeField] private List<VariantDraft> _variantDrafts = new();
|
||||
[SerializeField] private bool _initializeTestInventory;
|
||||
[SerializeField] private int _codepage = 936;
|
||||
private BattleEditorSession _session;
|
||||
private BattleEditorGamepadInput _gamepadInput;
|
||||
private double _lastTime;
|
||||
private Task<BattleData> _reconnect;
|
||||
private CancellationTokenSource _reconnectCancellation;
|
||||
private bool _gamepadPresentationBlocked;
|
||||
private bool _currentDraftDirty;
|
||||
private readonly DisplayFramePacer _repaintPacer = new();
|
||||
private string _error, _selected, _target, _action, _search = "", _previewJson;
|
||||
[SerializeField] private bool _autoAllies;
|
||||
[SerializeField] private bool _autoEnemies = true;
|
||||
private int _addActor;
|
||||
private BattleSide _addSide = BattleSide.Enemy;
|
||||
private Vector2 _rosterScroll, _inspectorScroll;
|
||||
private readonly List<string> _log = new();
|
||||
private readonly BattleHudView _hud = new();
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("_debugCombat")]
|
||||
[SerializeField] private bool _debugBattle;
|
||||
[SerializeField] private bool _originalAspect;
|
||||
[SerializeField] private bool _expandCamera = true;
|
||||
[SerializeField] private bool _touchHud;
|
||||
[SerializeField] private Vector4 _hudSafeInsets = new(8, 8, 8, 8);
|
||||
|
||||
private BattleScenario Scenario => _draft.Scenario;
|
||||
|
||||
#if PAL3A
|
||||
[MenuItem("PAL3A/Battle Editor", priority = 31)]
|
||||
#else
|
||||
[MenuItem("PAL3/Battle Editor", priority = 31)]
|
||||
#endif
|
||||
public static void Open() => GetWindow<BattleEditorWindow>("Battle Editor");
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
titleContent = new GUIContent("Battle Editor");
|
||||
wantsMouseMove = true;
|
||||
minSize = new Vector2(960, 640);
|
||||
saveChangesMessage = "保存战斗配置后再关闭?";
|
||||
NormalizeDrafts();
|
||||
VariantDraft state = RestoreAuthoringVariant(BattleData.Variant);
|
||||
if (_draft == null)
|
||||
{
|
||||
_draft = CreateInstance<BattleScenarioAsset>();
|
||||
_draft.hideFlags = HideFlags.HideAndDontSave;
|
||||
_draft.Scenario = new BattleScenario { Variant = BattleData.Variant };
|
||||
if (_draftJson.Length == 0 && _asset == null)
|
||||
_initializeTestInventory = true;
|
||||
}
|
||||
if (_draftJson.Length > 0)
|
||||
_draft.Scenario = BattleScenarioJson.RestoreDraft(_draftJson);
|
||||
if (_savedJson.Length == 0)
|
||||
_savedJson = BattleScenarioJson.Serialize(Scenario);
|
||||
_session = new BattleEditorSession();
|
||||
_session.PreviewReleased += _hud.Release;
|
||||
_gamepadInput?.Dispose();
|
||||
_gamepadInput = new BattleEditorGamepadInput(CanReceiveGamepad, ReceiveGamepad);
|
||||
_hud.PointerTookControl += ReleaseGamepadInput;
|
||||
_hud.KeyboardTookControl += ReleaseGamepadInput;
|
||||
_lastTime = EditorApplication.timeSinceStartup;
|
||||
Undo.undoRedoPerformed += OnUndo;
|
||||
EditorApplication.projectChanged += OnAuthoringProjectChanged;
|
||||
EditorApplication.update += Tick;
|
||||
EditorApplication.playModeStateChanged += OnPlayMode;
|
||||
if (!string.IsNullOrEmpty(state.ConnectionRoot))
|
||||
BeginReconnect(state.ConnectionRoot, state.ConnectionCodepage);
|
||||
UpdateDirty();
|
||||
}
|
||||
|
||||
public void CreateGUI() => rootVisualElement.Add(new IMGUIContainer(DrawWindow) { style = { flexGrow = 1 } });
|
||||
|
||||
[Serializable]
|
||||
private sealed class VariantDraft
|
||||
{
|
||||
public string Variant;
|
||||
public string DraftJson;
|
||||
public string SavedJson;
|
||||
public string Root;
|
||||
public int Codepage;
|
||||
public string ConnectionRoot;
|
||||
public int ConnectionCodepage;
|
||||
public bool InitializeTestInventory;
|
||||
public BattleScenarioAsset Asset;
|
||||
}
|
||||
|
||||
private static string CanonicalDraftJson(string json) => string.IsNullOrEmpty(json) ? "" : BattleScenarioJson.Serialize(BattleScenarioJson.RestoreDraft(json));
|
||||
|
||||
private void NormalizeDrafts()
|
||||
{
|
||||
// Repair the old field-only codec before migrating either side of
|
||||
// the dirty comparison into a different variant's stored state.
|
||||
_draftJson = CanonicalDraftJson(_draftJson);
|
||||
_savedJson = CanonicalDraftJson(_savedJson);
|
||||
if (_draft != null && _draftJson.Length > 0)
|
||||
_draft.Scenario = BattleScenarioJson.RestoreDraft(_draftJson);
|
||||
foreach (VariantDraft state in _variantDrafts)
|
||||
{
|
||||
state.DraftJson = CanonicalDraftJson(state.DraftJson);
|
||||
state.SavedJson = CanonicalDraftJson(state.SavedJson);
|
||||
}
|
||||
}
|
||||
|
||||
private void StoreAuthoringVariant()
|
||||
{
|
||||
if (_draft != null)
|
||||
_draftJson = BattleScenarioJson.Serialize(Scenario);
|
||||
if (string.IsNullOrEmpty(_authoringVariant))
|
||||
return;
|
||||
VariantDraft state = CurrentVariantDraft();
|
||||
state.DraftJson = _draftJson;
|
||||
state.SavedJson = _savedJson;
|
||||
state.Asset = _asset;
|
||||
state.Root = _root;
|
||||
state.Codepage = _codepage;
|
||||
state.InitializeTestInventory = _initializeTestInventory;
|
||||
}
|
||||
|
||||
private VariantDraft CurrentVariantDraft()
|
||||
{
|
||||
VariantDraft state = _variantDrafts.FirstOrDefault(value => value.Variant == _authoringVariant);
|
||||
if (state == null)
|
||||
{
|
||||
state = new VariantDraft { Variant = _authoringVariant };
|
||||
_variantDrafts.Add(state);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
private VariantDraft RestoreAuthoringVariant(string variant)
|
||||
{
|
||||
// Migrate windows serialized before variant ownership was recorded.
|
||||
if (string.IsNullOrEmpty(_authoringVariant))
|
||||
_authoringVariant = _draft != null ? Scenario.Variant : _draftJson.Length > 0 ? BattleScenarioJson.RestoreDraft(_draftJson).Variant : variant;
|
||||
if (_authoringVariant != variant)
|
||||
{
|
||||
CancelReconnect();
|
||||
StoreAuthoringVariant();
|
||||
VariantDraft state = _variantDrafts.FirstOrDefault(value => value.Variant == variant);
|
||||
_draftJson = state?.DraftJson ?? "";
|
||||
_savedJson = state?.SavedJson ?? "";
|
||||
_asset = state?.Asset;
|
||||
_root = state?.Root ?? "";
|
||||
_codepage = state?.Codepage ?? 936;
|
||||
_initializeTestInventory = state?.InitializeTestInventory ?? true;
|
||||
if (_draft != null)
|
||||
{
|
||||
Undo.ClearUndo(_draft);
|
||||
_draft.Scenario = _draftJson.Length > 0 ? BattleScenarioJson.RestoreDraft(_draftJson) : new BattleScenario { Variant = variant };
|
||||
}
|
||||
_selected = _target = _action = _previewJson = _error = null;
|
||||
}
|
||||
_authoringVariant = variant;
|
||||
bool needsDefaults = string.IsNullOrEmpty(_root) && !_variantDrafts.Any(value => value.Variant == variant);
|
||||
VariantDraft current = CurrentVariantDraft();
|
||||
// Windows serialized before reconnect settings were stored also start
|
||||
// from the shared default once. Pending edits stay in Root/Codepage.
|
||||
if (current.ConnectionCodepage == 0)
|
||||
(current.ConnectionRoot, current.ConnectionCodepage) = DefaultConnection(variant);
|
||||
if (needsDefaults)
|
||||
(_root, _codepage) = (current.ConnectionRoot, current.ConnectionCodepage);
|
||||
return current;
|
||||
}
|
||||
|
||||
private static (string Root, int Codepage) DefaultConnection(string variant) =>
|
||||
(EditorPrefs.GetString(variant + ".BattleEditor.Path", Path.GetFullPath(Path.Combine(Application.dataPath, "../../Game Data", variant))),
|
||||
EditorPrefs.GetInt(variant + ".BattleEditor.Codepage", 936));
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
CancelReconnect();
|
||||
_hud.SetInputFocus(false);
|
||||
_hud.PointerTookControl -= ReleaseGamepadInput;
|
||||
_hud.KeyboardTookControl -= ReleaseGamepadInput;
|
||||
_gamepadInput?.Dispose();
|
||||
_gamepadInput = null;
|
||||
Undo.undoRedoPerformed -= OnUndo;
|
||||
EditorApplication.projectChanged -= OnAuthoringProjectChanged;
|
||||
EditorApplication.update -= Tick;
|
||||
EditorApplication.playModeStateChanged -= OnPlayMode;
|
||||
StoreAuthoringVariant();
|
||||
BattleEditorSession session = _session;
|
||||
_session = null;
|
||||
if (session != null)
|
||||
session.PreviewReleased -= _hud.Release;
|
||||
try
|
||||
{
|
||||
_hud.Release();
|
||||
}
|
||||
finally
|
||||
{
|
||||
session?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_draft != null)
|
||||
DestroyImmediate(_draft);
|
||||
}
|
||||
|
||||
private void OnPlayMode(PlayModeStateChange state)
|
||||
{
|
||||
if (state is PlayModeStateChange.ExitingEditMode or PlayModeStateChange.ExitingPlayMode)
|
||||
_session?.Stop();
|
||||
}
|
||||
|
||||
private void OnLostFocus()
|
||||
{
|
||||
_heldBattleKeys.Clear();
|
||||
_hud.SetInputFocus(false);
|
||||
_gamepadInput?.Suspend();
|
||||
}
|
||||
|
||||
private void OnFocus() => _hud.SetInputFocus(true);
|
||||
|
||||
private void ReleaseGamepadInput() => _gamepadInput?.Suspend();
|
||||
|
||||
private void OnUndo()
|
||||
{
|
||||
string previousDraft = _draftJson;
|
||||
// Early Undo records predate the first data connection. Preserve
|
||||
// the generated baseline when restoring an unbound snapshot.
|
||||
if (_draft != null && _asset == null && string.IsNullOrEmpty(Scenario.DataFingerprint) && !string.IsNullOrEmpty(_savedJson))
|
||||
{
|
||||
BattleScenario baseline = BattleScenarioJson.RestoreDraft(_savedJson);
|
||||
if (!string.IsNullOrEmpty(baseline.DataFingerprint))
|
||||
ApplyTestInventoryDefaults(Scenario, baseline);
|
||||
}
|
||||
UpdateDirty();
|
||||
if (_draftJson != previousDraft)
|
||||
PauseForDraftChange();
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void OnAuthoringProjectChanged()
|
||||
{
|
||||
UpdateDirty();
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void Tick()
|
||||
{
|
||||
CompleteReconnect();
|
||||
double now = EditorApplication.timeSinceStartup;
|
||||
if (_session?.IsReplaying == true)
|
||||
Try(_session.TickReplay, pauseOnError: false, clearErrorOnSuccess: false);
|
||||
else if (_session?.IsPlaying == true)
|
||||
{
|
||||
Try(() => _session.Tick((float)Math.Clamp(now - _lastTime, 0, 0.1)), clearErrorOnSuccess: false);
|
||||
}
|
||||
_lastTime = now;
|
||||
bool blocksHud = GamepadPresentationBlocksHud;
|
||||
if (blocksHud && !_gamepadPresentationBlocked)
|
||||
_gamepadInput?.ResetNavigation();
|
||||
_gamepadPresentationBlocked = blocksHud;
|
||||
if ((_session?.IsReplaying == true || _session?.IsPlaying == true || _session?.Preview != null && focusedWindow == this) &&
|
||||
_repaintPacer.TryAdvance(now, DisplayFrameRate.RefreshRate))
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void Try(Action action, bool pauseOnError = true, bool clearErrorOnSuccess = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
if (clearErrorOnSuccess)
|
||||
_error = null;
|
||||
}
|
||||
catch (ExitGUIException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_error = ex.Message;
|
||||
if (pauseOnError && _session != null)
|
||||
_session.IsPlaying = false;
|
||||
Log(_error);
|
||||
}
|
||||
}
|
||||
|
||||
private void Log(string message)
|
||||
{
|
||||
_log.Add(message);
|
||||
if (_log.Count > 100)
|
||||
_log.RemoveAt(0);
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
ConnectData(_root, _codepage);
|
||||
EditorPrefs.SetString(BattleData.Variant + ".BattleEditor.Path", _root);
|
||||
EditorPrefs.SetInt(BattleData.Variant + ".BattleEditor.Codepage", _codepage);
|
||||
}
|
||||
|
||||
private void TryLoadData() => Try(LoadData, pauseOnError: false);
|
||||
|
||||
private void ConnectData(string root, int codepage)
|
||||
{
|
||||
CancelReconnect();
|
||||
_session.Load(root, codepage);
|
||||
DataConnected();
|
||||
}
|
||||
|
||||
private void BeginReconnect(string root, int codepage)
|
||||
{
|
||||
CancelReconnect();
|
||||
_reconnectCancellation = new CancellationTokenSource();
|
||||
CancellationToken cancellation = _reconnectCancellation.Token;
|
||||
_reconnect = Task.Run(() => Directory.Exists(root) ? new BattleData(root, codepage, cancellation) : null, cancellation);
|
||||
}
|
||||
|
||||
private void CompleteReconnect()
|
||||
{
|
||||
if (_reconnect is not { IsCompleted: true } reconnect)
|
||||
return;
|
||||
_reconnect = null;
|
||||
_reconnectCancellation.Dispose();
|
||||
_reconnectCancellation = null;
|
||||
Try(() =>
|
||||
{
|
||||
BattleData data = reconnect.GetAwaiter().GetResult();
|
||||
if (data == null)
|
||||
return;
|
||||
if (_session.Data != null)
|
||||
{
|
||||
data.Dispose();
|
||||
return;
|
||||
}
|
||||
_session.UseData(data);
|
||||
DataConnected();
|
||||
}, pauseOnError: false, clearErrorOnSuccess: false);
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void CancelReconnect()
|
||||
{
|
||||
if (_reconnect == null)
|
||||
return;
|
||||
Task<BattleData> reconnect = _reconnect;
|
||||
CancellationTokenSource cancellation = _reconnectCancellation;
|
||||
_reconnect = null;
|
||||
_reconnectCancellation = null;
|
||||
cancellation.Cancel();
|
||||
_ = reconnect.ContinueWith(completed =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (completed.IsCompletedSuccessfully)
|
||||
completed.Result?.Dispose();
|
||||
_ = completed.Exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
cancellation.Dispose();
|
||||
}
|
||||
}, TaskScheduler.Default);
|
||||
}
|
||||
|
||||
private void DataConnected()
|
||||
{
|
||||
if (_initializeTestInventory)
|
||||
{
|
||||
BattleScenario defaults = BattleTestLoadoutBuilder.CreateScenario(_session.Data);
|
||||
BattleScenario baseline = BattleScenarioJson.RestoreDraft(_savedJson);
|
||||
ApplyTestInventoryDefaults(baseline, defaults);
|
||||
_savedJson = BattleScenarioJson.Serialize(baseline);
|
||||
ApplyTestInventoryDefaults(Scenario, defaults);
|
||||
_initializeTestInventory = false;
|
||||
UpdateDirty();
|
||||
}
|
||||
_validation = null;
|
||||
VariantDraft state = CurrentVariantDraft();
|
||||
state.ConnectionRoot = _session.Data.Resources.Root;
|
||||
state.ConnectionCodepage = _session.Data.Resources.Codepage;
|
||||
Log($"{BattleData.Variant}: {_session.Data.Scenes.Length} 个战场,{_session.Data.Database.CombatActorInfos.Count} 个角色;只读加载 basedata.cpk。");
|
||||
}
|
||||
|
||||
private static void ApplyTestInventoryDefaults(BattleScenario scenario, BattleScenario defaults)
|
||||
{
|
||||
if (scenario.Items.Count == 0)
|
||||
{
|
||||
scenario.Items = defaults.Items;
|
||||
if (scenario.TreasureUses.Count == 0)
|
||||
scenario.TreasureUses = defaults.TreasureUses;
|
||||
}
|
||||
scenario.DataFingerprint = defaults.DataFingerprint;
|
||||
}
|
||||
|
||||
private bool CurrentDraftDirty => _currentDraftDirty;
|
||||
|
||||
private IEnumerable<VariantDraft> DirtyVariants() => _variantDrafts.Where(state => !string.IsNullOrEmpty(state.DraftJson) &&
|
||||
state.DraftJson != (state.Asset != null ? BattleScenarioJson.Serialize(state.Asset.Scenario) : state.SavedJson));
|
||||
|
||||
private void UpdateDirty()
|
||||
{
|
||||
if (_draft == null)
|
||||
return;
|
||||
_validation = null;
|
||||
StoreAuthoringVariant();
|
||||
string[] dirty = DirtyVariants().Select(state => state.Variant).ToArray();
|
||||
_currentDraftDirty = dirty.Contains(_authoringVariant);
|
||||
hasUnsavedChanges = dirty.Length > 0;
|
||||
saveChangesMessage = "保存以下作品的战斗配置后再关闭?" + string.Join("、", dirty);
|
||||
}
|
||||
|
||||
private void Edit(string label, Action change)
|
||||
{
|
||||
PauseForDraftChange();
|
||||
Undo.RecordObject(_draft, label);
|
||||
change();
|
||||
EditorUtility.SetDirty(_draft);
|
||||
UpdateDirty();
|
||||
}
|
||||
|
||||
private bool CanReplace()
|
||||
{
|
||||
if (!CurrentDraftDirty)
|
||||
return true;
|
||||
int answer = EditorUtility.DisplayDialogComplex("战斗配置尚未保存", "保存当前配置后再继续?", "保存", "取消", "放弃");
|
||||
if (answer == 1)
|
||||
return false;
|
||||
if (answer == 0)
|
||||
{
|
||||
Try(() => SaveScenario(false));
|
||||
return !CurrentDraftDirty;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void NewScenario()
|
||||
{
|
||||
if (!CanReplace())
|
||||
return;
|
||||
_session.Stop();
|
||||
Undo.ClearUndo(_draft);
|
||||
_asset = null;
|
||||
_draft.Scenario = BattleTestLoadoutBuilder.CreateScenario(_session.Data);
|
||||
_initializeTestInventory = _session.Data == null;
|
||||
_savedJson = BattleScenarioJson.Serialize(Scenario);
|
||||
UpdateDirty();
|
||||
_selected = null;
|
||||
_drawer = WorkspaceDrawer.Configuration;
|
||||
_configurationPage = 1;
|
||||
}
|
||||
|
||||
private void LoadAsset(BattleScenarioAsset asset)
|
||||
{
|
||||
if (asset == null || asset.Scenario == null)
|
||||
return;
|
||||
CheckAuthoringVersion(asset.Scenario);
|
||||
if (asset == _asset || !CanReplace())
|
||||
return;
|
||||
_session.Stop();
|
||||
Undo.ClearUndo(_draft);
|
||||
_asset = asset;
|
||||
_initializeTestInventory = false;
|
||||
_draft.Scenario = asset.Scenario.Copy();
|
||||
_savedJson = BattleScenarioJson.Serialize(Scenario);
|
||||
UpdateDirty();
|
||||
_selected = null;
|
||||
}
|
||||
|
||||
// EditorWindow calls this for its close/save flow. Every draft named
|
||||
// in the close prompt must be saved before the window can be destroyed.
|
||||
public override void SaveChanges() => Try(() => SaveDrafts(SelectScenarioPath));
|
||||
|
||||
private void SaveDrafts(Func<string, string> pickPath)
|
||||
{
|
||||
StoreAuthoringVariant();
|
||||
try
|
||||
{
|
||||
var planned = new List<(VariantDraft State, BattleScenario Scenario, string Path)>();
|
||||
var newPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (VariantDraft state in DirtyVariants())
|
||||
{
|
||||
BattleScenario scenario = BattleScenarioJson.RestoreDraft(state.DraftJson);
|
||||
if (scenario.Version != BattleScenario.CurrentVersion || scenario.Variant is not ("PAL3" or "PAL3A") || scenario.Variant != state.Variant)
|
||||
throw new InvalidDataException("Unsupported battle draft: " + state.Variant + ". The draft and preset have been kept unchanged.");
|
||||
string path = null;
|
||||
if (state.Asset == null)
|
||||
{
|
||||
path = pickPath(scenario.Variant);
|
||||
if (path == null)
|
||||
return;
|
||||
if (!newPaths.Add(path))
|
||||
throw new IOException("请为每个作品选择不同的预设路径。");
|
||||
}
|
||||
planned.Add((state, scenario, path));
|
||||
}
|
||||
foreach (var (state, scenario, path) in planned)
|
||||
{
|
||||
BattleScenarioAsset destination = WriteScenario(scenario, state.Asset, path);
|
||||
state.Asset = destination;
|
||||
state.SavedJson = state.DraftJson;
|
||||
state.InitializeTestInventory = false;
|
||||
if (state.Variant == _authoringVariant)
|
||||
{
|
||||
_asset = destination;
|
||||
_savedJson = state.SavedJson;
|
||||
_initializeTestInventory = false;
|
||||
}
|
||||
}
|
||||
base.SaveChanges();
|
||||
}
|
||||
finally
|
||||
{
|
||||
UpdateDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveScenario(bool saveAs)
|
||||
{
|
||||
CheckAuthoringVersion(Scenario);
|
||||
BattleScenarioAsset destination = saveAs ? null : _asset;
|
||||
string path = destination == null ? SelectScenarioPath(Scenario.Variant) : null;
|
||||
if (destination == null && path == null)
|
||||
return;
|
||||
destination = WriteScenario(Scenario, destination, path);
|
||||
_asset = destination;
|
||||
_initializeTestInventory = false;
|
||||
_savedJson = BattleScenarioJson.Serialize(Scenario);
|
||||
UpdateDirty();
|
||||
}
|
||||
|
||||
private static string SelectScenarioPath(string variant)
|
||||
{
|
||||
string path = EditorUtility.SaveFilePanelInProject("保存 " + variant + " 战斗配置", "BattleScenario", "asset", "选择自有预设保存位置");
|
||||
if (path.Length == 0)
|
||||
return null;
|
||||
if (AssetDatabase.LoadMainAssetAtPath(path) != null)
|
||||
throw new IOException("该路径已有资产,请选择新路径或直接保存当前预设。");
|
||||
return path;
|
||||
}
|
||||
|
||||
private BattleScenarioAsset WriteScenario(BattleScenario scenario, BattleScenarioAsset destination, string path)
|
||||
{
|
||||
if (destination == null)
|
||||
{
|
||||
destination = CreateInstance<BattleScenarioAsset>();
|
||||
try
|
||||
{
|
||||
destination.Scenario = scenario.Copy();
|
||||
AssetDatabase.CreateAsset(destination, path);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (!EditorUtility.IsPersistent(destination))
|
||||
DestroyImmediate(destination);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
destination.Scenario = scenario.Copy();
|
||||
EditorUtility.SetDirty(destination);
|
||||
}
|
||||
AssetDatabase.SaveAssetIfDirty(destination);
|
||||
Log("已保存 " + AssetDatabase.GetAssetPath(destination));
|
||||
return destination;
|
||||
}
|
||||
|
||||
private static void CheckAuthoringVersion(BattleScenario scenario)
|
||||
{
|
||||
if (scenario.Version != BattleScenario.CurrentVersion || scenario.Variant != BattleData.Variant)
|
||||
throw new InvalidDataException($"This editor supports {BattleData.Variant} scenario version {BattleScenario.CurrentVersion}. The draft and existing asset have been kept unchanged.");
|
||||
}
|
||||
|
||||
public override void DiscardChanges()
|
||||
{
|
||||
PauseForDraftChange();
|
||||
foreach (VariantDraft state in _variantDrafts.Where(state => state.Variant != _authoringVariant))
|
||||
{
|
||||
state.DraftJson = BattleScenarioJson.Serialize(state.Asset != null ? state.Asset.Scenario : new BattleScenario { Variant = state.Variant });
|
||||
state.SavedJson = state.DraftJson;
|
||||
state.InitializeTestInventory = state.Asset == null;
|
||||
}
|
||||
_draft.Scenario = _asset != null ? _asset.Scenario.Copy() : BattleTestLoadoutBuilder.CreateScenario(_session?.Data);
|
||||
_initializeTestInventory = _asset == null && _session?.Data == null;
|
||||
_savedJson = BattleScenarioJson.Serialize(Scenario);
|
||||
base.DiscardChanges();
|
||||
UpdateDirty();
|
||||
}
|
||||
|
||||
private void StartPreview()
|
||||
{
|
||||
_session.Start(Scenario);
|
||||
_previewJson = BattleScenarioJson.Serialize(Scenario);
|
||||
Log("动作预览已启动;在诊断面板选择角色、动作或攻击目标。此模式只演示动画。");
|
||||
}
|
||||
|
||||
private void ExportReport()
|
||||
{
|
||||
string path = EditorUtility.SaveFilePanel("导出战斗配置与诊断", "", "battle-preview", "json");
|
||||
if (path.Length == 0)
|
||||
return;
|
||||
var report = new PreviewReport
|
||||
{
|
||||
Scenario = Scenario.Copy(),
|
||||
Captured = _session.CapturedScenario,
|
||||
Diagnostics = (_session.Data?.Validate(Scenario, forBattle: true) ?? Scenario.Validate()).Concat(_session.Preview?.Diagnostics ?? new List<string>())
|
||||
.Concat(_error == null ? Array.Empty<string>() : new[] { _error }).Distinct().ToArray(),
|
||||
};
|
||||
report.Inputs = _session.Battle?.Inputs.ToArray();
|
||||
report.Events = _session.Battle?.Events.ToArray();
|
||||
report.Result = _session.Battle?.Result;
|
||||
report.FinalTick = _session.Battle?.Tick ?? 0;
|
||||
report.Definitions = _session.Battle?.Definitions;
|
||||
report.Actors = _session.Battle?.Actors.ToArray();
|
||||
report.Inventory = _session.Battle?.Inventory.ToArray();
|
||||
report.Money = _session.Battle?.Money ?? Scenario.Money;
|
||||
report.Pal3A = _session.Battle?.Definitions.Variant == "PAL3A" ? _session.Battle.Pal3AState : null;
|
||||
ResourceBrowser.ResourceCatalog.WriteTextFile(path,
|
||||
Newtonsoft.Json.JsonConvert.SerializeObject(report, Newtonsoft.Json.Formatting.Indented), _session.Data?.Resources.Root);
|
||||
Log("已导出 " + path);
|
||||
}
|
||||
|
||||
// JSON export DTO; Unity does not persist this report.
|
||||
private sealed class PreviewReport
|
||||
{
|
||||
public int FormatVersion = 2;
|
||||
|
||||
public BattleScenario Scenario;
|
||||
public BattleScenario Captured;
|
||||
public string[] Diagnostics;
|
||||
public long FinalTick;
|
||||
public BattleInput[] Inputs;
|
||||
public BattleEvent[] Events;
|
||||
public BattleResult Result;
|
||||
public BattleDefinitions Definitions;
|
||||
public BattleActorSnapshot[] Actors;
|
||||
public BattleItemSnapshot[] Inventory;
|
||||
public int Money;
|
||||
public BattlePal3AStateSnapshot Pal3A;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84eeee9e564d34db0b1179ea68e39ca3
|
||||
@@ -0,0 +1,633 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Battle;
|
||||
using Battle.Presentation;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed partial class BattleEditorWindow
|
||||
{
|
||||
private const float DrawerWidth = 360;
|
||||
|
||||
private enum WorkspaceDrawer
|
||||
{
|
||||
None, Configuration, Diagnostics, Connection
|
||||
}
|
||||
|
||||
private enum WorkspaceAction
|
||||
{
|
||||
Connect, Random, Configure, Start, Pause, Resume, Restart, Apply
|
||||
}
|
||||
|
||||
[SerializeField] private WorkspaceDrawer _drawer;
|
||||
[SerializeField] private int _configurationPage;
|
||||
[SerializeField] private int _diagnosticPage;
|
||||
[SerializeField] private BattleDamageNumberColorMode _damageNumberColor;
|
||||
private bool _addParticipant;
|
||||
private string[] _validation;
|
||||
private readonly Dictionary<string, bool> _sections = new();
|
||||
private readonly Dictionary<string, Rect> _workspaceControls = new();
|
||||
private Rect _workspaceCanvasRect;
|
||||
private Rect _welcomeRect;
|
||||
private Vector2 _workspaceGuiScreenOrigin;
|
||||
private int _assetPickerId;
|
||||
private Action<BattleScenarioAsset, int> _showAssetPicker = (asset, id) =>
|
||||
EditorGUIUtility.ShowObjectPicker<BattleScenarioAsset>(asset, false, "", id);
|
||||
|
||||
private BattleEditorTheme _theme;
|
||||
|
||||
private BattleEditorTheme Theme => _theme != null && _theme.ProSkin == EditorGUIUtility.isProSkin ? _theme : _theme = new BattleEditorTheme();
|
||||
|
||||
private void RememberControl(string id, Rect rect)
|
||||
{
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
_workspaceControls[id] = new Rect(GUIUtility.GUIToScreenPoint(rect.position) - _workspaceGuiScreenOrigin, rect.size);
|
||||
}
|
||||
|
||||
private bool DraftPending => _session?.Preview != null && _previewJson != _draftJson;
|
||||
|
||||
private void PauseForDraftChange()
|
||||
{
|
||||
if (_session != null)
|
||||
{
|
||||
_session.CancelReplay();
|
||||
_session.IsPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
private string[] Validation()
|
||||
{
|
||||
if (_validation == null)
|
||||
{
|
||||
if (BattleScenarioEditing.NeedsRepair(Scenario))
|
||||
_validation = new[] { "配置缺少必需内容,请先修复。" };
|
||||
else
|
||||
_validation = (_session.Data?.Validate(Scenario, forBattle: true) ?? Scenario.Validate()).ToArray();
|
||||
}
|
||||
return _validation;
|
||||
}
|
||||
|
||||
private WorkspaceAction PrimaryAction()
|
||||
{
|
||||
if (_session.Data == null)
|
||||
return WorkspaceAction.Connect;
|
||||
if (BattleScenarioEditing.NeedsRepair(Scenario))
|
||||
return WorkspaceAction.Configure;
|
||||
if (Scenario.Participants.Count == 0 && string.IsNullOrEmpty(Scenario.Scene))
|
||||
return WorkspaceAction.Random;
|
||||
if (Validation().Length > 0)
|
||||
return WorkspaceAction.Configure;
|
||||
if (DraftPending)
|
||||
return WorkspaceAction.Apply;
|
||||
if (_session.Battle == null)
|
||||
return WorkspaceAction.Start;
|
||||
if (_session.ResultPresentation?.Completed == true ||
|
||||
_session.Battle.Status is BattleSessionStatus.Aborted or BattleSessionStatus.Faulted ||
|
||||
_session.Battle.Status == BattleSessionStatus.Completed && _session.ResultPresentation == null)
|
||||
return WorkspaceAction.Restart;
|
||||
return _session.IsPlaying ? WorkspaceAction.Pause : WorkspaceAction.Resume;
|
||||
}
|
||||
|
||||
private string PrimaryLabel() => PrimaryAction() switch
|
||||
{
|
||||
WorkspaceAction.Connect => "选择数据目录",
|
||||
WorkspaceAction.Random => "创建随机战斗",
|
||||
WorkspaceAction.Configure => "检查配置",
|
||||
WorkspaceAction.Start => "开始测试",
|
||||
WorkspaceAction.Pause => "暂停",
|
||||
WorkspaceAction.Resume => _session.Battle.Status == BattleSessionStatus.Completed ? "继续结果" : "继续测试",
|
||||
WorkspaceAction.Restart => "重新测试",
|
||||
_ => "应用并重新开始",
|
||||
};
|
||||
|
||||
private void RunPrimaryAction()
|
||||
{
|
||||
switch (PrimaryAction())
|
||||
{
|
||||
case WorkspaceAction.Connect:
|
||||
ChooseDataFolder(true);
|
||||
break;
|
||||
case WorkspaceAction.Random:
|
||||
Try(CreateRandomExample);
|
||||
break;
|
||||
case WorkspaceAction.Configure:
|
||||
_drawer = WorkspaceDrawer.Configuration;
|
||||
_inspectorScroll = Vector2.zero;
|
||||
break;
|
||||
case WorkspaceAction.Pause:
|
||||
_session.IsPlaying = false;
|
||||
break;
|
||||
case WorkspaceAction.Resume:
|
||||
_session.IsPlaying = true;
|
||||
break;
|
||||
default:
|
||||
Try(() =>
|
||||
{
|
||||
StartBattle();
|
||||
_session.IsPlaying = true;
|
||||
});
|
||||
break;
|
||||
}
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private readonly HashSet<KeyCode> _heldBattleKeys = new();
|
||||
|
||||
private void DrawWindow()
|
||||
{
|
||||
Event input = Event.current;
|
||||
if (input.rawType == EventType.KeyUp)
|
||||
_heldBattleKeys.Remove(input.keyCode);
|
||||
bool newBattleKey = BattleHudView.IsBattleKey(input) && _heldBattleKeys.Add(input.keyCode);
|
||||
if (Event.current.type == EventType.MouseDown)
|
||||
ReleaseGamepadInput();
|
||||
if (_draft == null || _session == null)
|
||||
return;
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
_workspaceControls.Clear();
|
||||
_workspaceGuiScreenOrigin = GUIUtility.GUIToScreenPoint(Vector2.zero);
|
||||
}
|
||||
_assetPickerId = GUIUtility.GetControlID(0x42617474, FocusType.Passive);
|
||||
HandleAssetPicker();
|
||||
bool replaying = _session.IsReplaying;
|
||||
if (replaying && input.type == EventType.KeyDown && input.keyCode == KeyCode.Escape)
|
||||
{
|
||||
_session.CancelReplay();
|
||||
input.Use();
|
||||
}
|
||||
using var disabled = new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode || replaying);
|
||||
DrawWorkspaceToolbar();
|
||||
bool drawerVisible = _drawer != WorkspaceDrawer.None;
|
||||
float drawerLeft = position.width - DrawerWidth - 8;
|
||||
_workspaceCanvasRect = new Rect(8, BattleEditorTheme.CanvasTop, drawerVisible ? drawerLeft - 16 : position.width - 16, Mathf.Max(100, position.height - BattleEditorTheme.CanvasTop - 8));
|
||||
DrawCanvas(_workspaceCanvasRect, newBattleKey);
|
||||
if (DraftPending || replaying)
|
||||
{
|
||||
var banner = new Rect(_workspaceCanvasRect.x + 12, _workspaceCanvasRect.y + 8, _workspaceCanvasRect.width - 24, 30);
|
||||
EditorGUI.DrawRect(banner, new Color(0.12f, 0.12f, 0.12f, .96f));
|
||||
GUI.Label(banner, replaying ? "正在重放战斗记录…" : "配置已修改 · 画布保留上次测试,应用配置后继续操作",
|
||||
BattleHudCanvas.LabelStyle(11, Color.white, alignment: TextAnchor.MiddleCenter));
|
||||
if (replaying && !EditorApplication.isPlayingOrWillChangePlaymode)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
try
|
||||
{
|
||||
if (GUI.Button(new Rect(banner.xMax - 72, banner.y + 3, 66, 24), "取消"))
|
||||
_session.CancelReplay();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GUI.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (drawerVisible)
|
||||
DrawDrawer(new Rect(drawerLeft, BattleEditorTheme.CanvasTop, DrawerWidth, _workspaceCanvasRect.height));
|
||||
}
|
||||
|
||||
private bool WorkspaceButton(string id, Rect rect, string label, bool selected = false, bool primary = false, bool toolbar = false)
|
||||
{
|
||||
RememberControl(id, rect);
|
||||
Color previous = GUI.backgroundColor;
|
||||
try
|
||||
{
|
||||
if (primary)
|
||||
GUI.backgroundColor = Theme.Accent;
|
||||
return GUI.Toggle(rect, selected, label, primary ? Theme.PrimaryButton : toolbar ? Theme.ToolbarButton : Theme.Button) != selected;
|
||||
}
|
||||
finally
|
||||
{
|
||||
GUI.backgroundColor = previous;
|
||||
}
|
||||
}
|
||||
|
||||
private bool DrawerButton(string label, params GUILayoutOption[] options) => GUILayout.Button(label, Theme.Button, options);
|
||||
|
||||
private int DrawerTabs(string id, int selected, string[] labels)
|
||||
{
|
||||
Rect rect = GUILayoutUtility.GetRect(GUIContent.none, Theme.Tabs,
|
||||
GUILayout.Height(BattleEditorTheme.ControlHeight), GUILayout.ExpandWidth(true));
|
||||
RememberControl(id, rect);
|
||||
int navigationId = GUIUtility.GetControlID(id.GetHashCode(), FocusType.Keyboard, rect);
|
||||
Event input = Event.current;
|
||||
if (GUI.enabled && input.type == EventType.MouseDown && input.button == 0 && rect.Contains(input.mousePosition))
|
||||
GUIUtility.keyboardControl = navigationId;
|
||||
// GUILayout.Toolbar resolves built-in Left/Mid/Right styles by
|
||||
// name, discarding the local height. Use those native textures
|
||||
// through our own style copies so their actual pixels stay 24pt.
|
||||
float[] widths = labels.Select(label => Theme.Tabs.CalcSize(new GUIContent(label)).x).ToArray();
|
||||
float total = widths.Sum();
|
||||
float extra = Math.Max(0, rect.width - total) / labels.Length;
|
||||
float x = rect.x;
|
||||
int next = selected;
|
||||
for (int index = 0; index < labels.Length; index++)
|
||||
{
|
||||
float width = total > rect.width ? widths[index] * rect.width / total : widths[index] + extra;
|
||||
GUIStyle style = index == 0 ? Theme.TabLeft : index == labels.Length - 1 ? Theme.TabRight : Theme.TabMiddle;
|
||||
float pixels = EditorGUIUtility.pixelsPerPoint;
|
||||
float left = Mathf.Round(x * pixels) / pixels;
|
||||
float right = Mathf.Round((x + width) * pixels) / pixels;
|
||||
var tabRect = new Rect(left, rect.y, right - left, rect.height);
|
||||
RememberControl(id.Replace("tabs:", "tab:") + ":" + index, tabRect);
|
||||
if (GUI.Toggle(tabRect, selected == index, labels[index], style) && selected != index)
|
||||
next = index;
|
||||
x += width;
|
||||
}
|
||||
if (GUI.enabled && input.type == EventType.KeyDown && input.keyCode is KeyCode.LeftArrow or KeyCode.RightArrow &&
|
||||
GUIUtility.keyboardControl == navigationId && !EditorGUIUtility.editingTextField)
|
||||
{
|
||||
next = (selected + (input.keyCode == KeyCode.LeftArrow ? labels.Length - 1 : 1)) % labels.Length;
|
||||
GUI.changed = true;
|
||||
input.Use();
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
private void DrawWorkspaceToolbar()
|
||||
{
|
||||
const float y = 4, gap = 6, height = BattleEditorTheme.ControlHeight;
|
||||
EditorGUI.DrawRect(new Rect(0, 0, position.width, BattleEditorTheme.CanvasTop), Theme.Header);
|
||||
EditorGUI.DrawRect(new Rect(0, BattleEditorTheme.CanvasTop - 1, position.width, 1), Theme.Border);
|
||||
if (WorkspaceButton("file", new Rect(8, y, 50, height), "文件 ▾", toolbar: true))
|
||||
ShowFileMenu();
|
||||
string connection = _reconnect != null ? "正在连接… ▾" : _session.Data == null ? "连接数据 ▾" : "数据已连接 ▾";
|
||||
if (WorkspaceButton("connection", new Rect(64, y, 92, height), connection,
|
||||
_drawer == WorkspaceDrawer.Connection, toolbar: true))
|
||||
ToggleDrawer(WorkspaceDrawer.Connection);
|
||||
ToolbarSeparator(162, y, height);
|
||||
GUI.Label(new Rect(174, y, 42, height), BattleData.Variant, Theme.Title);
|
||||
|
||||
// Keep the primary action at the right edge in every test state.
|
||||
// Only the document title absorbs changes in available width.
|
||||
float primaryX = position.width - 8 - 120;
|
||||
float runX = primaryX - (_session.Preview != null ? 44 + gap : 0) - (_session.Battle != null ? 52 + gap : 0);
|
||||
float toolsX = runX - 12 - 72 * 2 - gap;
|
||||
string name = (_asset != null ? _asset.name : "未命名战斗") + (CurrentDraftDirty ? " *" : "");
|
||||
GUI.Label(new Rect(222, y, Mathf.Max(0, toolsX - 234), height),
|
||||
new GUIContent(name, _asset != null ? AssetDatabase.GetAssetPath(_asset) : "使用文件菜单保存为战斗预设"), Theme.Metadata);
|
||||
if (WorkspaceButton("configuration", new Rect(toolsX, y, 72, height), "编辑配置",
|
||||
_drawer == WorkspaceDrawer.Configuration, toolbar: true))
|
||||
ToggleDrawer(WorkspaceDrawer.Configuration);
|
||||
if (WorkspaceButton("diagnostics", new Rect(toolsX + 72 + gap, y, 72, height),
|
||||
_error == null ? "诊断工具" : "诊断 · !", _drawer == WorkspaceDrawer.Diagnostics, toolbar: true))
|
||||
{
|
||||
ToggleDrawer(WorkspaceDrawer.Diagnostics);
|
||||
if (_error != null)
|
||||
{
|
||||
_drawer = WorkspaceDrawer.Diagnostics;
|
||||
_diagnosticPage = 2;
|
||||
_inspectorScroll = Vector2.zero;
|
||||
}
|
||||
}
|
||||
ToolbarSeparator(runX - 7, y, height);
|
||||
float x = runX;
|
||||
if (_session.Preview != null)
|
||||
{
|
||||
if (WorkspaceButton("stop", new Rect(x, y, 44, height), "停止", toolbar: true))
|
||||
_session.Stop();
|
||||
x += 44 + gap;
|
||||
}
|
||||
if (_session.Battle != null)
|
||||
{
|
||||
float[] speeds = { 1f, 2f, 4f };
|
||||
int old = Array.IndexOf(speeds, _session.Speed);
|
||||
if (old < 0)
|
||||
{
|
||||
old = speeds.Length;
|
||||
speeds = speeds.Append(_session.Speed).ToArray();
|
||||
}
|
||||
var speedRect = new Rect(x, y, 52, height);
|
||||
RememberControl("speed", speedRect);
|
||||
int next = EditorGUI.Popup(speedRect, old, speeds.Select(speed => $"{speed:0.##}×").ToArray(), Theme.Popup);
|
||||
if (old != next)
|
||||
_session.Speed = speeds[next];
|
||||
}
|
||||
if (WorkspaceButton("primary", new Rect(primaryX, y, 120, height), PrimaryLabel(), primary: true))
|
||||
RunPrimaryAction();
|
||||
}
|
||||
|
||||
private void ToolbarSeparator(float x, float y, float height) =>
|
||||
EditorGUI.DrawRect(new Rect(x, y + 5, 1, height - 10), Theme.Border);
|
||||
|
||||
private void ToggleDrawer(WorkspaceDrawer drawer)
|
||||
{
|
||||
_drawer = _drawer == drawer ? WorkspaceDrawer.None : drawer;
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void DrawWelcome(Rect canvas)
|
||||
{
|
||||
float width = Mathf.Min(400, canvas.width - 40);
|
||||
_welcomeRect = new Rect(canvas.center.x - width / 2, canvas.center.y - 92, width, 184);
|
||||
WorkspaceAction action = PrimaryAction();
|
||||
string text = action switch
|
||||
{
|
||||
WorkspaceAction.Connect => $"连接 {BattleData.Variant} 原版数据,配置并测试一场战斗。",
|
||||
WorkspaceAction.Random => "随机生成场景与双方队伍,或从预设开始。",
|
||||
WorkspaceAction.Configure => Validation().FirstOrDefault() ?? "在右侧配置场景与双方队伍。",
|
||||
_ => $"场景 {Scenario.Scene} · 我方 {Scenario.Participants.Count(p => p.Side == BattleSide.Ally)} 人 · 敌方 {Scenario.Participants.Count(p => p.Side == BattleSide.Enemy)} 人",
|
||||
};
|
||||
GUI.Label(new Rect(_welcomeRect.x, _welcomeRect.y + 8, width, 34), "战斗编辑器", Theme.WelcomeTitle);
|
||||
GUI.Label(new Rect(_welcomeRect.x, _welcomeRect.y + 50, width, 36), text, Theme.WelcomeText);
|
||||
const float buttonWidth = 224;
|
||||
float x = _welcomeRect.center.x - buttonWidth / 2;
|
||||
if (WorkspaceButton("welcome-primary", new Rect(x, _welcomeRect.y + 102, buttonWidth, BattleEditorTheme.ControlHeight), PrimaryLabel(), primary: true))
|
||||
RunPrimaryAction();
|
||||
bool needsRoster = (Scenario.Participants?.Count ?? 0) == 0;
|
||||
using (new EditorGUI.DisabledScope(_session.Data == null))
|
||||
if (WorkspaceButton("welcome-manual", new Rect(x, _welcomeRect.y + 136, 108, BattleEditorTheme.ControlHeight),
|
||||
needsRoster ? "手动配置" : "编辑配置"))
|
||||
{
|
||||
_drawer = WorkspaceDrawer.Configuration;
|
||||
_configurationPage = needsRoster ? 1 : 0;
|
||||
}
|
||||
if (WorkspaceButton("welcome-open", new Rect(x + 116, _welcomeRect.y + 136, 108, BattleEditorTheme.ControlHeight), "打开预设…"))
|
||||
OpenAssetPicker();
|
||||
}
|
||||
|
||||
private void DrawDrawer(Rect rect)
|
||||
{
|
||||
GUI.Box(rect, GUIContent.none, EditorStyles.helpBox);
|
||||
GUILayout.BeginArea(new Rect(rect.x + 10, rect.y + 8, rect.width - 20, rect.height - 16));
|
||||
float previous = EditorGUIUtility.labelWidth;
|
||||
EditorGUIUtility.labelWidth = 142;
|
||||
try
|
||||
{
|
||||
Rect header = GUILayoutUtility.GetRect(0, BattleEditorTheme.ControlHeight, GUILayout.ExpandWidth(true));
|
||||
GUI.Label(new Rect(header.x, header.y, header.width - 32, header.height), _drawer switch
|
||||
{
|
||||
WorkspaceDrawer.Configuration => "战斗配置",
|
||||
WorkspaceDrawer.Diagnostics => "诊断工具",
|
||||
_ => "连接原版数据"
|
||||
}, Theme.Title);
|
||||
if (WorkspaceButton("drawer-close", new Rect(header.xMax - 24, header.y, 24, header.height), "×"))
|
||||
ToggleDrawer(_drawer);
|
||||
GUILayout.Space(6);
|
||||
if (_drawer == WorkspaceDrawer.Configuration)
|
||||
_configurationPage = DrawerTabs("tabs:configuration", _configurationPage, new[] { "场景", "队伍", "物品" });
|
||||
if (_drawer == WorkspaceDrawer.Diagnostics)
|
||||
_diagnosticPage = DrawerTabs("tabs:diagnostics", _diagnosticPage, new[] { "观察", "资源表", "日志" });
|
||||
GUILayout.Space(6);
|
||||
using var scroll = new EditorGUILayout.ScrollViewScope(_inspectorScroll);
|
||||
_inspectorScroll = scroll.scrollPosition;
|
||||
GUILayout.Space(2);
|
||||
if (_drawer == WorkspaceDrawer.Connection)
|
||||
DrawConnection();
|
||||
else if (_drawer == WorkspaceDrawer.Diagnostics)
|
||||
DrawDiagnostics();
|
||||
else
|
||||
DrawConfiguration();
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUIUtility.labelWidth = previous;
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawConfiguration()
|
||||
{
|
||||
if (_session.Data == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("请先连接原版数据,再选择战斗场景和添加参战者。", MessageType.Info);
|
||||
if (DrawerButton("连接原版数据"))
|
||||
_drawer = WorkspaceDrawer.Connection;
|
||||
}
|
||||
if (BattleScenarioEditing.NeedsRepair(Scenario))
|
||||
{
|
||||
EditorGUILayout.HelpBox("配置缺少必需内容。修复会保留已有字段并移除空元素,可撤销。", MessageType.Warning);
|
||||
if (DrawerButton("修复缺失配置"))
|
||||
Edit("Repair battle authoring fields", () => _draft.Scenario = BattleScenarioEditing.Repair(Scenario));
|
||||
return;
|
||||
}
|
||||
foreach (string message in Validation().Take(3))
|
||||
EditorGUILayout.HelpBox(message, MessageType.Warning);
|
||||
if (_session.Data != null && Scenario.DataFingerprint != _session.Data.Fingerprint)
|
||||
{
|
||||
if (DrawerButton("将配置绑定到当前数据"))
|
||||
Edit("Bind battle data", () => Scenario.DataFingerprint = _session.Data.Fingerprint);
|
||||
}
|
||||
if (_configurationPage == 0)
|
||||
DrawScenario(Scenario);
|
||||
else if (_configurationPage == 1)
|
||||
{
|
||||
DrawRoster();
|
||||
GUILayout.Space(10);
|
||||
BattleParticipant actor = Scenario.Participants.FirstOrDefault(p => p.InstanceId == _selected);
|
||||
if (actor != null)
|
||||
DrawParticipant(actor);
|
||||
else
|
||||
GUILayout.Label("选择上方参战者编辑等级、阵位与初始状态。", EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
Field(Scenario, "Money", "本局金钱");
|
||||
Field(Scenario, "TreasureUses", "仙宝 ID/剩余次数(0–255)");
|
||||
Field(Scenario, "Items", "物品 ID/数量");
|
||||
EditorGUILayout.HelpBox("只影响本次测试,不写入正式背包或存档。可在诊断的资源表中查找物品并加入配置。", MessageType.Info);
|
||||
}
|
||||
}
|
||||
|
||||
private bool Section(string id, string title)
|
||||
{
|
||||
GUILayout.Space(BattleEditorTheme.GroupSpacing);
|
||||
Rect rect = EditorGUILayout.GetControlRect(false, BattleEditorTheme.ControlHeight);
|
||||
RememberControl("section:" + id, rect);
|
||||
float labelWidth = EditorGUIUtility.labelWidth;
|
||||
bool value;
|
||||
try
|
||||
{
|
||||
EditorGUIUtility.labelWidth = rect.width;
|
||||
value = EditorGUI.Foldout(rect, _sections.GetValueOrDefault(id), title, true, Theme.Section);
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUIUtility.labelWidth = labelWidth;
|
||||
}
|
||||
_sections[id] = value;
|
||||
if (value)
|
||||
GUILayout.Space(4);
|
||||
return value;
|
||||
}
|
||||
|
||||
private void DrawConnection()
|
||||
{
|
||||
if (_session.Data != null)
|
||||
{
|
||||
GUILayout.Label("当前连接", EditorStyles.boldLabel);
|
||||
EditorGUILayout.SelectableLabel(_session.Data.Resources.Root, EditorStyles.wordWrappedMiniLabel, GUILayout.Height(44));
|
||||
GUILayout.Label(_session.Data.Resources.Codepage == 950 ? "繁體中文 · 950" : "简体中文 · 936", EditorStyles.miniLabel);
|
||||
}
|
||||
GUILayout.Space(8);
|
||||
GUILayout.Label("数据目录", EditorStyles.boldLabel);
|
||||
_root = EditorGUILayout.TextField(_root);
|
||||
if (DrawerButton("浏览目录…"))
|
||||
ChooseDataFolder(false);
|
||||
_codepage = EditorGUILayout.Popup("文字编码", _codepage == 950 ? 1 : 0, new[] { "简体 936", "繁體 950" }) == 0 ? 936 : 950;
|
||||
EditorGUILayout.HelpBox($"选择 {BattleData.Variant} 中直接包含 basedata 的目录。加载成功后会停止当前测试,保留战斗配置。", MessageType.Info);
|
||||
if (DrawerButton("加载数据"))
|
||||
TryLoadData();
|
||||
if (_error != null)
|
||||
EditorGUILayout.HelpBox(_error, MessageType.Error);
|
||||
}
|
||||
|
||||
private void ChooseDataFolder(bool load)
|
||||
{
|
||||
_drawer = WorkspaceDrawer.Connection;
|
||||
string path = EditorUtility.OpenFolderPanel("选择 " + BattleData.Variant + " 数据目录", _root, "");
|
||||
if (path.Length == 0)
|
||||
return;
|
||||
_root = path;
|
||||
if (load)
|
||||
TryLoadData();
|
||||
}
|
||||
|
||||
private void DrawDiagnostics()
|
||||
{
|
||||
if (_diagnosticPage == 1)
|
||||
{
|
||||
if (BattleScenarioEditing.NeedsRepair(Scenario))
|
||||
EditorGUILayout.HelpBox("先修复配置,再从资源表加入字段。", MessageType.Warning);
|
||||
else
|
||||
DrawDataCatalog();
|
||||
return;
|
||||
}
|
||||
if (_diagnosticPage == 2)
|
||||
{
|
||||
if (_error != null)
|
||||
EditorGUILayout.HelpBox(_error, MessageType.Error);
|
||||
foreach (string message in Validation())
|
||||
EditorGUILayout.HelpBox(message, MessageType.Warning);
|
||||
foreach (string message in _session.Preview?.Diagnostics ?? Array.Empty<string>())
|
||||
EditorGUILayout.HelpBox(message, MessageType.Warning);
|
||||
GUILayout.Label(string.Join("\n", _log), EditorStyles.wordWrappedMiniLabel);
|
||||
if (_session.Battle != null)
|
||||
GUILayout.Label(string.Join("\n", _session.Battle.Events.Skip(Math.Max(0, _session.Battle.Events.Count - 50))), EditorStyles.wordWrappedMiniLabel);
|
||||
if (DrawerButton("导出配置与诊断…"))
|
||||
Try(ExportReport);
|
||||
return;
|
||||
}
|
||||
DrawDisplaySettings();
|
||||
if (_session.Data == null || BattleScenarioEditing.NeedsRepair(Scenario))
|
||||
return;
|
||||
if (DraftPending)
|
||||
EditorGUILayout.HelpBox("画布使用修改前的配置。应用并重新开始后,调试命令恢复可用。", MessageType.Info);
|
||||
using (new EditorGUI.DisabledScope(DraftPending))
|
||||
{
|
||||
if (_session.Battle != null)
|
||||
{
|
||||
if (DrawerButton("单步(一个逻辑步)"))
|
||||
Try(_session.StepBattle);
|
||||
if (Section("live-inspection", "当前测试状态与调试命令"))
|
||||
DrawBattleBody();
|
||||
}
|
||||
if (_session.Preview != null && _session.Battle == null)
|
||||
{
|
||||
GUILayout.Label("动作预览", EditorStyles.boldLabel);
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
if (DrawerButton(_session.IsPlaying ? "暂停动作" : "播放动作"))
|
||||
{
|
||||
if (!_session.IsPlaying && _session.Preview.Time >= _session.Preview.Duration)
|
||||
_session.Preview.Sample(0);
|
||||
_session.IsPlaying = !_session.IsPlaying;
|
||||
}
|
||||
GUILayout.Space(6);
|
||||
if (DrawerButton("单步动作"))
|
||||
{
|
||||
_session.IsPlaying = false;
|
||||
Try(() => _session.Preview.Sample(_session.Preview.Time + 0.02f));
|
||||
}
|
||||
}
|
||||
float speed = EditorGUILayout.Slider("预览倍速", _session.Speed, 0.1f, 4);
|
||||
if (speed != _session.Speed)
|
||||
_session.Speed = speed;
|
||||
float time = EditorGUILayout.Slider("时间", _session.Preview.Time, 0, _session.Preview.Duration);
|
||||
if (time != _session.Preview.Time)
|
||||
{
|
||||
_session.IsPlaying = false;
|
||||
Try(() => _session.Preview.Sample(time));
|
||||
}
|
||||
DrawActions(_session.Preview);
|
||||
}
|
||||
}
|
||||
if (Section("preview-tools", "动作与测试工具"))
|
||||
{
|
||||
GUILayout.Label("动作预览会替换当前测试,只播放动画。", EditorStyles.wordWrappedMiniLabel);
|
||||
if (DrawerButton("建立动作预览"))
|
||||
Try(StartPreview);
|
||||
_autoAllies = EditorGUILayout.Toggle("下次开局我方自动", _autoAllies);
|
||||
_autoEnemies = EditorGUILayout.Toggle("下次开局敌方自动", _autoEnemies);
|
||||
if (_session.Preview != null && !DraftPending && DrawerButton("重开当前测试快照"))
|
||||
Try(_session.Restart);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawDisplaySettings()
|
||||
{
|
||||
if (!Section("display", "画布与操作设置"))
|
||||
return;
|
||||
_originalAspect = EditorGUILayout.Toggle("原版 4:3 画布", _originalAspect);
|
||||
_expandCamera = EditorGUILayout.Toggle("扩展原版视野", _expandCamera);
|
||||
_touchHud = EditorGUILayout.Toggle("触屏操作", _touchHud);
|
||||
_hudSafeInsets = EditorGUILayout.Vector4Field("安全区 左/上/右/下", _hudSafeInsets);
|
||||
int color = EditorGUILayout.Popup("受击数字颜色", (int)_damageNumberColor, new[] { "原版蓝色", "黄色", "白色" });
|
||||
_damageNumberColor = (BattleDamageNumberColorMode)color;
|
||||
_debugBattle = EditorGUILayout.Toggle("显示角色调试标签", _debugBattle);
|
||||
if (_session.Preview != null && DrawerButton("镜头回到全景"))
|
||||
_session.Preview.View.Frame();
|
||||
}
|
||||
|
||||
private void ShowFileMenu()
|
||||
{
|
||||
var menu = new GenericMenu();
|
||||
bool editable = !EditorApplication.isPlayingOrWillChangePlaymode;
|
||||
AddFileAction(menu, "新建战斗", () => Try(NewScenario), editable);
|
||||
AddFileAction(menu, "打开预设…", OpenAssetPicker, editable);
|
||||
if (_session.Data != null && editable)
|
||||
menu.AddItem(new GUIContent("创建随机战斗"), false, () => Try(CreateRandomExample));
|
||||
else
|
||||
menu.AddDisabledItem(new GUIContent("创建随机战斗"));
|
||||
menu.AddSeparator("");
|
||||
AddFileAction(menu, "保存", () => Try(() => SaveScenario(false)), editable);
|
||||
AddFileAction(menu, "另存为…", () => Try(() => SaveScenario(true)), editable);
|
||||
menu.AddSeparator("");
|
||||
menu.AddItem(new GUIContent("导出配置与诊断…"), false, () => Try(ExportReport));
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
|
||||
private static void AddFileAction(GenericMenu menu, string label, GenericMenu.MenuFunction action, bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
menu.AddItem(new GUIContent(label), false, action);
|
||||
else
|
||||
menu.AddDisabledItem(new GUIContent(label));
|
||||
}
|
||||
|
||||
private void OpenAssetPicker()
|
||||
{
|
||||
_showAssetPicker(_asset, _assetPickerId);
|
||||
}
|
||||
|
||||
private void HandleAssetPicker()
|
||||
{
|
||||
if (Event.current.commandName == "ObjectSelectorClosed" && EditorGUIUtility.GetObjectPickerControlID() == _assetPickerId)
|
||||
{
|
||||
var asset = EditorGUIUtility.GetObjectPickerObject() as BattleScenarioAsset;
|
||||
if (asset != null)
|
||||
Try(() => LoadAsset(asset));
|
||||
Event.current.Use();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f7c7960157d4bde852d6597a6363ca7
|
||||
@@ -0,0 +1,22 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using Battle;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(menuName = BattleData.Variant + "/Battle scenario", fileName = "BattleScenario")]
|
||||
public sealed class BattleScenarioAsset : ScriptableObject, ISerializationCallbackReceiver
|
||||
{
|
||||
[NonSerialized] public BattleScenario Scenario = new() { Variant = BattleData.Variant };
|
||||
[SerializeField, HideInInspector] private string _scenarioJson = "";
|
||||
|
||||
public void OnBeforeSerialize() => _scenarioJson = Scenario == null ? "" : BattleScenarioJson.Serialize(Scenario);
|
||||
|
||||
public void OnAfterDeserialize() => Scenario = string.IsNullOrEmpty(_scenarioJson) ? new BattleScenario { Variant = BattleData.Variant } : BattleScenarioJson.Deserialize(_scenarioJson);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 777cc6aa6f58e42999315727852ab67a
|
||||
@@ -0,0 +1,60 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Battle;
|
||||
|
||||
// Invalid imports remain inspectable; restoring the required authoring graph
|
||||
// is explicit and undoable, rather than silently changing data while drawing.
|
||||
public static class BattleScenarioEditing
|
||||
{
|
||||
public static bool NeedsRepair(BattleScenario scenario) => scenario == null ||
|
||||
scenario.Participants == null || scenario.Items == null || scenario.TreasureUses == null ||
|
||||
scenario.Camera == null || scenario.Pal3A?.SpiritWheel?.Charges is not { Length: 5 } ||
|
||||
scenario.Participants.Any(actor => actor == null || actor.Skills == null || actor.Statuses == null ||
|
||||
actor.Attributes is not { Length: 12 } || actor.Vitals is not { Length: 3 } || actor.Equipment is not { Length: 6 } ||
|
||||
actor.Skills.Any(skill => skill == null) || actor.Statuses.Any(state => state == null)) ||
|
||||
scenario.Items.Any(item => item == null) || scenario.TreasureUses.Any(item => item == null);
|
||||
|
||||
public static BattleScenario Repair(BattleScenario scenario)
|
||||
{
|
||||
scenario ??= new BattleScenario();
|
||||
scenario.Camera ??= new BattleCamera();
|
||||
scenario.Pal3A ??= new BattlePal3AState();
|
||||
scenario.Pal3A.SpiritWheel ??= new BattleSpiritWheel();
|
||||
scenario.Pal3A.SpiritWheel.Charges = Resize(scenario.Pal3A.SpiritWheel.Charges, 5);
|
||||
scenario.Participants ??= new();
|
||||
scenario.Items ??= new();
|
||||
scenario.TreasureUses ??= new();
|
||||
scenario.Participants.RemoveAll(actor => actor == null);
|
||||
scenario.Items.RemoveAll(item => item == null);
|
||||
scenario.TreasureUses.RemoveAll(item => item == null);
|
||||
foreach (BattleParticipant actor in scenario.Participants)
|
||||
{
|
||||
actor.Skills ??= new();
|
||||
actor.Statuses ??= new();
|
||||
actor.Skills.RemoveAll(skill => skill == null);
|
||||
actor.Statuses.RemoveAll(state => state == null);
|
||||
actor.Attributes = Resize(actor.Attributes, 12);
|
||||
actor.Vitals = Resize(actor.Vitals, 3);
|
||||
actor.Equipment = Resize(actor.Equipment, 6);
|
||||
}
|
||||
return scenario;
|
||||
}
|
||||
|
||||
private static int[] Resize(int[] values, int length)
|
||||
{
|
||||
if (values?.Length == length)
|
||||
return values;
|
||||
var repaired = new int[length];
|
||||
if (values != null)
|
||||
Array.Copy(values, repaired, Math.Min(values.Length, length));
|
||||
return repaired;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bef801fb57244918610e0fe626aa58b
|
||||
@@ -0,0 +1,68 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using Battle;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
// Unity's inline class serialization turns absent optional snapshots into
|
||||
// new objects. Keep the engine-independent authoring contract as JSON so
|
||||
// null sword state survives assets, Undo, domain reload and reports.
|
||||
public static class BattleScenarioJson
|
||||
{
|
||||
private static readonly JsonSerializerSettings Settings = new()
|
||||
{
|
||||
ObjectCreationHandling = ObjectCreationHandling.Replace,
|
||||
TypeNameHandling = TypeNameHandling.None
|
||||
};
|
||||
|
||||
private const string FormatProperty = "$battleScenarioFormat";
|
||||
|
||||
public static string Serialize(BattleScenario scenario)
|
||||
{
|
||||
if (scenario == null)
|
||||
return "null";
|
||||
JObject document = JObject.FromObject(scenario, JsonSerializer.Create(Settings));
|
||||
document.AddFirst(new JProperty(FormatProperty, 1));
|
||||
return document.ToString(Formatting.None);
|
||||
}
|
||||
|
||||
public static BattleScenario Deserialize(string json) => Decode(JObject.Parse(json));
|
||||
|
||||
private static BattleScenario Decode(JObject document)
|
||||
{
|
||||
BattleScenario scenario = document.ToObject<BattleScenario>(JsonSerializer.Create(Settings));
|
||||
if (document.GetValue(nameof(BattleScenario.Participants), StringComparison.OrdinalIgnoreCase) is JArray participants)
|
||||
for (int index = 0; index < participants.Count; index++)
|
||||
if (participants[index] is JObject actor &&
|
||||
actor.GetValue(nameof(BattleParticipant.InstanceId), StringComparison.OrdinalIgnoreCase) == null)
|
||||
scenario.Participants[index].InstanceId = null;
|
||||
return scenario;
|
||||
}
|
||||
|
||||
// Only the old window codec needs repair. New authored invalid values
|
||||
// remain visible to validation instead of being silently normalized.
|
||||
public static BattleScenario RestoreDraft(string json)
|
||||
{
|
||||
JObject document = JObject.Parse(json);
|
||||
BattleScenario scenario = Decode(document);
|
||||
bool canonical = document[FormatProperty] != null ||
|
||||
document.SelectToken("Camera.Position.IsFinite") != null;
|
||||
if (!canonical && document["Participants"] is JArray participants)
|
||||
foreach (JToken participant in participants)
|
||||
canonical |= participant.SelectToken("Position.IsFinite") != null;
|
||||
if (!canonical && scenario.Participants != null)
|
||||
foreach (BattleParticipant actor in scenario.Participants)
|
||||
if (actor != null && (scenario.Variant != "PAL3" || actor.Equipment is not { Length: > 0 } ||
|
||||
actor.Equipment[0] != BattleMagicSwordRules.WeaponId ||
|
||||
actor.UsesNativeDefaultWeapon && BattleLoadoutRules.PlayerIdentity("PAL3", actor.ActorId) != 0))
|
||||
actor.MagicSword = null;
|
||||
return scenario;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c2bfeb6071b4932b01f957aed0180f1
|
||||
@@ -0,0 +1,214 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using Battle;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
// The authoring DTO stays outside Unity's inline serializer. Every write
|
||||
// goes through the window's transaction, including boxed struct writeback.
|
||||
public static class BattleScenarioTypedFields
|
||||
{
|
||||
private static readonly Dictionary<string, bool> Expanded = new();
|
||||
private static readonly Dictionary<Type, FieldInfo[]> Fields = new();
|
||||
|
||||
public static void Field(object owner, string fieldName, string label, Action<string, Action> edit, GUIStyle buttonStyle = null)
|
||||
{
|
||||
if (owner == null || edit == null)
|
||||
throw new ArgumentNullException(owner == null ? nameof(owner) : nameof(edit));
|
||||
FieldInfo field = owner.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public)
|
||||
?? throw new ArgumentException("Unknown authoring field: " + fieldName, nameof(fieldName));
|
||||
if (field.IsInitOnly)
|
||||
throw new ArgumentException("The authoring field is read-only.", nameof(fieldName));
|
||||
string identity = owner is BattleParticipant actor ? actor.InstanceId : owner.GetType().FullName;
|
||||
Draw(field.FieldType, field.GetValue(owner), value => field.SetValue(owner, value), label,
|
||||
identity + "." + fieldName, edit, new List<object>(), 0, buttonStyle);
|
||||
}
|
||||
|
||||
private static void Draw(Type type, object value, Action<object> assign, string label, string path,
|
||||
Action<string, Action> edit, List<object> ancestors, int depth, GUIStyle buttonStyle)
|
||||
{
|
||||
if (type == typeof(string))
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string next = EditorGUILayout.TextField(label, (string)value ?? "");
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
edit(label, () => assign(next));
|
||||
return;
|
||||
}
|
||||
if (type.IsEnum)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Enum next = EditorGUILayout.EnumPopup(label, (Enum)value);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
edit(label, () => assign(next));
|
||||
return;
|
||||
}
|
||||
if (type.IsPrimitive || type == typeof(decimal))
|
||||
{
|
||||
DrawScalar(type, value, assign, label, edit);
|
||||
return;
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
using var row = new EditorGUILayout.HorizontalScope();
|
||||
EditorGUILayout.LabelField(label, "未配置", GUILayout.Height(buttonStyle?.fixedHeight ?? EditorGUIUtility.singleLineHeight));
|
||||
if (GUILayout.Button("创建", buttonStyle ?? GUI.skin.button, GUILayout.Width(48)))
|
||||
edit(label, () => assign(Create(type)));
|
||||
return;
|
||||
}
|
||||
if (depth >= 12 || !type.IsValueType && ancestors.Exists(parent => ReferenceEquals(parent, value)))
|
||||
{
|
||||
EditorGUILayout.LabelField(label, type.Name);
|
||||
return;
|
||||
}
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
bool expanded = !Expanded.TryGetValue(path, out bool stored) || stored;
|
||||
Rect header = EditorGUILayout.GetControlRect(false, buttonStyle?.fixedHeight ?? EditorGUIUtility.singleLineHeight);
|
||||
Expanded[path] = EditorGUI.Foldout(header, expanded, label, true);
|
||||
bool optional = type == typeof(BattleMagicSword);
|
||||
string action = value is IList ? "清空" : optional ? "移除" : "重置";
|
||||
if (!type.IsValueType && GUILayout.Button(action, buttonStyle ?? GUI.skin.button, GUILayout.Width(48)))
|
||||
{
|
||||
edit(label, () =>
|
||||
{
|
||||
if (value is Array array)
|
||||
{
|
||||
var cleared = (Array)array.Clone();
|
||||
Array.Clear(cleared, 0, cleared.Length);
|
||||
assign(cleared);
|
||||
}
|
||||
else if (value is IList list)
|
||||
{
|
||||
list.Clear();
|
||||
assign(list);
|
||||
}
|
||||
else
|
||||
assign(optional ? null : Create(type));
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!Expanded[path])
|
||||
return;
|
||||
}
|
||||
ancestors.Add(value);
|
||||
int previousIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel++;
|
||||
try
|
||||
{
|
||||
if (value is IList list)
|
||||
DrawList(type, list, assign, label, path, edit, ancestors, depth, buttonStyle);
|
||||
else
|
||||
{
|
||||
if (!Fields.TryGetValue(type, out FieldInfo[] fields))
|
||||
Fields[type] = fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public);
|
||||
foreach (FieldInfo field in fields)
|
||||
{
|
||||
if (field.IsInitOnly || field.IsLiteral || field.IsNotSerialized)
|
||||
continue;
|
||||
Draw(field.FieldType, field.GetValue(value), replacement =>
|
||||
{
|
||||
field.SetValue(value, replacement);
|
||||
assign(value);
|
||||
}, ObjectNames.NicifyVariableName(field.Name), path + "." + field.Name, edit, ancestors, depth + 1, buttonStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
EditorGUI.indentLevel = previousIndent;
|
||||
ancestors.RemoveAt(ancestors.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawList(Type type, IList list, Action<object> assign, string label, string path,
|
||||
Action<string, Action> edit, List<object> ancestors, int depth, GUIStyle buttonStyle)
|
||||
{
|
||||
Type element = type.IsArray ? type.GetElementType() : type.GetGenericArguments()[0];
|
||||
int count = list.Count;
|
||||
for (int index = 0; index < count; index++)
|
||||
{
|
||||
int slot = index;
|
||||
using var row = new EditorGUILayout.VerticalScope(EditorStyles.helpBox);
|
||||
Draw(element, list[slot], value =>
|
||||
{
|
||||
list[slot] = value;
|
||||
assign(list);
|
||||
}, "元素 " + slot, path + "[" + slot + "]", edit, ancestors, depth + 1, buttonStyle);
|
||||
if (!type.IsArray && GUILayout.Button("删除元素", buttonStyle ?? GUI.skin.button, GUILayout.Width(80)))
|
||||
{
|
||||
edit(label, () =>
|
||||
{
|
||||
list.RemoveAt(slot);
|
||||
assign(list);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!type.IsArray && GUILayout.Button("添加元素", buttonStyle ?? GUI.skin.button))
|
||||
edit(label, () =>
|
||||
{
|
||||
list.Add(Create(element));
|
||||
assign(list);
|
||||
});
|
||||
}
|
||||
|
||||
private static object Create(Type type) => type == typeof(string) ? "" :
|
||||
type.IsArray ? Array.CreateInstance(type.GetElementType(), 0) : Activator.CreateInstance(type);
|
||||
|
||||
private static void DrawScalar(Type type, object value, Action<object> assign, string label, Action<string, Action> edit)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
object next;
|
||||
if (type == typeof(bool))
|
||||
next = EditorGUILayout.Toggle(label, (bool)value);
|
||||
else if (type == typeof(float))
|
||||
next = EditorGUILayout.FloatField(label, (float)value);
|
||||
else if (type == typeof(double))
|
||||
next = EditorGUILayout.DoubleField(label, (double)value);
|
||||
else if (type == typeof(decimal))
|
||||
{
|
||||
string text = EditorGUILayout.TextField(label, ((decimal)value).ToString(CultureInfo.InvariantCulture));
|
||||
next = decimal.TryParse(text, NumberStyles.Number, CultureInfo.InvariantCulture, out decimal number) ? number : value;
|
||||
}
|
||||
else if (type == typeof(ulong))
|
||||
{
|
||||
string text = EditorGUILayout.TextField(label, value.ToString());
|
||||
next = ulong.TryParse(text, out ulong number) ? number : value;
|
||||
}
|
||||
else if (type == typeof(char))
|
||||
{
|
||||
string text = EditorGUILayout.TextField(label, value.ToString());
|
||||
next = text.Length == 0 ? '\0' : text[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
long number = EditorGUILayout.LongField(label, Convert.ToInt64(value));
|
||||
next = IntegerValue(type, number);
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck() && !Equals(next, value))
|
||||
edit(label, () => assign(next));
|
||||
}
|
||||
|
||||
private static object IntegerValue(Type type, long number)
|
||||
{
|
||||
(long minimum, long maximum) = type == typeof(byte) ? (byte.MinValue, byte.MaxValue) :
|
||||
type == typeof(sbyte) ? (sbyte.MinValue, sbyte.MaxValue) :
|
||||
type == typeof(short) ? (short.MinValue, short.MaxValue) :
|
||||
type == typeof(ushort) ? (ushort.MinValue, ushort.MaxValue) :
|
||||
type == typeof(uint) ? (uint.MinValue, uint.MaxValue) :
|
||||
type == typeof(int) ? (int.MinValue, int.MaxValue) : (long.MinValue, long.MaxValue);
|
||||
return Convert.ChangeType(Math.Clamp(number, minimum, maximum), type, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1830535980b498e9d14bffa78ccd877
|
||||
@@ -0,0 +1,297 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Battle;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed partial class BattleEditorWindow
|
||||
{
|
||||
private BattleAction _battleAction;
|
||||
private int _battleAbility;
|
||||
private string _commandActor;
|
||||
private string _protectionController, _protectionSelection;
|
||||
|
||||
private void StartBattle()
|
||||
{
|
||||
_session.StartBattle(Scenario, _autoAllies, _autoEnemies);
|
||||
_previewJson = BattleScenarioJson.Serialize(Scenario);
|
||||
_commandActor = null;
|
||||
Log("战斗已创建;技能、物品、装备、状态与局内成长使用已校验的原版规则。未覆盖语义会明确拒绝,完整边界见诊断。使用顶部主操作播放,或在诊断中单步。");
|
||||
}
|
||||
|
||||
private void DrawBattleBody()
|
||||
{
|
||||
BattleSession combat = _session.Battle;
|
||||
var participants = combat.Actors.ToDictionary(actor => actor.Id, actor => combat.CaptureParticipant(actor.Id));
|
||||
string Label(string id) => id != null && participants.TryGetValue(id, out BattleParticipant actor) ? ActorLabel(actor) : id;
|
||||
GUILayout.Label($"战场 {combat.ActiveScene} · Boss 回合 {combat.BossRounds}", EditorStyles.wordWrappedMiniLabel);
|
||||
if (combat.Definitions.Variant == "PAL3A" && combat.FiveSpiritElement != 0)
|
||||
GUILayout.Label($"五灵法阵:{(Core.Contract.Enums.ElementType)combat.FiveSpiritElement} · {(combat.FiveSpiritForce == 1 ? "我方" : "敌方")}", EditorStyles.wordWrappedMiniLabel);
|
||||
if (combat.Definitions.Variant == "PAL3A")
|
||||
GUILayout.Label("五灵轮(水/火/风/雷/土):" + string.Join("/", combat.Pal3AState.SpiritWheel.Charges) +
|
||||
$" · 炎兽 {combat.Pal3AState.SpiritWheel.NangongRounds} 回合 · 累计精请求 {combat.Pal3AState.HpLoss} · 神请求 {combat.Pal3AState.MpLoss}", EditorStyles.wordWrappedMiniLabel);
|
||||
GUILayout.Label($"本局金钱 {combat.Money} · 物品 {string.Join("、", combat.Inventory.Select(item => $"{AbilityName(combat, item.Id, true)} ×{item.Count}"))}", EditorStyles.wordWrappedMiniLabel);
|
||||
EditorGUILayout.HelpBox("原版 AI 使用同一套技能、物品、资源和状态规则;可逐角色配置,或手动下令后重放记录。", MessageType.Info);
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
using (new EditorGUI.DisabledScope(combat.Status != BattleSessionStatus.Running))
|
||||
{
|
||||
foreach (BattleSide side in Enum.GetValues(typeof(BattleSide)))
|
||||
{
|
||||
bool before = combat.IsAutomatic(side);
|
||||
bool automatic;
|
||||
using (new EditorGUI.DisabledScope(combat.ActiveFormationController != null))
|
||||
automatic = GUILayout.Toggle(before, (side == BattleSide.Ally ? "我方" : "敌方") + "自动");
|
||||
if (before != automatic)
|
||||
combat.SetAutomatic(side, automatic);
|
||||
}
|
||||
}
|
||||
}
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
using (new EditorGUI.DisabledScope(combat.Status != BattleSessionStatus.Running))
|
||||
{
|
||||
if (DrawerButton("下一命中"))
|
||||
Try(() => _session.AdvanceTo(BattleEventKind.Hit));
|
||||
if (DrawerButton("下一行动结束"))
|
||||
Try(() => _session.AdvanceTo(BattleEventKind.ActionEnded));
|
||||
if (DrawerButton("中止战斗"))
|
||||
{
|
||||
combat.Abort();
|
||||
_session.SyncBattle();
|
||||
}
|
||||
}
|
||||
if (DrawerButton("重放记录"))
|
||||
Try(_session.BeginReplay, pauseOnError: false);
|
||||
}
|
||||
if (combat.Result != null)
|
||||
{
|
||||
if (_session.ResultPresentation is { } presentation)
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
using (new EditorGUI.DisabledScope(!presentation.CanSkip))
|
||||
if (DrawerButton("跳过当前提示"))
|
||||
_session.SkipResultStep();
|
||||
if (DrawerButton("重播结果演出"))
|
||||
Try(_session.ReplayResults, pauseOnError: false);
|
||||
}
|
||||
}
|
||||
DrawBattleResult(combat.Result, Label);
|
||||
}
|
||||
else if (combat.ActiveFormationController is { } controller)
|
||||
DrawFormationControl(combat, controller, Label);
|
||||
else if (combat.WaitingActor is { } waiting)
|
||||
DrawBattleCommand(combat, waiting, Label);
|
||||
if (combat.FleeResult is { } fleeResult)
|
||||
EditorGUILayout.HelpBox(fleeResult.Success ? "逃跑成功" : "逃跑失败", MessageType.Info);
|
||||
foreach (BattleActorSnapshot actor in combat.Actors)
|
||||
{
|
||||
Rect row = EditorGUILayout.GetControlRect(false, 20);
|
||||
EditorGUI.ProgressBar(row, actor.Gauge / (float)BattleSession.FullGauge,
|
||||
$"{Label(actor.Id)} · 精 {actor.Hp}/{actor.MaxHp} · 气 {actor.Sp}/{actor.MaxSp} · 神 {actor.Mp}/{actor.MaxMp} · {actor.Pose}{(actor.Ready ? " · 就绪" : "")}");
|
||||
if (Event.current.type == EventType.MouseDown && row.Contains(Event.current.mousePosition))
|
||||
{
|
||||
_selected = actor.Id;
|
||||
Event.current.Use();
|
||||
}
|
||||
if (actor.Pose is BattlePose.Casting or BattlePose.Fleeing)
|
||||
{
|
||||
Rect cast = EditorGUILayout.GetControlRect(false, 16);
|
||||
string action = actor.Pose == BattlePose.Fleeing ? "逃跑等待" : AbilityName(combat, actor.AbilityId, false);
|
||||
EditorGUI.ProgressBar(cast, actor.CastGauge / (float)BattleSession.FullCastGauge, $"第二槽 {actor.CastGauge}/{BattleSession.FullCastGauge} · {action}");
|
||||
}
|
||||
}
|
||||
if (combat.Actors.FirstOrDefault(actor => actor.Id == _selected) is { } selected)
|
||||
{
|
||||
GUILayout.Label($"{Label(selected.Id)} · 等级 {selected.Level} · 经验 {selected.Experience} · 回合 {selected.Rounds} · 好感 {selected.Love}", EditorStyles.boldLabel);
|
||||
GUILayout.Label("当前属性:" + string.Join(" · ", selected.Attributes.Select((value, index) => $"{AttributeLabels[index]} {value}")), EditorStyles.wordWrappedMiniLabel);
|
||||
GUILayout.Label("状态:" + (selected.States.Count == 0 ? "无" : string.Join("、", selected.States.Select(state => $"{state.State}({(state.Permanent ? "永久" : $"{state.RemainingRounds}回合")}{(state.LatentRounds > 0 ? $",潜伏{state.LatentRounds}" : "")})"))), EditorStyles.wordWrappedMiniLabel);
|
||||
if (selected.MagicSword is { } sword)
|
||||
GUILayout.Label($"魔剑:{AbilityName(combat, sword.SkillId, false)} · 能量 {sword.Energy:F2}/200 · 净化 {sword.PurificationCount} 次", EditorStyles.wordWrappedMiniLabel);
|
||||
GUILayout.Label("技能熟练:" + string.Join("、", selected.Skills.Select(skill => $"{AbilityName(combat, skill.Id, false)} Lv{skill.Level} · {skill.Uses}次{(skill.Mastered ? " · 掌握" : "")}")), EditorStyles.wordWrappedMiniLabel);
|
||||
DrawAiControls(combat, selected);
|
||||
if (selected.ActionId != 0 && DrawerButton("取消所选角色行动(调试,保留已消耗资源)"))
|
||||
Try(() =>
|
||||
{
|
||||
combat.CancelAction(selected.Id);
|
||||
_session.SyncBattle();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawFormationControl(BattleSession combat, string controller, Func<string, string> label)
|
||||
{
|
||||
GUILayout.Label("阵法 · " + label(controller), EditorStyles.boldLabel);
|
||||
GUILayout.Label("可连续调整阵位;确认时只清操作者的第一槽。最终还原原阵型不耗条。", EditorStyles.wordWrappedMiniLabel);
|
||||
foreach (BattleActorSnapshot actor in combat.Actors.Where(actor => actor.Side == BattleSide.Ally))
|
||||
{
|
||||
string denied = combat.CanSwapFormation(actor.Id, actor.Slot);
|
||||
using (new EditorGUI.DisabledScope(denied != null))
|
||||
{
|
||||
BattleSlot next = (BattleSlot)EditorGUILayout.EnumPopup(label(actor.Id), actor.Slot);
|
||||
if (next != actor.Slot)
|
||||
Try(() =>
|
||||
{
|
||||
string reason = combat.CanSwapFormation(actor.Id, next);
|
||||
if (reason != null)
|
||||
throw new InvalidOperationException(reason);
|
||||
combat.SwapFormation(actor.Id, next);
|
||||
_session.SyncBattle();
|
||||
});
|
||||
}
|
||||
if (denied != null)
|
||||
GUILayout.Label(denied, EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
if (DrawerButton("确认阵型"))
|
||||
Try(() =>
|
||||
{
|
||||
combat.EndFormation(controller);
|
||||
_session.SyncBattle();
|
||||
});
|
||||
}
|
||||
|
||||
private bool DrawProtectionControl(BattleSession combat, string controller, Func<string, string> label)
|
||||
{
|
||||
if (combat.CanSetProtection(controller, null) != null)
|
||||
return false;
|
||||
string[] targets = new[] { (string)null }.Concat(combat.Actors.Where(actor => actor.Side == BattleSide.Ally &&
|
||||
combat.CanSetProtection(controller, actor.Id) == null).Select(actor => actor.Id)).ToArray();
|
||||
if (_protectionController != controller)
|
||||
{
|
||||
_protectionController = controller;
|
||||
_protectionSelection = combat.ProtectionTarget;
|
||||
}
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
int selected = Math.Max(0, Array.IndexOf(targets, _protectionSelection));
|
||||
selected = EditorGUILayout.Popup("援护对象", selected, targets.Select(id => id == null ? "不援护" : label(id)).ToArray(), GUILayout.Height(BattleEditorTheme.ControlHeight));
|
||||
_protectionSelection = targets[selected];
|
||||
using var disabled = new EditorGUI.DisabledScope(_protectionSelection == combat.ProtectionTarget);
|
||||
if (DrawerButton("确认援护", GUILayout.Width(90)))
|
||||
{
|
||||
bool changed = combat.SetProtection(controller, _protectionSelection);
|
||||
_session.SyncBattle();
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DrawBattleCommand(BattleSession combat, string waiting, Func<string, string> label)
|
||||
{
|
||||
BattleActorSnapshot actor = combat.Actors.First(candidate => candidate.Id == waiting);
|
||||
if (_commandActor != waiting)
|
||||
{
|
||||
_commandActor = waiting;
|
||||
_battleAction = BattleAction.Attack;
|
||||
_battleAbility = 0;
|
||||
}
|
||||
GUILayout.Label("等待 " + label(waiting), EditorStyles.boldLabel);
|
||||
if (actor.Side == BattleSide.Ally)
|
||||
{
|
||||
string lineupReason = combat.CanBeginFormation(waiting);
|
||||
using (new EditorGUI.DisabledScope(lineupReason != null))
|
||||
if (DrawerButton("阵法换位"))
|
||||
Try(() => combat.BeginFormation(waiting));
|
||||
if (lineupReason != null)
|
||||
GUILayout.Label(lineupReason, EditorStyles.wordWrappedMiniLabel);
|
||||
if (DrawProtectionControl(combat, waiting, label))
|
||||
return;
|
||||
}
|
||||
_battleAction = (BattleAction)DrawerTabs("tabs:battle-action", (int)_battleAction, combat.Definitions.Variant == "PAL3A" ? new[] { "普攻", "防御", "技能", "物品", "逃跑", "炎兽变身" } : new[] { "普攻", "防御", "技能", "物品", "逃跑" });
|
||||
BattleAbilityDefinition ability = null;
|
||||
if (_battleAction is BattleAction.Skill or BattleAction.Item)
|
||||
{
|
||||
bool item = _battleAction == BattleAction.Item;
|
||||
IReadOnlyDictionary<int, BattleAbilityDefinition> definitions = item ? combat.Definitions.Items : combat.Definitions.Skills;
|
||||
int[] ids = (item ? combat.Inventory.Where(entry => entry.Count > 0).Select(entry => entry.Id) : actor.Skills.Select(skill => skill.Id)
|
||||
.Concat(actor.MagicSword is { SkillId: > 0 } sword ? new[] { sword.SkillId } : Array.Empty<int>())).Distinct().ToArray();
|
||||
int selected = Math.Max(0, Array.IndexOf(ids, _battleAbility));
|
||||
selected = EditorGUILayout.Popup(item ? "本局物品" : "已学技能", selected, ids.Select(id =>
|
||||
{
|
||||
if (item)
|
||||
return $"{AbilityName(combat, id, true)} ×{combat.Inventory.First(entry => entry.Id == id).Count}";
|
||||
if (actor.MagicSword?.SkillId == id)
|
||||
return $"{AbilityName(combat, id, false)} · 魔剑 {actor.MagicSword.Energy:F2}/200";
|
||||
BattleSkillSnapshot skill = actor.Skills.First(entry => entry.Id == id);
|
||||
return $"{AbilityName(combat, id, false)} · Lv{skill.Level} · {skill.Uses}次{(skill.Mastered ? " · 掌握" : "")}";
|
||||
}).ToArray());
|
||||
_battleAbility = ids.Length > 0 ? ids[selected] : 0;
|
||||
if (definitions.TryGetValue(_battleAbility, out ability))
|
||||
GUILayout.Label($"范围:{ability.Range}{(ability.Revives ? " · 可选择死亡角色" : "")}", EditorStyles.wordWrappedMiniLabel);
|
||||
else
|
||||
GUILayout.Label(item ? "本局没有可用物品。" : "此角色未配置技能。", EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
int abilityId = _battleAction is BattleAction.Skill or BattleAction.Item ? _battleAbility : 0;
|
||||
var query = new BattleCommand(waiting, _battleAction, abilityId: abilityId);
|
||||
BattleActorSnapshot[] targets = combat.GetTargetCandidates(query).ToArray();
|
||||
if (targets.Length > 0)
|
||||
{
|
||||
int targetIndex = Math.Max(0, Array.FindIndex(targets, target => target.Id == _target));
|
||||
targetIndex = EditorGUILayout.Popup("合法目标/范围中心", targetIndex, targets.Select(target => label(target.Id) + (target.Alive ? "" : " · 死亡")).ToArray());
|
||||
_target = targets[targetIndex].Id;
|
||||
}
|
||||
else
|
||||
_target = null;
|
||||
var command = new BattleCommand(waiting, _battleAction, _target, abilityId);
|
||||
string reason = combat.CanSubmit(command);
|
||||
BattleCostEstimate[] costs = combat.GetCostEstimate(command).ToArray();
|
||||
if (costs.Length > 0)
|
||||
GUILayout.Label("消耗预估:" + string.Join(" · ", costs.Select(cost => $"{ResourceName(cost.Resource)} 需求{cost.Required}/实付{cost.Payable}/持有{cost.Available}")), EditorStyles.wordWrappedMiniLabel);
|
||||
if (_battleAction == BattleAction.Item && ability != null)
|
||||
GUILayout.Label($"消耗预估:物品 1 件/持有 {combat.Inventory.FirstOrDefault(item => item.Id == ability.Id)?.Count ?? 0} 件", EditorStyles.wordWrappedMiniLabel);
|
||||
if (reason != null)
|
||||
EditorGUILayout.HelpBox(reason, MessageType.Warning);
|
||||
using (new EditorGUI.DisabledScope(reason != null))
|
||||
if (DrawerButton("执行指令"))
|
||||
Try(() =>
|
||||
{
|
||||
combat.Submit(command);
|
||||
_session.SyncBattle();
|
||||
});
|
||||
GUILayout.Label("输入选择与校验不会扣资源或消耗随机数;配置草稿的修改在下次开局生效。", EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
|
||||
private static string AbilityName(BattleSession combat, int id, bool item)
|
||||
{
|
||||
var definitions = item ? combat.Definitions.Items : combat.Definitions.Skills;
|
||||
return definitions.TryGetValue(id, out BattleAbilityDefinition ability) ? $"{ability.Name} ({id})" : id.ToString();
|
||||
}
|
||||
|
||||
private static string ResourceName(int resource) => resource switch
|
||||
{
|
||||
0 => "精",
|
||||
1 => "气",
|
||||
2 => "神",
|
||||
10 => "金钱",
|
||||
16 => "蛊",
|
||||
_ => $"资源{resource}"
|
||||
};
|
||||
|
||||
private static void DrawBattleResult(BattleResult result, Func<string, string> label)
|
||||
{
|
||||
GUILayout.Label($"{result.Status} · 胜方:{result.Winner?.ToString() ?? "无"} · {(result.Escaped ? "已逃跑 · " : "")}{result.Reason}", EditorStyles.boldLabel);
|
||||
GUILayout.Label($"本局金钱 {result.MoneyBefore} → {result.MoneyAfter}", EditorStyles.wordWrappedMiniLabel);
|
||||
if (result.Pal3A != null)
|
||||
GUILayout.Label("五灵轮:" + string.Join("/", result.Pal3A.SpiritWheel.Charges) + $" · 累计精请求 {result.Pal3A.HpLoss} · 神请求 {result.Pal3A.MpLoss}", EditorStyles.wordWrappedMiniLabel);
|
||||
foreach (BattleActorReward reward in result.Rewards ?? Array.Empty<BattleActorReward>())
|
||||
{
|
||||
GUILayout.Label($"{label(reward.Actor)}:经验 +{reward.ExperienceGained}({reward.ExperienceBefore} → {reward.ExperienceAfter}),等级 {reward.LevelBefore} → {reward.LevelAfter}", EditorStyles.wordWrappedMiniLabel);
|
||||
if (reward.AttributesBefore != null && reward.AttributesAfter != null)
|
||||
GUILayout.Label("属性成长:" + string.Join(" · ", reward.AttributesBefore.Select((before, index) => (before, after: reward.AttributesAfter[index], index))
|
||||
.Where(value => value.before != value.after).Select(value => $"{AttributeLabels[value.index]} {value.before} → {value.after}")), EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
GUILayout.Label("掉落:" + string.Join("、", (result.Loot ?? Array.Empty<BattleItemSnapshot>()).Select(item => $"{item.Id} ×{item.Count}")), EditorStyles.wordWrappedMiniLabel);
|
||||
GUILayout.Label("结算只保留在本次独立战斗报告中。", EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d275724c54f441e3bdc76f46b61c8d49
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 217fe13c1b454337aa7542f9228a5361
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,243 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Battle;
|
||||
using Core.Contract.Constants;
|
||||
using Core.Contract.Enums;
|
||||
using Core.DataReader.Dat;
|
||||
using Engine.Extensions;
|
||||
|
||||
public sealed partial class BattleAnimationCatalog : IBattleAbilityEffects, IBattleAbilityBodyAnimations, IBattleEffectActorAnimations
|
||||
{
|
||||
private readonly Dictionary<(string, int, bool), BattleAbilityStageProfile> _abilityStages = new();
|
||||
|
||||
public BattleAbilityStageProfile AbilityStage(string actor, BattleAbilityDefinition ability)
|
||||
{
|
||||
if (ability == null || !_participants.TryGetValue(actor, out BattleParticipant participant) ||
|
||||
!ability.IsItem && ability.SkillTypeId == 4)
|
||||
throw new ArgumentException("An ordinary ability stage needs its captured actor and original ability.");
|
||||
var key = (actor, ability.Id, ability.IsItem);
|
||||
if (_abilityStages.TryGetValue(key, out BattleAbilityStageProfile captured))
|
||||
return captured;
|
||||
if (!_linkers.SkillIdToEffectGroupMap.TryGetValue(ability.Id, out EffectGroupInfo[] groups) || groups.Length != 2)
|
||||
throw new NotSupportedException($"Ability {ability.Id} has no original two-group effect linker.");
|
||||
bool main = _actors[actor].Main;
|
||||
BattleAbilityStageKind kind = ability.IsItem ? BattleAbilityStageKind.Item : ability.IsMagic || !main ? BattleAbilityStageKind.Magic : BattleAbilityStageKind.Skill;
|
||||
bool npcItemIdle = BattleData.Variant == "PAL3A" && !main && ability.IsItem;
|
||||
bool noBody = npcItemIdle || ability.IsTreasure || BattleData.Variant == "PAL3A" && kind == BattleAbilityStageKind.Skill && ability.Id is 4102 or 4103 or 4108 or 4507;
|
||||
int bodyTicks = 0;
|
||||
bool retainedBody = false;
|
||||
if (!noBody)
|
||||
{
|
||||
if (_data.TryActionPath(participant, AbilityClip(participant, ability), out string path))
|
||||
{
|
||||
BattleAnimationMetadata body = _data.GetAnimationMetadata(path);
|
||||
bodyTicks = ToTicks(body.TotalGameBoxTicks / (double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / ActivePlaybackRate);
|
||||
}
|
||||
else
|
||||
retainedBody = true;
|
||||
}
|
||||
BattleMovementKind? approach = null, returning = null;
|
||||
if (kind == BattleAbilityStageKind.Skill && main)
|
||||
{
|
||||
#if PAL3
|
||||
approach = ability.Id switch
|
||||
{
|
||||
4101 or 4304 => BattleMovementKind.Teleport,
|
||||
4205 => BattleMovementKind.Fly,
|
||||
4505 => BattleMovementKind.Run,
|
||||
_ => null
|
||||
};
|
||||
returning = Priority(actor) switch
|
||||
{
|
||||
1 or 3 => BattleMovementKind.Fly,
|
||||
2 => BattleMovementKind.Teleport,
|
||||
_ => BattleMovementKind.Run
|
||||
};
|
||||
|
||||
#else
|
||||
approach = ability.Id switch
|
||||
{
|
||||
4101 => BattleMovementKind.Teleport,
|
||||
4504 or 4505 => BattleMovementKind.Run,
|
||||
4506 => BattleMovementKind.Fly,
|
||||
_ => null
|
||||
};
|
||||
returning = Priority(actor) switch
|
||||
{
|
||||
0 => ability.Id is 4101 or 4107 or 4108 ? BattleMovementKind.Run : null,
|
||||
4 => ability.Id is 4504 or 4505 or 4506 ? BattleMovementKind.Run : BattleMovementKind.Teleport,
|
||||
_ => BattleMovementKind.Run
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
||||
BattleAbilityWorkBoundary work = ability.IsTreasure ? BattleAbilityWorkBoundary.WorkTimeAndFirstGroupFinished :
|
||||
kind == BattleAbilityStageKind.Skill && ability.Id == 4101 ? BattleAbilityWorkBoundary.WorkTimeAndBodyIdle : BattleAbilityWorkBoundary.WorkTime;
|
||||
bool opposing = kind switch
|
||||
{
|
||||
BattleAbilityStageKind.Item => ability.ItemType == 2,
|
||||
BattleAbilityStageKind.Magic => ability.SkillTypeId == 2,
|
||||
_ => (int)ability.Range > 2
|
||||
};
|
||||
var profile = new BattleAbilityStageProfile(kind, CaptureAbilityBinding(groups[0]), CaptureAbilityBinding(groups[1]),
|
||||
groups[0].WorkTimeInSeconds, work, bodyTicks, opposing, approach, returning, retainedBody, npcItemIdle);
|
||||
_abilityStages.Add(key, profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
private static BattleAbilityEffectBinding CaptureAbilityBinding(EffectGroupInfo group) => new(group.EffGroupId, group.WaitDurationInSeconds,
|
||||
(group.IsCenteredAroundCaster ? 1 : 0) | (group.IsCenteredAroundReceiver ? 2 : 0) | (group.IsCasterActor ? 4 : 0) | (group.IsReceiverActor ? 8 : 0),
|
||||
new BattleMovementPoint(group.EffectGameBoxPosition.X, group.EffectGameBoxPosition.Y, group.EffectGameBoxPosition.Z));
|
||||
|
||||
public IReadOnlyList<BattleMovementPlan> AbilityMovement(BattleActorSnapshot source, BattleActorSnapshot target,
|
||||
BattleAbilityDefinition ability, BattleDefinitions definitions, bool returning)
|
||||
{
|
||||
if (source == null || ability == null || definitions == null)
|
||||
throw new ArgumentNullException(source == null ? nameof(source) : ability == null ? nameof(ability) : nameof(definitions));
|
||||
BattleAbilityStageProfile profile = AbilityStage(source.Id, ability);
|
||||
BattleMovementKind kind = (returning ? profile.ReturnKind : profile.ApproachKind) ?? throw new InvalidOperationException("This original ability has no corresponding movement task.");
|
||||
BattleMovementPoint destination = source.Home;
|
||||
if (!returning)
|
||||
{
|
||||
if (target == null)
|
||||
throw new InvalidOperationException("This original ability approaches one explicit target.");
|
||||
float radius = AbilityRadius(source, definitions) + AbilityRadius(target, definitions);
|
||||
#if PAL3A
|
||||
BattlePhysicalStageProfile sourceProfile = Physical(source.Id);
|
||||
int identity = sourceProfile.Identity;
|
||||
int weapon = sourceProfile.WeaponType;
|
||||
float extra = identity switch
|
||||
{
|
||||
0 => 40,
|
||||
1 => 50,
|
||||
2 => 40,
|
||||
3 => 32,
|
||||
_ => 0
|
||||
};
|
||||
bool extended = identity switch
|
||||
{
|
||||
0 => weapon == 1,
|
||||
1 => weapon == 3,
|
||||
2 => weapon == 6,
|
||||
3 => weapon == 7,
|
||||
_ => false
|
||||
};
|
||||
if (extended)
|
||||
radius += extra;
|
||||
if (_participants[target.Id].ActorId == 706)
|
||||
radius -= extra;
|
||||
|
||||
#endif
|
||||
if (_participants[source.Id].ActorId is 7364 or 7381)
|
||||
radius *= 2;
|
||||
float x = source.Position.X - target.Home.X, y = source.Position.Y - target.Home.Y, z = source.Position.Z - target.Home.Z;
|
||||
double length = Math.Sqrt((double)x * x + (double)y * y + (double)z * z);
|
||||
BattleMovementPoint normal = length < (double)0.005f ? new BattleMovementPoint(0, 1, 0) :
|
||||
new BattleMovementPoint((float)(x / length), (float)(y / length), (float)(z / length));
|
||||
destination = new BattleMovementPoint(target.Home.X + normal.X * radius, target.Home.Y + normal.Y * radius, target.Home.Z + normal.Z * radius);
|
||||
}
|
||||
if (kind != BattleMovementKind.Fly)
|
||||
return Array.AsReadOnly(new[] { new BattleMovementPlan(kind, source.Position, destination) });
|
||||
string moving = AbilityMovementAction(source.Id, ability, kind, returning);
|
||||
BattleAnimationMetadata model = _data.GetAnimationMetadata(_data.ActionPath(_participants[source.Id], moving));
|
||||
int? Marker(BattlePhysicalMarkerKind markerKind)
|
||||
{
|
||||
var matches = model.AnimationEvents.Where(marker => PhysicalMarkerKind(marker.Name) == markerKind).ToArray();
|
||||
if (matches.Length > 1)
|
||||
throw new NotSupportedException($"Animation {moving} has multiple {markerKind} markers.");
|
||||
return matches.Length == 0 ? null : Math.Max(0, checked((int)Math.Ceiling(matches[0].GameBoxTick /
|
||||
(double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / ActivePlaybackRate / BattleSession.StepSeconds)));
|
||||
}
|
||||
int? up = Marker(BattlePhysicalMarkerKind.FlyUp);
|
||||
if (!up.HasValue)
|
||||
throw new NotSupportedException($"Animation {moving} has no takeoff marker.");
|
||||
int? down = Marker(BattlePhysicalMarkerKind.FlyDown);
|
||||
int over = Marker(BattlePhysicalMarkerKind.Over) ?? ToTicks(model.TotalGameBoxTicks / (double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / ActivePlaybackRate);
|
||||
return Array.AsReadOnly(new[] { new BattleMovementPlan(kind, source.Position, destination, up, down, over) });
|
||||
}
|
||||
|
||||
private float AbilityRadius(BattleActorSnapshot actor, BattleDefinitions definitions)
|
||||
{
|
||||
int identity = PhysicalIdentity(_participants[actor.Id]);
|
||||
float adjustment = identity == (BattleData.Variant == "PAL3" ? 1 : 3) ? 10f : 0f;
|
||||
if (actor.NativeAnimationHalfDepth.HasValue)
|
||||
return actor.NativeAnimationHalfDepth.Value - adjustment;
|
||||
string clip = Clip(actor, definitions) ?? _data.IdleAction(_participants[actor.Id]);
|
||||
BattleAnimationMetadata model = _data.GetAnimationMetadata(_data.ActionPath(_participants[actor.Id], clip));
|
||||
if (!model.HasBounds)
|
||||
throw new InvalidOperationException("An original combat radius requires the current MV3 collision bounds.");
|
||||
return (model.MaximumZ - model.MinimumZ) * 0.5f - adjustment;
|
||||
}
|
||||
|
||||
public string EffectActor(uint modelCrc)
|
||||
{
|
||||
var hash = new Core.DataReader.Cpk.Crc32Hash();
|
||||
hash.Init();
|
||||
return _participants.Values.OrderBy(actor => actor.Side == BattleSide.Enemy ? 5 + (int)actor.Slot : Priority(actor.InstanceId))
|
||||
.FirstOrDefault(actor => (hash.Compute(_data.Model(actor), _data.Resources.Codepage) == modelCrc ||
|
||||
hash.Compute(_data.Model(actor).ToLowerInvariant(), _data.Resources.Codepage) == modelCrc))?.InstanceId;
|
||||
}
|
||||
|
||||
public int? AbilityNativeAction(string actor, BattleAbilityDefinition ability)
|
||||
{
|
||||
if (ability.SkillTypeId == 4)
|
||||
return 40;
|
||||
BattleAbilityStageProfile profile = AbilityStage(actor, ability);
|
||||
if (profile.NpcItemIdle)
|
||||
return null;
|
||||
if (!profile.RetainsBody && profile.BodyAnimationTicks == 0)
|
||||
return null;
|
||||
bool main = _actors[actor].Main;
|
||||
if (!main && !ability.IsItem)
|
||||
{
|
||||
uint[] skills = _data.Database.CombatActorInfos[_participants[actor].ActorId].SkillIds;
|
||||
return skills.Length > 1 && skills[1] == ability.Id ? 56 : skills.Length > 2 && skills[2] == ability.Id ? 57 : 55;
|
||||
}
|
||||
if (ability.IsItem)
|
||||
return AbilityClip(_participants[actor], ability) == ActorConstants.ActionToNameMap[ActorActionType.UseItemRecover] ? 38 : 39;
|
||||
if (ability.IsMagic)
|
||||
return 35;
|
||||
return ability.Id == (BattleData.Variant == "PAL3" ? 4101 : 4106) ? 37 : 36;
|
||||
}
|
||||
|
||||
public BattlePhysicalAnimation AbilityBody(string actor, BattleAbilityDefinition ability)
|
||||
{
|
||||
if (ability.SkillTypeId == 4)
|
||||
return CompilePhysicalAnimation(_participants[actor], ActorConstants.ActionToNameMap[ActorActionType.WeaponSkill]);
|
||||
BattleAbilityStageProfile profile = AbilityStage(actor, ability);
|
||||
if (profile.NpcItemIdle)
|
||||
{
|
||||
string idle = ActorConstants.ActionToNameMap[ActorActionType.PreAttack];
|
||||
return _data.TryActionPath(_participants[actor], idle, out _) ? CompilePhysicalAnimation(_participants[actor], idle) : null;
|
||||
}
|
||||
if (!profile.RetainsBody && profile.BodyAnimationTicks == 0)
|
||||
return null;
|
||||
string clip = AbilityClip(_participants[actor], ability);
|
||||
return _data.TryActionPath(_participants[actor], clip, out _) ? CompilePhysicalAnimation(_participants[actor], clip) : null;
|
||||
}
|
||||
|
||||
public BattlePhysicalAnimation AbilityMovementBody(string actor, BattleAbilityDefinition ability, BattleMovementKind kind, bool returning)
|
||||
{
|
||||
string clip = AbilityMovementAction(actor, ability, kind, returning);
|
||||
return CompilePhysicalAnimation(_participants[actor], clip);
|
||||
}
|
||||
|
||||
private string AbilityMovementAction(string actor, BattleAbilityDefinition ability, BattleMovementKind kind, bool returning) =>
|
||||
kind == BattleMovementKind.Teleport ? _data.IdleAction(_participants[actor]) :
|
||||
BattleData.Variant == "PAL3A" && !returning && ability.Id == 4506 ? "z22" : _actors[actor].Clips[BattlePose.Moving];
|
||||
|
||||
public BattlePhysicalAnimation ExternalBody(BattleActorSnapshot actor, string requested, BattleDefinitions definitions) =>
|
||||
_data.TryActionPath(_participants[actor.Id], requested, out _) ? CompilePhysicalAnimation(_participants[actor.Id], requested) : null;
|
||||
|
||||
public string AbilityMovementClip(BattleActorSnapshot actor) =>
|
||||
BattleData.Variant == "PAL3A" && actor.AbilityId == 4506 && actor.Movement?.Plan.Kind == BattleMovementKind.Fly ? "z22" : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74019725c6f145d292bfbef0889c26c8
|
||||
@@ -0,0 +1,36 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Battle;
|
||||
using Core.Contract.Constants;
|
||||
using Core.Contract.Enums;
|
||||
|
||||
public sealed partial class BattleAnimationCatalog
|
||||
{
|
||||
public IReadOnlyDictionary<int, BattlePhysicalAnimation> ResultBodyAnimations(BattleParticipant participant)
|
||||
{
|
||||
var result = new Dictionary<int, BattlePhysicalAnimation>
|
||||
{
|
||||
[32] = CompilePhysicalAnimation(participant, _data.IdleAction(participant)),
|
||||
[42] = CompilePhysicalAnimation(participant, ActorConstants.ActionToNameMap[ActorActionType.Defence]),
|
||||
[45] = CompilePhysicalAnimation(participant, ActorConstants.ActionToNameMap[ActorActionType.Freeze]),
|
||||
[46] = CompilePhysicalAnimation(participant, ActorConstants.ActionToNameMap[ActorActionType.Dying]),
|
||||
[47] = CompilePhysicalAnimation(participant, ActorConstants.ActionToNameMap[ActorActionType.Dead]),
|
||||
[49] = CompilePhysicalAnimation(participant, ActorConstants.ActionToNameMap[ActorActionType.Win])
|
||||
};
|
||||
#if PAL3A
|
||||
int identity = PhysicalIdentity(participant);
|
||||
int weapon = participant.Equipment.Length > 0 && participant.Equipment[0] != 0 ? (int)_data.Database.GameItemInfos[participant.Equipment[0]].WeaponType : 0;
|
||||
bool alternateLevelUp = identity == 1 && weapon == 3 || identity == 4 && weapon == 8;
|
||||
result[59] = CompilePhysicalAnimation(participant, alternateLevelUp ? "z162" : ActorConstants.ActionToNameMap[ActorActionType.LevelUp]);
|
||||
#endif
|
||||
return new ReadOnlyDictionary<int, BattlePhysicalAnimation>(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8119d208c5946d19ad62aa3e8073177
|
||||
@@ -0,0 +1,364 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Battle;
|
||||
using Core.Contract.Constants;
|
||||
using Core.Contract.Enums;
|
||||
using Core.DataReader.Dat;
|
||||
using Engine.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
// Compiles resource metadata once. It owns no scene objects and never observes the mutable editor draft.
|
||||
public sealed partial class BattleAnimationCatalog : IBattleCatalog, IBattleAbilityTimings, IBattleStageGeometry, IBattleMagicSwordTimings, IBattleDodgeTimings
|
||||
{
|
||||
#if PAL3
|
||||
private const double ActivePlaybackRate = 1.3f;
|
||||
#else
|
||||
private const double ActivePlaybackRate = 1.0;
|
||||
#endif
|
||||
|
||||
private sealed class ActorDefinition
|
||||
{
|
||||
public bool Main;
|
||||
public int Priority, Sp, Divisor = 1;
|
||||
public Vector3 Home;
|
||||
public readonly Dictionary<BattlePose, string> Clips = new();
|
||||
public Dictionary<BattlePose, int> Durations = new();
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, ActorDefinition> _actors = new(StringComparer.Ordinal);
|
||||
private readonly Dictionary<(string Source, string Target), BattleAttackPlan> _initialAttacks = new();
|
||||
private readonly Dictionary<(string, int, bool), (string Clip, AttackTiming Timing)> _abilities = new();
|
||||
private readonly Dictionary<string, BattleParticipant> _participants;
|
||||
private readonly BattleData _data;
|
||||
private readonly int _sceneElement;
|
||||
private readonly EffectLinkerFile _linkers;
|
||||
|
||||
public List<string> Diagnostics { get; } = new();
|
||||
|
||||
public BattleAnimationCatalog(BattleData data, BattleSetup setup, BattleDefinitions definitions = null)
|
||||
: this(data, setup, definitions, data.Read("basedata.cpk\\cbdata\\efflinker.dat", new EffectLinkerFileReader()))
|
||||
{
|
||||
}
|
||||
|
||||
private BattleAnimationCatalog(BattleData data, BattleSetup setup, BattleDefinitions definitions, EffectLinkerFile linkers)
|
||||
{
|
||||
_data = data;
|
||||
_linkers = linkers;
|
||||
BattleScenario scenario = setup.CreateInstance();
|
||||
_sceneElement = scenario.SceneElement;
|
||||
_participants = scenario.Participants.ToDictionary(actor => actor.InstanceId, StringComparer.Ordinal);
|
||||
foreach (BattleParticipant actor in scenario.Participants)
|
||||
{
|
||||
var info = data.Database.CombatActorInfos[actor.ActorId];
|
||||
bool main = info.Type == CombatActorType.MainActor;
|
||||
if (data.CombatRosterDenial(actor.ActorId, actor.Side) is string rosterDenial)
|
||||
throw new NotSupportedException(rosterDenial);
|
||||
int divisor = 1;
|
||||
if (main && (actor.Equipment.Length == 0 || actor.Equipment[0] == 0))
|
||||
throw new NotSupportedException($"Actor {actor.ActorId}: choose a compatible basic weapon before starting combat.");
|
||||
if (main && actor.Equipment.Length > 0 && actor.Equipment[0] != 0)
|
||||
{
|
||||
var weapon = data.Database.GameItemInfos[actor.Equipment[0]];
|
||||
PlayerActorId identity = (PlayerActorId)PhysicalIdentity(actor);
|
||||
if (weapon.Type != ItemType.Weapon || !BattleLoadoutRules.IsNativeDefaultWeapon(BattleData.Variant, actor) && !weapon.ApplicableActors.Contains(identity))
|
||||
throw new ArgumentException($"Actor {actor.ActorId}: slot 0 must contain a compatible weapon.");
|
||||
divisor = Math.Max(1, weapon.AttackHitCount);
|
||||
}
|
||||
var definition = new ActorDefinition
|
||||
{
|
||||
Main = main,
|
||||
Home = data.Position(actor, _sceneElement),
|
||||
Sp = Math.Max(0, info.SpImpactValue),
|
||||
Divisor = divisor,
|
||||
Priority = main ? PhysicalIdentity(actor) : (int)actor.Slot
|
||||
};
|
||||
_actors.Add(actor.InstanceId, definition);
|
||||
AddClip(BattlePose.Idle, data.IdleAction(actor));
|
||||
AddClip(BattlePose.Attacking, data.AttackAction(actor));
|
||||
AddClip(BattlePose.Moving, ActorConstants.ActionToNameMap[main ? ActorActionType.AttackMove : ActorActionType.NpcWalk]);
|
||||
AddClip(BattlePose.Hurt, ActorConstants.ActionToNameMap[main ? ActorActionType.BeAttack : ActorActionType.NpcBeAttacked]);
|
||||
if (main)
|
||||
{
|
||||
AddClip(BattlePose.Dodging, ActorConstants.ActionToNameMap[ActorActionType.Dodge]);
|
||||
AddClip(BattlePose.GuardEntry, ActorConstants.ActionToNameMap[ActorActionType.StartDefence]);
|
||||
AddClip(BattlePose.Guard, ActorConstants.ActionToNameMap[ActorActionType.Defence]);
|
||||
AddClip(BattlePose.Dead, ActorConstants.ActionToNameMap[ActorActionType.Dead]);
|
||||
AddClip(BattlePose.Fleeing, ActorConstants.ActionToNameMap[ActorActionType.Flee]);
|
||||
}
|
||||
else
|
||||
{
|
||||
definition.Clips[BattlePose.Dodging] = definition.Clips[BattlePose.Idle];
|
||||
definition.Durations[BattlePose.Dodging] = definition.Durations[BattlePose.Idle];
|
||||
definition.Clips[BattlePose.GuardEntry] = definition.Clips[BattlePose.Idle];
|
||||
definition.Durations[BattlePose.GuardEntry] = 1;
|
||||
definition.Clips[BattlePose.Guard] = definition.Clips[BattlePose.Idle];
|
||||
definition.Durations[BattlePose.Guard] = definition.Durations[BattlePose.Idle];
|
||||
}
|
||||
|
||||
void AddClip(BattlePose pose, string name)
|
||||
{
|
||||
definition.Clips[pose] = name;
|
||||
if (!data.TryActionPath(actor, name, out string path))
|
||||
{
|
||||
if (pose == BattlePose.Idle)
|
||||
throw new InvalidOperationException($"Actor {actor.ActorId}: missing initial animation {name}.");
|
||||
return;
|
||||
}
|
||||
BattleAnimationMetadata clip = data.GetAnimationMetadata(path);
|
||||
double rate = pose == BattlePose.Idle ? 0.65f : ActivePlaybackRate;
|
||||
definition.Durations[pose] = ToTicks(clip.TotalGameBoxTicks / (double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / rate);
|
||||
}
|
||||
}
|
||||
foreach (BattleParticipant source in scenario.Participants)
|
||||
foreach (BattleParticipant target in scenario.Participants.Where(target => target.InstanceId != source.InstanceId))
|
||||
InitialAttack(source.InstanceId, target.InstanceId);
|
||||
if (definitions != null)
|
||||
foreach (BattleParticipant actor in scenario.Participants)
|
||||
foreach (BattleAbilityDefinition ability in actor.Skills.Select(skill => definitions.Skills.GetValueOrDefault(skill.Id))
|
||||
.Concat(actor.MagicSword == null ? Array.Empty<BattleAbilityDefinition>() : new[] { definitions.Skills.GetValueOrDefault(actor.MagicSword.SkillId) })
|
||||
.Concat(scenario.Items.Select(item => definitions.Items.GetValueOrDefault(item.Id))).Where(ability => ability != null))
|
||||
try
|
||||
{
|
||||
Ability(actor.InstanceId, ability);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Diagnostics.Add($"Actor {actor.ActorId}, ability {ability.Id}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3 UnityPosition(BattleMovementPoint point) =>
|
||||
new(-point.X / UnityPrimitivesConvertor.GameBoxUnitToUnityUnit,
|
||||
point.Y / UnityPrimitivesConvertor.GameBoxUnitToUnityUnit,
|
||||
point.Z / UnityPrimitivesConvertor.GameBoxUnitToUnityUnit);
|
||||
|
||||
private static BattleMovementPoint NativePosition(Vector3 point) =>
|
||||
new(-point.x * UnityPrimitivesConvertor.GameBoxUnitToUnityUnit,
|
||||
point.y * UnityPrimitivesConvertor.GameBoxUnitToUnityUnit,
|
||||
point.z * UnityPrimitivesConvertor.GameBoxUnitToUnityUnit);
|
||||
|
||||
public BattleMovementPoint InitialHome(string actor) => NativePosition(_actors[actor].Home);
|
||||
|
||||
public BattleMovementPoint FormationHome(string actor, BattleSlot slot) =>
|
||||
NativePosition(_data.FormationPosition(_participants[actor].Side, slot, _sceneElement));
|
||||
|
||||
public BattleAttackPlan PlanAttack(string source, string target, BattleMovementPoint sourceHome, BattleMovementPoint targetHome)
|
||||
{
|
||||
return CompilePhysicalAttackPlan(source, target, sourceHome, targetHome);
|
||||
}
|
||||
|
||||
public IReadOnlyList<BattleMovementPlan> PlanFormationMove(string actor, BattleMovementPoint currentHome,
|
||||
BattleMovementPoint destination, bool passThroughMidpoint)
|
||||
{
|
||||
BattleParticipant participant = _participants[actor];
|
||||
int identity = Priority(actor);
|
||||
BattleMovementKind kind = identity == 2 ? BattleMovementKind.Teleport : BattleMovementKind.Run;
|
||||
#if PAL3
|
||||
if (identity is 1 or 3)
|
||||
kind = BattleMovementKind.Fly;
|
||||
#endif
|
||||
if (passThroughMidpoint)
|
||||
{
|
||||
if (BattleData.Variant != "PAL3" || identity is not (0 or 4))
|
||||
throw new ArgumentException("The original crossing route is limited to PAL3 identities 0 and 4.");
|
||||
float x = currentHome.X - destination.X;
|
||||
float z = currentHome.Z - destination.Z;
|
||||
float length = MathF.Sqrt(x * x + z * z);
|
||||
var normal = length < 0.005f ? new BattleMovementPoint(0, 1, 0) : new BattleMovementPoint(z / length, 0, -x / length);
|
||||
var midpoint = new BattleMovementPoint((currentHome.X + destination.X) / 2 + normal.X * 30,
|
||||
(currentHome.Y + destination.Y) / 2 + normal.Y * 30, (currentHome.Z + destination.Z) / 2 + normal.Z * 30);
|
||||
return Array.AsReadOnly(new[]
|
||||
{
|
||||
new BattleMovementPlan(BattleMovementKind.Run, currentHome, midpoint),
|
||||
new BattleMovementPlan(BattleMovementKind.Run, midpoint, destination)
|
||||
});
|
||||
}
|
||||
if (kind != BattleMovementKind.Fly)
|
||||
{
|
||||
if (kind == BattleMovementKind.Teleport)
|
||||
_data.ActionPath(participant, ActorConstants.ActionToNameMap[ActorActionType.PreAttack]);
|
||||
return Array.AsReadOnly(new[] { new BattleMovementPlan(kind, currentHome, destination) });
|
||||
}
|
||||
BattleAnimationMetadata clip = _data.GetAnimationMetadata(_data.ActionPath(participant, _actors[actor].Clips[BattlePose.Moving]));
|
||||
int? Marker(string name)
|
||||
{
|
||||
var markers = clip.AnimationEvents.Where(marker => marker.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
if (markers.Length == 0)
|
||||
return null;
|
||||
if (markers.Length != 1)
|
||||
throw new NotSupportedException("Formation movement needs one native " + name + " marker.");
|
||||
return Math.Max(0, checked((int)Math.Ceiling(markers[0].GameBoxTick /
|
||||
(double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / ActivePlaybackRate / BattleSession.StepSeconds)));
|
||||
}
|
||||
int? up = Marker("flyup"), down = Marker("flydown");
|
||||
int over = Marker("over") ?? ToTicks(clip.TotalGameBoxTicks / (double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / ActivePlaybackRate);
|
||||
if (!up.HasValue)
|
||||
throw new NotSupportedException("PAL3 flying formation movement has no verified flyup marker.");
|
||||
return Array.AsReadOnly(new[] { new BattleMovementPlan(kind, currentHome, destination,
|
||||
flyUpTick: up, flyDownTick: down, overTick: over) });
|
||||
}
|
||||
|
||||
public AttackTiming Attack(string source, string target) => InitialAttack(source, target).Timing;
|
||||
|
||||
private BattleAttackPlan InitialAttack(string source, string target)
|
||||
{
|
||||
if (!_initialAttacks.TryGetValue((source, target), out BattleAttackPlan plan))
|
||||
{
|
||||
plan = PlanAttack(source, target, InitialHome(source), InitialHome(target));
|
||||
_initialAttacks.Add((source, target), plan);
|
||||
}
|
||||
return plan;
|
||||
}
|
||||
|
||||
private void InvalidateInitialAttacks(string actor)
|
||||
{
|
||||
foreach (var key in _initialAttacks.Keys.Where(key => key.Source == actor || key.Target == actor).ToArray())
|
||||
_initialAttacks.Remove(key);
|
||||
}
|
||||
|
||||
public BattleMagicSwordStageProfile MagicSword(string actor, BattleAbilityDefinition ability)
|
||||
{
|
||||
if (BattleData.Variant != "PAL3" || ability.IsItem || ability.SkillTypeId != 4 ||
|
||||
!BattleMagicSwordRules.IsSupportedSkill(ability.Id) || _participants[actor].MagicSword?.SkillId != ability.Id ||
|
||||
_participants[actor].Equipment[0] != BattleMagicSwordRules.WeaponId)
|
||||
throw new NotSupportedException("A magic sword stage requires the captured PAL3 weapon skill.");
|
||||
if (!_linkers.SkillIdToEffectGroupMap.TryGetValue(ability.Id, out EffectGroupInfo[] groups) || groups.Length != 2)
|
||||
throw new NotSupportedException("The weapon skill has no verified original effect linker.");
|
||||
if (groups.Any(group => group.IsCenteredAroundCaster || group.IsCenteredAroundReceiver || group.IsCasterActor || group.IsReceiverActor))
|
||||
throw new NotSupportedException("The original weapon skill uses an unverified effect placement mode.");
|
||||
string clip = ActorConstants.ActionToNameMap[ActorActionType.WeaponSkill];
|
||||
BattleAnimationMetadata model = _data.GetAnimationMetadata(_data.ActionPath(_participants[actor], clip));
|
||||
int body = ToTicks(model.TotalGameBoxTicks / (double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / ActivePlaybackRate);
|
||||
return new BattleMagicSwordStageProfile(groups[0].EffGroupId, groups[1].EffGroupId,
|
||||
groups[0].WaitDurationInSeconds, groups[1].WaitDurationInSeconds, body,
|
||||
new BattleMovementPoint(groups[0].EffectGameBoxPosition.X, groups[0].EffectGameBoxPosition.Y, groups[0].EffectGameBoxPosition.Z),
|
||||
new BattleMovementPoint(groups[1].EffectGameBoxPosition.X, groups[1].EffectGameBoxPosition.Y, groups[1].EffectGameBoxPosition.Z));
|
||||
}
|
||||
|
||||
public AttackTiming Ability(string actor, BattleAbilityDefinition ability)
|
||||
{
|
||||
var key = (actor, ability.Id, ability.IsItem);
|
||||
if (_abilities.TryGetValue(key, out var cached))
|
||||
return cached.Timing;
|
||||
BattleParticipant participant = _participants[actor];
|
||||
if (!ability.IsItem && ability.SkillTypeId == 4)
|
||||
{
|
||||
BattleMagicSwordStageProfile profile = MagicSword(actor, ability);
|
||||
// Only the body duration is used. The dedicated stage waits for group 1 completion.
|
||||
var body = new AttackTiming(0, profile.BodyAnimationTicks, new[] { 0 }, bodyAnimationTicks: profile.BodyAnimationTicks);
|
||||
_abilities.Add(key, (ActorConstants.ActionToNameMap[ActorActionType.WeaponSkill], body));
|
||||
return body;
|
||||
}
|
||||
BattleAbilityStageProfile ordinary = AbilityStage(actor, ability);
|
||||
string clip = ordinary.RetainsBody ? null : ordinary.BodyAnimationTicks == 0 ? _data.IdleAction(participant) : AbilityClip(participant, ability);
|
||||
int preparation = ordinary.Kind == BattleAbilityStageKind.Item ? 1 : ordinary.Kind == BattleAbilityStageKind.Magic ? 2 : 3;
|
||||
int hit = Math.Max(0, checked((int)Math.Ceiling(ordinary.WorkSeconds / BattleSession.StepSeconds)));
|
||||
int end = Math.Max(1, Math.Max(hit, ordinary.BodyAnimationTicks));
|
||||
var timing = new AttackTiming(0, end, new[] { hit }, preparationTicks: preparation,
|
||||
bodyAnimationTicks: ordinary.BodyAnimationTicks, nativeWorkTimeSeconds: ordinary.WorkSeconds);
|
||||
_abilities.Add(key, (clip, timing));
|
||||
return timing;
|
||||
}
|
||||
|
||||
private string AbilityClip(BattleParticipant actor, BattleAbilityDefinition ability)
|
||||
{
|
||||
bool main = _actors[actor.InstanceId].Main;
|
||||
#if PAL3A
|
||||
if (main && !ability.IsItem && !ability.IsMagic && ability.Id == 4506)
|
||||
return "z171";
|
||||
#endif
|
||||
ActorActionType action;
|
||||
if (!main && !ability.IsItem)
|
||||
{
|
||||
uint[] skills = _data.Database.CombatActorInfos[actor.ActorId].SkillIds;
|
||||
action = skills.Length > 1 && skills[1] == ability.Id ? ActorActionType.NpcMagic2
|
||||
: skills.Length > 2 && skills[2] == ability.Id ? ActorActionType.NpcMagic3 : ActorActionType.NpcMagic1;
|
||||
}
|
||||
else if (ability.IsItem)
|
||||
{
|
||||
bool Recover(int attribute) => ability.ItemType == 1 && ability.Attributes.Any(effect => effect.Attribute == attribute &&
|
||||
(effect.Mode == BattleValueMode.RecoverToMax || effect.Mode is BattleValueMode.Absolute or BattleValueMode.Percentage && effect.Value > 0));
|
||||
bool recover = Recover(0);
|
||||
#if PAL3A
|
||||
recover |= Recover(2) || ability.ItemType == 1 && ability.States.Any(state => state.State is not (BattleState.Dying or BattleState.Death));
|
||||
#endif
|
||||
action = recover ? ActorActionType.UseItemRecover : ActorActionType.UseItemAttack;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if PAL3
|
||||
bool second = ability.Id == 4101;
|
||||
#else
|
||||
bool second = ability.Id == 4106;
|
||||
#endif
|
||||
action = ability.IsMagic ? ActorActionType.Magic : second ? ActorActionType.Skill2 : ActorActionType.Skill1;
|
||||
}
|
||||
return ActorConstants.ActionToNameMap[action];
|
||||
}
|
||||
|
||||
public string Clip(BattleActorSnapshot actor, BattleDefinitions definitions)
|
||||
{
|
||||
if (AbilityMovementClip(actor) is { } movingClip)
|
||||
return movingClip;
|
||||
if (actor.Pose == BattlePose.Repositioning && actor.Movement?.Finished == false)
|
||||
return actor.Movement.Plan.Kind == BattleMovementKind.Teleport
|
||||
? ActorConstants.ActionToNameMap[ActorActionType.PreAttack] : _actors[actor.Id].Clips[BattlePose.Moving];
|
||||
if (actor.Pose == BattlePose.Casting)
|
||||
{
|
||||
return ActorConstants.ActionToNameMap[_actors[actor.Id].Main ? ActorActionType.MagicWait : ActorActionType.NpcMagic1];
|
||||
}
|
||||
if (actor.Pose is BattlePose.UsingSkill or BattlePose.UsingItem)
|
||||
{
|
||||
var abilities = actor.CurrentAction == BattleAction.Item ? definitions.Items : definitions.Skills;
|
||||
BattleAbilityDefinition ability = abilities[actor.AbilityId];
|
||||
Ability(actor.Id, ability);
|
||||
return _abilities[(actor.Id, actor.AbilityId, ability.IsItem)].Clip;
|
||||
}
|
||||
return Clip(actor.Id, actor.Pose);
|
||||
}
|
||||
|
||||
private static int ToTicks(double seconds) => Math.Max(1, checked((int)Math.Ceiling(seconds / BattleSession.StepSeconds)));
|
||||
|
||||
public double PlaybackRate(BattleActorSnapshot actor) =>
|
||||
actor.Pose == BattlePose.Repositioning && actor.Movement?.Plan.Kind == BattleMovementKind.Teleport
|
||||
? 0.65f : PlaybackRate(actor.Id, actor.Pose);
|
||||
|
||||
public double PlaybackRate(string actor, BattlePose pose) => pose == BattlePose.Idle ||
|
||||
pose == BattlePose.Guard && !_actors[actor].Main ? 0.65f : ActivePlaybackRate;
|
||||
|
||||
public static bool IsBasicEnemy(BattleData data, int actorId)
|
||||
{
|
||||
if (!data.Database.CombatActorInfos.TryGetValue(actorId, out var actor) || actor.Type == CombatActorType.MainActor || actorId == 7366 ||
|
||||
!data.Database.SkillInfos.TryGetValue((int)actor.NormalAttackModeId, out var mode))
|
||||
return false;
|
||||
return mode.TargetRangeType is TargetRangeType.FirstPartySingle or TargetRangeType.EnemyPartySingle &&
|
||||
mode.CombatStateImpactTypes.Count == 0 && mode.SpecialSkillId == 0;
|
||||
}
|
||||
|
||||
public int GuardEntry(string actor) => _actors[actor].Durations.GetValueOrDefault(BattlePose.GuardEntry, 1);
|
||||
|
||||
public int Dodge(string actor) => _actors[actor].Durations.GetValueOrDefault(BattlePose.Dodging, 1);
|
||||
|
||||
public int Hurt(string actor) => _actors[actor].Durations.GetValueOrDefault(BattlePose.Hurt, 1);
|
||||
|
||||
public int SpImpact(string actor) => _actors[actor].Sp;
|
||||
|
||||
public int Priority(string actor) => _actors[actor].Priority;
|
||||
|
||||
public int DamageDivisor(string actor) => _actors[actor].Divisor;
|
||||
|
||||
public Vector3 Approach(string source, string target) => UnityPosition(InitialAttack(source, target).Approach);
|
||||
|
||||
public string Clip(string actor, BattlePose pose) => _actors[actor].Clips.GetValueOrDefault(pose == BattlePose.Returning ? BattlePose.Moving : pose);
|
||||
|
||||
public int Duration(string actor, BattlePose pose) => _actors[actor].Durations.GetValueOrDefault(pose);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e648b09101b41bd9822b8a036ded99d
|
||||
@@ -0,0 +1,20 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using Battle;
|
||||
|
||||
public sealed partial class BattleAnimationCatalog : IBattleBodyAudioCatalog
|
||||
{
|
||||
public BattleBodySoundProfile BodySounds(string actor)
|
||||
{
|
||||
var participant = _participants[actor];
|
||||
var properties = _data.Database.CombatActorInfos[participant.ActorId].Properties;
|
||||
return new BattleBodySoundProfile(properties?.Length > 0 ? (int)properties[0] : 0,
|
||||
properties?.Length > 1 ? (int)properties[1] : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60e30ddc314f4b75a413a93e7f7ed077
|
||||
@@ -0,0 +1,43 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Pal3.Battle;
|
||||
using Pal3.Core.DataReader.Dat;
|
||||
|
||||
public sealed partial class BattleAnimationCatalog : IBattleCoAttackTimings
|
||||
{
|
||||
private readonly Dictionary<int, BattleComboStageProfile> _coAttacks = new();
|
||||
|
||||
public BattleMovementPoint CoAttackHome(string actor, BattleSlot slot) =>
|
||||
NativePosition(_data.FormationPosition(_participants[actor].Side, slot, 0));
|
||||
|
||||
public BattleComboStageProfile CoAttack(string actor, BattleComboDefinition combo)
|
||||
{
|
||||
if (combo == null || !_participants.ContainsKey(actor))
|
||||
throw new ArgumentException("The original combo needs a captured source actor and definition.");
|
||||
if (_coAttacks.TryGetValue(combo.Id, out BattleComboStageProfile cached))
|
||||
return cached;
|
||||
if (!_linkers.SkillIdToEffectGroupMap.TryGetValue(combo.Id, out EffectGroupInfo[] groups) || groups.Length != 2)
|
||||
throw new NotSupportedException($"Combo {combo.Id} has no original two-group effect linker.");
|
||||
// All shipped combo linkers place their groups in scene coordinates.
|
||||
// Reject unsupported authored placements before the source gauge changes.
|
||||
if (groups.Any(group => group.IsCenteredAroundCaster || group.IsCenteredAroundReceiver || group.IsCasterActor || group.IsReceiverActor))
|
||||
throw new NotSupportedException($"Combo {combo.Id} has an unverified actor-relative effect placement.");
|
||||
var enemyCenter = NativePosition(_data.FormationPosition(BattleSide.Enemy, BattleSlot.Center, 0));
|
||||
static BattleMovementPoint Origin(EffectGroupInfo group) =>
|
||||
new(group.EffectGameBoxPosition.X, group.EffectGameBoxPosition.Y, group.EffectGameBoxPosition.Z);
|
||||
var profile = new BattleComboStageProfile(groups[0].EffGroupId, groups[1].EffGroupId,
|
||||
groups[0].WaitDurationInSeconds, groups[1].WaitDurationInSeconds, groups[0].WorkTimeInSeconds,
|
||||
Origin(groups[0]), Origin(groups[1]), enemyCenter);
|
||||
_coAttacks.Add(combo.Id, profile);
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e349a4299ec847789c4c32d7bfe6452e
|
||||
@@ -0,0 +1,66 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Battle;
|
||||
using Engine.Extensions;
|
||||
|
||||
public sealed partial class BattleAnimationCatalog : IBattleElementWheelTimings
|
||||
{
|
||||
private readonly Dictionary<(string Actor, string Model, int Skill), BattleAbilityStageProfile> _elementWheelStages = new();
|
||||
private readonly Dictionary<(string Actor, string Model, int Skill), AttackTiming> _elementWheelTimings = new();
|
||||
private readonly Dictionary<(string Actor, string Model, int Skill), BattlePhysicalAnimation> _elementWheelBodies = new();
|
||||
|
||||
public BattleAbilityStageProfile ElementWheelStage(string actor, BattleAbilityDefinition ability)
|
||||
{
|
||||
if (BattleData.Variant != "PAL3A" || ability == null || ability.Id is < 264 or > 268 ||
|
||||
!_participants.TryGetValue(actor, out BattleParticipant participant) || PhysicalIdentity(participant) != 0)
|
||||
throw new ArgumentException("The original element wheel requires Nangong Huang and its field skill.");
|
||||
var key = (actor, _data.Model(participant), ability.Id);
|
||||
if (_elementWheelStages.TryGetValue(key, out BattleAbilityStageProfile captured))
|
||||
return captured;
|
||||
if (!_linkers.SkillIdToEffectGroupMap.TryGetValue(ability.Id, out var groups) || groups.Length != 2)
|
||||
throw new NotSupportedException("The element wheel needs its two original linker groups.");
|
||||
int bodyTicks = 0;
|
||||
bool retainedBody = !_data.TryActionPath(participant, "z24", out string path);
|
||||
if (!retainedBody)
|
||||
{
|
||||
BattleAnimationMetadata body = _data.GetAnimationMetadata(path);
|
||||
bodyTicks = ToTicks(body.TotalGameBoxTicks / (double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / ActivePlaybackRate);
|
||||
}
|
||||
captured = new BattleAbilityStageProfile(BattleAbilityStageKind.ElementWheel, CaptureAbilityBinding(groups[0]), CaptureAbilityBinding(groups[1]),
|
||||
groups[0].WorkTimeInSeconds, BattleAbilityWorkBoundary.WorkTime, bodyTicks, false, retainsBody: retainedBody);
|
||||
_elementWheelStages.Add(key, captured);
|
||||
return captured;
|
||||
}
|
||||
|
||||
public AttackTiming ElementWheel(string actor, BattleAbilityDefinition ability)
|
||||
{
|
||||
BattleAbilityStageProfile profile = ElementWheelStage(actor, ability);
|
||||
var key = (actor, _data.Model(_participants[actor]), ability.Id);
|
||||
if (_elementWheelTimings.TryGetValue(key, out AttackTiming captured))
|
||||
return captured;
|
||||
int hit = Math.Max(0, checked((int)Math.Ceiling(profile.WorkSeconds / BattleSession.StepSeconds)));
|
||||
captured = new AttackTiming(0, Math.Max(1, Math.Max(hit, profile.BodyAnimationTicks)), new[] { hit },
|
||||
bodyAnimationTicks: profile.BodyAnimationTicks, nativeWorkTimeSeconds: profile.WorkSeconds);
|
||||
_elementWheelTimings.Add(key, captured);
|
||||
return captured;
|
||||
}
|
||||
|
||||
public BattlePhysicalAnimation ElementWheelBody(string actor, BattleAbilityDefinition ability)
|
||||
{
|
||||
BattleAbilityStageProfile profile = ElementWheelStage(actor, ability);
|
||||
var key = (actor, _data.Model(_participants[actor]), ability.Id);
|
||||
if (_elementWheelBodies.TryGetValue(key, out BattlePhysicalAnimation captured))
|
||||
return captured;
|
||||
captured = profile.RetainsBody ? null : CompilePhysicalAnimation(_participants[actor], "z24");
|
||||
_elementWheelBodies.Add(key, captured);
|
||||
return captured;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05bb74ccb4f04d1da86102b3d436f750
|
||||
@@ -0,0 +1,106 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Battle;
|
||||
|
||||
public sealed partial class BattleAnimationCatalog : IBattleMonsterFactory
|
||||
{
|
||||
private readonly ConditionalWeakTable<BattleMonsterCreation, BattleAnimationCatalog> _preparedMonsters = new();
|
||||
|
||||
public BattleMonsterCreation Prepare(int nativeIndex, int actorId, string instanceId)
|
||||
{
|
||||
if (nativeIndex < 5 || nativeIndex > 10 || string.IsNullOrWhiteSpace(instanceId))
|
||||
throw new ArgumentException("A native enemy slot and stable instance ID are required.");
|
||||
BattleParticipant participant = _data.CreateParticipant(actorId, BattleSide.Enemy, (BattleSlot)(nativeIndex - 5));
|
||||
participant.InstanceId = instanceId;
|
||||
participant.Statuses.Clear();
|
||||
BattleActorDefinition original = BattleDefinitionCompiler.Actor(_data, participant, BattleData.Variant);
|
||||
// Released CreateMonster zeroes the role and installs poison
|
||||
// immunity only; it does not replay LoadRoleData's initial states.
|
||||
var definition = new BattleActorDefinition(new BattleActorData
|
||||
{
|
||||
InstanceId = instanceId,
|
||||
Identity = original.Identity,
|
||||
Boss = original.Boss,
|
||||
Equipment = original.Equipment.ToArray(),
|
||||
ImmuneStates = original.ImmuneStates.ToArray(),
|
||||
PermanentStates = original.PermanentStates.Where(state => state == BattleState.PoisonResist).ToArray(),
|
||||
PhysicalAttackElements = original.PhysicalAttackElements,
|
||||
PhysicalDefenseElements = original.PhysicalDefenseElements,
|
||||
PhysicalAttackElementValues = original.PhysicalAttackElementValues.ToArray(),
|
||||
PhysicalDefenseElementValues = original.PhysicalDefenseElementValues.ToArray(),
|
||||
NormalAttackMode = original.NormalAttackMode,
|
||||
NormalAttackRange = original.NormalAttackRange,
|
||||
ExperienceReward = original.ExperienceReward,
|
||||
MoneyReward = original.MoneyReward,
|
||||
LootItem = original.LootItem,
|
||||
LootCount = original.LootCount,
|
||||
CorpseItem = original.CorpseItem,
|
||||
CorpseSkill = original.CorpseSkill,
|
||||
CorpsePercent = original.CorpsePercent,
|
||||
EscapePercent = original.EscapePercent,
|
||||
StealableMoney = original.StealableMoney,
|
||||
StealableItemId = original.StealableItemId,
|
||||
StealableItemCount = original.StealableItemCount,
|
||||
GrowthUnsupportedReason = original.GrowthUnsupportedReason,
|
||||
UnsupportedReason = original.UnsupportedReason,
|
||||
});
|
||||
var creation = new BattleMonsterCreation(nativeIndex, participant, definition);
|
||||
var scenario = new BattleScenario
|
||||
{
|
||||
Variant = BattleData.Variant,
|
||||
DataFingerprint = _data.Fingerprint,
|
||||
Scene = "prepared-native-monster",
|
||||
SceneElement = _sceneElement,
|
||||
Participants = _participants.Values.Where(actor => actor.InstanceId != instanceId).Select(actor => actor.Copy()).ToList()
|
||||
};
|
||||
scenario.Participants.Add(participant);
|
||||
var setup = new BattleSetup(scenario);
|
||||
BattleDefinitions definitions = BattleDefinitionCompiler.Build(_data, setup);
|
||||
var prepared = new BattleAnimationCatalog(_data, setup, definitions, _linkers);
|
||||
// Force both movement/body and ability metadata to be captured
|
||||
// before a live slot is changed or any source action is cancelled.
|
||||
_ = prepared.Physical(instanceId);
|
||||
foreach (BattleSkill skill in participant.Skills)
|
||||
if (definitions.Skills.TryGetValue(skill.Id, out BattleAbilityDefinition ability) && ability.SkillTypeId != 4 &&
|
||||
string.IsNullOrEmpty(ability.UnsupportedReason) && skill.Id != (BattleData.Variant == "PAL3" ? 7711 : 7714))
|
||||
{
|
||||
_ = prepared.Ability(instanceId, ability);
|
||||
_ = prepared.AbilityStage(instanceId, ability);
|
||||
}
|
||||
_preparedMonsters.Add(creation, prepared);
|
||||
return creation;
|
||||
}
|
||||
|
||||
public void Commit(BattleMonsterCreation creation)
|
||||
{
|
||||
if (creation == null || !_preparedMonsters.TryGetValue(creation, out BattleAnimationCatalog prepared))
|
||||
throw new ArgumentException("The monster was not prepared by this catalog.", nameof(creation));
|
||||
_preparedMonsters.Remove(creation);
|
||||
string instanceId = creation.Participant.InstanceId;
|
||||
_participants[instanceId] = prepared._participants[instanceId];
|
||||
_actors[instanceId] = prepared._actors[instanceId];
|
||||
_physicalProfiles[instanceId] = prepared._physicalProfiles[instanceId];
|
||||
foreach (var key in _abilities.Keys.Where(key => key.Item1 == instanceId).ToArray())
|
||||
_abilities.Remove(key);
|
||||
foreach (var key in _abilityStages.Keys.Where(key => key.Item1 == instanceId).ToArray())
|
||||
_abilityStages.Remove(key);
|
||||
foreach (var pair in prepared._abilities.Where(pair => pair.Key.Item1 == instanceId))
|
||||
_abilities[pair.Key] = pair.Value;
|
||||
foreach (var pair in prepared._abilityStages.Where(pair => pair.Key.Item1 == instanceId))
|
||||
_abilityStages[pair.Key] = pair.Value;
|
||||
InvalidateInitialAttacks(instanceId);
|
||||
foreach (var pair in prepared._initialAttacks.Where(pair => pair.Key.Source == instanceId || pair.Key.Target == instanceId))
|
||||
_initialAttacks.Add(pair.Key, pair.Value);
|
||||
Diagnostics.AddRange(prepared.Diagnostics);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 013fde954ab74e0bb75dd861994b9dde
|
||||
@@ -0,0 +1,72 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Battle;
|
||||
using Core.Contract.Constants;
|
||||
using Core.Contract.Enums;
|
||||
using Engine.Extensions;
|
||||
|
||||
public sealed partial class BattleAnimationCatalog : IBattlePal3AFormCatalog
|
||||
{
|
||||
private readonly Dictionary<string, string> _pal3AOriginalModels = new(StringComparer.Ordinal);
|
||||
private readonly Dictionary<(string Actor, bool Transformed), BattlePhysicalAnimation> _pal3AFormClips = new();
|
||||
|
||||
public BattlePhysicalAnimation FormChangeAnimation(string actorId, bool transformed)
|
||||
{
|
||||
if (BattleData.Variant != "PAL3A" || !_participants.TryGetValue(actorId, out BattleParticipant actor) ||
|
||||
actor.ActorId is not (101 or 103))
|
||||
throw new ArgumentException("This actor has no original PAL3A hero form.", nameof(actorId));
|
||||
if (_pal3AFormClips.TryGetValue((actorId, transformed), out BattlePhysicalAnimation captured))
|
||||
return captured;
|
||||
if (!_pal3AOriginalModels.ContainsKey(actorId))
|
||||
_pal3AOriginalModels.Add(actorId, _data.Model(actor));
|
||||
BattleParticipant candidate = actor.Copy();
|
||||
candidate.Model = transformed ? actor.ActorId == 101 ? "107" : "106" : _pal3AOriginalModels[actorId];
|
||||
captured = CompilePhysicalAnimation(candidate, "z20");
|
||||
_pal3AFormClips.Add((actorId, transformed), captured);
|
||||
return captured;
|
||||
}
|
||||
|
||||
public void ActivatePal3AForm(string actorId, BattlePal3AFormKind kind)
|
||||
{
|
||||
if (BattleData.Variant != "PAL3A" || !_participants.TryGetValue(actorId, out BattleParticipant actor))
|
||||
throw new ArgumentException("The original PAL3A form actor is missing.", nameof(actorId));
|
||||
if (!_pal3AOriginalModels.ContainsKey(actorId))
|
||||
_pal3AOriginalModels.Add(actorId, _data.Model(actor));
|
||||
// Only this session's selected model changes. Every compiled clip and
|
||||
// physical profile remains immutable and no live Unity object enters it.
|
||||
BattleParticipant candidate = actor.Copy();
|
||||
candidate.Model = kind switch
|
||||
{
|
||||
BattlePal3AFormKind.NangongFireBeast when actor.ActorId == 101 => "107",
|
||||
BattlePal3AFormKind.PengxuFairyBeast when actor.ActorId == 103 => "106",
|
||||
BattlePal3AFormKind.Human => _pal3AOriginalModels[actorId],
|
||||
_ => throw new ArgumentException("The selected form belongs to another hero.", nameof(kind))
|
||||
};
|
||||
ActorDefinition definition = _actors[actorId];
|
||||
var durations = new Dictionary<BattlePose, int>();
|
||||
foreach (var pair in definition.Clips)
|
||||
if (_data.TryActionPath(candidate, pair.Value, out string path))
|
||||
{
|
||||
BattleAnimationMetadata clip = _data.GetAnimationMetadata(path);
|
||||
double rate = pair.Key == BattlePose.Idle ? .65f : ActivePlaybackRate;
|
||||
durations[pair.Key] = ToTicks(clip.TotalGameBoxTicks / (double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / rate);
|
||||
}
|
||||
actor.Model = candidate.Model;
|
||||
definition.Durations = durations;
|
||||
_physicalProfiles.Remove(actorId);
|
||||
InvalidateInitialAttacks(actorId);
|
||||
foreach (var key in _abilities.Keys.Where(key => key.Item1 == actorId).ToArray())
|
||||
_abilities.Remove(key);
|
||||
foreach (var key in _abilityStages.Keys.Where(key => key.Item1 == actorId).ToArray())
|
||||
_abilityStages.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebd344f22fbf4095a1abf041660da603
|
||||
@@ -0,0 +1,108 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Battle;
|
||||
using Core.Contract.Constants;
|
||||
using Core.Contract.Enums;
|
||||
using Core.DataReader.Mv3;
|
||||
using Engine.Extensions;
|
||||
|
||||
public sealed partial class BattleAnimationCatalog : IBattlePhysicalTimings
|
||||
{
|
||||
private readonly Dictionary<string, BattlePhysicalStageProfile> _physicalProfiles = new(StringComparer.Ordinal);
|
||||
|
||||
private static int PhysicalIdentity(BattleParticipant actor) => actor.Side == BattleSide.Enemy ? -1 : BattleData.PlayerIdentity(actor.ActorId);
|
||||
|
||||
public BattlePhysicalStageProfile Physical(string actor)
|
||||
{
|
||||
if (_physicalProfiles.TryGetValue(actor, out BattlePhysicalStageProfile cached))
|
||||
return cached;
|
||||
BattleParticipant participant = _participants[actor];
|
||||
int identity = PhysicalIdentity(participant);
|
||||
int weapon = 0, count = 1;
|
||||
if (identity >= 0 && participant.Equipment.Length > 0 && participant.Equipment[0] != 0)
|
||||
{
|
||||
var item = _data.Database.GameItemInfos[participant.Equipment[0]];
|
||||
weapon = (int)item.WeaponType;
|
||||
count = item.AttackHitCount;
|
||||
}
|
||||
var animations = new Dictionary<BattlePose, BattlePhysicalAnimation>();
|
||||
foreach (var pair in _actors[actor].Clips)
|
||||
animations[pair.Key] = CompilePhysicalAnimation(participant, pair.Value);
|
||||
if (participant.Side == BattleSide.Ally)
|
||||
{
|
||||
animations[BattlePose.Dying] = CompilePhysicalAnimation(participant, ActorConstants.ActionToNameMap[ActorActionType.Dying]);
|
||||
animations[BattlePose.Sleeping] = CompilePhysicalAnimation(participant, ActorConstants.ActionToNameMap[ActorActionType.Freeze]);
|
||||
animations[BattlePose.GuardHurt] = CompilePhysicalAnimation(participant, ActorConstants.ActionToNameMap[ActorActionType.DefenceBeAttack]);
|
||||
}
|
||||
animations[BattlePose.Casting] = CompilePhysicalAnimation(participant, ActorConstants.ActionToNameMap[participant.Side == BattleSide.Ally ? ActorActionType.MagicWait : ActorActionType.NpcMagic1]);
|
||||
animations[BattlePose.Attacking] = CompilePhysicalAnimation(participant, _data.AttackAction(participant));
|
||||
var profile = new BattlePhysicalStageProfile(BattleData.Variant, participant.ActorId, identity, weapon, count, animations, thrownStart: BattleData.Variant == "PAL3A" ? CompilePhysicalAnimation(participant, "z021") : null,
|
||||
thrownReturn: BattleData.Variant == "PAL3A" ? CompilePhysicalAnimation(participant, "z022") : null);
|
||||
_physicalProfiles.Add(actor, profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
private BattlePhysicalAnimation CompilePhysicalAnimation(BattleParticipant actor, string clipName)
|
||||
{
|
||||
if (!_data.TryActionPath(actor, clipName, out string path))
|
||||
return null;
|
||||
BattleAnimationMetadata clip = _data.GetAnimationMetadata(path);
|
||||
if (!clip.HasBounds)
|
||||
throw new NotSupportedException($"Actor {actor.ActorId}, clip {clipName}: original collision bounds are missing.");
|
||||
float minimum = clip.MinimumZ;
|
||||
float maximum = clip.MaximumZ;
|
||||
var markers = new List<BattlePhysicalMarker>();
|
||||
foreach (Mv3AnimationEvent marker in clip.AnimationEvents)
|
||||
{
|
||||
int tick = Math.Max(0, checked((int)Math.Ceiling(marker.GameBoxTick /
|
||||
(double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / ActivePlaybackRate / BattleSession.StepSeconds)));
|
||||
markers.Add(new BattlePhysicalMarker(tick, PhysicalMarkerKind(marker.Name), marker.GameBoxTick, marker.Name));
|
||||
}
|
||||
int duration = ToTicks(clip.TotalGameBoxTicks / (double)UnityPrimitivesConvertor.GameBoxTicksPerSecond / ActivePlaybackRate);
|
||||
return new BattlePhysicalAnimation(clipName, duration, (maximum - minimum) / 2f, markers, clip.TotalGameBoxTicks);
|
||||
}
|
||||
|
||||
private static BattlePhysicalMarkerKind PhysicalMarkerKind(string name) => name.ToLowerInvariant() switch
|
||||
{
|
||||
"work" => BattlePhysicalMarkerKind.Work,
|
||||
"work1" => BattlePhysicalMarkerKind.Work1,
|
||||
"work2" => BattlePhysicalMarkerKind.Work2,
|
||||
"work3" => BattlePhysicalMarkerKind.Work3,
|
||||
"over" => BattlePhysicalMarkerKind.Over,
|
||||
"flyup" or "sjump" => BattlePhysicalMarkerKind.FlyUp,
|
||||
"flydown" or "ejump" => BattlePhysicalMarkerKind.FlyDown,
|
||||
"start" => BattlePhysicalMarkerKind.Start,
|
||||
"catched" => BattlePhysicalMarkerKind.Catched,
|
||||
"throwed" => BattlePhysicalMarkerKind.Throwed,
|
||||
_ => BattlePhysicalMarkerKind.Other
|
||||
};
|
||||
|
||||
private BattleAttackPlan CompilePhysicalAttackPlan(string source, string target, BattleMovementPoint sourceHome, BattleMovementPoint targetHome)
|
||||
{
|
||||
BattlePhysicalStageProfile profile = Physical(source);
|
||||
BattlePhysicalAnimation animation = profile.Animation(BattlePose.Attacking);
|
||||
int[] work = (animation?.Markers ?? Array.Empty<BattlePhysicalMarker>()).Where(marker => marker.Kind <= (BattleData.Variant == "PAL3A" ? BattlePhysicalMarkerKind.Work3 : BattlePhysicalMarkerKind.Work1))
|
||||
.Select(marker => marker.Tick).ToArray();
|
||||
// Travel is a native body task, not a precomputed linear duration. This
|
||||
// compatibility timeline exposes only the clip's real work messages.
|
||||
var timing = new AttackTiming(0, Math.Max(animation?.DurationTicks ?? 1, work.DefaultIfEmpty(0).Max()), work, allowEmptyHits: true);
|
||||
var direction = BattleMovement.NormalizeDirection(new BattleMovementPoint(sourceHome.X - targetHome.X,
|
||||
sourceHome.Y - targetHome.Y, sourceHome.Z - targetHome.Z));
|
||||
float distance = profile.Radius(BattlePose.Idle) + Physical(target).Radius(BattlePose.Idle);
|
||||
if (profile.ResourceId is 7364 or 7381)
|
||||
distance *= 2;
|
||||
bool stationary = profile.Approach().Count == 1 && profile.Approach()[0] == BattlePhysicalBodyKind.TurnToRole || profile.UsesThrownWeapon;
|
||||
var approach = stationary ? sourceHome : new BattleMovementPoint(targetHome.X + direction.X * distance,
|
||||
targetHome.Y + direction.Y * distance, targetHome.Z + direction.Z * distance);
|
||||
return new BattleAttackPlan(timing, sourceHome, approach, targetHome);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a68a93c9c1894bc282dca11b7e4e667a
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f2fe36b7f174d9db12dc2cfc84239de
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Core.DataReader.Mv3;
|
||||
|
||||
// Catalogs need timing, markers and source collision bounds, not the
|
||||
// expanded rendering geometry or regenerated normals of every keyframe.
|
||||
public sealed class BattleAnimationMetadata
|
||||
{
|
||||
public uint TotalGameBoxTicks
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public IReadOnlyList<Mv3AnimationEvent> AnimationEvents
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public bool HasBounds
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public float MinimumZ
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public float MaximumZ
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public BattleAnimationMetadata(Mv3File source)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
TotalGameBoxTicks = source.TotalGameBoxTicks;
|
||||
AnimationEvents = Array.AsReadOnly(source.AnimationEvents.ToArray());
|
||||
HasBounds = source.Meshes.Length > 0;
|
||||
if (HasBounds)
|
||||
{
|
||||
MinimumZ = source.Meshes.Min(mesh => mesh.GameBoxBoundsMin.Z);
|
||||
MaximumZ = source.Meshes.Max(mesh => mesh.GameBoxBoundsMax.Z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cb112473f844644acda2ba7f0ac62c7
|
||||
@@ -0,0 +1,39 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.BattleEditor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Core.DataReader.Mv3;
|
||||
|
||||
public sealed partial class BattleData
|
||||
{
|
||||
private readonly Dictionary<string, BattleAnimationMetadata> _animationMetadata = new(StringComparer.OrdinalIgnoreCase);
|
||||
private bool _animationMetadataDisposed;
|
||||
|
||||
public BattleAnimationMetadata GetAnimationMetadata(string path)
|
||||
{
|
||||
if (_animationMetadataDisposed)
|
||||
throw new ObjectDisposedException(nameof(BattleData));
|
||||
var entry = Resources.Find(path) ?? throw new FileNotFoundException("Missing battle animation: " + path);
|
||||
if (_animationMetadata.TryGetValue(entry.Path, out BattleAnimationMetadata metadata))
|
||||
return metadata;
|
||||
// Keep full reader validation on the first read. Only the small
|
||||
// immutable projection survives in this data owner's cache.
|
||||
Mv3File model = Read(entry.Path, new Mv3FileReader());
|
||||
metadata = new BattleAnimationMetadata(model);
|
||||
_animationMetadata.Add(entry.Path, metadata);
|
||||
return metadata;
|
||||
}
|
||||
|
||||
private void DisposeAnimationMetadata()
|
||||
{
|
||||
_animationMetadataDisposed = true;
|
||||
_animationMetadata.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 1637 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user