Beispiel #1
0
 //Update all graph node's BBFields for current Blackboard.
 void UpdateNodeBBFields()
 {
     for (var i = 0; i < allNodes.Count; i++)
     {
         BBParameter.SetBBFields(allNodes[i], blackboard);
     }
 }
 //Update all graph node's BBFields for current Blackboard. Also called when agent or blackboard change
 void UpdateNodeBBFields()
 {
     foreach (var node in allNodes)
     {
         BBParameter.SetBBFields(node, blackboard);
     }
 }
Beispiel #3
0
 //Set the target blackboard for all BBVariables found in this instance. This is done every time the blackboard of the Task is set to a new value
 //as well as when the owner system is set by SetOwnerSystem
 void UpdateBBFields(IBlackboard bb)
 {
     BBParameter.SetBBFields(this, bb);
     if (overrideAgent != null)
     {
         overrideAgent.bb = bb;                 //explicitely set TaskAgent BBParameter since it's private
     }
 }
Beispiel #4
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);
        }
Beispiel #5
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 #6
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 #7
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 #8
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 #9
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.contextObject, "New Task");
            }
                        #endif

            newTask.SetOwnerSystem(newOwnerSystem);
            BBParameter.SetBBFields(newTask, newOwnerSystem.blackboard);
            newTask.OnValidate(newOwnerSystem);
            return(newTask);
        }
Beispiel #10
0
        //Duplicate the task for the target ITaskSystem
        virtual public Task Duplicate(ITaskSystem newOwnerSystem)
        {
            //Deep clone
            var newTask = JSONSerializer.Deserialize <Task>(JSONSerializer.Serialize(typeof(Task), this));

                        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                UnityEditor.Undo.RecordObject(newOwnerSystem.contextObject, "Duplicate Task");
            }
                        #endif

            newTask.SetOwnerSystem(newOwnerSystem);
            BBParameter.SetBBFields(newTask, newOwnerSystem.blackboard);
            newTask.OnValidate(newOwnerSystem);
            return(newTask);
        }
Beispiel #11
0
        ///Duplicate node alone assigned to the provided graph
        public Node Duplicate(Graph targetGraph)
        {
            if (targetGraph == null)
            {
                ParadoxNotion.Services.Logger.LogError("Can't duplicate a Node without providing a Target Graph", "NodeCanvas");
                return(null);
            }

            //deep clone
            var newNode = JSONSerializer.Clone <Node>(this);

            if (targetGraph != null)
            {
                targetGraph.RecordUndo("Duplicate Node");
            }

            targetGraph.allNodes.Add(newNode);
            newNode.inConnections.Clear();
            newNode.outConnections.Clear();

            if (targetGraph == this.graph)
            {
                newNode.position += new Vector2(50, 50);
            }

            newNode._UID  = null;
            newNode.graph = targetGraph;
            BBParameter.SetBBFields(newNode, targetGraph.blackboard);

            //--
            // var assignable = this as ITaskAssignable;
            // if ( assignable != null && assignable.task != null ) {
            //     ( newNode as ITaskAssignable ).task = assignable.task.Duplicate(targetGraph);
            // }

            foreach (var task in Graph.GetTasksInElement(newNode))
            {
                task.Validate(targetGraph);
            }
            //--

            newNode.OnValidate(targetGraph);
            return(newNode);
        }
Beispiel #12
0
        ///Create a new Node of type and assigned to the provided graph. Use this for constructor
        public static Node Create(Graph targetGraph, System.Type nodeType, Vector2 pos)
        {
            if (targetGraph == null)
            {
                Logger.LogError("Can't Create a Node without providing a Target Graph", LogTag.GRAPH);
                return(null);
            }

            var newNode = (Node)System.Activator.CreateInstance(nodeType);

            UndoUtility.RecordObject(targetGraph, "Create Node");

            newNode.graph    = targetGraph;
            newNode.position = pos;
            BBParameter.SetBBFields(newNode, targetGraph.blackboard);
            newNode.Validate(targetGraph);
            newNode.OnCreate(targetGraph);
            UndoUtility.SetDirty(targetGraph);
            return(newNode);
        }
Beispiel #13
0
        ///Duplicate node alone assigned to the provided graph
        public Node Duplicate(Graph targetGraph)
        {
            if (targetGraph == null)
            {
                Debug.LogError("Can't duplicate a Node without providing a Target Graph");
                return(null);
            }

            //deep clone
            var newNode = JSONSerializer.Deserialize <Node>(JSONSerializer.Serialize(typeof(Node), this));

                        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                UnityEditor.Undo.RecordObject(targetGraph, "Duplicate");
            }
                        #endif

            targetGraph.allNodes.Add(newNode);
            newNode.inConnections.Clear();
            newNode.outConnections.Clear();

            if (targetGraph == this.graph)
            {
                newNode.nodePosition += new Vector2(50, 50);
            }

            newNode.graph = targetGraph;
            BBParameter.SetBBFields(newNode, targetGraph.blackboard);

            var assignable = this as ITaskAssignable;
            if (assignable != null && assignable.task != null)
            {
                (newNode as ITaskAssignable).task = assignable.task.Duplicate(targetGraph);
            }

            newNode.OnValidate(targetGraph);
            return(newNode);
        }
Beispiel #14
0
        ///Create a new Node of type and assigned to the provided graph. Use this for constructor
        public static Node Create(Graph targetGraph, System.Type nodeType, Vector2 pos)
        {
            if (targetGraph == null)
            {
                ParadoxNotion.Services.Logger.LogError("Can't Create a Node without providing a Target Graph", "NodeCanvas");
                return(null);
            }

            var newNode = (Node)System.Activator.CreateInstance(nodeType);

            if (targetGraph != null)
            {
                targetGraph.RecordUndo("Create Node");
            }

            newNode.graph    = targetGraph;
            newNode.position = pos;
            BBParameter.SetBBFields(newNode, targetGraph.blackboard);

            newNode.OnValidate(targetGraph);
            newNode.OnCreate(targetGraph);
            return(newNode);
        }
Beispiel #15
0
        ///Create a new Node of type and assigned to the provided graph. Use this for constructor
        public static Node Create(Graph targetGraph, System.Type nodeType, Vector2 pos)
        {
            if (targetGraph == null)
            {
                Debug.LogError("Can't Create a Node without providing a Target Graph");
                return(null);
            }

            var newNode = (Node)System.Activator.CreateInstance(nodeType);

                        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                UnityEditor.Undo.RecordObject(targetGraph, "Create Node");
            }
                        #endif

            newNode.graph        = targetGraph;
            newNode.nodePosition = pos;
            BBParameter.SetBBFields(newNode, targetGraph.blackboard);

            newNode.OnValidate(targetGraph);
            return(newNode);
        }
Beispiel #16
0
        ///Duplicate node alone assigned to the provided graph
        public Node Duplicate(Graph targetGraph)
        {
            if (targetGraph == null)
            {
                Logger.LogError("Can't duplicate a Node without providing a Target Graph", LogTag.GRAPH);
                return(null);
            }

            //deep clone
            var newNode = JSONSerializer.Clone <Node>(this);

            UndoUtility.RecordObject(targetGraph, "Duplicate Node");

            targetGraph.allNodes.Add(newNode);
            newNode.inConnections.Clear();
            newNode.outConnections.Clear();

            if (targetGraph == this.graph)
            {
                newNode.position += new Vector2(50, 50);
            }

            newNode._UID  = null;
            newNode.graph = targetGraph;
            BBParameter.SetBBFields(newNode, targetGraph.blackboard);

            foreach (var task in Graph.GetTasksInElement(newNode))
            {
                task.Validate(targetGraph);
            }
            //--

            newNode.Validate(targetGraph);
            UndoUtility.SetDirty(targetGraph);
            return(newNode);
        }
Beispiel #17
0
 ///Validate the task in respects to the target ITaskSystem
 public void Validate(ITaskSystem ownerSystem)
 {
     SetOwnerSystem(ownerSystem);
     BBParameter.SetBBFields(this, ownerSystem.blackboard);
     OnValidate(ownerSystem);
 }