-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEntityParser.cs
50 lines (38 loc) · 1.38 KB
/
EntityParser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.IO;
using System;
namespace Nitemare3D
{
//converts nitemare 3d map viewer files into enums (thank you David for leaving those in they're very helpful)
public static class EntityParser
{
public static void Convert(string file)
{
var lines = File.ReadAllLines(file);
string header = "namespace Nitemare3D\n{\n\tpublic enum Outputted\n\t{\n";
var f = File.CreateText("OutputtedEnum.cs");
f.Write(header);
foreach(var line in lines)
{
var tokens = line.Split(' ', line.Length, StringSplitOptions.RemoveEmptyEntries);
var id = int.Parse(tokens[0], System.Globalization.NumberStyles.HexNumber);
//get enum name
string name = "";
for(int i = 4; i < tokens.Length; i++)
{
name += tokens[i];
}
string output = "";
for(int i = 0; i < name.Length; i++)
{
if(char.IsLetterOrDigit(name[i]))
{
output += name[i];
}
}
f.WriteLine("\t\t" + output + " = " + id + ",");
}
f.Write("\t}\n}");
f.Close();
}
}
}