extend PCK support
This commit is contained in:
@@ -18,28 +18,32 @@ var mouse_mov : Vector3
|
||||
var sway_lerp = 5
|
||||
|
||||
func _ready():
|
||||
var config = load_data() as ConfigFile
|
||||
Init_Config(config)
|
||||
get_tree().get_current_scene().ready.connect(init)
|
||||
|
||||
func init():
|
||||
var config = Runtimeloader.loadConfig(CONFIG_PATH) as ConfigFile
|
||||
if(config == null):
|
||||
return
|
||||
|
||||
Init_Config(config)
|
||||
weapons[current_weapon].init()
|
||||
raycast.target_position.z = -weapons[current_weapon].RAY_LEN
|
||||
|
||||
func load_data():
|
||||
var path = Runtimeloader.PATH
|
||||
|
||||
var config = ConfigFile.new()
|
||||
var err = config.load(path + CONFIG_PATH)
|
||||
|
||||
if err != OK:
|
||||
printerr("FAILED LOADING WEAPONS DATA @ ",path + CONFIG_PATH)
|
||||
|
||||
return config
|
||||
|
||||
func Init_Config(config):
|
||||
for weapon in config.get_sections():
|
||||
var root = Weapon.new()
|
||||
root.name = weapon
|
||||
var weapon_model = Runtimeloader.load_gltf(config.get_value(weapon, "MODEL"), root) as Node3D
|
||||
|
||||
var model_path = config.get_value(weapon, "MODEL") as String
|
||||
var weapon_model
|
||||
if(model_path.ends_with(".glb") or model_path.ends_with(".gltf")):
|
||||
weapon_model = Runtimeloader.load_gltf(model_path, root) as Node3D
|
||||
elif(model_path.ends_with(".tscn") or model_path.ends_with(".scn")):
|
||||
weapon_model = Runtimeloader.loadScene(model_path, root)
|
||||
else:
|
||||
printerr("Invalid file extension for "+ model_path)
|
||||
continue
|
||||
|
||||
|
||||
root.position = config.get_value(weapon, "HAND_POS")
|
||||
root.rotation = config.get_value(weapon, "HAND_ROT")
|
||||
|
||||
Reference in New Issue
Block a user