fix unpausing during edits while paused, fixed end node changes not being rendered properly

This commit is contained in:
Xevion
2020-11-26 09:19:28 -06:00
parent d841b8760b
commit 734148ca19
2 changed files with 12 additions and 5 deletions
+7 -2
View File
@@ -82,8 +82,7 @@ namespace Algorithms {
return null; return null;
} }
// Fix start and end position being overriden
ChangeController.RemovePositions(start, 1);
// if all good, return path // if all good, return path
Node temp = _closedList[_closedList.IndexOf(current)]; Node temp = _closedList[_closedList.IndexOf(current)];
@@ -95,6 +94,12 @@ namespace Algorithms {
temp = temp.Parent; temp = temp.Parent;
} while (temp != null && !temp.Equals(startNode)); } while (temp != null && !temp.Equals(startNode));
// Fix start and end position being overriden
// TODO: Look into using a proper fix for this instead of a 'patch'.
ChangeController.RemovePositions(start, 1);
ChangeController.RemovePositions(end, 3);
return _path; return _path;
} }
+5 -3
View File
@@ -50,7 +50,7 @@ public class UIController : MonoBehaviour {
private AnimationState _previousAnimationState; private AnimationState _previousAnimationState;
private bool EditShouldReload => private bool EditShouldReload =>
_animationState == AnimationState.Started || _animationState == AnimationState.Paused; _animationState == AnimationState.Started;
// Grid State & Pathfinding // Grid State & Pathfinding
private NodeGrid _grid; private NodeGrid _grid;
@@ -95,7 +95,9 @@ public class UIController : MonoBehaviour {
Node node = _grid.GetNode(position); Node node = _grid.GetNode(position);
_modify = node.Walkable ? ClickType.Add : ClickType.Remove; _modify = node.Walkable ? ClickType.Add : ClickType.Remove;
node.Walkable = !node.Walkable; node.Walkable = !node.Walkable;
if (EditShouldReload) if (_animationState == AnimationState.Paused)
_animationState = AnimationState.Stopped;
else if (_animationState == AnimationState.Started)
_animationState = AnimationState.Reloading; _animationState = AnimationState.Reloading;
} }
@@ -230,7 +232,7 @@ public class UIController : MonoBehaviour {
string pathCount = _path != null ? $"{_path.Count}" : "N/A"; string pathCount = _path != null ? $"{_path.Count}" : "N/A";
debugText.text = $"{_state.CurrentRuntime * 1000.0:F1}ms\n" + debugText.text = $"{_state.CurrentRuntime * 1000.0:F1}ms\n" +
$"{CurrentIndex + 1:000} / {_state.Count:000}\n" + $"{CurrentIndex:000} / {_state.Count:000}\n" +
$"Path: {pathCount} tiles"; $"Path: {pathCount} tiles";
} }