From 734148ca192cc97150488e06daba4bab5acff32c Mon Sep 17 00:00:00 2001 From: Xevion Date: Thu, 26 Nov 2020 09:19:28 -0600 Subject: [PATCH] fix unpausing during edits while paused, fixed end node changes not being rendered properly --- Paths/Assets/Scripts/Algorithms/AStar.cs | 9 +++++++-- Paths/Assets/Scripts/UIController.cs | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Paths/Assets/Scripts/Algorithms/AStar.cs b/Paths/Assets/Scripts/Algorithms/AStar.cs index d8b82c1..7f56aa7 100644 --- a/Paths/Assets/Scripts/Algorithms/AStar.cs +++ b/Paths/Assets/Scripts/Algorithms/AStar.cs @@ -82,8 +82,7 @@ namespace Algorithms { return null; } - // Fix start and end position being overriden - ChangeController.RemovePositions(start, 1); + // if all good, return path Node temp = _closedList[_closedList.IndexOf(current)]; @@ -95,6 +94,12 @@ namespace Algorithms { temp = temp.Parent; } 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; } diff --git a/Paths/Assets/Scripts/UIController.cs b/Paths/Assets/Scripts/UIController.cs index 590affb..837aec1 100644 --- a/Paths/Assets/Scripts/UIController.cs +++ b/Paths/Assets/Scripts/UIController.cs @@ -50,7 +50,7 @@ public class UIController : MonoBehaviour { private AnimationState _previousAnimationState; private bool EditShouldReload => - _animationState == AnimationState.Started || _animationState == AnimationState.Paused; + _animationState == AnimationState.Started; // Grid State & Pathfinding private NodeGrid _grid; @@ -95,7 +95,9 @@ public class UIController : MonoBehaviour { Node node = _grid.GetNode(position); _modify = node.Walkable ? ClickType.Add : ClickType.Remove; node.Walkable = !node.Walkable; - if (EditShouldReload) + if (_animationState == AnimationState.Paused) + _animationState = AnimationState.Stopped; + else if (_animationState == AnimationState.Started) _animationState = AnimationState.Reloading; } @@ -230,7 +232,7 @@ public class UIController : MonoBehaviour { string pathCount = _path != null ? $"{_path.Count}" : "N/A"; 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"; }