extends Node3D class_name Core @onready var character: Character = (get_owner() as Character) @onready var status: Status = (%Status as Status) @onready var skill: Skill = (%Skill as Skill) @onready var move: Move = (%Move as Move) var active_core_action_list: Array[String] = ["free_attack_heavy", "free_attack_light", "free_jump", "free_interact", "lock_attack_heavy", "lock_attack_light", "lock_jump", "lock_interact"] func _ready(): for i in range(8): status.core_active_list.append(null) func _process(delta): pass func get_action_index(action: String) -> int: return active_core_action_list.find(action) func cast_skill_sub(index: int, cast_dir: Vector2, target: int) -> void: var core: CoreCfg = status.core_active_list[index] if not core: return #施放技能扣除mp var skill_cfg: SkillCfg = core.get_skill_cfg(0) #todo if not skill.cast_skill_mp_cost(skill_cfg): return var sub_character: Character = Global.character_mgr.get_character(status.sub_character_id) if not sub_character: return var skill_order = Status.SkillOrder.new() skill_order.skill_cfg = skill_cfg skill_order.cast_dir = cast_dir skill_order.target = target sub_character.add_ai_skill_order(skill_order) func cast_skill_by_action(action: String, cast_dir: Vector2) -> bool: var index: int = active_core_action_list.find(action) if index < 0: return false return cast_skill(index, cast_dir) func cast_skill(index: int, cast_dir: Vector2) -> bool: var core: CoreCfg = status.core_active_list[index] if not core: return false match core.type: Enum.ECoreType.Passive: return false _: pass var skill_cfg: SkillCfg = core.get_skill_cfg(0) #todo #施放技能条件检查 if not skill.cast_skill_check(skill_cfg, status.break_level): return false #施放技能扣除mp if not skill.cast_skill_mp_cost(skill_cfg): return false skill.cast_skill(skill_cfg, cast_dir) return true func set_active_core(index: int, core: CoreCfg) -> void: match core.type: Enum.ECoreType.Passive: return _: pass if (index < 0) or (index >= 8): return status.core_active_list[index] = core status.emit_status("core_active_list") return func add_passive_core(core: CoreCfg) -> void: match core.type: Enum.ECoreType.Active: return _: pass status.core_passive_list.append(core) status.emit_status("core_passive_list") return func remove_passive_core(core: CoreCfg) -> void: match core.type: Enum.ECoreType.Active: return _: pass status.core_passive_list.filter(func(c): return c!=core) status.emit_status("core_passive_list") return