|  |  |  | 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) | 
					
						
							|  |  |  | @onready var combo: Combo = (%Combo as Combo) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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(): | 
					
						
							|  |  |  |     # test | 
					
						
							|  |  |  |     for i in range(8): | 
					
						
							|  |  |  |         status.core_active_list.append(null) | 
					
						
							|  |  |  |     set_active_core(0, load("res://config/core/free01.tres") as CoreCfg) | 
					
						
							|  |  |  |     set_active_core(1, load("res://config/core/free02.tres") as CoreCfg) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _process(delta): | 
					
						
							|  |  |  |     pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func set_active_core(index: int, core: CoreCfg) -> void: | 
					
						
							|  |  |  |     match core.type: | 
					
						
							|  |  |  |         Enum.ECoreType.Free: pass | 
					
						
							|  |  |  |         Enum.ECoreType.Lock: index+=4 | 
					
						
							|  |  |  |         Enum.ECoreType.Passive: return | 
					
						
							|  |  |  |         _: pass | 
					
						
							|  |  |  |     if (index < 0) or (index >= 8): | 
					
						
							|  |  |  |         return | 
					
						
							|  |  |  |     var core_pre = status.core_active_list[index] | 
					
						
							|  |  |  |     if core_pre: | 
					
						
							|  |  |  |         on_remove_active_core(index, core_pre) | 
					
						
							|  |  |  |     status.core_active_list[index] = core | 
					
						
							|  |  |  |     on_add_active_core(index, core) | 
					
						
							|  |  |  |     status.emit_status("core_active_list") | 
					
						
							|  |  |  |     return | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func on_add_active_core(index: int, core: CoreCfg): | 
					
						
							|  |  |  |     for skill in core.skill_list: | 
					
						
							|  |  |  |         var action: String = active_core_action_list[index] | 
					
						
							|  |  |  |         combo.add_skill(action, skill) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func on_remove_active_core(index: int, core: CoreCfg): | 
					
						
							|  |  |  |     for skill in core.skill_list: | 
					
						
							|  |  |  |         var action: String = active_core_action_list[index] | 
					
						
							|  |  |  |         combo.remove_skill(action, skill) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func add_passive_core(core: CoreCfg) -> void: | 
					
						
							|  |  |  |     match core.type: | 
					
						
							|  |  |  |         Enum.ECoreType.Free: return | 
					
						
							|  |  |  |         Enum.ECoreType.Lock: 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.Free: return | 
					
						
							|  |  |  |         Enum.ECoreType.Lock: return | 
					
						
							|  |  |  |         _: pass | 
					
						
							|  |  |  |     status.core_passive_list.filter(func(c): return c!=core) | 
					
						
							|  |  |  |     status.emit_status("core_passive_list") | 
					
						
							|  |  |  |     return |