From 08168a30b6c6afb8148f761be95a42c2941e2614 Mon Sep 17 00:00:00 2001 From: Goz3rr Date: Sat, 30 Mar 2019 15:13:57 +0100 Subject: [PATCH] Add color struct support --- .../PropertyTypes/StructProperty.cs | 2 ++ .../PropertyTypes/Structs/Color.cs | 32 +++++++++++++++++++ .../SatisfactorySaveParser.csproj | 1 + 3 files changed, 35 insertions(+) create mode 100644 SatisfactorySaveParser/PropertyTypes/Structs/Color.cs diff --git a/SatisfactorySaveParser/PropertyTypes/StructProperty.cs b/SatisfactorySaveParser/PropertyTypes/StructProperty.cs index 013f037..5693409 100644 --- a/SatisfactorySaveParser/PropertyTypes/StructProperty.cs +++ b/SatisfactorySaveParser/PropertyTypes/StructProperty.cs @@ -115,6 +115,8 @@ private static IStructData ParseStructData(BinaryReader reader, string type) { case "LinearColor": return new LinearColor(reader); + case "Color": + return new Color(reader); case "Rotator": return new Rotator(reader); case "Vector": diff --git a/SatisfactorySaveParser/PropertyTypes/Structs/Color.cs b/SatisfactorySaveParser/PropertyTypes/Structs/Color.cs new file mode 100644 index 0000000..0bc88d5 --- /dev/null +++ b/SatisfactorySaveParser/PropertyTypes/Structs/Color.cs @@ -0,0 +1,32 @@ +using System; +using System.IO; + +namespace SatisfactorySaveParser.PropertyTypes.Structs +{ + public class Color : IStructData + { + public byte R { get; set; } + public byte G { get; set; } + public byte B { get; set; } + public byte A { get; set; } + + public int SerializedLength => 4; + public string Type => "Color"; + + public Color(BinaryReader reader) + { + R = reader.ReadByte(); + G = reader.ReadByte(); + B = reader.ReadByte(); + A = reader.ReadByte(); + } + + public void Serialize(BinaryWriter writer) + { + writer.Write(R); + writer.Write(G); + writer.Write(B); + writer.Write(A); + } + } +} diff --git a/SatisfactorySaveParser/SatisfactorySaveParser.csproj b/SatisfactorySaveParser/SatisfactorySaveParser.csproj index 1d5a2a3..b8b0338 100644 --- a/SatisfactorySaveParser/SatisfactorySaveParser.csproj +++ b/SatisfactorySaveParser/SatisfactorySaveParser.csproj @@ -60,6 +60,7 @@ +