Added missing Symbol to the game, Improved move and explore logic, added map refresh for tiles.

This commit is contained in:
2026-05-09 09:38:34 +02:00
parent 342b6e490f
commit e00259cd31
13 changed files with 127 additions and 35 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bkr5w2n0ur3b0"
path="res://.godot/imported/BronzeGearSymbol.png-fbe63b91e723706590d2614f99b9e000.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Images/Items/BronzeGearSymbol.png"
dest_files=["res://.godot/imported/BronzeGearSymbol.png-fbe63b91e723706590d2614f99b9e000.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
+4 -1
View File
@@ -66,7 +66,7 @@ environment = SubResource("Environment_sb48q")
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1558432386] [node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1558432386]
follow_viewport_enabled = true follow_viewport_enabled = true
[node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "mainCam", "map", "FPS", "RAM", "options", "uiContent", "menu", "inventory")] [node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "mainCam", "map", "FPS", "RAM", "options", "uiContent", "menu", "inventory", "researchList")]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@@ -88,6 +88,7 @@ options = NodePath("MainUI/Content/Options")
uiContent = NodePath("MainUI/Content") uiContent = NodePath("MainUI/Content")
menu = NodePath("MainUI/Content/Menu") menu = NodePath("MainUI/Content/Menu")
inventory = NodePath("MainUI/Content/Inventory") inventory = NodePath("MainUI/Content/Inventory")
researchList = NodePath("MainUI/Content/Research")
[node name="MainUI" type="VBoxContainer" parent="CanvasLayer/UIHandler" unique_id=1437975209] [node name="MainUI" type="VBoxContainer" parent="CanvasLayer/UIHandler" unique_id=1437975209]
layout_mode = 1 layout_mode = 1
@@ -397,6 +398,7 @@ size_flags_vertical = 3
theme_override_constants/separation = 10 theme_override_constants/separation = 10
[node name="Research" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=1416471893 node_paths=PackedStringArray("researchGraph")] [node name="Research" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=1416471893 node_paths=PackedStringArray("researchGraph")]
visible = false
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@@ -462,6 +464,7 @@ texture_normal = ExtResource("12_3so38")
[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/Button2" to="CanvasLayer/UIHandler" method="ShowOptions"]
[connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/Content/Menu/VBoxContainer/Button3" to="CanvasLayer/UIHandler" method="ExitGame"] [connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/Content/Menu/VBoxContainer/Button3" to="CanvasLayer/UIHandler" method="ExitGame"]
[connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer/Inventory" to="CanvasLayer/UIHandler" method="HandleInventoryButton"] [connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer/Inventory" to="CanvasLayer/UIHandler" method="HandleInventoryButton"]
[connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer/Research" to="CanvasLayer/UIHandler" method="HandleResearchButton"]
[connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer/Map" to="CanvasLayer/UIHandler" method="HandleMapButton"] [connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer/Map" to="CanvasLayer/UIHandler" method="HandleMapButton"]
[connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer/Robots" to="CanvasLayer/UIHandler" method="HandleRobotListButton"] [connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer/Robots" to="CanvasLayer/UIHandler" method="HandleRobotListButton"]
[connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer/Options" to="CanvasLayer/UIHandler" method="HandleMenuButton"] [connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer/Options" to="CanvasLayer/UIHandler" method="HandleMenuButton"]
+18
View File
@@ -34,8 +34,26 @@ public class ItemData
return char.ToUpper(noUnderscore[0]) + noUnderscore.Substring(1); return char.ToUpper(noUnderscore[0]) + noUnderscore.Substring(1);
} }
public static string GetReadableName(string input)
{
string noUnderscore = input.Replace("_", " ").ToLower();
return char.ToUpper(noUnderscore[0]) + noUnderscore.Substring(1);
}
public static string GetIndex(string readable) public static string GetIndex(string readable)
{ {
return readable.ToLower().Replace(" ", "_"); return readable.ToLower().Replace(" ", "_");
} }
public string GetCraftingDisplay()
{
string result = "";
result += GetReadableName() + ": \r";
foreach (Ingredient ingredient in Inputs)
{
result += $"{GetReadableName(ingredient.Item)} ({ingredient.Amount}),\r";
}
result = result.Remove(result.Length - 2);
return result;
}
} }
+1 -1
View File
@@ -70,7 +70,7 @@ public class CraftNode : ProgramNode
if(GameData.availableResearch[item.Research].state != ResearchState.RESEARCHED) continue; if(GameData.availableResearch[item.Research].state != ResearchState.RESEARCHED) continue;
if (item.Inputs.Count > 0) if (item.Inputs.Count > 0)
{ {
options.AddItem(item.GetReadableName()); options.AddItem(item.GetCraftingDisplay());
} }
} }
if (selectedItem != null) if (selectedItem != null)
+2 -3
View File
@@ -41,15 +41,14 @@ public class ExploreNode : ProgramNode
Vector3 target = pathPoints[0] - startPosition; Vector3 target = pathPoints[0] - startPosition;
float distance = target.Length(); float distance = target.Length();
if (distance < 0.1f) if (distance < 0.1f * Mathf.Sqrt(GameData.robotSpeed))
{ {
robot.Position = pathPoints[0]; robot.Position = pathPoints[0];
Vector3I mapIndex = Pathfinding.GetClosestStartPoint(robot.Position); Vector3I mapIndex = Pathfinding.GetClosestStartPoint(robot.Position);
Tile tile = GameData.map[mapIndex.Y].tiles[mapIndex.X, mapIndex.Z]; Tile tile = GameData.map[mapIndex.Y].tiles[mapIndex.X, mapIndex.Z];
if (!tile.wasVisited) if (!tile.wasVisited)
{ {
tile.wasVisited = true; tile.VisitTile();
tile.ContentNode.Visible = true;
} }
pathPoints.Remove(pathPoints[0]); pathPoints.Remove(pathPoints[0]);
if (pathPoints.Count <= 0) if (pathPoints.Count <= 0)
+1 -2
View File
@@ -30,8 +30,7 @@ public class MoveNode : ProgramNode
Tile tile = GameData.map[mapIndex.Y].tiles[mapIndex.X, mapIndex.Z]; Tile tile = GameData.map[mapIndex.Y].tiles[mapIndex.X, mapIndex.Z];
if (!tile.wasVisited) if (!tile.wasVisited)
{ {
tile.wasVisited = true; tile.VisitTile();
tile.ContentNode.Visible = true;
} }
pathPoints.Remove(pathPoints[0]); pathPoints.Remove(pathPoints[0]);
if (pathPoints.Count <= 0) if (pathPoints.Count <= 0)
+1 -1
View File
@@ -4,7 +4,7 @@ using Godot;
public partial class GameData public partial class GameData
{ {
public static bool DEBUGMODE = true; public static bool DEBUGMODE = false;
public static Random rand = new Random(seed); public static Random rand = new Random(seed);
public static Layer[] map; public static Layer[] map;
//Current layer the player wants to see //Current layer the player wants to see
+9 -1
View File
@@ -16,6 +16,7 @@ public partial class UIHandler : Control
[Export] Control uiContent; [Export] Control uiContent;
[Export] PanelContainer menu; [Export] PanelContainer menu;
[Export] PanelContainer inventory; [Export] PanelContainer inventory;
[Export] ResearchList researchList;
bool receivedRobotJumpSignal = false; bool receivedRobotJumpSignal = false;
public override void _Ready() public override void _Ready()
@@ -46,6 +47,7 @@ public partial class UIHandler : Control
if (Input.IsActionJustPressed("menu")) HandleMenuButton(); if (Input.IsActionJustPressed("menu")) HandleMenuButton();
if (Input.IsActionJustPressed("robot_list")) HandleRobotListButton(); if (Input.IsActionJustPressed("robot_list")) HandleRobotListButton();
if (Input.IsActionJustPressed("inventory")) HandleInventoryButton(); if (Input.IsActionJustPressed("inventory")) HandleInventoryButton();
if (Input.IsActionJustPressed("research")) HandleResearchButton();
} }
@@ -57,7 +59,7 @@ public partial class UIHandler : Control
public void HandleMapButton() public void HandleMapButton()
{ {
OpenUIElement(map); OpenUIElement(map);
map.ShowMap(); if(map.Visible) map.ShowMap();
} }
public void HandleRobotListButton() public void HandleRobotListButton()
@@ -71,6 +73,12 @@ public partial class UIHandler : Control
OpenUIElement(inventory); OpenUIElement(inventory);
} }
public void HandleResearchButton()
{
OpenUIElement(researchList);
if(researchList.Visible) researchList.SetupGraph();
}
public void DisplayStats() public void DisplayStats()
{ {
FPS.Text = Engine.GetFramesPerSecond().ToString() + " FPS"; FPS.Text = Engine.GetFramesPerSecond().ToString() + " FPS";
+2 -24
View File
@@ -7,16 +7,12 @@ public partial class ResearchList : PanelContainer
{ {
[Export] private GraphEdit researchGraph; [Export] private GraphEdit researchGraph;
private const float StartXDivisor = 32f;
private const float StartYDivisor = 4f;
private const float NodeSpacingMultiplier = 10f;
private List<string> reloadKeys = new List<string>(); private List<string> reloadKeys = new List<string>();
public override void _Ready() public override void _Ready()
{ {
RecalculateResearchStates(); RecalculateResearchStates();
SetupGraph(); if(Visible) SetupGraph();
} }
public void SetupGraph() public void SetupGraph()
@@ -25,6 +21,7 @@ public partial class ResearchList : PanelContainer
ClearGraph(); ClearGraph();
CreateResearchNodes(); CreateResearchNodes();
CreateResearchConnections(); CreateResearchConnections();
researchGraph.ArrangeNodes();
} }
private void ClearGraph() private void ClearGraph()
@@ -111,7 +108,6 @@ public partial class ResearchList : PanelContainer
{ {
Name = id, Name = id,
Title = id, Title = id,
PositionOffset = GetNodePosition(texture),
SelfModulate = stateColor SelfModulate = stateColor
}; };
@@ -131,24 +127,6 @@ public partial class ResearchList : PanelContainer
return node; return node;
} }
private Vector2 GetNodePosition(Texture2D texture)
{
Vector2 viewportSize = GetViewport().GetVisibleRect().Size;
float textureWidth = texture?.GetWidth() ?? 64f;
Vector2 startPosition = new Vector2(
viewportSize.X / StartXDivisor,
viewportSize.Y / StartYDivisor
);
float xOffset =
GameData.availableResearch.Count * -textureWidth +
researchGraph.GetChildCount() * textureWidth * NodeSpacingMultiplier;
return startPosition + new Vector2(xOffset, 0);
}
private void OnResearchPressed(string id) private void OnResearchPressed(string id)
{ {
GameData.availableResearch[id].state = ResearchState.RESEARCHED; GameData.availableResearch[id].state = ResearchState.RESEARCHED;
-1
View File
@@ -49,5 +49,4 @@ public partial class Robot : Node3D
isExecuting = true; isExecuting = true;
currentNode = nodes[0]; currentNode = nodes[0];
} }
} }
+41
View File
@@ -1,9 +1,12 @@
using Godot; using Godot;
using System; using System;
using System.Collections.Generic;
public partial class Map : PanelContainer public partial class Map : PanelContainer
{ {
[Export] GridContainer grid; [Export] GridContainer grid;
private HashSet<Tile> handledTiles = new HashSet<Tile>();
private Dictionary<Tile, TextureRect> textureMap = new Dictionary<Tile, TextureRect>();
// Called when the node enters the scene tree for the first time. // Called when the node enters the scene tree for the first time.
public override void _Ready() public override void _Ready()
{ {
@@ -76,6 +79,15 @@ public partial class Map : PanelContainer
texture.TooltipText = "Not explored"; texture.TooltipText = "Not explored";
} }
textureMap[tiles[x, z]] = texture;
if (!handledTiles.Contains(tiles[x, z]))
{
tiles[x, z].OnTileVisited += OnTileVisited;
handledTiles.Add(tiles[x, z]);
}
texture.SizeFlagsHorizontal = SizeFlags.ExpandFill; texture.SizeFlagsHorizontal = SizeFlags.ExpandFill;
texture.SizeFlagsVertical = SizeFlags.ExpandFill; texture.SizeFlagsVertical = SizeFlags.ExpandFill;
texture.StretchMode = TextureRect.StretchModeEnum.Scale; texture.StretchMode = TextureRect.StretchModeEnum.Scale;
@@ -86,6 +98,35 @@ public partial class Map : PanelContainer
} }
} }
private void OnTileVisited(object sender, EventArgs e)
{
Tile tile = sender as Tile;
if (tile == null)
return;
if (textureMap.TryGetValue(tile, out TextureRect texture))
{
UpdateMap(tile, texture);
}
}
public void UpdateMap(Tile tile, TextureRect texture)
{
if (!IsInstanceValid(texture)) return;
if (tile.containsResource)
{
texture.Texture = ResourceDistributor.resources[tile.resource.name];
texture.TooltipText = tile.resource.item.GetReadableName() + $"\r(X: {tile.GridPosition.X},Y: {GameData.currentLayer},Z: {tile.GridPosition.Y})";
}
else
{
texture.Texture = GenerateTexture(32, new Color(0, 0, 0, 0));
texture.TooltipText = "";
}
}
public Texture2D GenerateTexture(int size, Color fillColor) public Texture2D GenerateTexture(int size, Color fillColor)
{ {
+7
View File
@@ -14,6 +14,7 @@ public partial class Tile
public bool containsLight, containsDecoration, containsResource; public bool containsLight, containsDecoration, containsResource;
public GameResource resource; public GameResource resource;
public bool wasVisited; public bool wasVisited;
public event EventHandler OnTileVisited;
public void SetMeshes(Dictionary<string, MeshInstance3D> tileMeshes) public void SetMeshes(Dictionary<string, MeshInstance3D> tileMeshes)
@@ -138,4 +139,10 @@ public partial class Tile
} }
} }
} }
public void VisitTile()
{
wasVisited = true;
OnTileVisited?.Invoke(this, EventArgs.Empty);
}
} }