|
|
@ -158,7 +158,8 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Tell all components that implement IUpdateable to update to the new version |
|
|
|
// Tell all components that implement IUpdateable to update to the new version |
|
|
|
foreach (Component component in GetComponents<Component>()) |
|
|
|
var components = GetComponents<Component>(); |
|
|
|
|
|
|
|
foreach (var component in components) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IUpdateable u = component as IUpdateable; |
|
|
|
IUpdateable u = component as IUpdateable; |
|
|
|
if (u != null) |
|
|
|
if (u != null) |
|
|
@ -213,7 +214,8 @@ namespace Fungus |
|
|
|
// It shouldn't happen but it seemed to occur for a user on the forum |
|
|
|
// It shouldn't happen but it seemed to occur for a user on the forum |
|
|
|
variables.RemoveAll(item => item == null); |
|
|
|
variables.RemoveAll(item => item == null); |
|
|
|
|
|
|
|
|
|
|
|
foreach (Variable variable in GetComponents<Variable>()) |
|
|
|
var allVariables = GetComponents<Variable>(); |
|
|
|
|
|
|
|
foreach (var variable in allVariables) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!variables.Contains(variable)) |
|
|
|
if (!variables.Contains(variable)) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -222,8 +224,8 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var blocks = GetComponents<Block>(); |
|
|
|
var blocks = GetComponents<Block>(); |
|
|
|
|
|
|
|
var commands = GetComponents<Command>(); |
|
|
|
foreach (var command in GetComponents<Command>()) |
|
|
|
foreach (var command in commands) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool found = false; |
|
|
|
bool found = false; |
|
|
|
foreach (var block in blocks) |
|
|
|
foreach (var block in blocks) |
|
|
@ -241,7 +243,8 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (EventHandler eventHandler in GetComponents<EventHandler>()) |
|
|
|
var eventHandlers = GetComponents<EventHandler>(); |
|
|
|
|
|
|
|
foreach (var eventHandler in eventHandlers) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool found = false; |
|
|
|
bool found = false; |
|
|
|
foreach (var block in blocks) |
|
|
|
foreach (var block in blocks) |
|
|
@ -279,8 +282,8 @@ namespace Fungus |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public static void BroadcastFungusMessage(string messageName) |
|
|
|
public static void BroadcastFungusMessage(string messageName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MessageReceived[] eventHandlers = UnityEngine.Object.FindObjectsOfType<MessageReceived>(); |
|
|
|
var eventHandlers = UnityEngine.Object.FindObjectsOfType<MessageReceived>(); |
|
|
|
foreach (MessageReceived eventHandler in eventHandlers) |
|
|
|
foreach (var eventHandler in eventHandlers) |
|
|
|
{ |
|
|
|
{ |
|
|
|
eventHandler.OnSendFungusMessage(messageName); |
|
|
|
eventHandler.OnSendFungusMessage(messageName); |
|
|
|
} |
|
|
|
} |
|
|
@ -506,7 +509,7 @@ namespace Fungus |
|
|
|
public virtual void StopAllBlocks() |
|
|
|
public virtual void StopAllBlocks() |
|
|
|
{ |
|
|
|
{ |
|
|
|
var blocks = GetComponents<Block>(); |
|
|
|
var blocks = GetComponents<Block>(); |
|
|
|
foreach (Block block in blocks) |
|
|
|
foreach (var block in blocks) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (block.IsExecuting()) |
|
|
|
if (block.IsExecuting()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -521,8 +524,8 @@ namespace Fungus |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public virtual void SendFungusMessage(string messageName) |
|
|
|
public virtual void SendFungusMessage(string messageName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MessageReceived[] eventHandlers = GetComponents<MessageReceived>(); |
|
|
|
var eventHandlers = GetComponents<MessageReceived>(); |
|
|
|
foreach (MessageReceived eventHandler in eventHandlers) |
|
|
|
foreach (var eventHandler in eventHandlers) |
|
|
|
{ |
|
|
|
{ |
|
|
|
eventHandler.OnSendFungusMessage(messageName); |
|
|
|
eventHandler.OnSendFungusMessage(messageName); |
|
|
|
} |
|
|
|
} |
|
|
@ -553,7 +556,7 @@ namespace Fungus |
|
|
|
while (true) |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool collision = false; |
|
|
|
bool collision = false; |
|
|
|
foreach(Variable variable in variables) |
|
|
|
foreach(var variable in variables) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (variable == null || |
|
|
|
if (variable == null || |
|
|
|
variable == ignoreVariable || |
|
|
|
variable == ignoreVariable || |
|
|
@ -640,7 +643,8 @@ namespace Fungus |
|
|
|
while (true) |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool collision = false; |
|
|
|
bool collision = false; |
|
|
|
foreach (var command in block.CommandList) |
|
|
|
var commandList = block.CommandList; |
|
|
|
|
|
|
|
foreach (var command in commandList) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Label label = command as Label; |
|
|
|
Label label = command as Label; |
|
|
|
if (label == null || |
|
|
|
if (label == null || |
|
|
@ -673,7 +677,7 @@ namespace Fungus |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public Variable GetVariable(string key) |
|
|
|
public Variable GetVariable(string key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable variable in variables) |
|
|
|
foreach (var variable in variables) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (variable != null && variable.Key == key) |
|
|
|
if (variable != null && variable.Key == key) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -692,7 +696,7 @@ namespace Fungus |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public T GetVariable<T>(string key) where T : Variable |
|
|
|
public T GetVariable<T>(string key) where T : Variable |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable variable in variables) |
|
|
|
foreach (var variable in variables) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (variable != null && variable.Key == key) |
|
|
|
if (variable != null && variable.Key == key) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -710,7 +714,7 @@ namespace Fungus |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public void SetVariable<T>(string key, T newvariable) where T : Variable |
|
|
|
public void SetVariable<T>(string key, T newvariable) where T : Variable |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable v in variables) |
|
|
|
foreach (var v in variables) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (v != null && v.Key == key) |
|
|
|
if (v != null && v.Key == key) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -732,7 +736,7 @@ namespace Fungus |
|
|
|
public virtual List<Variable> GetPublicVariables() |
|
|
|
public virtual List<Variable> GetPublicVariables() |
|
|
|
{ |
|
|
|
{ |
|
|
|
List<Variable> publicVariables = new List<Variable>(); |
|
|
|
List<Variable> publicVariables = new List<Variable>(); |
|
|
|
foreach (Variable v in variables) |
|
|
|
foreach (var v in variables) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (v != null && v.Scope == VariableScope.Public) |
|
|
|
if (v != null && v.Scope == VariableScope.Public) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -874,8 +878,8 @@ namespace Fungus |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (hideComponents) |
|
|
|
if (hideComponents) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Block[] blocks = GetComponents<Block>(); |
|
|
|
var blocks = GetComponents<Block>(); |
|
|
|
foreach (Block block in blocks) |
|
|
|
foreach (var block in blocks) |
|
|
|
{ |
|
|
|
{ |
|
|
|
block.hideFlags = HideFlags.HideInInspector; |
|
|
|
block.hideFlags = HideFlags.HideInInspector; |
|
|
|
if (block.gameObject != gameObject) |
|
|
|
if (block.gameObject != gameObject) |
|
|
@ -884,13 +888,13 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Command[] commands = GetComponents<Command>(); |
|
|
|
var commands = GetComponents<Command>(); |
|
|
|
foreach (var command in commands) |
|
|
|
foreach (var command in commands) |
|
|
|
{ |
|
|
|
{ |
|
|
|
command.hideFlags = HideFlags.HideInInspector; |
|
|
|
command.hideFlags = HideFlags.HideInInspector; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
EventHandler[] eventHandlers = GetComponents<EventHandler>(); |
|
|
|
var eventHandlers = GetComponents<EventHandler>(); |
|
|
|
foreach (var eventHandler in eventHandlers) |
|
|
|
foreach (var eventHandler in eventHandlers) |
|
|
|
{ |
|
|
|
{ |
|
|
|
eventHandler.hideFlags = HideFlags.HideInInspector; |
|
|
|
eventHandler.hideFlags = HideFlags.HideInInspector; |
|
|
@ -898,8 +902,8 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
MonoBehaviour[] monoBehaviours = GetComponents<MonoBehaviour>(); |
|
|
|
var monoBehaviours = GetComponents<MonoBehaviour>(); |
|
|
|
foreach (MonoBehaviour monoBehaviour in monoBehaviours) |
|
|
|
foreach (var monoBehaviour in monoBehaviours) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (monoBehaviour == null) |
|
|
|
if (monoBehaviour == null) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -947,7 +951,7 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
if (resetVariables) |
|
|
|
if (resetVariables) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable variable in variables) |
|
|
|
foreach (var variable in variables) |
|
|
|
{ |
|
|
|
{ |
|
|
|
variable.OnReset(); |
|
|
|
variable.OnReset(); |
|
|
|
} |
|
|
|
} |
|
|
@ -959,7 +963,7 @@ namespace Fungus |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public virtual bool IsCommandSupported(CommandInfoAttribute commandInfo) |
|
|
|
public virtual bool IsCommandSupported(CommandInfoAttribute commandInfo) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (string key in hideCommands) |
|
|
|
foreach (var key in hideCommands) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Match on category or command name (case insensitive) |
|
|
|
// Match on category or command name (case insensitive) |
|
|
|
if (String.Compare(commandInfo.Category, key, StringComparison.OrdinalIgnoreCase) == 0 || |
|
|
|
if (String.Compare(commandInfo.Category, key, StringComparison.OrdinalIgnoreCase) == 0 || |
|
|
@ -1037,7 +1041,7 @@ namespace Fungus |
|
|
|
string key = match.Value.Substring(2, match.Value.Length - 3); |
|
|
|
string key = match.Value.Substring(2, match.Value.Length - 3); |
|
|
|
|
|
|
|
|
|
|
|
// Look for any matching private variables in this Flowchart first |
|
|
|
// Look for any matching private variables in this Flowchart first |
|
|
|
foreach (Variable variable in variables) |
|
|
|
foreach (var variable in variables) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (variable == null) |
|
|
|
if (variable == null) |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -1089,7 +1093,7 @@ namespace Fungus |
|
|
|
string key = match.Value.Substring(2, match.Value.Length - 3); |
|
|
|
string key = match.Value.Substring(2, match.Value.Length - 3); |
|
|
|
|
|
|
|
|
|
|
|
// Look for any matching public variables in this Flowchart |
|
|
|
// Look for any matching public variables in this Flowchart |
|
|
|
foreach (Variable variable in variables) |
|
|
|
foreach (var variable in variables) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (variable == null) |
|
|
|
if (variable == null) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|