Added resource harvesting to DSL.
This commit is contained in:
+129
-43
@@ -8,7 +8,9 @@
|
||||
},
|
||||
"workstation": "",
|
||||
"texture": "res://Assets/Images/Resources/IronSymbol.png",
|
||||
"research": "bronzeage"
|
||||
"research": "bronzeage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "tin_ore",
|
||||
@@ -19,7 +21,9 @@
|
||||
},
|
||||
"workstation": "",
|
||||
"texture": "res://Assets/Images/Resources/TinSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "copper_ore",
|
||||
@@ -30,7 +34,9 @@
|
||||
},
|
||||
"workstation": "",
|
||||
"texture": "res://Assets/Images/Resources/CopperSymbol.png",
|
||||
"research": "stoneage"
|
||||
"research": "stoneage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "mushroom",
|
||||
@@ -41,7 +47,9 @@
|
||||
},
|
||||
"workstation": "",
|
||||
"texture": "res://Assets/Images/Resources/MushroomSymbol.png",
|
||||
"research": "basics"
|
||||
"research": "basics",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "spider_silk",
|
||||
@@ -52,7 +60,9 @@
|
||||
},
|
||||
"workstation": "",
|
||||
"texture": "res://Assets/Images/Resources/SpiderSilkSymbol.png",
|
||||
"research": "basics"
|
||||
"research": "basics",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "coal",
|
||||
@@ -63,7 +73,9 @@
|
||||
},
|
||||
"workstation": "",
|
||||
"texture": "res://Assets/Images/Resources/CoalSymbol.png",
|
||||
"research": "basics"
|
||||
"research": "basics",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "water",
|
||||
@@ -74,7 +86,9 @@
|
||||
},
|
||||
"workstation": "",
|
||||
"texture": "res://Assets/Images/Resources/WaterSymbol.png",
|
||||
"research": "basics"
|
||||
"research": "basics",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "stone",
|
||||
@@ -85,7 +99,9 @@
|
||||
},
|
||||
"workstation": "",
|
||||
"texture": "res://Assets/Images/Resources/StoneSymbol.png",
|
||||
"research": "basics"
|
||||
"research": "basics",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "sand",
|
||||
@@ -101,7 +117,9 @@
|
||||
},
|
||||
"workstation": "crusher",
|
||||
"texture": "res://Assets/Images/Items/SandSymbol.png",
|
||||
"research": "stoneage"
|
||||
"research": "stoneage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "stone_gear",
|
||||
@@ -117,7 +135,9 @@
|
||||
},
|
||||
"workstation": "workbench",
|
||||
"texture": "res://Assets/Images/Items/StoneGearSymbol.png",
|
||||
"research": "stoneage"
|
||||
"research": "stoneage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "copper_gear",
|
||||
@@ -133,7 +153,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/CopperGearSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "tin_gear",
|
||||
@@ -149,7 +171,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/TinGearSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "bronze_gear",
|
||||
@@ -165,7 +189,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/BronzeGearSymbol.png",
|
||||
"research": "bronzeage"
|
||||
"research": "bronzeage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "bronze_ingot",
|
||||
@@ -189,7 +215,9 @@
|
||||
},
|
||||
"workstation": "furnace",
|
||||
"texture": "res://Assets/Images/Items/BronzeIngotSymbol.png",
|
||||
"research": "bronzeage"
|
||||
"research": "bronzeage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "iron_gear",
|
||||
@@ -205,7 +233,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/IronGearSymbol.png",
|
||||
"research": "ironage"
|
||||
"research": "ironage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "iron_ingot",
|
||||
@@ -225,7 +255,9 @@
|
||||
},
|
||||
"workstation": "furnace",
|
||||
"texture": "res://Assets/Images/Items/IronIngotSymbol.png",
|
||||
"research": "ironage"
|
||||
"research": "ironage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "tin_ingot",
|
||||
@@ -245,7 +277,9 @@
|
||||
},
|
||||
"workstation": "furnace",
|
||||
"texture": "res://Assets/Images/Items/TinIngotSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "copper_ingot",
|
||||
@@ -265,7 +299,9 @@
|
||||
},
|
||||
"workstation": "furnace",
|
||||
"texture": "res://Assets/Images/Items/CopperIngotSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "rope",
|
||||
@@ -281,7 +317,9 @@
|
||||
},
|
||||
"workstation": "workbench",
|
||||
"texture": "res://Assets/Images/Items/RopeSymbol.png",
|
||||
"research": "stoneage"
|
||||
"research": "stoneage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "stone_robot",
|
||||
@@ -305,7 +343,9 @@
|
||||
},
|
||||
"workstation": "workbench",
|
||||
"texture": "res://Assets/Images/Items/StoneRobotSymbol.png",
|
||||
"research": "stoneage"
|
||||
"research": "stoneage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "copper_robot",
|
||||
@@ -333,7 +373,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/CopperRobotSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "tin_robot",
|
||||
@@ -361,7 +403,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/TinRobotSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "bronze_robot",
|
||||
@@ -389,7 +433,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/BronzeRobotSymbol.png",
|
||||
"research": "bronzeage"
|
||||
"research": "bronzeage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "iron_robot",
|
||||
@@ -417,7 +463,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/IronRobotSymbol.png",
|
||||
"research": "ironage"
|
||||
"research": "ironage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "glass",
|
||||
@@ -437,7 +485,9 @@
|
||||
},
|
||||
"workstation": "furnace",
|
||||
"texture": "res://Assets/Images/Items/GlassSymbol.png",
|
||||
"research": "stoneage"
|
||||
"research": "stoneage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "fabric",
|
||||
@@ -457,7 +507,9 @@
|
||||
},
|
||||
"workstation": "loom",
|
||||
"texture": "res://Assets/Images/Items/RopeSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "copper_rod",
|
||||
@@ -473,7 +525,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/CopperRodSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "tin_rod",
|
||||
@@ -489,7 +543,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/TinRodSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "bronze_rod",
|
||||
@@ -505,7 +561,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/BronzeRodSymbol.png",
|
||||
"research": "bronzeage"
|
||||
"research": "bronzeage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "iron_rod",
|
||||
@@ -521,7 +579,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/IronRodSymbol.png",
|
||||
"research": "ironage"
|
||||
"research": "ironage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "battery_v1",
|
||||
@@ -545,7 +605,9 @@
|
||||
},
|
||||
"workstation": "workbench",
|
||||
"texture": "res://Assets/Images/Items/Batteryv1Symbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "dynamo_v1",
|
||||
@@ -569,7 +631,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/Dynamov1Symbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "copper_wire",
|
||||
@@ -585,7 +649,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/CopperWireSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "heating_element_v1",
|
||||
@@ -601,7 +667,9 @@
|
||||
},
|
||||
"workstation": "workbench",
|
||||
"texture": "res://Assets/Images/Items/Heaterv1Symbol.png",
|
||||
"research": "stoneage"
|
||||
"research": "stoneage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "stone_plate",
|
||||
@@ -617,7 +685,9 @@
|
||||
},
|
||||
"workstation": "workbench",
|
||||
"texture": "res://Assets/Images/Items/StonePlateSymbol.png",
|
||||
"research": "stoneage"
|
||||
"research": "stoneage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "copper_plate",
|
||||
@@ -633,7 +703,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/CopperPlateSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "iron_plate",
|
||||
@@ -649,7 +721,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/IronPlateSymbol.png",
|
||||
"research": "ironage"
|
||||
"research": "ironage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "bronze_plate",
|
||||
@@ -665,7 +739,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/BronzePlateSymbol.png",
|
||||
"research": "bronzeage"
|
||||
"research": "bronzeage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "tin_plate",
|
||||
@@ -681,7 +757,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/TinPlateSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "battery_v2",
|
||||
@@ -705,7 +783,9 @@
|
||||
},
|
||||
"workstation": "workbench",
|
||||
"texture": "res://Assets/Images/Items/Batteryv2Symbol.png",
|
||||
"research": "ironage"
|
||||
"research": "ironage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "dynamo_v2",
|
||||
@@ -733,7 +813,9 @@
|
||||
},
|
||||
"workstation": "anvil",
|
||||
"texture": "res://Assets/Images/Items/Dynamov2Symbol.png",
|
||||
"research": "ironage"
|
||||
"research": "ironage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "steam",
|
||||
@@ -753,7 +835,9 @@
|
||||
},
|
||||
"workstation": "steam_generator_v1",
|
||||
"texture": "res://Assets/Images/Items/SteamSymbol.png",
|
||||
"research": "copperage"
|
||||
"research": "copperage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
},
|
||||
{
|
||||
"id": "glass_bottles",
|
||||
@@ -773,6 +857,8 @@
|
||||
},
|
||||
"workstation": "glassblower",
|
||||
"texture": "res://Assets/Images/Items/GlassBottleSymbol.png",
|
||||
"research": "stoneage"
|
||||
"research": "stoneage",
|
||||
"crafttime": 1.0,
|
||||
"stacksize": 99
|
||||
}
|
||||
]
|
||||
@@ -32,17 +32,6 @@ autowrap_mode = 0
|
||||
horizontal_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]
|
||||
layout_mode = 2
|
||||
text = "Harvest"
|
||||
|
||||
@@ -8,7 +8,7 @@ public class GameResource
|
||||
bool isEndless;
|
||||
float extractionSpeed;
|
||||
double timeSinceLastExtraction;
|
||||
ItemData item;
|
||||
public ItemData item;
|
||||
|
||||
public GameResource(string name)
|
||||
{
|
||||
@@ -34,4 +34,9 @@ public class GameResource
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CanExtract()
|
||||
{
|
||||
return isEndless || currentAmount > 0;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ public class Inventory
|
||||
Item inventoryItem = inventory.Find(x => x.data.Id == item.data.Id && x.currentAmount + amount <= x.data.StackSize);
|
||||
if (inventoryItem != null)
|
||||
{
|
||||
GD.Print(inventory.IndexOf(inventoryItem) + ": " + inventoryItem.currentAmount);
|
||||
inventoryItem.currentAmount += amount;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,15 +8,30 @@ public class HarvestNode : ProgramNode
|
||||
}
|
||||
public override NodeResult Execute(Robot robot, double delta)
|
||||
{
|
||||
GD.Print("Harvest");
|
||||
if (nextNode != null)
|
||||
Vector3I mapIndex = Pathfinding.GetClosestStartPoint(robot.Position);
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
@@ -4,6 +4,7 @@ using Godot;
|
||||
|
||||
public partial class GameData
|
||||
{
|
||||
public static bool DEBUGMODE = true;
|
||||
public static Random rand = new Random(seed);
|
||||
public static Layer[] map;
|
||||
//Current layer the player wants to see
|
||||
|
||||
@@ -21,12 +21,12 @@ public partial class Robot : Node3D
|
||||
switch (currentNode.Execute(this, delta))
|
||||
{
|
||||
case NodeResult.SUCCESS:
|
||||
GD.Print(currentNode.lastExecutionMessage);
|
||||
currentNode = currentNode.nextNode;
|
||||
if (currentNode == null)
|
||||
{
|
||||
isExecuting = false;
|
||||
}
|
||||
GD.Print(currentNode.lastExecutionMessage);
|
||||
break;
|
||||
case NodeResult.FAILURE:
|
||||
isExecuting = false;
|
||||
|
||||
@@ -62,7 +62,7 @@ public partial class Map : PanelContainer
|
||||
continue;
|
||||
}
|
||||
texture = new TextureRect();
|
||||
if (tiles[x, z].wasVisited)
|
||||
if (tiles[x, z].wasVisited || GameData.DEBUGMODE)
|
||||
{
|
||||
if (tiles[x, z].containsResource)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user