Cleaned up project with better structure.

This commit is contained in:
2026-05-09 11:29:48 +02:00
parent 1ad3454f6a
commit 6708aa277f
95 changed files with 711 additions and 700 deletions
+4 -2
View File
@@ -1,4 +1,3 @@
using System.Linq;
using Godot;
public class CraftNode : ProgramNode
@@ -16,11 +15,13 @@ public class CraftNode : ProgramNode
lastExecutionMessage = "No Item selected";
return NodeResult.FAILURE;
}
if (amount <= 0)
{
lastExecutionMessage = "Amount has to be atleast 1";
return NodeResult.FAILURE;
}
if (!GameData.inventory.CanCraft(selectedItem.data.Inputs, amount))
{
lastExecutionMessage = "Not enough items to craft this";
@@ -67,12 +68,13 @@ public class CraftNode : ProgramNode
options.AddItem("Select item...");
foreach (ItemData item in GameData.availableItems.Values)
{
if(GameData.availableResearch[item.Research].state != ResearchState.RESEARCHED) continue;
if (GameData.availableResearch[item.Research].state != ResearchState.RESEARCHED) continue;
if (item.Inputs.Count > 0)
{
options.AddItem(item.GetCraftingDisplay());
}
}
if (selectedItem != null)
{
for (int i = 0; i < options.ItemCount; i++)
+5 -5
View File
@@ -16,9 +16,10 @@ public class ExploreNode : ProgramNode
if (pathPoints == null)
{
int safetyCounter = 0;
int layerRange = Math.Max(GameData.lowestLayer, 1);
while (true)
{
targetPosition = new Vector3I(GameData.rand.Next(GameData.layerSize), GameData.rand.Next(GameData.lowestLayer), GameData.rand.Next(GameData.layerSize));
targetPosition = new Vector3I(GameData.rand.Next(GameData.layerSize), GameData.rand.Next(layerRange), GameData.rand.Next(GameData.layerSize));
if (!GameData.map[targetPosition.Y].tiles[targetPosition.X, targetPosition.Z].wasVisited) break;
safetyCounter++;
if (safetyCounter > Math.Pow(GameData.layerSize, 2) * 2)
@@ -29,7 +30,7 @@ public class ExploreNode : ProgramNode
}
}
pathPoints ??= [.. Pathfinding.GetPath(Pathfinding.GetClosestStartPoint(robot.Position), targetPosition)];
pathPoints ??= new List<Vector3>(Pathfinding.GetPath(Pathfinding.GetClosestStartPoint(robot.Position), targetPosition));
if (pathPoints.Count <= 0)
{
@@ -50,6 +51,7 @@ public class ExploreNode : ProgramNode
{
tile.VisitTile();
}
pathPoints.Remove(pathPoints[0]);
if (pathPoints.Count <= 0)
{
@@ -84,16 +86,14 @@ public class ExploreNode : ProgramNode
public override void ReadParameters(NodeDisplay display)
{
//Currently does nothing
}
public override void Setup(NodeDisplay display)
{
//Currently does nothing
}
public override string Save()
{
return $"Name: {DisplayText}";
}
}
}
+1 -3
View File
@@ -36,7 +36,6 @@ public class HarvestNode : ProgramNode
public override void ReadParameters(NodeDisplay display)
{
//Currently does nothing
}
public override ProgramNode Duplicate()
@@ -47,11 +46,10 @@ public class HarvestNode : ProgramNode
public override void Setup(NodeDisplay display)
{
//Currently does nothing
}
public override string Save()
{
return $"Name: {DisplayText}";
}
}
}
+5 -4
View File
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Godot;
@@ -13,12 +12,14 @@ public class MoveNode : ProgramNode
}
public override NodeResult Execute(Robot robot, double delta)
{
pathPoints ??= [.. Pathfinding.GetPath(Pathfinding.GetClosestStartPoint(robot.Position), targetPosition)];
pathPoints ??= new List<Vector3>(Pathfinding.GetPath(Pathfinding.GetClosestStartPoint(robot.Position), targetPosition));
if (pathPoints.Count <= 0)
{
lastExecutionMessage = "No path available";
return NodeResult.FAILURE;
}
startPosition = robot.Position;
Vector3 target = pathPoints[0] - startPosition;
float distance = target.Length();
@@ -32,6 +33,7 @@ public class MoveNode : ProgramNode
{
tile.VisitTile();
}
pathPoints.Remove(pathPoints[0]);
if (pathPoints.Count <= 0)
{
@@ -74,11 +76,10 @@ public class MoveNode : ProgramNode
public override void Setup(NodeDisplay display)
{
//Currently does nothing
}
public override string Save()
{
return $"Name: {DisplayText}, Position: ({targetPosition.X}|{targetPosition.Y}|{targetPosition.Z})";
}
}
}