public static DataChangeEvent Serdes(DataChangeEvent e, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } if (s.IsWriting() && e == null) { throw new ArgumentNullException(nameof(e)); } ChangeProperty property = s.EnumU8(nameof(ChangeProperty), e?.ChangeProperty ?? ChangeProperty.Unk0); return(property switch { ChangeProperty.Unk0 => ChangeUnk0Event.Serdes((ChangeUnk0Event)e, s), ChangeProperty.Health => ChangeHealthEvent.Serdes((ChangeHealthEvent)e, mapping, s), ChangeProperty.Mana => ChangeManaEvent.Serdes((ChangeManaEvent)e, mapping, s), ChangeProperty.Status => ChangeStatusEvent.Serdes((ChangeStatusEvent)e, mapping, s), ChangeProperty.Language => ChangeLanguageEvent.Serdes((ChangeLanguageEvent)e, mapping, s), ChangeProperty.Experience => ChangeExperienceEvent.Serdes((ChangeExperienceEvent)e, mapping, s), ChangeProperty.UnkB => ChangeUnkBEvent.Serdes((ChangeUnkBEvent)e, s), ChangeProperty.UnkC => ChangeUnkCEvent.Serdes((ChangeUnkCEvent)e, s), ChangeProperty.Item => ChangeItemEvent.Serdes((ChangeItemEvent)e, mapping, s), ChangeProperty.Gold => ChangeGoldEvent.Serdes((ChangeGoldEvent)e, mapping, s), ChangeProperty.Food => ChangeFoodEvent.Serdes((ChangeFoodEvent)e, mapping, s), _ => throw new FormatException($"Unexpected data change type \"{property}\"") });
public static ChangeUnkCEvent Serdes(ChangeUnkCEvent e, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new ChangeUnkCEvent(); e.Operation = s.EnumU8(nameof(Operation), e.Operation); e.Unk3 = s.UInt8(nameof(Unk3), e.Unk3); int zeroed = s.UInt8(null, 0); e.Unk5 = s.UInt8(nameof(Unk5), e.Unk5); e.Unk6 = s.UInt16(nameof(Unk6), e.Unk6); e.Amount = s.UInt16(nameof(Amount), e.Amount); s.Assert(zeroed == 0, "ChangeUnkCEvent: Expected byte 4 to be 0"); return(e); }