mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-27 01:48:06 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
790f72d836 | ||
|
|
4fcb2b74da | ||
|
|
e0d1cf0f80 | ||
|
|
bdb0476417 | ||
|
|
4d23ec3c47 | ||
|
|
4f6f411816 | ||
|
|
cf015037bf | ||
|
|
259768e954 | ||
|
|
57a2189812 | ||
|
|
00f7b223a0 | ||
|
|
e4791b460e | ||
|
|
60458949df | ||
|
|
a8bfe5917b | ||
|
|
f90463466d | ||
|
|
e6a9cfb28a | ||
|
|
7f22dfe51b | ||
|
|
ef8e891ab0 | ||
|
|
ee6b6ec2af | ||
|
|
1406fc857e | ||
|
|
09300bb28a | ||
|
|
c4ac634589 | ||
|
|
3a101d6e0a | ||
|
|
4a6d68ea59 | ||
|
|
a6eabdb8d8 | ||
|
|
43133b2ebd | ||
|
|
8d21346cd7 | ||
|
|
e0267dce3b | ||
|
|
263d9fcd8c |
No files matched your search
@@ -1,5 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 017f90526f3834e4ca575928f2369942
|
||||
labels:
|
||||
- NuGetForUnity
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd9629b50a962774fa83514636685099
|
||||
guid: d25342fa4b1c06a4fb5b9275bf3f6350
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
Binary file not shown.
File renamed without changes.
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c55e208d745dcdd4f869b845af4cfab3
|
||||
guid: 2202405c70c652942ae8270006c01f9d
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
Binary file not shown.
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18067ab6c9f2b9c4db7a28c5a071bb6a
|
||||
guid: bed3e3b7fed51194da24fb7fb8c0a316
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
@@ -0,0 +1,71 @@
|
||||
#  Json.NET
|
||||
|
||||
[](https://www.nuget.org/packages/Newtonsoft.Json/)
|
||||
[](https://dev.azure.com/jamesnk/Public/_build/latest?definitionId=8)
|
||||
|
||||
Json.NET is a popular high-performance JSON framework for .NET
|
||||
|
||||
## Serialize JSON
|
||||
|
||||
```csharp
|
||||
Product product = new Product();
|
||||
product.Name = "Apple";
|
||||
product.Expiry = new DateTime(2008, 12, 28);
|
||||
product.Sizes = new string[] { "Small" };
|
||||
|
||||
string json = JsonConvert.SerializeObject(product);
|
||||
// {
|
||||
// "Name": "Apple",
|
||||
// "Expiry": "2008-12-28T00:00:00",
|
||||
// "Sizes": [
|
||||
// "Small"
|
||||
// ]
|
||||
// }
|
||||
```
|
||||
|
||||
## Deserialize JSON
|
||||
|
||||
```csharp
|
||||
string json = @"{
|
||||
'Name': 'Bad Boys',
|
||||
'ReleaseDate': '1995-4-7T00:00:00',
|
||||
'Genres': [
|
||||
'Action',
|
||||
'Comedy'
|
||||
]
|
||||
}";
|
||||
|
||||
Movie m = JsonConvert.DeserializeObject<Movie>(json);
|
||||
|
||||
string name = m.Name;
|
||||
// Bad Boys
|
||||
```
|
||||
|
||||
## LINQ to JSON
|
||||
|
||||
```csharp
|
||||
JArray array = new JArray();
|
||||
array.Add("Manual text");
|
||||
array.Add(new DateTime(2000, 5, 23));
|
||||
|
||||
JObject o = new JObject();
|
||||
o["MyArray"] = array;
|
||||
|
||||
string json = o.ToString();
|
||||
// {
|
||||
// "MyArray": [
|
||||
// "Manual text",
|
||||
// "2000-05-23T00:00:00"
|
||||
// ]
|
||||
// }
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Homepage](https://www.newtonsoft.com/json)
|
||||
- [Documentation](https://www.newtonsoft.com/json/help)
|
||||
- [NuGet Package](https://www.nuget.org/packages/Newtonsoft.Json)
|
||||
- [Release Notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
|
||||
- [Contributing Guidelines](https://github.com/JamesNK/Newtonsoft.Json/blob/master/CONTRIBUTING.md)
|
||||
- [License](https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md)
|
||||
- [Stack Overflow](https://stackoverflow.com/questions/tagged/json.net)
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 129c820b154da074e821d870a3627120
|
||||
NativeFormatImporter:
|
||||
guid: 6069c71b8cbde2c46af37b4d5e9d6a4f
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0569847255b194d4da45463253c1e4b1
|
||||
guid: 520a919eca99b2345bd9cdcf39fe8e58
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b982b4ebc3ab07418a1e9965b232813
|
||||
guid: 45501e75b3795d04cbf421ad8a1021d3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
BIN
Binary file not shown.
+3
-13
@@ -1,5 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4c52cca01a63c54ba72e8a873c28f55
|
||||
guid: 0321b95b71cdcb84396730b66dc18f74
|
||||
labels:
|
||||
- NuGetForUnity
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -16,18 +18,6 @@ PluginImporter:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+61
-3
@@ -865,6 +865,32 @@
|
||||
Converts a <see cref="T:System.DateTime"/> to and from Unix epoch time
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.Converters.UnixDateTimeConverter.AllowPreEpoch">
|
||||
<summary>
|
||||
Gets or sets a value indicating whether the dates before Unix epoch
|
||||
should converted to and from JSON.
|
||||
</summary>
|
||||
<value>
|
||||
<c>true</c> to allow converting dates before Unix epoch to and from JSON;
|
||||
<c>false</c> to throw an exception when a date being converted to or from JSON
|
||||
occurred before Unix epoch. The default value is <c>false</c>.
|
||||
</value>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Converters.UnixDateTimeConverter.#ctor">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Newtonsoft.Json.Converters.UnixDateTimeConverter"/> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Converters.UnixDateTimeConverter.#ctor(System.Boolean)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Newtonsoft.Json.Converters.UnixDateTimeConverter"/> class.
|
||||
</summary>
|
||||
<param name="allowPreEpoch">
|
||||
<c>true</c> to allow converting dates before Unix epoch to and from JSON;
|
||||
<c>false</c> to throw an exception when a date being converted to or from JSON
|
||||
occurred before Unix epoch. The default value is <c>false</c>.
|
||||
</param>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Converters.UnixDateTimeConverter.WriteJson(Newtonsoft.Json.JsonWriter,System.Object,Newtonsoft.Json.JsonSerializer)">
|
||||
<summary>
|
||||
Writes the JSON representation of the object.
|
||||
@@ -2554,7 +2580,7 @@
|
||||
<summary>
|
||||
Gets or sets the maximum depth allowed when reading JSON. Reading past this depth will throw a <see cref="T:Newtonsoft.Json.JsonReaderException"/>.
|
||||
A null value means there is no maximum.
|
||||
The default value is <c>128</c>.
|
||||
The default value is <c>64</c>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.JsonReader.TokenType">
|
||||
@@ -3014,7 +3040,7 @@
|
||||
<summary>
|
||||
Gets or sets the maximum depth allowed when reading JSON. Reading past this depth will throw a <see cref="T:Newtonsoft.Json.JsonReaderException"/>.
|
||||
A null value means there is no maximum.
|
||||
The default value is <c>128</c>.
|
||||
The default value is <c>64</c>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.JsonSerializer.CheckAdditionalContent">
|
||||
@@ -3330,7 +3356,7 @@
|
||||
<summary>
|
||||
Gets or sets the maximum depth allowed when reading JSON. Reading past this depth will throw a <see cref="T:Newtonsoft.Json.JsonReaderException"/>.
|
||||
A null value means there is no maximum.
|
||||
The default value is <c>128</c>.
|
||||
The default value is <c>64</c>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.JsonSerializerSettings.Formatting">
|
||||
@@ -3397,6 +3423,12 @@
|
||||
Initializes a new instance of the <see cref="T:Newtonsoft.Json.JsonSerializerSettings"/> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.JsonSerializerSettings.#ctor(Newtonsoft.Json.JsonSerializerSettings)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Newtonsoft.Json.JsonSerializerSettings"/> class
|
||||
using values copied from the passed in <see cref="T:Newtonsoft.Json.JsonSerializerSettings"/>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Newtonsoft.Json.JsonTextReader">
|
||||
<summary>
|
||||
Represents a reader that provides fast, non-cached, forward-only access to JSON text data.
|
||||
@@ -7031,6 +7063,25 @@
|
||||
<param name="reader">The reader.</param>
|
||||
<returns>An instance of <see cref="T:Newtonsoft.Json.Linq.JRaw"/> with the content of the reader's current token.</returns>
|
||||
</member>
|
||||
<member name="T:Newtonsoft.Json.Linq.JsonCloneSettings">
|
||||
<summary>
|
||||
Specifies the settings used when cloning JSON.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Linq.JsonCloneSettings.#ctor">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Newtonsoft.Json.Linq.JsonCloneSettings"/> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.Linq.JsonCloneSettings.CopyAnnotations">
|
||||
<summary>
|
||||
Gets or sets a flag that indicates whether to copy annotations when cloning a <see cref="T:Newtonsoft.Json.Linq.JToken"/>.
|
||||
The default value is <c>true</c>.
|
||||
</summary>
|
||||
<value>
|
||||
A flag that indicates whether to copy annotations when cloning a <see cref="T:Newtonsoft.Json.Linq.JToken"/>.
|
||||
</value>
|
||||
</member>
|
||||
<member name="T:Newtonsoft.Json.Linq.JsonLoadSettings">
|
||||
<summary>
|
||||
Specifies the settings used when loading JSON.
|
||||
@@ -8071,6 +8122,13 @@
|
||||
</summary>
|
||||
<returns>A new instance of the <see cref="T:Newtonsoft.Json.Linq.JToken"/>.</returns>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Linq.JToken.DeepClone(Newtonsoft.Json.Linq.JsonCloneSettings)">
|
||||
<summary>
|
||||
Creates a new instance of the <see cref="T:Newtonsoft.Json.Linq.JToken"/>. All child tokens are recursively cloned.
|
||||
</summary>
|
||||
<param name="settings">A <see cref="T:Newtonsoft.Json.Linq.JsonCloneSettings"/> object to configure cloning settings.</param>
|
||||
<returns>A new instance of the <see cref="T:Newtonsoft.Json.Linq.JToken"/>.</returns>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Linq.JToken.AddAnnotation(System.Object)">
|
||||
<summary>
|
||||
Adds an object to the annotation list of this <see cref="T:Newtonsoft.Json.Linq.JToken"/>.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cdd1b6e2b1397547b722844a364a7c7
|
||||
guid: 9b4b3cddff1ae1343a973b35c0738edd
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
+55
-5
@@ -1,9 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ea59359fa70a004da570d3fae618d57
|
||||
guid: be12599e7ed6ddb44ac085726df1d0fd
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
@@ -20,11 +20,12 @@ TextureImporter:
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
@@ -63,6 +64,8 @@ TextureImporter:
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
@@ -76,6 +79,54 @@ TextureImporter:
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: iPhone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
@@ -90,9 +141,8 @@ TextureImporter:
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+2
@@ -1,5 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f691697ada4059c46a06801ddaf2ee3a
|
||||
labels:
|
||||
- NuGetForUnity
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 217cb7caed5f7fb49b339428b1d80974
|
||||
folderAsset: yes
|
||||
timeCreated: 1510280316
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3fad56c531ac5a4db190a745f589a8e
|
||||
folderAsset: yes
|
||||
timeCreated: 1510280304
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -1,33 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8dc1be91775c4bb469f6b74cef450eaa
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Patrick McCarthy
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d9014b99ad06af428514a5902d29ff3
|
||||
timeCreated: 1573248500
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83c5d2001771f15429a88d67e81366d6
|
||||
timeCreated: 1517876157
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1738075a39a390447b7a620ca6962142
|
||||
folderAsset: yes
|
||||
timeCreated: 1510280362
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.3 KiB |
@@ -1,88 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eec19781926cd2248b7c9abfde8db555
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 9
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 215e43cda847e6d44af8b40376eeed8a
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,7 +4,7 @@ TrueTypeFontImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
fontSize: 16
|
||||
forceTextureCase: -2
|
||||
forceTextureCase: 3
|
||||
characterSpacing: 0
|
||||
characterPadding: 1
|
||||
includeFontData: 1
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Binary file not shown.
@@ -1,21 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcba7b37316258447a7e7b8a9faefba8
|
||||
TrueTypeFontImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
fontSize: 16
|
||||
forceTextureCase: -2
|
||||
characterSpacing: 0
|
||||
characterPadding: 1
|
||||
includeFontData: 1
|
||||
fontNames:
|
||||
- Slidexiaxing
|
||||
fallbackFontReferences: []
|
||||
customCharacters:
|
||||
fontRenderingMode: 0
|
||||
ascentCalculationMode: 1
|
||||
useLegacyBoundsCalculation: 0
|
||||
shouldRoundAdvanceValue: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -543,6 +543,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -804,6 +805,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -1360,6 +1362,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 0
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -1571,10 +1574,10 @@ RectTransform:
|
||||
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: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 40}
|
||||
m_SizeDelta: {x: 1024, y: 220}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 220}
|
||||
m_Pivot: {x: 0.5, y: 0}
|
||||
--- !u!222 &4063106792528428755
|
||||
CanvasRenderer:
|
||||
@@ -1689,6 +1692,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 0
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -1790,6 +1794,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -1876,6 +1881,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -2006,6 +2012,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -2184,10 +2191,10 @@ RectTransform:
|
||||
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: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 40}
|
||||
m_SizeDelta: {x: 1024, y: 600}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 600}
|
||||
m_Pivot: {x: 0.5, y: 0}
|
||||
--- !u!223 &4883717640244246670
|
||||
Canvas:
|
||||
@@ -2206,6 +2213,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -2701,7 +2709,7 @@ GameObject:
|
||||
- component: {fileID: 5650567296555352649}
|
||||
- component: {fileID: 416810473558055248}
|
||||
m_Layer: 5
|
||||
m_Name: BigMapButton
|
||||
m_Name: MultiFunctionButton
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@@ -3118,6 +3126,7 @@ Canvas:
|
||||
m_OverrideSorting: 1
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 0
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -3180,6 +3189,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -3321,8 +3331,8 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 387607491181381395}
|
||||
- component: {fileID: 2679516728184289285}
|
||||
- component: {fileID: 882591667526732793}
|
||||
- component: {fileID: 5846368339154605878}
|
||||
- component: {fileID: 3670689598550541589}
|
||||
m_Layer: 5
|
||||
m_Name: DialogueCanvas
|
||||
m_TagString: Untagged
|
||||
@@ -3368,12 +3378,30 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 10000
|
||||
m_TargetDisplay: 0
|
||||
--- !u!114 &882591667526732793
|
||||
--- !u!114 &5846368339154605878
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7484238520589272425}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &3670689598550541589
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@@ -3396,23 +3424,6 @@ MonoBehaviour:
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 0
|
||||
--- !u!114 &5846368339154605878
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7484238520589272425}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!1 &7820229574742230346
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3470,6 +3481,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -3549,10 +3561,10 @@ RectTransform:
|
||||
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: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 40}
|
||||
m_SizeDelta: {x: 1024, y: 600}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 600}
|
||||
m_Pivot: {x: 0.5, y: 0}
|
||||
--- !u!223 &8378544136915806352
|
||||
Canvas:
|
||||
@@ -3571,6 +3583,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@@ -3812,6 +3825,8 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 8498315575182197477}
|
||||
- component: {fileID: 4450587676581078315}
|
||||
- component: {fileID: 4003192220913667494}
|
||||
- component: {fileID: 7116787231374669820}
|
||||
m_Layer: 5
|
||||
m_Name: DialogueCanvasGroup
|
||||
m_TagString: Untagged
|
||||
@@ -3839,10 +3854,10 @@ RectTransform:
|
||||
m_Father: {fileID: 387607491181381395}
|
||||
m_RootOrder: -1
|
||||
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_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_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!225 &4450587676581078315
|
||||
CanvasGroup:
|
||||
@@ -3856,6 +3871,46 @@ CanvasGroup:
|
||||
m_Interactable: 1
|
||||
m_BlocksRaycasts: 1
|
||||
m_IgnoreParentGroups: 0
|
||||
--- !u!114 &4003192220913667494
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8534461212021361286}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e9d6f17a4e68481a9705f217be9b4156, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
maxThresholdRatio: 1.66667
|
||||
minThresholdRatio: 1.4
|
||||
minWidth: 800
|
||||
midWidth: 950
|
||||
maxWidth: 1100
|
||||
--- !u!223 &7116787231374669820
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8534461212021361286}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 2
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 0
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!1 &8627381932629902481
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3942,7 +3997,7 @@ MonoBehaviour:
|
||||
contentScrollRect: {fileID: 8374998735291348270}
|
||||
touchControlUI: {fileID: 1398116650379626629}
|
||||
interactionButton: {fileID: 2629186827427555584}
|
||||
bigMapButton: {fileID: 416810473558055248}
|
||||
multiFunctionButton: {fileID: 416810473558055248}
|
||||
mainMenuButton: {fileID: 7186792160907318265}
|
||||
eventSystem: {fileID: 20216138}
|
||||
postProcessVolume: {fileID: 8346885185333560231}
|
||||
@@ -4272,10 +4327,10 @@ RectTransform:
|
||||
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: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 40}
|
||||
m_SizeDelta: {x: 1024, y: 600}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 600}
|
||||
m_Pivot: {x: 0.5, y: 0}
|
||||
--- !u!223 &4602793290283543645
|
||||
Canvas:
|
||||
@@ -4294,6 +4349,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 7
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
|
||||
@@ -104,7 +104,7 @@ NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
serializedVersion: 3
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
@@ -117,7 +117,7 @@ NavMeshSettings:
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
buildHeightMesh: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
@@ -128,6 +128,7 @@ PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 332266281639726118, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
@@ -230,6 +231,14 @@ PrefabInstance:
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3491202665095195611, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3596785283706710040, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
propertyPath: m_Material
|
||||
value:
|
||||
objectReference: {fileID: 256925267}
|
||||
- target: {fileID: 4209774545385276068, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
@@ -278,6 +287,14 @@ PrefabInstance:
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5077207798598084246, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
propertyPath: m_Material
|
||||
value:
|
||||
objectReference: {fileID: 1661395006}
|
||||
- target: {fileID: 6514349001384511054, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
propertyPath: m_Material
|
||||
value:
|
||||
objectReference: {fileID: 91034975}
|
||||
- target: {fileID: 6936565495695538149, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
@@ -446,6 +463,10 @@ PrefabInstance:
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9166793672834017742, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0.00012207031
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9166793672834029268, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 0
|
||||
@@ -454,6 +475,10 @@ PrefabInstance:
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9166793672834029268, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9166793672834030092, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
@@ -575,4 +600,112 @@ PrefabInstance:
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: e86d7889291c041ba854821fd25047d6, type: 3}
|
||||
--- !u!21 &91034975
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Pal3/RoundedFrostedGlass
|
||||
m_Shader: {fileID: 4800000, guid: 7207745e33764e88af7a51d39feb7b81, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BlurAmount: 4
|
||||
m_Colors:
|
||||
- _AdditiveColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||
- _MultiplyColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
- _WidthHeightRadius: {r: 800, g: 600, b: 65, a: 0}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!21 &256925267
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Pal3/RoundedFrostedGlass
|
||||
m_Shader: {fileID: 4800000, guid: 7207745e33764e88af7a51d39feb7b81, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BlurAmount: 3
|
||||
m_Colors:
|
||||
- _AdditiveColor: {r: 0.039215688, g: 0.039215688, b: 0.039215688, a: 1}
|
||||
- _MultiplyColor: {r: 0.54901963, g: 0.54901963, b: 0.54901963, a: 1}
|
||||
- _WidthHeightRadius: {r: 1024, g: 220, b: 35, a: 0}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!21 &1661395006
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Pal3/RoundedFrostedGlass
|
||||
m_Shader: {fileID: 4800000, guid: 7207745e33764e88af7a51d39feb7b81, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BlurAmount: 4
|
||||
m_Colors:
|
||||
- _AdditiveColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||
- _MultiplyColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
- _WidthHeightRadius: {r: 800, g: 600, b: 65, a: 0}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -3,7 +3,7 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if UNITY_EDITOR_OSX
|
||||
#if UNITY_EDITOR_OSX && UNITY_IOS
|
||||
|
||||
namespace Build.Editor
|
||||
{
|
||||
|
||||
+19
-6
@@ -12,14 +12,22 @@ namespace Core.Animation
|
||||
|
||||
public enum AnimationCurveType
|
||||
{
|
||||
// OG game only has these two
|
||||
Linear = 0,
|
||||
Sine,
|
||||
Sine = 1,
|
||||
|
||||
// New ones added by me
|
||||
Quadratic = 2,
|
||||
Cubic = 3,
|
||||
Exponential = 4,
|
||||
EaseIn = 5,
|
||||
EaseOut = 6,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides helper functions to do Transform animations etc.
|
||||
/// </summary>
|
||||
public static class AnimationHelper
|
||||
public static class CoreAnimation
|
||||
{
|
||||
// Progress -> (0,1)
|
||||
private static float GetInterpolationRatio(float progress, AnimationCurveType curveType)
|
||||
@@ -28,6 +36,11 @@ namespace Core.Animation
|
||||
{
|
||||
AnimationCurveType.Linear => progress,
|
||||
AnimationCurveType.Sine => Mathf.Sin(progress * (Mathf.PI / 2)),
|
||||
AnimationCurveType.Quadratic => Mathf.Pow(progress, 2),
|
||||
AnimationCurveType.Cubic => Mathf.Pow(progress, 3),
|
||||
AnimationCurveType.Exponential => Mathf.Exp(progress) - 1,
|
||||
AnimationCurveType.EaseIn => Mathf.Pow(progress, 3),
|
||||
AnimationCurveType.EaseOut => 1 - Mathf.Pow(1 - progress, 3),
|
||||
_ => progress
|
||||
};
|
||||
}
|
||||
@@ -62,7 +75,7 @@ namespace Core.Animation
|
||||
yield return null;
|
||||
}
|
||||
|
||||
public static IEnumerator MoveTransformAsync(Transform target,
|
||||
public static IEnumerator MoveAsync(this Transform target,
|
||||
Vector3 toPosition,
|
||||
float duration,
|
||||
AnimationCurveType curveType = AnimationCurveType.Linear,
|
||||
@@ -83,7 +96,7 @@ namespace Core.Animation
|
||||
yield return null;
|
||||
}
|
||||
|
||||
public static IEnumerator ShakeTransformAsync(Transform target,
|
||||
public static IEnumerator ShakeAsync(this Transform target,
|
||||
float duration,
|
||||
float amplitude,
|
||||
bool shakeOnXAxis,
|
||||
@@ -107,7 +120,7 @@ namespace Core.Animation
|
||||
yield return null;
|
||||
}
|
||||
|
||||
public static IEnumerator OrbitTransformAroundCenterPointAsync(Transform target,
|
||||
public static IEnumerator OrbitAroundCenterPointAsync(this Transform target,
|
||||
Quaternion toRotation,
|
||||
Vector3 centerPoint,
|
||||
float duration,
|
||||
@@ -143,7 +156,7 @@ namespace Core.Animation
|
||||
yield return null;
|
||||
}
|
||||
|
||||
public static IEnumerator RotateTransformAsync(Transform target,
|
||||
public static IEnumerator RotateAsync(this Transform target,
|
||||
Quaternion toRotation,
|
||||
float duration,
|
||||
AnimationCurveType curveType,
|
||||
File renamed without changes.
@@ -18,9 +18,12 @@ namespace Core.DataLoader
|
||||
/// <param name="filePath">Audio file path</param>
|
||||
/// <param name="audioType">Audio type</param>
|
||||
/// <param name="streamAudio">Create streaming AudioClip</param>
|
||||
/// <param name="callback">AudioClip callback invoker</param>
|
||||
/// <param name="onLoaded">AudioClip callback invoker when loaded</param>
|
||||
/// <returns>IEnumerator</returns>
|
||||
public static IEnumerator LoadAudioClipAsync(string filePath, AudioType audioType, bool streamAudio, Action<AudioClip> callback)
|
||||
public static IEnumerator LoadAudioClipAsync(string filePath,
|
||||
AudioType audioType,
|
||||
bool streamAudio,
|
||||
Action<AudioClip> onLoaded)
|
||||
{
|
||||
if (filePath.StartsWith("/")) filePath = filePath[1..];
|
||||
|
||||
@@ -42,7 +45,7 @@ namespace Core.DataLoader
|
||||
((DownloadHandlerAudioClip) request.downloadHandler).streamAudio = streamAudio;
|
||||
|
||||
AudioClip audioClip = DownloadHandlerAudioClip.GetContent(request);
|
||||
callback?.Invoke(audioClip);
|
||||
onLoaded?.Invoke(audioClip);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -13,17 +13,49 @@ namespace Core.DataLoader
|
||||
/// </summary>
|
||||
public sealed class BmpTextureLoader : ITextureLoader
|
||||
{
|
||||
private BMPImage _image;
|
||||
private BmpFile _image;
|
||||
|
||||
public void Load(byte[] data, out bool hasAlphaChannel)
|
||||
{
|
||||
hasAlphaChannel = false;
|
||||
_image = new BmpLoader().LoadBmp(data);
|
||||
_image = new BmpFileReader().Read(data);
|
||||
}
|
||||
|
||||
public Texture2D ToTexture2D()
|
||||
{
|
||||
return _image?.ToTexture2D();
|
||||
if (_image == null) return null;
|
||||
|
||||
var texture = new Texture2D(_image.Info.AbsWidth,
|
||||
_image.Info.AbsHeight,
|
||||
TextureFormat.RGBA32,
|
||||
mipChain: false);
|
||||
|
||||
if (_image.Info.Height < 0)
|
||||
{
|
||||
FlipImage();
|
||||
}
|
||||
|
||||
texture.SetPixels32(_image.ImageData);
|
||||
texture.Apply();
|
||||
return texture;
|
||||
}
|
||||
|
||||
// flip image if height is negative
|
||||
private void FlipImage()
|
||||
{
|
||||
if (_image.Info.Height > 0)
|
||||
return;
|
||||
int w = _image.Info.AbsWidth;
|
||||
int h = _image.Info.AbsHeight;
|
||||
int h2 = h / 2;
|
||||
for (int y = 0; y < h2; y++)
|
||||
{
|
||||
for(int x = 0, o1=y*w, o2=(h-y-1)*w; x < w; x++,o1++,o2++)
|
||||
{
|
||||
(_image.ImageData[o1], _image.ImageData[o2]) = (_image.ImageData[o2], _image.ImageData[o1]);
|
||||
}
|
||||
}
|
||||
_image.Info.Height = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,44 +31,55 @@ namespace Core.DataLoader
|
||||
var dataStartIndex = 18;
|
||||
_pixels = new Color32[_width * _height];
|
||||
|
||||
hasAlphaChannel = false;
|
||||
if (bitDepth == 32)
|
||||
switch (bitDepth)
|
||||
{
|
||||
fixed (byte* srcStart = &data[dataStartIndex], dstStart = &_pixels[0].r)
|
||||
case 32:
|
||||
hasAlphaChannel = Convert32BitData(data, dataStartIndex);
|
||||
break;
|
||||
case 24:
|
||||
hasAlphaChannel = false;
|
||||
Convert24BitData(data, dataStartIndex);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("TGA texture had non 32/24 bit depth.");
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe bool Convert32BitData(byte[] data, int startIndex)
|
||||
{
|
||||
bool hasAlphaChannel = false;
|
||||
fixed (byte* srcStart = &data[startIndex], dstStart = &_pixels[0].r)
|
||||
{
|
||||
var firstAlpha = *(srcStart + 3);
|
||||
byte* src = srcStart, dst = dstStart;
|
||||
for (var i = 0; i < _width * _height; i++, src += 4, dst += 4)
|
||||
{
|
||||
var firstAlpha = *(srcStart + 3);
|
||||
byte* src = srcStart, dst = dstStart;
|
||||
for (var i = 0; i < _width * _height; i++, src+=4, dst += 4)
|
||||
{
|
||||
*dst = *(src + 2);
|
||||
*(dst + 1) = *(src + 1);
|
||||
*(dst + 2) = *src;
|
||||
*dst = *(src + 2);
|
||||
*(dst + 1) = *(src + 1);
|
||||
*(dst + 2) = *src;
|
||||
|
||||
var alpha = *(src + 3);
|
||||
*(dst + 3) = alpha;
|
||||
var alpha = *(src + 3);
|
||||
*(dst + 3) = alpha;
|
||||
|
||||
if (alpha != firstAlpha) hasAlphaChannel = true;
|
||||
}
|
||||
if (alpha != firstAlpha) hasAlphaChannel = true;
|
||||
}
|
||||
}
|
||||
else if (bitDepth == 24)
|
||||
return hasAlphaChannel;
|
||||
}
|
||||
|
||||
private unsafe void Convert24BitData(byte[] data, int startIndex)
|
||||
{
|
||||
fixed (byte* srcStart = &data[startIndex], dstStart = &_pixels[0].r)
|
||||
{
|
||||
fixed (byte* srcStart = &data[dataStartIndex], dstStart = &_pixels[0].r)
|
||||
byte* src = srcStart, dst = dstStart;
|
||||
for (var i = 0; i < _width * _height; i++, src += 3, dst += 4)
|
||||
{
|
||||
byte* src = srcStart, dst = dstStart;
|
||||
for (var i = 0; i < _width * _height; i++, src += 3, dst += 4)
|
||||
{
|
||||
*dst = *(src + 2);
|
||||
*(dst + 1) = *(src + 1);
|
||||
*(dst + 2) = *src;
|
||||
*(dst + 3) = 0;
|
||||
}
|
||||
*dst = *(src + 2);
|
||||
*(dst + 1) = *(src + 1);
|
||||
*(dst + 2) = *src;
|
||||
*(dst + 3) = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("TGA texture had non 32/24 bit depth.");
|
||||
}
|
||||
}
|
||||
|
||||
public Texture2D ToTexture2D()
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Bmp
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class BmpFile
|
||||
{
|
||||
public BmpFileHeader Header;
|
||||
public BitmapInfoHeader Info;
|
||||
public uint RMask = 0x00FF0000;
|
||||
public uint GMask = 0x0000FF00;
|
||||
public uint BMask = 0x000000FF;
|
||||
public uint AMask = 0x00000000;
|
||||
public List<Color32> Palette;
|
||||
public Color32[] ImageData;
|
||||
|
||||
// private void ReplaceColor(Color32 aColorToSearch, Color32 aReplacementColor)
|
||||
// {
|
||||
// Color32 s = aColorToSearch;
|
||||
// for (int i = 0; i < ImageData.Length; i++)
|
||||
// {
|
||||
// Color32 c = ImageData[i];
|
||||
// if (c.r == s.r && c.g == s.g && c.b == s.b && c.a == s.a)
|
||||
// ImageData[i] = aReplacementColor;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void ReplaceFirstPixelColor(Color32 aReplacementColor)
|
||||
// {
|
||||
// ReplaceColor(ImageData[0], aReplacementColor);
|
||||
// }
|
||||
//
|
||||
// public void ReplaceFirstPixelColorWithTransparency()
|
||||
// {
|
||||
// ReplaceFirstPixelColor(new Color32(0, 0, 0, 0));
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9154c40a64f24da895b103e894c14457
|
||||
timeCreated: 1680782385
|
||||
+178
-226
@@ -57,7 +57,7 @@ namespace Core.DataReader.Bmp
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public enum BMPComressionMode : int
|
||||
public enum BmpCompressionMode : int
|
||||
{
|
||||
BI_RGB = 0x00,
|
||||
BI_RLE8 = 0x01,
|
||||
@@ -70,247 +70,183 @@ namespace Core.DataReader.Bmp
|
||||
BI_CMYK = 0x0B,
|
||||
BI_CMYKRLE8 = 0x0C,
|
||||
BI_CMYKRLE4 = 0x0D,
|
||||
}
|
||||
|
||||
}
|
||||
public struct BMPFileHeader
|
||||
public struct BmpFileHeader
|
||||
{
|
||||
public ushort magic; // "BM"
|
||||
public uint filesize;
|
||||
public uint reserved;
|
||||
public uint offset;
|
||||
public ushort Magic; // "BM"
|
||||
public uint Filesize;
|
||||
public uint Reserved;
|
||||
public uint Offset;
|
||||
}
|
||||
|
||||
public struct BitmapInfoHeader
|
||||
{
|
||||
public uint size;
|
||||
public int width;
|
||||
public int height;
|
||||
public ushort nColorPlanes; // always 1
|
||||
public ushort nBitsPerPixel; // [1,4,8,16,24,32]
|
||||
public BMPComressionMode compressionMethod;
|
||||
public uint rawImageSize; // can be "0"
|
||||
public int xPPM;
|
||||
public int yPPM;
|
||||
public uint nPaletteColors;
|
||||
public uint nImportantColors;
|
||||
|
||||
public int absWidth { get { return Mathf.Abs(width); } }
|
||||
public int absHeight { get { return Mathf.Abs(height); } }
|
||||
public uint Size;
|
||||
public int Width;
|
||||
public int Height;
|
||||
public ushort NColorPlanes; // always 1
|
||||
public ushort NBitsPerPixel; // [1,4,8,16,24,32]
|
||||
public BmpCompressionMode CompressionMode;
|
||||
public uint RawImageSize; // can be "0"
|
||||
public int XPpm;
|
||||
public int YPpm;
|
||||
public uint NPaletteColors;
|
||||
public uint NImportantColors;
|
||||
|
||||
public int AbsWidth { get { return Mathf.Abs(Width); } }
|
||||
public int AbsHeight { get { return Mathf.Abs(Height); } }
|
||||
}
|
||||
|
||||
public sealed class BMPImage
|
||||
public sealed class BmpFileReader
|
||||
{
|
||||
public BMPFileHeader header;
|
||||
public BitmapInfoHeader info;
|
||||
public uint rMask = 0x00FF0000;
|
||||
public uint gMask = 0x0000FF00;
|
||||
public uint bMask = 0x000000FF;
|
||||
public uint aMask = 0x00000000;
|
||||
public List<Color32> palette;
|
||||
public Color32[] imageData;
|
||||
private const ushort MAGIC = 0x4D42; // "BM" little endian
|
||||
|
||||
public Texture2D ToTexture2D()
|
||||
{
|
||||
var texture = new Texture2D(info.absWidth,
|
||||
info.absHeight,
|
||||
TextureFormat.RGBA32,
|
||||
mipChain: false);
|
||||
private bool READ_PALETTE_ALPHA = false;
|
||||
private bool FORCE_ALPHA_READ_WHEN_POSSIBLE = false;
|
||||
|
||||
if (info.height < 0)
|
||||
FlipImage();
|
||||
|
||||
texture.SetPixels32(imageData);
|
||||
texture.Apply();
|
||||
return texture;
|
||||
}
|
||||
|
||||
// flip image if height is negative
|
||||
internal void FlipImage()
|
||||
{
|
||||
if (info.height > 0)
|
||||
return;
|
||||
int w = info.absWidth;
|
||||
int h = info.absHeight;
|
||||
int h2 = h / 2;
|
||||
for (int y = 0; y < h2; y++)
|
||||
{
|
||||
for(int x = 0, o1=y*w, o2=(h-y-1)*w; x < w; x++,o1++,o2++)
|
||||
{
|
||||
(imageData[o1], imageData[o2]) = (imageData[o2], imageData[o1]);
|
||||
}
|
||||
}
|
||||
info.height = h;
|
||||
}
|
||||
|
||||
public void ReplaceColor(Color32 aColorToSearch, Color32 aReplacementColor)
|
||||
{
|
||||
Color32 s = aColorToSearch;
|
||||
for (int i = 0; i < imageData.Length; i++)
|
||||
{
|
||||
Color32 c = imageData[i];
|
||||
if (c.r == s.r && c.g == s.g && c.b == s.b && c.a == s.a)
|
||||
imageData[i] = aReplacementColor;
|
||||
}
|
||||
}
|
||||
public void ReplaceFirstPixelColor(Color32 aReplacementColor)
|
||||
{
|
||||
ReplaceColor(imageData[0], aReplacementColor);
|
||||
}
|
||||
public void ReplaceFirstPixelColorWithTransparency()
|
||||
{
|
||||
ReplaceFirstPixelColor(new Color32(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public class BmpLoader
|
||||
{
|
||||
const ushort MAGIC = 0x4D42; // "BM" little endian
|
||||
public bool ReadPaletteAlpha = false;
|
||||
public bool ForceAlphaReadWhenPossible = false;
|
||||
|
||||
public BMPImage LoadBmp(string aFileName)
|
||||
public BmpFile Read(string aFileName)
|
||||
{
|
||||
using FileStream file = File.OpenRead(aFileName);
|
||||
return LoadBmp(file);
|
||||
return Read(file);
|
||||
}
|
||||
|
||||
public BMPImage LoadBmp(byte[] aData)
|
||||
public BmpFile Read(byte[] aData)
|
||||
{
|
||||
using var stream = new MemoryStream(aData);
|
||||
return LoadBmp(stream);
|
||||
return Read(stream);
|
||||
}
|
||||
|
||||
public BMPImage LoadBmp(Stream aData)
|
||||
public BmpFile Read(Stream aData)
|
||||
{
|
||||
using var reader = new BinaryReader(aData);
|
||||
return LoadBmp(reader);
|
||||
return Read(reader);
|
||||
}
|
||||
|
||||
public BMPImage LoadBmp(BinaryReader aReader)
|
||||
public BmpFile Read(BinaryReader aReader)
|
||||
{
|
||||
BMPImage bmp = new BMPImage();
|
||||
if (!ReadFileHeader(aReader, ref bmp.header))
|
||||
BmpFile bmp = new BmpFile();
|
||||
if (!ReadFileHeader(aReader, ref bmp.Header))
|
||||
{
|
||||
Debug.LogError("Not a BMP file");
|
||||
return null;
|
||||
}
|
||||
if (!ReadInfoHeader(aReader, ref bmp.info))
|
||||
if (!ReadInfoHeader(aReader, ref bmp.Info))
|
||||
{
|
||||
Debug.LogError("Unsupported header format");
|
||||
return null;
|
||||
}
|
||||
if (bmp.info.compressionMethod != BMPComressionMode.BI_RGB
|
||||
&& bmp.info.compressionMethod != BMPComressionMode.BI_BITFIELDS
|
||||
&& bmp.info.compressionMethod != BMPComressionMode.BI_ALPHABITFIELDS
|
||||
&& bmp.info.compressionMethod != BMPComressionMode.BI_RLE4
|
||||
&& bmp.info.compressionMethod != BMPComressionMode.BI_RLE8
|
||||
if (bmp.Info.CompressionMode != BmpCompressionMode.BI_RGB
|
||||
&& bmp.Info.CompressionMode != BmpCompressionMode.BI_BITFIELDS
|
||||
&& bmp.Info.CompressionMode != BmpCompressionMode.BI_ALPHABITFIELDS
|
||||
&& bmp.Info.CompressionMode != BmpCompressionMode.BI_RLE4
|
||||
&& bmp.Info.CompressionMode != BmpCompressionMode.BI_RLE8
|
||||
)
|
||||
{
|
||||
Debug.LogError("Unsupported image format: " + bmp.info.compressionMethod);
|
||||
Debug.LogError("Unsupported image format: " + bmp.Info.CompressionMode);
|
||||
return null;
|
||||
}
|
||||
long offset = 14 + bmp.info.size;
|
||||
long offset = 14 + bmp.Info.Size;
|
||||
aReader.BaseStream.Seek(offset, SeekOrigin.Begin);
|
||||
if (bmp.info.nBitsPerPixel < 24)
|
||||
if (bmp.Info.NBitsPerPixel < 24)
|
||||
{
|
||||
bmp.rMask = 0x00007C00;
|
||||
bmp.gMask = 0x000003E0;
|
||||
bmp.bMask = 0x0000001F;
|
||||
bmp.RMask = 0x00007C00;
|
||||
bmp.GMask = 0x000003E0;
|
||||
bmp.BMask = 0x0000001F;
|
||||
}
|
||||
|
||||
if (bmp.info.nBitsPerPixel > 8 && (bmp.info.compressionMethod == BMPComressionMode.BI_BITFIELDS || bmp.info.compressionMethod == BMPComressionMode.BI_ALPHABITFIELDS))
|
||||
if (bmp.Info.NBitsPerPixel > 8 && (bmp.Info.CompressionMode == BmpCompressionMode.BI_BITFIELDS || bmp.Info.CompressionMode == BmpCompressionMode.BI_ALPHABITFIELDS))
|
||||
{
|
||||
bmp.rMask = aReader.ReadUInt32();
|
||||
bmp.gMask = aReader.ReadUInt32();
|
||||
bmp.bMask = aReader.ReadUInt32();
|
||||
bmp.RMask = aReader.ReadUInt32();
|
||||
bmp.GMask = aReader.ReadUInt32();
|
||||
bmp.BMask = aReader.ReadUInt32();
|
||||
}
|
||||
if (ForceAlphaReadWhenPossible)
|
||||
bmp.aMask = GetMask(bmp.info.nBitsPerPixel) ^ (bmp.rMask | bmp.gMask | bmp.bMask);
|
||||
if (FORCE_ALPHA_READ_WHEN_POSSIBLE)
|
||||
bmp.AMask = GetMask(bmp.Info.NBitsPerPixel) ^ (bmp.RMask | bmp.GMask | bmp.BMask);
|
||||
|
||||
if (bmp.info.compressionMethod == BMPComressionMode.BI_ALPHABITFIELDS)
|
||||
bmp.aMask = aReader.ReadUInt32();
|
||||
if (bmp.Info.CompressionMode == BmpCompressionMode.BI_ALPHABITFIELDS)
|
||||
bmp.AMask = aReader.ReadUInt32();
|
||||
|
||||
if (bmp.info.nPaletteColors > 0 || bmp.info.nBitsPerPixel <= 8)
|
||||
bmp.palette = ReadPalette(aReader, bmp, ReadPaletteAlpha || ForceAlphaReadWhenPossible);
|
||||
if (bmp.Info.NPaletteColors > 0 || bmp.Info.NBitsPerPixel <= 8)
|
||||
bmp.Palette = ReadPalette(aReader, bmp, READ_PALETTE_ALPHA || FORCE_ALPHA_READ_WHEN_POSSIBLE);
|
||||
|
||||
|
||||
aReader.BaseStream.Seek(bmp.header.offset, SeekOrigin.Begin);
|
||||
bool uncompressed = bmp.info.compressionMethod == BMPComressionMode.BI_RGB ||
|
||||
bmp.info.compressionMethod == BMPComressionMode.BI_BITFIELDS ||
|
||||
bmp.info.compressionMethod == BMPComressionMode.BI_ALPHABITFIELDS;
|
||||
if (bmp.info.nBitsPerPixel == 32 && uncompressed)
|
||||
aReader.BaseStream.Seek(bmp.Header.Offset, SeekOrigin.Begin);
|
||||
bool uncompressed = bmp.Info.CompressionMode == BmpCompressionMode.BI_RGB ||
|
||||
bmp.Info.CompressionMode == BmpCompressionMode.BI_BITFIELDS ||
|
||||
bmp.Info.CompressionMode == BmpCompressionMode.BI_ALPHABITFIELDS;
|
||||
if (bmp.Info.NBitsPerPixel == 32 && uncompressed)
|
||||
Read32BitImage(aReader, bmp);
|
||||
else if (bmp.info.nBitsPerPixel == 24 && uncompressed)
|
||||
else if (bmp.Info.NBitsPerPixel == 24 && uncompressed)
|
||||
Read24BitImage(aReader, bmp);
|
||||
else if (bmp.info.nBitsPerPixel == 16 && uncompressed)
|
||||
else if (bmp.Info.NBitsPerPixel == 16 && uncompressed)
|
||||
Read16BitImage(aReader, bmp);
|
||||
else if (bmp.info.compressionMethod == BMPComressionMode.BI_RLE4 && bmp.info.nBitsPerPixel == 4 && bmp.palette != null)
|
||||
else if (bmp.Info.CompressionMode == BmpCompressionMode.BI_RLE4 && bmp.Info.NBitsPerPixel == 4 && bmp.Palette != null)
|
||||
ReadIndexedImageRLE4(aReader, bmp);
|
||||
else if (bmp.info.compressionMethod == BMPComressionMode.BI_RLE8 && bmp.info.nBitsPerPixel == 8 && bmp.palette != null)
|
||||
else if (bmp.Info.CompressionMode == BmpCompressionMode.BI_RLE8 && bmp.Info.NBitsPerPixel == 8 && bmp.Palette != null)
|
||||
ReadIndexedImageRLE8(aReader, bmp);
|
||||
else if (uncompressed && bmp.info.nBitsPerPixel <= 8 && bmp.palette != null)
|
||||
else if (uncompressed && bmp.Info.NBitsPerPixel <= 8 && bmp.Palette != null)
|
||||
ReadIndexedImage(aReader, bmp);
|
||||
else
|
||||
{
|
||||
Debug.LogError("Unsupported file format: " + bmp.info.compressionMethod + " BPP: " + bmp.info.nBitsPerPixel);
|
||||
Debug.LogError("Unsupported file format: " + bmp.Info.CompressionMode + " BPP: " + bmp.Info.NBitsPerPixel);
|
||||
return null;
|
||||
}
|
||||
return bmp;
|
||||
}
|
||||
|
||||
|
||||
private static void Read32BitImage(BinaryReader aReader, BMPImage bmp)
|
||||
private static void Read32BitImage(BinaryReader aReader, BmpFile bmp)
|
||||
{
|
||||
int w = Mathf.Abs(bmp.info.width);
|
||||
int h = Mathf.Abs(bmp.info.height);
|
||||
Color32[] data = bmp.imageData = new Color32[w * h];
|
||||
int w = Mathf.Abs(bmp.Info.Width);
|
||||
int h = Mathf.Abs(bmp.Info.Height);
|
||||
Color32[] data = bmp.ImageData = new Color32[w * h];
|
||||
if (aReader.BaseStream.Position + w * h * 4 > aReader.BaseStream.Length)
|
||||
{
|
||||
Debug.LogError("Unexpected end of file.");
|
||||
return;
|
||||
}
|
||||
int shiftR = GetShiftCount(bmp.rMask);
|
||||
int shiftG = GetShiftCount(bmp.gMask);
|
||||
int shiftB = GetShiftCount(bmp.bMask);
|
||||
int shiftA = GetShiftCount(bmp.aMask);
|
||||
int shiftR = GetShiftCount(bmp.RMask);
|
||||
int shiftG = GetShiftCount(bmp.GMask);
|
||||
int shiftB = GetShiftCount(bmp.BMask);
|
||||
int shiftA = GetShiftCount(bmp.AMask);
|
||||
byte a = 255;
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
uint v = aReader.ReadUInt32();
|
||||
byte r = (byte)((v & bmp.rMask) >> shiftR);
|
||||
byte g = (byte)((v & bmp.gMask) >> shiftG);
|
||||
byte b = (byte)((v & bmp.bMask) >> shiftB);
|
||||
if (bmp.bMask != 0)
|
||||
a = (byte)((v & bmp.aMask) >> shiftA);
|
||||
byte r = (byte)((v & bmp.RMask) >> shiftR);
|
||||
byte g = (byte)((v & bmp.GMask) >> shiftG);
|
||||
byte b = (byte)((v & bmp.BMask) >> shiftB);
|
||||
if (bmp.BMask != 0)
|
||||
a = (byte)((v & bmp.AMask) >> shiftA);
|
||||
data[i] = new Color32(r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void Read24BitImage(BinaryReader aReader, BMPImage bmp)
|
||||
private static void Read24BitImage(BinaryReader aReader, BmpFile bmp)
|
||||
{
|
||||
int w = Mathf.Abs(bmp.info.width);
|
||||
int h = Mathf.Abs(bmp.info.height);
|
||||
int w = Mathf.Abs(bmp.Info.Width);
|
||||
int h = Mathf.Abs(bmp.Info.Height);
|
||||
int rowLength = ((24 * w + 31) / 32) * 4;
|
||||
int count = rowLength * h;
|
||||
int pad = rowLength - w * 3;
|
||||
Color32[] data = bmp.imageData = new Color32[w * h];
|
||||
Color32[] data = bmp.ImageData = new Color32[w * h];
|
||||
if (aReader.BaseStream.Position + count > aReader.BaseStream.Length)
|
||||
{
|
||||
Debug.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)");
|
||||
return;
|
||||
}
|
||||
int shiftR = GetShiftCount(bmp.rMask);
|
||||
int shiftG = GetShiftCount(bmp.gMask);
|
||||
int shiftB = GetShiftCount(bmp.bMask);
|
||||
int shiftR = GetShiftCount(bmp.RMask);
|
||||
int shiftG = GetShiftCount(bmp.GMask);
|
||||
int shiftB = GetShiftCount(bmp.BMask);
|
||||
for (int y = 0; y < h; y++)
|
||||
{
|
||||
for (int x = 0; x < w; x++)
|
||||
{
|
||||
uint v = aReader.ReadByte() | ((uint)aReader.ReadByte() << 8) | ((uint)aReader.ReadByte() << 16);
|
||||
byte r = (byte)((v & bmp.rMask) >> shiftR);
|
||||
byte g = (byte)((v & bmp.gMask) >> shiftG);
|
||||
byte b = (byte)((v & bmp.bMask) >> shiftB);
|
||||
byte r = (byte)((v & bmp.RMask) >> shiftR);
|
||||
byte g = (byte)((v & bmp.GMask) >> shiftG);
|
||||
byte b = (byte)((v & bmp.BMask) >> shiftB);
|
||||
data[x + y * w] = new Color32(r, g, b, 255);
|
||||
}
|
||||
for (int i = 0; i < pad; i++)
|
||||
@@ -318,34 +254,34 @@ namespace Core.DataReader.Bmp
|
||||
}
|
||||
}
|
||||
|
||||
private static void Read16BitImage(BinaryReader aReader, BMPImage bmp)
|
||||
private static void Read16BitImage(BinaryReader aReader, BmpFile bmp)
|
||||
{
|
||||
int w = Mathf.Abs(bmp.info.width);
|
||||
int h = Mathf.Abs(bmp.info.height);
|
||||
int w = Mathf.Abs(bmp.Info.Width);
|
||||
int h = Mathf.Abs(bmp.Info.Height);
|
||||
int rowLength = ((16 * w + 31) / 32) * 4;
|
||||
int count = rowLength * h;
|
||||
int pad = rowLength - w * 2;
|
||||
Color32[] data = bmp.imageData = new Color32[w * h];
|
||||
Color32[] data = bmp.ImageData = new Color32[w * h];
|
||||
if (aReader.BaseStream.Position + count > aReader.BaseStream.Length)
|
||||
{
|
||||
Debug.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)");
|
||||
return;
|
||||
}
|
||||
int shiftR = GetShiftCount(bmp.rMask);
|
||||
int shiftG = GetShiftCount(bmp.gMask);
|
||||
int shiftB = GetShiftCount(bmp.bMask);
|
||||
int shiftA = GetShiftCount(bmp.aMask);
|
||||
int shiftR = GetShiftCount(bmp.RMask);
|
||||
int shiftG = GetShiftCount(bmp.GMask);
|
||||
int shiftB = GetShiftCount(bmp.BMask);
|
||||
int shiftA = GetShiftCount(bmp.AMask);
|
||||
byte a = 255;
|
||||
for (int y = 0; y < h; y++)
|
||||
{
|
||||
for (int x = 0; x < w; x++)
|
||||
{
|
||||
uint v = aReader.ReadByte() | ((uint)aReader.ReadByte() << 8);
|
||||
byte r = (byte)((v & bmp.rMask) >> shiftR);
|
||||
byte g = (byte)((v & bmp.gMask) >> shiftG);
|
||||
byte b = (byte)((v & bmp.bMask) >> shiftB);
|
||||
if (bmp.aMask != 0)
|
||||
a = (byte)((v & bmp.aMask) >> shiftA);
|
||||
byte r = (byte)((v & bmp.RMask) >> shiftR);
|
||||
byte g = (byte)((v & bmp.GMask) >> shiftG);
|
||||
byte b = (byte)((v & bmp.BMask) >> shiftB);
|
||||
if (bmp.AMask != 0)
|
||||
a = (byte)((v & bmp.AMask) >> shiftA);
|
||||
data[x + y * w] = new Color32(r, g, b, a);
|
||||
}
|
||||
for (int i = 0; i < pad; i++)
|
||||
@@ -353,15 +289,15 @@ namespace Core.DataReader.Bmp
|
||||
}
|
||||
}
|
||||
|
||||
private static void ReadIndexedImage(BinaryReader aReader, BMPImage bmp)
|
||||
private static void ReadIndexedImage(BinaryReader aReader, BmpFile bmp)
|
||||
{
|
||||
int w = Mathf.Abs(bmp.info.width);
|
||||
int h = Mathf.Abs(bmp.info.height);
|
||||
int bitCount = bmp.info.nBitsPerPixel;
|
||||
int w = Mathf.Abs(bmp.Info.Width);
|
||||
int h = Mathf.Abs(bmp.Info.Height);
|
||||
int bitCount = bmp.Info.NBitsPerPixel;
|
||||
int rowLength = ((bitCount * w + 31) / 32) * 4;
|
||||
int count = rowLength * h;
|
||||
int pad = rowLength - (w * bitCount + 7) / 8;
|
||||
Color32[] data = bmp.imageData = new Color32[w * h];
|
||||
Color32[] data = bmp.ImageData = new Color32[w * h];
|
||||
if (aReader.BaseStream.Position + count > aReader.BaseStream.Length)
|
||||
{
|
||||
Debug.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)");
|
||||
@@ -373,23 +309,24 @@ namespace Core.DataReader.Bmp
|
||||
for (int x = 0; x < w; x++)
|
||||
{
|
||||
int v = (int)bitReader.ReadBits(bitCount);
|
||||
if (v >= bmp.palette.Count)
|
||||
if (v >= bmp.Palette.Count)
|
||||
{
|
||||
Debug.LogError("Indexed bitmap has indices greater than it's color palette");
|
||||
return;
|
||||
}
|
||||
data[x + y * w] = bmp.palette[v];
|
||||
data[x + y * w] = bmp.Palette[v];
|
||||
}
|
||||
bitReader.Flush();
|
||||
for (int i = 0; i < pad; i++)
|
||||
aReader.ReadByte();
|
||||
}
|
||||
}
|
||||
private static void ReadIndexedImageRLE4(BinaryReader aReader, BMPImage bmp)
|
||||
|
||||
private static void ReadIndexedImageRLE4(BinaryReader aReader, BmpFile bmp)
|
||||
{
|
||||
int w = Mathf.Abs(bmp.info.width);
|
||||
int h = Mathf.Abs(bmp.info.height);
|
||||
Color32[] data = bmp.imageData = new Color32[w * h];
|
||||
int w = Mathf.Abs(bmp.Info.Width);
|
||||
int h = Mathf.Abs(bmp.Info.Height);
|
||||
Color32[] data = bmp.ImageData = new Color32[w * h];
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int yOffset = 0;
|
||||
@@ -401,12 +338,12 @@ namespace Core.DataReader.Bmp
|
||||
{
|
||||
for (int i = (count / 2); i > 0; i--)
|
||||
{
|
||||
data[x++ + yOffset] = bmp.palette[(d >> 4) & 0x0F];
|
||||
data[x++ + yOffset] = bmp.palette[d & 0x0F];
|
||||
data[x++ + yOffset] = bmp.Palette[(d >> 4) & 0x0F];
|
||||
data[x++ + yOffset] = bmp.Palette[d & 0x0F];
|
||||
}
|
||||
if ((count & 0x01) > 0)
|
||||
{
|
||||
data[x++ + yOffset] = bmp.palette[(d >> 4) & 0x0F];
|
||||
data[x++ + yOffset] = bmp.Palette[(d >> 4) & 0x0F];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -432,13 +369,13 @@ namespace Core.DataReader.Bmp
|
||||
for (int i = (d / 2); i > 0; i--)
|
||||
{
|
||||
byte d2 = aReader.ReadByte();
|
||||
data[x++ + yOffset] = bmp.palette[(d2 >> 4) & 0x0F];
|
||||
data[x++ + yOffset] = bmp.Palette[(d2 >> 4) & 0x0F];
|
||||
if (x + 1 < w)
|
||||
data[x++ + yOffset] = bmp.palette[d2 & 0x0F];
|
||||
data[x++ + yOffset] = bmp.Palette[d2 & 0x0F];
|
||||
}
|
||||
if ((d & 0x01) > 0)
|
||||
{
|
||||
data[x++ + yOffset] = bmp.palette[(aReader.ReadByte() >> 4) & 0x0F];
|
||||
data[x++ + yOffset] = bmp.Palette[(aReader.ReadByte() >> 4) & 0x0F];
|
||||
}
|
||||
if ((((d - 1) / 2) & 1) == 0)
|
||||
{
|
||||
@@ -448,11 +385,12 @@ namespace Core.DataReader.Bmp
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void ReadIndexedImageRLE8(BinaryReader aReader, BMPImage bmp)
|
||||
|
||||
private static void ReadIndexedImageRLE8(BinaryReader aReader, BmpFile bmp)
|
||||
{
|
||||
int w = Mathf.Abs(bmp.info.width);
|
||||
int h = Mathf.Abs(bmp.info.height);
|
||||
Color32[] data = bmp.imageData = new Color32[w * h];
|
||||
int w = Mathf.Abs(bmp.Info.Width);
|
||||
int h = Mathf.Abs(bmp.Info.Height);
|
||||
Color32[] data = bmp.ImageData = new Color32[w * h];
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int yOffset = 0;
|
||||
@@ -464,7 +402,7 @@ namespace Core.DataReader.Bmp
|
||||
{
|
||||
for (int i = count; i > 0; i--)
|
||||
{
|
||||
data[x++ + yOffset] = bmp.palette[d];
|
||||
data[x++ + yOffset] = bmp.Palette[d];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -489,7 +427,7 @@ namespace Core.DataReader.Bmp
|
||||
{
|
||||
for (int i = d; i > 0; i--)
|
||||
{
|
||||
data[x++ + yOffset] = bmp.palette[aReader.ReadByte()];
|
||||
data[x++ + yOffset] = bmp.Palette[aReader.ReadByte()];
|
||||
}
|
||||
if ((d & 0x01) > 0)
|
||||
{
|
||||
@@ -499,6 +437,7 @@ namespace Core.DataReader.Bmp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetShiftCount(uint mask)
|
||||
{
|
||||
for (int i = 0; i < 32; i++)
|
||||
@@ -509,6 +448,7 @@ namespace Core.DataReader.Bmp
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static uint GetMask(int bitCount)
|
||||
{
|
||||
uint mask = 0;
|
||||
@@ -519,41 +459,44 @@ namespace Core.DataReader.Bmp
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
private static bool ReadFileHeader(BinaryReader aReader, ref BMPFileHeader aFileHeader)
|
||||
|
||||
private static bool ReadFileHeader(BinaryReader aReader, ref BmpFileHeader aFileHeader)
|
||||
{
|
||||
aFileHeader.magic = aReader.ReadUInt16();
|
||||
if (aFileHeader.magic != MAGIC)
|
||||
aFileHeader.Magic = aReader.ReadUInt16();
|
||||
if (aFileHeader.Magic != MAGIC)
|
||||
return false;
|
||||
aFileHeader.filesize = aReader.ReadUInt32();
|
||||
aFileHeader.reserved = aReader.ReadUInt32();
|
||||
aFileHeader.offset = aReader.ReadUInt32();
|
||||
aFileHeader.Filesize = aReader.ReadUInt32();
|
||||
aFileHeader.Reserved = aReader.ReadUInt32();
|
||||
aFileHeader.Offset = aReader.ReadUInt32();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool ReadInfoHeader(BinaryReader aReader, ref BitmapInfoHeader aHeader)
|
||||
{
|
||||
aHeader.size = aReader.ReadUInt32();
|
||||
if (aHeader.size < 40)
|
||||
aHeader.Size = aReader.ReadUInt32();
|
||||
if (aHeader.Size < 40)
|
||||
return false;
|
||||
aHeader.width = aReader.ReadInt32();
|
||||
aHeader.height = aReader.ReadInt32();
|
||||
aHeader.nColorPlanes = aReader.ReadUInt16();
|
||||
aHeader.nBitsPerPixel = aReader.ReadUInt16();
|
||||
aHeader.compressionMethod = (BMPComressionMode)aReader.ReadInt32();
|
||||
aHeader.rawImageSize = aReader.ReadUInt32();
|
||||
aHeader.xPPM = aReader.ReadInt32();
|
||||
aHeader.yPPM = aReader.ReadInt32();
|
||||
aHeader.nPaletteColors = aReader.ReadUInt32();
|
||||
aHeader.nImportantColors = aReader.ReadUInt32();
|
||||
int pad = (int)aHeader.size - 40;
|
||||
aHeader.Width = aReader.ReadInt32();
|
||||
aHeader.Height = aReader.ReadInt32();
|
||||
aHeader.NColorPlanes = aReader.ReadUInt16();
|
||||
aHeader.NBitsPerPixel = aReader.ReadUInt16();
|
||||
aHeader.CompressionMode = (BmpCompressionMode)aReader.ReadInt32();
|
||||
aHeader.RawImageSize = aReader.ReadUInt32();
|
||||
aHeader.XPpm = aReader.ReadInt32();
|
||||
aHeader.YPpm = aReader.ReadInt32();
|
||||
aHeader.NPaletteColors = aReader.ReadUInt32();
|
||||
aHeader.NImportantColors = aReader.ReadUInt32();
|
||||
int pad = (int)aHeader.Size - 40;
|
||||
if (pad > 0)
|
||||
aReader.ReadBytes(pad);
|
||||
return true;
|
||||
}
|
||||
public static List<Color32> ReadPalette(BinaryReader aReader, BMPImage aBmp, bool aReadAlpha)
|
||||
|
||||
public static List<Color32> ReadPalette(BinaryReader aReader, BmpFile aBmp, bool aReadAlpha)
|
||||
{
|
||||
uint count = aBmp.info.nPaletteColors;
|
||||
uint count = aBmp.Info.NPaletteColors;
|
||||
if (count == 0u)
|
||||
count = 1u << aBmp.info.nBitsPerPixel;
|
||||
count = 1u << aBmp.Info.NBitsPerPixel;
|
||||
var palette = new List<Color32>((int)count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
@@ -569,43 +512,52 @@ namespace Core.DataReader.Bmp
|
||||
}
|
||||
|
||||
}
|
||||
public class BitStreamReader
|
||||
|
||||
internal class BitStreamReader
|
||||
{
|
||||
BinaryReader m_Reader;
|
||||
byte m_Data = 0;
|
||||
int m_Bits = 0;
|
||||
private readonly BinaryReader _mReader;
|
||||
|
||||
private byte _mData = 0;
|
||||
private int _mBits = 0;
|
||||
|
||||
public BitStreamReader(BinaryReader aReader)
|
||||
{
|
||||
m_Reader = aReader;
|
||||
_mReader = aReader;
|
||||
}
|
||||
|
||||
public BitStreamReader(Stream aStream) : this(new BinaryReader(aStream)) { }
|
||||
|
||||
public byte ReadBit()
|
||||
{
|
||||
if (m_Bits <= 0)
|
||||
if (_mBits <= 0)
|
||||
{
|
||||
m_Data = m_Reader.ReadByte();
|
||||
m_Bits = 8;
|
||||
_mData = _mReader.ReadByte();
|
||||
_mBits = 8;
|
||||
}
|
||||
return (byte)((m_Data >> --m_Bits) & 1);
|
||||
return (byte)((_mData >> --_mBits) & 1);
|
||||
}
|
||||
|
||||
public ulong ReadBits(int aCount)
|
||||
{
|
||||
ulong val = 0UL;
|
||||
if (aCount <= 0 || aCount > 32)
|
||||
throw new ArgumentOutOfRangeException("aCount", "aCount must be between 1 and 32 inclusive");
|
||||
for (int i = aCount - 1; i >= 0; i--)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(aCount), "aCount must be between 1 and 32 inclusive");
|
||||
}
|
||||
|
||||
ulong val = 0UL;
|
||||
|
||||
for (var i = aCount - 1; i >= 0; i--)
|
||||
{
|
||||
val |= ((ulong)ReadBit() << i);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public void Flush()
|
||||
{
|
||||
m_Data = 0;
|
||||
m_Bits = 0;
|
||||
_mData = 0;
|
||||
_mBits = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -11,7 +11,6 @@ namespace Core.DataReader.Cpk
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Lzo;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
/// <summary>
|
||||
@@ -26,7 +25,7 @@ namespace Core.DataReader.Cpk
|
||||
private const int CPK_DEFAULT_MAX_NUM_OF_FILE = 32768; // Max number of files per archive
|
||||
|
||||
private readonly string _filePath;
|
||||
private readonly CrcHash _crcHash;
|
||||
private readonly Crc32Hash _crcHash;
|
||||
private readonly int _codepage;
|
||||
private Dictionary<uint, CpkTableEntity> _tableEntities;
|
||||
|
||||
@@ -37,7 +36,7 @@ namespace Core.DataReader.Cpk
|
||||
private bool _archiveInMemory;
|
||||
private byte[] _archiveData;
|
||||
|
||||
public CpkArchive(string cpkFilePath, CrcHash crcHash, int codepage)
|
||||
public CpkArchive(string cpkFilePath, Crc32Hash crcHash, int codepage)
|
||||
{
|
||||
if (!File.Exists(cpkFilePath))
|
||||
{
|
||||
@@ -129,7 +128,7 @@ namespace Core.DataReader.Cpk
|
||||
/// <returns>True if file exists</returns>
|
||||
public bool FileExists(string fileVirtualPath)
|
||||
{
|
||||
var crc = _crcHash.ComputeCrc32Hash(fileVirtualPath.ToLower(), _codepage);
|
||||
var crc = _crcHash.Compute(fileVirtualPath.ToLower(), _codepage);
|
||||
return _crcToTableIndexMap.ContainsKey(crc);
|
||||
}
|
||||
|
||||
@@ -201,7 +200,7 @@ namespace Core.DataReader.Cpk
|
||||
|
||||
private CpkTableEntity ValidateAndGetTableEntity(string fileVirtualPath)
|
||||
{
|
||||
var crc = _crcHash.ComputeCrc32Hash(fileVirtualPath.ToLower(), _codepage);
|
||||
var crc = _crcHash.Compute(fileVirtualPath.ToLower(), _codepage);
|
||||
if (!_crcToTableIndexMap.ContainsKey(crc))
|
||||
{
|
||||
throw new ArgumentException($"<{fileVirtualPath}> does not exists in the archive.");
|
||||
@@ -253,9 +252,9 @@ namespace Core.DataReader.Cpk
|
||||
{
|
||||
_crcToTableIndexMap[entity.CRC] = index;
|
||||
|
||||
if (_fatherCrcToChildCrcTableIndexMap.ContainsKey(entity.FatherCRC))
|
||||
if (_fatherCrcToChildCrcTableIndexMap.TryGetValue(entity.FatherCRC, out var childCrcTable))
|
||||
{
|
||||
_fatherCrcToChildCrcTableIndexMap[entity.FatherCRC].Add(entity.CRC);
|
||||
childCrcTable.Add(entity.CRC);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Core.DataReader.Cpk
|
||||
/// <summary>
|
||||
/// CpkEntry model
|
||||
/// </summary>
|
||||
public class CpkEntry
|
||||
public sealed class CpkEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Virtualized file system path within the CPK archive.
|
||||
|
||||
@@ -10,9 +10,9 @@ namespace Core.DataReader.Cpk
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Crc hash provider.
|
||||
/// Crc32 hash provider.
|
||||
/// </summary>
|
||||
public sealed class CrcHash
|
||||
public sealed class Crc32Hash
|
||||
{
|
||||
private const uint CRC_TABLE_MAX = 256;
|
||||
private const uint POLYNOMIAL = 0x04C11DB7; // CRC seed
|
||||
@@ -41,28 +41,28 @@ namespace Core.DataReader.Cpk
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public uint ComputeCrc32Hash(string str, int codepage, bool useCache = true)
|
||||
public uint Compute(string str, int codepage, bool useCache = true)
|
||||
{
|
||||
if (!useCache)
|
||||
{
|
||||
return ComputeCrc32HashInternal(Encoding.GetEncoding(codepage).GetBytes(str));
|
||||
return ComputeInternal(Encoding.GetEncoding(codepage).GetBytes(str));
|
||||
}
|
||||
|
||||
var cacheKey = $"{str}-{codepage}";
|
||||
|
||||
if (_crcResultCache.ContainsKey(cacheKey))
|
||||
if (_crcResultCache.TryGetValue(cacheKey, out var hash))
|
||||
{
|
||||
return _crcResultCache[cacheKey];
|
||||
return hash;
|
||||
}
|
||||
|
||||
uint result = ComputeCrc32HashInternal(Encoding.GetEncoding(codepage).GetBytes(str));
|
||||
uint result = ComputeInternal(Encoding.GetEncoding(codepage).GetBytes(str));
|
||||
|
||||
_crcResultCache[cacheKey] = result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private unsafe uint ComputeCrc32HashInternal(byte[] data)
|
||||
private unsafe uint ComputeInternal(byte[] data)
|
||||
{
|
||||
if (!_initialized) throw new InvalidOperationException("CrcHash not initialized yet.");
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace Core.DataReader.Cvd
|
||||
/// <summary>
|
||||
/// CVD (.cvd) file model
|
||||
/// </summary>
|
||||
public class CvdFile
|
||||
public sealed class CvdFile
|
||||
{
|
||||
public float AnimationDuration { get; }
|
||||
public CvdGeometryNode[] RootNodes { get; }
|
||||
|
||||
@@ -10,16 +10,22 @@ namespace Core.DataReader.Cvd
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Extensions;
|
||||
using GameBox;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
public static class CvdFileReader
|
||||
public sealed class CvdFileReader : IFileReader<CvdFile>
|
||||
{
|
||||
public static CvdFile Read(byte[] data, int codepage)
|
||||
private readonly int _codepage;
|
||||
|
||||
public CvdFileReader(int codepage)
|
||||
{
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
public CvdFile Read(byte[] data)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
@@ -43,7 +49,7 @@ namespace Core.DataReader.Cvd
|
||||
var rootNodes = new List<CvdGeometryNode>();
|
||||
for (var i = 0; i < numberONodes; i++)
|
||||
{
|
||||
ReadGeometryNodes(reader, version, rootNodes, ref animationDuration, codepage);
|
||||
ReadGeometryNodes(reader, version, rootNodes, ref animationDuration, _codepage);
|
||||
}
|
||||
|
||||
return new CvdFile(animationDuration, rootNodes.ToArray());
|
||||
@@ -102,7 +108,7 @@ namespace Core.DataReader.Cvd
|
||||
Marshal.SizeOf(typeof(CvdLinearVector3Key)));
|
||||
|
||||
var positionKeyInfos = ReadPositionAnimationKeyInfo(reader, positionKeySize);
|
||||
if (positionKeyInfos.Last().Time > animationDuration) animationDuration = positionKeyInfos.Last().Time;
|
||||
if (positionKeyInfos[^1].Time > animationDuration) animationDuration = positionKeyInfos[^1].Time;
|
||||
|
||||
var rotationKeySize = Mathf.Max(
|
||||
Marshal.SizeOf(typeof(CvdTcbRotationKey)),
|
||||
@@ -110,7 +116,7 @@ namespace Core.DataReader.Cvd
|
||||
Marshal.SizeOf(typeof(CvdLinearRotationKey)));
|
||||
|
||||
var rotationKeyInfos = ReadRotationAnimationKeyInfo(reader, rotationKeySize);
|
||||
if (rotationKeyInfos.Last().Time > animationDuration) animationDuration = rotationKeyInfos.Last().Time;
|
||||
if (rotationKeyInfos[^1].Time > animationDuration) animationDuration = rotationKeyInfos[^1].Time;
|
||||
|
||||
var scaleKeySize = Mathf.Max(
|
||||
Marshal.SizeOf(typeof(CvdTcbScaleKey)),
|
||||
@@ -118,12 +124,12 @@ namespace Core.DataReader.Cvd
|
||||
Marshal.SizeOf(typeof(CvdLinearScaleKey)));
|
||||
|
||||
var scaleKeyInfos = ReadScaleAnimationKeyInfo(reader, scaleKeySize);
|
||||
if (scaleKeyInfos.Last().Time > animationDuration) animationDuration = scaleKeyInfos.Last().Time;
|
||||
if (scaleKeyInfos[^1].Time > animationDuration) animationDuration = scaleKeyInfos[^1].Time;
|
||||
|
||||
var scale = reader.ReadSingle();
|
||||
|
||||
CvdMesh mesh = ReadMesh(reader, version, codepage);
|
||||
if (mesh.AnimationTimeKeys.Last() > animationDuration) animationDuration = mesh.AnimationTimeKeys.Last();
|
||||
if (mesh.AnimationTimeKeys[^1] > animationDuration) animationDuration = mesh.AnimationTimeKeys[^1];
|
||||
|
||||
var transformMatrix = new GameBoxMatrix4X4()
|
||||
{
|
||||
|
||||
@@ -122,8 +122,13 @@ namespace Core.DataReader.Data
|
||||
public float[] Param;
|
||||
}
|
||||
|
||||
public class EffectDefinitionFile
|
||||
public sealed class EffectDefinitionFile
|
||||
{
|
||||
public EffectDefinition[] EffectDefinitions;
|
||||
public EffectDefinitionFile(EffectDefinition[] effectDefinitions)
|
||||
{
|
||||
EffectDefinitions = effectDefinitions;
|
||||
}
|
||||
|
||||
public EffectDefinition[] EffectDefinitions { get; }
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,11 @@ namespace Core.DataReader.Data
|
||||
using Extensions;
|
||||
using Utils;
|
||||
|
||||
public static class EffectDefinitionFileReader
|
||||
public sealed class EffectDefinitionFileReader : IFileReader<EffectDefinitionFile>
|
||||
{
|
||||
private const int NUM_OF_EFFECTS = 1324;
|
||||
|
||||
public static void Read(byte[] data, int codepage)
|
||||
public EffectDefinitionFile Read(byte[] data)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
@@ -28,14 +28,16 @@ namespace Core.DataReader.Data
|
||||
|
||||
for (var i = 0; i < NUM_OF_EFFECTS; i++)
|
||||
{
|
||||
effectDefinitions[i] = ReadEffectDefinition(reader, codepage);
|
||||
effectDefinitions[i] = ReadEffectDefinition(reader);
|
||||
}
|
||||
|
||||
return new EffectDefinitionFile(effectDefinitions);
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static EffectDefinition ReadEffectDefinition(UnsafeBinaryReader reader, int codepage)
|
||||
private static EffectDefinition ReadEffectDefinition(UnsafeBinaryReader reader)
|
||||
#else
|
||||
private static EffectDefinition ReadEffectDefinition(BinaryReader reader, int codepage)
|
||||
private static EffectDefinition ReadEffectDefinition(BinaryReader reader)
|
||||
#endif
|
||||
{
|
||||
var effectDefinition = new EffectDefinition();
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Core.DataReader.Dxt
|
||||
using System.IO;
|
||||
using Extensions;
|
||||
|
||||
public class DxtPixelFormat
|
||||
public sealed class DxtPixelFormat
|
||||
{
|
||||
public int Size;
|
||||
public int Flags;
|
||||
@@ -35,7 +35,7 @@ namespace Core.DataReader.Dxt
|
||||
}
|
||||
}
|
||||
|
||||
public class DxtHeader
|
||||
public sealed class DxtHeader
|
||||
{
|
||||
public int Size;
|
||||
public int Flags;
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Core.DataReader.Gdb
|
||||
}
|
||||
|
||||
// Pal3 Game Database file
|
||||
public class GdbFile
|
||||
public sealed class GdbFile
|
||||
{
|
||||
public Dictionary<int, GameItem> GameItems { get; } // Game item Id -> Game item
|
||||
|
||||
|
||||
@@ -9,14 +9,21 @@ namespace Core.DataReader.Gdb
|
||||
using System.IO;
|
||||
using Extensions;
|
||||
|
||||
public static class GdbFileReader
|
||||
public sealed class GdbFileReader : IFileReader<GdbFile>
|
||||
{
|
||||
public static GdbFile Read(byte[] data, int codepage)
|
||||
private readonly int _codepage;
|
||||
|
||||
public GdbFileReader(int codepage)
|
||||
{
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
public GdbFile Read(byte[] data)
|
||||
{
|
||||
using var stream = new MemoryStream(data);
|
||||
using var reader = new BinaryReader(stream);
|
||||
|
||||
_ = reader.ReadString(128, codepage); // header string
|
||||
_ = reader.ReadString(128, _codepage); // header string
|
||||
|
||||
uint actorDataOffset = reader.ReadUInt32();
|
||||
int numOfActors = reader.ReadInt32();
|
||||
@@ -34,7 +41,7 @@ namespace Core.DataReader.Gdb
|
||||
var gameItems = new Dictionary<int, GameItem>();
|
||||
for (var i = 0; i < numOfItems; i++)
|
||||
{
|
||||
GameItem item = ReadGameItem(reader, codepage);
|
||||
GameItem item = ReadGameItem(reader, _codepage);
|
||||
gameItems[(int) item.Id] = item;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader
|
||||
{
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// File reader interface.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public interface IFileReader<out T>
|
||||
{
|
||||
T Read(byte[] data)
|
||||
{
|
||||
using var stream = new MemoryStream(data);
|
||||
return Read(stream);
|
||||
}
|
||||
|
||||
T Read(Stream stream)
|
||||
{
|
||||
using var memoryStream = new MemoryStream();
|
||||
stream.CopyTo(memoryStream);
|
||||
return Read(memoryStream.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c4f0a8feb4f4a5d9cf984163dea25ce
|
||||
timeCreated: 1680782159
|
||||
@@ -5,19 +5,54 @@
|
||||
|
||||
namespace Core.DataReader.Ini
|
||||
{
|
||||
public struct BoneActor
|
||||
{
|
||||
public string MeshFileName;
|
||||
public string MaterialFileName;
|
||||
public string EffectFileName;
|
||||
}
|
||||
|
||||
public struct ActorAction
|
||||
{
|
||||
public string ActionName;
|
||||
public string ActionFileName;
|
||||
}
|
||||
|
||||
public class ActorConfigFile
|
||||
public struct BoneMaterial
|
||||
{
|
||||
public ActorConfigFile(ActorAction[] actorActions)
|
||||
public string MaterialName;
|
||||
public string MaterialFileName;
|
||||
public string EffectFileName;
|
||||
}
|
||||
|
||||
public abstract class ActorActionConfig
|
||||
{
|
||||
protected ActorActionConfig(ActorAction[] actorActions)
|
||||
{
|
||||
ActorActions = actorActions;
|
||||
}
|
||||
|
||||
public ActorAction[] ActorActions { get; }
|
||||
}
|
||||
|
||||
public sealed class Mv3ActionConfig : ActorActionConfig
|
||||
{
|
||||
public Mv3ActionConfig(ActorAction[] actorActions) : base(actorActions)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MovActionConfig : ActorActionConfig
|
||||
{
|
||||
public MovActionConfig(BoneActor actor,
|
||||
ActorAction[] actorActions,
|
||||
BoneMaterial[] boneMaterials) : base(actorActions)
|
||||
{
|
||||
Actor = actor;
|
||||
BoneMaterials = boneMaterials;
|
||||
}
|
||||
|
||||
public BoneActor Actor { get; }
|
||||
public BoneMaterial[] BoneMaterials { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Ini
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using IniParser;
|
||||
using IniParser.Model;
|
||||
|
||||
/// <summary>
|
||||
/// Read and parse .ini actor config file.
|
||||
/// </summary>
|
||||
public static class ActorConfigFileReader
|
||||
{
|
||||
private const string ACTION_SECTION_HEADER_PREFIX = "action_";
|
||||
private const string ACTION_SECTION_PROPERTY_NAME = "name";
|
||||
private const string ACTION_SECTION_PROPERTY_FILE = "file";
|
||||
|
||||
public static ActorConfigFile Read(byte[] configData)
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
using var stream = new MemoryStream(configData);
|
||||
using var reader = new StreamReader(stream, Encoding.ASCII);
|
||||
|
||||
IniData iniData = parser.ReadData(reader);
|
||||
|
||||
var actions = new List<ActorAction>();
|
||||
foreach (SectionData section in iniData.Sections
|
||||
.Where(s => s.SectionName.StartsWith(ACTION_SECTION_HEADER_PREFIX)))
|
||||
{
|
||||
actions.Add(new ActorAction()
|
||||
{
|
||||
ActionName = iniData[section.SectionName][ACTION_SECTION_PROPERTY_NAME],
|
||||
ActionFileName = iniData[section.SectionName][ACTION_SECTION_PROPERTY_FILE],
|
||||
});
|
||||
}
|
||||
|
||||
return new ActorConfigFile(actions.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9628650b0d0f4476b6dfc7c21e71425c
|
||||
timeCreated: 1642741115
|
||||
@@ -0,0 +1,75 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Ini
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using IniParser;
|
||||
using IniParser.Model;
|
||||
|
||||
public sealed class MovConfigFileReader : IFileReader<MovActionConfig>
|
||||
{
|
||||
private const string ACTOR_SECTION_HEADER = "actor";
|
||||
private const string ACTION_SECTION_HEADER_PREFIX = "action_";
|
||||
private const string MATERIAL_SECTION_HEADER_PREFIX = "material_";
|
||||
private const string PROPERTY_NAME = "name";
|
||||
private const string PROPERTY_FILE = "file";
|
||||
private const string PROPERTY_EFFECT = "effect";
|
||||
private const string PROPERTY_MESH = "mesh";
|
||||
private const string PROPERTY_MATERIAL = "material";
|
||||
|
||||
public MovActionConfig Read(byte[] data)
|
||||
{
|
||||
FileIniDataParser parser = new ();
|
||||
using var stream = new MemoryStream(data);
|
||||
using var reader = new StreamReader(stream, Encoding.ASCII);
|
||||
|
||||
IniData iniData = parser.ReadData(reader);
|
||||
|
||||
BoneActor? actor = null;
|
||||
List<ActorAction> actions = new ();
|
||||
List<BoneMaterial> materials = new ();
|
||||
|
||||
foreach (SectionData section in iniData.Sections)
|
||||
{
|
||||
if (string.Equals(section.SectionName, ACTOR_SECTION_HEADER, StringComparison.Ordinal))
|
||||
{
|
||||
actor = new BoneActor()
|
||||
{
|
||||
MeshFileName = iniData[section.SectionName][PROPERTY_MESH],
|
||||
MaterialFileName = iniData[section.SectionName][PROPERTY_MATERIAL],
|
||||
EffectFileName = iniData[section.SectionName][PROPERTY_EFFECT],
|
||||
};
|
||||
}
|
||||
|
||||
if (section.SectionName.StartsWith(ACTION_SECTION_HEADER_PREFIX))
|
||||
{
|
||||
actions.Add(new ActorAction()
|
||||
{
|
||||
ActionName = iniData[section.SectionName][PROPERTY_NAME],
|
||||
ActionFileName = iniData[section.SectionName][PROPERTY_FILE],
|
||||
});
|
||||
}
|
||||
|
||||
if (section.SectionName.StartsWith(MATERIAL_SECTION_HEADER_PREFIX))
|
||||
{
|
||||
materials.Add(new BoneMaterial()
|
||||
{
|
||||
MaterialName = iniData[section.SectionName][PROPERTY_NAME],
|
||||
MaterialFileName = iniData[section.SectionName][PROPERTY_FILE],
|
||||
EffectFileName = iniData[section.SectionName][PROPERTY_EFFECT],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (actor == null) throw new InvalidDataException("Actor section is missing in MOV config.");
|
||||
|
||||
return new MovActionConfig(actor.Value, actions.ToArray(), materials.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdd5f5157ef84a99a901cd3480e7523a
|
||||
timeCreated: 1680784465
|
||||
@@ -0,0 +1,45 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Ini
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using IniParser;
|
||||
using IniParser.Model;
|
||||
|
||||
public sealed class Mv3ConfigFileReader : IFileReader<Mv3ActionConfig>
|
||||
{
|
||||
private const string ACTION_SECTION_HEADER_PREFIX = "action_";
|
||||
|
||||
private const string PROPERTY_NAME = "name";
|
||||
private const string PROPERTY_FILE = "file";
|
||||
|
||||
public Mv3ActionConfig Read(byte[] data)
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
using var stream = new MemoryStream(data);
|
||||
using var reader = new StreamReader(stream, Encoding.ASCII);
|
||||
|
||||
IniData iniData = parser.ReadData(reader);
|
||||
|
||||
var actions = new List<ActorAction>();
|
||||
foreach (SectionData section in iniData.Sections)
|
||||
{
|
||||
if (section.SectionName.StartsWith(ACTION_SECTION_HEADER_PREFIX))
|
||||
{
|
||||
actions.Add(new ActorAction()
|
||||
{
|
||||
ActionName = iniData[section.SectionName][PROPERTY_NAME],
|
||||
ActionFileName = iniData[section.SectionName][PROPERTY_FILE],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return new Mv3ActionConfig(actions.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b3f43f738664557928e3aee78515b27
|
||||
timeCreated: 1680784304
|
||||
@@ -32,7 +32,7 @@ namespace Core.DataReader.Lgt
|
||||
public float AspectRatio;
|
||||
}
|
||||
|
||||
public class LgtFile
|
||||
public sealed class LgtFile
|
||||
{
|
||||
public LightNode[] LightNodes { get; }
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ namespace Core.DataReader.Lgt
|
||||
using GameBox;
|
||||
using Utils;
|
||||
|
||||
public static class LgtFileReader
|
||||
public sealed class LgtFileReader : IFileReader<LgtFile>
|
||||
{
|
||||
public static LgtFile Read(byte[] data)
|
||||
public LgtFile Read(byte[] data)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8a9cd17be17429bb156a12da7a1a4cf
|
||||
timeCreated: 1680655988
|
||||
@@ -0,0 +1,47 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Mov
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public struct MovAnimationKeyFrame
|
||||
{
|
||||
public uint Tick;
|
||||
public Vector3 Translation; // Relative translation to parent bone
|
||||
public Quaternion Rotation; // Relative rotation to parent bone
|
||||
public float[][] Scale; // 3x3
|
||||
}
|
||||
|
||||
public struct MovBoneAnimationTrack
|
||||
{
|
||||
public int BoneId;
|
||||
public string BoneName; // len = 64
|
||||
public int AnimationFlags; // 1 translation, 2 rotation, 4 scale
|
||||
public MovAnimationKeyFrame[] KeyFrames;
|
||||
}
|
||||
|
||||
public struct MovAnimationEvent
|
||||
{
|
||||
public uint Tick;
|
||||
public string Name; // 16 chars max
|
||||
}
|
||||
|
||||
public sealed class MovFile
|
||||
{
|
||||
public uint Duration { get; }
|
||||
public MovBoneAnimationTrack[] BoneAnimationTracks { get; }
|
||||
public MovAnimationEvent[] AnimationEvents { get; }
|
||||
|
||||
public MovFile(uint duration,
|
||||
MovBoneAnimationTrack[] boneAnimationTracks,
|
||||
MovAnimationEvent[] animationEvents)
|
||||
{
|
||||
Duration = duration;
|
||||
BoneAnimationTracks = boneAnimationTracks;
|
||||
AnimationEvents = animationEvents;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 101efe531c534b61bb6f47c71a916a78
|
||||
timeCreated: 1680655995
|
||||
@@ -0,0 +1,140 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// 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.Mov
|
||||
{
|
||||
using System.IO;
|
||||
using Extensions;
|
||||
using GameBox;
|
||||
using Utils;
|
||||
|
||||
public sealed class MovFileReader : IFileReader<MovFile>
|
||||
{
|
||||
private readonly int _codepage;
|
||||
|
||||
public MovFileReader(int codepage)
|
||||
{
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
public MovFile 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 != "anm")
|
||||
{
|
||||
throw new InvalidDataException("Invalid MOV(.mov) file: header != anm");
|
||||
}
|
||||
|
||||
var version = reader.ReadInt32();
|
||||
if (version != 100)
|
||||
{
|
||||
throw new InvalidDataException("Invalid MOV(.mov) file: version != 100");
|
||||
}
|
||||
|
||||
var duration = reader.ReadSingle();
|
||||
var numberOfBoneAnimationTracks = reader.ReadInt32();
|
||||
var numberOfVertices = reader.ReadInt32();
|
||||
var numberOfAnimationEvents = reader.ReadInt32();
|
||||
|
||||
var animationEvents = new MovAnimationEvent[numberOfAnimationEvents];
|
||||
for (var i = 0; i < numberOfAnimationEvents; i++)
|
||||
{
|
||||
animationEvents[i] = ReadAnimationEvent(reader, _codepage);
|
||||
}
|
||||
|
||||
var boneAnimationTracks = new MovBoneAnimationTrack[numberOfBoneAnimationTracks];
|
||||
for (var i = 0; i < numberOfBoneAnimationTracks; i++)
|
||||
{
|
||||
boneAnimationTracks[i] = ReadBoneAnimationTrack(reader, _codepage);
|
||||
}
|
||||
|
||||
uint totalDuration = 0;
|
||||
for (var i = 0; i < boneAnimationTracks.Length; i++)
|
||||
{
|
||||
int numOfKeyFrames = boneAnimationTracks[i].KeyFrames.Length;
|
||||
if (numOfKeyFrames > 0)
|
||||
{
|
||||
uint tick = boneAnimationTracks[i].KeyFrames[numOfKeyFrames - 1].Tick;
|
||||
if (tick > totalDuration)
|
||||
{
|
||||
totalDuration = tick;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new MovFile(totalDuration, boneAnimationTracks, animationEvents);
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static MovAnimationEvent ReadAnimationEvent(UnsafeBinaryReader reader, int codepage)
|
||||
#else
|
||||
private static MovAnimationEvent ReadAnimationEvent(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
return new MovAnimationEvent()
|
||||
{
|
||||
Tick = GameBoxInterpreter.GameBoxSecondsToTick(reader.ReadSingle()),
|
||||
Name = reader.ReadString(16, codepage)
|
||||
};
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static MovBoneAnimationTrack ReadBoneAnimationTrack(UnsafeBinaryReader reader, int codepage)
|
||||
#else
|
||||
private static MovBoneAnimationTrack ReadBoneAnimationTrack(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
var boneId = reader.ReadInt32();
|
||||
|
||||
var lengthOfBoneName = reader.ReadInt32();
|
||||
var boneName = reader.ReadString(lengthOfBoneName, codepage);
|
||||
|
||||
var numberOfKeyFrames = reader.ReadInt32();
|
||||
var animationFlags = reader.ReadInt32();
|
||||
|
||||
var animationKeyFrames = new MovAnimationKeyFrame[numberOfKeyFrames];
|
||||
for (var i = 0; i < animationKeyFrames.Length; i++)
|
||||
{
|
||||
animationKeyFrames[i] = new MovAnimationKeyFrame()
|
||||
{
|
||||
Tick = GameBoxInterpreter.GameBoxSecondsToTick(reader.ReadSingle()),
|
||||
Translation = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3()),
|
||||
Rotation = GameBoxInterpreter.MovQuaternionToUnityQuaternion(new GameBoxQuaternion()
|
||||
{
|
||||
X = reader.ReadSingle(),
|
||||
Y = reader.ReadSingle(),
|
||||
Z = reader.ReadSingle(),
|
||||
W = reader.ReadSingle(),
|
||||
}),
|
||||
Scale = new []
|
||||
{
|
||||
new [] {reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()},
|
||||
new [] {reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()},
|
||||
new [] {reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return new MovBoneAnimationTrack()
|
||||
{
|
||||
BoneId = boneId,
|
||||
BoneName = boneName,
|
||||
AnimationFlags = animationFlags,
|
||||
KeyFrames = animationKeyFrames
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e25570593c94fd7add46aabfcb798fe
|
||||
timeCreated: 1680656014
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c74b3e11cc3a4207af349e11ec1f90b3
|
||||
timeCreated: 1681103413
|
||||
@@ -0,0 +1,87 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Msh
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public enum BoneNodeType
|
||||
{
|
||||
Normal = 0,
|
||||
Bone,
|
||||
Dummy,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum MshLayerFlag
|
||||
{
|
||||
Position = 1 << 0,
|
||||
Normal = 1 << 1,
|
||||
Tex1 = 1 << 2,
|
||||
Tex2 = 1 << 3,
|
||||
Tex3 = 1 << 4,
|
||||
Tex4 = 1 << 5,
|
||||
Tex5 = 1 << 6,
|
||||
Tex6 = 1 << 7,
|
||||
Tex7 = 1 << 8,
|
||||
Tex8 = 1 << 9,
|
||||
Lod = 1 << 10,
|
||||
Bone = 1 << 11,
|
||||
Physics = 1 << 12,
|
||||
}
|
||||
|
||||
public struct PhyVertex
|
||||
{
|
||||
public Vector3 Position;
|
||||
public byte[] BoneIds;
|
||||
public byte[] Weights;
|
||||
}
|
||||
|
||||
public struct PhyFace
|
||||
{
|
||||
public int[] Indices;
|
||||
public ushort[] Normals;
|
||||
public float[,] U;
|
||||
public float[,] V;
|
||||
}
|
||||
|
||||
public struct MshMesh
|
||||
{
|
||||
public int MaterialId;
|
||||
public MshLayerFlag LayerFlags;
|
||||
public PhyVertex[] Vertices;
|
||||
public PhyFace[] Faces;
|
||||
}
|
||||
|
||||
public class BoneNode
|
||||
{
|
||||
public BoneNodeType Type;
|
||||
public int Id;
|
||||
public string Name;
|
||||
public BoneNode Parent;
|
||||
public int ParentId;
|
||||
public BoneNode[] Children;
|
||||
|
||||
public Vector3 Translation;
|
||||
public Quaternion Rotation;
|
||||
public Matrix4x4 Scale;
|
||||
public float FlipScaleSign; // Sign of the determinant of the matrix
|
||||
public Matrix4x4 LocalTransform; // The matrix transform from model space to bone space
|
||||
}
|
||||
|
||||
public sealed class MshFile
|
||||
{
|
||||
public BoneNode RootBoneNode { get; }
|
||||
public MshMesh[] SubMeshes { get; }
|
||||
|
||||
public MshFile(BoneNode rootBoneNode,
|
||||
MshMesh[] subMeshes)
|
||||
{
|
||||
RootBoneNode = rootBoneNode;
|
||||
SubMeshes = subMeshes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee069b75b97249f98c630cc6c9ee3d47
|
||||
timeCreated: 1681103417
|
||||
@@ -0,0 +1,237 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// 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.Msh
|
||||
{
|
||||
using System.IO;
|
||||
using Extensions;
|
||||
using GameBox;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
public sealed class MshFileReader : IFileReader<MshFile>
|
||||
{
|
||||
private readonly int _codepage;
|
||||
|
||||
public MshFileReader(int codepage)
|
||||
{
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
public MshFile 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 != "msh")
|
||||
{
|
||||
throw new InvalidDataException("Invalid MSH(.msh) file: header != msh");
|
||||
}
|
||||
|
||||
var version = reader.ReadInt32();
|
||||
if (version != 100)
|
||||
{
|
||||
throw new InvalidDataException("Invalid MSH(.msh) file: version != 100");
|
||||
}
|
||||
|
||||
int skeletonDataOffset = reader.ReadInt32();
|
||||
int meshDataOffset = reader.ReadInt32();
|
||||
|
||||
BoneNode rootBoneNode = new()
|
||||
{
|
||||
Type = BoneNodeType.Normal,
|
||||
Id = 0,
|
||||
Name = "root",
|
||||
Parent = null,
|
||||
ParentId = 0,
|
||||
};
|
||||
|
||||
var numberOfChildBones = reader.ReadInt32();
|
||||
var childBoneNodes = new BoneNode[numberOfChildBones];
|
||||
for (var i = 0; i < numberOfChildBones; i++)
|
||||
{
|
||||
childBoneNodes[i] = ReadBoneNode(reader, rootBoneNode, _codepage);
|
||||
}
|
||||
|
||||
rootBoneNode.Children = childBoneNodes;
|
||||
|
||||
var numberOfSubMeshes = reader.ReadInt32();
|
||||
var subMeshes = new MshMesh[numberOfSubMeshes];
|
||||
for (var i = 0; i < numberOfSubMeshes; i++)
|
||||
{
|
||||
subMeshes[i] = ReadSubMesh(reader, _codepage);
|
||||
}
|
||||
|
||||
return new MshFile(rootBoneNode, subMeshes);
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static BoneNode ReadBoneNode(UnsafeBinaryReader reader, BoneNode parent, int codepage)
|
||||
#else
|
||||
private static BoneNode ReadBoneNode(BinaryReader reader, BoneNode parent, int codepage)
|
||||
#endif
|
||||
{
|
||||
var nodeType = (BoneNodeType)reader.ReadInt32();
|
||||
var nameLength = reader.ReadInt32();
|
||||
var name = reader.ReadString(nameLength, codepage);
|
||||
|
||||
Vector3 translation = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3());
|
||||
Quaternion rotation = GameBoxInterpreter.MshQuaternionToUnityQuaternion(new GameBoxQuaternion()
|
||||
{
|
||||
X = reader.ReadSingle(),
|
||||
Y = reader.ReadSingle(),
|
||||
Z = reader.ReadSingle(),
|
||||
W = reader.ReadSingle(),
|
||||
});
|
||||
|
||||
Matrix4x4 scaleMatrix = GameBoxInterpreter.ToUnityMatrix4x4(new GameBoxMatrix4X4()
|
||||
{
|
||||
Xx = reader.ReadSingle(), Xy = reader.ReadSingle(), Xz = reader.ReadSingle(), Xw = 0,
|
||||
Yx = reader.ReadSingle(), Yy = reader.ReadSingle(), Yz = reader.ReadSingle(), Yw = 0,
|
||||
Zx = reader.ReadSingle(), Zy = reader.ReadSingle(), Zz = reader.ReadSingle(), Zw = 0,
|
||||
Tx = 0, Ty = 0, Tz = 0, Tw = 1,
|
||||
});
|
||||
|
||||
float flipScaleSign = reader.ReadSingle();
|
||||
Matrix4x4 localTransformMatrix = GameBoxInterpreter.ToUnityMatrix4x4(new GameBoxMatrix4X4()
|
||||
{
|
||||
Xx = reader.ReadSingle(), Xy = reader.ReadSingle(), Xz = reader.ReadSingle(), Xw = reader.ReadSingle(),
|
||||
Yx = reader.ReadSingle(), Yy = reader.ReadSingle(), Yz = reader.ReadSingle(), Yw = reader.ReadSingle(),
|
||||
Zx = reader.ReadSingle(), Zy = reader.ReadSingle(), Zz = reader.ReadSingle(), Zw = reader.ReadSingle(),
|
||||
Tx = reader.ReadSingle(), Ty = reader.ReadSingle(), Tz = reader.ReadSingle(), Tw = reader.ReadSingle()
|
||||
});
|
||||
|
||||
var boneID = reader.ReadInt32();
|
||||
var parentBoneID = reader.ReadInt32();
|
||||
var numberOfChildBones = reader.ReadInt32();
|
||||
|
||||
BoneNode boneNode = new()
|
||||
{
|
||||
Type = nodeType,
|
||||
Id = boneID,
|
||||
Name = name,
|
||||
Parent = parent,
|
||||
ParentId = parentBoneID,
|
||||
Translation = translation,
|
||||
Rotation = rotation,
|
||||
Scale = scaleMatrix,
|
||||
FlipScaleSign = flipScaleSign,
|
||||
LocalTransform = localTransformMatrix,
|
||||
};
|
||||
|
||||
var childBoneNodes = new BoneNode[numberOfChildBones];
|
||||
for (var i = 0; i < numberOfChildBones; i++)
|
||||
{
|
||||
childBoneNodes[i] = ReadBoneNode(reader, boneNode, codepage);
|
||||
}
|
||||
|
||||
boneNode.Children = childBoneNodes;
|
||||
|
||||
return boneNode;
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static MshMesh ReadSubMesh(UnsafeBinaryReader reader, int codepage)
|
||||
#else
|
||||
private static MshMesh ReadSubMesh(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
var materialId = reader.ReadInt32();
|
||||
var numberOfVertices = reader.ReadInt32();
|
||||
var numberOfFaces = reader.ReadInt32();
|
||||
var numberOfSprings = reader.ReadInt32();
|
||||
var numberOfLods = reader.ReadInt32();
|
||||
var layerFlag = (MshLayerFlag)reader.ReadInt32();
|
||||
|
||||
var vertices = new Vector3[numberOfVertices];
|
||||
|
||||
if (layerFlag.HasFlag(MshLayerFlag.Position))
|
||||
{
|
||||
for (var i = 0; i < numberOfVertices; i++)
|
||||
{
|
||||
vertices[i] = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3());
|
||||
}
|
||||
}
|
||||
|
||||
var phyVertices = new PhyVertex[numberOfVertices];
|
||||
if (layerFlag.HasFlag(MshLayerFlag.Bone))
|
||||
{
|
||||
for (var i = 0; i < numberOfVertices; i++)
|
||||
{
|
||||
var numberOfBones = reader.ReadByte();
|
||||
var boneIds = new byte[numberOfBones];
|
||||
var weights = new byte[numberOfBones];
|
||||
for (var j = 0; j < numberOfBones; j++)
|
||||
{
|
||||
boneIds[j] = reader.ReadByte();
|
||||
weights[j] = reader.ReadByte();
|
||||
}
|
||||
|
||||
phyVertices[i] = new PhyVertex
|
||||
{
|
||||
Position = vertices[i],
|
||||
BoneIds = boneIds,
|
||||
Weights = weights,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var phyFaces = new PhyFace[numberOfFaces];
|
||||
for (var i = 0; i < numberOfFaces; i++)
|
||||
{
|
||||
phyFaces[i] = new PhyFace
|
||||
{
|
||||
Indices = new []
|
||||
{
|
||||
reader.ReadInt32(),
|
||||
reader.ReadInt32(),
|
||||
reader.ReadInt32()
|
||||
},
|
||||
Normals = new []
|
||||
{
|
||||
reader.ReadUInt16(),
|
||||
reader.ReadUInt16(),
|
||||
reader.ReadUInt16(),
|
||||
reader.ReadUInt16()
|
||||
},
|
||||
U = new [,]
|
||||
{
|
||||
{ reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle() }
|
||||
},
|
||||
V = new [,]
|
||||
{
|
||||
{ reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle() },
|
||||
{ reader.ReadSingle(), reader.ReadSingle() }
|
||||
}
|
||||
};
|
||||
|
||||
for (var j = 0; j < 3; j++)
|
||||
{
|
||||
phyFaces[i].U[j, 0] = ((int)(phyFaces[i].U[j, 0] * 255)) / 255f;
|
||||
phyFaces[i].V[j, 0] = ((int)(phyFaces[i].V[j, 0] * 255)) / 255f;
|
||||
}
|
||||
}
|
||||
|
||||
return new MshMesh()
|
||||
{
|
||||
MaterialId = materialId,
|
||||
Vertices = phyVertices,
|
||||
Faces = phyFaces,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9ae56d14511449b91e1fd9f6ac670a2
|
||||
timeCreated: 1681103424
|
||||
@@ -8,18 +8,6 @@ namespace Core.DataReader.Mv3
|
||||
using GameBox;
|
||||
using UnityEngine;
|
||||
|
||||
// MV3 (.mv3) file header
|
||||
internal struct Mv3Header
|
||||
{
|
||||
public string Magic; // 4 char
|
||||
public int Version;
|
||||
public uint Duration;
|
||||
public int NumberOfMaterials;
|
||||
public int NumberOfTagNodes;
|
||||
public int NumberOfMeshes;
|
||||
public int NumberOfAnimationEvents;
|
||||
}
|
||||
|
||||
public struct Mv3AnimationEvent
|
||||
{
|
||||
public uint Tick;
|
||||
@@ -82,10 +70,10 @@ namespace Core.DataReader.Mv3
|
||||
public Vector3[] Normals;
|
||||
public int[] Triangles;
|
||||
public Vector2[] Uvs;
|
||||
public VertexAnimationKeyFrame[] KeyFrames;
|
||||
public Mv3AnimationKeyFrame[] KeyFrames;
|
||||
}
|
||||
|
||||
public struct VertexAnimationKeyFrame
|
||||
public struct Mv3AnimationKeyFrame
|
||||
{
|
||||
public uint Tick;
|
||||
public Vector3[] Vertices;
|
||||
@@ -94,23 +82,20 @@ namespace Core.DataReader.Mv3
|
||||
/// <summary>
|
||||
/// MV3 (.mv3) file model
|
||||
/// </summary>
|
||||
public class Mv3File
|
||||
public sealed class Mv3File
|
||||
{
|
||||
public int Version { get; }
|
||||
public uint Duration { get; }
|
||||
public Mv3AnimationEvent[] AnimationEvents { get; }
|
||||
public Mv3TagNode[] TagNodes { get; }
|
||||
public Mv3Material[] Materials { get; }
|
||||
public Mv3Mesh[] Meshes { get; }
|
||||
|
||||
public Mv3File(int version,
|
||||
uint duration,
|
||||
public Mv3File(uint duration,
|
||||
Mv3AnimationEvent[] animationEvents,
|
||||
Mv3TagNode[] tagNodes,
|
||||
Mv3Material[] materials,
|
||||
Mv3Mesh[] meshes)
|
||||
{
|
||||
Version = version;
|
||||
Duration = duration;
|
||||
AnimationEvents = animationEvents;
|
||||
TagNodes = tagNodes;
|
||||
|
||||
@@ -15,9 +15,16 @@ namespace Core.DataReader.Mv3
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
public static class Mv3FileReader
|
||||
public sealed class Mv3FileReader : IFileReader<Mv3File>
|
||||
{
|
||||
public static Mv3File Read(byte[] data, int codepage)
|
||||
private readonly int _codepage;
|
||||
|
||||
public Mv3FileReader(int codepage)
|
||||
{
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
public Mv3File Read(byte[] data)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
@@ -54,29 +61,28 @@ namespace Core.DataReader.Mv3
|
||||
var animationEvents = new Mv3AnimationEvent[numberOfAnimationEvents];
|
||||
for (var i = 0; i < numberOfAnimationEvents; i++)
|
||||
{
|
||||
animationEvents[i] = ReadAnimationEvent(reader, codepage);
|
||||
animationEvents[i] = ReadAnimationEvent(reader, _codepage);
|
||||
}
|
||||
|
||||
var tagNodes = new Mv3TagNode[numberOfTagNodes];
|
||||
for (var i = 0; i < numberOfTagNodes; i++)
|
||||
{
|
||||
tagNodes[i] = ReadTagNode(reader, codepage);
|
||||
tagNodes[i] = ReadTagNode(reader, _codepage);
|
||||
}
|
||||
|
||||
var materials = new Mv3Material[numberOfMaterials];
|
||||
for (var i = 0; i < numberOfMaterials; i++)
|
||||
{
|
||||
materials[i] = ReadMaterial(reader, codepage);
|
||||
materials[i] = ReadMaterial(reader, _codepage);
|
||||
}
|
||||
|
||||
var meshes = new Mv3Mesh[numberOfMeshes];
|
||||
for (var i = 0; i < numberOfMeshes; i++)
|
||||
{
|
||||
meshes[i] = ReadMesh(reader, codepage);
|
||||
meshes[i] = ReadMesh(reader, _codepage);
|
||||
}
|
||||
|
||||
return new Mv3File(version,
|
||||
duration,
|
||||
return new Mv3File(duration,
|
||||
animationEvents,
|
||||
tagNodes,
|
||||
materials,
|
||||
@@ -207,10 +213,10 @@ namespace Core.DataReader.Mv3
|
||||
|
||||
GameBoxInterpreter.ToUnityTriangles(triangles);
|
||||
|
||||
var animationKeyFrames = new VertexAnimationKeyFrame[vertFrames.Length];
|
||||
var animationKeyFrames = new Mv3AnimationKeyFrame[vertFrames.Length];
|
||||
for (var i = 0; i < animationKeyFrames.Length; i++)
|
||||
{
|
||||
animationKeyFrames[i] = new VertexAnimationKeyFrame()
|
||||
animationKeyFrames[i] = new Mv3AnimationKeyFrame()
|
||||
{
|
||||
Tick = vertFrames[i].Tick,
|
||||
Vertices = keyFrameVertices[i].ToArray(),
|
||||
@@ -292,13 +298,10 @@ namespace Core.DataReader.Mv3
|
||||
private static Mv3AnimationEvent ReadAnimationEvent(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
var tick = reader.ReadUInt32();
|
||||
var name = reader.ReadBytes(16);
|
||||
|
||||
return new Mv3AnimationEvent()
|
||||
{
|
||||
Tick = tick,
|
||||
Name = Utility.ConvertToString(name, codepage)
|
||||
Tick = reader.ReadUInt32(),
|
||||
Name = reader.ReadString(16, codepage),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace Core.DataReader.Nav
|
||||
Rock2, // 岩石基底地面
|
||||
Rock3, // 人工石地面
|
||||
Brick, // 砖
|
||||
Unknown1, // 异空间A
|
||||
Unknown2, // 异空间B
|
||||
Unknown3, // 异空间C
|
||||
DevilWorld1, // 异空间A
|
||||
DevilWorld2, // 异空间B
|
||||
DevilWorld3, // 异空间C
|
||||
Other, // 其它
|
||||
FloorIce, // 冰
|
||||
FloorBlood, // 血池
|
||||
@@ -88,7 +88,7 @@ namespace Core.DataReader.Nav
|
||||
/// <summary>
|
||||
/// NAV (.nav) file model
|
||||
/// </summary>
|
||||
public class NavFile
|
||||
public sealed class NavFile
|
||||
{
|
||||
public NavTileLayer[] TileLayers { get; }
|
||||
public NavFaceLayer[] FaceLayers { get; }
|
||||
|
||||
@@ -7,15 +7,14 @@ namespace Core.DataReader.Nav
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Extensions;
|
||||
using GameBox;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
public static class NavFileReader
|
||||
public sealed class NavFileReader : IFileReader<NavFile>
|
||||
{
|
||||
public static NavFile Read(Stream stream)
|
||||
public NavFile Read(Stream stream)
|
||||
{
|
||||
using var reader = new BinaryReader(stream);
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Core.DataReader.Pol
|
||||
/// <summary>
|
||||
/// POLY (.pol) file model
|
||||
/// </summary>
|
||||
public class PolFile
|
||||
public sealed class PolFile
|
||||
{
|
||||
public int Version { get; }
|
||||
public PolGeometryNode[] NodeDescriptions { get; }
|
||||
|
||||
@@ -14,9 +14,16 @@ namespace Core.DataReader.Pol
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
public static class PolFileReader
|
||||
public sealed class PolFileReader : IFileReader<PolFile>
|
||||
{
|
||||
public static PolFile Read(byte[] data, int codepage)
|
||||
private readonly int _codepage;
|
||||
|
||||
public PolFileReader(int codepage)
|
||||
{
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
public PolFile Read(byte[] data)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
@@ -41,7 +48,7 @@ namespace Core.DataReader.Pol
|
||||
{
|
||||
nodeInfos[i] = new PolGeometryNode
|
||||
{
|
||||
Name = reader.ReadString(32, codepage),
|
||||
Name = reader.ReadString(32, _codepage),
|
||||
Position = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3()),
|
||||
Radius = reader.ReadSingle(),
|
||||
Offset = reader.ReadInt32()
|
||||
@@ -57,7 +64,7 @@ namespace Core.DataReader.Pol
|
||||
tagNodes = new TagNode[numberOfTagNodes];
|
||||
for (var i = 0; i < numberOfTagNodes; i++)
|
||||
{
|
||||
tagNodes[i] = ReadTagNodeInfo(reader, codepage);
|
||||
tagNodes[i] = ReadTagNodeInfo(reader, _codepage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,7 +72,7 @@ namespace Core.DataReader.Pol
|
||||
var meshInfos = new PolMesh[numberOfNodes];
|
||||
for (var i = 0; i < numberOfNodes; i++)
|
||||
{
|
||||
meshInfos[i] = ReadMeshData(reader, version, codepage);
|
||||
meshInfos[i] = ReadMeshData(reader, version, _codepage);
|
||||
}
|
||||
|
||||
return new PolFile(version, nodeInfos, meshInfos, tagNodes);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Core.DataReader.Sce
|
||||
/// <summary>
|
||||
/// SCE (.sce) file model
|
||||
/// </summary>
|
||||
public class SceFile
|
||||
public sealed class SceFile
|
||||
{
|
||||
public SceIndex[] Indexes { get; }
|
||||
public Dictionary<uint, SceScriptBlock> ScriptBlocks { get; }
|
||||
|
||||
@@ -8,9 +8,16 @@ namespace Core.DataReader.Sce
|
||||
using System.IO;
|
||||
using Extensions;
|
||||
|
||||
public static class SceFileReader
|
||||
public sealed class SceFileReader : IFileReader<SceFile>
|
||||
{
|
||||
public static SceFile Read(Stream stream, int codepage)
|
||||
private readonly int _codepage;
|
||||
|
||||
public SceFileReader(int codepage)
|
||||
{
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
public SceFile Read(Stream stream)
|
||||
{
|
||||
using var reader = new BinaryReader(stream);
|
||||
|
||||
@@ -34,16 +41,16 @@ namespace Core.DataReader.Sce
|
||||
var indexes = new SceIndex[numberOfBlocks];
|
||||
for (var i = 0; i < numberOfBlocks; i++)
|
||||
{
|
||||
indexes[i] = ReadSceIndex(reader, codepage);
|
||||
indexes[i] = ReadSceIndex(reader, _codepage);
|
||||
}
|
||||
|
||||
var scriptBlocks = new SceScriptBlock[numberOfBlocks];
|
||||
for (var i = 0; i < numberOfBlocks; i++)
|
||||
{
|
||||
scriptBlocks[i] = ReadScriptBlock(reader, indexes[i], codepage);
|
||||
scriptBlocks[i] = ReadScriptBlock(reader, indexes[i], _codepage);
|
||||
}
|
||||
|
||||
return new SceFile(indexes, scriptBlocks, codepage);
|
||||
return new SceFile(indexes, scriptBlocks, _codepage);
|
||||
}
|
||||
|
||||
private static SceScriptBlock ReadScriptBlock(BinaryReader reader, SceIndex sceIndex, int codepage)
|
||||
|
||||
@@ -262,7 +262,9 @@ namespace Core.DataReader.Scn
|
||||
|
||||
public ScnPath Path;
|
||||
|
||||
// 对话开始时: 0: 可转向, 1: 不可转向
|
||||
public uint NoTurn;
|
||||
|
||||
public uint LoopAction;
|
||||
|
||||
// 移动速度
|
||||
@@ -387,7 +389,7 @@ namespace Core.DataReader.Scn
|
||||
/// <summary>
|
||||
/// SCN (.scn) file model
|
||||
/// </summary>
|
||||
public class ScnFile
|
||||
public sealed class ScnFile
|
||||
{
|
||||
public ScnSceneInfo SceneInfo { get; }
|
||||
public ScnNpcInfo[] NpcInfos { get; }
|
||||
|
||||
@@ -7,14 +7,20 @@ namespace Core.DataReader.Scn
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Extensions;
|
||||
using GameBox;
|
||||
using UnityEngine;
|
||||
|
||||
public static class ScnFileReader
|
||||
public sealed class ScnFileReader : IFileReader<ScnFile>
|
||||
{
|
||||
public static ScnFile Read(Stream stream, int codepage)
|
||||
private readonly int _codepage;
|
||||
|
||||
public ScnFileReader(int codepage)
|
||||
{
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
public ScnFile Read(Stream stream)
|
||||
{
|
||||
using var reader = new BinaryReader(stream);
|
||||
|
||||
@@ -34,9 +40,9 @@ namespace Core.DataReader.Scn
|
||||
|
||||
var sceneInfo = new ScnSceneInfo()
|
||||
{
|
||||
CityName = reader.ReadString(32, codepage),
|
||||
SceneName = reader.ReadString(32, codepage),
|
||||
Model = reader.ReadString(32, codepage),
|
||||
CityName = reader.ReadString(32, _codepage),
|
||||
SceneName = reader.ReadString(32, _codepage),
|
||||
Model = reader.ReadString(32, _codepage),
|
||||
SceneType = (ScnSceneType) reader.ReadInt32(),
|
||||
LightMap = reader.ReadInt32(),
|
||||
SkyBox = reader.ReadUInt32(),
|
||||
@@ -47,14 +53,14 @@ namespace Core.DataReader.Scn
|
||||
var npcInfos = new ScnNpcInfo[numberOfNpc];
|
||||
for (var i = 0; i < numberOfNpc; i++)
|
||||
{
|
||||
npcInfos[i] = ReadNpcInfo(reader, codepage);
|
||||
npcInfos[i] = ReadNpcInfo(reader, _codepage);
|
||||
}
|
||||
|
||||
reader.BaseStream.Seek(objectDataOffset, SeekOrigin.Begin);
|
||||
var objInfos = new ScnObjectInfo[numberOfObjects];
|
||||
for (var i = 0; i < numberOfObjects; i++)
|
||||
{
|
||||
ScnObjectInfo sceneObject = ReadObjectInfo(reader, codepage);
|
||||
ScnObjectInfo sceneObject = ReadObjectInfo(reader, _codepage);
|
||||
objInfos[i] = sceneObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.Extensions
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public static class DictionaryExtension
|
||||
{
|
||||
public static Dictionary<TValue, TKey> Reverse<TKey, TValue>(this IDictionary<TKey, TValue> source)
|
||||
{
|
||||
Dictionary<TValue, TKey> dictionary = new ();
|
||||
foreach (var entry in source)
|
||||
{
|
||||
dictionary.TryAdd(entry.Value, entry.Key);
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a48f89d727f043f8b236676cab943164
|
||||
timeCreated: 1680666212
|
||||
@@ -22,11 +22,11 @@ namespace Core.FileSystem
|
||||
{
|
||||
private readonly string _rootPath;
|
||||
private readonly ConcurrentDictionary<string, CpkArchive> _cpkArchives = new();
|
||||
private readonly CrcHash _crcHash;
|
||||
private readonly Crc32Hash _crcHash;
|
||||
|
||||
private CpkFileSystem() {} // Hide default constructor
|
||||
|
||||
public CpkFileSystem(string rootPath, CrcHash crcHash)
|
||||
public CpkFileSystem(string rootPath, Crc32Hash crcHash)
|
||||
{
|
||||
rootPath = Requires.IsNotNullOrEmpty(rootPath, nameof(rootPath));
|
||||
crcHash = Requires.IsNotNull(crcHash, nameof(crcHash));
|
||||
@@ -115,9 +115,9 @@ namespace Core.FileSystem
|
||||
{
|
||||
ParseFileVirtualPath(fileVirtualPath, out var cpkFileName, out var relativeVirtualPath);
|
||||
|
||||
if (_cpkArchives.ContainsKey(cpkFileName))
|
||||
if (_cpkArchives.TryGetValue(cpkFileName, out CpkArchive archive))
|
||||
{
|
||||
return _cpkArchives[cpkFileName].FileExists(relativeVirtualPath);
|
||||
return archive.FileExists(relativeVirtualPath);
|
||||
}
|
||||
|
||||
// Check if the file exists in any of the segmented cpk archives.
|
||||
@@ -142,9 +142,9 @@ namespace Core.FileSystem
|
||||
{
|
||||
ParseFileVirtualPath(fileVirtualPath, out var cpkFileName, out var relativeVirtualPath);
|
||||
|
||||
if (_cpkArchives.ContainsKey(cpkFileName))
|
||||
if (_cpkArchives.TryGetValue(cpkFileName, out CpkArchive archive))
|
||||
{
|
||||
return _cpkArchives[cpkFileName].ReadAllBytes(relativeVirtualPath);
|
||||
return archive.ReadAllBytes(relativeVirtualPath);
|
||||
}
|
||||
|
||||
// Find and read the file content in segmented cpk archives.
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Core.GameBox
|
||||
{
|
||||
public const float GameBoxUnitToUnityUnit = 20f;
|
||||
public const float GameBoxMv3UnitToUnityUnit = 1270f;
|
||||
public const uint GameBoxTicksPerSecond = 4800;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 ToUnityVertex(Vector3 vertex, float scale)
|
||||
@@ -130,6 +131,18 @@ namespace Core.GameBox
|
||||
return new Quaternion(-quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Quaternion MovQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
|
||||
{
|
||||
return new Quaternion(-quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Quaternion MshQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
|
||||
{
|
||||
return new Quaternion(-quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Quaternion LgtQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
|
||||
{
|
||||
@@ -188,5 +201,18 @@ namespace Core.GameBox
|
||||
new Vector4(matrix.Zx, matrix.Zy, matrix.Zz, matrix.Zw),
|
||||
new Vector4(matrix.Tx, matrix.Ty, matrix.Tz, matrix.Tw));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint GameBoxSecondsToTick(float seconds)
|
||||
{
|
||||
return (uint)(seconds * GameBoxTicksPerSecond);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float TickToGameBoxSeconds(uint tick)
|
||||
{
|
||||
return (float)tick / GameBoxTicksPerSecond;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,9 @@ namespace Core.Services
|
||||
{
|
||||
if (!_services.ContainsKey(typeof(T)))
|
||||
{
|
||||
Debug.LogError($"{typeof(T)} not registered with {GetType().Name}");
|
||||
throw new InvalidOperationException();
|
||||
string error = $"{typeof(T)} not registered with {GetType().Name}";
|
||||
Debug.LogError(error);
|
||||
throw new InvalidOperationException(error);
|
||||
}
|
||||
|
||||
return (T)_services[typeof(T)];
|
||||
|
||||
@@ -52,7 +52,6 @@ namespace Core.Utils
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ushort ReadUInt16()
|
||||
{
|
||||
|
||||
@@ -6,23 +6,13 @@
|
||||
namespace Core.Utils
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DataReader.Cpk;
|
||||
using UnityEngine;
|
||||
|
||||
public static class Utility
|
||||
{
|
||||
public static string ConvertToString(byte[] charArray, int codepage)
|
||||
{
|
||||
var i = 0;
|
||||
var length = charArray.Length;
|
||||
while (i < length && charArray[i] != 0) i++;
|
||||
return Encoding.GetEncoding(codepage).GetString(charArray, 0, i);
|
||||
}
|
||||
|
||||
public static Color32 ToColor32(byte[] rgba)
|
||||
{
|
||||
return new Color32(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
@@ -126,18 +116,20 @@ namespace Core.Utils
|
||||
b = (byte) ((temp / 32 + temp) / 32);
|
||||
}
|
||||
|
||||
public static string GetDirectoryName(string path, char directoryPathSeparator)
|
||||
public static string GetRelativeDirectoryPath(string filePath,
|
||||
char directoryPathSeparator = CpkConstants.DirectorySeparator)
|
||||
{
|
||||
return !path.Contains(directoryPathSeparator) ?
|
||||
return !filePath.Contains(directoryPathSeparator) ?
|
||||
string.Empty :
|
||||
path[..path.LastIndexOf(directoryPathSeparator)];
|
||||
filePath[..filePath.LastIndexOf(directoryPathSeparator)];
|
||||
}
|
||||
|
||||
public static string GetFileName(string path, char directoryPathSeparator)
|
||||
public static string GetFileName(string filePath,
|
||||
char directoryPathSeparator = CpkConstants.DirectorySeparator)
|
||||
{
|
||||
return !path.Contains(directoryPathSeparator) ?
|
||||
return !filePath.Contains(directoryPathSeparator) ?
|
||||
string.Empty :
|
||||
path[(path.LastIndexOf(directoryPathSeparator)+1)..];
|
||||
filePath[(filePath.LastIndexOf(directoryPathSeparator)+1)..];
|
||||
}
|
||||
|
||||
public static bool IsHandheldDevice()
|
||||
@@ -150,16 +142,6 @@ namespace Core.Utils
|
||||
return SystemInfo.deviceType == DeviceType.Desktop;
|
||||
}
|
||||
|
||||
public static Bounds EncapsulateBounds(IEnumerable<Bounds> bounds)
|
||||
{
|
||||
var finalBounds = new Bounds(Vector3.zero, Vector3.zero);
|
||||
foreach (Bounds b in bounds)
|
||||
{
|
||||
finalBounds.Encapsulate(b);
|
||||
}
|
||||
return finalBounds;
|
||||
}
|
||||
|
||||
public static bool IsPointWithinCollider(Collider collider, Vector3 point)
|
||||
{
|
||||
if (collider == null) return false;
|
||||
|
||||
@@ -17,20 +17,20 @@ namespace Editor
|
||||
{
|
||||
#if PAL3
|
||||
private const string GAME_VARIANT_SYMBOL = "PAL3";
|
||||
private static string OutputFileName = "ConsoleCommands.PAL3.generated";
|
||||
private static string OutputFileName = "ConsoleCommands.PAL3.g.cs";
|
||||
#elif PAL3A
|
||||
private const string GAME_VARIANT_SYMBOL = "PAL3A";
|
||||
private static string OutputFileName = "ConsoleCommands.PAL3A.generated";
|
||||
private static string OutputFileName = "ConsoleCommands.PAL3A.g.cs";
|
||||
#endif
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Source Generator/Generate ConsoleCommands.PAL3.generated.cs", priority = 2)]
|
||||
[MenuItem("PAL3/Source Generator/Generate ConsoleCommands.PAL3.g.cs", priority = 2)]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Source Generator/Generate ConsoleCommands.PAL3A.generated.cs", priority = 2)]
|
||||
[MenuItem("PAL3A/Source Generator/Generate ConsoleCommands.PAL3A.g.cs", priority = 2)]
|
||||
#endif
|
||||
public static void GenerateConsoleCommands()
|
||||
{
|
||||
var writePath = $"Assets/Scripts/PAL3/Command/{OutputFileName}.cs";
|
||||
var writePath = $"Assets/Scripts/PAL3/Command/{OutputFileName}";
|
||||
var nameSpace = "Pal3.Command";
|
||||
var className = "ConsoleCommands";
|
||||
ISourceGenerator sourceGenerator = new ConsoleCommandsAutoGen<ICommand>();
|
||||
@@ -67,7 +67,7 @@ namespace Editor
|
||||
using StreamWriter sw = new StreamWriter(writePath);
|
||||
sw.Write(output);
|
||||
|
||||
Debug.Log($"{fileName}.cs generated.");
|
||||
Debug.Log($"{fileName} generated.");
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Pal3.Actor
|
||||
{
|
||||
if (IsMainActor())
|
||||
{
|
||||
return ActorConstants.ActionNames[ActorActionType.Stand];
|
||||
return ActorConstants.ActionToNameMap[ActorActionType.Stand];
|
||||
}
|
||||
|
||||
if (IsMonsterActor() && HasAction(ActorConstants.MonsterIdleAction))
|
||||
@@ -56,18 +56,18 @@ namespace Pal3.Actor
|
||||
return ActorConstants.MonsterIdleAction;
|
||||
}
|
||||
|
||||
if (HasAction(ActorConstants.ActionNames[ActorActionType.NpcStand1]))
|
||||
if (HasAction(ActorConstants.ActionToNameMap[ActorActionType.NpcStand1]))
|
||||
{
|
||||
return ActorConstants.ActionNames[ActorActionType.NpcStand1];
|
||||
return ActorConstants.ActionToNameMap[ActorActionType.NpcStand1];
|
||||
}
|
||||
|
||||
if (HasAction(ActorConstants.ActionNames[ActorActionType.NpcStand2]))
|
||||
if (HasAction(ActorConstants.ActionToNameMap[ActorActionType.NpcStand2]))
|
||||
{
|
||||
return ActorConstants.ActionNames[ActorActionType.NpcStand2];
|
||||
return ActorConstants.ActionToNameMap[ActorActionType.NpcStand2];
|
||||
}
|
||||
|
||||
Debug.LogError($"No default idle animation found for {Info.Id}_{Info.Name}");
|
||||
return ActorConstants.ActionNames[ActorActionType.NpcStand1];
|
||||
return ActorConstants.ActionToNameMap[ActorActionType.NpcStand1];
|
||||
}
|
||||
|
||||
public string GetMovementAction(MovementMode mode)
|
||||
@@ -76,12 +76,12 @@ namespace Pal3.Actor
|
||||
{
|
||||
return mode switch
|
||||
{
|
||||
MovementMode.Walk => ActorConstants.ActionNames[ActorActionType.Walk],
|
||||
MovementMode.Run => HasAction(ActorConstants.ActionNames[ActorActionType.Run])
|
||||
? ActorConstants.ActionNames[ActorActionType.Run]
|
||||
: ActorConstants.ActionNames[ActorActionType.Walk],
|
||||
MovementMode.StepBack => ActorConstants.ActionNames[ActorActionType.StepBack],
|
||||
_ => ActorConstants.ActionNames[ActorActionType.Walk]
|
||||
MovementMode.Walk => ActorConstants.ActionToNameMap[ActorActionType.Walk],
|
||||
MovementMode.Run => HasAction(ActorConstants.ActionToNameMap[ActorActionType.Run])
|
||||
? ActorConstants.ActionToNameMap[ActorActionType.Run]
|
||||
: ActorConstants.ActionToNameMap[ActorActionType.Walk],
|
||||
MovementMode.StepBack => ActorConstants.ActionToNameMap[ActorActionType.StepBack],
|
||||
_ => ActorConstants.ActionToNameMap[ActorActionType.Walk]
|
||||
};
|
||||
}
|
||||
|
||||
@@ -92,17 +92,17 @@ namespace Pal3.Actor
|
||||
|
||||
return mode switch
|
||||
{
|
||||
MovementMode.Walk => ActorConstants.ActionNames[ActorActionType.NpcWalk],
|
||||
MovementMode.Run => ActorConstants.ActionNames[ActorActionType.NpcRun],
|
||||
_ => ActorConstants.ActionNames[ActorActionType.NpcWalk]
|
||||
MovementMode.Walk => ActorConstants.ActionToNameMap[ActorActionType.NpcWalk],
|
||||
MovementMode.Run => ActorConstants.ActionToNameMap[ActorActionType.NpcRun],
|
||||
_ => ActorConstants.ActionToNameMap[ActorActionType.NpcWalk]
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Get weapon based on inventory context
|
||||
public string GetWeaponName()
|
||||
{
|
||||
return ActorConstants.MainActorWeaponMap.ContainsKey(Info.Name) ?
|
||||
ActorConstants.MainActorWeaponMap[Info.Name] : null;
|
||||
return ActorConstants.MainActorWeaponMap.TryGetValue(Info.Name, out var value) ?
|
||||
value : null;
|
||||
}
|
||||
|
||||
public float GetInteractionMaxDistance()
|
||||
|
||||
@@ -7,57 +7,40 @@ namespace Pal3.Actor
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.DataLoader;
|
||||
using Core.DataReader.Cpk;
|
||||
using Core.DataReader.Mv3;
|
||||
using Core.DataReader.Pol;
|
||||
using Core.Extensions;
|
||||
using Core.Renderer;
|
||||
using Core.Services;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using GamePlay;
|
||||
using Renderer;
|
||||
using Script.Waiter;
|
||||
using State;
|
||||
using UnityEngine;
|
||||
|
||||
public class ActorActionController : MonoBehaviour,
|
||||
ICommandExecutor<ActorAutoStandCommand>,
|
||||
ICommandExecutor<ActorPerformActionCommand>,
|
||||
ICommandExecutor<ActorStopActionCommand>,
|
||||
public abstract class ActorActionController : MonoBehaviour,
|
||||
ICommandExecutor<ActorStopActionAndStandCommand>,
|
||||
ICommandExecutor<ActorChangeTextureCommand>,
|
||||
ICommandExecutor<ActorEnablePlayerControlCommand>,
|
||||
ICommandExecutor<ActorShowEmojiCommand>,
|
||||
#if PAL3A
|
||||
ICommandExecutor<ActorShowEmoji2Command>,
|
||||
#endif
|
||||
ICommandExecutor<GameStateChangedNotification>
|
||||
ICommandExecutor<GameStateChangedNotification>,
|
||||
ICommandExecutor<ActorPerformActionCommand>
|
||||
{
|
||||
private const float EMOJI_ANIMATION_FPS = 5f;
|
||||
private const float ACTOR_COLLIDER_RADIUS_MIN = 0.5f;
|
||||
private const float ACTOR_COLLIDER_RADIUS_MAX = 1.5f;
|
||||
|
||||
private GameResourceProvider _resourceProvider;
|
||||
private IMaterialFactory _materialFactory;
|
||||
private Actor _actor;
|
||||
private Color _tintColor;
|
||||
|
||||
private bool _isDropShadowEnabled;
|
||||
private GameObject _shadow;
|
||||
private SpriteRenderer _shadowSpriteRenderer;
|
||||
|
||||
private bool _autoStand = true;
|
||||
private string _currentAction = string.Empty;
|
||||
private Mv3ModelRenderer _mv3AnimationRenderer;
|
||||
private WaitUntilCanceled _animationLoopPointWaiter;
|
||||
|
||||
private Bounds _rendererBounds;
|
||||
private Bounds _meshBounds;
|
||||
|
||||
private bool _hasColliderAndRigidBody;
|
||||
private Rigidbody _rigidbody;
|
||||
@@ -67,50 +50,15 @@ namespace Pal3.Actor
|
||||
// Also, the player actor is only non-kinematic during gameplay state.
|
||||
private bool _isKinematic = true;
|
||||
|
||||
public void Init(GameResourceProvider resourceProvider,
|
||||
internal void Init(GameResourceProvider resourceProvider,
|
||||
Actor actor,
|
||||
bool hasColliderAndRigidBody,
|
||||
bool isDropShadowEnabled,
|
||||
Color tintColor)
|
||||
bool isDropShadowEnabled)
|
||||
{
|
||||
_resourceProvider = resourceProvider;
|
||||
_actor = actor;
|
||||
_hasColliderAndRigidBody = hasColliderAndRigidBody;
|
||||
_isDropShadowEnabled = isDropShadowEnabled;
|
||||
_tintColor = tintColor;
|
||||
_materialFactory = resourceProvider.GetMaterialFactory();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
||||
|
||||
DeActivate();
|
||||
|
||||
if (_mv3AnimationRenderer != null)
|
||||
{
|
||||
Destroy(_mv3AnimationRenderer);
|
||||
}
|
||||
|
||||
if (_shadow != null)
|
||||
{
|
||||
Destroy(_shadow);
|
||||
}
|
||||
|
||||
if (_collider != null)
|
||||
{
|
||||
Destroy(_collider);
|
||||
}
|
||||
|
||||
if (_rigidbody != null)
|
||||
{
|
||||
Destroy(_rigidbody);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetCurrentAction()
|
||||
@@ -139,86 +87,19 @@ namespace Pal3.Actor
|
||||
int loopCount = -1,
|
||||
WaitUntilCanceled waiter = null)
|
||||
{
|
||||
PerformAction(ActorConstants.ActionNames[actorActionType], overwrite, loopCount, waiter);
|
||||
PerformAction(ActorConstants.ActionToNameMap[actorActionType], overwrite, loopCount, waiter);
|
||||
}
|
||||
|
||||
public void PerformAction(string actionName,
|
||||
public virtual void PerformAction(string actionName,
|
||||
bool overwrite = false,
|
||||
int loopCount = -1,
|
||||
WaitUntilCanceled waiter = null)
|
||||
{
|
||||
if (!overwrite && string.Equals(_currentAction, actionName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_actor.HasAction(actionName))
|
||||
{
|
||||
Debug.LogError($"Action {actionName} not found for actor {_actor.Info.Name}.");
|
||||
_animationLoopPointWaiter?.CancelWait();
|
||||
waiter?.CancelWait();
|
||||
return;
|
||||
}
|
||||
|
||||
Mv3File mv3File;
|
||||
ITextureResourceProvider textureProvider;
|
||||
try
|
||||
{
|
||||
(mv3File, textureProvider) = _actor.GetActionMv3(actionName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError(ex);
|
||||
_animationLoopPointWaiter?.CancelWait();
|
||||
waiter?.CancelWait();
|
||||
return;
|
||||
}
|
||||
|
||||
DisposeAction();
|
||||
|
||||
_animationLoopPointWaiter = waiter;
|
||||
_currentAction = actionName.ToLower();
|
||||
_mv3AnimationRenderer = gameObject.GetOrAddComponent<Mv3ModelRenderer>();
|
||||
|
||||
ActorActionType actionType = ActorConstants.ActionNames
|
||||
.FirstOrDefault(_ => string.Equals(_.Value, actionName, StringComparison.OrdinalIgnoreCase)).Key;
|
||||
|
||||
if (mv3File.TagNodes is {Length: > 0} && _actor.GetWeaponName() is {} weaponName &&
|
||||
ActorConstants.ActionNameToWeaponArmTypeMap[actionType] != WeaponArmType.None)
|
||||
{
|
||||
var separator = CpkConstants.DirectorySeparator;
|
||||
|
||||
var weaponPath = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.WeaponFolderName}{separator}{weaponName}{separator}{weaponName}.pol";
|
||||
|
||||
(PolFile polFile, ITextureResourceProvider weaponTextureProvider) = _resourceProvider.GetPol(weaponPath);
|
||||
_mv3AnimationRenderer.Init(mv3File,
|
||||
_materialFactory,
|
||||
textureProvider,
|
||||
_tintColor,
|
||||
polFile,
|
||||
weaponTextureProvider);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mv3AnimationRenderer.Init(mv3File,
|
||||
_materialFactory,
|
||||
textureProvider,
|
||||
_tintColor);
|
||||
}
|
||||
|
||||
_mv3AnimationRenderer.AnimationLoopPointReached += AnimationLoopPointReached;
|
||||
_mv3AnimationRenderer.StartAnimation(loopCount);
|
||||
|
||||
_rendererBounds = _mv3AnimationRenderer.GetRendererBounds();
|
||||
_meshBounds = _mv3AnimationRenderer.GetMeshBounds();
|
||||
|
||||
ActorActionType action = ActorConstants.ActionNames
|
||||
.FirstOrDefault(a => a.Value.Equals(_currentAction)).Key;
|
||||
|
||||
if (_isDropShadowEnabled)
|
||||
{
|
||||
SetupShadow(action);
|
||||
SetupShadow(_currentAction);
|
||||
}
|
||||
|
||||
if (_hasColliderAndRigidBody)
|
||||
@@ -228,8 +109,55 @@ namespace Pal3.Actor
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupShadow(ActorActionType actorAction)
|
||||
public virtual void PauseAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual float GetActorHeight()
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public virtual Bounds GetRendererBounds()
|
||||
{
|
||||
return new Bounds(transform.position, Vector3.one);
|
||||
}
|
||||
|
||||
public virtual Bounds GetMeshBounds()
|
||||
{
|
||||
return new Bounds(Vector3.zero, Vector3.zero);
|
||||
}
|
||||
|
||||
internal virtual void DisposeCurrentAction()
|
||||
{
|
||||
_currentAction = string.Empty;
|
||||
}
|
||||
|
||||
internal virtual void DeActivate()
|
||||
{
|
||||
DisposeCurrentAction();
|
||||
|
||||
if (_shadow != null)
|
||||
{
|
||||
Destroy(_shadow);
|
||||
}
|
||||
|
||||
if (_rigidbody != null)
|
||||
{
|
||||
Destroy(_rigidbody);
|
||||
}
|
||||
|
||||
if (_collider != null)
|
||||
{
|
||||
Destroy(_collider);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupShadow(string actionName)
|
||||
{
|
||||
ActorActionType? actionType = ActorConstants.NameToActionMap.ContainsKey(actionName.ToLower()) ?
|
||||
ActorConstants.NameToActionMap[actionName.ToLower()] : null;
|
||||
|
||||
// Disable shadow for some of the actors.
|
||||
#if PAL3
|
||||
if (_actor.Info.Id == (byte) PlayerActorId.HuaYing) return;
|
||||
@@ -245,7 +173,7 @@ namespace Pal3.Actor
|
||||
#endif
|
||||
|
||||
// Disable shadow for some actions
|
||||
if (ActorConstants.ActionWithoutShadow.Contains(actorAction))
|
||||
if (actionType.HasValue && ActorConstants.ActionWithoutShadow.Contains(actionType.Value))
|
||||
{
|
||||
if (_shadow != null) _shadowSpriteRenderer.enabled = false;
|
||||
}
|
||||
@@ -354,95 +282,6 @@ namespace Pal3.Actor
|
||||
waiter.CancelWait();
|
||||
}
|
||||
|
||||
public float GetActorHeight()
|
||||
{
|
||||
if (_mv3AnimationRenderer == null || !_mv3AnimationRenderer.IsVisible())
|
||||
{
|
||||
return _meshBounds.size.y;
|
||||
}
|
||||
|
||||
return _mv3AnimationRenderer.GetMeshBounds().size.y;
|
||||
}
|
||||
|
||||
public Bounds GetRendererBounds()
|
||||
{
|
||||
return (_mv3AnimationRenderer == null || !_mv3AnimationRenderer.IsVisible()) ? _rendererBounds :
|
||||
_mv3AnimationRenderer.GetRendererBounds();
|
||||
}
|
||||
|
||||
public Bounds GetMeshBounds()
|
||||
{
|
||||
return (_mv3AnimationRenderer == null || !_mv3AnimationRenderer.IsVisible()) ? _meshBounds :
|
||||
_mv3AnimationRenderer.GetMeshBounds();
|
||||
}
|
||||
|
||||
private void AnimationLoopPointReached(object _, int loopCount)
|
||||
{
|
||||
if (loopCount is 0 or -2)
|
||||
{
|
||||
_animationLoopPointWaiter?.CancelWait();
|
||||
}
|
||||
|
||||
if (_autoStand && _mv3AnimationRenderer.IsVisible())
|
||||
{
|
||||
if (loopCount is 0 ||
|
||||
(loopCount is -2 && !_mv3AnimationRenderer.IsActionInHoldState()))
|
||||
{
|
||||
PerformAction(_actor.GetIdleAction());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeAction()
|
||||
{
|
||||
_animationLoopPointWaiter?.CancelWait();
|
||||
|
||||
if (_mv3AnimationRenderer != null)
|
||||
{
|
||||
_mv3AnimationRenderer.AnimationLoopPointReached -= AnimationLoopPointReached;
|
||||
_mv3AnimationRenderer.DisposeAnimation();
|
||||
}
|
||||
|
||||
_currentAction = string.Empty;
|
||||
}
|
||||
|
||||
private void DisposeShadow()
|
||||
{
|
||||
if (_shadow != null)
|
||||
{
|
||||
Destroy(_shadow);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeCollider()
|
||||
{
|
||||
if (_collider != null)
|
||||
{
|
||||
Destroy(_collider);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeRigidBody()
|
||||
{
|
||||
if (_rigidbody != null)
|
||||
{
|
||||
Destroy(_rigidbody);
|
||||
}
|
||||
}
|
||||
|
||||
public void DeActivate()
|
||||
{
|
||||
DisposeAction();
|
||||
DisposeShadow();
|
||||
DisposeRigidBody();
|
||||
DisposeCollider();
|
||||
}
|
||||
|
||||
public void Execute(ActorAutoStandCommand command)
|
||||
{
|
||||
if (command.ActorId == _actor.Info.Id) _autoStand = (command.AutoStand == 1);
|
||||
}
|
||||
|
||||
public void Execute(ActorPerformActionCommand command)
|
||||
{
|
||||
if (command.ActorId == _actor.Info.Id)
|
||||
@@ -468,45 +307,12 @@ namespace Pal3.Actor
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(ActorStopActionCommand command)
|
||||
{
|
||||
if (command.ActorId != _actor.Info.Id ||
|
||||
_mv3AnimationRenderer == null ||
|
||||
!_mv3AnimationRenderer.IsVisible()) return;
|
||||
|
||||
if (_mv3AnimationRenderer.IsActionInHoldState())
|
||||
{
|
||||
_animationLoopPointWaiter?.CancelWait();
|
||||
_animationLoopPointWaiter = new WaitUntilCanceled();
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ScriptRunnerAddWaiterRequest(_animationLoopPointWaiter));
|
||||
|
||||
_mv3AnimationRenderer.ResumeAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
_mv3AnimationRenderer.PauseAnimation();
|
||||
_animationLoopPointWaiter?.CancelWait();
|
||||
|
||||
if (_autoStand && _mv3AnimationRenderer.IsVisible())
|
||||
{
|
||||
PerformAction(_actor.GetIdleAction());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(ActorStopActionAndStandCommand command)
|
||||
{
|
||||
if (_actor.Info.Id != command.ActorId) return;
|
||||
PerformAction(_actor.GetIdleAction());
|
||||
}
|
||||
|
||||
public void Execute(ActorChangeTextureCommand command)
|
||||
{
|
||||
if (_actor.Info.Id != command.ActorId) return;
|
||||
_mv3AnimationRenderer.ChangeTexture(command.TextureName);
|
||||
}
|
||||
|
||||
public void Execute(ActorEnablePlayerControlCommand command)
|
||||
{
|
||||
if (command.ActorId == ActorConstants.PlayerActorVirtualID) return;
|
||||
|
||||
@@ -6,16 +6,13 @@
|
||||
namespace Pal3.Actor
|
||||
{
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Core.DataLoader;
|
||||
using System.Collections.Generic;
|
||||
using Core.DataReader.Cpk;
|
||||
using Core.DataReader.Ini;
|
||||
using Core.DataReader.Mv3;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using UnityEngine;
|
||||
|
||||
public enum ActorAnimationFileType
|
||||
public enum ActorAnimationType
|
||||
{
|
||||
Mv3 = 0,
|
||||
Mov
|
||||
@@ -23,9 +20,11 @@ namespace Pal3.Actor
|
||||
|
||||
public abstract class ActorBase
|
||||
{
|
||||
public ActorAnimationFileType AnimationFileType;
|
||||
public ActorAnimationType AnimationType { get; private set; }
|
||||
|
||||
private ActorConfigFile _actorConfig;
|
||||
private readonly Dictionary<string, string> _actionNameToFileNameMap = new (StringComparer.OrdinalIgnoreCase);
|
||||
private readonly Dictionary<string, string> _actionNameToMeshFileNameMap = new (StringComparer.OrdinalIgnoreCase);
|
||||
private readonly Dictionary<string, string> _actionNameToMaterialFileNameMap = new (StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private readonly GameResourceProvider _resourceProvider;
|
||||
|
||||
@@ -41,21 +40,54 @@ namespace Pal3.Actor
|
||||
|
||||
private void InitActorConfig(string name)
|
||||
{
|
||||
var separator = CpkConstants.DirectorySeparator;
|
||||
char separator = CpkConstants.DirectorySeparator;
|
||||
|
||||
var defaultActorConfigFile = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.ActorFolderName}{separator}{name}{separator}{name}.ini";
|
||||
string actorActionConfigFolder = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.ActorFolderName}{separator}{name}{separator}";
|
||||
|
||||
if (_resourceProvider.GetActorConfig(defaultActorConfigFile) is { } defaultConfig)
|
||||
ActorActionConfig defaultConfig = _resourceProvider.GetActorActionConfig(actorActionConfigFolder + $"{name}.ini");
|
||||
|
||||
if (defaultConfig is Mv3ActionConfig mv3Config)
|
||||
{
|
||||
_actorConfig = defaultConfig;
|
||||
AnimationFileType = ActorAnimationFileType.Mv3;
|
||||
AddActorConfig(mv3Config);
|
||||
AnimationType = ActorAnimationType.Mv3;
|
||||
return;
|
||||
}
|
||||
else // For MOV animation actor, config files are defined as 01.ini, 02.ini ...up tp 09.ini
|
||||
|
||||
// Add default config if it is MOV
|
||||
if (defaultConfig is MovActionConfig)
|
||||
{
|
||||
Debug.LogWarning($"Unsupported MOV actor config found for: actor {name}");
|
||||
//throw new NotImplementedException("MOV actor currently not supported.");
|
||||
AnimationFileType = ActorAnimationFileType.Mov;
|
||||
AddActorConfig(defaultConfig);
|
||||
}
|
||||
|
||||
// For MOV animation 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")
|
||||
is MovActionConfig movConfig)
|
||||
{
|
||||
AddActorConfig(movConfig);
|
||||
}
|
||||
}
|
||||
|
||||
AnimationType = ActorAnimationType.Mov;
|
||||
}
|
||||
|
||||
private void AddActorConfig(ActorActionConfig config)
|
||||
{
|
||||
foreach (ActorAction action in config.ActorActions)
|
||||
{
|
||||
_actionNameToFileNameMap.TryAdd(action.ActionName, action.ActionFileName);
|
||||
}
|
||||
|
||||
if (config is MovActionConfig movActionConfig)
|
||||
{
|
||||
foreach (ActorAction action in config.ActorActions)
|
||||
{
|
||||
_actionNameToMeshFileNameMap.TryAdd(action.ActionName, movActionConfig.Actor.MeshFileName);
|
||||
_actionNameToMaterialFileNameMap.TryAdd(action.ActionName, movActionConfig.Actor.MaterialFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,31 +98,40 @@ namespace Pal3.Actor
|
||||
InitActorConfig(name);
|
||||
}
|
||||
|
||||
public (Mv3File mv3File, ITextureResourceProvider textureProvider) GetActionMv3(ActorActionType actorActionType)
|
||||
{
|
||||
return GetActionMv3(ActorConstants.ActionNames[actorActionType]);
|
||||
}
|
||||
|
||||
public bool HasAction(string actionName)
|
||||
{
|
||||
if (_actorConfig == null) return false;
|
||||
|
||||
return _actorConfig.ActorActions
|
||||
.Any(act => act.ActionName.Equals(actionName, StringComparison.OrdinalIgnoreCase));
|
||||
return _actionNameToFileNameMap.ContainsKey(actionName);
|
||||
}
|
||||
|
||||
public (Mv3File mv3File, ITextureResourceProvider textureProvider) GetActionMv3(string actionName)
|
||||
public string GetActionFilePath(string actionName)
|
||||
{
|
||||
ActorAction action = _actorConfig.ActorActions
|
||||
.First(act => act.ActionName.Equals(actionName, StringComparison.OrdinalIgnoreCase));
|
||||
if (!_actionNameToFileNameMap.TryGetValue(actionName, out var actionFileName))
|
||||
{
|
||||
throw new ArgumentException($"Action file name not found for action name {actionName}");
|
||||
}
|
||||
|
||||
var separator = CpkConstants.DirectorySeparator;
|
||||
char separator = CpkConstants.DirectorySeparator;
|
||||
return $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.ActorFolderName}{separator}{_actorName}{separator}" +
|
||||
$"{actionFileName}";
|
||||
}
|
||||
|
||||
var mv3File = $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.ActorFolderName}{separator}{_actorName}{separator}" +
|
||||
$"{action.ActionFileName}";
|
||||
public string GetMeshFilePath(string actionName)
|
||||
{
|
||||
if (AnimationType != ActorAnimationType.Mov)
|
||||
{
|
||||
throw new InvalidOperationException("Mesh file path is only available for MOV animation type.");
|
||||
}
|
||||
|
||||
return _resourceProvider.GetMv3(mv3File);
|
||||
if (!_actionNameToMeshFileNameMap.TryGetValue(actionName, out var meshFileName))
|
||||
{
|
||||
throw new ArgumentException($"Mesh file name not found for action name {actionName}");
|
||||
}
|
||||
|
||||
char separator = CpkConstants.DirectorySeparator;
|
||||
return $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.ActorFolderName}{separator}{_actorName}{separator}" +
|
||||
$"{meshFileName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 199 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user