private void CancelBarForAgent(Guid agentId, UIProgressBar bar) { try { if (bar.IsValid) { bar.Cancel(); } } catch { } if (_agentProgressBars.ContainsKey(agentId)) { _agentProgressBars.Remove(agentId); } }
protected void DistanceCheck(AgentPrivate agent, UIProgressBar bar, int index = -1) { ObjectPrivate op; Vector startingPosition; try { op = ScenePrivate.FindObject(agent.AgentInfo.ObjectId); if (op == null || !op.IsValid) { return; } startingPosition = op.Position; } catch (Exception) { return; } while (true) { try { if (!agent.IsValid || !op.IsValid || !bar.IsValid) { return; } if ((op.Position - startingPosition).LengthSquared() > CancelDistanceSquared) { bar.Cancel(); } Wait(0.2f); } catch (Exception) { return; } } }