sinmai-mods/FixLocaleIssues/Manager/patch_MA2Record.cs
2024-08-08 13:32:25 +07:00

36 lines
899 B
C#

// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
using System.Globalization;
using MonoMod;
namespace Manager;
public class patch_MA2Record : MA2Record
{
[MonoModIgnore]
private static extern Ma2fileParamID.Def getParamIDFromRec(Ma2fileRecordID.Def rec, int index);
[MonoModReplace]
public new float getF32(uint index)
{
if (index >= _str.Count)
{
return 0;
}
var paramIDFromRec = getParamIDFromRec(_recID, (int)index);
if (!paramIDFromRec.isValid() || !paramIDFromRec.isAvailableFloat() || _str[(int)index].Length == 0)
{
return 0;
}
if (!float.TryParse(_str[(int)index], NumberStyles.Float, CultureInfo.InvariantCulture, out var num))
{
return 0;
}
return num;
}
}