public static NpcActiveEvent Serdes(NpcActiveEvent e, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new NpcActiveEvent(); e.IsActive = s.UInt8(nameof(IsActive), e.IsActive); e.NpcIndex = s.UInt8(nameof(NpcIndex), e.NpcIndex); int zeroed = s.UInt8(null, 0); e.Unk5 = s.UInt8(nameof(Unk5), e.Unk5); e.Unk6 = s.UInt16(nameof(Unk6), e.Unk6); zeroed += s.UInt16(null, 0); s.Assert(zeroed == 0, "NpcActiveEvent:Expected fields 4,8 to be 0"); return(e); }
public static ModifyEvent BaseSerdes(ModifyEvent genericEvent, AssetMapping mapping, AssetId eventSource, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } var subType = s.EnumU8("SubType", genericEvent?.SubType ?? ModifyType.Unk2); return(subType switch { ModifyType.Switch => SwitchEvent.Serdes((SwitchEvent)genericEvent, mapping, s), ModifyType.DisableEventChain => DisableEventChainEvent.Serdes((DisableEventChainEvent)genericEvent, eventSource, s), ModifyType.NpcActive => NpcActiveEvent.Serdes((NpcActiveEvent)genericEvent, s), ModifyType.AddPartyMember => AddPartyMemberEvent.Serdes((AddPartyMemberEvent)genericEvent, mapping, s), ModifyType.InventoryItem => AddRemoveInventoryItemEvent.Serdes((AddRemoveInventoryItemEvent)genericEvent, mapping, s), ModifyType.MapLighting => SetMapLightingEvent.Serdes((SetMapLightingEvent)genericEvent, s), ModifyType.PartyGold => ChangePartyGoldEvent.Serdes((ChangePartyGoldEvent)genericEvent, s), ModifyType.PartyRations => ChangePartyRationsEvent.Serdes((ChangePartyRationsEvent)genericEvent, s), ModifyType.Time => ChangeTimeEvent.Serdes((ChangeTimeEvent)genericEvent, s), ModifyType.Leader => SetPartyLeaderEvent.Serdes((SetPartyLeaderEvent)genericEvent, mapping, s), ModifyType.Ticker => TickerEvent.Serdes((TickerEvent)genericEvent, mapping, s), ModifyType.Unk2 => ModifyUnk2Event.Serdes((ModifyUnk2Event)genericEvent, s), _ => throw new InvalidEnumArgumentException(nameof(subType), (int)subType, typeof(ModifyType)) });