diff --git a/Assets/EnergySymbol.aseprite b/Assets/EnergySymbol.aseprite new file mode 100644 index 0000000..e7c7465 Binary files /dev/null and b/Assets/EnergySymbol.aseprite differ diff --git a/Assets/EnergySymbol.png b/Assets/EnergySymbol.png new file mode 100644 index 0000000..d132125 Binary files /dev/null and b/Assets/EnergySymbol.png differ diff --git a/Assets/EnergySymbol.png.import b/Assets/EnergySymbol.png.import new file mode 100644 index 0000000..8639054 --- /dev/null +++ b/Assets/EnergySymbol.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://deuxffyhsrinn" +path="res://.godot/imported/EnergySymbol.png-64f11837bac65e727f9268f845f35249.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/EnergySymbol.png" +dest_files=["res://.godot/imported/EnergySymbol.png-64f11837bac65e727f9268f845f35249.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 diff --git a/Assets/Objects/Tiles.glb b/Assets/Objects/Tiles.glb index 7e7ce1d..995c141 100644 Binary files a/Assets/Objects/Tiles.glb and b/Assets/Objects/Tiles.glb differ diff --git a/Assets/OptionsSymbol.aseprite b/Assets/OptionsSymbol.aseprite new file mode 100644 index 0000000..893cbe7 Binary files /dev/null and b/Assets/OptionsSymbol.aseprite differ diff --git a/Assets/OptionsSymbol.png b/Assets/OptionsSymbol.png new file mode 100644 index 0000000..d30533c Binary files /dev/null and b/Assets/OptionsSymbol.png differ diff --git a/Assets/OptionsSymbol.png.import b/Assets/OptionsSymbol.png.import new file mode 100644 index 0000000..7424d76 --- /dev/null +++ b/Assets/OptionsSymbol.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b77mo4fhklnja" +path="res://.godot/imported/OptionsSymbol.png-6737f7fc496e85a68b0e96b880f46122.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/OptionsSymbol.png" +dest_files=["res://.godot/imported/OptionsSymbol.png-6737f7fc496e85a68b0e96b880f46122.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 diff --git a/Assets/RobotSymbol.aseprite b/Assets/RobotSymbol.aseprite new file mode 100644 index 0000000..fdc965e Binary files /dev/null and b/Assets/RobotSymbol.aseprite differ diff --git a/Assets/RobotSymbol.png b/Assets/RobotSymbol.png new file mode 100644 index 0000000..e4ff193 Binary files /dev/null and b/Assets/RobotSymbol.png differ diff --git a/Assets/RobotSymbol.png.import b/Assets/RobotSymbol.png.import new file mode 100644 index 0000000..fb96486 --- /dev/null +++ b/Assets/RobotSymbol.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ban872p4eh4gi" +path="res://.godot/imported/RobotSymbol.png-986bd050c59e116c51936dcd370ba5c4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/RobotSymbol.png" +dest_files=["res://.godot/imported/RobotSymbol.png-986bd050c59e116c51936dcd370ba5c4.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 diff --git a/Assets/WaterSymbol.aseprite b/Assets/WaterSymbol.aseprite new file mode 100644 index 0000000..8f3739c Binary files /dev/null and b/Assets/WaterSymbol.aseprite differ diff --git a/Assets/WaterSymbol.png b/Assets/WaterSymbol.png new file mode 100644 index 0000000..77226e4 Binary files /dev/null and b/Assets/WaterSymbol.png differ diff --git a/Assets/WaterSymbol.png.import b/Assets/WaterSymbol.png.import new file mode 100644 index 0000000..2d70695 --- /dev/null +++ b/Assets/WaterSymbol.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dje86ro2e37xl" +path="res://.godot/imported/WaterSymbol.png-cfddb36cae72b19ba800831b4972a1c5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/WaterSymbol.png" +dest_files=["res://.godot/imported/WaterSymbol.png-cfddb36cae72b19ba800831b4972a1c5.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 diff --git a/Scenes/Game.tscn b/Scenes/Game.tscn index 13a6fb8..d5d4237 100644 --- a/Scenes/Game.tscn +++ b/Scenes/Game.tscn @@ -8,6 +8,10 @@ [ext_resource type="Script" uid="uid://k6vlo7ulvtep" path="res://Scripts/Robot/RobotList.cs" id="7_2irst"] [ext_resource type="PackedScene" uid="uid://cpq7ppe8bw2bq" path="res://Scenes/Options.tscn" id="8_71axn"] [ext_resource type="Script" uid="uid://fegfbcnlk8p5" path="res://Scripts/WorldGeneration/Map.cs" id="8_bf53h"] +[ext_resource type="Texture2D" uid="uid://deuxffyhsrinn" path="res://Assets/EnergySymbol.png" id="9_71axn"] +[ext_resource type="Texture2D" uid="uid://dje86ro2e37xl" path="res://Assets/WaterSymbol.png" id="10_71axn"] +[ext_resource type="Texture2D" uid="uid://ban872p4eh4gi" path="res://Assets/RobotSymbol.png" id="11_dahhg"] +[ext_resource type="Texture2D" uid="uid://b77mo4fhklnja" path="res://Assets/OptionsSymbol.png" id="12_3so38"] [sub_resource type="CompressedTexture2D" id="CompressedTexture2D_u44n3"] @@ -311,6 +315,48 @@ text = "Exit" visible = false layout_mode = 1 +[node name="Survival" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=141921319] +layout_mode = 1 +offset_right = 150.0 +offset_bottom = 23.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Survival" unique_id=1716446061] +layout_mode = 2 + +[node name="RowEnergy" type="HBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Survival/VBoxContainer" unique_id=867560906] +layout_mode = 2 + +[node name="TextureRect" type="TextureRect" parent="CanvasLayer/UIHandler/MainUI/Content/Survival/VBoxContainer/RowEnergy" unique_id=1218525340] +layout_mode = 2 +texture = ExtResource("9_71axn") +expand_mode = 2 + +[node name="RichTextLabel" type="RichTextLabel" parent="CanvasLayer/UIHandler/MainUI/Content/Survival/VBoxContainer/RowEnergy" unique_id=32920400] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Energy: 100/100" +fit_content = true +autowrap_mode = 0 +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="RowWater" type="HBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Survival/VBoxContainer" unique_id=465013052] +layout_mode = 2 + +[node name="TextureRect" type="TextureRect" parent="CanvasLayer/UIHandler/MainUI/Content/Survival/VBoxContainer/RowWater" unique_id=1398125603] +layout_mode = 2 +texture = ExtResource("10_71axn") +expand_mode = 2 + +[node name="RichTextLabel" type="RichTextLabel" parent="CanvasLayer/UIHandler/MainUI/Content/Survival/VBoxContainer/RowWater" unique_id=1355787203] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Water: 100/100" +fit_content = true +autowrap_mode = 0 +horizontal_alignment = 1 +vertical_alignment = 1 + [node name="FooterContainer" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI" unique_id=1495029884] layout_mode = 2 @@ -319,14 +365,6 @@ layout_mode = 2 theme_override_constants/separation = 20 alignment = 2 -[node name="Robots" type="Button" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=360269454] -layout_mode = 2 -text = "Robots (R)" - -[node name="Options" type="Button" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=293744135] -layout_mode = 2 -text = "Options (ESC)" - [node name="FPS" type="RichTextLabel" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=2029942501] layout_mode = 2 fit_content = true @@ -337,6 +375,14 @@ layout_mode = 2 fit_content = true autowrap_mode = 0 +[node name="Robots" type="TextureButton" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=1666653447] +layout_mode = 2 +texture_normal = ExtResource("11_dahhg") + +[node name="Options" type="TextureButton" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=1930105751] +layout_mode = 2 +texture_normal = ExtResource("12_3so38") + [connection signal="button_up" from="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/VBoxContainer/Scripting/EditorWindow/Buttons/Clear" to="CanvasLayer/UIHandler/MainUI/Content/CodingWindow" method="ClearWindow"] [connection signal="button_up" from="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/VBoxContainer/Scripting/EditorWindow/Buttons/Compile" to="CanvasLayer/UIHandler/MainUI/Content/CodingWindow" method="CompileProgram"] [connection signal="pressed" from="CanvasLayer/UIHandler/MainUI/Content/Menu/VBoxContainer/Button" to="CanvasLayer/UIHandler" method="HandleMenu"] diff --git a/Scripts/DSL/NodeResult.cs b/Scripts/DSL/NodeResult.cs new file mode 100644 index 0000000..59ca8be --- /dev/null +++ b/Scripts/DSL/NodeResult.cs @@ -0,0 +1,6 @@ +public enum NodeResult +{ + SUCCESS, + FAILURE, + RUNNING +} \ No newline at end of file diff --git a/Scripts/DSL/NodeResult.cs.uid b/Scripts/DSL/NodeResult.cs.uid new file mode 100644 index 0000000..3d962f6 --- /dev/null +++ b/Scripts/DSL/NodeResult.cs.uid @@ -0,0 +1 @@ +uid://dpp7ycquabyq8 diff --git a/Scripts/DSL/Nodes/CraftNode.cs b/Scripts/DSL/Nodes/CraftNode.cs index 5270e3a..b5f0b0e 100644 --- a/Scripts/DSL/Nodes/CraftNode.cs +++ b/Scripts/DSL/Nodes/CraftNode.cs @@ -6,7 +6,7 @@ public class CraftNode : ProgramNode { DisplayText = "Craft"; } - public override bool Execute(Robot robot, double delta) + public override NodeResult Execute(Robot robot, double delta) { GD.Print("Craft"); if (nextNode != null) @@ -15,7 +15,7 @@ public class CraftNode : ProgramNode } else { - return true; + return NodeResult.SUCCESS; } } diff --git a/Scripts/DSL/Nodes/HarvestNode.cs b/Scripts/DSL/Nodes/HarvestNode.cs index 69bc21b..0aa7d4d 100644 --- a/Scripts/DSL/Nodes/HarvestNode.cs +++ b/Scripts/DSL/Nodes/HarvestNode.cs @@ -6,7 +6,7 @@ public class HarvestNode : ProgramNode { DisplayText = "Harvest"; } - public override bool Execute(Robot robot, double delta) + public override NodeResult Execute(Robot robot, double delta) { GD.Print("Harvest"); if (nextNode != null) @@ -15,7 +15,7 @@ public class HarvestNode : ProgramNode } else { - return true; + return NodeResult.SUCCESS; } } diff --git a/Scripts/DSL/Nodes/MoveNode.cs b/Scripts/DSL/Nodes/MoveNode.cs index b4c28dc..0df9406 100644 --- a/Scripts/DSL/Nodes/MoveNode.cs +++ b/Scripts/DSL/Nodes/MoveNode.cs @@ -11,10 +11,14 @@ public class MoveNode : ProgramNode { DisplayText = "Move"; } - public override bool Execute(Robot robot, double delta) + public override NodeResult Execute(Robot robot, double delta) { pathPoints ??= [.. 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,11 +36,12 @@ public class MoveNode : ProgramNode pathPoints.Remove(pathPoints[0]); if (pathPoints.Count <= 0) { - pathPoints = null; - return true; + lastExecutionMessage = ""; + return NodeResult.SUCCESS; } - return false; + lastExecutionMessage = ""; + return NodeResult.RUNNING; } Vector3 direction = target / distance; @@ -47,14 +52,12 @@ public class MoveNode : ProgramNode } robot.GlobalPosition += direction * (float)delta * GameData.robotSpeed; - return false; + return NodeResult.RUNNING; } public override void ReadParameters(NodeDisplay display) { HBoxContainer valueContainer = display.GetNode("./EditorDisplay/HBoxContainer/"); - - GD.Print(valueContainer.GetNode("./CoordinateX").Value); int posX = (int)valueContainer.GetNode("./CoordinateX").Value; int posY = (int)valueContainer.GetNode("./CoordinateY").Value; int posZ = (int)valueContainer.GetNode("./CoordinateZ").Value; diff --git a/Scripts/DSL/Nodes/ProgramNode.cs b/Scripts/DSL/Nodes/ProgramNode.cs index 8d6d3a2..7d5a507 100644 --- a/Scripts/DSL/Nodes/ProgramNode.cs +++ b/Scripts/DSL/Nodes/ProgramNode.cs @@ -4,8 +4,9 @@ public abstract class ProgramNode { public ProgramNode nextNode; public string DisplayText; + public string lastExecutionMessage; - public abstract bool Execute(Robot robot, double delta); + public abstract NodeResult Execute(Robot robot, double delta); public abstract void ReadParameters(NodeDisplay display); public abstract ProgramNode Duplicate(); } \ No newline at end of file diff --git a/Scripts/Robot/Robot.cs b/Scripts/Robot/Robot.cs index de2a8bf..f9dac69 100644 --- a/Scripts/Robot/Robot.cs +++ b/Scripts/Robot/Robot.cs @@ -18,13 +18,22 @@ public partial class Robot : Node3D { if (isExecuting) { - if (currentNode.Execute(this, delta)) + switch (currentNode.Execute(this, delta)) { - currentNode = currentNode.nextNode; - if (currentNode == null) - { + case NodeResult.SUCCESS: + currentNode = currentNode.nextNode; + if (currentNode == null) + { + isExecuting = false; + } + break; + case NodeResult.FAILURE: isExecuting = false; - } + GD.Print(currentNode.lastExecutionMessage); + break; + case NodeResult.RUNNING: + //Currently does nothing. + break; } } diff --git a/Scripts/WorldGeneration/Layer.cs b/Scripts/WorldGeneration/Layer.cs index 5c7fddf..2a70bb9 100644 --- a/Scripts/WorldGeneration/Layer.cs +++ b/Scripts/WorldGeneration/Layer.cs @@ -14,6 +14,7 @@ public partial class Layer : Node3D public bool hasContentGenerated = false; public Vector2I gateCoordinate; public List currentResources; + public bool isGateOpen = false; // Called when the node enters the scene tree for the first time. public override void _Ready() @@ -89,7 +90,7 @@ public partial class Layer : Node3D var node = new Node3D { Position = tile.Position, - Visible = false + Visible = tile.collapsedMesh != null && tile.collapsedMesh == "gate" }; decorationRoot.AddChild(node); @@ -115,7 +116,7 @@ public partial class Layer : Node3D for (int z = 0; z < layerSize; z++) { //Exclude spawn from border generation - if(x == 0 && z == 0) continue; + if(x == 0 && z == 0 && level == 0) continue; if (!IsBorder(x, z)) continue; @@ -155,6 +156,7 @@ public partial class Layer : Node3D if (tiles[posX, posY].tileMeshes.ContainsKey("gate")) { tiles[posX, posY].Collapse("gate"); + tiles[posX, posY].containsDecoration = true; gateCoordinate = new Vector2I(posX, posY); Propagate(gateCoordinate); break; diff --git a/Scripts/WorldGeneration/Pathfinding.cs b/Scripts/WorldGeneration/Pathfinding.cs index c139cbc..319282d 100644 --- a/Scripts/WorldGeneration/Pathfinding.cs +++ b/Scripts/WorldGeneration/Pathfinding.cs @@ -8,6 +8,7 @@ public class Pathfinding private static Dictionary coordToId = new(); private static Dictionary idToCoord = new(); private static long nextId = 1; + private static long[] layerGateIds = new long[GameData.ruinSize]; private static long GetOrCreateId(Vector3I coord) { @@ -26,6 +27,7 @@ public class Pathfinding aStar.Clear(); coordToId.Clear(); idToCoord.Clear(); + layerGateIds = new long[GameData.ruinSize]; nextId = 1; for (int y = 0; y < GameData.ruinSize; y++) @@ -43,6 +45,10 @@ public class Pathfinding long id = GetOrCreateId(coord); aStar.AddPoint(id, tile.Position); + if (tile.collapsedMesh == "gate") + { + layerGateIds[y] = id; + } } } } @@ -74,6 +80,16 @@ public class Pathfinding } } } + + for (int y = 0; y < GameData.ruinSize; y++) + { + UpdateGatePoint(y, false); + } + } + + public static void UpdateGatePoint(int layer, bool isOpen) + { + aStar.SetPointDisabled(layerGateIds[layer], !isOpen); } public static List GetPath(Vector3I start, Vector3I end) diff --git a/Scripts/WorldGeneration/Tile.cs b/Scripts/WorldGeneration/Tile.cs index e928db2..139f13d 100644 --- a/Scripts/WorldGeneration/Tile.cs +++ b/Scripts/WorldGeneration/Tile.cs @@ -132,7 +132,10 @@ public partial class Tile Position = placeholder.transform.Origin }; ContentNode.AddChild(decoration); - decoration.LookAt(transform.Origin, Vector3.Up); + if (!key.ToLower().Contains("gate")) + { + decoration.LookAt(transform.Origin, Vector3.Up); + } } } } diff --git a/Scripts/WorldGeneration/WFC.cs b/Scripts/WorldGeneration/WFC.cs index c19306e..de9c710 100644 --- a/Scripts/WorldGeneration/WFC.cs +++ b/Scripts/WorldGeneration/WFC.cs @@ -181,7 +181,7 @@ public class WFC } else { - return fromTile.collapsedMesh == "gate"; + return fromTile.collapsedMesh == "gate" && GameData.map[from.Y].isGateOpen; } }