Changing bridge layer logic to Bridge script instead of BasicCharacter. The Bridge was moved from GameLevel to TerrainManager because its more related to terrain.

This commit is contained in:
2025-06-21 20:34:26 -03:00
parent 57b67e6d98
commit 724df1b070
10 changed files with 127 additions and 39 deletions

39
Terrain/bridge.gd Normal file
View File

@@ -0,0 +1,39 @@
extends TileMapLayer
class_name Bridge
@export_category("Objects")
@export var bellow_bridge_area: Area2D
@export var on_bridge_area: Area2D
func _process(_delta: float) -> void:
var character_body_bellow_bridge: Node2D = bellow_bridge_area.get_body()
var character_body_on_bridge: Node2D = on_bridge_area.get_body()
if character_body_bellow_bridge:
if bellow_bridge_area.get_character_body_bellow_bridge():
character_body_bellow_bridge.set_collision_layer_value(4, false)
character_body_bellow_bridge.set_collision_mask_value(4, false)
self.z_index = 2
else:
character_body_bellow_bridge.set_collision_layer_value(4, true)
character_body_bellow_bridge.set_collision_mask_value(4, false)
self.z_index = 0
if character_body_on_bridge:
if on_bridge_area.get_character_body_on_bridge():
character_body_on_bridge.set_collision_layer_value(8, false)
character_body_on_bridge.set_collision_mask_value(8, false)
character_body_on_bridge.set_collision_layer_value(1, false)
character_body_on_bridge.set_collision_mask_value(1, false)
character_body_on_bridge.set_collision_layer_value(2, true)
character_body_on_bridge.set_collision_mask_value(2, true)
else:
character_body_on_bridge.set_collision_layer_value(8, true)
character_body_on_bridge.set_collision_mask_value(8, true)
character_body_on_bridge.set_collision_layer_value(1, true)
character_body_on_bridge.set_collision_mask_value(1, true)
character_body_on_bridge.set_collision_layer_value(2, false)
character_body_on_bridge.set_collision_mask_value(2, false)