🔧 Settings, Maps and Environments management

This commit is contained in:
anyreso 2024-04-28 06:15:19 +00:00
parent 31e6c0910a
commit 5d896e1dd3
31 changed files with 1917 additions and 381 deletions

View file

@ -3,24 +3,21 @@ class_name MatchParticipantComponent extends MultiplayerSynchronizer
signal player_id_changed(new_player_id : int)
signal nickname_changed(new_nickname : String)
@export var nickname : String = "<Newblood>":
set(value):
nickname = value
nickname_changed.emit(nickname)
@export var player_id : int:
set(value):
player_id = value
player_id_changed.emit(player_id)
@export var team_id : int = 1
@export var nickname : String = "<Newblood>":
set(value):
nickname = value
nickname_changed.emit(nickname)
func _ready() -> void:
replication_config = SceneReplicationConfig.new()
root_path = "."
_set_replication_for(NodePath("player_id").get_as_property_path())
_set_replication_for(NodePath("team_id").get_as_property_path())
_set_replication_for(NodePath("nickname").get_as_property_path())
func _set_replication_for(property_node_path : NodePath) -> void:
replication_config.add_property(property_node_path)
replication_config.property_set_replication_mode(property_node_path, SceneReplicationConfig.REPLICATION_MODE_ON_CHANGE)
replication_config = SceneReplicationConfig.new()
for prop : String in ["player_id", "team_id", "nickname"]:
var prop_path : NodePath = NodePath(prop).get_as_property_path()
replication_config.add_property(prop_path)
replication_config.property_set_replication_mode(
prop_path, SceneReplicationConfig.REPLICATION_MODE_ON_CHANGE)

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/>.
class_name Flag extends Node3D
enum FlagState { FLAG_STATE_ON_STAND, FLAG_STATE_DROPPED, FLAG_STATE_TAKEN }

View file

@ -48,7 +48,6 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
@onready var spring_arm_height : float = $Smoothing/SpringArm3D.position.y
@onready var _original_weapon_transform : Transform3D = weapon.transform
@onready var tp_player : Vanguard = $Smoothing/ThirdPerson/PlayerMesh
@onready var _game_settings : Settings = get_node("/root/GlobalSettings")
@onready var jetpack_particles : Array = $Smoothing/ThirdPerson/PlayerMesh/JetpackFX.get_children()
@onready var match_participant_component : MatchParticipantComponent = $MatchParticipantComponent
@ -74,13 +73,13 @@ func _ready() -> void:
input.jumped.connect(_jump)
input.throwed_flag.connect(_throw_flag)
input.MOUSE_SENSITIVITY = _game_settings.mouse_sensitivity
input.inverted_y_axis = _game_settings.inverted_y_axis
input.MOUSE_SENSITIVITY = Settings.get_value("controls", "mouse_sensitivity")
input.inverted_y_axis = Settings.get_value("controls", "inverted_y_axis")
func _setup_pawn(_new_player_id : int) -> void:
if _is_pawn():
camera.current = true
camera.fov = _game_settings.fov
camera.fov = Settings.get_value("video", "fov")
pawn_player = self
# set the spring arm translation to be about head height level
$Smoothing/SpringArm3D.transform = Transform3D().translated(Vector3(0, collision_shape.shape.height / 2, 0) * 0.9)
@ -154,7 +153,7 @@ func _process(_delta : float) -> void:
if not _is_pawn():
tp_player.global_transform.basis = Basis.from_euler(Vector3(0.0, input.camera_rotation.x + PI, 0.0))
elif not %Inventory/SpaceGun/Mesh/AnimationPlayer.is_playing():
%Inventory/SpaceGun/Mesh/AnimationPlayer.play("idle")
%Inventory/SpaceGun/Mesh/AnimationPlayer.play("idle")
%SpringArm3D.global_transform.basis = Basis.from_euler(Vector3(input.camera_rotation.y, input.camera_rotation.x, 0.0))
func _physics_process(delta : float) -> void:

View file

@ -36,7 +36,6 @@ func update_multiplayer_authority(player_id : int) -> void:
func _unhandled_input(event: InputEvent) -> void:
var mouse_mode : Input.MouseMode = Input.get_mouse_mode()
# isolate mouse events
if event is InputEventMouseMotion:
if mouse_mode == Input.MOUSE_MODE_CAPTURED:
@ -44,14 +43,15 @@ func _unhandled_input(event: InputEvent) -> void:
_update_camera(event.relative)
func _update_camera(relative_motion : Vector2) -> void:
# clamp vertical rotation (head motion)
# reverse y axis
if inverted_y_axis:
relative_motion.y *= -1.0
# clamp vertical rotation (head motion)
camera_rotation.y -= relative_motion.y * MOUSE_SENSITIVITY / 100
camera_rotation.y = clamp(camera_rotation.y, deg_to_rad(-90.0),deg_to_rad(90.0))
camera_rotation.y = clamp(camera_rotation.y, deg_to_rad(-90.0), deg_to_rad(90.0))
# wrap horizontal rotation (to prevent accumulation)
camera_rotation.x -= relative_motion.x * MOUSE_SENSITIVITY / 100
camera_rotation.x = wrapf(camera_rotation.x, deg_to_rad(0.0),deg_to_rad(360.0))
camera_rotation.x = wrapf(camera_rotation.x, deg_to_rad(0.0), deg_to_rad(360.0))
func _process(_delta : float) -> void:
direction = Input.get_vector("left", "right", "forward", "backward")