ambush 参数:enter_affected_by_visibility

This commit is contained in:
cakipaul 2025-07-15 16:05:10 +08:00
parent cb52aed2ed
commit aedf7d3896
3 changed files with 27 additions and 23 deletions

View File

@ -9,7 +9,12 @@ class_name Event2D
event_name = val
if is_node_ready() and Engine.is_editor_hint():
_auto_memo()
@export_enum("none", "show", "hide") var event_mode := "show"
@export_enum("none", "show", "hide") var event_mode := "show":
set(val):
if event_mode != val:
event_mode = val
if is_node_ready() and Engine.is_editor_hint():
_auto_memo()
@export var event_stages: Array[int] = []:
set(val):
if event_stages != val:
@ -23,7 +28,12 @@ class_name Event2D
pre_event_name = val
if is_node_ready() and Engine.is_editor_hint():
_auto_memo()
@export_enum("none", "show", "hide") var pre_event_mode := "show"
@export_enum("none", "show", "hide") var pre_event_mode := "show":
set(val):
if pre_event_mode != val:
pre_event_mode = val
if is_node_ready() and Engine.is_editor_hint():
_auto_memo()
@export var pre_event_stages: Array[int] = []:
set(val):
if pre_event_stages != val:
@ -63,10 +73,12 @@ func refresh_visibility() -> void:
should_show = prev_stage in pre_event_stages
if pre_event_mode == "hide":
should_show = !should_show
if should_show and event_name != &"" and event_mode != "none":
should_show = stage in event_stages
if event_mode == "hide":
should_show = !should_show
# 只有在 pre_event should_show 后,才会检查 event
if should_show:
if event_name != &"" and event_mode != "none":
should_show = stage in event_stages
if event_mode == "hide":
should_show = !should_show
if visible != should_show:
visible = should_show

View File

@ -20,6 +20,8 @@ signal sign_mark_offset_updated
trigger_mode = val
if is_node_ready():
_check_sign_status()
# enter or area_enter 时是否受可见性影响
@export var enter_affected_by_visibility := false
@export var collision_width_and_x := Vector2(20.0, 0):
set(val):
collision_width_and_x = val
@ -149,6 +151,8 @@ func _interacted():
func _entered(_body = null):
if enabled and trigger_mode == "enter":
if enter_affected_by_visibility and not is_visible_in_tree():
return
# _entered 不需要 visible
# if is_visible_in_tree():
_do_trigger()
@ -156,6 +160,8 @@ func _entered(_body = null):
func _area_entered(_area = null):
if enabled and trigger_mode == "area_enter":
if enter_affected_by_visibility and not is_visible_in_tree():
return
# _area_entered 不需要 visible
# if is_visible_in_tree():
_do_trigger()

View File

@ -980,29 +980,14 @@ texture = ExtResource("10_sqio2")
position = Vector2(105, 2)
script = ExtResource("10_qoe83")
event_name = &"c03_f2_madman_runaway"
event_mode = "hide"
event_stages = Array[int]([1])
event_stages = Array[int]([0])
pre_event_name = &"c03_invite_xchan_supper"
pre_event_mode = "hide"
pre_event_stages = Array[int]([0])
event_memo = "当前置事件[c03_invite_xchan_supper!=0:初始化]
并且当事件[c03_f2_madman_runaway!=1:跑开_纸人挡路]时显示该节点"
并且当事件[c03_f2_madman_runaway=0:初始化]时显示该节点"
metadata/_custom_type_script = "uid://bkkiyk5jkdw4d"
[node name="小蜡烛PointLight2D" type="PointLight2D" parent="Ground/DeployLayer/Event2D疯子跑开"]
visible = false
position = Vector2(69, 45)
color = Color(0.999971, 0.912551, 0.842208, 1)
blend_mode = 2
texture = ExtResource("11_2rktm")
texture_scale = 0.6
[node name="小蜡烛" type="AnimatedSprite2D" parent="Ground/DeployLayer/Event2D疯子跑开/小蜡烛PointLight2D"]
self_modulate = Color(0.611765, 0.611765, 0.611765, 1)
position = Vector2(0, 12.8172)
sprite_frames = SubResource("SpriteFrames_lipxo")
autoplay = "default"
[node name="Pro疯子慌张跑开" parent="Ground/DeployLayer/Event2D疯子跑开" instance=ExtResource("10_p6da7")]
position = Vector2(102, 22)
sprite_frames = ExtResource("12_sqio2")
@ -1025,6 +1010,7 @@ debug_mov_animation = "疯子_慌张跑开"
[node name="Ambush疯子慌张跑开" parent="Ground/DeployLayer/Event2D疯子跑开" instance=ExtResource("14_k01ve")]
position = Vector2(125, 46)
enter_affected_by_visibility = true
[node name="楼梯蜡烛" type="Node2D" parent="Ground/DeployLayer" index="8"]