30 lines
948 B
GDScript
30 lines
948 B
GDScript
class_name FighterReplicationState
|
|||
|
|
extends Node
|
||
|
|
|
||
|
|
@export var position: Vector3 = Vector3.ZERO
|
||
|
|
@export var velocity: Vector3 = Vector3.ZERO
|
||
|
|
@export var yaw: float = 0.0
|
||
|
|
@export var pitch: float = 0.0
|
||
|
|
@export var shot_serial: int = 0
|
||
|
|
@export var weapon: int = 0
|
||
|
|
@export var life: int = 0
|
||
|
|
|
||
|
|
func _init() -> void: name = "ReplicationState"
|
||
|
|
func capture(fighter: Fighter) -> void:
|
||
|
|
position = fighter.global_position
|
||
|
|
velocity = fighter.velocity
|
||
|
|
yaw = fighter.yaw
|
||
|
|
pitch = fighter.pitch
|
||
|
|
shot_serial = fighter.shot_serial
|
||
|
|
weapon = fighter.weapon
|
||
|
|
life = fighter.life
|
||
|
|
|
||
|
|
func configuration() -> SceneReplicationConfig:
|
||
|
|
var config := SceneReplicationConfig.new()
|
||
|
|
for field in ["position","velocity","yaw","pitch","shot_serial","weapon","life"]:
|
||
|
|
var path := NodePath(".:"+field)
|
||
|
|
config.add_property(path)
|
||
|
|
config.property_set_spawn(path,true)
|
||
|
|
config.property_set_replication_mode(path,SceneReplicationConfig.REPLICATION_MODE_ALWAYS)
|
||
|
|
return config
|