-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworded some things, and finally implemented level saving! Levels look very strange in FEZ (check the FEZ Community Projects Discord to see what I mean), so there's still a lot of work to do.
- Loading branch information
Showing
15 changed files
with
66,510 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[gd_scene load_steps=5 format=3 uid="uid://dtgqsmedef7w7"] | ||
|
||
[sub_resource type="PlaneMesh" id="PlaneMesh_svens"] | ||
|
||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_2attf"] | ||
depth_draw_mode = 1 | ||
albedo_color = Color(0.0235294, 0.027451, 0.560784, 1) | ||
disable_receive_shadows = true | ||
proximity_fade_distance = 10.0 | ||
|
||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_gswgw"] | ||
depth_draw_mode = 1 | ||
albedo_color = Color(0.121569, 0.984314, 0.156863, 1) | ||
disable_receive_shadows = true | ||
|
||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_qo6fp"] | ||
depth_draw_mode = 1 | ||
albedo_color = Color(1, 0.117647, 0.156863, 1) | ||
disable_receive_shadows = true | ||
|
||
[node name="Stopper" type="Node3D"] | ||
|
||
[node name="xz" type="MeshInstance3D" parent="."] | ||
transform = Transform3D(25, 0, 0, 0, 25, 0, 0, 0, 25, 0, 0, 0) | ||
layers = 16 | ||
visibility_range_end = 50.0 | ||
visibility_range_end_margin = 20.0 | ||
visibility_range_fade_mode = 1 | ||
mesh = SubResource("PlaneMesh_svens") | ||
surface_material_override/0 = SubResource("StandardMaterial3D_2attf") | ||
|
||
[node name="yx" type="MeshInstance3D" parent="."] | ||
transform = Transform3D(25, 0, 0, 0, -1.09278e-06, -25, 0, 25, -1.09278e-06, 0, 0, 0) | ||
layers = 16 | ||
visibility_range_end = 50.0 | ||
visibility_range_end_margin = 20.0 | ||
visibility_range_fade_mode = 1 | ||
mesh = SubResource("PlaneMesh_svens") | ||
skeleton = NodePath("../xz") | ||
surface_material_override/0 = SubResource("StandardMaterial3D_gswgw") | ||
|
||
[node name="yz" type="MeshInstance3D" parent="."] | ||
transform = Transform3D(-1.09278e-06, 25, -1.09278e-06, 0, -1.09278e-06, -25, -25, -1.09278e-06, 4.77671e-14, 0, 0, 0) | ||
layers = 16 | ||
visibility_range_end = 50.0 | ||
visibility_range_end_margin = 20.0 | ||
visibility_range_fade_mode = 1 | ||
mesh = SubResource("PlaneMesh_svens") | ||
skeleton = NodePath("../xz") | ||
surface_material_override/0 = SubResource("StandardMaterial3D_qo6fp") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
extends Node | ||
|
||
# Exporting is a little more complicated than importing. We have our data, we know what it looks like, | ||
# we just have to get it out in a way FEZ likes. To help with this, I made a "template" file that we can | ||
# overwrite with our data. | ||
|
||
@onready var _loader = $"../Loader" | ||
|
||
var lvlSize = [0, 0, 0] | ||
|
||
# Standard definitions. This will get ugly! | ||
var _aoActor = { "Inactive": false, "ContainedTrile": "None", "AttachedGroup": null, "SpinView": "None", "SpinEvery": 0, "SpinOffset": 0, "OffCenter": false, "RotationCenter": [0, 0, 0], "VibrationPattern": [], "CodePattern": [], "Segment": { "Destination": [0, 0, 0], "Duration": 1, "WaitTimeOnStart": 0, "WaitTimeOnFinish": 0, "Acceleration": 0, "Deceleration": 0, "JitterFactor": 0, "Orientation": [0, 0, 0, 1], "CustomData": null }, "NextNode": null, "DestinationLevel": "", "TreasureMapName": "", "InvisibleSides": [], "TimeswitchWindBackSpeed": 0} | ||
|
||
func _on_save_file_selected(path: String): | ||
var adjPath = path.get_slice(".", 0) # Get just the filename, in case the user puts in file extension. | ||
var filename = adjPath.get_file() | ||
var cleanPath = adjPath.get_base_dir() | ||
|
||
_saveFEZLVL(cleanPath, filename) | ||
pass # Replace with function body. | ||
|
||
func _saveFEZLVL(path, filename): | ||
var readTemp = JSON.new() | ||
var err = readTemp.parse(FileAccess.get_file_as_string("res://Scripts/Exporter/template.fezlvl.json")) | ||
if err == OK: | ||
var template = readTemp.data | ||
# Get all of Loader's children. | ||
for n in _loader.get_child_count(): | ||
var obj = _loader.get_child(n) | ||
var type = obj.get_meta("Type") | ||
|
||
match type: | ||
"Trile": | ||
var pos = [obj.position.x, obj.position.y, obj.position.z] | ||
var emp = [round(pos[0]), round(pos[1]), round(pos[2])] | ||
var phi = 0 | ||
var actset = null | ||
|
||
var trileDict = { "Emplacement": emp, | ||
"Position": pos, | ||
"Phi": phi, | ||
"Id": int(obj.get_meta("Id")), | ||
"ActorSettings": actset} | ||
|
||
template["Triles"].append(trileDict) | ||
pass | ||
|
||
"AO": | ||
var aoName = obj.get_meta("Name") | ||
var pos = [obj.position.x, obj.position.y, obj.position.z] | ||
var rot = [obj.quaternion.x, obj.quaternion.y, obj.quaternion.z, obj.quaternion.w] | ||
var aoScale = [obj.scale.x, obj.scale.y, obj.scale.z] | ||
var actset = _aoActor | ||
|
||
var aoDict = { "Name": aoName.to_upper(), | ||
"Position": pos, | ||
"Rotation": rot, | ||
"Scale": aoScale, | ||
"ActorSettings": actset} | ||
var arrIdx = template["ArtObjects"].size() + 1 | ||
var metaDict = { str(arrIdx) : aoDict} | ||
|
||
template["ArtObjects"].merge(metaDict) | ||
pass | ||
|
||
"StartingPoint": | ||
var id = obj.get_meta("Id") | ||
var face = obj.get_meta("Face") | ||
var spDict = { "Id": id, "Face": face} | ||
|
||
template["StartingPosition"] = spDict | ||
pass | ||
pass | ||
template["Name"] = filename.to_upper() | ||
template["TrileSetName"] = _loader.trileset[3].to_upper() | ||
|
||
# Find the level's size automatically by finding the most out-there object. | ||
var maxX = _findLargest(template["Triles"], 0) | ||
var maxY = _findLargest(template["Triles"], 1) | ||
var maxZ = _findLargest(template["Triles"], 2) | ||
template["Size"] = [maxX, maxY, maxZ] | ||
|
||
print("Done writing file. Phew!") | ||
|
||
var writeLVL := JSON.stringify(template, " ", false, false) | ||
|
||
var file = FileAccess.open(path + "/" + filename + ".fezlvl.json", FileAccess.WRITE) | ||
file.store_string(writeLVL) | ||
file.close() | ||
pass | ||
pass | ||
|
||
func _findLargest(triles, idx: int): | ||
var comparer: int = 1 | ||
for trile in triles: | ||
if trile["Position"][idx] > comparer: | ||
comparer = trile["Position"][idx] | ||
pass | ||
return comparer |
Oops, something went wrong.