-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathObjectAttributes.cs
More file actions
100 lines (93 loc) · 3.81 KB
/
ObjectAttributes.cs
File metadata and controls
100 lines (93 loc) · 3.81 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using Dat.Data;
using Definitions.ObjectModels;
using System.Diagnostics.CodeAnalysis;
namespace Dat.FileParsing;
public static class ObjectAttributes
{
public static int StructSize<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>() where T : ILocoStruct
=> AttributeHelper.Get<LocoStructSizeAttribute>(typeof(T))!.Size;
//public static ObjectType ObjectType<T>() // where T : ILocoStruct
// => AttributeHelper.Get<LocoStructTypeAttribute>(typeof(T))!.ObjectType;
//public static ObjectType ObjectType(ILocoStruct str) // where T : ILocoStruct
// => AttributeHelper.Get<LocoStructTypeAttribute>(str.GetType())!.ObjectType;
//public static string[] StringTableNames<T>() // where T : ILocoStruct
// => AttributeHelper.Get<LocoStringTableAttribute>(typeof(T))!.Strings;
public static string[] StringTable(DatObjectType objectType)
=> objectType switch
{
DatObjectType.InterfaceSkin => ["Name"],
DatObjectType.Sound => ["Name"],
DatObjectType.Currency => ["Name", "PrefixSymbol", "SuffixSymbol"],
DatObjectType.Steam => ["Name"],
DatObjectType.CliffEdge => ["Name"],
DatObjectType.Water => ["Name"],
DatObjectType.Land => ["Name"],
DatObjectType.TownNames => ["Name"],
DatObjectType.Cargo => ["Name", "UnitsAndCargoName", "UnitNameSingular", "UnitNamePlural"],
DatObjectType.Wall => ["Name"],
DatObjectType.TrackSignal => ["Name", "Description"],
DatObjectType.LevelCrossing => ["Name"],
DatObjectType.StreetLight => ["Name"],
DatObjectType.Tunnel => ["Name"],
DatObjectType.Bridge => ["Name"],
DatObjectType.TrackStation => ["Name"],
DatObjectType.TrackExtra => ["Name"],
DatObjectType.Track => ["Name"],
DatObjectType.RoadStation => ["Name"],
DatObjectType.RoadExtra => ["Name"],
DatObjectType.Road => ["Name"],
DatObjectType.Airport => ["Name"],
DatObjectType.Dock => ["Name"],
DatObjectType.Vehicle => ["Name"],
DatObjectType.Tree => ["Name"],
DatObjectType.Snow => ["Name"],
DatObjectType.Climate => ["Name"],
DatObjectType.HillShapes => ["Name"],
DatObjectType.Building => ["Name"],
DatObjectType.Scaffolding => ["Name"],
DatObjectType.Industry => ["Name", "var_02", "<unused>", "NameClosingDown", "NameUpProduction", "NameDownProduction", "NameSingular", "NamePlural"],
DatObjectType.Region => ["Name"],
DatObjectType.Competitor => ["FullName", "LastName"],
DatObjectType.ScenarioText => ["Name", "Details"],
_ => throw new NotSupportedException($"Object type {objectType} is not supported.")
};
public static int StructSize(DatObjectType objectType)
=> objectType switch
{
DatObjectType.InterfaceSkin => 0x18,
DatObjectType.Sound => 0x0C,
DatObjectType.Currency => 0x0C,
DatObjectType.Steam => 0x28,
DatObjectType.CliffEdge => 0x06,
DatObjectType.Water => 0x0E,
DatObjectType.Land => 0x1E,
DatObjectType.TownNames => 0x1A,
DatObjectType.Cargo => 0x1F,
DatObjectType.Wall => 0x0A,
DatObjectType.TrackSignal => 0x1E,
DatObjectType.LevelCrossing => 0x12,
DatObjectType.StreetLight => 0x0C,
DatObjectType.Tunnel => 0x06,
DatObjectType.Bridge => 0x2C,
DatObjectType.TrackStation => 0xAE,
DatObjectType.TrackExtra => 0x12,
DatObjectType.Track => 0x36,
DatObjectType.RoadStation => 0x6E,
DatObjectType.RoadExtra => 0x12,
DatObjectType.Road => 0x30,
DatObjectType.Airport => 0xBA,
DatObjectType.Dock => 0x28,
DatObjectType.Vehicle => 0x15E,
DatObjectType.Tree => 0x4C,
DatObjectType.Snow => 0x06,
DatObjectType.Climate => 0x0A,
DatObjectType.HillShapes => 0x0E,
DatObjectType.Building => 0xBE,
DatObjectType.Scaffolding => 0x12,
DatObjectType.Industry => 0xF4,
DatObjectType.Region => 0x12,
DatObjectType.Competitor => 0x38,
DatObjectType.ScenarioText => 0x06,
_ => throw new NotSupportedException($"Object type {objectType} is not supported.")
};
}