//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); } }
//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 } }
///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); }
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); }
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.contextObject, "New Task"); } #endif newTask.SetOwnerSystem(newOwnerSystem); BBParameter.SetBBFields(newTask, newOwnerSystem.blackboard); newTask.OnValidate(newOwnerSystem); return(newTask); }
//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); }
///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); }
///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); }
///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); }
///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); }
///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); }
///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); }
///Validate the task in respects to the target ITaskSystem public void Validate(ITaskSystem ownerSystem) { SetOwnerSystem(ownerSystem); BBParameter.SetBBFields(this, ownerSystem.blackboard); OnValidate(ownerSystem); }