Class: Api::ActionSpatialCameraMove
- Inherits:
-
Object
- Object
- Api::ActionSpatialCameraMove
- Defined in:
- lib/sc2ai/protocol/spatial_pb.rb
Instance Attribute Summary collapse
-
#center_minimap ⇒ Object
optional field readers.
Class Method Summary collapse
Instance Method Summary collapse
- #_encode(buff) ⇒ Object
- #decode_from(buff, index, len) ⇒ Object
- #has_center_minimap? ⇒ Boolean
-
#initialize(center_minimap: nil) ⇒ ActionSpatialCameraMove
constructor
END writers for optional fields.
- #to_h ⇒ Object
- #to_proto(_options = {}) ⇒ Object
Constructor Details
#initialize(center_minimap: nil) ⇒ ActionSpatialCameraMove
END writers for optional fields
10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 |
# File 'lib/sc2ai/protocol/spatial_pb.rb', line 10434 def initialize(center_minimap: nil) @_bitmask = 0 if center_minimap == nil @center_minimap = nil else @_bitmask |= 0x0000000000000001 @center_minimap = center_minimap end end |
Instance Attribute Details
#center_minimap ⇒ Object
optional field readers
10424 10425 10426 |
# File 'lib/sc2ai/protocol/spatial_pb.rb', line 10424 def center_minimap @center_minimap end |
Class Method Details
.decode(buff) ⇒ Object
10413 10414 10415 |
# File 'lib/sc2ai/protocol/spatial_pb.rb', line 10413 def self.decode(buff) allocate.decode_from(buff.b, 0, buff.bytesize) end |
.encode(obj) ⇒ Object
10417 10418 10419 |
# File 'lib/sc2ai/protocol/spatial_pb.rb', line 10417 def self.encode(obj) obj._encode("".b) end |
Instance Method Details
#_encode(buff) ⇒ Object
10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 |
# File 'lib/sc2ai/protocol/spatial_pb.rb', line 10767 def _encode(buff) val = @center_minimap 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 = buff.bytesize - current_len - 1 # Hope the size fits in one byte byte = & 0x7F >>= 7 byte |= 0x80 if > 0 buff.setbyte(current_len, byte) # If the sub message was bigger if > 0 current_len += 1 # compute how much we need to shift encoded_int_len = 0 remaining_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 != 0 byte = & 0x7F >>= 7 byte |= 0x80 if > 0 buff.setbyte(current_len, byte) current_len += 1 end end buff end buff end |
#decode_from(buff, index, len) ⇒ Object
10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 |
# File 'lib/sc2ai/protocol/spatial_pb.rb', line 10453 def decode_from(buff, index, len) @_bitmask = 0 @center_minimap = 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_minimap = Api::PointI.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_minimap? ⇒ Boolean
10449 10450 10451 |
# File 'lib/sc2ai/protocol/spatial_pb.rb', line 10449 def has_center_minimap? (@_bitmask & 0x0000000000000001) == 0x0000000000000001 end |
#to_h ⇒ Object
10819 10820 10821 10822 10823 |
# File 'lib/sc2ai/protocol/spatial_pb.rb', line 10819 def to_h result = {} result["center_minimap".to_sym] = @center_minimap.to_h result end |
#to_proto(_options = {}) ⇒ Object
10445 10446 10447 |
# File 'lib/sc2ai/protocol/spatial_pb.rb', line 10445 def to_proto( = {}) self.class.encode(self) end |