/// <summary> /// Dispatches an event for a robot. /// </summary> /// <remarks> /// Too old events will not be dispatched and a critical event is always dispatched. /// </remarks> /// <param name="evnt">is the event to dispatch to the robot.</param> private void Dispatch(Event evnt) { if (robot != null && evnt != null) { try { // skip too old events if ((evnt.Time > Time - MAX_EVENT_STACK) || HiddenAccessN.IsCriticalEvent(evnt)) { HiddenAccessN.Dispatch(evnt, robot, robotProxy.getStatics(), robotProxy.getGraphicsImpl()); } } catch (Exception ex) { if (ex is SecurityException) { robotProxy.punishSecurityViolation(robotProxy.getStatics().getName() + " " + ex.Message); } else if (ex.InnerException is SecurityException) { robotProxy.punishSecurityViolation(robotProxy.getStatics().getName() + " " + ex.InnerException + ": " + ex.Message); } else if (!(ex is EventInterruptedException || ex is AbortedException || ex is DeathException || ex is DisabledException || ex is WinException)) { robotProxy.println("SYSTEM: " + ex.GetType().Name + " occurred on " + evnt.GetType().Name); robotProxy.GetOut().WriteLine(ex.StackTrace); } throw; } } }
/// <summary> /// Adds an event to the event queue. /// </summary> /// <param name="evnt">is the event to add to the event queue.</param> public void Add(Event evnt) { if (!HiddenAccessN.IsCriticalEvent(evnt)) { int priority = GetEventPriority(evnt.GetType().Name); HiddenAccessN.SetEventPriority(evnt, priority); } AddImpl(evnt); }
/// <summary> /// Registers the full and simple class name of the specified event and sets the default /// priority of the event class. /// </summary> /// <param name="evnt">an event belonging to the event class to register the class name for etc.</param> private void registerEventNames(Event evnt) { if (!HiddenAccessN.IsCriticalEvent(evnt)) { HiddenAccessN.SetDefaultPriority(evnt); } Type type = evnt.GetType(); eventNames.Add(type.FullName, evnt); // full name with package name eventNames.Add(type.Name, evnt); // only the class name }
public void clear(long clearTime) { for (int i = 0; i < Count; i++) { Event e = this[i]; if ((e.Time <= clearTime) && !HiddenAccessN.IsCriticalEvent(e)) { RemoveAt(i--); } } }
public void clear(bool includingSystemEvents) { if (includingSystemEvents) { Clear(); return; } for (int i = 0; i < Count; i++) { Event e = this[i]; if (!HiddenAccessN.IsCriticalEvent(e)) { RemoveAt(i--); } } }
/// <summary> /// Sets the event priority of events belonging to a specific class. /// </summary> /// <param name="eventClass"> /// is a string with the full class name of the event type to set the priority for.</param> /// <param name="priority">is the new priority</param> public void SetEventPriority(string eventClass, int priority) { if (eventClass == null) { return; } Event evnt; if (!eventNames.TryGetValue(eventClass, out evnt)) { robotProxy.println("SYSTEM: Unknown event class: " + eventClass); return; } if (HiddenAccessN.IsCriticalEvent(evnt)) { robotProxy.println("SYSTEM: You may not change the priority of a system event."); } HiddenAccessN.SetEventPriority(evnt, priority); }