Skip to content

Commit

Permalink
Cube (#10)
Browse files Browse the repository at this point in the history
* half-working cube

* Cube WORKS
  • Loading branch information
AlexValder authored May 16, 2022
1 parent ee35552 commit 657dac1
Show file tree
Hide file tree
Showing 18 changed files with 1,126 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.import/
.idea/
packages/
export.cfg
export_presets.cfg
*.translation
Expand All @@ -8,4 +9,5 @@ export_presets.cfg
data_*/
*.user
*.ini
log/
log/
TEST/
4 changes: 4 additions & 0 deletions DefaultMeshProperties/Cube.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
{
"maze": {
"side": 5,
"seed": ""
}
}
4 changes: 4 additions & 0 deletions MazeCube.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="DefaultMeshProperties\Cylinder.json" />
<EmbeddedResource Remove="UnitTests\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="GodotCSToolbox" Version="1.0.0-beta10" />
Expand All @@ -20,4 +21,7 @@
<Content Include="Scenes\SceneScripts\FpsLabel.gd" />
<Content Include="Scenes\SceneScripts\LeftPanel.gd" />
</ItemGroup>
<ItemGroup>
<Compile Remove="UnitTests\**" />
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions MazeCube.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MazeCube", "MazeCube.csproj", "{2AB9095D-2F86-409A-AAA3-7F94BCCEB5EF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{EC0DA686-660E-45FF-8C44-11A76AAFCCCC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,5 +17,11 @@ Global
{2AB9095D-2F86-409A-AAA3-7F94BCCEB5EF}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{2AB9095D-2F86-409A-AAA3-7F94BCCEB5EF}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{2AB9095D-2F86-409A-AAA3-7F94BCCEB5EF}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
{EC0DA686-660E-45FF-8C44-11A76AAFCCCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC0DA686-660E-45FF-8C44-11A76AAFCCCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC0DA686-660E-45FF-8C44-11A76AAFCCCC}.ExportDebug|Any CPU.ActiveCfg = Debug|Any CPU
{EC0DA686-660E-45FF-8C44-11A76AAFCCCC}.ExportDebug|Any CPU.Build.0 = Debug|Any CPU
{EC0DA686-660E-45FF-8C44-11A76AAFCCCC}.ExportRelease|Any CPU.ActiveCfg = Debug|Any CPU
{EC0DA686-660E-45FF-8C44-11A76AAFCCCC}.ExportRelease|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
EndGlobal
11 changes: 10 additions & 1 deletion Scenes/GuiParts/CubeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@

namespace MazeCube.Scenes.GuiParts {
public class CubeSettings : ModelSettingsBase {
// ReSharper disable FieldCanBeMadeReadOnly.Local
[NodePath("MazeGrid")] private GridContainer _gridParamContainer = null;
// ReSharped enable FieldCanBeMadeReadOnly.Local

public override void _Ready() {
base._Ready();
this.SetupNodeTools();
}

public override Dictionary<string, object> GetParams() {
return new();
return new() {
["maze"] = new Dictionary<string, object> {
["side"] = _gridParamContainer.GetNode<SpinBox>("GridSideSizeSpinBox").Value,
["seed"] = _gridParamContainer.GetNode<LineEdit>("SeedLineEdit").Text,
},
};
}
}
}
45 changes: 42 additions & 3 deletions Scenes/GuiParts/CubeSettings.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,45 @@
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="MazeGrid" type="GridContainer" parent="."]
margin_right = 1024.0
margin_bottom = 52.0
grow_horizontal = 0
grow_vertical = 0
columns = 2

[node name="label1" type="Label" parent="MazeGrid"]
margin_top = 5.0
margin_right = 510.0
margin_bottom = 19.0
size_flags_horizontal = 3
text = " Grid Side Size"
valign = 1

[node name="GridSideSizeSpinBox" type="SpinBox" parent="MazeGrid"]
margin_left = 514.0
margin_right = 1024.0
margin_bottom = 24.0
size_flags_horizontal = 3
min_value = 3.0
max_value = 15.0
value = 5.0
align = 1

[node name="label2" type="Label" parent="MazeGrid"]
margin_top = 33.0
margin_right = 510.0
margin_bottom = 47.0
size_flags_horizontal = 3
text = " Seed"
valign = 1

[node name="SeedLineEdit" type="LineEdit" parent="MazeGrid"]
margin_left = 514.0
margin_top = 28.0
margin_right = 1024.0
margin_bottom = 52.0
align = 1
max_length = 32
placeholder_text = "seed"
34 changes: 33 additions & 1 deletion Scripts/MazeGen/Grid/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;

namespace MazeCube.Scripts.MazeGen.Grid {
public class Cell {
public class Cell : IComparable<Cell>, IComparable {
public int X { get; }
public int Y { get; }
public Directions Directions { get; internal set; }
Expand All @@ -16,6 +16,38 @@ public Cell(int x, int y) {
X = x;
Y = y;
}

public override string ToString() => $"[{X}, {Y}]";

public int CompareTo(Cell other) {
if (ReferenceEquals(this, other)) {
return 0;
}

if (ReferenceEquals(null, other)) {
return 1;
}

var xComparison = X.CompareTo(other.X);
if (xComparison != 0) {
return xComparison;
}

return Y.CompareTo(other.Y);
}

public int CompareTo(object obj) {
if (ReferenceEquals(null, obj)) {
return 1;
}

if (ReferenceEquals(this, obj)) {
return 0;
}

return obj is Cell other
? CompareTo(other)
: throw new ArgumentException($"Object must be of type {nameof(Cell)}");
}
}
}
Loading

0 comments on commit 657dac1

Please sign in to comment.