|
|
|
|
@tool
|
|
|
|
|
extends Node3D
|
|
|
|
|
|
|
|
|
|
func get_resource_name(resource:Resource) -> String:
|
|
|
|
|
return resource.resource_path.get_file().trim_suffix('.tres') #todo 性能
|
|
|
|
|
|
|
|
|
|
func snap_vector3(value:Vector3) -> Vector3:
|
|
|
|
|
return Vector3(snap_float(value.x),snap_float(value.y),snap_float(value.z))
|
|
|
|
|
|
|
|
|
|
func snap_float(value:float) -> float:
|
|
|
|
|
return floor(value/Setting.pixel_size) * Setting.pixel_size
|
|
|
|
|
|
|
|
|
|
func vector_reduce(vector:Vector2,reduce:float) -> Vector2:
|
|
|
|
|
var len = vector.length()
|
|
|
|
|
if len == 0:
|
|
|
|
|
return vector
|
|
|
|
|
var new_len = max(len - reduce,0)
|
|
|
|
|
var scale_rate = new_len / len
|
|
|
|
|
return vector * scale_rate
|
|
|
|
|
|
|
|
|
|
func refresh_animation_lib():
|
|
|
|
|
var animation_library_path = "res://resource/skill_animation_library/animation_library.tres"
|
|
|
|
|
var animation_library = load(animation_library_path)
|
|
|
|
|
|
|
|
|
|
var dir_path = "res://resource/skill_animation"
|
|
|
|
|
var dir = DirAccess.open(dir_path)
|
|
|
|
|
for file in dir.get_files():
|
|
|
|
|
var path = dir_path + "/" + file
|
|
|
|
|
var res = load(path)
|
|
|
|
|
if res is Animation:
|
|
|
|
|
var animation = res as Animation
|
|
|
|
|
var animation_name = Util.get_resource_name(animation)
|
|
|
|
|
print(animation_name)
|
|
|
|
|
animation_library.add_animation(animation_name,animation)
|
|
|
|
|
animation_library.animation_added.emit(animation_name)
|
|
|
|
|
|
|
|
|
|
ResourceSaver.save(animation_library,animation_library_path)
|
|
|
|
|
|
|
|
|
|
func refresh_mesh_library(path_list:Array):
|
|
|
|
|
var default_shape_full = [load("res://resource/mesh_library/default_shape_full.tres") as Shape3D]
|
|
|
|
|
var default_shape_half = [load("res://resource/mesh_library/default_shape_half.tres") as Shape3D]
|
|
|
|
|
var mesh_library = load("res://resource/mesh_library/mesh_library.tres") as MeshLibrary
|
|
|
|
|
for file_name_full in path_list:
|
|
|
|
|
var mesh_name = file_name_full.get_file().split('-')[0].trim_suffix('.vox')
|
|
|
|
|
print(mesh_name)
|
|
|
|
|
var mesh = load(file_name_full) as Mesh
|
|
|
|
|
var mesh_id = mesh_library.find_item_by_name(mesh_name)
|
|
|
|
|
if mesh_id == -1:
|
|
|
|
|
mesh_id = mesh_library.get_last_unused_item_id()
|
|
|
|
|
mesh_library.create_item(mesh_id)
|
|
|
|
|
mesh_library.set_item_name(mesh_id,mesh_name)
|
|
|
|
|
mesh_library.set_item_mesh(mesh_id,mesh)
|
|
|
|
|
if mesh_name.begins_with("f_"):
|
|
|
|
|
mesh_library.set_item_shapes(mesh_id,default_shape_full)
|
|
|
|
|
elif mesh_name.begins_with("h_"):
|
|
|
|
|
mesh_library.set_item_shapes(mesh_id,default_shape_half)
|
|
|
|
|
elif mesh_name.begins_with("s_"):
|
|
|
|
|
var new_shape = [mesh.create_convex_shape()]
|
|
|
|
|
mesh_library.set_item_shapes(mesh_id,new_shape)
|
|
|
|
|
var ids = mesh_library.get_item_list()
|
|
|
|
|
var meshes = []
|
|
|
|
|
for id in ids:
|
|
|
|
|
meshes.append(mesh_library.get_item_mesh(id))
|
|
|
|
|
var previews = EditorInterface.make_mesh_previews(meshes, 64)
|
|
|
|
|
for i in range(len(ids)):
|
|
|
|
|
mesh_library.set_item_preview(ids[i],previews[i])
|
|
|
|
|
ResourceSaver.save(mesh_library)
|
|
|
|
|
|
|
|
|
|
func get_all_player_skill():
|
|
|
|
|
var ret = []
|
|
|
|
|
var dir_path = "res://config/player_skill"
|
|
|
|
|
var dir = DirAccess.open(dir_path)
|
|
|
|
|
for file in dir.get_files():
|
|
|
|
|
var path = dir_path + "/" + file
|
|
|
|
|
var res = load(path)
|
|
|
|
|
if res is PlayerSkillCfg:
|
|
|
|
|
ret.append(res)
|
|
|
|
|
return ret
|