From de902271df9b343902117ef1efba3051794a91d6 Mon Sep 17 00:00:00 2001 From: anyreso Date: Sun, 12 May 2024 17:18:09 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20multiplayer=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/explosive_damage_component.gd | 2 +- entities/components/health_component.gd | 4 +- entities/components/match_participant.gd | 20 +++ .../components/match_participant_component.gd | 25 ---- entities/components/projectile_spawner.gd | 2 +- .../{player_input.gd => inputs_sync.gd} | 14 +- entities/player/player.gd | 16 +-- entities/player/player.tscn | 122 +++++++++--------- entities/weapons/chaingun/chaingun.gd | 2 +- entities/weapons/chaingun/projectile.gd | 4 +- .../weapons/grenade_launcher/explosion.gd | 4 +- .../grenade_launcher/grenade_launcher.gd | 2 +- .../weapons/grenade_launcher/projectile.gd | 4 +- entities/weapons/space_gun/projectile.gd | 4 +- .../weapons/space_gun/projectile_explosion.gd | 4 +- entities/weapons/space_gun/space_gun.gd | 2 +- .../progress_bar/resources/visual_shader.res | Bin 5794 -> 5786 bytes interfaces/scoreboard/scoreboard.gd | 8 +- interfaces/scoreboard/scoreboard.tscn | 5 + .../deathmatch_scoring_component.gd | 6 +- maps/components/rabbit_scoring_component.gd | 10 +- modes/multiplayer/multiplayer.gd | 10 +- modes/singleplayer/demo.gd | 2 +- tests/test_deathmatch_scoring_component.gd | 10 +- tests/test_health_component.gd | 6 +- tests/test_scoreboard.gd | 6 +- 26 files changed, 147 insertions(+), 147 deletions(-) create mode 100644 entities/components/match_participant.gd delete mode 100644 entities/components/match_participant_component.gd rename entities/player/{player_input.gd => inputs_sync.gd} (90%) diff --git a/entities/components/explosive_damage_component.gd b/entities/components/explosive_damage_component.gd index 7830027..ba2b452 100644 --- a/entities/components/explosive_damage_component.gd +++ b/entities/components/explosive_damage_component.gd @@ -19,7 +19,7 @@ signal finished @export var damage : float = .35 @export var impulse_force : int = 1000 -var damage_dealer : MatchParticipantComponent +var damage_dealer : MatchParticipant var _damaged_objects : Dictionary= { "bodies": [], diff --git a/entities/components/health_component.gd b/entities/components/health_component.gd index b2d94eb..f35f5e4 100644 --- a/entities/components/health_component.gd +++ b/entities/components/health_component.gd @@ -19,7 +19,7 @@ class_name HealthComponent extends Area3D set(value): health = value health_changed.emit(value) -@export var match_participant_component : MatchParticipantComponent +@export var match_participant : MatchParticipant signal health_zeroed(killer_id : int) signal health_changed(value : float) @@ -33,7 +33,7 @@ func _ready() -> void: @rpc("call_local", "reliable") func damage(amount : float, damage_dealer_player_id : int, damage_dealer_team_id : int) -> void: - if (damage_dealer_team_id == match_participant_component.team_id) and (damage_dealer_player_id != match_participant_component.player_id): + if (damage_dealer_team_id == match_participant.team_id) and (damage_dealer_player_id != match_participant.player_id): return health = clampf(health - amount, 0.0, max_health) diff --git a/entities/components/match_participant.gd b/entities/components/match_participant.gd new file mode 100644 index 0000000..7a6f16a --- /dev/null +++ b/entities/components/match_participant.gd @@ -0,0 +1,20 @@ +class_name MatchParticipant extends Node + +signal player_id_changed(new_player_id : int) +signal username_changed(new_username : String) +signal team_id_changed(new_team_id : int) + +@export var username : String = "Newblood": + set(value): + username = value + username_changed.emit(username) + +@export var player_id : int: + set(value): + player_id = value + player_id_changed.emit(player_id) + +@export var team_id : int = 1: + set(value): + team_id = value + team_id_changed.emit(team_id) diff --git a/entities/components/match_participant_component.gd b/entities/components/match_participant_component.gd deleted file mode 100644 index 20ef898..0000000 --- a/entities/components/match_participant_component.gd +++ /dev/null @@ -1,25 +0,0 @@ -class_name MatchParticipantComponent extends MultiplayerSynchronizer - -signal player_id_changed(new_player_id : int) -signal username_changed(new_username : String) - -@export var username : String = "": - set(value): - username = value - username_changed.emit(username) - -@export var player_id : int: - set(value): - player_id = value - player_id_changed.emit(player_id) - -@export var team_id : int = 1 - -func _enter_tree() -> void: - root_path = "." - replication_config = SceneReplicationConfig.new() - for prop : String in ["player_id", "team_id", "username"]: - var prop_path : NodePath = NodePath(prop).get_as_property_path() - replication_config.add_property(prop_path) - replication_config.property_set_replication_mode( - prop_path, SceneReplicationConfig.REPLICATION_MODE_ON_CHANGE) diff --git a/entities/components/projectile_spawner.gd b/entities/components/projectile_spawner.gd index c17e95c..373e369 100644 --- a/entities/components/projectile_spawner.gd +++ b/entities/components/projectile_spawner.gd @@ -21,7 +21,7 @@ class_name ProjectileSpawner extends Node3D func new_projectile( projectile_type : Object, owner_velocity : Vector3, - shooter : MatchParticipantComponent + shooter : MatchParticipant ) -> Node3D: return projectile_type.new_projectile( self, diff --git a/entities/player/player_input.gd b/entities/player/inputs_sync.gd similarity index 90% rename from entities/player/player_input.gd rename to entities/player/inputs_sync.gd index 6ee7a36..8837cb7 100644 --- a/entities/player/player_input.gd +++ b/entities/player/inputs_sync.gd @@ -12,7 +12,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -class_name PlayerInput extends MultiplayerSynchronizer +extends Node @export var jetting : bool = false @export var skiing : bool = false @@ -30,13 +30,13 @@ func update_multiplayer_authority(player_id : int) -> void: set_multiplayer_authority(player_id) func _unhandled_input(event: InputEvent) -> void: - var mouse_mode : Input.MouseMode = Input.get_mouse_mode() - # isolate mouse events - if event is InputEventMouseMotion: - if mouse_mode == Input.MOUSE_MODE_CAPTURED: - # retrieve mouse position relative to last frame - _update_camera(event.relative) if is_multiplayer_authority(): + var mouse_mode : Input.MouseMode = Input.get_mouse_mode() + # isolate mouse events + if event is InputEventMouseMotion: + if mouse_mode == Input.MOUSE_MODE_CAPTURED: + # update camera with mouse position relative to last frame + _update_camera(event.relative) if event is InputEventMouseButton: # @NOTE: there could be a control setting for direction if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed: diff --git a/entities/player/player.gd b/entities/player/player.gd index 0146edb..ee51e18 100644 --- a/entities/player/player.gd +++ b/entities/player/player.gd @@ -23,6 +23,7 @@ signal energy_changed(energy : float) @export var health_component : HealthComponent @export var flag_carry_component : FlagCarryComponent @export var walkable_surface_sensor : ShapeCast3D +@export var match_participant : MatchParticipant ## The inventory component can store up to [member Inventory.slots] objects. It ## also has specific slots to hold grenades, packs and a flag. @@ -47,14 +48,13 @@ signal energy_changed(energy : float) @export_group("State") @export var player_state : PlayerState = PlayerState.PLAYER_ALIVE +@export var input : Node -@onready var input : PlayerInput = $PlayerInput @onready var camera : Camera3D = %Pivot/Camera3D @onready var hud : CanvasLayer = $HUD @onready var animation_player : AnimationPlayer = $AnimationPlayer @onready var collision_shape : CollisionShape3D = $CollisionShape3D @onready var jetpack_particles : Array = $ThirdPerson/Mesh/JetpackFX.get_children() -@onready var match_participant_component : MatchParticipantComponent = $MatchParticipantComponent var g : float = ProjectSettings.get_setting("physics/3d/default_gravity") # in m/s² var gravity : Vector3 = g * ProjectSettings.get_setting("physics/3d/default_gravity_vector") @@ -63,9 +63,9 @@ var _jumping : bool = false static var pawn_player : Player func _ready() -> void: - match_participant_component.player_id_changed.connect(_setup_pawn) - match_participant_component.username_changed.connect(iff._on_username_changed) - match_participant_component.player_id_changed.connect(input.update_multiplayer_authority) + match_participant.player_id_changed.connect(_setup_pawn) + match_participant.player_id_changed.connect(input.update_multiplayer_authority) + match_participant.username_changed.connect(iff._on_username_changed) health_component.health_changed.connect(hud._on_health_changed) health_component.health_changed.connect(iff._on_health_changed) @@ -82,8 +82,8 @@ func _process(_delta : float) -> void: %Pivot.global_transform.basis = Basis.from_euler(Vector3(input.camera_rotation.y, input.camera_rotation.x, 0.0)) if not _is_pawn(): tp_mesh.global_transform.basis = Basis.from_euler(Vector3(.0, input.camera_rotation.x + PI, 0.0)) - if match_participant_component and pawn_player: - if pawn_player.match_participant_component.team_id == match_participant_component.team_id: + if match_participant and pawn_player: + if pawn_player.match_participant.team_id == match_participant.team_id: iff.fill = Color.GREEN else: iff.fill = Color.RED @@ -103,7 +103,7 @@ func _setup_pawn(_new_player_id : int) -> void: hud.hide() func _is_pawn() -> bool: - var peer_is_pawn : bool = multiplayer.get_unique_id() == match_participant_component.player_id + var peer_is_pawn : bool = multiplayer.get_unique_id() == match_participant.player_id return Global.type is Singleplayer or peer_is_pawn # @NOTE: this method works only because `tp_mesh` duplicates weapons meshes from the inventory diff --git a/entities/player/player.tscn b/entities/player/player.tscn index ae403d8..4d3487b 100644 --- a/entities/player/player.tscn +++ b/entities/player/player.tscn @@ -4,8 +4,7 @@ [ext_resource type="PackedScene" uid="uid://bbeecp3jusppn" path="res://interfaces/hud/iffs/IFF.tscn" id="2_s5wgp"] [ext_resource type="PackedScene" uid="uid://bcv81ku26xo" path="res://interfaces/hud/hud.tscn" id="3_ccety"] [ext_resource type="Shape3D" uid="uid://cb8esdlnottdn" path="res://entities/player/resources/collider.tres" id="4_8kvcy"] -[ext_resource type="Script" path="res://entities/components/match_participant_component.gd" id="6_lrose"] -[ext_resource type="Script" path="res://entities/player/player_input.gd" id="6_ymcrr"] +[ext_resource type="Script" path="res://entities/components/match_participant.gd" id="6_lrose"] [ext_resource type="Script" path="res://entities/components/inventory.gd" id="8_768qh"] [ext_resource type="PackedScene" uid="uid://drbefw6akui2v" path="res://entities/player/vanguard.tscn" id="8_eiy7q"] [ext_resource type="Script" path="res://entities/components/flag_carry_component.gd" id="8_pdfbn"] @@ -18,6 +17,7 @@ [ext_resource type="PackedScene" uid="uid://b0xql5hi0b52y" path="res://entities/weapons/chaingun/chaingun.tscn" id="15_io0a3"] [ext_resource type="PackedScene" uid="uid://cstl7yxc75572" path="res://entities/weapons/grenade_launcher/grenade_launcher.tscn" id="16_4xs2j"] [ext_resource type="PackedScene" uid="uid://d3l7fvbdg6m5g" path="res://entities/flag/assets/flag.glb" id="18_7nkei"] +[ext_resource type="Script" path="res://entities/player/inputs_sync.gd" id="18_v4iu1"] [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_clur0"] resource_local_to_scene = true @@ -59,45 +59,6 @@ _data = { "death": SubResource("Animation_yqgrk") } -[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_rqdp6"] -properties/0/path = NodePath(".:linear_velocity") -properties/0/spawn = false -properties/0/replication_mode = 1 -properties/1/path = NodePath(".:position") -properties/1/spawn = false -properties/1/replication_mode = 1 -properties/2/path = NodePath("HealthComponent:health") -properties/2/spawn = false -properties/2/replication_mode = 2 -properties/3/path = NodePath(".:player_state") -properties/3/spawn = false -properties/3/replication_mode = 2 - -[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_5j4ew"] -properties/0/path = NodePath(".:direction") -properties/0/spawn = false -properties/0/replication_mode = 1 -properties/1/path = NodePath(".:jetting") -properties/1/spawn = false -properties/1/replication_mode = 2 -properties/2/path = NodePath(".:camera_rotation") -properties/2/spawn = false -properties/2/replication_mode = 1 -properties/3/path = NodePath(".:skiing") -properties/3/spawn = false -properties/3/replication_mode = 2 - -[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_7na0c"] -properties/0/path = NodePath("MatchParticipantComponent:player_id") -properties/0/spawn = false -properties/0/replication_mode = 2 -properties/1/path = NodePath("MatchParticipantComponent:team_id") -properties/1/spawn = false -properties/1/replication_mode = 2 -properties/2/path = NodePath("MatchParticipantComponent:nickname") -properties/2/spawn = false -properties/2/replication_mode = 2 - [sub_resource type="Gradient" id="Gradient_3u0pn"] offsets = PackedFloat32Array(0, 0.872727) colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0) @@ -206,7 +167,46 @@ particles_anim_loop = false [sub_resource type="QuadMesh" id="QuadMesh_uc7ts"] material = SubResource("StandardMaterial3D_2jwv2") -[node name="Player" type="RigidBody3D" node_paths=PackedStringArray("iff", "health_component", "flag_carry_component", "walkable_surface_sensor", "inventory", "tp_mesh") groups=["Player"]] +[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_rqdp6"] +properties/0/path = NodePath(".:linear_velocity") +properties/0/spawn = false +properties/0/replication_mode = 1 +properties/1/path = NodePath(".:position") +properties/1/spawn = false +properties/1/replication_mode = 1 +properties/2/path = NodePath("HealthComponent:health") +properties/2/spawn = false +properties/2/replication_mode = 2 +properties/3/path = NodePath(".:player_state") +properties/3/spawn = false +properties/3/replication_mode = 2 + +[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_5j4ew"] +properties/0/path = NodePath(".:direction") +properties/0/spawn = true +properties/0/replication_mode = 1 +properties/1/path = NodePath(".:jetting") +properties/1/spawn = true +properties/1/replication_mode = 2 +properties/2/path = NodePath(".:camera_rotation") +properties/2/spawn = true +properties/2/replication_mode = 1 +properties/3/path = NodePath(".:skiing") +properties/3/spawn = true +properties/3/replication_mode = 2 + +[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_7na0c"] +properties/0/path = NodePath(".:username") +properties/0/spawn = true +properties/0/replication_mode = 1 +properties/1/path = NodePath(".:player_id") +properties/1/spawn = true +properties/1/replication_mode = 1 +properties/2/path = NodePath(".:team_id") +properties/2/spawn = true +properties/2/replication_mode = 1 + +[node name="Player" type="RigidBody3D" node_paths=PackedStringArray("iff", "health_component", "flag_carry_component", "walkable_surface_sensor", "match_participant", "inventory", "tp_mesh", "input") groups=["Player"]] collision_mask = 2147483649 collision_priority = 9.0 axis_lock_angular_x = true @@ -221,17 +221,19 @@ iff = NodePath("IFF") health_component = NodePath("HealthComponent") flag_carry_component = NodePath("Pivot/FlagCarryComponent") walkable_surface_sensor = NodePath("WalkableSurfaceSensor") +match_participant = NodePath("MatchParticipant") inventory = NodePath("Pivot/Inventory") tp_mesh = NodePath("ThirdPerson/Mesh") jump_height = 1.5 +input = NodePath("Inputs") [node name="IFF" parent="." instance=ExtResource("2_s5wgp")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1, 0) fill = Color(0, 1, 0, 1) -[node name="HealthComponent" type="Area3D" parent="." node_paths=PackedStringArray("match_participant_component")] +[node name="HealthComponent" type="Area3D" parent="." node_paths=PackedStringArray("match_participant")] script = ExtResource("14_ctgxn") -match_participant_component = NodePath("../MatchParticipantComponent") +match_participant = NodePath("../MatchParticipant") [node name="CollisionShape3D" type="CollisionShape3D" parent="HealthComponent"] shape = ExtResource("4_8kvcy") @@ -254,23 +256,6 @@ libraries = { autoplay = "shoot" playback_default_blend_time = 0.05 -[node name="ServerSynchronizer" type="MultiplayerSynchronizer" parent="."] -replication_config = SubResource("SceneReplicationConfig_rqdp6") - -[node name="PlayerInput" type="MultiplayerSynchronizer" parent="."] -root_path = NodePath(".") -replication_config = SubResource("SceneReplicationConfig_5j4ew") -script = ExtResource("6_ymcrr") -jetting = null -skiing = null -direction = null -camera_rotation = null - -[node name="MatchParticipantComponent" type="MultiplayerSynchronizer" parent="."] -root_path = NodePath(".") -replication_config = SubResource("SceneReplicationConfig_7na0c") -script = ExtResource("6_lrose") - [node name="Pivot" type="Node3D" parent="."] unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0) @@ -441,6 +426,21 @@ script = ExtResource("11_k330l") target = NodePath("..") flags = 3 +[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] +replication_config = SubResource("SceneReplicationConfig_rqdp6") + +[node name="Inputs" type="Node" parent="."] +script = ExtResource("18_v4iu1") + +[node name="InputsSync" type="MultiplayerSynchronizer" parent="Inputs"] +replication_config = SubResource("SceneReplicationConfig_5j4ew") + +[node name="MatchParticipant" type="Node" parent="."] +script = ExtResource("6_lrose") + +[node name="MatchParticipantSync" type="MultiplayerSynchronizer" parent="MatchParticipant"] +replication_config = SubResource("SceneReplicationConfig_7na0c") + [connection signal="energy_changed" from="." to="HUD" method="_on_player_energy_changed"] [editable path="ThirdPerson/Mesh"] diff --git a/entities/weapons/chaingun/chaingun.gd b/entities/weapons/chaingun/chaingun.gd index 6142d96..80cd8b9 100644 --- a/entities/weapons/chaingun/chaingun.gd +++ b/entities/weapons/chaingun/chaingun.gd @@ -32,7 +32,7 @@ func trigger() -> void: var projectile : Node3D = $ProjectileSpawner.new_projectile( ChainGunProjectile, owner.linear_velocity, - owner.match_participant_component + owner.match_participant ) # add to owner of player for now Global.type.add_child(projectile) diff --git a/entities/weapons/chaingun/projectile.gd b/entities/weapons/chaingun/projectile.gd index 0690902..f15e115 100644 --- a/entities/weapons/chaingun/projectile.gd +++ b/entities/weapons/chaingun/projectile.gd @@ -18,7 +18,7 @@ class_name ChainGunProjectile extends Node3D @export var lifespan : float = .5 # in seconds @export var build_up_time : float = .6 # seconds -var shooter : MatchParticipantComponent +var shooter : MatchParticipant var velocity : Vector3 = Vector3.ZERO @onready var shape_cast : ShapeCast3D = $ShapeCast3D @@ -45,7 +45,7 @@ func _physics_process(delta : float) -> void: static func new_projectile( origin : Marker3D, inherited_velocity : Vector3, - _shooter : MatchParticipantComponent, + _shooter : MatchParticipant, scene : PackedScene ) -> ChainGunProjectile: var projectile : ChainGunProjectile = scene.instantiate() diff --git a/entities/weapons/grenade_launcher/explosion.gd b/entities/weapons/grenade_launcher/explosion.gd index 1f3ad83..08a7233 100644 --- a/entities/weapons/grenade_launcher/explosion.gd +++ b/entities/weapons/grenade_launcher/explosion.gd @@ -4,7 +4,7 @@ class_name GrenadeLauncherProjectileExplosion extends Node3D @export var explosive_damage : ExplosiveDamageComponent ## The component responsible for owner identification -var shooter : MatchParticipantComponent: +var shooter : MatchParticipant: set(value): shooter = value explosive_damage.damage_dealer = value @@ -29,7 +29,7 @@ func _on_finished() -> void: ## [GrenadeLauncherProjectileExplosion] scene of the [GrenadeLauncherProjectile]. static func new_explosion( origin : Vector3, - _shooter : MatchParticipantComponent, + _shooter : MatchParticipant, scene : PackedScene ) -> GrenadeLauncherProjectileExplosion: var explosion : GrenadeLauncherProjectileExplosion = scene.instantiate() diff --git a/entities/weapons/grenade_launcher/grenade_launcher.gd b/entities/weapons/grenade_launcher/grenade_launcher.gd index 4e859f9..d1559da 100644 --- a/entities/weapons/grenade_launcher/grenade_launcher.gd +++ b/entities/weapons/grenade_launcher/grenade_launcher.gd @@ -18,7 +18,7 @@ func trigger() -> void: var projectile : Node3D = $ProjectileSpawner.new_projectile( GrenadeLauncherProjectile, owner.linear_velocity, - owner.match_participant_component + owner.match_participant ) # add to owner of player for now Global.type.add_child(projectile) diff --git a/entities/weapons/grenade_launcher/projectile.gd b/entities/weapons/grenade_launcher/projectile.gd index 54938d7..f1699c9 100644 --- a/entities/weapons/grenade_launcher/projectile.gd +++ b/entities/weapons/grenade_launcher/projectile.gd @@ -20,7 +20,7 @@ class_name GrenadeLauncherProjectile extends RigidBody3D @export var speed : float = 44. # m/s @export var lifespan : float = 1.6 # in seconds -var shooter : MatchParticipantComponent +var shooter : MatchParticipant var pending_explosion : bool = false ## Called when the node enters the scene tree for the first time. @@ -47,7 +47,7 @@ func _on_body_entered(_body : Node) -> void: static func new_projectile( origin : Node3D, inherited_velocity : Vector3, - _shooter : MatchParticipantComponent, + _shooter : MatchParticipant, scene : PackedScene ) -> GrenadeLauncherProjectile: var projectile : GrenadeLauncherProjectile = scene.instantiate() diff --git a/entities/weapons/space_gun/projectile.gd b/entities/weapons/space_gun/projectile.gd index 953510d..10854b7 100644 --- a/entities/weapons/space_gun/projectile.gd +++ b/entities/weapons/space_gun/projectile.gd @@ -25,7 +25,7 @@ class_name SpaceGunProjectile extends Node3D @onready var projectile_trail : Trail3D = $Smoothing/ProjectileTrail var velocity : Vector3 = Vector3.ZERO -var shooter : MatchParticipantComponent +var shooter : MatchParticipant func _ready() -> void: var lifespan_timer : Timer = Timer.new() @@ -61,7 +61,7 @@ func _physics_process(delta : float) -> void: static func new_projectile( origin : Marker3D, inherited_velocity : Vector3, - _shooter : MatchParticipantComponent, + _shooter : MatchParticipant, scene : PackedScene ) -> SpaceGunProjectile: var projectile : SpaceGunProjectile = scene.instantiate() diff --git a/entities/weapons/space_gun/projectile_explosion.gd b/entities/weapons/space_gun/projectile_explosion.gd index 483c9c7..ae76b68 100644 --- a/entities/weapons/space_gun/projectile_explosion.gd +++ b/entities/weapons/space_gun/projectile_explosion.gd @@ -20,7 +20,7 @@ class_name SpaceGunProjectileExplosion extends Node3D var explosion_effect_pending : bool = false -var shooter : MatchParticipantComponent: +var shooter : MatchParticipant: set(value): shooter = value assert(explosive_damage) @@ -31,7 +31,7 @@ func _ready() -> void: fire.finished.connect(func() -> void: queue_free()) ## This method is a parameterized constructor for the [SpaceGunProjectileExplosion] scene of the [SpaceGunProjectile] -static func new_explosion(spawn_position : Vector3, _shooter : MatchParticipantComponent, scene : PackedScene) -> SpaceGunProjectileExplosion: +static func new_explosion(spawn_position : Vector3, _shooter : MatchParticipant, scene : PackedScene) -> SpaceGunProjectileExplosion: var explosion : SpaceGunProjectileExplosion = scene.instantiate() explosion.shooter = _shooter explosion.position = spawn_position diff --git a/entities/weapons/space_gun/space_gun.gd b/entities/weapons/space_gun/space_gun.gd index 788dc4e..24a5a55 100644 --- a/entities/weapons/space_gun/space_gun.gd +++ b/entities/weapons/space_gun/space_gun.gd @@ -33,7 +33,7 @@ func trigger() -> void: var projectile : Node3D = $ProjectileSpawner.new_projectile( SpaceGunProjectile, owner.linear_velocity, - owner.match_participant_component + owner.match_participant ) # add to owner of player for now Global.type.add_child(projectile) diff --git a/interfaces/progress_bar/resources/visual_shader.res b/interfaces/progress_bar/resources/visual_shader.res index b1f30fafb58ad10b6e093b909207603af5231eb8..5ff16fdfacc0d9fa110c4eca54753e7d0f8feb35 100644 GIT binary patch delta 2758 zcmV;%3OV(nEt)MIQd2`i0ssI201yBGnmGUf%mn}dbOrzbas>bY#IYUk1uqTMJU$|O zE4Ym@ZNCW-ivaCE;?EJ=#^FC$^Y_d`RM1Mb(9m*d-GyTP9O39WJCi#GE&*DTY6cvC zM$1;NkA_M`Wi+n+78p&#;mzffsaPhF^)gcaWjcBeJ7bDN%VF3xRd!*1`A2e#bOqcCWG^Y3}u>Sb5<4TgU-R6ZIiBzp4%Hx%}Y)IB=&3dQf5M7LYw@Dy5_xvq`hVky77(}HTH zpkvrHT_7;rIBbpvlPw360j-n42NpR1ixHlbBN9j%S}Kw}C=B4p5MyG1ao>==;)iII z(BYz1>UFq~5yH{lPzr7$kQStr1EiD%uB}!?lMo0Le=kx&hYKk&T%%anym$cvKmpCX zzWMybIwwulgRU%!Y@fH?4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ba--R}6Qvl3k2ZH;X4fhTvhsx+t*dk3i!?c7@KT9!E4US-4yC~jcG|O{EI6w;E;zW&A5Vb}vg06Z# z#bF3R{m@g8u_bJFxLQ;@AV)cpX^&wNaKK6pD77#BV5$i9B>>j{&6D2|NPo2e%mA$b z8CN`7Pt(q2wybl_L(D(-Fqg@oI4LO3HQ%xh=GwQ6gTdYW=i&3TBDiJSKMaoYq@X-0 zta|fIsbsL1#2l;_ZK?PlWmV86rAlS7oFM%=9gbzv+nwWd-9OJInM?Z(&MBTA#--sI zOz7ph!q;eP_NYklDcQ>Z?mV=eDAw-EIy6l2NWCg*E7xY_xRR|_D^1(LWX>VSDaFUK z9S@HFEH&?nz2tEX^TS+MUm2}9uW1*>BMp<`637)Od87gJ-nsfmt4O9QRnh0thPkfJ zle-g|0_zTwRupZ2Ez)|Q|EQ``kKR+&4F8Fx4e?8hg2g&B{Z21PO@9_Lk(887N?rnu zn0$;*B~ZyhFOi6DGKEN|k?7YRZrxhvMY>?lqSiE`Q4O!dT}j-2FcK$7IfGY%f< z*?V73($gz{s=T$tL9%a6AvGb;8OG34`Ec void: elif event.is_action_released("scoreboard"): hide() -func add_participant(participant : MatchParticipantComponent) -> void: +func add_participant(participant : MatchParticipant) -> void: _add_scoreboard_entry.rpc(participant.player_id, participant.username) -func remove_participant(participant : MatchParticipantComponent) -> void: +func remove_participant(participant : MatchParticipant) -> void: _remove_scoreboard_entry.rpc(participant.player_id) -func increment_kill_count(participant : MatchParticipantComponent) -> void: +func increment_kill_count(participant : MatchParticipant) -> void: _entries[participant.player_id].kills += 1 -func add_score_to_player(participant : MatchParticipantComponent, amount : int) -> void: +func add_score_to_player(participant : MatchParticipant, amount : int) -> void: var player_id : int = participant.player_id var entry : ScoreboardEntry = _entries[player_id] _update_scoreboard_entry.rpc(player_id, entry.username, entry.kills, entry.score + amount) diff --git a/interfaces/scoreboard/scoreboard.tscn b/interfaces/scoreboard/scoreboard.tscn index 119f412..37b6e97 100644 --- a/interfaces/scoreboard/scoreboard.tscn +++ b/interfaces/scoreboard/scoreboard.tscn @@ -9,6 +9,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 script = ExtResource("1_k2wav") [node name="Panel" type="Panel" parent="."] @@ -18,6 +19,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 [node name="MarginContainer" type="MarginContainer" parent="Panel"] layout_mode = 1 @@ -26,11 +28,13 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 theme_override_constants/margin_left = 64 theme_override_constants/margin_top = 64 [node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer"] layout_mode = 2 +mouse_filter = 2 [node name="Label" type="Label" parent="Panel/MarginContainer/VBoxContainer"] layout_mode = 2 @@ -42,6 +46,7 @@ text = "Scoreboard" unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 4 +mouse_filter = 2 theme_override_constants/h_separation = 32 theme_override_constants/v_separation = 16 columns = 3 diff --git a/maps/components/deathmatch_scoring_component.gd b/maps/components/deathmatch_scoring_component.gd index ee4dd80..042db76 100644 --- a/maps/components/deathmatch_scoring_component.gd +++ b/maps/components/deathmatch_scoring_component.gd @@ -28,9 +28,9 @@ func unsubscribe_player(player : Player) -> void: player.died.disconnect(_on_player_died) func _on_player_died(player : Player, killer_id : int) -> void: - if player.match_participant_component.player_id != killer_id: + if player.match_participant.player_id != killer_id: var node_name : String = str(killer_id) if _players.has_node(node_name): var killer : Player = _players.get_node(node_name) - _scoreboard.increment_kill_count(killer.match_participant_component) - _scoreboard.add_score_to_player(killer.match_participant_component, 10) + _scoreboard.increment_kill_count(killer.match_participant) + _scoreboard.add_score_to_player(killer.match_participant, 10) diff --git a/maps/components/rabbit_scoring_component.gd b/maps/components/rabbit_scoring_component.gd index 9507727..7595ea1 100644 --- a/maps/components/rabbit_scoring_component.gd +++ b/maps/components/rabbit_scoring_component.gd @@ -38,16 +38,16 @@ func setup(flag : Flag) -> void: flag.dropped.connect(_on_flag_dropped) func _on_flag_grabbed(grabber : Player) -> void: - grabber.match_participant_component.team_id = _team_rabbit.team_id - _scoreboard.add_score_to_player(grabber.match_participant_component, ON_GRAB_SCORE) + grabber.match_participant.team_id = _team_rabbit.team_id + _scoreboard.add_score_to_player(grabber.match_participant, ON_GRAB_SCORE) _flag_carrier_scoring_timer.start() func _on_flag_regrabbed(grabber : Player) -> void: - grabber.match_participant_component.team_id = _team_rabbit.team_id + grabber.match_participant.team_id = _team_rabbit.team_id func _on_flag_dropped(dropper : Player) -> void: - dropper.match_participant_component.team_id = _team_chasers.team_id + dropper.match_participant.team_id = _team_chasers.team_id _flag_carrier_scoring_timer.stop() func _on_flag_carrier_scoring_timer_timeout(flag : Flag) -> void: - _scoreboard.add_score_to_player(flag.last_carrier.match_participant_component, ON_HOLD_SCORE) + _scoreboard.add_score_to_player(flag.last_carrier.match_participant, ON_HOLD_SCORE) diff --git a/modes/multiplayer/multiplayer.gd b/modes/multiplayer/multiplayer.gd index d659940..cd67f5f 100644 --- a/modes/multiplayer/multiplayer.gd +++ b/modes/multiplayer/multiplayer.gd @@ -68,19 +68,19 @@ func add_player(peer_id : int, username : String) -> void: player.name = str(peer_id) player.died.connect(_on_player_died) players.add_child(player) - player.match_participant_component.player_id = peer_id - player.match_participant_component.team_id = ($RabbitScoringComponent as RabbitScoringComponent)._team_chasers.team_id - player.match_participant_component.username = username + player.match_participant.player_id = peer_id + player.match_participant.team_id = ($RabbitScoringComponent as RabbitScoringComponent)._team_chasers.team_id + player.match_participant.username = username player.global_position = MapsManager.get_player_spawn().position $DeathmatchScoringComponent.subscribe_player(player) - scoreboard.add_participant(player.match_participant_component) + scoreboard.add_participant(player.match_participant) print("Peer `%s` connected" % player.name) func remove_player(peer_id : int) -> void: var node_name : String = str(peer_id) if players.has_node(node_name): var player : Player = players.get_node(node_name) - scoreboard.remove_participant(player.match_participant_component) + scoreboard.remove_participant(player.match_participant) player.died.disconnect(_on_player_died) $DeathmatchScoringComponent.unsubscribe_player(player) player.queue_free() diff --git a/modes/singleplayer/demo.gd b/modes/singleplayer/demo.gd index 3f248c8..5a23b69 100644 --- a/modes/singleplayer/demo.gd +++ b/modes/singleplayer/demo.gd @@ -20,7 +20,7 @@ class_name Singleplayer extends Node func _ready() -> void: player_node.died.connect(respawn_player) - player_node.match_participant_component.player_id = 1 + player_node.match_participant.player_id = 1 MapsManager.current_map = $Desert _add_flag() diff --git a/tests/test_deathmatch_scoring_component.gd b/tests/test_deathmatch_scoring_component.gd index 6126b10..027f902 100644 --- a/tests/test_deathmatch_scoring_component.gd +++ b/tests/test_deathmatch_scoring_component.gd @@ -26,8 +26,8 @@ func _setup_player(player_id : int) -> Player: var player : Player = PLAYER.instantiate() player.name = str(player_id) add_child(player) # we can't autofree in this test setup - var participant : MatchParticipantComponent = player.match_participant_component - player.match_participant_component.player_id = player_id + var participant : MatchParticipant = player.match_participant + player.match_participant.player_id = player_id _scoreboard.add_participant(participant) _subject.subscribe_player(player) _subject._players = self @@ -50,7 +50,7 @@ func after_each() -> void: _subject.free() func _kill_player(victim : Player, killer : Player) -> void: - victim.died.emit(victim, killer.match_participant_component.player_id) + victim.died.emit(victim, killer.match_participant.player_id) func test_player_gets_no_score_for_self_kill() -> void: _kill_player(_victim, _victim) @@ -59,8 +59,8 @@ func test_player_gets_no_score_for_self_kill() -> void: func test_killer_gets_score_after_kill() -> void: _kill_player(_victim, _killer) - assert_called(_scoreboard, 'add_score_to_player', [_killer.match_participant_component, _subject.ON_KILL_SCORE]) - assert_called(_scoreboard, 'increment_kill_count', [_killer.match_participant_component]) + assert_called(_scoreboard, 'add_score_to_player', [_killer.match_participant, _subject.ON_KILL_SCORE]) + assert_called(_scoreboard, 'increment_kill_count', [_killer.match_participant]) func test_killer_leaves_before_kill() -> void: remove_child(_killer) diff --git a/tests/test_health_component.gd b/tests/test_health_component.gd index e73f4fd..3329dd5 100644 --- a/tests/test_health_component.gd +++ b/tests/test_health_component.gd @@ -23,14 +23,14 @@ func before_each() -> void: _subject = HealthComponent.new() watch_signals(_subject) _subject.max_health = TEST_MAX_HEALTH - var participant : MatchParticipantComponent = MatchParticipantComponent.new() + var participant : MatchParticipant = MatchParticipant.new() participant.player_id = TEST_PLAYER_ID participant.team_id = TEST_TEAM_ID - _subject.match_participant_component = participant + _subject.match_participant = participant add_child_autofree(_subject) func after_each() -> void: - _subject.match_participant_component.free() + _subject.match_participant.free() func test_that_it_has_max_health_when_ready() -> void: assert_eq(_subject.health, _subject.max_health) diff --git a/tests/test_scoreboard.gd b/tests/test_scoreboard.gd index 90bc77f..cfc58f8 100644 --- a/tests/test_scoreboard.gd +++ b/tests/test_scoreboard.gd @@ -26,7 +26,7 @@ func test_that_new_scoreboard_is_empty() -> void: assert_eq(_subject._entries, {}) func test_that_added_entry_is_added_correctly() -> void: - var participant : MatchParticipantComponent = MatchParticipantComponent.new() + var participant : MatchParticipant = MatchParticipant.new() participant.username = "test_username" _subject.add_participant(participant) var entries : Array = _subject._entries.values() @@ -38,7 +38,7 @@ func test_that_added_entry_is_added_correctly() -> void: participant.free() func test_that_scores_are_added_correctly() -> void: - var participant : MatchParticipantComponent = MatchParticipantComponent.new() + var participant : MatchParticipant = MatchParticipant.new() _subject.add_participant(participant) _subject.add_score_to_player(participant, 10) var tested_entry : Scoreboard.ScoreboardEntry = _subject._entries.values()[0] @@ -46,7 +46,7 @@ func test_that_scores_are_added_correctly() -> void: participant.free() func test_that_kill_counts_are_incremented_correctly() -> void: - var participant : MatchParticipantComponent = MatchParticipantComponent.new() + var participant : MatchParticipant = MatchParticipant.new() _subject.add_participant(participant) _subject.increment_kill_count(participant) var tested_entry : Scoreboard.ScoreboardEntry = _subject._entries.values()[0]