Removed popup from the game, added simple options and menu. Added spawn to tiles and reworked content spawning

This commit is contained in:
=
2026-05-01 18:34:48 +02:00
parent 95455597da
commit dd81c2ff2e
13 changed files with 181 additions and 113 deletions
Binary file not shown.
+47 -75
View File
@@ -4,10 +4,9 @@
[ext_resource type="Script" uid="uid://dqrdb3bvws6b6" path="res://Scripts/Helpers/SteamworksHandler.cs" id="2_b2bpf"]
[ext_resource type="Script" uid="uid://c7khr6oist3ku" path="res://Scripts/Camera3d.cs" id="3_7lihs"]
[ext_resource type="Script" uid="uid://bm7knir4552j5" path="res://Scripts/Helpers/UIHandler.cs" id="4_fgofq"]
[ext_resource type="Texture2D" uid="uid://bmcpkt6mae2qi" path="res://Assets/AlarmSign.png" id="5_b2bpf"]
[ext_resource type="Script" uid="uid://bsd6n6b06a4pe" path="res://Scripts/DSL/CodingWindow.cs" id="6_7lihs"]
[ext_resource type="Script" uid="uid://k6vlo7ulvtep" path="res://Scripts/Robot/RobotList.cs" id="7_2irst"]
[ext_resource type="Script" uid="uid://c3v2vdj3ghp78" path="res://Scripts/Information.cs" id="7_fgofq"]
[ext_resource type="PackedScene" uid="uid://cpq7ppe8bw2bq" path="res://Scenes/Options.tscn" id="8_71axn"]
[ext_resource type="Script" uid="uid://fegfbcnlk8p5" path="res://Scripts/WorldGeneration/Map.cs" id="8_bf53h"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_u44n3"]
@@ -55,7 +54,7 @@ environment = SubResource("Environment_sb48q")
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1558432386]
follow_viewport_enabled = true
[node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "information", "mainCam", "map")]
[node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "information", "mainCam", "map", "FPS", "RAM", "options", "uiContent", "menu")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -69,9 +68,14 @@ size_flags_vertical = 3
script = ExtResource("4_fgofq")
codingWindow = NodePath("MainUI/Content/CodingWindow")
robotList = NodePath("MainUI/Content/RobotList")
information = NodePath("Popup/Information")
information = NodePath("")
mainCam = NodePath("../../Camera3D")
map = NodePath("MainUI/Content/Map")
FPS = NodePath("MainUI/FooterContainer/HBoxContainer/FPS")
RAM = NodePath("MainUI/FooterContainer/HBoxContainer/RAM")
options = NodePath("MainUI/Content/Options")
uiContent = NodePath("MainUI/Content")
menu = NodePath("MainUI/Content/Menu")
[node name="MainUI" type="VBoxContainer" parent="CanvasLayer/UIHandler" unique_id=1437975209]
layout_mode = 1
@@ -85,39 +89,6 @@ grow_vertical = 2
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_b2bpf")
[node name="Header" type="HBoxContainer" parent="CanvasLayer/UIHandler/MainUI/HeaderContainer" unique_id=1048237062]
layout_mode = 2
theme_override_constants/separation = 200
alignment = 1
[node name="Robotcount" type="RichTextLabel" parent="CanvasLayer/UIHandler/MainUI/HeaderContainer/Header" unique_id=1955918671]
layout_mode = 2
text = "Roboter: 0/0"
fit_content = true
autowrap_mode = 0
[node name="RobotWarning" type="TextureRect" parent="CanvasLayer/UIHandler/MainUI/HeaderContainer/Header" unique_id=759915558]
layout_mode = 2
texture = ExtResource("5_b2bpf")
expand_mode = 2
[node name="DayCount" type="RichTextLabel" parent="CanvasLayer/UIHandler/MainUI/HeaderContainer/Header" unique_id=1228850272]
layout_mode = 2
text = "Tag 1"
fit_content = true
autowrap_mode = 0
[node name="Time" type="RichTextLabel" parent="CanvasLayer/UIHandler/MainUI/HeaderContainer/Header" unique_id=1457538761]
layout_mode = 2
text = "19:20"
fit_content = true
autowrap_mode = 0
[node name="LightColor" type="ColorPickerButton" parent="CanvasLayer/UIHandler/MainUI/HeaderContainer/Header" unique_id=395026790]
layout_mode = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
text = "Choose Color..."
[node name="Content" type="Control" parent="CanvasLayer/UIHandler/MainUI" unique_id=45665557]
layout_mode = 2
size_flags_vertical = 3
@@ -303,6 +274,40 @@ layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="Menu" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=370952082]
visible = false
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Menu" unique_id=1924672355]
layout_mode = 2
[node name="Button" type="Button" parent="CanvasLayer/UIHandler/MainUI/Content/Menu/VBoxContainer" unique_id=1938871792]
layout_mode = 2
text = "Continue"
[node name="Button2" type="Button" parent="CanvasLayer/UIHandler/MainUI/Content/Menu/VBoxContainer" unique_id=1298589221]
layout_mode = 2
text = "Options"
[node name="Button3" type="Button" parent="CanvasLayer/UIHandler/MainUI/Content/Menu/VBoxContainer" unique_id=2028306785]
layout_mode = 2
text = "Exit"
[node name="Options" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=230632848 instance=ExtResource("8_71axn")]
visible = false
layout_mode = 1
[node name="FooterContainer" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI" unique_id=1495029884]
layout_mode = 2
@@ -319,51 +324,18 @@ text = "Robots (R)"
layout_mode = 2
text = "Options (ESC)"
[node name="Popup" type="Control" parent="CanvasLayer/UIHandler" unique_id=1989677138]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -19.0
offset_top = -21.0
offset_right = 21.0
offset_bottom = 19.0
grow_horizontal = 2
grow_vertical = 2
[node name="Information" type="PanelContainer" parent="CanvasLayer/UIHandler/Popup" unique_id=1457118246 node_paths=PackedStringArray("title", "content")]
visible = false
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("7_fgofq")
title = NodePath("VBoxContainer/Title")
content = NodePath("VBoxContainer/Content")
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/Popup/Information" unique_id=302174818]
[node name="FPS" type="RichTextLabel" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=2029942501]
layout_mode = 2
[node name="Title" type="RichTextLabel" parent="CanvasLayer/UIHandler/Popup/Information/VBoxContainer" unique_id=680933734]
layout_mode = 2
text = "Test"
fit_content = true
autowrap_mode = 0
horizontal_alignment = 1
[node name="Content" type="RichTextLabel" parent="CanvasLayer/UIHandler/Popup/Information/VBoxContainer" unique_id=1438295895]
[node name="RAM" type="RichTextLabel" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=1663333928]
layout_mode = 2
text = "Test"
fit_content = true
autowrap_mode = 0
horizontal_alignment = 1
[node name="Button" type="Button" parent="CanvasLayer/UIHandler/Popup/Information/VBoxContainer" unique_id=1927576326]
layout_mode = 2
text = "OK"
[connection signal="color_changed" from="CanvasLayer/UIHandler/MainUI/HeaderContainer/Header/LightColor" to="CanvasLayer/UIHandler" method="ChangeColor"]
[connection signal="button_up" from="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/VBoxContainer/Scripting/EditorWindow/Buttons/Clear" to="CanvasLayer/UIHandler/MainUI/Content/CodingWindow" method="ClearWindow"]
[connection signal="button_up" from="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/VBoxContainer/Scripting/EditorWindow/Buttons/Compile" to="CanvasLayer/UIHandler/MainUI/Content/CodingWindow" method="CompileProgram"]
[connection signal="pressed" from="CanvasLayer/UIHandler/Popup/Information/VBoxContainer/Button" to="CanvasLayer/UIHandler/Popup/Information" method="HideInformation"]
[connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/Content/Menu/VBoxContainer/Button" to="CanvasLayer/UIHandler" method="HandleMenu"]
[connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/Content/Menu/VBoxContainer/Button2" to="CanvasLayer/UIHandler" method="ShowOptions"]
[connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/Content/Menu/VBoxContainer/Button3" to="CanvasLayer/UIHandler" method="ExitGame"]
+39
View File
@@ -0,0 +1,39 @@
[gd_scene format=3 uid="uid://cpq7ppe8bw2bq"]
[node name="Options" type="PanelContainer" unique_id=230632848]
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
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1149639381]
layout_mode = 2
[node name="Title" type="RichTextLabel" parent="VBoxContainer" unique_id=1694731141]
layout_mode = 2
bbcode_enabled = true
text = "[font_size=32]Options[/font_size]"
fit_content = true
autowrap_mode = 0
horizontal_alignment = 1
[node name="GridContainer" type="GridContainer" parent="VBoxContainer" unique_id=488511819]
layout_mode = 2
columns = 2
[node name="RichTextLabel" type="RichTextLabel" parent="VBoxContainer/GridContainer" unique_id=189106367]
layout_mode = 2
text = "Light color: "
fit_content = true
autowrap_mode = 0
[node name="ColorPickerButton" type="ColorPickerButton" parent="VBoxContainer/GridContainer" unique_id=1830638845]
layout_mode = 2
size_flags_horizontal = 3
[node name="Button" type="Button" parent="VBoxContainer" unique_id=1183264327]
layout_mode = 2
text = "Close"
+5
View File
@@ -13,6 +13,11 @@ public partial class Camera3d : Camera3D
private Vector2 _mouseDelta;
public override void _Ready()
{
Position = new Vector3(0, 0, tileWidth/2);
}
public override void _Process(double delta)
{
if (canMove) MoveCamera(delta);
+7 -1
View File
@@ -7,9 +7,15 @@ public class LightHandler
public static void RedrawLights(Color color)
{
List<OmniLight3D> availableLights = new();
foreach(OmniLight3D light in lights)
{
light.LightColor = color;
if (GodotObject.IsInstanceValid(light))
{
light.LightColor = color;
availableLights.Add(light);
}
}
lights = [..availableLights];
}
}
+50 -2
View File
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Godot;
@@ -6,12 +7,16 @@ public partial class UIHandler : Control
{
[Export] CodingWindow codingWindow;
[Export] RobotList robotList;
[Export] Information information;
[Export] Camera3D mainCam;
[Export] Map map;
[Export] RichTextLabel FPS;
[Export] RichTextLabel RAM;
[Export] PanelContainer options;
[Export] Control uiContent;
[Export] PanelContainer menu;
public override void _Ready()
{
GetNode<ColorPickerButton>("./MainUI/HeaderContainer/Header/LightColor").Color = GameData.lightColor;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -31,6 +36,31 @@ public partial class UIHandler : Control
map.ShowMap();
}
}
if (Input.IsActionJustPressed("menu"))
{
HandleMenu();
}
DisplayStats();
}
public void HandleMenu()
{
bool shouldMenuOpen = true;
foreach (PanelContainer element in uiContent.GetChildren())
{
if (element.Visible)
{
element.Visible = false;
shouldMenuOpen = false;
}
}
if (shouldMenuOpen)
{
menu.Visible = true;
}
}
public void ChangeColor(Color color)
@@ -43,4 +73,22 @@ public partial class UIHandler : Control
{
codingWindow.ShowWindow(robot);
}
public void DisplayStats()
{
FPS.Text = Engine.GetFramesPerSecond().ToString() + " FPS";
double memory = Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024);
string memoryDisplay = memory > 1024 ? Math.Round(memory / 1024, 2).ToString() + " GB" : memory.ToString() + " MB";
RAM.Text = memoryDisplay;
}
public void ShowOptions()
{
options.Visible = true;
}
public void ExitGame()
{
GetTree().ChangeSceneToFile("res://Scenes/MainMenu.tscn");
}
}
-29
View File
@@ -1,29 +0,0 @@
using Godot;
using System;
public partial class Information : PanelContainer
{
[Export] RichTextLabel title;
[Export] RichTextLabel content;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public void DisplayInformation(string title, string content)
{
this.title.Text = title;
this.content.Text = content;
Visible = true;
}
public void HideInformation()
{
Visible = false;
}
}
-1
View File
@@ -1 +0,0 @@
uid://c3v2vdj3ghp78
+12 -2
View File
@@ -29,7 +29,7 @@ public partial class Layer : Node3D
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public void ClearDecorations()
@@ -113,6 +113,8 @@ public partial class Layer : Node3D
{
for (int z = 0; z < layerSize; z++)
{
//Exclude spawn from border generation
if(x == 0 && z == 0) continue;
if (!IsBorder(x, z))
continue;
@@ -135,6 +137,13 @@ public partial class Layer : Node3D
private void GenerateNecessaryTiles()
{
//Generate spawn only in the first layer
if (level == 0)
{
tiles[0,0].Collapse("spawn");
Propagate(new Vector2I());
}
//Randomly position the gate to the next layer
int posX, posY;
while (true)
{
@@ -146,11 +155,12 @@ public partial class Layer : Node3D
{
tiles[posX, posY].Collapse("gate");
gateCoordinate = new Vector2I(posX, posY);
GD.Print(gateCoordinate);
Propagate(gateCoordinate);
break;
}
}
}
public bool GenerateLayer(Vector2I collapseOrigin)
+1
View File
@@ -78,6 +78,7 @@ public partial class Tile
public void SpawnContent(Dictionary<string, MeshInstance3D> contentMeshes, Transform3D transform, List<Placeholder> placeholders)
{
if(!wasVisited) return;
foreach (Placeholder placeholder in placeholders)
{
if (containsLight && placeholder.name == "light") SpawnLight(contentMeshes["light"], placeholder, transform);
+5 -2
View File
@@ -66,7 +66,9 @@ public class WFC
["corner_down_right"] = new() { Direction.Forward, Direction.Right, Direction.Up },
["junction"] = new() { Direction.Backward, Direction.Forward, Direction.Left, Direction.Right, Direction.Up },
["gate"] = new() { Direction.Backward, Direction.Forward, Direction.Left, Direction.Right, Direction.Up, Direction.Down }
["gate"] = new() { Direction.Backward, Direction.Forward, Direction.Left, Direction.Right, Direction.Up, Direction.Down },
["spawn"] = new() { Direction.Forward, Direction.Left },
};
public static Dictionary<string, float> weights = new()
@@ -90,7 +92,8 @@ public class WFC
["end_left"] = 0.2f,
["end_right"] = 0.3f,
["gate"] = 0.0f
["gate"] = 0.0f,
["spawn"] = 0.0f
};
public static Direction Opposite(Direction dir)
+10 -1
View File
@@ -90,7 +90,7 @@ public partial class World : Node3D
{
Robot robot = ResourceLoader.LoadRobotPrefab().Instantiate<Robot>();
robot.Name = $"Robot #{robots.Count + 1}";
robot.Position = map[0].tiles[rand.Next(layerSize), rand.Next(layerSize)].Position;
robot.Position = map[0].tiles[0,0].Position;
AddChild(robot);
robots.Add(robot);
}
@@ -113,6 +113,15 @@ public partial class World : Node3D
map[layer] = layerNode;
}
map[0].tiles[0,0].wasVisited = true;
map[0].tiles[0,0].containsDecoration = true;
map[0].tiles[0,0].containsLight = true;
map[0].tiles[0,0].containsResource = false;
}
private void HandleTileVisit(int level)
{
HandleRenderData(BuildRenderData(level));
}
private List<TileRenderData> BuildRenderData(int layerIndex)
+5
View File
@@ -87,6 +87,11 @@ map={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":77,"key_label":0,"unicode":109,"location":0,"echo":false,"script":null)
]
}
menu={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
[layer_names]