/// <summary> /// Registers a mod handler function that will be called on every Update. /// </summary> /// <param name="modName">Mod Name.</param> /// <param name="handlerFunction">Handler function.</param> public bool RegisterUpdateModHandler(string modName, MessageCallback handlerFunction) { lock (EventLock) { if (RegisteredUpdateMods.ContainsKey(modName)) { Debug.Log($"[LMP]: Failed to register Update mod handler for {modName}, mod already registered"); return(false); } Debug.Log($"[LMP]: Registered Update mod handler for {modName}"); RegisteredUpdateMods.Add(modName, handlerFunction); UpdateQueue.Add(modName, new ConcurrentQueue <byte[]>()); } return(true); }
public void RequestUpdate(TextAreaUpdate update) { if (UpdateQueue.Count == 1 && UpdateQueue[0].TextAreaUpdateType == TextAreaUpdateType.WholeTextArea) { // if we're going to update the whole text area, we don't need to store detail updates return; } if (update.TextAreaUpdateType == TextAreaUpdateType.WholeTextArea) { // if we're going to update the whole text area, we don't need to store detail updates UpdateQueue.Clear(); } UpdateQueue.Add(update); }
/// <summary> /// Adds update information about an entity to the update queue after having received an attributeChanged event /// </summary> /// <param name="sender">Entity that invoked the attribute change event</param> /// <param name="e">Event Arguments</param> private void AddEntityUpdateToQueue(Object sender, ChangedAttributeEventArgs e) { bool gotLock = false; try { QueueLock.Enter(ref gotLock); UpdateQueue.Add(CreateUpdateInfoFromEventArgs((Entity)sender, e)); } finally { if (gotLock) { QueueLock.Exit(); } } }