summaryrefslogtreecommitdiff
path: root/tests/my-game/example/stat.js
blob: 12746ed5b3f3548b3fe419cd8e6276802d75164c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class Stat {
    constructor() {
        this.bb = null;
        this.bb_pos = 0;
    }
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsStat(bb, obj) {
        return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsStat(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    id(optionalEncoding) {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
    }
    val() {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
    }
    mutate_val(value) {
        const offset = this.bb.__offset(this.bb_pos, 6);
        if (offset === 0) {
            return false;
        }
        this.bb.writeInt64(this.bb_pos + offset, value);
        return true;
    }
    count() {
        const offset = this.bb.__offset(this.bb_pos, 8);
        return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
    }
    mutate_count(value) {
        const offset = this.bb.__offset(this.bb_pos, 8);
        if (offset === 0) {
            return false;
        }
        this.bb.writeUint16(this.bb_pos + offset, value);
        return true;
    }
    static getFullyQualifiedName() {
        return 'MyGame.Example.Stat';
    }
    static startStat(builder) {
        builder.startObject(3);
    }
    static addId(builder, idOffset) {
        builder.addFieldOffset(0, idOffset, 0);
    }
    static addVal(builder, val) {
        builder.addFieldInt64(1, val, builder.createLong(0, 0));
    }
    static addCount(builder, count) {
        builder.addFieldInt16(2, count, 0);
    }
    static endStat(builder) {
        const offset = builder.endObject();
        return offset;
    }
    static createStat(builder, idOffset, val, count) {
        Stat.startStat(builder);
        Stat.addId(builder, idOffset);
        Stat.addVal(builder, val);
        Stat.addCount(builder, count);
        return Stat.endStat(builder);
    }
    serialize() {
        return this.bb.bytes();
    }
    static deserialize(buffer) {
        return Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer));
    }
    unpack() {
        return new StatT(this.id(), this.val(), this.count());
    }
    unpackTo(_o) {
        _o.id = this.id();
        _o.val = this.val();
        _o.count = this.count();
    }
}
export class StatT {
    constructor(id = null, val = flatbuffers.createLong(0, 0), count = 0) {
        this.id = id;
        this.val = val;
        this.count = count;
    }
    pack(builder) {
        const id = (this.id !== null ? builder.createString(this.id) : 0);
        return Stat.createStat(builder, id, this.val, this.count);
    }
}