mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-16 00:44:50 +00:00
♻️ systems refactoring
This commit is contained in:
parent
5ab387571e
commit
69c8b65093
17 changed files with 186 additions and 168 deletions
|
|
@ -13,7 +13,7 @@ signal nickname_changed(new_nickname : String)
|
||||||
player_id_changed.emit(player_id)
|
player_id_changed.emit(player_id)
|
||||||
@export var team_id : int = 1
|
@export var team_id : int = 1
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
func _ready() -> void:
|
||||||
root_path = "."
|
root_path = "."
|
||||||
replication_config = SceneReplicationConfig.new()
|
replication_config = SceneReplicationConfig.new()
|
||||||
for prop : String in ["player_id", "team_id", "nickname"]:
|
for prop : String in ["player_id", "team_id", "nickname"]:
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ func _setup_pawn(_new_player_id : int) -> void:
|
||||||
|
|
||||||
func _is_pawn() -> bool:
|
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_component.player_id
|
||||||
return Game.mode is Singleplayer or peer_is_pawn
|
return Global.type is Singleplayer or peer_is_pawn
|
||||||
|
|
||||||
# @NOTE: this method works only because `tp_mesh` duplicates weapons meshes from the inventory
|
# @NOTE: this method works only because `tp_mesh` duplicates weapons meshes from the inventory
|
||||||
func _on_inventory_selection_changed(_selected : Node3D, index : int) -> void:
|
func _on_inventory_selection_changed(_selected : Node3D, index : int) -> void:
|
||||||
|
|
|
||||||
|
|
@ -263,6 +263,10 @@ replication_config = SubResource("SceneReplicationConfig_rqdp6")
|
||||||
root_path = NodePath(".")
|
root_path = NodePath(".")
|
||||||
replication_config = SubResource("SceneReplicationConfig_5j4ew")
|
replication_config = SubResource("SceneReplicationConfig_5j4ew")
|
||||||
script = ExtResource("6_ymcrr")
|
script = ExtResource("6_ymcrr")
|
||||||
|
jetting = null
|
||||||
|
skiing = null
|
||||||
|
direction = null
|
||||||
|
camera_rotation = null
|
||||||
|
|
||||||
[node name="MatchParticipantComponent" type="MultiplayerSynchronizer" parent="."]
|
[node name="MatchParticipantComponent" type="MultiplayerSynchronizer" parent="."]
|
||||||
root_path = NodePath(".")
|
root_path = NodePath(".")
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ func trigger() -> void:
|
||||||
owner.match_participant_component
|
owner.match_participant_component
|
||||||
)
|
)
|
||||||
# add to owner of player for now
|
# add to owner of player for now
|
||||||
Game.mode.add_child(projectile)
|
Global.type.add_child(projectile)
|
||||||
projectile.shape_cast.add_exception(owner)
|
projectile.shape_cast.add_exception(owner)
|
||||||
|
|
||||||
func _on_visibility_changed() -> void:
|
func _on_visibility_changed() -> void:
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ func trigger() -> void:
|
||||||
owner.match_participant_component
|
owner.match_participant_component
|
||||||
)
|
)
|
||||||
# add to owner of player for now
|
# add to owner of player for now
|
||||||
Game.mode.add_child(projectile)
|
Global.type.add_child(projectile)
|
||||||
|
|
||||||
func _on_visibility_changed() -> void:
|
func _on_visibility_changed() -> void:
|
||||||
if self.visible:
|
if self.visible:
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ script = ExtResource("2_38xn3")
|
||||||
anim_player = NodePath("AnimationPlayer")
|
anim_player = NodePath("AnimationPlayer")
|
||||||
|
|
||||||
[node name="ProjectileSpawner" type="Node3D" parent="." index="0"]
|
[node name="ProjectileSpawner" type="Node3D" parent="." index="0"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.266945)
|
||||||
script = ExtResource("4_5h5sw")
|
script = ExtResource("4_5h5sw")
|
||||||
PROJECTILE = ExtResource("3_rg5nk")
|
PROJECTILE = ExtResource("3_rg5nk")
|
||||||
inheritance = 0.75
|
inheritance = 0.75
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ func trigger() -> void:
|
||||||
owner.match_participant_component
|
owner.match_participant_component
|
||||||
)
|
)
|
||||||
# add to owner of player for now
|
# add to owner of player for now
|
||||||
Game.mode.add_child(projectile)
|
Global.type.add_child(projectile)
|
||||||
# ensure projectile does not collide with owner
|
# ensure projectile does not collide with owner
|
||||||
var collider : ShapeCast3D = projectile.shape_cast
|
var collider : ShapeCast3D = projectile.shape_cast
|
||||||
collider.add_exception(owner)
|
collider.add_exception(owner)
|
||||||
|
|
|
||||||
45
interfaces/menus/boot/boot.gd
Normal file
45
interfaces/menus/boot/boot.gd
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
# This file is part of open-fpsz.
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
class_name BootMenu extends CanvasLayer
|
||||||
|
|
||||||
|
signal start_demo
|
||||||
|
|
||||||
|
func _on_demo_pressed() -> void:
|
||||||
|
start_demo.emit()
|
||||||
|
|
||||||
|
func _on_multiplayer_pressed() -> void:
|
||||||
|
$MultiplayerPanelContainer.hide()
|
||||||
|
$MultiplayerPanelContainer.tab_container.current_tab = 0
|
||||||
|
$SettingsPanelContainer.hide()
|
||||||
|
$MainPanelContainer.hide()
|
||||||
|
$MultiplayerPanelContainer.show()
|
||||||
|
show()
|
||||||
|
|
||||||
|
func _on_settings_pressed() -> void:
|
||||||
|
$MultiplayerPanelContainer.hide()
|
||||||
|
$MultiplayerPanelContainer.tab_container.current_tab = 0
|
||||||
|
$SettingsPanelContainer.show()
|
||||||
|
$MainPanelContainer.hide()
|
||||||
|
show()
|
||||||
|
|
||||||
|
func _on_quit_pressed() -> void:
|
||||||
|
get_tree().quit()
|
||||||
|
|
||||||
|
func _on_main_menu_pressed() -> void:
|
||||||
|
$MultiplayerPanelContainer.hide()
|
||||||
|
$MultiplayerPanelContainer.tab_container.current_tab = 0
|
||||||
|
$SettingsPanelContainer.hide()
|
||||||
|
$MainPanelContainer.show()
|
||||||
|
show()
|
||||||
|
|
@ -1,56 +1,8 @@
|
||||||
[gd_scene load_steps=28 format=3 uid="uid://bjctlqvs33nqy"]
|
[gd_scene load_steps=28 format=3 uid="uid://bjctlqvs33nqy"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://interfaces/menus/boot/boot.gd" id="1_6acql"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c1tjamjm8qjog" path="res://interfaces/menus/boot/background.webp" id="1_ph586"]
|
[ext_resource type="Texture2D" uid="uid://c1tjamjm8qjog" path="res://interfaces/menus/boot/background.webp" id="1_ph586"]
|
||||||
|
|
||||||
[sub_resource type="GDScript" id="GDScript_jd8xf"]
|
|
||||||
resource_name = "MainMenu"
|
|
||||||
script/source = "# This file is part of open-fpsz.
|
|
||||||
#
|
|
||||||
# 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/>.
|
|
||||||
class_name BootMenu extends CanvasLayer
|
|
||||||
|
|
||||||
signal start_demo
|
|
||||||
|
|
||||||
func _on_demo_pressed() -> void:
|
|
||||||
start_demo.emit()
|
|
||||||
|
|
||||||
func _on_multiplayer_pressed() -> void:
|
|
||||||
$MultiplayerPanelContainer.hide()
|
|
||||||
$MultiplayerPanelContainer.tab_container.current_tab = 0
|
|
||||||
$SettingsPanelContainer.hide()
|
|
||||||
$MainPanelContainer.hide()
|
|
||||||
$MultiplayerPanelContainer.show()
|
|
||||||
show()
|
|
||||||
|
|
||||||
func _on_settings_pressed() -> void:
|
|
||||||
$MultiplayerPanelContainer.hide()
|
|
||||||
$MultiplayerPanelContainer.tab_container.current_tab = 0
|
|
||||||
$SettingsPanelContainer.show()
|
|
||||||
$MainPanelContainer.hide()
|
|
||||||
show()
|
|
||||||
|
|
||||||
func _on_quit_pressed() -> void:
|
|
||||||
get_tree().quit()
|
|
||||||
|
|
||||||
func _on_main_menu_pressed() -> void:
|
|
||||||
$MultiplayerPanelContainer.hide()
|
|
||||||
$MultiplayerPanelContainer.tab_container.current_tab = 0
|
|
||||||
$SettingsPanelContainer.hide()
|
|
||||||
$MainPanelContainer.show()
|
|
||||||
show()
|
|
||||||
"
|
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_krqeq"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_krqeq"]
|
||||||
bg_color = Color(0.501961, 0.501961, 0.501961, 0.25098)
|
bg_color = Color(0.501961, 0.501961, 0.501961, 0.25098)
|
||||||
|
|
||||||
|
|
@ -1052,7 +1004,7 @@ bg_color = Color(0, 0, 0, 0)
|
||||||
bg_color = Color(0, 0.5, 0.5, 0.2)
|
bg_color = Color(0, 0.5, 0.5, 0.2)
|
||||||
|
|
||||||
[node name="BootMenu" type="CanvasLayer"]
|
[node name="BootMenu" type="CanvasLayer"]
|
||||||
script = SubResource("GDScript_jd8xf")
|
script = ExtResource("1_6acql")
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="."]
|
[node name="TextureRect" type="TextureRect" parent="."]
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
|
|
||||||
63
main.gd
Normal file
63
main.gd
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
# This file is part of open-fpsz.
|
||||||
|
#
|
||||||
|
# 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 Node3D
|
||||||
|
|
||||||
|
@export_category("Modes")
|
||||||
|
@export var SINGLEPLAYER : PackedScene
|
||||||
|
@export var MULTIPLAYER : PackedScene
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
# only run server in headless
|
||||||
|
if DisplayServer.get_name() == "headless":
|
||||||
|
Global.type = MULTIPLAYER.instantiate()
|
||||||
|
Global.type.start_server(9000, MapsManager.maps[MapsManager._rng.randi_range(0, len(MapsManager.maps) - 1)])
|
||||||
|
return
|
||||||
|
# connect boot menu signals
|
||||||
|
$BootMenu.start_demo.connect(_start_demo)
|
||||||
|
$BootMenu/MultiplayerPanelContainer.start_server.connect(_start_server)
|
||||||
|
$BootMenu/MultiplayerPanelContainer.join_server.connect(_join_server)
|
||||||
|
# do not set initial window mode for debug build
|
||||||
|
if not OS.is_debug_build():
|
||||||
|
DisplayServer.window_set_mode(Settings.get_value("video", "window_mode"))
|
||||||
|
|
||||||
|
func _unhandled_input(event : InputEvent) -> void:
|
||||||
|
if event.is_action_pressed("exit"):
|
||||||
|
if Global.type is Multiplayer:
|
||||||
|
$BootMenu._on_multiplayer_pressed()
|
||||||
|
else:
|
||||||
|
$BootMenu._on_main_menu_pressed()
|
||||||
|
# reset game mode and get back to main menu
|
||||||
|
Global.type = null
|
||||||
|
if DisplayServer.get_name() != "headless":
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||||
|
return
|
||||||
|
|
||||||
|
func _start_demo() -> void:
|
||||||
|
Global.type = SINGLEPLAYER.instantiate()
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
|
$BootMenu.hide()
|
||||||
|
|
||||||
|
func _start_server(port : int, nickname : String) -> void:
|
||||||
|
Global.type = MULTIPLAYER.instantiate()
|
||||||
|
Global.type.start_server(port, MapsManager.maps[$BootMenu/MultiplayerPanelContainer.map_selector.selected], nickname)
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
|
$BootMenu.hide()
|
||||||
|
|
||||||
|
func _join_server(host : String, port : int, nickname : String) -> void:
|
||||||
|
Global.type = MULTIPLAYER.instantiate()
|
||||||
|
Global.type.connected_to_server.connect($BootMenu/MultiplayerPanelContainer._on_connected_to_server)
|
||||||
|
Global.type.connection_failed.connect($BootMenu/MultiplayerPanelContainer._on_connection_failed)
|
||||||
|
Global.type.join_server(host, port, nickname)
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
83
main.tscn
83
main.tscn
|
|
@ -1,91 +1,12 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://dr8salxjlpsba"]
|
[gd_scene load_steps=5 format=3 uid="uid://dr8salxjlpsba"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://main.gd" id="1_opvjh"]
|
||||||
[ext_resource type="PackedScene" uid="uid://boviiugcnfyrj" path="res://modes/singleplayer/demo.tscn" id="1_vgk6g"]
|
[ext_resource type="PackedScene" uid="uid://boviiugcnfyrj" path="res://modes/singleplayer/demo.tscn" id="1_vgk6g"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bvwxfgygm2xb8" path="res://modes/multiplayer/multiplayer.tscn" id="2_iumx3"]
|
[ext_resource type="PackedScene" uid="uid://bvwxfgygm2xb8" path="res://modes/multiplayer/multiplayer.tscn" id="2_iumx3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bjctlqvs33nqy" path="res://interfaces/menus/boot/boot.tscn" id="3_s8c8j"]
|
[ext_resource type="PackedScene" uid="uid://bjctlqvs33nqy" path="res://interfaces/menus/boot/boot.tscn" id="3_s8c8j"]
|
||||||
|
|
||||||
[sub_resource type="GDScript" id="GDScript_e61dq"]
|
|
||||||
script/source = "# This file is part of open-fpsz.
|
|
||||||
#
|
|
||||||
# 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 Node3D
|
|
||||||
|
|
||||||
@export_category(\"Modes\")
|
|
||||||
@export var SINGLEPLAYER : PackedScene
|
|
||||||
@export var MULTIPLAYER : PackedScene
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
# only run server in headless
|
|
||||||
if DisplayServer.get_name() == \"headless\":
|
|
||||||
Game.mode = MULTIPLAYER.instantiate()
|
|
||||||
Game.mode.start_server(9000, MapsManager.maps[MapsManager._rng.randi_range(0, len(MapsManager.maps) - 1)])
|
|
||||||
return
|
|
||||||
# connect boot menu signals
|
|
||||||
$BootMenu.start_demo.connect(_start_demo)
|
|
||||||
$BootMenu/MultiplayerPanelContainer.start_server.connect(_start_server)
|
|
||||||
$BootMenu/MultiplayerPanelContainer.join_server.connect(_join_server)
|
|
||||||
# do not set initial window mode for debug build
|
|
||||||
if not OS.is_debug_build():
|
|
||||||
DisplayServer.window_set_mode(Settings.get_value(\"video\", \"window_mode\"))
|
|
||||||
|
|
||||||
func _unhandled_input(event : InputEvent) -> void:
|
|
||||||
if event.is_action_pressed(\"exit\"):
|
|
||||||
if Game.mode is Multiplayer:
|
|
||||||
$BootMenu._on_multiplayer_pressed()
|
|
||||||
else:
|
|
||||||
$BootMenu._on_main_menu_pressed()
|
|
||||||
# reset game mode and get back to main menu
|
|
||||||
Game.mode = null
|
|
||||||
if DisplayServer.get_name() != \"headless\":
|
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
||||||
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)
|
|
||||||
# switch mouse mode
|
|
||||||
if OS.is_debug_build() and Input.is_action_just_pressed(\"toggle_mouse_capture\"):
|
|
||||||
if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE:
|
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
||||||
elif Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
||||||
|
|
||||||
|
|
||||||
func _start_demo() -> void:
|
|
||||||
Game.mode = SINGLEPLAYER.instantiate()
|
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
||||||
$BootMenu.hide()
|
|
||||||
|
|
||||||
func _start_server(port : int, nickname : String) -> void:
|
|
||||||
Game.mode = MULTIPLAYER.instantiate()
|
|
||||||
Game.mode.start_server(port, MapsManager.maps[$BootMenu/MultiplayerPanelContainer.map_selector.selected], nickname)
|
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
||||||
$BootMenu.hide()
|
|
||||||
|
|
||||||
func _join_server(host : String, port : int, nickname : String) -> void:
|
|
||||||
Game.mode = MULTIPLAYER.instantiate()
|
|
||||||
Game.mode.connected_to_server.connect($BootMenu/MultiplayerPanelContainer._on_connected_to_server)
|
|
||||||
Game.mode.connection_failed.connect($BootMenu/MultiplayerPanelContainer._on_connection_failed)
|
|
||||||
Game.mode.join_server(host, port, nickname)
|
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
||||||
"
|
|
||||||
|
|
||||||
[node name="Main" type="Node3D"]
|
[node name="Main" type="Node3D"]
|
||||||
script = SubResource("GDScript_e61dq")
|
script = ExtResource("1_opvjh")
|
||||||
SINGLEPLAYER = ExtResource("1_vgk6g")
|
SINGLEPLAYER = ExtResource("1_vgk6g")
|
||||||
MULTIPLAYER = ExtResource("2_iumx3")
|
MULTIPLAYER = ExtResource("2_iumx3")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
[gd_resource type="Resource" script_class="ArrayPackedSceneResource" load_steps=3 format=3 uid="uid://dut5f1sq0wfeb"]
|
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://btlkog4b87p4x" path="res://maps/desert/desert.tscn" id="2_8vsif"]
|
|
||||||
[ext_resource type="Script" path="res://types/resources/array_packed_scene.gd" id="3_by6r1"]
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
script = ExtResource("3_by6r1")
|
|
||||||
_packed_scenes = Array[PackedScene]([ExtResource("2_8vsif")])
|
|
||||||
|
|
@ -17,9 +17,9 @@ config/icon="res://icon.svg"
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
|
Global="*res://systems/global.gd"
|
||||||
Settings="*res://systems/settings.gd"
|
Settings="*res://systems/settings.gd"
|
||||||
MapsManager="*res://systems/maps_manager.gd"
|
MapsManager="*res://systems/MapsManager.tscn"
|
||||||
Game="*res://systems/game.gd"
|
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
|
|
||||||
|
|
@ -102,6 +102,11 @@ window_mode={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194342,"key_label":0,"unicode":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194342,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
mouse_mode={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194332,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
fire_primary={
|
fire_primary={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||||
|
|
@ -112,11 +117,6 @@ throw_flag={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
toggle_mouse_capture={
|
|
||||||
"deadzone": 0.5,
|
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194332,"key_label":0,"unicode":0,"echo":false,"script":null)
|
|
||||||
]
|
|
||||||
}
|
|
||||||
scoreboard={
|
scoreboard={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
|
|
||||||
8
systems/MapsManager.tscn
Normal file
8
systems/MapsManager.tscn
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://c4h2mdvdwndxl"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://systems/maps_manager.gd" id="1_a1ovw"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://btlkog4b87p4x" path="res://maps/desert/desert.tscn" id="2_v1r16"]
|
||||||
|
|
||||||
|
[node name="MapsManager" type="Node"]
|
||||||
|
script = ExtResource("1_a1ovw")
|
||||||
|
maps = Array[PackedScene]([ExtResource("2_v1r16")])
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
extends Node
|
|
||||||
|
|
||||||
## This is the mode currently used by the game.
|
|
||||||
var mode : Node:
|
|
||||||
set(new_mode):
|
|
||||||
# clean up previous mode
|
|
||||||
if mode != null:
|
|
||||||
mode.queue_free()
|
|
||||||
# keep reference to new mode
|
|
||||||
mode = new_mode
|
|
||||||
# setup new mode
|
|
||||||
if new_mode != null:
|
|
||||||
add_child(new_mode)
|
|
||||||
46
systems/global.gd
Normal file
46
systems/global.gd
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
# This file is part of open-fpsz.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
signal type_changed(type : Node)
|
||||||
|
|
||||||
|
## This is the type currently used by the game.
|
||||||
|
var type : Node:
|
||||||
|
set(new_type):
|
||||||
|
# clean up previous type
|
||||||
|
if type != null:
|
||||||
|
type.queue_free()
|
||||||
|
# swap types
|
||||||
|
if type != new_type:
|
||||||
|
# keep reference to new type
|
||||||
|
type = new_type
|
||||||
|
if type != null:
|
||||||
|
add_child(type)
|
||||||
|
type_changed.emit(type)
|
||||||
|
|
||||||
|
func _unhandled_input(event : InputEvent) -> void:
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
# switch mouse mode
|
||||||
|
if OS.is_debug_build() and Input.is_action_just_pressed("mouse_mode"):
|
||||||
|
if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE:
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
|
elif Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||||
|
|
@ -15,6 +15,9 @@
|
||||||
## Manage environment settings and terrain maps within a scene.
|
## Manage environment settings and terrain maps within a scene.
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
## The list of available maps.
|
||||||
|
@export var maps : Array[PackedScene]
|
||||||
|
|
||||||
## The default [Environment] used by the current scene in case the [Terrain3D]
|
## The default [Environment] used by the current scene in case the [Terrain3D]
|
||||||
## node does not have a [WorldEnvironment] as one of its children.
|
## node does not have a [WorldEnvironment] as one of its children.
|
||||||
var environment := Environment.new()
|
var environment := Environment.new()
|
||||||
|
|
@ -22,9 +25,6 @@ var environment := Environment.new()
|
||||||
## Random number generator instance
|
## Random number generator instance
|
||||||
var _rng := RandomNumberGenerator.new()
|
var _rng := RandomNumberGenerator.new()
|
||||||
|
|
||||||
var _maps_resource : ArrayPackedSceneResource = preload("res://maps/maps.tres")
|
|
||||||
var maps : Array[PackedScene] = _maps_resource.get_items()
|
|
||||||
|
|
||||||
## Reference to the current terrain map in the scene
|
## Reference to the current terrain map in the scene
|
||||||
var current_map : Terrain3D = null:
|
var current_map : Terrain3D = null:
|
||||||
set(new_map):
|
set(new_map):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue