public void Execute() { try { TargetTask.Execute(); } catch (Exception exception) { Log.InfoFormat("{0} caught exception {1}", Name, exception.Message); Log.Debug("Exception", exception); var handlerPair = _exceptionHandlers.Cast <KeyValuePair <Type, ITask>?>() .FirstOrDefault(p => p.Value.Key.IsInstanceOfType(exception)); if (handlerPair.HasValue) { var handlerPairValue = handlerPair.Value; Log.InfoFormat("{0} handler is {1}", handlerPairValue.Key.Name, handlerPairValue.Value?.Name ?? "none"); (handlerPairValue.Value as IExceptionHandlerTask)?.SetSource(TargetTask, exception); handlerPairValue.Value?.Execute(); } else { Log.Info("No handler, rethrowing"); throw; } } finally { FinallyTask?.Execute(); } }
public void SetNewSelectedTarget(int id) { SelectedTarget = TargetList.Items.FirstOrDefault(x => x.Id == id).Clone(); SetExclamationPointButton((int)SelectedTarget.Important); SelectedTargetTask = new TargetTask(); TargetTitleText = $"{SelectedTarget.Name}"; }
public override void OnUpdate() { if (Time.timeSinceLevelLoad > m_nextCheck) { if (ZoneName == "noZone") { return; //TODO, check for No Zone. } bool IfSeenInZone = ZoneManager.IsHaveObject(MasterAI.GetComponent <AITaskManager>(), ZoneName); if (IfSeenInZone && !InvertIfSeenInZoneCondition) { Zone z = ZoneManager.GetZone(ZoneName); if (z != null) { TargetTask.SetTargetObj(z.gameObject); TriggerTransition(); } } if (!IfSeenInZone && InvertIfSeenInZoneCondition) { Zone z = ZoneManager.GetZone(ZoneName); if (z != null) { TargetTask.SetTargetObj(z.gameObject); TriggerTransition(); } } m_nextCheck += CHECK_INTERVAL; } }
/// <summary> /// Метод определения типа "Выбранной Цели" (годовая, месячная, недельная, дневная). Используется при нажатии кнопки "Добавить цель" /// </summary> public void SetNewSelectedTarget() { switch (currentMenuItem) { case MenuItem.Year: SelectedTarget = new Target(TargetType.Year); break; case MenuItem.Month: SelectedTarget = new Target(TargetType.Month); break; case MenuItem.Week: SelectedTarget = new Target(TargetType.Week); break; case MenuItem.Day: SelectedTarget = new Target(TargetType.Day); break; default: break; } SelectedTargetTask = new TargetTask(); TargetTitleText = "Добавить новую цель"; }
public override void OnSight(Observable o) { if (false) { if (IfSeenInZone != "NONE") { bool inZone = ZoneManager.IsPointInZone(o.transform.position, IfSeenInZone); float d = Vector2.Distance(new Vector2(MasterAI.transform.position.x, MasterAI.transform.position.z), new Vector2(o.transform.position.x, o.transform.position.z)); if (DistanceCriteria == TransitionDistanceCriteria.WITHIN_DISTANCE_OF && d < WithinDistance || DistanceCriteria == TransitionDistanceCriteria.OUTSIDE_DISTANCE_OF && d > WithinDistance) { return; } if (inZone && !TriggerIfInZone) { return; } if (!inZone && TriggerIfInZone) { return; } } TargetTask.SetTargetObj(o.gameObject); TriggerTransition(); } }
public override void OnSight(Observable o) { Debug.Log("On sight of : " + o); if (o.GetComponent<FactionHolder>() == null || (IgnoreNeutral || o.GetComponent<FactionHolder>().Faction == FactionType.NEUTRAL)) return; if (MasterAI.GetComponent<FactionHolder>().CanAttack(o.GetComponent<FactionHolder>().Faction)) { Debug.Log("Faction is: " + o.GetComponent<FactionHolder>().Faction); float d = Vector2.Distance(new Vector2(MasterAI.transform.position.x, MasterAI.transform.position.z), new Vector2(o.transform.position.x, o.transform.position.z)); if (IfSeenInZone != "NONE" && (DistanceCriteria == TransitionDistanceCriteria.WITHIN_DISTANCE_OF && d < WithinDistance || DistanceCriteria == TransitionDistanceCriteria.OUTSIDE_DISTANCE_OF && d > WithinDistance)) { bool inZone = ZoneManager.IsPointInZone(o.transform.position, IfSeenInZone); if (inZone && InvertInZoneCondition) { return; } if (!inZone && InvertInZoneCondition) { return; } } TargetTask.SetTargetObj(o.gameObject); TriggerTransition(); } }
public override void OnItemGet(Item i) { base.OnItemGet(i); if (i.name == PrefabOfItem.name) { TargetTask.SetTargetObj(i.gameObject); TriggerTransition(); } }
public override void OnHit(HitInfo hb) { base.OnHit(hb); if (hb.Damage > DamageThreashould) { TargetTask.SetTargetObj(hb.mHitbox.gameObject); TriggerTransition(); } }
public override void OnSight(Observable o) { if (o.GetComponent <Attackable> () && MasterAI.GetComponent <Attackable> ().CanAttack( o.GetComponent <Attackable> ().Faction)) { TargetTask.SetTargetObj(o.gameObject); //Debug.Log ("Triggering Transition"); TriggerTransition(); } }
public override void OnSight(Observable o) { if (o.GetComponent <LogicalObject>() && o.GetComponent <LogicalObject>().Label == ObjectSeen) { if (IfSeenInZone != "NONE") { bool inZone = ZoneManager.IsPointInZone(o.transform.position, IfSeenInZone); if (inZone && !TriggerIfInZone) { return; } if (!inZone && TriggerIfInZone) { return; } } TargetTask.SetTargetObj(o.gameObject); TriggerTransition(); } }
public void Execute() { var success = false; var attemptIndex = 0; do { ++attemptIndex; try { if (attemptIndex > 1 && TargetFailedTask != null) { Log.DebugFormat("Executing failure response task {0}", TargetFailedTask.Name); TargetFailedTask.Execute(); } TargetTask.Execute(); success = true; } catch (TE exception) { Log.ErrorFormat("Attempt #{0} to execute {1} failed: {2}", attemptIndex, TargetTask.Name, exception.Message); Log.Debug("Exception", exception); if (attemptIndex >= RetryCount) { Log.ErrorFormat("Reached limit of {0} retries of {1}", RetryCount, TargetTask.Name); throw; } if (RetryDelayMilliseconds > 0) { Log.InfoFormat("Waiting {0} milliseconds before retrying", RetryDelayMilliseconds); Thread.Sleep(RetryDelayMilliseconds); } } }while (!success); }
public override void OnSight(Observable o) { Debug.Log("On sight of : " + o); if (o.GetComponent <Attackable>() && o.GetComponent <Attackable>().Faction == TriggeringFaction) { Debug.Log("Faction is: " + TriggeringFaction); if (IfSeenInZone != "NONE") { bool inZone = ZoneManager.IsPointInZone(o.transform.position, IfSeenInZone); if (inZone && InvertInZoneCondition) { return; } if (!inZone && InvertInZoneCondition) { return; } } TargetTask.SetTargetObj(o.gameObject); TriggerTransition(); } }
public override void OnSight(Observable o) { Debug.Log("On sight of : " + o); if (ValidObject(o)) { Debug.Log("Faction is: " + TriggeringFaction); float d = Vector2.Distance(new Vector2(MasterAI.transform.position.x, MasterAI.transform.position.z), new Vector2(o.transform.position.x, o.transform.position.z)); if (DistanceCriteria == TransitionDistanceCriteria.WITHIN_DISTANCE_OF && d < Distance || DistanceCriteria == TransitionDistanceCriteria.OUTSIDE_DISTANCE_OF && d > Distance) { return; } if (TargetZoneCondition != ZoneCondition.DO_NOT_CHECK_FOR_ZONE) { bool inZone = ZoneManager.IsPointInZone(o.transform.position, ZoneName); if ((!inZone && TargetZoneCondition != ZoneCondition.IF_TARGET_IN_ZONE) || (inZone && TargetZoneCondition != ZoneCondition.IF_TARGET_OUT_OF_ZONE)) { return; } } if (MyZoneCondition != MyZoneCondition.DO_NOT_CHECK_FOR_ZONE) { bool inZone = ZoneManager.IsPointInZone(MasterAI.transform.position, MyZoneName); if ((!inZone && MyZoneCondition != MyZoneCondition.I_AM_IN_ZONE) || (inZone && MyZoneCondition != MyZoneCondition.I_AM_OUT_OF_ZONE)) { return; } } TargetTask.SetTargetObj(o.gameObject); TriggerTransition(); } }
// Read the build tasks from the registry private void InitializeTools() { string vsRoot = Common.GetLocalRegistryRoot(); // Open the "CodeTools" key RegistryKey root = Registry.LocalMachine.OpenSubKey(vsRoot + "\\CodeTools", false); if (root != null) { String[] toolKeys = root.GetSubKeyNames(); foreach (string toolName in toolKeys) { RegistryKey toolKey = root.OpenSubKey(toolName, false); if (toolKey != null) { Tool tool = new Tool(toolName); string displayName = (string)toolKey.GetValue("displayName"); if (displayName != null) { tool.toolName = displayName; } Common.Trace("New tool: " + tool.toolName); RegistryKey tasksKey = toolKey.OpenSubKey("Tasks",false); if (tasksKey!=null) { foreach (string projectType in tasksKey.GetSubKeyNames()) { Guid projectGuid = new Guid(projectType); RegistryKey projectKey = tasksKey.OpenSubKey(projectType, false); if (projectKey != null) { // Daan: projectGuid can be Guid.Empty Host host = new Host(projectGuid); foreach (string target in projectKey.GetSubKeyNames()) { RegistryKey targetKey = projectKey.OpenSubKey(target, false); if (targetKey != null) { foreach (string buildTask in targetKey.GetValueNames()) { if (buildTask != null && buildTask != null) { TargetTask ttask = new TargetTask(target, buildTask); host.targetTasks.Add(ttask); Common.Trace("+ Target: " + target + ", Task: " + buildTask + ", Project: " + projectGuid.ToString()); } } } } if (host.targetTasks.Count > 0) { tool.hosts.Add(host); } } } } if (tool.hosts.Count > 0) { tool.taskManager = new TaskManager(tool.toolName); tools.Add(tool); } } } } }
// Read the build tasks from the registry private void InitializeTools() { // Open the "CodeTools" key RegistryKey root = Registry.LocalMachine.OpenSubKey(Common.GetCodeToolsRegistryRoot(), false); if (root != null) { String[] toolKeys = root.GetSubKeyNames(); foreach (string toolName in toolKeys) { RegistryKey toolKey = root.OpenSubKey(toolName, false); if (toolKey != null) { int delay = (int)toolKey.GetValue("RefreshDelay", TaskManager.DefaultRefreshDelay); string displayName = (string)toolKey.GetValue("displayName"); Tool tool = new Tool(displayName != null ? displayName : toolName, delay); Common.Trace("New tool: " + tool.toolName); RegistryKey tasksKey = toolKey.OpenSubKey("Tasks", false); if (tasksKey != null) { foreach (string projectType in tasksKey.GetSubKeyNames()) { Guid projectGuid = new Guid(projectType); RegistryKey projectKey = tasksKey.OpenSubKey(projectType, false); if (projectKey != null) // Daan: projectGuid can be Guid.Empty { Host host = new Host(projectGuid); foreach (string target in projectKey.GetSubKeyNames()) { RegistryKey targetKey = projectKey.OpenSubKey(target, false); if (targetKey != null) { foreach (string buildTask in targetKey.GetValueNames()) { if (buildTask != null && buildTask != null) { TargetTask ttask = new TargetTask(target, buildTask); host.targetTasks.Add(ttask); Common.Trace("+ Target: " + target + ", Task: " + buildTask + ", Project: " + projectGuid.ToString()); } } } } if (host.targetTasks.Count > 0) { tool.hosts.Add(host); } } } } if (tool.hosts.Count > 0) { tool.taskManager = new TaskManager(tool.toolName, tool.refreshDelay); tools.Add(tool); } } } } }
public void Execute() { TargetTask.Execute(); }