HOLY FUCK MAP LOADING WORKS!!!!!!!!
This commit is contained in:
parent
b9a9cb6203
commit
ae8b17a347
8 changed files with 163 additions and 148 deletions
|
@ -1,8 +1,7 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://bw0tk6ml7gayq"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bw0tk6ml7gayq"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/DynamicMap.gd" id="1_mytgt"]
|
||||
[ext_resource type="Script" path="res://src/TempDebugCamera.gd" id="2_co6fy"]
|
||||
[ext_resource type="PackedScene" uid="uid://dm33ofcbh8sht" path="res://scenes/world/Player.tscn" id="3_58gow"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_tvhkv"]
|
||||
sky_top_color = Color(0.483795, 0.593484, 0.746094, 1)
|
||||
|
@ -22,12 +21,9 @@ script = ExtResource("1_mytgt")
|
|||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_d5g72")
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("3_58gow")]
|
||||
|
||||
[node name="CameraPivot" type="Node3D" parent="."]
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="CameraPivot"]
|
||||
current = true
|
||||
script = ExtResource("2_co6fy")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
|
@ -37,3 +33,5 @@ transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0,
|
|||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.97521, -1.86909, -3.06)
|
||||
use_collision = true
|
||||
size = Vector3(15.4238, 0.866943, 15.2599)
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="."]
|
||||
|
|
|
@ -26,7 +26,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.75, 0)
|
|||
[node name="Collision" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("CylinderShape3D_bsew3")
|
||||
disabled = true
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Collision"]
|
||||
visible = false
|
||||
|
|
|
@ -14,4 +14,5 @@ const ROOM4 = 5
|
|||
|
||||
const gridsz = 19 # Same size as the main map itself (better for the map creator)
|
||||
|
||||
const RoomScale = 0.010
|
||||
#const RoomScale = 0.010
|
||||
const RoomScale = 8.0 / 2048.0
|
||||
|
|
|
@ -57,20 +57,19 @@ func LoadRoomTemplates(file: String):
|
|||
|
||||
var rt = CreateRoomTemplate(StrTemp)
|
||||
RoomTemplates.push_back(rt)
|
||||
rt.Name = TemporaryString.to_lower()
|
||||
rt.Name = templateName.to_lower()
|
||||
|
||||
StrTemp = template["shape"].to_lower()
|
||||
|
||||
match StrTemp:
|
||||
"room1", "1":
|
||||
if StrTemp == "room1" or StrTemp == "1":
|
||||
rt.Shape = Constants.ROOM1
|
||||
"room2", "2":
|
||||
elif StrTemp == "room2" or StrTemp == "2":
|
||||
rt.Shape = Constants.ROOM2
|
||||
"room2c", "2c":
|
||||
elif StrTemp == "room2c" or StrTemp == "2c":
|
||||
rt.Shape = Constants.ROOM2C
|
||||
"room3", "3":
|
||||
elif StrTemp == "room3" or StrTemp == "3":
|
||||
rt.Shape = Constants.ROOM3
|
||||
"room4", "4":
|
||||
elif StrTemp == "room4" or StrTemp == "4":
|
||||
rt.Shape = Constants.ROOM4
|
||||
|
||||
for i1 in range(4):
|
||||
|
@ -179,8 +178,9 @@ func CalculateRoomExtents(r: Room):
|
|||
print("roomextents: ", r.MinX, ", ", r.MinY, ", ", r.MinZ, ", ", r.MaxX, ", ", r.MaxY, ", ", r.MaxZ)
|
||||
|
||||
func LoadRoomMesh(rt: RoomTemplate):
|
||||
var path = Utils.GetCaseiFileName(str("res://", rt.objPath.replace("\\", "/"))).replace("res://", "")
|
||||
if rt.objPath.contains(".rmesh"): # file is roommesh
|
||||
rt.obj = RMesh.LoadRMesh(rt.objPath, rt)
|
||||
rt.obj = RMesh.LoadRMesh(path, rt)
|
||||
# TODO: Implement b3d maps, not pressing as newer vers use exclusively rmesh
|
||||
#else: #file is b3d
|
||||
#If rt\objPath <> "" Then rt\obj = LoadWorld(rt\objPath, rt) Else rt\obj = CreatePivot()
|
||||
|
@ -297,7 +297,7 @@ func CreateMap():
|
|||
for i1 in range(y, MapHeight): # MapHeight - 1
|
||||
MapTemp[x][i1] = 1
|
||||
|
||||
while y < 2:
|
||||
while y > 2:
|
||||
width = randi_range(10, 15)
|
||||
|
||||
if x > MapWidth * 0.6:
|
||||
|
@ -351,7 +351,7 @@ func CreateMap():
|
|||
if tempheight == height:
|
||||
temp = x2
|
||||
x = temp
|
||||
y = y - height
|
||||
y -= height
|
||||
|
||||
var ZoneAmount = 3
|
||||
var Room1Amount = Utils.Init1DArray(3, 0)
|
||||
|
@ -362,7 +362,7 @@ func CreateMap():
|
|||
|
||||
# count the amount of rooms
|
||||
#For y = 1 To MapHeight - 1
|
||||
for y1 in range(MapHeight):
|
||||
for y1 in range(0, MapHeight):
|
||||
zone = GetZone(y1)
|
||||
|
||||
for x1 in range(MapWidth):
|
||||
|
@ -372,24 +372,23 @@ func CreateMap():
|
|||
if MapTemp[x1][y1] < 255:
|
||||
MapTemp[x1][y1] = temp
|
||||
#print(MapTemp[x1][y1])
|
||||
match MapTemp[x1][y1]:
|
||||
1:
|
||||
if MapTemp[x1][y1] == 1:
|
||||
Room1Amount[zone] += 1
|
||||
print("R1A ", Room1Amount[zone])
|
||||
2:
|
||||
elif MapTemp[x1][y1] == 2:
|
||||
if min(MapTemp[x1 + 1][y1], 1) + min(MapTemp[x1 - 1][y1], 1) == 2:
|
||||
Room2Amount[zone] += 1
|
||||
elif min(MapTemp[x1][y1 + 1], 1) + min(MapTemp[x1][y1 - 1], 1) == 2:
|
||||
Room2Amount[zone] += 1
|
||||
else:
|
||||
Room2CAmount[zone] += 1
|
||||
3:
|
||||
elif MapTemp[x1][y1] == 3:
|
||||
Room3Amount[zone] += 1
|
||||
4:
|
||||
elif MapTemp[x1][y1] == 4:
|
||||
Room4Amount[zone] += 1
|
||||
|
||||
# force more room1s (if needed)
|
||||
for i in range(0, 2):
|
||||
for i in range(0, 3):
|
||||
# need more rooms if there are less than 5 of them
|
||||
temp = -Room1Amount[i] + 5
|
||||
var y2 = 0
|
||||
|
@ -417,8 +416,7 @@ func CreateMap():
|
|||
|
||||
placed = false
|
||||
if MapTemp[x2][y2] > 1 and MapTemp[x2][y2] < 4:
|
||||
match MapTemp[x2][y2]:
|
||||
2:
|
||||
if MapTemp[x2][y2] == 2:
|
||||
if min(MapTemp[x2 + 1][y2], 1) + min(MapTemp[x2 - 1][y2], 1) == 2:
|
||||
Room2Amount[i] = Room2Amount[i] - 1
|
||||
Room3Amount[i] = Room3Amount[i] + 1
|
||||
|
@ -427,7 +425,7 @@ func CreateMap():
|
|||
Room2Amount[i] = Room2Amount[i] - 1
|
||||
Room3Amount[i] = Room3Amount[i] + 1
|
||||
placed = true
|
||||
3:
|
||||
elif MapTemp[x2][y2] == 3:
|
||||
Room3Amount[i] = Room3Amount[i] - 1
|
||||
Room4Amount[i] = Room4Amount[i] + 1
|
||||
placed = true
|
||||
|
@ -444,16 +442,15 @@ func CreateMap():
|
|||
break
|
||||
|
||||
# force more room4s and room2Cs
|
||||
for i in range(0, 2):
|
||||
for i in range(0, 3):
|
||||
var temp2 = 0
|
||||
match i:
|
||||
2:
|
||||
if i == 2:
|
||||
zone = 2
|
||||
temp2 = MapHeight / 3 #-1
|
||||
1:
|
||||
elif i == 1:
|
||||
zone = MapHeight / 3 + 1
|
||||
temp2 = MapHeight * (2.0 / 3.0) - 1
|
||||
0:
|
||||
elif i == 0:
|
||||
zone = MapHeight * (2.0 / 3.0) + 1
|
||||
temp2 = MapHeight - 2
|
||||
if Room4Amount[i] < 1: # we want at least 1 ROOM4
|
||||
|
@ -496,7 +493,7 @@ func CreateMap():
|
|||
temp2 = temp2 - 1
|
||||
|
||||
for y1 in range(zone, temp2):
|
||||
for x1 in range(3, MapWidth - 3):
|
||||
for x1 in range(3, MapWidth - 2):
|
||||
if MapTemp[x1][y1] == 1:
|
||||
if MapTemp[x1 - 1][y1] > 0:
|
||||
if (MapTemp[x1][y1 - 1] + MapTemp[x1][y1 + 1] + MapTemp[x1 + 2][y1]) == 0:
|
||||
|
@ -570,12 +567,12 @@ func CreateMap():
|
|||
MaxRooms = max(MaxRooms, Room2CAmount[0] + Room2CAmount[1] + Room2CAmount[2] + 1)
|
||||
MaxRooms = max(MaxRooms, Room3Amount[0] + Room3Amount[1] + Room3Amount[2] + 1)
|
||||
MaxRooms = max(MaxRooms, Room4Amount[0] + Room4Amount[1] + Room4Amount[2] + 1)
|
||||
MapRoom = Utils.Init2DArray(Constants.ROOM4 + 1, MaxRooms)
|
||||
MapRoom = Utils.Init2DArray(Constants.ROOM4 + 1, MaxRooms, "")
|
||||
|
||||
# zone 1 --------------------------------------------------------------------------------------------------
|
||||
|
||||
var min_pos = 1
|
||||
var max_pos = Room1Amount[0] - 1
|
||||
var max_pos = Room1Amount[0]-1
|
||||
|
||||
MapRoom[Constants.ROOM1][0] = "start"
|
||||
SetRoom("roompj", Constants.ROOM1, floor(0.1 * float(Room1Amount[0])), min_pos,max_pos)
|
||||
|
@ -663,15 +660,15 @@ func CreateMap():
|
|||
temp = 0
|
||||
var r: Room
|
||||
var spacing = 8.0
|
||||
for y1 in range(MapHeight - 1, 1, -1):
|
||||
for y1 in range(MapHeight - 1, 0, -1):
|
||||
zone = GetZone(y1)
|
||||
|
||||
if y1 < MapHeight / 3 + 1:
|
||||
zone = 3
|
||||
elif y1 < MapHeight * (2.0 / 3.0):
|
||||
zone=2
|
||||
zone = 2
|
||||
else:
|
||||
zone=1
|
||||
zone = 1
|
||||
|
||||
for x1 in range(MapWidth - 2):
|
||||
if MapTemp[x1][y1] == 255:
|
||||
|
@ -682,8 +679,8 @@ func CreateMap():
|
|||
elif MapTemp[x1][y1] > 0:
|
||||
temp = min(MapTemp[x1 + 1][y1], 1) + min(MapTemp[x1 - 1][y1], 1) + min(MapTemp[x1][y1 + 1], 1) + min(MapTemp[x1][y1 - 1], 1)
|
||||
|
||||
match temp: # viereisiss<73> ruuduissa olevien huoneiden m<><6D>r<EFBFBD>
|
||||
1:
|
||||
# viereisiss<73> ruuduissa olevien huoneiden m<><6D>r<EFBFBD>
|
||||
if temp == 1:
|
||||
if MapRoomID[Constants.ROOM1] < MaxRooms and MapName[x1][y1] == "":
|
||||
if MapRoom[Constants.ROOM1][MapRoomID[Constants.ROOM1]] != "":
|
||||
MapName[x1][y1] = MapRoom[Constants.ROOM1][MapRoomID[Constants.ROOM1]]
|
||||
|
@ -693,15 +690,15 @@ func CreateMap():
|
|||
r.angle = 180
|
||||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
elif MapTemp[x1 - 1][y1]:
|
||||
r.angle = 270
|
||||
r.angle = 90
|
||||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
elif MapTemp[x1 + 1][y1]:
|
||||
r.angle = 90
|
||||
r.angle = 270
|
||||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
else:
|
||||
r.angle = 0
|
||||
MapRoomID[Constants.ROOM1] = MapRoomID[Constants.ROOM1] + 1
|
||||
2:
|
||||
elif temp == 2:
|
||||
if MapTemp[x1 - 1][y1] > 0 and MapTemp[x1 + 1][y1] > 0:
|
||||
if MapRoomID[Constants.ROOM2] < MaxRooms and MapName[x1][y1] == "":
|
||||
if MapRoom[Constants.ROOM2][MapRoomID[Constants.ROOM2]] != "":
|
||||
|
@ -731,11 +728,11 @@ func CreateMap():
|
|||
|
||||
if MapTemp[x1 - 1][y1] > 0 and MapTemp[x1][y1 + 1] > 0:
|
||||
r = CreateRoom(zone, Constants.ROOM2C, x1 * 8, 0, y1 * 8, MapName[x1][y1])
|
||||
r.angle = 180
|
||||
r.angle = 90
|
||||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
elif MapTemp[x1 + 1][y1] > 0 and MapTemp[x1][y1 + 1] > 0:
|
||||
r = CreateRoom(zone, Constants.ROOM2C, x1 * 8, 0, y1 * 8, MapName[x1][y1])
|
||||
r.angle = 90
|
||||
r.angle = 180
|
||||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
elif MapTemp[x1 - 1][y1] > 0 and MapTemp[x1][y1 - 1] > 0:
|
||||
r = CreateRoom(zone, Constants.ROOM2C, x1 * 8, 0, y1 * 8, MapName[x1][y1])
|
||||
|
@ -743,8 +740,10 @@ func CreateMap():
|
|||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
else:
|
||||
r = CreateRoom(zone, Constants.ROOM2C, x1 * 8, 0, y1 * 8, MapName[x1][y1])
|
||||
r.angle = 270
|
||||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
MapRoomID[Constants.ROOM2C] = MapRoomID[Constants.ROOM2C] + 1
|
||||
3:
|
||||
elif temp == 3:
|
||||
if MapRoomID[Constants.ROOM3] < MaxRooms and MapName[x1][y1] == "":
|
||||
if MapRoom[Constants.ROOM3][MapRoomID[Constants.ROOM3]] != "":
|
||||
MapName[x1][y1] = MapRoom[Constants.ROOM3][MapRoomID[Constants.ROOM3]]
|
||||
|
@ -754,13 +753,13 @@ func CreateMap():
|
|||
r.angle = 180
|
||||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
elif not MapTemp[x1 - 1][y1]:
|
||||
r.angle = 90
|
||||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
elif not MapTemp[x1 + 1][y1]:
|
||||
r.angle = 270
|
||||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
elif not MapTemp[x1 + 1][y1]:
|
||||
r.angle = 90
|
||||
r.obj.rotation.y = deg_to_rad(r.angle)
|
||||
MapRoomID[Constants.ROOM3] = MapRoomID[Constants.ROOM3] + 1
|
||||
4:
|
||||
elif temp == 4:
|
||||
if MapRoomID[Constants.ROOM4] < MaxRooms and MapName[x1][y1] == "":
|
||||
if MapRoom[Constants.ROOM4][MapRoomID[Constants.ROOM4]] != "":
|
||||
MapName[x1][y1] = MapRoom[Constants.ROOM4][MapRoomID[Constants.ROOM4]]
|
||||
|
|
|
@ -13,7 +13,8 @@ func _process(_delta: float) -> void:
|
|||
|
||||
func _on_video_stream_player_finished() -> void:
|
||||
if Global.videoToPlay == "res://GFX/menu/startup_TSS.avi":
|
||||
get_tree().change_scene_to_file("res://scenes/screens/MainMenu.tscn")
|
||||
#get_tree().change_scene_to_file("res://scenes/screens/MainMenu.tscn")
|
||||
get_tree().change_scene_to_file("res://scenes/screens/LoadingScreen.tscn")
|
||||
return
|
||||
|
||||
Global.videoToPlay = "res://GFX/menu/startup_TSS.avi"
|
||||
|
|
|
@ -40,6 +40,8 @@ static func GetCaseiFileName(path: String):
|
|||
else:
|
||||
loadedFileNames = Dictionary()
|
||||
var sillyDir = DirAccess.open(dirName)
|
||||
if not sillyDir:
|
||||
return null
|
||||
sillyDir.list_dir_begin()
|
||||
var dirFileName = sillyDir.get_next()
|
||||
while dirFileName != "":
|
||||
|
|
|
@ -10,7 +10,7 @@ static func StripFilename(file: String):
|
|||
if len(file) > 0:
|
||||
for i in range(len(file)):
|
||||
mi = file.substr(i, 1)
|
||||
if mi == "\\" or mi == "//":
|
||||
if mi == "\\" or mi == "/":
|
||||
lastSlash = i
|
||||
|
||||
return file.substr(0, lastSlash + 1)
|
||||
|
@ -29,12 +29,23 @@ static func LoadRMesh(file: String, rt: RoomTemplate):
|
|||
|
||||
var header = ReadString(reader)
|
||||
var hasTriggerBox = header == "RoomMesh.HasTriggerBox"
|
||||
if header != "RoomMesh":
|
||||
if header != "RoomMesh" and header != "RoomMesh.HasTriggerBox":
|
||||
print(str(correctedPath, " is Not RMESH"))
|
||||
return
|
||||
|
||||
var scene = Node3D.new()
|
||||
scene.name = str(fileName, "_", rt.Name, "_", RMESH_LOAD_COUNT)
|
||||
# debug rot and name!
|
||||
#var text3 = Label3D.new()
|
||||
#text3.position.y = 10
|
||||
#text3.scale.x = 3
|
||||
#text3.scale.y = 3
|
||||
#text3.scale.z = 3
|
||||
#text3.billboard = BaseMaterial3D.BILLBOARD_ENABLED
|
||||
#text3.name = "Egg"
|
||||
#scene.add_child(text3)
|
||||
#scene.set_script(load("res://src/stinky.gd"))
|
||||
#scene.set_meta("rmesh", fileName)
|
||||
RMESH_LOAD_COUNT += 1
|
||||
|
||||
var count: int = 0
|
||||
|
|
4
src/stinky.gd
Normal file
4
src/stinky.gd
Normal file
|
@ -0,0 +1,4 @@
|
|||
extends Node3D
|
||||
|
||||
func _process(delta: float):
|
||||
$Egg.text = str("ROT: ", rad_to_deg(rotation.y), "\n", get_meta("rmesh"))
|
Loading…
Add table
Reference in a new issue