env settings and maps / env management

This commit is contained in:
anyreso 2024-04-27 14:52:11 -04:00
parent e2a9353e7a
commit 2a676a519c
15 changed files with 761 additions and 474 deletions

File diff suppressed because it is too large Load diff

View file

@ -2,11 +2,25 @@
[ext_resource type="PackedScene" uid="uid://boviiugcnfyrj" path="res://modes/demo.tscn" id="1_50a80"]
[ext_resource type="PackedScene" uid="uid://bjctlqvs33nqy" path="res://interfaces/menus/boot/boot.tscn" id="1_acy5o"]
[ext_resource type="PackedScene" uid="uid://bvwxfgygm2xb8" path="res://modes/multiplayer.tscn" id="2_g8xeb"]
[ext_resource type="PackedScene" uid="uid://bvwxfgygm2xb8" path="res://modes/multiplayer/multiplayer.tscn" id="2_g8xeb"]
[ext_resource type="Resource" uid="uid://dut5f1sq0wfeb" path="res://maps/maps.tres" id="3_1ipir"]
[sub_resource type="GDScript" id="GDScript_e61dq"]
script/source = "class_name Game extends Node3D
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 Game extends Node3D
@export_category(\"Modes\")
@export var SINGLEPLAYER : PackedScene
@ -32,6 +46,7 @@ var mode : Node:
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _ready() -> void:
$BootMenu.start_demo.connect(_start_demo)
$BootMenu/MultiplayerPanelContainer.start_server.connect(_start_server)
@ -39,7 +54,8 @@ func _ready() -> void:
# 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\"):
# reset game mode
@ -73,7 +89,7 @@ func _start_server(port : int, nickname : String) -> void:
mode.start_server({
\"port\": port,
\"nickname\": nickname,
\"map\": maps[clamp($BootMenu/Multiplayer.map_selector.selected, 0, len(maps))]
\"map\": maps[clamp($BootMenu/MultiplayerPanelContainer.map_selector.selected, 0, len(maps))]
})
$BootMenu.hide()

View file

@ -1,27 +1,23 @@
[gd_scene load_steps=6 format=3 uid="uid://btlkog4b87p4x"]
[gd_scene load_steps=5 format=3 uid="uid://btlkog4b87p4x"]
[ext_resource type="Terrain3DStorage" uid="uid://wgmg245njt8e" path="res://maps/desert/resources/storage.res" id="1_7nbyj"]
[ext_resource type="Environment" uid="uid://nw62ce5cglvs" path="res://environments/desert.tres" id="1_e1o3u"]
[ext_resource type="Terrain3DMaterial" uid="uid://c3isipd4wqxpk" path="res://maps/desert/resources/material.tres" id="2_psdr0"]
[ext_resource type="Terrain3DTextureList" uid="uid://d1j24k8sq8qpj" path="res://maps/desert/resources/textures.tres" id="3_aowug"]
[ext_resource type="Script" path="res://maps/map.gd" id="4_cl7fm"]
[ext_resource type="Environment" uid="uid://nw62ce5cglvs" path="res://maps/desert/resources/env.tres" id="5_4l4vc"]
[node name="Desert" type="Terrain3D" node_paths=PackedStringArray("_flagstand", "_player_spawns_root")]
[node name="Desert" type="Terrain3D"]
storage = ExtResource("1_7nbyj")
material = ExtResource("2_psdr0")
texture_list = ExtResource("3_aowug")
collision_layer = 2147483648
collision_mask = 2147483648
script = ExtResource("4_cl7fm")
_flagstand = NodePath("FlagStand")
_player_spawns_root = NodePath("PlayerSpawns")
[node name="Sunlight" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.5, 0.55667, -0.663414, 0, 0.766044, 0.642788, 0.866025, -0.321394, 0.383022, -1613.38, 2730.74, 446.64)
shadow_enabled = true
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = ExtResource("1_e1o3u")
environment = ExtResource("5_4l4vc")
[node name="PlayerSpawns" type="Node" parent="."]
@ -33,3 +29,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1161.42, 174.535, 909.901)
[node name="FlagStand" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 878.613, 134.55, 916.185)
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 1024, 920, 1024)

View file

@ -1,21 +1,24 @@
[gd_scene load_steps=6 format=3 uid="uid://chbno00ugl6te"]
[gd_scene load_steps=5 format=3 uid="uid://chbno00ugl6te"]
[ext_resource type="Environment" uid="uid://d2ahijqqspw5f" path="res://environments/default.tres" id="1_3nr12"]
[ext_resource type="Script" path="res://maps/map.gd" id="1_6ysiv"]
[ext_resource type="Terrain3DStorage" uid="uid://dyon4xda4k40d" path="res://maps/genesis/resources/storage.res" id="1_a88qe"]
[ext_resource type="Terrain3DMaterial" uid="uid://bd4lr5sxu8xu" path="res://maps/genesis/resources/material.res" id="2_o2y3d"]
[ext_resource type="Terrain3DTextureList" uid="uid://dnqa8kxgm3xuw" path="res://maps/genesis/resources/textures.res" id="3_1cww7"]
[ext_resource type="Environment" uid="uid://d2ahijqqspw5f" path="res://maps/genesis/resources/env.tres" id="5_3klr3"]
[node name="Genesis" type="Terrain3D" node_paths=PackedStringArray("_flagstand", "_player_spawns_root")]
[node name="Genesis" type="Terrain3D"]
storage = ExtResource("1_a88qe")
material = ExtResource("2_o2y3d")
texture_list = ExtResource("3_1cww7")
collision_layer = 2147483648
collision_mask = 2147483648
mesh_size = 24
script = ExtResource("1_6ysiv")
_flagstand = NodePath("FlagPillar/CSGCylinder3D/FlagStand")
_player_spawns_root = NodePath("PlayerSpawns")
[node name="Sunlight" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866024, -0.433016, 0.25, 0, 0.499998, 0.866027, -0.500003, 0.75, -0.43301, 0, 100, 0)
shadow_enabled = true
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = ExtResource("5_3klr3")
[node name="PlayerSpawns" type="Node" parent="."]
@ -39,12 +42,5 @@ size = Vector3(0.5, 6, 0.5)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.42967, 0)
height = 5.0
[node name="FlagStand" type="Marker3D" parent="FlagPillar/CSGCylinder3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.53822, 0)
[node name="Sunlight" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866024, -0.433016, 0.25, 0, 0.499998, 0.866027, -0.500003, 0.75, -0.43301, 0, 100, 0)
shadow_enabled = true
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = ExtResource("1_3nr12")
[node name="FlagStand" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 108.644, 0)

View file

@ -1,15 +0,0 @@
class_name Map extends Terrain3D
@export var _flagstand : Node3D
@export var _player_spawns_root : Node
var _rng : RandomNumberGenerator = RandomNumberGenerator.new()
func get_flagstand() -> Node3D:
return _flagstand
func get_player_spawn() -> Node3D:
var spawn_count : int = _player_spawns_root.get_child_count()
var spawn_index : int = _rng.randi_range(0, spawn_count - 1)
var spawn_selected : Node3D = _player_spawns_root.get_child(spawn_index)
return spawn_selected

View file

@ -15,6 +15,7 @@ script/source = "extends Node
func _ready() -> void:
player_node.died.connect(respawn_player)
MapsManager.current_map = $Desert
func respawn_player(player : Player, _killer_id : int) -> void:
player.respawn(player_respawn_location)

View file

@ -25,7 +25,6 @@ class_name Multiplayer extends Node
@onready var map : Node = $Map
@onready var scoreboard : Scoreboard = $Scoreboard
var _map_manager : Map
var _flag : Flag
var _flag_carrier_scoring_timer : Timer = Timer.new()
@ -85,17 +84,17 @@ func _on_player_died(player : Player, killer_id : int) -> void:
respawn_player(player)
func respawn_player(player : Player) -> void:
var spawn_location : Vector3 = _map_manager.get_player_spawn().position
var spawn_location : Vector3 = MapsManager.get_player_spawn().position
player.respawn.rpc(spawn_location)
func add_player(peer_id : int, nickname : String) -> void:
var player : Player = PLAYER.instantiate()
players.add_child(player)grep
player.name = str(peer_id)
player.player_id = peer_id
player.team_id = team_chasers.team_id
player.nickname = nickname
player.global_position = _map_manager.get_player_spawn().position
players.add_child(player)
player.global_position = MapsManager.get_player_spawn().position
player.died.connect(_on_player_died)
scoreboard.add_player(player)
print("Peer `%s` connected" % player.name)
@ -111,17 +110,17 @@ func remove_player(peer_id : int) -> void:
func _load_map(scene : PackedScene, nickname : String) -> void:
var map_scene : Node = scene.instantiate()
_map_manager = map_scene
map_scene.ready.connect(_add_flag)
map.add_child(map_scene)
MapsManager.current_map = map_scene
MapsManager.current_map.ready.connect(_add_flag)
if DisplayServer.get_name() != "headless":
add_player(1, nickname)
map.add_child(map_scene)
func _add_flag() -> void:
_flag = FLAG.instantiate()
_flag.grabbed.connect(_on_flag_grabbed)
_flag.dropped.connect(_on_flag_dropped)
_flag.global_position = _map_manager.get_flagstand().global_position
_flag.global_position = MapsManager.flagstand.global_position
objectives.add_child(_flag)
@rpc("any_peer", "reliable")

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=5 format=3 uid="uid://bvwxfgygm2xb8"]
[ext_resource type="Script" path="res://modes/multiplayer.gd" id="1_r1kd6"]
[ext_resource type="Script" path="res://modes/multiplayer/multiplayer.gd" id="1_r1kd6"]
[ext_resource type="PackedScene" uid="uid://cbhx1xme0sb7k" path="res://entities/player/player.tscn" id="2_og1vb"]
[ext_resource type="PackedScene" uid="uid://c88l3h0ph00c7" path="res://entities/flag/flag.tscn" id="3_h0rie"]
[ext_resource type="PackedScene" uid="uid://b8bosdd0o1lu7" path="res://interfaces/scoreboard/scoreboard.tscn" id="5_uj0pp"]
@ -9,6 +9,8 @@
script = ExtResource("1_r1kd6")
PLAYER = ExtResource("2_og1vb")
FLAG = ExtResource("3_h0rie")
MAX_CLIENTS = null
RESPAWN_TIME = null
[node name="Map" type="Node" parent="."]

View file

@ -1,3 +0,0 @@
class_name Team extends Object
var team_id : int

View file

@ -18,6 +18,7 @@ config/icon="res://icon.svg"
[autoload]
Settings="*res://systems/settings.gd"
MapsManager="*res://systems/maps_manager.gd"
[debug]

55
systems/maps_manager.gd Normal file
View file

@ -0,0 +1,55 @@
# 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
var environment := Environment.new()
var flagstand : Marker3D = null
var _rng := RandomNumberGenerator.new()
var current_map : Terrain3D = null:
set(new_map):
if current_map != null:
current_map.queue_free()
current_map = new_map
flagstand = new_map.get_node("FlagStand")
var world : World3D = get_viewport().find_world_3d()
if world.environment:
# forward user environment settings
world.environment.sdfgi_enabled = MapsManager.environment.sdfgi_enabled
world.environment.glow_enabled = MapsManager.environment.glow_enabled
world.environment.ssao_enabled = MapsManager.environment.ssao_enabled
world.environment.ssr_enabled = MapsManager.environment.ssr_enabled
world.environment.ssr_max_steps = MapsManager.environment.ssr_max_steps
world.environment.ssil_enabled = MapsManager.environment.ssil_enabled
world.environment.volumetric_fog_enabled = MapsManager.environment.volumetric_fog_enabled
func get_player_spawn() -> Node3D:
if current_map == null:
push_error("MapsManager.current_map is null")
return null
if not current_map.has_node("PlayerSpawns"):
push_warning("PlayerSpawns node not found in MapsManager.current_map")
return null
var player_spawns : Node = current_map.get_node("PlayerSpawns")
var spawn_count : int = player_spawns.get_child_count()
if spawn_count == 0:
push_error("PlayerSpawns has no children (%s)" % current_map.name)
return null
var spawn_index : int = _rng.randi_range(0, spawn_count - 1)
var random_spawn : Marker3D = player_spawns.get_child(spawn_index)
return random_spawn

View file

@ -1,3 +1,17 @@
# 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
var _file : ConfigFile = ConfigFile.new()
@ -42,7 +56,7 @@ func reset() -> void:
# environment settings
_file.set_value("environment", "sdfgi", 0)
_file.set_value("environment", "glow", 0)
_file.set_value("environment", "saoo", 0)
_file.set_value("environment", "ssao", 0)
_file.set_value("environment", "ssr", 0)
_file.set_value("environment", "ssil", 0)
_file.set_value("environment", "volumetric_fog", 0)

17
systems/teams.gd Normal file
View file

@ -0,0 +1,17 @@
# 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 Team extends Object
var team_id : int