public static SoundEvent Serdes(SoundEvent e, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new SoundEvent(); e.Mode = s.EnumU8(nameof(Mode), e.Mode); e.SoundId = SampleId.SerdesU8(nameof(SoundId), e.SoundId, mapping, s); e.Unk3 = s.UInt8(nameof(Unk3), e.Unk3); e.Volume = s.UInt8(nameof(Volume), e.Volume); e.RestartProbability = s.UInt8(nameof(RestartProbability), e.RestartProbability); e.FrequencyOverride = s.UInt16(nameof(FrequencyOverride), e.FrequencyOverride); e.Unk8 = s.UInt16(nameof(Unk8), e.Unk8); ApiUtil.Assert(e.Unk3 <= 100); ApiUtil.Assert(e.Volume <= 150); ApiUtil.Assert(e.RestartProbability <= 102); ApiUtil.Assert(e.Unk8 == 0); return(e); }
public static SoundEvent Serdes(SoundEvent e, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new SoundEvent(); e.Mode = s.EnumU8(nameof(Mode), e.Mode); e.SoundId = SampleId.SerdesU8(nameof(SoundId), e.SoundId, mapping, s); e.Unk3 = s.UInt8(nameof(Unk3), e.Unk3); e.Volume = s.UInt8(nameof(Volume), e.Volume); e.RestartProbability = s.UInt8(nameof(RestartProbability), e.RestartProbability); e.FrequencyOverride = s.UInt16(nameof(FrequencyOverride), e.FrequencyOverride); int zeroed = s.UInt16(null, 0); s.Assert(e.Unk3 <= 100, "SoundEvent: Expected unk3 to be <= 100"); s.Assert(e.Volume <= 150, "SoundEvent: Expected volume to be <= 150"); s.Assert(e.RestartProbability <= 102, "SoundEvent: Expected restart probability to be <= 102"); s.Assert(zeroed == 0, "SoundEvent: Expected field 8 to be 0"); return(e); }