Fixed team interactions

This commit is contained in:
Rendo 2025-11-27 11:30:42 +05:00
commit 917d52680c
5 changed files with 45 additions and 21 deletions

View file

@ -1,10 +1,23 @@
extends Node
@export var player: Player
@export var layer: bool
@export var inverse: bool
const ATTACK_LAYER: int = 0b10000
const DEFENCE_LAYER: int = 0b100000
func _ready() -> void:
get_parent().collision_mask |= (ATTACK_LAYER if player.team == Session.TEAMS.DEFENCE else DEFENCE_LAYER)
func on_spawned() -> void:
var mask = (ATTACK_LAYER if (player.team == Session.TEAMS.DEFENCE != inverse) else DEFENCE_LAYER)
if layer:
get_parent().collision_layer |= mask
else:
get_parent().collision_mask |= mask
global_update.rpc(layer,mask)
@rpc
func global_update(new_layer,mask) -> void:
if new_layer:
get_parent().collision_layer |= mask
else:
get_parent().collision_mask |= mask