Added resource harvesting to DSL.

This commit is contained in:
=
2026-05-05 19:45:50 +02:00
parent a320a86a2f
commit 5882f3865d
8 changed files with 158 additions and 61 deletions
+129 -43
View File
@@ -8,7 +8,9 @@
}, },
"workstation": "", "workstation": "",
"texture": "res://Assets/Images/Resources/IronSymbol.png", "texture": "res://Assets/Images/Resources/IronSymbol.png",
"research": "bronzeage" "research": "bronzeage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "tin_ore", "id": "tin_ore",
@@ -19,7 +21,9 @@
}, },
"workstation": "", "workstation": "",
"texture": "res://Assets/Images/Resources/TinSymbol.png", "texture": "res://Assets/Images/Resources/TinSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "copper_ore", "id": "copper_ore",
@@ -30,7 +34,9 @@
}, },
"workstation": "", "workstation": "",
"texture": "res://Assets/Images/Resources/CopperSymbol.png", "texture": "res://Assets/Images/Resources/CopperSymbol.png",
"research": "stoneage" "research": "stoneage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "mushroom", "id": "mushroom",
@@ -41,7 +47,9 @@
}, },
"workstation": "", "workstation": "",
"texture": "res://Assets/Images/Resources/MushroomSymbol.png", "texture": "res://Assets/Images/Resources/MushroomSymbol.png",
"research": "basics" "research": "basics",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "spider_silk", "id": "spider_silk",
@@ -52,7 +60,9 @@
}, },
"workstation": "", "workstation": "",
"texture": "res://Assets/Images/Resources/SpiderSilkSymbol.png", "texture": "res://Assets/Images/Resources/SpiderSilkSymbol.png",
"research": "basics" "research": "basics",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "coal", "id": "coal",
@@ -63,7 +73,9 @@
}, },
"workstation": "", "workstation": "",
"texture": "res://Assets/Images/Resources/CoalSymbol.png", "texture": "res://Assets/Images/Resources/CoalSymbol.png",
"research": "basics" "research": "basics",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "water", "id": "water",
@@ -74,7 +86,9 @@
}, },
"workstation": "", "workstation": "",
"texture": "res://Assets/Images/Resources/WaterSymbol.png", "texture": "res://Assets/Images/Resources/WaterSymbol.png",
"research": "basics" "research": "basics",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "stone", "id": "stone",
@@ -85,7 +99,9 @@
}, },
"workstation": "", "workstation": "",
"texture": "res://Assets/Images/Resources/StoneSymbol.png", "texture": "res://Assets/Images/Resources/StoneSymbol.png",
"research": "basics" "research": "basics",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "sand", "id": "sand",
@@ -101,7 +117,9 @@
}, },
"workstation": "crusher", "workstation": "crusher",
"texture": "res://Assets/Images/Items/SandSymbol.png", "texture": "res://Assets/Images/Items/SandSymbol.png",
"research": "stoneage" "research": "stoneage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "stone_gear", "id": "stone_gear",
@@ -117,7 +135,9 @@
}, },
"workstation": "workbench", "workstation": "workbench",
"texture": "res://Assets/Images/Items/StoneGearSymbol.png", "texture": "res://Assets/Images/Items/StoneGearSymbol.png",
"research": "stoneage" "research": "stoneage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "copper_gear", "id": "copper_gear",
@@ -133,7 +153,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/CopperGearSymbol.png", "texture": "res://Assets/Images/Items/CopperGearSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "tin_gear", "id": "tin_gear",
@@ -149,7 +171,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/TinGearSymbol.png", "texture": "res://Assets/Images/Items/TinGearSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "bronze_gear", "id": "bronze_gear",
@@ -165,7 +189,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/BronzeGearSymbol.png", "texture": "res://Assets/Images/Items/BronzeGearSymbol.png",
"research": "bronzeage" "research": "bronzeage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "bronze_ingot", "id": "bronze_ingot",
@@ -189,7 +215,9 @@
}, },
"workstation": "furnace", "workstation": "furnace",
"texture": "res://Assets/Images/Items/BronzeIngotSymbol.png", "texture": "res://Assets/Images/Items/BronzeIngotSymbol.png",
"research": "bronzeage" "research": "bronzeage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "iron_gear", "id": "iron_gear",
@@ -205,7 +233,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/IronGearSymbol.png", "texture": "res://Assets/Images/Items/IronGearSymbol.png",
"research": "ironage" "research": "ironage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "iron_ingot", "id": "iron_ingot",
@@ -225,7 +255,9 @@
}, },
"workstation": "furnace", "workstation": "furnace",
"texture": "res://Assets/Images/Items/IronIngotSymbol.png", "texture": "res://Assets/Images/Items/IronIngotSymbol.png",
"research": "ironage" "research": "ironage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "tin_ingot", "id": "tin_ingot",
@@ -245,7 +277,9 @@
}, },
"workstation": "furnace", "workstation": "furnace",
"texture": "res://Assets/Images/Items/TinIngotSymbol.png", "texture": "res://Assets/Images/Items/TinIngotSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "copper_ingot", "id": "copper_ingot",
@@ -265,7 +299,9 @@
}, },
"workstation": "furnace", "workstation": "furnace",
"texture": "res://Assets/Images/Items/CopperIngotSymbol.png", "texture": "res://Assets/Images/Items/CopperIngotSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "rope", "id": "rope",
@@ -281,7 +317,9 @@
}, },
"workstation": "workbench", "workstation": "workbench",
"texture": "res://Assets/Images/Items/RopeSymbol.png", "texture": "res://Assets/Images/Items/RopeSymbol.png",
"research": "stoneage" "research": "stoneage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "stone_robot", "id": "stone_robot",
@@ -305,7 +343,9 @@
}, },
"workstation": "workbench", "workstation": "workbench",
"texture": "res://Assets/Images/Items/StoneRobotSymbol.png", "texture": "res://Assets/Images/Items/StoneRobotSymbol.png",
"research": "stoneage" "research": "stoneage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "copper_robot", "id": "copper_robot",
@@ -333,7 +373,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/CopperRobotSymbol.png", "texture": "res://Assets/Images/Items/CopperRobotSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "tin_robot", "id": "tin_robot",
@@ -361,7 +403,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/TinRobotSymbol.png", "texture": "res://Assets/Images/Items/TinRobotSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "bronze_robot", "id": "bronze_robot",
@@ -389,7 +433,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/BronzeRobotSymbol.png", "texture": "res://Assets/Images/Items/BronzeRobotSymbol.png",
"research": "bronzeage" "research": "bronzeage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "iron_robot", "id": "iron_robot",
@@ -417,7 +463,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/IronRobotSymbol.png", "texture": "res://Assets/Images/Items/IronRobotSymbol.png",
"research": "ironage" "research": "ironage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "glass", "id": "glass",
@@ -437,7 +485,9 @@
}, },
"workstation": "furnace", "workstation": "furnace",
"texture": "res://Assets/Images/Items/GlassSymbol.png", "texture": "res://Assets/Images/Items/GlassSymbol.png",
"research": "stoneage" "research": "stoneage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "fabric", "id": "fabric",
@@ -457,7 +507,9 @@
}, },
"workstation": "loom", "workstation": "loom",
"texture": "res://Assets/Images/Items/RopeSymbol.png", "texture": "res://Assets/Images/Items/RopeSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "copper_rod", "id": "copper_rod",
@@ -473,7 +525,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/CopperRodSymbol.png", "texture": "res://Assets/Images/Items/CopperRodSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "tin_rod", "id": "tin_rod",
@@ -489,7 +543,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/TinRodSymbol.png", "texture": "res://Assets/Images/Items/TinRodSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "bronze_rod", "id": "bronze_rod",
@@ -505,7 +561,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/BronzeRodSymbol.png", "texture": "res://Assets/Images/Items/BronzeRodSymbol.png",
"research": "bronzeage" "research": "bronzeage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "iron_rod", "id": "iron_rod",
@@ -521,7 +579,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/IronRodSymbol.png", "texture": "res://Assets/Images/Items/IronRodSymbol.png",
"research": "ironage" "research": "ironage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "battery_v1", "id": "battery_v1",
@@ -545,7 +605,9 @@
}, },
"workstation": "workbench", "workstation": "workbench",
"texture": "res://Assets/Images/Items/Batteryv1Symbol.png", "texture": "res://Assets/Images/Items/Batteryv1Symbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "dynamo_v1", "id": "dynamo_v1",
@@ -569,7 +631,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/Dynamov1Symbol.png", "texture": "res://Assets/Images/Items/Dynamov1Symbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "copper_wire", "id": "copper_wire",
@@ -585,7 +649,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/CopperWireSymbol.png", "texture": "res://Assets/Images/Items/CopperWireSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "heating_element_v1", "id": "heating_element_v1",
@@ -601,7 +667,9 @@
}, },
"workstation": "workbench", "workstation": "workbench",
"texture": "res://Assets/Images/Items/Heaterv1Symbol.png", "texture": "res://Assets/Images/Items/Heaterv1Symbol.png",
"research": "stoneage" "research": "stoneage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "stone_plate", "id": "stone_plate",
@@ -617,7 +685,9 @@
}, },
"workstation": "workbench", "workstation": "workbench",
"texture": "res://Assets/Images/Items/StonePlateSymbol.png", "texture": "res://Assets/Images/Items/StonePlateSymbol.png",
"research": "stoneage" "research": "stoneage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "copper_plate", "id": "copper_plate",
@@ -633,7 +703,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/CopperPlateSymbol.png", "texture": "res://Assets/Images/Items/CopperPlateSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "iron_plate", "id": "iron_plate",
@@ -649,7 +721,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/IronPlateSymbol.png", "texture": "res://Assets/Images/Items/IronPlateSymbol.png",
"research": "ironage" "research": "ironage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "bronze_plate", "id": "bronze_plate",
@@ -665,7 +739,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/BronzePlateSymbol.png", "texture": "res://Assets/Images/Items/BronzePlateSymbol.png",
"research": "bronzeage" "research": "bronzeage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "tin_plate", "id": "tin_plate",
@@ -681,7 +757,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/TinPlateSymbol.png", "texture": "res://Assets/Images/Items/TinPlateSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "battery_v2", "id": "battery_v2",
@@ -705,7 +783,9 @@
}, },
"workstation": "workbench", "workstation": "workbench",
"texture": "res://Assets/Images/Items/Batteryv2Symbol.png", "texture": "res://Assets/Images/Items/Batteryv2Symbol.png",
"research": "ironage" "research": "ironage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "dynamo_v2", "id": "dynamo_v2",
@@ -733,7 +813,9 @@
}, },
"workstation": "anvil", "workstation": "anvil",
"texture": "res://Assets/Images/Items/Dynamov2Symbol.png", "texture": "res://Assets/Images/Items/Dynamov2Symbol.png",
"research": "ironage" "research": "ironage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "steam", "id": "steam",
@@ -753,7 +835,9 @@
}, },
"workstation": "steam_generator_v1", "workstation": "steam_generator_v1",
"texture": "res://Assets/Images/Items/SteamSymbol.png", "texture": "res://Assets/Images/Items/SteamSymbol.png",
"research": "copperage" "research": "copperage",
"crafttime": 1.0,
"stacksize": 99
}, },
{ {
"id": "glass_bottles", "id": "glass_bottles",
@@ -773,6 +857,8 @@
}, },
"workstation": "glassblower", "workstation": "glassblower",
"texture": "res://Assets/Images/Items/GlassBottleSymbol.png", "texture": "res://Assets/Images/Items/GlassBottleSymbol.png",
"research": "stoneage" "research": "stoneage",
"crafttime": 1.0,
"stacksize": 99
} }
] ]
-11
View File
@@ -32,17 +32,6 @@ autowrap_mode = 0
horizontal_alignment = 1 horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
[node name="Item" type="OptionButton" parent="EditorDisplay/HBoxContainer" unique_id=912931137]
layout_mode = 2
size_flags_horizontal = 3
[node name="Amount" type="SpinBox" parent="EditorDisplay/HBoxContainer" unique_id=1234084123]
layout_mode = 2
size_flags_horizontal = 3
rounded = true
alignment = 1
prefix = "x"
[node name="ListDisplay" type="Button" parent="." unique_id=884865258] [node name="ListDisplay" type="Button" parent="." unique_id=884865258]
layout_mode = 2 layout_mode = 2
text = "Harvest" text = "Harvest"
+6 -1
View File
@@ -8,7 +8,7 @@ public class GameResource
bool isEndless; bool isEndless;
float extractionSpeed; float extractionSpeed;
double timeSinceLastExtraction; double timeSinceLastExtraction;
ItemData item; public ItemData item;
public GameResource(string name) public GameResource(string name)
{ {
@@ -34,4 +34,9 @@ public class GameResource
} }
return false; return false;
} }
public bool CanExtract()
{
return isEndless || currentAmount > 0;
}
} }
+1
View File
@@ -12,6 +12,7 @@ public class Inventory
Item inventoryItem = inventory.Find(x => x.data.Id == item.data.Id && x.currentAmount + amount <= x.data.StackSize); Item inventoryItem = inventory.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);
inventoryItem.currentAmount += amount; inventoryItem.currentAmount += amount;
return true; return true;
} }
+19 -4
View File
@@ -8,15 +8,30 @@ public class HarvestNode : ProgramNode
} }
public override NodeResult Execute(Robot robot, double delta) public override NodeResult Execute(Robot robot, double delta)
{ {
GD.Print("Harvest"); Vector3I mapIndex = Pathfinding.GetClosestStartPoint(robot.Position);
if (nextNode != null) Tile tile = GameData.map[mapIndex.Y].tiles[mapIndex.X, mapIndex.Z];
if (!tile.containsResource)
{ {
return nextNode.Execute(robot, delta); lastExecutionMessage = "No resource on this tile";
return NodeResult.FAILURE;
} }
else
if (!tile.resource.CanExtract())
{ {
lastExecutionMessage = "Resource is depleted and not endless";
return NodeResult.SUCCESS; return NodeResult.SUCCESS;
} }
if (tile.resource.Extract(delta))
{
if (!GameData.inventory.AddItem(new Item {data = tile.resource.item}, 1))
{
lastExecutionMessage = "Not enough space";
return NodeResult.FAILURE;
}
}
return NodeResult.RUNNING;
} }
public override void ReadParameters(NodeDisplay display) public override void ReadParameters(NodeDisplay display)
+1
View File
@@ -4,6 +4,7 @@ using Godot;
public partial class GameData public partial class GameData
{ {
public static bool DEBUGMODE = true;
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
+1 -1
View File
@@ -21,12 +21,12 @@ public partial class Robot : Node3D
switch (currentNode.Execute(this, delta)) switch (currentNode.Execute(this, delta))
{ {
case NodeResult.SUCCESS: case NodeResult.SUCCESS:
GD.Print(currentNode.lastExecutionMessage);
currentNode = currentNode.nextNode; currentNode = currentNode.nextNode;
if (currentNode == null) if (currentNode == null)
{ {
isExecuting = false; isExecuting = false;
} }
GD.Print(currentNode.lastExecutionMessage);
break; break;
case NodeResult.FAILURE: case NodeResult.FAILURE:
isExecuting = false; isExecuting = false;
+1 -1
View File
@@ -62,7 +62,7 @@ public partial class Map : PanelContainer
continue; continue;
} }
texture = new TextureRect(); texture = new TextureRect();
if (tiles[x, z].wasVisited) if (tiles[x, z].wasVisited || GameData.DEBUGMODE)
{ {
if (tiles[x, z].containsResource) if (tiles[x, z].containsResource)
{ {