Proper death
This commit is contained in:
parent
e8af70b198
commit
d918533ebe
4 changed files with 20 additions and 4 deletions
|
|
@ -8824,6 +8824,7 @@ script = ExtResource("38_2cl6u")
|
||||||
[connection signal="died" from="." to="Camera3D/DeadSpectator" method="set_active"]
|
[connection signal="died" from="." to="Camera3D/DeadSpectator" method="set_active"]
|
||||||
[connection signal="died" from="." to="BodyStateMachine/Death" method="on_death"]
|
[connection signal="died" from="." to="BodyStateMachine/Death" method="on_death"]
|
||||||
[connection signal="died" from="." to="PlayerMovement" method="disable"]
|
[connection signal="died" from="." to="PlayerMovement" method="disable"]
|
||||||
|
[connection signal="died" from="." to="WeaponSystem" method="drop_death"]
|
||||||
[connection signal="died" from="." to="WeaponSystem" method="disable"]
|
[connection signal="died" from="." to="WeaponSystem" method="disable"]
|
||||||
[connection signal="died" from="." to="PickupRange" method="disable"]
|
[connection signal="died" from="." to="PickupRange" method="disable"]
|
||||||
[connection signal="health_changed" from="." to="HUD/Healthbar" method="on_hp_changed"]
|
[connection signal="health_changed" from="." to="HUD/Healthbar" method="on_hp_changed"]
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ func die() -> void:
|
||||||
died.emit()
|
died.emit()
|
||||||
die_on_peers.rpc()
|
die_on_peers.rpc()
|
||||||
passived = true
|
passived = true
|
||||||
|
collision_layer = 0
|
||||||
|
|
||||||
@rpc("authority","call_remote","reliable")
|
@rpc("authority","call_remote","reliable")
|
||||||
func die_on_peers():
|
func die_on_peers():
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ var debuff_tween: Tween
|
||||||
|
|
||||||
func disable() -> void:
|
func disable() -> void:
|
||||||
disabled = true
|
disabled = true
|
||||||
|
player.velocity = Vector3.ZERO
|
||||||
|
|
||||||
func process_movement(max_speed: float,acceleration: float,deceleration: float,delta: float) -> void:
|
func process_movement(max_speed: float,acceleration: float,deceleration: float,delta: float) -> void:
|
||||||
if is_multiplayer_authority() == false:
|
if is_multiplayer_authority() == false:
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ signal slots_updated(current_slot: StringName,slots: Dictionary[StringName,Strin
|
||||||
signal ammo_updated(ammo: int, remaining_ammo: int)
|
signal ammo_updated(ammo: int, remaining_ammo: int)
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
if not multiplayer.is_server():
|
||||||
|
return
|
||||||
player_input.drop.connect(drop_current)
|
player_input.drop.connect(drop_current)
|
||||||
player_input.fire_begin.connect(use_begin)
|
player_input.fire_begin.connect(use_begin)
|
||||||
player_input.fire_end.connect(use_end)
|
player_input.fire_end.connect(use_end)
|
||||||
|
|
@ -128,6 +130,13 @@ func drop_slot(slot: StringName):
|
||||||
return
|
return
|
||||||
drop(slots[slot])
|
drop(slots[slot])
|
||||||
|
|
||||||
|
func drop_death():
|
||||||
|
if slots["primary"] != null:
|
||||||
|
drop_slot("primary")
|
||||||
|
elif slots["secondary"] != null:
|
||||||
|
drop_slot("secondary")
|
||||||
|
drop_slot("bomb")
|
||||||
|
|
||||||
func check_for_empty() -> void:
|
func check_for_empty() -> void:
|
||||||
if is_multiplayer_authority() == false:
|
if is_multiplayer_authority() == false:
|
||||||
return
|
return
|
||||||
|
|
@ -174,35 +183,39 @@ func disable() -> void:
|
||||||
disabled = true
|
disabled = true
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
|
if not multiplayer.is_server():
|
||||||
|
return
|
||||||
if current_state == null or disabled:
|
if current_state == null or disabled:
|
||||||
return
|
return
|
||||||
current_state.update(delta)
|
current_state.update(delta)
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
if not multiplayer.is_server():
|
||||||
|
return
|
||||||
if current_state == null or disabled:
|
if current_state == null or disabled:
|
||||||
return
|
return
|
||||||
current_state.physics_update(delta)
|
current_state.physics_update(delta)
|
||||||
|
|
||||||
func use_begin() -> void:
|
func use_begin() -> void:
|
||||||
if Session.round_state == Session.ROUND_STATES.BUY:
|
if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled:
|
||||||
return
|
return
|
||||||
if current_state != null:
|
if current_state != null:
|
||||||
current_state.use_begin()
|
current_state.use_begin()
|
||||||
|
|
||||||
func use_end() -> void:
|
func use_end() -> void:
|
||||||
if Session.round_state == Session.ROUND_STATES.BUY:
|
if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled:
|
||||||
return
|
return
|
||||||
if current_state != null:
|
if current_state != null:
|
||||||
current_state.use_end()
|
current_state.use_end()
|
||||||
|
|
||||||
func alternate_state() -> void:
|
func alternate_state() -> void:
|
||||||
if Session.round_state == Session.ROUND_STATES.BUY:
|
if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled:
|
||||||
return
|
return
|
||||||
if current_state != null:
|
if current_state != null:
|
||||||
current_state.alternate_state()
|
current_state.alternate_state()
|
||||||
|
|
||||||
func switch_mode() -> void:
|
func switch_mode() -> void:
|
||||||
if Session.round_state == Session.ROUND_STATES.BUY:
|
if not multiplayer.is_server() or Session.round_state == Session.ROUND_STATES.BUY or disabled:
|
||||||
return
|
return
|
||||||
if current_state != null:
|
if current_state != null:
|
||||||
current_state.switch_mode()
|
current_state.switch_mode()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue