mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-05 22:25:49 +00:00
ref[protocol]: use strict syntax to refactor GdScript generation
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const ProtocolManager = preload("res://zfoogd/ProtocolManager.gd")
|
||||
const ProtocolManager = preload("./ProtocolManager.gd")
|
||||
|
||||
const EMPTY: String = ""
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ ${protocol_field_definition}
|
||||
func protocolId() -> int:
|
||||
return ${protocol_id}
|
||||
|
||||
func get_class_name() -> String:
|
||||
return "${protocol_name}"
|
||||
|
||||
func _to_string() -> String:
|
||||
const jsonTemplate = "${protocol_json}"
|
||||
var params = [${protocol_to_string}]
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
class ${protocol_name}Registration:
|
||||
func write(buffer: ByteBuffer, packet: Object):
|
||||
func write(buffer: ByteBuffer, packet: ${protocol_name}):
|
||||
if (packet == null):
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
${protocol_write_serialization}
|
||||
pass
|
||||
|
||||
func read(buffer: ByteBuffer):
|
||||
func read(buffer: ByteBuffer) -> ${protocol_name}:
|
||||
var length = buffer.readInt()
|
||||
if (length == 0):
|
||||
return null
|
||||
var beforeReadIndex = buffer.getReadOffset()
|
||||
var packet = buffer.newInstance(${protocol_id})
|
||||
var packet: ${protocol_name} = buffer.newInstance(${protocol_id})
|
||||
${protocol_read_deserialization}
|
||||
if (length > 0):
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
class_name ${protocol_name}
|
||||
|
||||
${protocol_imports}
|
||||
|
||||
${protocol_class}
|
||||
|
||||
Reference in New Issue
Block a user