Skip to content

Commit 2a0da2b

Browse files
committed
Extract derialization funcs to static for LEX
1 parent 7d8d457 commit 2a0da2b

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

ME3Tweaks.Wwiser/Model/Hierarchy/Enums/StreamType.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ public void Serialize(Stream stream, Endianness endianness, BinarySerializationC
3636
public void Deserialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext)
3737
{
3838
var version = serializationContext.FindAncestor<BankSerializationContext>().Version;
39+
40+
Value = DeserializeStatic(stream, version);
41+
}
42+
43+
public static StreamTypeInner DeserializeStatic(Stream stream, uint version)
44+
{
3945
byte value;
40-
4146
if (version <= 89)
4247
{
4348
Span<byte> span = stackalloc byte[4];
@@ -63,9 +68,9 @@ public void Deserialize(Stream stream, Endianness endianness, BinarySerializatio
6368
}
6469
}
6570

66-
Value = (StreamTypeInner)value;
71+
return (StreamTypeInner)value;
6772
}
68-
73+
6974
public enum StreamTypeInner : byte
7075
{
7176
DataBnk,

ME3Tweaks.Wwiser/Model/ParameterNode/AuxParams.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private AuxFlags GetAuxFlagsFromProperties(uint version)
119119
}
120120

121121
[Flags]
122-
private enum AuxFlags : byte
122+
public enum AuxFlags : byte
123123
{
124124
Unk1 = 1 << 0,
125125
Unk2 = 1 << 1,

ME3Tweaks.Wwiser/Model/ParameterNode/PropId.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,21 @@ public void Deserialize(Stream stream, Endianness endianness, BinarySerializatio
5050
{
5151
var context = serializationContext.FindAncestor<BankSerializationContext>();
5252
var version = context.Version;
53-
if (context.UseModulator)
53+
(PropValue, ModulatorValue) = DeserializeStatic(stream, context.UseModulator, version);
54+
}
55+
56+
public static (PropId, ModulatorPropId) DeserializeStatic(Stream stream, bool useModulator, uint version)
57+
{
58+
ModulatorPropId modId = 0;
59+
PropId propId = 0;
60+
if (useModulator)
5461
{
5562
var id = (ModulatorPropId)stream.ReadByte();
5663
if (version < 150 && id >= ModulatorPropId.Lfo_Retrigger)
5764
{
5865
id++;
5966
}
60-
ModulatorValue = id;
67+
modId = id;
6168
}
6269
else
6370
{
@@ -79,8 +86,9 @@ public void Deserialize(Stream stream, Endianness endianness, BinarySerializatio
7986
id = DeserializeVersionLte150(id);
8087
}
8188

82-
PropValue = id;
89+
propId = id;
8390
}
91+
return (propId, modId);
8492
}
8593

8694
private static PropId SerializeVersion113(PropId input, uint version)
@@ -179,7 +187,7 @@ private static PropId SerializeVersionLte112(PropId input, uint version)
179187
return id;
180188
}
181189

182-
protected virtual PropId DeserializeVersionLte65(PropId input)
190+
private static PropId DeserializeVersionLte65(PropId input)
183191
{
184192
return input switch
185193
{

0 commit comments

Comments
 (0)