summaryrefslogtreecommitdiff
path: root/packets/item_option.gd
blob: 9a226db91edfaa731a8da9eb9680c775565c4da4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class_name ItemOption
extends PacketChunk


const BYTE_LENGTH := 5


## Byte Type: u16
## Byte Length: 2
var index: int

## Byte Type: u16
## Byte Length: 2
var value: int

## Byte Type: u8
## Byte Length: 1
var parameter: int


static func from_bytes(bytes: ByteStream):
	var option = ItemOption.new()
	
	option.index = bytes.decode_u16()
	option.value = bytes.decode_u16()
	option.parameter = bytes.decode_u8()
	
	return option


static func array_from_bytes(bytes: ByteStream) -> Array[ItemOption]:
	var array: Array[ItemOption] = []
	
	while bytes.available():
		var chunk = from_bytes(bytes)
		array.append(chunk)
	
	return array