public bool RunTrajectory(Trajectory traj) { TrajectoryRunning = traj; TimeSpan estimatedDuration = traj.GetDuration(this); Stopwatch sw = Stopwatch.StartNew(); TrajectoryCutOff = false; TrajectoryFailed = false; foreach (IAction action in traj.ConvertToActions(this)) { if (!Execution.Shutdown) { action.Executer(); if (TrajectoryCutOff || TrajectoryFailed) { break; } if (action is ActionAvance || action is ActionRecule) { Historique.Log("Noeud atteint " + TrajectoryRunning.Points[0].X.ToString("0") + ":" + TrajectoryRunning.Points[0].Y.ToString("0"), TypeLog.PathFinding); TrajectoryRunning.RemovePoint(0); } } } if (!Execution.Shutdown) { TrajectoryRunning = null; if (!TrajectoryCutOff && !TrajectoryFailed) { Historique.Log("Trajectoire parcourue en " + (sw.ElapsedMilliseconds / 1000.0).ToString("0.0") + "s (durée théorique : " + (estimatedDuration.TotalSeconds).ToString("0.0") + "s)", TypeLog.PathFinding); return(true); } if (TrajectoryFailed) { Historique.Log("Echec du parcours de la trajectoire (dérapage, blocage...)", TypeLog.PathFinding); return(false); } } return(false); }