sc2ai 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,31 +11,19 @@ module Api
11
11
  PLACEHOLDER = 4
12
12
 
13
13
  def self.lookup(val)
14
- if val == 0
15
- :ENUM_DISPLAY_TYPE_UNSET
16
- elsif val == 1
17
- :VISIBLE
18
- elsif val == 2
19
- :SNAPSHOT
20
- elsif val == 3
21
- :HIDDEN
22
- elsif val == 4
23
- :PLACEHOLDER
24
- end
14
+ return :ENUM_DISPLAY_TYPE_UNSET if val == 0
15
+ return :VISIBLE if val == 1
16
+ return :SNAPSHOT if val == 2
17
+ return :HIDDEN if val == 3
18
+ return :PLACEHOLDER if val == 4
25
19
  end
26
20
 
27
21
  def self.resolve(val)
28
- if val == :ENUM_DISPLAY_TYPE_UNSET
29
- 0
30
- elsif val == :VISIBLE
31
- 1
32
- elsif val == :SNAPSHOT
33
- 2
34
- elsif val == :HIDDEN
35
- 3
36
- elsif val == :PLACEHOLDER
37
- 4
38
- end
22
+ return 0 if val == :ENUM_DISPLAY_TYPE_UNSET
23
+ return 1 if val == :VISIBLE
24
+ return 2 if val == :SNAPSHOT
25
+ return 3 if val == :HIDDEN
26
+ return 4 if val == :PLACEHOLDER
39
27
  end
40
28
  end
41
29
  module Alliance
@@ -46,31 +34,19 @@ module Api
46
34
  ENEMY = 4
47
35
 
48
36
  def self.lookup(val)
49
- if val == 0
50
- :ENUM_ALLIANCE_UNSET
51
- elsif val == 1
52
- :SELF
53
- elsif val == 2
54
- :ALLY
55
- elsif val == 3
56
- :NEUTRAL
57
- elsif val == 4
58
- :ENEMY
59
- end
37
+ return :ENUM_ALLIANCE_UNSET if val == 0
38
+ return :SELF if val == 1
39
+ return :ALLY if val == 2
40
+ return :NEUTRAL if val == 3
41
+ return :ENEMY if val == 4
60
42
  end
61
43
 
62
44
  def self.resolve(val)
63
- if val == :ENUM_ALLIANCE_UNSET
64
- 0
65
- elsif val == :SELF
66
- 1
67
- elsif val == :ALLY
68
- 2
69
- elsif val == :NEUTRAL
70
- 3
71
- elsif val == :ENEMY
72
- 4
73
- end
45
+ return 0 if val == :ENUM_ALLIANCE_UNSET
46
+ return 1 if val == :SELF
47
+ return 2 if val == :ALLY
48
+ return 3 if val == :NEUTRAL
49
+ return 4 if val == :ENEMY
74
50
  end
75
51
  end
76
52
  module CloakState
@@ -81,31 +57,19 @@ module Api
81
57
  CLOAKED_ALLIED = 4
82
58
 
83
59
  def self.lookup(val)
84
- if val == 0
85
- :CLOAKED_UNKNOWN
86
- elsif val == 1
87
- :CLOAKED
88
- elsif val == 2
89
- :CLOAKED_DETECTED
90
- elsif val == 3
91
- :NOT_CLOAKED
92
- elsif val == 4
93
- :CLOAKED_ALLIED
94
- end
60
+ return :CLOAKED_UNKNOWN if val == 0
61
+ return :CLOAKED if val == 1
62
+ return :CLOAKED_DETECTED if val == 2
63
+ return :NOT_CLOAKED if val == 3
64
+ return :CLOAKED_ALLIED if val == 4
95
65
  end
96
66
 
97
67
  def self.resolve(val)
98
- if val == :CLOAKED_UNKNOWN
99
- 0
100
- elsif val == :CLOAKED
101
- 1
102
- elsif val == :CLOAKED_DETECTED
103
- 2
104
- elsif val == :NOT_CLOAKED
105
- 3
106
- elsif val == :CLOAKED_ALLIED
107
- 4
108
- end
68
+ return 0 if val == :CLOAKED_UNKNOWN
69
+ return 1 if val == :CLOAKED
70
+ return 2 if val == :CLOAKED_DETECTED
71
+ return 3 if val == :NOT_CLOAKED
72
+ return 4 if val == :CLOAKED_ALLIED
109
73
  end
110
74
  end
111
75
 
@@ -309,7 +273,7 @@ module Api
309
273
 
310
274
  unknown_bytes = +"".b
311
275
  val = tag
312
- while val != 0
276
+ loop do
313
277
  byte = val & 0x7F
314
278
 
315
279
  val >>= 7
@@ -320,6 +284,7 @@ module Api
320
284
 
321
285
  byte |= 0x80 if val != 0
322
286
  unknown_bytes << byte
287
+ break if val == 0
323
288
  end
324
289
 
325
290
  case wire_type
@@ -394,7 +359,7 @@ module Api
394
359
  end
395
360
 
396
361
  val = value
397
- while val != 0
362
+ loop do
398
363
  byte = val & 0x7F
399
364
 
400
365
  val >>= 7
@@ -405,6 +370,7 @@ module Api
405
370
 
406
371
  byte |= 0x80 if val != 0
407
372
  unknown_bytes << byte
373
+ break if val == 0
408
374
  end
409
375
 
410
376
  unknown_bytes << buff.byteslice(index, value)
@@ -1475,14 +1441,67 @@ module Api
1475
1441
 
1476
1442
  def to_h
1477
1443
  result = {}
1478
- result["map_size".to_sym] = @map_size.to_h
1479
- result["pathing_grid".to_sym] = @pathing_grid.to_h
1480
- result["terrain_height".to_sym] = @terrain_height.to_h
1481
- result["placement_grid".to_sym] = @placement_grid.to_h
1482
- result["playable_area".to_sym] = @playable_area.to_h
1483
- result["start_locations".to_sym] = @start_locations
1444
+
1445
+ result[:"map_size"] = @map_size.to_h
1446
+ result[:"pathing_grid"] = @pathing_grid.to_h
1447
+ result[:"terrain_height"] = @terrain_height.to_h
1448
+ result[:"placement_grid"] = @placement_grid.to_h
1449
+ result[:"playable_area"] = @playable_area.to_h
1450
+ result[:"start_locations"] = @start_locations.map(&:to_h)
1451
+
1452
+ result
1453
+ end
1454
+
1455
+ def as_json(options = {})
1456
+ result = {}
1457
+
1458
+ result["mapSize"] = (
1459
+ if @map_size.nil?
1460
+ {}
1461
+ else
1462
+ @map_size.as_json(options)
1463
+ end
1464
+ ) if !options[:compact] || has_map_size?
1465
+ result["pathingGrid"] = (
1466
+ if @pathing_grid.nil?
1467
+ {}
1468
+ else
1469
+ @pathing_grid.as_json(options)
1470
+ end
1471
+ ) if !options[:compact] || has_pathing_grid?
1472
+ result["terrainHeight"] = (
1473
+ if @terrain_height.nil?
1474
+ {}
1475
+ else
1476
+ @terrain_height.as_json(options)
1477
+ end
1478
+ ) if !options[:compact] || has_terrain_height?
1479
+ result["placementGrid"] = (
1480
+ if @placement_grid.nil?
1481
+ {}
1482
+ else
1483
+ @placement_grid.as_json(options)
1484
+ end
1485
+ ) if !options[:compact] || has_placement_grid?
1486
+ result["playableArea"] = (
1487
+ if @playable_area.nil?
1488
+ {}
1489
+ else
1490
+ @playable_area.as_json(options)
1491
+ end
1492
+ ) if !options[:compact] || has_playable_area?
1493
+ tmp_start_locations = @start_locations.map { |v| v.as_json(options) }
1494
+
1495
+ result["startLocations"] = tmp_start_locations if !options[:compact] ||
1496
+ tmp_start_locations.any?
1497
+
1484
1498
  result
1485
1499
  end
1500
+
1501
+ def to_json(as_json_options = {})
1502
+ require "json"
1503
+ JSON.dump(as_json(as_json_options))
1504
+ end
1486
1505
  end
1487
1506
  class ObservationRaw
1488
1507
  def self.decode(buff)
@@ -1664,7 +1683,7 @@ module Api
1664
1683
 
1665
1684
  unknown_bytes = +"".b
1666
1685
  val = tag
1667
- while val != 0
1686
+ loop do
1668
1687
  byte = val & 0x7F
1669
1688
 
1670
1689
  val >>= 7
@@ -1675,6 +1694,7 @@ module Api
1675
1694
 
1676
1695
  byte |= 0x80 if val != 0
1677
1696
  unknown_bytes << byte
1697
+ break if val == 0
1678
1698
  end
1679
1699
 
1680
1700
  case wire_type
@@ -1749,7 +1769,7 @@ module Api
1749
1769
  end
1750
1770
 
1751
1771
  val = value
1752
- while val != 0
1772
+ loop do
1753
1773
  byte = val & 0x7F
1754
1774
 
1755
1775
  val >>= 7
@@ -1760,6 +1780,7 @@ module Api
1760
1780
 
1761
1781
  byte |= 0x80 if val != 0
1762
1782
  unknown_bytes << byte
1783
+ break if val == 0
1763
1784
  end
1764
1785
 
1765
1786
  unknown_bytes << buff.byteslice(index, value)
@@ -2886,14 +2907,56 @@ module Api
2886
2907
 
2887
2908
  def to_h
2888
2909
  result = {}
2889
- result["player".to_sym] = @player.to_h
2890
- result["units".to_sym] = @units
2891
- result["map_state".to_sym] = @map_state.to_h
2892
- result["event".to_sym] = @event.to_h
2893
- result["effects".to_sym] = @effects
2894
- result["radar".to_sym] = @radar
2910
+
2911
+ result[:"player"] = @player.to_h
2912
+ result[:"units"] = @units.map(&:to_h)
2913
+ result[:"map_state"] = @map_state.to_h
2914
+ result[:"event"] = @event.to_h
2915
+ result[:"effects"] = @effects.map(&:to_h)
2916
+ result[:"radar"] = @radar.map(&:to_h)
2917
+
2895
2918
  result
2896
2919
  end
2920
+
2921
+ def as_json(options = {})
2922
+ result = {}
2923
+
2924
+ result["player"] = (
2925
+ if @player.nil?
2926
+ {}
2927
+ else
2928
+ @player.as_json(options)
2929
+ end
2930
+ ) if !options[:compact] || has_player?
2931
+ tmp_units = @units.map { |v| v.as_json(options) }
2932
+
2933
+ result["units"] = tmp_units if !options[:compact] || tmp_units.any?
2934
+
2935
+ result["mapState"] = (
2936
+ if @map_state.nil?
2937
+ {}
2938
+ else
2939
+ @map_state.as_json(options)
2940
+ end
2941
+ ) if !options[:compact] || has_map_state?
2942
+ result["event"] = @event.nil? ? {} : @event.as_json(options) if !options[
2943
+ :compact
2944
+ ] || has_event?
2945
+ tmp_effects = @effects.map { |v| v.as_json(options) }
2946
+
2947
+ result["effects"] = tmp_effects if !options[:compact] || tmp_effects.any?
2948
+
2949
+ tmp_radar = @radar.map { |v| v.as_json(options) }
2950
+
2951
+ result["radar"] = tmp_radar if !options[:compact] || tmp_radar.any?
2952
+
2953
+ result
2954
+ end
2955
+
2956
+ def to_json(as_json_options = {})
2957
+ require "json"
2958
+ JSON.dump(as_json(as_json_options))
2959
+ end
2897
2960
  end
2898
2961
  class RadarRing
2899
2962
  def self.decode(buff)
@@ -3022,7 +3085,7 @@ module Api
3022
3085
 
3023
3086
  unknown_bytes = +"".b
3024
3087
  val = tag
3025
- while val != 0
3088
+ loop do
3026
3089
  byte = val & 0x7F
3027
3090
 
3028
3091
  val >>= 7
@@ -3033,6 +3096,7 @@ module Api
3033
3096
 
3034
3097
  byte |= 0x80 if val != 0
3035
3098
  unknown_bytes << byte
3099
+ break if val == 0
3036
3100
  end
3037
3101
 
3038
3102
  case wire_type
@@ -3107,7 +3171,7 @@ module Api
3107
3171
  end
3108
3172
 
3109
3173
  val = value
3110
- while val != 0
3174
+ loop do
3111
3175
  byte = val & 0x7F
3112
3176
 
3113
3177
  val >>= 7
@@ -3118,6 +3182,7 @@ module Api
3118
3182
 
3119
3183
  byte |= 0x80 if val != 0
3120
3184
  unknown_bytes << byte
3185
+ break if val == 0
3121
3186
  end
3122
3187
 
3123
3188
  unknown_bytes << buff.byteslice(index, value)
@@ -3408,7 +3473,7 @@ module Api
3408
3473
  end
3409
3474
 
3410
3475
  val = @radius
3411
- if val != 0
3476
+ if has_radius?
3412
3477
  buff << 0x15
3413
3478
 
3414
3479
  [val].pack("e", buffer: buff)
@@ -3419,10 +3484,28 @@ module Api
3419
3484
 
3420
3485
  def to_h
3421
3486
  result = {}
3422
- result["pos".to_sym] = @pos.to_h
3423
- result["radius".to_sym] = @radius
3487
+
3488
+ result[:"pos"] = @pos.to_h
3489
+ result[:"radius"] = @radius
3490
+
3424
3491
  result
3425
3492
  end
3493
+
3494
+ def as_json(options = {})
3495
+ result = {}
3496
+
3497
+ result["pos"] = @pos.nil? ? {} : @pos.as_json(options) if !options[
3498
+ :compact
3499
+ ] || has_pos?
3500
+ result["radius"] = @radius if !options[:compact] || has_radius?
3501
+
3502
+ result
3503
+ end
3504
+
3505
+ def to_json(as_json_options = {})
3506
+ require "json"
3507
+ JSON.dump(as_json(as_json_options))
3508
+ end
3426
3509
  end
3427
3510
  class PowerSource
3428
3511
  def self.decode(buff)
@@ -3579,7 +3662,7 @@ module Api
3579
3662
 
3580
3663
  unknown_bytes = +"".b
3581
3664
  val = tag
3582
- while val != 0
3665
+ loop do
3583
3666
  byte = val & 0x7F
3584
3667
 
3585
3668
  val >>= 7
@@ -3590,6 +3673,7 @@ module Api
3590
3673
 
3591
3674
  byte |= 0x80 if val != 0
3592
3675
  unknown_bytes << byte
3676
+ break if val == 0
3593
3677
  end
3594
3678
 
3595
3679
  case wire_type
@@ -3664,7 +3748,7 @@ module Api
3664
3748
  end
3665
3749
 
3666
3750
  val = value
3667
- while val != 0
3751
+ loop do
3668
3752
  byte = val & 0x7F
3669
3753
 
3670
3754
  val >>= 7
@@ -3675,6 +3759,7 @@ module Api
3675
3759
 
3676
3760
  byte |= 0x80 if val != 0
3677
3761
  unknown_bytes << byte
3762
+ break if val == 0
3678
3763
  end
3679
3764
 
3680
3765
  unknown_bytes << buff.byteslice(index, value)
@@ -4073,21 +4158,22 @@ module Api
4073
4158
  end
4074
4159
 
4075
4160
  val = @radius
4076
- if val != 0
4161
+ if has_radius?
4077
4162
  buff << 0x15
4078
4163
 
4079
4164
  [val].pack("e", buffer: buff)
4080
4165
  end
4081
4166
 
4082
4167
  val = @tag
4083
- if val != 0
4168
+ if has_tag?
4084
4169
  buff << 0x18
4085
4170
 
4086
- while val != 0
4171
+ loop do
4087
4172
  byte = val & 0x7F
4088
4173
  val >>= 7
4089
4174
  byte |= 0x80 if val > 0
4090
4175
  buff << byte
4176
+ break if val == 0
4091
4177
  end
4092
4178
  end
4093
4179
  buff << @_unknown_fields if @_unknown_fields
@@ -4096,11 +4182,30 @@ module Api
4096
4182
 
4097
4183
  def to_h
4098
4184
  result = {}
4099
- result["pos".to_sym] = @pos.to_h
4100
- result["radius".to_sym] = @radius
4101
- result["tag".to_sym] = @tag
4185
+
4186
+ result[:"pos"] = @pos.to_h
4187
+ result[:"radius"] = @radius
4188
+ result[:"tag"] = @tag
4189
+
4190
+ result
4191
+ end
4192
+
4193
+ def as_json(options = {})
4194
+ result = {}
4195
+
4196
+ result["pos"] = @pos.nil? ? {} : @pos.as_json(options) if !options[
4197
+ :compact
4198
+ ] || has_pos?
4199
+ result["radius"] = @radius if !options[:compact] || has_radius?
4200
+ result["tag"] = @tag if !options[:compact] || has_tag?
4201
+
4102
4202
  result
4103
4203
  end
4204
+
4205
+ def to_json(as_json_options = {})
4206
+ require "json"
4207
+ JSON.dump(as_json(as_json_options))
4208
+ end
4104
4209
  end
4105
4210
  class PlayerRaw
4106
4211
  def self.decode(buff)
@@ -4241,7 +4346,7 @@ module Api
4241
4346
 
4242
4347
  unknown_bytes = +"".b
4243
4348
  val = tag
4244
- while val != 0
4349
+ loop do
4245
4350
  byte = val & 0x7F
4246
4351
 
4247
4352
  val >>= 7
@@ -4252,6 +4357,7 @@ module Api
4252
4357
 
4253
4358
  byte |= 0x80 if val != 0
4254
4359
  unknown_bytes << byte
4360
+ break if val == 0
4255
4361
  end
4256
4362
 
4257
4363
  case wire_type
@@ -4326,7 +4432,7 @@ module Api
4326
4432
  end
4327
4433
 
4328
4434
  val = value
4329
- while val != 0
4435
+ loop do
4330
4436
  byte = val & 0x7F
4331
4437
 
4332
4438
  val >>= 7
@@ -4337,6 +4443,7 @@ module Api
4337
4443
 
4338
4444
  byte |= 0x80 if val != 0
4339
4445
  unknown_bytes << byte
4446
+ break if val == 0
4340
4447
  end
4341
4448
 
4342
4449
  unknown_bytes << buff.byteslice(index, value)
@@ -4886,11 +4993,12 @@ module Api
4886
4993
  if val != 0
4887
4994
  buff << 0x18
4888
4995
 
4889
- while val != 0
4996
+ loop do
4890
4997
  byte = val & 0x7F
4891
4998
  val >>= 7
4892
4999
  byte |= 0x80 if val > 0
4893
5000
  buff << byte
5001
+ break if val == 0
4894
5002
  end
4895
5003
  end
4896
5004
  end
@@ -4901,11 +5009,41 @@ module Api
4901
5009
 
4902
5010
  def to_h
4903
5011
  result = {}
4904
- result["power_sources".to_sym] = @power_sources
4905
- result["camera".to_sym] = @camera.to_h
4906
- result["upgrade_ids".to_sym] = @upgrade_ids
5012
+
5013
+ result[:"power_sources"] = @power_sources.map(&:to_h)
5014
+ result[:"camera"] = @camera.to_h
5015
+ result[:"upgrade_ids"] = @upgrade_ids
5016
+
5017
+ result
5018
+ end
5019
+
5020
+ def as_json(options = {})
5021
+ result = {}
5022
+
5023
+ tmp_power_sources = @power_sources.map { |v| v.as_json(options) }
5024
+
5025
+ result["powerSources"] = tmp_power_sources if !options[:compact] ||
5026
+ tmp_power_sources.any?
5027
+
5028
+ result["camera"] = (
5029
+ if @camera.nil?
5030
+ {}
5031
+ else
5032
+ @camera.as_json(options)
5033
+ end
5034
+ ) if !options[:compact] || has_camera?
5035
+ tmp_upgrade_ids = @upgrade_ids
5036
+
5037
+ result["upgradeIds"] = tmp_upgrade_ids if !options[:compact] ||
5038
+ tmp_upgrade_ids.any?
5039
+
4907
5040
  result
4908
5041
  end
5042
+
5043
+ def to_json(as_json_options = {})
5044
+ require "json"
5045
+ JSON.dump(as_json(as_json_options))
5046
+ end
4909
5047
  end
4910
5048
  class UnitOrder
4911
5049
  def self.decode(buff)
@@ -5097,7 +5235,7 @@ module Api
5097
5235
 
5098
5236
  unknown_bytes = +"".b
5099
5237
  val = tag
5100
- while val != 0
5238
+ loop do
5101
5239
  byte = val & 0x7F
5102
5240
 
5103
5241
  val >>= 7
@@ -5108,6 +5246,7 @@ module Api
5108
5246
 
5109
5247
  byte |= 0x80 if val != 0
5110
5248
  unknown_bytes << byte
5249
+ break if val == 0
5111
5250
  end
5112
5251
 
5113
5252
  case wire_type
@@ -5182,7 +5321,7 @@ module Api
5182
5321
  end
5183
5322
 
5184
5323
  val = value
5185
- while val != 0
5324
+ loop do
5186
5325
  byte = val & 0x7F
5187
5326
 
5188
5327
  val >>= 7
@@ -5193,6 +5332,7 @@ module Api
5193
5332
 
5194
5333
  byte |= 0x80 if val != 0
5195
5334
  unknown_bytes << byte
5335
+ break if val == 0
5196
5336
  end
5197
5337
 
5198
5338
  unknown_bytes << buff.byteslice(index, value)
@@ -5652,14 +5792,15 @@ module Api
5652
5792
  end
5653
5793
  def _encode(buff)
5654
5794
  val = @ability_id
5655
- if val != 0
5795
+ if has_ability_id?
5656
5796
  buff << 0x08
5657
5797
 
5658
- while val != 0
5798
+ loop do
5659
5799
  byte = val & 0x7F
5660
5800
  val >>= 7
5661
5801
  byte |= 0x80 if val > 0
5662
5802
  buff << byte
5803
+ break if val == 0
5663
5804
  end
5664
5805
  end
5665
5806
 
@@ -5715,16 +5856,17 @@ module Api
5715
5856
  if val != 0
5716
5857
  buff << 0x18
5717
5858
 
5718
- while val != 0
5859
+ loop do
5719
5860
  byte = val & 0x7F
5720
5861
  val >>= 7
5721
5862
  byte |= 0x80 if val > 0
5722
5863
  buff << byte
5864
+ break if val == 0
5723
5865
  end
5724
5866
  end
5725
5867
 
5726
5868
  val = @progress
5727
- if val != 0
5869
+ if has_progress?
5728
5870
  buff << 0x25
5729
5871
 
5730
5872
  [val].pack("e", buffer: buff)
@@ -5735,11 +5877,45 @@ module Api
5735
5877
 
5736
5878
  def to_h
5737
5879
  result = {}
5738
- send("target").tap { |f| result[f.to_sym] = send(f) if f }
5739
- result["ability_id".to_sym] = @ability_id
5740
- result["progress".to_sym] = @progress
5880
+
5881
+ resolved_target = self.target
5882
+
5883
+ result[:"ability_id"] = @ability_id
5884
+ result[
5885
+ :"target_world_space_pos"
5886
+ ] = @target_world_space_pos.to_h if resolved_target ==
5887
+ :"target_world_space_pos"
5888
+ result[:"target_unit_tag"] = @target_unit_tag if resolved_target ==
5889
+ :"target_unit_tag"
5890
+ result[:"progress"] = @progress
5891
+
5892
+ result
5893
+ end
5894
+
5895
+ def as_json(options = {})
5896
+ result = {}
5897
+
5898
+ resolved_target = self.target
5899
+
5900
+ result["abilityId"] = @ability_id if !options[:compact] || has_ability_id?
5901
+ result["targetWorldSpacePos"] = (
5902
+ if @target_world_space_pos.nil?
5903
+ {}
5904
+ else
5905
+ @target_world_space_pos.as_json(options)
5906
+ end
5907
+ ) if resolved_target == :"target_world_space_pos"
5908
+ result["targetUnitTag"] = @target_unit_tag if resolved_target ==
5909
+ :"target_unit_tag"
5910
+ result["progress"] = @progress if !options[:compact] || has_progress?
5911
+
5741
5912
  result
5742
5913
  end
5914
+
5915
+ def to_json(as_json_options = {})
5916
+ require "json"
5917
+ JSON.dump(as_json(as_json_options))
5918
+ end
5743
5919
  end
5744
5920
  class PassengerUnit
5745
5921
  def self.decode(buff)
@@ -6009,7 +6185,7 @@ module Api
6009
6185
 
6010
6186
  unknown_bytes = +"".b
6011
6187
  val = tag
6012
- while val != 0
6188
+ loop do
6013
6189
  byte = val & 0x7F
6014
6190
 
6015
6191
  val >>= 7
@@ -6020,6 +6196,7 @@ module Api
6020
6196
 
6021
6197
  byte |= 0x80 if val != 0
6022
6198
  unknown_bytes << byte
6199
+ break if val == 0
6023
6200
  end
6024
6201
 
6025
6202
  case wire_type
@@ -6094,7 +6271,7 @@ module Api
6094
6271
  end
6095
6272
 
6096
6273
  val = value
6097
- while val != 0
6274
+ loop do
6098
6275
  byte = val & 0x7F
6099
6276
 
6100
6277
  val >>= 7
@@ -6105,6 +6282,7 @@ module Api
6105
6282
 
6106
6283
  byte |= 0x80 if val != 0
6107
6284
  unknown_bytes << byte
6285
+ break if val == 0
6108
6286
  end
6109
6287
 
6110
6288
  unknown_bytes << buff.byteslice(index, value)
@@ -6741,68 +6919,70 @@ module Api
6741
6919
  end
6742
6920
  def _encode(buff)
6743
6921
  val = @tag
6744
- if val != 0
6922
+ if has_tag?
6745
6923
  buff << 0x08
6746
6924
 
6747
- while val != 0
6925
+ loop do
6748
6926
  byte = val & 0x7F
6749
6927
  val >>= 7
6750
6928
  byte |= 0x80 if val > 0
6751
6929
  buff << byte
6930
+ break if val == 0
6752
6931
  end
6753
6932
  end
6754
6933
 
6755
6934
  val = @health
6756
- if val != 0
6935
+ if has_health?
6757
6936
  buff << 0x15
6758
6937
 
6759
6938
  [val].pack("e", buffer: buff)
6760
6939
  end
6761
6940
 
6762
6941
  val = @health_max
6763
- if val != 0
6942
+ if has_health_max?
6764
6943
  buff << 0x1d
6765
6944
 
6766
6945
  [val].pack("e", buffer: buff)
6767
6946
  end
6768
6947
 
6769
6948
  val = @shield
6770
- if val != 0
6949
+ if has_shield?
6771
6950
  buff << 0x25
6772
6951
 
6773
6952
  [val].pack("e", buffer: buff)
6774
6953
  end
6775
6954
 
6776
6955
  val = @shield_max
6777
- if val != 0
6956
+ if has_shield_max?
6778
6957
  buff << 0x3d
6779
6958
 
6780
6959
  [val].pack("e", buffer: buff)
6781
6960
  end
6782
6961
 
6783
6962
  val = @energy
6784
- if val != 0
6963
+ if has_energy?
6785
6964
  buff << 0x2d
6786
6965
 
6787
6966
  [val].pack("e", buffer: buff)
6788
6967
  end
6789
6968
 
6790
6969
  val = @energy_max
6791
- if val != 0
6970
+ if has_energy_max?
6792
6971
  buff << 0x45
6793
6972
 
6794
6973
  [val].pack("e", buffer: buff)
6795
6974
  end
6796
6975
 
6797
6976
  val = @unit_type
6798
- if val != 0
6977
+ if has_unit_type?
6799
6978
  buff << 0x30
6800
6979
 
6801
- while val != 0
6980
+ loop do
6802
6981
  byte = val & 0x7F
6803
6982
  val >>= 7
6804
6983
  byte |= 0x80 if val > 0
6805
6984
  buff << byte
6985
+ break if val == 0
6806
6986
  end
6807
6987
  end
6808
6988
  buff << @_unknown_fields if @_unknown_fields
@@ -6811,16 +6991,38 @@ module Api
6811
6991
 
6812
6992
  def to_h
6813
6993
  result = {}
6814
- result["tag".to_sym] = @tag
6815
- result["health".to_sym] = @health
6816
- result["health_max".to_sym] = @health_max
6817
- result["shield".to_sym] = @shield
6818
- result["shield_max".to_sym] = @shield_max
6819
- result["energy".to_sym] = @energy
6820
- result["energy_max".to_sym] = @energy_max
6821
- result["unit_type".to_sym] = @unit_type
6994
+
6995
+ result[:"tag"] = @tag
6996
+ result[:"health"] = @health
6997
+ result[:"health_max"] = @health_max
6998
+ result[:"shield"] = @shield
6999
+ result[:"energy"] = @energy
7000
+ result[:"unit_type"] = @unit_type
7001
+ result[:"shield_max"] = @shield_max
7002
+ result[:"energy_max"] = @energy_max
7003
+
6822
7004
  result
6823
7005
  end
7006
+
7007
+ def as_json(options = {})
7008
+ result = {}
7009
+
7010
+ result["tag"] = @tag if !options[:compact] || has_tag?
7011
+ result["health"] = @health if !options[:compact] || has_health?
7012
+ result["healthMax"] = @health_max if !options[:compact] || has_health_max?
7013
+ result["shield"] = @shield if !options[:compact] || has_shield?
7014
+ result["energy"] = @energy if !options[:compact] || has_energy?
7015
+ result["unitType"] = @unit_type if !options[:compact] || has_unit_type?
7016
+ result["shieldMax"] = @shield_max if !options[:compact] || has_shield_max?
7017
+ result["energyMax"] = @energy_max if !options[:compact] || has_energy_max?
7018
+
7019
+ result
7020
+ end
7021
+
7022
+ def to_json(as_json_options = {})
7023
+ require "json"
7024
+ JSON.dump(as_json(as_json_options))
7025
+ end
6824
7026
  end
6825
7027
  class RallyTarget
6826
7028
  def self.decode(buff)
@@ -6958,7 +7160,7 @@ module Api
6958
7160
 
6959
7161
  unknown_bytes = +"".b
6960
7162
  val = tag
6961
- while val != 0
7163
+ loop do
6962
7164
  byte = val & 0x7F
6963
7165
 
6964
7166
  val >>= 7
@@ -6969,6 +7171,7 @@ module Api
6969
7171
 
6970
7172
  byte |= 0x80 if val != 0
6971
7173
  unknown_bytes << byte
7174
+ break if val == 0
6972
7175
  end
6973
7176
 
6974
7177
  case wire_type
@@ -7043,7 +7246,7 @@ module Api
7043
7246
  end
7044
7247
 
7045
7248
  val = value
7046
- while val != 0
7249
+ loop do
7047
7250
  byte = val & 0x7F
7048
7251
 
7049
7252
  val >>= 7
@@ -7054,6 +7257,7 @@ module Api
7054
7257
 
7055
7258
  byte |= 0x80 if val != 0
7056
7259
  unknown_bytes << byte
7260
+ break if val == 0
7057
7261
  end
7058
7262
 
7059
7263
  unknown_bytes << buff.byteslice(index, value)
@@ -7395,14 +7599,15 @@ module Api
7395
7599
  end
7396
7600
 
7397
7601
  val = @tag
7398
- if val != 0
7602
+ if has_tag?
7399
7603
  buff << 0x10
7400
7604
 
7401
- while val != 0
7605
+ loop do
7402
7606
  byte = val & 0x7F
7403
7607
  val >>= 7
7404
7608
  byte |= 0x80 if val > 0
7405
7609
  buff << byte
7610
+ break if val == 0
7406
7611
  end
7407
7612
  end
7408
7613
  buff << @_unknown_fields if @_unknown_fields
@@ -7411,10 +7616,28 @@ module Api
7411
7616
 
7412
7617
  def to_h
7413
7618
  result = {}
7414
- result["point".to_sym] = @point.to_h
7415
- result["tag".to_sym] = @tag
7619
+
7620
+ result[:"point"] = @point.to_h
7621
+ result[:"tag"] = @tag
7622
+
7416
7623
  result
7417
7624
  end
7625
+
7626
+ def as_json(options = {})
7627
+ result = {}
7628
+
7629
+ result["point"] = @point.nil? ? {} : @point.as_json(options) if !options[
7630
+ :compact
7631
+ ] || has_point?
7632
+ result["tag"] = @tag if !options[:compact] || has_tag?
7633
+
7634
+ result
7635
+ end
7636
+
7637
+ def to_json(as_json_options = {})
7638
+ require "json"
7639
+ JSON.dump(as_json(as_json_options))
7640
+ end
7418
7641
  end
7419
7642
  class Unit
7420
7643
  def self.decode(buff)
@@ -7546,12 +7769,15 @@ module Api
7546
7769
  # enum writers
7547
7770
  def display_type=(v)
7548
7771
  @display_type = Api::DisplayType.resolve(v) || v
7772
+ @_bitmask |= 0x0000000000000001
7549
7773
  end
7550
7774
  def alliance=(v)
7551
7775
  @alliance = Api::Alliance.resolve(v) || v
7776
+ @_bitmask |= 0x0000000000000002
7552
7777
  end
7553
7778
  def cloak=(v)
7554
7779
  @cloak = Api::CloakState.resolve(v) || v
7780
+ @_bitmask |= 0x0000000000000200
7555
7781
  end
7556
7782
 
7557
7783
  # BEGIN writers for optional fields
@@ -8245,6 +8471,14 @@ module Api
8245
8471
  self.class.encode(self)
8246
8472
  end
8247
8473
 
8474
+ def has_display_type?
8475
+ (@_bitmask & 0x0000000000000001) == 0x0000000000000001
8476
+ end
8477
+
8478
+ def has_alliance?
8479
+ (@_bitmask & 0x0000000000000002) == 0x0000000000000002
8480
+ end
8481
+
8248
8482
  def has_tag?
8249
8483
  (@_bitmask & 0x0000000000000004) == 0x0000000000000004
8250
8484
  end
@@ -8273,6 +8507,10 @@ module Api
8273
8507
  (@_bitmask & 0x0000000000000100) == 0x0000000000000100
8274
8508
  end
8275
8509
 
8510
+ def has_cloak?
8511
+ (@_bitmask & 0x0000000000000200) == 0x0000000000000200
8512
+ end
8513
+
8276
8514
  def has_detect_range?
8277
8515
  (@_bitmask & 0x0000000000000400) == 0x0000000000000400
8278
8516
  end
@@ -8503,7 +8741,7 @@ module Api
8503
8741
 
8504
8742
  unknown_bytes = +"".b
8505
8743
  val = tag
8506
- while val != 0
8744
+ loop do
8507
8745
  byte = val & 0x7F
8508
8746
 
8509
8747
  val >>= 7
@@ -8514,6 +8752,7 @@ module Api
8514
8752
 
8515
8753
  byte |= 0x80 if val != 0
8516
8754
  unknown_bytes << byte
8755
+ break if val == 0
8517
8756
  end
8518
8757
 
8519
8758
  case wire_type
@@ -8588,7 +8827,7 @@ module Api
8588
8827
  end
8589
8828
 
8590
8829
  val = value
8591
- while val != 0
8830
+ loop do
8592
8831
  byte = val & 0x7F
8593
8832
 
8594
8833
  val >>= 7
@@ -8599,6 +8838,7 @@ module Api
8599
8838
 
8600
8839
  byte |= 0x80 if val != 0
8601
8840
  unknown_bytes << byte
8841
+ break if val == 0
8602
8842
  end
8603
8843
 
8604
8844
  unknown_bytes << buff.byteslice(index, value)
@@ -12728,10 +12968,10 @@ module Api
12728
12968
  end
12729
12969
  def _encode(buff)
12730
12970
  val = @display_type
12731
- if val != 0
12971
+ if has_display_type?
12732
12972
  buff << 0x08
12733
12973
 
12734
- while val != 0
12974
+ loop do
12735
12975
  byte = val & 0x7F
12736
12976
 
12737
12977
  val >>= 7
@@ -12742,14 +12982,15 @@ module Api
12742
12982
 
12743
12983
  byte |= 0x80 if val != 0
12744
12984
  buff << byte
12985
+ break if val == 0
12745
12986
  end
12746
12987
  end
12747
12988
 
12748
12989
  val = @alliance
12749
- if val != 0
12990
+ if has_alliance?
12750
12991
  buff << 0x10
12751
12992
 
12752
- while val != 0
12993
+ loop do
12753
12994
  byte = val & 0x7F
12754
12995
 
12755
12996
  val >>= 7
@@ -12760,38 +13001,41 @@ module Api
12760
13001
 
12761
13002
  byte |= 0x80 if val != 0
12762
13003
  buff << byte
13004
+ break if val == 0
12763
13005
  end
12764
13006
  end
12765
13007
 
12766
13008
  val = @tag
12767
- if val != 0
13009
+ if has_tag?
12768
13010
  buff << 0x18
12769
13011
 
12770
- while val != 0
13012
+ loop do
12771
13013
  byte = val & 0x7F
12772
13014
  val >>= 7
12773
13015
  byte |= 0x80 if val > 0
12774
13016
  buff << byte
13017
+ break if val == 0
12775
13018
  end
12776
13019
  end
12777
13020
 
12778
13021
  val = @unit_type
12779
- if val != 0
13022
+ if has_unit_type?
12780
13023
  buff << 0x20
12781
13024
 
12782
- while val != 0
13025
+ loop do
12783
13026
  byte = val & 0x7F
12784
13027
  val >>= 7
12785
13028
  byte |= 0x80 if val > 0
12786
13029
  buff << byte
13030
+ break if val == 0
12787
13031
  end
12788
13032
  end
12789
13033
 
12790
13034
  val = @owner
12791
- if val != 0
13035
+ if has_owner?
12792
13036
  buff << 0x28
12793
13037
 
12794
- while val != 0
13038
+ loop do
12795
13039
  byte = val & 0x7F
12796
13040
 
12797
13041
  val >>= 7
@@ -12802,6 +13046,7 @@ module Api
12802
13046
 
12803
13047
  byte |= 0x80 if val != 0
12804
13048
  buff << byte
13049
+ break if val == 0
12805
13050
  end
12806
13051
  end
12807
13052
 
@@ -12854,31 +13099,31 @@ module Api
12854
13099
  end
12855
13100
 
12856
13101
  val = @facing
12857
- if val != 0
13102
+ if has_facing?
12858
13103
  buff << 0x3d
12859
13104
 
12860
13105
  [val].pack("e", buffer: buff)
12861
13106
  end
12862
13107
 
12863
13108
  val = @radius
12864
- if val != 0
13109
+ if has_radius?
12865
13110
  buff << 0x45
12866
13111
 
12867
13112
  [val].pack("e", buffer: buff)
12868
13113
  end
12869
13114
 
12870
13115
  val = @build_progress
12871
- if val != 0
13116
+ if has_build_progress?
12872
13117
  buff << 0x4d
12873
13118
 
12874
13119
  [val].pack("e", buffer: buff)
12875
13120
  end
12876
13121
 
12877
13122
  val = @cloak
12878
- if val != 0
13123
+ if has_cloak?
12879
13124
  buff << 0x50
12880
13125
 
12881
- while val != 0
13126
+ loop do
12882
13127
  byte = val & 0x7F
12883
13128
 
12884
13129
  val >>= 7
@@ -12889,6 +13134,7 @@ module Api
12889
13134
 
12890
13135
  byte |= 0x80 if val != 0
12891
13136
  buff << byte
13137
+ break if val == 0
12892
13138
  end
12893
13139
  end
12894
13140
 
@@ -12900,18 +13146,19 @@ module Api
12900
13146
  buff << 0xd8
12901
13147
  buff << 0x01
12902
13148
 
12903
- while val != 0
13149
+ loop do
12904
13150
  byte = val & 0x7F
12905
13151
  val >>= 7
12906
13152
  byte |= 0x80 if val > 0
12907
13153
  buff << byte
13154
+ break if val == 0
12908
13155
  end
12909
13156
  end
12910
13157
  end
12911
13158
  end
12912
13159
 
12913
13160
  val = @detect_range
12914
- if val != 0
13161
+ if has_detect_range?
12915
13162
  buff << 0xfd
12916
13163
  buff << 0x01
12917
13164
 
@@ -12919,76 +13166,76 @@ module Api
12919
13166
  end
12920
13167
 
12921
13168
  val = @radar_range
12922
- if val != 0
13169
+ if has_radar_range?
12923
13170
  buff << 0x85
12924
13171
  buff << 0x02
12925
13172
 
12926
13173
  [val].pack("e", buffer: buff)
12927
13174
  end
12928
13175
 
12929
- val = @is_selected
12930
- if val == true
13176
+ if has_is_selected?
13177
+ val = @is_selected
12931
13178
  buff << 0x58
12932
13179
 
12933
- buff << 1
12934
- elsif val == false
12935
- # Default value, encode nothing
12936
- else
12937
- raise "bool values should be true or false"
13180
+ if val == true
13181
+ buff << 1
13182
+ elsif val == false
13183
+ buff << 0
13184
+ end
12938
13185
  end
12939
13186
 
12940
- val = @is_on_screen
12941
- if val == true
13187
+ if has_is_on_screen?
13188
+ val = @is_on_screen
12942
13189
  buff << 0x60
12943
13190
 
12944
- buff << 1
12945
- elsif val == false
12946
- # Default value, encode nothing
12947
- else
12948
- raise "bool values should be true or false"
13191
+ if val == true
13192
+ buff << 1
13193
+ elsif val == false
13194
+ buff << 0
13195
+ end
12949
13196
  end
12950
13197
 
12951
- val = @is_blip
12952
- if val == true
13198
+ if has_is_blip?
13199
+ val = @is_blip
12953
13200
  buff << 0x68
12954
13201
 
12955
- buff << 1
12956
- elsif val == false
12957
- # Default value, encode nothing
12958
- else
12959
- raise "bool values should be true or false"
13202
+ if val == true
13203
+ buff << 1
13204
+ elsif val == false
13205
+ buff << 0
13206
+ end
12960
13207
  end
12961
13208
 
12962
- val = @is_powered
12963
- if val == true
13209
+ if has_is_powered?
13210
+ val = @is_powered
12964
13211
  buff << 0x98
12965
13212
  buff << 0x02
12966
13213
 
12967
- buff << 1
12968
- elsif val == false
12969
- # Default value, encode nothing
12970
- else
12971
- raise "bool values should be true or false"
13214
+ if val == true
13215
+ buff << 1
13216
+ elsif val == false
13217
+ buff << 0
13218
+ end
12972
13219
  end
12973
13220
 
12974
- val = @is_active
12975
- if val == true
13221
+ if has_is_active?
13222
+ val = @is_active
12976
13223
  buff << 0xb8
12977
13224
  buff << 0x02
12978
13225
 
12979
- buff << 1
12980
- elsif val == false
12981
- # Default value, encode nothing
12982
- else
12983
- raise "bool values should be true or false"
13226
+ if val == true
13227
+ buff << 1
13228
+ elsif val == false
13229
+ buff << 0
13230
+ end
12984
13231
  end
12985
13232
 
12986
13233
  val = @attack_upgrade_level
12987
- if val != 0
13234
+ if has_attack_upgrade_level?
12988
13235
  buff << 0xc0
12989
13236
  buff << 0x02
12990
13237
 
12991
- while val != 0
13238
+ loop do
12992
13239
  byte = val & 0x7F
12993
13240
 
12994
13241
  val >>= 7
@@ -12999,15 +13246,16 @@ module Api
12999
13246
 
13000
13247
  byte |= 0x80 if val != 0
13001
13248
  buff << byte
13249
+ break if val == 0
13002
13250
  end
13003
13251
  end
13004
13252
 
13005
13253
  val = @armor_upgrade_level
13006
- if val != 0
13254
+ if has_armor_upgrade_level?
13007
13255
  buff << 0xc8
13008
13256
  buff << 0x02
13009
13257
 
13010
- while val != 0
13258
+ loop do
13011
13259
  byte = val & 0x7F
13012
13260
 
13013
13261
  val >>= 7
@@ -13018,15 +13266,16 @@ module Api
13018
13266
 
13019
13267
  byte |= 0x80 if val != 0
13020
13268
  buff << byte
13269
+ break if val == 0
13021
13270
  end
13022
13271
  end
13023
13272
 
13024
13273
  val = @shield_upgrade_level
13025
- if val != 0
13274
+ if has_shield_upgrade_level?
13026
13275
  buff << 0xd0
13027
13276
  buff << 0x02
13028
13277
 
13029
- while val != 0
13278
+ loop do
13030
13279
  byte = val & 0x7F
13031
13280
 
13032
13281
  val >>= 7
@@ -13037,25 +13286,26 @@ module Api
13037
13286
 
13038
13287
  byte |= 0x80 if val != 0
13039
13288
  buff << byte
13289
+ break if val == 0
13040
13290
  end
13041
13291
  end
13042
13292
 
13043
13293
  val = @health
13044
- if val != 0
13294
+ if has_health?
13045
13295
  buff << 0x75
13046
13296
 
13047
13297
  [val].pack("e", buffer: buff)
13048
13298
  end
13049
13299
 
13050
13300
  val = @health_max
13051
- if val != 0
13301
+ if has_health_max?
13052
13302
  buff << 0x7d
13053
13303
 
13054
13304
  [val].pack("e", buffer: buff)
13055
13305
  end
13056
13306
 
13057
13307
  val = @shield
13058
- if val != 0
13308
+ if has_shield?
13059
13309
  buff << 0x85
13060
13310
  buff << 0x01
13061
13311
 
@@ -13063,7 +13313,7 @@ module Api
13063
13313
  end
13064
13314
 
13065
13315
  val = @shield_max
13066
- if val != 0
13316
+ if has_shield_max?
13067
13317
  buff << 0xa5
13068
13318
  buff << 0x02
13069
13319
 
@@ -13071,7 +13321,7 @@ module Api
13071
13321
  end
13072
13322
 
13073
13323
  val = @energy
13074
- if val != 0
13324
+ if has_energy?
13075
13325
  buff << 0x8d
13076
13326
  buff << 0x01
13077
13327
 
@@ -13079,7 +13329,7 @@ module Api
13079
13329
  end
13080
13330
 
13081
13331
  val = @energy_max
13082
- if val != 0
13332
+ if has_energy_max?
13083
13333
  buff << 0xad
13084
13334
  buff << 0x02
13085
13335
 
@@ -13087,11 +13337,11 @@ module Api
13087
13337
  end
13088
13338
 
13089
13339
  val = @mineral_contents
13090
- if val != 0
13340
+ if has_mineral_contents?
13091
13341
  buff << 0x90
13092
13342
  buff << 0x01
13093
13343
 
13094
- while val != 0
13344
+ loop do
13095
13345
  byte = val & 0x7F
13096
13346
 
13097
13347
  val >>= 7
@@ -13102,15 +13352,16 @@ module Api
13102
13352
 
13103
13353
  byte |= 0x80 if val != 0
13104
13354
  buff << byte
13355
+ break if val == 0
13105
13356
  end
13106
13357
  end
13107
13358
 
13108
13359
  val = @vespene_contents
13109
- if val != 0
13360
+ if has_vespene_contents?
13110
13361
  buff << 0x98
13111
13362
  buff << 0x01
13112
13363
 
13113
- while val != 0
13364
+ loop do
13114
13365
  byte = val & 0x7F
13115
13366
 
13116
13367
  val >>= 7
@@ -13121,43 +13372,44 @@ module Api
13121
13372
 
13122
13373
  byte |= 0x80 if val != 0
13123
13374
  buff << byte
13375
+ break if val == 0
13124
13376
  end
13125
13377
  end
13126
13378
 
13127
- val = @is_flying
13128
- if val == true
13379
+ if has_is_flying?
13380
+ val = @is_flying
13129
13381
  buff << 0xa0
13130
13382
  buff << 0x01
13131
13383
 
13132
- buff << 1
13133
- elsif val == false
13134
- # Default value, encode nothing
13135
- else
13136
- raise "bool values should be true or false"
13384
+ if val == true
13385
+ buff << 1
13386
+ elsif val == false
13387
+ buff << 0
13388
+ end
13137
13389
  end
13138
13390
 
13139
- val = @is_burrowed
13140
- if val == true
13391
+ if has_is_burrowed?
13392
+ val = @is_burrowed
13141
13393
  buff << 0xa8
13142
13394
  buff << 0x01
13143
13395
 
13144
- buff << 1
13145
- elsif val == false
13146
- # Default value, encode nothing
13147
- else
13148
- raise "bool values should be true or false"
13396
+ if val == true
13397
+ buff << 1
13398
+ elsif val == false
13399
+ buff << 0
13400
+ end
13149
13401
  end
13150
13402
 
13151
- val = @is_hallucination
13152
- if val == true
13403
+ if has_is_hallucination?
13404
+ val = @is_hallucination
13153
13405
  buff << 0xb0
13154
13406
  buff << 0x02
13155
13407
 
13156
- buff << 1
13157
- elsif val == false
13158
- # Default value, encode nothing
13159
- else
13160
- raise "bool values should be true or false"
13408
+ if val == true
13409
+ buff << 1
13410
+ elsif val == false
13411
+ buff << 0
13412
+ end
13161
13413
  end
13162
13414
 
13163
13415
  list = @orders
@@ -13215,15 +13467,16 @@ module Api
13215
13467
  end
13216
13468
 
13217
13469
  val = @add_on_tag
13218
- if val != 0
13470
+ if has_add_on_tag?
13219
13471
  buff << 0xb8
13220
13472
  buff << 0x01
13221
13473
 
13222
- while val != 0
13474
+ loop do
13223
13475
  byte = val & 0x7F
13224
13476
  val >>= 7
13225
13477
  byte |= 0x80 if val > 0
13226
13478
  buff << byte
13479
+ break if val == 0
13227
13480
  end
13228
13481
  end
13229
13482
 
@@ -13282,11 +13535,11 @@ module Api
13282
13535
  end
13283
13536
 
13284
13537
  val = @cargo_space_taken
13285
- if val != 0
13538
+ if has_cargo_space_taken?
13286
13539
  buff << 0xc8
13287
13540
  buff << 0x01
13288
13541
 
13289
- while val != 0
13542
+ loop do
13290
13543
  byte = val & 0x7F
13291
13544
 
13292
13545
  val >>= 7
@@ -13297,15 +13550,16 @@ module Api
13297
13550
 
13298
13551
  byte |= 0x80 if val != 0
13299
13552
  buff << byte
13553
+ break if val == 0
13300
13554
  end
13301
13555
  end
13302
13556
 
13303
13557
  val = @cargo_space_max
13304
- if val != 0
13558
+ if has_cargo_space_max?
13305
13559
  buff << 0xd0
13306
13560
  buff << 0x01
13307
13561
 
13308
- while val != 0
13562
+ loop do
13309
13563
  byte = val & 0x7F
13310
13564
 
13311
13565
  val >>= 7
@@ -13316,15 +13570,16 @@ module Api
13316
13570
 
13317
13571
  byte |= 0x80 if val != 0
13318
13572
  buff << byte
13573
+ break if val == 0
13319
13574
  end
13320
13575
  end
13321
13576
 
13322
13577
  val = @assigned_harvesters
13323
- if val != 0
13578
+ if has_assigned_harvesters?
13324
13579
  buff << 0xe0
13325
13580
  buff << 0x01
13326
13581
 
13327
- while val != 0
13582
+ loop do
13328
13583
  byte = val & 0x7F
13329
13584
 
13330
13585
  val >>= 7
@@ -13335,15 +13590,16 @@ module Api
13335
13590
 
13336
13591
  byte |= 0x80 if val != 0
13337
13592
  buff << byte
13593
+ break if val == 0
13338
13594
  end
13339
13595
  end
13340
13596
 
13341
13597
  val = @ideal_harvesters
13342
- if val != 0
13598
+ if has_ideal_harvesters?
13343
13599
  buff << 0xe8
13344
13600
  buff << 0x01
13345
13601
 
13346
- while val != 0
13602
+ loop do
13347
13603
  byte = val & 0x7F
13348
13604
 
13349
13605
  val >>= 7
@@ -13354,11 +13610,12 @@ module Api
13354
13610
 
13355
13611
  byte |= 0x80 if val != 0
13356
13612
  buff << byte
13613
+ break if val == 0
13357
13614
  end
13358
13615
  end
13359
13616
 
13360
13617
  val = @weapon_cooldown
13361
- if val != 0
13618
+ if has_weapon_cooldown?
13362
13619
  buff << 0xf5
13363
13620
  buff << 0x01
13364
13621
 
@@ -13366,24 +13623,25 @@ module Api
13366
13623
  end
13367
13624
 
13368
13625
  val = @engaged_target_tag
13369
- if val != 0
13626
+ if has_engaged_target_tag?
13370
13627
  buff << 0x90
13371
13628
  buff << 0x02
13372
13629
 
13373
- while val != 0
13630
+ loop do
13374
13631
  byte = val & 0x7F
13375
13632
  val >>= 7
13376
13633
  byte |= 0x80 if val > 0
13377
13634
  buff << byte
13635
+ break if val == 0
13378
13636
  end
13379
13637
  end
13380
13638
 
13381
13639
  val = @buff_duration_remain
13382
- if val != 0
13640
+ if has_buff_duration_remain?
13383
13641
  buff << 0xd8
13384
13642
  buff << 0x02
13385
13643
 
13386
- while val != 0
13644
+ loop do
13387
13645
  byte = val & 0x7F
13388
13646
 
13389
13647
  val >>= 7
@@ -13394,15 +13652,16 @@ module Api
13394
13652
 
13395
13653
  byte |= 0x80 if val != 0
13396
13654
  buff << byte
13655
+ break if val == 0
13397
13656
  end
13398
13657
  end
13399
13658
 
13400
13659
  val = @buff_duration_max
13401
- if val != 0
13660
+ if has_buff_duration_max?
13402
13661
  buff << 0xe0
13403
13662
  buff << 0x02
13404
13663
 
13405
- while val != 0
13664
+ loop do
13406
13665
  byte = val & 0x7F
13407
13666
 
13408
13667
  val >>= 7
@@ -13413,6 +13672,7 @@ module Api
13413
13672
 
13414
13673
  byte |= 0x80 if val != 0
13415
13674
  buff << byte
13675
+ break if val == 0
13416
13676
  end
13417
13677
  end
13418
13678
 
@@ -13475,52 +13735,152 @@ module Api
13475
13735
 
13476
13736
  def to_h
13477
13737
  result = {}
13478
- result["display_type".to_sym] = @display_type
13479
- result["alliance".to_sym] = @alliance
13480
- result["tag".to_sym] = @tag
13481
- result["unit_type".to_sym] = @unit_type
13482
- result["owner".to_sym] = @owner
13483
- result["pos".to_sym] = @pos.to_h
13484
- result["facing".to_sym] = @facing
13485
- result["radius".to_sym] = @radius
13486
- result["build_progress".to_sym] = @build_progress
13487
- result["cloak".to_sym] = @cloak
13488
- result["buff_ids".to_sym] = @buff_ids
13489
- result["detect_range".to_sym] = @detect_range
13490
- result["radar_range".to_sym] = @radar_range
13491
- result["is_selected".to_sym] = @is_selected
13492
- result["is_on_screen".to_sym] = @is_on_screen
13493
- result["is_blip".to_sym] = @is_blip
13494
- result["is_powered".to_sym] = @is_powered
13495
- result["is_active".to_sym] = @is_active
13496
- result["attack_upgrade_level".to_sym] = @attack_upgrade_level
13497
- result["armor_upgrade_level".to_sym] = @armor_upgrade_level
13498
- result["shield_upgrade_level".to_sym] = @shield_upgrade_level
13499
- result["health".to_sym] = @health
13500
- result["health_max".to_sym] = @health_max
13501
- result["shield".to_sym] = @shield
13502
- result["shield_max".to_sym] = @shield_max
13503
- result["energy".to_sym] = @energy
13504
- result["energy_max".to_sym] = @energy_max
13505
- result["mineral_contents".to_sym] = @mineral_contents
13506
- result["vespene_contents".to_sym] = @vespene_contents
13507
- result["is_flying".to_sym] = @is_flying
13508
- result["is_burrowed".to_sym] = @is_burrowed
13509
- result["is_hallucination".to_sym] = @is_hallucination
13510
- result["orders".to_sym] = @orders
13511
- result["add_on_tag".to_sym] = @add_on_tag
13512
- result["passengers".to_sym] = @passengers
13513
- result["cargo_space_taken".to_sym] = @cargo_space_taken
13514
- result["cargo_space_max".to_sym] = @cargo_space_max
13515
- result["assigned_harvesters".to_sym] = @assigned_harvesters
13516
- result["ideal_harvesters".to_sym] = @ideal_harvesters
13517
- result["weapon_cooldown".to_sym] = @weapon_cooldown
13518
- result["engaged_target_tag".to_sym] = @engaged_target_tag
13519
- result["buff_duration_remain".to_sym] = @buff_duration_remain
13520
- result["buff_duration_max".to_sym] = @buff_duration_max
13521
- result["rally_targets".to_sym] = @rally_targets
13738
+
13739
+ result[:"display_type"] = @display_type
13740
+ result[:"alliance"] = @alliance
13741
+ result[:"tag"] = @tag
13742
+ result[:"unit_type"] = @unit_type
13743
+ result[:"owner"] = @owner
13744
+ result[:"pos"] = @pos.to_h
13745
+ result[:"facing"] = @facing
13746
+ result[:"radius"] = @radius
13747
+ result[:"build_progress"] = @build_progress
13748
+ result[:"cloak"] = @cloak
13749
+ result[:"is_selected"] = @is_selected
13750
+ result[:"is_on_screen"] = @is_on_screen
13751
+ result[:"is_blip"] = @is_blip
13752
+ result[:"health"] = @health
13753
+ result[:"health_max"] = @health_max
13754
+ result[:"shield"] = @shield
13755
+ result[:"energy"] = @energy
13756
+ result[:"mineral_contents"] = @mineral_contents
13757
+ result[:"vespene_contents"] = @vespene_contents
13758
+ result[:"is_flying"] = @is_flying
13759
+ result[:"is_burrowed"] = @is_burrowed
13760
+ result[:"orders"] = @orders.map(&:to_h)
13761
+ result[:"add_on_tag"] = @add_on_tag
13762
+ result[:"passengers"] = @passengers.map(&:to_h)
13763
+ result[:"cargo_space_taken"] = @cargo_space_taken
13764
+ result[:"cargo_space_max"] = @cargo_space_max
13765
+ result[:"buff_ids"] = @buff_ids
13766
+ result[:"assigned_harvesters"] = @assigned_harvesters
13767
+ result[:"ideal_harvesters"] = @ideal_harvesters
13768
+ result[:"weapon_cooldown"] = @weapon_cooldown
13769
+ result[:"detect_range"] = @detect_range
13770
+ result[:"radar_range"] = @radar_range
13771
+ result[:"engaged_target_tag"] = @engaged_target_tag
13772
+ result[:"is_powered"] = @is_powered
13773
+ result[:"shield_max"] = @shield_max
13774
+ result[:"energy_max"] = @energy_max
13775
+ result[:"is_hallucination"] = @is_hallucination
13776
+ result[:"is_active"] = @is_active
13777
+ result[:"attack_upgrade_level"] = @attack_upgrade_level
13778
+ result[:"armor_upgrade_level"] = @armor_upgrade_level
13779
+ result[:"shield_upgrade_level"] = @shield_upgrade_level
13780
+ result[:"buff_duration_remain"] = @buff_duration_remain
13781
+ result[:"buff_duration_max"] = @buff_duration_max
13782
+ result[:"rally_targets"] = @rally_targets.map(&:to_h)
13783
+
13522
13784
  result
13523
13785
  end
13786
+
13787
+ def as_json(options = {})
13788
+ result = {}
13789
+
13790
+ result["displayType"] = @display_type if !options[:compact] ||
13791
+ has_display_type?
13792
+ result["alliance"] = @alliance if !options[:compact] || has_alliance?
13793
+ result["tag"] = @tag if !options[:compact] || has_tag?
13794
+ result["unitType"] = @unit_type if !options[:compact] || has_unit_type?
13795
+ result["owner"] = @owner if !options[:compact] || has_owner?
13796
+ result["pos"] = @pos.nil? ? {} : @pos.as_json(options) if !options[
13797
+ :compact
13798
+ ] || has_pos?
13799
+ result["facing"] = @facing if !options[:compact] || has_facing?
13800
+ result["radius"] = @radius if !options[:compact] || has_radius?
13801
+ result["buildProgress"] = @build_progress if !options[:compact] ||
13802
+ has_build_progress?
13803
+ result["cloak"] = @cloak if !options[:compact] || has_cloak?
13804
+ result["isSelected"] = @is_selected if !options[:compact] ||
13805
+ has_is_selected?
13806
+ result["isOnScreen"] = @is_on_screen if !options[:compact] ||
13807
+ has_is_on_screen?
13808
+ result["isBlip"] = @is_blip if !options[:compact] || has_is_blip?
13809
+ result["health"] = @health if !options[:compact] || has_health?
13810
+ result["healthMax"] = @health_max if !options[:compact] || has_health_max?
13811
+ result["shield"] = @shield if !options[:compact] || has_shield?
13812
+ result["energy"] = @energy if !options[:compact] || has_energy?
13813
+ result["mineralContents"] = @mineral_contents if !options[:compact] ||
13814
+ has_mineral_contents?
13815
+ result["vespeneContents"] = @vespene_contents if !options[:compact] ||
13816
+ has_vespene_contents?
13817
+ result["isFlying"] = @is_flying if !options[:compact] || has_is_flying?
13818
+ result["isBurrowed"] = @is_burrowed if !options[:compact] ||
13819
+ has_is_burrowed?
13820
+ tmp_orders = @orders.map { |v| v.as_json(options) }
13821
+
13822
+ result["orders"] = tmp_orders if !options[:compact] || tmp_orders.any?
13823
+
13824
+ result["addOnTag"] = @add_on_tag if !options[:compact] || has_add_on_tag?
13825
+ tmp_passengers = @passengers.map { |v| v.as_json(options) }
13826
+
13827
+ result["passengers"] = tmp_passengers if !options[:compact] ||
13828
+ tmp_passengers.any?
13829
+
13830
+ result["cargoSpaceTaken"] = @cargo_space_taken if !options[:compact] ||
13831
+ has_cargo_space_taken?
13832
+ result["cargoSpaceMax"] = @cargo_space_max if !options[:compact] ||
13833
+ has_cargo_space_max?
13834
+ tmp_buff_ids = @buff_ids
13835
+
13836
+ result["buffIds"] = tmp_buff_ids if !options[:compact] ||
13837
+ tmp_buff_ids.any?
13838
+
13839
+ result["assignedHarvesters"] = @assigned_harvesters if !options[
13840
+ :compact
13841
+ ] || has_assigned_harvesters?
13842
+ result["idealHarvesters"] = @ideal_harvesters if !options[:compact] ||
13843
+ has_ideal_harvesters?
13844
+ result["weaponCooldown"] = @weapon_cooldown if !options[:compact] ||
13845
+ has_weapon_cooldown?
13846
+ result["detectRange"] = @detect_range if !options[:compact] ||
13847
+ has_detect_range?
13848
+ result["radarRange"] = @radar_range if !options[:compact] ||
13849
+ has_radar_range?
13850
+ result["engagedTargetTag"] = @engaged_target_tag if !options[:compact] ||
13851
+ has_engaged_target_tag?
13852
+ result["isPowered"] = @is_powered if !options[:compact] || has_is_powered?
13853
+ result["shieldMax"] = @shield_max if !options[:compact] || has_shield_max?
13854
+ result["energyMax"] = @energy_max if !options[:compact] || has_energy_max?
13855
+ result["isHallucination"] = @is_hallucination if !options[:compact] ||
13856
+ has_is_hallucination?
13857
+ result["isActive"] = @is_active if !options[:compact] || has_is_active?
13858
+ result["attackUpgradeLevel"] = @attack_upgrade_level if !options[
13859
+ :compact
13860
+ ] || has_attack_upgrade_level?
13861
+ result["armorUpgradeLevel"] = @armor_upgrade_level if !options[
13862
+ :compact
13863
+ ] || has_armor_upgrade_level?
13864
+ result["shieldUpgradeLevel"] = @shield_upgrade_level if !options[
13865
+ :compact
13866
+ ] || has_shield_upgrade_level?
13867
+ result["buffDurationRemain"] = @buff_duration_remain if !options[
13868
+ :compact
13869
+ ] || has_buff_duration_remain?
13870
+ result["buffDurationMax"] = @buff_duration_max if !options[:compact] ||
13871
+ has_buff_duration_max?
13872
+ tmp_rally_targets = @rally_targets.map { |v| v.as_json(options) }
13873
+
13874
+ result["rallyTargets"] = tmp_rally_targets if !options[:compact] ||
13875
+ tmp_rally_targets.any?
13876
+
13877
+ result
13878
+ end
13879
+
13880
+ def to_json(as_json_options = {})
13881
+ require "json"
13882
+ JSON.dump(as_json(as_json_options))
13883
+ end
13524
13884
  end
13525
13885
  class MapState
13526
13886
  def self.decode(buff)
@@ -13649,7 +14009,7 @@ module Api
13649
14009
 
13650
14010
  unknown_bytes = +"".b
13651
14011
  val = tag
13652
- while val != 0
14012
+ loop do
13653
14013
  byte = val & 0x7F
13654
14014
 
13655
14015
  val >>= 7
@@ -13660,6 +14020,7 @@ module Api
13660
14020
 
13661
14021
  byte |= 0x80 if val != 0
13662
14022
  unknown_bytes << byte
14023
+ break if val == 0
13663
14024
  end
13664
14025
 
13665
14026
  case wire_type
@@ -13734,7 +14095,7 @@ module Api
13734
14095
  end
13735
14096
 
13736
14097
  val = value
13737
- while val != 0
14098
+ loop do
13738
14099
  byte = val & 0x7F
13739
14100
 
13740
14101
  val >>= 7
@@ -13745,6 +14106,7 @@ module Api
13745
14106
 
13746
14107
  byte |= 0x80 if val != 0
13747
14108
  unknown_bytes << byte
14109
+ break if val == 0
13748
14110
  end
13749
14111
 
13750
14112
  unknown_bytes << buff.byteslice(index, value)
@@ -14143,10 +14505,34 @@ module Api
14143
14505
 
14144
14506
  def to_h
14145
14507
  result = {}
14146
- result["visibility".to_sym] = @visibility.to_h
14147
- result["creep".to_sym] = @creep.to_h
14508
+
14509
+ result[:"visibility"] = @visibility.to_h
14510
+ result[:"creep"] = @creep.to_h
14511
+
14148
14512
  result
14149
14513
  end
14514
+
14515
+ def as_json(options = {})
14516
+ result = {}
14517
+
14518
+ result["visibility"] = (
14519
+ if @visibility.nil?
14520
+ {}
14521
+ else
14522
+ @visibility.as_json(options)
14523
+ end
14524
+ ) if !options[:compact] || has_visibility?
14525
+ result["creep"] = @creep.nil? ? {} : @creep.as_json(options) if !options[
14526
+ :compact
14527
+ ] || has_creep?
14528
+
14529
+ result
14530
+ end
14531
+
14532
+ def to_json(as_json_options = {})
14533
+ require "json"
14534
+ JSON.dump(as_json(as_json_options))
14535
+ end
14150
14536
  end
14151
14537
  class Event
14152
14538
  def self.decode(buff)
@@ -14250,7 +14636,7 @@ module Api
14250
14636
 
14251
14637
  unknown_bytes = +"".b
14252
14638
  val = tag
14253
- while val != 0
14639
+ loop do
14254
14640
  byte = val & 0x7F
14255
14641
 
14256
14642
  val >>= 7
@@ -14261,6 +14647,7 @@ module Api
14261
14647
 
14262
14648
  byte |= 0x80 if val != 0
14263
14649
  unknown_bytes << byte
14650
+ break if val == 0
14264
14651
  end
14265
14652
 
14266
14653
  case wire_type
@@ -14335,7 +14722,7 @@ module Api
14335
14722
  end
14336
14723
 
14337
14724
  val = value
14338
- while val != 0
14725
+ loop do
14339
14726
  byte = val & 0x7F
14340
14727
 
14341
14728
  val >>= 7
@@ -14346,6 +14733,7 @@ module Api
14346
14733
 
14347
14734
  byte |= 0x80 if val != 0
14348
14735
  unknown_bytes << byte
14736
+ break if val == 0
14349
14737
  end
14350
14738
 
14351
14739
  unknown_bytes << buff.byteslice(index, value)
@@ -14545,11 +14933,12 @@ module Api
14545
14933
  if val != 0
14546
14934
  buff << 0x08
14547
14935
 
14548
- while val != 0
14936
+ loop do
14549
14937
  byte = val & 0x7F
14550
14938
  val >>= 7
14551
14939
  byte |= 0x80 if val > 0
14552
14940
  buff << byte
14941
+ break if val == 0
14553
14942
  end
14554
14943
  end
14555
14944
  end
@@ -14560,9 +14949,27 @@ module Api
14560
14949
 
14561
14950
  def to_h
14562
14951
  result = {}
14563
- result["dead_units".to_sym] = @dead_units
14952
+
14953
+ result[:"dead_units"] = @dead_units
14954
+
14955
+ result
14956
+ end
14957
+
14958
+ def as_json(options = {})
14959
+ result = {}
14960
+
14961
+ tmp_dead_units = @dead_units
14962
+
14963
+ result["deadUnits"] = tmp_dead_units if !options[:compact] ||
14964
+ tmp_dead_units.any?
14965
+
14564
14966
  result
14565
14967
  end
14968
+
14969
+ def to_json(as_json_options = {})
14970
+ require "json"
14971
+ JSON.dump(as_json(as_json_options))
14972
+ end
14566
14973
  end
14567
14974
  class Effect
14568
14975
  def self.decode(buff)
@@ -14595,6 +15002,7 @@ module Api
14595
15002
  # enum writers
14596
15003
  def alliance=(v)
14597
15004
  @alliance = Api::Alliance.resolve(v) || v
15005
+ @_bitmask |= 0x0000000000000002
14598
15006
  end
14599
15007
 
14600
15008
  # BEGIN writers for optional fields
@@ -14681,6 +15089,10 @@ module Api
14681
15089
  (@_bitmask & 0x0000000000000001) == 0x0000000000000001
14682
15090
  end
14683
15091
 
15092
+ def has_alliance?
15093
+ (@_bitmask & 0x0000000000000002) == 0x0000000000000002
15094
+ end
15095
+
14684
15096
  def has_owner?
14685
15097
  (@_bitmask & 0x0000000000000004) == 0x0000000000000004
14686
15098
  end
@@ -14760,7 +15172,7 @@ module Api
14760
15172
 
14761
15173
  unknown_bytes = +"".b
14762
15174
  val = tag
14763
- while val != 0
15175
+ loop do
14764
15176
  byte = val & 0x7F
14765
15177
 
14766
15178
  val >>= 7
@@ -14771,6 +15183,7 @@ module Api
14771
15183
 
14772
15184
  byte |= 0x80 if val != 0
14773
15185
  unknown_bytes << byte
15186
+ break if val == 0
14774
15187
  end
14775
15188
 
14776
15189
  case wire_type
@@ -14845,7 +15258,7 @@ module Api
14845
15258
  end
14846
15259
 
14847
15260
  val = value
14848
- while val != 0
15261
+ loop do
14849
15262
  byte = val & 0x7F
14850
15263
 
14851
15264
  val >>= 7
@@ -14856,6 +15269,7 @@ module Api
14856
15269
 
14857
15270
  byte |= 0x80 if val != 0
14858
15271
  unknown_bytes << byte
15272
+ break if val == 0
14859
15273
  end
14860
15274
 
14861
15275
  unknown_bytes << buff.byteslice(index, value)
@@ -15470,14 +15884,15 @@ module Api
15470
15884
  end
15471
15885
  def _encode(buff)
15472
15886
  val = @effect_id
15473
- if val != 0
15887
+ if has_effect_id?
15474
15888
  buff << 0x08
15475
15889
 
15476
- while val != 0
15890
+ loop do
15477
15891
  byte = val & 0x7F
15478
15892
  val >>= 7
15479
15893
  byte |= 0x80 if val > 0
15480
15894
  buff << byte
15895
+ break if val == 0
15481
15896
  end
15482
15897
  end
15483
15898
 
@@ -15535,10 +15950,10 @@ module Api
15535
15950
  end
15536
15951
 
15537
15952
  val = @alliance
15538
- if val != 0
15953
+ if has_alliance?
15539
15954
  buff << 0x18
15540
15955
 
15541
- while val != 0
15956
+ loop do
15542
15957
  byte = val & 0x7F
15543
15958
 
15544
15959
  val >>= 7
@@ -15549,14 +15964,15 @@ module Api
15549
15964
 
15550
15965
  byte |= 0x80 if val != 0
15551
15966
  buff << byte
15967
+ break if val == 0
15552
15968
  end
15553
15969
  end
15554
15970
 
15555
15971
  val = @owner
15556
- if val != 0
15972
+ if has_owner?
15557
15973
  buff << 0x20
15558
15974
 
15559
- while val != 0
15975
+ loop do
15560
15976
  byte = val & 0x7F
15561
15977
 
15562
15978
  val >>= 7
@@ -15567,11 +15983,12 @@ module Api
15567
15983
 
15568
15984
  byte |= 0x80 if val != 0
15569
15985
  buff << byte
15986
+ break if val == 0
15570
15987
  end
15571
15988
  end
15572
15989
 
15573
15990
  val = @radius
15574
- if val != 0
15991
+ if has_radius?
15575
15992
  buff << 0x2d
15576
15993
 
15577
15994
  [val].pack("e", buffer: buff)
@@ -15582,13 +15999,35 @@ module Api
15582
15999
 
15583
16000
  def to_h
15584
16001
  result = {}
15585
- result["effect_id".to_sym] = @effect_id
15586
- result["pos".to_sym] = @pos
15587
- result["alliance".to_sym] = @alliance
15588
- result["owner".to_sym] = @owner
15589
- result["radius".to_sym] = @radius
16002
+
16003
+ result[:"effect_id"] = @effect_id
16004
+ result[:"pos"] = @pos.map(&:to_h)
16005
+ result[:"alliance"] = @alliance
16006
+ result[:"owner"] = @owner
16007
+ result[:"radius"] = @radius
16008
+
15590
16009
  result
15591
16010
  end
16011
+
16012
+ def as_json(options = {})
16013
+ result = {}
16014
+
16015
+ result["effectId"] = @effect_id if !options[:compact] || has_effect_id?
16016
+ tmp_pos = @pos.map { |v| v.as_json(options) }
16017
+
16018
+ result["pos"] = tmp_pos if !options[:compact] || tmp_pos.any?
16019
+
16020
+ result["alliance"] = @alliance if !options[:compact] || has_alliance?
16021
+ result["owner"] = @owner if !options[:compact] || has_owner?
16022
+ result["radius"] = @radius if !options[:compact] || has_radius?
16023
+
16024
+ result
16025
+ end
16026
+
16027
+ def to_json(as_json_options = {})
16028
+ require "json"
16029
+ JSON.dump(as_json(as_json_options))
16030
+ end
15592
16031
  end
15593
16032
  class ActionRaw
15594
16033
  def self.decode(buff)
@@ -15723,7 +16162,7 @@ module Api
15723
16162
 
15724
16163
  unknown_bytes = +"".b
15725
16164
  val = tag
15726
- while val != 0
16165
+ loop do
15727
16166
  byte = val & 0x7F
15728
16167
 
15729
16168
  val >>= 7
@@ -15734,6 +16173,7 @@ module Api
15734
16173
 
15735
16174
  byte |= 0x80 if val != 0
15736
16175
  unknown_bytes << byte
16176
+ break if val == 0
15737
16177
  end
15738
16178
 
15739
16179
  case wire_type
@@ -15808,7 +16248,7 @@ module Api
15808
16248
  end
15809
16249
 
15810
16250
  val = value
15811
- while val != 0
16251
+ loop do
15812
16252
  byte = val & 0x7F
15813
16253
 
15814
16254
  val >>= 7
@@ -15819,6 +16259,7 @@ module Api
15819
16259
 
15820
16260
  byte |= 0x80 if val != 0
15821
16261
  unknown_bytes << byte
16262
+ break if val == 0
15822
16263
  end
15823
16264
 
15824
16265
  unknown_bytes << buff.byteslice(index, value)
@@ -16390,9 +16831,53 @@ module Api
16390
16831
 
16391
16832
  def to_h
16392
16833
  result = {}
16393
- send("action").tap { |f| result[f.to_sym] = send(f) if f }
16834
+
16835
+ resolved_action = self.action
16836
+
16837
+ result[:"unit_command"] = @unit_command.to_h if resolved_action ==
16838
+ :"unit_command"
16839
+ result[:"camera_move"] = @camera_move.to_h if resolved_action ==
16840
+ :"camera_move"
16841
+ result[:"toggle_autocast"] = @toggle_autocast.to_h if resolved_action ==
16842
+ :"toggle_autocast"
16843
+
16844
+ result
16845
+ end
16846
+
16847
+ def as_json(options = {})
16848
+ result = {}
16849
+
16850
+ resolved_action = self.action
16851
+
16852
+ result["unitCommand"] = (
16853
+ if @unit_command.nil?
16854
+ {}
16855
+ else
16856
+ @unit_command.as_json(options)
16857
+ end
16858
+ ) if resolved_action == :"unit_command"
16859
+ result["cameraMove"] = (
16860
+ if @camera_move.nil?
16861
+ {}
16862
+ else
16863
+ @camera_move.as_json(options)
16864
+ end
16865
+ ) if resolved_action == :"camera_move"
16866
+ result["toggleAutocast"] = (
16867
+ if @toggle_autocast.nil?
16868
+ {}
16869
+ else
16870
+ @toggle_autocast.as_json(options)
16871
+ end
16872
+ ) if resolved_action == :"toggle_autocast"
16873
+
16394
16874
  result
16395
16875
  end
16876
+
16877
+ def to_json(as_json_options = {})
16878
+ require "json"
16879
+ JSON.dump(as_json(as_json_options))
16880
+ end
16396
16881
  end
16397
16882
  class ActionRawUnitCommand
16398
16883
  def self.decode(buff)
@@ -16607,7 +17092,7 @@ module Api
16607
17092
 
16608
17093
  unknown_bytes = +"".b
16609
17094
  val = tag
16610
- while val != 0
17095
+ loop do
16611
17096
  byte = val & 0x7F
16612
17097
 
16613
17098
  val >>= 7
@@ -16618,6 +17103,7 @@ module Api
16618
17103
 
16619
17104
  byte |= 0x80 if val != 0
16620
17105
  unknown_bytes << byte
17106
+ break if val == 0
16621
17107
  end
16622
17108
 
16623
17109
  case wire_type
@@ -16692,7 +17178,7 @@ module Api
16692
17178
  end
16693
17179
 
16694
17180
  val = value
16695
- while val != 0
17181
+ loop do
16696
17182
  byte = val & 0x7F
16697
17183
 
16698
17184
  val >>= 7
@@ -16703,6 +17189,7 @@ module Api
16703
17189
 
16704
17190
  byte |= 0x80 if val != 0
16705
17191
  unknown_bytes << byte
17192
+ break if val == 0
16706
17193
  end
16707
17194
 
16708
17195
  unknown_bytes << buff.byteslice(index, value)
@@ -17298,10 +17785,10 @@ module Api
17298
17785
  end
17299
17786
  def _encode(buff)
17300
17787
  val = @ability_id
17301
- if val != 0
17788
+ if has_ability_id?
17302
17789
  buff << 0x08
17303
17790
 
17304
- while val != 0
17791
+ loop do
17305
17792
  byte = val & 0x7F
17306
17793
 
17307
17794
  val >>= 7
@@ -17312,6 +17799,7 @@ module Api
17312
17799
 
17313
17800
  byte |= 0x80 if val != 0
17314
17801
  buff << byte
17802
+ break if val == 0
17315
17803
  end
17316
17804
  end
17317
17805
 
@@ -17367,11 +17855,12 @@ module Api
17367
17855
  if val != 0
17368
17856
  buff << 0x18
17369
17857
 
17370
- while val != 0
17858
+ loop do
17371
17859
  byte = val & 0x7F
17372
17860
  val >>= 7
17373
17861
  byte |= 0x80 if val > 0
17374
17862
  buff << byte
17863
+ break if val == 0
17375
17864
  end
17376
17865
  end
17377
17866
 
@@ -17382,25 +17871,26 @@ module Api
17382
17871
  if val != 0
17383
17872
  buff << 0x20
17384
17873
 
17385
- while val != 0
17874
+ loop do
17386
17875
  byte = val & 0x7F
17387
17876
  val >>= 7
17388
17877
  byte |= 0x80 if val > 0
17389
17878
  buff << byte
17879
+ break if val == 0
17390
17880
  end
17391
17881
  end
17392
17882
  end
17393
17883
  end
17394
17884
 
17395
- val = @queue_command
17396
- if val == true
17885
+ if has_queue_command?
17886
+ val = @queue_command
17397
17887
  buff << 0x28
17398
17888
 
17399
- buff << 1
17400
- elsif val == false
17401
- # Default value, encode nothing
17402
- else
17403
- raise "bool values should be true or false"
17889
+ if val == true
17890
+ buff << 1
17891
+ elsif val == false
17892
+ buff << 0
17893
+ end
17404
17894
  end
17405
17895
  buff << @_unknown_fields if @_unknown_fields
17406
17896
  buff
@@ -17408,12 +17898,52 @@ module Api
17408
17898
 
17409
17899
  def to_h
17410
17900
  result = {}
17411
- send("target").tap { |f| result[f.to_sym] = send(f) if f }
17412
- result["ability_id".to_sym] = @ability_id
17413
- result["unit_tags".to_sym] = @unit_tags
17414
- result["queue_command".to_sym] = @queue_command
17901
+
17902
+ resolved_target = self.target
17903
+
17904
+ result[:"ability_id"] = @ability_id
17905
+ result[
17906
+ :"target_world_space_pos"
17907
+ ] = @target_world_space_pos.to_h if resolved_target ==
17908
+ :"target_world_space_pos"
17909
+ result[:"target_unit_tag"] = @target_unit_tag if resolved_target ==
17910
+ :"target_unit_tag"
17911
+ result[:"unit_tags"] = @unit_tags
17912
+ result[:"queue_command"] = @queue_command
17913
+
17415
17914
  result
17416
17915
  end
17916
+
17917
+ def as_json(options = {})
17918
+ result = {}
17919
+
17920
+ resolved_target = self.target
17921
+
17922
+ result["abilityId"] = @ability_id if !options[:compact] || has_ability_id?
17923
+ result["targetWorldSpacePos"] = (
17924
+ if @target_world_space_pos.nil?
17925
+ {}
17926
+ else
17927
+ @target_world_space_pos.as_json(options)
17928
+ end
17929
+ ) if resolved_target == :"target_world_space_pos"
17930
+ result["targetUnitTag"] = @target_unit_tag if resolved_target ==
17931
+ :"target_unit_tag"
17932
+ tmp_unit_tags = @unit_tags
17933
+
17934
+ result["unitTags"] = tmp_unit_tags if !options[:compact] ||
17935
+ tmp_unit_tags.any?
17936
+
17937
+ result["queueCommand"] = @queue_command if !options[:compact] ||
17938
+ has_queue_command?
17939
+
17940
+ result
17941
+ end
17942
+
17943
+ def to_json(as_json_options = {})
17944
+ require "json"
17945
+ JSON.dump(as_json(as_json_options))
17946
+ end
17417
17947
  end
17418
17948
  class ActionRawCameraMove
17419
17949
  def self.decode(buff)
@@ -17523,7 +18053,7 @@ module Api
17523
18053
 
17524
18054
  unknown_bytes = +"".b
17525
18055
  val = tag
17526
- while val != 0
18056
+ loop do
17527
18057
  byte = val & 0x7F
17528
18058
 
17529
18059
  val >>= 7
@@ -17534,6 +18064,7 @@ module Api
17534
18064
 
17535
18065
  byte |= 0x80 if val != 0
17536
18066
  unknown_bytes << byte
18067
+ break if val == 0
17537
18068
  end
17538
18069
 
17539
18070
  case wire_type
@@ -17608,7 +18139,7 @@ module Api
17608
18139
  end
17609
18140
 
17610
18141
  val = value
17611
- while val != 0
18142
+ loop do
17612
18143
  byte = val & 0x7F
17613
18144
 
17614
18145
  val >>= 7
@@ -17619,6 +18150,7 @@ module Api
17619
18150
 
17620
18151
  byte |= 0x80 if val != 0
17621
18152
  unknown_bytes << byte
18153
+ break if val == 0
17622
18154
  end
17623
18155
 
17624
18156
  unknown_bytes << buff.byteslice(index, value)
@@ -17856,9 +18388,30 @@ module Api
17856
18388
 
17857
18389
  def to_h
17858
18390
  result = {}
17859
- result["center_world_space".to_sym] = @center_world_space.to_h
18391
+
18392
+ result[:"center_world_space"] = @center_world_space.to_h
18393
+
17860
18394
  result
17861
18395
  end
18396
+
18397
+ def as_json(options = {})
18398
+ result = {}
18399
+
18400
+ result["centerWorldSpace"] = (
18401
+ if @center_world_space.nil?
18402
+ {}
18403
+ else
18404
+ @center_world_space.as_json(options)
18405
+ end
18406
+ ) if !options[:compact] || has_center_world_space?
18407
+
18408
+ result
18409
+ end
18410
+
18411
+ def to_json(as_json_options = {})
18412
+ require "json"
18413
+ JSON.dump(as_json(as_json_options))
18414
+ end
17862
18415
  end
17863
18416
  class ActionRawToggleAutocast
17864
18417
  def self.decode(buff)
@@ -17999,7 +18552,7 @@ module Api
17999
18552
 
18000
18553
  unknown_bytes = +"".b
18001
18554
  val = tag
18002
- while val != 0
18555
+ loop do
18003
18556
  byte = val & 0x7F
18004
18557
 
18005
18558
  val >>= 7
@@ -18010,6 +18563,7 @@ module Api
18010
18563
 
18011
18564
  byte |= 0x80 if val != 0
18012
18565
  unknown_bytes << byte
18566
+ break if val == 0
18013
18567
  end
18014
18568
 
18015
18569
  case wire_type
@@ -18084,7 +18638,7 @@ module Api
18084
18638
  end
18085
18639
 
18086
18640
  val = value
18087
- while val != 0
18641
+ loop do
18088
18642
  byte = val & 0x7F
18089
18643
 
18090
18644
  val >>= 7
@@ -18095,6 +18649,7 @@ module Api
18095
18649
 
18096
18650
  byte |= 0x80 if val != 0
18097
18651
  unknown_bytes << byte
18652
+ break if val == 0
18098
18653
  end
18099
18654
 
18100
18655
  unknown_bytes << buff.byteslice(index, value)
@@ -18408,10 +18963,10 @@ module Api
18408
18963
  end
18409
18964
  def _encode(buff)
18410
18965
  val = @ability_id
18411
- if val != 0
18966
+ if has_ability_id?
18412
18967
  buff << 0x08
18413
18968
 
18414
- while val != 0
18969
+ loop do
18415
18970
  byte = val & 0x7F
18416
18971
 
18417
18972
  val >>= 7
@@ -18422,6 +18977,7 @@ module Api
18422
18977
 
18423
18978
  byte |= 0x80 if val != 0
18424
18979
  buff << byte
18980
+ break if val == 0
18425
18981
  end
18426
18982
  end
18427
18983
 
@@ -18432,11 +18988,12 @@ module Api
18432
18988
  if val != 0
18433
18989
  buff << 0x10
18434
18990
 
18435
- while val != 0
18991
+ loop do
18436
18992
  byte = val & 0x7F
18437
18993
  val >>= 7
18438
18994
  byte |= 0x80 if val > 0
18439
18995
  buff << byte
18996
+ break if val == 0
18440
18997
  end
18441
18998
  end
18442
18999
  end
@@ -18447,9 +19004,28 @@ module Api
18447
19004
 
18448
19005
  def to_h
18449
19006
  result = {}
18450
- result["ability_id".to_sym] = @ability_id
18451
- result["unit_tags".to_sym] = @unit_tags
19007
+
19008
+ result[:"ability_id"] = @ability_id
19009
+ result[:"unit_tags"] = @unit_tags
19010
+
19011
+ result
19012
+ end
19013
+
19014
+ def as_json(options = {})
19015
+ result = {}
19016
+
19017
+ result["abilityId"] = @ability_id if !options[:compact] || has_ability_id?
19018
+ tmp_unit_tags = @unit_tags
19019
+
19020
+ result["unitTags"] = tmp_unit_tags if !options[:compact] ||
19021
+ tmp_unit_tags.any?
19022
+
18452
19023
  result
18453
19024
  end
19025
+
19026
+ def to_json(as_json_options = {})
19027
+ require "json"
19028
+ JSON.dump(as_json(as_json_options))
19029
+ end
18454
19030
  end
18455
19031
  end