Exemple #1
0
        public static SwitchEvent Serdes(SwitchEvent e, AssetMapping mapping, ISerializer s)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            e ??= new SwitchEvent();
            e.Operation = s.EnumU8(nameof(Operation), e.Operation);
            e.Unk3      = s.UInt8(nameof(Unk3), e.Unk3);
            int zeroed = s.UInt8(null, 0);

            zeroed    += s.UInt8(null, 0);
            e.SwitchId = SwitchId.SerdesU16(nameof(SwitchId), e.SwitchId, mapping, s);
            zeroed    += s.UInt16(null, 0);
            s.Assert(zeroed == 0, "SwitchEvent: Expected fields 4,5,8 to be 0");
            return(e);
        }
Exemple #2
0
        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))
            });