public void SetTarget(Tile target, Agent agent) { CheckedOnce = true; Target = target; MyAgent = agent; bool genPath = true; bool targetMoveCheck = true; bool stillWalkableCheck = true; Path.Clear(); if (Path.Count() > 0) { genPath = false; if (AgentTarget != null) { if (AgentTarget.CurrentTile != Target) { targetMoveCheck = false; } } foreach (var t in Path) { if (!t.Walkable) { stillWalkableCheck = false; } } if (!stillWalkableCheck && !targetMoveCheck) { genPath = true; } } if (genPath) { var newPath = MapGenerator.AStarPathFinder(agent.CurrentTile, target, false); Path.Clear(); foreach (var t in newPath) { if (t != agent.CurrentTile) { Path.Add(t); } } } }