"Fossies" - the Fresh Open Source Software Archive

Member "flatbuffers-23.1.21/tests/MyGame/Example/Ability.go" (21 Jan 2023, 1483 Bytes) of package /linux/misc/flatbuffers-23.1.21.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Code generated by the FlatBuffers compiler. DO NOT EDIT.
    2 
    3 package Example
    4 
    5 import (
    6     flatbuffers "github.com/google/flatbuffers/go"
    7 )
    8 
    9 type AbilityT struct {
   10     Id uint32 `json:"id"`
   11     Distance uint32 `json:"distance"`
   12 }
   13 
   14 func (t *AbilityT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
   15     if t == nil { return 0 }
   16     return CreateAbility(builder, t.Id, t.Distance)
   17 }
   18 func (rcv *Ability) UnPackTo(t *AbilityT) {
   19     t.Id = rcv.Id()
   20     t.Distance = rcv.Distance()
   21 }
   22 
   23 func (rcv *Ability) UnPack() *AbilityT {
   24     if rcv == nil { return nil }
   25     t := &AbilityT{}
   26     rcv.UnPackTo(t)
   27     return t
   28 }
   29 
   30 type Ability struct {
   31     _tab flatbuffers.Struct
   32 }
   33 
   34 func (rcv *Ability) Init(buf []byte, i flatbuffers.UOffsetT) {
   35     rcv._tab.Bytes = buf
   36     rcv._tab.Pos = i
   37 }
   38 
   39 func (rcv *Ability) Table() flatbuffers.Table {
   40     return rcv._tab.Table
   41 }
   42 
   43 func (rcv *Ability) Id() uint32 {
   44     return rcv._tab.GetUint32(rcv._tab.Pos + flatbuffers.UOffsetT(0))
   45 }
   46 func (rcv *Ability) MutateId(n uint32) bool {
   47     return rcv._tab.MutateUint32(rcv._tab.Pos+flatbuffers.UOffsetT(0), n)
   48 }
   49 
   50 func (rcv *Ability) Distance() uint32 {
   51     return rcv._tab.GetUint32(rcv._tab.Pos + flatbuffers.UOffsetT(4))
   52 }
   53 func (rcv *Ability) MutateDistance(n uint32) bool {
   54     return rcv._tab.MutateUint32(rcv._tab.Pos+flatbuffers.UOffsetT(4), n)
   55 }
   56 
   57 func CreateAbility(builder *flatbuffers.Builder, id uint32, distance uint32) flatbuffers.UOffsetT {
   58     builder.Prep(4, 8)
   59     builder.PrependUint32(distance)
   60     builder.PrependUint32(id)
   61     return builder.Offset()
   62 }