Exemple #1
0
        public static TickerEvent Serdes(TickerEvent e, AssetMapping mapping, ISerializer s)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }

            e ??= new TickerEvent();
            e.Operation = s.EnumU8(nameof(Operation), e.Operation);
            e.Amount    = s.UInt8(nameof(Amount), e.Amount);
            e.Unk4      = s.UInt8(nameof(Unk4), e.Unk4);
            int zeroed = s.UInt8(null, 0);

            e.TickerId = TickerId.SerdesU16(nameof(TickerId), e.TickerId, mapping, s);
            zeroed    += s.UInt16(null, 0);
            ApiUtil.Assert(e.Unk4 == 0 || e.Unk4 == 1);
            s.Assert(zeroed == 0, "TickerEvent: Expected fields 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))
            });