Initial commit

This commit is contained in:
2026-01-21 23:51:53 +01:00
commit 60b208fee0
1703 changed files with 100223 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

View File

@@ -0,0 +1,122 @@
extends Node3D
class_name LevelGenerator
var levelGrid: Array[Array]
@export var gridSize: int = 250
var spawnableRooms: Array[RoomData]
var biomes: Array[Biome]
var rng := RandomNumberGenerator.new()
func _ready() -> void:
initGrid()
var spaceshipRoomList := RoomListSpaceship.new() # Have something choose the map in this part later
spawnableRooms = spaceshipRoomList.rooms
var temp: Array[DoorPosition]
# Generate the level
temp = spawnRoom(spawnableRooms[0],Vector2i(40,40),0,true)
for x in temp:
spawnRoomAtDoor(spawnableRooms[0],x)
printLevelGrid()
func initGrid() -> void:
for x in gridSize:
var newRow: Array
levelGrid.push_back(newRow)
for y in gridSize:
var newCell := GridCell.new()
levelGrid[x].push_back(newCell)
func addGridCells(cell1: GridCell,cell2: GridCell) -> GridCell:
var returnCell: GridCell = GridCell.new()
returnCell.spaceTaken = cell1.spaceTaken or cell2.spaceTaken
returnCell.door = cell2.door
returnCell.doorOrientation = cell2.doorOrientation
returnCell.biome = cell1.biome
return returnCell
func addArrays2D(array1: Array[Array], array2: Array[Array], arr2pos: Vector2i = Vector2i(0,0)) -> void:
if array1.size() < (arr2pos.x - 1) + array2.size(): return
if array1[arr2pos.y].size() < (arr2pos.y - 1) + array2[0].size(): return
for x in array2.size():
for y in array2[x].size():
array1[x+arr2pos.x][y+arr2pos.y] = addGridCells(array1[x+arr2pos.x][y+arr2pos.y],array2[x][y])
func rotateArray2D(array: Array[Array], numberOfRotationsBy90Degrees: int = 1) -> void:
var size: int = array.size()
var layerCount: int = size/2
for x in numberOfRotationsBy90Degrees%4:
for layer in layerCount:
var first: int = layer
var last: int = size - first - 1
for element in range(first, last):
var offset = element - first
var top = array[first][element]
var right = array[element][last]
var bot = array[last][last-offset]
var left = array[last-offset][first]
array[element][last] = top
array[last][last-offset] = right
array[last-offset][first] = bot
array[first][element] = left
func getDoorPosition(cell: GridCell, GridCellPosition: Vector2i) -> DoorPosition:
if !cell.door:
print("Tried to get door at cell that isnt a door")
return null
var returnDoorPosition := DoorPosition.new()
returnDoorPosition.pos = GridCellPosition
returnDoorPosition.orientation = cell.doorOrientation
return returnDoorPosition
func addObject(AddedObject:PackedScene, Parent: Node3D, Position: Vector3, Rotation: Vector3= Vector3(0,0,0)):
if !AddedObject:
print("tried to add object but packed scene is null")
return
var obj = AddedObject.instantiate()
Parent.add_child(obj)
obj.position = Position
obj.rotation = Rotation
return obj
func rotateRoom(roomData: RoomData, numberOfRotationsBy90Degrees: int) -> void:
rotateArray2D(roomData.roomGrid,numberOfRotationsBy90Degrees)
for door in roomData.doorPositions:
door.rotatePosRight(roomData.roomGrid.size(),numberOfRotationsBy90Degrees)
door.orientation += numberOfRotationsBy90Degrees % 4
func spawnRoom(roomData: RoomData,pos: Vector2i,numberOfRotationsBy90Degrees: int = 0, centered: bool = false) -> Array[DoorPosition]: #Pos corresponds to the upper left corner of the room immage
var roomScene: PackedScene = load(roomData.roomSceneRef)
rotateRoom(roomData,numberOfRotationsBy90Degrees)
var roomGrid := roomData.roomGrid
var doorPositions: Array[DoorPosition] = roomData.doorPositions
if centered:
pos = Vector2i(pos.x-(roomGrid.size()/2),pos.y-(roomGrid[0].size()/2))
addArrays2D(levelGrid,roomGrid,pos)
addObject(roomScene,self,Vector3(pos.x+(roomGrid.size()/2),0,pos.y+(roomGrid[0].size()/2)),Vector3(0,(numberOfRotationsBy90Degrees%4)*PI/2,0))
for door in doorPositions:
door.pos += pos
return doorPositions
func spawnRoomAtDoor(roomData: RoomData, door: DoorPosition) -> void:
var spawnDoor: DoorPosition = roomData.doorPositions[rng.randi_range(0,roomData.doorPositions.size()-1)]
var doorOrientationDifference : int = spawnDoor.orientation - door.orientation
var numberOfRoomRotations: int = 0
if !abs(doorOrientationDifference) == 2:
if doorOrientationDifference > 0:
numberOfRoomRotations = 1
if doorOrientationDifference == 0:
numberOfRoomRotations = 2
if doorOrientationDifference < 0:
numberOfRoomRotations = 3
spawnRoom(roomData,door.pos,numberOfRoomRotations)
func printLevelGrid() -> void:
var debugCube: PackedScene = preload("res://test/debugCube.tscn")
for x in levelGrid.size():
for y in levelGrid[x].size():
if levelGrid[x][y].spaceTaken:
addObject(debugCube,self,Vector3(x+0.5,0,y+0.5))

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,156 @@
[gd_scene load_steps=11 format=3 uid="uid://c240icwf4uov8"]
[ext_resource type="Script" uid="uid://b4avd5n3wv18p" path="res://script/main.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://hx4hednm6nub" path="res://scene/mainmenu.tscn" id="2_v0l8b"]
[ext_resource type="Texture2D" uid="uid://s7wkvdx006f" path="res://assets/2D/Back.png" id="3_0ha60"]
[ext_resource type="Texture2D" uid="uid://dra4s4sa7lh6t" path="res://assets/2D/Progress.png" id="4_4j5ol"]
[ext_resource type="Texture2D" uid="uid://c1401tikex5vt" path="res://assets/2D/Viser.png" id="5_0ha60"]
[ext_resource type="PackedScene" uid="uid://d1dplm1rdcx1h" path="res://scene/settingsmenu.tscn" id="6_4j5ol"]
[ext_resource type="Texture2D" uid="uid://csbtt12ohhvec" path="res://assets/2D/GreenCross.png" id="7_p1hux"]
[ext_resource type="PackedScene" uid="uid://bo3jh7r0wnwgr" path="res://scene/pausemenu.tscn" id="8_of57s"]
[sub_resource type="AudioStreamMicrophone" id="AudioStreamMicrophone_of57s"]
[sub_resource type="AudioStreamOpusChunked" id="AudioStreamOpusChunked_of57s"]
audiosamplerate = 48000
audiosamplesize = 960
mix_rate = 48000
[node name="Main" type="Control"]
process_mode = 3
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1")
metadata/_edit_horizontal_guides_ = [-61.0]
[node name="Dialogs" type="Node" parent="."]
[node name="DisconnectDialog" type="AcceptDialog" parent="Dialogs"]
title = "Server connection:"
dialog_text = "Connection closed"
[node name="InviteCodeDialog" type="AcceptDialog" parent="Dialogs"]
auto_translate_mode = 1
title = "Lobby code:"
initial_position = 2
size = Vector2i(158, 100)
dialog_text = "Error"
[node name="JoinGameDialog" type="AcceptDialog" parent="Dialogs"]
auto_translate_mode = 1
title = "Logging in..."
initial_position = 2
size = Vector2i(158, 100)
dialog_text = "Error"
[node name="ErrorDialog" type="AcceptDialog" parent="Dialogs"]
auto_translate_mode = 1
title = "Logging in..."
initial_position = 2
size = Vector2i(158, 100)
dialog_text = "Error"
[node name="Settingsmenu" parent="." instance=ExtResource("6_4j5ol")]
unique_name_in_owner = true
visible = false
layout_mode = 1
[node name="Mainmenu" parent="." instance=ExtResource("2_v0l8b")]
unique_name_in_owner = true
layout_mode = 1
[node name="Pausemenu" parent="." instance=ExtResource("8_of57s")]
unique_name_in_owner = true
visible = false
layout_mode = 1
[node name="Hud" type="Control" parent="."]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
[node name="TextureProgressBar" type="TextureProgressBar" parent="Hud"]
z_index = 2
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -101.25
offset_top = -129.0
offset_right = 101.25
grow_horizontal = 2
grow_vertical = 0
value = 100.0
nine_patch_stretch = true
texture_under = ExtResource("3_0ha60")
texture_progress = ExtResource("4_4j5ol")
[node name="Identifier" type="Label" parent="Hud"]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -94.0
offset_bottom = 23.0
grow_horizontal = 0
[node name="Viser" type="TextureRect" parent="Hud"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("5_0ha60")
stretch_mode = 3
[node name="InteractCross" type="TextureRect" parent="Hud"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -160.0
offset_top = -120.0
offset_right = -120.0
offset_bottom = -80.0
grow_horizontal = 2
grow_vertical = 0
texture = ExtResource("7_p1hux")
[node name="Maps" type="Node3D" parent="."]
[node name="Players" type="Node3D" parent="."]
[node name="Spectators" type="Node3D" parent="."]
[node name="MapSpawner" type="MultiplayerSpawner" parent="."]
_spawnable_scenes = PackedStringArray("uid://bco4seshb8fjf", "uid://k0jpd2sugl7b")
spawn_path = NodePath("../Maps")
[node name="PlayerSpawner" type="MultiplayerSpawner" parent="."]
_spawnable_scenes = PackedStringArray("uid://rvvjguhqjtpb")
spawn_path = NodePath("../Players")
[node name="VoiceInput" type="AudioStreamPlayer" parent="."]
stream = SubResource("AudioStreamMicrophone_of57s")
autoplay = true
bus = &"Mic"
[node name="DebugVoiceOutput" type="AudioStreamPlayer3D" parent="."]
stream = SubResource("AudioStreamOpusChunked_of57s")
autoplay = true

View File

@@ -0,0 +1,121 @@
[gd_scene load_steps=17 format=3 uid="uid://bco4seshb8fjf"]
[ext_resource type="Script" uid="uid://fvwy57of2gvq" path="res://Maps/Lobby/lobby.gd" id="1_3j6ah"]
[ext_resource type="Texture2D" uid="uid://cimsjl61nhh5s" path="res://assets/2D/HDR_blue_nebulae-1.hdr" id="1_o7c6e"]
[ext_resource type="Script" uid="uid://cjgxd88k1bntf" path="res://script/pathfindingGridLoad.gd" id="3_bhyb3"]
[ext_resource type="Script" uid="uid://cjiiw7cybj24b" path="res://script/ButtonLogicImpulse.gd" id="4_2vvmy"]
[ext_resource type="Script" uid="uid://ymaax1x5fos3" path="res://script/interactBox.gd" id="5_f6mem"]
[ext_resource type="AudioStream" uid="uid://1bkjenax2g3s" path="res://assets/Audio/Ambience 1 SpaceBots Audio.mp3" id="6_f6mem"]
[ext_resource type="PackedScene" uid="uid://1u8jah8h1mav" path="res://Maps/Spaceship/Objects/Grabable/boombox_1.tscn" id="7_b4v87"]
[sub_resource type="Gradient" id="Gradient_skcuv"]
interpolation_mode = 1
offsets = PackedFloat32Array(0, 0.25, 0.361502, 0.375, 0.488263, 0.5, 0.615023, 0.625, 0.732394, 0.75, 0.859155, 0.875, 1)
colors = PackedColorArray(0, 0, 0, 1, 0.25, 0.25, 0.25, 1, 0.28169, 0.28169, 0.28169, 1, 0.375, 0.375, 0.375, 1, 0.408451, 0.408451, 0.408451, 1, 0.5, 0.5, 0.5, 1, 0.530516, 0.530516, 0.530516, 1, 0.625, 0.625, 0.625, 1, 0.661972, 0.661972, 0.661972, 1, 0.75, 0.75, 0.75, 1, 0.802817, 0.802817, 0.802817, 1, 0.875, 0.875, 0.875, 1, 1, 1, 1, 1)
metadata/_snap_enabled = true
metadata/_snap_count = 8
[sub_resource type="GradientTexture1D" id="GradientTexture1D_h11mn"]
gradient = SubResource("Gradient_skcuv")
[sub_resource type="Gradient" id="Gradient_3j6ah"]
offsets = PackedFloat32Array(0.187793, 0.704225, 0.929577)
colors = PackedColorArray(0, 0, 0, 1, 0.58042, 0.58042, 0.58042, 1, 0.860369, 0.860369, 0.860369, 1)
[sub_resource type="FastNoiseLite" id="FastNoiseLite_bhyb3"]
frequency = 0.03
fractal_octaves = 8
fractal_lacunarity = 5.0
fractal_gain = 0.495
fractal_weighted_strength = 0.23
domain_warp_enabled = true
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_jyrsd"]
color_ramp = SubResource("Gradient_3j6ah")
noise = SubResource("FastNoiseLite_bhyb3")
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_2vvmy"]
panorama = ExtResource("1_o7c6e")
[sub_resource type="Sky" id="Sky_bs3qb"]
sky_material = SubResource("PanoramaSkyMaterial_2vvmy")
[sub_resource type="Environment" id="Environment_f6mem"]
background_mode = 2
sky = SubResource("Sky_bs3qb")
glow_enabled = true
glow_levels/1 = 1.38
glow_levels/2 = 1.55
glow_levels/3 = 5.63
glow_levels/5 = 1.75
glow_levels/6 = 0.9
glow_levels/7 = 0.75
glow_strength = 1.73
glow_mix = 0.03
glow_bloom = 0.05
glow_blend_mode = 4
glow_hdr_luminance_cap = 1.5
glow_map = SubResource("NoiseTexture2D_jyrsd")
volumetric_fog_emission = Color(1, 1, 1, 1)
volumetric_fog_emission_energy = 0.04
adjustment_brightness = 1.5
adjustment_color_correction = SubResource("GradientTexture1D_h11mn")
[sub_resource type="BoxShape3D" id="BoxShape3D_b4v87"]
size = Vector3(4.5, 1, 1)
[node name="Lobby" type="Node3D"]
script = ExtResource("1_3j6ah")
metadata/_custom_type_script = "uid://cbjn7f7r081q8"
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_f6mem")
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 10.1725, 0)
use_collision = true
[node name="CSGBox3D2" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.00969505, 0)
operation = 2
size = Vector3(49, 19, 49)
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D"]
flip_faces = true
size = Vector3(50, 20, 50)
[node name="OmniLight3D" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 7.47177, 0)
omni_range = 19.6325
[node name="PathfindingGridLoader" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -25, 2.01037, -25)
script = ExtResource("3_bhyb3")
lengthX = 25
lengthZ = 25
metadata/_custom_type_script = "uid://cjgxd88k1bntf"
[node name="StartMission" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.69191, 1.21511)
pixel_size = 0.02
text = "Start Mission"
[node name="ButtonLogicImpulse" type="Timer" parent="StartMission" node_paths=PackedStringArray("interactBox")]
script = ExtResource("4_2vvmy")
interactBox = NodePath("../InteractBox")
metadata/_custom_type_script = "uid://cjiiw7cybj24b"
[node name="InteractBox" type="Area3D" parent="StartMission" node_paths=PackedStringArray("object")]
script = ExtResource("5_f6mem")
object = NodePath("../ButtonLogicImpulse")
metadata/_custom_type_script = "uid://ymaax1x5fos3"
[node name="CollisionShape3D" type="CollisionShape3D" parent="StartMission/InteractBox"]
shape = SubResource("BoxShape3D_b4v87")
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer" parent="."]
stream = ExtResource("6_f6mem")
parameters/looping = true
[node name="Boombox1" parent="." instance=ExtResource("7_b4v87")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.3857, 1.1725, -4.27042)