mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-16 08:55:33 +00:00
Merge branch 'cleanup/minor-refactorings' into 'develop'
🐛 Refactored AreaDamageComponent to be an ExplosiveDamageComponent See merge request open-fpsz/open-fpsz!33
This commit is contained in:
commit
9b22018128
12 changed files with 1331 additions and 1340 deletions
|
|
@ -1,4 +0,0 @@
|
||||||
extends Area3D
|
|
||||||
class_name AreaDamageComponent
|
|
||||||
|
|
||||||
@export var damage : int = 100
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
[gd_scene load_steps=2 format=3 uid="uid://ds1hekx1dq1bg"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://components/area_damage_component.gd" id="1_hn2e3"]
|
|
||||||
|
|
||||||
[node name="AreaDamage" type="Area3D"]
|
|
||||||
collision_layer = 4
|
|
||||||
script = ExtResource("1_hn2e3")
|
|
||||||
16
components/explosive_damage_component.gd
Normal file
16
components/explosive_damage_component.gd
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
class_name ExplosiveDamageComponent extends Area3D
|
||||||
|
|
||||||
|
@export var damage : int = 100
|
||||||
|
@export var impulse_force : int = 1000
|
||||||
|
|
||||||
|
func _physics_process(_delta):
|
||||||
|
for body in get_overlapping_bodies():
|
||||||
|
if body is RigidBody3D:
|
||||||
|
var direction = (body.global_position - global_position).normalized()
|
||||||
|
body.apply_central_impulse(direction * impulse_force)
|
||||||
|
|
||||||
|
for area in get_overlapping_areas():
|
||||||
|
if area is HealthComponent and is_multiplayer_authority():
|
||||||
|
area.damage.rpc(damage)
|
||||||
|
|
||||||
|
set_physics_process(false)
|
||||||
9
components/explosive_damage_component.tscn
Normal file
9
components/explosive_damage_component.tscn
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://ds1hekx1dq1bg"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://components/explosive_damage_component.gd" id="1_2uehk"]
|
||||||
|
|
||||||
|
[node name="ExplosiveDamage" type="Area3D"]
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 5
|
||||||
|
monitorable = false
|
||||||
|
script = ExtResource("1_2uehk")
|
||||||
|
|
@ -12,10 +12,9 @@ signal health_changed(value : int)
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
heal_full()
|
heal_full()
|
||||||
area_entered.connect(_on_area_entered)
|
|
||||||
|
|
||||||
@rpc("call_local")
|
@rpc("call_local")
|
||||||
func _damage(amount : int) -> void:
|
func damage(amount : int) -> void:
|
||||||
health = clampf(health - amount, 0.0, max_health)
|
health = clampf(health - amount, 0.0, max_health)
|
||||||
if health == 0.0:
|
if health == 0.0:
|
||||||
health_zeroed.emit()
|
health_zeroed.emit()
|
||||||
|
|
@ -29,10 +28,3 @@ func heal_full():
|
||||||
return
|
return
|
||||||
|
|
||||||
_heal.rpc(max_health)
|
_heal.rpc(max_health)
|
||||||
|
|
||||||
func _on_area_entered(area : Area3D):
|
|
||||||
if not is_multiplayer_authority():
|
|
||||||
return
|
|
||||||
|
|
||||||
if area is AreaDamageComponent:
|
|
||||||
_damage.rpc(area.damage)
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
[ext_resource type="Shape3D" uid="uid://dkwljsgaflf31" path="res://entities/player/collision_shape.res" id="2_sgbmt"]
|
[ext_resource type="Shape3D" uid="uid://dkwljsgaflf31" path="res://entities/player/collision_shape.res" id="2_sgbmt"]
|
||||||
|
|
||||||
[node name="HealthComponent" type="Area3D"]
|
[node name="HealthComponent" type="Area3D"]
|
||||||
collision_layer = 0
|
collision_layer = 4
|
||||||
collision_mask = 4
|
collision_mask = 0
|
||||||
script = ExtResource("1_00xis")
|
script = ExtResource("1_00xis")
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -183,8 +183,8 @@ func _die():
|
||||||
animation_player.play("death")
|
animation_player.play("death")
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_interval(4)
|
tween.tween_interval(4)
|
||||||
tween.tween_callback(func(): died.emit(self))
|
|
||||||
tween.tween_callback(func():
|
tween.tween_callback(func():
|
||||||
|
died.emit(self)
|
||||||
if _is_first_person():
|
if _is_first_person():
|
||||||
animation_player.stop()
|
animation_player.stop()
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ func _process(delta):
|
||||||
_fire_primary.rpc()
|
_fire_primary.rpc()
|
||||||
jetting = Input.is_action_pressed("jump_and_jet")
|
jetting = Input.is_action_pressed("jump_and_jet")
|
||||||
skiing = Input.is_action_pressed("ski")
|
skiing = Input.is_action_pressed("ski")
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
_update_camera(delta)
|
_update_camera(delta)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://c7ae4jw5d8mue"]
|
[gd_scene load_steps=2 format=3 uid="uid://bvwxfgygm2xb8"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cbhx1xme0sb7k" path="res://entities/player/player.tscn" id="1_7bj5d"]
|
[sub_resource type="GDScript" id="GDScript_1qrbp"]
|
||||||
[ext_resource type="PackedScene" uid="uid://chbno00ugl6te" path="res://maps/genesis/genesis.tscn" id="2_nnx26"]
|
|
||||||
|
|
||||||
[sub_resource type="GDScript" id="GDScript_pj58d"]
|
|
||||||
script/source = "class_name Multiplayer extends Node
|
script/source = "class_name Multiplayer extends Node
|
||||||
|
|
||||||
@export_category(\"Parameters\")
|
@export_category(\"Parameters\")
|
||||||
|
|
@ -43,10 +40,10 @@ func join_server(host, port):
|
||||||
multiplayer.connected_to_server.connect(_on_connected_to_server)
|
multiplayer.connected_to_server.connect(_on_connected_to_server)
|
||||||
multiplayer.connection_failed.connect(_on_connection_failed)
|
multiplayer.connection_failed.connect(_on_connection_failed)
|
||||||
multiplayer.multiplayer_peer = peer
|
multiplayer.multiplayer_peer = peer
|
||||||
|
|
||||||
func _on_connected_to_server():
|
func _on_connected_to_server():
|
||||||
connected_to_server.emit()
|
connected_to_server.emit()
|
||||||
|
|
||||||
func _on_connection_failed():
|
func _on_connection_failed():
|
||||||
connection_failed.emit()
|
connection_failed.emit()
|
||||||
|
|
||||||
|
|
@ -75,9 +72,7 @@ func _exit_tree():
|
||||||
"
|
"
|
||||||
|
|
||||||
[node name="Multiplayer" type="Node"]
|
[node name="Multiplayer" type="Node"]
|
||||||
script = SubResource("GDScript_pj58d")
|
script = SubResource("GDScript_1qrbp")
|
||||||
MAP = ExtResource("2_nnx26")
|
|
||||||
PLAYER = ExtResource("1_7bj5d")
|
|
||||||
|
|
||||||
[node name="Map" type="Node" parent="."]
|
[node name="Map" type="Node" parent="."]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,9 @@
|
||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
@onready var fire = $Fire
|
@onready var fire = $Fire
|
||||||
@onready var area_damage : AreaDamageComponent = $AreaDamageComponent
|
@onready var explosive_damage : ExplosiveDamageComponent = $ExplosiveDamageComponent
|
||||||
var explosion_effect_pending : bool = false
|
var explosion_effect_pending : bool = false
|
||||||
|
|
||||||
const impulse_force = 1000;
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
fire.emitting = true
|
fire.emitting = true
|
||||||
|
fire.finished.connect(func(): queue_free())
|
||||||
func _physics_process(_delta):
|
|
||||||
var bodies = area_damage.get_overlapping_bodies() if area_damage.monitoring else []
|
|
||||||
for body in bodies:
|
|
||||||
if body is RigidBody3D:
|
|
||||||
var direction = (body.global_position - global_position).normalized()
|
|
||||||
body.apply_central_impulse(direction * impulse_force)
|
|
||||||
|
|
||||||
area_damage.monitorable = false
|
|
||||||
area_damage.monitoring = false
|
|
||||||
await get_tree().create_timer(1.0).timeout
|
|
||||||
queue_free()
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=9 format=3 uid="uid://8atq41j7wd55"]
|
[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://weapons/space_gun/projectile_explosion.gd" id="1_fp5td"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ds1hekx1dq1bg" path="res://components/area_damage_component.tscn" id="2_reyvo"]
|
[ext_resource type="PackedScene" uid="uid://ds1hekx1dq1bg" path="res://components/explosive_damage_component.tscn" id="2_d4sf4"]
|
||||||
|
|
||||||
[sub_resource type="Curve" id="Curve_rg204"]
|
[sub_resource type="Curve" id="Curve_rg204"]
|
||||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||||
|
|
@ -41,8 +41,8 @@ fixed_fps = 60
|
||||||
process_material = SubResource("ParticleProcessMaterial_3mf41")
|
process_material = SubResource("ParticleProcessMaterial_3mf41")
|
||||||
draw_pass_1 = SubResource("SphereMesh_k3pnh")
|
draw_pass_1 = SubResource("SphereMesh_k3pnh")
|
||||||
|
|
||||||
[node name="AreaDamageComponent" parent="." instance=ExtResource("2_reyvo")]
|
[node name="ExplosiveDamageComponent" parent="." instance=ExtResource("2_d4sf4")]
|
||||||
damage = 35
|
damage = 35
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="AreaDamageComponent"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="ExplosiveDamageComponent"]
|
||||||
shape = SubResource("SphereShape3D_mlo2k")
|
shape = SubResource("SphereShape3D_mlo2k")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue