🔧 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

@ -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")