Add more gfx and hook logic for gfx(KK only)

This commit is contained in:
Tran Hai Nam
2026-05-13 17:27:47 +07:00
parent d5ba997382
commit 1fe7df6c24
72 changed files with 602106 additions and 17 deletions
@@ -126,7 +126,6 @@ namespace ModelViewer.Common
public uint m_dwSpan;
public int m_nMinLoops;
public int m_nMaxLoops;
public bool IsInfinite() { return m_nMinLoops == -1 || m_nMaxLoops == -1; }
public int CalcLoopNum() { return IsInfinite() ? -1 : Random.Range(m_nMinLoops, m_nMaxLoops); }
public bool Load(FileStream fileStream, StreamReader file, uint dwVersion)
@@ -247,9 +246,9 @@ namespace ModelViewer.Common
switch (nType)
{
case A3DCombinedActionConst.EVENT_TYPE_GFX:
return new FX_BASE_INFO();
return new GFX_INFO();
case A3DCombinedActionConst.EVENT_TYPE_SFX:
return new FX_BASE_INFO();
return new SFX_INFO();
// case A3DCombinedActionConst.EVENT_TYPE_CHLDACT:
// return new ChildActInfo(pAct);
// case A3DCombinedActionConst.EVENT_TYPE_MATCHG:
@@ -315,7 +314,7 @@ namespace ModelViewer.Common
[System.Serializable]
public class FX_BASE_INFO : EVENT_INFO
{
// public RandStringContainer m_pFiles;
//public RandStringContainer m_pFiles;
// Then you have to random from this list to play the fx file (Can be VFX or SFX)
public List<string> m_strFilePaths = new();
public string m_strHookName;
@@ -497,9 +496,145 @@ namespace ModelViewer.Common
return true;
}
public override bool Load(AFile pFile, StreamReader pTextFile, uint dwVersion)
// public override bool Load(AFile pFile, StreamReader pTextFile, uint dwVersion)
// {
// LoadBase(null, pTextFile, dwVersion);
// return true;
// }
}
[System.Serializable]
public class GFX_INFO : FX_BASE_INFO
{
public float m_fScale;
public float m_fAlpha;
public float m_fPlaySpeed;
public bool m_bUseOuterPath;
public bool m_bRelativeToECModel;
public int m_iDelayTime; // delay time from current position to the dest position
// ModActParamList m_ParamList;
public bool m_bRotWithModel; //if cogfx rotate with model
public override bool Load(AFile fileStream, StreamReader file, uint dwVersion)
{
LoadBase(null, pTextFile, dwVersion);
base.LoadBase(null, file, dwVersion);
bool isBinary = fileStream != null;
if (isBinary)
{
}
else
{
string szLine = string.Empty;
string tagValue;
bool bOldVersion = false;
if (dwVersion >= 24)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_gfx_alpha, out tagValue);
float.TryParse(tagValue, out m_fAlpha);
}
if (dwVersion == 22)
{
float val = -1.0f;
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_gfx_alpha, out tagValue);
float.TryParse(tagValue, out val);
if (val != -1.0f)
{
m_fAlpha = val;
bOldVersion = true;
}
}
if (dwVersion >= 10)
{
if (dwVersion != 22 || bOldVersion)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
}
// sscanf(szLine, _format_gfx_play_speed, &m_fPlaySpeed);
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_gfx_play_speed, out tagValue);
float.TryParse(tagValue, out m_fPlaySpeed);
}
if (dwVersion >= 22 && !bOldVersion)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_gfx_outer_path, out tagValue);
int.TryParse(tagValue, out int nBool);
m_bUseOuterPath = (nBool != 0);
}
if (dwVersion >= 13 && dwVersion < 15)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_fadeout, out tagValue);
int.TryParse(tagValue, out int nBool);
bool bFadeOut = (nBool != 0);
if (bFadeOut)
m_dwFadeOutTime = A3DCombinedActionConst.DEFAULT_GFX_FADE_OUT_TIME;
else
m_dwFadeOutTime = 0;
}
if (dwVersion >= 35)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_gfx_rel_ecm, out tagValue);
int.TryParse(tagValue, out int nBool);
m_bRelativeToECModel = (nBool != 0);
}
if (dwVersion >= 54)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_gfx_delay_time, out tagValue);
int.TryParse(tagValue, out m_iDelayTime);
}
if (dwVersion >= 66)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_gfx_rot_with_model, out tagValue);
int.TryParse(tagValue, out int nBool);
m_bRotWithModel = (nBool != 0);
}
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_gfx_param_count, out tagValue);
int.TryParse(tagValue, out int nParamCount);
}
return true;
}
}
[System.Serializable]
public class SFX_INFO : FX_BASE_INFO
{
public A3DModelReader.Scene.SceneObject.GfxSoundParamInfo m_pSoundParamInfo;
public override bool Load(AFile fileStream, StreamReader file, uint dwVersion)
{
m_pSoundParamInfo = new();
if (!LoadBase(null, file, dwVersion) || !m_pSoundParamInfo.LoadSoundParamInfo(null, file))
return false;
return true;
}
}
@@ -510,7 +645,7 @@ namespace ModelViewer.Common
public string m_strName;
public int m_nLoops;
public bool IsLooping()
{
if (m_ActLst.Count == 0)
@@ -527,7 +662,7 @@ namespace ModelViewer.Common
// And rename it from m_dwComActSpan -> m_dwComActMinSpan
public uint m_dwComActMinSpan;
public bool m_bInfinite;
//public byte[] m_Ranks = new byte[CECModelConst.ACTCHA_MAX];
public byte[] m_Ranks = new byte[(int)ActionChannel.ACTCHA_MAX];
public int[] m_aEventCounter = new int[A3DCombinedActionConst.EVENT_TYPE_END - A3DCombinedActionConst.EVENT_TYPE_BASE + 1];
public int m_nEventChannel;
public float m_fPlaySpeed;
@@ -588,10 +723,10 @@ namespace ModelViewer.Common
int.TryParse(values[1].Substring(values[1].LastIndexOf(' ') + 1).Trim(), out rank);
}
// if (channel >= 0 && channel < CECModelConst.ACTCHA_MAX)
// {
// m_Ranks[channel] = (byte)rank;
// }
if (channel >= 0 && channel < (int)ActionChannel.ACTCHA_MAX)
{
m_Ranks[channel] = (byte)rank;
}
}
}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9f46ca8ebc0aa6b478b8cf2b31d52738
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f1cb6c7a2beee1e479baf4def267e510
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,141 @@
using System.IO;
namespace A3DModelReader.Scene.SceneObject
{
[System.Serializable]
public class GfxSoundParamInfo
{
public static string _format_sfx_ver = "SoundVer: ";
public static string _format_sfx_2d = "Force2D: ";
public static string _format_sfx_loop = "IsLoop: ";
public static string _format_sfx_volume = "Volume: ";
public static string _format_sfx_min_dist = "MinDist: ";
public static string _format_sfx_max_dist = "MaxDist: ";
public static string _format_sfx_volumemin = "VolMin: ";
public static string _format_sfx_volumemax = "VolMax: ";
public static string _format_sfx_absolutevolume = "AbsoluteVolume: ";
public static string _format_sfx_pitchmin = "PitchMin: ";
public static string _format_sfx_pitchmax = "PitchMax: ";
public static string _format_sfx_fixspeed = "FixSpeed: ";
public static string _format_sfx_silentheader = "SilentHeader: ";
public bool m_bForce2D;
public bool m_bLoop;
public int m_dwVolumeMax, m_dwVolumeMin;
public bool m_bAbsoluteVolume;
public float m_fPitchMax, m_fPitchMin;
public float m_fMinDist;
public float m_fMaxDist;
public bool m_bFixSpeed;
public int m_iSilentHeader;
public bool LoadSoundParamInfo(FileStream fileStream, StreamReader file)
{
bool isBinary = fileStream != null;
if (isBinary)
{
return false;
}
else
{
string szLine = string.Empty;
string tagValue;
int nVer = 0;
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
// sscanf(szLine, _format_sfx_ver, &nVer);
AAssit.GetStringAfter(szLine, _format_sfx_ver, out tagValue);
int.TryParse(tagValue, out nVer);
if (nVer != 0)
szLine = file.ReadLine();
// sscanf(szLine, _format_sfx_2d, &nRead);
AAssit.GetStringAfter(szLine, _format_sfx_2d, out tagValue);
int.TryParse(tagValue, out int nRead);
m_bForce2D = (nRead != 0);
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_loop, out tagValue);
int.TryParse(tagValue, out nRead);
m_bLoop = (nRead != 0);
if (nVer <= 1)
{
int dwVolume = 100;
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_volume, out tagValue);
int.TryParse(tagValue, out dwVolume);
m_dwVolumeMin = m_dwVolumeMax = dwVolume;
}
else // >= 2
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_volumemin, out tagValue);
int.TryParse(tagValue, out m_dwVolumeMin);
// sscanf(szLine, _format_sfx_volumemin, &m_dwVolumeMin);
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_volumemax, out tagValue);
int.TryParse(tagValue, out m_dwVolumeMax);
}
if (nVer >= 4)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_absolutevolume, out tagValue);
int.TryParse(tagValue, out nRead);
m_bAbsoluteVolume = nRead != 0;
}
if (nVer >= 2)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_pitchmin, out tagValue);
float.TryParse(tagValue, out m_fPitchMin);
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_pitchmax, out tagValue);
float.TryParse(tagValue, out m_fPitchMax);
}
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_min_dist, out tagValue);
float.TryParse(tagValue, out m_fMinDist);
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_max_dist, out tagValue);
float.TryParse(tagValue, out m_fMaxDist);
if (nVer >= 3)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_fixspeed, out tagValue);
int.TryParse(tagValue, out nRead);
m_bFixSpeed = nRead != 0;
}
if (nVer >= 5)
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, _format_sfx_silentheader, out tagValue);
int.TryParse(tagValue, out m_iSilentHeader);
}
}
return true;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f11129e472ddf554396a946b5860e90d