钩锁功能完善

This commit is contained in:
Reed 2026-01-05 15:28:43 +08:00
parent bea2ff4c5c
commit 0e84094564
24 changed files with 213 additions and 117 deletions

View File

@ -0,0 +1,47 @@
[gd_scene load_steps=12 format=3 uid="uid://bj2318o3y68x2"]
[ext_resource type="Script" uid="uid://ds6jy3s0hhmwt" path="res://_game/DemoScript.gd" id="1_2tycc"]
[ext_resource type="PackedScene" uid="uid://cvqehvdjpoar4" path="res://_player/player_controller.tscn" id="2_gslp7"]
[ext_resource type="PackedScene" uid="uid://gwhff4qaouxy" path="res://_player/Avatar.tscn" id="3_6jw57"]
[ext_resource type="PackedScene" uid="uid://bt55vmoc83l6g" path="res://_game/scenes/l_1_s_1.tscn" id="4_6jw57"]
[ext_resource type="PackedScene" uid="uid://c6and5mqr3wv1" path="res://_game/scenes/l_1_s_2.tscn" id="5_2t6pm"]
[ext_resource type="PackedScene" uid="uid://0sivr6aig7gm" path="res://_game/scenes/l_1_s_3.tscn" id="6_xkd7q"]
[ext_resource type="Script" uid="uid://5e157vdk6175" path="res://addons/reedscene/scene/ReedScene.gd" id="6_xotud"]
[ext_resource type="Script" uid="uid://bh066o84byplh" path="res://addons/reedscene/scene/ReedSceneID.gd" id="7_2tycc"]
[ext_resource type="Script" uid="uid://dn0ksjoswquf5" path="res://addons/reedscene/scene/SceneManager.gd" id="8_3ihdv"]
[ext_resource type="Script" uid="uid://dsgl7lbyjsiif" path="res://addons/reedscene/act/ActManager.gd" id="9_hc6q0"]
[ext_resource type="Script" uid="uid://pxjf5vst08eo" path="res://addons/reedscene/prop/PropManager.gd" id="10_mwuv1"]
[node name="Game" type="Node2D"]
script = ExtResource("1_2tycc")
[node name="PlayerController" parent="." node_paths=PackedStringArray("auto_controlled_avatar") instance=ExtResource("2_gslp7")]
auto_controlled_avatar = NodePath("../Avatar")
[node name="Avatar" parent="." instance=ExtResource("3_6jw57")]
position = Vector2(283, 253)
collision_mask = 4
[node name="l1_s1" parent="." instance=ExtResource("4_6jw57")]
[node name="l1_s2" parent="." instance=ExtResource("5_2t6pm")]
debug_log = true
[node name="l1_s3" parent="." instance=ExtResource("6_xkd7q")]
debug_log = true
[node name="ReedScene" type="Node2D" parent="."]
script = ExtResource("6_xotud")
metadata/_custom_type_script = "uid://5e157vdk6175"
[node name="[Invalid!]" type="Node" parent="ReedScene"]
script = ExtResource("7_2tycc")
[node name="SceneManager" type="Node" parent="ReedScene"]
script = ExtResource("8_3ihdv")
[node name="ActManager" type="Node" parent="ReedScene"]
script = ExtResource("9_hc6q0")
[node name="Props" type="Node2D" parent="ReedScene"]
script = ExtResource("10_mwuv1")

View File

@ -222,7 +222,7 @@ script = ExtResource("9_648qh")
state_id = 1
effects = Array[ExtResource("12_fyfyw")]([SubResource("Resource_1vufk")])
[node name="l1_s1_tile" parent="." instance=ExtResource("10_25twt")]
[node name="l1_s1_tile" parent="." groups=["GRAPABLE"] instance=ExtResource("10_25twt")]
tile_map_data = PackedByteArray("AAAAAAQAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAsAAAAAAAAAAAAAAAwAAAAAAAAAAAAAABQAAAAAAAAAAAAAABUAAAAAAAAAAAAAABYAAAAAAAAAAAABAAQAAAAAAAAAAAABAAUAAAAAAAAAAAABAAYAAAAAAAAAAAABAAcAAAAAAAAAAAABAAgAAAAAAAAAAAABAAkAAAAAAAAAAAABAAoAAAAAAAAAAAABAAsAAAAAAAAAAAABAAwAAAAAAAAAAAABABQAAAAAAAAAAAABABUAAAAAAAAAAAABABYAAAAAAAAAAAACABQAAAAAAAAAAAACABUAAAAAAAAAAAACABYAAAAAAAAAAAADAAAAAAAAAAAAAAADAAEAAAAAAAAAAAADAAIAAAAAAAAAAAADABQAAAAAAAAAAAADABUAAAAAAAAAAAADABYAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAEAAAAAAAAAAAAEAAIAAAAAA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AAAiAAAAAAAAAAAAAAAiAAEAAAAAAAAAAAAiAAIAAAAAAAAAAAAjAAAAAAAAAAAAAAAjAAEAAAAAAAAAAAAjAAIAAAAAAAAAAAAkAAAAAAAAAAAAAAAkAAEAAAAAAAAAAAAkAAIAAAAAAAAAAAAlAAAAAAAAAAAAAAAlAAEAAAAAAAAAAAAlAAIAAAAAAAAAAAAmAAAAAAAAAAAAAAAmAAEAAAAAAAAAAAAmAAIAAAAAAAAAAAAnAAAAAAAAAAAAAAAnAAEAAAAAAAAAAAAnAAIAAAAAAAAAAAAoAAAAAAAAAAAAAAAoAAEAAAAAAAAAAAAoAAIAAAAAAAAAAAApAAAAAAAAAAAAAAApAAEAAAAAAAAAAAApAAIAAAAAAAAAAAAoAAMAAAAAAAAAAAAoAAQAAAAAAAAAAAAoAAUAAAAAAAAAAAAoAAYAAAAAAAAAAAAoAAcAAAAAAAAAAAAoAAgAAAAAAAAAAAAoAAkAAAAAAAAAAAAoAAoAAAAAAAAAAAAoAAsAAAAAAAAAAAAoAAwAAAAAAAAAAAApAAMAAAAAAAAAAAApAAQAAAAAAAAAAAApAAUAAAAAAAAAAAApAAYAAAAAAAAAAAApAAcAAAAAAAAAAAApAAgAAAAAAAAAAAApAAkAAAAAAAAAAAApAAoAAAAAAAAAAAApAAsAAAAAAAAAAAApAAwAAAAAAAAAAAA=")
[node name="Coin" parent="." instance=ExtResource("11_1t0dx")]

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=40 format=3 uid="uid://gwhff4qaouxy"]
[gd_scene load_steps=41 format=3 uid="uid://gwhff4qaouxy"]
[ext_resource type="Script" uid="uid://dq1g1qp66chwy" path="res://_player/avatar.gd" id="1_rkqpu"]
[ext_resource type="Script" uid="uid://isu8onknb75o" path="res://_player/states/character_state_machine.gd" id="1_wvs5h"]
@ -36,6 +36,9 @@
[ext_resource type="Script" uid="uid://bhexx6mj1xv3q" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd" id="32_u7cua"]
[ext_resource type="Script" uid="uid://bueehfgv5vnc0" path="res://_player/extra/camera_priority_locker.gd" id="34_1a1t3"]
[sub_resource type="CircleShape2D" id="CircleShape2D_1a1t3"]
radius = 3.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qnulu"]
size = Vector2(9, 23)
@ -52,9 +55,20 @@ size = Vector2(10, 25)
[node name="Avatar" type="CharacterBody2D" groups=["PLAYER"]]
collision_layer = 2
collision_mask = 0
floor_snap_length = 4.0
platform_wall_layers = 4
script = ExtResource("1_rkqpu")
[node name="GroundCompanion" type="Area2D" parent="."]
unique_name_in_owner = true
position = Vector2(0, 11)
collision_layer = 0
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="GroundCompanion"]
shape = SubResource("CircleShape2D_1a1t3")
debug_color = Color(0, 0.6363917, 0.4093975, 0.41960785)
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_qnulu")
@ -146,17 +160,17 @@ dash_speed = 400.0
end_dash_speed = 190.0
climb_hop_velocity_x = 180.0
climb_hop_velocity_y = 334.0
jump_force = 290.0
jump_hold_maxium_time = 0.135
jump_force = 296.0
jump_hold_maxium_time = 0.125
jump_horizontal_Boost = 265.0
light_gravity_threshold = 120.0
light_gravity_threshold = 135.0
light_gravity_mult = 0.6
wall_jump_base_force_x = 260.0
wall_jump_base_force_y = 220.0
fall_maxium_speed = 430.0
air_control_mult = 0.85
run_accel = 2100.0
run_reduce = 420.0
run_accel = 1100.0
run_reduce = 2400.0
move_speed_max = 192.0
[node name="WallDetector" parent="LocomotionComponent" instance=ExtResource("20_air0b")]
@ -165,15 +179,11 @@ unique_name_in_owner = true
[node name="MidRayCast2D" parent="LocomotionComponent/WallDetector" index="1"]
position = Vector2(0, 3)
[node name="SpawnHookComponet" type="Node" parent="." node_paths=PackedStringArray("binded_hook_ray_cast_2d")]
[node name="SpawnHookComponet" type="Node" parent="."]
script = ExtResource("21_p14kj")
binded_hook_ray_cast_2d = NodePath("HookCheckRayer")
binded_hook_move_input_property_name = &"m_input_intent_direction"
metadata/_custom_type_script = "uid://bkkkyugppu7sl"
[node name="HookCheckRayer" type="RayCast2D" parent="SpawnHookComponet"]
collision_mask = 4
[node name="ReedSFXMananger" type="Node" parent="."]
script = ExtResource("24_x5g5e")
bindings = Array[ExtResource("25_rjd7i")]([ExtResource("26_256x0")])
@ -207,14 +217,6 @@ debug_color = Color(0.95815283, 0, 0.5313341, 0.41960785)
[node name="RemotePositionSetting" type="Node2D" parent="."]
[node name="Remotor[HookCheckRayer]" type="RemoteTransform2D" parent="RemotePositionSetting"]
remote_path = NodePath("../../SpawnHookComponet/HookCheckRayer")
update_rotation = false
update_scale = false
script = ExtResource("28_mxt3b")
observed_remote_path = NodePath("../../SpawnHookComponet/HookCheckRayer")
metadata/_custom_type_script = "uid://bijoqygv6tncj"
[node name="Remotor[WallDetector]" type="RemoteTransform2D" parent="RemotePositionSetting"]
remote_path = NodePath("../../LocomotionComponent/WallDetector")
update_rotation = false

View File

@ -7,6 +7,8 @@ class_name Player extends CharacterBody2D
@onready var spawn_hook_comp: SpawnHookComponet = $SpawnHookComponet
@onready var foot_pos_marker: Marker2D = %FootPosMarker
@onready var ground_companion: Area2D = %GroundCompanion
enum Direction{LEFT,RIGHT}
var direction: Direction = Direction.RIGHT: set = _player_direction_changed
@ -49,6 +51,7 @@ func _draw() -> void:
draw_string(ThemeDB.fallback_font,Vector2.ZERO,str(get_wall_normal()))
func _process(delta: float) -> void:
print(self.is_on_floor())
queue_redraw()
@ -58,6 +61,10 @@ func set_move_input(dir: Vector2) -> void:
func get_move_input() -> Vector2:
return m_input_intent_direction
## 更宽泛的floor检测
func get_is_on_floor() -> bool:
return self.is_on_floor() or ground_companion.has_overlapping_areas() or ground_companion.has_overlapping_bodies()
#func _physics_process(delta: float) -> void:
#
###用於更新輸入的朝向

View File

@ -54,8 +54,8 @@ func _unhandled_input(event: InputEvent) -> void:
elif event.is_action_released(&"jump"):
_controlled_avatar.release_jump()
if event.is_action_pressed(&"dash"):
_controlled_avatar.press_dash()
#if event.is_action_pressed(&"dash"):
#_controlled_avatar.press_dash()
if event.is_action_pressed(&"climb"):
_controlled_avatar.press_climb()

View File

@ -24,6 +24,8 @@ func _setup() -> void:
self.add_event_handler(&"trigger_jump",_handler_trigger_jump)
func _enter() -> void:
## 进入时只要want to jump == true则会触发跳跃而不是fall
var want_to_jump = blackboard.get_var(&"want_to_jump",false)
initial_state = root.fall_state
@ -36,8 +38,9 @@ func _enter() -> void:
func _update(delta: float) -> void:
if auto_jump_timer > 0:
auto_jump_timer -= delta
print("允许自动跳")
if agent.is_on_floor() && agent.velocity.y >= 0:
if agent.get_is_on_floor() && agent.velocity.y >= 0:
#自动跳
if auto_jump_timer > 0:
auto_jump_timer = 0

View File

@ -44,6 +44,7 @@ func _init_trans() -> void:
self.add_transition(ANYSTATE,grap_hook_state,&"want_to_grap_hook",_has_move_input)
self.add_transition(grap_hook_state,airbone_state,&"exit_on_ground")
self.add_transition(grap_hook_state,ground_state,&"exit_on_air")
self.add_transition(grap_hook_state,airbone_state,&"hook_to_jump")
func _update(delta: float) -> void:

View File

@ -2,13 +2,35 @@ extends LimboHSM
@onready var root: Normal = %Normal
@export var jump_grace_time: float = .13
var _jump_grace_timer: float
func _setup() -> void:
self.add_transition(root.hook_shooting_state,root.grapping_state,root.hook_shooting_state.EVENT_FINISHED)
self.add_transition(
root.hook_shooting_state,
root.grapping_state,
root.hook_shooting_state.EVENT_FINISHED,
_can_enter_grapping_state
)
self.add_event_handler(&"trigger_jump",_handle_trigger_jump)
func _enter() -> void:
_jump_grace_timer = 0
get_root().blackboard.set_var(&"is_hooking",true) ##BB里锁住Dash状态
func _update(delta: float) -> void:
if _jump_grace_timer > 0:
_jump_grace_timer -= delta
func _exit() -> void:
get_root().blackboard.set_var(&"is_hooking",false) ##BB里锁住Dash状态
agent.locomotion_comp.enable_movement()
func _handle_trigger_jump() -> bool:
_jump_grace_timer = jump_grace_time
return false
func _can_enter_grapping_state() -> bool:
return agent.spawn_hook_comp.has_hook_anchor()

View File

@ -1,24 +1,34 @@
extends LimboState
@onready var root: Normal = %Normal
@export_category("Hook Pull Release")
@export var release_distance: float = 12.0
@export var release_dot_threshold: float = 0.0
@export var min_pull_time: float = 0.08
@export var min_pull_timer: float = 0.08
var _pull_time := 0.0
var _pull_timer := 0.0
var _anchor
func _setup() -> void:
self.add_event_handler(&"trigger_jump",_handle_trigger_jump)
func _enter() -> void:
_pull_time = 0.0
if root.grap_hook_state._jump_grace_timer > 0:
_hook_to_jump()
_pull_timer = 0.0
_anchor = agent.spawn_hook_comp.get_current_hook_anchor()
if _anchor and is_instance_valid(_anchor):
agent.locomotion_comp._custom_move_to(_anchor)
func _update(delta: float) -> void:
_pull_time += delta
_pull_timer += delta
if _pull_time < min_pull_time:
if _pull_timer < min_pull_timer:
return
if not _anchor or not is_instance_valid(_anchor):
@ -45,6 +55,16 @@ func _update(delta: float) -> void:
func _exit() -> void:
agent.locomotion_comp.stop_custom_move(false)
_anchor = null
agent.spawn_hook_comp.release_cached_hook()
func _handle_trigger_jump() -> bool:
_hook_to_jump()
return false
func _hook_to_jump() -> void:
get_root().blackboard.set_var(&"want_to_jump",true)
self.dispatch(&"hook_to_jump")
func _force_release() -> void:
agent.locomotion_comp.stop_custom_move(false)

View File

@ -19,7 +19,7 @@ func _update(delta: float) -> void:
dispatch(self.EVENT_FINISHED)
func _handler_trigger_jump() -> bool:
self.blackboard.set_var(&"want_to_jump",true)
get_root().blackboard.set_var(&"want_to_jump",true)
self.dispatch(self.EVENT_FINISHED)
return true

View File

@ -24,16 +24,25 @@ func _exit() -> void:
func _handle_hook_input_completed() -> bool:
agent.spawn_hook_comp.suspend_hook_stretching(false)
##如果鈎爪沒有找到任何錨點,則直接退出
if not agent.spawn_hook_comp.has_hook_anchor():
_exit_with_no_anchor()
return true
func _handle_hook_stretching_end(reach_end: bool,Anchor:Node2D) -> void:
##如果鈎爪沒有找到任何錨點,則直接退出
if not Anchor:
if agent.is_on_floor():
self.dispatch(&"exit_on_ground")
else:
self.dispatch(&"exit_on_air")
return
if not agent.spawn_hook_comp.has_hook_anchor():
_exit_with_no_anchor()
self.dispatch(self.EVENT_FINISHED)
func _exit_with_no_anchor() -> void:
if agent.is_on_floor():
self.dispatch(&"exit_on_ground")
else:
self.dispatch(&"exit_on_air")
agent.spawn_hook_comp.release_cached_hook()
return

View File

@ -6,7 +6,7 @@
[sub_resource type="RectangleShape2D" id="RectangleShape2D_g1m3x"]
size = Vector2(20, 128)
[node name="Door" type="AnimatableBody2D"]
[node name="Door" type="AnimatableBody2D" groups=["GRAPABLE"]]
collision_layer = 4
collision_mask = 0
script = ExtResource("1_gt1uq")

View File

@ -1,7 +1,5 @@
class_name SpawnHookComponet extends ComponentBase
##SpawnHookComponent必须绑定一个相关的RayCast2D用来控制射线想要检测的位置。
@export var binded_hook_ray_cast_2d : RayCast2D
##可以通過在這裏添加一個ComponentOwner默認的字段名來讀取輸入方向默認是為空的。
@export var binded_hook_move_input_property_name: StringName
@ -26,7 +24,8 @@ func spawn_grap_hook_inst(dir: Vector2) -> Hook:
return _current_grap_hook_inst
func release_cached_hook() -> void:
_current_grap_hook_inst.release_hook()
if _current_grap_hook_inst:
_current_grap_hook_inst.release_hook()
##尝试关闭hook的延长
func suspend_hook_stretching(force_suspend: bool = false) -> bool:
@ -41,6 +40,10 @@ func _on_hook_stretching_end(reach_limit,anchor:Node2D) -> void:
func get_current_hook_anchor() -> Node2D:
return _current_grap_hook_inst._anchor
##是否存在anchor
func has_hook_anchor() -> bool:
return _current_grap_hook_inst and _current_grap_hook_inst._anchor
##初始化組件
func _init_component() -> void:
pass

View File

@ -39,8 +39,12 @@ var _is_wall_jumping: bool = false
func jump() -> bool:
if _is_jumping : return false
##如果是同方向的,则
if sign(characterbody.velocity.x) * sign(_movement_input) > 0:
#给与一个跳跃的补正速度
characterbody.velocity.x = _movement_input * jump_horizontal_Boost # 跳跃的水平补正速度
characterbody.velocity.x += _movement_input * jump_horizontal_Boost * .7
else:
characterbody.velocity.x = _movement_input * jump_horizontal_Boost # 跳跃的水平补正速度
_jump_timer = jump_hold_maxium_time
_is_jumping = true

View File

@ -105,12 +105,12 @@ func _update_gravity(delta: float) -> void:
func _update_movement(delta : float) -> void:
var input_dir = sign(_movement_input) as float
var current_dir = characterbody.velocity.normalized().x as float
var current_dir = sign(characterbody.velocity.x) as float
var accel: float
if abs(characterbody.velocity.x) > move_speed_max and input_dir * current_dir > 0:
accel = run_reduce
if abs(characterbody.velocity.x) > move_speed_max and input_dir * current_dir <= 0 and input_dir != 0:
accel = run_reduce #如果移动方向和当前的速度方向不同向且不是起步那么apply 减速的加速度。
else:
accel = run_accel
accel = run_accel #其他case都是加速的加速度
#如果检测到当前速度和加速度方向不同则发送移动方向更改event
if current_dir * input_dir < 0 and not _in_pivoting:

View File

@ -39,7 +39,7 @@ layout_mode = 2
[node name="DropArea" type="PanelContainer" parent="MarginContainer/HBC_Main/VBoxContainer/HBC_Drop"]
unique_name_in_owner = true
custom_minimum_size = Vector2(30, 30)
custom_minimum_size = Vector2(18, 18)
layout_mode = 2
mouse_filter = 1
script = ExtResource("2_stte8")
@ -48,8 +48,8 @@ script = ExtResource("2_stte8")
layout_mode = 2
mouse_filter = 2
texture = ExtResource("2_lwr2w")
expand_mode = 1
stretch_mode = 5
expand_mode = 2
stretch_mode = 4
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBC_Main/VBoxContainer/HBC_Drop"]
layout_mode = 2

View File

@ -14,8 +14,8 @@ const COLOR_CHECKED: Color = Color.GREEN
## 設置Locker的時候自更新一次State
var vaild: bool = false:
set(value):
_set_state(3)
vaild = value
_set_state(0)
var _icon: TextureRect
var _state := 0 # 0 idle, 1 can, 2 cannot

View File

@ -30,8 +30,12 @@ const COLOR_CHECKED_1: Color = Color.GREEN
const COLOR_CHECKED_2: Color = Color.YELLOW
const COLOR_CHECKED_3: Color = Color.ORANGE_RED
signal prop_info_cached(info: Dictionary,slot:StateDrapSlot)
signal prop_info_released(id:int, slot:StateDrapSlot)
func _ready() -> void:
_btn_init()
_reset_to_default()
_reset_cb_use_trans()
@ -48,34 +52,32 @@ func _set_state(new_state: int) -> void:
match _state:
0: ## 初始狀態,什麽都沒有
pass
_reset_to_default()
1: ## vaild 狀態,可以插入了
pass
drop_area.vaild = true
_update_context()
prop_info_cached.emit(_cached_info,self)
func _btn_init() -> void:
clear_button.pressed.connect(_on_clear_pressed)
func _on_clear_pressed() -> void:
_clear_cached_act()
_set_state(0)
func init(index: int) -> void:
self.index.text = str(index)
func _on_node_path_dropped(path: NodePath) -> void:
## 如果已經可以插入但是重新被插入了一個State先clear再插入。
if get_ready_to_insert():
_clear_cached_act()
if _state == 1:
_set_state(0)
var state := StateResolveUtils.get_state_node_from_path(path)
if state == null:
_clear_cached_act()
_reset_to_default()
return
var info := StateResolveUtils.resolve_state_display_info(state)
if info == null:
_clear_cached_act()
_reset_to_default()
return
@ -90,9 +92,7 @@ func _on_node_path_dropped(path: NodePath) -> void:
_cached_prop_id = int(info.prop_id)
_update_context(info)
drop_area.vaild = true
_set_state(1)
func _on_drap_area_state_change(state:int) -> void:
pass
@ -117,11 +117,13 @@ func _resolve_state_from_path(path: NodePath) -> ReedPropState:
## 重置回默认
func _reset_to_default() ->void:
_clear_cached_act()
state_label.text = NORMAL_STATE_LABLE
state_label.modulate = COLOR_IDLE
context.text = NORMAL_CONTEXT
context.modulate = COLOR_IDLE
drop_area.vaild = false
## 初始化use trans 的 check box
@ -146,12 +148,14 @@ func _build_cached_act(state: ReedPropState, info: Dictionary) -> void:
## 清空Cached Act
func _clear_cached_act() -> void:
##如果清除前存在CahcedInfo就释放信号
if _cached_info.has("prop_id"):
var id = _cached_info.prop_id
prop_info_released.emit(id, self)
_cached_single_act = null
_cached_prop_id = -1
_cached_info = {}
drop_area.vaild = false
_update_context()
## 设置文本
func _update_context(info:Dictionary = {}) ->void:
@ -159,6 +163,7 @@ func _update_context(info:Dictionary = {}) ->void:
## TODO:这里后续应该有一个报错的Message
if info == {} :
if _cached_info == {}:
_reset_to_default()
return
else:
info = _cached_info

View File

@ -19,6 +19,8 @@ const DEFAULT_CONTEXT: Dictionary = {
var _inited: bool = false
var _max_length: int = -1
var _cached_prop_id: Array[int]
## 默认的Slot
const SLOT: PackedScene = preload("res://addons/reedscene/act/StateDrapSlot.tscn")
@ -67,12 +69,23 @@ func _add_slot() -> void:
return
var slot := SLOT.instantiate()
slot.prop_info_cached.connect(_on_slot_prop_cached)
vbc_spawn_slot_root.add_child(slot)
slot.owner = get_tree().edited_scene_root # 编辑器可保存
slot.init(vbc_spawn_slot_root.get_children().size())
_update_b_remove_state()
func _on_slot_prop_cached(info:Dictionary,slot:StateDrapSlot) -> void:
if not info.has("prop_id"):
return
var id : int = info.prop_id
if _cached_prop_id.has(id):
slot._set_state(0)
else:
_cached_prop_id.append(id)
## 移除一個Slot最少不能為0
func _remove_slot() -> void:
var count := vbc_spawn_slot_root.get_child_count()

View File

@ -51,9 +51,9 @@ static func get_state_node_from_path(path: NodePath) -> ReedPropState:
static func resolve_state_display_info(state: ReedPropState) -> Dictionary:
var result := {
"prop_name": "",
"prop_id": "",
"prop_id": -1,
"state_name": "",
"state_id": ""
"state_id": -1
}
if state == null:

View File

@ -99,44 +99,6 @@ func _init_states() -> void:
push_error("[PropComponent:%s] State init failed: %s"
% [prop_id, s.name])
## ==============================
## Act Sync Entry
## ==============================
#func sync_to_state(state_id: int, act_id: int, instant := false) -> bool:
#var ctx := {
#"reason": "ACT_SYNC",
#"act_id": act_id,
#"instant": instant
#}
#return change_state(state_id, false ,ctx)
## ==============================
## Editor Tool
## ==============================
#func _editor_ensure_states_root() -> void:
#var states := get_node_or_null(STATES_ROOT_NAME)
#if states != null:
#return
#
## 创建 StateManager 而不是普通 Node
#states = ReedPropStateManager.new()
#states.name = STATES_ROOT_NAME
#add_child(states)
#
## 让其成为 Scene 的一部分(非常重要)
#states.owner = get_tree().edited_scene_root
#
## 自动添加一个默认 State
#var default_state := ReedPropState.new()
#default_state.name = "Default"
#states.add_child(default_state)
#default_state.owner = get_tree().edited_scene_root
#
#if debug_log:
#print("[PropComponent] Created States(StateManager) + Default State")
## 引擎層預知一個工具節點給予到State及其子節點。
func _editor_ensure_states_root() -> void:
var states := get_node_or_null(STATES_ROOT_NAME)

View File

@ -40,13 +40,15 @@ func _exit_tree() -> void:
## 注冊Inspector
func _register_inspectors() -> void:
#TODO: 临时禁用Act的Inspector后续如果有需求再迭代。
# Inspector 1ActManager
var act_inspector := preload(
ACT_INSPECTOR_SCENE_PATH
).new()
add_inspector_plugin(act_inspector)
inspector_plugins.append(act_inspector)
#var act_inspector := preload(
#ACT_INSPECTOR_SCENE_PATH
#).new()
#
#add_inspector_plugin(act_inspector)
#inspector_plugins.append(act_inspector)
# Inspector 2ReedSceneID
var scene_id_inspector := preload(

View File

@ -70,11 +70,6 @@ jump={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":74,"key_label":0,"unicode":106,"location":0,"echo":false,"script":null)
]
}
dash={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":75,"key_label":0,"unicode":107,"location":0,"echo":false,"script":null)
]
}
climb={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
@ -86,7 +81,7 @@ move={
}
grap_hook={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"location":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":75,"key_label":0,"unicode":107,"location":0,"echo":false,"script":null)
]
}