diff --git a/components/NavigationComponent.cs b/components/NavigationComponent.cs
index 66fcaa0..6d6540a 100644
--- a/components/NavigationComponent.cs
+++ b/components/NavigationComponent.cs
@@ -8,6 +8,8 @@ using GodotComponentTest.utils;
///
///
public class NavigationComponent : Spatial {
+ [Export] public bool PathSmoothing = false;
+
public World World { set; get; }
public Vector3 CurrentGoalPositionWorld { get; private set; } = Vector3.Zero;
public float CurrentGoalAngleWorld { get; private set; }
@@ -15,7 +17,7 @@ public class NavigationComponent : Spatial {
private NavigationPoint _currentGoal;
private HexCell[] _path;
private List _pathWorldNavigationPoints = new();
- private List _planningPathSmoothedWorldNavigationPoints = new();
+ private List _activePathWorldNavigationPoints = new();
private List _planningPathWorldNavigationPoints = new();
private List _smoothedPathWorldNavigationPoints = new();
@@ -46,7 +48,7 @@ public class NavigationComponent : Spatial {
GD.Print("Invalid starting point for FindPath(): returning empty path.");
_planningPathWorldNavigationPoints = new List();
_planningPathWorldNavigationPoints.Add(new NavigationPoint(fromPositionWorld));
- _planningPathSmoothedWorldNavigationPoints = _planningPathWorldNavigationPoints;
+ _activePathWorldNavigationPoints = _planningPathWorldNavigationPoints;
return;
}
@@ -57,7 +59,7 @@ public class NavigationComponent : Spatial {
GD.Print("Invalid target point for FindPath(): returning empty path.");
_planningPathWorldNavigationPoints = new List();
_planningPathWorldNavigationPoints.Add(new NavigationPoint(fromPositionWorld));
- _planningPathSmoothedWorldNavigationPoints = _planningPathWorldNavigationPoints;
+ _activePathWorldNavigationPoints = _planningPathWorldNavigationPoints;
return;
}
@@ -79,11 +81,19 @@ public class NavigationComponent : Spatial {
}
// Perform smoothing
- _planningPathSmoothedWorldNavigationPoints = World.SmoothPath(entity, _planningPathWorldNavigationPoints);
-
+ if (PathSmoothing)
+ {
+ _activePathWorldNavigationPoints = World.SmoothPath(entity, _planningPathWorldNavigationPoints);
+ }
+ else
+ {
+ _activePathWorldNavigationPoints = _planningPathWorldNavigationPoints;
+ }
+
+
// Ensure starting point is the current position
- if (_planningPathSmoothedWorldNavigationPoints.Count > 0) {
- _planningPathSmoothedWorldNavigationPoints[0] = new NavigationPoint(fromPositionWorld);
+ if (_activePathWorldNavigationPoints.Count > 0) {
+ _activePathWorldNavigationPoints[0] = new NavigationPoint(fromPositionWorld);
}
}
@@ -91,7 +101,7 @@ public class NavigationComponent : Spatial {
FindPath(entity, fromPositionWorld, navigationPoint.WorldPosition);
_planningPathWorldNavigationPoints[_planningPathWorldNavigationPoints.Count - 1] = navigationPoint;
- _planningPathSmoothedWorldNavigationPoints[_planningPathSmoothedWorldNavigationPoints.Count - 1] =
+ _activePathWorldNavigationPoints[_activePathWorldNavigationPoints.Count - 1] =
navigationPoint;
}
@@ -277,7 +287,7 @@ public class NavigationComponent : Spatial {
}
public void ActivatePlannedPath() {
- _pathWorldNavigationPoints = _planningPathSmoothedWorldNavigationPoints;
+ _pathWorldNavigationPoints = _activePathWorldNavigationPoints;
UpdateCurrentGoal();
}
@@ -384,7 +394,7 @@ public class NavigationComponent : Spatial {
}
previousPoint = parentNode.GlobalTranslation;
- foreach (NavigationPoint point in _planningPathSmoothedWorldNavigationPoints) {
+ foreach (NavigationPoint point in _activePathWorldNavigationPoints) {
debugGeometry.SetColor(new Color(1, 1, 0));
debugGeometry.AddVertex(previousPoint + yOffset);
debugGeometry.AddVertex(point.WorldPosition + yOffset);
diff --git a/entities/Entity.cs b/entities/Entity.cs
index d9ecc81..4ce6e37 100644
--- a/entities/Entity.cs
+++ b/entities/Entity.cs
@@ -4,9 +4,9 @@ using Godot;
public class Entity : KinematicBody {
[Flags]
public enum EntityMaskEnum {
- Obstacle = 1 << 1,
- Ground = 1 << 2,
- Water = 1 << 3
+ Obstacle = 1 << 0,
+ Ground = 1 << 1,
+ Water = 1 << 2
}
[Export(PropertyHint.Flags, "Obstacle,Ground,Water")]
diff --git a/project.godot b/project.godot
index a00bed8..aa869bd 100644
--- a/project.godot
+++ b/project.godot
@@ -9,17 +9,17 @@
config_version=4
_global_script_classes=[ {
-"base": "Reference",
+"base": "Node",
"class": "ClickableComponent",
"language": "GDScript",
"path": "res://components/ClickableComponent.gd"
}, {
-"base": "Reference",
+"base": "KinematicBody2D",
"class": "CollisionLine",
"language": "GDScript",
"path": "res://utils/CollisionLine.gd"
}, {
-"base": "Reference",
+"base": "Node",
"class": "ColorComponent",
"language": "GDScript",
"path": "res://components/ColorComponent.gd"
@@ -54,7 +54,7 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://utils/SpringDamper.gd"
}, {
-"base": "Reference",
+"base": "Sprite",
"class": "TintedSpriteComponent",
"language": "GDScript",
"path": "res://components/TintedSpriteComponent.gd"
diff --git a/scenes/Game.tscn b/scenes/Game.tscn
index cb35a4f..9c9eb3c 100644
--- a/scenes/Game.tscn
+++ b/scenes/Game.tscn
@@ -373,7 +373,6 @@ input_ray_pickable = false
[node name="Chest" parent="Entities" instance=ExtResource( 11 )]
transform = Transform( -0.825665, 0, 0.56416, 0, 1, 0, -0.56416, 0, -0.825665, -3.27709, 0, 1.02593 )
-EntityMask = 3
[node name="World" parent="." instance=ExtResource( 7 )]
diff --git a/scenes/World.cs b/scenes/World.cs
index 44c683c..43634af 100644
--- a/scenes/World.cs
+++ b/scenes/World.cs
@@ -489,7 +489,10 @@ public class World : Spatial {
nextHexCost = 0;
}
}
- // GD.Print("Could not find tile type info for color " + tileTypeColor);
+ else
+ {
+ GD.Print("Could not find tile type info for color " + tileTypeColor);
+ }
}
return nextHexCost;