Beispiel #1
0
 public override void OnValidate(ITaskSystem ownerSystem)
 {
     if (functionWrapper != null && functionWrapper.HasChanged())
     {
         functionWrapper = ReflectedFunctionWrapper.Create(functionWrapper.GetMethod(), blackboard);
     }
 }
Beispiel #2
0
        //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;
        }
Beispiel #3
0
 public override void OnValidate(ITaskSystem ownerSystem)
 {
     if (functionWrapper != null && functionWrapper.HasChanged())
     {
         SetMethod(functionWrapper.GetMethod());
     }
 }
Beispiel #4
0
    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);
        }
    }
Beispiel #5
0
 public override void OnValidate(ITaskSystem ownerSystem)
 {
     if (method != null && method.HasChanged())
     {
         SetMethod(method);
     }
 }
Beispiel #6
0
    public override Task Duplicate(ITaskSystem newOwnerSystem)
    {
        var newConditionnedAction = (MultipleCondition)base.Duplicate(newOwnerSystem);

        newConditionnedAction.conditionTasks = (ConditionList)conditionTasks.Duplicate(newOwnerSystem);

        return(newConditionnedAction);
    }
Beispiel #7
0
        ///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);
        }
Beispiel #8
0
        ///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()) );
     }
 }
Beispiel #12
0
        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);
        }
Beispiel #13
0
 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;
        }
Beispiel #15
0
 public ChangeUserForm(ITaskSystem tsystem, User Admin)
 {
     InitializeComponent();
     TSystem = tsystem;
     _admin  = Admin;
     foreach (var user in TSystem.GetUsersByName(_admin, ""))
     {
         usersListBox.Items.Add(user);
     }
 }
Beispiel #16
0
        //


        //These are special so I write them first
        public void SetOwnerSystem(ITaskSystem newOwnerSystem)
        {
            if (newOwnerSystem == null)
            {
                return;
            }

            _ownerSystem = (MonoBehaviour)newOwnerSystem;
            UpdateBBFields(newOwnerSystem.blackboard);
        }
Beispiel #17
0
        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);
        }
Beispiel #18
0
        //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);
        }
Beispiel #19
0
        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);
        }
Beispiel #20
0
        ///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);
            }
        }
Beispiel #21
0
        //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);
     }
 }
Beispiel #24
0
 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);
     }
 }
Beispiel #27
0
        ///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);
        }
Beispiel #28
0
        //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();
            }
        }
Beispiel #29
0
        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);
        }
Beispiel #30
0
        ///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);
        }
Beispiel #31
0
        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);
        }
Beispiel #32
0
        //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
        }
Beispiel #33
0
        //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
        }
Beispiel #34
0
        //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());
     }
 }
Beispiel #36
0
 public override void OnValidate(ITaskSystem ownerSystem)
 {
     if (functionWrapper != null && functionWrapper.HasChanged()){
         functionWrapper = ReflectedFunctionWrapper.Create(functionWrapper.GetMethod(), blackboard);
     }
 }