Finished first EA Version #1

Merged
Nicola merged 110 commits from dev into main 2026-05-19 20:01:13 +02:00
14 changed files with 184 additions and 11 deletions
Showing only changes of commit ffe1077abc - Show all commits
Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

+40
View File
@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ciehcg34et0q3"
path="res://.godot/imported/InventorySymbol.png-992c7fa6db2b090a5926e973600828c4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Images/InventorySymbol.png"
dest_files=["res://.godot/imported/InventorySymbol.png-992c7fa6db2b090a5926e973600828c4.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
Binary file not shown.
+40
View File
@@ -0,0 +1,40 @@
[gd_scene format=3 uid="uid://4by1t1x6m4yt"]
[ext_resource type="Script" uid="uid://qdjn5oqn6p5d" path="res://Scripts/Crafting/ItemDisplay.cs" id="1_if7q5"]
[node name="Item" type="PanelContainer" unique_id=247502695 node_paths=PackedStringArray("texture", "text", "amount")]
anchors_preset = 14
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_bottom = 31.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_if7q5")
texture = NodePath("HBoxContainer/TextureRect")
text = NodePath("HBoxContainer/ID")
amount = NodePath("HBoxContainer/Amount")
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=906487472]
layout_mode = 2
theme_override_constants/separation = 20
alignment = 1
[node name="TextureRect" type="TextureRect" parent="HBoxContainer" unique_id=1795632837]
layout_mode = 2
[node name="ID" type="RichTextLabel" parent="HBoxContainer" unique_id=46246913]
layout_mode = 2
text = "Robot #1"
fit_content = true
autowrap_mode = 0
horizontal_alignment = 1
vertical_alignment = 1
[node name="Amount" type="RichTextLabel" parent="HBoxContainer" unique_id=1705181895]
layout_mode = 2
text = "Robot #1"
fit_content = true
autowrap_mode = 0
horizontal_alignment = 1
vertical_alignment = 1
+13 -2
View File
@@ -11,7 +11,9 @@
[ext_resource type="Texture2D" uid="uid://deuxffyhsrinn" path="res://Assets/Images/EnergySymbol.png" id="9_71axn"] [ext_resource type="Texture2D" uid="uid://deuxffyhsrinn" path="res://Assets/Images/EnergySymbol.png" id="9_71axn"]
[ext_resource type="Texture2D" uid="uid://dje86ro2e37xl" path="res://Assets/Images/Resources/WaterSymbol.png" id="10_71axn"] [ext_resource type="Texture2D" uid="uid://dje86ro2e37xl" path="res://Assets/Images/Resources/WaterSymbol.png" id="10_71axn"]
[ext_resource type="Texture2D" uid="uid://d068gyi3e48cv" path="res://Assets/Images/MapSymbol.png" id="11_3cx6b"] [ext_resource type="Texture2D" uid="uid://d068gyi3e48cv" path="res://Assets/Images/MapSymbol.png" id="11_3cx6b"]
[ext_resource type="Script" uid="uid://com0u7nqag6pp" path="res://Scripts/Crafting/InventoryDisplay.cs" id="11_acvyw"]
[ext_resource type="Texture2D" uid="uid://ban872p4eh4gi" path="res://Assets/Images/RobotSymbol.png" id="11_dahhg"] [ext_resource type="Texture2D" uid="uid://ban872p4eh4gi" path="res://Assets/Images/RobotSymbol.png" id="11_dahhg"]
[ext_resource type="Texture2D" uid="uid://ciehcg34et0q3" path="res://Assets/Images/InventorySymbol.png" id="11_wxwew"]
[ext_resource type="Texture2D" uid="uid://b77mo4fhklnja" path="res://Assets/Images/OptionsSymbol.png" id="12_3so38"] [ext_resource type="Texture2D" uid="uid://b77mo4fhklnja" path="res://Assets/Images/OptionsSymbol.png" id="12_3so38"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_u44n3"] [sub_resource type="CompressedTexture2D" id="CompressedTexture2D_u44n3"]
@@ -62,7 +64,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")] [node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "mainCam", "map", "FPS", "RAM", "options", "uiContent", "menu", "inventory")]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@@ -83,6 +85,7 @@ RAM = NodePath("MainUI/FooterContainer/HBoxContainer/RAM")
options = NodePath("MainUI/Content/Options") 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")
[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
@@ -353,7 +356,7 @@ text = "Exit"
visible = false visible = false
layout_mode = 1 layout_mode = 1
[node name="Inventory" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=407422598] [node name="Inventory" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=407422598 node_paths=PackedStringArray("itemList")]
visible = false visible = false
layout_mode = 1 layout_mode = 1
anchors_preset = 11 anchors_preset = 11
@@ -363,6 +366,8 @@ anchor_bottom = 1.0
offset_left = -525.0 offset_left = -525.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 2 grow_vertical = 2
script = ExtResource("11_acvyw")
itemList = NodePath("VBoxContainer/ScrollContainer/VBoxContainer")
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Inventory" unique_id=1776118554] [node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Inventory" unique_id=1776118554]
layout_mode = 2 layout_mode = 2
@@ -405,6 +410,11 @@ layout_mode = 2
fit_content = true fit_content = true
autowrap_mode = 0 autowrap_mode = 0
[node name="Inventory" type="TextureButton" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=1598826377]
layout_mode = 2
tooltip_text = "Map (M)"
texture_normal = ExtResource("11_wxwew")
[node name="Map" type="TextureButton" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=1320346210] [node name="Map" type="TextureButton" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=1320346210]
layout_mode = 2 layout_mode = 2
tooltip_text = "Map (M)" tooltip_text = "Map (M)"
@@ -425,6 +435,7 @@ texture_normal = ExtResource("12_3so38")
[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/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/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/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"]
+7 -7
View File
@@ -3,25 +3,25 @@ using Godot;
public class Inventory public class Inventory
{ {
public List<Item> inventory = new(); public List<Item> items = new();
public int maxInventorySize = 8; public int maxInventorySize = 8;
public bool AddItem(Item item, int amount) public bool AddItem(Item item, int amount)
{ {
Item inventoryItem = inventory.Find(x => x.data.Id == item.data.Id && x.currentAmount + amount <= x.data.StackSize); Item inventoryItem = items.Find(x => x.data.Id == item.data.Id && x.currentAmount + amount <= x.data.StackSize);
if (inventoryItem != null) if (inventoryItem != null)
{ {
GD.Print(inventory.IndexOf(inventoryItem) + ": " + inventoryItem.currentAmount); GD.Print(items.IndexOf(inventoryItem) + ": " + inventoryItem.currentAmount);
inventoryItem.currentAmount += amount; inventoryItem.currentAmount += amount;
return true; return true;
} }
else else
{ {
if (inventory.Count < maxInventorySize) if (items.Count < maxInventorySize)
{ {
inventory.Add(item); items.Add(item);
inventory[inventory.Count - 1].currentAmount += amount; items[items.Count - 1].currentAmount += amount;
return true; return true;
} }
} }
@@ -34,7 +34,7 @@ public class Inventory
Item item; Item item;
foreach(Ingredient ingredient in neededIngredients) foreach(Ingredient ingredient in neededIngredients)
{ {
item = inventory.Find(x => x.data.Id == ingredient.item && x.currentAmount >= ingredient.amount * amount); item = items.Find(x => x.data.Id == ingredient.item && x.currentAmount >= ingredient.amount * amount);
if (item == null) if (item == null)
{ {
canCraft = false; canCraft = false;
+35
View File
@@ -0,0 +1,35 @@
using Godot;
public partial class InventoryDisplay : PanelContainer
{
PackedScene itemDisplayPrefab = ResourceLoader.LoadItemDisplay();
[Export] VBoxContainer itemList;
public override void _Notification(int id)
{
if (id == NotificationVisibilityChanged)
{
if (Visible) ReloadItems();
}
}
public void ReloadItems()
{
foreach (Node node in itemList.GetChildren())
{
itemList.RemoveChild(node);
node.QueueFree();
}
ItemDisplay display;
foreach (Item item in GameData.inventory.items)
{
display = itemDisplayPrefab.Instantiate<ItemDisplay>();
display.item = item;
display.text.Text = item.GetReadableName();
display.amount.Text = item.currentAmount.ToString();
display.texture.Texture = ResourceLoader.LoadPath(item.data.Texture);
itemList.AddChild(display);
}
}
}
+1
View File
@@ -0,0 +1 @@
uid://com0u7nqag6pp
+6 -1
View File
@@ -8,7 +8,6 @@ public class Item
public int currentAmount = 0; public int currentAmount = 0;
public double elapsedCraftTime = 0; public double elapsedCraftTime = 0;
public int amountCrafted = 0; public int amountCrafted = 0;
public Texture2D display;
public CraftingResult Craft(int amount, double delta) public CraftingResult Craft(int amount, double delta)
{ {
@@ -31,5 +30,11 @@ public class Item
} }
return CraftingResult.FAILED; return CraftingResult.FAILED;
} }
public string GetReadableName()
{
string noUnderscore = data.Id.Replace("_", " ").ToLower();
return char.ToUpper(noUnderscore[0]) + noUnderscore.Substring(1);
}
} }
+19
View File
@@ -0,0 +1,19 @@
using Godot;
using System;
public partial class ItemDisplay : PanelContainer
{
[Export] public TextureRect texture;
[Export] public RichTextLabel text;
[Export] public RichTextLabel amount;
public Item item;
// 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)
{
}
}
+1
View File
@@ -0,0 +1 @@
uid://qdjn5oqn6p5d
+10
View File
@@ -21,6 +21,16 @@ public partial class ResourceLoader
return GD.Load<PackedScene>($"res://Prefabs/Robot/RobotDisplay.tscn"); return GD.Load<PackedScene>($"res://Prefabs/Robot/RobotDisplay.tscn");
} }
public static PackedScene LoadItemDisplay()
{
return GD.Load<PackedScene>($"res://Prefabs/Crafting/ItemDisplay.tscn");
}
public static Texture2D LoadPath(string path)
{
return GD.Load<Texture2D>(path);
}
public static Dictionary<string, MeshInstance3D> LoadTiles() public static Dictionary<string, MeshInstance3D> LoadTiles()
{ {
Dictionary<string, MeshInstance3D> tileMeshes = new Dictionary<string, MeshInstance3D>(); Dictionary<string, MeshInstance3D> tileMeshes = new Dictionary<string, MeshInstance3D>();
+7 -1
View File
@@ -15,6 +15,7 @@ public partial class UIHandler : Control
[Export] PanelContainer options; [Export] PanelContainer options;
[Export] Control uiContent; [Export] Control uiContent;
[Export] PanelContainer menu; [Export] PanelContainer menu;
[Export] PanelContainer inventory;
bool receivedRobotJumpSignal = false; bool receivedRobotJumpSignal = false;
public override void _Ready() public override void _Ready()
@@ -37,6 +38,7 @@ public partial class UIHandler : Control
if (Input.IsActionJustPressed("map")) HandleMapButton(); if (Input.IsActionJustPressed("map")) HandleMapButton();
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();
DisplayStats(); DisplayStats();
} }
@@ -56,6 +58,11 @@ public partial class UIHandler : Control
OpenUIElement(robotList); OpenUIElement(robotList);
} }
public void HandleInventoryButton()
{
OpenUIElement(inventory);
}
public void DisplayStats() public void DisplayStats()
{ {
FPS.Text = Engine.GetFramesPerSecond().ToString() + " FPS"; FPS.Text = Engine.GetFramesPerSecond().ToString() + " FPS";
@@ -86,7 +93,6 @@ public partial class UIHandler : Control
{ {
foreach (PanelContainer child in uiContent.GetChildren()) foreach (PanelContainer child in uiContent.GetChildren())
{ {
GD.Print(child == element);
if (child == element) continue; if (child == element) continue;
child.Visible = false; child.Visible = false;
} }
+5
View File
@@ -87,6 +87,11 @@ menu={
"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) "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)
] ]
} }
inventory={
"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":73,"key_label":0,"unicode":105,"location":0,"echo":false,"script":null)
]
}
[layer_names] [layer_names]