Implement Teams and disallow team damage in Rabbit

This commit is contained in:
Squinty 2024-04-26 15:49:43 +00:00
parent 1a19e5edfa
commit ac8bd2d07c
10 changed files with 46 additions and 23 deletions

View file

@ -6,7 +6,7 @@ enum FlagState { FLAG_STATE_ON_STAND, FLAG_STATE_DROPPED, FLAG_STATE_TAKEN }
signal grabbed(grabber : Player)
signal regrabbed
signal dropped
signal dropped(dropper : Player)
var last_carrier : Player = null
@onready var _mesh : Node = $Smoothing/Mesh
@ -24,9 +24,9 @@ func grab(grabber : Player) -> void:
else:
regrabbed.emit()
func drop() -> void:
func drop(dropper : Player) -> void:
if flag_state == FlagState.FLAG_STATE_TAKEN:
_mesh.show()
flag_state = FlagState.FLAG_STATE_DROPPED
dropped.emit()
dropped.emit(dropper)

View file

@ -39,6 +39,7 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
set(id):
player_id = id
$PlayerInput.set_multiplayer_authority(id)
@export var team_id : int = 1
@export var nickname : String
@onready var input : PlayerInput = $PlayerInput
@ -113,7 +114,7 @@ func _jump() -> void:
_jumping = true
func _throw_flag() -> void:
flag_carry_component.throw(linear_velocity)
flag_carry_component.throw(linear_velocity, self)
func is_on_floor() -> bool:
if shape_cast.is_colliding():
@ -228,12 +229,13 @@ func _is_player_dead() -> bool:
return player_state != PlayerState.PLAYER_ALIVE
func die(killer_id : int) -> void:
flag_carry_component.drop()
flag_carry_component.drop(self)
player_state = PlayerState.PLAYER_DEAD
if _is_pawn():
animation_player.play("death")
died.emit(self, killer_id)
@rpc("call_local", "reliable")
func respawn(location : Vector3) -> void:
animation_player.stop()
player_state = PlayerState.PLAYER_ALIVE
@ -243,7 +245,7 @@ func respawn(location : Vector3) -> void:
func _exit_tree() -> void:
player_state = PlayerState.PLAYER_DEAD
flag_carry_component.drop()
flag_carry_component.drop(self)
func display_jetpack_particles() -> void:
for particle: GPUParticles3D in jetpack_particles:

View file

@ -77,6 +77,9 @@ properties/4/replication_mode = 2
properties/5/path = NodePath(".:nickname")
properties/5/spawn = true
properties/5/replication_mode = 2
properties/6/path = NodePath(".:team_id")
properties/6/spawn = true
properties/6/replication_mode = 2
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_5j4ew"]
properties/0/path = NodePath(".:direction")
@ -237,7 +240,8 @@ shape = ExtResource("2_vjqny")
[node name="HUD" parent="." instance=ExtResource("3_ccety")]
[node name="HealthComponent" parent="." instance=ExtResource("5_t6i6e")]
[node name="HealthComponent" parent="." node_paths=PackedStringArray("_player") instance=ExtResource("5_t6i6e")]
_player = NodePath("..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="HealthComponent"]
shape = ExtResource("2_vjqny")