Class: Api::Size2DI

Inherits:
Object
  • Object
show all
Includes:
PointDistanceExtension, Sc2::Position
Defined in:
lib/sc2ai/protocol/_meta_documentation.rb,
lib/sc2ai/protocol/common_pb.rb

Overview

Protobuf virtual class.

Constant Summary

Constants included from Sc2::Position

Sc2::Position::TOLERANCE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Sc2::Position

#==, #add, #angle_to, #away_from, #cross_product, #distance_squared_to, #distance_to, #distance_to_circle, #distance_to_coordinate, #divide, #dot, #lerp, #magnitude, #multiply, #normalize, #offset, #offset!, #random_offset, #random_offset!, #subtract, #towards

Constructor Details

#initialize(x: nil, y: nil) ⇒ Size2DI

END writers for optional fields



3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
# File 'lib/sc2ai/protocol/common_pb.rb', line 3345

def initialize(x: nil, y: nil)
  @_bitmask = 0

  if x == nil
    @x = 0
  else
    unless -2_147_483_648 <= x && x <= 2_147_483_647
      raise RangeError,
            "Value (#{x}) for field x is out of bounds (-2147483648..2147483647)"
    end
    @_bitmask |= 0x0000000000000001
    @x = x
  end

  if y == nil
    @y = 0
  else
    unless -2_147_483_648 <= y && y <= 2_147_483_647
      raise RangeError,
            "Value (#{y}) for field y is out of bounds (-2147483648..2147483647)"
    end
    @_bitmask |= 0x0000000000000002
    @y = y
  end
end

Instance Attribute Details

#xObject

optional field readers



3318
3319
3320
# File 'lib/sc2ai/protocol/common_pb.rb', line 3318

def x
  @x
end

#yObject

Returns the value of attribute y.



3320
3321
3322
# File 'lib/sc2ai/protocol/common_pb.rb', line 3320

def y
  @y
end

Class Method Details

.decode(buff) ⇒ Object



3307
3308
3309
# File 'lib/sc2ai/protocol/common_pb.rb', line 3307

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

.encode(obj) ⇒ Object



3311
3312
3313
# File 'lib/sc2ai/protocol/common_pb.rb', line 3311

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

Instance Method Details

#_encode(buff) ⇒ Object



3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
# File 'lib/sc2ai/protocol/common_pb.rb', line 3825

def _encode(buff)
  val = @x
  if val != 0
    buff << 0x08

    while val != 0
      byte = val & 0x7F

      val >>= 7
      # This drops the top bits,
      # Otherwise, with a signed right shift,
      # we get infinity one bits at the top
      val &= (1 << 57) - 1

      byte |= 0x80 if val != 0
      buff << byte
    end
  end

  val = @y
  if val != 0
    buff << 0x10

    while val != 0
      byte = val & 0x7F

      val >>= 7
      # This drops the top bits,
      # Otherwise, with a signed right shift,
      # we get infinity one bits at the top
      val &= (1 << 57) - 1

      byte |= 0x80 if val != 0
      buff << byte
    end
  end

  buff
end

#decode_from(buff, index, len) ⇒ Object



3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
# File 'lib/sc2ai/protocol/common_pb.rb', line 3383

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

  @x = 0
  @y = 0

  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 == 0x8
      found = true
      ## PULL_INT32
      @x =
        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

          # Negative 32 bit integers are still encoded with 10 bytes
          # handle 2's complement negative numbers
          # If the top bit is 1, then it must be negative.
          -(
            (
              (
                ~(
                  (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)
                )
              ) & 0xFFFF_FFFF
            ) + 1
          )
        else
          raise "integer decoding error"
        end

      ## END PULL_INT32

      @_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
    if tag == 0x10
      found = true
      ## PULL_INT32
      @y =
        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

          # Negative 32 bit integers are still encoded with 10 bytes
          # handle 2's complement negative numbers
          # If the top bit is 1, then it must be negative.
          -(
            (
              (
                ~(
                  (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)
                )
              ) & 0xFFFF_FFFF
            ) + 1
          )
        else
          raise "integer decoding error"
        end

      ## END PULL_INT32

      @_bitmask |= 0x0000000000000002
      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_x?Boolean

Returns:

  • (Boolean)


3375
3376
3377
# File 'lib/sc2ai/protocol/common_pb.rb', line 3375

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

#has_y?Boolean

Returns:

  • (Boolean)


3379
3380
3381
# File 'lib/sc2ai/protocol/common_pb.rb', line 3379

def has_y?
  (@_bitmask & 0x0000000000000002) == 0x0000000000000002
end

#to_hObject



3865
3866
3867
3868
3869
3870
# File 'lib/sc2ai/protocol/common_pb.rb', line 3865

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

#to_proto(_options = {}) ⇒ Object



3371
3372
3373
# File 'lib/sc2ai/protocol/common_pb.rb', line 3371

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