/// <summary> /// Executes a registered method within the event tables. If only one argument is parsed /// then the Global Event Table is executed. /// </summary> /// <param name="input">The user's input</param> public void TryExecuteCommand(string input) { // Trim the input of trailing white spaces and split the string into an array of strings. var args = input.Trim().Split(delimiter); if (args.Length > 1) { var parameters = argParser.ParseParameters(CopyArgs(args, 2)); int intValue = argParser.TryParseInt(args[1]); if (cache.IsIdCached(intValue)) { InvokeRelativeEvent(args[0], intValue, parameters); var objectArg = cache[intValue]; GlobalEventHandler.InvokeEvent(args[0], System.Convert.ChangeType(objectArg, objectArg.GetType())); } else { GlobalEventHandler.InvokeEvent(args[0], intValue); } } else { InvokeGlobalEvent(args[0]); } }
/// <summary> /// Adds a custom message to the scrollable console view. This supports RTF (rich text format). /// </summary> /// <param name="text">The custom message to show on the console</param> /// <param name="textColor">The default color of the text</param> public static void Log(string text, Color textColor) { GlobalEventHandler.InvokeEvent(ConsoleEvents.OutputEvent, text, textColor); }
/// <summary> /// Invokes a global event which removes the instance Id fo an object and its associated object. /// This invokes all instances of the scriptable object of type IdCache. /// </summary> /// <param name="id">The Id to remove.</param> public static void RemoveInstanceId(int id) { GlobalEventHandler.InvokeEvent <int>(Events.ConsoleEvents.RemoveEvent, id); }
/// <summary> /// Invokes a global event which store the instance Id of an object and the associated object. /// This invokes all instances of the scriptable object of type IdCache. /// </summary> /// <param name="id">The unique id of the object.</param> /// <param name="instance">The object associated with the id.</param> public static void CacheInstanceId(int id, object instance) { GlobalEventHandler.InvokeEvent <int, object>(Events.ConsoleEvents.CacheEvent, id, instance); }
private void InvokeGlobalEvent(string eventName) { GlobalEventHandler.InvokeEvent(eventName); }