Global refactor
This commit is contained in:
parent
3868af29e3
commit
0589ca4e23
180 changed files with 249 additions and 401 deletions
|
|
@ -1,59 +0,0 @@
|
|||
extends Camera3D
|
||||
|
||||
class_name PlayerCamera
|
||||
|
||||
var vertical_compensation : float
|
||||
var compensation_tween: Tween
|
||||
var compensate: bool = false
|
||||
var disabled: bool = false
|
||||
var compensation_speed: float
|
||||
@export var compensation_time: float = 1.0
|
||||
@export var compensation_delay: float = 0.5
|
||||
|
||||
func _ready() -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
# Move to level controller when possible
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
current = true
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if disabled: return
|
||||
if compensate:
|
||||
if abs(vertical_compensation) <= 0.001:
|
||||
vertical_compensation = 0
|
||||
compensate = false
|
||||
return
|
||||
rotate_camera(0,compensation_speed * delta)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not is_multiplayer_authority() or disabled:
|
||||
return
|
||||
if Input.mouse_mode == Input.MouseMode.MOUSE_MODE_CAPTURED and event is InputEventMouseMotion:
|
||||
rotate_camera(-event.relative.x * ClientSettings.SENSITIVITY,-event.relative.y * ClientSettings.SENSITIVITY)
|
||||
|
||||
func rotate_camera(x,y) -> void:
|
||||
get_parent().rotate_y(x)
|
||||
rotation.x = clamp(rotation.x + y,-PI/2,PI/2)
|
||||
orthonormalize()
|
||||
if sign(vertical_compensation) == sign(y):
|
||||
if abs(vertical_compensation) - abs(y) < 0:
|
||||
vertical_compensation = 0
|
||||
else:
|
||||
vertical_compensation -= y
|
||||
|
||||
func recoil(x,y) -> void:
|
||||
rotate_camera(x,y)
|
||||
vertical_compensation -= y
|
||||
if compensation_tween:
|
||||
compensation_tween.kill()
|
||||
compensation_tween = create_tween()
|
||||
compensation_tween.tween_interval(compensation_delay)
|
||||
compensation_tween.tween_callback(start_compensating)
|
||||
|
||||
func start_compensating() -> void:
|
||||
compensate = true
|
||||
compensation_speed = vertical_compensation / compensation_time
|
||||
|
||||
func disable() -> void:
|
||||
disabled = true
|
||||
Loading…
Add table
Add a link
Reference in a new issue