-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite StateChunk to be version independent, parse FeedbackInfo
- Loading branch information
Showing
13 changed files
with
244 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using BinarySerialization; | ||
|
||
namespace ME3Tweaks.Wwiser.Model.ParameterNode; | ||
|
||
public class FeedbackInfo : IBinarySerializable | ||
{ | ||
[Ignore] | ||
public uint Size { get; set; } | ||
|
||
[Ignore] | ||
public uint[] Unks { get; set; } = Array.Empty<uint>(); | ||
|
||
[Ignore] | ||
public uint BusId { get; set; } | ||
|
||
[Ignore] | ||
public float FeedbackVolume { get; set; } | ||
|
||
[Ignore] | ||
public float FeedbackModifierMin { get; set; } | ||
|
||
[Ignore] | ||
public float FeedbackModifierMax { get; set; } | ||
|
||
[Ignore] | ||
public float FeedbackLPF { get; set; } | ||
|
||
[Ignore] | ||
public float FeedbackLPFModifierMin { get; set; } | ||
|
||
[Ignore] | ||
public float FeedbackLPFModifierMax { get; set; } | ||
|
||
public void Serialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext) | ||
{ | ||
var context = serializationContext.FindAncestor<BankSerializationContext>(); | ||
if (!context.UseFeedback) return; | ||
if (context.Version <= 26) | ||
{ | ||
Size = (uint)Unks.Length * sizeof(uint); | ||
stream.Write(BitConverter.GetBytes(Size)); | ||
foreach (var u in Unks) | ||
{ | ||
stream.Write(BitConverter.GetBytes(u)); | ||
} | ||
stream.Write(BitConverter.GetBytes(FeedbackVolume)); | ||
} | ||
else | ||
{ | ||
stream.Write(BitConverter.GetBytes(BusId)); | ||
if (BusId != 0) | ||
{ | ||
stream.Write(BitConverter.GetBytes(FeedbackVolume)); | ||
stream.Write(BitConverter.GetBytes(FeedbackModifierMin)); | ||
stream.Write(BitConverter.GetBytes(FeedbackModifierMax)); | ||
stream.Write(BitConverter.GetBytes(FeedbackLPF)); | ||
stream.Write(BitConverter.GetBytes(FeedbackLPFModifierMin)); | ||
stream.Write(BitConverter.GetBytes(FeedbackLPFModifierMax)); | ||
} | ||
} | ||
} | ||
|
||
public void Deserialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext) | ||
{ | ||
var context = serializationContext.FindAncestor<BankSerializationContext>(); | ||
var reader = new BinaryReader(stream); | ||
if (!context.UseFeedback) return; | ||
if (context.Version <= 26) | ||
{ | ||
Size = reader.ReadUInt32(); | ||
Unks = new uint[Size / 4]; | ||
Unks = Unks.Select(_ => reader.ReadUInt32()).ToArray(); | ||
FeedbackVolume = reader.ReadSingle(); | ||
} | ||
else | ||
{ | ||
BusId = reader.ReadUInt32(); | ||
if (BusId != 0) | ||
{ | ||
FeedbackVolume = reader.ReadSingle(); | ||
FeedbackModifierMin = reader.ReadSingle(); | ||
FeedbackModifierMax = reader.ReadSingle(); | ||
FeedbackLPF = reader.ReadSingle(); | ||
FeedbackLPFModifierMin = reader.ReadSingle(); | ||
FeedbackLPFModifierMax = reader.ReadSingle(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
ME3Tweaks.Wwiser/Model/RTPC/RtpcCurves.cs → ...el/ParameterNode/RtpcParameterNodeBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using BinarySerialization; | ||
using ME3Tweaks.Wwiser.Formats; | ||
|
||
namespace ME3Tweaks.Wwiser.Model.State; | ||
|
||
/// <summary> | ||
/// Weirdly serialized count in different versions. | ||
/// <=122 it's a normal uint, otherwise some sort of space-saving uint | ||
/// </summary> | ||
public class StateCount : IBinarySerializable | ||
{ | ||
[Ignore] | ||
public uint Value { get; set; } | ||
|
||
public void Serialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext) | ||
{ | ||
var context = serializationContext.FindAncestor<BankSerializationContext>(); | ||
if (context.Version > 122) | ||
{ | ||
VarCount.WriteResizingUint(stream, Value); | ||
} | ||
else if (context.Version is > 36 and <= 52) | ||
{ | ||
stream.Write(BitConverter.GetBytes((ushort)Value)); | ||
} | ||
else | ||
{ | ||
stream.Write(BitConverter.GetBytes(Value)); | ||
} | ||
} | ||
public void Deserialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext) | ||
{ | ||
|
||
var context = serializationContext.FindAncestor<BankSerializationContext>(); | ||
if (context.Version > 122) | ||
{ | ||
Value = VarCount.ReadResizingUint(stream); | ||
} | ||
else if (context.Version is > 36 and <= 52) | ||
{ | ||
Span<byte> span = stackalloc byte[2]; | ||
var read = stream.Read(span); | ||
if (read != 2) throw new Exception(); | ||
Value = BitConverter.ToUInt16(span); | ||
} | ||
else | ||
{ | ||
Span<byte> span = stackalloc byte[4]; | ||
var read = stream.Read(span); | ||
if (read != 4) throw new Exception(); | ||
Value = BitConverter.ToUInt32(span); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.