first commit 🎉

This commit is contained in:
anyreso 2026-02-17 23:36:57 -05:00
commit 6e724f67fe
805 changed files with 62098 additions and 0 deletions

69
autoloads/game.gd Normal file
View file

@ -0,0 +1,69 @@
# This file is part of sunder.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends Node
## The list of available maps.
@export var maps:Array[PackedScene]
## The [Ping] manager.
@export var ping:Ping
## The [Map] instance
@export var map:Map
## The [Environment] used to keep track of user [Settings].
var environment := Environment.new()
signal exit
func change_scene_to_packed(packed:PackedScene) -> Node:
var tree:SceneTree = get_tree()
tree.change_scene_to_packed(packed)
await tree.scene_changed
return tree.current_scene
func change_scene(path:String = ProjectSettings.get("application/run/main_scene")) -> void:
_load_scene(path)
func _load_scene(path:String) -> void:
if FileAccess.file_exists(path):
var packed:PackedScene = load(path)
if packed:
change_scene_to_packed(packed)
func _unhandled_input(event:InputEvent) -> void:
if event.is_action_pressed("exit"):
# @TODO: confirm with user about exiting to main menu when the exit key
# is pressed before exiting (except when already in main menu)
exit.emit()
return
# switch window mode
if event.is_action_pressed("window_mode"):
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
# (dev only) retrieve pointer control with "mouse_mode" action (F1)
if OS.is_debug_build() and Input.is_action_just_pressed("mouse_mode"):
match Input.mouse_mode:
Input.MOUSE_MODE_VISIBLE:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
Input.MOUSE_MODE_CAPTURED:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func quit() -> void:
get_tree().quit()

1
autoloads/game.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://b6kpnfrqara76

15
autoloads/game.tscn Normal file
View file

@ -0,0 +1,15 @@
[gd_scene format=3 uid="uid://d1hctaeqptnww"]
[ext_resource type="Script" uid="uid://b6kpnfrqara76" path="res://autoloads/game.gd" id="1_x1hkl"]
[ext_resource type="PackedScene" uid="uid://rqirbdfmt2g6" path="res://scenes/maps/blaze/blaze.tscn" id="2_4v8jd"]
[ext_resource type="PackedScene" uid="uid://btlkog4b87p4x" path="res://scenes/maps/desert/desert.tscn" id="3_7vqsd"]
[ext_resource type="Script" uid="uid://cyobq87tprm0d" path="res://scripts/multiplayer/ping.gd" id="8_4xo4q"]
[node name="Game" type="Node" unique_id=1653944252 node_paths=PackedStringArray("ping")]
script = ExtResource("1_x1hkl")
maps = Array[PackedScene]([ExtResource("2_4v8jd"), ExtResource("3_7vqsd")])
ping = NodePath("Ping")
[node name="Ping" type="Timer" parent="." unique_id=1844061512]
script = ExtResource("8_4xo4q")
metadata/_custom_type_script = "uid://cyobq87tprm0d"

72
autoloads/settings.gd Normal file
View file

@ -0,0 +1,72 @@
# This file is part of sunder.
#
# This program is free software:you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## Wrapper around ConfigFile to manage game settings file.
extends Node
# @TODO: use res:// settings to load defaults when needed instead of hardcoding here
const settings_path:String = "res://config/settings.cfg"
const user_settings_path:String = "user://settings.cfg"
var _config_file:ConfigFile = ConfigFile.new()
func _ready() -> void:
# make sure we load most recent core settings
reset()
# merge core settings with user-defined settings
var err:Error = _config_file.load(user_settings_path)
if err == ERR_FILE_CANT_OPEN:
push_warning("settings not found, using defaults")
# save state
save()
func get_value(section:String, key:String, default:Variant = null) -> Variant:
return _config_file.get_value(section, key, default)
func set_value(section:String, key:String, value:Variant) -> void:
return _config_file.set_value(section, key, value)
func reset() -> void:
_config_file.clear()
# video settings
_config_file.set_value("ui", "scale", 2)
_config_file.set_value("video", "quality", 1.)
_config_file.set_value("video", "filter", 0)
_config_file.set_value("video", "fsr_sharpness", 0)
_config_file.set_value("video", "window_mode", 2)
_config_file.set_value("video", "vsync", 0)
_config_file.set_value("video", "taa", 0)
_config_file.set_value("video", "msaa", 0)
_config_file.set_value("video", "fxaa", 0)
_config_file.set_value("video", "fov", 90)
# controls settings
_config_file.set_value("controls", "mouse_sensitivity", .6)
_config_file.set_value("controls", "inverted_y_axis", false)
# quality settings
_config_file.set_value("quality", "shadow_size", 3)
_config_file.set_value("quality", "shadow_filter", 2)
_config_file.set_value("quality", "mesh_lod", 2)
# environment settings
_config_file.set_value("environment", "sdfgi", 0)
_config_file.set_value("environment", "glow", 0)
_config_file.set_value("environment", "ssao", 0)
_config_file.set_value("environment", "ssr", 0)
_config_file.set_value("environment", "ssil", 0)
_config_file.set_value("environment", "volumetric_fog", 0)
# server settings
_config_file.set_value("server", "host", "localhost")
_config_file.set_value("server", "port", 9000)
func save() -> void:
_config_file.save(user_settings_path)

View file

@ -0,0 +1 @@
uid://c1ffi8wwc08gy