Class: Api::ActionRawCameraMove

Inherits:
Object
  • Object
show all
Defined in:
lib/sc2ai/protocol/raw_pb.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(center_world_space: nil) ⇒ ActionRawCameraMove

END writers for optional fields



17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
# File 'lib/sc2ai/protocol/raw_pb.rb', line 17324

def initialize(center_world_space: nil)
  @_bitmask = 0

  if center_world_space == nil
    @center_world_space = nil
  else
    @_bitmask |= 0x0000000000000001
    @center_world_space = center_world_space
  end
end

Instance Attribute Details

#center_world_spaceObject

optional field readers



17314
17315
17316
# File 'lib/sc2ai/protocol/raw_pb.rb', line 17314

def center_world_space
  @center_world_space
end

Class Method Details

.decode(buff) ⇒ Object



17303
17304
17305
# File 'lib/sc2ai/protocol/raw_pb.rb', line 17303

def self.decode(buff)
  allocate.decode_from(buff.b, 0, buff.bytesize)
end

.encode(obj) ⇒ Object



17307
17308
17309
# File 'lib/sc2ai/protocol/raw_pb.rb', line 17307

def self.encode(obj)
  obj._encode("".b)
end

Instance Method Details

#_encode(buff) ⇒ Object



17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
# File 'lib/sc2ai/protocol/raw_pb.rb', line 17657

def _encode(buff)
  val = @center_world_space
  if val
    buff << 0x0a

    # Save the buffer size before appending the submessage
    current_len = buff.bytesize

    # Write a single dummy byte to later store encoded length
    buff << 42 # "*"
    val._encode(buff)

    # Calculate the submessage's size
    submessage_size = buff.bytesize - current_len - 1

    # Hope the size fits in one byte
    byte = submessage_size & 0x7F
    submessage_size >>= 7
    byte |= 0x80 if submessage_size > 0
    buff.setbyte(current_len, byte)

    # If the sub message was bigger
    if submessage_size > 0
      current_len += 1

      # compute how much we need to shift
      encoded_int_len = 0
      remaining_size = submessage_size
      while remaining_size != 0
        remaining_size >>= 7
        encoded_int_len += 1
      end

      # Make space in the string with dummy bytes
      buff.bytesplice(current_len, 0, "*********", 0, encoded_int_len)

      # Overwrite the dummy bytes with the encoded length
      while submessage_size != 0
        byte = submessage_size & 0x7F
        submessage_size >>= 7
        byte |= 0x80 if submessage_size > 0
        buff.setbyte(current_len, byte)
        current_len += 1
      end
    end

    buff
  end

  buff
end

#decode_from(buff, index, len) ⇒ Object



17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
# File 'lib/sc2ai/protocol/raw_pb.rb', line 17343

def decode_from(buff, index, len)
  @_bitmask = 0

  @center_world_space = nil

  return self if index >= len
  ## PULL_UINT64
  tag =
    if (byte0 = buff.getbyte(index)) < 0x80
      index += 1
      byte0
    elsif (byte1 = buff.getbyte(index + 1)) < 0x80
      index += 2
      (byte1 << 7) | (byte0 & 0x7F)
    elsif (byte2 = buff.getbyte(index + 2)) < 0x80
      index += 3
      (byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte3 = buff.getbyte(index + 3)) < 0x80
      index += 4
      (byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
        (byte0 & 0x7F)
    elsif (byte4 = buff.getbyte(index + 4)) < 0x80
      index += 5
      (byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
        ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte5 = buff.getbyte(index + 5)) < 0x80
      index += 6
      (byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
        ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte6 = buff.getbyte(index + 6)) < 0x80
      index += 7
      (byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
        ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
        ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte7 = buff.getbyte(index + 7)) < 0x80
      index += 8
      (byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
        ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
        ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte8 = buff.getbyte(index + 8)) < 0x80
      index += 9
      (byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
        ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
        ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
        ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte9 = buff.getbyte(index + 9)) < 0x80
      index += 10

      (byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
        ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
        ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
        ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    else
      raise "integer decoding error"
    end

  ## END PULL_UINT64

  found = true
  while true
    # If we have looped around since the last found tag this one is
    # unexpected, so discard it and continue.
    if !found
      wire_type = tag & 0x7
      case wire_type
      when 0
        i = 0
        while true
          newbyte = buff.getbyte(index)
          index += 1
          break if newbyte.nil? || newbyte < 0x80
          i += 1
          break if i > 9
        end
      when 1
        index += 8
      when 2
        ## PULL_BYTES
        value =
          if (byte0 = buff.getbyte(index)) < 0x80
            index += 1
            byte0
          elsif (byte1 = buff.getbyte(index + 1)) < 0x80
            index += 2
            (byte1 << 7) | (byte0 & 0x7F)
          elsif (byte2 = buff.getbyte(index + 2)) < 0x80
            index += 3
            (byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
          elsif (byte3 = buff.getbyte(index + 3)) < 0x80
            index += 4
            (byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
              (byte0 & 0x7F)
          elsif (byte4 = buff.getbyte(index + 4)) < 0x80
            index += 5
            (byte4 << 28) | ((byte3 & 0x7F) << 21) |
              ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
              (byte0 & 0x7F)
          elsif (byte5 = buff.getbyte(index + 5)) < 0x80
            index += 6
            (byte5 << 35) | ((byte4 & 0x7F) << 28) |
              ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
              ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
          elsif (byte6 = buff.getbyte(index + 6)) < 0x80
            index += 7
            (byte6 << 42) | ((byte5 & 0x7F) << 35) |
              ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
              ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
              (byte0 & 0x7F)
          elsif (byte7 = buff.getbyte(index + 7)) < 0x80
            index += 8
            (byte7 << 49) | ((byte6 & 0x7F) << 42) |
              ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
              ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
              ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
          elsif (byte8 = buff.getbyte(index + 8)) < 0x80
            index += 9
            (byte8 << 56) | ((byte7 & 0x7F) << 49) |
              ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
              ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
              ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
              (byte0 & 0x7F)
          elsif (byte9 = buff.getbyte(index + 9)) < 0x80
            index += 10

            (byte9 << 63) | ((byte8 & 0x7F) << 56) |
              ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
              ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
              ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
              ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
          else
            raise "integer decoding error"
          end

        buff.byteslice(index, value)
        index += value

        ## END PULL_BYTES
      when 5
        index += 4
      else
        raise "unknown wire type #{wire_type}"
      end
      return self if index >= len
      ## PULL_UINT64
      tag =
        if (byte0 = buff.getbyte(index)) < 0x80
          index += 1
          byte0
        elsif (byte1 = buff.getbyte(index + 1)) < 0x80
          index += 2
          (byte1 << 7) | (byte0 & 0x7F)
        elsif (byte2 = buff.getbyte(index + 2)) < 0x80
          index += 3
          (byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte3 = buff.getbyte(index + 3)) < 0x80
          index += 4
          (byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
            (byte0 & 0x7F)
        elsif (byte4 = buff.getbyte(index + 4)) < 0x80
          index += 5
          (byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte5 = buff.getbyte(index + 5)) < 0x80
          index += 6
          (byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte6 = buff.getbyte(index + 6)) < 0x80
          index += 7
          (byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte7 = buff.getbyte(index + 7)) < 0x80
          index += 8
          (byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte8 = buff.getbyte(index + 8)) < 0x80
          index += 9
          (byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
            ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte9 = buff.getbyte(index + 9)) < 0x80
          index += 10

          (byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
            ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        else
          raise "integer decoding error"
        end

      ## END PULL_UINT64
    end
    found = false

    if tag == 0xa
      found = true
      ## PULL_MESSAGE
      ## PULL_UINT64
      msg_len =
        if (byte0 = buff.getbyte(index)) < 0x80
          index += 1
          byte0
        elsif (byte1 = buff.getbyte(index + 1)) < 0x80
          index += 2
          (byte1 << 7) | (byte0 & 0x7F)
        elsif (byte2 = buff.getbyte(index + 2)) < 0x80
          index += 3
          (byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte3 = buff.getbyte(index + 3)) < 0x80
          index += 4
          (byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
            (byte0 & 0x7F)
        elsif (byte4 = buff.getbyte(index + 4)) < 0x80
          index += 5
          (byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte5 = buff.getbyte(index + 5)) < 0x80
          index += 6
          (byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte6 = buff.getbyte(index + 6)) < 0x80
          index += 7
          (byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte7 = buff.getbyte(index + 7)) < 0x80
          index += 8
          (byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte8 = buff.getbyte(index + 8)) < 0x80
          index += 9
          (byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
            ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte9 = buff.getbyte(index + 9)) < 0x80
          index += 10

          (byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
            ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        else
          raise "integer decoding error"
        end

      ## END PULL_UINT64

      @center_world_space =
        Api::Point.allocate.decode_from(buff, index, index += msg_len)
      ## END PULL_MESSAGE

      @_bitmask |= 0x0000000000000001
      return self if index >= len
      ## PULL_UINT64
      tag =
        if (byte0 = buff.getbyte(index)) < 0x80
          index += 1
          byte0
        elsif (byte1 = buff.getbyte(index + 1)) < 0x80
          index += 2
          (byte1 << 7) | (byte0 & 0x7F)
        elsif (byte2 = buff.getbyte(index + 2)) < 0x80
          index += 3
          (byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte3 = buff.getbyte(index + 3)) < 0x80
          index += 4
          (byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
            (byte0 & 0x7F)
        elsif (byte4 = buff.getbyte(index + 4)) < 0x80
          index += 5
          (byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte5 = buff.getbyte(index + 5)) < 0x80
          index += 6
          (byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte6 = buff.getbyte(index + 6)) < 0x80
          index += 7
          (byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte7 = buff.getbyte(index + 7)) < 0x80
          index += 8
          (byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte8 = buff.getbyte(index + 8)) < 0x80
          index += 9
          (byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
            ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte9 = buff.getbyte(index + 9)) < 0x80
          index += 10

          (byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
            ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        else
          raise "integer decoding error"
        end

      ## END PULL_UINT64
    end

    return self if index >= len
  end
end

#has_center_world_space?Boolean

Returns:

  • (Boolean)


17339
17340
17341
# File 'lib/sc2ai/protocol/raw_pb.rb', line 17339

def has_center_world_space?
  (@_bitmask & 0x0000000000000001) == 0x0000000000000001
end

#to_hObject



17709
17710
17711
17712
17713
# File 'lib/sc2ai/protocol/raw_pb.rb', line 17709

def to_h
  result = {}
  result["center_world_space".to_sym] = @center_world_space.to_h
  result
end

#to_proto(_options = {}) ⇒ Object



17335
17336
17337
# File 'lib/sc2ai/protocol/raw_pb.rb', line 17335

def to_proto(_options = {})
  self.class.encode(self)
end