80 lines
2.7 KiB
C#
80 lines
2.7 KiB
C#
|
// ReSharper disable CheckNamespace
|
||
|
// ReSharper disable InconsistentNaming
|
||
|
|
||
|
using System;
|
||
|
using System.CodeDom.Compiler;
|
||
|
using System.IO;
|
||
|
using System.Text;
|
||
|
using MonoMod;
|
||
|
using LooseDBTables;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace DB;
|
||
|
|
||
|
[MonoModIgnore]
|
||
|
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
|
||
|
public class RatingTableIDEnum
|
||
|
{
|
||
|
public static extern bool LoadFromFile(string filename);
|
||
|
public static extern void DumpToFile(string filename);
|
||
|
protected static RatingTableTableRecord[] records;
|
||
|
}
|
||
|
|
||
|
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
|
||
|
[Serializable]
|
||
|
public class SerializableRatingTableTableRecord {
|
||
|
public System.Int32 EnumValue;
|
||
|
public System.String EnumName;
|
||
|
public System.String Name;
|
||
|
public System.Int32 Achive;
|
||
|
public System.Int32 Offset;
|
||
|
|
||
|
}
|
||
|
|
||
|
[GeneratedCode("LooseDBTables.GeneratePatches", "1.0.0.0")]
|
||
|
public class patch_RatingTableIDEnum : RatingTableIDEnum {
|
||
|
public new static bool LoadFromFile(string filename) {
|
||
|
if (!File.Exists(filename)) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var table = JsonUtility.FromJson<Table<SerializableRatingTableTableRecord>>(File.ReadAllText(filename));
|
||
|
|
||
|
try
|
||
|
{
|
||
|
if (table.records.Length != records.Length) {
|
||
|
Debug.LogError($"Count read error: {filename}");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var src = table.records;
|
||
|
var dst = records;
|
||
|
|
||
|
for (var i = 0; i < table.records.Length; i++) {
|
||
|
dst[i] = new RatingTableTableRecord { EnumValue = (System.Int32)src[i].EnumValue, EnumName = (System.String)src[i].EnumName, Name = (System.String)src[i].Name, Achive = (System.Int32)src[i].Achive, Offset = (System.Int32)src[i].Offset, };
|
||
|
}
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
Debug.LogError($"File read error: {filename}");
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public new static void DumpToFile(string filename) {
|
||
|
var table = new Table<SerializableRatingTableTableRecord>() {
|
||
|
records = new SerializableRatingTableTableRecord[records.Length]
|
||
|
};
|
||
|
|
||
|
var src = records;
|
||
|
var dst = table.records;
|
||
|
|
||
|
for (var i = 0; i < records.Length; i++) {
|
||
|
dst[i] = new SerializableRatingTableTableRecord { EnumValue = (System.Int32)src[i].EnumValue, EnumName = (System.String)src[i].EnumName, Name = (System.String)src[i].Name, Achive = (System.Int32)src[i].Achive, Offset = (System.Int32)src[i].Offset, };
|
||
|
}
|
||
|
|
||
|
File.WriteAllText(filename, JsonUtility.ToJson(table, true), Encoding.UTF8);
|
||
|
}
|
||
|
}
|