From e2f3e4bd7118c8f55d20b29d76cb9a13acf72f8b Mon Sep 17 00:00:00 2001 From: Anson Bridges Date: Thu, 8 Sep 2022 16:42:07 -0400 Subject: gdnative testing. gdnative classes cannot be extended by gdscript --- godot/scripts/machines/Cannon.gd | 2 +- godot/scripts/machines/NetworkedMachine.gd | 54 --------------------------- godot/scripts/machines/NetworkedMachineGDS.gd | 54 +++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 55 deletions(-) delete mode 100644 godot/scripts/machines/NetworkedMachine.gd create mode 100644 godot/scripts/machines/NetworkedMachineGDS.gd (limited to 'godot/scripts/machines') diff --git a/godot/scripts/machines/Cannon.gd b/godot/scripts/machines/Cannon.gd index 6b636c5..15807bf 100644 --- a/godot/scripts/machines/Cannon.gd +++ b/godot/scripts/machines/Cannon.gd @@ -1,4 +1,4 @@ -extends "res://scripts/machines/NetworkedMachine.gd" +extends "res://bin/networked_machine.gdns" var world_ballistics = null diff --git a/godot/scripts/machines/NetworkedMachine.gd b/godot/scripts/machines/NetworkedMachine.gd deleted file mode 100644 index 5ce5cbe..0000000 --- a/godot/scripts/machines/NetworkedMachine.gd +++ /dev/null @@ -1,54 +0,0 @@ -extends RigidBody - -var in_use : bool = false -var user = null -var world = null - -func _ready(): - world = get_tree().get_root().find_node("GAMEWORLD", true, false) - -remote func update_phys_transform(t, lv, av): - transform = t - linear_velocity = lv - angular_velocity = av - -remotesync func net_apply_impulse(impulse_v): - apply_central_impulse(impulse_v) - -func _integrate_forces(_state): - if is_network_master() and mode == MODE_RIGID: - rpc("update_phys_transform", transform, linear_velocity, angular_velocity) - -remotesync func set_net_owner(id, char_name): - set_network_master(id) - if id == 1 and char_name == "NONE": #not under control - on_no_control() - if user != null: - user.lose_machine() - user = null - in_use = false - else: - in_use = true - user = world.get_node("PLAYERS/"+char_name) - user.take_control_of_machine(self) - if is_network_master(): - on_new_control() - -func relinquish_control(): - rpc("set_net_owner", 1, "NONE") - -#TO BE OVERRIDDEN BY CHILDREN -func on_new_control(): - pass - -func on_no_control(): - pass - -func attack1(): - pass - -func attack2(): - pass - -func direction_input(_fwd,_bwd,_left,_right,_left2,_right2): - pass diff --git a/godot/scripts/machines/NetworkedMachineGDS.gd b/godot/scripts/machines/NetworkedMachineGDS.gd new file mode 100644 index 0000000..5ce5cbe --- /dev/null +++ b/godot/scripts/machines/NetworkedMachineGDS.gd @@ -0,0 +1,54 @@ +extends RigidBody + +var in_use : bool = false +var user = null +var world = null + +func _ready(): + world = get_tree().get_root().find_node("GAMEWORLD", true, false) + +remote func update_phys_transform(t, lv, av): + transform = t + linear_velocity = lv + angular_velocity = av + +remotesync func net_apply_impulse(impulse_v): + apply_central_impulse(impulse_v) + +func _integrate_forces(_state): + if is_network_master() and mode == MODE_RIGID: + rpc("update_phys_transform", transform, linear_velocity, angular_velocity) + +remotesync func set_net_owner(id, char_name): + set_network_master(id) + if id == 1 and char_name == "NONE": #not under control + on_no_control() + if user != null: + user.lose_machine() + user = null + in_use = false + else: + in_use = true + user = world.get_node("PLAYERS/"+char_name) + user.take_control_of_machine(self) + if is_network_master(): + on_new_control() + +func relinquish_control(): + rpc("set_net_owner", 1, "NONE") + +#TO BE OVERRIDDEN BY CHILDREN +func on_new_control(): + pass + +func on_no_control(): + pass + +func attack1(): + pass + +func attack2(): + pass + +func direction_input(_fwd,_bwd,_left,_right,_left2,_right2): + pass -- cgit v1.2.3