Files
test/Assets/ModelRenderer/Scripts/A3DModelReader/Scene/SceneObject/A3DGFXElement_SoundParamInfo.cs
T
2026-05-13 17:27:47 +07:00

142 lines
5.9 KiB
C#

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;
}
}
}