Finished first EA Version #1

Merged
Nicola merged 110 commits from dev into main 2026-05-19 20:01:13 +02:00
9 changed files with 248 additions and 135 deletions
Showing only changes of commit a320a86a2f - Show all commits
+155 -78
View File
@@ -1,9 +1,97 @@
[
{
"id": "iron_ore",
"inputs": [],
"output": {
"item": "iron_ore",
"amount": 1
},
"workstation": "",
"texture": "res://Assets/Images/Resources/IronSymbol.png",
"research": "bronzeage"
},
{
"id": "tin_ore",
"inputs": [],
"output": {
"item": "tin_ore",
"amount": 1
},
"workstation": "",
"texture": "res://Assets/Images/Resources/TinSymbol.png",
"research": "copperage"
},
{
"id": "copper_ore",
"inputs": [],
"output": {
"item": "copper_ore",
"amount": 1
},
"workstation": "",
"texture": "res://Assets/Images/Resources/CopperSymbol.png",
"research": "stoneage"
},
{
"id": "mushroom",
"inputs": [],
"output": {
"item": "mushroom",
"amount": 1
},
"workstation": "",
"texture": "res://Assets/Images/Resources/MushroomSymbol.png",
"research": "basics"
},
{
"id": "spider_silk",
"inputs": [],
"output": {
"item": "spider_silk",
"amount": 1
},
"workstation": "",
"texture": "res://Assets/Images/Resources/SpiderSilkSymbol.png",
"research": "basics"
},
{
"id": "coal",
"inputs": [],
"output": {
"item": "coal",
"amount": 1
},
"workstation": "",
"texture": "res://Assets/Images/Resources/CoalSymbol.png",
"research": "basics"
},
{
"id": "water",
"inputs": [],
"output": {
"item": "water",
"amount": 1
},
"workstation": "",
"texture": "res://Assets/Images/Resources/WaterSymbol.png",
"research": "basics"
},
{
"id": "stone",
"inputs": [],
"output": {
"item": "stone",
"amount": 1
},
"workstation": "",
"texture": "res://Assets/Images/Resources/StoneSymbol.png",
"research": "basics"
},
{
"id": "sand",
"inputs": [
{
"ingredient": "stone",
"item": "stone",
"amount": 1
}
],
@@ -19,7 +107,7 @@
"id": "stone_gear",
"inputs": [
{
"ingredient": "stone",
"item": "stone",
"amount": 1
}
],
@@ -35,7 +123,7 @@
"id": "copper_gear",
"inputs": [
{
"ingredient": "copper_ingot",
"item": "copper_ingot",
"amount": 1
}
],
@@ -51,7 +139,7 @@
"id": "tin_gear",
"inputs": [
{
"ingredient": "tin_ingot",
"item": "tin_ingot",
"amount": 1
}
],
@@ -67,7 +155,7 @@
"id": "bronze_gear",
"inputs": [
{
"ingredient": "bronze_ingot",
"item": "bronze_ingot",
"amount": 1
}
],
@@ -83,15 +171,15 @@
"id": "bronze_ingot",
"inputs": [
{
"ingredient": "tin_ingot",
"item": "tin_ingot",
"amount": 1
},
{
"ingredient": "copper_ingot",
"item": "copper_ingot",
"amount": 1
},
{
"ingredient": "coal",
"item": "coal",
"amount": 1
}
],
@@ -107,7 +195,7 @@
"id": "iron_gear",
"inputs": [
{
"ingredient": "iron_ingot",
"item": "iron_ingot",
"amount": 1
}
],
@@ -123,11 +211,11 @@
"id": "iron_ingot",
"inputs": [
{
"ingredient": "iron_ore",
"item": "iron_ore",
"amount": 1
},
{
"ingredient": "coal",
"item": "coal",
"amount": 1
}
],
@@ -143,11 +231,11 @@
"id": "tin_ingot",
"inputs": [
{
"ingredient": "tin_ore",
"item": "tin_ore",
"amount": 1
},
{
"ingredient": "coal",
"item": "coal",
"amount": 1
}
],
@@ -163,11 +251,11 @@
"id": "copper_ingot",
"inputs": [
{
"ingredient": "copper_ore",
"item": "copper_ore",
"amount": 1
},
{
"ingredient": "coal",
"item": "coal",
"amount": 1
}
],
@@ -183,7 +271,7 @@
"id": "rope",
"inputs": [
{
"ingredient": "spider_silk",
"item": "spider_silk",
"amount": 1
}
],
@@ -195,30 +283,19 @@
"texture": "res://Assets/Images/Items/RopeSymbol.png",
"research": "stoneage"
},
{
"id": "spider_silk",
"inputs": [],
"output": {
"item": "spider_silk",
"amount": 1
},
"workstation": "",
"texture": "res://Assets/Images/Items/RopeSymbol.png",
"research": "basics"
},
{
"id": "stone_robot",
"inputs": [
{
"ingredient": "stone",
"item": "stone",
"amount": 1
},
{
"ingredient": "rope",
"item": "rope",
"amount": 1
},
{
"ingredient": "stone_gear",
"item": "stone_gear",
"amount": 1
}
],
@@ -234,19 +311,19 @@
"id": "copper_robot",
"inputs": [
{
"ingredient": "copper_plate",
"item": "copper_plate",
"amount": 1
},
{
"ingredient": "rope",
"item": "rope",
"amount": 1
},
{
"ingredient": "copper_gear",
"item": "copper_gear",
"amount": 1
},
{
"ingredient": "battery_v1",
"item": "battery_v1",
"amount": 1
}
],
@@ -262,19 +339,19 @@
"id": "tin_robot",
"inputs": [
{
"ingredient": "tin_plate",
"item": "tin_plate",
"amount": 1
},
{
"ingredient": "rope",
"item": "rope",
"amount": 1
},
{
"ingredient": "tin_gear",
"item": "tin_gear",
"amount": 1
},
{
"ingredient": "battery_v1",
"item": "battery_v1",
"amount": 1
}
],
@@ -290,19 +367,19 @@
"id": "bronze_robot",
"inputs": [
{
"ingredient": "bronze_plate",
"item": "bronze_plate",
"amount": 1
},
{
"ingredient": "rope",
"item": "rope",
"amount": 1
},
{
"ingredient": "bronze_gear",
"item": "bronze_gear",
"amount": 1
},
{
"ingredient": "battery_v1",
"item": "battery_v1",
"amount": 1
}
],
@@ -318,19 +395,19 @@
"id": "iron_robot",
"inputs": [
{
"ingredient": "iron_plate",
"item": "iron_plate",
"amount": 1
},
{
"ingredient": "rope",
"item": "rope",
"amount": 1
},
{
"ingredient": "iron_gear",
"item": "iron_gear",
"amount": 1
},
{
"ingredient": "battery_v2",
"item": "battery_v2",
"amount": 1
}
],
@@ -346,11 +423,11 @@
"id": "glass",
"inputs": [
{
"ingredient": "sand",
"item": "sand",
"amount": 1
},
{
"ingredient": "coal",
"item": "coal",
"amount": 1
}
],
@@ -366,11 +443,11 @@
"id": "fabric",
"inputs": [
{
"ingredient": "rope",
"item": "rope",
"amount": 1
},
{
"ingredient": "spider_silk",
"item": "spider_silk",
"amount": 1
}
],
@@ -386,7 +463,7 @@
"id": "copper_rod",
"inputs": [
{
"ingredient": "copper_ingot",
"item": "copper_ingot",
"amount": 1
}
],
@@ -402,7 +479,7 @@
"id": "tin_rod",
"inputs": [
{
"ingredient": "tin_ingot",
"item": "tin_ingot",
"amount": 1
}
],
@@ -418,7 +495,7 @@
"id": "bronze_rod",
"inputs": [
{
"ingredient": "bronze_ingot",
"item": "bronze_ingot",
"amount": 1
}
],
@@ -434,7 +511,7 @@
"id": "iron_rod",
"inputs": [
{
"ingredient": "iron_ingot",
"item": "iron_ingot",
"amount": 1
}
],
@@ -450,15 +527,15 @@
"id": "battery_v1",
"inputs": [
{
"ingredient": "copper_rod",
"item": "copper_rod",
"amount": 1
},
{
"ingredient": "tin_rod",
"item": "tin_rod",
"amount": 1
},
{
"ingredient": "water",
"item": "water",
"amount": 1
}
],
@@ -474,15 +551,15 @@
"id": "dynamo_v1",
"inputs": [
{
"ingredient": "battery_v1",
"item": "battery_v1",
"amount": 1
},
{
"ingredient": "tin_rod",
"item": "tin_rod",
"amount": 1
},
{
"ingredient": "copper_wire",
"item": "copper_wire",
"amount": 1
}
],
@@ -498,7 +575,7 @@
"id": "copper_wire",
"inputs": [
{
"ingredient": "copper_ingot",
"item": "copper_ingot",
"amount": 1
}
],
@@ -514,7 +591,7 @@
"id": "heating_element_v1",
"inputs": [
{
"ingredient": "stone",
"item": "stone",
"amount": 1
}
],
@@ -530,7 +607,7 @@
"id": "stone_plate",
"inputs": [
{
"ingredient": "stone",
"item": "stone",
"amount": 1
}
],
@@ -546,7 +623,7 @@
"id": "copper_plate",
"inputs": [
{
"ingredient": "copper_ingot",
"item": "copper_ingot",
"amount": 1
}
],
@@ -562,7 +639,7 @@
"id": "iron_plate",
"inputs": [
{
"ingredient": "iron_ingot",
"item": "iron_ingot",
"amount": 1
}
],
@@ -578,7 +655,7 @@
"id": "bronze_plate",
"inputs": [
{
"ingredient": "bronze_ingot",
"item": "bronze_ingot",
"amount": 1
}
],
@@ -594,7 +671,7 @@
"id": "tin_plate",
"inputs": [
{
"ingredient": "tin_ingot",
"item": "tin_ingot",
"amount": 1
}
],
@@ -610,15 +687,15 @@
"id": "battery_v2",
"inputs": [
{
"ingredient": "iron_rod",
"item": "iron_rod",
"amount": 1
},
{
"ingredient": "copper_rod",
"item": "copper_rod",
"amount": 1
},
{
"ingredient": "water",
"item": "water",
"amount": 1
}
],
@@ -634,19 +711,19 @@
"id": "dynamo_v2",
"inputs": [
{
"ingredient": "battery_v2",
"item": "battery_v2",
"amount": 1
},
{
"ingredient": "iron_rod",
"item": "iron_rod",
"amount": 1
},
{
"ingredient": "copper_wire",
"item": "copper_wire",
"amount": 1
},
{
"ingredient": "tin_plate",
"item": "tin_plate",
"amount": 1
}
],
@@ -662,11 +739,11 @@
"id": "steam",
"inputs": [
{
"ingredient": "water",
"item": "water",
"amount": 1
},
{
"ingredient": "coal",
"item": "coal",
"amount": 1
}
],
@@ -682,11 +759,11 @@
"id": "glass_bottles",
"inputs": [
{
"ingredient": "glass",
"item": "glass",
"amount": 1
},
{
"ingredient": "coal",
"item": "coal",
"amount": 1
}
],
+6 -1
View File
@@ -1,11 +1,14 @@
using Godot;
public class GameResource : Ingredient
public class GameResource
{
public string name;
int currentAmount;
int maxAmount;
bool isEndless;
float extractionSpeed;
double timeSinceLastExtraction;
ItemData item;
public GameResource(string name)
{
@@ -14,6 +17,7 @@ public class GameResource : Ingredient
currentAmount = maxAmount;
isEndless = false;
extractionSpeed = 1f;
item = GameData.availableItems[name];
}
public bool Extract(double delta)
@@ -25,6 +29,7 @@ public class GameResource : Ingredient
if (currentAmount > 0)
{
currentAmount--;
return true;
}
return false;
+3 -4
View File
@@ -1,8 +1,7 @@
using Godot;
public abstract class Ingredient
public class Ingredient
{
public string name;
public int currentAmount;
public int stackSize;
public string item;
public int amount;
}
+11 -11
View File
@@ -3,23 +3,23 @@ using Godot;
public class Inventory
{
public List<Ingredient> inventory = new();
public List<Item> inventory = new();
public int maxInventorySize = 8;
public bool AddIngredient(Ingredient ingredient, int amount)
public bool AddItem(Item item, int amount)
{
Ingredient ing = inventory.Find(x => x.name == ingredient.name && x.currentAmount + amount <= x.stackSize);
if (ing != null)
Item inventoryItem = inventory.Find(x => x.data.Id == item.data.Id && x.currentAmount + amount <= x.data.StackSize);
if (inventoryItem != null)
{
ing.currentAmount += amount;
inventoryItem.currentAmount += amount;
return true;
}
else
{
if (inventory.Count < maxInventorySize)
{
inventory.Add(ingredient);
inventory.Add(item);
inventory[inventory.Count - 1].currentAmount += amount;
return true;
}
@@ -27,14 +27,14 @@ public class Inventory
return false;
}
public bool CanCraft(Dictionary<Ingredient, int> neededIngredients, int amount)
public bool CanCraft(List<Ingredient> neededIngredients, int amount)
{
bool canCraft = true;
Ingredient ingredient;
foreach(Ingredient key in neededIngredients.Keys)
Item item;
foreach(Ingredient ingredient in neededIngredients)
{
ingredient = inventory.Find(x => x.name == key.name && x.currentAmount >= neededIngredients[key] * amount);
if (ingredient == null)
item = inventory.Find(x => x.data.Id == ingredient.item && x.currentAmount >= ingredient.amount * amount);
if (item == null)
{
canCraft = false;
break;
+11 -19
View File
@@ -1,32 +1,23 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Godot;
public class Item : Ingredient
public class Item
{
public Dictionary<Ingredient, int> ingredients;
public double craftTime;
public double elapsedCraftTime;
public int amountCrafted;
public Item(string name, Dictionary<Ingredient, int> ingredients, int stackSize, double craftTime)
{
this.name = name;
this.ingredients = ingredients;
currentAmount = 0;
this.stackSize = stackSize;
this.craftTime = craftTime;
amountCrafted = 0;
}
public ItemData data;
public int currentAmount = 0;
public double elapsedCraftTime = 0;
public int amountCrafted = 0;
public Texture2D display;
public CraftingResult Craft(int amount, double delta)
{
if (GameData.inventory.CanCraft(ingredients, amount-amountCrafted))
if (GameData.inventory.CanCraft(data.Inputs, amount - amountCrafted))
{
elapsedCraftTime += delta;
if (elapsedCraftTime >= craftTime)
if (elapsedCraftTime >= data.CraftTime)
{
elapsedCraftTime -= craftTime;
elapsedCraftTime -= data.CraftTime;
currentAmount += 1;
amountCrafted++;
if (amountCrafted >= amount)
@@ -41,3 +32,4 @@ public class Item : Ingredient
return CraftingResult.FAILED;
}
}
+30
View File
@@ -0,0 +1,30 @@
using Godot;
using System.Collections.Generic;
using System.Text.Json.Serialization;
public class ItemData
{
[JsonPropertyName("id")]
public string Id { get; set; }
[JsonPropertyName("inputs")]
public List<Ingredient> Inputs { get; set; }
[JsonPropertyName("output")]
public Ingredient Output { get; set; }
[JsonPropertyName("workstation")]
public string Workstation { get; set; }
[JsonPropertyName("texture")]
public string Texture { get; set; }
[JsonPropertyName("research")]
public string Research { get; set; }
[JsonPropertyName("crafttime")]
public double CraftTime { get; set; }
[JsonPropertyName("stacksize")]
public int StackSize { get; set; }
}
+1
View File
@@ -0,0 +1 @@
uid://cj8yubkrsdq70
+1 -1
View File
@@ -17,7 +17,7 @@ public partial class GameData
public static float robotSpeed = 20f;
public static float tileWidth = 6;
public static float tileHeight = 4;
public static Dictionary<Ingredient, Texture2D> availableIngredients = ResourceLoader.LoadIngredients();
public static Dictionary<string, ItemData> availableItems = ResourceLoader.LoadItems();
//--- PLAYER ADJUSTABLE VALUES ---
//Color used in primary objects (e.g. Robots)
+27 -18
View File
@@ -2,6 +2,7 @@ using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
public partial class ResourceLoader
{
@@ -49,37 +50,45 @@ public partial class ResourceLoader
public static Dictionary<ProgramNode, PackedScene> LoadDSLNodes()
{
Dictionary<ProgramNode, PackedScene> nodes = new()
{
{ new MoveNode(), GD.Load<PackedScene>($"res://Prefabs/DSL/MoveNode.tscn") },
{
{ new MoveNode(), GD.Load<PackedScene>($"res://Prefabs/DSL/MoveNode.tscn") },
{ new HarvestNode(), GD.Load<PackedScene>($"res://Prefabs/DSL/HarvestNode.tscn") },
{ new CraftNode(), GD.Load<PackedScene>($"res://Prefabs/DSL/CraftNode.tscn") },
{ new ExploreNode(), GD.Load<PackedScene>($"res://Prefabs/DSL/ExploreNode.tscn") }
};
};
return nodes;
}
public static Dictionary<string, Texture2D> LoadResourceSymbols()
{
Dictionary<string, Texture2D> symbols = new()
{
{ "Iron ore", GD.Load<Texture2D>($"res://Assets/Images/Resources/IronSymbol.png") },
{ "Tin ore", GD.Load<Texture2D>($"res://Assets/Images/Resources/TinSymbol.png") },
{ "Copper ore", GD.Load<Texture2D>($"res://Assets/Images/Resources/CopperSymbol.png") },
{ "Mushroom", GD.Load<Texture2D>($"res://Assets/Images/Resources/MushroomSymbol.png") },
{ "Spiderweb", GD.Load<Texture2D>($"res://Assets/Images/Resources/SpiderSilkSymbol.png") },
{ "Coal", GD.Load<Texture2D>($"res://Assets/Images/Resources/CoalSymbol.png") },
{ "Water", GD.Load<Texture2D>($"res://Assets/Images/Resources/WaterSymbol.png") },
{ "Stone", GD.Load<Texture2D>($"res://Assets/Images/Resources/StoneSymbol.png") },
};
{
{ "iron_ore", GD.Load<Texture2D>($"res://Assets/Images/Resources/IronSymbol.png") },
{ "tin_ore", GD.Load<Texture2D>($"res://Assets/Images/Resources/TinSymbol.png") },
{ "copper_ore", GD.Load<Texture2D>($"res://Assets/Images/Resources/CopperSymbol.png") },
{ "mushroom", GD.Load<Texture2D>($"res://Assets/Images/Resources/MushroomSymbol.png") },
{ "spider_silk", GD.Load<Texture2D>($"res://Assets/Images/Resources/SpiderSilkSymbol.png") },
{ "coal", GD.Load<Texture2D>($"res://Assets/Images/Resources/CoalSymbol.png") },
{ "water", GD.Load<Texture2D>($"res://Assets/Images/Resources/WaterSymbol.png") },
{ "stone", GD.Load<Texture2D>($"res://Assets/Images/Resources/StoneSymbol.png") },
};
return symbols;
}
public static Dictionary<Ingredient, Texture2D> LoadIngredients()
public static Dictionary<string, ItemData> LoadItems()
{
Dictionary<Ingredient, Texture2D> ingredients = new()
{
};
return ingredients;
FileAccess file = FileAccess.Open("res://Assets/Recipes.json", FileAccess.ModeFlags.Read);
string json = file.GetAsText();
Dictionary<string, ItemData> result = new();
List<ItemData> items = JsonSerializer.Deserialize<List<ItemData>>(json);
foreach (ItemData item in items)
{
result.Add(item.Id, item);
}
return result;
}
}