first commit
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Name("Action State", 100)]
|
||||
[Description("Execute a number of Action Tasks OnEnter. All actions will be stoped OnExit. This state is Finished when all Actions are finished as well")]
|
||||
public class ActionState : FSMState, ITaskAssignable
|
||||
{
|
||||
|
||||
[SerializeField]
|
||||
private ActionList _actionList;
|
||||
[SerializeField]
|
||||
private bool _repeatStateActions;
|
||||
|
||||
public Task task {
|
||||
get { return actionList; }
|
||||
set { actionList = (ActionList)value; }
|
||||
}
|
||||
|
||||
public ActionList actionList {
|
||||
get { return _actionList; }
|
||||
set { _actionList = value; }
|
||||
}
|
||||
|
||||
public bool repeatStateActions {
|
||||
get { return _repeatStateActions; }
|
||||
set { _repeatStateActions = value; }
|
||||
}
|
||||
|
||||
public override void OnValidate(Graph assignedGraph) {
|
||||
if ( actionList == null ) {
|
||||
actionList = (ActionList)Task.Create(typeof(ActionList), assignedGraph);
|
||||
actionList.executionMode = ActionList.ActionsExecutionMode.ActionsRunInParallel;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnEnter() { OnUpdate(); }
|
||||
|
||||
protected override void OnUpdate() {
|
||||
var actionListStatus = actionList.Execute(graphAgent, graphBlackboard);
|
||||
if ( !repeatStateActions && actionListStatus != Status.Running ) {
|
||||
Finish(actionListStatus);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnExit() {
|
||||
actionList.EndAction(null);
|
||||
}
|
||||
|
||||
protected override void OnPause() {
|
||||
actionList.Pause();
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
///---------------------------------------UNITY EDITOR-------------------------------------------
|
||||
#if UNITY_EDITOR
|
||||
|
||||
protected override void OnNodeGUI() {
|
||||
if ( repeatStateActions ) {
|
||||
GUILayout.Label("<b>[REPEAT]</b>");
|
||||
}
|
||||
base.OnNodeGUI();
|
||||
}
|
||||
|
||||
protected override void OnNodeInspectorGUI() {
|
||||
|
||||
ShowTransitionsInspector();
|
||||
|
||||
if ( actionList == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
EditorUtils.CoolLabel("Actions");
|
||||
GUI.color = repeatStateActions ? GUI.color : new Color(1, 1, 1, 0.5f);
|
||||
repeatStateActions = UnityEditor.EditorGUILayout.ToggleLeft("Repeat State Actions", repeatStateActions);
|
||||
GUI.color = Color.white;
|
||||
actionList.ShowListGUI();
|
||||
actionList.ShowNestedActionsGUI();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddb1611039b7dac4ab5c471307d8c524
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/ActionState.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,122 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Name("Any State")]
|
||||
[Description("The transitions of this node will be constantly checked. If any becomes true, that transition will take place. This is not a state.")]
|
||||
[Color("b3ff7f")]
|
||||
public class AnyState : FSMNode, IUpdatable
|
||||
{
|
||||
|
||||
[Tooltip("If enabled, a transition to an already running state will not happen.")]
|
||||
public bool dontRetriggerStates = false;
|
||||
|
||||
public override string name { //yei for caps
|
||||
get { return "FROM ANY STATE"; }
|
||||
}
|
||||
|
||||
public override int maxInConnections { get { return 0; } }
|
||||
public override int maxOutConnections { get { return -1; } }
|
||||
public override bool allowAsPrime { get { return false; } }
|
||||
|
||||
public override void OnGraphStarted() {
|
||||
for ( var i = 0; i < outConnections.Count; i++ ) {
|
||||
( outConnections[i] as FSMConnection ).EnableCondition(graphAgent, graphBlackboard);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGraphStoped() {
|
||||
for ( var i = 0; i < outConnections.Count; i++ ) {
|
||||
( outConnections[i] as FSMConnection ).DisableCondition();
|
||||
}
|
||||
}
|
||||
|
||||
void IUpdatable.Update() {
|
||||
|
||||
if ( outConnections.Count == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
status = Status.Running;
|
||||
|
||||
for ( var i = 0; i < outConnections.Count; i++ ) {
|
||||
|
||||
var connection = (FSMConnection)outConnections[i];
|
||||
var condition = connection.condition;
|
||||
|
||||
if ( !connection.isActive || condition == null ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( dontRetriggerStates ) {
|
||||
if ( FSM.currentState == (FSMState)connection.targetNode && FSM.currentState.status == Status.Running ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( condition.Check(graphAgent, graphBlackboard) ) {
|
||||
FSM.EnterState((FSMState)connection.targetNode, connection.transitionCallMode);
|
||||
connection.status = Status.Success; //editor vis
|
||||
return;
|
||||
}
|
||||
|
||||
connection.status = Status.Failure; //editor vis
|
||||
}
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
///---------------------------------------UNITY EDITOR-------------------------------------------
|
||||
#if UNITY_EDITOR
|
||||
|
||||
protected override void OnNodeGUI() {
|
||||
base.OnNodeGUI();
|
||||
if ( dontRetriggerStates ) {
|
||||
UnityEngine.GUILayout.Label("<b>[NO RETRIGGER]</b>");
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetConnectionInfo(int index) {
|
||||
if ( ( outConnections[index] as FSMConnection ).condition == null ) {
|
||||
return "* Never Triggered *";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void OnNodeInspectorGUI() {
|
||||
EditorUtils.CoolLabel("Transitions");
|
||||
if ( outConnections.Count == 0 ) {
|
||||
UnityEditor.EditorGUILayout.HelpBox("No Transition", UnityEditor.MessageType.None);
|
||||
}
|
||||
|
||||
var anyNullCondition = false;
|
||||
EditorUtils.ReorderableList(outConnections, (i, picked) =>
|
||||
{
|
||||
var connection = (FSMConnection)outConnections[i];
|
||||
GUILayout.BeginHorizontal("box");
|
||||
if ( connection.condition != null ) {
|
||||
GUILayout.Label(connection.condition.summaryInfo, GUILayout.MinWidth(0), GUILayout.ExpandWidth(true));
|
||||
} else {
|
||||
GUILayout.Label("OnFinish (This is never triggered)", GUILayout.MinWidth(0), GUILayout.ExpandWidth(true));
|
||||
anyNullCondition = true;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label("► '" + connection.targetNode.name + "'");
|
||||
GUILayout.EndHorizontal();
|
||||
});
|
||||
|
||||
EditorUtils.BoldSeparator();
|
||||
|
||||
if ( anyNullCondition ) {
|
||||
UnityEditor.EditorGUILayout.HelpBox("This is not a state and as such it never finish, thus OnFinish transitions are never called.\nPlease add a condition in all transitions of this node.", UnityEditor.MessageType.Warning);
|
||||
}
|
||||
|
||||
dontRetriggerStates = UnityEditor.EditorGUILayout.ToggleLeft("Don't Retrigger Running States", dontRetriggerStates);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07c3b9fe69fee1641aa48869d70de213
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/AnyState.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,39 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Name("Parallel Sub FSM", -1)]
|
||||
[Description("Execute a Sub FSM in parallel and for as long as this FSM is running.")]
|
||||
[Category("SubGraphs")]
|
||||
[Color("ff64cb")]
|
||||
public class ConcurrentSubFSM : FSMNodeNested<FSM>, IUpdatable
|
||||
{
|
||||
|
||||
[SerializeField, ExposeField, Name("Parallel FSM")]
|
||||
protected BBParameter<FSM> _subFSM = null;
|
||||
|
||||
public override string name => base.name.ToUpper();
|
||||
public override int maxInConnections => 0;
|
||||
public override int maxOutConnections => 0;
|
||||
public override bool allowAsPrime => false;
|
||||
|
||||
public override FSM subGraph { get { return _subFSM.value; } set { _subFSM.value = value; } }
|
||||
public override BBParameter subGraphParameter => _subFSM;
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
public override void OnGraphStarted() {
|
||||
if ( subGraph == null ) { return; }
|
||||
status = Status.Running;
|
||||
this.TryStartSubGraph(graphAgent, (result) => { status = result ? Status.Success : Status.Failure; });
|
||||
}
|
||||
|
||||
void IUpdatable.Update() {
|
||||
this.TryUpdateSubGraph();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a8f80842481d7642b7398217e48a47e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/ConcurrentSubFSM.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,39 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
using NodeCanvas.BehaviourTrees;
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Name("Parallel Sub Behaviour Tree", -1)]
|
||||
[Description("Execute a Sub Behaviour Tree in parallel and for as long as this FSM is running.")]
|
||||
[Category("SubGraphs")]
|
||||
[Color("ff64cb")]
|
||||
public class ConcurrentSubTree : FSMNodeNested<BehaviourTree>, IUpdatable
|
||||
{
|
||||
|
||||
[SerializeField, ExposeField, Name("Parallel Tree")]
|
||||
protected BBParameter<BehaviourTree> _subTree = null;
|
||||
|
||||
public override string name => base.name.ToUpper();
|
||||
public override int maxInConnections => 0;
|
||||
public override int maxOutConnections => 0;
|
||||
public override bool allowAsPrime => false;
|
||||
|
||||
public override BehaviourTree subGraph { get { return _subTree.value; } set { _subTree.value = value; } }
|
||||
public override BBParameter subGraphParameter => _subTree;
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
public override void OnGraphStarted() {
|
||||
if ( subGraph == null ) { return; }
|
||||
status = Status.Running;
|
||||
this.TryStartSubGraph(graphAgent, (result) => { status = result ? Status.Success : Status.Failure; });
|
||||
}
|
||||
|
||||
void IUpdatable.Update() {
|
||||
this.TryUpdateSubGraph();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd5d84502c0a56842a0576cfbe8ce754
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/ConcurrentSubTree.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,21 @@
|
||||
using ParadoxNotion.Design;
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Description("This node has no functionality and you can use this for organization.\nIn comparison to an empty Action State, Transitions here are immediately evaluated in the same frame that this node is entered.")]
|
||||
[Color("6ebbff")]
|
||||
[Name("Pass", 98)]
|
||||
public class EmptyState : FSMState
|
||||
{
|
||||
|
||||
public override string name {
|
||||
get { return base.name.ToUpper(); }
|
||||
}
|
||||
|
||||
protected override void OnEnter() {
|
||||
Finish();
|
||||
CheckTransitions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8abe07e17374d204abec1e16fc1f0072
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/EmptyState.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,104 @@
|
||||
using NodeCanvas.BehaviourTrees;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Name("Sub BehaviourTree")]
|
||||
[Description("Execute a Behaviour Tree OnEnter. OnExit that Behavior Tree will be stoped or paused based on the relevant specified setting. You can optionaly specify a Success Event and a Failure Event which will be sent when the BT's root node status returns either of the two. If so, use alongside with a CheckEvent on a transition.")]
|
||||
[DropReferenceType(typeof(BehaviourTree))]
|
||||
[ParadoxNotion.Design.Icon("BT")]
|
||||
public class NestedBTState : FSMStateNested<BehaviourTree>
|
||||
{
|
||||
|
||||
public enum BTExecutionMode
|
||||
{
|
||||
Once,
|
||||
Repeat
|
||||
}
|
||||
|
||||
public enum BTExitMode
|
||||
{
|
||||
StopAndRestart,
|
||||
PauseAndResume
|
||||
}
|
||||
|
||||
[SerializeField, ExposeField, Name("Sub Tree")]
|
||||
private BBParameter<BehaviourTree> _nestedBT = null;
|
||||
[Tooltip("What will happen to the BT when this state exits.")]
|
||||
public BTExitMode exitMode = BTExitMode.StopAndRestart;
|
||||
[Tooltip("Sould the BT repeat?")]
|
||||
public BTExecutionMode executionMode = BTExecutionMode.Repeat;
|
||||
|
||||
[DimIfDefault, Tooltip("The event to send when the BT finish in Success.")]
|
||||
public string successEvent;
|
||||
[DimIfDefault, Tooltip("The event to send when the BT finish in Failure.")]
|
||||
public string failureEvent;
|
||||
|
||||
public override BehaviourTree subGraph { get { return _nestedBT.value; } set { _nestedBT.value = value; } }
|
||||
public override BBParameter subGraphParameter => _nestedBT;
|
||||
|
||||
//
|
||||
|
||||
protected override void OnEnter() {
|
||||
|
||||
if ( subGraph == null ) {
|
||||
Finish(false);
|
||||
return;
|
||||
}
|
||||
|
||||
currentInstance = (BehaviourTree)this.CheckInstance();
|
||||
currentInstance.repeat = ( executionMode == BTExecutionMode.Repeat );
|
||||
currentInstance.updateInterval = 0;
|
||||
this.TryWriteAndBindMappedVariables();
|
||||
currentInstance.StartGraph(graph.agent, graph.blackboard.parent, Graph.UpdateMode.Manual, OnFinish);
|
||||
OnUpdate();
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
|
||||
currentInstance.UpdateGraph(this.graph.deltaTime);
|
||||
|
||||
if ( !string.IsNullOrEmpty(successEvent) && currentInstance.rootStatus == Status.Success ) {
|
||||
currentInstance.Stop(true);
|
||||
}
|
||||
|
||||
if ( !string.IsNullOrEmpty(failureEvent) && currentInstance.rootStatus == Status.Failure ) {
|
||||
currentInstance.Stop(false);
|
||||
}
|
||||
}
|
||||
|
||||
void OnFinish(bool success) {
|
||||
if ( this.status == Status.Running ) {
|
||||
|
||||
this.TryReadAndUnbindMappedVariables();
|
||||
|
||||
if ( !string.IsNullOrEmpty(successEvent) && success ) {
|
||||
SendEvent(successEvent);
|
||||
}
|
||||
|
||||
if ( !string.IsNullOrEmpty(failureEvent) && !success ) {
|
||||
SendEvent(failureEvent);
|
||||
}
|
||||
|
||||
Finish(success);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnExit() {
|
||||
if ( currentInstance != null ) {
|
||||
if ( this.status == Status.Running ) {
|
||||
this.TryReadAndUnbindMappedVariables();
|
||||
}
|
||||
if ( exitMode == BTExitMode.StopAndRestart ) {
|
||||
currentInstance.Stop();
|
||||
} else {
|
||||
currentInstance.Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f783a6a0ceff66b4ab995ee26ffe5948
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/NestedBTState.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,63 @@
|
||||
using NodeCanvas.DialogueTrees;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Name("Sub Dialogue")]
|
||||
[Description("Execute the assigned Dialogue Tree OnEnter and stop it OnExit. Optionaly an event can be sent for whether the dialogue ended in Success or Failure. This can be controled by using the 'Finish' Dialogue Node inside the Dialogue Tree. Use a 'CheckEvent' condition to make use of those events. The 'Instigator' Actor of the Dialogue Tree will be set to this graph agent.")]
|
||||
[DropReferenceType(typeof(DialogueTree))]
|
||||
[ParadoxNotion.Design.Icon("Dialogue")]
|
||||
public class NestedDTState : FSMStateNested<DialogueTree>
|
||||
{
|
||||
|
||||
[SerializeField, ExposeField, Name("Sub Tree")]
|
||||
private BBParameter<DialogueTree> _nestedDLG = null;
|
||||
|
||||
[DimIfDefault, Tooltip("The event to send when the Dialogue Tree finished in Success.")]
|
||||
public string successEvent;
|
||||
[DimIfDefault, Tooltip("The event to send when the Dialogue Tree finish in Failure.")]
|
||||
public string failureEvent;
|
||||
|
||||
public override DialogueTree subGraph { get { return _nestedDLG.value; } set { _nestedDLG.value = value; } }
|
||||
public override BBParameter subGraphParameter => _nestedDLG;
|
||||
|
||||
//
|
||||
|
||||
protected override void OnEnter() {
|
||||
if ( subGraph == null ) {
|
||||
Finish(false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.TryStartSubGraph(graphAgent, OnDialogueFinished);
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
currentInstance.UpdateGraph(this.graph.deltaTime);
|
||||
}
|
||||
|
||||
protected override void OnExit() {
|
||||
if ( currentInstance != null ) {
|
||||
currentInstance.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDialogueFinished(bool success) {
|
||||
if ( this.status == Status.Running ) {
|
||||
if ( !string.IsNullOrEmpty(successEvent) && success ) {
|
||||
SendEvent(successEvent);
|
||||
}
|
||||
|
||||
if ( !string.IsNullOrEmpty(failureEvent) && !success ) {
|
||||
SendEvent(failureEvent);
|
||||
}
|
||||
|
||||
Finish(success);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b6030e6c23c1534ca4d4210998eb4d6
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/NestedDTState.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,61 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
|
||||
[Name("Sub FSM")]
|
||||
[Description("Execute a sub FSM OnEnter, and Stop that FSM OnExit. This state is Finished only when and if the sub FSM is finished as well.")]
|
||||
[DropReferenceType(typeof(FSM))]
|
||||
[ParadoxNotion.Design.Icon("FSM")]
|
||||
public class NestedFSMState : FSMStateNested<FSM>
|
||||
{
|
||||
|
||||
public enum FSMExitMode
|
||||
{
|
||||
StopAndRestart,
|
||||
PauseAndResume
|
||||
}
|
||||
|
||||
[SerializeField, ExposeField, Name("Sub FSM")]
|
||||
private BBParameter<FSM> _nestedFSM = null;
|
||||
|
||||
[Tooltip("What will happen to the sub FSM when this state exits.")]
|
||||
public FSMExitMode exitMode;
|
||||
|
||||
public override FSM subGraph { get { return _nestedFSM.value; } set { _nestedFSM.value = value; } }
|
||||
public override BBParameter subGraphParameter => _nestedFSM;
|
||||
|
||||
//
|
||||
|
||||
protected override void OnEnter() {
|
||||
if ( subGraph == null ) {
|
||||
Finish(false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.TryStartSubGraph(graphAgent, Finish);
|
||||
OnUpdate();
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
currentInstance.UpdateGraph(this.graph.deltaTime);
|
||||
}
|
||||
|
||||
protected override void OnExit() {
|
||||
if ( currentInstance != null ) {
|
||||
if ( this.status == Status.Running ) {
|
||||
this.TryReadAndUnbindMappedVariables();
|
||||
}
|
||||
if ( exitMode == FSMExitMode.StopAndRestart ) {
|
||||
currentInstance.Stop();
|
||||
} else {
|
||||
currentInstance.Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ba2d9e312e9fa145aae02b450447b07
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/NestedFSMState.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,85 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Description("Execute a number of Actions when the FSM starts/enters, if Conditions are met. This is not a state.")]
|
||||
[Color("ff64cb")]
|
||||
[ParadoxNotion.Design.Icon("MacroIn")]
|
||||
[Name("On FSM Enter")]
|
||||
public class OnFSMEnter : FSMNode, IUpdatable
|
||||
{
|
||||
|
||||
[SerializeField] private ConditionList _conditionList;
|
||||
[SerializeField] private ActionList _actionList;
|
||||
|
||||
public override string name => base.name.ToUpper();
|
||||
public override int maxInConnections => 0;
|
||||
public override int maxOutConnections => 0;
|
||||
public override bool allowAsPrime => false;
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
public override void OnValidate(Graph assignedGraph) {
|
||||
if ( _conditionList == null ) {
|
||||
_conditionList = (ConditionList)Task.Create(typeof(ConditionList), assignedGraph);
|
||||
_conditionList.checkMode = ConditionList.ConditionsCheckMode.AllTrueRequired;
|
||||
}
|
||||
if ( _actionList == null ) {
|
||||
_actionList = (ActionList)Task.Create(typeof(ActionList), assignedGraph);
|
||||
_actionList.executionMode = ActionList.ActionsExecutionMode.ActionsRunInParallel;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGraphStarted() {
|
||||
_conditionList.Enable(graphAgent, graphBlackboard);
|
||||
if ( _conditionList.Check(graphAgent, graphBlackboard) ) {
|
||||
status = _actionList.Execute(graphAgent, graphBlackboard);
|
||||
} else { status = Status.Failure; }
|
||||
}
|
||||
|
||||
public override void OnGraphStoped() {
|
||||
_conditionList.Disable();
|
||||
_actionList.EndAction(null);
|
||||
}
|
||||
|
||||
void IUpdatable.Update() {
|
||||
if ( status == Status.Running ) {
|
||||
status = _actionList.Execute(graphAgent, graphBlackboard);
|
||||
}
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
///---------------------------------------UNITY EDITOR-------------------------------------------
|
||||
#if UNITY_EDITOR
|
||||
|
||||
protected override void OnNodeGUI() {
|
||||
if ( _conditionList.conditions.Count > 0 ) {
|
||||
GUILayout.BeginVertical(Styles.roundedBox);
|
||||
GUILayout.Label(_conditionList.summaryInfo);
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
GUILayout.BeginVertical(Styles.roundedBox);
|
||||
GUILayout.Label(_actionList.summaryInfo);
|
||||
GUILayout.EndVertical();
|
||||
|
||||
base.OnNodeGUI();
|
||||
}
|
||||
|
||||
protected override void OnNodeInspectorGUI() {
|
||||
EditorUtils.CoolLabel("Conditions (optional)");
|
||||
_conditionList.ShowListGUI();
|
||||
_conditionList.ShowNestedConditionsGUI();
|
||||
EditorUtils.BoldSeparator();
|
||||
EditorUtils.CoolLabel("Actions");
|
||||
_actionList.ShowListGUI();
|
||||
_actionList.ShowNestedActionsGUI();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b14eff6fa54e645469e5f0902dc1e8f9
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/OnFSMEnter.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,80 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Description("Execute a number of Actions when the FSM stops/exits, if Conditions are met. Note that the actions will only execute for 1 frame. This is not a state.")]
|
||||
[Color("ff64cb")]
|
||||
[ParadoxNotion.Design.Icon("MacroOut")]
|
||||
[Name("On FSM Exit")]
|
||||
public class OnFSMExit : FSMNode
|
||||
{
|
||||
|
||||
[SerializeField] private ConditionList _conditionList;
|
||||
[SerializeField] private ActionList _actionList;
|
||||
|
||||
public override string name => base.name.ToUpper();
|
||||
public override int maxInConnections => 0;
|
||||
public override int maxOutConnections => 0;
|
||||
public override bool allowAsPrime => false;
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
public override void OnValidate(Graph assignedGraph) {
|
||||
if ( _conditionList == null ) {
|
||||
_conditionList = (ConditionList)Task.Create(typeof(ConditionList), assignedGraph);
|
||||
_conditionList.checkMode = ConditionList.ConditionsCheckMode.AllTrueRequired;
|
||||
}
|
||||
if ( _actionList == null ) {
|
||||
_actionList = (ActionList)Task.Create(typeof(ActionList), assignedGraph);
|
||||
_actionList.executionMode = ActionList.ActionsExecutionMode.ActionsRunInParallel;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGraphStarted() {
|
||||
_conditionList.Enable(graphAgent, graphBlackboard);
|
||||
}
|
||||
|
||||
public override void OnGraphStoped() {
|
||||
if ( _conditionList.Check(graphAgent, graphBlackboard) ) {
|
||||
_actionList.Execute(graphAgent, graphBlackboard);
|
||||
}
|
||||
_actionList.EndAction(null);
|
||||
_conditionList.Disable();
|
||||
}
|
||||
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
///---------------------------------------UNITY EDITOR-------------------------------------------
|
||||
#if UNITY_EDITOR
|
||||
|
||||
protected override void OnNodeGUI() {
|
||||
if ( _conditionList.conditions.Count > 0 ) {
|
||||
GUILayout.BeginVertical(Styles.roundedBox);
|
||||
GUILayout.Label(_conditionList.summaryInfo);
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
GUILayout.BeginVertical(Styles.roundedBox);
|
||||
GUILayout.Label(_actionList.summaryInfo);
|
||||
GUILayout.EndVertical();
|
||||
|
||||
base.OnNodeGUI();
|
||||
}
|
||||
|
||||
protected override void OnNodeInspectorGUI() {
|
||||
EditorUtils.CoolLabel("Conditions (optional)");
|
||||
_conditionList.ShowListGUI();
|
||||
_conditionList.ShowNestedConditionsGUI();
|
||||
EditorUtils.BoldSeparator();
|
||||
EditorUtils.CoolLabel("Actions");
|
||||
_actionList.ShowListGUI();
|
||||
_actionList.ShowNestedActionsGUI();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b690cf7166bc1c64984e93389fb62701
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/OnFSMExit.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,85 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Description("Execute a number of Actions repeatedly and in parallel to any other FSM state while the FSM is running. Conditions are optional. This is not a state.")]
|
||||
[Color("ff64cb")]
|
||||
[ParadoxNotion.Design.Icon("Repeat")]
|
||||
[Name("On FSM Update")]
|
||||
public class OnFSMUpdate : FSMNode, IUpdatable
|
||||
{
|
||||
|
||||
[SerializeField] private ConditionList _conditionList;
|
||||
[SerializeField] private ActionList _actionList;
|
||||
|
||||
public override string name => base.name.ToUpper();
|
||||
public override int maxInConnections => 0;
|
||||
public override int maxOutConnections => 0;
|
||||
public override bool allowAsPrime => false;
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
public override void OnValidate(Graph assignedGraph) {
|
||||
if ( _conditionList == null ) {
|
||||
_conditionList = (ConditionList)Task.Create(typeof(ConditionList), assignedGraph);
|
||||
_conditionList.checkMode = ConditionList.ConditionsCheckMode.AllTrueRequired;
|
||||
}
|
||||
if ( _actionList == null ) {
|
||||
_actionList = (ActionList)Task.Create(typeof(ActionList), assignedGraph);
|
||||
_actionList.executionMode = ActionList.ActionsExecutionMode.ActionsRunInParallel;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGraphStarted() {
|
||||
_conditionList.Enable(graphAgent, graphBlackboard);
|
||||
}
|
||||
|
||||
public override void OnGraphStoped() {
|
||||
_conditionList.Disable();
|
||||
_actionList.EndAction(null);
|
||||
}
|
||||
|
||||
void IUpdatable.Update() {
|
||||
if ( _conditionList.Check(graphAgent, graphBlackboard) ) {
|
||||
status = _actionList.Execute(graphAgent, graphBlackboard);
|
||||
} else {
|
||||
_actionList.EndAction(null);
|
||||
status = Status.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
///---------------------------------------UNITY EDITOR-------------------------------------------
|
||||
#if UNITY_EDITOR
|
||||
|
||||
protected override void OnNodeGUI() {
|
||||
if ( _conditionList.conditions.Count > 0 ) {
|
||||
GUILayout.BeginVertical(Styles.roundedBox);
|
||||
GUILayout.Label(_conditionList.summaryInfo);
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
GUILayout.BeginVertical(Styles.roundedBox);
|
||||
GUILayout.Label(_actionList.summaryInfo);
|
||||
GUILayout.EndVertical();
|
||||
|
||||
base.OnNodeGUI();
|
||||
}
|
||||
|
||||
protected override void OnNodeInspectorGUI() {
|
||||
EditorUtils.CoolLabel("Conditions (optional)");
|
||||
_conditionList.ShowListGUI();
|
||||
_conditionList.ShowNestedConditionsGUI();
|
||||
EditorUtils.BoldSeparator();
|
||||
EditorUtils.CoolLabel("Actions");
|
||||
_actionList.ShowListGUI();
|
||||
_actionList.ShowNestedActionsGUI();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e81c1848a517df4c9327dc6d65e75ff
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/OnFSMUpdate.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,127 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.StateMachines
|
||||
{
|
||||
|
||||
[Name("Action State (Super)", 99)]
|
||||
[Description("The Super Action State provides finer control on when to execute actions. This state is never Finished by it's own if there is any Actions in the OnUpdate list and thus OnFinish transitions will never be called in that case. OnExit Actions are only called for 1 frame when the state exits.")]
|
||||
public class SuperActionState : FSMState
|
||||
{
|
||||
|
||||
[SerializeField]
|
||||
private ActionList _onEnterList;
|
||||
[SerializeField]
|
||||
private ActionList _onUpdateList;
|
||||
[SerializeField]
|
||||
private ActionList _onExitList;
|
||||
|
||||
private bool enterListFinished = false;
|
||||
|
||||
public override void OnValidate(Graph assignedGraph) {
|
||||
if ( _onEnterList == null ) {
|
||||
_onEnterList = (ActionList)Task.Create(typeof(ActionList), assignedGraph);
|
||||
_onEnterList.executionMode = ActionList.ActionsExecutionMode.ActionsRunInParallel;
|
||||
}
|
||||
if ( _onUpdateList == null ) {
|
||||
_onUpdateList = (ActionList)Task.Create(typeof(ActionList), assignedGraph);
|
||||
_onUpdateList.executionMode = ActionList.ActionsExecutionMode.ActionsRunInParallel;
|
||||
}
|
||||
if ( _onExitList == null ) {
|
||||
_onExitList = (ActionList)Task.Create(typeof(ActionList), assignedGraph);
|
||||
_onExitList.executionMode = ActionList.ActionsExecutionMode.ActionsRunInParallel;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnEnter() {
|
||||
enterListFinished = false;
|
||||
OnUpdate();
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( !enterListFinished ) {
|
||||
var enterListStatus = _onEnterList.Execute(graphAgent, graphBlackboard);
|
||||
if ( enterListStatus != Status.Running ) {
|
||||
enterListFinished = true;
|
||||
if ( _onUpdateList.actions.Count == 0 ) {
|
||||
Finish(enterListStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
_onUpdateList.Execute(graphAgent, graphBlackboard);
|
||||
}
|
||||
|
||||
protected override void OnExit() {
|
||||
_onEnterList.EndAction(null);
|
||||
_onUpdateList.EndAction(null);
|
||||
_onExitList.Execute(graphAgent, graphBlackboard);
|
||||
_onExitList.EndAction(null);
|
||||
}
|
||||
|
||||
protected override void OnPause() {
|
||||
_onEnterList.Pause();
|
||||
_onUpdateList.Pause();
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
///---------------------------------------UNITY EDITOR-------------------------------------------
|
||||
#if UNITY_EDITOR
|
||||
|
||||
[SerializeField, ParadoxNotion.Serialization.FullSerializer.fsIgnoreInBuild]
|
||||
private bool foldEnter;
|
||||
[SerializeField, ParadoxNotion.Serialization.FullSerializer.fsIgnoreInBuild]
|
||||
private bool foldUpdate;
|
||||
[SerializeField, ParadoxNotion.Serialization.FullSerializer.fsIgnoreInBuild]
|
||||
private bool foldExit;
|
||||
|
||||
protected override void OnNodeGUI() {
|
||||
|
||||
GUILayout.BeginVertical(Styles.roundedBox);
|
||||
GUILayout.Label(string.Format("<i>{0} OnEnter Actions</i>", _onEnterList.actions.Count), Styles.leftLabel);
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.BeginVertical(Styles.roundedBox);
|
||||
GUILayout.Label(string.Format("<i>{0} OnUpdate Actions</i>", _onUpdateList.actions.Count), Styles.leftLabel);
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.BeginVertical(Styles.roundedBox);
|
||||
GUILayout.Label(string.Format("<i>{0} OnExit Actions</i>", _onExitList.actions.Count), Styles.leftLabel);
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
protected override void OnNodeInspectorGUI() {
|
||||
|
||||
ShowTransitionsInspector();
|
||||
|
||||
if ( _onEnterList == null || _onUpdateList == null || _onExitList == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
EditorUtils.CoolLabel("Actions");
|
||||
|
||||
foldEnter = UnityEditor.EditorGUILayout.Foldout(foldEnter, string.Format("OnEnter Actions ({0})", _onEnterList.actions.Count));
|
||||
if ( foldEnter ) {
|
||||
_onEnterList.ShowListGUI();
|
||||
_onEnterList.ShowNestedActionsGUI();
|
||||
}
|
||||
EditorUtils.Separator();
|
||||
|
||||
foldUpdate = UnityEditor.EditorGUILayout.Foldout(foldUpdate, string.Format("OnUpdate Actions ({0})", _onUpdateList.actions.Count));
|
||||
if ( foldUpdate ) {
|
||||
_onUpdateList.ShowListGUI();
|
||||
_onUpdateList.ShowNestedActionsGUI();
|
||||
}
|
||||
EditorUtils.Separator();
|
||||
|
||||
foldExit = UnityEditor.EditorGUILayout.Foldout(foldExit, string.Format("OnExit Actions ({0})", _onExitList.actions.Count));
|
||||
if ( foldExit ) {
|
||||
_onExitList.ShowListGUI();
|
||||
_onExitList.ShowNestedActionsGUI();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0aefad866fbf9c45b00499f08198f4d
|
||||
timeCreated: 1447866445
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/SuperActionState.cs
|
||||
uploadId: 704937
|
||||
Reference in New Issue
Block a user