Fresh start: replace with naxIO/netfox-cs-sample foundation
Complete replacement of the tactical-shooter project with the netfox-cs-sample (MIT) — a CS 1.6 inspired multiplayer FPS built with Godot 4 and netfox. ## What's new - Full CS-style gameplay: teams (T/CT), rounds, economy, buy menu - 6 weapons: Knife, Glock, USP, AK-47, M4A1, AWP - Bomb plant/defuse with 2 bombsites - Flashbang & smoke grenades - Proper netfox rollback netcode at 64 tick - Network popup UI for host/join - HUD, crosshair, round timer, scoreboard - All netfox singletons registered as autoloads (works in exported builds) ## Architecture - Listen-server (host from client, no dedicated server binary) - Multiplayer-fps game lives at examples/multiplayer-fps/ - Netfox addons registered as autoloads for exported build compat - Godot 4.7 with Forward+ renderer ## Removed - Old headless-server architecture (client_main, server_main, player.gd, etc.) - Custom netfox bootstrap with ENet fallback - Old ChaffGames FPS template (2,420 lines, 844 KB) - SimulationServer GDExtension stub - Godot-jolt physics (netfox sample uses default Godot physics) - Duplicate weapon_data.gd, anti_cheat.gd, round_manager.gd, etc. - Server browser API Python venv (87 MB) - test_range map and modular assets ## Preserved - Git history - Server config at config/default_server_config.cfg - Windows export preset - Build directory (gitignored) Co-authored-by: naxIO <naxIO@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
@tool
|
||||
extends Node
|
||||
|
||||
static var _instance: Vest.__.CreateTestCommand = null
|
||||
|
||||
static func find():
|
||||
return _instance
|
||||
|
||||
static func execute() -> void:
|
||||
if _instance:
|
||||
_instance.create_test()
|
||||
else:
|
||||
push_warning("No instance of Create Test command found!")
|
||||
|
||||
func create_test():
|
||||
var editor := Vest._get_editor_interface()
|
||||
var edited_script := editor.get_script_editor().get_current_script() as Script
|
||||
|
||||
if not edited_script:
|
||||
editor.get_script_editor().open_script_create_dialog("VestTest", "")
|
||||
return
|
||||
|
||||
var script_path := edited_script.resource_path
|
||||
var script_directory := script_path.get_base_dir()
|
||||
var script_filename := script_path.get_file()
|
||||
|
||||
if Vest.get_test_name_patterns().any(func(it): return it.matches(script_filename)):
|
||||
# Script is already a test
|
||||
return
|
||||
|
||||
var preferred_pattern := Vest.get_test_name_patterns()[0]
|
||||
var test_filename := preferred_pattern.substitute(script_filename)
|
||||
var test_directory := get_test_directory(script_directory)
|
||||
var test_path := test_directory.path_join(test_filename)
|
||||
|
||||
editor.get_script_editor().open_script_create_dialog("VestTest", test_path)
|
||||
|
||||
func get_test_directory(script_dir: String) -> String:
|
||||
match Vest.get_new_test_location_preference():
|
||||
Vest.NEW_TEST_MIRROR_DIR_STRUCTURE:
|
||||
return get_mirrored_test_dir(script_dir)
|
||||
Vest.NEW_TEST_NEXT_TO_SOURCE:
|
||||
return script_dir
|
||||
Vest.NEW_TEST_IN_ROOT:
|
||||
return Vest.get_tests_root()
|
||||
|
||||
return script_dir
|
||||
|
||||
func get_mirrored_test_dir(script_dir: String) -> String:
|
||||
# TODO: Class for managing paths?
|
||||
if not script_dir.ends_with("/"):
|
||||
script_dir += "/"
|
||||
|
||||
if script_dir.begins_with(Vest.get_sources_root()):
|
||||
var relative_to_src_root := script_dir.substr(Vest.get_sources_root().length())
|
||||
return Vest.get_tests_root() + relative_to_src_root
|
||||
else:
|
||||
var relative_to_root := script_dir.replace("res://", "")
|
||||
return Vest.get_tests_root() + relative_to_root
|
||||
|
||||
func _ready():
|
||||
_instance = self
|
||||
var editor := Vest._get_editor_interface()
|
||||
editor.get_command_palette().add_command("Create test", "vest/create-test", create_test, "Ctrl+Shift+T")
|
||||
|
||||
func _exit_tree():
|
||||
var editor := Vest._get_editor_interface()
|
||||
editor.get_command_palette().remove_command("vest/create-test")
|
||||
|
||||
func _shortcut_input(event):
|
||||
if event is InputEventKey:
|
||||
if event.is_command_or_control_pressed() and event.shift_pressed and event.key_label == KEY_T and event.is_pressed():
|
||||
create_test()
|
||||
get_viewport().set_input_as_handled()
|
||||
@@ -0,0 +1 @@
|
||||
uid://cmda0loe05f5y
|
||||
@@ -0,0 +1,101 @@
|
||||
@tool
|
||||
extends Node
|
||||
|
||||
static var _instance: Vest.__.GoToTestCommand = null
|
||||
|
||||
static func find() -> Vest.__.GoToTestCommand:
|
||||
return _instance
|
||||
|
||||
func go_to_test():
|
||||
var editor := Vest._get_editor_interface()
|
||||
var edited_script := editor.get_script_editor().get_current_script() as Script
|
||||
|
||||
if not edited_script:
|
||||
# No script is being edited
|
||||
return
|
||||
|
||||
var script_path := edited_script.resource_path
|
||||
var script_filename := script_path.get_file()
|
||||
|
||||
var target_filenames := get_search_filenames(script_filename, Vest.get_test_name_patterns())
|
||||
var hits := find_matching_scripts(script_path, target_filenames)
|
||||
|
||||
if hits.size() == 1:
|
||||
# Single hit, navigate to script asap
|
||||
editor.edit_script(load(hits.front()))
|
||||
else:
|
||||
# Multiple hits, let user choose which one to open
|
||||
show_popup(hits)
|
||||
|
||||
func get_search_filenames(script_filename: String, patterns: Array[FilenamePattern]) -> Array[String]:
|
||||
var result := [] as Array[String]
|
||||
|
||||
# Check if currently open script is a test, in which case guess implementation's filename
|
||||
for pattern in patterns:
|
||||
if pattern.matches(script_filename):
|
||||
result.append(pattern.reverse(script_filename))
|
||||
|
||||
# Currently open script is not a test, figure out possible test names
|
||||
if result.is_empty():
|
||||
result.append_array(patterns.map(func(it): return it.substitute(script_filename)))
|
||||
|
||||
return result
|
||||
|
||||
func find_matching_scripts(script_path: String, search_filenames: Array[String]) -> Array[String]:
|
||||
var result := [] as Array[String]
|
||||
Vest.traverse_directory("res://", func(path: String):
|
||||
if path == script_path:
|
||||
return
|
||||
if path.get_file() not in search_filenames:
|
||||
return
|
||||
|
||||
result.append(path)
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
func show_popup(matching_script_paths: Array[String]):
|
||||
var editor := Vest._get_editor_interface()
|
||||
|
||||
var popup := PopupMenu.new()
|
||||
popup.min_size = Vector2(0, 0)
|
||||
popup.size = Vector2(0, 0)
|
||||
|
||||
# Add options for matches
|
||||
for idx in range(matching_script_paths.size()):
|
||||
var script_path := matching_script_paths[idx]
|
||||
popup.add_icon_item(Vest.Icons.jump_to, script_path)
|
||||
popup.set_item_icon_max_width(popup.item_count - 1, VestUI.get_icon_size())
|
||||
|
||||
# Add option to create
|
||||
popup.add_icon_item(Vest.Icons.lightbulb, "Create test")
|
||||
popup.set_item_icon_max_width(popup.item_count - 1, VestUI.get_icon_size())
|
||||
|
||||
# Show popup at mouse pos
|
||||
editor.popup_dialog(popup, Rect2i(
|
||||
get_viewport().get_mouse_position(),
|
||||
Vector2.ZERO
|
||||
))
|
||||
popup.set_focused_item(0)
|
||||
|
||||
popup.index_pressed.connect(func(idx: int):
|
||||
if idx < matching_script_paths.size():
|
||||
editor.edit_script(load(matching_script_paths[idx]))
|
||||
else:
|
||||
Vest.__.CreateTestCommand.execute()
|
||||
)
|
||||
|
||||
func _ready():
|
||||
_instance = self
|
||||
var editor := Vest._get_editor_interface()
|
||||
editor.get_command_palette().add_command("Go to test", "vest/go-test", go_to_test, "Ctrl+T")
|
||||
|
||||
func _exit_tree():
|
||||
var editor := Vest._get_editor_interface()
|
||||
editor.get_command_palette().remove_command("vest/go-test")
|
||||
|
||||
func _shortcut_input(event):
|
||||
if event is InputEventKey:
|
||||
if event.is_command_or_control_pressed() and not event.shift_pressed and event.key_label == KEY_T and event.is_pressed():
|
||||
go_to_test()
|
||||
get_viewport().set_input_as_handled()
|
||||
@@ -0,0 +1 @@
|
||||
uid://btsb4tdggfvfg
|
||||
@@ -0,0 +1,53 @@
|
||||
@tool
|
||||
extends Node
|
||||
|
||||
func run_test():
|
||||
_run(false, Vest.__.ONLY_AUTO)
|
||||
|
||||
func debug_test():
|
||||
_run(true, Vest.__.ONLY_AUTO)
|
||||
|
||||
func _run(is_debug: bool, only_mode: int) -> void:
|
||||
var editor_interface := Vest._get_editor_interface()
|
||||
var script_editor := editor_interface.get_script_editor() as ScriptEditor
|
||||
|
||||
var edited_script := script_editor.get_current_script()
|
||||
if not edited_script:
|
||||
# TODO: Polyfilled toast mechanism so user can see these warns
|
||||
push_warning("No script to run! Open a script in the script editor.")
|
||||
return
|
||||
|
||||
if not _is_ancestor_of(VestTest, edited_script):
|
||||
push_warning("Currently open script is not a test! Extend VestTest.")
|
||||
return
|
||||
|
||||
print_verbose("Running test \"%s\"" % [edited_script.resource_path])
|
||||
var vest_ui := VestUI._get_ui()
|
||||
vest_ui.run_script(edited_script, is_debug, only_mode)
|
||||
|
||||
func _is_ancestor_of(base_script: Script, script: Script) -> bool:
|
||||
for i in range(128): # Prevent runaway loops
|
||||
if script == null: break
|
||||
if base_script == script: return true
|
||||
|
||||
script = script.get_base_script()
|
||||
return false
|
||||
|
||||
func _ready():
|
||||
var editor := Vest._get_editor_interface()
|
||||
editor.get_command_palette().add_command("Run test", "vest/run-test", run_test, "F7")
|
||||
editor.get_command_palette().add_command("Debug test", "vest/debug-test", debug_test, "Ctrl+F7")
|
||||
|
||||
func _exit_tree():
|
||||
var editor := Vest._get_editor_interface()
|
||||
editor.get_command_palette().remove_command("vest/run-test")
|
||||
editor.get_command_palette().remove_command("vest/debug-test")
|
||||
|
||||
func _shortcut_input(event):
|
||||
if event is InputEventKey:
|
||||
if event.key_label == KEY_F7 and not event.shift_pressed and event.is_pressed():
|
||||
if event.is_command_or_control_pressed():
|
||||
debug_test()
|
||||
else:
|
||||
run_test()
|
||||
get_viewport().set_input_as_handled()
|
||||
@@ -0,0 +1 @@
|
||||
uid://owfqf5cu1gju
|
||||
Reference in New Issue
Block a user