/// <summary> /// take and execute one action from the ConcurrentBag if any item exist /// </summary> public ActionDef TryExecuteAction() { ActionDef action; if (UiActions.TryTake(out action)) { action.ActionService.Act(action.ActionData); } return(action); }
/// <summary> /// take and execute all actions from the ConcurrentBag if any item exist /// </summary> public bool TryExecuteActions() { int count = 0; while (UiActions.Count > 0) { ActionDef action; if (UiActions.TryTake(out action)) { action.ActionService.Act(action.ActionData); count++; } } return(count > 0); }