mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-27 09:58:06 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5944c664f1 | ||
|
|
72f77ff1a7 | ||
|
|
41efbdce8e | ||
|
|
d751d5ea2a | ||
|
|
12ef307fe6 | ||
|
|
bc672d6179 | ||
|
|
fbadf6766e | ||
|
|
41502ddefb | ||
|
|
61ca35b1b8 | ||
|
|
cbb4d5e575 | ||
|
|
b37ac428d2 | ||
|
|
f9d17a9896 | ||
|
|
65d4fefd6f | ||
|
|
5e746c7922 | ||
|
|
3c31cb1787 | ||
|
|
b0ea2f8638 | ||
|
|
e38ffc9a40 | ||
|
|
96e2d151f9 | ||
|
|
23fa70496b | ||
|
|
b3f67d3683 | ||
|
|
84e44d7eec | ||
|
|
661d2ce1c0 | ||
|
|
be695cc353 | ||
|
|
6aa8da32ea | ||
|
|
2de4bce9e1 | ||
|
|
56ec4d81ad | ||
|
|
261ad74a74 | ||
|
|
654ade106e | ||
|
|
15970562d7 | ||
|
|
c3fe8198d4 | ||
|
|
593e915dcd | ||
|
|
6d6f195aad | ||
|
|
17814972f4 | ||
|
|
a898c69b79 | ||
|
|
4d473bf69b | ||
|
|
9eb091ead6 | ||
|
|
49f25b255e | ||
|
|
820c3f1795 | ||
|
|
dac1505886 | ||
|
|
2f12c317c4 | ||
|
|
421aeb4c3f | ||
|
|
7dfdd4396f | ||
|
|
4cf4890693 | ||
|
|
dbeef96411 | ||
|
|
c47f5b8edb | ||
|
|
173c95c70d | ||
|
|
993b5e7653 | ||
|
|
bbeca7a6c6 | ||
|
|
845f7e8fd5 | ||
|
|
f2fe362d53 | ||
|
|
53efd23d0f | ||
|
|
8730c457c2 | ||
|
|
1e2e080657 | ||
|
|
a14be2670b | ||
|
|
766fe2c430 | ||
|
|
f7c0aa8e71 | ||
|
|
18563a5063 | ||
|
|
5a12990ce1 | ||
|
|
4c31d56b78 | ||
|
|
9de0e3f9cb | ||
|
|
8ff5685ed8 | ||
|
|
4ac04f9e06 | ||
|
|
f7c993ef22 | ||
|
|
ba68240d77 | ||
|
|
76f1b1f551 | ||
|
|
dc8b9f6423 | ||
|
|
94b26e15c3 | ||
|
|
7ff9146b5e | ||
|
|
2e5421146b | ||
|
|
780041ec27 | ||
|
|
8d13753246 | ||
|
|
1a865a32c0 | ||
|
|
59d7af002b | ||
|
|
9d62fc637a | ||
|
|
da132bdf91 | ||
|
|
0ca80340bc | ||
|
|
93228511c3 | ||
|
|
63b5ca8393 | ||
|
|
9003dbe3fc | ||
|
|
d8181e8dd8 | ||
|
|
60519b39ef | ||
|
|
23d3809cb7 | ||
|
|
6622b3737c | ||
|
|
e00eb972a2 | ||
|
|
e71a244ca6 | ||
|
|
3b6730b60a | ||
|
|
97272bbf0f | ||
|
|
4a68472423 | ||
|
|
51a5163fc1 | ||
|
|
fd3e89c23b | ||
|
|
170a78a0bf | ||
|
|
5b69fd1c7f | ||
|
|
be861dc536 | ||
|
|
6dfff9ff57 | ||
|
|
cbe4f82489 | ||
|
|
01a41fa834 | ||
|
|
cb821a0901 | ||
|
|
4b36a38b21 | ||
|
|
17ebee5b28 | ||
|
|
f0e1b2db98 | ||
|
|
23673aae2a | ||
|
|
ca3b28a089 | ||
|
|
45b5971ede | ||
|
|
ad97b6a817 | ||
|
|
c92716f3e5 | ||
|
|
7538ebe506 | ||
|
|
1c5623ad7d | ||
|
|
eda6c9a1bf | ||
|
|
fc4aec4e4d | ||
|
|
84355c168f | ||
|
|
809e55de82 | ||
|
|
7d606ab1f6 | ||
|
|
14b006dc87 | ||
|
|
840de611dd | ||
|
|
67209cb26e | ||
|
|
caf8c9cf3c | ||
|
|
7746523600 | ||
|
|
44c1424072 | ||
|
|
ba4d258939 | ||
|
|
5e89df5e60 | ||
|
|
8b0a6caa14 | ||
|
|
0fd5217fb8 | ||
|
|
33afb8c794 | ||
|
|
3b62ced28c | ||
|
|
a7edeeb319 | ||
|
|
57e102524a | ||
|
|
cad2ab4d59 | ||
|
|
4e7f0c2e93 | ||
|
|
a8b73c2060 | ||
|
|
db88fcdb9c | ||
|
|
7f81ed8c44 | ||
|
|
52fbf4e704 | ||
|
|
b5403823c8 | ||
|
|
2731f81c09 | ||
|
|
7f651a8b44 | ||
|
|
206dcf9e1d | ||
|
|
5bfba92940 | ||
|
|
f173fb665b | ||
|
|
ffbadeec5e | ||
|
|
7c34cd743a | ||
|
|
64c1fef3bb | ||
|
|
f45927fd9a | ||
|
|
5fa165914c | ||
|
|
9ef0365414 | ||
|
|
c50ae9fbe8 | ||
|
|
4de7b57852 | ||
|
|
f1f1b37716 | ||
|
|
b88c7d5d10 | ||
|
|
4b78cd4726 |
No files matched your search
+14
@@ -70,3 +70,17 @@ 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/
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b0b27c9e5e4d2e4fbc9b6584f828f7b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File renamed without changes.
@@ -0,0 +1,54 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
reference: https://www.shadertoy.com/view/MsKXDh
|
||||
*/
|
||||
|
||||
Shader "Pal3/PostEffectDistortion"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_TimeScale ("Time Scale",float) = 4.0
|
||||
_XFactor ("X Factor",float) = 15.0
|
||||
_YFactor("Y Factor",float) = 10.0
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
|
||||
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
|
||||
|
||||
float _TimeScale;
|
||||
float _XFactor;
|
||||
float _YFactor;
|
||||
|
||||
float4 Frag(VaryingsDefault i) : SV_Target
|
||||
{
|
||||
float2 uv = i.texcoord;
|
||||
const float time = _Time.y;
|
||||
|
||||
uv.x += sin(uv.y * _XFactor + time * _TimeScale) / 400.0;
|
||||
uv.y += cos(uv.x * _YFactor + time * _TimeScale) / 450.0;
|
||||
|
||||
uv.x += sin((uv.y+uv.x) * _XFactor + time * _TimeScale) / (180.0 + (_TimeScale * sin(time)));
|
||||
uv.y += cos((uv.y+uv.x) * _YFactor + time * _TimeScale) / (200.0 + (_TimeScale * sin(time)));
|
||||
|
||||
float4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex,uv);
|
||||
return col;
|
||||
}
|
||||
ENDHLSL
|
||||
|
||||
SubShader
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
Pass
|
||||
{
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertDefault
|
||||
#pragma fragment Frag
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b8bcccc572f924448668c94cfa547b4
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+174
@@ -44,6 +44,105 @@ MonoBehaviour:
|
||||
opacity:
|
||||
overrideState: 0
|
||||
value: 1
|
||||
--- !u!114 &-8365138130595697379
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bb4ad18ac69b12845a429aba13929a07, type: 3}
|
||||
m_Name: Distortion
|
||||
m_EditorClassIdentifier:
|
||||
active: 0
|
||||
enabled:
|
||||
overrideState: 1
|
||||
value: 1
|
||||
timeScale:
|
||||
overrideState: 0
|
||||
value: 4
|
||||
xFactor:
|
||||
overrideState: 0
|
||||
value: 15
|
||||
yFactor:
|
||||
overrideState: 0
|
||||
value: 10
|
||||
--- !u!114 &-806185241644601601
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bb4ad18ac69b12845a429aba13929a07, type: 3}
|
||||
m_Name: Distortion
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
enabled:
|
||||
overrideState: 1
|
||||
value: 1
|
||||
timeScale:
|
||||
overrideState: 0
|
||||
value: 4
|
||||
xFactor:
|
||||
overrideState: 0
|
||||
value: 15
|
||||
yFactor:
|
||||
overrideState: 0
|
||||
value: 10
|
||||
--- !u!114 &-804113543285745465
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c1cb7e9e120078f43bce4f0b1be547a7, type: 3}
|
||||
m_Name: AmbientOcclusion
|
||||
m_EditorClassIdentifier:
|
||||
active: 0
|
||||
enabled:
|
||||
overrideState: 1
|
||||
value: 1
|
||||
mode:
|
||||
overrideState: 1
|
||||
value: 1
|
||||
intensity:
|
||||
overrideState: 1
|
||||
value: 0.25
|
||||
color:
|
||||
overrideState: 0
|
||||
value: {r: 0, g: 0, b: 0, a: 1}
|
||||
ambientOnly:
|
||||
overrideState: 0
|
||||
value: 1
|
||||
noiseFilterTolerance:
|
||||
overrideState: 0
|
||||
value: 0
|
||||
blurTolerance:
|
||||
overrideState: 0
|
||||
value: -4.6
|
||||
upsampleTolerance:
|
||||
overrideState: 0
|
||||
value: -12
|
||||
thicknessModifier:
|
||||
overrideState: 0
|
||||
value: 1
|
||||
directLightingStrength:
|
||||
overrideState: 0
|
||||
value: 0
|
||||
radius:
|
||||
overrideState: 0
|
||||
value: 0.25
|
||||
quality:
|
||||
overrideState: 0
|
||||
value: 2
|
||||
--- !u!114 &-118557119588518591
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
@@ -1370,3 +1469,78 @@ MonoBehaviour:
|
||||
settings:
|
||||
- {fileID: -118557119588518591}
|
||||
- {fileID: -8887095760420704611}
|
||||
- {fileID: 455792505896753558}
|
||||
- {fileID: -804113543285745465}
|
||||
- {fileID: -8365138130595697379}
|
||||
--- !u!114 &455792505896753558
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 48a79b01ea5641d4aa6daa2e23605641, type: 3}
|
||||
m_Name: Bloom
|
||||
m_EditorClassIdentifier:
|
||||
active: 0
|
||||
enabled:
|
||||
overrideState: 1
|
||||
value: 1
|
||||
intensity:
|
||||
overrideState: 1
|
||||
value: 5
|
||||
threshold:
|
||||
overrideState: 1
|
||||
value: 1.3
|
||||
softKnee:
|
||||
overrideState: 1
|
||||
value: 0.5
|
||||
clamp:
|
||||
overrideState: 0
|
||||
value: 65472
|
||||
diffusion:
|
||||
overrideState: 0
|
||||
value: 7
|
||||
anamorphicRatio:
|
||||
overrideState: 0
|
||||
value: 0
|
||||
color:
|
||||
overrideState: 0
|
||||
value: {r: 1, g: 1, b: 1, a: 1}
|
||||
fastMode:
|
||||
overrideState: 1
|
||||
value: 1
|
||||
dirtTexture:
|
||||
overrideState: 0
|
||||
value: {fileID: 0}
|
||||
defaultState: 1
|
||||
dirtIntensity:
|
||||
overrideState: 0
|
||||
value: 0
|
||||
--- !u!114 &954549172052332416
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bb4ad18ac69b12845a429aba13929a07, type: 3}
|
||||
m_Name: Distortion
|
||||
m_EditorClassIdentifier:
|
||||
active: 0
|
||||
enabled:
|
||||
overrideState: 1
|
||||
value: 1
|
||||
timeScale:
|
||||
overrideState: 0
|
||||
value: 4
|
||||
xFactor:
|
||||
overrideState: 0
|
||||
value: 15
|
||||
yFactor:
|
||||
overrideState: 0
|
||||
value: 10
|
||||
File renamed without changes.
@@ -100,9 +100,9 @@ MonoBehaviour:
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 0.15686275, g: 0.15686275, b: 0.15686275, a: 0.78431374}
|
||||
m_HighlightedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.78431374}
|
||||
m_PressedColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.78431374}
|
||||
m_SelectedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.9019608}
|
||||
m_HighlightedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.78431374}
|
||||
m_PressedColor: {r: 0.078431375, g: 0.19607843, b: 0.39215687, a: 0.78431374}
|
||||
m_SelectedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.78431374}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
|
||||
@@ -11,6 +11,18 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: IngameDebugConsole
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11414302, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_Navigation.m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11420596, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_Navigation.m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11437802, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_Navigation.m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11452418, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: toggleBinding.m_Id
|
||||
value: 06175ea3-1b47-4b6e-bcd7-4d191ce555d1
|
||||
@@ -19,6 +31,18 @@ PrefabInstance:
|
||||
propertyPath: toggleBinding.m_SingletonActionBindings.Array.data[0].m_Id
|
||||
value: badbacc7-7d97-42d1-ac38-980883100f6e
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11466918, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_Navigation.m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11472314, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_Navigation.m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11477250, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_Navigation.m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 0
|
||||
@@ -235,6 +259,22 @@ PrefabInstance:
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 114000010993257018, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_Navigation.m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 114466839828933532, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_Navigation.m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 114664465529608634, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_Navigation.m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 114786672304321734, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_Navigation.m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
@@ -286,36 +326,3 @@ PrefabInstance:
|
||||
m_RemovedComponents:
|
||||
- {fileID: 11492840, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
--- !u!1 &2755888773260686779 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 109254, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
|
||||
m_PrefabInstance: {fileID: 2755888773260713853}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &2755888771526933940
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2755888773260686779}
|
||||
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: 0
|
||||
m_PointerBehavior: 0
|
||||
@@ -166,7 +166,6 @@ GameObject:
|
||||
- component: {fileID: 311849592}
|
||||
- component: {fileID: 311849591}
|
||||
- component: {fileID: 311849595}
|
||||
- component: {fileID: 311849594}
|
||||
- component: {fileID: 7927220425085558669}
|
||||
m_Layer: 0
|
||||
m_Name: GameCamera
|
||||
@@ -221,7 +220,7 @@ Camera:
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 55
|
||||
m_Bits: 63
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
@@ -242,102 +241,6 @@ AudioListener:
|
||||
m_GameObject: {fileID: 311849590}
|
||||
m_Enabled: 1
|
||||
--- !u!82 &311849595
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 311849590}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_PlayOnAwake: 1
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
panLevelCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spreadCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMixCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!82 &311849594
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@@ -440,7 +343,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 311849590}
|
||||
m_Enabled: 0
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 948f4100a11a5c24981795d21301da5c, type: 3}
|
||||
m_Name:
|
||||
@@ -448,7 +351,7 @@ MonoBehaviour:
|
||||
volumeTrigger: {fileID: 311849593}
|
||||
volumeLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 55
|
||||
m_Bits: 136
|
||||
stopNaNPropagation: 0
|
||||
finalBlitToCameraTarget: 0
|
||||
antialiasingMode: 0
|
||||
@@ -460,7 +363,7 @@ MonoBehaviour:
|
||||
subpixelMorphologicalAntialiasing:
|
||||
quality: 2
|
||||
fastApproximateAntialiasing:
|
||||
fastMode: 0
|
||||
fastMode: 1
|
||||
keepAlpha: 0
|
||||
fog:
|
||||
enabled: 1
|
||||
@@ -990,9 +893,9 @@ MonoBehaviour:
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 0, g: 0, b: 0, a: 0.7058824}
|
||||
m_HighlightedColor: {r: 0.15686275, g: 0.15686275, b: 0.15686275, a: 0.6666667}
|
||||
m_HighlightedColor: {r: 0.509434, g: 0.509434, b: 0.509434, a: 0.6666667}
|
||||
m_PressedColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.6666667}
|
||||
m_SelectedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.9019608}
|
||||
m_SelectedColor: {r: 0.38679248, g: 0.38679248, b: 0.38679248, a: 0.9019608}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
@@ -1203,9 +1106,9 @@ MonoBehaviour:
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 0, g: 0, b: 0, a: 0.7058824}
|
||||
m_HighlightedColor: {r: 0.15686275, g: 0.15686275, b: 0.15686275, a: 0.6666667}
|
||||
m_HighlightedColor: {r: 0.509434, g: 0.509434, b: 0.509434, a: 0.6666667}
|
||||
m_PressedColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.6666667}
|
||||
m_SelectedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.9019608}
|
||||
m_SelectedColor: {r: 0.38679248, g: 0.38679248, b: 0.38679248, a: 0.9019608}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
@@ -2571,7 +2474,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: -200, y: -50}
|
||||
m_SizeDelta: {x: -160, y: -50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &280950566019251211
|
||||
CanvasRenderer:
|
||||
@@ -2628,12 +2531,12 @@ MonoBehaviour:
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 22
|
||||
m_fontSize: 23
|
||||
m_fontSizeBase: 22
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_enableAutoSizing: 1
|
||||
m_fontSizeMin: 16
|
||||
m_fontSizeMax: 23
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 1
|
||||
m_VerticalAlignment: 256
|
||||
@@ -2705,8 +2608,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 105, y: 0}
|
||||
m_SizeDelta: {x: -410, y: -50}
|
||||
m_AnchoredPosition: {x: 117.5, y: 0}
|
||||
m_SizeDelta: {x: -395, y: -50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8762462625390650021
|
||||
CanvasRenderer:
|
||||
@@ -2763,12 +2666,12 @@ MonoBehaviour:
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 22
|
||||
m_fontSize: 23
|
||||
m_fontSizeBase: 22
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_enableAutoSizing: 1
|
||||
m_fontSizeMin: 16
|
||||
m_fontSizeMax: 23
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 1
|
||||
m_VerticalAlignment: 256
|
||||
@@ -2852,7 +2755,7 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 5491488055271105370}
|
||||
- component: {fileID: 8346885185333560231}
|
||||
m_Layer: 0
|
||||
m_Layer: 3
|
||||
m_Name: PostProcessVolume
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
@@ -4132,7 +4035,6 @@ MonoBehaviour:
|
||||
mainCamera: {fileID: 311849592}
|
||||
curtainImage: {fileID: 147356289}
|
||||
musicSource: {fileID: 311849595}
|
||||
sfxSource: {fileID: 311849594}
|
||||
videoPlayerCanvas: {fileID: 5102776189801015787}
|
||||
videoPlayer: {fileID: 4844794614659113022}
|
||||
noteCanvasGroup: {fileID: 6941303344842138483}
|
||||
@@ -4246,8 +4148,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: -105, y: 0}
|
||||
m_SizeDelta: {x: -410, y: -50}
|
||||
m_AnchoredPosition: {x: -117.5, y: 0}
|
||||
m_SizeDelta: {x: -395, y: -50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6439756746665821290
|
||||
CanvasRenderer:
|
||||
@@ -4304,12 +4206,12 @@ MonoBehaviour:
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 22
|
||||
m_fontSize: 23
|
||||
m_fontSizeBase: 22
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_enableAutoSizing: 1
|
||||
m_fontSizeMin: 16
|
||||
m_fontSizeMax: 23
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 1
|
||||
m_VerticalAlignment: 256
|
||||
|
||||
@@ -100,9 +100,9 @@ MonoBehaviour:
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 0, g: 0, b: 0, a: 0.7058824}
|
||||
m_HighlightedColor: {r: 0.15686275, g: 0.15686275, b: 0.15686275, a: 0.6666667}
|
||||
m_PressedColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.6666667}
|
||||
m_SelectedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.9019608}
|
||||
m_HighlightedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.6666667}
|
||||
m_PressedColor: {r: 0.07450981, g: 0.19607843, b: 0.39215687, a: 0.6666667}
|
||||
m_SelectedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.9019608}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
@@ -317,11 +317,11 @@ MonoBehaviour:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 18
|
||||
m_fontSizeBase: 18
|
||||
m_fontSizeBase: 21
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_enableAutoSizing: 1
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontSizeMax: 21
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 2
|
||||
m_VerticalAlignment: 512
|
||||
|
||||
@@ -100,9 +100,9 @@ MonoBehaviour:
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 0.15686275, g: 0.15686275, b: 0.15686275, a: 0.78431374}
|
||||
m_HighlightedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.78431374}
|
||||
m_PressedColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.78431374}
|
||||
m_SelectedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.9019608}
|
||||
m_HighlightedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.78431374}
|
||||
m_PressedColor: {r: 0.07450981, g: 0.19607843, b: 0.39215687, a: 0.78431374}
|
||||
m_SelectedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.9019608}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2eaeb845461401e488e4640caf779ddf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b93923849ec63ad4ea52f79bf5bc9cb6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
因为当前特效的实现方式使用了第三方插件和素材,所以此文件夹内的所有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 => 蓝龙葵变红龙葵的特效
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 815b64a4a03e7b949bd85e1e5c19deb3
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a637ebcead3359c4f849f936d41707ee
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
因为当前特效的实现方式使用了第三方插件和素材,所以此文件夹内的所有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,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1d950c46b3119043a1919074fdc27c5
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f33d244048b1054a8753633da7ffe28
|
||||
guid: fcd2231fc0b299247b47f42991d73ab5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
File renamed without changes.
File renamed without changes.
@@ -10,14 +10,16 @@ Shader "Pal3/Dev"
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
LOD 100
|
||||
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Pass {
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
@@ -63,4 +65,4 @@ Shader "Pal3/Dev"
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -1,33 +1,30 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Standard"
|
||||
Shader "Pal3/Opaque"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_ShadowTex ("Shadow map (RGB)", 2D) = "white" {}
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.0
|
||||
_Exposure("Exposure Amount", Range(0.1,1.0)) = 0.4
|
||||
_Transparency("Transparency Amount", Range(0.1,1.0)) = 1.0
|
||||
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
|
||||
|
||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="TransparentCutout" }
|
||||
LOD 100
|
||||
|
||||
Lighting Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
|
||||
Tags { "QUEUE" = "Geometry" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags{ "Qeueue" = "Geometry" }
|
||||
Blend Off
|
||||
ZWrite On
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
@@ -44,18 +41,18 @@ Shader "Pal3/Standard"
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
UNITY_FOG_COORDS(2)
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float4 _TintColor;
|
||||
|
||||
float _HasShadowTex;
|
||||
sampler2D _ShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
fixed _Cutoff;
|
||||
float _Exposure;
|
||||
float _Transparency;
|
||||
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
@@ -64,22 +61,18 @@ Shader "Pal3/Standard"
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.shadowcoord = TRANSFORM_TEX(v.shadowcoord, _ShadowTex);
|
||||
UNITY_TRANSFER_FOG(o, o.vertex);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.texcoord);
|
||||
|
||||
// Cutout
|
||||
clip(color.a - _Cutoff);
|
||||
// Shadow
|
||||
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
|
||||
// Transparency
|
||||
color.a = _Transparency;
|
||||
|
||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
||||
if(_HasShadowTex > 0.5f)
|
||||
{
|
||||
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
|
||||
}
|
||||
color *= _TintColor;
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a83b1b6f4822140d58c7bad4e3b39932
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
Shader "Pal3/Sprite"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha One
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = tex2D(_MainTex, i.uv);
|
||||
col.a = 1.0f; // force alpha to 1 to avoid transparency
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6122fb5a4bad8433982c0407309f8dbf
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,97 @@
|
||||
Shader "Pal3/Transparent"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
|
||||
_Threshold ("Transparent Threshold", Range(0, 1)) = 1.0
|
||||
|
||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
|
||||
|
||||
[Enum(UnityEngine.Rendering.BlendMode)]
|
||||
_BlendSrcFactor("Source Blend Factor", int) = 5 // BlendMode.SrcAlpha as Default
|
||||
|
||||
[Enum(UnityEngine.Rendering.BlendMode)]
|
||||
_BlendDstFactor("Dest Blend Factor", int) = 10 // BlendMode.OneMinusSrcAlpha as Default
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Lighting Off
|
||||
|
||||
Tags { "Queue" = "Transparent" }
|
||||
|
||||
// Pass 2 ,transparent part
|
||||
Pass
|
||||
{
|
||||
Blend [_BlendSrcFactor] [_BlendDstFactor]
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float _Threshold;
|
||||
|
||||
float _HasShadowTex;
|
||||
sampler2D _ShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
float _Exposure;
|
||||
|
||||
float4 _TintColor;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.shadowcoord = TRANSFORM_TEX(v.shadowcoord, _ShadowTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.texcoord);
|
||||
const float alpha = color.a;
|
||||
if(color.a >= _Threshold)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
if(_HasShadowTex > 0.5f)
|
||||
{
|
||||
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
|
||||
color.a = alpha;
|
||||
}
|
||||
color *= _TintColor;
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a73f8d5b84814e63a97995e839fdabb
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+31
-26
@@ -1,32 +1,31 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/StandardNoShadow"
|
||||
Shader "Pal3/TransparentOpaquePart"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.0
|
||||
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
|
||||
_Transparency("Transparency Amount", Range(0.1,1.0)) = 1.0
|
||||
_Threshold ("Transparent Threshold", Range(0, 1)) = 1.0
|
||||
|
||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="TransparentCutout" }
|
||||
LOD 100
|
||||
|
||||
Lighting Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
|
||||
Tags { "Qeueue" = "Geometry" }
|
||||
|
||||
// pass 1 , opaque part
|
||||
Pass
|
||||
{
|
||||
Blend Off
|
||||
ZWrite On
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
@@ -34,6 +33,7 @@ Shader "Pal3/StandardNoShadow"
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
@@ -41,15 +41,21 @@ Shader "Pal3/StandardNoShadow"
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
fixed _Cutoff;
|
||||
half4 _TintColor;
|
||||
float _Transparency;
|
||||
float _Threshold;
|
||||
|
||||
float _HasShadowTex;
|
||||
sampler2D _ShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
float _Exposure;
|
||||
|
||||
float4 _TintColor;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
@@ -58,22 +64,21 @@ Shader "Pal3/StandardNoShadow"
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
UNITY_TRANSFER_FOG(o, o.vertex);
|
||||
o.shadowcoord = TRANSFORM_TEX(v.shadowcoord, _ShadowTex);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.texcoord);
|
||||
clip(color.a - _Threshold);
|
||||
|
||||
// Cutout
|
||||
clip(color.a - _Cutoff);
|
||||
// Tint color
|
||||
if(_HasShadowTex > 0.5f)
|
||||
{
|
||||
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
|
||||
}
|
||||
color *= _TintColor;
|
||||
// Transparency
|
||||
color.a = _Transparency;
|
||||
|
||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 784c49f60e0c64f6595ed503bd3a3a69
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
Shader "Pal3/Water"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
// main texture
|
||||
_MainTex ("Main texture", 2D) = "white" {}
|
||||
|
||||
// alpha value
|
||||
_Alpha ("Alpha",Range(0, 1)) = 0.5
|
||||
|
||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.3
|
||||
|
||||
// pre baked shadow texture
|
||||
_ShadowTex ("Shadow texture", 2D) = "white" {}
|
||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||
|
||||
[Enum(UnityEngine.Rendering.BlendMode)]
|
||||
_BlendSrcFactor("Source Blend Factor", int) = 5 // BlendMode.SrcAlpha as Default
|
||||
|
||||
[Enum(UnityEngine.Rendering.BlendMode)]
|
||||
_BlendDstFactor("Dest Blend Factor", int) = 10 // BlendMode.OneMinusSrcAlpha as Default
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Lighting Off
|
||||
|
||||
Tags { "QUEUE" = "Transparent-1" } // -1 to fix sorting order issue with semi-transparent trees etc.
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend [_BlendSrcFactor] [_BlendDstFactor]
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 texcoord2 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 texcoord2 : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
float _Alpha;
|
||||
float _Exposure;
|
||||
|
||||
float _HasShadowTex;
|
||||
sampler2D _ShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.texcoord2 = TRANSFORM_TEX(v.texcoord2, _ShadowTex);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
const half4 color = tex2D(_MainTex, i.texcoord);
|
||||
const half4 colorShadow = tex2D(_ShadowTex, i.texcoord2);
|
||||
half4 mixedColor = color * colorShadow / (1 - _Exposure);
|
||||
mixedColor.a = _Alpha; // use global alpha
|
||||
return mixedColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54296b5ef906d4d219289838c47b2f01
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -24,7 +24,7 @@ RenderSettings:
|
||||
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_AmbientMode: 3
|
||||
m_SubtractiveShadowColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 0}
|
||||
m_HaloStrength: 0.5
|
||||
@@ -97,8 +97,8 @@ LightmapSettings:
|
||||
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}
|
||||
m_LightingDataAsset: {fileID: 112000000, guid: b024d577cdecd974eab12c932a37f51b, type: 2}
|
||||
m_LightingSettings: {fileID: 4890085278179872738, guid: b0ad69fd7711b6842b5f287b194ede35, type: 2}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if UNITY_EDITOR_OSX
|
||||
|
||||
namespace Build.Editor
|
||||
{
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Set NSPrefersDisplaySafeAreaCompatibilityMode in XCode project settings (Info.plist)
|
||||
/// </summary>
|
||||
public static class SetDisplaySafeAreaCompatibilityModeProcessor
|
||||
{
|
||||
[PostProcessBuild]
|
||||
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
|
||||
{
|
||||
if (buildTarget != BuildTarget.StandaloneOSX) return;
|
||||
|
||||
// Get plist
|
||||
#if PAL3
|
||||
string plistPath = pathToBuiltProject + "/PAL3/Info.plist";
|
||||
#elif PAL3A
|
||||
string plistPath = pathToBuiltProject + "/PAL3A/Info.plist";
|
||||
#endif
|
||||
|
||||
PlistDocument plist = new PlistDocument();
|
||||
plist.ReadFromString(File.ReadAllText(plistPath));
|
||||
|
||||
// Get root
|
||||
PlistElementDict rootDict = plist.root;
|
||||
|
||||
rootDict.SetBoolean("NSPrefersDisplaySafeAreaCompatibilityMode", false);
|
||||
|
||||
// Write to file
|
||||
File.WriteAllText(plistPath, plist.WriteToString());
|
||||
|
||||
Debug.Log("NSPrefersDisplaySafeAreaCompatibilityMode set to NO.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acf008c658174728b71ceb4a88b76bc6
|
||||
timeCreated: 1664790861
|
||||
@@ -68,17 +68,17 @@ namespace Core.Algorithm.PathFinding
|
||||
}
|
||||
|
||||
// Init start node
|
||||
var startNode = nodeArray[GetIndex(from.x, from.y, gridSize.x)];
|
||||
Node startNode = nodeArray[GetIndex(from.x, from.y, gridSize.x)];
|
||||
startNode.GCost = 0;
|
||||
startNode.CalculateFCost();
|
||||
nodeArray[startNode.Index] = startNode;
|
||||
|
||||
var endNodeIndex = GetIndex(to.x, to.y, gridSize.x);
|
||||
|
||||
List<int> openList = new List<int>();
|
||||
List<int> closedList = new List<int>();
|
||||
var openList = new List<int>();
|
||||
var closedList = new List<int>();
|
||||
|
||||
Vector2Int[] neighbourOffset = new Vector2Int[8];
|
||||
var neighbourOffset = new Vector2Int[8];
|
||||
neighbourOffset[0] = new Vector2Int(+0, -1);
|
||||
neighbourOffset[1] = new Vector2Int(+0, +1);
|
||||
neighbourOffset[2] = new Vector2Int(-1, +0);
|
||||
@@ -93,7 +93,7 @@ namespace Core.Algorithm.PathFinding
|
||||
while (openList.Count > 0)
|
||||
{
|
||||
var currentNodeIndex = GetLowestCostFNodeIndex(openList, nodeArray);
|
||||
var currentNode = nodeArray[currentNodeIndex];
|
||||
Node currentNode = nodeArray[currentNodeIndex];
|
||||
if (currentNodeIndex == endNodeIndex)
|
||||
{
|
||||
break;
|
||||
@@ -113,7 +113,7 @@ namespace Core.Algorithm.PathFinding
|
||||
|
||||
for (var i = 0; i < neighbourOffset.Length; i++)
|
||||
{
|
||||
var offset = neighbourOffset[i];
|
||||
Vector2Int offset = neighbourOffset[i];
|
||||
var neighbourPosition = new Vector2Int(currentNode.X + offset.x, currentNode.Y + offset.y);
|
||||
|
||||
if (!IsPositionInsideGrid(neighbourPosition, gridSize))
|
||||
@@ -128,7 +128,7 @@ namespace Core.Algorithm.PathFinding
|
||||
continue;
|
||||
}
|
||||
|
||||
var neighbourNode = nodeArray[neighbourNodeIndex];
|
||||
Node neighbourNode = nodeArray[neighbourNodeIndex];
|
||||
if (neighbourNode.IsObstacle)
|
||||
{
|
||||
continue;
|
||||
@@ -152,7 +152,7 @@ namespace Core.Algorithm.PathFinding
|
||||
}
|
||||
}
|
||||
|
||||
var endNode = nodeArray[endNodeIndex];
|
||||
Node endNode = nodeArray[endNodeIndex];
|
||||
if (endNode.PreviousNodeIndex != -1)
|
||||
{
|
||||
var pathList = GetPath(nodeArray, endNode);
|
||||
@@ -172,10 +172,10 @@ namespace Core.Algorithm.PathFinding
|
||||
|
||||
private static int GetLowestCostFNodeIndex(IList<int> openList, ReadOnlySpan<Node> nodeArray)
|
||||
{
|
||||
var lowestCostNode = nodeArray[openList[0]];
|
||||
Node lowestCostNode = nodeArray[openList[0]];
|
||||
for (var i = 0; i < openList.Count; i++)
|
||||
{
|
||||
var currentNode = nodeArray[openList[i]];
|
||||
Node currentNode = nodeArray[openList[i]];
|
||||
if (currentNode.FCost < lowestCostNode.FCost)
|
||||
{
|
||||
lowestCostNode = currentNode;
|
||||
@@ -202,10 +202,10 @@ namespace Core.Algorithm.PathFinding
|
||||
else
|
||||
{
|
||||
List<Vector2Int> path = new () { new Vector2Int(endNode.X, endNode.Y) };
|
||||
var currentNode = endNode;
|
||||
Node currentNode = endNode;
|
||||
while (currentNode.PreviousNodeIndex != -1)
|
||||
{
|
||||
var previousNode = nodeArray[currentNode.PreviousNodeIndex];
|
||||
Node previousNode = nodeArray[currentNode.PreviousNodeIndex];
|
||||
path.Add(new Vector2Int(previousNode.X, previousNode.Y));
|
||||
currentNode = previousNode;
|
||||
}
|
||||
|
||||
@@ -111,12 +111,12 @@ namespace Core.Algorithm.PathFinding
|
||||
}
|
||||
}
|
||||
|
||||
var startNode = nodes[from.x, from.y];
|
||||
SearchNode startNode = nodes[from.x, from.y];
|
||||
startNode.IsObstacle = false;
|
||||
startNode.SearchType = SearchType.Start;
|
||||
startNode.GCost = 0;
|
||||
|
||||
var endNode = nodes[to.x, to.y];
|
||||
SearchNode endNode = nodes[to.x, to.y];
|
||||
endNode.IsObstacle = false;
|
||||
startNode.SearchType = SearchType.Goal;
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Core.Algorithm.PathFinding
|
||||
for (var i = 0; i < currentNeighbors.Count; i++)
|
||||
{
|
||||
SearchNode neighbor = currentNeighbors[i];
|
||||
if(neighbor.Closed)
|
||||
if (neighbor.Closed)
|
||||
{
|
||||
var newGCost = neighbor.GCost +
|
||||
heuristicFunc(new Vector2Int(neighbor.X, neighbor.Y), new Vector2Int(node.X, node.Y));
|
||||
@@ -165,7 +165,7 @@ namespace Core.Algorithm.PathFinding
|
||||
var neighbors = GetNeighbors(node, nodes);
|
||||
for (var i = 0; i < neighbors.Count; i++)
|
||||
{
|
||||
var neighbor = neighbors[i];
|
||||
SearchNode neighbor = neighbors[i];
|
||||
if (IsNeighborValid(neighbor))
|
||||
{
|
||||
if (neighbor.Opened == false)
|
||||
@@ -185,7 +185,7 @@ namespace Core.Algorithm.PathFinding
|
||||
}
|
||||
|
||||
var path = new List<Vector2Int>();
|
||||
var lastNode = GetNode(endNode.Position, nodes);
|
||||
SearchNode lastNode = GetNode(endNode.Position, nodes);
|
||||
while (lastNode != null)
|
||||
{
|
||||
path.Add(new Vector2Int(lastNode.X, lastNode.Y));
|
||||
@@ -229,7 +229,7 @@ namespace Core.Algorithm.PathFinding
|
||||
SearchNode startNode,
|
||||
Func<Vector2Int, Vector2Int, int> heuristicFunc)
|
||||
{
|
||||
var parent = (currentNode.X == startNode.X && currentNode.Y == startNode.Y) ?
|
||||
SearchNode parent = (currentNode.X == startNode.X && currentNode.Y == startNode.Y) ?
|
||||
startNode : currentNode.Parent;
|
||||
|
||||
float gCost = parent.GCost +
|
||||
@@ -264,7 +264,7 @@ namespace Core.Algorithm.PathFinding
|
||||
List<SearchNode> result,
|
||||
SearchNode[,] nodes)
|
||||
{
|
||||
var node = GetNode(curtPos.x + dx, curtPos.y + dy, nodes);
|
||||
SearchNode node = GetNode(curtPos.x + dx, curtPos.y + dy, nodes);
|
||||
|
||||
if (node is {IsObstacle: false})
|
||||
{
|
||||
@@ -295,7 +295,7 @@ namespace Core.Algorithm.PathFinding
|
||||
return true;
|
||||
}
|
||||
|
||||
var node = GetNode(x0, y0, nodes);
|
||||
SearchNode node = GetNode(x0, y0, nodes);
|
||||
if (node is {IsObstacle: true})
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -531,7 +531,7 @@
|
||||
lock (_queue)
|
||||
{
|
||||
//Copy to a separate list because we don't want to 'yield return' inside a lock
|
||||
foreach(var node in _queue)
|
||||
foreach(SimpleNode node in _queue)
|
||||
{
|
||||
queueData.Add(node.Data);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ namespace Core.Animation
|
||||
float to,
|
||||
float duration,
|
||||
AnimationCurveType curveType,
|
||||
Action<float> onValueChanged)
|
||||
Action<float> onValueChanged,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (Mathf.Abs(duration) < Mathf.Epsilon)
|
||||
{
|
||||
@@ -45,7 +46,7 @@ namespace Core.Animation
|
||||
}
|
||||
|
||||
var timePast = 0f;
|
||||
while (timePast < duration)
|
||||
while (timePast < duration && !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
var newValue = Mathf.Lerp(from, to,
|
||||
GetInterpolationRatio(timePast / duration, curveType));
|
||||
@@ -54,7 +55,10 @@ namespace Core.Animation
|
||||
yield return null;
|
||||
}
|
||||
|
||||
onValueChanged?.Invoke(to);
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
onValueChanged?.Invoke(to);
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
@@ -64,7 +68,7 @@ namespace Core.Animation
|
||||
AnimationCurveType curveType = AnimationCurveType.Linear,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var oldPosition = target.position;
|
||||
Vector3 oldPosition = target.position;
|
||||
|
||||
var timePast = 0f;
|
||||
while (timePast < duration && target != null && !cancellationToken.IsCancellationRequested)
|
||||
@@ -79,14 +83,18 @@ namespace Core.Animation
|
||||
yield return null;
|
||||
}
|
||||
|
||||
public static IEnumerator ShakeTransform(Transform target, float duration, float amplitude,
|
||||
bool shakeOnXAxis, bool shakeOnYAxis, bool shakeOnZAxis)
|
||||
public static IEnumerator ShakeTransform(Transform target,
|
||||
float duration,
|
||||
float amplitude,
|
||||
bool shakeOnXAxis,
|
||||
bool shakeOnYAxis,
|
||||
bool shakeOnZAxis)
|
||||
{
|
||||
var originalPosition = target.localPosition;
|
||||
Vector3 originalPosition = target.localPosition;
|
||||
|
||||
while (duration > 0 && target != null)
|
||||
{
|
||||
var delta = UnityEngine.Random.insideUnitSphere * amplitude;
|
||||
Vector3 delta = UnityEngine.Random.insideUnitSphere * amplitude;
|
||||
target.localPosition = originalPosition + new Vector3(
|
||||
shakeOnXAxis ? delta.x : 0f,
|
||||
shakeOnYAxis ? delta.y : 0f,
|
||||
@@ -108,16 +116,16 @@ namespace Core.Animation
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var distance = Vector3.Distance(target.position, centerPoint);
|
||||
var startRotation = target.rotation;
|
||||
Quaternion startRotation = target.rotation;
|
||||
|
||||
var timePast = 0f;
|
||||
while (timePast < duration && target != null && !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
var rotation = Quaternion.Lerp(startRotation, toRotation,
|
||||
Quaternion rotation = Quaternion.Lerp(startRotation, toRotation,
|
||||
GetInterpolationRatio(timePast / duration, curveType));
|
||||
|
||||
var direction = (rotation * Vector3.forward).normalized;
|
||||
var newPosition = centerPoint + direction * -(distance + (timePast / duration) * distanceDelta);
|
||||
Vector3 direction = (rotation * Vector3.forward).normalized;
|
||||
Vector3 newPosition = centerPoint + direction * -(distance + (timePast / duration) * distanceDelta);
|
||||
|
||||
target.rotation = rotation;
|
||||
target.position = newPosition;
|
||||
@@ -141,12 +149,12 @@ namespace Core.Animation
|
||||
AnimationCurveType curveType,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var startRotation = target.rotation;
|
||||
Quaternion startRotation = target.rotation;
|
||||
|
||||
var timePast = 0f;
|
||||
while (timePast < duration && target != null && !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
var rotation = Quaternion.Lerp(startRotation, toRotation,
|
||||
Quaternion rotation = Quaternion.Lerp(startRotation, toRotation,
|
||||
GetInterpolationRatio(timePast / duration, curveType));
|
||||
|
||||
target.rotation = rotation;
|
||||
|
||||
@@ -34,7 +34,15 @@ namespace Core.DataLoader
|
||||
}
|
||||
else
|
||||
{
|
||||
callback?.Invoke(DownloadHandlerAudioClip.GetContent(request));
|
||||
try
|
||||
{
|
||||
AudioClip audioClip = DownloadHandlerAudioClip.GetContent(request);
|
||||
callback?.Invoke(audioClip);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"Failed to get audio clip: {filePath} with exception: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,8 @@ namespace Core.DataLoader
|
||||
throw new ArgumentException($"Not a valid DXT file.");
|
||||
}
|
||||
|
||||
var header = DxtHeader.ReadHeader(reader);
|
||||
DxtHeader header = DxtHeader.ReadHeader(reader);
|
||||
var format = header.DxtPixelFormat.Format;
|
||||
hasAlphaChannel = format == "DXT1";
|
||||
|
||||
_width = header.Width;
|
||||
_height = header.Height;
|
||||
@@ -40,9 +39,11 @@ namespace Core.DataLoader
|
||||
switch (format)
|
||||
{
|
||||
case "DXT1":
|
||||
hasAlphaChannel = false;
|
||||
LoadDxt1Texture(data);
|
||||
break;
|
||||
case "DXT3":
|
||||
hasAlphaChannel = true;
|
||||
LoadDxt3Texture(data);
|
||||
break;
|
||||
case "DXT5":
|
||||
@@ -81,7 +82,7 @@ namespace Core.DataLoader
|
||||
public Texture2D ToTexture2D()
|
||||
{
|
||||
if (_rawData == null) return null;
|
||||
Texture2D texture = new Texture2D(_width, _height, _format, false);
|
||||
Texture2D texture = new Texture2D(_width, _height, _format, mipChain: false);
|
||||
texture.LoadRawTextureData(_rawData);
|
||||
texture.Apply();
|
||||
return texture;
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Core.DataLoader
|
||||
public Texture2D ToTexture2D()
|
||||
{
|
||||
if (_pixels == null) return null;
|
||||
var texture = new Texture2D(_width, _height);
|
||||
var texture = new Texture2D(_width, _height, TextureFormat.RGBA32, mipChain: false);
|
||||
texture.SetPixels32(_pixels);
|
||||
texture.Apply();
|
||||
return texture;
|
||||
|
||||
@@ -111,14 +111,17 @@ namespace Core.DataReader.Bmp
|
||||
|
||||
public Texture2D ToTexture2D()
|
||||
{
|
||||
var tex = new Texture2D(info.absWidth, info.absHeight);
|
||||
var texture = new Texture2D(info.absWidth,
|
||||
info.absHeight,
|
||||
TextureFormat.RGBA32,
|
||||
mipChain: false);
|
||||
|
||||
if (info.height < 0)
|
||||
FlipImage();
|
||||
|
||||
tex.SetPixels32(imageData);
|
||||
tex.Apply();
|
||||
return tex;
|
||||
texture.SetPixels32(imageData);
|
||||
texture.Apply();
|
||||
return texture;
|
||||
}
|
||||
|
||||
// flip image if height is negative
|
||||
@@ -141,10 +144,10 @@ namespace Core.DataReader.Bmp
|
||||
|
||||
public void ReplaceColor(Color32 aColorToSearch, Color32 aReplacementColor)
|
||||
{
|
||||
var s = aColorToSearch;
|
||||
Color32 s = aColorToSearch;
|
||||
for (int i = 0; i < imageData.Length; i++)
|
||||
{
|
||||
var c = imageData[i];
|
||||
Color32 c = imageData[i];
|
||||
if (c.r == s.r && c.g == s.g && c.b == s.b && c.a == s.a)
|
||||
imageData[i] = aReplacementColor;
|
||||
}
|
||||
@@ -167,7 +170,7 @@ namespace Core.DataReader.Bmp
|
||||
|
||||
public BMPImage LoadBmp(string aFileName)
|
||||
{
|
||||
using var file = File.OpenRead(aFileName);
|
||||
using FileStream file = File.OpenRead(aFileName);
|
||||
return LoadBmp(file);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Core.DataReader.Cpk
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Lzo;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
/// <summary>
|
||||
@@ -23,21 +24,20 @@ namespace Core.DataReader.Cpk
|
||||
private const uint SUPPORTED_CPK_VERSION = 1;
|
||||
private const uint CPK_HEADER_MAGIC = 0x_1A_54_53_52; // CPK header magic label
|
||||
private const int CPK_DEFAULT_MAX_NUM_OF_FILE = 32768; // Max number of files per archive
|
||||
private const int GBK_CODE_PAGE = 936; // GBK Encoding's code page
|
||||
|
||||
private readonly string _filePath;
|
||||
private readonly CrcHash _crcHash;
|
||||
private readonly int _codepage;
|
||||
private Dictionary<uint, CpkTableEntity> _tableEntities;
|
||||
|
||||
private readonly Dictionary<uint, byte[]> _fileNameMap = new ();
|
||||
private readonly Dictionary<uint, uint> _crcToTableIndexMap = new ();
|
||||
private readonly Dictionary<uint, HashSet<uint>> _fatherCrcToChildCrcTableIndexMap = new ();
|
||||
|
||||
private readonly CrcHash _crcHash;
|
||||
|
||||
|
||||
private bool _archiveInMemory;
|
||||
private byte[] _archiveData;
|
||||
|
||||
public CpkArchive(string cpkFilePath, CrcHash crcHash)
|
||||
public CpkArchive(string cpkFilePath, CrcHash crcHash, int codepage)
|
||||
{
|
||||
if (!File.Exists(cpkFilePath))
|
||||
{
|
||||
@@ -46,6 +46,7 @@ namespace Core.DataReader.Cpk
|
||||
|
||||
_filePath = cpkFilePath;
|
||||
_crcHash = crcHash;
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -94,6 +95,33 @@ namespace Core.DataReader.Cpk
|
||||
BuildCrcIndexMap();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract the complete archive to the specified destination
|
||||
/// </summary>
|
||||
public void ExtractTo(string outputFolder)
|
||||
{
|
||||
ExtractToInternal(outputFolder, GetRootEntries());
|
||||
}
|
||||
|
||||
private void ExtractToInternal(string outputFolder, IEnumerable<CpkEntry> nodes)
|
||||
{
|
||||
foreach (CpkEntry node in nodes)
|
||||
{
|
||||
var relativePath = node.VirtualPath.Replace(
|
||||
CpkConstants.DirectorySeparator, Path.DirectorySeparatorChar);
|
||||
|
||||
if (node.IsDirectory)
|
||||
{
|
||||
new DirectoryInfo(outputFolder + relativePath).Create();
|
||||
ExtractToInternal(outputFolder, node.Children);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.WriteAllBytes(outputFolder + relativePath, ReadAllBytes(node.VirtualPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if file exists inside the archive.
|
||||
/// </summary>
|
||||
@@ -101,7 +129,7 @@ namespace Core.DataReader.Cpk
|
||||
/// <returns>True if file exists</returns>
|
||||
public bool FileExists(string fileVirtualPath)
|
||||
{
|
||||
var crc = _crcHash.ComputeCrc32Hash(fileVirtualPath.ToLower());
|
||||
var crc = _crcHash.ComputeCrc32Hash(fileVirtualPath.ToLower(), _codepage);
|
||||
return _crcToTableIndexMap.ContainsKey(crc);
|
||||
}
|
||||
|
||||
@@ -119,7 +147,7 @@ namespace Core.DataReader.Cpk
|
||||
|
||||
private byte[] ReadAllBytesUsingInMemoryCache(string fileVirtualPath)
|
||||
{
|
||||
var entity = ValidateAndGetTableEntity(fileVirtualPath);
|
||||
CpkTableEntity entity = ValidateAndGetTableEntity(fileVirtualPath);
|
||||
|
||||
byte[] data;
|
||||
|
||||
@@ -141,7 +169,7 @@ namespace Core.DataReader.Cpk
|
||||
|
||||
private byte[] GetFileContent(string fileVirtualPath)
|
||||
{
|
||||
var entity = ValidateAndGetTableEntity(fileVirtualPath);
|
||||
CpkTableEntity entity = ValidateAndGetTableEntity(fileVirtualPath);
|
||||
return GetFileContentInternal(entity);
|
||||
}
|
||||
|
||||
@@ -173,13 +201,13 @@ namespace Core.DataReader.Cpk
|
||||
|
||||
private CpkTableEntity ValidateAndGetTableEntity(string fileVirtualPath)
|
||||
{
|
||||
var crc = _crcHash.ComputeCrc32Hash(fileVirtualPath.ToLower());
|
||||
var crc = _crcHash.ComputeCrc32Hash(fileVirtualPath.ToLower(), _codepage);
|
||||
if (!_crcToTableIndexMap.ContainsKey(crc))
|
||||
{
|
||||
throw new ArgumentException($"<{fileVirtualPath}> does not exists in the archive.");
|
||||
}
|
||||
|
||||
var entity = _tableEntities[_crcToTableIndexMap[crc]];
|
||||
CpkTableEntity entity = _tableEntities[_crcToTableIndexMap[crc]];
|
||||
|
||||
if (entity.IsDirectory())
|
||||
{
|
||||
@@ -221,7 +249,7 @@ namespace Core.DataReader.Cpk
|
||||
|
||||
private void BuildCrcIndexMap()
|
||||
{
|
||||
foreach (var (index, entity) in _tableEntities)
|
||||
foreach ((var index, CpkTableEntity entity) in _tableEntities)
|
||||
{
|
||||
_crcToTableIndexMap[entity.CRC] = index;
|
||||
|
||||
@@ -264,7 +292,7 @@ namespace Core.DataReader.Cpk
|
||||
FileOptions.RandomAccess);
|
||||
}
|
||||
|
||||
foreach (var entity in _tableEntities.Values)
|
||||
foreach (CpkTableEntity entity in _tableEntities.Values)
|
||||
{
|
||||
long extraInfoOffset = entity.StartPos + entity.PackedSize;
|
||||
var extraInfo = new byte[entity.ExtraInfoSize];
|
||||
@@ -286,13 +314,13 @@ namespace Core.DataReader.Cpk
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (rootPath != string.Empty) rootPath += CpkConstants.CpkDirectorySeparatorChar;
|
||||
if (rootPath != string.Empty) rootPath += CpkConstants.DirectorySeparator;
|
||||
|
||||
foreach (var childCrc in _fatherCrcToChildCrcTableIndexMap[fatherCrc])
|
||||
{
|
||||
var index = _crcToTableIndexMap[childCrc];
|
||||
var child = _tableEntities[index];
|
||||
var fileName = Encoding.GetEncoding(GBK_CODE_PAGE).GetString(_fileNameMap[child.CRC]);
|
||||
CpkTableEntity child = _tableEntities[index];
|
||||
var fileName = Encoding.GetEncoding(_codepage).GetString(_fileNameMap[child.CRC]);
|
||||
|
||||
var virtualPath = rootPath + fileName;
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Core.DataReader.Cpk
|
||||
{
|
||||
public static class CpkConstants
|
||||
{
|
||||
public const char CpkDirectorySeparatorChar = '\\';
|
||||
public const char DirectorySeparator = '\\';
|
||||
|
||||
public const string FileExtension = ".cpk";
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ namespace Core.DataReader.Cpk
|
||||
{
|
||||
private const uint CRC_TABLE_MAX = 256;
|
||||
private const uint POLYNOMIAL = 0x04C11DB7; // CRC seed
|
||||
private const int GBK_CODE_PAGE = 936; // GBK Encoding's code page
|
||||
|
||||
private static readonly uint[] CrcTable = new uint[CRC_TABLE_MAX];
|
||||
private bool _initialized;
|
||||
@@ -44,10 +43,10 @@ namespace Core.DataReader.Cpk
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public uint ComputeCrc32Hash(string str)
|
||||
public uint ComputeCrc32Hash(string str, int codepage)
|
||||
{
|
||||
//Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
return ComputeCrc32HashInternal(Encoding.GetEncoding(GBK_CODE_PAGE).GetBytes(str));
|
||||
return ComputeCrc32HashInternal(Encoding.GetEncoding(codepage).GetBytes(str));
|
||||
}
|
||||
|
||||
private unsafe uint ComputeCrc32HashInternal(byte[] data)
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
public CvdVertex[][] FrameVertices;
|
||||
public int[] Triangles;
|
||||
public byte BlendFlag;
|
||||
public GameBoxBlendFlag BlendFlag;
|
||||
public GameBoxMaterial Material;
|
||||
public string TextureName;
|
||||
public float[] AnimationTimeKeys;
|
||||
@@ -173,12 +173,12 @@ namespace Core.DataReader.Cvd
|
||||
public class CvdAnimationScaleKeyFrame : CvdAnimationKeyFrame
|
||||
{
|
||||
public Vector3 Scale { get; set; }
|
||||
public GameBoxQuaternion Rotation { get; set; }
|
||||
public Quaternion Rotation { get; set; }
|
||||
}
|
||||
|
||||
public class CvdAnimationRotationKeyFrame : CvdAnimationKeyFrame
|
||||
{
|
||||
public GameBoxQuaternion Rotation { get; set; }
|
||||
public Quaternion Rotation { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Core.DataReader.Cvd
|
||||
|
||||
public static class CvdFileReader
|
||||
{
|
||||
public static CvdFile Read(byte[] data)
|
||||
public static CvdFile Read(byte[] data, int codepage)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
@@ -43,7 +43,7 @@ namespace Core.DataReader.Cvd
|
||||
var rootNodes = new List<CvdGeometryNode>();
|
||||
for (var i = 0; i < numberONodes; i++)
|
||||
{
|
||||
ReadGeometryNodes(reader, version, rootNodes, ref animationDuration);
|
||||
ReadGeometryNodes(reader, version, rootNodes, ref animationDuration, codepage);
|
||||
}
|
||||
|
||||
return new CvdFile(animationDuration, rootNodes.ToArray());
|
||||
@@ -53,12 +53,14 @@ namespace Core.DataReader.Cvd
|
||||
private static void ReadGeometryNodes(UnsafeBinaryReader reader,
|
||||
float version,
|
||||
List<CvdGeometryNode> rootNodes,
|
||||
ref float animationDuration)
|
||||
ref float animationDuration,
|
||||
int codepage)
|
||||
#else
|
||||
private static void ReadGeometryNodes(BinaryReader reader,
|
||||
float version,
|
||||
List<CvdGeometryNode> rootNodes,
|
||||
ref float animationDuration)
|
||||
ref float animationDuration,
|
||||
int codepage)
|
||||
#endif
|
||||
{
|
||||
CvdGeometryNode parentNode = default;
|
||||
@@ -66,7 +68,7 @@ namespace Core.DataReader.Cvd
|
||||
var isGeometryNode = reader.ReadByte();
|
||||
if (isGeometryNode == 1)
|
||||
{
|
||||
parentNode = ReadGeometryNode(reader, version, ref animationDuration);
|
||||
parentNode = ReadGeometryNode(reader, version, ref animationDuration, codepage);
|
||||
parentNode.IsGeometryNode = true;
|
||||
}
|
||||
|
||||
@@ -75,7 +77,7 @@ namespace Core.DataReader.Cvd
|
||||
var children = new List<CvdGeometryNode>();
|
||||
for (var i = 0; i < numberOfChildNodes; i++)
|
||||
{
|
||||
ReadGeometryNodes(reader, version, children, ref animationDuration);
|
||||
ReadGeometryNodes(reader, version, children, ref animationDuration, codepage);
|
||||
}
|
||||
|
||||
parentNode.Children = children.ToArray();
|
||||
@@ -85,11 +87,13 @@ namespace Core.DataReader.Cvd
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static CvdGeometryNode ReadGeometryNode(UnsafeBinaryReader reader,
|
||||
float version,
|
||||
ref float animationDuration)
|
||||
ref float animationDuration,
|
||||
int codepage)
|
||||
#else
|
||||
private static CvdGeometryNode ReadGeometryNode(BinaryReader reader,
|
||||
float version,
|
||||
ref float animationDuration)
|
||||
ref float animationDuration,
|
||||
int codepage)
|
||||
#endif
|
||||
{
|
||||
var positionKeySize = Mathf.Max(
|
||||
@@ -118,7 +122,7 @@ namespace Core.DataReader.Cvd
|
||||
|
||||
var scale = reader.ReadSingle();
|
||||
|
||||
var mesh = ReadMesh(reader, version);
|
||||
CvdMesh mesh = ReadMesh(reader, version, codepage);
|
||||
if (mesh.AnimationTimeKeys.Last() > animationDuration) animationDuration = mesh.AnimationTimeKeys.Last();
|
||||
|
||||
var transformMatrix = new GameBoxMatrix4X4()
|
||||
@@ -178,7 +182,7 @@ namespace Core.DataReader.Cvd
|
||||
|
||||
for (var i = 0; i < frameInfos.Length; i++)
|
||||
{
|
||||
var (type, data) = frameInfos[i];
|
||||
(CvdAnimationKeyType type, var data) = frameInfos[i];
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -189,7 +193,7 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
KeyType = type,
|
||||
Time = positionKey.TcbKey.AnimationKey.Time,
|
||||
Position = positionKey.Value,
|
||||
Position = GameBoxInterpreter.CvdPositionToUnityPosition(positionKey.Value),
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -200,7 +204,7 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
KeyType = type,
|
||||
Time = positionKey.AnimationKey.Time,
|
||||
Position = positionKey.Value,
|
||||
Position = GameBoxInterpreter.CvdPositionToUnityPosition(positionKey.Value),
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -211,7 +215,7 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
KeyType = type,
|
||||
Time = positionKey.AnimationKey.Time,
|
||||
Position = positionKey.Value,
|
||||
Position = GameBoxInterpreter.CvdPositionToUnityPosition(positionKey.Value),
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -232,25 +236,25 @@ namespace Core.DataReader.Cvd
|
||||
|
||||
for (var i = 0; i < frameInfos.Length; i++)
|
||||
{
|
||||
var (type, data) = frameInfos[i];
|
||||
(CvdAnimationKeyType type, var data) = frameInfos[i];
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CvdAnimationKeyType.Tcb:
|
||||
{
|
||||
var rotationKey = Utility.ReadStruct<CvdTcbRotationKey>(data);
|
||||
var quaternion = Quaternion.AngleAxis(rotationKey.Angle, rotationKey.Axis);
|
||||
Quaternion quaternion = Quaternion.AngleAxis(rotationKey.Angle, rotationKey.Axis);
|
||||
rotationKeyFrames[i] = new CvdAnimationRotationKeyFrame()
|
||||
{
|
||||
KeyType = type,
|
||||
Time = rotationKey.TcbKey.AnimationKey.Time,
|
||||
Rotation = new GameBoxQuaternion()
|
||||
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(new GameBoxQuaternion()
|
||||
{
|
||||
X = quaternion.x,
|
||||
Y = quaternion.y,
|
||||
Z = quaternion.z,
|
||||
W = quaternion.w,
|
||||
}
|
||||
})
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -261,7 +265,7 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
KeyType = type,
|
||||
Time = rotationKey.AnimationKey.Time,
|
||||
Rotation = rotationKey.Value
|
||||
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(rotationKey.Value)
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -272,7 +276,7 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
KeyType = type,
|
||||
Time = rotationKey.AnimationKey.Time,
|
||||
Rotation = rotationKey.Value
|
||||
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(rotationKey.Value)
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -293,7 +297,7 @@ namespace Core.DataReader.Cvd
|
||||
|
||||
for (var i = 0; i < frameInfos.Length; i++)
|
||||
{
|
||||
var (type, data) = frameInfos[i];
|
||||
(CvdAnimationKeyType type, var data) = frameInfos[i];
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -304,8 +308,8 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
KeyType = type,
|
||||
Time = scaleKey.TcbKey.AnimationKey.Time,
|
||||
Scale = scaleKey.Value,
|
||||
Rotation = scaleKey.Rotation
|
||||
Scale = GameBoxInterpreter.CvdScaleToUnityScale(scaleKey.Value),
|
||||
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(scaleKey.Rotation)
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -316,8 +320,8 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
KeyType = type,
|
||||
Time = scaleKey.AnimationKey.Time,
|
||||
Scale = scaleKey.Value,
|
||||
Rotation = scaleKey.Rotation
|
||||
Scale = GameBoxInterpreter.CvdScaleToUnityScale(scaleKey.Value),
|
||||
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(scaleKey.Rotation)
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -328,8 +332,8 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
KeyType = type,
|
||||
Time = scaleKey.AnimationKey.Time,
|
||||
Scale = scaleKey.Value,
|
||||
Rotation = scaleKey.Rotation
|
||||
Scale = GameBoxInterpreter.CvdScaleToUnityScale(scaleKey.Value),
|
||||
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(scaleKey.Rotation)
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -340,27 +344,27 @@ namespace Core.DataReader.Cvd
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static CvdMesh ReadMesh(UnsafeBinaryReader reader, float version)
|
||||
private static CvdMesh ReadMesh(UnsafeBinaryReader reader, float version, int codepage)
|
||||
#else
|
||||
private static CvdMesh ReadMesh(BinaryReader reader, float version)
|
||||
private static CvdMesh ReadMesh(BinaryReader reader, float version, int codepage)
|
||||
#endif
|
||||
{
|
||||
var numberOfFrames = reader.ReadInt32();
|
||||
var numberOfVertices = reader.ReadInt32();
|
||||
|
||||
//var vertexType = GameBoxVertexType.XYZ | GameBoxVertexType.Normal | GameBoxVertexType.UV0;
|
||||
//var vertexSize = GameBoxVertex.GetSize((uint)vertexType);
|
||||
|
||||
var frameVertices = new CvdVertex[numberOfFrames][];
|
||||
for (var i = 0; i < numberOfFrames; i++)
|
||||
{
|
||||
var vertices = new CvdVertex[numberOfVertices];
|
||||
for (var j = 0; j < numberOfVertices; j++)
|
||||
{
|
||||
var uv = reader.ReadVector2();
|
||||
var normal = reader.ReadVector3();
|
||||
var position = reader.ReadVector3();
|
||||
Vector2 uv = reader.ReadVector2();
|
||||
Vector3 normal = GameBoxInterpreter.ToUnityNormal(reader.ReadVector3());
|
||||
Vector3 position = GameBoxInterpreter.CvdPositionToUnityPosition(reader.ReadVector3());
|
||||
|
||||
// Quick fix for the missing/wrong normals
|
||||
if (normal == Vector3.zero) normal = Vector3.up;
|
||||
|
||||
vertices[j] = new CvdVertex()
|
||||
{
|
||||
Normal = normal,
|
||||
@@ -381,7 +385,7 @@ namespace Core.DataReader.Cvd
|
||||
var meshSections = new CvdMeshSection[numberOfMeshes];
|
||||
for (var i = 0; i < numberOfMeshes; i++)
|
||||
{
|
||||
meshSections[i] = ReadMeshSection(reader, version, frameVertices);
|
||||
meshSections[i] = ReadMeshSection(reader, version, frameVertices, codepage);
|
||||
}
|
||||
|
||||
return new CvdMesh()
|
||||
@@ -394,14 +398,16 @@ namespace Core.DataReader.Cvd
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static CvdMeshSection ReadMeshSection(UnsafeBinaryReader reader,
|
||||
float version,
|
||||
CvdVertex[][] allFrameVertices)
|
||||
CvdVertex[][] allFrameVertices,
|
||||
int codepage)
|
||||
#else
|
||||
private static CvdMeshSection ReadMeshSection(BinaryReader reader,
|
||||
float version,
|
||||
CvdVertex[][] allFrameVertices)
|
||||
CvdVertex[][] allFrameVertices,
|
||||
int codepage)
|
||||
#endif
|
||||
{
|
||||
var blendFlag = reader.ReadByte();
|
||||
var blendFlag = (GameBoxBlendFlag)reader.ReadByte();
|
||||
|
||||
var material = new GameBoxMaterial()
|
||||
{
|
||||
@@ -412,7 +418,7 @@ namespace Core.DataReader.Cvd
|
||||
Power = reader.ReadSingle()
|
||||
};
|
||||
|
||||
var textureName = reader.ReadGbkString(64);
|
||||
var textureName = reader.ReadString(64, codepage);
|
||||
|
||||
var numberOfIndices = reader.ReadInt32();
|
||||
|
||||
@@ -452,11 +458,11 @@ namespace Core.DataReader.Cvd
|
||||
}
|
||||
|
||||
var frameVertices = new CvdVertex[allFrameVertices.Length][];
|
||||
List<int> triangles;
|
||||
List<int> indexBuffer;
|
||||
|
||||
(triangles, indexBuffer) = CalculateTriangles(indices);
|
||||
|
||||
(List<int> triangles, List<int> indexBuffer) = CalculateTriangles(indices);
|
||||
|
||||
GameBoxInterpreter.ToUnityTriangles(triangles);
|
||||
|
||||
for (var i = 0; i < allFrameVertices.Length; i++)
|
||||
{
|
||||
var verts = new CvdVertex[indexBuffer.Count];
|
||||
@@ -487,7 +493,7 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
var indexBuffer = new List<int>();
|
||||
var triangles = new List<int>();
|
||||
var indexMap = new Dictionary<int, int>();
|
||||
var index = 0;
|
||||
|
||||
for (var j = 0; j < allIndices.Length; j++)
|
||||
{
|
||||
@@ -500,17 +506,8 @@ namespace Core.DataReader.Cvd
|
||||
|
||||
for (var k = 0; k < 3; k++)
|
||||
{
|
||||
if (indexMap.ContainsKey(indices[k]))
|
||||
{
|
||||
triangles.Add(indexMap[indices[k]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
var index = indexBuffer.Count;
|
||||
indexBuffer.Add(indices[k]);
|
||||
indexMap[indices[k]] = index;
|
||||
triangles.Add(index);
|
||||
}
|
||||
indexBuffer.Add(indices[k]);
|
||||
triangles.Add(index++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6277e4ab422e47bdadc0826e97a1dbe3
|
||||
timeCreated: 1665782936
|
||||
@@ -0,0 +1,129 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Data
|
||||
{
|
||||
//using System.Runtime.InteropServices;
|
||||
|
||||
//[StructLayout(LayoutKind.Explicit)]
|
||||
public struct EffectDefinition
|
||||
{
|
||||
//[FieldOffset(0)]
|
||||
public uint ClassNameCrc;
|
||||
|
||||
//[FieldOffset(4)]
|
||||
//[MarshalAs (UnmanagedType.ByValArray, SizeConst = 30)]
|
||||
public string TypeName;
|
||||
|
||||
//[FieldOffset(36)]
|
||||
public uint TypeNameCrc;
|
||||
|
||||
//[FieldOffset(40)]
|
||||
//[MarshalAs (UnmanagedType.ByValArray, SizeConst = 128)]
|
||||
// Union
|
||||
public string TextureName;
|
||||
public string ParticleFileName;
|
||||
public string SfxFileNamePrefix;
|
||||
public string VideoFileNamePrefix;
|
||||
|
||||
//[FieldOffset(168)]
|
||||
public int FramesPerRow;
|
||||
|
||||
//[FieldOffset(172)]
|
||||
public int FramesPerColumn;
|
||||
|
||||
//[FieldOffset(176)]
|
||||
public int FrameCount;
|
||||
|
||||
//[FieldOffset(180)]
|
||||
public float FramePerSecond;
|
||||
|
||||
//[FieldOffset(184)]
|
||||
public float InitXPosition;
|
||||
|
||||
//[FieldOffset(188)]
|
||||
public float InitYPosition;
|
||||
|
||||
//[FieldOffset(192)]
|
||||
public float InitZPosition;
|
||||
|
||||
//[FieldOffset(196)]
|
||||
// Union
|
||||
public float InitYRotation;
|
||||
public float InitAngle;
|
||||
|
||||
//[FieldOffset(200)]
|
||||
public int InitSize;
|
||||
|
||||
//[FieldOffset(204)]
|
||||
public uint InitColor;
|
||||
|
||||
//[FieldOffset(208)]
|
||||
public int MaxQuadCount;
|
||||
|
||||
//[FieldOffset(212)]
|
||||
public bool IsValid;
|
||||
|
||||
//[FieldOffset(213)]
|
||||
public bool IsAdditiveBlend;
|
||||
|
||||
//[FieldOffset(214)]
|
||||
public bool IsBillboard;
|
||||
|
||||
//[FieldOffset(215)]
|
||||
public bool IsZTestIgnored;
|
||||
|
||||
//[FieldOffset(216)]
|
||||
public float InitXRotation;
|
||||
|
||||
//[FieldOffset(220)]
|
||||
public float InitZRotation;
|
||||
|
||||
//[FieldOffset(224)]
|
||||
public float RotationAngle;
|
||||
|
||||
//[FieldOffset(228)]
|
||||
public float Width;
|
||||
|
||||
//[FieldOffset(232)]
|
||||
public float DivisionCount;
|
||||
|
||||
//[FieldOffset(236)]
|
||||
public float TopShrink;
|
||||
|
||||
//[FieldOffset(240)]
|
||||
public float BottomShrink;
|
||||
|
||||
//[FieldOffset(244)]
|
||||
public float TopRadius;
|
||||
|
||||
//[FieldOffset(248)]
|
||||
public float BottomRadius;
|
||||
|
||||
//[FieldOffset(252)]
|
||||
public float TopRadiusIncreaseSpeed;
|
||||
|
||||
//[FieldOffset(256)]
|
||||
public float BottomRadiusIncreaseSpeed;
|
||||
|
||||
//[FieldOffset(260)]
|
||||
public float TopRiseSpeed;
|
||||
|
||||
//[FieldOffset(264)]
|
||||
public float BottomRiseSpeed;
|
||||
|
||||
//[FieldOffset(268)]
|
||||
public float TextureRepeat;
|
||||
|
||||
//[FieldOffset(272)]
|
||||
//[MarshalAs (UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public float[] Param;
|
||||
}
|
||||
|
||||
public class EffectDefinitionFile
|
||||
{
|
||||
public EffectDefinition[] EffectDefinitions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c47b38acef943118e9374c4113e7b5e
|
||||
timeCreated: 1665782973
|
||||
@@ -0,0 +1,107 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
//#define USE_UNSAFE_BINARY_READER
|
||||
|
||||
namespace Core.DataReader.Data
|
||||
{
|
||||
using System.IO;
|
||||
using Extensions;
|
||||
using Utils;
|
||||
|
||||
public static class EffectDefinitionFileReader
|
||||
{
|
||||
private const int NUM_OF_EFFECTS = 1324;
|
||||
|
||||
public static void Read(byte[] data, int codepage)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
#else
|
||||
using var stream = new MemoryStream(data);
|
||||
using var reader = new BinaryReader(stream);
|
||||
#endif
|
||||
|
||||
var effectDefinitions = new EffectDefinition[NUM_OF_EFFECTS];
|
||||
|
||||
for (var i = 0; i < NUM_OF_EFFECTS; i++)
|
||||
{
|
||||
effectDefinitions[i] = ReadEffectDefinition(reader, codepage);
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static EffectDefinition ReadEffectDefinition(UnsafeBinaryReader reader, int codepage)
|
||||
#else
|
||||
private static EffectDefinition ReadEffectDefinition(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
var effectDefinition = new EffectDefinition();
|
||||
|
||||
effectDefinition.ClassNameCrc = reader.ReadUInt32();
|
||||
effectDefinition.TypeName = reader.ReadString(32, 936);
|
||||
effectDefinition.TypeNameCrc = reader.ReadUInt32();
|
||||
|
||||
// union
|
||||
{
|
||||
var unionStr = reader.ReadString(128, 936);
|
||||
effectDefinition.TextureName = unionStr;
|
||||
effectDefinition.ParticleFileName = unionStr;
|
||||
effectDefinition.SfxFileNamePrefix = unionStr;
|
||||
effectDefinition.VideoFileNamePrefix = unionStr;
|
||||
}
|
||||
|
||||
effectDefinition.FramesPerRow = reader.ReadInt32();
|
||||
effectDefinition.FramesPerColumn = reader.ReadInt32();
|
||||
effectDefinition.FrameCount = reader.ReadInt32();
|
||||
effectDefinition.FramePerSecond = reader.ReadSingle();
|
||||
|
||||
effectDefinition.InitXPosition = reader.ReadSingle();
|
||||
effectDefinition.InitYPosition = reader.ReadSingle();
|
||||
effectDefinition.InitZPosition = reader.ReadSingle();
|
||||
|
||||
// union
|
||||
{
|
||||
var unionFloat = reader.ReadSingle();
|
||||
effectDefinition.InitYRotation = unionFloat;
|
||||
effectDefinition.InitAngle = unionFloat;
|
||||
}
|
||||
|
||||
effectDefinition.InitSize = reader.ReadInt32();
|
||||
effectDefinition.InitColor = reader.ReadUInt32();
|
||||
effectDefinition.MaxQuadCount = reader.ReadInt32();
|
||||
|
||||
effectDefinition.IsValid = reader.ReadBoolean();
|
||||
effectDefinition.IsAdditiveBlend = reader.ReadBoolean();
|
||||
effectDefinition.IsBillboard = reader.ReadBoolean();
|
||||
effectDefinition.IsZTestIgnored = reader.ReadBoolean();
|
||||
|
||||
effectDefinition.InitXRotation = reader.ReadSingle();
|
||||
effectDefinition.InitZRotation = reader.ReadSingle();
|
||||
|
||||
effectDefinition.RotationAngle = reader.ReadSingle();
|
||||
effectDefinition.Width = reader.ReadSingle();
|
||||
effectDefinition.DivisionCount = reader.ReadSingle();
|
||||
effectDefinition.TopShrink = reader.ReadSingle();
|
||||
effectDefinition.BottomShrink = reader.ReadSingle();
|
||||
effectDefinition.TopRadius = reader.ReadSingle();
|
||||
effectDefinition.BottomRadius = reader.ReadSingle();
|
||||
effectDefinition.TopRadiusIncreaseSpeed = reader.ReadSingle();
|
||||
effectDefinition.BottomRadiusIncreaseSpeed = reader.ReadSingle();
|
||||
effectDefinition.TopRiseSpeed = reader.ReadSingle();
|
||||
effectDefinition.BottomRiseSpeed = reader.ReadSingle();
|
||||
|
||||
effectDefinition.TextureRepeat = reader.ReadSingle();
|
||||
|
||||
effectDefinition.Param = new[]
|
||||
{
|
||||
reader.ReadSingle(),
|
||||
reader.ReadSingle(),
|
||||
};
|
||||
|
||||
return effectDefinition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a324f42c7b6346dc8c98a2c6c377c9d6
|
||||
timeCreated: 1665784313
|
||||
@@ -30,7 +30,7 @@ namespace Core.DataReader.Ini
|
||||
IniData iniData = parser.ReadData(reader);
|
||||
|
||||
var actions = new List<ActorAction>();
|
||||
foreach (var section in iniData.Sections
|
||||
foreach (SectionData section in iniData.Sections
|
||||
.Where(s => s.SectionName.StartsWith(ACTION_SECTION_HEADER_PREFIX)))
|
||||
{
|
||||
actions.Add(new ActorAction()
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7033622484af4557882d201a3784de14
|
||||
timeCreated: 1665907414
|
||||
@@ -0,0 +1,44 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Lgt
|
||||
{
|
||||
using GameBox;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public struct LightNode
|
||||
{
|
||||
public Matrix4x4 WorldMatrix;
|
||||
|
||||
public GameBoxLightType LightType;
|
||||
public Color LightColor;
|
||||
public Color AmbientColor;
|
||||
public bool UseDiffuse;
|
||||
public bool UseSpecular;
|
||||
public float NearStart;
|
||||
public float NearEnd;
|
||||
public float FarStart;
|
||||
public float FarEnd;
|
||||
|
||||
public GameBoxLightDecayType LightDecayType;
|
||||
public float DecayRadius;
|
||||
|
||||
public GameBoxLightShapeType LightShapeType;
|
||||
public float Size;
|
||||
public float Falloff;
|
||||
public float AspectRatio;
|
||||
}
|
||||
|
||||
public class LgtFile
|
||||
{
|
||||
public LightNode[] LightNodes { get; }
|
||||
|
||||
public LgtFile(LightNode[] lightNodes)
|
||||
{
|
||||
LightNodes = lightNodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25179e1de24d41698cd68a919c3d0990
|
||||
timeCreated: 1665907430
|
||||
@@ -0,0 +1,83 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#define USE_UNSAFE_BINARY_READER
|
||||
|
||||
namespace Core.DataReader.Lgt
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Extensions;
|
||||
using GameBox;
|
||||
using Utils;
|
||||
|
||||
public static class LgtFileReader
|
||||
{
|
||||
public static LgtFile Read(byte[] data)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
#else
|
||||
using var stream = new MemoryStream(data);
|
||||
using var reader = new BinaryReader(stream);
|
||||
#endif
|
||||
|
||||
var numOfLightNodes = reader.ReadInt32();
|
||||
var lightNodes = new List<LightNode>();
|
||||
|
||||
for (var i = 0; i < numOfLightNodes; i++)
|
||||
{
|
||||
var lightNode = ReadLightNode(reader);
|
||||
|
||||
if (Enum.IsDefined(typeof(GameBoxLightType), lightNode.LightType) &&
|
||||
Enum.IsDefined(typeof(GameBoxLightShapeType), lightNode.LightShapeType))
|
||||
{
|
||||
lightNodes.Add(lightNode);
|
||||
}
|
||||
}
|
||||
|
||||
return new LgtFile(lightNodes.ToArray());
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static LightNode ReadLightNode(UnsafeBinaryReader reader)
|
||||
#else
|
||||
private static LightNode ReadLightNode(BinaryReader reader)
|
||||
#endif
|
||||
{
|
||||
var transformMatrix = new GameBoxMatrix4X4()
|
||||
{
|
||||
Xx = reader.ReadSingle(), Xy = reader.ReadSingle(), Xz = reader.ReadSingle(), Xw = reader.ReadSingle(),
|
||||
Yx = reader.ReadSingle(), Yy = reader.ReadSingle(), Yz = reader.ReadSingle(), Yw = reader.ReadSingle(),
|
||||
Zx = reader.ReadSingle(), Zy = reader.ReadSingle(), Zz = reader.ReadSingle(), Zw = reader.ReadSingle(),
|
||||
Tx = reader.ReadSingle(), Ty = reader.ReadSingle(), Tz = reader.ReadSingle(), Tw = reader.ReadSingle()
|
||||
};
|
||||
transformMatrix.Tw = 1f;
|
||||
|
||||
var lightNode = new LightNode
|
||||
{
|
||||
WorldMatrix = GameBoxInterpreter.ToUnityMatrix4x4(transformMatrix),
|
||||
LightType = (GameBoxLightType)reader.ReadInt32(),
|
||||
LightColor = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
AmbientColor = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
UseDiffuse = reader.ReadBoolean(),
|
||||
UseSpecular = reader.ReadBoolean(),
|
||||
NearStart = reader.ReadSingle(),
|
||||
NearEnd = reader.ReadSingle(),
|
||||
FarStart = reader.ReadSingle(),
|
||||
FarEnd = reader.ReadSingle(),
|
||||
LightDecayType = (GameBoxLightDecayType)reader.ReadInt32(),
|
||||
DecayRadius = reader.ReadSingle(),
|
||||
LightShapeType = (GameBoxLightShapeType)reader.ReadInt32(),
|
||||
Size = reader.ReadSingle(),
|
||||
Falloff = reader.ReadSingle(),
|
||||
AspectRatio = reader.ReadSingle()
|
||||
};
|
||||
|
||||
return lightNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f29568c4d19d4fcca931e8bf250ccc01
|
||||
timeCreated: 1665907439
|
||||
@@ -81,13 +81,13 @@ namespace Core.DataReader.Mv3
|
||||
public Mv3Attribute[] Attributes;
|
||||
public Mv3VertFrame[] Frames;
|
||||
public Vector2[] TexCoords;
|
||||
public Vector3[] Normals;
|
||||
}
|
||||
|
||||
public struct VertexAnimationKeyFrame
|
||||
{
|
||||
public uint Tick;
|
||||
public Vector3[] Vertices;
|
||||
public Vector3[] Normals;
|
||||
public int[] Triangles;
|
||||
public Vector2[] Uv;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Core.DataReader.Mv3
|
||||
|
||||
public static class Mv3FileReader
|
||||
{
|
||||
public static Mv3File Read(byte[] data)
|
||||
public static Mv3File Read(byte[] data, int codepage)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
@@ -54,28 +54,29 @@ namespace Core.DataReader.Mv3
|
||||
var animationEvents = new Mv3AnimationEvent[numberOfAnimationEvents];
|
||||
for (var i = 0; i < numberOfAnimationEvents; i++)
|
||||
{
|
||||
animationEvents[i] = ReadAnimationEvent(reader);
|
||||
animationEvents[i] = ReadAnimationEvent(reader, codepage);
|
||||
}
|
||||
|
||||
var tagNodes = new Mv3TagNode[numberOfTagNodes];
|
||||
for (var i = 0; i < numberOfTagNodes; i++)
|
||||
{
|
||||
tagNodes[i] = ReadTagNode(reader);
|
||||
tagNodes[i] = ReadTagNode(reader, codepage);
|
||||
}
|
||||
|
||||
var materials = new Mv3Material[numberOfMaterials];
|
||||
for (var i = 0; i < numberOfMaterials; i++)
|
||||
{
|
||||
materials[i] = ReadMaterial(reader);
|
||||
materials[i] = ReadMaterial(reader, codepage);
|
||||
}
|
||||
|
||||
var meshes = new Mv3Mesh[numberOfMeshes];
|
||||
var meshKeyFrames = new VertexAnimationKeyFrame[numberOfMeshes][];
|
||||
for (var i = 0; i < numberOfMeshes; i++)
|
||||
{
|
||||
var mesh = ReadMesh(reader);
|
||||
meshes[i] = mesh;
|
||||
Mv3Mesh mesh = ReadMesh(reader, codepage);
|
||||
meshKeyFrames[i] = CalculateKeyFrameVertices(mesh);
|
||||
mesh.Normals = Utility.CalculateNormals(meshKeyFrames[i][0].Vertices, meshKeyFrames[i][0].Triangles);
|
||||
meshes[i] = mesh;
|
||||
}
|
||||
|
||||
return new Mv3File(version,
|
||||
@@ -88,12 +89,12 @@ namespace Core.DataReader.Mv3
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static Mv3Mesh ReadMesh(UnsafeBinaryReader reader)
|
||||
private static Mv3Mesh ReadMesh(UnsafeBinaryReader reader, int codepage)
|
||||
#else
|
||||
private static Mv3Mesh ReadMesh(BinaryReader reader)
|
||||
private static Mv3Mesh ReadMesh(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
var name = reader.ReadGbkString(64);
|
||||
var name = reader.ReadString(64, codepage);
|
||||
var numberOfVertices = reader.ReadInt32();
|
||||
var boundBox = new GameBoxAABBox()
|
||||
{
|
||||
@@ -185,38 +186,28 @@ namespace Core.DataReader.Mv3
|
||||
{
|
||||
var triangles = new List<int>();
|
||||
var texCoords = mv3Mesh.TexCoords;
|
||||
var indexMap = new Dictionary<int, int>();
|
||||
var keyFrameInfo = new List<(Vector3 vertex, Vector2 uv)>[mv3Mesh.Frames.Length]
|
||||
.Select(item=>new List<(Vector3 vertex, Vector2 uv)>()).ToArray();
|
||||
|
||||
var triangleIndex = 0;
|
||||
|
||||
for (var i = 0; i < mv3Mesh.Attributes[0].IndexBuffers.Length; i++)
|
||||
{
|
||||
var indexBuffer = mv3Mesh.Attributes[0].IndexBuffers[i];
|
||||
Mv3IndexBuffer indexBuffer = mv3Mesh.Attributes[0].IndexBuffers[i];
|
||||
for (var j = 0; j < 3; j++)
|
||||
{
|
||||
var hash = indexBuffer.TriangleIndex[j] * texCoords.Length + indexBuffer.TexCoordIndex[j];
|
||||
if (indexMap.ContainsKey(hash))
|
||||
for (var k = 0; k < mv3Mesh.Frames.Length; k++)
|
||||
{
|
||||
triangles.Add(indexMap[hash]);
|
||||
Mv3VertFrame frame = mv3Mesh.Frames[k];
|
||||
Mv3Vert vertex = frame.Vertices[indexBuffer.TriangleIndex[j]];
|
||||
|
||||
keyFrameInfo[k].Add((GameBoxInterpreter
|
||||
.ToUnityVertex(new Vector3(vertex.X, vertex.Y, vertex.Z),
|
||||
GameBoxInterpreter.GameBoxMv3UnitToUnityUnit),
|
||||
texCoords[indexBuffer.TexCoordIndex[j]]));
|
||||
}
|
||||
else
|
||||
{
|
||||
var index = indexMap.Keys.Count;
|
||||
|
||||
for (var k = 0; k < mv3Mesh.Frames.Length; k++)
|
||||
{
|
||||
var frame = mv3Mesh.Frames[k];
|
||||
var vertex = frame.Vertices[indexBuffer.TriangleIndex[j]];
|
||||
|
||||
keyFrameInfo[k].Add((GameBoxInterpreter
|
||||
.ToUnityVertex(new Vector3(vertex.X, vertex.Y, vertex.Z),
|
||||
GameBoxInterpreter.GameBoxMv3UnitToUnityUnit),
|
||||
texCoords[indexBuffer.TexCoordIndex[j]]));
|
||||
}
|
||||
|
||||
indexMap[hash] = index;
|
||||
triangles.Add(index);
|
||||
}
|
||||
triangles.Add(triangleIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,12 +229,12 @@ namespace Core.DataReader.Mv3
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static Mv3TagNode ReadTagNode(UnsafeBinaryReader reader)
|
||||
private static Mv3TagNode ReadTagNode(UnsafeBinaryReader reader, int codepage)
|
||||
#else
|
||||
private static Mv3TagNode ReadTagNode(BinaryReader reader)
|
||||
private static Mv3TagNode ReadTagNode(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
var nodeName = reader.ReadGbkString(64);
|
||||
var nodeName = reader.ReadString(64, codepage);
|
||||
var flipScale = reader.ReadSingle();
|
||||
var numberOfFrames = reader.ReadInt32();
|
||||
|
||||
@@ -268,7 +259,7 @@ namespace Core.DataReader.Mv3
|
||||
#endif
|
||||
{
|
||||
var tick = reader.ReadUInt32();
|
||||
var position = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3());
|
||||
Vector3 position = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3());
|
||||
|
||||
var rotation = new GameBoxQuaternion()
|
||||
{
|
||||
@@ -295,9 +286,9 @@ namespace Core.DataReader.Mv3
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static Mv3AnimationEvent ReadAnimationEvent(UnsafeBinaryReader reader)
|
||||
private static Mv3AnimationEvent ReadAnimationEvent(UnsafeBinaryReader reader, int codepage)
|
||||
#else
|
||||
private static Mv3AnimationEvent ReadAnimationEvent(BinaryReader reader)
|
||||
private static Mv3AnimationEvent ReadAnimationEvent(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
var tick = reader.ReadUInt32();
|
||||
@@ -306,14 +297,14 @@ namespace Core.DataReader.Mv3
|
||||
return new Mv3AnimationEvent()
|
||||
{
|
||||
Tick = tick,
|
||||
Name = Utility.ConvertToGbkString(name)
|
||||
Name = Utility.ConvertToString(name, codepage)
|
||||
};
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static Mv3Material ReadMaterial(UnsafeBinaryReader reader)
|
||||
private static Mv3Material ReadMaterial(UnsafeBinaryReader reader, int codepage)
|
||||
#else
|
||||
private static Mv3Material ReadMaterial(BinaryReader reader)
|
||||
private static Mv3Material ReadMaterial(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
var material = new GameBoxMaterial()
|
||||
@@ -342,7 +333,7 @@ namespace Core.DataReader.Mv3
|
||||
}
|
||||
else
|
||||
{
|
||||
textureName = reader.ReadGbkString(length);
|
||||
textureName = reader.ReadString(length, codepage);
|
||||
}
|
||||
|
||||
textureNames.Add(textureName);
|
||||
|
||||
@@ -7,9 +7,11 @@ namespace Core.DataReader.Nav
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Extensions;
|
||||
using GameBox;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
public static class NavFileReader
|
||||
{
|
||||
@@ -65,8 +67,8 @@ namespace Core.DataReader.Nav
|
||||
}
|
||||
}
|
||||
|
||||
var max = reader.ReadVector3();
|
||||
var min = reader.ReadVector3();
|
||||
Vector3 max = reader.ReadVector3();
|
||||
Vector3 min = reader.ReadVector3();
|
||||
|
||||
var width = reader.ReadInt32();
|
||||
var height = reader.ReadInt32();
|
||||
@@ -106,7 +108,7 @@ namespace Core.DataReader.Nav
|
||||
var vertices = new Vector3[numberOfVertices];
|
||||
for (var i = 0; i < numberOfVertices; i++)
|
||||
{
|
||||
vertices[i] = reader.ReadVector3();
|
||||
vertices[i] = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3());
|
||||
}
|
||||
|
||||
var triangles = new int[numberOfFaces * 3];
|
||||
@@ -118,6 +120,25 @@ namespace Core.DataReader.Nav
|
||||
triangles[index + 2] = reader.ReadUInt16();
|
||||
}
|
||||
|
||||
// Some of the nav meshes in the original game are upside down (don't know why),
|
||||
// so we need to flip them if that's the case. You might argue that we can just
|
||||
// make the mesh double sided, but that would cause some other issues (trust me).
|
||||
{
|
||||
Vector3[] normals = Utility.CalculateNormals(vertices, triangles);
|
||||
|
||||
for (var i = 0; i < numberOfFaces; i++)
|
||||
{
|
||||
var index = i * 3;
|
||||
if (normals[triangles[index]].y +
|
||||
normals[triangles[index + 1]].y +
|
||||
normals[triangles[index + 2]].y < 0)
|
||||
{
|
||||
// Change the winding order of the face.
|
||||
(triangles[index], triangles[index + 1]) = (triangles[index + 1], triangles[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new NavFaceLayer()
|
||||
{
|
||||
Vertices = vertices,
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace Core.DataReader.Pol
|
||||
{
|
||||
public Vector3[] Positions;
|
||||
public Vector3[] Normals;
|
||||
public float[] Radii;
|
||||
public Color32[] DiffuseColors;
|
||||
public Color32[] SpecularColors;
|
||||
public Vector2[][] Uvs;
|
||||
@@ -44,7 +43,7 @@ namespace Core.DataReader.Pol
|
||||
|
||||
public struct PolTexture
|
||||
{
|
||||
public uint BlendFlag; // 0--opaque, 1--alpha blend, 2--invert color blend, 3--add
|
||||
public GameBoxBlendFlag BlendFlag; // 0--opaque, 1--alpha blend, 2--invert color blend, 3--add
|
||||
public GameBoxMaterial Material;
|
||||
public string[] TextureNames;
|
||||
public int VertStart;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Core.DataReader.Pol
|
||||
|
||||
public static class PolFileReader
|
||||
{
|
||||
public static PolFile Read(byte[] data)
|
||||
public static PolFile Read(byte[] data, int codepage)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
@@ -41,8 +41,8 @@ namespace Core.DataReader.Pol
|
||||
{
|
||||
nodeInfos[i] = new PolGeometryNode
|
||||
{
|
||||
Name = reader.ReadGbkString(32),
|
||||
Position = reader.ReadVector3(),
|
||||
Name = reader.ReadString(32, codepage),
|
||||
Position = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3()),
|
||||
Radius = reader.ReadSingle(),
|
||||
Offset = reader.ReadInt32()
|
||||
};
|
||||
@@ -57,7 +57,7 @@ namespace Core.DataReader.Pol
|
||||
tagNodes = new TagNode[numberOfTagNodes];
|
||||
for (var i = 0; i < numberOfTagNodes; i++)
|
||||
{
|
||||
tagNodes[i] = ReadTagNodeInfo(reader);
|
||||
tagNodes[i] = ReadTagNodeInfo(reader, codepage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,27 +65,27 @@ namespace Core.DataReader.Pol
|
||||
var meshInfos = new PolMesh[numberOfNodes];
|
||||
for (var i = 0; i < numberOfNodes; i++)
|
||||
{
|
||||
meshInfos[i] = ReadMeshData(reader, version);
|
||||
meshInfos[i] = ReadMeshData(reader, version, codepage);
|
||||
}
|
||||
|
||||
return new PolFile(version, nodeInfos, meshInfos, tagNodes);
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static TagNode ReadTagNodeInfo(UnsafeBinaryReader reader)
|
||||
private static TagNode ReadTagNodeInfo(UnsafeBinaryReader reader, int codepage)
|
||||
#else
|
||||
private static TagNode ReadTagNodeInfo(BinaryReader reader)
|
||||
private static TagNode ReadTagNodeInfo(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
var name = reader.ReadGbkString(32);
|
||||
var transformMatrix = GameBoxInterpreter.ToUnityMatrix4x4(new GameBoxMatrix4X4()
|
||||
var name = reader.ReadString(32, codepage);
|
||||
Matrix4x4 transformMatrix = GameBoxInterpreter.ToUnityMatrix4x4(new GameBoxMatrix4X4()
|
||||
{
|
||||
Xx = reader.ReadSingle(), Xy = reader.ReadSingle(), Xz = reader.ReadSingle(), Xw = reader.ReadSingle(),
|
||||
Yx = reader.ReadSingle(), Yy = reader.ReadSingle(), Yz = reader.ReadSingle(), Yw = reader.ReadSingle(),
|
||||
Zx = reader.ReadSingle(), Zy = reader.ReadSingle(), Zz = reader.ReadSingle(), Zw = reader.ReadSingle(),
|
||||
Tx = reader.ReadSingle(), Ty = reader.ReadSingle(), Tz = reader.ReadSingle(), Tw = reader.ReadSingle()
|
||||
});
|
||||
var origin = GameBoxInterpreter.ToUnityPosition(transformMatrix.MultiplyPoint(Vector3.zero));
|
||||
Vector3 origin = GameBoxInterpreter.ToUnityPosition(transformMatrix.MultiplyPoint(Vector3.zero));
|
||||
|
||||
var type = reader.ReadInt32();
|
||||
var customColorStringLength = reader.ReadInt32();
|
||||
@@ -116,9 +116,9 @@ namespace Core.DataReader.Pol
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static PolMesh ReadMeshData(UnsafeBinaryReader reader, int version)
|
||||
private static PolMesh ReadMeshData(UnsafeBinaryReader reader, int version, int codepage)
|
||||
#else
|
||||
private static PolMesh ReadMeshData(BinaryReader reader, int version)
|
||||
private static PolMesh ReadMeshData(BinaryReader reader, int version, int codepage)
|
||||
#endif
|
||||
{
|
||||
var boundBox = new GameBoxAABBox()
|
||||
@@ -137,7 +137,6 @@ namespace Core.DataReader.Pol
|
||||
var positions = new Vector3[numberOfVertices];
|
||||
var normals = new Vector3[numberOfVertices];
|
||||
var diffuseColors = new Color32[numberOfVertices];
|
||||
var radii = new float[numberOfVertices];
|
||||
var specularColors = new Color32[numberOfVertices];
|
||||
var uvs = new Vector2[4][];
|
||||
|
||||
@@ -163,9 +162,7 @@ namespace Core.DataReader.Pol
|
||||
}
|
||||
if ((vertexTypeFlag & GameBoxVertexType.Normal) != 0)
|
||||
{
|
||||
normals[i] = GameBoxInterpreter
|
||||
.ToUnityVertex(reader.ReadVector3(),
|
||||
GameBoxInterpreter.GameBoxUnitToUnityUnit);
|
||||
normals[i] = GameBoxInterpreter.ToUnityNormal(reader.ReadVector3());
|
||||
}
|
||||
if ((vertexTypeFlag & GameBoxVertexType.Diffuse) != 0)
|
||||
{
|
||||
@@ -199,6 +196,9 @@ namespace Core.DataReader.Pol
|
||||
var y = reader.ReadSingle();
|
||||
uvs[3][i] = new Vector2(x, y);
|
||||
}
|
||||
|
||||
// Quick fix for the missing/wrong normals
|
||||
if (normals[i] == Vector3.zero) normals[i] = Vector3.up;
|
||||
}
|
||||
|
||||
var vertexInfo = new PolVertexInfo()
|
||||
@@ -206,7 +206,6 @@ namespace Core.DataReader.Pol
|
||||
Positions = positions,
|
||||
Normals = normals,
|
||||
DiffuseColors = diffuseColors,
|
||||
Radii = radii,
|
||||
SpecularColors = specularColors,
|
||||
Uvs = uvs,
|
||||
};
|
||||
@@ -217,7 +216,7 @@ namespace Core.DataReader.Pol
|
||||
|
||||
for (var i = 0; i < numberOfTextures; i++)
|
||||
{
|
||||
textureInfos[i] = ReadTextureInfo(reader, version);
|
||||
textureInfos[i] = ReadTextureInfo(reader, version, codepage);
|
||||
}
|
||||
|
||||
return new PolMesh
|
||||
@@ -230,12 +229,12 @@ namespace Core.DataReader.Pol
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static PolTexture ReadTextureInfo(UnsafeBinaryReader reader, int version)
|
||||
private static PolTexture ReadTextureInfo(UnsafeBinaryReader reader, int version, int codepage)
|
||||
#else
|
||||
private static PolTexture ReadTextureInfo(BinaryReader reader, int version)
|
||||
private static PolTexture ReadTextureInfo(BinaryReader reader, int version, int codepage)
|
||||
#endif
|
||||
{
|
||||
var blendFlag = reader.ReadUInt32();
|
||||
var blendFlag = (GameBoxBlendFlag)reader.ReadUInt32();
|
||||
|
||||
var material = new GameBoxMaterial()
|
||||
{
|
||||
@@ -255,7 +254,7 @@ namespace Core.DataReader.Pol
|
||||
|
||||
for (var i = 0; i < numberOfTextures; i++)
|
||||
{
|
||||
var textureName = reader.ReadGbkString(64);
|
||||
var textureName = reader.ReadString(64, codepage);
|
||||
textureNames[i] = textureName;
|
||||
}
|
||||
|
||||
@@ -270,13 +269,13 @@ namespace Core.DataReader.Pol
|
||||
for (var i = 0; i < numberOfFaces; i++)
|
||||
{
|
||||
var index = i * 3;
|
||||
var x = reader.ReadInt16();
|
||||
var y = reader.ReadInt16();
|
||||
var z = reader.ReadInt16();
|
||||
(triangles[index], triangles[index + 1], triangles[index + 2]) =
|
||||
GameBoxInterpreter.ToUnityTriangle((x, y, z));
|
||||
triangles[index] = reader.ReadInt16();
|
||||
triangles[index + 1] = reader.ReadInt16();
|
||||
triangles[index + 2] = reader.ReadInt16();
|
||||
}
|
||||
|
||||
GameBoxInterpreter.ToUnityTriangles(triangles);
|
||||
|
||||
return new PolTexture()
|
||||
{
|
||||
BlendFlag = blendFlag,
|
||||
|
||||
@@ -43,18 +43,20 @@ namespace Core.DataReader.Sce
|
||||
{
|
||||
public SceIndex[] Indexes { get; }
|
||||
public Dictionary<uint, SceScriptBlock> ScriptBlocks { get; }
|
||||
public int Codepage { get; }
|
||||
|
||||
public SceFile(SceIndex[] indexes, SceScriptBlock[] scriptBlocks)
|
||||
public SceFile(SceIndex[] indexes, SceScriptBlock[] scriptBlocks, int codepage)
|
||||
{
|
||||
Indexes = indexes;
|
||||
|
||||
var scriptBlocksDic = new Dictionary<uint, SceScriptBlock>();
|
||||
foreach (var block in scriptBlocks)
|
||||
foreach (SceScriptBlock block in scriptBlocks)
|
||||
{
|
||||
scriptBlocksDic[block.Id] = block;
|
||||
}
|
||||
|
||||
ScriptBlocks = scriptBlocksDic;
|
||||
Codepage = codepage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace Core.DataReader.Sce
|
||||
|
||||
public static class SceFileReader
|
||||
{
|
||||
public static SceFile Read(Stream stream)
|
||||
public static SceFile Read(Stream stream, int codepage)
|
||||
{
|
||||
using var reader = new BinaryReader(stream);
|
||||
|
||||
@@ -34,25 +34,25 @@ namespace Core.DataReader.Sce
|
||||
var indexes = new SceIndex[numberOfBlocks];
|
||||
for (var i = 0; i < numberOfBlocks; i++)
|
||||
{
|
||||
indexes[i] = ReadSceIndex(reader);
|
||||
indexes[i] = ReadSceIndex(reader, codepage);
|
||||
}
|
||||
|
||||
var scriptBlocks = new SceScriptBlock[numberOfBlocks];
|
||||
for (var i = 0; i < numberOfBlocks; i++)
|
||||
{
|
||||
scriptBlocks[i] = ReadScriptBlock(reader, indexes[i]);
|
||||
scriptBlocks[i] = ReadScriptBlock(reader, indexes[i], codepage);
|
||||
}
|
||||
|
||||
return new SceFile(indexes, scriptBlocks);
|
||||
return new SceFile(indexes, scriptBlocks, codepage);
|
||||
}
|
||||
|
||||
private static SceScriptBlock ReadScriptBlock(BinaryReader reader, SceIndex sceIndex)
|
||||
private static SceScriptBlock ReadScriptBlock(BinaryReader reader, SceIndex sceIndex, int codepage)
|
||||
{
|
||||
reader.BaseStream.Seek(sceIndex.Offset, SeekOrigin.Begin);
|
||||
|
||||
var id = reader.ReadUInt32();
|
||||
var descriptionLength = reader.ReadUInt16();
|
||||
var description = reader.ReadGbkString(descriptionLength);
|
||||
var description = reader.ReadString(descriptionLength, codepage);
|
||||
var numberOfUserVars = reader.ReadUInt16();
|
||||
|
||||
var userVarInfos = new SceUserVarInfo[numberOfUserVars];
|
||||
@@ -86,13 +86,13 @@ namespace Core.DataReader.Sce
|
||||
};
|
||||
}
|
||||
|
||||
private static SceIndex ReadSceIndex(BinaryReader reader)
|
||||
private static SceIndex ReadSceIndex(BinaryReader reader, int codepage)
|
||||
{
|
||||
return new SceIndex()
|
||||
{
|
||||
Id = reader.ReadUInt32(),
|
||||
Offset = reader.ReadUInt32(),
|
||||
Description = reader.ReadGbkString(64)
|
||||
Description = reader.ReadString(64, codepage)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
namespace Core.DataReader.Scn
|
||||
{
|
||||
using System;
|
||||
using GameBox;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
@@ -59,7 +60,7 @@ namespace Core.DataReader.Scn
|
||||
RotatingStoneBeam = 7, // 旋传石梁 (一字型)
|
||||
RotatingWall = 8, // 旋转墙 (折尺型,JG13)
|
||||
PreciseTrigger = 9, // 精确触发点
|
||||
Tuyere = 10, // 风口
|
||||
WindBlower = 10, // 风口
|
||||
Pushable = 11, // 推箱子
|
||||
SpecialMechanism = 12, // 主角特技机关
|
||||
ImpulsiveMechanism = 13, // 冲撞
|
||||
@@ -139,6 +140,39 @@ namespace Core.DataReader.Scn
|
||||
public int LightMap; // 0日景灯光, 1夜景灯光, -1不知道是什么意思(比如M01)
|
||||
public uint SkyBox;
|
||||
public uint[] Reserved; // 6 DWORDs
|
||||
|
||||
/// <summary>
|
||||
/// Check if two scene share the same model.
|
||||
/// </summary>
|
||||
/// <param name="sceneInfo">ScnSceneInfo</param>
|
||||
/// <returns>True if two scene share the same model</returns>
|
||||
public bool ModelEquals(ScnSceneInfo sceneInfo)
|
||||
{
|
||||
#if PAL3
|
||||
return string.Equals(CityName, sceneInfo.CityName, StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(Model, sceneInfo.Model, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
#elif PAL3A
|
||||
var modelAName = Model;
|
||||
if (modelAName.EndsWith("y", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
modelAName = modelAName[..^1];
|
||||
}
|
||||
var modelBName = sceneInfo.Model;
|
||||
if (modelBName.EndsWith("y", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
modelBName = modelBName[..^1];
|
||||
|
||||
}
|
||||
return string.Equals(CityName, sceneInfo.CityName, StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(modelAName, modelBName, StringComparison.OrdinalIgnoreCase);
|
||||
#endif
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{CityName.ToLower()}_{Name.ToLower()}_{LightMap}";
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Core.DataReader.Scn
|
||||
|
||||
public static class ScnFileReader
|
||||
{
|
||||
public static ScnFile Read(Stream stream)
|
||||
public static ScnFile Read(Stream stream, int codepage)
|
||||
{
|
||||
using var reader = new BinaryReader(stream);
|
||||
|
||||
@@ -32,9 +32,9 @@ namespace Core.DataReader.Scn
|
||||
|
||||
var sceneInfo = new ScnSceneInfo()
|
||||
{
|
||||
CityName = reader.ReadGbkString(32),
|
||||
Name = reader.ReadGbkString(32),
|
||||
Model = reader.ReadGbkString(32),
|
||||
CityName = reader.ReadString(32, codepage),
|
||||
Name = reader.ReadString(32, codepage),
|
||||
Model = reader.ReadString(32, codepage),
|
||||
SceneType = (ScnSceneType) reader.ReadInt32(),
|
||||
LightMap = reader.ReadInt32(),
|
||||
SkyBox = reader.ReadUInt32(),
|
||||
@@ -45,7 +45,7 @@ namespace Core.DataReader.Scn
|
||||
var npcInfos = new ScnNpcInfo[numberOfNpc];
|
||||
for (var i = 0; i < numberOfNpc; i++)
|
||||
{
|
||||
var npcInfo = ReadNpcInfo(reader);
|
||||
ScnNpcInfo npcInfo = ReadNpcInfo(reader, codepage);
|
||||
if (npcInfo.Unknown1[0] != 0 ||
|
||||
npcInfo.Unknown1[1] != 0 ||
|
||||
npcInfo.Unknown2[0] != 0 ||
|
||||
@@ -61,21 +61,21 @@ namespace Core.DataReader.Scn
|
||||
var objInfos = new ScnObjectInfo[numberOfObjects];
|
||||
for (var i = 0; i < numberOfObjects; i++)
|
||||
{
|
||||
var sceneObject = ReadObjectInfo(reader);
|
||||
ScnObjectInfo sceneObject = ReadObjectInfo(reader, codepage);
|
||||
objInfos[i] = sceneObject;
|
||||
}
|
||||
|
||||
return new ScnFile(sceneInfo, npcInfos, objInfos);
|
||||
}
|
||||
|
||||
private static ScnNpcInfo ReadNpcInfo(BinaryReader reader)
|
||||
private static ScnNpcInfo ReadNpcInfo(BinaryReader reader, int codepage)
|
||||
{
|
||||
return new ScnNpcInfo()
|
||||
{
|
||||
Id = reader.ReadByte(),
|
||||
Kind = (ScnActorKind)reader.ReadByte(),
|
||||
Name = reader.ReadGbkString(32),
|
||||
Texture = reader.ReadGbkString(32),
|
||||
Name = reader.ReadString(32, codepage),
|
||||
Texture = reader.ReadString(32, codepage),
|
||||
Unknown1 = reader.ReadBytes(2),
|
||||
FacingDirection = reader.ReadSingle(),
|
||||
OnLayer = reader.ReadByte(),
|
||||
@@ -86,7 +86,7 @@ namespace Core.DataReader.Scn
|
||||
InitBehaviour = (ScnActorBehaviour) reader.ReadInt32(),
|
||||
ScriptId = reader.ReadUInt32(),
|
||||
PositionY = reader.ReadSingle(),
|
||||
InitAction = reader.ReadGbkString(16),
|
||||
InitAction = reader.ReadString(16, codepage),
|
||||
MonsterId = reader.ReadUInt32Array(3),
|
||||
MonsterNumber = reader.ReadUInt16(),
|
||||
MonsterRepeat = reader.ReadUInt16(),
|
||||
@@ -102,7 +102,7 @@ namespace Core.DataReader.Scn
|
||||
};
|
||||
}
|
||||
|
||||
private static ScnObjectInfo ReadObjectInfo(BinaryReader reader)
|
||||
private static ScnObjectInfo ReadObjectInfo(BinaryReader reader, int codepage)
|
||||
{
|
||||
#if PAL3
|
||||
return new ScnObjectInfo()
|
||||
@@ -112,7 +112,7 @@ namespace Core.DataReader.Scn
|
||||
Times = reader.ReadByte(),
|
||||
Switch = reader.ReadByte(),
|
||||
|
||||
Name = reader.ReadGbkString(32),
|
||||
Name = reader.ReadString(32, codepage),
|
||||
TriggerType = reader.ReadUInt16(),
|
||||
NonBlocking = reader.ReadUInt16(),
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Core.DataReader.Scn
|
||||
NeedLv = reader.ReadUInt16(),
|
||||
NeedWu = reader.ReadUInt16(),
|
||||
NeedAllOpen = reader.ReadUInt16(),
|
||||
FailedMessage = reader.ReadGbkString(16),
|
||||
FailedMessage = reader.ReadString(16, codepage),
|
||||
|
||||
ScriptId = reader.ReadUInt32(),
|
||||
Path = new ScnPath()
|
||||
@@ -149,7 +149,7 @@ namespace Core.DataReader.Scn
|
||||
},
|
||||
|
||||
LinkedObject = reader.ReadUInt16(),
|
||||
DependentSceneName = reader.ReadGbkString(32),
|
||||
DependentSceneName = reader.ReadString(32, codepage),
|
||||
DependentId = reader.ReadUInt16(),
|
||||
|
||||
BoundBox = new GameBoxAABBox()
|
||||
@@ -159,7 +159,7 @@ namespace Core.DataReader.Scn
|
||||
},
|
||||
|
||||
XRotation = reader.ReadSingle(),
|
||||
SfxName = reader.ReadGbkString(8),
|
||||
SfxName = reader.ReadString(8, codepage),
|
||||
EffectModelType = reader.ReadUInt32(),
|
||||
|
||||
ScriptChangeActive = reader.ReadUInt32(),
|
||||
@@ -175,7 +175,7 @@ namespace Core.DataReader.Scn
|
||||
Times = reader.ReadByte(),
|
||||
Switch = reader.ReadByte(),
|
||||
|
||||
Name = reader.ReadGbkString(32),
|
||||
Name = reader.ReadString(32, codepage),
|
||||
TriggerType = reader.ReadUInt16(),
|
||||
NonBlocking = reader.ReadUInt16(),
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace Core.DataReader.Scn
|
||||
NeedLv = reader.ReadUInt16(),
|
||||
NeedWu = reader.ReadUInt16(),
|
||||
NeedAllOpen = reader.ReadUInt16(),
|
||||
FailedMessage = reader.ReadGbkString(16),
|
||||
FailedMessage = reader.ReadString(16, codepage),
|
||||
|
||||
// TODO
|
||||
Unknown2 = reader.ReadBytes(4),
|
||||
@@ -218,7 +218,7 @@ namespace Core.DataReader.Scn
|
||||
},
|
||||
|
||||
LinkedObject = reader.ReadUInt16(),
|
||||
DependentSceneName = reader.ReadGbkString(32),
|
||||
DependentSceneName = reader.ReadString(32, codepage),
|
||||
DependentId = reader.ReadUInt16(),
|
||||
|
||||
BoundBox = new GameBoxAABBox()
|
||||
@@ -229,7 +229,7 @@ namespace Core.DataReader.Scn
|
||||
|
||||
XRotation = reader.ReadSingle(),
|
||||
ZRotation = reader.ReadSingle(),
|
||||
SfxName = reader.ReadGbkString(8),
|
||||
SfxName = reader.ReadString(8, codepage),
|
||||
EffectModelType = reader.ReadUInt32(),
|
||||
|
||||
ScriptChangeActive = reader.ReadUInt32(),
|
||||
|
||||
@@ -14,8 +14,6 @@ namespace Core.Extensions
|
||||
/// </summary>
|
||||
public static class BinaryReaderExtension
|
||||
{
|
||||
private const int GBK_CODE_PAGE = 936; // GBK Encoding's code page
|
||||
|
||||
public static Vector3 ReadVector3(this BinaryReader binaryReader)
|
||||
{
|
||||
var x = binaryReader.ReadSingle();
|
||||
@@ -86,13 +84,13 @@ namespace Core.Extensions
|
||||
return new string(binaryReader.ReadChars(count));
|
||||
}
|
||||
|
||||
public static string ReadGbkString(this BinaryReader binaryReader, int count)
|
||||
public static string ReadString(this BinaryReader binaryReader, int count, int codepage)
|
||||
{
|
||||
var strBytes = binaryReader.ReadBytes(count);
|
||||
var i = 0;
|
||||
var length = strBytes.Length;
|
||||
while (i < length && strBytes[i] != 0) i++;
|
||||
return Encoding.GetEncoding(GBK_CODE_PAGE).GetString(strBytes, 0, i);
|
||||
return Encoding.GetEncoding(codepage).GetString(strBytes, 0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,9 @@ namespace Core.FileSystem
|
||||
|
||||
public CpkFileSystem(string rootPath, CrcHash crcHash)
|
||||
{
|
||||
rootPath = !string.IsNullOrEmpty(rootPath) ? rootPath : throw new ArgumentNullException(nameof(rootPath));
|
||||
crcHash = crcHash ?? throw new ArgumentNullException(nameof(crcHash));
|
||||
|
||||
if (!rootPath.EndsWith(Path.DirectorySeparatorChar))
|
||||
{
|
||||
rootPath += Path.DirectorySeparatorChar;
|
||||
@@ -53,18 +56,19 @@ namespace Core.FileSystem
|
||||
/// Mount a Cpk archive to the file system.
|
||||
/// </summary>
|
||||
/// <param name="cpkFileRelativePath">CPK file relative path</param>
|
||||
public void Mount(string cpkFileRelativePath)
|
||||
/// <param name="codepage">Codepage CPK file uses for encoding text info</param>
|
||||
public void Mount(string cpkFileRelativePath, int codepage)
|
||||
{
|
||||
var cpkFileName = Path.GetFileName(cpkFileRelativePath).ToLower();
|
||||
|
||||
if (_cpkArchives.ContainsKey(cpkFileName.ToLower()))
|
||||
if (_cpkArchives.ContainsKey(cpkFileName))
|
||||
{
|
||||
Debug.LogWarning($"{cpkFileRelativePath} already mounted.");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"CpkFileSystem mounting: {_rootPath + cpkFileRelativePath}");
|
||||
var cpkArchive = new CpkArchive(_rootPath + cpkFileRelativePath, _crcHash);
|
||||
var cpkArchive = new CpkArchive(_rootPath + cpkFileRelativePath, _crcHash, codepage);
|
||||
cpkArchive.Init();
|
||||
_cpkArchives[cpkFileName] = cpkArchive;
|
||||
}
|
||||
@@ -79,7 +83,7 @@ namespace Core.FileSystem
|
||||
{
|
||||
ParseFileVirtualPath(fileVirtualPath, out var cpkFileName, out var relativeVirtualPath);
|
||||
|
||||
if (_cpkArchives.ContainsKey(cpkFileName.ToLower()))
|
||||
if (_cpkArchives.ContainsKey(cpkFileName))
|
||||
{
|
||||
segmentedArchiveName = null;
|
||||
return false;
|
||||
@@ -87,7 +91,7 @@ namespace Core.FileSystem
|
||||
|
||||
// Check if the file exists in any of the segmented cpk archives.
|
||||
foreach (var subCpkPath in _cpkArchives.Keys
|
||||
.Where(_ => _.StartsWith(cpkFileName[..^".cpk".Length] + '_', StringComparison.OrdinalIgnoreCase)))
|
||||
.Where(_ => _.StartsWith(cpkFileName[..^CpkConstants.FileExtension.Length] + '_', StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var relativePathInSubCpk = relativeVirtualPath.Replace(cpkFileName, subCpkPath);
|
||||
if (_cpkArchives[subCpkPath].FileExists(relativePathInSubCpk))
|
||||
@@ -111,14 +115,14 @@ namespace Core.FileSystem
|
||||
{
|
||||
ParseFileVirtualPath(fileVirtualPath, out var cpkFileName, out var relativeVirtualPath);
|
||||
|
||||
if (_cpkArchives.ContainsKey(cpkFileName.ToLower()))
|
||||
if (_cpkArchives.ContainsKey(cpkFileName))
|
||||
{
|
||||
return _cpkArchives[cpkFileName].FileExists(relativeVirtualPath);
|
||||
}
|
||||
|
||||
// Check if the file exists in any of the segmented cpk archives.
|
||||
foreach (var subCpkPath in _cpkArchives.Keys
|
||||
.Where(_ => _.StartsWith(cpkFileName[..^".cpk".Length] + '_', StringComparison.OrdinalIgnoreCase)))
|
||||
.Where(_ => _.StartsWith(cpkFileName[..^CpkConstants.FileExtension.Length] + '_', StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var relativePathInSubCpk = relativeVirtualPath.Replace(cpkFileName, subCpkPath);
|
||||
if (_cpkArchives[subCpkPath].FileExists(relativePathInSubCpk))
|
||||
@@ -145,7 +149,7 @@ namespace Core.FileSystem
|
||||
|
||||
// Find and read the file content in segmented cpk archives.
|
||||
foreach (var subCpkPath in _cpkArchives.Keys
|
||||
.Where(_ => _.StartsWith(cpkFileName[..^".cpk".Length] + '_', StringComparison.OrdinalIgnoreCase)))
|
||||
.Where(_ => _.StartsWith(cpkFileName[..^CpkConstants.FileExtension.Length] + '_', StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var relativePathInSubCpk = relativeVirtualPath.Replace(cpkFileName, subCpkPath);
|
||||
if (_cpkArchives[subCpkPath].FileExists(relativePathInSubCpk))
|
||||
@@ -194,12 +198,31 @@ namespace Core.FileSystem
|
||||
/// </summary>
|
||||
public void DisposeAllInMemoryArchives()
|
||||
{
|
||||
foreach (var cpkArchive in _cpkArchives.Values)
|
||||
foreach (CpkArchive cpkArchive in _cpkArchives.Values)
|
||||
{
|
||||
cpkArchive.DisposeInMemoryArchive();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract all archives to the specified destination
|
||||
/// </summary>
|
||||
public void ExtractTo(string outputFolder)
|
||||
{
|
||||
foreach ((string cpkFileName, CpkArchive cpkArchive) in _cpkArchives)
|
||||
{
|
||||
var outputDir = outputFolder + cpkFileName + Path.DirectorySeparatorChar;
|
||||
|
||||
if (!Directory.Exists(outputDir))
|
||||
{
|
||||
Directory.CreateDirectory(outputDir);
|
||||
}
|
||||
|
||||
cpkArchive.ExtractTo(outputDir);
|
||||
Debug.Log($"{cpkFileName} extracted to {outputDir}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search files using keyword.
|
||||
/// </summary>
|
||||
@@ -213,7 +236,7 @@ namespace Core.FileSystem
|
||||
{
|
||||
var rootNodes = archive.Value.GetRootEntries();
|
||||
results.Add(from result in SearchInternal(rootNodes, keyword)
|
||||
select archive.Key + CpkConstants.CpkDirectorySeparatorChar + result);
|
||||
select archive.Key + CpkConstants.DirectorySeparator + result);
|
||||
});
|
||||
|
||||
var resultList = new List<string>();
|
||||
@@ -226,17 +249,17 @@ namespace Core.FileSystem
|
||||
|
||||
private void ParseFileVirtualPath(string fullVirtualPath, out string cpkFileName, out string relativeVirtualPath)
|
||||
{
|
||||
if (!fullVirtualPath.Contains(CpkConstants.CpkDirectorySeparatorChar))
|
||||
if (!fullVirtualPath.Contains(CpkConstants.DirectorySeparator))
|
||||
{
|
||||
throw new ArgumentException($"File virtual path is invalid: {fullVirtualPath}.");
|
||||
}
|
||||
cpkFileName = fullVirtualPath[..fullVirtualPath.IndexOf(CpkConstants.CpkDirectorySeparatorChar)].ToLower();
|
||||
relativeVirtualPath = fullVirtualPath[(fullVirtualPath.IndexOf(CpkConstants.CpkDirectorySeparatorChar) + 1)..];
|
||||
cpkFileName = fullVirtualPath[..fullVirtualPath.IndexOf(CpkConstants.DirectorySeparator)].ToLower();
|
||||
relativeVirtualPath = fullVirtualPath[(fullVirtualPath.IndexOf(CpkConstants.DirectorySeparator) + 1)..];
|
||||
}
|
||||
|
||||
private IEnumerable<string> SearchInternal(IEnumerable<CpkEntry> nodes, string keyword)
|
||||
{
|
||||
foreach (var node in nodes)
|
||||
foreach (CpkEntry node in nodes)
|
||||
{
|
||||
if (node.IsDirectory)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,8 @@ namespace Core.FileSystem
|
||||
/// Mount a Cpk archive to the file system.
|
||||
/// </summary>
|
||||
/// <param name="cpkFileRelativePath">CPK file relative path</param>
|
||||
public void Mount(string cpkFileRelativePath);
|
||||
/// <param name="codepage">Codepage CPK file uses for encoding text info</param>
|
||||
public void Mount(string cpkFileRelativePath, int codepage);
|
||||
|
||||
/// <summary>
|
||||
/// Check if file exists in any of the segmented archives using virtual path.
|
||||
@@ -63,6 +64,11 @@ namespace Core.FileSystem
|
||||
/// </summary>
|
||||
public void DisposeAllInMemoryArchives();
|
||||
|
||||
/// <summary>
|
||||
/// Extract all archives to the specified destination
|
||||
/// </summary>
|
||||
public void ExtractTo(string outputFolder);
|
||||
|
||||
/// <summary>
|
||||
/// Search files using keyword.
|
||||
/// </summary>
|
||||
|
||||
@@ -55,6 +55,14 @@ namespace Core.GameBox
|
||||
scale.y);
|
||||
}
|
||||
|
||||
public static Vector3 ToUnityNormal(Vector3 normal)
|
||||
{
|
||||
return new Vector3(
|
||||
-normal.x,
|
||||
normal.y,
|
||||
normal.z);
|
||||
}
|
||||
|
||||
public static Quaternion CvdQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
|
||||
{
|
||||
return new Quaternion(-quaternion.X, quaternion.Z, -quaternion.Y, quaternion.W);
|
||||
@@ -64,6 +72,15 @@ namespace Core.GameBox
|
||||
{
|
||||
return new Quaternion(-quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
|
||||
}
|
||||
|
||||
public static Quaternion LgtQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
|
||||
{
|
||||
var rotation = new Quaternion(quaternion.X, quaternion.Y, -quaternion.Z, quaternion.W);
|
||||
rotation.eulerAngles = new Vector3(rotation.eulerAngles.x + 90f,
|
||||
-rotation.eulerAngles.y,
|
||||
rotation.eulerAngles.z);
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public static Quaternion ToUnityRotation(float pitch, float yaw, float roll)
|
||||
{
|
||||
@@ -77,33 +94,15 @@ namespace Core.GameBox
|
||||
vector3.y / scale,
|
||||
vector3.z / scale);
|
||||
}
|
||||
|
||||
// Since GameBox's rendering pipeline uses different internal axis system
|
||||
// Here we are switching x and y index to minor it back to the Unity axis
|
||||
// for triangles
|
||||
public static (short x, short y, short z) ToUnityTriangle((short x, short y, short z) triangle)
|
||||
{
|
||||
return (triangle.y, triangle.x, triangle.z);
|
||||
}
|
||||
|
||||
|
||||
public static void ToUnityTriangles(List<int> triangles)
|
||||
{
|
||||
for (var i = 0; i < triangles.Count; i += 3)
|
||||
{
|
||||
(triangles[i], triangles[i + 1]) = (triangles[i + 1], triangles[i]);
|
||||
}
|
||||
triangles.Reverse();
|
||||
}
|
||||
|
||||
public static int[] ToUnityTriangles(ReadOnlySpan<int> triangles)
|
||||
public static void ToUnityTriangles(int[] triangles)
|
||||
{
|
||||
var indices = new int[triangles.Length];
|
||||
for (var i = 0; i < triangles.Length; i += 3)
|
||||
{
|
||||
indices[i] = triangles[i + 1];
|
||||
indices[i + 1] = triangles[i];
|
||||
indices[i + 2] = triangles[i + 2];
|
||||
}
|
||||
return indices;
|
||||
Array.Reverse(triangles);
|
||||
}
|
||||
|
||||
public static bool IsPositionInsideRect(GameBoxRect rect, Vector2Int position)
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace Core.GameBox
|
||||
|
||||
public static class GameBoxVertexType
|
||||
{
|
||||
public const int MaxUvSet = 4;
|
||||
public const int Null = 0;
|
||||
public const int MaxUvSet = 4;
|
||||
public const int XYZ = (1 << 0);
|
||||
public const int Normal = (1 << 1);
|
||||
public const int Diffuse = (1 << 2);
|
||||
@@ -72,6 +72,34 @@ namespace Core.GameBox
|
||||
public const int FlagMask = (1 << 31);
|
||||
}
|
||||
|
||||
public enum GameBoxBlendFlag
|
||||
{
|
||||
Opaque, // opaque
|
||||
AlphaBlend, // src.alpha, 1-src.alpha, +
|
||||
InvertColorBlend, // srcAlpha, One , +
|
||||
AdditiveBlend, //
|
||||
}
|
||||
|
||||
public enum GameBoxLightType
|
||||
{
|
||||
Omni, // point light
|
||||
Spot, // spot light
|
||||
Directional, // directional light
|
||||
}
|
||||
|
||||
public enum GameBoxLightDecayType
|
||||
{
|
||||
None,
|
||||
Distance,
|
||||
Square,
|
||||
}
|
||||
|
||||
public enum GameBoxLightShapeType
|
||||
{
|
||||
Cone,
|
||||
Square,
|
||||
}
|
||||
|
||||
public static class GameBoxVertex
|
||||
{
|
||||
public static int GetSize(uint vertexType)
|
||||
|
||||
@@ -29,9 +29,15 @@ namespace Core.Renderer
|
||||
|
||||
public IEnumerator PlaySpriteAnimation(Sprite[] sprites,
|
||||
float fps,
|
||||
int loopCount)
|
||||
int loopCount,
|
||||
Material material = default)
|
||||
{
|
||||
_isPlaying = true;
|
||||
|
||||
if (material != default)
|
||||
{
|
||||
_spriteRenderer.material = material;
|
||||
}
|
||||
|
||||
if (loopCount == -1)
|
||||
{
|
||||
@@ -51,7 +57,7 @@ namespace Core.Renderer
|
||||
|
||||
private IEnumerator PlaySpriteAnimationInternal(Sprite[] sprites, float fps)
|
||||
{
|
||||
foreach (var sprite in sprites)
|
||||
foreach (Sprite sprite in sprites)
|
||||
{
|
||||
if (!_isPlaying) yield break;
|
||||
_spriteRenderer.sprite = sprite;
|
||||
|
||||
@@ -12,6 +12,13 @@ namespace Core.Renderer
|
||||
{
|
||||
private Skybox _skybox;
|
||||
|
||||
private static readonly int RightTexturePropertyID = Shader.PropertyToID("_RightTex");
|
||||
private static readonly int BackTexturePropertyID = Shader.PropertyToID("_BackTex");
|
||||
private static readonly int LeftTexturePropertyID = Shader.PropertyToID("_LeftTex");
|
||||
private static readonly int FrontTexturePropertyID = Shader.PropertyToID("_FrontTex");
|
||||
private static readonly int UpTexturePropertyID = Shader.PropertyToID("_UpTex");
|
||||
private static readonly int DownTexturePropertyID = Shader.PropertyToID("_DownTex");
|
||||
|
||||
public void Render(Texture2D[] textures)
|
||||
{
|
||||
var mainCamera = GetComponent<Camera>();
|
||||
@@ -19,7 +26,7 @@ namespace Core.Renderer
|
||||
{
|
||||
throw new Exception("SkyBoxRenderer needs to be attached to a camera game object.");
|
||||
}
|
||||
var material = CreateSkyboxMaterial(textures);
|
||||
Material material = CreateSkyboxMaterial(textures);
|
||||
_skybox = mainCamera.gameObject.AddComponent<Skybox>();
|
||||
_skybox.material = material;
|
||||
}
|
||||
@@ -32,12 +39,12 @@ namespace Core.Renderer
|
||||
private static Material CreateSkyboxMaterial(Texture2D[] textures)
|
||||
{
|
||||
var material = new Material(Shader.Find("Skybox/6 Sided"));
|
||||
material.SetTexture("_RightTex", textures[0]);
|
||||
material.SetTexture("_BackTex", textures[1]);
|
||||
material.SetTexture("_LeftTex", textures[2]);
|
||||
material.SetTexture("_FrontTex", textures[3]);
|
||||
material.SetTexture("_UpTex", textures[4]);
|
||||
material.SetTexture("_DownTex", textures[5]);
|
||||
material.SetTexture(RightTexturePropertyID, textures[0]);
|
||||
material.SetTexture(BackTexturePropertyID, textures[1]);
|
||||
material.SetTexture(LeftTexturePropertyID, textures[2]);
|
||||
material.SetTexture(FrontTexturePropertyID, textures[3]);
|
||||
material.SetTexture(UpTexturePropertyID, textures[4]);
|
||||
material.SetTexture(DownTexturePropertyID, textures[5]);
|
||||
return material;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Core.Renderer
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
var rotation = _camera.transform.rotation;
|
||||
Quaternion rotation = _camera.transform.rotation;
|
||||
rotation = Quaternion.Euler(0f, rotation.eulerAngles.y, 0f);
|
||||
transform.rotation = rotation;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
namespace Core.Renderer
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public sealed class StaticMeshRenderer : MonoBehaviour
|
||||
public sealed class StaticMeshRenderer : MonoBehaviour, IDisposable
|
||||
{
|
||||
private MeshRenderer _meshRenderer;
|
||||
private MeshFilter _meshFilter;
|
||||
@@ -16,58 +16,15 @@ namespace Core.Renderer
|
||||
public Mesh Render(ref Vector3[] vertices,
|
||||
ref int[] triangles,
|
||||
ref Vector3[] normals,
|
||||
ref Vector2[] uv,
|
||||
ref Material material,
|
||||
ref Vector2[] mainTextureUvs,
|
||||
ref Vector2[] secondaryTextureUvs,
|
||||
ref Material[] materials,
|
||||
bool isDynamic)
|
||||
{
|
||||
Dispose();
|
||||
|
||||
_meshRenderer = gameObject.AddComponent<MeshRenderer>();
|
||||
//_meshRenderer.receiveShadows = false;
|
||||
//_meshRenderer.lightProbeUsage = LightProbeUsage.Off;
|
||||
_meshRenderer.sharedMaterial = material;
|
||||
|
||||
_meshFilter = gameObject.AddComponent<MeshFilter>();
|
||||
|
||||
var mesh = new Mesh();
|
||||
if (isDynamic)
|
||||
{
|
||||
mesh.MarkDynamic();
|
||||
}
|
||||
|
||||
mesh.SetVertices(vertices);
|
||||
mesh.SetTriangles(triangles, 0);
|
||||
mesh.SetNormals(normals);
|
||||
mesh.SetUVs(0, uv);
|
||||
|
||||
if (triangles.Length == 0)
|
||||
{
|
||||
// https://docs.unity3d.com/ScriptReference/Mesh.RecalculateBounds.html
|
||||
// After modifying vertices you should call this function to ensure the
|
||||
// bounding volume is correct. Assigning triangles automatically
|
||||
// recalculates the bounding volume.
|
||||
mesh.RecalculateBounds();
|
||||
}
|
||||
|
||||
_meshFilter.sharedMesh = mesh;
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
public Mesh Render(ref Vector3[] vertices,
|
||||
ref int[] triangles,
|
||||
ref Vector3[] normals,
|
||||
ref Vector2[] mainTextureUv,
|
||||
ref Vector2[] secondaryTextureUv,
|
||||
ref Material material,
|
||||
bool isDynamic)
|
||||
{
|
||||
Dispose();
|
||||
|
||||
_meshRenderer = gameObject.AddComponent<MeshRenderer>();
|
||||
//_meshRenderer.receiveShadows = false;
|
||||
//_meshRenderer.lightProbeUsage = LightProbeUsage.Off;
|
||||
_meshRenderer.sharedMaterial = material;
|
||||
_meshRenderer.sharedMaterials = materials;
|
||||
|
||||
_meshFilter = gameObject.AddComponent<MeshFilter>();
|
||||
var mesh = new Mesh();
|
||||
@@ -79,8 +36,8 @@ namespace Core.Renderer
|
||||
mesh.SetVertices(vertices);
|
||||
mesh.SetTriangles(triangles, 0);
|
||||
mesh.SetNormals(normals);
|
||||
mesh.SetUVs(0, mainTextureUv);
|
||||
mesh.SetUVs(1, secondaryTextureUv);
|
||||
mesh.SetUVs(0, mainTextureUvs);
|
||||
mesh.SetUVs(1, secondaryTextureUvs);
|
||||
|
||||
if (triangles.Length == 0)
|
||||
{
|
||||
@@ -121,7 +78,7 @@ namespace Core.Renderer
|
||||
Dispose();
|
||||
}
|
||||
|
||||
private void Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
if (_meshFilter != null)
|
||||
{
|
||||
@@ -131,7 +88,11 @@ namespace Core.Renderer
|
||||
|
||||
if (_meshRenderer != null)
|
||||
{
|
||||
Destroy(_meshRenderer.sharedMaterial);
|
||||
foreach (Material material in _meshRenderer.sharedMaterials)
|
||||
{
|
||||
Destroy(material);
|
||||
}
|
||||
|
||||
Destroy(_meshRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
{
|
||||
// Unity has a built-in shader that is useful for drawing
|
||||
// simple colored things.
|
||||
var shader = Shader.Find("Hidden/Internal-Colored");
|
||||
Shader shader = Shader.Find("Hidden/Internal-Colored");
|
||||
_lineMaterial = new Material(shader);
|
||||
_lineMaterial.hideFlags = HideFlags.HideAndDontSave;
|
||||
// Turn on alpha blending
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Core.Utils
|
||||
RuntimePlatform.IPhonePlayer => iOSSupportedVideoFormats,
|
||||
RuntimePlatform.Android => AndroidSupportedVideoFormats,
|
||||
|
||||
_ => new () {".mp4" }
|
||||
_ => new HashSet<string> {".mp4" }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace Core.Utils
|
||||
|
||||
public sealed unsafe class UnsafeBinaryReader : IDisposable
|
||||
{
|
||||
private const int GBK_CODE_PAGE = 936; // GBK Encoding's code page
|
||||
private byte* _dataPtr;
|
||||
private GCHandle _handle;
|
||||
|
||||
@@ -148,18 +147,13 @@ namespace Core.Utils
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public string ReadGbkString(int count)
|
||||
public string ReadString(int count, int codepage)
|
||||
{
|
||||
var strBytes = ReadBytes(count);
|
||||
var i = 0;
|
||||
var length = strBytes.Length;
|
||||
while (i < length && strBytes[i] != 0) i++;
|
||||
return Encoding.GetEncoding(GBK_CODE_PAGE).GetString(strBytes, 0, i);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
Dispose(true);
|
||||
return Encoding.GetEncoding(codepage).GetString(strBytes, 0, i);
|
||||
}
|
||||
|
||||
private bool _disposedValue;
|
||||
|
||||
@@ -14,14 +14,12 @@ namespace Core.Utils
|
||||
|
||||
public static class Utility
|
||||
{
|
||||
private const int GBK_CODE_PAGE = 936; // GBK Encoding's code page
|
||||
|
||||
public static string ConvertToGbkString(byte[] charArray)
|
||||
public static string ConvertToString(byte[] charArray, int codepage)
|
||||
{
|
||||
var i = 0;
|
||||
var length = charArray.Length;
|
||||
while (i < length && charArray[i] != 0) i++;
|
||||
return Encoding.GetEncoding(GBK_CODE_PAGE).GetString(charArray, 0, i);
|
||||
return Encoding.GetEncoding(codepage).GetString(charArray, 0, i);
|
||||
}
|
||||
|
||||
public static Color32 ToColor32(byte[] rgba)
|
||||
@@ -159,13 +157,51 @@ namespace Core.Utils
|
||||
public static Bounds EncapsulateBounds(IEnumerable<Bounds> bounds)
|
||||
{
|
||||
var finalBounds = new Bounds(Vector3.zero, Vector3.zero);
|
||||
foreach (var b in bounds)
|
||||
foreach (Bounds b in bounds)
|
||||
{
|
||||
finalBounds.Encapsulate(b);
|
||||
}
|
||||
return finalBounds;
|
||||
}
|
||||
|
||||
public static Vector3[] CalculateNormals(Vector3[] vertices, int[] triangles)
|
||||
{
|
||||
Vector3[] normals = new Vector3[vertices.Length];
|
||||
|
||||
for (var face = 0; face < triangles.Length / 3; face++)
|
||||
{
|
||||
int v1 = triangles[face * 3];
|
||||
int v2 = triangles[face * 3 + 1];
|
||||
int v3 = triangles[face * 3 + 2];
|
||||
|
||||
Vector3 pt1 = vertices[v1];
|
||||
Vector3 pt2 = vertices[v2];
|
||||
Vector3 pt3 = vertices[v3];
|
||||
|
||||
Vector3 d1 = pt2 - pt1;
|
||||
Vector3 d2 = pt3 - pt1;
|
||||
Vector3 normal = Vector3.Normalize(Vector3.Cross(d1, d2));
|
||||
|
||||
normals[v1] += normal;
|
||||
normals[v2] += normal;
|
||||
normals[v3] += normal;
|
||||
}
|
||||
|
||||
for (var i = 0; i < normals.Length; i++)
|
||||
{
|
||||
if (normals[i] == Vector3.zero)
|
||||
{
|
||||
normals[i] = Vector3.up;
|
||||
}
|
||||
else
|
||||
{
|
||||
normals[i] = Vector3.Normalize(normals[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return normals;
|
||||
}
|
||||
|
||||
public static void DrawBounds(Bounds b, float duration = 1000)
|
||||
{
|
||||
var p1 = new Vector3(b.min.x, b.min.y, b.min.z);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Editor
|
||||
BuildTargetGroup.iOS,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private static NamedBuildTarget[] GetAllSupportedNamedBuildTargets()
|
||||
{
|
||||
return new[]
|
||||
@@ -49,13 +49,13 @@ namespace Editor
|
||||
NamedBuildTarget.iOS,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private static void ApplyPlayerSettingsForVariant(string appName)
|
||||
{
|
||||
PlayerSettings.productName = appName;
|
||||
PlayerSettings.companyName = GameConstants.CompanyName;
|
||||
|
||||
foreach (var targetGroup in GetAllSupportedTargetGroups())
|
||||
foreach (BuildTargetGroup targetGroup in GetAllSupportedTargetGroups())
|
||||
{
|
||||
PlayerSettings.SetApplicationIdentifier(targetGroup,
|
||||
$"{GameConstants.AppIdentifierPrefix}.{appName}");
|
||||
@@ -65,7 +65,7 @@ namespace Editor
|
||||
var gameIcon = Resources.Load<Texture2D>(gameIconPath);
|
||||
if (gameIcon == null) throw new Exception($"Game icon not found: {gameIconPath}");
|
||||
|
||||
foreach (var buildTarget in GetAllSupportedNamedBuildTargets())
|
||||
foreach (NamedBuildTarget buildTarget in GetAllSupportedNamedBuildTargets())
|
||||
{
|
||||
// Set app icon
|
||||
var iconSizes = PlayerSettings.GetIconSizes(buildTarget, IconKind.Application);
|
||||
@@ -88,7 +88,7 @@ namespace Editor
|
||||
|
||||
private static void AddSymbol(string symbolToAdd)
|
||||
{
|
||||
foreach (var targetGroup in GetAllSupportedTargetGroups())
|
||||
foreach (BuildTargetGroup targetGroup in GetAllSupportedTargetGroups())
|
||||
{
|
||||
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
|
||||
var allDefines = defines.Split(';').ToList();
|
||||
@@ -96,7 +96,7 @@ namespace Editor
|
||||
{
|
||||
allDefines.Add(symbolToAdd);
|
||||
}
|
||||
|
||||
allDefines.Sort();
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup,
|
||||
string.Join(";", allDefines.ToArray()));
|
||||
}
|
||||
@@ -104,7 +104,7 @@ namespace Editor
|
||||
|
||||
private static void RemoveSymbol(string symbolToDelete)
|
||||
{
|
||||
foreach (var targetGroup in GetAllSupportedTargetGroups())
|
||||
foreach (BuildTargetGroup targetGroup in GetAllSupportedTargetGroups())
|
||||
{
|
||||
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
|
||||
var allDefines = defines.Split(';').ToList();
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Editor.SourceGenerator.Base
|
||||
public static Type[] GetTypesOfInterface(Type interfaceType)
|
||||
{
|
||||
var result = new List<Type>();
|
||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
result.AddRange(asm.GetTypes()
|
||||
.Where(t => t.IsClass && t.GetInterfaces().Contains(interfaceType)));
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Pal3.Actor
|
||||
return Info.Kind switch
|
||||
{
|
||||
ScnActorKind.Soldier => 4f,
|
||||
ScnActorKind.MainActor => 4f,
|
||||
ScnActorKind.MainActor => 2.5f,
|
||||
ScnActorKind.StoryNpc => 4f,
|
||||
ScnActorKind.HotelManager => 6f,
|
||||
ScnActorKind.Dealer => 6f,
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Pal3.Actor
|
||||
using Core.DataLoader;
|
||||
using Core.DataReader.Cpk;
|
||||
using Core.DataReader.Mv3;
|
||||
using Core.DataReader.Pol;
|
||||
using Core.Extensions;
|
||||
using Core.Renderer;
|
||||
using Core.Services;
|
||||
@@ -153,24 +154,32 @@ namespace Pal3.Actor
|
||||
_currentAction = actionName.ToLower();
|
||||
_mv3AnimationRenderer = gameObject.GetOrAddComponent<Mv3ModelRenderer>();
|
||||
|
||||
var actionType = ActorConstants.ActionNames
|
||||
ActorActionType actionType = ActorConstants.ActionNames
|
||||
.FirstOrDefault(_ => string.Equals(_.Value, actionName, StringComparison.OrdinalIgnoreCase)).Key;
|
||||
|
||||
if (mv3File.TagNodes is {Length: > 0} && _actor.GetWeaponName() is {} weaponName &&
|
||||
ActorConstants.ActionNameToWeaponArmTypeMap[actionType] != WeaponArmType.None)
|
||||
{
|
||||
var separator = CpkConstants.CpkDirectorySeparatorChar;
|
||||
var separator = CpkConstants.DirectorySeparator;
|
||||
|
||||
var weaponPath = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.WeaponFolderName}{separator}{weaponName}{separator}{weaponName}.pol";
|
||||
|
||||
var (polFile, weaponTextureProvider) = _resourceProvider.GetPol(weaponPath);
|
||||
_mv3AnimationRenderer.Init(mv3File, textureProvider, _tintColor,
|
||||
polFile, weaponTextureProvider, Color.white);
|
||||
(PolFile polFile, ITextureResourceProvider weaponTextureProvider) = _resourceProvider.GetPol(weaponPath);
|
||||
_mv3AnimationRenderer.Init(mv3File,
|
||||
_resourceProvider.GetMaterialFactory(),
|
||||
textureProvider,
|
||||
_tintColor,
|
||||
polFile,
|
||||
weaponTextureProvider,
|
||||
Color.white);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mv3AnimationRenderer.Init(mv3File, textureProvider, _tintColor);
|
||||
_mv3AnimationRenderer.Init(mv3File,
|
||||
_resourceProvider.GetMaterialFactory(),
|
||||
textureProvider,
|
||||
_tintColor);
|
||||
}
|
||||
|
||||
_mv3AnimationRenderer.AnimationLoopPointReached += AnimationLoopPointReached;
|
||||
@@ -179,10 +188,13 @@ namespace Pal3.Actor
|
||||
_worldBounds = _mv3AnimationRenderer.GetWorldBounds();
|
||||
_localBounds = _mv3AnimationRenderer.GetLocalBounds();
|
||||
|
||||
var action = ActorConstants.ActionNames
|
||||
ActorActionType action = ActorConstants.ActionNames
|
||||
.FirstOrDefault(a => a.Value.Equals(_currentAction)).Key;
|
||||
|
||||
#if !RTX_ON
|
||||
SetupShadow(action);
|
||||
#endif
|
||||
|
||||
SetupCollider();
|
||||
SetupRigidBody();
|
||||
}
|
||||
@@ -222,7 +234,7 @@ namespace Pal3.Actor
|
||||
_collider = gameObject.AddComponent<CapsuleCollider>();
|
||||
}
|
||||
|
||||
var bounds = GetLocalBounds();
|
||||
Bounds bounds = GetLocalBounds();
|
||||
_collider.center = bounds.center;
|
||||
_collider.height = bounds.size.y;
|
||||
_collider.radius = bounds.size.x * 0.35f;
|
||||
@@ -238,20 +250,20 @@ namespace Pal3.Actor
|
||||
RigidbodyConstraints.FreezeRotation;
|
||||
}
|
||||
|
||||
var currentGameState = ServiceLocator.Instance.Get<GameStateManager>().GetCurrentState();
|
||||
GameState currentGameState = ServiceLocator.Instance.Get<GameStateManager>().GetCurrentState();
|
||||
_rigidbody.isKinematic = currentGameState != GameState.Gameplay || _isKinematic;
|
||||
}
|
||||
|
||||
private void RenderShadow()
|
||||
{
|
||||
_shadow = new GameObject("Shadow");
|
||||
var shadowTexture = _resourceProvider.GetShadowTexture();
|
||||
Texture2D shadowTexture = _resourceProvider.GetShadowTexture();
|
||||
_shadowSpriteRenderer = _shadow.AddComponent<SpriteRenderer>();
|
||||
_shadowSpriteRenderer.sprite = Sprite.Create(shadowTexture,
|
||||
new Rect(0, 0, shadowTexture.width, shadowTexture.height),
|
||||
new Vector2(0.5f, 0.5f));
|
||||
_shadowSpriteRenderer.color = new Color(0f, 0f, 0f, 0.7f);
|
||||
var shadowTransform = _shadow.transform;
|
||||
Transform shadowTransform = _shadow.transform;
|
||||
shadowTransform.rotation = Quaternion.Euler(90f, 0f, 0f);
|
||||
shadowTransform.localScale = new Vector3(1.4f, 1.4f, 1f);
|
||||
shadowTransform.localPosition = new Vector3(0f, 0.07f, 0f);
|
||||
@@ -274,7 +286,7 @@ namespace Pal3.Actor
|
||||
var emojiGameObject = new GameObject($"Emoji_{emojiType.ToString()}");
|
||||
emojiGameObject.transform.SetParent(transform);
|
||||
emojiGameObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
|
||||
var actorHeadPosition = GetActorHeadWorldPosition();
|
||||
Vector3 actorHeadPosition = GetActorHeadWorldPosition();
|
||||
emojiGameObject.transform.position = new Vector3(actorHeadPosition.x,
|
||||
actorHeadPosition.y + 0.1f, // With a small Y offset
|
||||
actorHeadPosition.z);
|
||||
@@ -300,7 +312,7 @@ namespace Pal3.Actor
|
||||
|
||||
public Vector3 GetActorHeadWorldPosition()
|
||||
{
|
||||
var parentPosition = transform.position;
|
||||
Vector3 parentPosition = transform.position;
|
||||
|
||||
if (_mv3AnimationRenderer == null || !_mv3AnimationRenderer.IsVisible())
|
||||
{
|
||||
@@ -478,7 +490,7 @@ namespace Pal3.Actor
|
||||
}
|
||||
else if (command.NewState == GameState.Gameplay)
|
||||
{
|
||||
var playerActor = ServiceLocator.Instance.Get<PlayerManager>().GetPlayerActor();
|
||||
PlayerActorId playerActor = ServiceLocator.Instance.Get<PlayerManager>().GetPlayerActor();
|
||||
_isKinematic = _actor.Info.Id != (byte)playerActor;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Pal3.Actor
|
||||
|
||||
private void InitActorConfig(string name)
|
||||
{
|
||||
var separator = CpkConstants.CpkDirectorySeparatorChar;
|
||||
var separator = CpkConstants.DirectorySeparator;
|
||||
|
||||
var defaultActorConfigFile = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.ActorFolderName}{separator}{name}{separator}{name}.ini";
|
||||
@@ -61,6 +61,7 @@ namespace Pal3.Actor
|
||||
|
||||
protected void ChangeName(string name)
|
||||
{
|
||||
if (_actorName == name) return;
|
||||
_actorName = name;
|
||||
InitActorConfig(name);
|
||||
}
|
||||
@@ -80,10 +81,10 @@ namespace Pal3.Actor
|
||||
|
||||
public (Mv3File mv3File, ITextureResourceProvider textureProvider) GetActionMv3(string actionName)
|
||||
{
|
||||
var action = _actorConfig.ActorActions
|
||||
ActorAction action = _actorConfig.ActorActions
|
||||
.First(act => act.ActionName.Equals(actionName, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
var separator = CpkConstants.CpkDirectorySeparatorChar;
|
||||
var separator = CpkConstants.DirectorySeparator;
|
||||
|
||||
var mv3File = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.ActorFolderName}{separator}{_actorName}{separator}" +
|
||||
|
||||
@@ -25,8 +25,6 @@ namespace Pal3.Actor
|
||||
ICommandExecutor<ActorSetScriptCommand>,
|
||||
#if PAL3A
|
||||
ICommandExecutor<ActorSetYPositionCommand>,
|
||||
ICommandExecutor<EffectAttachToActorCommand>,
|
||||
ICommandExecutor<EffectPlayCommand>,
|
||||
#endif
|
||||
ICommandExecutor<ActorChangeScaleCommand>
|
||||
{
|
||||
@@ -40,9 +38,16 @@ namespace Pal3.Actor
|
||||
get => _actor.IsActive;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
Activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
DeActivate();
|
||||
}
|
||||
|
||||
_actor.IsActive = value;
|
||||
if (value) Activate();
|
||||
else DeActivate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,15 +85,6 @@ namespace Pal3.Actor
|
||||
return _actor.Info.ScriptId != 0;
|
||||
}
|
||||
|
||||
public void Interact()
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new PlayerInteractionTriggeredNotification());
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunCommand((int) _actor.Info.ScriptId));
|
||||
}
|
||||
|
||||
private void Activate()
|
||||
{
|
||||
#if PAL3A
|
||||
@@ -109,24 +105,31 @@ namespace Pal3.Actor
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_actor.Info.InitBehaviour)
|
||||
// Perform init action
|
||||
if (!_actor.IsActive)
|
||||
{
|
||||
case ScnActorBehaviour.None:
|
||||
_currentBehaviour = ScnActorBehaviour.None;
|
||||
_actionController.PerformAction(_actor.GetInitAction());
|
||||
break;
|
||||
case ScnActorBehaviour.Hold:
|
||||
_currentBehaviour = ScnActorBehaviour.Hold;
|
||||
_actionController.PerformAction(_actor.GetInitAction());
|
||||
break;
|
||||
case ScnActorBehaviour.Wander:
|
||||
_currentBehaviour = ScnActorBehaviour.Wander;
|
||||
_actionController.PerformAction(_actor.GetIdleAction());
|
||||
break;
|
||||
case ScnActorBehaviour.PathFollow:
|
||||
_currentBehaviour = ScnActorBehaviour.PathFollow;
|
||||
_actionController.PerformAction(_actor.GetIdleAction());
|
||||
break;
|
||||
switch (_actor.Info.InitBehaviour)
|
||||
{
|
||||
case ScnActorBehaviour.None:
|
||||
_currentBehaviour = ScnActorBehaviour.None;
|
||||
_actionController.PerformAction(_actor.Info.Kind != ScnActorKind.HotelManager &&
|
||||
_actor.Info.Kind != ScnActorKind.StoryNpc
|
||||
? _actor.GetInitAction()
|
||||
: _actor.GetIdleAction());
|
||||
break;
|
||||
case ScnActorBehaviour.Hold:
|
||||
_currentBehaviour = ScnActorBehaviour.Hold;
|
||||
_actionController.PerformAction(_actor.GetInitAction());
|
||||
break;
|
||||
case ScnActorBehaviour.Wander:
|
||||
_currentBehaviour = ScnActorBehaviour.Wander;
|
||||
_actionController.PerformAction(_actor.GetIdleAction());
|
||||
break;
|
||||
case ScnActorBehaviour.PathFollow:
|
||||
_currentBehaviour = ScnActorBehaviour.PathFollow;
|
||||
_actionController.PerformAction(_actor.GetIdleAction());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_currentBehaviour == ScnActorBehaviour.PathFollow)
|
||||
@@ -198,46 +201,11 @@ namespace Pal3.Actor
|
||||
public void Execute(ActorSetYPositionCommand command)
|
||||
{
|
||||
if (command.ActorId != _actor.Info.Id) return;
|
||||
var oldPosition = transform.position;
|
||||
Vector3 oldPosition = transform.position;
|
||||
transform.position = new Vector3(oldPosition.x,
|
||||
command.YPosition / GameBoxInterpreter.GameBoxUnitToUnityUnit,
|
||||
oldPosition.z);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PAL3A
|
||||
private bool _effectAttachedToSelf = false;
|
||||
public void Execute(EffectAttachToActorCommand command)
|
||||
{
|
||||
if (_actor.Info.Id == command.ActorId) _effectAttachedToSelf = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PAL3A
|
||||
public void Execute(EffectPlayCommand command)
|
||||
{
|
||||
if (!_effectAttachedToSelf) return;
|
||||
|
||||
switch (command.EffectGroupId)
|
||||
{
|
||||
// 南宫煌形态切换为狼形态特效
|
||||
case 164:
|
||||
{
|
||||
_actor.ChangeName(ActorConstants.NanGongHuangWolfModeActorName);
|
||||
if (_actor.IsActive) _actionController.PerformAction(_actor.GetIdleAction(), overwrite: true);
|
||||
break;
|
||||
}
|
||||
// 南宫煌形态切换为人形态特效
|
||||
case 315:
|
||||
{
|
||||
_actor.ChangeName(ActorConstants.NanGongHuangHumanModeActorName);
|
||||
if (_actor.IsActive) _actionController.PerformAction(_actor.GetIdleAction(), overwrite: true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_effectAttachedToSelf = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace Pal3.Actor
|
||||
switch (actor.Info.Id)
|
||||
{
|
||||
case (byte)PlayerActorId.HuaYing:
|
||||
actorGameObject.AddComponent<HuaYingController>().Init(actorController, actionController);
|
||||
actorGameObject.AddComponent<HuaYingController>().Init(actor, actorController, actionController);
|
||||
break;
|
||||
case (byte)PlayerActorId.LongKui:
|
||||
actorGameObject.AddComponent<LongKuiController>().Init(actor, actionController);
|
||||
@@ -56,7 +56,7 @@ namespace Pal3.Actor
|
||||
switch (actor.Info.Id)
|
||||
{
|
||||
case (byte)PlayerActorId.TaoZi:
|
||||
actorGameObject.AddComponent<FlyingActorController>().Init(actionController);
|
||||
actorGameObject.AddComponent<FlyingActorController>().Init(actor, actionController);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Pal3.Actor
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.DataReader.Nav;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using MetaData;
|
||||
@@ -50,9 +51,10 @@ namespace Pal3.Actor
|
||||
|
||||
private readonly Path _currentPath = new ();
|
||||
private WaitUntilCanceled _movementWaiter;
|
||||
private CancellationTokenSource _movementCts = new ();
|
||||
|
||||
private bool _isDuringCollision;
|
||||
private Vector3 _lastKnownValidPositionDuringCollision;
|
||||
private Vector3 _lastKnownValidPositionWhenCollisionEnter;
|
||||
|
||||
private Func<int, byte[], HashSet<Vector2Int>> _getAllActiveActorBlockingTilePositions;
|
||||
|
||||
@@ -65,14 +67,14 @@ namespace Pal3.Actor
|
||||
_currentLayerIndex = actor.Info.OnLayer;
|
||||
_getAllActiveActorBlockingTilePositions = getAllActiveActorBlockingTilePositions;
|
||||
|
||||
var initPosition = GameBoxInterpreter.ToUnityPosition(new Vector3(actor.Info.PositionX,
|
||||
Vector3 initPosition = GameBoxInterpreter.ToUnityPosition(new Vector3(actor.Info.PositionX,
|
||||
actor.Info.PositionY, actor.Info.PositionZ));
|
||||
|
||||
var tilePosition = _tilemap.GetTilePosition(initPosition, _currentLayerIndex);
|
||||
Vector2Int tilePosition = _tilemap.GetTilePosition(initPosition, _currentLayerIndex);
|
||||
if (actor.Info.InitBehaviour != ScnActorBehaviour.Hold &&
|
||||
_tilemap.IsTilePositionInsideTileMap(tilePosition, _currentLayerIndex))
|
||||
{
|
||||
var tile = _tilemap.GetTile(tilePosition, _currentLayerIndex);
|
||||
NavTile tile = _tilemap.GetTile(tilePosition, _currentLayerIndex);
|
||||
|
||||
if (tile.IsWalkable())
|
||||
{
|
||||
@@ -84,7 +86,7 @@ namespace Pal3.Actor
|
||||
{
|
||||
// Snap to the nearest adjacent tile if exists
|
||||
var nextToWalkableTile =_tilemap.TryGetAdjacentWalkableTile(tilePosition,
|
||||
_currentLayerIndex, out var nearestTile);
|
||||
_currentLayerIndex, out Vector2Int nearestTile);
|
||||
transform.position = nextToWalkableTile ?
|
||||
_tilemap.GetWorldPosition(nearestTile, _currentLayerIndex) :
|
||||
initPosition;
|
||||
@@ -105,6 +107,7 @@ namespace Pal3.Actor
|
||||
{
|
||||
_currentPath.Clear();
|
||||
_movementWaiter?.CancelWait();
|
||||
_movementCts?.Cancel();
|
||||
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
||||
}
|
||||
|
||||
@@ -126,18 +129,22 @@ namespace Pal3.Actor
|
||||
private void Update()
|
||||
{
|
||||
if (_currentPath.IsEndOfPath()) return;
|
||||
|
||||
var result = MoveTowards(_currentPath.GetCurrentWayPoint(), _currentPath.MovementMode, _currentPath.IgnoreObstacle);
|
||||
|
||||
if (result == MovementResult.Blocked)
|
||||
MovementResult result = MoveTowards(_currentPath.GetCurrentWayPoint(), _currentPath.MovementMode,
|
||||
_currentPath.IgnoreObstacle);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
ReachingToEndOfPath();
|
||||
}
|
||||
else if (result == MovementResult.Completed)
|
||||
{
|
||||
if (!_currentPath.MoveToNextWayPoint())
|
||||
{
|
||||
case MovementResult.Blocked:
|
||||
ReachingToEndOfPath();
|
||||
break;
|
||||
case MovementResult.Completed:
|
||||
{
|
||||
if (!_currentPath.MoveToNextWayPoint())
|
||||
{
|
||||
ReachingToEndOfPath();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,18 +158,18 @@ namespace Pal3.Actor
|
||||
// player actor's rigidbody.
|
||||
if (_isDuringCollision && _actionController.GetRigidBody() is {isKinematic: false})
|
||||
{
|
||||
var currentPosition = transform.position;
|
||||
var tilePosition = _tilemap.GetTilePosition(currentPosition, _currentLayerIndex);
|
||||
Vector3 currentPosition = transform.position;
|
||||
Vector2Int tilePosition = _tilemap.GetTilePosition(currentPosition, _currentLayerIndex);
|
||||
if (!_tilemap.IsTilePositionInsideTileMap(tilePosition, _currentLayerIndex))
|
||||
{
|
||||
transform.position = _lastKnownValidPositionDuringCollision;
|
||||
transform.position = _lastKnownValidPositionWhenCollisionEnter;
|
||||
}
|
||||
else
|
||||
{
|
||||
var currentTile = _tilemap.GetTile(tilePosition, _currentLayerIndex);
|
||||
NavTile currentTile = _tilemap.GetTile(tilePosition, _currentLayerIndex);
|
||||
if (!currentTile.IsWalkable())
|
||||
{
|
||||
transform.position = _lastKnownValidPositionDuringCollision;
|
||||
transform.position = _lastKnownValidPositionWhenCollisionEnter;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -170,7 +177,6 @@ namespace Pal3.Actor
|
||||
currentTile.Y / GameBoxInterpreter.GameBoxUnitToUnityUnit,
|
||||
currentPosition.z);
|
||||
transform.position = adjustedPosition;
|
||||
_lastKnownValidPositionDuringCollision = adjustedPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +185,24 @@ namespace Pal3.Actor
|
||||
private void OnCollisionEnter(Collision _)
|
||||
{
|
||||
_isDuringCollision = true;
|
||||
_lastKnownValidPositionDuringCollision = transform.position;
|
||||
|
||||
Vector3 currentActorPosition = transform.position;
|
||||
Vector2Int currentTilePosition = _tilemap.GetTilePosition(currentActorPosition, _currentLayerIndex);
|
||||
|
||||
if (_tilemap.IsTilePositionInsideTileMap(currentTilePosition, _currentLayerIndex) &&
|
||||
_tilemap.GetTile(currentActorPosition, _currentLayerIndex).IsWalkable())
|
||||
{
|
||||
_lastKnownValidPositionWhenCollisionEnter = currentActorPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastKnownValidPositionWhenCollisionEnter =
|
||||
_tilemap.TryGetAdjacentWalkableTile(currentTilePosition,
|
||||
_currentLayerIndex,
|
||||
out Vector2Int nearestWalkableTilePosition)
|
||||
? _tilemap.GetWorldPosition(nearestWalkableTilePosition, _currentLayerIndex)
|
||||
: currentActorPosition; // Highly unlikely to happen, but this is the best effort
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionExit(Collision _)
|
||||
@@ -224,7 +247,7 @@ namespace Pal3.Actor
|
||||
|
||||
public void MoveToTapPoint(Dictionary<int, Vector3> tapPoints, bool isDoubleTap)
|
||||
{
|
||||
var targetPosition = Vector3.zero;
|
||||
Vector3 targetPosition = Vector3.zero;
|
||||
var targetPositionFound = false;
|
||||
if (tapPoints.ContainsKey(_currentLayerIndex))
|
||||
{
|
||||
@@ -257,7 +280,7 @@ namespace Pal3.Actor
|
||||
|
||||
private bool IsNearPortalAreaOfLayer(Vector3 position, int layerIndex)
|
||||
{
|
||||
var tilePosition = _tilemap.GetTilePosition(position, layerIndex);
|
||||
Vector2Int tilePosition = _tilemap.GetTilePosition(position, layerIndex);
|
||||
|
||||
if (_tilemap.IsInsidePortalArea(tilePosition, layerIndex)) return true;
|
||||
|
||||
@@ -269,9 +292,9 @@ namespace Pal3.Actor
|
||||
private bool IsNotObstacleAtLayer(Vector3 position, int layerIndex, out float y)
|
||||
{
|
||||
y = 0;
|
||||
var tilePosition = _tilemap.GetTilePosition(position, layerIndex);
|
||||
Vector2Int tilePosition = _tilemap.GetTilePosition(position, layerIndex);
|
||||
if (!_tilemap.IsTilePositionInsideTileMap(tilePosition, layerIndex)) return false;
|
||||
var tile = _tilemap.GetTile(tilePosition, layerIndex);
|
||||
NavTile tile = _tilemap.GetTile(tilePosition, layerIndex);
|
||||
if (!tile.IsWalkable()) return false;
|
||||
y = tile.Y / GameBoxInterpreter.GameBoxUnitToUnityUnit;
|
||||
return true;
|
||||
@@ -279,8 +302,8 @@ namespace Pal3.Actor
|
||||
|
||||
public MovementResult MoveTowards(Vector3 targetPosition, int movementMode, bool ignoreObstacle = false)
|
||||
{
|
||||
var currentTransform = transform;
|
||||
var currentPosition = currentTransform.position;
|
||||
Transform currentTransform = transform;
|
||||
Vector3 currentPosition = currentTransform.position;
|
||||
|
||||
// TODO: Use speed info from datascript\scene.txt file
|
||||
//var speed = _actor.Info.Speed == 0 ? 2f : _actor.Info.Speed;
|
||||
@@ -289,7 +312,7 @@ namespace Pal3.Actor
|
||||
|
||||
if (!_actor.IsMainActor()) moveSpeed /= 2f;
|
||||
|
||||
var newPosition = Vector3.MoveTowards(currentPosition, targetPosition, moveSpeed * Time.deltaTime);
|
||||
Vector3 newPosition = Vector3.MoveTowards(currentPosition, targetPosition, moveSpeed * Time.deltaTime);
|
||||
|
||||
var canGotoPosition = CanGotoPosition(currentPosition, newPosition, out var newYPosition);
|
||||
|
||||
@@ -383,6 +406,7 @@ namespace Pal3.Actor
|
||||
private void ReachingToEndOfPath()
|
||||
{
|
||||
_movementWaiter?.CancelWait();
|
||||
|
||||
switch (_currentPath.EndOfPathAction)
|
||||
{
|
||||
case EndOfPathActionType.DisposeSelf:
|
||||
@@ -396,7 +420,9 @@ namespace Pal3.Actor
|
||||
_actionController.PerformAction(_actor.GetIdleAction());
|
||||
var waypoints = _currentPath.GetAllWayPoints();
|
||||
waypoints.Reverse();
|
||||
StartCoroutine(WaitForSomeTimeAndFollowPath(waypoints.ToArray(), _currentPath.MovementMode));
|
||||
StartCoroutine(WaitForSomeTimeAndFollowPath(waypoints.ToArray(),
|
||||
_currentPath.MovementMode,
|
||||
_movementCts.Token));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -404,17 +430,20 @@ namespace Pal3.Actor
|
||||
// Special handling for final rotation after moving backwards
|
||||
if (_currentPath.MovementMode == 2)
|
||||
{
|
||||
var actorTransform = transform;
|
||||
Transform actorTransform = transform;
|
||||
actorTransform.forward = -actorTransform.forward;
|
||||
}
|
||||
|
||||
_currentPath.Clear();
|
||||
}
|
||||
|
||||
private IEnumerator WaitForSomeTimeAndFollowPath(Vector3[] waypoints, int mode)
|
||||
private IEnumerator WaitForSomeTimeAndFollowPath(Vector3[] waypoints, int mode, CancellationToken cancellationToken)
|
||||
{
|
||||
yield return new WaitForSeconds(Random.Range(3, 8));
|
||||
SetupPath(waypoints, mode, EndOfPathActionType.Reverse, ignoreObstacle: true);
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
SetupPath(waypoints, mode, EndOfPathActionType.Reverse, ignoreObstacle: true);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator MoveDirectlyTo(Vector3 position, int mode)
|
||||
@@ -433,11 +462,12 @@ namespace Pal3.Actor
|
||||
private IEnumerator FindPathAndMoveToTilePosition(Vector2Int position,
|
||||
int mode,
|
||||
EndOfPathActionType endOfPathAction,
|
||||
CancellationToken cancellationToken,
|
||||
bool moveTowardsPositionIfNoPathFound = false,
|
||||
string specialAction = null)
|
||||
string specialAction = default)
|
||||
{
|
||||
Vector2Int[] path = Array.Empty<Vector2Int>();
|
||||
var fromTile = _tilemap.GetTilePosition(transform.position, _currentLayerIndex);
|
||||
Vector2Int fromTile = _tilemap.GetTilePosition(transform.position, _currentLayerIndex);
|
||||
var obstacles = _getAllActiveActorBlockingTilePositions(_currentLayerIndex, new [] {_actor.Info.Id});
|
||||
|
||||
var pathFindingThread = new Thread(() =>
|
||||
@@ -456,6 +486,8 @@ namespace Pal3.Actor
|
||||
yield return null;
|
||||
}
|
||||
|
||||
if (cancellationToken.IsCancellationRequested) yield break;
|
||||
|
||||
if (path.Length <= 0)
|
||||
{
|
||||
if (moveTowardsPositionIfNoPathFound)
|
||||
@@ -465,7 +497,7 @@ namespace Pal3.Actor
|
||||
_tilemap.GetWorldPosition(position, _currentLayerIndex),
|
||||
};
|
||||
|
||||
SetupPath(directWayPoints, mode, endOfPathAction, ignoreObstacle: true);
|
||||
SetupPath(directWayPoints, mode, endOfPathAction, ignoreObstacle: true, specialAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -503,8 +535,22 @@ namespace Pal3.Actor
|
||||
{
|
||||
if (_actor.Info.Id != command.ActorId) return;
|
||||
CancelCurrentMovement();
|
||||
transform.position = _tilemap.GetWorldPosition(new Vector2Int(command.TileXPosition,
|
||||
command.TileZPosition), _currentLayerIndex);
|
||||
|
||||
var tilePosition = new Vector2Int(command.TileXPosition, command.TileZPosition);
|
||||
|
||||
// Check if position at current layer exists,
|
||||
// if not, auto switch to next layer (if tile at next layer is walkable)
|
||||
if (_tilemap.GetLayerCount() > 1)
|
||||
{
|
||||
var isTileInsideCurrentLayer = _tilemap.IsTilePositionInsideTileMap(tilePosition, _currentLayerIndex);
|
||||
var isTileInsideAtNextLayer = _tilemap.IsTilePositionInsideTileMap(tilePosition, (_currentLayerIndex + 1) % 2);
|
||||
if (!isTileInsideCurrentLayer && isTileInsideAtNextLayer)
|
||||
{
|
||||
SetNavLayer((_currentLayerIndex + 1) % 2);
|
||||
}
|
||||
}
|
||||
|
||||
transform.position = _tilemap.GetWorldPosition(tilePosition, _currentLayerIndex);
|
||||
}
|
||||
|
||||
public void Execute(ActorPathToCommand command)
|
||||
@@ -514,7 +560,7 @@ namespace Pal3.Actor
|
||||
_movementWaiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(_movementWaiter));
|
||||
StartCoroutine(FindPathAndMoveToTilePosition(new Vector2Int(command.TileX, command.TileZ),
|
||||
command.Mode, EndOfPathActionType.Idle));
|
||||
command.Mode, EndOfPathActionType.Idle, _movementCts.Token));
|
||||
}
|
||||
|
||||
#if PAL3A
|
||||
@@ -525,7 +571,7 @@ namespace Pal3.Actor
|
||||
_movementWaiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(_movementWaiter));
|
||||
StartCoroutine(FindPathAndMoveToTilePosition(new Vector2Int(command.TileX, command.TileZ),
|
||||
mode: 0, EndOfPathActionType.Idle, specialAction: command.Action));
|
||||
mode: 0, EndOfPathActionType.Idle, _movementCts.Token, specialAction: command.Action));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -539,7 +585,7 @@ namespace Pal3.Actor
|
||||
{
|
||||
if (_actor.Info.Id != command.ActorId) return;
|
||||
var moveDistance = command.Distance / GameBoxInterpreter.GameBoxUnitToUnityUnit;
|
||||
var newPosition = transform.position + (-transform.forward * moveDistance);
|
||||
Vector3 newPosition = transform.position + (-transform.forward * moveDistance);
|
||||
MoveTo(newPosition, 2);
|
||||
}
|
||||
|
||||
@@ -555,6 +601,7 @@ namespace Pal3.Actor
|
||||
new Vector2Int(command.TileX, command.TileZ),
|
||||
command.Mode,
|
||||
EndOfPathActionType.DisposeSelf,
|
||||
_movementCts.Token,
|
||||
true));
|
||||
}
|
||||
|
||||
@@ -562,6 +609,8 @@ namespace Pal3.Actor
|
||||
{
|
||||
if (_actor.Info.Id != command.ActorId) return;
|
||||
_movementWaiter?.CancelWait();
|
||||
_movementCts?.Cancel();
|
||||
_movementCts = new CancellationTokenSource();
|
||||
_currentPath.Clear();
|
||||
}
|
||||
|
||||
@@ -574,7 +623,13 @@ namespace Pal3.Actor
|
||||
public void Execute(ActorActivateCommand command)
|
||||
{
|
||||
if (_actor.Info.Id != command.ActorId) return;
|
||||
if (command.IsActive == 0) _currentPath.Clear();
|
||||
if (command.IsActive == 0)
|
||||
{
|
||||
_movementWaiter?.CancelWait();
|
||||
_movementCts?.Cancel();
|
||||
_movementCts = new CancellationTokenSource();
|
||||
_currentPath.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ namespace Pal3.Actor
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.GameBox;
|
||||
using MetaData;
|
||||
using Player;
|
||||
using Script.Waiter;
|
||||
using UnityEngine;
|
||||
@@ -19,11 +18,14 @@ namespace Pal3.Actor
|
||||
ICommandExecutor<FlyingActorFlyToCommand>
|
||||
{
|
||||
private const float FLY_SPEED = 144f / GameBoxInterpreter.GameBoxUnitToUnityUnit;
|
||||
private const float FLYING_MOVEMENT_MODE_SWITCH_DISTANCE = 5f;
|
||||
|
||||
private Actor _actor;
|
||||
private ActorActionController _actionController;
|
||||
|
||||
public void Init(ActorActionController actionController)
|
||||
public void Init(Actor actor, ActorActionController actionController)
|
||||
{
|
||||
_actor = actor;
|
||||
_actionController = actionController;
|
||||
}
|
||||
|
||||
@@ -39,11 +41,12 @@ namespace Pal3.Actor
|
||||
|
||||
public void Execute(FlyingActorFlyToCommand command)
|
||||
{
|
||||
var targetPosition = GameBoxInterpreter.ToUnityPosition(new Vector3(command.X, command.Y, command.Z));
|
||||
Vector3 targetPosition = GameBoxInterpreter.ToUnityPosition(new Vector3(command.X, command.Y, command.Z));
|
||||
|
||||
if (Vector3.Distance(transform.position, PlayerActorNpcInfo.InitPosition) < float.Epsilon)
|
||||
{
|
||||
transform.position = targetPosition;
|
||||
_actionController.PerformAction(_actor.GetIdleAction());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,22 +56,24 @@ namespace Pal3.Actor
|
||||
var distance = (targetPosition - transform.position).magnitude;
|
||||
var duration = distance / FLY_SPEED;
|
||||
|
||||
_actionController.PerformAction(ActorActionType.Run);
|
||||
_actionController.PerformAction(distance < FLYING_MOVEMENT_MODE_SWITCH_DISTANCE
|
||||
? _actor.GetMovementAction(0)
|
||||
: _actor.GetMovementAction(1));
|
||||
|
||||
StartCoroutine(Fly(targetPosition, duration, waiter));
|
||||
}
|
||||
|
||||
private IEnumerator Fly(Vector3 targetPosition, float duration, WaitUntilCanceled waiter = null)
|
||||
{
|
||||
var oldPosition = transform.position;
|
||||
Vector3 oldPosition = transform.position;
|
||||
|
||||
// Facing towards target position, ignoring y
|
||||
transform.forward = (new Vector3(targetPosition.x, 0f, targetPosition.z)
|
||||
- new Vector3(oldPosition.x, 0f, oldPosition.z)).normalized;
|
||||
|
||||
transform.LookAt(new Vector3(targetPosition.x, oldPosition.y, targetPosition.z));
|
||||
|
||||
var timePast = 0f;
|
||||
while (timePast < duration)
|
||||
{
|
||||
var newPosition = oldPosition;
|
||||
Vector3 newPosition = oldPosition;
|
||||
newPosition += (timePast / duration) * (targetPosition - oldPosition);
|
||||
|
||||
transform.position = newPosition;
|
||||
@@ -78,6 +83,7 @@ namespace Pal3.Actor
|
||||
}
|
||||
|
||||
transform.position = targetPosition;
|
||||
_actionController.PerformAction(_actor.GetIdleAction());
|
||||
waiter?.CancelWait();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,19 @@ namespace Pal3.Actor
|
||||
ICommandExecutor<HuaYingSwitchBehaviourModeCommand>
|
||||
{
|
||||
private const float FLY_SPEED = 144f / GameBoxInterpreter.GameBoxUnitToUnityUnit;
|
||||
private const float ROTATION_SPEED = 10f;
|
||||
private const float ROTATION_SYNCING_DISTANCE = 2f;
|
||||
private const float FOLLOW_TARGET_MIN_DISTANCE = 1f;
|
||||
private const float FOLLOW_TARGET_MAX_DISTANCE = 6f;
|
||||
private const float FOLLOW_TARGET_X_OFFSET = -0.8f;
|
||||
private const float FOLLOW_TARGET_Y_OFFSET = -0.8f;
|
||||
|
||||
private readonly PlayerActorId _followActorId = PlayerActorId.XueJian;
|
||||
private const PlayerActorId FOLLOW_ACTOR_ID = PlayerActorId.XueJian;
|
||||
|
||||
private SceneManager _sceneManager;
|
||||
private Actor _actor;
|
||||
private ActorController _actorController;
|
||||
private ActorActionController _actorActionController;
|
||||
|
||||
private bool _isTargetRegistered;
|
||||
private GameObject _target;
|
||||
@@ -35,15 +39,24 @@ namespace Pal3.Actor
|
||||
private ActorActionController _targetActorActionController;
|
||||
private float _targetHeight;
|
||||
private bool _followTarget = true;
|
||||
private int _currentMode = 1; // defaults to follow target actor
|
||||
|
||||
public void Init(ActorController actorController,
|
||||
public void Init(Actor actor,
|
||||
ActorController actorController,
|
||||
ActorActionController actionController)
|
||||
{
|
||||
base.Init(actionController);
|
||||
base.Init(actor, actionController);
|
||||
_actor = actor;
|
||||
_actorController = actorController;
|
||||
_actorActionController = actionController;
|
||||
_sceneManager = ServiceLocator.Instance.Get<SceneManager>();
|
||||
}
|
||||
|
||||
public int GetCurrentMode()
|
||||
{
|
||||
return _currentMode;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
@@ -56,8 +69,8 @@ namespace Pal3.Actor
|
||||
|
||||
private Vector3 GetTargetStayPosition()
|
||||
{
|
||||
var targetFacingDirection = _target.transform.forward;
|
||||
var xOffsetDirection = Quaternion.Euler(0f, 90f, 0f) * targetFacingDirection;
|
||||
Vector3 targetFacingDirection = _target.transform.forward;
|
||||
Vector3 xOffsetDirection = Quaternion.Euler(0f, 90f, 0f) * targetFacingDirection;
|
||||
|
||||
return _target.transform.position +
|
||||
(-targetFacingDirection * FOLLOW_TARGET_MIN_DISTANCE) +
|
||||
@@ -95,28 +108,43 @@ namespace Pal3.Actor
|
||||
transform.position = GetTargetStayPosition();
|
||||
}
|
||||
|
||||
var myNewPosition = GetTargetStayPosition();
|
||||
Vector3 myNewPosition = GetTargetStayPosition();
|
||||
var distanceToNewPosition = Vector3.Distance(myNewPosition, transform.position);
|
||||
|
||||
if (Vector3.Distance(myNewPosition, transform.position) > FOLLOW_TARGET_MAX_DISTANCE)
|
||||
if (distanceToNewPosition < float.Epsilon)
|
||||
{
|
||||
transform.position = myNewPosition;
|
||||
_actorActionController.PerformAction(_actor.GetIdleAction());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Vector3.Distance(myNewPosition, transform.position) < FOLLOW_TARGET_MAX_DISTANCE)
|
||||
{
|
||||
_actorActionController.PerformAction(_actor.GetMovementAction(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = (transform.position - myNewPosition).normalized * FOLLOW_TARGET_MAX_DISTANCE +
|
||||
myNewPosition;
|
||||
_actorActionController.PerformAction(_actor.GetMovementAction(1));
|
||||
}
|
||||
|
||||
transform.position = Vector3.MoveTowards(transform.position,
|
||||
myNewPosition,
|
||||
Time.deltaTime * FLY_SPEED);
|
||||
transform.LookAt(new Vector3(myNewPosition.x, transform.position.y, myNewPosition.z));
|
||||
}
|
||||
|
||||
if (_isTargetRegistered)
|
||||
if (distanceToNewPosition < ROTATION_SYNCING_DISTANCE)
|
||||
{
|
||||
transform.rotation = _target.transform.rotation;
|
||||
Vector3 newRotation= Vector3.RotateTowards(transform.forward,
|
||||
_target.transform.forward, ROTATION_SPEED * Time.deltaTime, 0.0f);
|
||||
transform.rotation = Quaternion.LookRotation(newRotation);
|
||||
}
|
||||
}
|
||||
|
||||
private void FindAndSetTarget()
|
||||
{
|
||||
_target = _sceneManager.GetCurrentScene().GetActorGameObject((byte) _followActorId);
|
||||
_target = _sceneManager.GetCurrentScene().GetActorGameObject((byte) FOLLOW_ACTOR_ID);
|
||||
_targetActorController = _target.GetComponent<ActorController>();
|
||||
_targetActorActionController = _target.GetComponent<ActorActionController>();
|
||||
_isTargetRegistered = true;
|
||||
@@ -139,6 +167,8 @@ namespace Pal3.Actor
|
||||
_followTarget = false;
|
||||
break;
|
||||
}
|
||||
|
||||
_currentMode = command.Mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,14 @@ namespace Pal3.Actor
|
||||
using MetaData;
|
||||
using UnityEngine;
|
||||
|
||||
public class LongKuiController : MonoBehaviour,
|
||||
public sealed class LongKuiController : MonoBehaviour,
|
||||
ICommandExecutor<LongKuiSwitchModeCommand>
|
||||
{
|
||||
private Actor _actor;
|
||||
private ActorActionController _actionController;
|
||||
|
||||
private int _currentMode = 0;
|
||||
|
||||
public void Init(Actor actor, ActorActionController actionController)
|
||||
{
|
||||
_actor = actor;
|
||||
@@ -33,12 +35,20 @@ namespace Pal3.Actor
|
||||
{
|
||||
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
||||
}
|
||||
|
||||
public int GetCurrentMode()
|
||||
{
|
||||
return _currentMode;
|
||||
}
|
||||
|
||||
public void Execute(LongKuiSwitchModeCommand command)
|
||||
{
|
||||
_currentMode = command.Mode;
|
||||
|
||||
_actor.ChangeName(command.Mode == 0 ?
|
||||
ActorConstants.LongKuiHumanModeActorName :
|
||||
ActorConstants.LongKuiGhostModeActorName);
|
||||
|
||||
if (_actor.IsActive)
|
||||
{
|
||||
_actionController.PerformAction(_actor.GetIdleAction(), overwrite: true);
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Pal3.Audio
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Command;
|
||||
@@ -14,6 +15,7 @@ namespace Pal3.Audio
|
||||
using Command.SceCommands;
|
||||
using Core.DataLoader;
|
||||
using Core.DataReader.Cpk;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.Extensions;
|
||||
using Data;
|
||||
using MetaData;
|
||||
@@ -21,39 +23,45 @@ namespace Pal3.Audio
|
||||
using State;
|
||||
using UnityEngine;
|
||||
|
||||
public class AudioManager : MonoBehaviour,
|
||||
public sealed class AudioManager : MonoBehaviour,
|
||||
ICommandExecutor<PlaySfxCommand>,
|
||||
ICommandExecutor<PlayMusicCommand>,
|
||||
ICommandExecutor<PlaySfxAtGameObjectRequest>,
|
||||
ICommandExecutor<AttachSfxToGameObjectRequest>,
|
||||
ICommandExecutor<StopSfxPlayingAtGameObjectRequest>,
|
||||
ICommandExecutor<GameStateChangedNotification>,
|
||||
ICommandExecutor<StopMusicCommand>,
|
||||
ICommandExecutor<ScenePreLoadingNotification>,
|
||||
ICommandExecutor<ScenePostLoadingNotification>,
|
||||
ICommandExecutor<ResetGameStateCommand>
|
||||
{
|
||||
public float MusicVolume { get; set; } = 0.7f;
|
||||
public float SoundVolume { get; set; } = 0.6f;
|
||||
public float DefaultMusicVolume { get; set; } = 0.45f;
|
||||
public float DefaultSoundVolume { get; set; } = 0.65f;
|
||||
|
||||
private Camera _mainCamera;
|
||||
private AudioSource _musicPlayer;
|
||||
private AudioSource _sfxPlayer;
|
||||
private GameResourceProvider _resourceProvider;
|
||||
private SceneManager _sceneManager;
|
||||
|
||||
private const string STOP_MUSIC_NAME = "NONE";
|
||||
private string _currentMusicClipName = string.Empty;
|
||||
private string _currentScriptMusic = string.Empty;
|
||||
private readonly List<string> _playingSfxSourceNames = new ();
|
||||
|
||||
// TODO: Fix and remove this hack
|
||||
private const string PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME = "PlayerActorMovementSfx";
|
||||
private bool _playerMovementSfxInProgress;
|
||||
|
||||
private CancellationTokenSource _sceneAudioCts = new ();
|
||||
|
||||
public void Init(GameResourceProvider resourceProvider,
|
||||
public void Init(Camera mainCamera,
|
||||
GameResourceProvider resourceProvider,
|
||||
SceneManager sceneManager,
|
||||
AudioSource musicSource,
|
||||
AudioSource sfxSource)
|
||||
AudioSource musicSource)
|
||||
{
|
||||
_resourceProvider = resourceProvider;
|
||||
_sceneManager = sceneManager;
|
||||
_musicPlayer = musicSource;
|
||||
_sfxPlayer = sfxSource;
|
||||
_mainCamera = mainCamera != null ? mainCamera : throw new ArgumentNullException(nameof(mainCamera));
|
||||
_resourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_musicPlayer = musicSource != null ? musicSource : throw new ArgumentNullException(nameof(musicSource));
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
@@ -66,7 +74,7 @@ namespace Pal3.Audio
|
||||
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
||||
}
|
||||
|
||||
private void PlaySceneMusic(string cityName, string sceneName)
|
||||
private IEnumerator PlaySceneMusic(string cityName, string sceneName)
|
||||
{
|
||||
var key = $"{cityName}_{sceneName}";
|
||||
var musicName = string.Empty;
|
||||
@@ -83,28 +91,32 @@ namespace Pal3.Audio
|
||||
{
|
||||
_currentMusicClipName = string.Empty;
|
||||
_musicPlayer.Stop();
|
||||
return;
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (_musicPlayer.isPlaying &&
|
||||
string.Equals(_currentMusicClipName, musicName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
yield break;
|
||||
}
|
||||
|
||||
_currentMusicClipName = musicName;
|
||||
var musicFileVirtualPath = GetMusicFileVirtualPath(musicName);
|
||||
var musicFileCachePath = _resourceProvider.GetMp3FilePathInCacheFolder(musicFileVirtualPath);
|
||||
StartCoroutine(PlayMusic(musicFileVirtualPath, musicFileCachePath, -1));
|
||||
|
||||
yield return PlayMusic(musicName, musicFileVirtualPath, musicFileCachePath, -1);
|
||||
}
|
||||
|
||||
public IEnumerator PlayAudioClip(AudioSource audioSource,
|
||||
private IEnumerator PlayAudioClip(AudioSource audioSource,
|
||||
AudioClip audioClip,
|
||||
int loopCount,
|
||||
float interval,
|
||||
float volume,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (loopCount <= 0)
|
||||
if (audioSource == null || !audioSource.enabled) yield break;
|
||||
|
||||
if (loopCount == -1 && interval == 0f)
|
||||
{
|
||||
if (audioSource.clip != null)
|
||||
{
|
||||
@@ -117,119 +129,267 @@ namespace Pal3.Audio
|
||||
audioSource.loop = true;
|
||||
audioSource.Play();
|
||||
}
|
||||
else if (loopCount == -1 && interval > 0f)
|
||||
{
|
||||
while (!cancellationToken.IsCancellationRequested && audioSource != null)
|
||||
{
|
||||
audioSource.PlayOneShot(audioClip, volume);
|
||||
yield return new WaitForSeconds(audioClip.length + interval);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (--loopCount >= 0 && !cancellationToken.IsCancellationRequested)
|
||||
while (--loopCount >= 0 && !cancellationToken.IsCancellationRequested && audioSource != null)
|
||||
{
|
||||
audioSource.PlayOneShot(audioClip, volume);
|
||||
yield return new WaitForSeconds(audioClip.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator PlaySfx(string sfxFilePath, int loopCount, CancellationToken cancellationToken)
|
||||
{
|
||||
yield return AudioClipLoader.LoadAudioClip(sfxFilePath, AudioType.WAV, audioClip =>
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested) return;
|
||||
StartCoroutine(PlayAudioClip(_sfxPlayer, audioClip, loopCount, SoundVolume, cancellationToken));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Spatial Audio
|
||||
public IEnumerator PlaySfx(string sfxFilePath, int loopCount, GameObject parent, CancellationToken cancellationToken)
|
||||
{
|
||||
yield return AudioClipLoader.LoadAudioClip(sfxFilePath, AudioType.WAV, audioClip =>
|
||||
{
|
||||
if (parent == null || cancellationToken.IsCancellationRequested) return;
|
||||
|
||||
var audioSource = parent.GetOrAddComponent<AudioSource>();
|
||||
audioSource.spatialBlend = 1.0f;
|
||||
audioSource.rolloffMode = AudioRolloffMode.Linear;
|
||||
audioSource.maxDistance = 75f;
|
||||
|
||||
StartCoroutine(PlayAudioClip(audioSource, audioClip, loopCount, SoundVolume, cancellationToken));
|
||||
});
|
||||
}
|
||||
|
||||
private string GetMusicFileVirtualPath(string musicName)
|
||||
{
|
||||
var separator = CpkConstants.CpkDirectorySeparatorChar;
|
||||
return $"{FileConstants.MusicCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.MusicCpkPathInfo.relativePath}{separator}{musicName}.mp3";
|
||||
}
|
||||
|
||||
public IEnumerator PlayMusic(string musicFileVirtualPath, string musicFileCachePath, int loopCount)
|
||||
{
|
||||
yield return _resourceProvider.ExtractAndMoveMp3FileToCacheFolder(musicFileVirtualPath, musicFileCachePath);
|
||||
yield return AudioClipLoader.LoadAudioClip(musicFileCachePath, AudioType.MPEG, audioClip =>
|
||||
{
|
||||
StartCoroutine(PlayAudioClip(_musicPlayer, audioClip, loopCount, MusicVolume,
|
||||
new CancellationToken(false))); // Should not stop music during scene switch
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerator PlaySfxAfterDelay(string sfxFilePath,
|
||||
float startDelayInSeconds,
|
||||
private IEnumerator AttachSfxToGameObjectAndPlaySfx(GameObject parent,
|
||||
string sfxFilePath,
|
||||
string audioSourceName,
|
||||
int loopCount,
|
||||
GameObject parent,
|
||||
float volume,
|
||||
float interval = 0f,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (parent == null || cancellationToken.IsCancellationRequested) yield break;
|
||||
|
||||
AudioClip sfxAudioClip = null;
|
||||
|
||||
yield return _resourceProvider.LoadAudioClip(sfxFilePath, AudioType.WAV, audioClip =>
|
||||
{
|
||||
sfxAudioClip = audioClip;
|
||||
});
|
||||
|
||||
if (parent == null ||
|
||||
cancellationToken.IsCancellationRequested ||
|
||||
sfxAudioClip == null) yield break;
|
||||
|
||||
if (parent != _mainCamera.gameObject &&
|
||||
audioSourceName == PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME &&
|
||||
_playerMovementSfxInProgress == false)
|
||||
{
|
||||
yield break; // Means movement sfx is already stopped before it started due to the delay of the coroutine
|
||||
}
|
||||
|
||||
if (parent == _mainCamera.gameObject &&
|
||||
!_playingSfxSourceNames.Contains(audioSourceName))
|
||||
{
|
||||
yield break; // Means sfx is already stopped before it started due to the delay of the coroutine
|
||||
}
|
||||
|
||||
GameObject audioSourceParent;
|
||||
Transform audioSourceParentTransform = parent.transform.Find(audioSourceName);
|
||||
if (audioSourceParentTransform != null)
|
||||
{
|
||||
audioSourceParent = audioSourceParentTransform.gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
audioSourceParent = new GameObject(audioSourceName);
|
||||
audioSourceParent.transform.parent = parent.transform;
|
||||
audioSourceParent.transform.position = parent.transform.position;
|
||||
}
|
||||
|
||||
var audioSource = audioSourceParent.GetOrAddComponent<AudioSource>();
|
||||
audioSource.spatialBlend = 1.0f;
|
||||
audioSource.rolloffMode = AudioRolloffMode.Linear;
|
||||
audioSource.maxDistance = 75f;
|
||||
|
||||
yield return PlayAudioClip(audioSource, sfxAudioClip, loopCount, interval, volume, cancellationToken);
|
||||
}
|
||||
|
||||
private IEnumerator StartWithDelay(
|
||||
float delayInSeconds,
|
||||
IEnumerator coroutine,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (startDelayInSeconds > 0)
|
||||
if (delayInSeconds > 0)
|
||||
{
|
||||
yield return new WaitForSeconds(startDelayInSeconds);
|
||||
yield return new WaitForSeconds(delayInSeconds);
|
||||
}
|
||||
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
yield return PlaySfx(sfxFilePath,
|
||||
loopCount,
|
||||
parent,
|
||||
cancellationToken);
|
||||
yield return coroutine;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetMusicFileVirtualPath(string musicName)
|
||||
{
|
||||
var separator = CpkConstants.DirectorySeparator;
|
||||
return $"{FileConstants.MusicCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.MusicCpkPathInfo.relativePath}{separator}{musicName}.mp3";
|
||||
}
|
||||
|
||||
public IEnumerator PlayMusic(string musicName,
|
||||
string musicFileVirtualPath,
|
||||
string musicFileCachePath,
|
||||
int loopCount)
|
||||
{
|
||||
yield return _resourceProvider.ExtractAndMoveMp3FileToCacheFolder(musicFileVirtualPath, musicFileCachePath);
|
||||
|
||||
AudioClip musicClip = null;
|
||||
yield return _resourceProvider.LoadAudioClip(musicFileCachePath, AudioType.MPEG, audioClip =>
|
||||
{
|
||||
musicClip = audioClip;
|
||||
});
|
||||
|
||||
// We need to check if current music clip is the same as the one we are trying to play,
|
||||
// since we are using coroutine to load and play music, there is a chance that the music
|
||||
// clip we are trying to play is not the same as the one we supposed to play.
|
||||
if (musicClip == null ||
|
||||
!string.Equals(_currentMusicClipName, musicName, StringComparison.OrdinalIgnoreCase)) yield break;
|
||||
|
||||
yield return PlayAudioClip(_musicPlayer, musicClip, loopCount, 0f, DefaultMusicVolume,
|
||||
new CancellationToken(false)); // Should not stop music during scene switch
|
||||
}
|
||||
|
||||
public string GetCurrentScriptMusic()
|
||||
{
|
||||
return _currentScriptMusic;
|
||||
}
|
||||
|
||||
private void DestroyAllSfxAudioSource()
|
||||
{
|
||||
// Destroy current playing sfx
|
||||
foreach (Transform audioSourceParentTransform in _playingSfxSourceNames
|
||||
.Select(sfxName => _mainCamera.transform.Find(sfxName))
|
||||
.Where(audioSourceParentTransform => audioSourceParentTransform != null))
|
||||
{
|
||||
if (audioSourceParentTransform.GetComponent<AudioSource>() is { } audioSource)
|
||||
{
|
||||
audioSource.Stop();
|
||||
|
||||
if (audioSource.clip != null)
|
||||
{
|
||||
Destroy(audioSource.clip);
|
||||
}
|
||||
}
|
||||
|
||||
Destroy(audioSourceParentTransform.gameObject);
|
||||
}
|
||||
|
||||
_playingSfxSourceNames.Clear();
|
||||
}
|
||||
|
||||
private void ChangeAllSfxAudioSourceMuteSetting(bool mute)
|
||||
{
|
||||
foreach (Transform audioSourceParentTransform in _playingSfxSourceNames
|
||||
.Select(sfxName => _mainCamera.transform.Find(sfxName))
|
||||
.Where(audioSourceParentTransform => audioSourceParentTransform != null))
|
||||
{
|
||||
if (audioSourceParentTransform.GetComponent<AudioSource>() is { } audioSource)
|
||||
{
|
||||
audioSource.mute = mute;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(PlaySfxCommand command)
|
||||
{
|
||||
var sfxName = command.SfxName;
|
||||
#if PAL3
|
||||
var sfxName = command.SfxName.ToLower();
|
||||
#elif PAL3A
|
||||
var sfxName = command.SfxName.ToUpper();
|
||||
#endif
|
||||
|
||||
var loopCount = command.LoopCount;
|
||||
|
||||
// TODO: Start/stop walk/run sfx based on actor behaviour
|
||||
if (command.SfxName.Contains("we022", StringComparison.OrdinalIgnoreCase))
|
||||
#if PAL3
|
||||
// Fix actor movement sfx name
|
||||
if (sfxName.Equals("we021", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
loopCount = 3;
|
||||
sfxName = "we021a";
|
||||
}
|
||||
|
||||
// TODO: Change walk/run sfx based on tile type
|
||||
if (command.SfxName.Equals("we022", StringComparison.OrdinalIgnoreCase))
|
||||
if (sfxName.Equals("we022", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
sfxName = "we022b";
|
||||
sfxName = "we022a";
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: This sfx will be triggered to loop forever after actor
|
||||
// leaving the hotel. Maybe we should play it by attaching
|
||||
// the sound to the hotel position?
|
||||
if (command.SfxName.Equals("wc019", StringComparison.OrdinalIgnoreCase) &&
|
||||
command.LoopCount == -1)
|
||||
switch (loopCount)
|
||||
{
|
||||
return;
|
||||
case 0: // start playing sfx indefinitely for the given sfxName
|
||||
_playingSfxSourceNames.Add(sfxName);
|
||||
StartCoroutine(AttachSfxToGameObjectAndPlaySfx(_mainCamera.gameObject,
|
||||
_resourceProvider.GetSfxFilePath(sfxName),
|
||||
sfxName, // use sfx name as audio source name
|
||||
loopCount: -1, // loop indefinitely
|
||||
DefaultSoundVolume,
|
||||
interval: 0f,
|
||||
_sceneAudioCts.Token));
|
||||
break;
|
||||
case -1: // stop playing sfx by sfxName
|
||||
_playingSfxSourceNames.Remove(sfxName);
|
||||
Execute(new StopSfxPlayingAtGameObjectRequest(
|
||||
_mainCamera.gameObject,
|
||||
sfxName,
|
||||
disposeSource: true));
|
||||
break;
|
||||
default:
|
||||
{
|
||||
_playingSfxSourceNames.Add(sfxName);
|
||||
var sfxFilePath = _resourceProvider.GetSfxFilePath(sfxName);
|
||||
CancellationToken cancellationToken = _sceneAudioCts.Token;
|
||||
StartCoroutine(AttachSfxToGameObjectAndPlaySfx(_mainCamera.gameObject,
|
||||
sfxFilePath,
|
||||
sfxName, // use sfx name as audio source name
|
||||
loopCount,
|
||||
DefaultSoundVolume,
|
||||
interval: 0f,
|
||||
cancellationToken));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var sfxFilePath = _resourceProvider.GetSfxFilePath(sfxName);
|
||||
var cancellationToken = _sceneAudioCts.Token;
|
||||
StartCoroutine(PlaySfx(sfxFilePath, loopCount, cancellationToken));
|
||||
}
|
||||
|
||||
public void Execute(PlaySfxAtGameObjectRequest request)
|
||||
public void Execute(AttachSfxToGameObjectRequest request)
|
||||
{
|
||||
if (request.AudioSourceName == PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME)
|
||||
{
|
||||
_playerMovementSfxInProgress = true;
|
||||
}
|
||||
|
||||
var sfxFilePath = _resourceProvider.GetSfxFilePath(request.SfxName);
|
||||
var cancellationToken = _sceneAudioCts.Token;
|
||||
StartCoroutine(PlaySfxAfterDelay(sfxFilePath,
|
||||
request.StartDelayInSeconds,
|
||||
request.LoopCount,
|
||||
request.Parent,
|
||||
CancellationToken cancellationToken = _sceneAudioCts.Token;
|
||||
StartCoroutine(StartWithDelay(request.StartDelayInSeconds,
|
||||
AttachSfxToGameObjectAndPlaySfx(request.Parent,
|
||||
sfxFilePath,
|
||||
request.AudioSourceName,
|
||||
request.LoopCount,
|
||||
request.Volume,
|
||||
request.Interval,
|
||||
cancellationToken),
|
||||
cancellationToken));
|
||||
}
|
||||
|
||||
public void Execute(StopSfxPlayingAtGameObjectRequest command)
|
||||
{
|
||||
if (command.AudioSourceName == PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME)
|
||||
{
|
||||
_playerMovementSfxInProgress = false;
|
||||
}
|
||||
|
||||
Transform audioSourceParentTransform = command.Parent.transform.Find(command.AudioSourceName);
|
||||
if (audioSourceParentTransform == null) return;
|
||||
|
||||
GameObject audioSourceParent = audioSourceParentTransform.gameObject;
|
||||
var audioSource = audioSourceParent.GetComponentInChildren<AudioSource>();
|
||||
if (audioSource == default) return;
|
||||
|
||||
audioSource.Stop();
|
||||
audioSource.clip = null;
|
||||
|
||||
if (command.DisposeSource)
|
||||
{
|
||||
Destroy(audioSourceParent);
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(PlayMusicCommand command)
|
||||
{
|
||||
@@ -242,7 +402,9 @@ namespace Pal3.Audio
|
||||
|
||||
// TODO: Disable combat music since combat system has not been implemented yet.
|
||||
if (MusicConstants.CombatMusicInfo.Any(musicInfo =>
|
||||
command.MusicName.Equals(musicInfo.Value, StringComparison.OrdinalIgnoreCase)))
|
||||
command.MusicName.Equals(musicInfo.Value, StringComparison.OrdinalIgnoreCase)) ||
|
||||
command.MusicName.Equals("PI25A", StringComparison.OrdinalIgnoreCase) ||
|
||||
command.MusicName.Equals("PI25", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -251,7 +413,8 @@ namespace Pal3.Audio
|
||||
_currentMusicClipName = command.MusicName;
|
||||
var musicFileVirtualPath = GetMusicFileVirtualPath(command.MusicName);
|
||||
var musicFileCachePath = _resourceProvider.GetMp3FilePathInCacheFolder(musicFileVirtualPath);
|
||||
StartCoroutine(PlayMusic(musicFileVirtualPath,
|
||||
StartCoroutine(PlayMusic(command.MusicName,
|
||||
musicFileVirtualPath,
|
||||
musicFileCachePath,
|
||||
command.Loop == 0 ? -1 : command.Loop));
|
||||
}
|
||||
@@ -266,19 +429,13 @@ namespace Pal3.Audio
|
||||
_currentScriptMusic = string.Empty;
|
||||
_currentMusicClipName = string.Empty;
|
||||
|
||||
var sceneInfo = _sceneManager.GetCurrentScene().GetSceneInfo();
|
||||
PlaySceneMusic(sceneInfo.CityName, sceneInfo.Name);
|
||||
ScnSceneInfo sceneInfo = _sceneManager.GetCurrentScene().GetSceneInfo();
|
||||
StartCoroutine(PlaySceneMusic(sceneInfo.CityName, sceneInfo.Name));
|
||||
}
|
||||
|
||||
public void Execute(ScenePreLoadingNotification command)
|
||||
{
|
||||
if (_sfxPlayer.clip != null)
|
||||
{
|
||||
_sfxPlayer.loop = false;
|
||||
_sfxPlayer.Stop();
|
||||
Destroy(_sfxPlayer.clip);
|
||||
}
|
||||
|
||||
DestroyAllSfxAudioSource();
|
||||
_sceneAudioCts.Cancel();
|
||||
_sceneAudioCts = new CancellationTokenSource();
|
||||
}
|
||||
@@ -287,15 +444,15 @@ namespace Pal3.Audio
|
||||
{
|
||||
if (string.IsNullOrEmpty(_currentScriptMusic))
|
||||
{
|
||||
PlaySceneMusic(command.NewSceneInfo.CityName, command.NewSceneInfo.Name);
|
||||
StartCoroutine(PlaySceneMusic(command.NewSceneInfo.CityName, command.NewSceneInfo.Name));
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(ResetGameStateCommand command)
|
||||
{
|
||||
DestroyAllSfxAudioSource();
|
||||
_currentScriptMusic = string.Empty;
|
||||
_musicPlayer.Stop();
|
||||
_sfxPlayer.Stop();
|
||||
}
|
||||
|
||||
public void Execute(GameStateChangedNotification command)
|
||||
@@ -308,12 +465,12 @@ namespace Pal3.Audio
|
||||
}
|
||||
|
||||
_musicPlayer.mute = true;
|
||||
_sfxPlayer.mute = true;
|
||||
ChangeAllSfxAudioSourceMuteSetting(true);
|
||||
}
|
||||
else
|
||||
else if (command.PreviousState == GameState.VideoPlaying)
|
||||
{
|
||||
if (_musicPlayer.mute) _musicPlayer.mute = false;
|
||||
if (_sfxPlayer.mute) _sfxPlayer.mute = false;
|
||||
_musicPlayer.mute = false;
|
||||
ChangeAllSfxAudioSourceMuteSetting(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
|
||||
namespace Pal3.Camera
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
@@ -24,7 +27,7 @@ namespace Pal3.Camera
|
||||
using UnityEngine.InputSystem.OnScreen;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CameraManager : MonoBehaviour,
|
||||
public sealed class CameraManager : MonoBehaviour,
|
||||
ICommandExecutor<CameraSetTransformCommand>,
|
||||
ICommandExecutor<CameraSetDefaultTransformCommand>,
|
||||
ICommandExecutor<CameraShakeEffectCommand>,
|
||||
@@ -45,7 +48,9 @@ namespace Pal3.Camera
|
||||
ICommandExecutor<CameraFocusOnActorCommand>,
|
||||
ICommandExecutor<CameraFocusOnSceneObjectCommand>,
|
||||
ICommandExecutor<ScenePreLoadingNotification>,
|
||||
ICommandExecutor<GameStateChangedNotification>
|
||||
ICommandExecutor<SceneLeavingCurrentSceneNotification>,
|
||||
ICommandExecutor<GameStateChangedNotification>,
|
||||
ICommandExecutor<ResetGameStateCommand>
|
||||
{
|
||||
private const float FADE_ANIMATION_DURATION = 3f;
|
||||
private const float SCENE_STORY_B_ROOM_HEIGHT = 32f;
|
||||
@@ -73,28 +78,40 @@ namespace Pal3.Camera
|
||||
private PlayerInputActions _inputActions;
|
||||
private PlayerGamePlayController _gamePlayController;
|
||||
private SceneManager _sceneManager;
|
||||
private GameStateManager _gameStateManager;
|
||||
private bool _freeToRotate;
|
||||
|
||||
private GameObject _lookAtGameObject;
|
||||
|
||||
private int _currentAppliedDefaultTransformOption = 0;
|
||||
|
||||
private RectTransform _joyStickRect;
|
||||
private float _joyStickMovementRange;
|
||||
private bool _isTouchEnabled;
|
||||
|
||||
private bool _cameraAnimationInProgress;
|
||||
private CancellationTokenSource _asyncCameraAnimationCts = new ();
|
||||
private CancellationTokenSource _cameraFadeAnimationCts = new ();
|
||||
|
||||
private const int LAST_KNOWN_SCENE_STATE_LIST_MAX_LENGTH = 1;
|
||||
private readonly List<(ScnSceneInfo sceneInfo,
|
||||
Vector3 cameraPosition,
|
||||
Quaternion cameraRotation,
|
||||
Vector3 cameraOffset)> _cameraLastKnownSceneState = new ();
|
||||
|
||||
public void Init(PlayerInputActions inputActions,
|
||||
PlayerGamePlayController gamePlayController,
|
||||
SceneManager sceneManager,
|
||||
GameStateManager gameStateManager,
|
||||
Camera mainCamera,
|
||||
Canvas touchControlUI,
|
||||
Image curtainImage)
|
||||
{
|
||||
_inputActions = inputActions;
|
||||
_gamePlayController = gamePlayController;
|
||||
_sceneManager = sceneManager;
|
||||
|
||||
_inputActions = inputActions ?? throw new ArgumentNullException(nameof(inputActions));
|
||||
_gamePlayController = gamePlayController != null ? gamePlayController : throw new ArgumentNullException(nameof(gamePlayController));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_gameStateManager = gameStateManager ?? throw new ArgumentNullException(nameof(gameStateManager));
|
||||
|
||||
_camera = mainCamera;
|
||||
_camera!.fieldOfView = HorizontalToVerticalFov(24.05f, 4f/3f);
|
||||
|
||||
@@ -132,10 +149,10 @@ namespace Pal3.Camera
|
||||
_gamePlayController.GetPlayerActorLastKnownPosition();
|
||||
|
||||
var yOffset = new Vector3(0f, _lookAtPointYOffset, 0f);
|
||||
var targetPosition = _lastLookAtPoint + _cameraOffset;
|
||||
var currentPosition = _camera.transform.position;
|
||||
Vector3 targetPosition = _lastLookAtPoint + _cameraOffset;
|
||||
Vector3 currentPosition = _camera.transform.position;
|
||||
|
||||
var previousLookAtPoint = _lastLookAtPoint + (currentPosition - targetPosition);
|
||||
Vector3 previousLookAtPoint = _lastLookAtPoint + (currentPosition - targetPosition);
|
||||
|
||||
if (Vector3.Distance(targetPosition, currentPosition) > CAMERA_SMOOTH_FOLLOW_MAX_DISTANCE ||
|
||||
_shouldResetVelocity)
|
||||
@@ -192,7 +209,7 @@ namespace Pal3.Camera
|
||||
{
|
||||
var touchStartPosition = _inputActions.Gameplay.Touch0Start.ReadValue<Vector2>();
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(
|
||||
_joyStickRect, touchStartPosition, null, out var localPoint);
|
||||
_joyStickRect, touchStartPosition, null, out Vector2 localPoint);
|
||||
if (localPoint.x < -_joyStickMovementRange ||
|
||||
localPoint.x > _joyStickRect.rect.width + _joyStickMovementRange ||
|
||||
localPoint.y < -_joyStickMovementRange ||
|
||||
@@ -207,7 +224,7 @@ namespace Pal3.Camera
|
||||
{
|
||||
var touchStartPosition = _inputActions.Gameplay.Touch1Start.ReadValue<Vector2>();
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(
|
||||
_joyStickRect, touchStartPosition, null, out var localPoint);
|
||||
_joyStickRect, touchStartPosition, null, out Vector2 localPoint);
|
||||
if (localPoint.x < -_joyStickMovementRange ||
|
||||
localPoint.x > _joyStickRect.rect.width + _joyStickMovementRange ||
|
||||
localPoint.y < -_joyStickMovementRange ||
|
||||
@@ -252,8 +269,8 @@ namespace Pal3.Camera
|
||||
{
|
||||
_cameraAnimationInProgress = true;
|
||||
var curveType = (AnimationCurveType) mode;
|
||||
var cameraTransform = _camera.transform;
|
||||
var oldPosition = cameraTransform.position;
|
||||
Transform cameraTransform = _camera.transform;
|
||||
Vector3 oldPosition = cameraTransform.position;
|
||||
yield return AnimationHelper.MoveTransform(cameraTransform, position, duration, curveType, cancellationToken);
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
@@ -272,7 +289,7 @@ namespace Pal3.Camera
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
_cameraAnimationInProgress = true;
|
||||
var lookAtPoint = _lastLookAtPoint;
|
||||
Vector3 lookAtPoint = _lastLookAtPoint;
|
||||
yield return AnimationHelper.OrbitTransformAroundCenterPoint(_camera.transform,
|
||||
toRotation,
|
||||
lookAtPoint,
|
||||
@@ -312,11 +329,11 @@ namespace Pal3.Camera
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
_cameraAnimationInProgress = true;
|
||||
var oldPosition = _camera.transform.position;
|
||||
Vector3 oldPosition = _camera.transform.position;
|
||||
var oldDistance = Vector3.Distance(oldPosition, _lastLookAtPoint);
|
||||
var cameraDirection = (oldPosition - _lastLookAtPoint).normalized;
|
||||
var newPosition = oldPosition + cameraDirection * (distance - oldDistance);
|
||||
var cameraTransform = _camera.transform;
|
||||
Vector3 cameraDirection = (oldPosition - _lastLookAtPoint).normalized;
|
||||
Vector3 newPosition = oldPosition + cameraDirection * (distance - oldDistance);
|
||||
Transform cameraTransform = _camera.transform;
|
||||
|
||||
yield return AnimationHelper.MoveTransform(cameraTransform,
|
||||
newPosition,
|
||||
@@ -332,7 +349,11 @@ namespace Pal3.Camera
|
||||
waiter?.CancelWait();
|
||||
}
|
||||
|
||||
public IEnumerator Fade(bool fadeIn, float duration, Color color, WaitUntilCanceled waiter = null)
|
||||
public IEnumerator Fade(bool fadeIn,
|
||||
float duration,
|
||||
Color color,
|
||||
WaitUntilCanceled waiter = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
_curtainImage.color = color;
|
||||
|
||||
@@ -343,14 +364,22 @@ namespace Pal3.Camera
|
||||
alpha =>
|
||||
{
|
||||
_curtainImage.color = new Color(color.r, color.g, color.b, alpha);
|
||||
});
|
||||
}, cancellationToken);
|
||||
|
||||
_curtainImage.color = new Color(color.r, color.g, color.b, to);
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
_curtainImage.color = new Color(color.r, color.g, color.b, to);
|
||||
}
|
||||
|
||||
waiter?.CancelWait();
|
||||
}
|
||||
|
||||
public void ApplySceneSettings(ScnSceneInfo sceneInfo)
|
||||
public int GetCurrentAppliedDefaultTransformOption()
|
||||
{
|
||||
return _currentAppliedDefaultTransformOption;
|
||||
}
|
||||
|
||||
private void ApplySceneSettings(ScnSceneInfo sceneInfo)
|
||||
{
|
||||
switch (sceneInfo.SceneType)
|
||||
{
|
||||
@@ -358,27 +387,27 @@ namespace Pal3.Camera
|
||||
_freeToRotate = false;
|
||||
_lookAtPointYOffset = SCENE_STORY_B_ROOM_HEIGHT /
|
||||
GameBoxInterpreter.GameBoxUnitToUnityUnit;
|
||||
_camera.nearClipPlane = 0.5f;
|
||||
_camera.nearClipPlane = 1f;
|
||||
_camera.farClipPlane = 500f;
|
||||
ApplyDefaultSettings(1);
|
||||
break;
|
||||
case ScnSceneType.StoryA:
|
||||
_freeToRotate = true;
|
||||
_lookAtPointYOffset = 0;
|
||||
_camera.nearClipPlane = 1f;
|
||||
_camera.nearClipPlane = 2f;
|
||||
_camera.farClipPlane = 800f;
|
||||
ApplyDefaultSettings(0);
|
||||
break;
|
||||
case ScnSceneType.Maze:
|
||||
_freeToRotate = true;
|
||||
_lookAtPointYOffset = 0;
|
||||
_camera.nearClipPlane = 1f;
|
||||
_camera.nearClipPlane = 2f;
|
||||
_camera.farClipPlane = 800f;
|
||||
ApplyDefaultSettings(0);
|
||||
break;
|
||||
default:
|
||||
_lookAtPointYOffset = 0;
|
||||
_camera.nearClipPlane = 0.5f;
|
||||
_camera.nearClipPlane = 1f;
|
||||
_camera.farClipPlane = 500f;
|
||||
ApplyDefaultSettings(0);
|
||||
break;
|
||||
@@ -387,7 +416,7 @@ namespace Pal3.Camera
|
||||
_shouldResetVelocity = true;
|
||||
}
|
||||
|
||||
public void ApplyDefaultSettings(int option)
|
||||
private void ApplyDefaultSettings(int option)
|
||||
{
|
||||
Quaternion rotation;
|
||||
float distance = 688.0f / GameBoxInterpreter.GameBoxUnitToUnityUnit;
|
||||
@@ -417,10 +446,10 @@ namespace Pal3.Camera
|
||||
|
||||
var yOffset = new Vector3(0f, _lookAtPointYOffset, 0f);
|
||||
|
||||
var cameraDirection = (rotation * Vector3.forward).normalized;
|
||||
var cameraPosition = _lastLookAtPoint + cameraDirection * -distance + yOffset;
|
||||
Vector3 cameraDirection = (rotation * Vector3.forward).normalized;
|
||||
Vector3 cameraPosition = _lastLookAtPoint + cameraDirection * -distance + yOffset;
|
||||
|
||||
var cameraTransform = _camera.transform;
|
||||
Transform cameraTransform = _camera.transform;
|
||||
cameraTransform.rotation = rotation;
|
||||
cameraTransform.position = cameraPosition;
|
||||
|
||||
@@ -433,6 +462,7 @@ namespace Pal3.Camera
|
||||
|
||||
_lastLookAtPoint = _gamePlayController.GetPlayerActorLastKnownPosition();
|
||||
ApplyDefaultSettings(command.Option);
|
||||
_currentAppliedDefaultTransformOption = command.Option;
|
||||
_free = true;
|
||||
}
|
||||
|
||||
@@ -442,9 +472,9 @@ namespace Pal3.Camera
|
||||
|
||||
_lookAtGameObject = null;
|
||||
|
||||
var cameraPosition = GameBoxInterpreter.ToUnityPosition(
|
||||
Vector3 cameraPosition = GameBoxInterpreter.ToUnityPosition(
|
||||
new Vector3(command.X, command.Y, command.Z));
|
||||
var cameraTransform = _camera.transform;
|
||||
Transform cameraTransform = _camera.transform;
|
||||
cameraTransform.position = cameraPosition;
|
||||
cameraTransform.rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
|
||||
@@ -452,7 +482,10 @@ namespace Pal3.Camera
|
||||
(command.Distance / GameBoxInterpreter.GameBoxUnitToUnityUnit);
|
||||
_cameraOffset = cameraPosition - _lastLookAtPoint;
|
||||
|
||||
_free = false;
|
||||
if (_gameStateManager.GetCurrentState() != GameState.Gameplay)
|
||||
{
|
||||
_free = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(CameraFreeCommand command)
|
||||
@@ -479,7 +512,7 @@ namespace Pal3.Camera
|
||||
|
||||
var waiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(waiter));
|
||||
var rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(Orbit(rotation, command.Duration, (AnimationCurveType)command.CurveType, 0f, waiter));
|
||||
}
|
||||
|
||||
@@ -495,14 +528,14 @@ namespace Pal3.Camera
|
||||
{
|
||||
var waiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(waiter));
|
||||
var rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(Rotate(rotation, command.Duration, (AnimationCurveType)command.CurveType, waiter));
|
||||
}
|
||||
#if PAL3A
|
||||
else
|
||||
{
|
||||
_asyncCameraAnimationCts = new CancellationTokenSource();
|
||||
var rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(Rotate(rotation,
|
||||
command.Duration,
|
||||
(AnimationCurveType)command.CurveType,
|
||||
@@ -525,13 +558,13 @@ namespace Pal3.Camera
|
||||
{
|
||||
var waiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(waiter));
|
||||
var rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(Orbit(rotation, command.Duration, (AnimationCurveType)command.CurveType, distanceDelta, waiter));
|
||||
}
|
||||
else
|
||||
{
|
||||
_asyncCameraAnimationCts = new CancellationTokenSource();
|
||||
var rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(Orbit(rotation,
|
||||
command.Duration,
|
||||
(AnimationCurveType)command.CurveType,
|
||||
@@ -555,13 +588,13 @@ namespace Pal3.Camera
|
||||
{
|
||||
var waiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(waiter));
|
||||
var rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(Orbit(rotation, command.Duration, (AnimationCurveType)command.CurveType, distanceDelta, waiter));
|
||||
}
|
||||
else
|
||||
{
|
||||
_asyncCameraAnimationCts = new CancellationTokenSource();
|
||||
var rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
|
||||
StartCoroutine(Orbit(rotation,
|
||||
command.Duration,
|
||||
(AnimationCurveType)command.CurveType,
|
||||
@@ -574,38 +607,38 @@ namespace Pal3.Camera
|
||||
|
||||
public void Execute(CameraFadeInCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
if (!_cameraFadeAnimationCts.IsCancellationRequested) _cameraFadeAnimationCts.Cancel();
|
||||
_cameraFadeAnimationCts = new CancellationTokenSource();
|
||||
var waiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(waiter));
|
||||
StartCoroutine(Fade(true, FADE_ANIMATION_DURATION, Color.black, waiter));
|
||||
StartCoroutine(Fade(true, FADE_ANIMATION_DURATION, Color.black, waiter, _cameraFadeAnimationCts.Token));
|
||||
}
|
||||
|
||||
public void Execute(CameraFadeInWhiteCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
if (!_cameraFadeAnimationCts.IsCancellationRequested) _cameraFadeAnimationCts.Cancel();
|
||||
_cameraFadeAnimationCts = new CancellationTokenSource();
|
||||
var waiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(waiter));
|
||||
StartCoroutine(Fade(true, FADE_ANIMATION_DURATION, Color.white, waiter));
|
||||
StartCoroutine(Fade(true, FADE_ANIMATION_DURATION, Color.white, waiter, _cameraFadeAnimationCts.Token));
|
||||
}
|
||||
|
||||
public void Execute(CameraFadeOutCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
if (!_cameraFadeAnimationCts.IsCancellationRequested) _cameraFadeAnimationCts.Cancel();
|
||||
_cameraFadeAnimationCts = new CancellationTokenSource();
|
||||
var waiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(waiter));
|
||||
StartCoroutine(Fade(false, FADE_ANIMATION_DURATION, Color.black, waiter));
|
||||
StartCoroutine(Fade(false, FADE_ANIMATION_DURATION, Color.black, waiter, _cameraFadeAnimationCts.Token));
|
||||
}
|
||||
|
||||
public void Execute(CameraFadeOutWhiteCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
if (!_cameraFadeAnimationCts.IsCancellationRequested) _cameraFadeAnimationCts.Cancel();
|
||||
_cameraFadeAnimationCts = new CancellationTokenSource();
|
||||
var waiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(waiter));
|
||||
StartCoroutine(Fade(false, FADE_ANIMATION_DURATION, Color.white, waiter));
|
||||
StartCoroutine(Fade(false, FADE_ANIMATION_DURATION, Color.white, waiter, _cameraFadeAnimationCts.Token));
|
||||
}
|
||||
|
||||
public void Execute(CameraPushCommand command)
|
||||
@@ -649,14 +682,14 @@ namespace Pal3.Camera
|
||||
{
|
||||
var waiter = new WaitUntilCanceled(this);
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(waiter));
|
||||
var position = GameBoxInterpreter.ToUnityPosition(new Vector3(command.X, command.Y, command.Z));
|
||||
Vector3 position = GameBoxInterpreter.ToUnityPosition(new Vector3(command.X, command.Y, command.Z));
|
||||
StartCoroutine(Move(position, command.Duration, command.Mode, waiter));
|
||||
}
|
||||
#if PAL3A
|
||||
else
|
||||
{
|
||||
_asyncCameraAnimationCts = new CancellationTokenSource();
|
||||
var position = GameBoxInterpreter.ToUnityPosition(new Vector3(command.X, command.Y, command.Z));
|
||||
Vector3 position = GameBoxInterpreter.ToUnityPosition(new Vector3(command.X, command.Y, command.Z));
|
||||
StartCoroutine(Move(position,
|
||||
command.Duration,
|
||||
command.Mode,
|
||||
@@ -669,15 +702,51 @@ namespace Pal3.Camera
|
||||
public void Execute(CameraSetYawCommand command)
|
||||
{
|
||||
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
|
||||
|
||||
RotateToOrbitPoint(command.Yaw);
|
||||
}
|
||||
|
||||
public void Execute(SceneLeavingCurrentSceneNotification command)
|
||||
{
|
||||
if (_sceneManager.GetCurrentScene() is not { } currentScene) return;
|
||||
|
||||
if (_gameStateManager.GetCurrentState() == GameState.Gameplay &&
|
||||
currentScene.GetSceneInfo().SceneType != ScnSceneType.StoryB)
|
||||
{
|
||||
var cameraTransform = _camera.transform;
|
||||
_cameraLastKnownSceneState.Add((
|
||||
currentScene.GetSceneInfo(),
|
||||
cameraTransform.position,
|
||||
cameraTransform.rotation,
|
||||
_cameraOffset));
|
||||
|
||||
if (_cameraLastKnownSceneState.Count > LAST_KNOWN_SCENE_STATE_LIST_MAX_LENGTH)
|
||||
{
|
||||
_cameraLastKnownSceneState.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(ScenePreLoadingNotification notification)
|
||||
{
|
||||
_currentAppliedDefaultTransformOption = 0;
|
||||
ApplySceneSettings(notification.NewSceneInfo);
|
||||
}
|
||||
|
||||
// Apply the last known scene state if found in record.
|
||||
if (_gameStateManager.GetCurrentState() == GameState.Gameplay &&
|
||||
notification.NewSceneInfo.SceneType != ScnSceneType.StoryB)
|
||||
{
|
||||
if (_cameraLastKnownSceneState.Count > 0 && _cameraLastKnownSceneState.Any(_ =>
|
||||
_.sceneInfo.ModelEquals(notification.NewSceneInfo)))
|
||||
{
|
||||
(ScnSceneInfo _, Vector3 cameraPosition, Quaternion cameraRotation, Vector3 cameraOffset) =
|
||||
_cameraLastKnownSceneState.Last(_ => _.sceneInfo.ModelEquals(notification.NewSceneInfo));
|
||||
|
||||
_camera.transform.SetPositionAndRotation(cameraPosition, cameraRotation);
|
||||
_cameraOffset = cameraOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(CameraFocusOnActorCommand command)
|
||||
{
|
||||
if (command.ActorId == ActorConstants.PlayerActorVirtualID) return;
|
||||
@@ -697,5 +766,11 @@ namespace Pal3.Camera
|
||||
{
|
||||
if (command.NewState == GameState.Gameplay) _free = true;
|
||||
}
|
||||
|
||||
public void Execute(ResetGameStateCommand command)
|
||||
{
|
||||
_cameraLastKnownSceneState.Clear();
|
||||
_free = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ namespace Pal3.Command
|
||||
/// </summary>
|
||||
public void Dispatch(TCommand command)
|
||||
{
|
||||
var commandExecutorType = typeof(ICommandExecutor<>).MakeGenericType(command.GetType());
|
||||
Type commandExecutorType = typeof(ICommandExecutor<>).MakeGenericType(command.GetType());
|
||||
|
||||
var executed = false;
|
||||
foreach (var commandExecutor in _commandExecutorRegistry.GetRegisteredExecutors(commandExecutorType))
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Pal3.Command
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var executorType in executorTypes)
|
||||
foreach (Type executorType in executorTypes)
|
||||
{
|
||||
if (_executors.ContainsKey(executorType))
|
||||
{
|
||||
@@ -110,7 +110,7 @@ namespace Pal3.Command
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var executorType in executorTypes)
|
||||
foreach (Type executorType in executorTypes)
|
||||
{
|
||||
if (!_executors.ContainsKey(executorType))
|
||||
{
|
||||
@@ -132,7 +132,7 @@ namespace Pal3.Command
|
||||
/// <returns>ICommandExecutors</returns>
|
||||
public IEnumerable<ICommandExecutor<T>> GetRegisteredExecutors<T>() where T : TCommand
|
||||
{
|
||||
var handlerType = typeof(ICommandExecutor<T>);
|
||||
Type handlerType = typeof(ICommandExecutor<T>);
|
||||
|
||||
if (!_executors.ContainsKey(handlerType)) yield break;
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.Command
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
public static class CommandExtensions
|
||||
{
|
||||
public static string ToString(ICommand command)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
Type type = command.GetType();
|
||||
|
||||
builder.Append(type.Name[..^"Command".Length]);
|
||||
builder.Append(' ');
|
||||
|
||||
foreach (PropertyInfo propertyInfo in type.GetProperties())
|
||||
{
|
||||
builder.Append(propertyInfo.GetValue(command));
|
||||
builder.Append(' ');
|
||||
}
|
||||
|
||||
var commandStr = builder.ToString();
|
||||
if (commandStr.EndsWith(' ')) commandStr = commandStr[..^1];
|
||||
return commandStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 240 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user