コード例 #1
0
ファイル: DataChangeEvent.cs プロジェクト: lucorp/ualbion
        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}\"")
            });
コード例 #2
0
ファイル: ChangeLanguageEvent.cs プロジェクト: lucorp/ualbion
        public static ChangeLanguageEvent Serdes(ChangeLanguageEvent e, AssetMapping mapping, ISerializer s)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            e ??= new ChangeLanguageEvent();
            e.Operation = s.EnumU8(nameof(Operation), e.Operation);
            e.Unk3      = s.UInt8(nameof(Unk3), e.Unk3);
            int zeroed = s.UInt8(null, 0);

            e.PartyMemberId = PartyMemberId.SerdesU8(nameof(PartyMemberId), e.PartyMemberId, mapping, s);
            e.Language      = s.EnumU8(nameof(Language), e.Language);
            s.UInt8(null, 0);
            zeroed += s.UInt16(null, 0);
            s.Assert(zeroed == 0, "ChangeLanguageEvent: Expected byte 4 to be 0");
            return(e);
        }