コード例 #1
0
ファイル: DataChangeEvent.cs プロジェクト: vsafonkin/ualbion
        public static DataChangeEvent Serdes(DataChangeEvent e, AssetMapping mapping, ISerializer s)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            e ??= new DataChangeEvent();
            e.Property      = s.EnumU8(nameof(Property), e.Property);
            e.Mode          = s.EnumU8(nameof(Mode), e.Mode);
            e.Unk3          = s.UInt8(nameof(Unk3), e.Unk3);
            e.Unk4          = s.UInt8(nameof(Unk4), e.Unk4);
            e.PartyMemberId = PartyMemberId.SerdesU8(nameof(PartyMemberId), e.PartyMemberId, mapping, s);

            switch (e.Property)
            {
            case ChangeProperty.ReceiveOrRemoveItem:
                e._value = ItemId.SerdesU16(nameof(ItemId), ItemId.FromUInt32(e._value), AssetType.Item, mapping, s).ToUInt32();
                break;

            default:
                e._value = s.UInt16(nameof(Value), (ushort)e._value);
                break;
            }
            e.Amount = s.UInt16(nameof(Amount), e.Amount);
            return(e);
        }
コード例 #2
0
ファイル: VisitedEvent.cs プロジェクト: csinkers/ualbion
    public static VisitedEvent Serdes(int n, VisitedEvent u, AssetMapping mapping, ISerializer s)
    {
        if (s == null)
        {
            throw new ArgumentNullException(nameof(s));
        }

        u ??= new VisitedEvent();
        s.Begin();
        u.Unk0       = s.UInt8(nameof(Unk0), u.Unk0);
        u.EventSetId = EventSetId.SerdesU16(nameof(EventSetId), u.EventSetId, mapping, s);
        u.Type       = s.EnumU8(nameof(Type), u.Type);

        switch (u.Type)
        {
        case ActionType.AskAboutItem:
        case ActionType.UseItem:
        case ActionType.EquipItem:
        case ActionType.UnequipItem:
        case ActionType.PickupItem:
            u._value = ItemId.SerdesU16("Value", ItemId.FromUInt32(u._value), AssetType.Item, mapping, s).ToUInt32();
            break;

        case ActionType.Word:
            u._value = WordId.SerdesU16("Value", WordId.FromUInt32(u._value), mapping, s).ToUInt32();
            break;

        default:
            u._value = s.UInt16("Value", (ushort)u._value);
            break;
        }

        if (s.IsCommenting())
        {
            s.Comment(u.ToString());
        }
        s.End();
        return(u);
    }