mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-12 15:04:46 +00:00
Extract MatchParticipantComponent from Player entity and fix HealthComponent tests
This commit is contained in:
parent
d238c29f76
commit
b339bf34f0
23 changed files with 149 additions and 124 deletions
|
|
@ -15,6 +15,7 @@
|
|||
extends Control
|
||||
|
||||
@export var player : Player
|
||||
@export var match_participant_component : MatchParticipantComponent
|
||||
@export var attach_point : Marker3D
|
||||
@export var healthbar_low_health_color : Color = Color(1 ,0 ,0, 0.78)
|
||||
@export var healthbar_mid_health_color : Color = Color(1, 1, 0, 0.78)
|
||||
|
|
@ -28,8 +29,8 @@ extends Control
|
|||
@onready var is_within_los : bool = false
|
||||
@onready var healthbar_fill_stylebox : StyleBoxFlat = _health_bar.get_theme_stylebox("fill")
|
||||
|
||||
func _ready() -> void:
|
||||
_player_name_label.text = player.nickname
|
||||
func set_nickname(new_nickname : String) -> void:
|
||||
_player_name_label.text = new_nickname
|
||||
|
||||
func _process(_delta : float) -> void:
|
||||
# retrieve camera for current viewport
|
||||
|
|
@ -44,7 +45,7 @@ func _process(_delta : float) -> void:
|
|||
# Show the correct IFF based on whether the player we're looking at belongs is a friend or a foe
|
||||
# in other words if their team_ids are the same as the "pawn" player
|
||||
if player.pawn_player != null:
|
||||
if player.pawn_player.team_id == player.team_id:
|
||||
if player.pawn_player.match_participant_component.team_id == player.match_participant_component.team_id:
|
||||
%FoeChevron.hide()
|
||||
%FriendChevron.show()
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -30,17 +30,17 @@ func _unhandled_input(event : InputEvent) -> void:
|
|||
elif event.is_action_released("scoreboard"):
|
||||
hide()
|
||||
|
||||
func add_player(player : Player) -> void:
|
||||
_add_scoreboard_entry.rpc(player.player_id, player.nickname)
|
||||
func add_participant(participant : MatchParticipantComponent) -> void:
|
||||
_add_scoreboard_entry.rpc(participant.player_id, participant.nickname)
|
||||
|
||||
func remove_player(player : Player) -> void:
|
||||
_remove_scoreboard_entry.rpc(player.player_id)
|
||||
func remove_participant(participant : MatchParticipantComponent) -> void:
|
||||
_remove_scoreboard_entry.rpc(participant.player_id)
|
||||
|
||||
func increment_kill_count(player : Player) -> void:
|
||||
_entries[player.player_id].kills += 1
|
||||
func increment_kill_count(participant : MatchParticipantComponent) -> void:
|
||||
_entries[participant.player_id].kills += 1
|
||||
|
||||
func add_score_to_player(player : Player, amount : int) -> void:
|
||||
var player_id : int = player.player_id
|
||||
func add_score_to_player(participant : MatchParticipantComponent, amount : int) -> void:
|
||||
var player_id : int = participant.player_id
|
||||
var entry : ScoreboardEntry = _entries[player_id]
|
||||
_update_scoreboard_entry.rpc(player_id, entry.nickname, entry.kills, entry.score + amount)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue