/// <summary> /// Skips all tasks whose id is not present in the skipTasks.json. /// </summary> private void SkipTasks() { if (debugMode) { return; } string path = Path.Combine(Application.streamingAssetsPath, "skipTasks.json"); if (!File.Exists(path)) { return; } Debug.LogError("WARNING: Tasks will be skipped!"); TaskIdList taskIdList = JsonHelper.DeserializeFromFile <TaskIdList>(Path.Combine(Application.streamingAssetsPath, "skipTasks.json")); List <string> taskIds = taskIdList.taskIds; List <string> dummyTaskIds = taskIdList.dummyTaskIds; // remove task if id is not present in the file foreach (KeyValuePair <TaskTypeDistance, List <Task> > pair in tasks) { pair.Value.RemoveAll(task => !taskIds.Contains(task.id)); } // remove TaskTypeDistance keys and the corresponding element in the taskTypeOrder list List <TaskTypeDistance> keysToRemove = new List <TaskTypeDistance>(); foreach (KeyValuePair <TaskTypeDistance, List <Task> > pair in tasks) { if (pair.Value.Count == 0) { keysToRemove.Add(pair.Key); } } foreach (TaskTypeDistance key in keysToRemove) { tasks.Remove(key); taskTypeOrder.Remove(key); } // remove dummy task if id is not present in the file dummyTasks.RemoveRange(0, dummyTasks.Count - dummyTaskIds.Count); }
private void taskExecuter(IEventPointer eventPointer, object[] eventParameters) { try { foreach (EventAction ea in eventHandlers) { EventPointer ep = eventPointer as EventPointer; if (ea.Event.IsSameObjectRef(ep)) { List <ParameterClass> eventValues = new List <ParameterClass>(); if (eventParameters != null && eventParameters.Length > 0) { ParameterInfo[] pifs = ep.Parameters; if (pifs.Length != eventParameters.Length) { throw new DesignerException("Event {0} parameter count mismatch", ep.MemberName); } for (int i = 0; i < pifs.Length; i++) { ParameterClass p = new ParameterClass(new TypePointer(pifs[i].ParameterType)); p.Name = pifs[i].Name; p.ObjectInstance = eventParameters[i]; eventValues.Add(p); } } //execute the event handlers TaskIdList actIdList = ea.TaskIDList; foreach (TaskID tid in actIdList) { UInt32 classId = tid.ClassId; //if (tid.IsGroup) //{ //} //else //{ //find the action in the list of all actions List <IAction> acts = null; if (classId == _map.ClassId) { acts = actions; } else { ObjectIDmap classmap = _map.GetMapByClassId(classId); if (classmap != null) { ActionEventCollection av = classmap.GetTypedData <ActionEventCollection>(); if (av == null) { av = new ActionEventCollection(classmap); classmap.SetTypedData <ActionEventCollection>(av); av.LoadActions(); } acts = av.actions; } } if (acts != null) { foreach (IAction a in acts) { if (a.ActionId == tid.ActionId) { a.Execute(eventValues); break; } } } //} } break; } } } catch (Exception err) { MathNode.Log(err); } }