Merge branch 'feat/static-typing' into 'develop'

 enforce static typing

See merge request open-fpsz/open-fpsz!48
This commit is contained in:
Squinty 2024-04-19 06:19:21 +00:00
commit cf7796bf48
36 changed files with 271 additions and 374 deletions

View file

@ -17,10 +17,10 @@ class_name ExplosiveDamageComponent extends Area3D
@export var damage : int = 100
@export var impulse_force : int = 1000
func _physics_process(_delta):
func _physics_process(_delta : float) -> void:
for body in get_overlapping_bodies():
if body is RigidBody3D:
var direction = (body.global_position - global_position).normalized()
var direction : Vector3 = (body.global_position - global_position).normalized()
body.apply_central_impulse(direction * impulse_force)
for area in get_overlapping_areas():

View file

@ -24,20 +24,20 @@ class_name FlagCarryComponent extends Node
var _carried_flag : Flag
func _ready():
func _ready() -> void:
sensor.body_entered.connect(_sensor_on_body_entered)
func _process(_delta):
func _process(_delta : float) -> void:
if _is_carrying():
_carried_flag.global_position = attachment.global_position
_carried_flag.global_rotation = attachment.global_rotation
func _grab(flag : Flag):
func _grab(flag : Flag) -> void:
if not _is_carrying():
flag.grab()
_carried_flag = flag
func _release(inherited_velocity : Vector3, throw_speed : float):
func _release(inherited_velocity : Vector3, throw_speed : float) -> void:
if _is_carrying():
_carried_flag.drop()
_carried_flag.rotation_degrees.x = 0.0
@ -49,12 +49,12 @@ func _release(inherited_velocity : Vector3, throw_speed : float):
func _is_carrying() -> bool:
return _carried_flag != null
func _sensor_on_body_entered(collider):
func _sensor_on_body_entered(collider : Flag) -> void:
if collider is Flag:
_grab(collider)
func drop():
func drop() -> void:
_release(Vector3.ZERO, 0.0)
func throw(inherited_velocity : Vector3):
func throw(inherited_velocity : Vector3) -> void:
_release(inherited_velocity, max_throw_speed)

View file

@ -23,7 +23,7 @@ class_name HealthComponent extends Area3D
signal health_zeroed
signal health_changed(value : int)
func _ready():
func _ready() -> void:
heal_full()
@rpc("call_local")
@ -33,10 +33,10 @@ func damage(amount : int) -> void:
health_zeroed.emit()
@rpc("call_local")
func _heal(amount : int):
func _heal(amount : int) -> void:
health = clampf(health + amount, 0.0, max_health)
func heal_full():
func heal_full() -> void:
if not is_multiplayer_authority():
return

View file

@ -4,14 +4,14 @@ enum FlagState { FLAG_STATE_ON_STAND, FLAG_STATE_DROPPED, FLAG_STATE_TAKEN }
@export var flag_state : FlagState = FlagState.FLAG_STATE_ON_STAND
func can_be_grabbed():
func can_be_grabbed() -> bool:
return flag_state != FlagState.FLAG_STATE_TAKEN
func grab():
func grab() -> void:
if flag_state != FlagState.FLAG_STATE_TAKEN:
flag_state = FlagState.FLAG_STATE_TAKEN
func drop():
func drop() -> void:
if flag_state == FlagState.FLAG_STATE_TAKEN:
flag_state = FlagState.FLAG_STATE_DROPPED

View file

@ -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:

View file

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

View file

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

View file

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

View file

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

View file

@ -25,7 +25,7 @@ func _ready() -> void:
health_component.health_zeroed.connect(spawn)
start_pos = global_position
func spawn():
func spawn() -> void:
hide()
collision_shape_3d.disabled = true
await get_tree().create_timer(respawn_time).timeout

View file

Before

Width:  |  Height:  |  Size: 364 KiB

After

Width:  |  Height:  |  Size: 364 KiB

View file

Before

Width:  |  Height:  |  Size: 364 KiB

After

Width:  |  Height:  |  Size: 364 KiB

View file

@ -19,32 +19,32 @@ class_name Projectile extends Node3D
@export var speed : float = 78.4 # m/s
@export var lifespan : float = 5.0 # in seconds
@onready var shape_cast = $ShapeCast3D
@onready var game = get_tree().get_current_scene()
@onready var shape_cast : ShapeCast3D = $ShapeCast3D
@onready var game : Node3D = get_tree().get_current_scene()
var velocity : Vector3 = Vector3.ZERO
func _ready():
var lifespan_timer = Timer.new()
func _ready() -> void:
var lifespan_timer : Timer = Timer.new()
lifespan_timer.wait_time = lifespan
lifespan_timer.one_shot = true
lifespan_timer.autostart = true
lifespan_timer.timeout.connect(self_destruct)
add_child(lifespan_timer)
func self_destruct():
func self_destruct() -> void:
explode(position)
func explode(spawn_location):
var spawned_explosion = EXPLOSION.instantiate()
func explode(spawn_location : Vector3) -> void:
var spawned_explosion : Node = EXPLOSION.instantiate()
spawned_explosion.position = spawn_location
game.add_child(spawned_explosion)
queue_free()
func _physics_process(delta):
var previous_position = global_position
func _physics_process(delta : float) -> void:
var previous_position : Vector3 = global_position
global_position += velocity * delta
shape_cast.target_position = to_local(previous_position)
if shape_cast.is_colliding():
var contact_point = shape_cast.collision_result[0].point
var contact_point : Vector3 = shape_cast.collision_result[0].point
explode(contact_point)

View file

@ -1,8 +1,8 @@
[gd_scene load_steps=7 format=3 uid="uid://dn1tcakam5egs"]
[ext_resource type="Script" path="res://weapons/space_gun/projectile.gd" id="1_4j1dp"]
[ext_resource type="PackedScene" uid="uid://8atq41j7wd55" path="res://weapons/space_gun/projectile_explosion.tscn" id="2_llml6"]
[ext_resource type="Script" path="res://weapons/space_gun/projectile_trail.gd" id="3_ygqbh"]
[ext_resource type="Script" path="res://entities/weapons/space_gun/projectile.gd" id="1_4j1dp"]
[ext_resource type="PackedScene" uid="uid://8atq41j7wd55" path="res://entities/weapons/space_gun/projectile_explosion.tscn" id="2_llml6"]
[ext_resource type="Script" path="res://entities/weapons/space_gun/projectile_trail.gd" id="3_ygqbh"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4a265"]
transparency = 1

View file

@ -14,10 +14,10 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends Node3D
@onready var fire = $Fire
@onready var fire : GPUParticles3D = $Fire
@onready var explosive_damage : ExplosiveDamageComponent = $ExplosiveDamageComponent
var explosion_effect_pending : bool = false
func _ready():
func _ready() -> void:
fire.emitting = true
fire.finished.connect(func(): queue_free())
fire.finished.connect(func() -> void: queue_free())

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=9 format=3 uid="uid://8atq41j7wd55"]
[ext_resource type="Script" path="res://weapons/space_gun/projectile_explosion.gd" id="1_fp5td"]
[ext_resource type="Script" path="res://entities/weapons/space_gun/projectile_explosion.gd" id="1_fp5td"]
[ext_resource type="PackedScene" uid="uid://ds1hekx1dq1bg" path="res://components/explosive_damage_component.tscn" id="2_d4sf4"]
[sub_resource type="Curve" id="Curve_rg204"]

View file

@ -14,9 +14,9 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name Trail3D extends MeshInstance3D
var _points = [] # 3D points of trail
var _widths = [] # Calculated widths of trail
var _lifespans = [] # Trail point lifespans
var _points : Array = [] # 3D points of trail
var _widths : Array = [] # Calculated widths of trail
var _lifespans : Array = [] # Trail point lifespans
@export var _trail_enabled : bool = true # Is trail shown?
@ -33,7 +33,7 @@ var _lifespans = [] # Trail point lifespans
var _old_pos : Vector3 # Previous pos
func _append_point():
func _append_point() -> void:
_points.append(get_global_transform().origin)
_widths.append([
get_global_transform().basis.x * _from_width,
@ -41,23 +41,23 @@ func _append_point():
])
_lifespans.append(0.0)
func _remove_point(i):
func _remove_point(i : int) -> void:
_points.remove_at(i)
_widths.remove_at(i)
_lifespans.remove_at(i)
func _ready():
func _ready() -> void:
_old_pos = get_global_transform().origin
mesh = ImmediateMesh.new()
func _process(delta):
func _process(delta : float) -> void:
if(_old_pos - get_global_transform().origin).length() > _motion_delta and _trail_enabled:
_append_point() # Create new point
_old_pos = get_global_transform().origin # Update previous position to current position coordinates
# Update the lifespan
var p = 0
var max_points = _points.size()
var p : int = 0
var max_points : int = _points.size()
while p < max_points:
_lifespans[p] += delta
if _lifespans[p] > _lifespan:
@ -78,14 +78,14 @@ func _process(delta):
mesh.surface_begin(Mesh.PRIMITIVE_TRIANGLE_STRIP)
for i in range(_points.size()):
var t = float(i) / (_points.size() - 1.0)
var curr_color = _start_color.lerp(_end_color, 1 - t)
var t : float = float(i) / (_points.size() - 1.0)
var curr_color : Color = _start_color.lerp(_end_color, 1 - t)
mesh.surface_set_color(curr_color)
var curr_width = _widths[i][0] - pow(1 - t, _scale_acceleration) * _widths[i][1]
var curr_width : Vector3 = _widths[i][0] - pow(1 - t, _scale_acceleration) * _widths[i][1]
var t0 = i / _points.size()
var t1 = t
var t0 : float = i / _points.size()
var t1 : float = t
mesh.surface_set_uv(Vector2(t0, 0))
mesh.surface_add_vertex(to_local(_points[i] + curr_width))

View file

@ -17,8 +17,8 @@ class_name SpaceGun
@export var PROJECTILE : PackedScene
@onready var nozzle = $Nozzle
@onready var inventory = get_parent()
@onready var nozzle : Node3D = $Nozzle
@onready var inventory : Node3D = get_parent()
enum WeaponState { WEAPON_READY, WEAPON_RELOADING }
@ -27,20 +27,20 @@ var weapon_state : WeaponState = WeaponState.WEAPON_READY
const inheritance : float = .5 # ratio
const reload_time : float = 1. # seconds
func can_fire():
func can_fire() -> bool:
return weapon_state == WeaponState.WEAPON_READY
func fire_primary():
func fire_primary() -> void:
if not can_fire():
return
var projectile = PROJECTILE.instantiate()
var projectile : Node = PROJECTILE.instantiate()
projectile.transform = nozzle.global_transform
projectile.velocity = nozzle.global_basis.z.normalized() * projectile.speed
var inheritance_factor = clamp(inheritance, 0., 1.)
var inheritance_factor : float = clamp(inheritance, 0., 1.)
projectile.velocity += (inventory.owner.linear_velocity * inheritance_factor)
inventory.owner.add_sibling(projectile)
var collider = projectile.shape_cast
var collider : ShapeCast3D = projectile.shape_cast
collider.add_exception(inventory.owner)
weapon_state = WeaponState.WEAPON_RELOADING
await get_tree().create_timer(reload_time).timeout

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://c8co0qa2omjmh"]
[ext_resource type="Script" path="res://weapons/space_gun/space_gun.gd" id="1_6sm4s"]
[ext_resource type="Material" uid="uid://de6t4olk7hrs1" path="res://weapons/space_gun/assets/material.tres" id="1_uaehs"]
[ext_resource type="Script" path="res://entities/weapons/space_gun/space_gun.gd" id="1_6sm4s"]
[ext_resource type="Material" uid="uid://de6t4olk7hrs1" path="res://entities/weapons/space_gun/assets/material.tres" id="1_uaehs"]
[sub_resource type="ArrayMesh" id="ArrayMesh_2hpnh"]
_surfaces = [{

View file

@ -1,6 +1,6 @@
[gd_resource type="Environment" load_steps=4 format=3 uid="uid://d2ahijqqspw5f"]
[ext_resource type="Texture2D" uid="uid://btdbu0qbe1646" path="res://environments/skyboxes/kloppenheim_06_puresky_2k.exr" id="1_k44rf"]
[ext_resource type="Texture2D" uid="uid://odwhjbebqfcn" path="res://environments/skyboxes/kloppenheim_06_puresky_2k.exr" id="1_k44rf"]
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_7tawh"]
panorama = ExtResource("1_k44rf")

View file

@ -6,23 +6,23 @@
script/source = "extends CanvasLayer
class_name HUD
@onready var _health_bar = $HealthBar
@onready var _energy_bar = $EnergyBar
@onready var _health_bar : ProgressBar = $HealthBar
@onready var _energy_bar : ProgressBar = $EnergyBar
func _ready():
_update_health_bar(100)
_update_energy_bar(100)
func _ready() -> void:
_update_health_bar(100.)
_update_energy_bar(100.)
func _update_energy_bar(energy) -> void:
func _update_energy_bar(energy : float) -> void:
_energy_bar.value = energy
func _on_energy_changed(new_energy) -> void:
func _on_energy_changed(new_energy : float) -> void:
_update_energy_bar(new_energy)
func _update_health_bar(health) -> void:
func _update_health_bar(health : float) -> void:
_health_bar.value = health
func _on_health_changed(new_health) -> void:
func _on_health_changed(new_health : float) -> void:
_update_health_bar(new_health)
"
@ -34,14 +34,14 @@ bg_color = Color(0, 0.454902, 0.992157, 1)
[sub_resource type="GDScript" id="GDScript_w8l21"]
script/source = "extends Label
@onready var player = get_parent().owner
@onready var player : Player = get_parent().owner
# Called when the node enters the scene tree for the first time.
func _ready():
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
func _process(_delta : float) -> void:
text = \"\"
text += \"fps: %s\\n\" % str(Engine.get_frames_per_second())
text += \"position: %d, %d, %d\\n\" % [player.position.x, player.position.y, player.position.z]

View file

@ -17,11 +17,11 @@ extends Node2D
@export var attach_point : Node3D
@export var player : Player
@onready var _player_name_label = $Offset/VBoxContainer/PlayerNameLabel
@onready var _health_bar = $Offset/VBoxContainer/HealthBar
@onready var _v_box_container = $Offset/VBoxContainer
@onready var _player_name_label : Label = $Offset/VBoxContainer/PlayerNameLabel
@onready var _health_bar : ProgressBar = $Offset/VBoxContainer/HealthBar
@onready var _v_box_container : VBoxContainer = $Offset/VBoxContainer
func _process(_delta):
func _process(_delta : float) -> void:
var camera : Camera3D = get_viewport().get_camera_3d()
if camera.is_position_behind(attach_point.global_position):
_v_box_container.hide()
@ -34,8 +34,8 @@ func _process(_delta):
position.x = clampf(position.x, 0, viewport_size.x - _v_box_container.size.x)
position.y = clampf(position.y, _v_box_container.size.y, viewport_size.y)
func _update_health_bar(health) -> void:
func _update_health_bar(health : float) -> void:
_health_bar.value = health
func _on_health_changed(new_health) -> void:
func _on_health_changed(new_health : float) -> void:
_update_health_bar(new_health)

View file

@ -9,22 +9,22 @@ script/source = "class_name BootMenu extends CanvasLayer
signal start_demo
func _ready():
func _ready() -> void:
$Settings.menu_pressed.connect(_on_menu_pressed)
func _on_demo_pressed():
func _on_demo_pressed() -> void:
start_demo.emit()
func _on_multiplayer_pressed():
func _on_multiplayer_pressed() -> void:
_show_menu($Multiplayer)
func _on_settings_pressed():
func _on_settings_pressed() -> void:
_show_menu($Settings)
func _on_quit_pressed():
func _on_quit_pressed() -> void:
get_tree().quit()
func _on_menu_pressed():
func _on_menu_pressed() -> void:
_show_menu($Main)
func _show_menu(menu : PanelContainer) -> void:
@ -49,20 +49,20 @@ var _join_address : RegEx = RegEx.new()
var _registered_ports : RegEx = RegEx.new()
var _config_file : ConfigFile = ConfigFile.new()
signal start_server(port)
signal join_server(host, port)
signal start_server(port : int)
signal join_server(host : String, port : int)
@onready var modal : Control = $Modal
@onready var menu : CanvasLayer = get_parent()
func _ready():
func _ready() -> void:
# see https://datatracker.ietf.org/doc/html/rfc1700
_registered_ports.compile(r'^(?:102[4-9]|10[3-9]\\d|1[1-9]\\d{2}|[2-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$')
_join_address.compile(r'^(?<host>[a-zA-Z0-9.-]+)(:(?<port>:102[4-9]|10[3-9]\\d|1[1-9]\\d{2}|[2-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5]))?$')
_load_config()
hide() # start hidden
func _load_config():
func _load_config() -> void:
var error : Error = _config_file.load(CONFIG_FILE_PATH)
if error != OK:
return
@ -70,22 +70,22 @@ func _load_config():
var profile_name : String = _config_file.get_value(\"profile\", \"name\", \"Newblood\")
%ProfileName.text = profile_name
func _on_save_pressed():
func _on_save_pressed() -> void:
_config_file.set_value(\"profile\", \"name\", %ProfileName.text)
_config_file.save(CONFIG_FILE_PATH)
func _on_menu_pressed():
func _on_menu_pressed() -> void:
hide()
owner.get_node(\"Main\").show()
func _on_quit_pressed():
func _on_quit_pressed() -> void:
get_tree().quit()
func _on_host_pressed():
var port = DEFAULT_PORT
func _on_host_pressed() -> void:
var port : int = DEFAULT_PORT
# check for registered ports number matches
if %ServerPort.text:
var result = _registered_ports.search(%ServerPort.text)
var result : RegExMatch = _registered_ports.search(%ServerPort.text)
if result: # port is valid
port = int(result.get_string())
else: # port is not valid
@ -94,23 +94,23 @@ func _on_host_pressed():
start_server.emit(port, %ProfileName.text)
func _on_join_pressed():
var addr = [DEFAULT_HOST, DEFAULT_PORT]
func _on_join_pressed() -> void:
var addr : Array = [DEFAULT_HOST, DEFAULT_PORT]
# validate join address input
var result = _join_address.search(%JoinAddress.text)
var result : RegExMatch = _join_address.search(%JoinAddress.text)
if result: # address is valid
addr[0] = result.get_string(\"host\")
var rport = result.get_string(\"port\")
var rport : String = result.get_string(\"port\")
if rport: addr[1] = int(rport)
$Modal.show()
join_server.emit(addr[0], addr[1], %ProfileName.text)
func _on_connected_to_server():
func _on_connected_to_server() -> void:
$Modal.hide()
menu.hide()
func _on_connection_failed():
func _on_connection_failed() -> void:
$Modal.hide()
"

View file

@ -5,30 +5,29 @@ bg_color = Color(0.5, 0.5, 0.5, 0.25)
[sub_resource type="GDScript" id="GDScript_gbnwv"]
resource_name = "Settings"
script/source = "class_name Settings extends PanelContainer
script/source = "extends PanelContainer
const WINDOW_MODE_OPTIONS = [DisplayServer.WINDOW_MODE_WINDOWED, DisplayServer.WINDOW_MODE_FULLSCREEN]
@onready var _game_settings : GameSettings = get_node(\"/root/GlobalSettings\")
@onready var _game_settings : Settings = get_node(\"/root/GlobalSettings\")
signal menu_pressed
func _ready():
func _ready() -> void:
%FOVSpinBox.value = _game_settings.fov
%SensitivitySpinBox.value = _game_settings.mouse_sensitivity
var window_mode : int = 1 if _game_settings.fullscreen else 0
%InvertedYCheckbox.button_pressed = _game_settings.inverted_y_axis
%WindowModeOptionButton.select(window_mode)
func _on_save_pressed():
func _on_save_pressed() -> void:
_game_settings.fov = %FOVSpinBox.value
_game_settings.mouse_sensitivity = %SensitivitySpinBox.value
_game_settings.inverted_y_axis = %InvertedYCheckbox.button_pressed
_game_settings.fullscreen = %WindowModeOptionButton.selected == 1
_game_settings.save_to_file()
func _on_menu_pressed():
func _on_menu_pressed() -> void:
menu_pressed.emit()
"

View file

@ -13,33 +13,33 @@ script/source = "class_name Game extends Node3D
var mode : Node
func _ready():
func _ready() -> void:
$BootMenu.start_demo.connect(_start_demo)
$BootMenu/Multiplayer.start_server.connect(_start_server)
$BootMenu/Multiplayer.join_server.connect(_join_server)
func _start_demo():
func _start_demo() -> void:
_set_game_mode(SINGLEPLAYER.instantiate())
$BootMenu.hide()
func _start_server(port, nickname):
func _start_server(port : int, nickname : String) -> void:
_set_game_mode(MULTIPLAYER.instantiate())
mode.start_server(port, nickname)
$BootMenu.hide()
func _join_server(host, port, nickname):
func _join_server(host : String, port : int, nickname : String) -> void:
_set_game_mode(MULTIPLAYER.instantiate())
mode.connected_to_server.connect($BootMenu/Multiplayer._on_connected_to_server)
mode.connection_failed.connect($BootMenu/Multiplayer._on_connection_failed)
mode.join_server(host, port, nickname)
func _input(event):
func _input(event : InputEvent) -> void:
if event.is_action_pressed(\"exit\"):
_set_game_mode(null)
multiplayer.multiplayer_peer.close()
$BootMenu.show()
func _set_game_mode(new_mode : Node):
func _set_game_mode(new_mode : Node) -> void:
if mode != null:
remove_child(mode)
mode.queue_free()
@ -50,7 +50,7 @@ func _set_game_mode(new_mode : Node):
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
add_child(mode)
func _unhandled_input(event):
func _unhandled_input(_event : InputEvent) -> void:
# switch mouse mode
if OS.is_debug_build() and Input.is_action_just_pressed(\"toggle_mouse_capture\"):
if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE:

View file

@ -5,18 +5,17 @@
[ext_resource type="Terrain3DMaterial" uid="uid://bd4lr5sxu8xu" path="res://maps/genesis/resources/material.res" id="2_o2y3d"]
[ext_resource type="Terrain3DTextureList" uid="uid://dnqa8kxgm3xuw" path="res://maps/genesis/resources/textures.res" id="3_1cww7"]
[node name="Map" type="Node3D"]
[node name="Sunlight" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866026, -0.500003, 0.749999, -0.43301, 0, 0, 0)
shadow_enabled = true
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = ExtResource("1_3nr12")
[node name="Terrain3D" type="Terrain3D" parent="."]
[node name="Terrain3D" type="Terrain3D"]
storage = ExtResource("1_a88qe")
material = ExtResource("2_o2y3d")
texture_list = ExtResource("3_1cww7")
collision_layer = 2147483648
collision_mask = 2147483648
mesh_size = 24
[node name="Sunlight" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.75, -0.43301, 0, 100, 0)
shadow_enabled = true
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = ExtResource("1_3nr12")

View file

@ -9,14 +9,14 @@
script/source = "extends Node
@onready var player_node : Player = $Player
@onready var target_dummy = $TargetDummy
@onready var target_dummy : RigidBody3D = $TargetDummy
@onready var player_respawn_location = player_node.position
@onready var player_respawn_location : Vector3 = player_node.position
func _ready():
func _ready() -> void:
player_node.died.connect(respawn_player)
func respawn_player(player):
func respawn_player(player : Player) -> void:
player.respawn(player_respawn_location)
"

View file

@ -13,18 +13,18 @@ script/source = "class_name Multiplayer extends Node
@export var FLAG : PackedScene
@export var MAX_CLIENTS : int = 24
@onready var map = $Map
@onready var players = $Players
@onready var objectives = $Objectives
@onready var map : Node = $Map
@onready var players : Node = $Players
@onready var objectives : Node = $Objectives
signal connected_to_server
signal connection_failed
func load_map(scene : PackedScene):
func load_map(scene : PackedScene) -> void:
map.add_child(scene.instantiate())
func start_server(port, nickname):
var peer = ENetMultiplayerPeer.new()
func start_server(port : int, nickname : String) -> void:
var peer : ENetMultiplayerPeer = ENetMultiplayerPeer.new()
peer.create_server(port, MAX_CLIENTS)
multiplayer.multiplayer_peer = peer
@ -38,24 +38,24 @@ func start_server(port, nickname):
add_flag()
func join_server(host, port, nickname):
var peer = ENetMultiplayerPeer.new()
func join_server(host : String, port : int, nickname : String) -> void:
var peer : ENetMultiplayerPeer= ENetMultiplayerPeer.new()
peer.create_client(host, port)
multiplayer.connected_to_server.connect(_on_connected_to_server.bind(nickname))
multiplayer.connection_failed.connect(_on_connection_failed)
multiplayer.multiplayer_peer = peer
func _on_connected_to_server(nickname):
func _on_connected_to_server(nickname : String) -> void:
connected_to_server.emit()
_join_match.rpc(nickname)
func _on_connection_failed():
func _on_connection_failed() -> void:
connection_failed.emit()
func respawn_player(player):
func respawn_player(player : Player) -> void:
player.respawn(Vector3(0.0, 150.0, 0.0))
func add_player(peer_id : int, nickname : String):
func add_player(peer_id : int, nickname : String) -> void:
var player : Player = PLAYER.instantiate()
player.name = str(peer_id)
player.player_id = peer_id
@ -65,8 +65,8 @@ func add_player(peer_id : int, nickname : String):
player.died.connect(respawn_player)
print(\"Peer `%s` connected\" % player.name)
func remove_player(peer_id : int):
var node_name = str(peer_id)
func remove_player(peer_id : int) -> void:
var node_name : String = str(peer_id)
if players.has_node(node_name):
var player : Player = players.get_node(node_name)
player.die()
@ -74,17 +74,17 @@ func remove_player(peer_id : int):
print(\"Peer `%s` disconnected\" % node_name)
@rpc(\"any_peer\")
func _join_match(nickname):
func _join_match(nickname : String) -> void:
if multiplayer.is_server():
add_player(multiplayer.get_remote_sender_id(), nickname)
func add_flag():
func add_flag() -> void:
var flag : Flag = FLAG.instantiate()
flag.position = Vector3(5.0, 100.0, 0.0)
objectives.add_child(flag)
func _exit_tree():
func _exit_tree() -> void:
if multiplayer.is_server():
multiplayer.peer_connected.disconnect(add_player)
multiplayer.peer_disconnected.disconnect(remove_player)

View file

@ -17,7 +17,29 @@ config/icon="res://icon.svg"
[autoload]
GlobalSettings="*res://game_settings.gd"
GlobalSettings="*res://systems/settings.gd"
[debug]
gdscript/warnings/unassigned_variable=2
gdscript/warnings/unassigned_variable_op_assign=2
gdscript/warnings/unused_variable=2
gdscript/warnings/unused_local_constant=2
gdscript/warnings/unused_private_class_variable=2
gdscript/warnings/unused_parameter=2
gdscript/warnings/unused_signal=2
gdscript/warnings/shadowed_variable=2
gdscript/warnings/shadowed_variable_base_class=2
gdscript/warnings/shadowed_global_identifier=2
gdscript/warnings/unreachable_code=2
gdscript/warnings/unreachable_pattern=2
gdscript/warnings/standalone_expression=2
gdscript/warnings/standalone_ternary=2
gdscript/warnings/incompatible_ternary=2
gdscript/warnings/property_used_as_function=2
gdscript/warnings/constant_used_as_function=2
gdscript/warnings/function_used_as_property=2
gdscript/warnings/untyped_declaration=2
[editor]

View file

@ -1,8 +0,0 @@
shader_type canvas_item;
uniform sampler2D background : source_color;
void fragment() {
COLOR = texture(background, UV);
}

View file

@ -1,4 +1,4 @@
class_name GameSettings extends Node
class_name Settings extends Node
var _config_file : ConfigFile = ConfigFile.new()
@ -9,7 +9,7 @@ var fullscreen : bool
const SETTINGS_FILE_PATH : String = "user://settings.cfg"
func _ready():
func _ready() -> void:
var error : Error = _config_file.load(SETTINGS_FILE_PATH)
if error != OK:
print("Settings not found, using defaults")
@ -21,7 +21,7 @@ func _ready():
fullscreen = _config_file.get_value("graphics", "fullscreen", false)
_update_screen()
func save_to_file():
func save_to_file() -> void:
_config_file.set_value("gameplay", "fov", fov)
_config_file.set_value("gameplay", "mouse_sensitivity", mouse_sensitivity)
_config_file.set_value("gameplay", "inverted_y_axis", inverted_y_axis)
@ -29,7 +29,7 @@ func save_to_file():
_update_screen()
_config_file.save(SETTINGS_FILE_PATH)
func _update_screen():
func _update_screen() -> void:
if fullscreen:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
else:

View file

@ -1,45 +0,0 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://clq4uym4arpv3"
path="res://.godot/imported/SpaceGun.glb-ee1e940c9dd77150eaf36c6537feefef.scn"
[deps]
source_file="res://weapons/space_gun/assets/SpaceGun.glb"
dest_files=["res://.godot/imported/SpaceGun.glb-ee1e940c9dd77150eaf36c6537feefef.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={
"materials": {
"_defaultMat": {
"use_external/enabled": true,
"use_external/path": ""
},
"dark": {
"use_external/enabled": true,
"use_external/path": ""
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=2

View file

@ -1,35 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cvtqt0k2ewd07"
path.s3tc="res://.godot/imported/albedo.png-7f543d432ab75668956abd5bcc51a13b.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://weapons/space_gun/assets/albedo.png"
dest_files=["res://.godot/imported/albedo.png-7f543d432ab75668956abd5bcc51a13b.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View file

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b30y3pq4u5r0h"
path="res://.godot/imported/albedo0.png-8dedb9e51f95ee8e69f9a00bccf9fb16.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://weapons/space_gun/assets/textures/albedo0.png"
dest_files=["res://.godot/imported/albedo0.png-8dedb9e51f95ee8e69f9a00bccf9fb16.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1