...

Text file src/github.com/google/flatbuffers/tests/union_vector/Attacker.kt

Documentation: github.com/google/flatbuffers/tests/union_vector

     1// automatically generated by the FlatBuffers compiler, do not modify
     2
     3import com.google.flatbuffers.BaseVector
     4import com.google.flatbuffers.BooleanVector
     5import com.google.flatbuffers.ByteVector
     6import com.google.flatbuffers.Constants
     7import com.google.flatbuffers.DoubleVector
     8import com.google.flatbuffers.FlatBufferBuilder
     9import com.google.flatbuffers.FloatVector
    10import com.google.flatbuffers.LongVector
    11import com.google.flatbuffers.StringVector
    12import com.google.flatbuffers.Struct
    13import com.google.flatbuffers.Table
    14import com.google.flatbuffers.UnionVector
    15import java.nio.ByteBuffer
    16import java.nio.ByteOrder
    17import kotlin.math.sign
    18
    19@Suppress("unused")
    20class Attacker : Table() {
    21
    22    fun __init(_i: Int, _bb: ByteBuffer)  {
    23        __reset(_i, _bb)
    24    }
    25    fun __assign(_i: Int, _bb: ByteBuffer) : Attacker {
    26        __init(_i, _bb)
    27        return this
    28    }
    29    val swordAttackDamage : Int
    30        get() {
    31            val o = __offset(4)
    32            return if(o != 0) bb.getInt(o + bb_pos) else 0
    33        }
    34    fun mutateSwordAttackDamage(swordAttackDamage: Int) : Boolean {
    35        val o = __offset(4)
    36        return if (o != 0) {
    37            bb.putInt(o + bb_pos, swordAttackDamage)
    38            true
    39        } else {
    40            false
    41        }
    42    }
    43    companion object {
    44        fun validateVersion() = Constants.FLATBUFFERS_23_5_26()
    45        fun getRootAsAttacker(_bb: ByteBuffer): Attacker = getRootAsAttacker(_bb, Attacker())
    46        fun getRootAsAttacker(_bb: ByteBuffer, obj: Attacker): Attacker {
    47            _bb.order(ByteOrder.LITTLE_ENDIAN)
    48            return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
    49        }
    50        fun createAttacker(builder: FlatBufferBuilder, swordAttackDamage: Int) : Int {
    51            builder.startTable(1)
    52            addSwordAttackDamage(builder, swordAttackDamage)
    53            return endAttacker(builder)
    54        }
    55        fun startAttacker(builder: FlatBufferBuilder) = builder.startTable(1)
    56        fun addSwordAttackDamage(builder: FlatBufferBuilder, swordAttackDamage: Int) = builder.addInt(0, swordAttackDamage, 0)
    57        fun endAttacker(builder: FlatBufferBuilder) : Int {
    58            val o = builder.endTable()
    59            return o
    60        }
    61    }
    62}

View as plain text