mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-27 01:48:06 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db11847130 | ||
|
|
d88f737375 | ||
|
|
d1a7de0229 | ||
|
|
78e9692abc | ||
|
|
836463c795 | ||
|
|
630166880f | ||
|
|
421ee12a82 |
No files matched your search
@@ -134,7 +134,7 @@ namespace Core.Animation
|
||||
var timePast = 0f;
|
||||
while (timePast < duration && target != null && !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
Quaternion rotation = Quaternion.Lerp(startRotation, toRotation,
|
||||
Quaternion rotation = Quaternion.Slerp(startRotation, toRotation,
|
||||
GetInterpolationRatio(timePast / duration, curveType));
|
||||
|
||||
Vector3 direction = (rotation * Vector3.forward).normalized;
|
||||
@@ -167,7 +167,7 @@ namespace Core.Animation
|
||||
var timePast = 0f;
|
||||
while (timePast < duration && target != null && !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
Quaternion rotation = Quaternion.Lerp(startRotation, toRotation,
|
||||
Quaternion rotation = Quaternion.Slerp(startRotation, toRotation,
|
||||
GetInterpolationRatio(timePast / duration, curveType));
|
||||
|
||||
target.rotation = rotation;
|
||||
|
||||
@@ -154,7 +154,6 @@ namespace Core.DataReader.Cvd
|
||||
public int[] Triangles;
|
||||
public GameBoxBlendFlag BlendFlag;
|
||||
public GameBoxMaterial Material;
|
||||
public string TextureName;
|
||||
public float[] AnimationTimeKeys;
|
||||
public GameBoxMaterial[] AnimationMaterials;
|
||||
}
|
||||
|
||||
@@ -413,19 +413,18 @@ namespace Core.DataReader.Cvd
|
||||
int codepage)
|
||||
#endif
|
||||
{
|
||||
var blendFlag = (GameBoxBlendFlag)reader.ReadByte();
|
||||
GameBoxBlendFlag blendFlag = (GameBoxBlendFlag)reader.ReadByte();
|
||||
|
||||
var material = new GameBoxMaterial()
|
||||
GameBoxMaterial material = new ()
|
||||
{
|
||||
Diffuse = Utility.ToColor32(reader.ReadBytes(4)),
|
||||
Ambient = Utility.ToColor32(reader.ReadBytes(4)),
|
||||
Specular = Utility.ToColor32(reader.ReadBytes(4)),
|
||||
Emissive = Utility.ToColor32(reader.ReadBytes(4)),
|
||||
Power = reader.ReadSingle()
|
||||
SpecularPower = reader.ReadSingle(),
|
||||
TextureFileNames = new [] { reader.ReadString(64, codepage) }
|
||||
};
|
||||
|
||||
var textureName = reader.ReadString(64, codepage);
|
||||
|
||||
var numberOfIndices = reader.ReadInt32();
|
||||
|
||||
var indices = new (ushort x, ushort y, ushort z)[numberOfIndices];
|
||||
@@ -458,7 +457,7 @@ namespace Core.DataReader.Cvd
|
||||
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Power = reader.ReadSingle()
|
||||
SpecularPower = reader.ReadSingle()
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -486,7 +485,6 @@ namespace Core.DataReader.Cvd
|
||||
{
|
||||
BlendFlag = blendFlag,
|
||||
Material = material,
|
||||
TextureName = textureName,
|
||||
FrameVertices = frameVertices,
|
||||
Triangles = triangles.ToArray(),
|
||||
AnimationTimeKeys = animationTimeKeys,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f50098c0cef46349314b7f36bc59136
|
||||
timeCreated: 1690567483
|
||||
@@ -0,0 +1,19 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Mtl
|
||||
{
|
||||
using GameBox;
|
||||
|
||||
public sealed class MtlFile
|
||||
{
|
||||
public GameBoxMaterial[] Materials { get; }
|
||||
|
||||
public MtlFile(GameBoxMaterial[] materials)
|
||||
{
|
||||
Materials = materials;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f167ffdd8daf4bcfb2b50ee3e3e7bc8b
|
||||
timeCreated: 1690567491
|
||||
@@ -0,0 +1,76 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#define USE_UNSAFE_BINARY_READER
|
||||
|
||||
namespace Core.DataReader.Mtl
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Extensions;
|
||||
using GameBox;
|
||||
using Utils;
|
||||
|
||||
public sealed class MtlFileReader : IFileReader<MtlFile>
|
||||
{
|
||||
private readonly int _codepage;
|
||||
|
||||
public MtlFileReader(int codepage)
|
||||
{
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
public MtlFile Read(byte[] data)
|
||||
{
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
#else
|
||||
using var stream = new MemoryStream(data);
|
||||
using var reader = new BinaryReader(stream);
|
||||
#endif
|
||||
|
||||
var header = reader.ReadChars(4);
|
||||
var headerStr = new string(header[..^1]);
|
||||
|
||||
if (headerStr != "mtl")
|
||||
{
|
||||
throw new InvalidDataException("Invalid MTL(.mtl) file: header != mtl");
|
||||
}
|
||||
|
||||
var version = reader.ReadInt32();
|
||||
if (version != 100)
|
||||
{
|
||||
throw new InvalidDataException("Invalid MTL(.mtl) file: version != 100");
|
||||
}
|
||||
|
||||
int numberOfMaterials = reader.ReadInt32();
|
||||
var materials = new GameBoxMaterial[numberOfMaterials];
|
||||
|
||||
for (var i = 0; i < numberOfMaterials; i++)
|
||||
{
|
||||
materials[i] = new GameBoxMaterial
|
||||
{
|
||||
Diffuse = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
SpecularPower = reader.ReadSingle(),
|
||||
};
|
||||
|
||||
List<string> textureNames = new ();
|
||||
for (var j = 0; j < 4; j++)
|
||||
{
|
||||
int textureNameLength = reader.ReadInt32();
|
||||
if (textureNameLength == 0) continue;
|
||||
textureNames.Add(reader.ReadString(textureNameLength, _codepage));
|
||||
}
|
||||
|
||||
materials[i].TextureFileNames = textureNames.ToArray();
|
||||
}
|
||||
|
||||
return new MtlFile(materials);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16ec8deffba245bcb6808f8ad26677c7
|
||||
timeCreated: 1690567511
|
||||
@@ -56,12 +56,6 @@ namespace Core.DataReader.Mv3
|
||||
public Mv3Vert[] Vertices;
|
||||
}
|
||||
|
||||
public struct Mv3Material
|
||||
{
|
||||
public GameBoxMaterial Material;
|
||||
public string[] TextureNames;
|
||||
}
|
||||
|
||||
public struct Mv3Mesh
|
||||
{
|
||||
public string Name; // 64 chars max
|
||||
@@ -87,20 +81,20 @@ namespace Core.DataReader.Mv3
|
||||
public uint Duration { get; }
|
||||
public Mv3AnimationEvent[] AnimationEvents { get; }
|
||||
public Mv3TagNode[] TagNodes { get; }
|
||||
public Mv3Material[] Materials { get; }
|
||||
public Mv3Mesh[] Meshes { get; }
|
||||
public GameBoxMaterial[] Materials { get; }
|
||||
|
||||
public Mv3File(uint duration,
|
||||
Mv3AnimationEvent[] animationEvents,
|
||||
Mv3TagNode[] tagNodes,
|
||||
Mv3Material[] materials,
|
||||
Mv3Mesh[] meshes)
|
||||
Mv3Mesh[] meshes,
|
||||
GameBoxMaterial[] materials)
|
||||
{
|
||||
Duration = duration;
|
||||
AnimationEvents = animationEvents;
|
||||
TagNodes = tagNodes;
|
||||
Materials = materials;
|
||||
Meshes = meshes;
|
||||
Materials = materials;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace Core.DataReader.Mv3
|
||||
tagNodes[i] = ReadTagNode(reader, _codepage);
|
||||
}
|
||||
|
||||
var materials = new Mv3Material[numberOfMaterials];
|
||||
var materials = new GameBoxMaterial[numberOfMaterials];
|
||||
for (var i = 0; i < numberOfMaterials; i++)
|
||||
{
|
||||
materials[i] = ReadMaterial(reader, _codepage);
|
||||
@@ -85,8 +85,8 @@ namespace Core.DataReader.Mv3
|
||||
return new Mv3File(duration,
|
||||
animationEvents,
|
||||
tagNodes,
|
||||
materials,
|
||||
meshes);
|
||||
meshes,
|
||||
materials);
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
@@ -306,34 +306,30 @@ namespace Core.DataReader.Mv3
|
||||
}
|
||||
|
||||
#if USE_UNSAFE_BINARY_READER
|
||||
private static Mv3Material ReadMaterial(UnsafeBinaryReader reader, int codepage)
|
||||
private static GameBoxMaterial ReadMaterial(UnsafeBinaryReader reader, int codepage)
|
||||
#else
|
||||
private static Mv3Material ReadMaterial(BinaryReader reader, int codepage)
|
||||
private static GameBoxMaterial ReadMaterial(BinaryReader reader, int codepage)
|
||||
#endif
|
||||
{
|
||||
var material = new GameBoxMaterial()
|
||||
GameBoxMaterial material = new ()
|
||||
{
|
||||
Diffuse = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Power = reader.ReadSingle()
|
||||
SpecularPower = reader.ReadSingle()
|
||||
};
|
||||
|
||||
var textureNames = new List<string>();
|
||||
List<string> textureNames = new ();
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
string textureName;
|
||||
var length = reader.ReadInt32();
|
||||
if (length is < 0 or > 255)
|
||||
{
|
||||
throw new InvalidDataException($"Invalid length of material name: {length}");
|
||||
}
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
if (i > 0) continue;
|
||||
textureName = string.Empty; // Use default white texture?
|
||||
textureName = string.Empty; // Use default white texture
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -343,11 +339,9 @@ namespace Core.DataReader.Mv3
|
||||
textureNames.Add(textureName);
|
||||
}
|
||||
|
||||
return new Mv3Material()
|
||||
{
|
||||
Material = material,
|
||||
TextureNames = textureNames.ToArray(),
|
||||
};
|
||||
material.TextureFileNames = textureNames.ToArray();
|
||||
|
||||
return material;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,6 @@ namespace Core.DataReader.Pol
|
||||
{
|
||||
public GameBoxBlendFlag BlendFlag;
|
||||
public GameBoxMaterial Material;
|
||||
public string[] TextureNames;
|
||||
public uint VertStart;
|
||||
public uint VertEnd;
|
||||
public int[] Triangles;
|
||||
|
||||
@@ -241,20 +241,20 @@ namespace Core.DataReader.Pol
|
||||
private static PolTexture ReadTextureInfo(BinaryReader reader, int version, int codepage)
|
||||
#endif
|
||||
{
|
||||
var blendFlag = (GameBoxBlendFlag)reader.ReadUInt32();
|
||||
GameBoxBlendFlag blendFlag = (GameBoxBlendFlag)reader.ReadUInt32();
|
||||
|
||||
var material = new GameBoxMaterial()
|
||||
GameBoxMaterial material = new ()
|
||||
{
|
||||
Diffuse = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
|
||||
Power = reader.ReadSingle()
|
||||
SpecularPower = reader.ReadSingle()
|
||||
};
|
||||
|
||||
// Hack fix
|
||||
if (material.Power < 0) material.Power = 0;
|
||||
else if (material.Power > 128) material.Power = 128;
|
||||
if (material.SpecularPower < 0) material.SpecularPower = 0;
|
||||
else if (material.SpecularPower > 128) material.SpecularPower = 128;
|
||||
|
||||
var numberOfTextures = reader.ReadInt32();
|
||||
var textureNames = new string[numberOfTextures];
|
||||
@@ -265,6 +265,8 @@ namespace Core.DataReader.Pol
|
||||
textureNames[i] = textureName;
|
||||
}
|
||||
|
||||
material.TextureFileNames = textureNames;
|
||||
|
||||
_ = reader.ReadInt32();
|
||||
var vertStart = reader.ReadUInt32();
|
||||
var vertEnd = reader.ReadUInt32();
|
||||
@@ -285,7 +287,6 @@ namespace Core.DataReader.Pol
|
||||
{
|
||||
BlendFlag = blendFlag,
|
||||
Material = material,
|
||||
TextureNames = textureNames,
|
||||
VertStart = vertStart,
|
||||
VertEnd = vertEnd,
|
||||
Triangles = triangles
|
||||
|
||||
@@ -10,11 +10,12 @@ namespace Core.GameBox
|
||||
[System.Serializable]
|
||||
public struct GameBoxMaterial
|
||||
{
|
||||
public Color32 Diffuse;
|
||||
public Color32 Ambient;
|
||||
public Color32 Specular;
|
||||
public Color32 Emissive;
|
||||
public float Power;
|
||||
public Color Diffuse;
|
||||
public Color Ambient;
|
||||
public Color Specular;
|
||||
public Color Emissive;
|
||||
public float SpecularPower;
|
||||
public string[] TextureFileNames;
|
||||
}
|
||||
|
||||
// To meet opengl, use this order instead:
|
||||
|
||||
@@ -140,16 +140,19 @@ namespace Pal3.Actor
|
||||
if (_shadow != null)
|
||||
{
|
||||
Destroy(_shadow);
|
||||
_shadow = null;
|
||||
}
|
||||
|
||||
if (_rigidbody != null)
|
||||
{
|
||||
Destroy(_rigidbody);
|
||||
_rigidbody = null;
|
||||
}
|
||||
|
||||
if (_collider != null)
|
||||
{
|
||||
Destroy(_collider);
|
||||
_collider = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace Pal3.Actor
|
||||
|
||||
ActorActionConfig defaultConfig = _resourceProvider.GetActorActionConfig(actorActionConfigFolder + $"{name}.ini");
|
||||
|
||||
// Add default config if it is MV3 animated
|
||||
if (defaultConfig is Mv3ActionConfig mv3Config)
|
||||
{
|
||||
AddActorConfig(mv3Config);
|
||||
@@ -54,13 +55,13 @@ namespace Pal3.Actor
|
||||
return;
|
||||
}
|
||||
|
||||
// Add default config if it is MOV
|
||||
// Add default config if it is MOV animated
|
||||
if (defaultConfig is MovActionConfig)
|
||||
{
|
||||
AddActorConfig(defaultConfig);
|
||||
}
|
||||
|
||||
// For MOV animation actor, additional action config files are defined as
|
||||
// For MOV animated skeletal actor, additional action config files are defined as
|
||||
// 01.ini, 02.ini ...up tp 09.ini
|
||||
for (var i = 0; i <= 9; i++)
|
||||
{
|
||||
@@ -133,5 +134,23 @@ namespace Pal3.Actor
|
||||
$"{FileConstants.ActorFolderName}{separator}{_actorName}{separator}" +
|
||||
$"{meshFileName}";
|
||||
}
|
||||
|
||||
public string GetMaterialFilePath(string actionName)
|
||||
{
|
||||
if (AnimationType != ActorAnimationType.Skeletal)
|
||||
{
|
||||
throw new InvalidOperationException("Mtl file path is only available for skeletal animation type.");
|
||||
}
|
||||
|
||||
if (!_actionNameToMaterialFileNameMap.TryGetValue(actionName, out var mtlFileName))
|
||||
{
|
||||
throw new ArgumentException($"Mtl file name not found for action name {actionName}");
|
||||
}
|
||||
|
||||
char separator = CpkConstants.DirectorySeparator;
|
||||
return $"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.ActorFolderName}{separator}{_actorName}{separator}" +
|
||||
$"{mtlFileName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace Pal3.Actor
|
||||
using Core.DataLoader;
|
||||
using Core.DataReader.Mov;
|
||||
using Core.DataReader.Msh;
|
||||
using Core.DataReader.Mtl;
|
||||
using Core.Extensions;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
@@ -77,18 +78,23 @@ namespace Pal3.Actor
|
||||
return;
|
||||
}
|
||||
|
||||
MovFile movFile;
|
||||
MshFile mshFile;
|
||||
MtlFile mtlFile;
|
||||
MovFile movFile;
|
||||
ITextureResourceProvider textureProvider;
|
||||
try
|
||||
{
|
||||
string movFilePath = _actor.GetActionFilePath(actionName);
|
||||
movFile = _resourceProvider.GetGameResourceFile<MovFile>(movFilePath);
|
||||
textureProvider = _resourceProvider.CreateTextureResourceProvider(
|
||||
Utility.GetRelativeDirectoryPath(movFilePath));
|
||||
|
||||
string mshFilePath = _actor.GetMeshFilePath(actionName);
|
||||
mshFile = _resourceProvider.GetGameResourceFile<MshFile>(mshFilePath);
|
||||
|
||||
string mtlFilePath = _actor.GetMaterialFilePath(actionName);
|
||||
mtlFile = _resourceProvider.GetGameResourceFile<MtlFile>(mtlFilePath);
|
||||
|
||||
string movFilePath = _actor.GetActionFilePath(actionName);
|
||||
movFile = _resourceProvider.GetGameResourceFile<MovFile>(movFilePath);
|
||||
|
||||
textureProvider = _resourceProvider.CreateTextureResourceProvider(
|
||||
Utility.GetRelativeDirectoryPath(movFilePath));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -102,9 +108,9 @@ namespace Pal3.Actor
|
||||
_skeletalModelRenderer = gameObject.GetOrAddComponent<SkeletalModelRenderer>();
|
||||
|
||||
_skeletalModelRenderer.Init(mshFile,
|
||||
mtlFile,
|
||||
_materialFactory,
|
||||
textureProvider,
|
||||
_actor.Info.Name + ".tga", // TODO: Read texture name from MTL file
|
||||
_tintColor);
|
||||
|
||||
_skeletalModelRenderer.StartAnimation(movFile, loopCount);
|
||||
@@ -142,6 +148,7 @@ namespace Pal3.Actor
|
||||
if (_skeletalModelRenderer != null)
|
||||
{
|
||||
_skeletalModelRenderer.Dispose();
|
||||
_skeletalModelRenderer = null;
|
||||
}
|
||||
|
||||
base.DisposeCurrentAction();
|
||||
@@ -150,12 +157,6 @@ namespace Pal3.Actor
|
||||
internal override void DeActivate()
|
||||
{
|
||||
DisposeCurrentAction();
|
||||
|
||||
if (_skeletalModelRenderer != null)
|
||||
{
|
||||
Destroy(_skeletalModelRenderer);
|
||||
}
|
||||
|
||||
base.DeActivate();
|
||||
}
|
||||
|
||||
|
||||
@@ -221,6 +221,7 @@ namespace Pal3.Actor
|
||||
{
|
||||
_mv3ModelRenderer.AnimationLoopPointReached -= AnimationLoopPointReached;
|
||||
_mv3ModelRenderer.Dispose();
|
||||
_mv3ModelRenderer = null;
|
||||
}
|
||||
|
||||
base.DisposeCurrentAction();
|
||||
@@ -229,12 +230,6 @@ namespace Pal3.Actor
|
||||
internal override void DeActivate()
|
||||
{
|
||||
DisposeCurrentAction();
|
||||
|
||||
if (_mv3ModelRenderer != null)
|
||||
{
|
||||
Destroy(_mv3ModelRenderer);
|
||||
}
|
||||
|
||||
base.DeActivate();
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Pal3.Audio
|
||||
}
|
||||
|
||||
_currentMusicClipName = musicName;
|
||||
var musicFileVirtualPath = GetMusicFileVirtualPath(musicName);
|
||||
var musicFileVirtualPath = _resourceProvider.GetMusicFileVirtualPath(musicName);
|
||||
var musicFileCachePath = _resourceProvider.GetMp3FilePathInCacheFolder(musicFileVirtualPath);
|
||||
|
||||
yield return PlayMusicAsync(musicName, musicFileVirtualPath, musicFileCachePath, -1);
|
||||
@@ -257,13 +257,6 @@ namespace Pal3.Audio
|
||||
}
|
||||
}
|
||||
|
||||
private string GetMusicFileVirtualPath(string musicName)
|
||||
{
|
||||
var separator = CpkConstants.DirectorySeparator;
|
||||
return $"{FileConstants.MusicCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.MusicCpkPathInfo.relativePath}{separator}{musicName}.mp3";
|
||||
}
|
||||
|
||||
public IEnumerator PlayMusicAsync(string musicName,
|
||||
string musicFileVirtualPath,
|
||||
string musicFileCachePath,
|
||||
@@ -447,7 +440,7 @@ namespace Pal3.Audio
|
||||
|
||||
_currentScriptMusic = command.MusicName;
|
||||
_currentMusicClipName = command.MusicName;
|
||||
var musicFileVirtualPath = GetMusicFileVirtualPath(command.MusicName);
|
||||
var musicFileVirtualPath = _resourceProvider.GetMusicFileVirtualPath(command.MusicName);
|
||||
var musicFileCachePath = _resourceProvider.GetMp3FilePathInCacheFolder(musicFileVirtualPath);
|
||||
StartCoroutine(PlayMusicAsync(command.MusicName,
|
||||
musicFileVirtualPath,
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Pal3.Data
|
||||
using Core.DataReader.Lgt;
|
||||
using Core.DataReader.Mov;
|
||||
using Core.DataReader.Msh;
|
||||
using Core.DataReader.Mtl;
|
||||
using Core.DataReader.Mv3;
|
||||
using Core.DataReader.Nav;
|
||||
using Core.DataReader.Pol;
|
||||
@@ -137,18 +138,18 @@ namespace Pal3.Data
|
||||
new TextureProvider(_fileSystem, _textureLoaderFactory, relativeDirectoryPath);
|
||||
}
|
||||
|
||||
public T GetGameResourceFile<T>(string filePath, bool useCache = true)
|
||||
public T GetGameResourceFile<T>(string fileVirtualPath, bool useCache = true)
|
||||
{
|
||||
filePath = filePath.ToLower();
|
||||
fileVirtualPath = fileVirtualPath.ToLower();
|
||||
|
||||
if (useCache &&
|
||||
_gameResourceFileCache.ContainsKey(typeof(T)) &&
|
||||
_gameResourceFileCache[typeof(T)].ContainsKey(filePath))
|
||||
_gameResourceFileCache[typeof(T)].ContainsKey(fileVirtualPath))
|
||||
{
|
||||
return (T)_gameResourceFileCache[typeof(T)][filePath];
|
||||
return (T)_gameResourceFileCache[typeof(T)][fileVirtualPath];
|
||||
}
|
||||
|
||||
T file = GetGameResourceFileReader<T>().Read(_fileSystem.ReadAllBytes(filePath));
|
||||
T file = GetGameResourceFileReader<T>().Read(_fileSystem.ReadAllBytes(fileVirtualPath));
|
||||
|
||||
if (useCache)
|
||||
{
|
||||
@@ -157,17 +158,12 @@ namespace Pal3.Data
|
||||
{
|
||||
_gameResourceFileCache[typeof(T)] = new Dictionary<string, object>();
|
||||
}
|
||||
_gameResourceFileCache[typeof(T)][filePath] = file;
|
||||
_gameResourceFileCache[typeof(T)][fileVirtualPath] = file;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
public LgtFile GetLgt(string lgtFilePath)
|
||||
{
|
||||
return GetGameResourceFileReader<LgtFile>().Read(_fileSystem.ReadAllBytes(lgtFilePath));
|
||||
}
|
||||
|
||||
public NavFile GetNav(string sceneFileName, string sceneName)
|
||||
{
|
||||
#if PAL3
|
||||
@@ -286,6 +282,13 @@ namespace Pal3.Data
|
||||
return sfxFilePath;
|
||||
}
|
||||
|
||||
public string GetMusicFileVirtualPath(string musicName)
|
||||
{
|
||||
var separator = CpkConstants.DirectorySeparator;
|
||||
return $"{FileConstants.MusicCpkPathInfo.cpkName}{separator}" +
|
||||
$"{FileConstants.MusicCpkPathInfo.relativePath}{separator}{musicName}.mp3";
|
||||
}
|
||||
|
||||
public IEnumerator LoadAudioClipAsync(string filePath,
|
||||
AudioType audioType,
|
||||
bool streamAudio,
|
||||
@@ -651,59 +654,60 @@ namespace Pal3.Data
|
||||
|
||||
if (!newCityName.Equals(_currentCityName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Clean up cache after exiting current scene block
|
||||
_textureCache?.DisposeAll();
|
||||
|
||||
foreach (Sprite sprite in _spriteCache.Values)
|
||||
{
|
||||
Object.Destroy(sprite);
|
||||
}
|
||||
_spriteCache.Clear();
|
||||
|
||||
if (_gameResourceFileCache.ContainsKey(typeof(PolFile)))
|
||||
{
|
||||
_gameResourceFileCache[typeof(PolFile)]?.Clear();
|
||||
}
|
||||
|
||||
if (_gameResourceFileCache.ContainsKey(typeof(CvdFile)))
|
||||
{
|
||||
_gameResourceFileCache[typeof(CvdFile)]?.Clear();
|
||||
}
|
||||
|
||||
if (_gameResourceFileCache.ContainsKey(typeof(MshFile)))
|
||||
{
|
||||
_gameResourceFileCache[typeof(MshFile)]?.Clear();
|
||||
}
|
||||
|
||||
if (_gameResourceFileCache.ContainsKey(typeof(MovFile)))
|
||||
{
|
||||
_gameResourceFileCache[typeof(MovFile)]?.Clear();
|
||||
}
|
||||
|
||||
if (_gameResourceFileCache.ContainsKey(typeof(Mv3File)))
|
||||
{
|
||||
var mv3FileCache = _gameResourceFileCache[typeof(Mv3File)];
|
||||
|
||||
// Dispose non-main actor mv3 files
|
||||
// All main actor names start with "1"
|
||||
var mainActorMv3 = $"{FileConstants.ActorFolderName}{PathSeparator}1".ToLower();
|
||||
var mv3FilesToDispose = mv3FileCache.Keys
|
||||
.Where(mv3FilePath => !mv3FilePath.Contains(mainActorMv3))
|
||||
.ToArray();
|
||||
foreach (var mv3File in mv3FilesToDispose)
|
||||
{
|
||||
mv3FileCache.Remove(mv3File);
|
||||
}
|
||||
}
|
||||
|
||||
// clear all vfx prefabs in cache
|
||||
_vfxEffectPrefabCache.Clear();
|
||||
|
||||
DisposeTemporaryInMemoryGameResources();
|
||||
_currentCityName = newCityName;
|
||||
}
|
||||
|
||||
// Unloads assets that are not used (textures etc.)
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose temporary in-memory resources that are only used in current scene block.
|
||||
/// </summary>
|
||||
private void DisposeTemporaryInMemoryGameResources()
|
||||
{
|
||||
// Clean up texture cache after exiting current scene block
|
||||
_textureCache?.DisposeAll();
|
||||
|
||||
// Clean up sprite cache after exiting current scene block
|
||||
foreach (Sprite sprite in _spriteCache.Values)
|
||||
{
|
||||
Object.Destroy(sprite);
|
||||
}
|
||||
_spriteCache.Clear();
|
||||
|
||||
// Dispose in-memory game resource files
|
||||
foreach (var fileCache in _gameResourceFileCache)
|
||||
{
|
||||
if (fileCache.Key == typeof(Mv3File))
|
||||
{
|
||||
// Dispose non-main actor mv3 files
|
||||
// All main actor names start with "1"
|
||||
var mainActorMv3 = $"{FileConstants.ActorFolderName}{PathSeparator}1".ToLower();
|
||||
var mv3FilesToDispose = fileCache.Value.Keys
|
||||
.Where(mv3FilePath => !mv3FilePath.Contains(mainActorMv3))
|
||||
.ToArray();
|
||||
foreach (var mv3File in mv3FilesToDispose)
|
||||
{
|
||||
fileCache.Value.Remove(mv3File);
|
||||
}
|
||||
}
|
||||
else if (fileCache.Key == typeof(GdbFile) ||
|
||||
fileCache.Key == typeof(Mv3ActionConfig) ||
|
||||
fileCache.Key == typeof(MovActionConfig))
|
||||
{
|
||||
// These files are used/cached across scenes
|
||||
// Do not dispose them since they will be used in next scene block
|
||||
}
|
||||
else // Dispose all other files during scene block transition
|
||||
{
|
||||
fileCache.Value.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// clear all vfx prefabs in cache
|
||||
_vfxEffectPrefabCache.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,5 @@ namespace Pal3.Dev
|
||||
{
|
||||
[SerializeField] public GameBoxBlendFlag blendFlag;
|
||||
[SerializeField] public GameBoxMaterial material;
|
||||
[SerializeField] public string[] textureNames;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ namespace Pal3
|
||||
using Core.DataReader.Lgt;
|
||||
using Core.DataReader.Mov;
|
||||
using Core.DataReader.Msh;
|
||||
using Core.DataReader.Mtl;
|
||||
using Core.DataReader.Mv3;
|
||||
using Core.DataReader.Nav;
|
||||
using Core.DataReader.Pol;
|
||||
@@ -163,6 +164,7 @@ namespace Pal3
|
||||
ServiceLocator.Instance.Register<IFileReader<Mv3File>>(new Mv3FileReader(codepage));
|
||||
ServiceLocator.Instance.Register<IFileReader<MovFile>>(new MovFileReader(codepage));
|
||||
ServiceLocator.Instance.Register<IFileReader<MshFile>>(new MshFileReader(codepage));
|
||||
ServiceLocator.Instance.Register<IFileReader<MtlFile>>(new MtlFileReader(codepage));
|
||||
ServiceLocator.Instance.Register<IFileReader<PolFile>>(new PolFileReader(codepage));
|
||||
ServiceLocator.Instance.Register<IFileReader<GdbFile>>(new GdbFileReader(codepage));
|
||||
ServiceLocator.Instance.Register<IFileReader<LgtFile>>(new LgtFileReader());
|
||||
|
||||
@@ -140,10 +140,11 @@ namespace Pal3.Renderer
|
||||
{
|
||||
foreach (CvdMeshSection meshSection in node.Mesh.MeshSections)
|
||||
{
|
||||
if (string.IsNullOrEmpty(meshSection.TextureName)) continue;
|
||||
if (textureCache.ContainsKey(meshSection.TextureName)) continue;
|
||||
Texture2D texture2D = textureProvider.GetTexture(meshSection.TextureName);
|
||||
if (texture2D != null) textureCache[meshSection.TextureName] = texture2D;
|
||||
string textureName = meshSection.Material.TextureFileNames[0];
|
||||
if (string.IsNullOrEmpty(textureName)) continue;
|
||||
if (textureCache.ContainsKey(textureName)) continue;
|
||||
Texture2D texture2D = textureProvider.GetTexture(textureName);
|
||||
if (texture2D != null) textureCache[textureName] = texture2D;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,8 +233,9 @@ namespace Pal3.Renderer
|
||||
influence,
|
||||
frameMatrix);
|
||||
|
||||
if (string.IsNullOrEmpty(meshSection.TextureName) ||
|
||||
!textureCache.ContainsKey(meshSection.TextureName)) continue;
|
||||
string textureName = meshSection.Material.TextureFileNames[0];
|
||||
|
||||
if (string.IsNullOrEmpty(textureName) || !textureCache.ContainsKey(textureName)) continue;
|
||||
|
||||
var meshSectionObject = new GameObject($"{sectionHashKey}");
|
||||
|
||||
@@ -242,12 +244,11 @@ namespace Pal3.Renderer
|
||||
var materialInfoPresenter = meshObject.AddComponent<MaterialInfoPresenter>();
|
||||
materialInfoPresenter.blendFlag = meshSection.BlendFlag;
|
||||
materialInfoPresenter.material = meshSection.Material;
|
||||
materialInfoPresenter.textureNames = new[] {meshSection.TextureName};
|
||||
#endif
|
||||
|
||||
Material[] materials = materialFactory.CreateStandardMaterials(
|
||||
RendererType.Cvd,
|
||||
(meshSection.TextureName, textureCache[meshSection.TextureName]),
|
||||
(textureName, textureCache[textureName]),
|
||||
shadowTexture: (null, null), // CVD models don't have shadow textures
|
||||
_tintColor,
|
||||
meshSection.BlendFlag);
|
||||
@@ -528,7 +529,7 @@ namespace Pal3.Renderer
|
||||
CvdAnimationScaleKeyFrame fromKeyFrame = nodeScaleInfo[startIndex];
|
||||
CvdAnimationScaleKeyFrame toKeyFrame = nodeScaleInfo[endIndex];
|
||||
float influence = (time - fromKeyFrame.Time) / (toKeyFrame.Time - fromKeyFrame.Time);
|
||||
Quaternion calculatedRotation = Quaternion.Lerp(fromKeyFrame.Rotation, toKeyFrame.Rotation, influence);
|
||||
Quaternion calculatedRotation = Quaternion.Slerp(fromKeyFrame.Rotation, toKeyFrame.Rotation, influence);
|
||||
Vector3 calculatedScale = Vector3.Lerp(fromKeyFrame.Scale, toKeyFrame.Scale, influence);
|
||||
return (calculatedScale, calculatedRotation);
|
||||
}
|
||||
@@ -558,7 +559,7 @@ namespace Pal3.Renderer
|
||||
CvdAnimationRotationKeyFrame fromKeyFrame = nodeRotationInfo[startIndex];
|
||||
CvdAnimationRotationKeyFrame toKeyFrame = nodeRotationInfo[endIndex];
|
||||
float influence = (time - fromKeyFrame.Time) / (toKeyFrame.Time - fromKeyFrame.Time);
|
||||
return Quaternion.Lerp(fromKeyFrame.Rotation, toKeyFrame.Rotation, influence);
|
||||
return Quaternion.Slerp(fromKeyFrame.Rotation, toKeyFrame.Rotation, influence);
|
||||
}
|
||||
|
||||
public void StopCurrentAnimation()
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Pal3.Renderer
|
||||
{
|
||||
Mv3Mesh mesh = mv3File.Meshes[i];
|
||||
var materialId = mesh.Attributes[0].MaterialId;
|
||||
Mv3Material material = mv3File.Materials[materialId];
|
||||
GameBoxMaterial material = mv3File.Materials[materialId];
|
||||
|
||||
InitSubMeshes(i, ref mesh, ref material);
|
||||
}
|
||||
@@ -136,11 +136,11 @@ namespace Pal3.Renderer
|
||||
|
||||
private void InitSubMeshes(int index,
|
||||
ref Mv3Mesh mv3Mesh,
|
||||
ref Mv3Material material)
|
||||
ref GameBoxMaterial material)
|
||||
{
|
||||
var textureName = material.TextureNames[0];
|
||||
var textureName = material.TextureFileNames[0];
|
||||
|
||||
_gbMaterials[index] = material.Material;
|
||||
_gbMaterials[index] = material;
|
||||
_textures[index] = _textureProvider.GetTexture(textureName, out var hasAlphaChannel);
|
||||
_textureHasAlphaChannel[index]= hasAlphaChannel;
|
||||
_animationName[index] = mv3Mesh.Name;
|
||||
@@ -165,7 +165,6 @@ namespace Pal3.Renderer
|
||||
GameBoxBlendFlag.AlphaBlend :
|
||||
GameBoxBlendFlag.Opaque;
|
||||
materialInfoPresenter.material = _gbMaterials[index];
|
||||
materialInfoPresenter.textureNames = material.TextureNames;
|
||||
#endif
|
||||
|
||||
var meshRenderer = _meshObjects[index].AddComponent<StaticMeshRenderer>();
|
||||
@@ -454,7 +453,7 @@ namespace Pal3.Renderer
|
||||
|
||||
Vector3 position = Vector3.Lerp(_tagNodesInfo[i].TagFrames[currentFrameIndex].Position,
|
||||
_tagNodesInfo[i].TagFrames[nextFrameIndex].Position, influence);
|
||||
Quaternion rotation = Quaternion.Lerp(_tagNodesInfo[i].TagFrames[currentFrameIndex].Rotation,
|
||||
Quaternion rotation = Quaternion.Slerp(_tagNodesInfo[i].TagFrames[currentFrameIndex].Rotation,
|
||||
_tagNodesInfo[i].TagFrames[nextFrameIndex].Rotation, influence);
|
||||
|
||||
_tagNodes[i].transform.localPosition = position;
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Pal3.Renderer
|
||||
{
|
||||
foreach (PolTexture texture in mesh.Textures)
|
||||
{
|
||||
foreach (var textureName in texture.TextureNames)
|
||||
foreach (var textureName in texture.Material.TextureFileNames)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textureName)) continue;
|
||||
if (textureCache.ContainsKey(textureName)) continue;
|
||||
@@ -128,7 +128,7 @@ namespace Pal3.Renderer
|
||||
for (var i = 0; i < mesh.Textures.Length; i++)
|
||||
{
|
||||
var textures = new List<(string name, Texture2D texture)>();
|
||||
foreach (var textureName in mesh.Textures[i].TextureNames)
|
||||
foreach (var textureName in mesh.Textures[i].Material.TextureFileNames)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textureName))
|
||||
{
|
||||
@@ -155,7 +155,6 @@ namespace Pal3.Renderer
|
||||
var materialInfoPresenter = meshObject.AddComponent<MaterialInfoPresenter>();
|
||||
materialInfoPresenter.blendFlag = mesh.Textures[i].BlendFlag;
|
||||
materialInfoPresenter.material = mesh.Textures[i].Material;
|
||||
materialInfoPresenter.textureNames = mesh.Textures[i].TextureNames;
|
||||
#endif
|
||||
|
||||
var meshRenderer = meshObject.AddComponent<StaticMeshRenderer>();
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Pal3.Renderer
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Core.DataLoader;
|
||||
using Core.DataReader.Mtl;
|
||||
using Core.GameBox;
|
||||
using Core.Renderer;
|
||||
using Core.Utils;
|
||||
@@ -50,7 +51,7 @@ namespace Pal3.Renderer
|
||||
|
||||
FrameTicks = new uint[track.KeyFrames.Length];
|
||||
|
||||
for (int i = 0; i < track.KeyFrames.Length; i++)
|
||||
for (var i = 0; i < track.KeyFrames.Length; i++)
|
||||
{
|
||||
FrameTicks[i] = track.KeyFrames[i].Tick;
|
||||
}
|
||||
@@ -76,7 +77,7 @@ namespace Pal3.Renderer
|
||||
private MshFile _mshFile;
|
||||
private MovFile _movFile;
|
||||
|
||||
private string _textureName;
|
||||
private (string textureName, Texture2D texture) _mainTexture;
|
||||
private Texture2D _texture;
|
||||
private Color _tintColor;
|
||||
|
||||
@@ -93,19 +94,24 @@ namespace Pal3.Renderer
|
||||
private readonly Dictionary<int, Vector3[]> _vertexBuffer = new();
|
||||
|
||||
public void Init(MshFile mshFile,
|
||||
MtlFile mtlFile,
|
||||
IMaterialFactory materialFactory,
|
||||
ITextureResourceProvider textureProvider,
|
||||
string textureName,
|
||||
Color? tintColor = default) // TODO: Read texture name from <actorName>.mtl file
|
||||
Color? tintColor = default)
|
||||
{
|
||||
Dispose();
|
||||
|
||||
_mshFile = mshFile;
|
||||
_materialFactory = materialFactory;
|
||||
_textureName = textureName;
|
||||
_texture = textureProvider.GetTexture(_textureName);
|
||||
_tintColor = tintColor ?? Color.white;
|
||||
|
||||
// All .mtl files in PAL3 contain only one material,
|
||||
// and there is only one texture in the material
|
||||
// so we only need to load the first texture from the
|
||||
// first material to use as the main texture for the whole model
|
||||
string textureName = mtlFile.Materials[0].TextureFileNames[0];
|
||||
_mainTexture = (mtlFile.Materials[0].TextureFileNames[0], textureProvider.GetTexture(textureName));
|
||||
|
||||
SetupBone(_mshFile.RootBoneNode, parentBone: null);
|
||||
RenderMesh();
|
||||
}
|
||||
@@ -203,10 +209,21 @@ namespace Pal3.Renderer
|
||||
if (track != null)
|
||||
{
|
||||
int currentFrameIndex = Utility.GetFloorIndex(bone.FrameTicks, tick);
|
||||
uint currentFrameTick = bone.FrameTicks[currentFrameIndex];
|
||||
var nextFrameIndex = currentFrameIndex < bone.FrameTicks.Length - 1 ? currentFrameIndex + 1 : 0;
|
||||
uint nextFrameTick = nextFrameIndex == 0 ? _movFile.Duration : bone.FrameTicks[nextFrameIndex];
|
||||
|
||||
// TODO: Interpolate between frames
|
||||
Vector3 localPosition = track.Value.KeyFrames[currentFrameIndex].Translation;
|
||||
Quaternion localRotation = track.Value.KeyFrames[currentFrameIndex].Rotation;
|
||||
var influence = (float)(tick - currentFrameTick) / (nextFrameTick - currentFrameTick);
|
||||
|
||||
Vector3 localPosition = Vector3.Lerp(
|
||||
track.Value.KeyFrames[currentFrameIndex].Translation,
|
||||
track.Value.KeyFrames[nextFrameIndex].Translation,
|
||||
influence);
|
||||
|
||||
Quaternion localRotation = Quaternion.Slerp(
|
||||
track.Value.KeyFrames[currentFrameIndex].Rotation,
|
||||
track.Value.KeyFrames[nextFrameIndex].Rotation,
|
||||
influence);
|
||||
|
||||
boneGo.transform.localPosition = localPosition;
|
||||
boneGo.transform.localRotation = localRotation;
|
||||
@@ -215,9 +232,7 @@ namespace Pal3.Renderer
|
||||
|
||||
if (!bone.IsRoot())
|
||||
{
|
||||
Bone parentBone = _bones[boneNode.ParentId];
|
||||
Matrix4x4 parentCurPoseToModelMatrix = parentBone.CurrentPoseToModelMatrix;
|
||||
curPoseToModelMatrix = parentCurPoseToModelMatrix * curPoseToModelMatrix;
|
||||
curPoseToModelMatrix = _bones[boneNode.ParentId].CurrentPoseToModelMatrix * curPoseToModelMatrix;
|
||||
}
|
||||
|
||||
bone.CurrentPoseToModelMatrix = curPoseToModelMatrix;
|
||||
@@ -281,7 +296,7 @@ namespace Pal3.Renderer
|
||||
_renderMeshComponents = new RenderMeshComponent[_mshFile.SubMeshes.Length];
|
||||
_meshObjects = new GameObject[_mshFile.SubMeshes.Length];
|
||||
|
||||
for (int i = 0; i < _mshFile.SubMeshes.Length; i++)
|
||||
for (var i = 0; i < _mshFile.SubMeshes.Length; i++)
|
||||
{
|
||||
MshMesh subMesh = _mshFile.SubMeshes[i];
|
||||
RenderSubMesh(subMesh, i);
|
||||
@@ -314,14 +329,14 @@ namespace Pal3.Renderer
|
||||
|
||||
GameBoxInterpreter.ToUnityTriangles(triangles);
|
||||
|
||||
for (int i = 0; i < _indexBuffer[subMeshIndex].Count; i++)
|
||||
for (var i = 0; i < _indexBuffer[subMeshIndex].Count; i++)
|
||||
{
|
||||
vertices.Add(subMesh.Vertices[_indexBuffer[subMeshIndex][i]].Position);
|
||||
}
|
||||
|
||||
Material[] materials = _materialFactory.CreateStandardMaterials(
|
||||
RendererType.Msh,
|
||||
(_textureName, _texture),
|
||||
_mainTexture,
|
||||
default,
|
||||
_tintColor,
|
||||
GameBoxBlendFlag.Opaque);
|
||||
@@ -376,7 +391,7 @@ namespace Pal3.Renderer
|
||||
|
||||
Vector3[] vertices = _renderMeshComponents[subMeshIndex].Mesh.vertices;
|
||||
|
||||
for (int i = 0; i < _indexBuffer[subMeshIndex].Count; i++)
|
||||
for (var i = 0; i < _indexBuffer[subMeshIndex].Count; i++)
|
||||
{
|
||||
vertices[i] = _vertexBuffer[subMeshIndex][_indexBuffer[subMeshIndex][i]];
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Pal3.Scene
|
||||
// information to be used for lighting, so we are not using it for now.
|
||||
// if (_resourceProvider.FileExists(sceneMetadataFilePrefix + ".lgt"))
|
||||
// {
|
||||
// LgtFile = _resourceProvider.GetLgt(sceneMetadataFilePrefix + ".lgt");
|
||||
// LgtFile = _resourceProvider.GetGameResourceFile<LgtFile>(sceneMetadataFilePrefix + ".lgt");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -113,9 +113,14 @@ namespace Pal3.Scene
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new SceneLeavingCurrentSceneNotification());
|
||||
Object.Destroy(_currentScene);
|
||||
Object.Destroy(_currentSceneRoot);
|
||||
_currentScene = null;
|
||||
}
|
||||
|
||||
if (_currentSceneRoot != null)
|
||||
{
|
||||
Object.Destroy(_currentSceneRoot);
|
||||
_currentSceneRoot = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(SceneLoadCommand command)
|
||||
|
||||
@@ -103,6 +103,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
Object.Destroy(_triggerController);
|
||||
_triggerController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -112,11 +112,13 @@ namespace Pal3.Scene.SceneObjects
|
||||
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
_triggerController.OnPlayerActorExited -= OnPlayerActorExited;
|
||||
Object.Destroy(_triggerController);
|
||||
_triggerController = null;
|
||||
}
|
||||
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
if (_collider != null)
|
||||
{
|
||||
Destroy(_collider);
|
||||
_collider = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
if (_collider != null)
|
||||
{
|
||||
Destroy(_collider);
|
||||
_collider = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ namespace Pal3.Scene.SceneObjects.Common
|
||||
if (_collider != null)
|
||||
{
|
||||
Destroy(_collider);
|
||||
_collider = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_platformController != null)
|
||||
{
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -149,6 +149,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
_platformController.OnPlayerActorExited -= OnPlayerActorExited;
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
Object.Destroy(_triggerController);
|
||||
_triggerController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -120,6 +120,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -89,12 +89,14 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
if (_triggerController != null)
|
||||
{
|
||||
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
Object.Destroy(_triggerController);
|
||||
_triggerController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -80,6 +80,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -117,6 +117,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
_triggerController.OnPlayerActorExited -= OnPlayerActorExited;
|
||||
Object.Destroy(_triggerController);
|
||||
_triggerController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -168,11 +168,13 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_platformController != null)
|
||||
{
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -225,6 +225,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -92,6 +92,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_platformController != null)
|
||||
{
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -130,6 +130,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
_platformController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -114,6 +114,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
Object.Destroy(_triggerController);
|
||||
_triggerController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -391,6 +391,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
Object.Destroy(_triggerController);
|
||||
_triggerController = null;
|
||||
}
|
||||
|
||||
if (_standingPlatformController != null)
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -130,11 +130,13 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_platformController != null)
|
||||
{
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -91,6 +91,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_platformController != null)
|
||||
{
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -83,16 +83,19 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
if (_subObjectMeshCollider != null)
|
||||
{
|
||||
Object.Destroy(_subObjectMeshCollider);
|
||||
_subObjectMeshCollider = null;
|
||||
}
|
||||
|
||||
if (_subObjectGameObject != null)
|
||||
{
|
||||
Object.Destroy(_subObjectGameObject);
|
||||
_subObjectGameObject = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -281,6 +281,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_sceneObjectGameObject != null)
|
||||
{
|
||||
Object.Destroy(_sceneObjectGameObject);
|
||||
_sceneObjectGameObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_standingPlatformController != null)
|
||||
{
|
||||
Object.Destroy(_standingPlatformController);
|
||||
_standingPlatformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -113,6 +113,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -113,6 +113,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
private void OnDisable()
|
||||
{
|
||||
Destroy(_effectComponent);
|
||||
_effectComponent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_platformController != null)
|
||||
{
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -124,6 +124,8 @@ namespace Pal3.Scene.SceneObjects
|
||||
_interactionIndicatorRenderer.Dispose();
|
||||
Object.Destroy(_interactionIndicatorRenderer);
|
||||
Object.Destroy(_interactionIndicatorGameObject);
|
||||
_interactionIndicatorRenderer = null;
|
||||
_interactionIndicatorGameObject = null;
|
||||
}
|
||||
|
||||
if (ctx.StartedByPlayer &&
|
||||
@@ -204,11 +206,13 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
_interactionIndicatorRenderer.Dispose();
|
||||
Object.Destroy(_interactionIndicatorRenderer);
|
||||
_interactionIndicatorRenderer = null;
|
||||
}
|
||||
|
||||
if (_interactionIndicatorGameObject != null)
|
||||
{
|
||||
Object.Destroy(_interactionIndicatorGameObject);
|
||||
_interactionIndicatorGameObject = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -85,6 +85,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_platformController != null)
|
||||
{
|
||||
Object.Destroy(_platformController);
|
||||
_platformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_standingPlatformController != null)
|
||||
{
|
||||
Object.Destroy(_standingPlatformController);
|
||||
_standingPlatformController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -146,6 +146,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -159,6 +159,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -95,6 +95,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
_triggerController.OnPlayerActorEntered -= OnPlayerActorEntered;
|
||||
Object.Destroy(_triggerController);
|
||||
_triggerController = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -99,6 +99,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (ObjectInfo.Parameters[0] == 1 && _meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +144,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
if (_meshCollider != null)
|
||||
{
|
||||
Object.Destroy(_meshCollider);
|
||||
_meshCollider = null;
|
||||
}
|
||||
|
||||
base.Deactivate();
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace Pal3.UI
|
||||
private void OnDestroy()
|
||||
{
|
||||
Destroy(_material);
|
||||
image = null;
|
||||
_material = null;
|
||||
image = null;
|
||||
}
|
||||
|
||||
private void OnRectTransformDimensionsChange()
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
"com.unity.ide.rider": "3.0.24",
|
||||
"com.unity.ide.visualstudio": "2.0.18",
|
||||
"com.unity.ide.vscode": "1.2.5",
|
||||
"com.unity.inputsystem": "1.6.1",
|
||||
"com.unity.inputsystem": "1.6.3",
|
||||
"com.unity.memoryprofiler": "1.0.0",
|
||||
"com.unity.postprocessing": "3.2.2",
|
||||
"com.unity.test-framework": "1.1.33",
|
||||
"com.unity.textmeshpro": "3.0.6",
|
||||
"com.unity.timeline": "1.7.5",
|
||||
"com.unity.toolchain.macos-x86_64-linux-x86_64": "2.0.5",
|
||||
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.5",
|
||||
"com.unity.toolchain.macos-x86_64-linux-x86_64": "2.0.6",
|
||||
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.6",
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.visualscripting": "1.8.0",
|
||||
"com.unity.modules.ai": "1.0.0",
|
||||
|
||||
+10
-10
@@ -70,7 +70,7 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.inputsystem": {
|
||||
"version": "1.6.1",
|
||||
"version": "1.6.3",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@@ -111,18 +111,18 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.sysroot": {
|
||||
"version": "2.0.6",
|
||||
"version": "2.0.7",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.sysroot.linux-x86_64": {
|
||||
"version": "2.0.5",
|
||||
"version": "2.0.6",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.sysroot": "2.0.6"
|
||||
"com.unity.sysroot": "2.0.7"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
@@ -169,22 +169,22 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.toolchain.macos-x86_64-linux-x86_64": {
|
||||
"version": "2.0.5",
|
||||
"version": "2.0.6",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.sysroot": "2.0.6",
|
||||
"com.unity.sysroot.linux-x86_64": "2.0.5"
|
||||
"com.unity.sysroot": "2.0.7",
|
||||
"com.unity.sysroot.linux-x86_64": "2.0.6"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.toolchain.win-x86_64-linux-x86_64": {
|
||||
"version": "2.0.5",
|
||||
"version": "2.0.6",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.sysroot": "2.0.6",
|
||||
"com.unity.sysroot.linux-x86_64": "2.0.5"
|
||||
"com.unity.sysroot": "2.0.7",
|
||||
"com.unity.sysroot.linux-x86_64": "2.0.6"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
|
||||
@@ -133,7 +133,7 @@ PlayerSettings:
|
||||
vulkanEnableLateAcquireNextImage: 0
|
||||
vulkanEnableCommandBufferRecycling: 1
|
||||
loadStoreDebugModeEnabled: 0
|
||||
bundleVersion: 0.65
|
||||
bundleVersion: 0.66
|
||||
preloadedAssets: []
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
|
||||
Reference in new issue
Block a user