mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-15 16:34:48 +00:00
✨ enforce static typing
This commit is contained in:
parent
675974150f
commit
20eb9824cd
36 changed files with 271 additions and 374 deletions
|
|
@ -3,23 +3,23 @@ class_name Vanguard extends Node
|
|||
@export var spine_ik_target_attachment : Node3D
|
||||
|
||||
@onready var animation_tree : AnimationTree = $AnimationTree
|
||||
@onready var spine_ik = $Node/Skeleton3D/SpineIK
|
||||
@onready var spine_ik_target = $SpineIKTarget
|
||||
@onready var spine_ik : SkeletonIK3D = $Node/Skeleton3D/SpineIK
|
||||
@onready var spine_ik_target : Node3D = $SpineIKTarget
|
||||
|
||||
enum GroundState { GROUND_STATE_GROUNDED, GROUND_STATE_MID_AIR, GROUND_STATE_DEAD }
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
spine_ik.start()
|
||||
|
||||
func _process(_delta):
|
||||
func _process(_delta : float) -> void:
|
||||
spine_ik_target.global_transform = spine_ik_target_attachment.global_transform
|
||||
|
||||
func set_locomotion(locomotion : Vector2, ground_speed_factor : float) -> void:
|
||||
animation_tree.set("parameters/Locomotion/blend_position", locomotion)
|
||||
animation_tree.set("parameters/GroundSpeed/scale", ground_speed_factor)
|
||||
|
||||
func set_ground_state(ground_state : GroundState):
|
||||
var transition_name = "grounded"
|
||||
func set_ground_state(ground_state : GroundState) -> void:
|
||||
var transition_name : String = "grounded"
|
||||
if ground_state == GroundState.GROUND_STATE_MID_AIR:
|
||||
transition_name = "mid_air"
|
||||
if ground_state == GroundState.GROUND_STATE_DEAD:
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
[ext_resource type="PackedScene" uid="uid://4naw661fqmjg" path="res://entities/player/assets/vanguard.glb" id="1_d2ik6"]
|
||||
[ext_resource type="Script" path="res://entities/player/assets/vanguard.gd" id="2_c22xr"]
|
||||
[ext_resource type="PackedScene" uid="uid://clq4uym4arpv3" path="res://weapons/space_gun/assets/SpaceGun.glb" id="2_elp0s"]
|
||||
[ext_resource type="PackedScene" uid="uid://clq4uym4arpv3" path="res://entities/weapons/space_gun/assets/SpaceGun.glb" id="3_1d68x"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_a1qf3"]
|
||||
[sub_resource type="Animation" id="Animation_mhn14"]
|
||||
resource_name = "t_pose"
|
||||
length = 0.0333333
|
||||
tracks/0/type = "position_3d"
|
||||
|
|
@ -379,7 +379,7 @@ tracks/52/interp = 1
|
|||
tracks/52/loop_wrap = true
|
||||
tracks/52/keys = PackedFloat32Array(0, 1, 0.354872, -0.0338185, -0.004324, 0.934293)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_e1ctx"]
|
||||
[sub_resource type="Animation" id="Animation_qqdab"]
|
||||
resource_name = "run_left"
|
||||
length = 0.5
|
||||
loop_mode = 1
|
||||
|
|
@ -755,7 +755,7 @@ tracks/52/interp = 1
|
|||
tracks/52/loop_wrap = true
|
||||
tracks/52/keys = PackedFloat32Array(0, 1, 0.624011, -9.44547e-08, 0.04919, 0.779865)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_rxqgf"]
|
||||
[sub_resource type="Animation" id="Animation_q80px"]
|
||||
resource_name = "jump_up"
|
||||
length = 0.533333
|
||||
tracks/0/type = "position_3d"
|
||||
|
|
@ -1130,7 +1130,7 @@ tracks/52/interp = 1
|
|||
tracks/52/loop_wrap = true
|
||||
tracks/52/keys = PackedFloat32Array(0, 1, 0.624011, -9.44547e-08, 0.04919, 0.779865)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_4kiku"]
|
||||
[sub_resource type="Animation" id="Animation_nq3cu"]
|
||||
resource_name = "idle"
|
||||
length = 2.1
|
||||
loop_mode = 1
|
||||
|
|
@ -1506,7 +1506,7 @@ tracks/52/interp = 1
|
|||
tracks/52/loop_wrap = true
|
||||
tracks/52/keys = PackedFloat32Array(0, 1, 0.624011, -9.44547e-08, 0.04919, 0.779865)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_x1sal"]
|
||||
[sub_resource type="Animation" id="Animation_wavlm"]
|
||||
resource_name = "run_backward"
|
||||
length = 0.5
|
||||
loop_mode = 1
|
||||
|
|
@ -1882,7 +1882,7 @@ tracks/52/interp = 1
|
|||
tracks/52/loop_wrap = true
|
||||
tracks/52/keys = PackedFloat32Array(0, 1, 0.624011, -9.44547e-08, 0.04919, 0.779865)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_te6dm"]
|
||||
[sub_resource type="Animation" id="Animation_px8go"]
|
||||
resource_name = "run_forward"
|
||||
length = 0.5
|
||||
loop_mode = 1
|
||||
|
|
@ -2258,7 +2258,7 @@ tracks/52/interp = 1
|
|||
tracks/52/loop_wrap = true
|
||||
tracks/52/keys = PackedFloat32Array(0, 1, 0.624011, -9.44547e-08, 0.04919, 0.779865)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_i0yri"]
|
||||
[sub_resource type="Animation" id="Animation_3t7lf"]
|
||||
resource_name = "run_right"
|
||||
length = 0.5
|
||||
loop_mode = 1
|
||||
|
|
@ -2634,7 +2634,7 @@ tracks/52/interp = 1
|
|||
tracks/52/loop_wrap = true
|
||||
tracks/52/keys = PackedFloat32Array(0, 1, 0.624011, -9.44547e-08, 0.04919, 0.779865)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_m6nqq"]
|
||||
[sub_resource type="Animation" id="Animation_cwvpf"]
|
||||
resource_name = "death"
|
||||
length = 2.83333
|
||||
tracks/0/type = "position_3d"
|
||||
|
|
@ -3009,7 +3009,7 @@ tracks/52/interp = 1
|
|||
tracks/52/loop_wrap = true
|
||||
tracks/52/keys = PackedFloat32Array(0, 1, 0.624011, -9.44547e-08, 0.04919, 0.779865)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_tgrrp"]
|
||||
[sub_resource type="Animation" id="Animation_iawti"]
|
||||
resource_name = "jump_loop"
|
||||
loop_mode = 1
|
||||
tracks/0/type = "position_3d"
|
||||
|
|
@ -3384,17 +3384,17 @@ tracks/52/interp = 1
|
|||
tracks/52/loop_wrap = true
|
||||
tracks/52/keys = PackedFloat32Array(0, 1, 0.624011, -9.44547e-08, 0.04919, 0.779865)
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_jf6yk"]
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_cfog3"]
|
||||
_data = {
|
||||
"death": SubResource("Animation_m6nqq"),
|
||||
"idle": SubResource("Animation_4kiku"),
|
||||
"jump": SubResource("Animation_tgrrp"),
|
||||
"jump_up": SubResource("Animation_rxqgf"),
|
||||
"run_backward": SubResource("Animation_x1sal"),
|
||||
"run_forward": SubResource("Animation_te6dm"),
|
||||
"run_left": SubResource("Animation_e1ctx"),
|
||||
"run_right": SubResource("Animation_i0yri"),
|
||||
"t_pose": SubResource("Animation_a1qf3")
|
||||
"death": SubResource("Animation_cwvpf"),
|
||||
"idle": SubResource("Animation_nq3cu"),
|
||||
"jump": SubResource("Animation_iawti"),
|
||||
"jump_up": SubResource("Animation_q80px"),
|
||||
"run_backward": SubResource("Animation_wavlm"),
|
||||
"run_forward": SubResource("Animation_px8go"),
|
||||
"run_left": SubResource("Animation_qqdab"),
|
||||
"run_right": SubResource("Animation_3t7lf"),
|
||||
"t_pose": SubResource("Animation_mhn14")
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_lw37l"]
|
||||
|
|
@ -3477,15 +3477,15 @@ node_connections = [&"Death", 0, &"Death 2", &"GroundSpeed", 0, &"Locomotion", &
|
|||
script = ExtResource("2_c22xr")
|
||||
|
||||
[node name="Skeleton3D" parent="Node" index="0"]
|
||||
bones/0/position = Vector3(-0.0110252, 0.984399, 0.0113551)
|
||||
bones/0/rotation = Quaternion(-0.0346631, -0.421473, -0.031884, 0.905617)
|
||||
bones/2/rotation = Quaternion(0.00115413, 0.00432654, 0.00309339, 0.999985)
|
||||
bones/4/rotation = Quaternion(0.0693399, 0.00506471, 0.0139101, 0.997483)
|
||||
bones/6/rotation = Quaternion(0.159577, 0.00861707, 0.0109217, 0.987087)
|
||||
bones/8/rotation = Quaternion(0.687877, -0.396941, 0.388779, 0.467026)
|
||||
bones/10/rotation = Quaternion(0.244437, -0.0824007, -0.28381, 0.923533)
|
||||
bones/12/rotation = Quaternion(0.0818169, 0.211072, -0.754901, 0.615531)
|
||||
bones/14/rotation = Quaternion(0.0191213, 0.0755681, -0.152771, 0.985183)
|
||||
bones/0/position = Vector3(-0.00173, 0.968097, 0.0102844)
|
||||
bones/0/rotation = Quaternion(-0.0376647, -0.435369, -0.0400344, 0.898573)
|
||||
bones/2/rotation = Quaternion(0.00816777, 0.00677155, 0.00042395, 0.999944)
|
||||
bones/4/rotation = Quaternion(0.0731821, 0.00505516, 0.0168974, 0.997163)
|
||||
bones/6/rotation = Quaternion(0.168044, 0.010812, 0.0113512, 0.985655)
|
||||
bones/8/rotation = Quaternion(0.687995, -0.407168, 0.399605, 0.448546)
|
||||
bones/10/rotation = Quaternion(0.232583, -0.0669989, -0.309712, 0.919508)
|
||||
bones/12/rotation = Quaternion(0.0848093, 0.214035, -0.748836, 0.621483)
|
||||
bones/14/rotation = Quaternion(0.0439883, 0.072675, -0.153509, 0.984489)
|
||||
bones/20/rotation = Quaternion(-0.123455, 0.0248346, 0.23344, 0.964183)
|
||||
bones/24/rotation = Quaternion(0.0450683, -0.000817796, 0.0508488, 0.997689)
|
||||
bones/26/rotation = Quaternion(0.100545, -1.16532e-07, 0.00792588, 0.994901)
|
||||
|
|
@ -3499,12 +3499,12 @@ bones/44/rotation = Quaternion(0.633142, 6.48257e-09, 0.04991, 0.772425)
|
|||
bones/50/rotation = Quaternion(0.729888, -4.88266e-08, 0.0575362, 0.681141)
|
||||
bones/52/rotation = Quaternion(0.624011, -9.63141e-08, 0.04919, 0.779865)
|
||||
bones/54/rotation = Quaternion(-1.18924e-16, 2.81961e-21, -4.50738e-10, 1)
|
||||
bones/56/rotation = Quaternion(-0.024556, 0.0446797, -0.0067562, 0.998677)
|
||||
bones/58/rotation = Quaternion(-0.009168, 0.301287, -0.0413145, 0.952594)
|
||||
bones/62/rotation = Quaternion(0.693486, 0.36321, -0.399714, 0.476848)
|
||||
bones/64/rotation = Quaternion(0.33601, -0.304998, 0.117904, 0.883274)
|
||||
bones/66/rotation = Quaternion(0.562383, -0.570974, 0.40924, 0.436162)
|
||||
bones/68/rotation = Quaternion(-0.00653908, -0.261386, 0.0645819, 0.963049)
|
||||
bones/56/rotation = Quaternion(-0.027387, 0.0477242, -0.0102335, 0.998433)
|
||||
bones/58/rotation = Quaternion(-0.0272967, 0.307174, -0.0493656, 0.94998)
|
||||
bones/62/rotation = Quaternion(0.693539, 0.362122, -0.415845, 0.463622)
|
||||
bones/64/rotation = Quaternion(0.324204, -0.30741, 0.122213, 0.886259)
|
||||
bones/66/rotation = Quaternion(0.570764, -0.560023, 0.419045, 0.430121)
|
||||
bones/68/rotation = Quaternion(-0.0159497, -0.258891, 0.0744964, 0.962897)
|
||||
bones/70/rotation = Quaternion(0.155965, 0.0109114, -0.00107202, 0.987702)
|
||||
bones/72/rotation = Quaternion(0.563923, 4.19095e-08, -0.0577906, 0.823803)
|
||||
bones/74/rotation = Quaternion(0.285209, 0.0197164, -0.0936782, 0.953673)
|
||||
|
|
@ -3521,21 +3521,21 @@ bones/100/rotation = Quaternion(-6.44756e-14, -1.4372e-11, -3.12192e-10, 1)
|
|||
bones/102/rotation = Quaternion(0.179829, 0.0890365, -0.000307644, 0.97966)
|
||||
bones/104/rotation = Quaternion(0.388149, 1.28057e-07, -0.0397774, 0.920738)
|
||||
bones/106/rotation = Quaternion(0.372324, -1.37021e-07, -0.0381557, 0.927318)
|
||||
bones/110/rotation = Quaternion(-0.116972, 0.113122, 0.979413, 0.119461)
|
||||
bones/112/rotation = Quaternion(-0.344137, -0.000622203, -0.00428585, 0.93891)
|
||||
bones/114/rotation = Quaternion(0.449077, 0.0417981, -0.0071573, 0.892486)
|
||||
bones/116/rotation = Quaternion(0.424844, 0.0902863, 0.0296051, 0.900266)
|
||||
bones/120/rotation = Quaternion(0.102629, 0.24689, 0.953163, -0.141395)
|
||||
bones/122/rotation = Quaternion(-0.324519, -0.0831649, 0.0282907, 0.941791)
|
||||
bones/124/rotation = Quaternion(0.40683, -0.0639519, -0.00334525, 0.911257)
|
||||
bones/126/rotation = Quaternion(0.33772, -0.0673337, -0.0175452, 0.938671)
|
||||
bones/110/rotation = Quaternion(-0.0838619, 0.187447, 0.974965, 0.0852912)
|
||||
bones/112/rotation = Quaternion(-0.467849, 0.0166342, -0.0112761, 0.88358)
|
||||
bones/114/rotation = Quaternion(0.449729, 0.0515854, 0.00300445, 0.891669)
|
||||
bones/116/rotation = Quaternion(0.372768, 0.0597713, 0.0286748, 0.925553)
|
||||
bones/120/rotation = Quaternion(0.122412, 0.250244, 0.948794, -0.148942)
|
||||
bones/122/rotation = Quaternion(-0.341409, -0.0816528, 0.0267745, 0.935979)
|
||||
bones/124/rotation = Quaternion(0.404856, -0.0684155, -0.00791205, 0.911783)
|
||||
bones/126/rotation = Quaternion(0.379454, -0.0779287, -0.0184118, 0.921739)
|
||||
|
||||
[node name="HandAttachment" type="BoneAttachment3D" parent="Node/Skeleton3D" index="0"]
|
||||
transform = Transform3D(-0.173147, 0.0543575, 0.983395, 0.931783, 0.332502, 0.14568, -0.319062, 0.941535, -0.108221, -0.250617, 1.17554, 0.101266)
|
||||
transform = Transform3D(-0.174592, 0.0530693, 0.98321, 0.930948, 0.334134, 0.147277, -0.320708, 0.94103, -0.107742, -0.243063, 1.16434, 0.0953343)
|
||||
bone_name = "mixamorigRightHand"
|
||||
bone_idx = 14
|
||||
|
||||
[node name="SpaceGun" parent="Node/Skeleton3D/HandAttachment" index="0" instance=ExtResource("2_elp0s")]
|
||||
[node name="SpaceGun" parent="Node/Skeleton3D/HandAttachment" index="0" instance=ExtResource("3_1d68x")]
|
||||
transform = Transform3D(-0.0109711, 0.094734, -0.0300857, -0.00595679, 0.0295874, 0.095337, 0.0992177, 0.0122517, 0.00239707, -0.173344, 0.519761, 0.10355)
|
||||
|
||||
[node name="SpineIK" type="SkeletonIK3D" parent="Node/Skeleton3D" index="3"]
|
||||
|
|
@ -3551,7 +3551,7 @@ playback_default_blend_time = 0.2
|
|||
|
||||
[node name="AnimationTree" type="AnimationTree" parent="." index="2"]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_jf6yk")
|
||||
"": SubResource("AnimationLibrary_cfog3")
|
||||
}
|
||||
tree_root = SubResource("AnimationNodeBlendTree_1ok7t")
|
||||
anim_player = NodePath("../AnimationPlayer")
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
|||
@export var jetpack_vertical_force : float = 800
|
||||
|
||||
@export_group("State")
|
||||
@export var player_state = PlayerState.PLAYER_ALIVE
|
||||
@export var player_state : PlayerState = PlayerState.PLAYER_ALIVE
|
||||
@export var player_id : int = 1:
|
||||
set(id):
|
||||
player_id = id
|
||||
|
|
@ -41,26 +41,26 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
|||
|
||||
@onready var input : PlayerInput = $PlayerInput
|
||||
@onready var camera : Camera3D = $SpringArm3D/Camera3D
|
||||
@onready var hud = $HUD
|
||||
@onready var iff = $ThirdPerson/IFF
|
||||
@onready var hud : CanvasLayer = $HUD
|
||||
@onready var iff : Node2D = $ThirdPerson/IFF
|
||||
@onready var shape_cast : ShapeCast3D = $ShapeCast3D
|
||||
@onready var weapon = $SpringArm3D/Inventory/SpaceGun
|
||||
@onready var weapon : Node3D = $SpringArm3D/Inventory/SpaceGun
|
||||
@onready var animation_player : AnimationPlayer = $AnimationPlayer
|
||||
@onready var health_component = $HealthComponent
|
||||
@onready var health_component : Area3D = $HealthComponent
|
||||
@onready var flag_carry_component : FlagCarryComponent = $FlagCarryComponent
|
||||
@onready var spring_arm_height = $SpringArm3D.position.y
|
||||
@onready var spring_arm_height : float = $SpringArm3D.position.y
|
||||
@onready var _original_weapon_transform : Transform3D = weapon.transform
|
||||
@onready var flag_carry_attachment = $SpringArm3D/FlagCarryAttachment
|
||||
@onready var _game_settings : GameSettings = get_node("/root/GlobalSettings")
|
||||
@onready var flag_carry_attachment : Node3D = $SpringArm3D/FlagCarryAttachment
|
||||
@onready var _game_settings : Settings = get_node("/root/GlobalSettings")
|
||||
|
||||
signal died(player)
|
||||
signal energy_changed(energy)
|
||||
signal died(player : Player)
|
||||
signal energy_changed(energy : float)
|
||||
|
||||
var g : float = ProjectSettings.get_setting("physics/3d/default_gravity") # in m/s²
|
||||
var gravity : Vector3 = g * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
|
||||
var _jumping = false
|
||||
var _jumping : bool = false
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
energy_changed.connect(hud._on_energy_changed)
|
||||
if _is_pawn():
|
||||
health_component.health_changed.connect(hud._on_health_changed)
|
||||
|
|
@ -79,15 +79,15 @@ func _ready():
|
|||
input.jumped.connect(_jump)
|
||||
input.throwed_flag.connect(_throw_flag)
|
||||
|
||||
func _is_pawn():
|
||||
func _is_pawn() -> bool:
|
||||
return player_id == multiplayer.get_unique_id()
|
||||
|
||||
func _fire_primary():
|
||||
func _fire_primary() -> void:
|
||||
if _is_player_dead():
|
||||
return
|
||||
if not weapon.can_fire():
|
||||
return
|
||||
var current_weapon_transform = weapon.transform
|
||||
var current_weapon_transform : Transform3D = weapon.transform
|
||||
weapon.transform = _original_weapon_transform
|
||||
weapon.fire_primary()
|
||||
weapon.transform = current_weapon_transform
|
||||
|
|
@ -95,18 +95,18 @@ func _fire_primary():
|
|||
animation_player.stop()
|
||||
animation_player.play("shoot")
|
||||
|
||||
func _jump():
|
||||
func _jump() -> void:
|
||||
if _is_player_dead():
|
||||
return
|
||||
_jumping = true
|
||||
|
||||
func _throw_flag():
|
||||
func _throw_flag() -> void:
|
||||
flag_carry_component.throw(linear_velocity)
|
||||
|
||||
func is_on_floor() -> bool:
|
||||
if shape_cast.is_colliding():
|
||||
for i in shape_cast.get_collision_count():
|
||||
var collider = shape_cast.get_collider(i)
|
||||
var collider : Object = shape_cast.get_collider(i)
|
||||
if collider is Terrain3D:
|
||||
return true
|
||||
return false
|
||||
|
|
@ -114,15 +114,15 @@ func is_on_floor() -> bool:
|
|||
func _is_skiing() -> bool:
|
||||
return input.skiing
|
||||
|
||||
func _handle_aerial_control(direction):
|
||||
func _handle_aerial_control(direction : Vector3) -> void:
|
||||
if not input.jetting and not is_on_floor():
|
||||
apply_force(direction * aerial_control_force)
|
||||
|
||||
func _handle_jetpack(delta, direction):
|
||||
func _handle_jetpack(delta : float, direction : Vector3) -> void:
|
||||
if input.jetting:
|
||||
if energy > 0:
|
||||
var up_vector = Vector3.UP * jetpack_vertical_force * jetpack_force_factor
|
||||
var side_vector = direction * jetpack_horizontal_force * jetpack_force_factor
|
||||
var up_vector : Vector3 = Vector3.UP * jetpack_vertical_force * jetpack_force_factor
|
||||
var side_vector : Vector3 = direction * jetpack_horizontal_force * jetpack_force_factor
|
||||
apply_force(up_vector + side_vector)
|
||||
energy -= energy_drain_rate * delta
|
||||
else:
|
||||
|
|
@ -131,7 +131,7 @@ func _handle_jetpack(delta, direction):
|
|||
energy = clamp(energy, 0, energy_max)
|
||||
energy_changed.emit(energy)
|
||||
|
||||
func _process(_delta):
|
||||
func _process(_delta : float) -> void:
|
||||
if _is_player_dead():
|
||||
iff.hide()
|
||||
return
|
||||
|
|
@ -146,11 +146,11 @@ func _process(_delta):
|
|||
animation_player.play("idle")
|
||||
%SpringArm3D.global_transform.basis = Basis.from_euler(Vector3(input.camera_rotation.y, input.camera_rotation.x, 0.0))
|
||||
|
||||
func _physics_process(delta):
|
||||
func _physics_process(delta : float) -> void:
|
||||
# retrieve user's direction vector
|
||||
var _input_dir = input.direction
|
||||
var _input_dir : Vector2 = input.direction
|
||||
# compute direction in local space
|
||||
var _direction = (transform.basis * Vector3(_input_dir.x, 0, _input_dir.y)).normalized()
|
||||
var _direction : Vector3 = (transform.basis * Vector3(_input_dir.x, 0, _input_dir.y)).normalized()
|
||||
_update_third_person_animations()
|
||||
|
||||
if _is_player_dead():
|
||||
|
|
@ -171,9 +171,9 @@ func _physics_process(delta):
|
|||
if is_on_floor():
|
||||
if not _direction.is_zero_approx() and not _is_skiing():
|
||||
# retrieve collision normal
|
||||
var normal = shape_cast.get_collision_normal(0)
|
||||
var normal : Vector3 = shape_cast.get_collision_normal(0)
|
||||
# calculate the angle between the ground normal and the up vector
|
||||
var slope_angle = rad_to_deg(acos(normal.dot(Vector3.UP)))
|
||||
var slope_angle : float = rad_to_deg(acos(normal.dot(Vector3.UP)))
|
||||
# check if the slope angle exceeds the maximum slope angle
|
||||
if slope_angle <= max_floor_angle:
|
||||
# adjust direction based on the floor normal to align with the slope
|
||||
|
|
@ -181,14 +181,14 @@ func _physics_process(delta):
|
|||
|
||||
linear_velocity = lerp(linear_velocity, _direction * ground_speed, .1)
|
||||
|
||||
func _integrate_forces(_state):
|
||||
func _integrate_forces(_state : PhysicsDirectBodyState3D) -> void:
|
||||
if is_on_floor() and _jumping:
|
||||
var v = sqrt(2 * g * jump_height)
|
||||
var v : float = sqrt(2 * g * jump_height)
|
||||
apply_central_impulse(Vector3(0, mass * v, 0))
|
||||
|
||||
_jumping = false
|
||||
|
||||
func _update_third_person_animations():
|
||||
func _update_third_person_animations() -> void:
|
||||
if _is_pawn():
|
||||
return
|
||||
|
||||
|
|
@ -202,21 +202,21 @@ func _update_third_person_animations():
|
|||
tp_player.set_ground_state(Vanguard.GroundState.GROUND_STATE_GROUNDED)
|
||||
else:
|
||||
tp_player.set_ground_state(Vanguard.GroundState.GROUND_STATE_MID_AIR)
|
||||
var local_velocity = (tp_player.global_basis.inverse() * linear_velocity)
|
||||
var local_velocity : Vector3 = (tp_player.global_basis.inverse() * linear_velocity)
|
||||
const bias : float = 1.2 # Basically match feet speed with ground speed
|
||||
tp_player.set_locomotion(Vector2(local_velocity.x, local_velocity.z), bias)
|
||||
|
||||
func _is_player_dead():
|
||||
func _is_player_dead() -> bool:
|
||||
return player_state == PlayerState.PLAYER_DEAD
|
||||
|
||||
func die():
|
||||
func die() -> void:
|
||||
player_state = PlayerState.PLAYER_DEAD
|
||||
if _is_pawn():
|
||||
animation_player.stop()
|
||||
animation_player.play("death")
|
||||
var tween = create_tween()
|
||||
var tween : Tween = create_tween()
|
||||
tween.tween_interval(4)
|
||||
tween.tween_callback(func():
|
||||
tween.tween_callback(func() -> void:
|
||||
died.emit(self)
|
||||
if _is_pawn():
|
||||
animation_player.stop()
|
||||
|
|
@ -224,10 +224,10 @@ func die():
|
|||
flag_carry_component.drop()
|
||||
|
||||
@rpc("call_local")
|
||||
func set_nickname(value):
|
||||
func set_nickname(value : String) -> void:
|
||||
nickname = value
|
||||
|
||||
func respawn(location):
|
||||
func respawn(location : Vector3) -> void:
|
||||
linear_velocity = Vector3()
|
||||
health_component.heal_full()
|
||||
position = location
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
[ext_resource type="PackedScene" uid="uid://drbefw6akui2v" path="res://entities/player/assets/vanguard.tscn" id="2_beyex"]
|
||||
[ext_resource type="Shape3D" uid="uid://cb8esdlnottdn" path="res://entities/player/collision_shape.tres" id="2_vjqny"]
|
||||
[ext_resource type="PackedScene" uid="uid://bcv81ku26xo" path="res://interfaces/hud/hud.tscn" id="3_ccety"]
|
||||
[ext_resource type="PackedScene" uid="uid://c8co0qa2omjmh" path="res://weapons/space_gun/space_gun.tscn" id="4_lhn5w"]
|
||||
[ext_resource type="PackedScene" uid="uid://dn1tcakam5egs" path="res://weapons/space_gun/projectile.tscn" id="5_lvaut"]
|
||||
[ext_resource type="PackedScene" uid="uid://c8co0qa2omjmh" path="res://entities/weapons/space_gun/space_gun.tscn" id="4_6jh57"]
|
||||
[ext_resource type="PackedScene" uid="uid://dn1tcakam5egs" path="res://entities/weapons/space_gun/projectile.tscn" id="5_2xh36"]
|
||||
[ext_resource type="PackedScene" uid="uid://bof3mg7wgxrmn" path="res://components/health_component.tscn" id="5_t6i6e"]
|
||||
[ext_resource type="Script" path="res://entities/player/player_input.gd" id="6_ymcrr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dsysi2rd3bu76" path="res://interfaces/hud/iff.tscn" id="7_8hc80"]
|
||||
|
|
@ -244,9 +244,9 @@ near = 0.1
|
|||
|
||||
[node name="Inventory" type="Node3D" parent="SpringArm3D"]
|
||||
|
||||
[node name="SpaceGun" parent="SpringArm3D/Inventory" instance=ExtResource("4_lhn5w")]
|
||||
[node name="SpaceGun" parent="SpringArm3D/Inventory" instance=ExtResource("4_6jh57")]
|
||||
transform = Transform3D(-1, 0, 2.53518e-06, 0, 1, 0, -2.53518e-06, 0, -1, 0.244668, -0.229311, -0.30332)
|
||||
PROJECTILE = ExtResource("5_lvaut")
|
||||
PROJECTILE = ExtResource("5_2xh36")
|
||||
|
||||
[node name="SpineIKTarget" type="Node3D" parent="SpringArm3D"]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
|
||||
|
|
@ -265,9 +265,8 @@ sensor = NodePath("../Sensor")
|
|||
|
||||
[node name="ThirdPerson" type="Node3D" parent="."]
|
||||
|
||||
[node name="PlayerMesh" parent="ThirdPerson" node_paths=PackedStringArray("spine_ik_target_attachment") instance=ExtResource("2_beyex")]
|
||||
[node name="PlayerMesh" parent="ThirdPerson" instance=ExtResource("2_beyex")]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
|
||||
spine_ik_target_attachment = NodePath("../../SpringArm3D/SpineIKTarget")
|
||||
|
||||
[node name="IFFAttachment" type="Node3D" parent="ThirdPerson"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.27457, 0)
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
class_name PlayerInput extends MultiplayerSynchronizer
|
||||
|
||||
@export var jetting = false
|
||||
@export var skiing = false
|
||||
@export var direction = Vector2.ZERO
|
||||
@export var jetting : bool = false
|
||||
@export var skiing : bool = false
|
||||
@export var direction : Vector2 = Vector2.ZERO
|
||||
@export var camera_rotation : Vector2
|
||||
@export var MOUSE_SENSITIVITY : float = .6
|
||||
@export var inverted_y_axis : bool = false
|
||||
|
|
@ -25,13 +25,13 @@ signal jumped
|
|||
signal fired_primary
|
||||
signal throwed_flag
|
||||
|
||||
func _ready():
|
||||
var has_authority = is_multiplayer_authority()
|
||||
func _ready() -> void:
|
||||
var has_authority : bool = is_multiplayer_authority()
|
||||
set_process(has_authority)
|
||||
set_process_unhandled_input(has_authority)
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
var mouse_mode = Input.get_mouse_mode()
|
||||
var mouse_mode : Input.MouseMode = Input.get_mouse_mode()
|
||||
|
||||
# isolate mouse events
|
||||
if event is InputEventMouseMotion:
|
||||
|
|
@ -49,7 +49,7 @@ func _update_camera(relative_motion : Vector2) -> void:
|
|||
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))
|
||||
|
||||
func _process(delta):
|
||||
func _process(_delta : float) -> void:
|
||||
direction = Input.get_vector("left", "right", "forward", "backward")
|
||||
if Input.is_action_just_pressed("jump_and_jet"):
|
||||
_jump.rpc()
|
||||
|
|
@ -61,13 +61,13 @@ func _process(delta):
|
|||
skiing = Input.is_action_pressed("ski")
|
||||
|
||||
@rpc("call_local")
|
||||
func _jump():
|
||||
func _jump() -> void:
|
||||
jumped.emit()
|
||||
|
||||
@rpc("call_local")
|
||||
func _fire_primary():
|
||||
func _fire_primary() -> void:
|
||||
fired_primary.emit()
|
||||
|
||||
@rpc("call_local")
|
||||
func _throw_flag():
|
||||
func _throw_flag() -> void:
|
||||
throwed_flag.emit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue