mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-15 00:14:48 +00:00
✨ jetpack stuttering, physics updates, deps upgrades
This commit is contained in:
parent
36168ed18c
commit
bbf551f3fa
101 changed files with 2302 additions and 1740 deletions
|
|
@ -37,7 +37,7 @@ enum Mode {
|
|||
## The multiplayer mode.
|
||||
@export var mode : Mode = Mode.FREE_FOR_ALL
|
||||
## The current map node.
|
||||
@export var map : Node: set = set_map
|
||||
@export var map : Node
|
||||
## The maximum number of clients.
|
||||
@export var MAX_CLIENTS := 24
|
||||
## The time it takes for a player to respawn when killed, secconds (s).
|
||||
|
|
@ -79,8 +79,8 @@ func is_peer_connected() -> bool:
|
|||
|
||||
func set_map(new_map: Node) -> void:
|
||||
map = new_map
|
||||
map_root.add_child(map)
|
||||
MapsManager.current_map = map
|
||||
map_root.add_child(map)
|
||||
|
||||
## This method starts a server.
|
||||
func start_server(port : int, map_scene : PackedScene, _mode: Mode = mode, username : String = "mercury") -> void:
|
||||
|
|
@ -96,6 +96,8 @@ func start_server(port : int, map_scene : PackedScene, _mode: Mode = mode, usern
|
|||
add_child(timer)
|
||||
|
||||
map = map_scene.instantiate()
|
||||
map_root.add_child(map)
|
||||
|
||||
mode = _mode
|
||||
|
||||
ping.synchronized.connect(scoreboard._on_ping_sync)
|
||||
|
|
@ -103,14 +105,13 @@ func start_server(port : int, map_scene : PackedScene, _mode: Mode = mode, usern
|
|||
match mode:
|
||||
Mode.RABBIT:
|
||||
var flag : Flag = _FLAG.instantiate()
|
||||
var flagstand : Marker3D = map.get_node("FlagStand")
|
||||
objectives.add_child(flag)
|
||||
if flagstand:
|
||||
flag.global_position = flagstand.global_position
|
||||
var spawn : Node3D = map.get_objective_spawn()
|
||||
flag.global_position = spawn.global_position
|
||||
flag.respawn_timer.timeout.connect(func() -> void:
|
||||
if flagstand:
|
||||
if spawn:
|
||||
flag.waypoint.text = ""
|
||||
flag.global_position = flagstand.global_position
|
||||
flag.global_position = spawn.global_position
|
||||
flag.state = flag.FlagState.ON_STAND
|
||||
)
|
||||
|
||||
|
|
@ -191,9 +192,8 @@ func _start_match() -> void:
|
|||
if player.has_flag():
|
||||
var flag: Flag = player.flag_carry_component._flag
|
||||
player.flag_carry_component.drop(player.linear_velocity)
|
||||
var flagstand : Marker3D = map.get_node("FlagStand")
|
||||
if flagstand:
|
||||
flag.global_position = flagstand.global_position
|
||||
var spawn : Node3D = map.get_objective_spawn()
|
||||
flag.global_position = spawn.global_position
|
||||
scoreboard.reset_scores()
|
||||
timer.start(MATCH_DURATION) # restart timer with match duration
|
||||
players.respawn() # respawn everyone
|
||||
|
|
@ -211,9 +211,8 @@ func _on_post_match() -> void:
|
|||
if player.has_flag():
|
||||
var flag: Flag = player.flag_carry_component._flag
|
||||
player.flag_carry_component.drop(player.linear_velocity)
|
||||
var flagstand : Marker3D = map.get_node("FlagStand")
|
||||
if flagstand:
|
||||
flag.global_position = flagstand.global_position
|
||||
var spawn : Node3D = map.get_objective_spawn()
|
||||
flag.global_position = spawn.global_position
|
||||
# restart match
|
||||
_start_match()
|
||||
|
||||
|
|
@ -224,6 +223,8 @@ func join_server(host : String, port : int, username : String) -> void:
|
|||
multiplayer.connection_failed.connect(_on_connection_failed)
|
||||
multiplayer.server_disconnected.connect(_on_server_disconnected)
|
||||
multiplayer.multiplayer_peer = peer
|
||||
if map_root.get_child_count() > 0:
|
||||
map = map_root.get_child(0)
|
||||
|
||||
func _on_server_disconnected() -> void:
|
||||
Game.exit_pressed.emit()
|
||||
|
|
@ -242,7 +243,7 @@ func add_player(_peer_id : int, username : String) -> void:
|
|||
# @NOTE: player scene requires both params prior being added to the tree
|
||||
players.add_child(player)
|
||||
# @TODO: get spawn location randomly instead of using points
|
||||
player.global_position = MapsManager.get_player_spawn().global_position
|
||||
player.global_position = Game.type.map.get_player_spawn().global_position
|
||||
player.killed.connect(_on_player_killed)
|
||||
|
||||
## This method switch a [param peer_id] to the specified team along with its score.
|
||||
|
|
@ -289,7 +290,7 @@ func _on_connection_failed() -> void:
|
|||
|
||||
func _on_player_killed(victim: Player, _killer:int) -> void:
|
||||
await get_tree().create_timer(VICTIM_RESPAWN_TIME).timeout
|
||||
var spawn: Node3D = MapsManager.get_player_spawn()
|
||||
var spawn: Node3D = Game.type.map.get_player_spawn()
|
||||
victim.respawn.rpc_id(1, spawn.global_position)
|
||||
|
||||
# This method notifies the server that a player wants to join the match. It
|
||||
|
|
@ -318,8 +319,8 @@ func _cleanup_peer() -> void:
|
|||
multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new()
|
||||
queue_free()
|
||||
|
||||
func _exit_tree() -> void:
|
||||
#func _exit_tree() -> void:
|
||||
# @NOTE: The `is_multiplayer_authority` method in `_extree` push an error
|
||||
# about the multiplayer instance not being the currently active one.it_
|
||||
# see https://github.com/godotengine/godot/issues/77723
|
||||
multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new()
|
||||
#multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new()
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ script = ExtResource("5_op0if")
|
|||
[node name="Map" type="Node" parent="."]
|
||||
|
||||
[node name="MapSpawner" type="MultiplayerSpawner" parent="."]
|
||||
_spawnable_scenes = PackedStringArray("res://maps/desert/desert.tscn")
|
||||
_spawnable_scenes = PackedStringArray("res://maps/desert/desert.tscn", "res://maps/blaze/blaze.tscn")
|
||||
spawn_path = NodePath("../Map")
|
||||
spawn_limit = 1
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ extends Node
|
|||
|
||||
func respawn() -> void:
|
||||
for player : Player in get_children():
|
||||
var spawn : Node3D = MapsManager.get_player_spawn()
|
||||
var spawn : Node3D = Game.type.map.get_player_spawn()
|
||||
if spawn:
|
||||
player.respawn.rpc_id(get_multiplayer_authority(), spawn.global_position)
|
||||
|
|
|
|||
|
|
@ -19,19 +19,15 @@ class_name Singleplayer extends Node
|
|||
@onready var map : Node = $Blaze
|
||||
|
||||
func _ready() -> void:
|
||||
MapsManager.current_map = map
|
||||
player.health.exhausted.connect(_on_player_dead)
|
||||
var flag_spawn : Node = map.objectives.front()
|
||||
flag.global_position = flag_spawn.global_position
|
||||
#var flagstand : Marker3D = map.get_node("FlagStand")
|
||||
#if flagstand:
|
||||
#flag.global_position = flagstand.position
|
||||
var spawn : Node = map.get_objective_spawn()
|
||||
flag.global_position = spawn.global_position
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("exit"):
|
||||
queue_free()
|
||||
|
||||
func _on_player_dead(_player : Player) -> void:
|
||||
var spawns : Node = map.get_node("PlayerSpawns")
|
||||
var spawn : Marker3D = spawns.get_child(
|
||||
randi_range(0, spawns.get_child_count() - 1))
|
||||
var spawn : Node3D = map.get_player_spawn()
|
||||
player.respawn(spawn.global_position)
|
||||
|
|
|
|||
|
|
@ -1,64 +1,27 @@
|
|||
[gd_scene load_steps=15 format=3 uid="uid://boviiugcnfyrj"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://boviiugcnfyrj"]
|
||||
|
||||
[ext_resource type="Script" path="res://types/singleplayer/demo.gd" id="1_kkjqs"]
|
||||
[ext_resource type="PackedScene" uid="uid://cbhx1xme0sb7k" path="res://entities/player/player.tscn" id="2_6wbjq"]
|
||||
[ext_resource type="PackedScene" uid="uid://c88l3h0ph00c7" path="res://entities/flag/flag.tscn" id="4_1j2pw"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpnu1lvfncx6q" path="res://entities/dummy_target/dummy_target.tscn" id="5_euor2"]
|
||||
[ext_resource type="PackedScene" uid="uid://rqirbdfmt2g6" path="res://maps/blaze/blaze.tscn" id="6_8mg0m"]
|
||||
[ext_resource type="Texture2D" uid="uid://cyw6oism6152n" path="res://maps/blaze/assets/textures/Ground074_1K-PNG/Ground074_1K-PNG_Color.png" id="6_gw0iq"]
|
||||
[ext_resource type="Texture2D" uid="uid://c43blkvrhgves" path="res://maps/blaze/assets/textures/Ground068_1K-PNG/Ground068_1K-PNG_NormalDX.png" id="7_esfkt"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3hocnuaq1y5g" path="res://maps/blaze/assets/textures/Ground068_1K-PNG/Ground068_1K-PNG_Color.png" id="8_dd3kf"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_c5jqv"]
|
||||
resource_local_to_scene = true
|
||||
bounce = 1.0
|
||||
absorbent = true
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_45637"]
|
||||
cull_mode = 2
|
||||
vertex_color_use_as_albedo = true
|
||||
backlight_enabled = true
|
||||
backlight = Color(0.5, 0.5, 0.5, 1)
|
||||
|
||||
[sub_resource type="Terrain3DMeshAsset" id="Terrain3DMeshAsset_rjj13"]
|
||||
height_offset = 0.5
|
||||
density = 10.0
|
||||
material_override = SubResource("StandardMaterial3D_45637")
|
||||
generated_type = 1
|
||||
|
||||
[sub_resource type="Terrain3DTextureAsset" id="Terrain3DTextureAsset_h772r"]
|
||||
name = "Rock"
|
||||
albedo_color = Color(0.898039, 0.760784, 0.905882, 1)
|
||||
albedo_texture = ExtResource("6_gw0iq")
|
||||
normal_texture = ExtResource("7_esfkt")
|
||||
|
||||
[sub_resource type="Terrain3DTextureAsset" id="Terrain3DTextureAsset_jkohr"]
|
||||
name = "Ground"
|
||||
id = 1
|
||||
albedo_color = Color(0.882353, 0.764706, 0.87451, 1)
|
||||
albedo_texture = ExtResource("8_dd3kf")
|
||||
normal_texture = ExtResource("7_esfkt")
|
||||
|
||||
[sub_resource type="Terrain3DAssets" id="Terrain3DAssets_5xdp6"]
|
||||
mesh_list = Array[Terrain3DMeshAsset]([SubResource("Terrain3DMeshAsset_rjj13")])
|
||||
texture_list = Array[Terrain3DTextureAsset]([SubResource("Terrain3DTextureAsset_h772r"), SubResource("Terrain3DTextureAsset_jkohr")])
|
||||
bounce = 0.1
|
||||
|
||||
[node name="Demo" type="Node"]
|
||||
script = ExtResource("1_kkjqs")
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("2_6wbjq")]
|
||||
transform = Transform3D(-0.000506087, 0, -1, 0, 1, 0, 1, 0, -0.000506087, 612.497, 211.292, 853.632)
|
||||
transform = Transform3D(-0.533747, 0, -0.845644, 0, 1, 0, 0.845644, 0, -0.533747, -3.01833, 100, 4.7821)
|
||||
physics_material_override = SubResource("PhysicsMaterial_c5jqv")
|
||||
|
||||
[node name="DummyTarget" parent="." instance=ExtResource("5_euor2")]
|
||||
transform = Transform3D(-0.997996, 0, -0.0632782, 0, 1, 0, 0.0632782, 0, -0.997996, 901.962, 145.367, 882.65)
|
||||
|
||||
[node name="Flag" parent="." instance=ExtResource("4_1j2pw")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 895.356, 145.367, 888.261)
|
||||
|
||||
[node name="Blaze" parent="." instance=ExtResource("6_8mg0m")]
|
||||
|
||||
[node name="Terrain3D" parent="Blaze" index="2"]
|
||||
assets = SubResource("Terrain3DAssets_5xdp6")
|
||||
|
||||
[editable path="Blaze"]
|
||||
[node name="DummyTarget" parent="." instance=ExtResource("5_euor2")]
|
||||
transform = Transform3D(-0.997996, 0, -0.0632782, 0, 1, 0, 0.0632782, 0, -0.997996, 25, 100, 25)
|
||||
collision_layer = 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue