"Fossies" - the Fresh Open Source Software Archive

Member "flatbuffers-23.1.21/tests/ts/my-game/example/ability.ts" (21 Jan 2023, 1475 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) TypeScript 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. See also the last Fossies "Diffs" side-by-side code changes report for "ability.ts": 22.12.06_vs_23.1.4.

    1 // automatically generated by the FlatBuffers compiler, do not modify
    2 
    3 import * as flatbuffers from 'flatbuffers';
    4 
    5 
    6 
    7 export class Ability implements flatbuffers.IUnpackableObject<AbilityT> {
    8   bb: flatbuffers.ByteBuffer|null = null;
    9   bb_pos = 0;
   10   __init(i:number, bb:flatbuffers.ByteBuffer):Ability {
   11   this.bb_pos = i;
   12   this.bb = bb;
   13   return this;
   14 }
   15 
   16 id():number {
   17   return this.bb!.readUint32(this.bb_pos);
   18 }
   19 
   20 mutate_id(value:number):boolean {
   21   this.bb!.writeUint32(this.bb_pos + 0, value);
   22   return true;
   23 }
   24 
   25 distance():number {
   26   return this.bb!.readUint32(this.bb_pos + 4);
   27 }
   28 
   29 mutate_distance(value:number):boolean {
   30   this.bb!.writeUint32(this.bb_pos + 4, value);
   31   return true;
   32 }
   33 
   34 static getFullyQualifiedName():string {
   35   return 'MyGame.Example.Ability';
   36 }
   37 
   38 static sizeOf():number {
   39   return 8;
   40 }
   41 
   42 static createAbility(builder:flatbuffers.Builder, id: number, distance: number):flatbuffers.Offset {
   43   builder.prep(4, 8);
   44   builder.writeInt32(distance);
   45   builder.writeInt32(id);
   46   return builder.offset();
   47 }
   48 
   49 
   50 unpack(): AbilityT {
   51   return new AbilityT(
   52     this.id(),
   53     this.distance()
   54   );
   55 }
   56 
   57 
   58 unpackTo(_o: AbilityT): void {
   59   _o.id = this.id();
   60   _o.distance = this.distance();
   61 }
   62 }
   63 
   64 export class AbilityT implements flatbuffers.IGeneratedObject {
   65 constructor(
   66   public id: number = 0,
   67   public distance: number = 0
   68 ){}
   69 
   70 
   71 pack(builder:flatbuffers.Builder): flatbuffers.Offset {
   72   return Ability.createAbility(builder,
   73     this.id,
   74     this.distance
   75   );
   76 }
   77 }