feat: implement core movement, combat, weapon management, and networking systems
This commit is contained in:
@@ -13,6 +13,11 @@ func _ready() -> void:
|
||||
var nm = get_node_or_null("/root/NetworkManager")
|
||||
if nm:
|
||||
nm.connection_succeeded.connect(_on_connection_succeeded)
|
||||
|
||||
# Auto-open lobby if returning to main menu while still connected
|
||||
if nm.multiplayer.has_multiplayer_peer() and not nm.multiplayer.multiplayer_peer is OfflineMultiplayerPeer:
|
||||
call_deferred("_on_connection_succeeded")
|
||||
call_deferred("_hide_ui_vbox")
|
||||
|
||||
# ==========================================
|
||||
# BACKGROUND: 3D DIORAMA (Sliding Player)
|
||||
@@ -242,6 +247,31 @@ func _ready() -> void:
|
||||
)
|
||||
hl_left.add_child(_gamemode_opt)
|
||||
|
||||
var time_label = Label.new()
|
||||
time_label.text = "Match Duration"
|
||||
time_label.add_theme_font_size_override("font_size", 32)
|
||||
hl_left.add_child(time_label)
|
||||
|
||||
var _time_opt = OptionButton.new()
|
||||
_time_opt.add_theme_font_size_override("font_size", 24)
|
||||
_time_opt.add_item("1 Minute", 0)
|
||||
_time_opt.add_item("3 Minutes", 1)
|
||||
_time_opt.add_item("5 Minutes", 2)
|
||||
_time_opt.add_item("10 Minutes", 3)
|
||||
_time_opt.add_item("15 Minutes", 4)
|
||||
_time_opt.select(2) # Default 5 Minutes
|
||||
_time_opt.add_to_group("host_only_ui")
|
||||
_time_opt.item_selected.connect(func(index: int):
|
||||
var net_man = get_node_or_null("/root/NetworkManager")
|
||||
if net_man:
|
||||
if index == 0: net_man.match_duration_setting = 60.0
|
||||
elif index == 1: net_man.match_duration_setting = 180.0
|
||||
elif index == 2: net_man.match_duration_setting = 300.0
|
||||
elif index == 3: net_man.match_duration_setting = 600.0
|
||||
elif index == 4: net_man.match_duration_setting = 900.0
|
||||
)
|
||||
hl_left.add_child(_time_opt)
|
||||
|
||||
var hl_spacer = Control.new()
|
||||
hl_spacer.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
hl_left.add_child(hl_spacer)
|
||||
@@ -410,9 +440,12 @@ func _on_network_player_disconnected(_id: int) -> void:
|
||||
_update_lobby_players()
|
||||
|
||||
func _update_lobby_players() -> void:
|
||||
if not _host_lobby_players_list: return
|
||||
if not is_inside_tree() or not _host_lobby_players_list: return
|
||||
|
||||
var nm = get_node_or_null("/root/NetworkManager")
|
||||
if not nm: return
|
||||
|
||||
_host_lobby_players_list.clear()
|
||||
var nm = get_node("/root/NetworkManager")
|
||||
|
||||
for pid in nm.player_stats.keys():
|
||||
var p_name = nm.player_stats[pid].get("username", "Unknown")
|
||||
@@ -438,6 +471,10 @@ func _on_settings_pressed() -> void:
|
||||
func _on_exit_pressed() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
func _hide_ui_vbox() -> void:
|
||||
if _ui_vbox:
|
||||
_ui_vbox.hide()
|
||||
|
||||
# ==========================================
|
||||
# 3D DIORAMA BUILDER
|
||||
# ==========================================
|
||||
|
||||
@@ -102,9 +102,13 @@ func _ready() -> void:
|
||||
_nm.stats_updated.connect(_update_hud)
|
||||
_nm.killfeed_event.connect(_on_killfeed_event)
|
||||
_nm.match_state_updated.connect(_update_timer)
|
||||
_nm.match_ended.connect(_on_match_ended)
|
||||
_update_hud()
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if _nm and not _nm.match_active:
|
||||
return
|
||||
|
||||
if Input.is_action_just_pressed("scoreboard"):
|
||||
_scoreboard_panel.show()
|
||||
_update_hud()
|
||||
@@ -212,3 +216,66 @@ func _on_killfeed_event(victim: String, killer: String, weapon: String, v_color:
|
||||
t.tween_interval(4.0)
|
||||
t.tween_property(l, "modulate:a", 0.0, 1.0)
|
||||
t.tween_callback(l.queue_free)
|
||||
|
||||
func _on_match_ended() -> void:
|
||||
# Hide top HUD and killfeed
|
||||
var top_margin = get_child(0)
|
||||
if top_margin and top_margin is MarginContainer:
|
||||
top_margin.hide()
|
||||
var kf_margin = get_child(1)
|
||||
if kf_margin and kf_margin is MarginContainer:
|
||||
kf_margin.hide()
|
||||
|
||||
_scoreboard_panel.show()
|
||||
_update_hud()
|
||||
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
|
||||
# Disable player controls
|
||||
var player = get_parent()
|
||||
if player:
|
||||
var machine = player.get_node_or_null("MovementStateMachine")
|
||||
if machine:
|
||||
machine.process_mode = Node.PROCESS_MODE_DISABLED
|
||||
var cam = player.get("camera")
|
||||
if cam:
|
||||
var wman = cam.get_node_or_null("WeaponManager")
|
||||
if wman:
|
||||
wman.process_mode = Node.PROCESS_MODE_DISABLED
|
||||
|
||||
var end_vbox = VBoxContainer.new()
|
||||
end_vbox.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
|
||||
var end_label = Label.new()
|
||||
end_label.text = "MATCH OVER"
|
||||
end_label.add_theme_font_size_override("font_size", 72)
|
||||
end_label.add_theme_color_override("font_color", Color(1.0, 0.2, 0.2))
|
||||
end_label.add_theme_color_override("font_outline_color", Color.BLACK)
|
||||
end_label.add_theme_constant_override("outline_size", 16)
|
||||
end_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
end_vbox.add_child(end_label)
|
||||
|
||||
var spacer = Control.new()
|
||||
spacer.custom_minimum_size = Vector2(0, 650) # 600 for scoreboard + 50 padding
|
||||
end_vbox.add_child(spacer)
|
||||
|
||||
var btn_margin = MarginContainer.new()
|
||||
btn_margin.add_theme_constant_override("margin_left", 100)
|
||||
btn_margin.add_theme_constant_override("margin_right", 100)
|
||||
|
||||
var lobby_btn = Button.new()
|
||||
lobby_btn.text = "Return to Lobby"
|
||||
lobby_btn.add_theme_font_size_override("font_size", 32)
|
||||
lobby_btn.pressed.connect(func():
|
||||
get_tree().change_scene_to_file("res://ui/main_menu/main_menu.tscn")
|
||||
)
|
||||
btn_margin.add_child(lobby_btn)
|
||||
end_vbox.add_child(btn_margin)
|
||||
|
||||
var kf_margin2 = get_node_or_null("MarginContainer2")
|
||||
if not kf_margin2:
|
||||
var center = CenterContainer.new()
|
||||
center.name = "MarginContainer2"
|
||||
center.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
center.add_child(end_vbox)
|
||||
add_child(center)
|
||||
|
||||
@@ -262,6 +262,7 @@ func _build_ui() -> void:
|
||||
|
||||
var user_input = LineEdit.new()
|
||||
user_input.text = SettingsManager.username
|
||||
user_input.max_length = 16
|
||||
user_input.custom_minimum_size = Vector2(200, 0)
|
||||
user_hbox.add_child(user_input)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user