Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ const DEFAULT_SPRITE_FRAMES = preload("uid://ovu5wqo15s5g")
@export_range(0.1, 5, 0.1, "or_greater", "suffix:s") var time_to_detect_player: float = 1.0
## Scale factor for the detection area.
@export_range(0.1, 5, 0.1, "or_greater", "or_less") var detection_area_scale: float = 1.0:
set(new_value):
detection_area_scale = new_value
if detection_area:
detection_area.scale = Vector2.ONE * detection_area_scale
set = _set_detection_area_scale

@export_category("Debug")
## Enables movement in the editor for debugging.
Expand Down Expand Up @@ -118,6 +115,7 @@ var character_animation_player_behavior: CharacterAnimationPlayerBehavior = %Cha
@onready var _foot_sound: AudioStreamPlayer2D = %FootSound
@onready var _fire_sound: AudioStreamPlayer2D = %FireSound
@onready var _torch_hit_sound: AudioStreamPlayer2D = %TorchHitSound
@onready var _light: PointLight2D = %Light


func _get_configuration_warnings() -> PackedStringArray:
Expand All @@ -144,8 +142,8 @@ func _ready() -> void:

_set_sprite_frames(sprite_frames)

if detection_area:
detection_area.scale = Vector2.ONE * detection_area_scale
_set_sprite_frames(sprite_frames)
_set_detection_area_scale(detection_area_scale)

# When the level starts, the guard is placed at the beginning of the
# patrol path.
Expand Down Expand Up @@ -430,6 +428,15 @@ func _set_sprite_frames(new_sprite_frames: SpriteFrames) -> void:
update_configuration_warnings()


func _set_detection_area_scale(new_detection_area_scale: float) -> void:
detection_area_scale = new_detection_area_scale
if not is_node_ready():
return
if detection_area:
detection_area.scale = Vector2.ONE * detection_area_scale
_light.visible = detection_area_scale > 0.1


func _set_alerted_sound_stream(new_value: AudioStream) -> void:
alerted_sound_stream = new_value
if not is_node_ready():
Expand Down
1 change: 1 addition & 0 deletions scenes/game_elements/characters/enemies/guard/guard.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ collision_layer = 0
script = ExtResource("4_mswbt")

[node name="Light" type="PointLight2D" parent="DetectionArea" unique_id=366085581]
unique_name_in_owner = true
position = Vector2(37.3333, 1.33333)
scale = Vector2(0.340496, 0.340496)
color = Color(1, 1, 0.796078, 1)
Expand Down
Loading