PCK File loader
This commit is contained in:
12
Game.gd
12
Game.gd
@@ -7,7 +7,17 @@ extends Node3D
|
|||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
Runtimeloader.load_gltf("maps/Map.glb", true, true)
|
#var packer = PCKPacker.new()
|
||||||
|
#packer.pck_start("test_map.pck")
|
||||||
|
#packer.add_file("res://test_map.scn", "res://scoom/maps/test_maps.scn")
|
||||||
|
#packer.flush(true)
|
||||||
|
|
||||||
|
Runtimeloader.loadPCK("maps/test_map.pck", self)
|
||||||
|
|
||||||
|
var res = load("res://test_maps.scn") as PackedScene
|
||||||
|
var node = res.instantiate()
|
||||||
|
add_child(node)
|
||||||
|
Runtimeloader.get_all_entities(node)
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
|
|||||||
1
godot.gdkey
Normal file
1
godot.gdkey
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3a339a5360498c573a53f3342f5bc7adb6d9678117be64de6d8cff4d2c754c91
|
||||||
59
scenes/GUI/Main Menu.tscn
Normal file
59
scenes/GUI/Main Menu.tscn
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dsnlwjofq6psf"]
|
||||||
|
|
||||||
|
[node name="Main Menu" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
metadata/_edit_use_anchors_ = true
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -198.0
|
||||||
|
offset_top = -104.0
|
||||||
|
offset_right = 199.0
|
||||||
|
offset_bottom = 64.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 2
|
||||||
|
|
||||||
|
[node name="Start" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Start Game"
|
||||||
|
|
||||||
|
[node name="ModsMenu" type="MenuButton" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Select Mod"
|
||||||
|
flat = false
|
||||||
|
item_count = 2
|
||||||
|
popup/item_0/text = "test1"
|
||||||
|
popup/item_0/id = 0
|
||||||
|
popup/item_1/text = "test2"
|
||||||
|
popup/item_1/id = 1
|
||||||
|
|
||||||
|
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 10
|
||||||
|
|
||||||
|
[node name="SettingsButton" type="Button" parent="VBoxContainer/VBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Game Settings"
|
||||||
|
icon_alignment = 1
|
||||||
|
|
||||||
|
[node name="ExitButton" type="Button" parent="VBoxContainer/VBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Exit"
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[entity_test]
|
[entity_test]
|
||||||
model="models/Chainsaw.glb"
|
model="models/Chainsaw.glb"
|
||||||
type="pickup"
|
type="pickup"
|
||||||
scale=1.5
|
scale=Vector3(1.5, 1.5, 1.5)
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -1,30 +0,0 @@
|
|||||||
[remap]
|
|
||||||
|
|
||||||
importer="scene"
|
|
||||||
importer_version=1
|
|
||||||
type="PackedScene"
|
|
||||||
uid="uid://dll7swpo3b8o3"
|
|
||||||
path="res://.godot/imported/Map.glb-2d6fdb0ff78945164666e9514502f2ad.scn"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://scoom/maps/Map.glb"
|
|
||||||
dest_files=["res://.godot/imported/Map.glb-2d6fdb0ff78945164666e9514502f2ad.scn"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
nodes/root_type="Node3D"
|
|
||||||
nodes/root_name="Scene Root"
|
|
||||||
nodes/apply_root_scale=true
|
|
||||||
nodes/root_scale=1.0
|
|
||||||
meshes/ensure_tangents=true
|
|
||||||
meshes/generate_lods=true
|
|
||||||
meshes/create_shadow_meshes=true
|
|
||||||
meshes/light_baking=1
|
|
||||||
meshes/lightmap_texel_size=0.2
|
|
||||||
skins/use_named_skins=true
|
|
||||||
animation/import=true
|
|
||||||
animation/fps=30
|
|
||||||
animation/trimming=false
|
|
||||||
import_script/path=""
|
|
||||||
_subresources={}
|
|
||||||
BIN
scoom/maps/test_map.pck
Normal file
BIN
scoom/maps/test_map.pck
Normal file
Binary file not shown.
@@ -90,7 +90,7 @@ func accelerate(delta : float, p_target_dir : Vector3, p_target_speed : float, p
|
|||||||
|
|
||||||
func apply_friction(delta : float):
|
func apply_friction(delta : float):
|
||||||
|
|
||||||
var vec : Vector3 = velocity
|
#var vec : Vector3 = velocity
|
||||||
var speed : float = velocity.length()
|
var speed : float = velocity.length()
|
||||||
if is_zero_approx(speed):
|
if is_zero_approx(speed):
|
||||||
velocity = Vector3.ZERO
|
velocity = Vector3.ZERO
|
||||||
|
|||||||
@@ -39,12 +39,8 @@ func Init_Config(config):
|
|||||||
for weapon in config.get_sections():
|
for weapon in config.get_sections():
|
||||||
var root = Weapon.new()
|
var root = Weapon.new()
|
||||||
root.name = weapon
|
root.name = weapon
|
||||||
var weapon_model = Runtimeloader.load_gltf(config.get_value(weapon, "MODEL")) as Node3D
|
var weapon_model = Runtimeloader.load_gltf(config.get_value(weapon, "MODEL"), root) as Node3D
|
||||||
var old_parent = weapon_model.get_parent()
|
|
||||||
old_parent.remove_child(weapon_model)
|
|
||||||
|
|
||||||
#Set Weapon nodes
|
|
||||||
root.add_child(weapon_model)
|
|
||||||
root.position = config.get_value(weapon, "HAND_POS")
|
root.position = config.get_value(weapon, "HAND_POS")
|
||||||
root.rotation = config.get_value(weapon, "HAND_ROT")
|
root.rotation = config.get_value(weapon, "HAND_ROT")
|
||||||
root.hide()
|
root.hide()
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
extends Node
|
extends Node
|
||||||
var PATH = "res://scoom/"
|
var PATH = "res://scoom/"
|
||||||
|
var EXTERNAL_PATH = "res://scoom/"
|
||||||
const ENTITY_CONFIG = "entity.cfg"
|
const ENTITY_CONFIG = "entity.cfg"
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
if(not OS.has_feature("editor")):
|
if(not OS.has_feature("editor")):
|
||||||
PATH = OS.get_executable_path().get_base_dir() + "/scoom/"
|
EXTERNAL_PATH = OS.get_executable_path().get_base_dir() + "/scoom/"
|
||||||
|
|
||||||
print(PATH)
|
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if event is InputEventKey and event.is_pressed():
|
if event is InputEventKey and event.is_pressed():
|
||||||
@@ -19,7 +19,7 @@ func get_all_children(in_node, arr = []):
|
|||||||
arr = get_all_children(child,arr)
|
arr = get_all_children(child,arr)
|
||||||
return arr
|
return arr
|
||||||
|
|
||||||
func load_gltf(file, hasCollision = false, trimesh = false):
|
func load_gltf(file, parent = self, hasCollision = false, trimesh = false):
|
||||||
var gltf := GLTFDocument.new()
|
var gltf := GLTFDocument.new()
|
||||||
var gltf_state := GLTFState.new()
|
var gltf_state := GLTFState.new()
|
||||||
|
|
||||||
@@ -44,11 +44,20 @@ func load_gltf(file, hasCollision = false, trimesh = false):
|
|||||||
o.create_trimesh_collision()
|
o.create_trimesh_collision()
|
||||||
else:
|
else:
|
||||||
o.create_convex_collision()
|
o.create_convex_collision()
|
||||||
add_child(node)
|
parent.add_child(node)
|
||||||
if(entity_count > 0):
|
if(entity_count > 0):
|
||||||
print("Loaded ", entity_count, " entities.")
|
print("Loaded ", entity_count, " entities.")
|
||||||
|
|
||||||
return node
|
return node
|
||||||
|
|
||||||
|
func get_all_entities(at_node):
|
||||||
|
var entity_count = 0
|
||||||
|
for o in get_all_children(at_node):
|
||||||
|
if o.name.begins_with("entity_") && not o.name.ends_with("_geometry"):
|
||||||
|
print("Loading entity ", o.name)
|
||||||
|
if loadEntity(o):
|
||||||
|
entity_count += 1;
|
||||||
|
if(entity_count > 0):
|
||||||
|
print("Loaded ", entity_count, " entities.")
|
||||||
|
|
||||||
func loadEntity(node):
|
func loadEntity(node):
|
||||||
var config = ConfigFile.new()
|
var config = ConfigFile.new()
|
||||||
@@ -56,17 +65,23 @@ func loadEntity(node):
|
|||||||
|
|
||||||
if err != OK:
|
if err != OK:
|
||||||
printerr("COULD NOT LOAD ENTITY : ", node.name)
|
printerr("COULD NOT LOAD ENTITY : ", node.name)
|
||||||
node.queue_free()
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
var x = config.get_section_keys(node.name)
|
var x = config.get_section_keys(node.name)
|
||||||
if(x.size() < 1):
|
if(x.size() < 1):
|
||||||
node.queue_free()
|
|
||||||
printerr("NO CONFIG FOUND FOR ENTITY : ", node.name)
|
printerr("NO CONFIG FOUND FOR ENTITY : ", node.name)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
var entity = load_gltf(config.get_value(node.name, "model")) as Node3D
|
var entity = load_gltf(config.get_value(node.name, "model"), node.get_parent()) as Node3D
|
||||||
|
|
||||||
entity.transform.origin = node.transform.origin
|
entity.transform.origin = node.transform.origin
|
||||||
entity.scale = (Vector3(1.5,1.5,1.5))
|
entity.scale = config.get_value(node.name, "scale")
|
||||||
node.queue_free()
|
node.queue_free()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
func loadPCK(file, parent = self):
|
||||||
|
var success = ProjectSettings.load_resource_pack(EXTERNAL_PATH + file)
|
||||||
|
|
||||||
|
if success:
|
||||||
|
print("Resource pack loaded ", EXTERNAL_PATH + file)
|
||||||
|
|
||||||
|
|||||||
BIN
test_map.pck
Normal file
BIN
test_map.pck
Normal file
Binary file not shown.
Reference in New Issue
Block a user