Skip to content

Commit e32896c

Browse files
committed
covert remaining object record types into classes, and display them in UI
1 parent be42976 commit e32896c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+275
-242
lines changed

Dat/FileParsing/LocoBinaryReader.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Dat.Converters;
22
using Dat.Types;
33
using Definitions.ObjectModels.Objects.Airport;
4+
using Definitions.ObjectModels.Objects.Building;
45
using Definitions.ObjectModels.Objects.Sound;
56
using Definitions.ObjectModels.Objects.Vehicle;
67
using Definitions.ObjectModels.Types;
@@ -129,7 +130,11 @@ public List<uint8_t> ReadBuildingHeights(int count)
129130
=> [.. ReadBytes(count)];
130131

131132
public BuildingPartAnimation ReadBuildingPartAnimation()
132-
=> new(ReadByte(), ReadByte());
133+
=> new()
134+
{
135+
NumFrames = ReadByte(),
136+
AnimationSpeed = ReadByte(),
137+
};
133138

134139
public List<BuildingPartAnimation> ReadBuildingAnimations(int count)
135140
{
@@ -180,7 +185,7 @@ public VehicleObjectCar[] ReadCarComponents(int count)
180185

181186
for (var i = 0; i < count; ++i)
182187
{
183-
result[i] = new VehicleObjectCar
188+
result[i] = new VehicleObjectCar()
184189
{
185190
FrontBogiePosition = ReadByte(),
186191
BackBogiePosition = ReadByte(),

Dat/FileParsing/LocoBinaryWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Common;
22
using Dat.Converters;
33
using Dat.Types;
4-
using Definitions.ObjectModels.Objects.Airport;
4+
using Definitions.ObjectModels.Objects.Building;
55
using Definitions.ObjectModels.Objects.Sound;
66
using Definitions.ObjectModels.Objects.Vehicle;
77
using Definitions.ObjectModels.Types;

Dat/Loaders/IndustryObjectLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static LocoObject Load(Stream stream)
7373
model.ScaffoldingColour = (Colour)br.ReadByte();
7474
for (var i = 0; i < Constants.InitialProductionRateCount; ++i)
7575
{
76-
model.InitialProductionRate.Add(new IndustryObjectProductionRateRange(br.ReadUInt16(), br.ReadUInt16()));
76+
model.InitialProductionRate.Add(new() { Min = br.ReadUInt16(), Max = br.ReadUInt16()});
7777
}
7878
br.SkipByte(Constants.MaxProducedCargoType); // ProducedCargo, not part of object definition
7979
br.SkipByte(Constants.MaxRequiredCargoType); // RequiredCargo, not part of object definition
@@ -121,7 +121,7 @@ private static void LoadVariable(LocoBinaryReader br, IndustryObject model, byte
121121
// unk
122122
while (br.PeekByte() != LocoConstants.Terminator)
123123
{
124-
model.var_38.Add(new IndustryObjectUnk38(br.ReadByte(), br.ReadByte()));
124+
model.var_38.Add(new() { var_00 = br.ReadByte(), var_01 = br.ReadByte() });
125125
}
126126
br.SkipTerminator();
127127

Dat/Loaders/SteamObjectLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ private static void LoadVariable(LocoBinaryReader br, SteamObject model, byte nu
6868
{
6969
while (br.PeekByte() != LocoConstants.Terminator)
7070
{
71-
model.FrameInfoType0.Add(new ImageAndHeight() { ImageOffset = br.ReadByte(), Height = br.ReadByte() });
71+
model.FrameInfoType0.Add(new() { ImageOffset = br.ReadByte(), Height = br.ReadByte() });
7272
}
7373

7474
br.SkipTerminator();
7575

7676
while (br.PeekByte() != LocoConstants.Terminator)
7777
{
78-
model.FrameInfoType1.Add(new ImageAndHeight() { ImageOffset = br.ReadByte(), Height = br.ReadByte() });
78+
model.FrameInfoType1.Add(new() { ImageOffset = br.ReadByte(), Height = br.ReadByte() });
7979
}
8080

8181
br.SkipTerminator();

Dat/Loaders/TownNamesObjectLoader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static LocoObject Load(Stream stream)
3939
Bias = br.ReadByte(),
4040
Offset = br.ReadUInt16()
4141
};
42+
4243
model.Categories.Add(category);
4344
}
4445

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Definitions.ObjectModels.Objects.Airport;
2+
3+
public class AirportBuilding : ILocoStruct
4+
{
5+
public uint8_t Index { get; set; }
6+
public uint8_t Rotation { get; set; }
7+
public int8_t X { get; set; }
8+
public int8_t Y { get; set; }
9+
10+
public bool Validate() => true;
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace Definitions.ObjectModels.Objects.Airport;
2+
3+
public enum AirportMovementNodeFlags : uint16_t
4+
{
5+
None = 0,
6+
Terminal = 1 << 0,
7+
TakeoffEnd = 1 << 1,
8+
Flag2 = 1 << 2,
9+
Taxiing = 1 << 3,
10+
InFlight = 1 << 4,
11+
HeliTakeoffBegin = 1 << 5,
12+
TakeoffBegin = 1 << 6,
13+
HeliTakeoffEnd = 1 << 7,
14+
Touchdown = 1 << 8,
15+
}

Definitions/ObjectModels/Objects/Airport/AirportObject.cs

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,6 @@
1-
namespace Definitions.ObjectModels.Objects.Airport;
2-
3-
public enum AirportMovementNodeFlags : uint16_t
4-
{
5-
None = 0,
6-
Terminal = 1 << 0,
7-
TakeoffEnd = 1 << 1,
8-
Flag2 = 1 << 2,
9-
Taxiing = 1 << 3,
10-
InFlight = 1 << 4,
11-
HeliTakeoffBegin = 1 << 5,
12-
TakeoffBegin = 1 << 6,
13-
HeliTakeoffEnd = 1 << 7,
14-
Touchdown = 1 << 8,
15-
}
1+
using Definitions.ObjectModels.Objects.Building;
162

17-
public record MovementEdge(
18-
uint8_t var_00,
19-
uint8_t CurrNode,
20-
uint8_t NextNode,
21-
uint8_t var_03,
22-
uint32_t MustBeClearEdges, // Which edges must be clear to use the transition edge. should probably be some kind of flags?
23-
uint32_t AtLeastOneClearEdges // Which edges must have at least one clear to use transition edge. should probably be some kind of flags?
24-
) : ILocoStruct
25-
{
26-
public MovementEdge() : this(0, 0, 0, 0, 0, 0)
27-
{ }
28-
29-
public bool Validate()
30-
=> true;
31-
}
32-
33-
public record MovementNode(
34-
int16_t X,
35-
int16_t Y,
36-
int16_t Z,
37-
AirportMovementNodeFlags Flags
38-
) : ILocoStruct
39-
{
40-
public MovementNode() : this(0, 0, 0, AirportMovementNodeFlags.None)
41-
{ }
42-
43-
public bool Validate()
44-
=> true;
45-
}
46-
47-
public record AirportBuilding(
48-
uint8_t Index,
49-
uint8_t Rotation,
50-
int8_t X,
51-
int8_t Y
52-
) : ILocoStruct
53-
{
54-
public AirportBuilding() : this(0, 0, 0, 0)
55-
{ }
56-
57-
public bool Validate()
58-
=> true;
59-
}
60-
61-
public record BuildingPartAnimation(
62-
uint8_t NumFrames, // Must be a power of 2 (0 = no part animation, could still have animation sequence)
63-
uint8_t AnimationSpeed // Also encodes in bit 7 if the animation is position modified
64-
) : ILocoStruct
65-
{
66-
public BuildingPartAnimation() : this(0, 0)
67-
{ }
68-
69-
public bool Validate()
70-
=> IsPowerOfTwo(NumFrames);
71-
72-
static bool IsPowerOfTwo(uint8_t x)
73-
=> (x & (x - 1)) == 0 && x > 0;
74-
}
3+
namespace Definitions.ObjectModels.Objects.Airport;
754

765
public class AirportObject : ILocoStruct
776
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Definitions.ObjectModels.Objects.Airport;
2+
3+
public class MovementEdge : ILocoStruct
4+
{
5+
public uint8_t var_00 { get; set; }
6+
public uint8_t CurrNode { get; set; }
7+
public uint8_t NextNode { get; set; }
8+
public uint8_t var_03 { get; set; }
9+
public uint32_t MustBeClearEdges { get; set; } // Which edges must be clear to use the transition edge. should probably be some kind of flags?
10+
public uint32_t AtLeastOneClearEdges { get; set; } // Which edges must have at least one clear to use transition edge. should probably be some kind of flags?
11+
12+
public bool Validate() => true;
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Definitions.ObjectModels.Objects.Airport;
2+
3+
public class MovementNode : ILocoStruct
4+
{
5+
public int16_t X { get; set; }
6+
public int16_t Y { get; set; }
7+
public int16_t Z { get; set; }
8+
public AirportMovementNodeFlags Flags { get; set; }
9+
10+
public bool Validate() => true;
11+
}

0 commit comments

Comments
 (0)