Compare commits

..
23 Commits
Author SHA1 Message Date
Jiaqi Liu c5dc4d7335 v0.67 2023-08-01 22:52:28 -07:00
Jiaqi Liu 34370ec2e8 Add more supported build targets 2023-08-01 22:28:53 -07:00
Jiaqi Liu bd892fb3fb Fix a regression on path separator handling for unix-like system 2023-08-01 21:52:38 -07:00
Jiaqi Liu 39c27b04d7 Implement flashing animation for time-sensitive dialogue 2023-08-01 20:59:35 -07:00
Jiaqi Liu b1afd47878 Add background image to dialogue selection buttons
Add background image to dialogue selection buttons.
Add mov preview in game resource viewer.
Add padding to dialogue selection button text
2023-08-01 16:15:36 -07:00
Jiaqi Liu 9286d3160a Code refactoring 2023-08-01 13:49:12 -07:00
Jiaqi Liu 54fb05093c Code refactoring 2023-08-01 09:00:29 -07:00
Jiaqi Liu f872dd7c3d Remove hack code 2023-07-31 00:59:36 -07:00
Jiaqi Liu 9ffebd2b71 Fix shader issue with Metal on MacOS 2023-07-31 00:48:07 -07:00
Jiaqi Liu 4c6c8752d9 Code refactoring 2023-07-30 22:01:05 -07:00
Jiaqi Liu db11847130 v0.66 2023-07-30 03:58:14 -07:00
Jiaqi Liu d88f737375 Code refactoring 2023-07-30 03:36:57 -07:00
Jiaqi Liu d1a7de0229 Fix a bug that might be caused by a delayed destroy 2023-07-30 02:55:42 -07:00
Jiaqi Liu 78e9692abc Upgrade dependencies 2023-07-29 14:55:58 -07:00
Jiaqi Liu 836463c795 Smoothen skeletal animation with interpolation 2023-07-29 02:07:26 -07:00
Jiaqi Liu 630166880f Fix: Use Slerp for quaternion Interpolation 2023-07-29 02:06:59 -07:00
Jiaqi Liu 421ee12a82 Properly implement logic to read mtl file and handle GB Material 2023-07-28 19:52:03 -07:00
Jiaqi Liu 4dd3992a32 v0.65 2023-07-27 22:12:51 -07:00
Jiaqi Liu 5fab0d867e Implement skeletal animation logic (#17)
Properly implements SkeletalModelRenderer + SkeletalAnimationActorActionController
2023-07-27 21:48:39 -07:00
Jiaqi Liu a1801f59f5 Upgrade Unity version 2023-07-20 20:41:22 -07:00
Jiaqi Liu 3f467944ce Fix a bug where actor might spawn at wrong Y position 2023-07-06 00:28:33 -07:00
Jiaqi Liu b1add2a940 Minor refactoring 2023-07-05 23:58:27 -07:00
Jiaqi Liu 3e8f350740 Upgrade packages 2023-07-01 23:34:41 -07:00
99 changed files with 2059 additions and 984 deletions

No files matched your search

+4 -1
View File
@@ -83,4 +83,7 @@ crashlytics-build.properties
/Assets/Resources/Prefabs/VFX/PAL3A/*.meta
# Materials that are using 3rd party assets
/Assets/Resources/Materials/
/Assets/Resources/Materials/
# VS Conde config file
.vsconfig
@@ -34,7 +34,6 @@ RectTransform:
m_Children:
- {fileID: 584702074}
m_Father: {fileID: 7962283254459483698}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -136,9 +135,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: 100
m_MinWidth: 70
m_MinHeight: -1
m_PreferredWidth: 130
m_PreferredWidth: 100
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
@@ -174,7 +173,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 584360809}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -209,7 +207,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Rand.mv3
m_text: .mv3
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
m_sharedMaterial: {fileID: 2847917559404452115, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
@@ -310,7 +308,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7962283254459483698}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -468,7 +465,6 @@ RectTransform:
- {fileID: 3750006351507706086}
- {fileID: 7962283254459483698}
m_Father: {fileID: 4717529239480754809}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -492,6 +488,7 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
@@ -565,13 +562,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2142775982}
serializedVersion: 2
m_LocalRotation: {x: 0.106926456, y: 0.89080113, z: -0.34414864, w: 0.2767705}
m_LocalPosition: {x: -9.13127, y: 14.634583, z: 13.276214}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4717529239480754809}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 20, y: -180, z: 0}
--- !u!20 &2142775986
Camera:
@@ -768,6 +765,204 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &123332925323670007
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4368649423705725990}
- component: {fileID: 604100889191375676}
- component: {fileID: 7231553591477896172}
- component: {fileID: 5427468017432232242}
- component: {fileID: 5883971941730404980}
m_Layer: 5
m_Name: RandomMovButton
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4368649423705725990
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 123332925323670007}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8137720222258884206}
m_Father: {fileID: 7962283254459483698}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &604100889191375676
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 123332925323670007}
m_CullTransparentMesh: 1
--- !u!114 &7231553591477896172
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 123332925323670007}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 0.36862746}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &5427468017432232242
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 123332925323670007}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 0, g: 0, b: 0, a: 0.64705884}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.6509434, g: 0.6509434, b: 0.6509434, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 7231553591477896172}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &5883971941730404980
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 123332925323670007}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: 70
m_MinHeight: -1
m_PreferredWidth: 100
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!1 &222217343785305476
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6634203918711018630}
- component: {fileID: 3328190567514003159}
m_Layer: 5
m_Name: Spacer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6634203918711018630
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 222217343785305476}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7962283254459483698}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &3328190567514003159
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 222217343785305476}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: 20
m_MinHeight: -1
m_PreferredWidth: 20
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!1 &407167005608020107
GameObject:
m_ObjectHideFlags: 0
@@ -798,7 +993,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7962283254459483698}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -856,7 +1050,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3373501020589239246}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -891,7 +1084,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Rand.pol
m_text: .pol
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
m_sharedMaterial: {fileID: 2847917559404452115, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
@@ -991,7 +1184,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1132578971298683386}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -1026,7 +1218,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Rand.mp3
m_text: .mp3
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
m_sharedMaterial: {fileID: 2847917559404452115, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
@@ -1125,7 +1317,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7962283254459483698}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1184,7 +1375,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3750006351507706086}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1339,7 +1529,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4092775554206660067}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -1374,7 +1563,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Rand.cvd
m_text: .cvd
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
m_sharedMaterial: {fileID: 2847917559404452115, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
@@ -1477,7 +1666,6 @@ RectTransform:
m_Children:
- {fileID: 5870585403592386036}
m_Father: {fileID: 7962283254459483698}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1579,13 +1767,149 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: 100
m_MinWidth: 70
m_MinHeight: -1
m_PreferredWidth: 130
m_PreferredWidth: 100
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!1 &3879705876358869609
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8137720222258884206}
- component: {fileID: 4018928636488071206}
- component: {fileID: 4325337656176874974}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8137720222258884206
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3879705876358869609}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4368649423705725990}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4018928636488071206
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3879705876358869609}
m_CullTransparentMesh: 1
--- !u!114 &4325337656176874974
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3879705876358869609}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: '.mov
'
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
m_sharedMaterial: {fileID: 2847917559404452115, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 18
m_fontSizeBase: 18
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &4205777939607344913
GameObject:
m_ObjectHideFlags: 0
@@ -1618,7 +1942,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3750006351507706086}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1768,6 +2091,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4717529239480754811}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -1776,7 +2100,6 @@ Transform:
- {fileID: 1713758292}
- {fileID: 2142775987}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &431003956
MonoBehaviour:
@@ -1797,6 +2120,7 @@ MonoBehaviour:
randomCvdButton: {fileID: 3463608508234468754}
randomMv3Button: {fileID: 584360810}
randomMp3Button: {fileID: 4620712651305624973}
randomMovButton: {fileID: 5427468017432232242}
audioSource: {fileID: 2142775988}
fpsCounter: {fileID: 5259780322708739529}
--- !u!82 &4596748654320625574
@@ -1941,7 +2265,6 @@ RectTransform:
m_Children:
- {fileID: 7447090365930112548}
m_Father: {fileID: 7962283254459483698}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -2043,9 +2366,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: 100
m_MinWidth: 70
m_MinHeight: -1
m_PreferredWidth: 130
m_PreferredWidth: 100
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
@@ -2080,7 +2403,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7962283254459483698}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -2144,11 +2466,12 @@ RectTransform:
- {fileID: 4092775554206660067}
- {fileID: 2490674917526170126}
- {fileID: 584360809}
- {fileID: 6634203918711018630}
- {fileID: 4368649423705725990}
- {fileID: 4382597048068323552}
- {fileID: 1132578971298683386}
- {fileID: 746519510}
m_Father: {fileID: 1713758292}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -2172,6 +2495,7 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
@@ -2277,7 +2601,6 @@ RectTransform:
m_Children:
- {fileID: 3698878601942552789}
m_Father: {fileID: 7962283254459483698}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -2379,9 +2702,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: 100
m_MinWidth: 70
m_MinHeight: -1
m_PreferredWidth: 130
m_PreferredWidth: 100
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
@@ -2421,7 +2744,6 @@ RectTransform:
- {fileID: 3668306928943904264}
- {fileID: 7258066314304171550}
m_Father: {fileID: 1713758292}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
@@ -2445,6 +2767,7 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
+66 -49
View File
@@ -25,13 +25,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 20216135}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8627381932629902483}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &20216138
MonoBehaviour:
@@ -109,7 +109,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 9079540115457418875}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -181,13 +180,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 311849590}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8627381932629902483}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &311849592
Camera:
@@ -438,7 +437,6 @@ RectTransform:
m_Children:
- {fileID: 990422549647191827}
m_Father: {fileID: 5034920729594334697}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -519,7 +517,6 @@ RectTransform:
- {fileID: 4621121648098794307}
- {fileID: 4499928633135383787}
m_Father: {fileID: 8627381932629902483}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -619,7 +616,6 @@ RectTransform:
m_Children:
- {fileID: 2074168396019022583}
m_Father: {fileID: 8835758892377050535}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
@@ -658,7 +654,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4984290394953888209}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -781,7 +776,6 @@ RectTransform:
- {fileID: 3466221734632269409}
- {fileID: 6760472164127762522}
m_Father: {fileID: 8627381932629902483}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -882,7 +876,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2546561680202900797}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1018,7 +1011,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4984290394953888209}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1129,7 +1121,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 990422549647191827}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -1204,7 +1195,6 @@ RectTransform:
m_Children:
- {fileID: 2752362774692141791}
m_Father: {fileID: 1126459600050429590}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -1243,7 +1233,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5034920729594334697}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@@ -1338,7 +1327,6 @@ RectTransform:
m_Children:
- {fileID: 147356288}
m_Father: {fileID: 8627381932629902483}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1443,7 +1431,6 @@ RectTransform:
m_Children:
- {fileID: 6936565495695538149}
m_Father: {fileID: 5749901358741972170}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
@@ -1572,7 +1559,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8498315575182197477}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -1668,7 +1654,6 @@ RectTransform:
- {fileID: 2959112866268773121}
- {fileID: 332266281639726118}
m_Father: {fileID: 8627381932629902483}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1770,7 +1755,6 @@ RectTransform:
m_Children:
- {fileID: 7157762956599921952}
m_Father: {fileID: 8627381932629902483}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1857,7 +1841,6 @@ RectTransform:
m_Children:
- {fileID: 4255555531165553146}
m_Father: {fileID: 8627381932629902483}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1988,7 +1971,6 @@ RectTransform:
- {fileID: 4335801449381553810}
- {fileID: 1396044973851031465}
m_Father: {fileID: 8627381932629902483}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -2102,7 +2084,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3759849500141926318}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -2189,7 +2170,6 @@ RectTransform:
m_Children:
- {fileID: 8954138631489322986}
m_Father: {fileID: 8498315575182197477}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -2251,7 +2231,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4984290394953888209}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -2371,7 +2350,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8954138631489322986}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -2506,7 +2484,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6643911667603684870}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -2640,7 +2617,6 @@ RectTransform:
m_Children:
- {fileID: 2805789255595481173}
m_Father: {fileID: 3999692858221102514}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -2671,13 +2647,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4227195284865171261}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8627381932629902483}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8346885185333560231
MonoBehaviour:
@@ -2728,7 +2704,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4984290394953888209}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -2848,7 +2823,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2631067326830301932}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -2924,7 +2898,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7184533148466444589}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -3000,7 +2973,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3999692858221102514}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -3056,6 +3028,9 @@ GameObject:
- component: {fileID: 1866538870636123170}
- component: {fileID: 677852748167040680}
- component: {fileID: 896666593303268244}
- component: {fileID: 7106289808991898827}
- component: {fileID: 4638320210657625687}
- component: {fileID: 4482354705924986635}
m_Layer: 5
m_Name: DialogueSelectionButtonsGroup
m_TagString: Untagged
@@ -3076,7 +3051,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8498315575182197477}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
@@ -3098,8 +3072,8 @@ MonoBehaviour:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_Top: 10
m_Bottom: 10
m_ChildAlignment: 4
m_Spacing: 0
m_ChildForceExpandWidth: 1
@@ -3132,6 +3106,61 @@ Canvas:
m_SortingLayerID: 0
m_SortingOrder: 10001
m_TargetDisplay: 0
--- !u!222 &7106289808991898827
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6327749955785912399}
m_CullTransparentMesh: 1
--- !u!114 &4638320210657625687
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6327749955785912399}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &4482354705924986635
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6327749955785912399}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 47aa715050ab45e09496c366d4e11600, type: 3}
m_Name:
m_EditorClassIdentifier:
blurAmount: 3
cornerRadius: 20
additiveTintColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
multiplyTintColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
image: {fileID: 4638320210657625687}
--- !u!1 &7276870447534455730
GameObject:
m_ObjectHideFlags: 0
@@ -3165,7 +3194,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 15168862781853615}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -3278,7 +3306,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3759849500141926318}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -3354,7 +3381,6 @@ RectTransform:
m_Children:
- {fileID: 8498315575182197477}
m_Father: {fileID: 8627381932629902483}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -3457,7 +3483,6 @@ RectTransform:
m_Children:
- {fileID: 2546561680202900797}
m_Father: {fileID: 8627381932629902483}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -3559,7 +3584,6 @@ RectTransform:
- {fileID: 5886627391259666978}
- {fileID: 6629950239246188284}
m_Father: {fileID: 8498315575182197477}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -3622,7 +3646,6 @@ RectTransform:
m_Children:
- {fileID: 3491202665095195611}
m_Father: {fileID: 1396044973851031465}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -3711,7 +3734,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7157762956599921952}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -3852,12 +3874,11 @@ RectTransform:
- {fileID: 1126459600050429590}
- {fileID: 1866538870636123170}
m_Father: {fileID: 387607491181381395}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 20}
m_SizeDelta: {x: 800, y: -40}
m_SizeDelta: {x: 1100, y: -40}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!225 &4450587676581078315
CanvasGroup:
@@ -3936,6 +3957,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8627381932629902481}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1019.9595, y: 583.6859, z: 4.5594697}
m_LocalScale: {x: 1, y: 1, z: 1}
@@ -3955,7 +3977,6 @@ Transform:
- {fileID: 9166793672834059380}
- {fileID: 5491488055271105370}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8627381932629902480
MonoBehaviour:
@@ -4047,7 +4068,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 15168862781853615}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@@ -4151,7 +4171,6 @@ RectTransform:
m_Children:
- {fileID: 7681748703137084981}
m_Father: {fileID: 2631067326830301932}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -4189,7 +4208,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5886627391259666978}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -4325,7 +4343,6 @@ RectTransform:
- {fileID: 6643911667603684870}
- {fileID: 2518121778909046557}
m_Father: {fileID: 8498315575182197477}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -4413,7 +4430,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 2755888773251150947, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
propertyPath: m_Value
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2755888773251194751, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
propertyPath: m_Enabled
@@ -34,12 +34,11 @@ RectTransform:
m_Children:
- {fileID: 3008098735699080031}
m_Father: {fileID: 351020356915406194}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -40, y: -20}
m_SizeDelta: {x: -40, y: -10}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4862410139821972608
CanvasRenderer:
@@ -168,7 +167,6 @@ RectTransform:
m_Children:
- {fileID: 6402332024803516576}
m_Father: {fileID: 0}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -192,6 +190,7 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
@@ -268,12 +267,11 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6402332024803516576}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: -50, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &143571606391487229
CanvasRenderer:
@@ -16,25 +16,22 @@ Shader "Pal3/RoundedFrostedGlass"
Category
{
// We must be transparent, so other objects are drawn before this one.
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Opaque" }
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
SubShader
{
Cull Off
Lighting Off
ZTest Off
ZWrite Off
//ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
// Horizontal blur
GrabPass
{
"_HBlur"
}
/*
ZTest Off
Blend SrcAlpha OneMinusSrcAlpha
*/
Cull Off
Lighting Off
ZWrite Off
//ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
@@ -84,7 +81,7 @@ Shader "Pal3/RoundedFrostedGlass"
return outsideDistance + insideDistance - absoluteRound;
}
inline float CalcAlpha(float2 samplePosition, float2 size, float radius){
inline float calcAlpha(float2 samplePosition, float2 size, float radius){
const float2 samplePositionTranslated = (samplePosition - .5) * size;
const float distToRect = roundedRectangle(samplePositionTranslated, radius * .5, size * .5);
const float distanceChange = fwidth(distToRect) * 0.5;
@@ -106,7 +103,7 @@ Shader "Pal3/RoundedFrostedGlass"
half4 frag(v2f i) : COLOR
{
const float alpha = CalcAlpha(i.uvmain, _WidthHeightRadius.xy, _WidthHeightRadius.z);
const float alpha = calcAlpha(i.uvmain, _WidthHeightRadius.xy, _WidthHeightRadius.z);
half4 cutoffColor = mixAlpha(tex2D(_MainTex, i.uvmain), _AdditiveColor, alpha);
clip(cutoffColor.a - 0.001);
@@ -188,7 +185,7 @@ Shader "Pal3/RoundedFrostedGlass"
return outsideDistance + insideDistance - absoluteRound;
}
inline float CalcAlpha(float2 samplePosition, float2 size, float radius){
inline float calcAlpha(float2 samplePosition, float2 size, float radius){
const float2 samplePositionTranslated = (samplePosition - .5) * size;
const float distToRect = roundedRectangle(samplePositionTranslated, radius * .5, size * .5);
const float distanceChange = fwidth(distToRect) * 0.5;
@@ -210,7 +207,7 @@ Shader "Pal3/RoundedFrostedGlass"
half4 frag(v2f i) : COLOR
{
const float alpha = CalcAlpha(i.uvmain, _WidthHeightRadius.xy, _WidthHeightRadius.z);
const float alpha = calcAlpha(i.uvmain, _WidthHeightRadius.xy, _WidthHeightRadius.z);
half4 cutoffColor = mixAlpha(tex2D(_MainTex, i.uvmain), _AdditiveColor, alpha);
clip(cutoffColor.a - 0.001);
@@ -134,7 +134,7 @@ namespace Core.Animation
var timePast = 0f;
while (timePast < duration && target != null && !cancellationToken.IsCancellationRequested)
{
Quaternion rotation = Quaternion.Lerp(startRotation, toRotation,
Quaternion rotation = Quaternion.Slerp(startRotation, toRotation,
GetInterpolationRatio(timePast / duration, curveType));
Vector3 direction = (rotation * Vector3.forward).normalized;
@@ -167,7 +167,7 @@ namespace Core.Animation
var timePast = 0f;
while (timePast < duration && target != null && !cancellationToken.IsCancellationRequested)
{
Quaternion rotation = Quaternion.Lerp(startRotation, toRotation,
Quaternion rotation = Quaternion.Slerp(startRotation, toRotation,
GetInterpolationRatio(timePast / duration, curveType));
target.rotation = rotation;
@@ -154,7 +154,6 @@ namespace Core.DataReader.Cvd
public int[] Triangles;
public GameBoxBlendFlag BlendFlag;
public GameBoxMaterial Material;
public string TextureName;
public float[] AnimationTimeKeys;
public GameBoxMaterial[] AnimationMaterials;
}
@@ -413,19 +413,18 @@ namespace Core.DataReader.Cvd
int codepage)
#endif
{
var blendFlag = (GameBoxBlendFlag)reader.ReadByte();
GameBoxBlendFlag blendFlag = (GameBoxBlendFlag)reader.ReadByte();
var material = new GameBoxMaterial()
GameBoxMaterial material = new ()
{
Diffuse = Utility.ToColor32(reader.ReadBytes(4)),
Ambient = Utility.ToColor32(reader.ReadBytes(4)),
Specular = Utility.ToColor32(reader.ReadBytes(4)),
Emissive = Utility.ToColor32(reader.ReadBytes(4)),
Power = reader.ReadSingle()
SpecularPower = reader.ReadSingle(),
TextureFileNames = new [] { reader.ReadString(64, codepage) }
};
var textureName = reader.ReadString(64, codepage);
var numberOfIndices = reader.ReadInt32();
var indices = new (ushort x, ushort y, ushort z)[numberOfIndices];
@@ -458,7 +457,7 @@ namespace Core.DataReader.Cvd
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
Power = reader.ReadSingle()
SpecularPower = reader.ReadSingle()
};
}
}
@@ -486,7 +485,6 @@ namespace Core.DataReader.Cvd
{
BlendFlag = blendFlag,
Material = material,
TextureName = textureName,
FrameVertices = frameVertices,
Triangles = triangles.ToArray(),
AnimationTimeKeys = animationTimeKeys,
@@ -501,18 +499,18 @@ namespace Core.DataReader.Cvd
var triangles = new List<int>();
var index = 0;
for (var j = 0; j < allIndices.Length; j++)
for (var i = 0; i < allIndices.Length; i++)
{
var indices = new[]
{
allIndices[j].x,
allIndices[j].y,
allIndices[j].z
allIndices[i].x,
allIndices[i].y,
allIndices[i].z
};
for (var k = 0; k < 3; k++)
for (var j = 0; j < 3; j++)
{
indexBuffer.Add(indices[k]);
indexBuffer.Add(indices[j]);
triangles.Add(index++);
}
}
@@ -86,7 +86,7 @@ namespace Core.DataReader.Mov
{
return new MovAnimationEvent()
{
Tick = GameBoxInterpreter.GameBoxSecondsToTick(reader.ReadSingle()),
Tick = GameBoxInterpreter.SecondsToTick(reader.ReadSingle()),
Name = reader.ReadString(16, codepage)
};
}
@@ -110,7 +110,7 @@ namespace Core.DataReader.Mov
{
animationKeyFrames[i] = new MovAnimationKeyFrame()
{
Tick = GameBoxInterpreter.GameBoxSecondsToTick(reader.ReadSingle()),
Tick = GameBoxInterpreter.SecondsToTick(reader.ReadSingle()),
Translation = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3()),
Rotation = GameBoxInterpreter.MovQuaternionToUnityQuaternion(new GameBoxQuaternion()
{
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5f50098c0cef46349314b7f36bc59136
timeCreated: 1690567483
@@ -0,0 +1,19 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Core.DataReader.Mtl
{
using GameBox;
public sealed class MtlFile
{
public GameBoxMaterial[] Materials { get; }
public MtlFile(GameBoxMaterial[] materials)
{
Materials = materials;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f167ffdd8daf4bcfb2b50ee3e3e7bc8b
timeCreated: 1690567491
@@ -0,0 +1,76 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
#define USE_UNSAFE_BINARY_READER
namespace Core.DataReader.Mtl
{
using System.Collections.Generic;
using System.IO;
using Extensions;
using GameBox;
using Utils;
public sealed class MtlFileReader : IFileReader<MtlFile>
{
private readonly int _codepage;
public MtlFileReader(int codepage)
{
_codepage = codepage;
}
public MtlFile 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 header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
if (headerStr != "mtl")
{
throw new InvalidDataException("Invalid MTL(.mtl) file: header != mtl");
}
var version = reader.ReadInt32();
if (version != 100)
{
throw new InvalidDataException("Invalid MTL(.mtl) file: version != 100");
}
int numberOfMaterials = reader.ReadInt32();
var materials = new GameBoxMaterial[numberOfMaterials];
for (var i = 0; i < numberOfMaterials; i++)
{
materials[i] = new GameBoxMaterial
{
Diffuse = Utility.ToColor(reader.ReadSingleArray(4)),
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
SpecularPower = reader.ReadSingle(),
};
List<string> textureNames = new ();
for (var j = 0; j < 4; j++)
{
int textureNameLength = reader.ReadInt32();
if (textureNameLength == 0) continue;
textureNames.Add(reader.ReadString(textureNameLength, _codepage));
}
materials[i].TextureFileNames = textureNames.ToArray();
}
return new MtlFile(materials);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 16ec8deffba245bcb6808f8ad26677c7
timeCreated: 1690567511
+4 -10
View File
@@ -56,12 +56,6 @@ namespace Core.DataReader.Mv3
public Mv3Vert[] Vertices;
}
public struct Mv3Material
{
public GameBoxMaterial Material;
public string[] TextureNames;
}
public struct Mv3Mesh
{
public string Name; // 64 chars max
@@ -87,20 +81,20 @@ namespace Core.DataReader.Mv3
public uint Duration { get; }
public Mv3AnimationEvent[] AnimationEvents { get; }
public Mv3TagNode[] TagNodes { get; }
public Mv3Material[] Materials { get; }
public Mv3Mesh[] Meshes { get; }
public GameBoxMaterial[] Materials { get; }
public Mv3File(uint duration,
Mv3AnimationEvent[] animationEvents,
Mv3TagNode[] tagNodes,
Mv3Material[] materials,
Mv3Mesh[] meshes)
Mv3Mesh[] meshes,
GameBoxMaterial[] materials)
{
Duration = duration;
AnimationEvents = animationEvents;
TagNodes = tagNodes;
Materials = materials;
Meshes = meshes;
Materials = materials;
}
}
}
@@ -70,7 +70,7 @@ namespace Core.DataReader.Mv3
tagNodes[i] = ReadTagNode(reader, _codepage);
}
var materials = new Mv3Material[numberOfMaterials];
var materials = new GameBoxMaterial[numberOfMaterials];
for (var i = 0; i < numberOfMaterials; i++)
{
materials[i] = ReadMaterial(reader, _codepage);
@@ -85,8 +85,8 @@ namespace Core.DataReader.Mv3
return new Mv3File(duration,
animationEvents,
tagNodes,
materials,
meshes);
meshes,
materials);
}
#if USE_UNSAFE_BINARY_READER
@@ -306,34 +306,30 @@ namespace Core.DataReader.Mv3
}
#if USE_UNSAFE_BINARY_READER
private static Mv3Material ReadMaterial(UnsafeBinaryReader reader, int codepage)
private static GameBoxMaterial ReadMaterial(UnsafeBinaryReader reader, int codepage)
#else
private static Mv3Material ReadMaterial(BinaryReader reader, int codepage)
private static GameBoxMaterial ReadMaterial(BinaryReader reader, int codepage)
#endif
{
var material = new GameBoxMaterial()
GameBoxMaterial material = new ()
{
Diffuse = Utility.ToColor(reader.ReadSingleArray(4)),
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
Power = reader.ReadSingle()
SpecularPower = reader.ReadSingle()
};
var textureNames = new List<string>();
List<string> textureNames = new ();
for (var i = 0; i < 4; i++)
{
string textureName;
var length = reader.ReadInt32();
if (length is < 0 or > 255)
{
throw new InvalidDataException($"Invalid length of material name: {length}");
}
if (length == 0)
{
if (i > 0) continue;
textureName = string.Empty; // Use default white texture?
textureName = string.Empty; // Use default white texture
}
else
{
@@ -343,11 +339,9 @@ namespace Core.DataReader.Mv3
textureNames.Add(textureName);
}
return new Mv3Material()
{
Material = material,
TextureNames = textureNames.ToArray(),
};
material.TextureFileNames = textureNames.ToArray();
return material;
}
}
}
@@ -45,7 +45,6 @@ namespace Core.DataReader.Pol
{
public GameBoxBlendFlag BlendFlag;
public GameBoxMaterial Material;
public string[] TextureNames;
public uint VertStart;
public uint VertEnd;
public int[] Triangles;
@@ -241,20 +241,20 @@ namespace Core.DataReader.Pol
private static PolTexture ReadTextureInfo(BinaryReader reader, int version, int codepage)
#endif
{
var blendFlag = (GameBoxBlendFlag)reader.ReadUInt32();
GameBoxBlendFlag blendFlag = (GameBoxBlendFlag)reader.ReadUInt32();
var material = new GameBoxMaterial()
GameBoxMaterial material = new ()
{
Diffuse = Utility.ToColor(reader.ReadSingleArray(4)),
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
Power = reader.ReadSingle()
SpecularPower = reader.ReadSingle()
};
// Hack fix
if (material.Power < 0) material.Power = 0;
else if (material.Power > 128) material.Power = 128;
if (material.SpecularPower < 0) material.SpecularPower = 0;
else if (material.SpecularPower > 128) material.SpecularPower = 128;
var numberOfTextures = reader.ReadInt32();
var textureNames = new string[numberOfTextures];
@@ -265,6 +265,8 @@ namespace Core.DataReader.Pol
textureNames[i] = textureName;
}
material.TextureFileNames = textureNames;
_ = reader.ReadInt32();
var vertStart = reader.ReadUInt32();
var vertEnd = reader.ReadUInt32();
@@ -285,7 +287,6 @@ namespace Core.DataReader.Pol
{
BlendFlag = blendFlag,
Material = material,
TextureNames = textureNames,
VertStart = vertStart,
VertEnd = vertEnd,
Triangles = triangles
@@ -203,16 +203,15 @@ namespace Core.GameBox
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint GameBoxSecondsToTick(float seconds)
public static uint SecondsToTick(float seconds)
{
return (uint)(seconds * GameBoxTicksPerSecond);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float TickToGameBoxSeconds(uint tick)
public static float TickToSeconds(uint tick)
{
return (float)tick / GameBoxTicksPerSecond;
}
}
}
@@ -10,11 +10,12 @@ namespace Core.GameBox
[System.Serializable]
public struct GameBoxMaterial
{
public Color32 Diffuse;
public Color32 Ambient;
public Color32 Specular;
public Color32 Emissive;
public float Power;
public Color Diffuse;
public Color Ambient;
public Color Specular;
public Color Emissive;
public float SpecularPower;
public string[] TextureFileNames;
}
// To meet opengl, use this order instead:
@@ -62,18 +62,11 @@ namespace Core.Utils
{
return platform switch
{
RuntimePlatform.WindowsPlayer => WindowsSupportedVideoFormats,
RuntimePlatform.WindowsEditor => WindowsSupportedVideoFormats,
RuntimePlatform.OSXPlayer => MacOSSupportedVideoFormats,
RuntimePlatform.OSXEditor => MacOSSupportedVideoFormats,
RuntimePlatform.LinuxPlayer => LinuxSupportedVideoFormats,
RuntimePlatform.LinuxEditor => LinuxSupportedVideoFormats,
RuntimePlatform.WindowsPlayer or RuntimePlatform.WindowsEditor => WindowsSupportedVideoFormats,
RuntimePlatform.OSXPlayer or RuntimePlatform.OSXEditor => MacOSSupportedVideoFormats,
RuntimePlatform.LinuxPlayer or RuntimePlatform.LinuxEditor => LinuxSupportedVideoFormats,
RuntimePlatform.IPhonePlayer => iOSSupportedVideoFormats,
RuntimePlatform.Android => AndroidSupportedVideoFormats,
_ => new HashSet<string> {".mp4" }
};
}
+15
View File
@@ -18,6 +18,15 @@ namespace Editor
BuildTargetGroup.Android,
BuildTargetGroup.Standalone,
BuildTargetGroup.iOS,
BuildTargetGroup.WSA,
BuildTargetGroup.PS4,
BuildTargetGroup.PS5,
BuildTargetGroup.XboxOne,
BuildTargetGroup.tvOS,
BuildTargetGroup.Switch,
BuildTargetGroup.GameCoreXboxOne,
BuildTargetGroup.GameCoreXboxSeries,
BuildTargetGroup.VisionOS,
};
}
@@ -28,6 +37,12 @@ namespace Editor
NamedBuildTarget.Android,
NamedBuildTarget.Standalone,
NamedBuildTarget.iOS,
NamedBuildTarget.PS4,
NamedBuildTarget.XboxOne,
NamedBuildTarget.tvOS,
NamedBuildTarget.NintendoSwitch,
NamedBuildTarget.WindowsStoreApps,
NamedBuildTarget.VisionOS,
};
}
@@ -140,16 +140,19 @@ namespace Pal3.Actor
if (_shadow != null)
{
Destroy(_shadow);
_shadow = null;
}
if (_rigidbody != null)
{
Destroy(_rigidbody);
_rigidbody = null;
}
if (_collider != null)
{
Destroy(_collider);
_collider = null;
}
}
+29 -25
View File
@@ -7,15 +7,14 @@ namespace Pal3.Actor
{
using System;
using System.Collections.Generic;
using Core.DataReader.Cpk;
using Core.DataReader.Ini;
using Data;
using MetaData;
public enum ActorAnimationType
{
Mv3 = 0,
Mov
Vertex = 0, // .mv3 animation
Skeletal = 1, // .msh + .mov animation
}
public abstract class ActorBase
@@ -40,38 +39,34 @@ namespace Pal3.Actor
private void InitActorConfig(string name)
{
char separator = CpkConstants.DirectorySeparator;
string actorActionConfigFolder = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
$"{FileConstants.ActorFolderName}{separator}{name}{separator}";
ActorActionConfig defaultConfig = _resourceProvider.GetActorActionConfig(actorActionConfigFolder + $"{name}.ini");
ActorActionConfig defaultConfig = _resourceProvider.GetActorActionConfig(name, $"{name}.ini");
// Add default config if it is MV3 animated
if (defaultConfig is Mv3ActionConfig mv3Config)
{
AddActorConfig(mv3Config);
AnimationType = ActorAnimationType.Mv3;
AnimationType = ActorAnimationType.Vertex;
return;
}
// Add default config if it is MOV
// Add default config if it is MOV animated
if (defaultConfig is MovActionConfig)
{
AddActorConfig(defaultConfig);
}
// For MOV animation actor, additional action config files are defined as
// For MOV animated skeletal actor, additional action config files are defined as
// 01.ini, 02.ini ...up tp 09.ini
for (var i = 0; i <= 9; i++)
{
if (_resourceProvider.GetActorActionConfig(actorActionConfigFolder + $"{i:D2}.ini")
if (_resourceProvider.GetActorActionConfig(name, $"{i:D2}.ini")
is MovActionConfig movConfig)
{
AddActorConfig(movConfig);
}
}
AnimationType = ActorAnimationType.Mov;
AnimationType = ActorAnimationType.Skeletal;
}
private void AddActorConfig(ActorActionConfig config)
@@ -110,28 +105,37 @@ namespace Pal3.Actor
throw new ArgumentException($"Action file name not found for action name {actionName}");
}
char separator = CpkConstants.DirectorySeparator;
return $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
$"{FileConstants.ActorFolderName}{separator}{_actorName}{separator}" +
$"{actionFileName}";
return $"{FileConstants.GetActorFolderVirtualPath(_actorName)}{actionFileName}";
}
public string GetMeshFilePath(string actionName)
{
if (AnimationType != ActorAnimationType.Mov)
if (AnimationType != ActorAnimationType.Skeletal)
{
throw new InvalidOperationException("Mesh file path is only available for MOV animation type.");
throw new InvalidOperationException("Msh file path is only available for skeletal animation type.");
}
if (!_actionNameToMeshFileNameMap.TryGetValue(actionName, out var meshFileName))
{
throw new ArgumentException($"Mesh file name not found for action name {actionName}");
throw new ArgumentException($"Msh file name not found for action name {actionName}");
}
char separator = CpkConstants.DirectorySeparator;
return $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
$"{FileConstants.ActorFolderName}{separator}{_actorName}{separator}" +
$"{meshFileName}";
return $"{FileConstants.GetActorFolderVirtualPath(_actorName)}{meshFileName}";
}
public string GetMaterialFilePath(string actionName)
{
if (AnimationType != ActorAnimationType.Skeletal)
{
throw new InvalidOperationException("Mtl file path is only available for skeletal animation type.");
}
if (!_actionNameToMaterialFileNameMap.TryGetValue(actionName, out var mtlFileName))
{
throw new ArgumentException($"Mtl file name not found for action name {actionName}");
}
return $"{FileConstants.GetActorFolderVirtualPath(_actorName)}{mtlFileName}";
}
}
}
+19 -10
View File
@@ -40,17 +40,26 @@ namespace Pal3.Actor
#endif
ActorActionController actionController;
if (actor.AnimationType == ActorAnimationType.Mv3)
switch (actor.AnimationType)
{
Mv3ActorActionController mv3ActionController = actorGameObject.AddComponent<Mv3ActorActionController>();
mv3ActionController.Init(resourceProvider, actor, hasColliderAndRigidBody, isDropShadowEnabled, tintColor);
actionController = mv3ActionController;
}
else
{
MovActorActionController movActionController = actorGameObject.AddComponent<MovActorActionController>();
movActionController.Init(resourceProvider, actor, hasColliderAndRigidBody, isDropShadowEnabled, tintColor);
actionController = movActionController;
case ActorAnimationType.Vertex:
{
VertexAnimationActorActionController vertexActionController =
actorGameObject.AddComponent<VertexAnimationActorActionController>();
vertexActionController.Init(resourceProvider, actor, hasColliderAndRigidBody, isDropShadowEnabled, tintColor);
actionController = vertexActionController;
break;
}
case ActorAnimationType.Skeletal:
{
SkeletalAnimationActorActionController skeletalActionController =
actorGameObject.AddComponent<SkeletalAnimationActorActionController>();
skeletalActionController.Init(resourceProvider, actor, hasColliderAndRigidBody, isDropShadowEnabled, tintColor);
actionController = skeletalActionController;
break;
}
default:
throw new NotSupportedException($"Unsupported actor animation type: {actor.AnimationType}");
}
var movementController = actorGameObject.AddComponent<ActorMovementController>();
@@ -92,16 +92,19 @@ namespace Pal3.Actor
actor.Info.GameBoxYPosition,
actor.Info.GameBoxZPosition));
// Setup actor's initial position
if (actor.Info.InitBehaviour != ScnActorBehaviour.Hold &&
_tilemap.TryGetTile(initPosition, _currentLayerIndex, out NavTile tile))
{
if (tile.IsWalkable())
// If the actor is initially placed on a walkable tile, snap to the tile
// Same for the case when actor is configured to not facing the player actor during dialogue
if (tile.IsWalkable() || actor.Info.NoTurn == 1)
{
transform.position = new Vector3(initPosition.x,
GameBoxInterpreter.ToUnityYPosition(tile.GameBoxYPosition),
initPosition.z);
}
else
else // This is to handle the case where the actor is initially placed on a non-walkable tile
{
Vector2Int tilePosition = _tilemap.GetTilePosition(initPosition, _currentLayerIndex);
// Snap to the nearest adjacent tile if exists
@@ -22,7 +22,7 @@ namespace Pal3.Actor
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_FLY_SPEED_CHANEG_DISTANCE = 8f;
private const float FOLLOW_TARGET_FLY_SPEED_CHANGE_DISTANCE = 8f;
private const float FOLLOW_TARGET_MAX_DISTANCE = 15f;
private const float FOLLOW_TARGET_X_OFFSET = 0.8f;
private const float FOLLOW_TARGET_Y_OFFSET = -0.8f;
@@ -127,10 +127,10 @@ namespace Pal3.Actor
}
// Increase fly speed if the distance is greater than a threshold
var flySpeed = distanceToTarget > FOLLOW_TARGET_FLY_SPEED_CHANEG_DISTANCE ? MaxFlySpeed : DefaultFlySpeed;
var flySpeed = distanceToTarget > FOLLOW_TARGET_FLY_SPEED_CHANGE_DISTANCE ? MaxFlySpeed : DefaultFlySpeed;
_actorActionController.PerformAction(
Vector3.Distance(myNewPosition, transform.position) < FOLLOW_TARGET_FLY_SPEED_CHANEG_DISTANCE - 1f
Vector3.Distance(myNewPosition, transform.position) < FOLLOW_TARGET_FLY_SPEED_CHANGE_DISTANCE - 1f
? _actor.GetMovementAction(MovementMode.Walk)
: _actor.GetMovementAction(MovementMode.Run));
@@ -1,224 +0,0 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Actor
{
using System;
using Command;
using Command.InternalCommands;
using Command.SceCommands;
using Core.DataLoader;
using Core.DataReader.Mov;
using Core.DataReader.Msh;
using Core.Utils;
using Data;
using MetaData;
using Renderer;
using Script.Waiter;
using UnityEngine;
public class MovActorActionController : ActorActionController,
ICommandExecutor<ActorAutoStandCommand>,
ICommandExecutor<ActorStopActionCommand>
{
private GameResourceProvider _resourceProvider;
private IMaterialFactory _materialFactory;
private Actor _actor;
private Color _tintColor;
private bool _autoStand = true;
// private MovModelRenderer _movAnimationRenderer;
// private WaitUntilCanceled _animationLoopPointWaiter;
private Bounds _rendererBounds;
private Bounds _meshBounds;
public void Init(GameResourceProvider resourceProvider,
Actor actor,
bool hasColliderAndRigidBody,
bool isDropShadowEnabled,
Color tintColor)
{
base.Init(resourceProvider, actor, hasColliderAndRigidBody, isDropShadowEnabled);
_resourceProvider = resourceProvider;
_actor = actor;
_tintColor = tintColor;
_materialFactory = resourceProvider.GetMaterialFactory();
}
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void OnDisable()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
DeActivate();
base.DeActivate();
}
public override void PerformAction(string actionName,
bool overwrite = false,
int loopCount = -1,
WaitUntilCanceled waiter = null)
{
if (!overwrite && string.Equals(GetCurrentAction(), actionName, StringComparison.OrdinalIgnoreCase))
{
return;
}
if (!_actor.HasAction(actionName))
{
Debug.LogError($"Action {actionName} not found for actor {_actor.Info.Name}.");
waiter?.CancelWait();
return;
}
Debug.LogWarning($"Actor {_actor.Info.Name} is performing bone action {actionName}.");
MovFile movFile;
MshFile mshFile;
ITextureResourceProvider textureProvider;
try
{
string movFilePath = _actor.GetActionFilePath(actionName);
movFile = _resourceProvider.GetGameResourceFile<MovFile>(movFilePath);
textureProvider = _resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(movFilePath));
string mshFilePath = _actor.GetMeshFilePath(actionName);
mshFile = _resourceProvider.GetGameResourceFile<MshFile>(mshFilePath);
}
catch (Exception ex)
{
Debug.LogError(ex);
waiter?.CancelWait();
return;
}
DisposeCurrentAction();
// _animationLoopPointWaiter = waiter;
// _movAnimationRenderer = gameObject.GetOrAddComponent<MovModelRenderer>();
//
// ActorActionType actionType = ActorConstants.ActionNames
// .FirstOrDefault(_ => string.Equals(_.Value, actionName, StringComparison.OrdinalIgnoreCase)).Key;
//
// if (movFile.TagNodes is {Length: > 0} && _actor.GetWeaponName() is {} weaponName &&
// ActorConstants.ActionNameToWeaponArmTypeMap[actionType] != WeaponArmType.None)
// {
// var separator = CpkConstants.DirectorySeparator;
//
// var weaponPath = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
// $"{FileConstants.WeaponFolderName}{separator}{weaponName}{separator}{weaponName}.pol";
//
// (PolFile polFile, ITextureResourceProvider weaponTextureProvider) = _resourceProvider.GetPol(weaponPath);
// _movAnimationRenderer.Init(movFile,
// _materialFactory,
// textureProvider,
// _tintColor,
// polFile,
// weaponTextureProvider);
// }
// else
// {
// _movAnimationRenderer.Init(movFile,
// _materialFactory,
// textureProvider,
// _tintColor);
// }
//
// _movAnimationRenderer.AnimationLoopPointReached += AnimationLoopPointReached;
// _movAnimationRenderer.StartAnimation(loopCount);
//
// _rendererBounds = _movAnimationRenderer.GetRendererBounds();
// _meshBounds = _movAnimationRenderer.GetMeshBounds();
base.PerformAction(actionName, overwrite, loopCount, waiter);
}
// public override float GetActorHeight()
// {
// if (_movAnimationRenderer == null || !_movAnimationRenderer.IsVisible())
// {
// return _meshBounds.size.y;
// }
//
// return _movAnimationRenderer.GetMeshBounds().size.y;
// }
//
// public override Bounds GetRendererBounds()
// {
// return (_movAnimationRenderer == null || !_movAnimationRenderer.IsVisible()) ? _rendererBounds :
// _movAnimationRenderer.GetRendererBounds();
// }
//
// public override Bounds GetMeshBounds()
// {
// return (_movAnimationRenderer == null || !_movAnimationRenderer.IsVisible()) ? _meshBounds :
// _movAnimationRenderer.GetMeshBounds();
// }
internal override void DisposeCurrentAction()
{
// _animationLoopPointWaiter?.CancelWait();
//
// if (_movAnimationRenderer != null)
// {
// _movAnimationRenderer.AnimationLoopPointReached -= AnimationLoopPointReached;
// _movAnimationRenderer.DisposeAnimation();
// }
base.DisposeCurrentAction();
}
internal override void DeActivate()
{
DisposeCurrentAction();
// if (_movAnimationRenderer != null)
// {
// Destroy(_movAnimationRenderer);
// }
base.DeActivate();
}
public void Execute(ActorAutoStandCommand command)
{
if (command.ActorId == _actor.Info.Id) _autoStand = (command.AutoStand == 1);
}
public void Execute(ActorStopActionCommand command)
{
// if (command.ActorId != _actor.Info.Id ||
// _movAnimationRenderer == null ||
// !_movAnimationRenderer.IsVisible()) return;
//
// if (_movAnimationRenderer.IsActionInHoldState())
// {
// _animationLoopPointWaiter?.CancelWait();
// _animationLoopPointWaiter = new WaitUntilCanceled();
// CommandDispatcher<ICommand>.Instance.Dispatch(
// new ScriptRunnerAddWaiterRequest(_animationLoopPointWaiter));
//
// _movAnimationRenderer.ResumeAction();
// }
// else
// {
// _movAnimationRenderer.PauseAnimation();
// _animationLoopPointWaiter?.CancelWait();
//
// if (_autoStand && _movAnimationRenderer.IsVisible())
// {
// PerformAction(_actor.GetIdleAction());
// }
// }
}
}
}
@@ -0,0 +1,182 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Actor
{
using System;
using Command;
using Command.SceCommands;
using Core.DataLoader;
using Core.DataReader.Mov;
using Core.DataReader.Msh;
using Core.DataReader.Mtl;
using Core.Extensions;
using Core.Utils;
using Data;
using Renderer;
using Script.Waiter;
using UnityEngine;
public class SkeletalAnimationActorActionController : ActorActionController,
ICommandExecutor<ActorAutoStandCommand>,
ICommandExecutor<ActorStopActionCommand>
{
private GameResourceProvider _resourceProvider;
private IMaterialFactory _materialFactory;
private Actor _actor;
private Color _tintColor;
private bool _autoStand = true;
private SkeletalModelRenderer _skeletalModelRenderer;
private Bounds _rendererBounds;
private Bounds _meshBounds;
public void Init(GameResourceProvider resourceProvider,
Actor actor,
bool hasColliderAndRigidBody,
bool isDropShadowEnabled,
Color tintColor)
{
base.Init(resourceProvider, actor, hasColliderAndRigidBody, isDropShadowEnabled);
_resourceProvider = resourceProvider;
_actor = actor;
_tintColor = tintColor;
_materialFactory = resourceProvider.GetMaterialFactory();
}
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void OnDisable()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
DeActivate();
base.DeActivate();
}
public override void PerformAction(string actionName,
bool overwrite = false,
int loopCount = -1,
WaitUntilCanceled waiter = null)
{
if (!overwrite && string.Equals(GetCurrentAction(), actionName, StringComparison.OrdinalIgnoreCase))
{
return;
}
if (!_actor.HasAction(actionName))
{
Debug.LogError($"Action {actionName} not found for actor {_actor.Info.Name}.");
waiter?.CancelWait();
return;
}
MshFile mshFile;
MtlFile mtlFile;
MovFile movFile;
ITextureResourceProvider textureProvider;
try
{
string mshFilePath = _actor.GetMeshFilePath(actionName);
mshFile = _resourceProvider.GetGameResourceFile<MshFile>(mshFilePath);
string mtlFilePath = _actor.GetMaterialFilePath(actionName);
mtlFile = _resourceProvider.GetGameResourceFile<MtlFile>(mtlFilePath);
string movFilePath = _actor.GetActionFilePath(actionName);
movFile = _resourceProvider.GetGameResourceFile<MovFile>(movFilePath);
textureProvider = _resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(mtlFilePath));
}
catch (Exception ex)
{
Debug.LogError(ex);
waiter?.CancelWait();
return;
}
DisposeCurrentAction();
_skeletalModelRenderer = gameObject.GetOrAddComponent<SkeletalModelRenderer>();
_skeletalModelRenderer.Init(mshFile,
mtlFile,
_materialFactory,
textureProvider,
_tintColor);
_skeletalModelRenderer.StartAnimation(movFile, loopCount);
_rendererBounds = _skeletalModelRenderer.GetRendererBounds();
_meshBounds = _skeletalModelRenderer.GetMeshBounds();
base.PerformAction(actionName, overwrite, loopCount, waiter);
}
public override float GetActorHeight()
{
if (_skeletalModelRenderer == null || !_skeletalModelRenderer.IsVisible())
{
return _meshBounds.size.y;
}
return _skeletalModelRenderer.GetMeshBounds().size.y;
}
public override Bounds GetRendererBounds()
{
return (_skeletalModelRenderer == null || !_skeletalModelRenderer.IsVisible()) ? _rendererBounds :
_skeletalModelRenderer.GetRendererBounds();
}
public override Bounds GetMeshBounds()
{
return (_skeletalModelRenderer == null || !_skeletalModelRenderer.IsVisible()) ? _meshBounds :
_skeletalModelRenderer.GetMeshBounds();
}
internal override void DisposeCurrentAction()
{
if (_skeletalModelRenderer != null)
{
_skeletalModelRenderer.Dispose();
_skeletalModelRenderer = null;
}
base.DisposeCurrentAction();
}
internal override void DeActivate()
{
DisposeCurrentAction();
base.DeActivate();
}
public void Execute(ActorAutoStandCommand command)
{
if (command.ActorId == _actor.Info.Id) _autoStand = (command.AutoStand == 1);
}
public void Execute(ActorStopActionCommand command)
{
if (command.ActorId != _actor.Info.Id ||
_skeletalModelRenderer == null ||
!_skeletalModelRenderer.IsVisible()) return;
_skeletalModelRenderer.PauseAnimation();
if (_autoStand && _skeletalModelRenderer.IsVisible())
{
PerformAction(_actor.GetIdleAction());
}
}
}
}
@@ -10,7 +10,6 @@ namespace Pal3.Actor
using Command.InternalCommands;
using Command.SceCommands;
using Core.DataLoader;
using Core.DataReader.Cpk;
using Core.DataReader.Mv3;
using Core.DataReader.Pol;
using Core.DataReader.Scn;
@@ -22,7 +21,7 @@ namespace Pal3.Actor
using Script.Waiter;
using UnityEngine;
public class Mv3ActorActionController : ActorActionController,
public class VertexAnimationActorActionController : ActorActionController,
ICommandExecutor<ActorAutoStandCommand>,
ICommandExecutor<ActorStopActionCommand>,
ICommandExecutor<ActorChangeTextureCommand>
@@ -34,7 +33,7 @@ namespace Pal3.Actor
private bool _autoStand = true;
private Mv3ModelRenderer _mv3AnimationRenderer;
private Mv3ModelRenderer _mv3ModelRenderer;
private WaitUntilCanceled _animationLoopPointWaiter;
private Bounds _rendererBounds;
@@ -124,7 +123,7 @@ namespace Pal3.Actor
DisposeCurrentAction();
_animationLoopPointWaiter = waiter;
_mv3AnimationRenderer = gameObject.GetOrAddComponent<Mv3ModelRenderer>();
_mv3ModelRenderer = gameObject.GetOrAddComponent<Mv3ModelRenderer>();
ActorActionType? actionType = ActorConstants.NameToActionMap.ContainsKey(actionName.ToLower()) ?
ActorConstants.NameToActionMap[actionName.ToLower()] : null;
@@ -134,15 +133,11 @@ namespace Pal3.Actor
_actor.GetWeaponName() is {} weaponName &&
ActorConstants.ActionNameToWeaponArmTypeMap[actionType.Value] != WeaponArmType.None)
{
var separator = CpkConstants.DirectorySeparator;
var weaponPath = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
$"{FileConstants.WeaponFolderName}{separator}{weaponName}{separator}{weaponName}.pol";
string weaponPath = FileConstants.GetWeaponModelFileVirtualPath(weaponName);
PolFile polFile = _resourceProvider.GetGameResourceFile<PolFile>(weaponPath);
ITextureResourceProvider weaponTextureProvider = _resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(weaponPath));
_mv3AnimationRenderer.Init(mv3File,
_mv3ModelRenderer.Init(mv3File,
_materialFactory,
textureProvider,
_tintColor,
@@ -151,49 +146,49 @@ namespace Pal3.Actor
}
else
{
_mv3AnimationRenderer.Init(mv3File,
_mv3ModelRenderer.Init(mv3File,
_materialFactory,
textureProvider,
_tintColor);
}
_mv3AnimationRenderer.AnimationLoopPointReached += AnimationLoopPointReached;
_mv3AnimationRenderer.StartAnimation(loopCount);
_mv3ModelRenderer.AnimationLoopPointReached += AnimationLoopPointReached;
_mv3ModelRenderer.StartAnimation(loopCount);
_rendererBounds = _mv3AnimationRenderer.GetRendererBounds();
_meshBounds = _mv3AnimationRenderer.GetMeshBounds();
_rendererBounds = _mv3ModelRenderer.GetRendererBounds();
_meshBounds = _mv3ModelRenderer.GetMeshBounds();
base.PerformAction(actionName, overwrite, loopCount, waiter);
}
public override void PauseAnimation()
{
if (_mv3AnimationRenderer != null)
if (_mv3ModelRenderer != null)
{
_mv3AnimationRenderer.PauseAnimation();
_mv3ModelRenderer.PauseAnimation();
}
}
public override float GetActorHeight()
{
if (_mv3AnimationRenderer == null || !_mv3AnimationRenderer.IsVisible())
if (_mv3ModelRenderer == null || !_mv3ModelRenderer.IsVisible())
{
return _meshBounds.size.y;
}
return _mv3AnimationRenderer.GetMeshBounds().size.y;
return _mv3ModelRenderer.GetMeshBounds().size.y;
}
public override Bounds GetRendererBounds()
{
return (_mv3AnimationRenderer == null || !_mv3AnimationRenderer.IsVisible()) ? _rendererBounds :
_mv3AnimationRenderer.GetRendererBounds();
return (_mv3ModelRenderer == null || !_mv3ModelRenderer.IsVisible()) ? _rendererBounds :
_mv3ModelRenderer.GetRendererBounds();
}
public override Bounds GetMeshBounds()
{
return (_mv3AnimationRenderer == null || !_mv3AnimationRenderer.IsVisible()) ? _meshBounds :
_mv3AnimationRenderer.GetMeshBounds();
return (_mv3ModelRenderer == null || !_mv3ModelRenderer.IsVisible()) ? _meshBounds :
_mv3ModelRenderer.GetMeshBounds();
}
private void AnimationLoopPointReached(object _, int loopCount)
@@ -203,10 +198,10 @@ namespace Pal3.Actor
_animationLoopPointWaiter?.CancelWait();
}
if (_autoStand && _mv3AnimationRenderer.IsVisible())
if (_autoStand && _mv3ModelRenderer.IsVisible())
{
if (loopCount is 0 ||
(loopCount is -2 && !_mv3AnimationRenderer.IsActionInHoldState()))
(loopCount is -2 && !_mv3ModelRenderer.IsActionInHoldState()))
{
PerformAction(_actor.GetIdleAction());
}
@@ -217,10 +212,11 @@ namespace Pal3.Actor
{
_animationLoopPointWaiter?.CancelWait();
if (_mv3AnimationRenderer != null)
if (_mv3ModelRenderer != null)
{
_mv3AnimationRenderer.AnimationLoopPointReached -= AnimationLoopPointReached;
_mv3AnimationRenderer.Dispose();
_mv3ModelRenderer.AnimationLoopPointReached -= AnimationLoopPointReached;
_mv3ModelRenderer.Dispose();
_mv3ModelRenderer = null;
}
base.DisposeCurrentAction();
@@ -229,12 +225,6 @@ namespace Pal3.Actor
internal override void DeActivate()
{
DisposeCurrentAction();
if (_mv3AnimationRenderer != null)
{
Destroy(_mv3AnimationRenderer);
}
base.DeActivate();
}
@@ -246,23 +236,23 @@ namespace Pal3.Actor
public void Execute(ActorStopActionCommand command)
{
if (command.ActorId != _actor.Info.Id ||
_mv3AnimationRenderer == null ||
!_mv3AnimationRenderer.IsVisible()) return;
_mv3ModelRenderer == null ||
!_mv3ModelRenderer.IsVisible()) return;
if (_mv3AnimationRenderer.IsActionInHoldState())
if (_mv3ModelRenderer.IsActionInHoldState())
{
_animationLoopPointWaiter?.CancelWait();
_animationLoopPointWaiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(
new ScriptRunnerAddWaiterRequest(_animationLoopPointWaiter));
_mv3AnimationRenderer.ResumeAction();
_mv3ModelRenderer.ResumeAction();
}
else
{
_mv3AnimationRenderer.PauseAnimation();
_mv3ModelRenderer.PauseAnimation();
_animationLoopPointWaiter?.CancelWait();
if (_autoStand && _mv3AnimationRenderer.IsVisible())
if (_autoStand && _mv3ModelRenderer.IsVisible())
{
PerformAction(_actor.GetIdleAction());
}
@@ -272,7 +262,7 @@ namespace Pal3.Actor
public void Execute(ActorChangeTextureCommand command)
{
if (_actor.Info.Id != command.ActorId) return;
_mv3AnimationRenderer.ChangeTexture(command.TextureName);
_mv3ModelRenderer.ChangeTexture(command.TextureName);
}
}
}
+4 -11
View File
@@ -138,8 +138,8 @@ namespace Pal3.Audio
}
_currentMusicClipName = musicName;
var musicFileVirtualPath = GetMusicFileVirtualPath(musicName);
var musicFileCachePath = _resourceProvider.GetMp3FilePathInCacheFolder(musicFileVirtualPath);
var musicFileVirtualPath = FileConstants.GetMusicFileVirtualPath(musicName);
var musicFileCachePath = _resourceProvider.GetMusicFilePathInCacheFolder(musicName);
yield return PlayMusicAsync(musicName, musicFileVirtualPath, musicFileCachePath, -1);
}
@@ -257,13 +257,6 @@ namespace Pal3.Audio
}
}
private string GetMusicFileVirtualPath(string musicName)
{
var separator = CpkConstants.DirectorySeparator;
return $"{FileConstants.MusicCpkPathInfo.cpkName}{separator}" +
$"{FileConstants.MusicCpkPathInfo.relativePath}{separator}{musicName}.mp3";
}
public IEnumerator PlayMusicAsync(string musicName,
string musicFileVirtualPath,
string musicFileCachePath,
@@ -447,8 +440,8 @@ namespace Pal3.Audio
_currentScriptMusic = command.MusicName;
_currentMusicClipName = command.MusicName;
var musicFileVirtualPath = GetMusicFileVirtualPath(command.MusicName);
var musicFileCachePath = _resourceProvider.GetMp3FilePathInCacheFolder(musicFileVirtualPath);
var musicFileVirtualPath = FileConstants.GetMusicFileVirtualPath(command.MusicName);
var musicFileCachePath = _resourceProvider.GetMusicFilePathInCacheFolder(musicFileVirtualPath);
StartCoroutine(PlayMusicAsync(command.MusicName,
musicFileVirtualPath,
musicFileCachePath,
+94 -122
View File
@@ -22,6 +22,8 @@ namespace Pal3.Data
using Core.DataReader.Ini;
using Core.DataReader.Lgt;
using Core.DataReader.Mov;
using Core.DataReader.Msh;
using Core.DataReader.Mtl;
using Core.DataReader.Mv3;
using Core.DataReader.Nav;
using Core.DataReader.Pol;
@@ -83,15 +85,17 @@ namespace Pal3.Data
_litMaterialFactory = litMaterialFactory; // Lit materials are not required
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
var gdbFilePath =
$"{FileConstants.BaseDataCpkPathInfo.cpkName}{PathSeparator}" +
$"{FileConstants.CombatDataFolderName}{PathSeparator}{GameConstants.AppName}_Softstar.gdb";
_gameDatabase = GetGameResourceFileReader<GdbFile>().Read(_fileSystem.ReadAllBytes(gdbFilePath));
_gameDatabase = GetGameDatabaseFile(); // Initialize game database file
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private GdbFile GetGameDatabaseFile()
{
var gdbFilePath = FileConstants.GameDatabaseFileVirtualPath;
return GetGameResourceFileReader<GdbFile>().Read(_fileSystem.ReadAllBytes(gdbFilePath));
}
private IFileReader<T> GetGameResourceFileReader<T>()
{
return ServiceLocator.Instance.Get<IFileReader<T>>();
@@ -104,6 +108,7 @@ namespace Pal3.Data
_gameResourceFileCache.Clear();
_actorConfigCache.Clear();
_audioClipCache.Clear();
_vfxEffectPrefabCache.Clear();
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
@@ -136,18 +141,18 @@ namespace Pal3.Data
new TextureProvider(_fileSystem, _textureLoaderFactory, relativeDirectoryPath);
}
public T GetGameResourceFile<T>(string filePath, bool useCache = true)
public T GetGameResourceFile<T>(string fileVirtualPath, bool useCache = true)
{
filePath = filePath.ToLower();
fileVirtualPath = fileVirtualPath.ToLower();
if (useCache &&
_gameResourceFileCache.ContainsKey(typeof(T)) &&
_gameResourceFileCache[typeof(T)].ContainsKey(filePath))
_gameResourceFileCache[typeof(T)].ContainsKey(fileVirtualPath))
{
return (T)_gameResourceFileCache[typeof(T)][filePath];
return (T)_gameResourceFileCache[typeof(T)][fileVirtualPath];
}
T file = GetGameResourceFileReader<T>().Read(_fileSystem.ReadAllBytes(filePath));
T file = GetGameResourceFileReader<T>().Read(_fileSystem.ReadAllBytes(fileVirtualPath));
if (useCache)
{
@@ -156,61 +161,40 @@ namespace Pal3.Data
{
_gameResourceFileCache[typeof(T)] = new Dictionary<string, object>();
}
_gameResourceFileCache[typeof(T)][filePath] = file;
_gameResourceFileCache[typeof(T)][fileVirtualPath] = file;
}
return file;
}
public LgtFile GetLgt(string lgtFilePath)
public NavFile GetNavFile(string sceneFileName, string sceneName)
{
return GetGameResourceFileReader<LgtFile>().Read(_fileSystem.ReadAllBytes(lgtFilePath));
}
public NavFile GetNav(string sceneFileName, string sceneName)
{
#if PAL3
var navFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{PathSeparator}" +
$"{sceneName}{PathSeparator}{sceneName}.nav";
#elif PAL3A
var navFilePath = $"{FileConstants.ScnCpkPathInfo.cpkName}{PathSeparator}SCN{PathSeparator}" +
$"{sceneFileName}{PathSeparator}{sceneName}{PathSeparator}{sceneName}.nav";
#endif
var navFilePath = FileConstants.GetNavFileVirtualPath(sceneFileName, sceneName);
return GetGameResourceFileReader<NavFile>().Read(_fileSystem.ReadAllBytes(navFilePath));
}
public ScnFile GetScn(string sceneFileName, string sceneName)
public ScnFile GetScnFile(string sceneFileName, string sceneName)
{
#if PAL3
var scnFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{PathSeparator}{sceneName}.scn";
#elif PAL3A
var scnFilePath = $"{FileConstants.ScnCpkPathInfo.cpkName}{PathSeparator}SCN{PathSeparator}" +
$"{sceneFileName}{PathSeparator}{sceneFileName}_{sceneName}.scn";
#endif
var scnFilePath = FileConstants.GetScnFileVirtualPath(sceneFileName, sceneName);
return GetGameResourceFileReader<ScnFile>().Read(_fileSystem.ReadAllBytes(scnFilePath));
}
public SceFile GetSceneSce(string sceneFileName)
public SceFile GetSceneSceFile(string sceneFileName)
{
#if PAL3
var sceFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{PathSeparator}{sceneFileName}.sce";
#elif PAL3A
var sceFilePath = $"{FileConstants.SceCpkPathInfo.cpkName}{PathSeparator}Sce{PathSeparator}{sceneFileName}.sce";
#endif
var sceFilePath = FileConstants.GetSceneSceFileVirtualPath(sceneFileName);
return GetGameResourceFileReader<SceFile>().Read(_fileSystem.ReadAllBytes(sceFilePath));
}
public SceFile GetSystemSce()
public SceFile GetSystemSceFile()
{
return GetGameResourceFileReader<SceFile>().Read(_fileSystem.ReadAllBytes(FileConstants.SystemSceFileVirtualPath));
var systemSceFilePath = FileConstants.SystemSceFileVirtualPath;
return GetGameResourceFileReader<SceFile>().Read(_fileSystem.ReadAllBytes(systemSceFilePath));
}
public SceFile GetBigMapSce()
public SceFile GetBigMapSceFile()
{
return GetGameResourceFileReader<SceFile>().Read(_fileSystem.ReadAllBytes(FileConstants.BigMapSceFileVirtualPath));
var bigMapSceFilePath = FileConstants.BigMapSceFileVirtualPath;
return GetGameResourceFileReader<SceFile>().Read(_fileSystem.ReadAllBytes(bigMapSceFilePath));
}
public Dictionary<int, GameItem> GetGameItems()
@@ -222,8 +206,8 @@ namespace Pal3.Data
/// Get music file path in cache folder.
/// </summary>
/// <param name="musicFileVirtualPath">music file virtual path</param>
/// <returns>Mp3 file path in cache folder</returns>
public string GetMp3FilePathInCacheFolder(string musicFileVirtualPath)
/// <returns>Music file path in cache folder</returns>
public string GetMusicFilePathInCacheFolder(string musicFileVirtualPath)
{
return Application.persistentDataPath
+ Path.DirectorySeparatorChar
@@ -318,10 +302,7 @@ namespace Pal3.Data
private Texture2D GetActorAvatarTexture(string actorName, string avatarTextureName)
{
var roleAvatarTextureRelativePath =
$"{FileConstants.BaseDataCpkPathInfo.cpkName}{PathSeparator}" +
$"{FileConstants.ActorFolderName}{PathSeparator}{actorName}{PathSeparator}";
var roleAvatarTextureRelativePath = FileConstants.GetActorFolderVirtualPath(actorName);
ITextureResourceProvider textureProvider = CreateTextureResourceProvider(roleAvatarTextureRelativePath);
return textureProvider.GetTexture($"{avatarTextureName}.tga");
}
@@ -351,20 +332,14 @@ namespace Pal3.Data
private Texture2D GetEmojiSpriteSheetTexture(ActorEmojiType emojiType)
{
var emojiSpriteSheetRelativePath =
$"{FileConstants.BaseDataCpkPathInfo.cpkName}{PathSeparator}" +
$"{FileConstants.UIFolderName}{PathSeparator}{FileConstants.EmojiFolderName}{PathSeparator}";
string emojiSpriteSheetRelativePath = FileConstants.EmojiSpriteSheetFolderVirtualPath;
ITextureResourceProvider textureProvider = CreateTextureResourceProvider(emojiSpriteSheetRelativePath);
return textureProvider.GetTexture($"EM_{(int)emojiType:00}.tga");
}
public Texture2D GetCaptionTexture(string name)
{
var captionTextureRelativePath =
$"{FileConstants.BaseDataCpkPathInfo.cpkName}{PathSeparator}" +
$"{FileConstants.CaptionFolderName}{PathSeparator}";
var captionTextureRelativePath = FileConstants.CaptionFolderVirtualPath;
// No need to cache caption texture since it is a one time thing
ITextureResourceProvider textureProvider = CreateTextureResourceProvider(captionTextureRelativePath, useCache: false);
return textureProvider.GetTexture($"{name}.tga");
@@ -372,16 +347,16 @@ namespace Pal3.Data
public Texture2D[] GetSkyBoxTextures(int skyBoxId)
{
var relativeFilePath = string.Format(SceneConstants.SkyBoxTexturePathFormat.First(), skyBoxId);
var relativeFilePath = string.Format(FileConstants.SkyBoxTexturePathFormat.First(), skyBoxId);
ITextureResourceProvider textureProvider = CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(relativeFilePath));
var textures = new Texture2D[SceneConstants.SkyBoxTexturePathFormat.Length];
for (var i = 0; i < SceneConstants.SkyBoxTexturePathFormat.Length; i++)
var textures = new Texture2D[FileConstants.SkyBoxTexturePathFormat.Length];
for (var i = 0; i < FileConstants.SkyBoxTexturePathFormat.Length; i++)
{
var textureNameFormat = Utility.GetFileName(
string.Format(SceneConstants.SkyBoxTexturePathFormat[i], skyBoxId), PathSeparator);
string.Format(FileConstants.SkyBoxTexturePathFormat[i], skyBoxId), PathSeparator);
Texture2D texture = textureProvider.GetTexture(string.Format(textureNameFormat, i));
// Set wrap mode to clamp to remove "edges" between sides
texture.wrapMode = TextureWrapMode.Clamp;
@@ -393,10 +368,7 @@ namespace Pal3.Data
public Texture2D GetEffectTexture(string name, out bool hasAlphaChannel)
{
var effectFolderRelativePath =
$"{FileConstants.BaseDataCpkPathInfo.cpkName}{PathSeparator}" +
$"{FileConstants.EffectFolderName}{PathSeparator}";
var effectFolderRelativePath = FileConstants.EffectFolderVirtualPath;
ITextureResourceProvider textureProvider = CreateTextureResourceProvider(effectFolderRelativePath);
return textureProvider.GetTexture(name, out hasAlphaChannel);
}
@@ -435,7 +407,7 @@ namespace Pal3.Data
public Sprite[] GetJumpIndicatorSprites()
{
var relativePath = FileConstants.UISceneFolderVirtualPath + PathSeparator;
var relativePath = FileConstants.UISceneFolderVirtualPath;
var textureProvider = CreateTextureResourceProvider(relativePath);
var sprites = new Sprite[4];
@@ -464,8 +436,10 @@ namespace Pal3.Data
return sprites;
}
public ActorActionConfig GetActorActionConfig(string actorConfigFilePath)
public ActorActionConfig GetActorActionConfig(string actorName, string configFileName)
{
string actorConfigFilePath = FileConstants.GetActorFolderVirtualPath(actorName) + configFileName;
actorConfigFilePath = actorConfigFilePath.ToLower();
if (_actorConfigCache.TryGetValue(actorConfigFilePath, out ActorActionConfig actorActionConfig))
@@ -594,10 +568,7 @@ namespace Pal3.Data
public Texture2D GetCursorTexture()
{
var cursorSpriteRelativePath =
$"{FileConstants.BaseDataCpkPathInfo.cpkName}{PathSeparator}" +
$"{FileConstants.UIFolderName}{PathSeparator}{FileConstants.CursorFolderName}{PathSeparator}";
var cursorSpriteRelativePath = FileConstants.CursorSpriteFolderVirtualPath;
ITextureResourceProvider textureProvider = CreateTextureResourceProvider(cursorSpriteRelativePath);
Texture2D cursorTexture = textureProvider.GetTexture($"jt.tga");
return cursorTexture;
@@ -618,19 +589,14 @@ namespace Pal3.Data
foreach (var name in ActorConstants.MainActorNameMap.Values)
{
var actorConfigFile = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{PathSeparator}" +
$"{FileConstants.ActorFolderName}{PathSeparator}{name}{PathSeparator}{name}.ini";
ActorActionConfig actorActionConfig = GetActorActionConfig(actorConfigFile);
ActorActionConfig actorActionConfig = GetActorActionConfig(name, $"{name}.ini");
foreach (ActorAction actorAction in actorActionConfig.ActorActions)
{
// Cache known actions only.
if (!cachedActions.Contains(actorAction.ActionName.ToLower())) continue;
var mv3FilePath = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{PathSeparator}" +
$"{FileConstants.ActorFolderName}{PathSeparator}{name}{PathSeparator}" +
$"{actorAction.ActionFileName}";
var mv3FilePath = FileConstants.GetActorFolderVirtualPath(name) + actorAction.ActionFileName;
_ = GetGameResourceFile<Mv3File>(mv3FilePath); // Call GetMv3 to cache the mv3 file.
}
@@ -650,54 +616,60 @@ namespace Pal3.Data
if (!newCityName.Equals(_currentCityName, StringComparison.OrdinalIgnoreCase))
{
// Clean up cache after exiting current scene block
_textureCache?.DisposeAll();
foreach (Sprite sprite in _spriteCache.Values)
{
Object.Destroy(sprite);
}
_spriteCache.Clear();
if (_gameResourceFileCache.ContainsKey(typeof(PolFile)))
{
_gameResourceFileCache[typeof(PolFile)]?.Clear();
}
if (_gameResourceFileCache.ContainsKey(typeof(CvdFile)))
{
_gameResourceFileCache[typeof(CvdFile)]?.Clear();
}
if (_gameResourceFileCache.ContainsKey(typeof(MovFile)))
{
_gameResourceFileCache[typeof(MovFile)]?.Clear();
}
if (_gameResourceFileCache.ContainsKey(typeof(Mv3File)))
{
var mv3FileCache = _gameResourceFileCache[typeof(Mv3File)];
// Dispose non-main actor mv3 files
// All main actor names start with "1"
var mainActorMv3 = $"{FileConstants.ActorFolderName}{PathSeparator}1".ToLower();
var mv3FilesToDispose = mv3FileCache.Keys
.Where(mv3FilePath => !mv3FilePath.Contains(mainActorMv3))
.ToArray();
foreach (var mv3File in mv3FilesToDispose)
{
mv3FileCache.Remove(mv3File);
}
}
// clear all vfx prefabs in cache
_vfxEffectPrefabCache.Clear();
DisposeTemporaryInMemoryGameResources();
_currentCityName = newCityName;
}
// Unloads assets that are not used (textures etc.)
Resources.UnloadUnusedAssets();
}
/// <summary>
/// Dispose temporary in-memory resources that are only used in current scene block.
/// </summary>
private void DisposeTemporaryInMemoryGameResources()
{
// Clean up texture cache after exiting current scene block
_textureCache?.DisposeAll();
// Clean up sprite cache after exiting current scene block
foreach (Sprite sprite in _spriteCache.Values)
{
Object.Destroy(sprite);
}
_spriteCache.Clear();
// Dispose in-memory game resource files
foreach (var fileCache in _gameResourceFileCache)
{
if (fileCache.Key == typeof(Mv3File))
{
// Dispose non-main actor mv3 files
// All main actor names start with "1"
var mainActorMv3 = $"{FileConstants.GetActorFolderName()}{PathSeparator}1".ToLower();
var mv3FilesToDispose = fileCache.Value.Keys
.Where(mv3FilePath => !mv3FilePath.Contains(mainActorMv3))
.ToArray();
foreach (var mv3File in mv3FilesToDispose)
{
fileCache.Value.Remove(mv3File);
}
}
else if (fileCache.Key == typeof(GdbFile) ||
fileCache.Key == typeof(Mv3ActionConfig) ||
fileCache.Key == typeof(MovActionConfig))
{
// These files are used/cached across scenes
// Do not dispose them since they will be used in next scene block
}
else // Dispose all other files during scene block transition
{
fileCache.Value.Clear();
}
}
// clear all vfx prefabs in cache
_vfxEffectPrefabCache.Clear();
}
}
}
+10 -10
View File
@@ -349,10 +349,10 @@ namespace Pal3.Dev
{
SetupMenuLayout(isVertical: true);
const string lightingEnabledText = "实时光影:已开启";
const string lightingDisabledText = "实时光影:已关闭";
const string ssaoEnabledText = "环境光遮蔽:已开启";
const string ssaoDisabledText = "环境光遮蔽:已关闭";
const string lightingEnabledText = "实时光影:开启";
const string lightingDisabledText = "实时光影:关闭";
const string ssaoEnabledText = "环境光遮蔽:开启";
const string ssaoDisabledText = "环境光遮蔽:关闭";
// Toon materials are not available in open source build.
// so lighting and shadow will not work, thus we remove the option.
@@ -416,8 +416,8 @@ namespace Pal3.Dev
}
#if UNITY_STANDALONE
const string vsyncEnabledText = "垂直同步:已开启";
const string vsyncDisabledText = "垂直同步:已关闭";
const string vsyncEnabledText = "垂直同步:开启";
const string vsyncDisabledText = "垂直同步:关闭";
string GetVsyncButtonText() => _gameSettings.VSyncCount == 0 ? vsyncDisabledText : vsyncEnabledText;
CreateMenuButton(GetVsyncButtonText(), buttonTextUGUI => delegate
{
@@ -477,8 +477,8 @@ namespace Pal3.Dev
// });
// #endif
const string musicEnabledText = "音乐:已开启";
const string musicDisabledText = "音乐:已关闭";
const string musicEnabledText = "音乐:开启";
const string musicDisabledText = "音乐:关闭";
string GetMusicButtonText() => _gameSettings.MusicVolume == 0f ? musicDisabledText : musicEnabledText;
CreateMenuButton(GetMusicButtonText(), buttonTextUGUI => delegate
{
@@ -490,8 +490,8 @@ namespace Pal3.Dev
(_gameSettings.MusicVolume == 0f ? "关闭" : "开启") + ""));
});
const string sfxEnabledText = "音效:已开启";
const string sfxDisabledText = "音效:已关闭";
const string sfxEnabledText = "音效:开启";
const string sfxDisabledText = "音效:关闭";
string GetSfxButtonText() => _gameSettings.SfxVolume == 0f ? sfxDisabledText : sfxEnabledText;
CreateMenuButton(GetSfxButtonText(), buttonTextUGUI => delegate
{
@@ -15,6 +15,5 @@ namespace Pal3.Dev
{
[SerializeField] public GameBoxBlendFlag blendFlag;
[SerializeField] public GameBoxMaterial material;
[SerializeField] public string[] textureNames;
}
}
@@ -5,8 +5,6 @@
namespace Pal3.Effect.PostProcessing
{
using System;
using System.Collections;
using Command;
using Command.InternalCommands;
using Command.SceCommands;
@@ -164,33 +162,6 @@ namespace Pal3.Effect.PostProcessing
ToggleAmbientOcclusionBasedOnSetting();
TogglePostProcessLayerWhenNeeded();
}
#if UNITY_IOS || UNITY_STANDALONE_OSX
if (command.SettingName is nameof(GameSettings.ResolutionScale))
{
StartCoroutine(ReloadAmbientOcclusionSettingAsync());
}
#endif
}
#if UNITY_IOS || UNITY_STANDALONE_OSX
private IEnumerator Start()
{
yield return ReloadAmbientOcclusionSettingAsync();
}
// On iOS and MacOS, the SSAO and Resolution changing are causing the RoundedFrostedGlass
// shader to malfunction. This is a workaround to disable and re-enable SSAO to fix the issue.
private IEnumerator ReloadAmbientOcclusionSettingAsync()
{
if (_gameSettings.IsAmbientOcclusionEnabled)
{
yield return null;
_gameSettings.IsAmbientOcclusionEnabled = false;
yield return null;
_gameSettings.IsAmbientOcclusionEnabled = true;
}
}
#endif
}
}
+14 -24
View File
@@ -21,6 +21,7 @@ namespace Pal3
using Core.DataReader.Lgt;
using Core.DataReader.Mov;
using Core.DataReader.Msh;
using Core.DataReader.Mtl;
using Core.DataReader.Mv3;
using Core.DataReader.Nav;
using Core.DataReader.Pol;
@@ -141,7 +142,7 @@ namespace Pal3
string userPickedGameDataFolderPath = null;
yield return WaitForUserToPickGameDataFolder((path) => userPickedGameDataFolderPath = path);
yield return WaitForUserToPickGameDataFolderAsync(path => userPickedGameDataFolderPath = path);
if (!string.IsNullOrEmpty(userPickedGameDataFolderPath))
{
@@ -163,6 +164,7 @@ namespace Pal3
ServiceLocator.Instance.Register<IFileReader<Mv3File>>(new Mv3FileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<MovFile>>(new MovFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<MshFile>>(new MshFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<MtlFile>>(new MtlFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<PolFile>>(new PolFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<GdbFile>>(new GdbFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<LgtFile>>(new LgtFileReader());
@@ -207,7 +209,7 @@ namespace Pal3
FinalizeInit();
}
private IEnumerator WaitForUserToPickGameDataFolder(Action<string> callback)
private IEnumerator WaitForUserToPickGameDataFolderAsync(Action<string> callback)
{
string userPickedGameDataFolderPath = null;
@@ -332,32 +334,20 @@ namespace Pal3
{
ICpkFileSystem cpkFileSystem = new CpkFileSystem(gameRootPath, crcHash);
var filesToMount = new List<string>();
var baseDataCpk = FileConstants.BaseDataCpkPathInfo.relativePath +
Path.DirectorySeparatorChar + FileConstants.BaseDataCpkPathInfo.cpkName;
filesToMount.Add(baseDataCpk);
var musicCpk = FileConstants.MusicCpkPathInfo.relativePath +
Path.DirectorySeparatorChar + FileConstants.MusicCpkPathInfo.cpkName;
filesToMount.Add(musicCpk);
foreach ((string cpkName, string relativePath) sceneCpkPathInfo in FileConstants.SceneCpkPathInfos)
List<string> filesToMount = new ()
{
var sceneCpkPath = sceneCpkPathInfo.relativePath + Path.DirectorySeparatorChar +
sceneCpkPathInfo.cpkName;
filesToMount.Add(sceneCpkPath);
FileConstants.BaseDataCpkFilePath,
FileConstants.MusicCpkFilePath
};
foreach (string sceneCpkFileName in FileConstants.SceneCpkFileNames)
{
filesToMount.Add(FileConstants.GetSceneCpkFilePath(sceneCpkFileName));
}
#if PAL3A
var scnCpk = FileConstants.ScnCpkPathInfo.relativePath +
Path.DirectorySeparatorChar + FileConstants.ScnCpkPathInfo.cpkName;
filesToMount.Add(scnCpk);
var sceCpk = FileConstants.SceCpkPathInfo.relativePath +
Path.DirectorySeparatorChar + FileConstants.SceCpkPathInfo.cpkName;
filesToMount.Add(sceCpk);
filesToMount.Add(FileConstants.ScnCpkFilePath);
filesToMount.Add(FileConstants.SceCpkFilePath);
#endif
foreach (var cpkFilePath in filesToMount)
@@ -10,6 +10,7 @@ namespace Pal3.GameSystem
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Command;
using Command.InternalCommands;
using Command.SceCommands;
@@ -28,6 +29,7 @@ namespace Pal3.GameSystem
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.DualShock;
using UnityEngine.UI;
using Debug = UnityEngine.Debug;
public sealed class DialogueManager : MonoBehaviour,
ICommandExecutor<DialogueRenderActorAvatarCommand>,
@@ -39,6 +41,7 @@ namespace Pal3.GameSystem
private const float LIMIT_TIME_DIALOGUE_PLAYER_MAX_REACTION_TIME_IN_SECONDS = 4f;
private const float DIALOGUE_SHOW_HIDE_ANIMATION_DURATION = 0.1f;
private const float DIALOGUE_SHOW_HIDE_ANIMATION_Y_OFFSET = -30f;
private const float DIALOGUE_FLASHING_ANIMATION_DURATION = 0.5f;
private const string INFORMATION_TEXT_COLOR_HEX = "#ffff05";
@@ -68,6 +71,8 @@ namespace Pal3.GameSystem
private int _lastSelectedButtonIndex;
private readonly List<GameObject> _selectionButtons = new();
private double _totalTimeUsedBeforeSkippingTheLastDialogue;
private readonly Stopwatch _reactionTimer = new ();
private CancellationTokenSource _flashingAnimationCts = new ();
private DialogueRenderActorAvatarCommand _lastAvatarCommand;
private readonly Queue<IEnumerator> _dialogueRenderQueue = new();
@@ -240,6 +245,7 @@ namespace Pal3.GameSystem
Action onFinished = null)
{
CommandDispatcher<ICommand>.Instance.Dispatch(new DialogueRenderingStartedNotification());
_totalTimeUsedBeforeSkippingTheLastDialogue = 0f;
bool isRightAligned = true;
bool isAvatarPresented = false;
@@ -266,19 +272,28 @@ namespace Pal3.GameSystem
TextMeshProUGUI dialogueTextUI = GetRenderingTextUI(isAvatarPresented, isRightAligned);
// TODO: when trackReactionTime set to true, we should also show alert on UI
// to let player know
var timer = new Stopwatch();
timer.Start();
_dialogueBackgroundImage.enabled = true;
_dialogueCanvasGroup.alpha = 0f;
_dialogueCanvasGroup.enabled = true;
_isSkipDialogueRequested = false;
yield return StartDialogueAnimationAsync(true);
yield return PlayDialogueBackgroundPopAnimationAsync(true);
_isSkipDialogueRequested = false; // Ignore skip request during dialogue rendering animation
if (trackReactionTime) // Setup timer and start flashing animation
{
_reactionTimer.Restart();
if (!_flashingAnimationCts.IsCancellationRequested)
{
_flashingAnimationCts.Cancel();
}
_flashingAnimationCts = new CancellationTokenSource();
StartCoroutine(PlayDialogueBackgroundFlashingAnimationAsync(
duration: LIMIT_TIME_DIALOGUE_PLAYER_MAX_REACTION_TIME_IN_SECONDS,
_flashingAnimationCts.Token));
}
// Render dialogue text typing animation
foreach (var dialogue in GetSubDialoguesAsync(text))
{
IEnumerator renderDialogue = RenderDialogueTextWithAnimationAsync(dialogueTextUI, dialogue);
@@ -296,13 +311,15 @@ namespace Pal3.GameSystem
}
}
timer.Stop();
if (trackReactionTime)
if (trackReactionTime) // Stop flashing animation and timer
{
_totalTimeUsedBeforeSkippingTheLastDialogue = timer.Elapsed.TotalSeconds;
_flashingAnimationCts.Cancel();
_reactionTimer.Stop();
_totalTimeUsedBeforeSkippingTheLastDialogue = _reactionTimer.Elapsed.TotalSeconds;
Debug.LogWarning($"Reaction time: {_totalTimeUsedBeforeSkippingTheLastDialogue:0.00f}");
}
yield return StartDialogueAnimationAsync(false);
yield return PlayDialogueBackgroundPopAnimationAsync(false);
ResetUI();
@@ -311,7 +328,33 @@ namespace Pal3.GameSystem
onFinished?.Invoke();
}
private IEnumerator StartDialogueAnimationAsync(bool showDialogue)
private IEnumerator PlayDialogueBackgroundFlashingAnimationAsync(float duration, CancellationToken cancellationToken)
{
var startTime = Time.realtimeSinceStartup;
while (!cancellationToken.IsCancellationRequested)
{
yield return CoreAnimation.EnumerateValueAsync(1f, 0.2f, DIALOGUE_FLASHING_ANIMATION_DURATION / 2f,
AnimationCurveType.Linear, value =>
{
_dialogueCanvasGroup.alpha = value;
}, cancellationToken);
if (Time.realtimeSinceStartup - startTime >= duration) break;
yield return CoreAnimation.EnumerateValueAsync(0.2f, 1f, DIALOGUE_FLASHING_ANIMATION_DURATION / 2f,
AnimationCurveType.Linear, value =>
{
_dialogueCanvasGroup.alpha = value;
}, cancellationToken);
if (Time.realtimeSinceStartup - startTime >= duration) break;
}
_dialogueCanvasGroup.alpha = 1f;
}
private IEnumerator PlayDialogueBackgroundPopAnimationAsync(bool showDialogue)
{
const float yOffset = DIALOGUE_SHOW_HIDE_ANIMATION_Y_OFFSET;
Transform dialogueCanvasGroupTransform = _dialogueCanvasGroup.transform;
@@ -579,6 +622,14 @@ namespace Pal3.GameSystem
_lastAvatarCommand = null;
_totalTimeUsedBeforeSkippingTheLastDialogue = 0f;
_dialogueRenderQueue.Clear();
_reactionTimer?.Reset();
if (!_flashingAnimationCts.IsCancellationRequested)
{
_flashingAnimationCts.Cancel();
_flashingAnimationCts = new CancellationTokenSource();
}
ResetUI();
}
}
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.5.1
// version 1.6.1
// from Assets/Scripts/Pal3/Input/PlayerInputActions.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
+15 -19
View File
@@ -38,51 +38,47 @@ namespace Pal3.MetaData
private const char PathSeparator = CpkConstants.DirectorySeparator;
private static readonly string EffectScnRelativePath =
$"{FileConstants.BaseDataCpkPathInfo.cpkName}{PathSeparator}" +
$"{FileConstants.EffectScnFolderName}{PathSeparator}";
#if PAL3
public static readonly Dictionary<FireEffectType, (string TexturePathFormat, string ModelPath, float Size, float lightSourceYOffset)>
FireEffectInfo = new()
{
{FireEffectType.Type1, new (
EffectScnRelativePath + "Fire1" + PathSeparator + "torch{0:00}.tga",
FileConstants.EffectScnFolderVirtualPath + "Fire1" + PathSeparator + "torch{0:00}.tga",
"", 3.3f, 0.5f) },
{FireEffectType.Type2, new (
EffectScnRelativePath + "Fire2" + PathSeparator + "{0:00}.tga",
FileConstants.EffectScnFolderVirtualPath + "Fire2" + PathSeparator + "{0:00}.tga",
"", 1f, 0.2f) },
{FireEffectType.Type3, new (
EffectScnRelativePath + "Candle" + PathSeparator + "{0:000}.tga",
$"{EffectScnRelativePath}Candle{PathSeparator}candle.pol", 1f, 0.2f) },
FileConstants.EffectScnFolderVirtualPath + "Candle" + PathSeparator + "{0:000}.tga",
$"{FileConstants.EffectScnFolderVirtualPath}Candle{PathSeparator}candle.pol", 1f, 0.2f) },
{FireEffectType.Type4, new (
EffectScnRelativePath + "Fire4" + PathSeparator + "{0:00}.tga",
FileConstants.EffectScnFolderVirtualPath + "Fire4" + PathSeparator + "{0:00}.tga",
"", 5.8f, 0.5f) },
{FireEffectType.Type5, new (
EffectScnRelativePath + "Candle" + PathSeparator + "{0:000}.tga",
$"{EffectScnRelativePath}Lamp{PathSeparator}lamp.pol", 0.7f, 0.2f) },
FileConstants.EffectScnFolderVirtualPath + "Candle" + PathSeparator + "{0:000}.tga",
$"{FileConstants.EffectScnFolderVirtualPath}Lamp{PathSeparator}lamp.pol", 0.7f, 0.2f) },
};
#elif PAL3A
public static readonly Dictionary<FireEffectType, (string TexturePathFormat, string ModelPath, float Size, float lightSourceYOffset)>
FireEffectInfo = new()
{
{FireEffectType.Type1, new (
EffectScnRelativePath + "Fire4" + PathSeparator + "{0:00}.tga",
FileConstants.EffectScnFolderVirtualPath + "Fire4" + PathSeparator + "{0:00}.tga",
"", 5.8f, 0.5f) },
{FireEffectType.Type2, new (
EffectScnRelativePath + "Fire1" + PathSeparator + "torch{0:00}.tga",
FileConstants.EffectScnFolderVirtualPath + "Fire1" + PathSeparator + "torch{0:00}.tga",
"", 3.3f, 0.5f) },
{FireEffectType.Type3, new (
EffectScnRelativePath + "Candle" + PathSeparator + "{0:000}.tga",
$"{EffectScnRelativePath}Lamp{PathSeparator}lamp.pol", 0.7f, 0.2f) },
FileConstants.EffectScnFolderVirtualPath + "Candle" + PathSeparator + "{0:000}.tga",
$"{FileConstants.EffectScnFolderVirtualPath}Lamp{PathSeparator}lamp.pol", 0.7f, 0.2f) },
{FireEffectType.Type4, new (
EffectScnRelativePath + "Candle" + PathSeparator + "{0:000}.tga",
$"{EffectScnRelativePath}Candle{PathSeparator}candle.pol", 1f, 0.2f) },
FileConstants.EffectScnFolderVirtualPath + "Candle" + PathSeparator + "{0:000}.tga",
$"{FileConstants.EffectScnFolderVirtualPath}Candle{PathSeparator}candle.pol", 1f, 0.2f) },
{FireEffectType.Type5, new (
EffectScnRelativePath + "Fire2" + PathSeparator + "{0:00}.tga",
FileConstants.EffectScnFolderVirtualPath + "Fire2" + PathSeparator + "{0:00}.tga",
"", 1f, 0.3f) },
{FireEffectType.Type6, new (
EffectScnRelativePath + "Candle" + PathSeparator + "{0:000}.tga",
FileConstants.EffectScnFolderVirtualPath + "Candle" + PathSeparator + "{0:000}.tga",
"", 1f, 0.6f) },
};
#endif
+196 -126
View File
@@ -6,146 +6,216 @@
namespace Pal3.MetaData
{
using System.Collections.Generic;
using System.IO;
using Core.DataReader.Cpk;
using Core.DataReader.Scn;
public static class FileConstants
{
public const string SystemSceFileVirtualPath = @"basedata.cpk\init.sce";
public const string BigMapSceFileVirtualPath = @"basedata.cpk\ui\BigMap\BigMap.sce";
public const string UISceneFolderVirtualPath = @"basedata.cpk\ui\scene";
public const string ObjectFolderVirtualPath = @"basedata.cpk\object";
#if PAL3
public const string EffectScnFolderName = "EffectScn";
#elif PAL3A
public const string EffectScnFolderName = "effectscn";
#endif
public const string EffectFolderName = "effect";
public const string SfxFolderName = "snd";
#if PAL3
public const string ActorFolderName = "ROLE";
#elif PAL3A
public const string ActorFolderName = "role";
#endif
public const string UIFolderName = "ui";
public const string CombatDataFolderName = "cbdata";
public const string CaptionFolderName = "caption";
public const string EmojiFolderName = "EMOTE";
public const string CursorFolderName = "cursor";
public const string MovieFolderName = "movie";
public const string WeaponFolderName = "weapon";
public static readonly (string cpkName, string relativePath) BaseDataCpkPathInfo = new ("basedata.cpk", "basedata");
public static readonly (string cpkName, string relativePath) MusicCpkPathInfo = new ("music.cpk", "music");
public static readonly List<(string cpkName, string relativePath)> MovieCpkPathInfos = new()
{
("movie.cpk", "movie"),
("movie_end.cpk", "movie")
};
#if PAL3A
public static readonly (string cpkName, string relativePath) ScnCpkPathInfo = new ("SCN.CPK", "scene");
public static readonly (string cpkName, string relativePath) SceCpkPathInfo = new ("sce.cpk", "scene");
#if PAL3
private const string ACTOR_FOLDER_NAME = "ROLE";
#elif PAL3A
private const string ACTOR_FOLDER_NAME = "role";
#endif
#if PAL3
public static readonly List<(string cpkName, string relativePath)> SceneCpkPathInfos = new()
private const string EFFECT_SCN_FOLDER_NAME = "EffectScn";
#elif PAL3A
private const string EFFECT_SCN_FOLDER_NAME = "effectscn";
#endif
private const string SCENE_FOLDER_NAME = "scene";
private const string EFFECT_FOLDER_NAME = "effect";
private const string UI_FOLDER_NAME = "ui";
private const string BIG_MAP_FOLDER_NAME = "BigMap";
private const string OBJECT_FOLDER_NAME = "object";
private const string COMBAT_DATA_FOLDER_NAME = "cbdata";
private const string CAPTION_FOLDER_NAME = "caption";
private const string EMOJI_FOLDER_NAME = "EMOTE";
private const string CURSOR_FOLDER_NAME = "cursor";
private const string WEAPON_FOLDER_NAME = "weapon";
private const string BASE_DATA_FOLDER_NAME = "basedata";
private const string MUSIC_FOLDER_NAME = "music";
private const string BASE_DATA_CPK_FILE_NAME = "basedata.cpk";
private const string MUSIC_CPK_FILE_NAME = "music.cpk";
#if PAL3A
private const string SCN_CPK_FILE_NAME = "SCN.CPK";
private const string SCE_CPK_FILE_NAME = "sce.cpk";
#endif
public static readonly HashSet<string> MovieCpkFileNames = new()
{
("M01.cpk", "scene"),
("M02.cpk", "scene"),
("M03.cpk", "scene"),
("M04.cpk", "scene"),
("M05.cpk", "scene"),
("M06.cpk", "scene"),
("m08.cpk", "scene"),
("M09.cpk", "scene"),
("m10.cpk", "scene"),
("m11.cpk", "scene"),
("M15.cpk", "scene"),
("M16.cpk", "scene"),
("M17.cpk", "scene"),
("M18.cpk", "scene"),
("M19.cpk", "scene"),
("M20.cpk", "scene"),
("M21.cpk", "scene"),
("M22.cpk", "scene"),
("M23.cpk", "scene"),
("M24.cpk", "scene"),
("M25.cpk", "scene"),
("M26.cpk", "scene"),
("Q01.cpk", "scene"),
("Q02.cpk", "scene"),
("Q03.cpk", "scene"),
("Q04.cpk", "scene"),
("Q05.cpk", "scene"),
("Q06.cpk", "scene"),
("Q07.cpk", "scene"),
("Q08.cpk", "scene"),
("Q09.cpk", "scene"),
("Q10.cpk", "scene"),
("Q11.cpk", "scene"),
("Q12.cpk", "scene"),
("Q13.cpk", "scene"),
("Q14.cpk", "scene"),
("Q15.cpk", "scene"),
("Q16.cpk", "scene"),
("Q17.cpk", "scene"),
("T01.cpk", "scene"),
("T02.cpk", "scene"),
"movie.cpk",
"movie_end.cpk"
};
#if PAL3
public static readonly HashSet<string> SceneCpkFileNames = new ()
{
"M01.cpk", "M02.cpk", "M03.cpk", "M04.cpk", "M05.cpk", "M06.cpk", "m08.cpk", "M09.cpk",
"m10.cpk", "m11.cpk", "M15.cpk", "M16.cpk", "M17.cpk", "M18.cpk", "M19.cpk",
"M20.cpk", "M21.cpk", "M22.cpk", "M23.cpk", "M24.cpk", "M25.cpk", "M26.cpk",
"Q01.cpk", "Q02.cpk", "Q03.cpk", "Q04.cpk", "Q05.cpk", "Q06.cpk", "Q07.cpk", "Q08.cpk", "Q09.cpk",
"Q10.cpk", "Q11.cpk", "Q12.cpk", "Q13.cpk", "Q14.cpk", "Q15.cpk", "Q16.cpk", "Q17.cpk",
"T01.cpk", "T02.cpk"
};
#elif PAL3A
public static readonly List<(string cpkName, string relativePath)> SceneCpkPathInfos = new()
public static readonly HashSet<string> SceneCpkFileNames = new ()
{
("m01.cpk", "scene"),
("m02.cpk", "scene"),
("m03.cpk", "scene"),
("m04.cpk", "scene"),
("m05.cpk", "scene"),
("m06.cpk", "scene"),
("m07.cpk", "scene"),
("m08.cpk", "scene"),
("m09.cpk", "scene"),
("m10.cpk", "scene"),
("m11.cpk", "scene"),
("m12.cpk", "scene"),
("m13.cpk", "scene"),
("m14.cpk", "scene"),
("m15.cpk", "scene"),
("m16.cpk", "scene"),
("m17.cpk", "scene"),
("m18.cpk", "scene"),
("m19.cpk", "scene"),
("m20.cpk", "scene"),
("m21.cpk", "scene"),
("q01.cpk", "scene"),
("q02_01.cpk", "scene"),
("q02_02.cpk", "scene"),
("q02_03.cpk", "scene"),
("q03.cpk", "scene"),
("q04.cpk", "scene"),
("q05.cpk", "scene"),
("q06.cpk", "scene"),
("q07.cpk", "scene"),
("q08.cpk", "scene"),
("q09.cpk", "scene"),
("q10.cpk", "scene"),
("q11.cpk", "scene"),
("y01.cpk", "scene"),
"m01.cpk", "m02.cpk", "m03.cpk", "m04.cpk", "m05.cpk", "m06.cpk", "m07.cpk", "m08.cpk", "m09.cpk",
"m10.cpk", "m11.cpk", "m12.cpk", "m13.cpk", "m14.cpk", "m15.cpk", "m16.cpk", "m17.cpk", "m18.cpk", "m19.cpk",
"m20.cpk", "m21.cpk",
"q01.cpk", "q02_01.cpk", "q02_02.cpk", "q02_03.cpk", "q03.cpk", "q04.cpk", "q05.cpk", "q06.cpk", "q07.cpk", "q08.cpk", "q09.cpk",
"q10.cpk", "q11.cpk",
"y01.cpk"
};
#endif
#region Platform specific file names and paths
public static readonly string BaseDataCpkFilePath =
$"{BASE_DATA_FOLDER_NAME}{Path.DirectorySeparatorChar}{BASE_DATA_CPK_FILE_NAME}";
public static readonly string MusicCpkFilePath =
$"{MUSIC_FOLDER_NAME}{Path.DirectorySeparatorChar}{MUSIC_CPK_FILE_NAME}";
#if PAL3A
public static readonly string ScnCpkFilePath = $"{SCENE_FOLDER_NAME}{Path.DirectorySeparatorChar}{SCN_CPK_FILE_NAME}";
public static readonly string SceCpkFilePath = $"{SCENE_FOLDER_NAME}{Path.DirectorySeparatorChar}{SCE_CPK_FILE_NAME}";
#endif
public static string GetSceneCpkFilePath(string sceneCpkFileName)
{
return $"{SCENE_FOLDER_NAME}{Path.DirectorySeparatorChar}{sceneCpkFileName}";
}
#endregion
#region CPK file system virtual file names and paths
private const char CpkPathSeparator = CpkConstants.DirectorySeparator;
#if PAL3
public static readonly string GameDatabaseFileVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{COMBAT_DATA_FOLDER_NAME}{CpkPathSeparator}PAL3_Softstar.gdb";
#elif PAL3A
public static readonly string GameDatabaseFileVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{COMBAT_DATA_FOLDER_NAME}{CpkPathSeparator}PAL3A_Softstar.gdb";
#endif
public static readonly string EffectFolderVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{EFFECT_FOLDER_NAME}{CpkPathSeparator}";
public static readonly string EffectScnFolderVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{EFFECT_SCN_FOLDER_NAME}{CpkPathSeparator}";
public static readonly string SystemSceFileVirtualPath = $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}init.sce";
public static readonly string BigMapSceFileVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{UI_FOLDER_NAME}{CpkPathSeparator}{BIG_MAP_FOLDER_NAME}{CpkPathSeparator}BigMap.sce";
public static readonly string UISceneFolderVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{UI_FOLDER_NAME}{CpkPathSeparator}scene{CpkPathSeparator}";
public static readonly string[] SkyBoxTexturePathFormat =
{
EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_lf.tga",
EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_fr.tga",
EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_rt.tga",
EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_bk.tga",
EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_up.tga",
EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_dn.tga",
};
public static readonly string EmojiSpriteSheetFolderVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{UI_FOLDER_NAME}{CpkPathSeparator}{EMOJI_FOLDER_NAME}{CpkPathSeparator}";
public static readonly string CursorSpriteFolderVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{UI_FOLDER_NAME}{CpkPathSeparator}{CURSOR_FOLDER_NAME}{CpkPathSeparator}";
public static readonly string CaptionFolderVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{CAPTION_FOLDER_NAME}{CpkPathSeparator}";
public static string GetWeaponModelFileVirtualPath(string weaponName)
{
return $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}" +
$"{WEAPON_FOLDER_NAME}{CpkPathSeparator}{weaponName}{CpkPathSeparator}{weaponName}.pol";
}
public static string GetGameItemModelFileVirtualPath(string itemName)
{
return $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}item" +
$"{CpkPathSeparator}{itemName}{CpkPathSeparator}{itemName}.pol";
}
public static string GetGameObjectModelFileVirtualPath(string objectFileName)
{
return $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{OBJECT_FOLDER_NAME}" +
CpkConstants.DirectorySeparator + objectFileName;
}
public static string GetGameObjectModelFileVirtualPath(ScnSceneInfo sceneInfo, string objectName)
{
return $"{sceneInfo.CityName}{CpkConstants.FileExtension}{CpkPathSeparator}" +
$"{sceneInfo.Model}{CpkPathSeparator}{objectName}";
}
public static string GetMusicFileVirtualPath(string musicName)
{
var separator = CpkConstants.DirectorySeparator;
return $"{MUSIC_CPK_FILE_NAME}{separator}" +
$"{MUSIC_FOLDER_NAME}{separator}{musicName}.mp3";
}
public static string GetActorFolderVirtualPath(string actorName)
{
return $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}" +
$"{ACTOR_FOLDER_NAME}{CpkPathSeparator}{actorName}{CpkPathSeparator}";
}
public static string GetNavFileVirtualPath(string sceneFileName, string sceneName)
{
#if PAL3
var navFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{CpkPathSeparator}" +
$"{sceneName}{CpkPathSeparator}{sceneName}.nav";
#elif PAL3A
var navFilePath = $"{SCN_CPK_FILE_NAME}{CpkPathSeparator}SCN{CpkPathSeparator}" +
$"{sceneFileName}{CpkPathSeparator}{sceneName}{CpkPathSeparator}{sceneName}.nav";
#endif
return navFilePath;
}
public static string GetScnFileVirtualPath(string sceneFileName, string sceneName)
{
#if PAL3
var scnFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{CpkPathSeparator}{sceneName}.scn";
#elif PAL3A
var scnFilePath = $"{SCN_CPK_FILE_NAME}{CpkPathSeparator}SCN{CpkPathSeparator}" +
$"{sceneFileName}{CpkPathSeparator}{sceneFileName}_{sceneName}.scn";
#endif
return scnFilePath;
}
public static string GetSceneSceFileVirtualPath(string sceneFileName)
{
#if PAL3
var sceFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{CpkPathSeparator}{sceneFileName}.sce";
#elif PAL3A
var sceFilePath = $"{SCE_CPK_FILE_NAME}{CpkPathSeparator}Sce{CpkPathSeparator}{sceneFileName}.sce";
#endif
return sceFilePath;
}
#endregion
public static string GetActorFolderName()
{
return ACTOR_FOLDER_NAME;
}
}
}
@@ -6,26 +6,9 @@
namespace Pal3.MetaData
{
using System.Collections.Generic;
using Core.DataReader.Cpk;
public static class SceneConstants
{
private static readonly char PathSeparator = CpkConstants.DirectorySeparator;
private static readonly string EffectScnRelativePath =
$"{FileConstants.BaseDataCpkPathInfo.cpkName}{PathSeparator}" +
$"{FileConstants.EffectScnFolderName}{PathSeparator}";
public static readonly string[] SkyBoxTexturePathFormat =
{
EffectScnRelativePath + "skybox" + PathSeparator + "{0:00}" + PathSeparator + "{0:00}_lf.tga",
EffectScnRelativePath + "skybox" + PathSeparator + "{0:00}" + PathSeparator + "{0:00}_fr.tga",
EffectScnRelativePath + "skybox" + PathSeparator + "{0:00}" + PathSeparator + "{0:00}_rt.tga",
EffectScnRelativePath + "skybox" + PathSeparator + "{0:00}" + PathSeparator + "{0:00}_bk.tga",
EffectScnRelativePath + "skybox" + PathSeparator + "{0:00}" + PathSeparator + "{0:00}_up.tga",
EffectScnRelativePath + "skybox" + PathSeparator + "{0:00}" + PathSeparator + "{0:00}_dn.tga",
};
#if PAL3
public static readonly List<(string cpkName, string sceneName)> SceneCpkNameInfos = new()
{
@@ -140,10 +140,11 @@ namespace Pal3.Renderer
{
foreach (CvdMeshSection meshSection in node.Mesh.MeshSections)
{
if (string.IsNullOrEmpty(meshSection.TextureName)) continue;
if (textureCache.ContainsKey(meshSection.TextureName)) continue;
Texture2D texture2D = textureProvider.GetTexture(meshSection.TextureName);
if (texture2D != null) textureCache[meshSection.TextureName] = texture2D;
string textureName = meshSection.Material.TextureFileNames[0];
if (string.IsNullOrEmpty(textureName)) continue;
if (textureCache.ContainsKey(textureName)) continue;
Texture2D texture2D = textureProvider.GetTexture(textureName);
if (texture2D != null) textureCache[textureName] = texture2D;
}
}
@@ -232,8 +233,9 @@ namespace Pal3.Renderer
influence,
frameMatrix);
if (string.IsNullOrEmpty(meshSection.TextureName) ||
!textureCache.ContainsKey(meshSection.TextureName)) continue;
string textureName = meshSection.Material.TextureFileNames[0];
if (string.IsNullOrEmpty(textureName) || !textureCache.ContainsKey(textureName)) continue;
var meshSectionObject = new GameObject($"{sectionHashKey}");
@@ -242,12 +244,11 @@ namespace Pal3.Renderer
var materialInfoPresenter = meshObject.AddComponent<MaterialInfoPresenter>();
materialInfoPresenter.blendFlag = meshSection.BlendFlag;
materialInfoPresenter.material = meshSection.Material;
materialInfoPresenter.textureNames = new[] {meshSection.TextureName};
#endif
Material[] materials = materialFactory.CreateStandardMaterials(
RendererType.Cvd,
(meshSection.TextureName, textureCache[meshSection.TextureName]),
(textureName, textureCache[textureName]),
shadowTexture: (null, null), // CVD models don't have shadow textures
_tintColor,
meshSection.BlendFlag);
@@ -403,7 +404,7 @@ namespace Pal3.Renderer
_animationCts = new CancellationTokenSource();
yield return PlayAnimationInternal(timeScale,
yield return PlayAnimationInternalAsync(timeScale,
_animationDuration * durationPercentage,
loopCount,
startFromBeginning,
@@ -411,7 +412,7 @@ namespace Pal3.Renderer
_animationCts.Token);
}
private IEnumerator PlayAnimationInternal(float timeScale,
private IEnumerator PlayAnimationInternalAsync(float timeScale,
float duration,
int loopCount,
bool startFromBeginning,
@@ -422,21 +423,21 @@ namespace Pal3.Renderer
{
while (!cancellationToken.IsCancellationRequested)
{
yield return PlayOneTimeAnimationInternal(timeScale, duration, startFromBeginning, cancellationToken);
yield return PlayOneTimeAnimationInternalAsync(timeScale, duration, startFromBeginning, cancellationToken);
}
}
else if (loopCount > 0)
{
while (!cancellationToken.IsCancellationRequested && --loopCount >= 0)
{
yield return PlayOneTimeAnimationInternal(timeScale, duration, startFromBeginning, cancellationToken);
yield return PlayOneTimeAnimationInternalAsync(timeScale, duration, startFromBeginning, cancellationToken);
}
}
onFinished?.Invoke();
}
private IEnumerator PlayOneTimeAnimationInternal(float timeScale,
private IEnumerator PlayOneTimeAnimationInternalAsync(float timeScale,
float duration,
bool startFromBeginning,
CancellationToken cancellationToken)
@@ -528,7 +529,7 @@ namespace Pal3.Renderer
CvdAnimationScaleKeyFrame fromKeyFrame = nodeScaleInfo[startIndex];
CvdAnimationScaleKeyFrame toKeyFrame = nodeScaleInfo[endIndex];
float influence = (time - fromKeyFrame.Time) / (toKeyFrame.Time - fromKeyFrame.Time);
Quaternion calculatedRotation = Quaternion.Lerp(fromKeyFrame.Rotation, toKeyFrame.Rotation, influence);
Quaternion calculatedRotation = Quaternion.Slerp(fromKeyFrame.Rotation, toKeyFrame.Rotation, influence);
Vector3 calculatedScale = Vector3.Lerp(fromKeyFrame.Scale, toKeyFrame.Scale, influence);
return (calculatedScale, calculatedRotation);
}
@@ -558,7 +559,7 @@ namespace Pal3.Renderer
CvdAnimationRotationKeyFrame fromKeyFrame = nodeRotationInfo[startIndex];
CvdAnimationRotationKeyFrame toKeyFrame = nodeRotationInfo[endIndex];
float influence = (time - fromKeyFrame.Time) / (toKeyFrame.Time - fromKeyFrame.Time);
return Quaternion.Lerp(fromKeyFrame.Rotation, toKeyFrame.Rotation, influence);
return Quaternion.Slerp(fromKeyFrame.Rotation, toKeyFrame.Rotation, influence);
}
public void StopCurrentAnimation()
@@ -26,7 +26,6 @@ namespace Pal3.Renderer
private const string MV3_ANIMATION_HOLD_EVENT_NAME = "hold";
private const string MV3_MODEL_DEFAULT_TEXTURE_EXTENSION = ".tga";
private const float TIME_TO_TICK_SCALE = 5000f;
private ITextureResourceProvider _textureProvider;
private IMaterialFactory _materialFactory;
@@ -104,7 +103,7 @@ namespace Pal3.Renderer
{
Mv3Mesh mesh = mv3File.Meshes[i];
var materialId = mesh.Attributes[0].MaterialId;
Mv3Material material = mv3File.Materials[materialId];
GameBoxMaterial material = mv3File.Materials[materialId];
InitSubMeshes(i, ref mesh, ref material);
}
@@ -137,11 +136,11 @@ namespace Pal3.Renderer
private void InitSubMeshes(int index,
ref Mv3Mesh mv3Mesh,
ref Mv3Material material)
ref GameBoxMaterial material)
{
var textureName = material.TextureNames[0];
var textureName = material.TextureFileNames[0];
_gbMaterials[index] = material.Material;
_gbMaterials[index] = material;
_textures[index] = _textureProvider.GetTexture(textureName, out var hasAlphaChannel);
_textureHasAlphaChannel[index]= hasAlphaChannel;
_animationName[index] = mv3Mesh.Name;
@@ -166,7 +165,6 @@ namespace Pal3.Renderer
GameBoxBlendFlag.AlphaBlend :
GameBoxBlendFlag.Opaque;
materialInfoPresenter.material = _gbMaterials[index];
materialInfoPresenter.textureNames = material.TextureNames;
#endif
var meshRenderer = _meshObjects[index].AddComponent<StaticMeshRenderer>();
@@ -219,7 +217,7 @@ namespace Pal3.Renderer
{
if (_renderMeshComponents == null)
{
throw new Exception("Animation not initialized.");
throw new Exception("Animation model not initialized.");
}
PauseAnimation();
@@ -406,8 +404,7 @@ namespace Pal3.Renderer
while (!cancellationToken.IsCancellationRequested)
{
var tick = ((Time.timeSinceLevelLoad - startTime) * TIME_TO_TICK_SCALE
+ startTick);
uint tick = GameBoxInterpreter.SecondsToTick(Time.timeSinceLevelLoad - startTime) + startTick;
if (tick >= endTick)
{
@@ -421,12 +418,12 @@ namespace Pal3.Renderer
var frameTicks = _frameTicks[i];
var currentFrameIndex = Utility.GetFloorIndex(frameTicks, (uint) tick);
var currentFrameIndex = Utility.GetFloorIndex(frameTicks, tick);
var currentFrameTick = _frameTicks[i][currentFrameIndex];
var nextFrameIndex = currentFrameIndex < frameTicks.Length - 1 ? currentFrameIndex + 1 : 0;
var nextFrameTick = nextFrameIndex == 0 ? endTick : _frameTicks[i][nextFrameIndex];
var influence = (tick - currentFrameTick) / (nextFrameTick - currentFrameTick);
var influence = (float)(tick - currentFrameTick) / (nextFrameTick - currentFrameTick);
var vertices = meshComponent.MeshDataBuffer.VertexBuffer;
for (var j = 0; j < vertices.Length; j++)
@@ -452,11 +449,11 @@ namespace Pal3.Renderer
var nextFrameIndex = currentFrameIndex < frameTicks.Length - 1 ? currentFrameIndex + 1 : 0;
var nextFrameTick = nextFrameIndex == 0 ? endTick : _tagNodeFrameTicks[i][nextFrameIndex];
var influence = (tick - currentFrameTick) / (nextFrameTick - currentFrameTick);
var influence = (float)(tick - currentFrameTick) / (nextFrameTick - currentFrameTick);
Vector3 position = Vector3.Lerp(_tagNodesInfo[i].TagFrames[currentFrameIndex].Position,
_tagNodesInfo[i].TagFrames[nextFrameIndex].Position, influence);
Quaternion rotation = Quaternion.Lerp(_tagNodesInfo[i].TagFrames[currentFrameIndex].Rotation,
Quaternion rotation = Quaternion.Slerp(_tagNodesInfo[i].TagFrames[currentFrameIndex].Rotation,
_tagNodesInfo[i].TagFrames[nextFrameIndex].Rotation, influence);
_tagNodes[i].transform.localPosition = position;
@@ -95,7 +95,7 @@ namespace Pal3.Renderer
{
foreach (PolTexture texture in mesh.Textures)
{
foreach (var textureName in texture.TextureNames)
foreach (var textureName in texture.Material.TextureFileNames)
{
if (string.IsNullOrEmpty(textureName)) continue;
if (textureCache.ContainsKey(textureName)) continue;
@@ -128,7 +128,7 @@ namespace Pal3.Renderer
for (var i = 0; i < mesh.Textures.Length; i++)
{
var textures = new List<(string name, Texture2D texture)>();
foreach (var textureName in mesh.Textures[i].TextureNames)
foreach (var textureName in mesh.Textures[i].Material.TextureFileNames)
{
if (string.IsNullOrEmpty(textureName))
{
@@ -155,7 +155,6 @@ namespace Pal3.Renderer
var materialInfoPresenter = meshObject.AddComponent<MaterialInfoPresenter>();
materialInfoPresenter.blendFlag = mesh.Textures[i].BlendFlag;
materialInfoPresenter.material = mesh.Textures[i].Material;
materialInfoPresenter.textureNames = mesh.Textures[i].TextureNames;
#endif
var meshRenderer = meshObject.AddComponent<StaticMeshRenderer>();
+1 -1
View File
@@ -10,6 +10,6 @@ namespace Pal3.Renderer
Cvd,
Pol,
Mv3,
Mov,
Msh,
}
}
@@ -0,0 +1,486 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Renderer
{
using System;
using System.Collections;
using Core.DataReader.Msh;
using Core.DataReader.Mov;
using UnityEngine;
using System.Collections.Generic;
using System.Threading;
using Core.DataLoader;
using Core.DataReader.Mtl;
using Core.GameBox;
using Core.Renderer;
using Core.Utils;
internal class Bone
{
public string Name { get; }
public GameObject GameObject { get; }
public BoneNode BoneNode { get; }
public Matrix4x4 BindPoseModelToBoneSpace { get; set; }
public Matrix4x4 CurrentPoseToModelMatrix { get; set; }
public MovBoneAnimationTrack? AnimationTrack { get; private set; }
public uint[] FrameTicks { get; private set; }
public Bone(string name, GameObject gameObject, BoneNode boneNode)
{
Name = name;
GameObject = gameObject;
BoneNode = boneNode;
BindPoseModelToBoneSpace = Matrix4x4.identity;
CurrentPoseToModelMatrix = Matrix4x4.identity;
}
public bool IsRoot()
{
return BoneNode.ParentId == -1;
}
public void SetAnimationTrack(MovBoneAnimationTrack track)
{
AnimationTrack = track;
FrameTicks = new uint[track.KeyFrames.Length];
for (var i = 0; i < track.KeyFrames.Length; i++)
{
FrameTicks[i] = track.KeyFrames[i].Tick;
}
}
public void DisposeAnimationTrack()
{
AnimationTrack = null;
FrameTicks = null;
CurrentPoseToModelMatrix = Matrix4x4.identity;
}
}
/// <summary>
/// Skeletal animation model renderer
/// MSH(.msh) + MOV(.mov)
/// </summary>
public class SkeletalModelRenderer : MonoBehaviour, IDisposable
{
private IMaterialFactory _materialFactory;
private Material[][] _materials;
private MshFile _mshFile;
private MovFile _movFile;
private (string textureName, Texture2D texture) _mainTexture;
private Texture2D _texture;
private Color _tintColor;
private readonly Dictionary<int, Bone> _bones = new ();
private GameObject _rootBoneObject;
private GameObject[] _meshObjects;
private RenderMeshComponent[] _renderMeshComponents;
private Coroutine _animation;
private CancellationTokenSource _animationCts;
private readonly Dictionary<int, List<int>> _indexBuffer = new();
private readonly Dictionary<int, Vector3[]> _vertexBuffer = new();
public void Init(MshFile mshFile,
MtlFile mtlFile,
IMaterialFactory materialFactory,
ITextureResourceProvider textureProvider,
Color? tintColor = default)
{
Dispose();
_mshFile = mshFile;
_materialFactory = materialFactory;
_tintColor = tintColor ?? Color.white;
// All .mtl files in PAL3 contain only one material,
// and there is only one texture in the material
// so we only need to load the first texture from the
// first material to use as the main texture for the whole model
string textureName = mtlFile.Materials[0].TextureFileNames[0];
_mainTexture = (mtlFile.Materials[0].TextureFileNames[0], textureProvider.GetTexture(textureName));
SetupBone(_mshFile.RootBoneNode, parentBone: null);
RenderMesh();
}
public void StartAnimation(MovFile movFile, int loopCount = -1)
{
if (_renderMeshComponents == null)
{
throw new Exception("Animation model not initialized.");
}
PauseAnimation();
SetupAnimationTrack(movFile);
_animationCts = new CancellationTokenSource();
_animation = StartCoroutine(PlayAnimationInternalAsync(loopCount,
_animationCts.Token));
}
public void PauseAnimation()
{
if (_animation != null)
{
_animationCts.Cancel();
StopCoroutine(_animation);
_animation = null;
}
}
private void SetupAnimationTrack(MovFile movFile)
{
// Reset all existing bone animation tracks
foreach (Bone bone in _bones.Values)
{
bone.DisposeAnimationTrack();
}
_movFile = movFile;
// Bind animation tracks from mov file
foreach (MovBoneAnimationTrack track in _movFile.BoneAnimationTracks)
{
if (_bones.TryGetValue(track.BoneId, out Bone bonne))
{
bonne.SetAnimationTrack(track);
}
}
}
private IEnumerator PlayAnimationInternalAsync(int loopCount,
CancellationToken cancellationToken)
{
if (loopCount == -1) // Infinite loop until cancelled
{
while (!cancellationToken.IsCancellationRequested)
{
yield return PlayOneTimeAnimationInternalAsync(cancellationToken);
}
}
else if (loopCount > 0)
{
while (!cancellationToken.IsCancellationRequested && --loopCount >= 0)
{
yield return PlayOneTimeAnimationInternalAsync(cancellationToken);
}
}
}
private IEnumerator PlayOneTimeAnimationInternalAsync(CancellationToken cancellationToken)
{
var startTime = Time.timeSinceLevelLoad;
while (!cancellationToken.IsCancellationRequested)
{
uint tick = GameBoxInterpreter.SecondsToTick(Time.timeSinceLevelLoad - startTime);
if (tick >= _movFile.Duration)
{
yield break;
}
UpdateBone(_bones[0], tick);
UpdateSkinning();
yield return null;
}
}
private void UpdateBone(Bone bone, uint tick)
{
GameObject boneGo = bone.GameObject;
MovBoneAnimationTrack? track = bone.AnimationTrack;
BoneNode boneNode = bone.BoneNode;
if (track != null)
{
int currentFrameIndex = Utility.GetFloorIndex(bone.FrameTicks, tick);
uint currentFrameTick = bone.FrameTicks[currentFrameIndex];
var nextFrameIndex = currentFrameIndex < bone.FrameTicks.Length - 1 ? currentFrameIndex + 1 : 0;
uint nextFrameTick = nextFrameIndex == 0 ? _movFile.Duration : bone.FrameTicks[nextFrameIndex];
var influence = (float)(tick - currentFrameTick) / (nextFrameTick - currentFrameTick);
Vector3 localPosition = Vector3.Lerp(
track.Value.KeyFrames[currentFrameIndex].Translation,
track.Value.KeyFrames[nextFrameIndex].Translation,
influence);
Quaternion localRotation = Quaternion.Slerp(
track.Value.KeyFrames[currentFrameIndex].Rotation,
track.Value.KeyFrames[nextFrameIndex].Rotation,
influence);
boneGo.transform.localPosition = localPosition;
boneGo.transform.localRotation = localRotation;
Matrix4x4 curPoseToModelMatrix = Matrix4x4.Translate(localPosition) * Matrix4x4.Rotate(localRotation);
if (!bone.IsRoot())
{
curPoseToModelMatrix = _bones[boneNode.ParentId].CurrentPoseToModelMatrix * curPoseToModelMatrix;
}
bone.CurrentPoseToModelMatrix = curPoseToModelMatrix;
}
// Update children
for (var i = 0; i < boneNode.Children.Length; i++)
{
Bone childBone = _bones[boneNode.Children[i].Id];
UpdateBone(childBone, tick);
}
}
private void UpdateSkinning()
{
for (int subMeshIndex = 0; subMeshIndex < _renderMeshComponents.Length; subMeshIndex++)
{
MshMesh subMesh = _mshFile.SubMeshes[subMeshIndex];
Mesh mesh = _renderMeshComponents[subMeshIndex].Mesh;
mesh.SetVertices(BuildVerticesWithCurrentSkeleton(subMesh, subMeshIndex));
mesh.RecalculateBounds();
}
}
private void SetupBone(BoneNode boneNode, Bone parentBone)
{
GameObject boneGo = new GameObject($"{boneNode.Id}_{boneNode.Name}_{boneNode.Type}");
boneGo.transform.SetParent(parentBone == null ? gameObject.transform : parentBone.GameObject.transform);
boneGo.transform.localPosition = boneNode.Translation;
boneGo.transform.localRotation = boneNode.Rotation;
Bone bone = new (boneNode.Name, boneGo, boneNode);
if (parentBone == null)
{
_rootBoneObject = boneGo;
}
else
{
_bones.Add(boneNode.Id, bone);
Matrix4x4 translationMatrix = Matrix4x4.Translate(boneNode.Translation);
Matrix4x4 rotationMatrix = Matrix4x4.Rotate(boneNode.Rotation);
bone.BindPoseModelToBoneSpace = Matrix4x4.Inverse(rotationMatrix)
* Matrix4x4.Inverse(translationMatrix)
* parentBone.BindPoseModelToBoneSpace;
}
// Render child bones
foreach (BoneNode subBone in boneNode.Children)
{
SetupBone(subBone, bone);
}
}
private void RenderMesh()
{
if (_mshFile.SubMeshes.Length == 0) return;
_renderMeshComponents = new RenderMeshComponent[_mshFile.SubMeshes.Length];
_meshObjects = new GameObject[_mshFile.SubMeshes.Length];
for (var i = 0; i < _mshFile.SubMeshes.Length; i++)
{
MshMesh subMesh = _mshFile.SubMeshes[i];
RenderSubMesh(subMesh, i);
}
}
private void RenderSubMesh(MshMesh subMesh, int subMeshIndex)
{
_meshObjects[subMeshIndex] = new GameObject($"SubMesh_{subMeshIndex}");
_meshObjects[subMeshIndex].transform.SetParent(gameObject.transform, false);
List<Vector3> vertices = new List<Vector3>();
List<int> triangles = new List<int>();
Vector3[] normals = null;
List<Vector2> uvs = new List<Vector2>();
_indexBuffer[subMeshIndex] = new List<int>();
_vertexBuffer[subMeshIndex] = new Vector3[subMesh.Vertices.Length];
var index = 0;
foreach (PhyFace phyFace in subMesh.Faces)
{
for (var i = 0; i < phyFace.Indices.Length; i++)
{
_indexBuffer[subMeshIndex].Add(phyFace.Indices[i]);
uvs.Add(new Vector2(phyFace.U[i, 0], phyFace.V[i, 0]));
triangles.Add(index++);
}
}
GameBoxInterpreter.ToUnityTriangles(triangles);
for (var i = 0; i < _indexBuffer[subMeshIndex].Count; i++)
{
vertices.Add(subMesh.Vertices[_indexBuffer[subMeshIndex][i]].Position);
}
Material[] materials = _materialFactory.CreateStandardMaterials(
RendererType.Msh,
_mainTexture,
default,
_tintColor,
GameBoxBlendFlag.Opaque);
Vector3[] verts = vertices.ToArray();
int[] tris = triangles.ToArray();
Vector2[] uvs1 = uvs.ToArray();
Vector2[] uvs2 = null;
var meshRenderer = _meshObjects[subMeshIndex].AddComponent<StaticMeshRenderer>();
Mesh renderMesh = meshRenderer.Render(
ref verts,
ref tris,
ref normals,
ref uvs1,
ref uvs2,
ref materials,
true);
renderMesh.RecalculateNormals();
renderMesh.RecalculateTangents();
renderMesh.RecalculateBounds();
_renderMeshComponents[subMeshIndex] = new RenderMeshComponent
{
Mesh = renderMesh,
MeshRenderer = meshRenderer,
MeshDataBuffer = new MeshDataBuffer()
{
VertexBuffer = verts
}
};
}
private Vector3[] BuildVerticesWithCurrentSkeleton(MshMesh subMesh, int subMeshIndex)
{
for (var i = 0; i < subMesh.Vertices.Length; i++)
{
PhyVertex vert = subMesh.Vertices[i];
int boneId = vert.BoneIds[0];
Bone bone = _bones[boneId];
Vector4 originalPosition = new Vector4(vert.Position.x, vert.Position.y, vert.Position.z, 1.0f);
Vector4 currentPosition = bone.CurrentPoseToModelMatrix * bone.BindPoseModelToBoneSpace * originalPosition;
_vertexBuffer[subMeshIndex][i] = new Vector3(
currentPosition.x / currentPosition.w,
currentPosition.y / currentPosition.w,
currentPosition.z / currentPosition.w);
}
Vector3[] vertices = _renderMeshComponents[subMeshIndex].Mesh.vertices;
for (var i = 0; i < _indexBuffer[subMeshIndex].Count; i++)
{
vertices[i] = _vertexBuffer[subMeshIndex][_indexBuffer[subMeshIndex][i]];
}
return vertices;
}
public Bounds GetRendererBounds()
{
if (_renderMeshComponents.Length == 0)
{
return new Bounds(transform.position, Vector3.one);
}
Bounds bounds = _renderMeshComponents[0].MeshRenderer.GetRendererBounds();
for (var i = 1; i < _renderMeshComponents.Length; i++)
{
bounds.Encapsulate(_renderMeshComponents[i].MeshRenderer.GetRendererBounds());
}
return bounds;
}
public Bounds GetMeshBounds()
{
if (_renderMeshComponents.Length == 0)
{
return new Bounds(Vector3.zero, Vector3.one);
}
Bounds bounds = _renderMeshComponents[0].MeshRenderer.GetMeshBounds();
for (var i = 1; i < _renderMeshComponents.Length; i++)
{
bounds.Encapsulate(_renderMeshComponents[i].MeshRenderer.GetMeshBounds());
}
return bounds;
}
public bool IsVisible()
{
return _meshObjects != null;
}
private void OnDisable()
{
Dispose();
}
public void Dispose()
{
PauseAnimation();
if (_renderMeshComponents != null)
{
foreach (RenderMeshComponent renderMeshComponent in _renderMeshComponents)
{
Destroy(renderMeshComponent.Mesh);
Destroy(renderMeshComponent.MeshRenderer);
}
_renderMeshComponents = null;
}
if (_meshObjects != null)
{
foreach (GameObject meshObject in _meshObjects)
{
Destroy(meshObject);
}
_meshObjects = null;
}
if (_bones != null)
{
foreach (Bone bone in _bones.Values)
{
Destroy(bone.GameObject);
}
_bones.Clear();
}
if (_rootBoneObject != null)
{
Destroy(_rootBoneObject);
_rootBoneObject = null;
}
_indexBuffer.Clear();
_vertexBuffer.Clear();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ebe885a4d2b24f37a437c3c479c9291c
timeCreated: 1690401815
+2 -2
View File
@@ -110,13 +110,13 @@ namespace Pal3.Scene
// information to be used for lighting, so we are not using it for now.
// if (_resourceProvider.FileExists(sceneMetadataFilePrefix + ".lgt"))
// {
// LgtFile = _resourceProvider.GetLgt(sceneMetadataFilePrefix + ".lgt");
// LgtFile = _resourceProvider.GetGameResourceFile<LgtFile>(sceneMetadataFilePrefix + ".lgt");
// }
}
private void InitNavData()
{
NavFile = _resourceProvider.GetNav(ScnFile.SceneInfo.CityName, ScnFile.SceneInfo.Model);
NavFile = _resourceProvider.GetNavFile(ScnFile.SceneInfo.CityName, ScnFile.SceneInfo.Model);
Tilemap = new Tilemap(NavFile);
}
+8 -3
View File
@@ -76,7 +76,7 @@ namespace Pal3.Scene
timer.Start();
DisposeCurrentScene();
ScnFile scnFile = _resourceProvider.GetScn(sceneFileName, sceneName);
ScnFile scnFile = _resourceProvider.GetScnFile(sceneFileName, sceneName);
CommandDispatcher<ICommand>.Instance.Dispatch(new ScenePreLoadingNotification(scnFile.SceneInfo));
Debug.Log("Loading scene: " + JsonConvert.SerializeObject(scnFile.SceneInfo));
@@ -95,7 +95,7 @@ namespace Pal3.Scene
_sceneObjectIdsToNotLoadFromSaveState.Clear();
// Add scene script if exists.
SceFile sceFile = _resourceProvider.GetSceneSce(sceneFileName);
SceFile sceFile = _resourceProvider.GetSceneSceFile(sceneFileName);
CommandDispatcher<ICommand>.Instance.Dispatch(
_scriptManager.TryAddSceneScript(sceFile, $"_{sceneFileName}_{sceneName}", out var sceneScriptId)
? new ScenePostLoadingNotification(scnFile.SceneInfo, sceneScriptId)
@@ -113,9 +113,14 @@ namespace Pal3.Scene
{
CommandDispatcher<ICommand>.Instance.Dispatch(new SceneLeavingCurrentSceneNotification());
Object.Destroy(_currentScene);
Object.Destroy(_currentSceneRoot);
_currentScene = null;
}
if (_currentSceneRoot != null)
{
Object.Destroy(_currentSceneRoot);
_currentSceneRoot = null;
}
}
public void Execute(SceneLoadCommand command)
@@ -103,6 +103,7 @@ namespace Pal3.Scene.SceneObjects
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}
base.Deactivate();
@@ -28,8 +28,8 @@ namespace Pal3.Scene.SceneObjects
private readonly PlayerGamePlayController _playerGamePlayController;
private readonly string _interactionIndicatorModelPath = FileConstants.ObjectFolderVirtualPath +
CpkConstants.DirectorySeparator + "g02.cvd";
private const string INTERACTION_INDICATOR_MODEL_FILE_NAME = "g02.cvd";
private CvdModelRenderer _upperInteractionIndicatorRenderer;
private CvdModelRenderer _lowerInteractionIndicatorRenderer;
private GameObject _upperInteractionIndicatorGameObject;
@@ -59,9 +59,10 @@ namespace Pal3.Scene.SceneObjects
IMaterialFactory materialFactory = resourceProvider.GetMaterialFactory();
CvdFile indicatorCvdFile = resourceProvider.GetGameResourceFile<CvdFile>(_interactionIndicatorModelPath);
string indicatorModelPath = FileConstants.GetGameObjectModelFileVirtualPath(INTERACTION_INDICATOR_MODEL_FILE_NAME);
CvdFile indicatorCvdFile = resourceProvider.GetGameResourceFile<CvdFile>(indicatorModelPath);
ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(_interactionIndicatorModelPath));
Utility.GetRelativeDirectoryPath(indicatorModelPath));
// Upper indicator
{
@@ -112,11 +112,13 @@ namespace Pal3.Scene.SceneObjects
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
_triggerController.OnPlayerActorExited -= OnPlayerActorExited;
Object.Destroy(_triggerController);
_triggerController = null;
}
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
@@ -43,6 +43,7 @@ namespace Pal3.Scene.SceneObjects.Common
if (_collider != null)
{
Destroy(_collider);
_collider = null;
}
}
@@ -69,6 +69,7 @@ namespace Pal3.Scene.SceneObjects.Common
if (_collider != null)
{
Destroy(_collider);
_collider = null;
}
}
}
@@ -80,6 +80,7 @@ namespace Pal3.Scene.SceneObjects.Common
if (_collider != null)
{
Destroy(_collider);
_collider = null;
}
}
}
@@ -42,13 +42,13 @@ namespace Pal3.Scene.SceneObjects
state.SwitchState == 1)
{
isFlowerInOpenState = false;
ModelFilePath = ModelFilePath.Replace("1.pol", "2.pol",
ModelFileVirtualPath = ModelFileVirtualPath.Replace("1.pol", "2.pol",
StringComparison.OrdinalIgnoreCase);
}
else
{
isFlowerInOpenState = true;
ModelFilePath = ModelFilePath.Replace("2.pol", "1.pol",
ModelFileVirtualPath = ModelFileVirtualPath.Replace("2.pol", "1.pol",
StringComparison.OrdinalIgnoreCase);
}
@@ -75,6 +75,7 @@ namespace Pal3.Scene.SceneObjects
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}
base.Deactivate();
@@ -149,6 +149,7 @@ namespace Pal3.Scene.SceneObjects
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
_platformController.OnPlayerActorExited -= OnPlayerActorExited;
Object.Destroy(_platformController);
_platformController = null;
}
base.Deactivate();
@@ -55,6 +55,7 @@ namespace Pal3.Scene.SceneObjects
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
@@ -100,6 +100,7 @@ namespace Pal3.Scene.SceneObjects
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}
base.Deactivate();
@@ -120,6 +120,7 @@ namespace Pal3.Scene.SceneObjects
{
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_platformController);
_platformController = null;
}
base.Deactivate();
@@ -89,12 +89,14 @@ namespace Pal3.Scene.SceneObjects
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
if (_triggerController != null)
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}
base.Deactivate();
@@ -80,6 +80,7 @@ namespace Pal3.Scene.SceneObjects
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
@@ -117,6 +117,7 @@ namespace Pal3.Scene.SceneObjects
{
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_platformController);
_platformController = null;
}
base.Deactivate();
@@ -49,7 +49,7 @@ namespace Pal3.Scene.SceneObjects
#if PAL3
// Fix the color(texture) issue of impulsive mechanism in M11-2 which uses _r.pol as the main model
if (string.Equals(ModelFilePath, @"M11.cpk\2\_r.pol", StringComparison.OrdinalIgnoreCase))
if (string.Equals(ModelFileVirtualPath, @"M11.cpk\2\_r.pol", StringComparison.OrdinalIgnoreCase))
{
tintColor = new Color(0.9f, 0.45f, 0f, 0.1f);
}
@@ -59,7 +59,7 @@ namespace Pal3.Scene.SceneObjects
_subObjectGameObject = new GameObject($"Object_{ObjectInfo.Id}_{ObjectInfo.Type}_SubObject");
var subObjectModelPath = ModelFilePath.Insert(ModelFilePath.LastIndexOf('.'), "a");
var subObjectModelPath = ModelFileVirtualPath.Insert(ModelFileVirtualPath.LastIndexOf('.'), "a");
PolFile polFile = resourceProvider.GetGameResourceFile<PolFile>(subObjectModelPath);
ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(subObjectModelPath));
@@ -56,6 +56,7 @@ namespace Pal3.Scene.SceneObjects
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
_triggerController.OnPlayerActorExited -= OnPlayerActorExited;
Object.Destroy(_triggerController);
_triggerController = null;
}
base.Deactivate();
@@ -168,11 +168,13 @@ namespace Pal3.Scene.SceneObjects
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
@@ -225,6 +225,7 @@ namespace Pal3.Scene.SceneObjects
{
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_platformController);
_platformController = null;
}
base.Deactivate();
@@ -92,6 +92,7 @@ namespace Pal3.Scene.SceneObjects
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}
base.Deactivate();
@@ -130,6 +130,7 @@ namespace Pal3.Scene.SceneObjects
{
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_platformController);
_platformController = null;
}
base.Deactivate();
@@ -114,6 +114,7 @@ namespace Pal3.Scene.SceneObjects
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}
base.Deactivate();
@@ -391,6 +391,7 @@ namespace Pal3.Scene.SceneObjects
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}
if (_standingPlatformController != null)
@@ -75,6 +75,7 @@ namespace Pal3.Scene.SceneObjects
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
@@ -57,6 +57,7 @@ namespace Pal3.Scene.SceneObjects
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
@@ -130,11 +130,13 @@ namespace Pal3.Scene.SceneObjects
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
@@ -91,6 +91,7 @@ namespace Pal3.Scene.SceneObjects
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}
base.Deactivate();
@@ -41,11 +41,11 @@ namespace Pal3.Scene.SceneObjects
_meshCollider.Init(new Vector3(-1f, 0f, 0f));
// Add sub-component to the main object.
if (ModelFilePath.EndsWith("1.pol"))
if (ModelFileVirtualPath.EndsWith("1.pol"))
{
_subObjectGameObject = new GameObject($"Object_{ObjectInfo.Id}_{ObjectInfo.Type}_SubObject");
var subObjectModelPath = ModelFilePath.Replace("1.pol", "2.pol");
var subObjectModelPath = ModelFileVirtualPath.Replace("1.pol", "2.pol");
PolFile polFile = resourceProvider.GetGameResourceFile<PolFile>(subObjectModelPath);
ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(subObjectModelPath));
@@ -83,16 +83,19 @@ namespace Pal3.Scene.SceneObjects
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
if (_subObjectMeshCollider != null)
{
Object.Destroy(_subObjectMeshCollider);
_subObjectMeshCollider = null;
}
if (_subObjectGameObject != null)
{
Object.Destroy(_subObjectGameObject);
_subObjectGameObject = null;
}
base.Deactivate();
@@ -15,12 +15,10 @@ namespace Pal3.Scene.SceneObjects
using Command.SceCommands;
using Core.Animation;
using Core.DataLoader;
using Core.DataReader.Cpk;
using Core.DataReader.Cvd;
using Core.DataReader.Pol;
using Core.DataReader.Scn;
using Core.GameBox;
using Core.Services;
using Core.Utils;
using Data;
using Dev;
@@ -52,7 +50,7 @@ namespace Pal3.Scene.SceneObjects
public SceneObjectModelType ModelType { get; }
internal bool Activated;
internal string ModelFilePath;
internal string ModelFileVirtualPath;
private IEffect _effectComponent;
private GameObject _sceneObjectGameObject;
@@ -65,10 +63,10 @@ namespace Pal3.Scene.SceneObjects
ObjectInfo = objectInfo;
SceneInfo = sceneInfo;
ModelFilePath = hasModel && !string.IsNullOrEmpty(objectInfo.Name) ?
ModelFileVirtualPath = hasModel && !string.IsNullOrEmpty(objectInfo.Name) ?
GetModelFilePath(objectInfo, sceneInfo) : string.Empty;
ModelType = SceneObjectModelTypeResolver.GetType(Path.GetFileName(ModelFilePath));
ModelType = SceneObjectModelTypeResolver.GetType(Path.GetFileName(ModelFileVirtualPath));
GraphicsEffect = GetEffectType(objectInfo);
}
@@ -87,27 +85,23 @@ namespace Pal3.Scene.SceneObjects
private string GetModelFilePath(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
{
var separator = CpkConstants.DirectorySeparator;
var modelFilePath = string.Empty;
if (objectInfo.Name.StartsWith('_'))
if (objectInfo.Name.StartsWith('_')) // is object model in current scene folder
{
modelFilePath = $"{sceneInfo.CityName}{CpkConstants.FileExtension}{separator}" +
$"{sceneInfo.Model}{separator}{objectInfo.Name}";
modelFilePath = FileConstants.GetGameObjectModelFileVirtualPath(sceneInfo, objectInfo.Name);
}
else if (objectInfo.Name.StartsWith('+'))
{
// Special vfx effect.
}
else if (!objectInfo.Name.Contains('.'))
else if (!objectInfo.Name.Contains('.')) // is item name
{
modelFilePath = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}item" +
$"{separator}{objectInfo.Name}{separator}{objectInfo.Name}.pol";
modelFilePath = FileConstants.GetGameItemModelFileVirtualPath(objectInfo.Name);
}
else
else // is object model in game object folder
{
modelFilePath = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}object" +
$"{separator}{objectInfo.Name}";
modelFilePath = FileConstants.GetGameObjectModelFileVirtualPath(objectInfo.Name);
}
return modelFilePath;
@@ -130,9 +124,9 @@ namespace Pal3.Scene.SceneObjects
if (ModelType == SceneObjectModelType.PolModel)
{
PolFile polFile = resourceProvider.GetGameResourceFile<PolFile>(ModelFilePath);
PolFile polFile = resourceProvider.GetGameResourceFile<PolFile>(ModelFileVirtualPath);
ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(ModelFilePath));
Utility.GetRelativeDirectoryPath(ModelFileVirtualPath));
_polyModelRenderer = _sceneObjectGameObject.AddComponent<PolyModelRenderer>();
_polyModelRenderer.Render(polFile,
textureProvider,
@@ -141,9 +135,9 @@ namespace Pal3.Scene.SceneObjects
}
else if (ModelType == SceneObjectModelType.CvdModel)
{
CvdFile cvdFile = resourceProvider.GetGameResourceFile<CvdFile>(ModelFilePath);
CvdFile cvdFile = resourceProvider.GetGameResourceFile<CvdFile>(ModelFileVirtualPath);
ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(ModelFilePath));
Utility.GetRelativeDirectoryPath(ModelFileVirtualPath));
_cvdModelRenderer = _sceneObjectGameObject.AddComponent<CvdModelRenderer>();
_cvdModelRenderer.Init(cvdFile,
textureProvider,
@@ -281,6 +275,7 @@ namespace Pal3.Scene.SceneObjects
if (_sceneObjectGameObject != null)
{
Object.Destroy(_sceneObjectGameObject);
_sceneObjectGameObject = null;
}
}
@@ -66,6 +66,7 @@ namespace Pal3.Scene.SceneObjects
if (_standingPlatformController != null)
{
Object.Destroy(_standingPlatformController);
_standingPlatformController = null;
}
base.Deactivate();
@@ -113,6 +113,7 @@ namespace Pal3.Scene.SceneObjects
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
@@ -113,6 +113,7 @@ namespace Pal3.Scene.SceneObjects
private void OnDisable()
{
Destroy(_effectComponent);
_effectComponent = null;
}
}
}
@@ -89,6 +89,7 @@ namespace Pal3.Scene.SceneObjects
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}
base.Deactivate();
@@ -31,8 +31,8 @@ namespace Pal3.Scene.SceneObjects
private SceneObjectMeshCollider _meshCollider;
private readonly string _interactionIndicatorModelPath = FileConstants.ObjectFolderVirtualPath +
CpkConstants.DirectorySeparator + "g03.cvd";
private const string INTERACTION_INDICATOR_MODEL_FILE_NAME = "g03.cvd";
private CvdModelRenderer _interactionIndicatorRenderer;
private GameObject _interactionIndicatorGameObject;
@@ -66,14 +66,18 @@ namespace Pal3.Scene.SceneObjects
// and Parameter[1] is 0 (1 means the switch is not directly interactable)
if (ObjectInfo.Times > 0 && ObjectInfo.Parameters[1] == 0)
{
string interactionIndicatorModelPath = FileConstants.GetGameObjectModelFileVirtualPath(
INTERACTION_INDICATOR_MODEL_FILE_NAME);
Vector3 switchPosition = sceneGameObject.transform.position;
_interactionIndicatorGameObject = new GameObject("Switch_Interaction_Indicator");
_interactionIndicatorGameObject.transform.SetParent(sceneGameObject.transform, false);
_interactionIndicatorGameObject.transform.position =
new Vector3(switchPosition.x, GetRendererBounds().max.y + 1f, switchPosition.z);
CvdFile cvdFile = resourceProvider.GetGameResourceFile<CvdFile>(_interactionIndicatorModelPath);
CvdFile cvdFile = resourceProvider.GetGameResourceFile<CvdFile>(interactionIndicatorModelPath);
ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(_interactionIndicatorModelPath));
Utility.GetRelativeDirectoryPath(interactionIndicatorModelPath));
_interactionIndicatorRenderer = _interactionIndicatorGameObject.AddComponent<CvdModelRenderer>();
_interactionIndicatorRenderer.Init(cvdFile,
textureProvider,
@@ -124,6 +128,8 @@ namespace Pal3.Scene.SceneObjects
_interactionIndicatorRenderer.Dispose();
Object.Destroy(_interactionIndicatorRenderer);
Object.Destroy(_interactionIndicatorGameObject);
_interactionIndicatorRenderer = null;
_interactionIndicatorGameObject = null;
}
if (ctx.StartedByPlayer &&
@@ -204,11 +210,13 @@ namespace Pal3.Scene.SceneObjects
{
_interactionIndicatorRenderer.Dispose();
Object.Destroy(_interactionIndicatorRenderer);
_interactionIndicatorRenderer = null;
}
if (_interactionIndicatorGameObject != null)
{
Object.Destroy(_interactionIndicatorGameObject);
_interactionIndicatorGameObject = null;
}
base.Deactivate();
@@ -85,6 +85,7 @@ namespace Pal3.Scene.SceneObjects
if (_platformController != null)
{
Object.Destroy(_platformController);
_platformController = null;
}
base.Deactivate();
@@ -104,6 +104,7 @@ namespace Pal3.Scene.SceneObjects
if (_standingPlatformController != null)
{
Object.Destroy(_standingPlatformController);
_standingPlatformController = null;
}
base.Deactivate();
@@ -146,6 +146,7 @@ namespace Pal3.Scene.SceneObjects
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
@@ -159,6 +159,7 @@ namespace Pal3.Scene.SceneObjects
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
@@ -95,6 +95,7 @@ namespace Pal3.Scene.SceneObjects
{
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
Object.Destroy(_triggerController);
_triggerController = null;
}
base.Deactivate();
@@ -99,6 +99,7 @@ namespace Pal3.Scene.SceneObjects
if (ObjectInfo.Parameters[0] == 1 && _meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
}
@@ -143,6 +144,7 @@ namespace Pal3.Scene.SceneObjects
if (_meshCollider != null)
{
Object.Destroy(_meshCollider);
_meshCollider = null;
}
base.Deactivate();
+24 -19
View File
@@ -119,25 +119,6 @@ namespace Pal3.Script
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!_isDisposed)
{
if (disposing)
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
_scriptDataReader.Dispose();
}
_isDisposed = true;
}
}
public bool Update(float deltaTime)
{
var canExecute = true;
@@ -242,6 +223,30 @@ namespace Pal3.Script
}
}
~PalScriptRunner()
{
Dispose(disposing: false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!_isDisposed)
{
if (disposing)
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
_scriptDataReader.Dispose();
}
_isDisposed = true;
}
}
public void Execute(ScriptVarSetValueCommand command)
{
if (!_isExecuting) return;
+2 -2
View File
@@ -40,8 +40,8 @@ namespace Pal3.Script
public ScriptManager(GameResourceProvider resourceProvider)
{
resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
_systemSceFile = resourceProvider.GetSystemSce();
_bigMapSceFile = resourceProvider.GetBigMapSce();
_systemSceFile = resourceProvider.GetSystemSceFile();
_bigMapSceFile = resourceProvider.GetBigMapSceFile();
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
+1 -1
View File
@@ -21,7 +21,7 @@ namespace Pal3.UI
public void Init(GameResourceProvider gameResourceProvider)
{
gameResourceProvider = Requires.IsNotNull(gameResourceProvider, nameof(gameResourceProvider));
Requires.IsNotNull(gameResourceProvider, nameof(gameResourceProvider));
_cursorTextureNormal = gameResourceProvider.GetCursorTexture();
Cursor.SetCursor(_cursorTextureNormal, Vector2.zero, CursorMode.Auto);
}
@@ -48,8 +48,8 @@ namespace Pal3.UI
private void OnDestroy()
{
Destroy(_material);
image = null;
_material = null;
image = null;
}
private void OnRectTransformDimensionsChange()
@@ -16,10 +16,14 @@ namespace ResourceViewer
using Core.DataReader.Cpk;
using Core.DataReader.Cvd;
using Core.DataReader.Gdb;
using Core.DataReader.Mov;
using Core.DataReader.Msh;
using Core.DataReader.Mtl;
using Core.DataReader.Mv3;
using Core.DataReader.Pol;
using Core.DataReader.Sce;
using Core.DataReader.Scn;
using Core.Extensions;
using Core.FileSystem;
using Core.Services;
using Core.Utils;
@@ -50,6 +54,7 @@ namespace ResourceViewer
[SerializeField] private Button randomCvdButton;
[SerializeField] private Button randomMv3Button;
[SerializeField] private Button randomMp3Button;
[SerializeField] private Button randomMovButton;
[SerializeField] private AudioSource audioSource;
[SerializeField] private FpsCounter fpsCounter;
@@ -60,6 +65,7 @@ namespace ResourceViewer
private IList<string> _polFiles = new List<string>();
private IList<string> _cvdFiles = new List<string>();
private IList<string> _mv3Files = new List<string>();
private IList<string> _movFiles = new List<string>();
private IList<string> _mp3Files = new List<string>();
private static readonly Random Random = new ();
@@ -96,11 +102,13 @@ namespace ResourceViewer
_polFiles = _fileSystem.Search(".pol").ToList();
_cvdFiles = _fileSystem.Search(".cvd").ToList();
_mv3Files = _fileSystem.Search(".mv3").ToList();
_movFiles = _fileSystem.Search(".mov").ToList();
_mp3Files = _fileSystem.Search(".mp3").ToList();
randomPolButton.onClick.AddListener(RandPol);
randomCvdButton.onClick.AddListener(RandCvd);
randomMv3Button.onClick.AddListener(RandMv3);
randomMovButton.onClick.AddListener(RandMov);
randomMp3Button.onClick.AddListener(RandMp3);
DebugLogConsole.AddCommand<string>("Search", "Search files using keyword.", Search);
@@ -199,6 +207,11 @@ namespace ResourceViewer
while (!LoadMv3(_mv3Files[Random.Next(0, _mv3Files.Count)])) { }
}
private void RandMov()
{
while (!LoadMov(_movFiles[Random.Next(0, _movFiles.Count)])) { }
}
private void RandMp3()
{
while (!LoadMp3(_mp3Files[Random.Next(0, _mp3Files.Count)])) { }
@@ -226,6 +239,7 @@ namespace ResourceViewer
".pol" => LoadPol(filePath),
".cvd" => LoadCvd(filePath),
".mv3" => LoadMv3(filePath),
".mov" => LoadMov(filePath),
".mp3" => LoadMp3(filePath),
_ => throw new Exception($"File extension: <{ext}> not supported.")
};
@@ -279,9 +293,9 @@ namespace ResourceViewer
ITextureResourceProvider textureProvider = _resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(filePath));
var mesh = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparator));
var meshRenderer = mesh.AddComponent<CvdModelRenderer>();
mesh.transform.SetParent(_renderingRoot.transform);
var animationNode = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparator));
var meshRenderer = animationNode.AddComponent<CvdModelRenderer>();
animationNode.transform.SetParent(_renderingRoot.transform);
meshRenderer.Init(cvdFile,
textureProvider,
@@ -323,24 +337,26 @@ namespace ResourceViewer
var animationNode = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparator));
animationNode.transform.SetParent(_renderingRoot.transform);
var mv3AnimationRenderer = animationNode.AddComponent<Mv3ModelRenderer>();
// For debugging tag node:
//For debugging tag node:
// if (mv3File.TagNodes is {Length: > 0} &&
// !mv3File.TagNodes[0].Name.Equals("tag_weapon3", StringComparison.OrdinalIgnoreCase) &&
// filePath.Contains(@"ROLE\101"))
// {
// var weaponName = "JT13";
//
// var separator = CpkConstants.CpkDirectorySeparatorChar;
// var weaponPath = FileConstants.GetWeaponModelFileVirtualPath(weaponName);
//
// var weaponPath = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
// $"{FileConstants.WeaponFolderName}{separator}{weaponName}{separator}{weaponName}.pol";
//
// var (polFile, weaponTextureProvider) = _resourceProvider.GetPol(weaponPath);
// mv3AnimationRenderer.Init(mv3File, textureProvider, Color.white,
// polFile, weaponTextureProvider, Color.white);
// PolFile polFile = _resourceProvider.GetGameResourceFile<PolFile>(weaponPath);
// ITextureResourceProvider weaponTextureProvider = _resourceProvider.CreateTextureResourceProvider(
// Utility.GetRelativeDirectoryPath(weaponPath));
// mv3AnimationRenderer.Init(mv3File,
// _resourceProvider.GetMaterialFactory(),
// textureProvider,
// Color.white,
// polFile,
// weaponTextureProvider);
// }
// else
{
@@ -365,6 +381,55 @@ namespace ResourceViewer
}
}
private bool LoadMov(string filePath)
{
DestroyExistingRenderingObjects();
consoleTextUI.text = $"Loading: {filePath}";
Debug.Log($"Loading: {filePath}");
try
{
var actorFolderPath = Utility.GetRelativeDirectoryPath(filePath);
var actorName = Path.GetFileName(actorFolderPath);
string mshFilePath = actorFolderPath + CpkConstants.DirectorySeparator + actorName + ".msh";
var mshFile = _resourceProvider.GetGameResourceFile<MshFile>(mshFilePath);
string mtlFilePath = actorFolderPath + CpkConstants.DirectorySeparator + actorName + ".mtl";
var mtlFile = _resourceProvider.GetGameResourceFile<MtlFile>(mtlFilePath);
var movFile = _resourceProvider.GetGameResourceFile<MovFile>(filePath);
ITextureResourceProvider textureProvider = _resourceProvider.CreateTextureResourceProvider(
Utility.GetRelativeDirectoryPath(mtlFilePath));
var animationNode = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparator));
animationNode.transform.SetParent(_renderingRoot.transform);
var skeletalModelRenderer = animationNode.GetOrAddComponent<SkeletalModelRenderer>();
skeletalModelRenderer.Init(mshFile,
mtlFile,
_resourceProvider.GetMaterialFactory(),
textureProvider);
skeletalModelRenderer.StartAnimation(movFile);
consoleTextUI.text = $"{filePath}";
Camera.main!.transform.LookAt(new Vector3(0, 2, 0));
return true;
}
catch (Exception ex)
{
Debug.LogException(ex);
consoleTextUI.text = $"Failed to load: {filePath}";
return false;
}
}
#if UNITY_EDITOR
private void DecompileAllSceScripts(bool dialogueOnly)
{
@@ -535,7 +600,7 @@ namespace ResourceViewer
{
nowPlayingTextUI.text = "* Now Playing: " + Utility.GetFileName(filePath, CpkConstants.DirectorySeparator);
StartCoroutine(LoadMp3AudioClipAsync(filePath,
_resourceProvider.GetMp3FilePathInCacheFolder(filePath)));
_resourceProvider.GetMusicFilePathInCacheFolder(filePath)));
return true;
}
+4 -4
View File
@@ -6,14 +6,14 @@
"com.unity.ide.rider": "3.0.24",
"com.unity.ide.visualstudio": "2.0.18",
"com.unity.ide.vscode": "1.2.5",
"com.unity.inputsystem": "1.6.1",
"com.unity.inputsystem": "1.6.3",
"com.unity.memoryprofiler": "1.0.0",
"com.unity.postprocessing": "3.2.2",
"com.unity.test-framework": "1.1.33",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.7.4",
"com.unity.toolchain.macos-x86_64-linux-x86_64": "2.0.4",
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.4",
"com.unity.timeline": "1.7.5",
"com.unity.toolchain.macos-x86_64-linux-x86_64": "2.0.6",
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.6",
"com.unity.ugui": "1.0.0",
"com.unity.visualscripting": "1.8.0",
"com.unity.modules.ai": "1.0.0",
+11 -11
View File
@@ -70,7 +70,7 @@
"url": "https://packages.unity.com"
},
"com.unity.inputsystem": {
"version": "1.6.1",
"version": "1.6.3",
"depth": 0,
"source": "registry",
"dependencies": {
@@ -111,18 +111,18 @@
"url": "https://packages.unity.com"
},
"com.unity.sysroot": {
"version": "2.0.5",
"version": "2.0.7",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.sysroot.linux-x86_64": {
"version": "2.0.4",
"version": "2.0.6",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.sysroot": "2.0.5"
"com.unity.sysroot": "2.0.7"
},
"url": "https://packages.unity.com"
},
@@ -157,7 +157,7 @@
"url": "https://packages.unity.com"
},
"com.unity.timeline": {
"version": "1.7.4",
"version": "1.7.5",
"depth": 0,
"source": "registry",
"dependencies": {
@@ -169,22 +169,22 @@
"url": "https://packages.unity.com"
},
"com.unity.toolchain.macos-x86_64-linux-x86_64": {
"version": "2.0.4",
"version": "2.0.6",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.sysroot": "2.0.5",
"com.unity.sysroot.linux-x86_64": "2.0.4"
"com.unity.sysroot": "2.0.7",
"com.unity.sysroot.linux-x86_64": "2.0.6"
},
"url": "https://packages.unity.com"
},
"com.unity.toolchain.win-x86_64-linux-x86_64": {
"version": "2.0.4",
"version": "2.0.6",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.sysroot": "2.0.5",
"com.unity.sysroot.linux-x86_64": "2.0.4"
"com.unity.sysroot": "2.0.7",
"com.unity.sysroot.linux-x86_64": "2.0.6"
},
"url": "https://packages.unity.com"
},
+54 -13
View File
@@ -133,7 +133,7 @@ PlayerSettings:
vulkanEnableLateAcquireNextImage: 0
vulkanEnableCommandBufferRecycling: 1
loadStoreDebugModeEnabled: 0
bundleVersion: 0.64
bundleVersion: 0.67
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
@@ -155,11 +155,21 @@ PlayerSettings:
androidMaxAspectRatio: 2.1
applicationIdentifier:
Android: com.Jackil.PAL3
GameCoreScarlett: com.Jackil.PAL3
GameCoreXboxOne: com.Jackil.PAL3
Nintendo Switch: com.Jackil.PAL3
PS4: com.Jackil.PAL3
PS5: com.Jackil.PAL3
Standalone: com.Jackil.PAL3
VisionOS: com.Jackil.PAL3
Windows Store Apps: com.Jackil.PAL3
XboxOne: com.Jackil.PAL3
iPhone: com.Jackil.PAL3
tvOS: com.Jackil.PAL3
buildNumber:
Bratwurst: 0
Standalone: 0
VisionOS: 0
iPhone: 0
tvOS: 0
overrideDefaultApplicationIdentifier: 1
@@ -184,8 +194,8 @@ PlayerSettings:
tvOSSdkVersion: 0
tvOSRequireExtendedGameController: 0
tvOSTargetOSVersionString: 12.0
bratwurstSdkVersion: 0
bratwurstTargetOSVersionString: 16.4
VisionOSSdkVersion: 0
VisionOSTargetOSVersionString: 1.0
uIPrerenderedIcon: 0
uIRequiresPersistentWiFi: 0
uIRequiresFullScreen: 1
@@ -233,10 +243,10 @@ PlayerSettings:
appleDeveloperTeamID: 4997CKN8MT
iOSManualSigningProvisioningProfileID:
tvOSManualSigningProvisioningProfileID:
bratwurstManualSigningProvisioningProfileID:
VisionOSManualSigningProvisioningProfileID:
iOSManualSigningProvisioningProfileType: 0
tvOSManualSigningProvisioningProfileType: 0
bratwurstManualSigningProvisioningProfileType: 0
VisionOSManualSigningProvisioningProfileType: 0
appleEnableAutomaticSigning: 0
iOSRequireARKit: 0
iOSAutomaticallyDetectAndAddCapabilities: 1
@@ -327,6 +337,36 @@ PlayerSettings:
m_Width: 16
m_Height: 16
m_Kind: 0
- m_BuildTarget: PS4
m_Icons:
- serializedVersion: 2
m_Icon: {fileID: 2800000, guid: 6b32649dccc45df4ebe8e3f8eccee249, type: 3}
m_Width: 512
m_Height: 512
m_Kind: 0
- m_BuildTarget: XboxOne
m_Icons:
- serializedVersion: 2
m_Icon: {fileID: 2800000, guid: 6b32649dccc45df4ebe8e3f8eccee249, type: 3}
m_Width: 100
m_Height: 100
m_Kind: 0
- serializedVersion: 2
m_Icon: {fileID: 2800000, guid: 6b32649dccc45df4ebe8e3f8eccee249, type: 3}
m_Width: 208
m_Height: 208
m_Kind: 0
- serializedVersion: 2
m_Icon: {fileID: 2800000, guid: 6b32649dccc45df4ebe8e3f8eccee249, type: 3}
m_Width: 480
m_Height: 480
m_Kind: 0
- m_BuildTarget: Nintendo Switch
m_Icons: []
- m_BuildTarget: Windows Store Apps
m_Icons: []
- m_BuildTarget: VisionOS
m_Icons: []
m_BuildTargetPlatformIcons:
- m_BuildTarget: iPhone
m_Icons:
@@ -909,21 +949,22 @@ PlayerSettings:
Bratwurst: UNITY_POST_PROCESSING_STACK_V2
CloudRendering: UNITY_POST_PROCESSING_STACK_V2
EmbeddedLinux: UNITY_POST_PROCESSING_STACK_V2
GameCoreScarlett: UNITY_POST_PROCESSING_STACK_V2
GameCoreXboxOne: UNITY_POST_PROCESSING_STACK_V2
GameCoreScarlett: PAL3;UNITY_POST_PROCESSING_STACK_V2
GameCoreXboxOne: PAL3;UNITY_POST_PROCESSING_STACK_V2
LinuxHeadlessSimulation: UNITY_POST_PROCESSING_STACK_V2
Lumin: UNITY_POST_PROCESSING_STACK_V2
Nintendo Switch: UNITY_POST_PROCESSING_STACK_V2
PS4: UNITY_POST_PROCESSING_STACK_V2
PS5: UNITY_POST_PROCESSING_STACK_V2
Nintendo Switch: PAL3;UNITY_POST_PROCESSING_STACK_V2
PS4: PAL3;UNITY_POST_PROCESSING_STACK_V2
PS5: PAL3;UNITY_POST_PROCESSING_STACK_V2
QNX: UNITY_POST_PROCESSING_STACK_V2
Stadia: UNITY_POST_PROCESSING_STACK_V2
Standalone: PAL3;UNITY_POST_PROCESSING_STACK_V2
VisionOS: PAL3;UNITY_POST_PROCESSING_STACK_V2
WebGL: UNITY_POST_PROCESSING_STACK_V2
Windows Store Apps: UNITY_POST_PROCESSING_STACK_V2
XboxOne: UNITY_POST_PROCESSING_STACK_V2
Windows Store Apps: PAL3;UNITY_POST_PROCESSING_STACK_V2
XboxOne: PAL3;UNITY_POST_PROCESSING_STACK_V2
iPhone: PAL3
tvOS: UNITY_POST_PROCESSING_STACK_V2
tvOS: PAL3;UNITY_POST_PROCESSING_STACK_V2
additionalCompilerArguments: {}
platformArchitecture: {}
scriptingBackend:
+2 -2
View File
@@ -1,2 +1,2 @@
m_EditorVersion: 2022.3.4f1
m_EditorVersionWithRevision: 2022.3.4f1 (35713cd46cd7)
m_EditorVersion: 2022.3.5f1
m_EditorVersionWithRevision: 2022.3.5f1 (9674261d40ee)