Browse Source

Renamed SequenceController to FungusScript

master
chrisgregan 10 years ago
parent
commit
f94203aaf9
  1. 8
      Assets/Fungus/Editor/CompareCommandEditor.cs
  2. 20
      Assets/Fungus/Editor/FungusEditorWindow.cs
  3. 8
      Assets/Fungus/Editor/FungusScriptEditor.cs
  4. 0
      Assets/Fungus/Editor/FungusScriptEditor.cs.meta
  5. 6
      Assets/Fungus/Editor/SequenceEditor.cs
  6. 4
      Assets/Fungus/Editor/SetVariableCommandEditor.cs
  7. BIN
      Assets/Fungus/Tests/Sequence/SequenceTest.unity
  8. 4
      Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs
  9. 2
      Assets/Fungus/VisualScripting/CompareCommand.cs
  10. 14
      Assets/Fungus/VisualScripting/FungusCommand.cs
  11. 2
      Assets/Fungus/VisualScripting/FungusScript.cs
  12. 0
      Assets/Fungus/VisualScripting/FungusScript.cs.meta
  13. 24
      Assets/Fungus/VisualScripting/Sequence.cs
  14. 4
      Assets/Fungus/VisualScripting/SetVariableCommand.cs

8
Assets/Fungus/Editor/CompareCommandEditor.cs

@ -1,4 +1,4 @@
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -13,7 +13,7 @@ namespace Fungus
{ {
CompareCommand t = target as CompareCommand; CompareCommand t = target as CompareCommand;
SequenceController sc = t.GetParentSequenceController(); FungusScript sc = t.GetParentFungusScript();
if (sc == null) if (sc == null)
{ {
return; return;
@ -115,11 +115,11 @@ namespace Fungus
} }
Sequence onTrue = SequenceEditor.SequenceField(new GUIContent("On True Sequence", "Sequence to execute if comparision is true"), Sequence onTrue = SequenceEditor.SequenceField(new GUIContent("On True Sequence", "Sequence to execute if comparision is true"),
t.GetParentSequenceController(), t.GetParentFungusScript(),
t.onTrueSequence); t.onTrueSequence);
Sequence onFalse = SequenceEditor.SequenceField(new GUIContent("On False Sequence", "Sequence to execute if comparision is false"), Sequence onFalse = SequenceEditor.SequenceField(new GUIContent("On False Sequence", "Sequence to execute if comparision is false"),
t.GetParentSequenceController(), t.GetParentFungusScript(),
t.onFalseSequence); t.onFalseSequence);
if (onTrue != t.onTrueSequence) if (onTrue != t.onTrueSequence)

20
Assets/Fungus/Editor/FungusEditorWindow.cs

@ -25,19 +25,19 @@ public class FungusEditorWindow : EditorWindow
Repaint(); Repaint();
} }
SequenceController GetSequenceController() FungusScript GetFungusScript()
{ {
GameObject activeObject = Selection.activeGameObject; GameObject activeObject = Selection.activeGameObject;
while (activeObject != null) while (activeObject != null)
{ {
SequenceController sequenceController = activeObject.GetComponent<SequenceController>(); FungusScript fungusScript = activeObject.GetComponent<FungusScript>();
Sequence sequence = activeObject.GetComponent<Sequence>(); Sequence sequence = activeObject.GetComponent<Sequence>();
if (sequenceController != null) if (fungusScript != null)
{ {
// Found sequence controller // Found sequence controller
return sequenceController; return fungusScript;
} }
else if (sequence != null && else if (sequence != null &&
sequence.transform.parent != null) sequence.transform.parent != null)
@ -56,13 +56,13 @@ public class FungusEditorWindow : EditorWindow
void OnGUI() void OnGUI()
{ {
SequenceController sequenceController = GetSequenceController(); FungusScript fungusScript = GetFungusScript();
if (sequenceController == null) if (fungusScript == null)
{ {
return; return;
} }
Sequence[] sequences = sequenceController.GetComponentsInChildren<Sequence>(); Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>();
Rect scrollViewRect = new Rect(); Rect scrollViewRect = new Rect();
@ -110,10 +110,10 @@ public class FungusEditorWindow : EditorWindow
GUI.EndScrollView(); GUI.EndScrollView();
string labelText = sequenceController.name; string labelText = fungusScript.name;
if (Application.isPlaying) if (Application.isPlaying)
{ {
if (sequenceController.activeSequence == null) if (fungusScript.activeSequence == null)
{ {
labelText += " (Idle)"; labelText += " (Idle)";
} }
@ -133,7 +133,7 @@ public class FungusEditorWindow : EditorWindow
GUILayout.Space(15); GUILayout.Space(15);
if (GUILayout.Button(labelText)) if (GUILayout.Button(labelText))
{ {
Selection.activeGameObject = sequenceController.gameObject; Selection.activeGameObject = fungusScript.gameObject;
} }
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();

8
Assets/Fungus/Editor/SequenceControllerEditor.cs → Assets/Fungus/Editor/FungusScriptEditor.cs

@ -1,4 +1,4 @@
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -39,8 +39,8 @@ public class VariableDrawer : PropertyDrawer
} }
} }
[CustomEditor (typeof(SequenceController))] [CustomEditor (typeof(FungusScript))]
public class SequenceControllerEditor : Editor public class FungusScriptEditor : Editor
{ {
SerializedProperty variablesProperty; SerializedProperty variablesProperty;
@ -53,7 +53,7 @@ public class SequenceControllerEditor : Editor
{ {
serializedObject.Update(); serializedObject.Update();
SequenceController t = target as SequenceController; FungusScript t = target as FungusScript;
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();

0
Assets/Fungus/Editor/SequenceControllerEditor.cs.meta → Assets/Fungus/Editor/FungusScriptEditor.cs.meta

6
Assets/Fungus/Editor/SequenceEditor.cs

@ -8,9 +8,9 @@ using Fungus;
public class SequenceEditor : Editor public class SequenceEditor : Editor
{ {
static public Sequence SequenceField(GUIContent label, SequenceController sequenceController, Sequence sequence) static public Sequence SequenceField(GUIContent label, FungusScript fungusScript, Sequence sequence)
{ {
if (sequenceController == null) if (fungusScript == null)
{ {
return null; return null;
} }
@ -22,7 +22,7 @@ public class SequenceEditor : Editor
int selectedIndex = 0; int selectedIndex = 0;
sequenceNames.Add(new GUIContent("<None>")); sequenceNames.Add(new GUIContent("<None>"));
Sequence[] sequences = sequenceController.GetComponentsInChildren<Sequence>(); Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>();
for (int i = 0; i < sequences.Length; ++i) for (int i = 0; i < sequences.Length; ++i)
{ {
sequenceNames.Add(new GUIContent(sequences[i].name)); sequenceNames.Add(new GUIContent(sequences[i].name));

4
Assets/Fungus/Editor/SetVariableCommandEditor.cs

@ -1,4 +1,4 @@
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -13,7 +13,7 @@ namespace Fungus
{ {
SetVariableCommand t = target as SetVariableCommand; SetVariableCommand t = target as SetVariableCommand;
SequenceController sc = t.GetParentSequenceController(); FungusScript sc = t.GetParentFungusScript();
if (sc == null) if (sc == null)
{ {
return; return;

BIN
Assets/Fungus/Tests/Sequence/SequenceTest.unity

Binary file not shown.

4
Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs

@ -4,11 +4,11 @@ using Fungus;
public class SequenceTestRoom : Room public class SequenceTestRoom : Room
{ {
public SequenceController sequenceController; public FungusScript fungusScript;
void OnEnter() void OnEnter()
{ {
sequenceController.Execute(); fungusScript.Execute();
/* /*
Sequence s = GetComponent<Sequence>(); Sequence s = GetComponent<Sequence>();

2
Assets/Fungus/VisualScripting/CompareCommand.cs

@ -35,7 +35,7 @@ namespace Fungus
public override void OnEnter() public override void OnEnter()
{ {
Variable v = parentSequenceController.GetVariable(variableKey); Variable v = parentFungusScript.GetVariable(variableKey);
bool condition = false; bool condition = false;

14
Assets/Fungus/VisualScripting/FungusCommand.cs

@ -1,4 +1,4 @@
#if UNITY_EDITOR #if UNITY_EDITOR
using UnityEditor; using UnityEditor;
#endif #endif
using UnityEngine; using UnityEngine;
@ -14,7 +14,7 @@ namespace Fungus
public string errorMessage = ""; public string errorMessage = "";
[HideInInspector] [HideInInspector]
public SequenceController parentSequenceController; public FungusScript parentFungusScript;
[HideInInspector] [HideInInspector]
public Sequence parentSequence; public Sequence parentSequence;
@ -22,17 +22,17 @@ namespace Fungus
public virtual void Start() public virtual void Start()
{ {
parentSequence = GetComponent<Sequence>(); parentSequence = GetComponent<Sequence>();
parentSequenceController = GetParentSequenceController(); parentFungusScript = GetParentFungusScript();
} }
public SequenceController GetParentSequenceController() public FungusScript GetParentFungusScript()
{ {
SequenceController sc = null; FungusScript sc = null;
Transform parent = transform.parent; Transform parent = transform.parent;
while (parent != null) while (parent != null)
{ {
sc = parent.gameObject.GetComponent<SequenceController>(); sc = parent.gameObject.GetComponent<FungusScript>();
if (sc != null) if (sc != null)
{ {
break; break;
@ -67,7 +67,7 @@ namespace Fungus
{ {
OnExit(); OnExit();
parentSequence.Finish(); parentSequence.Finish();
parentSequenceController.ExecuteSequence(s); parentFungusScript.ExecuteSequence(s);
} }
public virtual void OnEnter() public virtual void OnEnter()

2
Assets/Fungus/VisualScripting/SequenceController.cs → Assets/Fungus/VisualScripting/FungusScript.cs

@ -7,7 +7,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Fungus; using Fungus;
public class SequenceController : MonoBehaviour public class FungusScript : MonoBehaviour
{ {
public float stepTime; public float stepTime;

0
Assets/Fungus/VisualScripting/SequenceController.cs.meta → Assets/Fungus/VisualScripting/FungusScript.cs.meta

24
Assets/Fungus/VisualScripting/Sequence.cs

@ -17,23 +17,23 @@ namespace Fungus
public Rect nodeRect = new Rect(10, 10, 100, 100); public Rect nodeRect = new Rect(10, 10, 100, 100);
[System.NonSerialized] [System.NonSerialized]
public SequenceController sequenceController; public FungusScript fungusScript;
[System.NonSerialized] [System.NonSerialized]
public FungusCommand activeCommand; public FungusCommand activeCommand;
public virtual void Start() public virtual void Start()
{ {
sequenceController = GetSequenceController(); fungusScript = GetFungusScript();
} }
public SequenceController GetSequenceController() public FungusScript GetFungusScript()
{ {
SequenceController sc = null; FungusScript sc = null;
Transform parent = transform.parent; Transform parent = transform.parent;
while (parent != null) while (parent != null)
{ {
sc = parent.gameObject.GetComponent<SequenceController>(); sc = parent.gameObject.GetComponent<FungusScript>();
if (sc != null) if (sc != null)
{ {
break; break;
@ -58,13 +58,13 @@ namespace Fungus
public bool IsRunning() public bool IsRunning()
{ {
if (sequenceController == null || if (fungusScript == null ||
sequenceController.activeSequence == null) fungusScript.activeSequence == null)
{ {
return false; return false;
} }
return (sequenceController.activeSequence == this); return (fungusScript.activeSequence == this);
} }
public void ExecuteNextCommand(FungusCommand currentCommand = null) public void ExecuteNextCommand(FungusCommand currentCommand = null)
@ -93,14 +93,14 @@ namespace Fungus
} }
else else
{ {
if (sequenceController.stepTime == 0f) if (fungusScript.stepTime == 0f)
{ {
activeCommand = nextCommand; activeCommand = nextCommand;
nextCommand.Execute(); nextCommand.Execute();
} }
else else
{ {
StartCoroutine(ExecuteAfterDelay(nextCommand, sequenceController.stepTime)); StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.stepTime));
} }
} }
@ -116,11 +116,11 @@ namespace Fungus
public void Finish() public void Finish()
{ {
activeCommand = null; activeCommand = null;
sequenceController.activeSequence = null; fungusScript.activeSequence = null;
// No more commands to run in current sequence // No more commands to run in current sequence
#if UNITY_EDITOR #if UNITY_EDITOR
Selection.activeGameObject = sequenceController.gameObject; Selection.activeGameObject = fungusScript.gameObject;
#endif #endif
} }
} }

4
Assets/Fungus/VisualScripting/SetVariableCommand.cs

@ -1,4 +1,4 @@
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using Fungus; using Fungus;
@ -22,7 +22,7 @@ public class SetVariableCommand : FungusCommand
return; return;
} }
Variable v = parentSequenceController.GetVariable(variableKey); Variable v = parentFungusScript.GetVariable(variableKey);
if (v == null) if (v == null)
{ {
Debug.LogError("Variable " + variableKey + " not defined."); Debug.LogError("Variable " + variableKey + " not defined.");

Loading…
Cancel
Save