public override void OnValidate(ITaskSystem ownerSystem) { if (functionWrapper != null && functionWrapper.HasChanged()) { functionWrapper = ReflectedFunctionWrapper.Create(functionWrapper.GetMethod(), blackboard); } }
//Shows a button that when clicked, pops a context menu with a list of tasks deriving the base type specified. When something is selected the callback is called //On top of that it also shows a search field for Tasks public static void ShowCreateTaskSelectionButton(ITaskSystem ownerSystem, Type baseType, Action <Task> callback) { GUI.backgroundColor = Colors.lightBlue; var label = "Assign " + baseType.Name.SplitCamelCase(); if (GUILayout.Button(label)) { Action <Type> TaskTypeSelected = (t) => { var newTask = Task.Create(t, ownerSystem); UndoUtility.RecordObject(ownerSystem.contextObject, "New Task"); callback(newTask); }; var menu = EditorUtils.GetTypeSelectionMenu(baseType, TaskTypeSelected); if (CopyBuffer.TryGetCache <Task>(out Task copy) && baseType.IsAssignableFrom(copy.GetType())) { menu.AddSeparator("/"); menu.AddItem(new GUIContent(string.Format("Paste ({0})", copy.name)), false, () => { callback(copy.Duplicate(ownerSystem)); }); } menu.ShowAsBrowser(label, typeof(Task)); } GUILayout.Space(2); GUI.backgroundColor = Color.white; }
public override void OnValidate(ITaskSystem ownerSystem) { if (functionWrapper != null && functionWrapper.HasChanged()) { SetMethod(functionWrapper.GetMethod()); } }
public override void OnValidate(ITaskSystem ownerSystem) { base.OnValidate(ownerSystem); SetOwnerSystem(ownerSystem); if (actionTasks == null) { actionTasks = (ActionList)Task.Create(typeof(ActionList), ownerSystem); actionTasks.executionMode = ActionList.ActionsExecutionMode.ActionsRunInParallel; } if (conditionTasks == null) { conditionTasks = (ConditionList)Task.Create(typeof(ConditionList), ownerSystem); conditionTasks.checkMode = ConditionList.ConditionsCheckMode.AllTrueRequired; } conditionTasks.OnValidate(ownerSystem); actionTasks.OnValidate(ownerSystem); conditionTasks.SetOwnerSystem(this.ownerSystem); actionTasks.SetOwnerSystem(this.ownerSystem); foreach (ConditionTask c in conditionTasks.conditions) { c.SetOwnerSystem(this.ownerSystem); } foreach (ActionTask a in actionTasks.actions) { a.SetOwnerSystem(this.ownerSystem); } }
public override void OnValidate(ITaskSystem ownerSystem) { if (method != null && method.HasChanged()) { SetMethod(method); } }
public override Task Duplicate(ITaskSystem newOwnerSystem) { var newConditionnedAction = (MultipleCondition)base.Duplicate(newOwnerSystem); newConditionnedAction.conditionTasks = (ConditionList)conditionTasks.Duplicate(newOwnerSystem); return(newConditionnedAction); }
///Duplicate the task for the target ITaskSystem virtual public Task Duplicate(ITaskSystem newOwnerSystem) { //Deep clone var newTask = JSONSerializer.Clone <Task>(this); newOwnerSystem.RecordUndo("Duplicate Task"); newTask.Validate(newOwnerSystem); return(newTask); }
///Duplicate the task for the target ITaskSystem virtual public Task Duplicate(ITaskSystem newOwnerSystem) { var newTask = JSONSerializer.Clone <Task>(this); UndoUtility.RecordObject(newOwnerSystem.contextObject, "Duplicate Task"); BBParameter.SetBBFields(newTask, newOwnerSystem.blackboard); newTask.Validate(newOwnerSystem); return(newTask); }
///ConditionList overrides to duplicate listed conditions correctly public override Task Duplicate(ITaskSystem newOwnerSystem){ var newList = (ConditionList)base.Duplicate(newOwnerSystem); newList.conditions.Clear(); foreach (var condition in conditions){ newList.AddCondition( (ConditionTask)condition.Duplicate(newOwnerSystem) ); } return newList; }
///ActionList overrides to duplicate listed actions correctly public override Task Duplicate(ITaskSystem newOwnerSystem){ var newList = (ActionList)base.Duplicate(newOwnerSystem); newList.actions.Clear(); foreach (var action in actions){ newList.AddAction( (ActionTask)action.Duplicate(newOwnerSystem) ); } return newList; }
public override void OnValidate(ITaskSystem ownerSystem) { if (method != null && method.HasChanged()){ SetMethod(method.Get()); } if (method != null && method.Get() == null){ Error( string.Format("Missing Method '{0}'", method.GetMethodString()) ); } }
public static Task Create(Type type, ITaskSystem newOwnerSystem) { var newTask = (Task)Activator.CreateInstance(type); newOwnerSystem.RecordUndo("New Task"); newTask.Validate(newOwnerSystem); newTask.OnCreate(newOwnerSystem); return(newTask); }
public override void OnValidate(ITaskSystem ownerSystem) { if (functionWrapper != null && functionWrapper.HasChanged()){ SetMethod(functionWrapper.GetMethod()); } if (functionWrapper != null && targetMethod == null){ Error(string.Format("Missing Method '{0}'", functionWrapper.GetMethodString())); } }
//Shows a button that when clicked, pops a context menu with a list of tasks deriving the base type specified. When something is selected the callback is called //On top of that it also shows a search field for Tasks public static void TaskSelectionButton(ITaskSystem ownerSystem, Type baseType, Action <Task> callback) { Action <Type> TaskTypeSelected = (t) => { var newTask = Task.Create(t, ownerSystem); Undo.RecordObject(ownerSystem.baseObject, "New Task"); callback(newTask); }; GUI.backgroundColor = lightBlue; if (GUILayout.Button("Add " + baseType.Name.SplitCamelCase())) { var menu = GetTypeSelectionMenu(baseType, TaskTypeSelected); if (Task.copiedTask != null && baseType.IsAssignableFrom(Task.copiedTask.GetType())) { menu.AddItem(new GUIContent(string.Format("Paste ({0})", Task.copiedTask.name)), false, () => { callback(Task.copiedTask.Duplicate(ownerSystem)); }); } menu.ShowAsContext(); Event.current.Use(); } GUI.backgroundColor = Color.white; GUILayout.BeginHorizontal(); var search = EditorGUILayout.TextField(lastSearch, (GUIStyle)"ToolbarSeachTextField"); if (GUILayout.Button("", (GUIStyle)"ToolbarSeachCancelButton")) { search = string.Empty; GUIUtility.keyboardControl = 0; } GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(search)) { if (search != lastSearch) { searchResults = GetScriptInfosOfType(baseType); } GUILayout.BeginVertical("TextField"); foreach (var taskInfo in searchResults) { if (taskInfo.name.ToLower().Contains(search.ToLower())) { if (GUILayout.Button(taskInfo.name)) { search = string.Empty; GUIUtility.keyboardControl = 0; TaskTypeSelected(taskInfo.type); } } } GUILayout.EndVertical(); } lastSearch = search; }
public ChangeUserForm(ITaskSystem tsystem, User Admin) { InitializeComponent(); TSystem = tsystem; _admin = Admin; foreach (var user in TSystem.GetUsersByName(_admin, "")) { usersListBox.Items.Add(user); } }
// //These are special so I write them first public void SetOwnerSystem(ITaskSystem newOwnerSystem) { if (newOwnerSystem == null) { return; } _ownerSystem = (MonoBehaviour)newOwnerSystem; UpdateBBFields(newOwnerSystem.blackboard); }
public static Task Create(Type type, ITaskSystem newOwnerSystem) { var newTask = (Task)Activator.CreateInstance(type); UndoUtility.RecordObject(newOwnerSystem.contextObject, "New Task"); BBParameter.SetBBFields(newTask, newOwnerSystem.blackboard); newTask.Validate(newOwnerSystem); newTask.OnCreate(newOwnerSystem); return(newTask); }
//Duplicate the task for the target ITaskSystem virtual public Task Duplicate(ITaskSystem newOwnerSystem) { //Deep clone var newTask = JSONSerializer.Clone <Task>(this); newOwnerSystem.RecordUndo("Duplicate Task"); newTask.SetOwnerSystem(newOwnerSystem); BBParameter.SetBBFields(newTask, newOwnerSystem.blackboard); newTask.OnValidate(newOwnerSystem); return(newTask); }
public static Task Create(Type type, ITaskSystem newOwnerSystem) { var newTask = (Task)Activator.CreateInstance(type); newOwnerSystem.RecordUndo("New Task"); newTask.SetOwnerSystem(newOwnerSystem); BBParameter.SetBBFields(newTask, newOwnerSystem.blackboard); newTask.OnValidate(newOwnerSystem); newTask.OnCreate(newOwnerSystem); return(newTask); }
///Validate the task in respects to the target ITaskSystem public void Validate(ITaskSystem ownerSystem) { SetOwnerSystem(ownerSystem); OnValidate(ownerSystem); var hardError = GetHardError(); if (hardError != null) { Logger.LogError(hardError, LogTag.VALIDATION, this); } }
//Following are special so they are declared first //... ///Sets the system in which this task lives in and initialize BBVariables. Called on Initialization of the system. public void SetOwnerSystem(ITaskSystem newOwnerSystem) { if (newOwnerSystem == null) { Debug.LogError("ITaskSystem set in task is null"); return; } ownerSystem = newOwnerSystem; UpdateBBFields(newOwnerSystem.blackboard); }
///ActionList overrides to duplicate listed actions correctly public override Task Duplicate(ITaskSystem newOwnerSystem) { var newList = (ActionList)base.Duplicate(newOwnerSystem); newList.actions.Clear(); foreach (var action in actions) { newList.AddAction((ActionTask)action.Duplicate(newOwnerSystem)); } return(newList); }
public static void TaskField(Task task, ITaskSystem ownerSystem, Type baseType, Action <Task> callback) { if (task == null) { TaskSelectionButton(ownerSystem, baseType, callback); } else { Task.ShowTaskInspectorGUI(task, callback); } }
public override void OnValidate(ITaskSystem ownerSystem) { if (functionWrapper != null && functionWrapper.HasChanged()) { SetMethod(functionWrapper.GetMethod()); } if (functionWrapper != null && targetMethod == null) { Error(string.Format("Missing Property '{0}'", functionWrapper.GetMethodString())); } }
public override void OnValidate(ITaskSystem ownerSystem) { if (method != null && method.HasChanged()) { SetMethod(method.Get()); } if (method != null && method.Get() == null) { Error(string.Format("Missing Method '{0}'", method.GetMethodString())); } }
public EditUserForm(ITaskSystem newSys, User newAdmin) { InitializeComponent(); Admin = newAdmin; TSystem = newSys; _selectedUser = null; foreach (var user in TSystem.GetUsersByName(TSystem.ActualUser, "")) { usersListBox.Items.Add(user); } }
///ConditionList overrides to duplicate listed conditions correctly public override Task Duplicate(ITaskSystem newOwnerSystem) { var newList = (ConditionList)base.Duplicate(newOwnerSystem); newList.conditions.Clear(); foreach (var condition in conditions) { newList.AddCondition((ConditionTask)condition.Duplicate(newOwnerSystem)); } return(newList); }
//Shows a button that when clicked, pops a context menu with a list of tasks deriving the base type specified. When something is selected the callback is called //On top of that it also shows a search field for Tasks public static void ShowCreateTaskSelectionButton(ITaskSystem ownerSystem, Type baseType, Action <Task> callback) { Action <Type> TaskTypeSelected = (t) => { var newTask = Task.Create(t, ownerSystem); Undo.RecordObject(ownerSystem.contextObject, "New Task"); callback(newTask); }; Func <GenericMenu> GetMenu = () => { var menu = EditorUtils.GetTypeSelectionMenu(baseType, TaskTypeSelected); if (CopyBuffer.Has <Task>() && baseType.IsAssignableFrom(CopyBuffer.Peek <Task>().GetType())) { menu.AddSeparator("/"); menu.AddItem(new GUIContent(string.Format("Paste ({0})", CopyBuffer.Peek <Task>().name)), false, () => { callback(CopyBuffer.Get <Task>().Duplicate(ownerSystem)); }); } return(menu); }; GUI.backgroundColor = Colors.lightBlue; var label = "Assign " + baseType.Name.SplitCamelCase(); if (GUILayout.Button(label)) { GetMenu().ShowAsBrowser(label, typeof(Task)); } GUI.backgroundColor = Color.white; search = EditorUtils.SearchField(search); if (!string.IsNullOrEmpty(search)) { GUILayout.BeginVertical("TextField"); var itemAdded = false; foreach (var taskInfo in EditorUtils.GetScriptInfosOfType(baseType).OrderBy(i => StringUtils.ScoreSearchMatch(search, i.name))) { if (StringUtils.SearchMatch(search, taskInfo.name, taskInfo.category)) { itemAdded = true; if (GUILayout.Button(taskInfo.name)) { search = string.Empty; GUIUtility.keyboardControl = 0; TaskTypeSelected(taskInfo.type); } } } if (!itemAdded) { GUILayout.Label("No results to display with current search input."); } GUILayout.EndVertical(); } }
public static Task Create(Type type, ITaskSystem newOwnerSystem) { if (type.IsGenericTypeDefinition) { type = type.MakeGenericType(type.GetFirstGenericParameterConstraintType()); } var newTask = (Task)Activator.CreateInstance(type); UndoUtility.RecordObject(newOwnerSystem.contextObject, "New Task"); BBParameter.SetBBFields(newTask, newOwnerSystem.blackboard); newTask.Validate(newOwnerSystem); newTask.OnCreate(newOwnerSystem); return(newTask); }
///Create a new Task of type assigned to the target ITaskSystem public static Task Create(Type type, ITaskSystem newOwnerSystem) { var newTask = (Task)Activator.CreateInstance(type); #if UNITY_EDITOR if (!Application.isPlaying) { UnityEditor.Undo.RecordObject(newOwnerSystem.baseObject, "New Task"); } #endif newTask.SetOwnerSystem(newOwnerSystem); newTask.OnValidate(newOwnerSystem); return(newTask); }
public AppMain(ITaskSystem system) { this._system = system; originalUser = system.ActualUser; InitializeComponent(); fillListBox(_system.GetTaskList(), taskListBox); countTotalTime(); if (!_system.ActualUser.IsAdmin) { administrationToolStripMenuItem.Enabled = false; menuStrip1.Refresh(); } this.Text = "Task System - " + (originalUser?.Name ?? _system.ActualUser.Name); }
//Following are special so they are declared first //... ///Sets the system in which this task lives in and initialize BBVariables. Called on Initialization of the system. public void SetOwnerSystem(ITaskSystem newOwnerSystem) { if (newOwnerSystem == null) { Debug.LogError("ITaskSystem set in task is null!!"); return; } ownerSystem = newOwnerSystem; //setting the bb in editor to update bbfields. in runtime, bbfields are updated when the task init. #if UNITY_EDITOR && CONVENIENCE_OVER_PERFORMANCE blackboard = newOwnerSystem.blackboard; #endif }
//Following are special so they are declared first //... ///Sets the system in which this task lives in and initialize BBVariables. Called on Initialization of the system. public void SetOwnerSystem(ITaskSystem newOwnerSystem) { if (newOwnerSystem == null) { ParadoxNotion.Services.Logger.LogError("ITaskSystem set in task is null!!", "Init", this); return; } ownerSystem = newOwnerSystem; //setting the bb in editor to update bbfields. in build runtime, bbfields are updated when the task init. #if UNITY_EDITOR && CONVENIENCE_OVER_PERFORMANCE blackboard = newOwnerSystem.blackboard; #endif }
//Duplicate the task for the target ITaskSystem virtual public Task Duplicate(ITaskSystem newOwnerSystem) { //Deep clone var newTask = JSON.Deserialize <Task>(JSON.Serialize(typeof(Task), this)); #if UNITY_EDITOR if (!Application.isPlaying) { UnityEditor.Undo.RecordObject(newOwnerSystem.baseObject, "Duplicate Task"); } #endif newTask.SetOwnerSystem(newOwnerSystem); newTask.OnValidate(newOwnerSystem); return(newTask); }
public override void OnValidate(ITaskSystem ownerSystem) { if (method != null && method.HasChanged()){ SetMethod(method.Get()); } }
public override void OnValidate(ITaskSystem ownerSystem) { if (functionWrapper != null && functionWrapper.HasChanged()){ functionWrapper = ReflectedFunctionWrapper.Create(functionWrapper.GetMethod(), blackboard); } }