Browse Source

Collection (#787)

Add concept of Collection to Fungus.
Add Collection Demo, Physics Cast Demo.

They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons.

A number of refactorings and additions along with this to make it work more seamlessly.

Variable operators defined by Variable itself
Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach
AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands
PlayMode Tests and Utils added
Additional Variable Types, such as Quaternion, Matrix4x4
Physics casts Commands that use collections


* Initial Fungus Collection work with support for int and IntegerVariable

* While and Condition related changes to allow for new command Loop Range

* Collection Get changes and ForEach rough

* Added Collection Commands
Reordered Elif logic in Condition

* More collection types and commands

* Variable reorg to allow for new types to be added more simply and centrally

* Added more Fungus Vars for Common Unity types
VariableList Adapter can delegate to the variable itself for custom drawing
Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion
Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block
VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types

* Many basic collection operations added
Common Collection types
Physics Overlap command

* Custom variable drawing moved to VariableInfo.cs rather than child variable itself
Added Physics cast and overlap commands

* Move all Editor scripts into Editor AsmDef folder

* LoopRange also registers as command name For

* Condition base class commenting improved and refactored repeated looping style child class elements into base

* More descriptive CollectionBase Command class names

* Fungus Collection interface and comments refined

* Rename ICollection to IFungusCollection
Cleanup formatting

* Collection example scene

* Added Collection Tests

* Format collection and test files
Added CopyFrom to IFungusCollection

* Added FungusCollection initial summaries

* Added CollectionRandom commands
-added simple use to CollectionLoop demo scene

* Added Unique to FungusCollection
-Updated tests to include unique
Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects

* CollectionPhysics tracks mousepos with visual
Added Fungus Command to get mouse position

* Variable custom draw moved to its own editor class, no longer part of typeinfo
Variable generation run

* Add playmode test for variable type sets
Add playmode test for flow control

* Update doco and formatting for Collection classes
Refactor parts of Conditional classes and AnyVariable
Move Property commands into Category 'Property'

* Update Collection comments, formatting and Update internal to public

* Add License header to added variable types
master
Steve Halliwell 5 years ago committed by GitHub
parent
commit
f2d1b38490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 70
      Assets/Fungus/Scripts/Commands/AssertCommand.cs
  2. 11
      Assets/Fungus/Scripts/Commands/AssertCommand.cs.meta
  3. 44
      Assets/Fungus/Scripts/Commands/Break.cs
  4. 5
      Assets/Fungus/Scripts/Commands/Collection.meta
  5. 35
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs
  6. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs.meta
  7. 42
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs
  8. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs.meta
  9. 50
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs
  10. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs.meta
  11. 47
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs
  12. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs.meta
  13. 54
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs
  14. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs.meta
  15. 39
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs
  16. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs.meta
  17. 39
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs
  18. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs.meta
  19. 27
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs
  20. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs.meta
  21. 37
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs
  22. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs.meta
  23. 53
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs
  24. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs.meta
  25. 37
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs
  26. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs.meta
  27. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs
  28. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs.meta
  29. 25
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs
  30. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs.meta
  31. 53
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs
  32. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs.meta
  33. 24
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs
  34. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs.meta
  35. 41
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs
  36. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs.meta
  37. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs
  38. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs.meta
  39. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs
  40. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs.meta
  41. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs
  42. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs.meta
  43. 39
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs
  44. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs.meta
  45. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs
  46. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs.meta
  47. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs
  48. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs.meta
  49. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs
  50. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs.meta
  51. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs
  52. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs.meta
  53. 27
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs
  54. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs.meta
  55. 27
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs
  56. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs.meta
  57. 27
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs
  58. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs.meta
  59. 27
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs
  60. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs.meta
  61. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs
  62. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs.meta
  63. 80
      Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs
  64. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs.meta
  65. 90
      Assets/Fungus/Scripts/Commands/Collection/ForEach.cs
  66. 11
      Assets/Fungus/Scripts/Commands/Collection/ForEach.cs.meta
  67. 51
      Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs
  68. 11
      Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs.meta
  69. 162
      Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs
  70. 11
      Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs.meta
  71. 154
      Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs
  72. 11
      Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs.meta
  73. 147
      Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs
  74. 11
      Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs.meta
  75. 136
      Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs
  76. 11
      Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs.meta
  77. 219
      Assets/Fungus/Scripts/Commands/Condition.cs
  78. 32
      Assets/Fungus/Scripts/Commands/Else.cs
  79. 10
      Assets/Fungus/Scripts/Commands/ElseIf.cs
  80. 19
      Assets/Fungus/Scripts/Commands/End.cs
  81. 8
      Assets/Fungus/Scripts/Commands/If.cs
  82. 89
      Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs
  83. 11
      Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs.meta
  84. 84
      Assets/Fungus/Scripts/Commands/LoopRange.cs
  85. 11
      Assets/Fungus/Scripts/Commands/LoopRange.cs.meta
  86. 13
      Assets/Fungus/Scripts/Commands/LuaCondition.cs
  87. 10
      Assets/Fungus/Scripts/Commands/LuaElseIf.cs
  88. 5
      Assets/Fungus/Scripts/Commands/LuaIf.cs
  89. 2
      Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs
  90. 8
      Assets/Fungus/Scripts/Commands/Property.meta
  91. 292
      Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs
  92. 11
      Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs.meta
  93. 261
      Assets/Fungus/Scripts/Commands/Property/AudioSourceProperty.cs
  94. 11
      Assets/Fungus/Scripts/Commands/Property/AudioSourceProperty.cs.meta
  95. 125
      Assets/Fungus/Scripts/Commands/Property/CollectionProperty.cs
  96. 11
      Assets/Fungus/Scripts/Commands/Property/CollectionProperty.cs.meta
  97. 153
      Assets/Fungus/Scripts/Commands/Property/Collider2DProperty.cs
  98. 13
      Assets/Fungus/Scripts/Commands/Property/Collider2DProperty.cs.meta
  99. 123
      Assets/Fungus/Scripts/Commands/Property/ColliderProperty.cs
  100. 13
      Assets/Fungus/Scripts/Commands/Property/ColliderProperty.cs.meta
  101. Some files were not shown because too many files have changed in this diff Show More

70
Assets/Fungus/Scripts/Commands/AssertCommand.cs

@ -0,0 +1,70 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
using UnityEngine.Assertions;
namespace Fungus
{
/// <summary>
/// Assert on 2 Fungus variable values.
/// </summary>
[CommandInfo("Scripting",
"Assert",
"Assert based on compared values.")]
[AddComponentMenu("")]
public class AssertCommand : Command
{
[SerializeField]
protected StringData message;
[SerializeField]
[VariableProperty(AllVariableTypes.VariableAny.Any)]
protected Variable a, b;
public enum Method
{
AreEqual,
AreNotEqual,
}
[SerializeField]
protected Method method;
public override void OnEnter()
{
switch (method)
{
case Method.AreEqual:
Assert.AreEqual(a.GetValue(), b.GetValue());
break;
case Method.AreNotEqual:
Assert.AreNotEqual(a.GetValue(), b.GetValue());
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
if (a == null)
return "Error: No A variable";
if (b == null)
return "Error: No B variable";
return a.Key + " " + method.ToString() + " " + b.Key;
}
public override bool HasReference(Variable variable)
{
return variable == message.stringRef ||
variable == a || variable == b ||
base.HasReference(variable);
}
}
}

11
Assets/Fungus/Scripts/Commands/AssertCommand.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c40b126bd148ae743b56bc8c00162589
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

44
Assets/Fungus/Scripts/Commands/Break.cs

@ -16,53 +16,31 @@ namespace Fungus
{
#region Public members
//located the containing loop and tell it to end
public override void OnEnter()
{
// Find index of previous while command
int whileIndex = -1;
int whileIndentLevel = -1;
for (int i = CommandIndex - 1; i >=0; --i)
Condition loopingCond = null;
// Find index of previous looping command
for (int i = CommandIndex - 1; i >= 0; --i)
{
While whileCommand = ParentBlock.CommandList[i] as While;
if (whileCommand != null)
Condition cond = ParentBlock.CommandList[i] as Condition;
if (cond != null && cond.IsLooping)
{
whileIndex = i;
whileIndentLevel = whileCommand.IndentLevel;
loopingCond = cond;
break;
}
}
if (whileIndex == -1)
if (loopingCond == null)
{
// No enclosing While command found, just continue
// No enclosing loop command found, just continue
Debug.LogError("Break called but found no enclosing looping construct." + GetLocationIdentifier());
Continue();
return;
}
// Find matching End statement at same indent level as While
for (int i = whileIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
End endCommand = ParentBlock.CommandList[i] as End;
if (endCommand != null &&
endCommand.IndentLevel == whileIndentLevel)
{
// Sanity check that break command is actually between the While and End commands
if (CommandIndex > whileIndex && CommandIndex < endCommand.CommandIndex)
{
// Continue at next command after End
Continue (endCommand.CommandIndex + 1);
return;
}
else
{
break;
}
}
loopingCond.MoveToEnd();
}
// No matching End command found so just continue
Continue();
}
public override Color GetButtonColor()

5
Assets/Fungus/Scripts/Commands/Transform.meta → Assets/Fungus/Scripts/Commands/Collection.meta

@ -1,9 +1,8 @@
fileFormatVersion: 2
guid: f7ddb80a0487d1342b36129da32ad1f6
guid: 7d7820abad934b747ae1797c3aa82197
folderAsset: yes
timeCreated: 1503815490
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

35
Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs

@ -0,0 +1,35 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Base class for all FungusCollection commands
/// </summary>
[AddComponentMenu("")]
public abstract class CollectionBaseCommand : Command
{
[SerializeField]
protected CollectionData collection;
public override Color GetButtonColor()
{
return new Color32(191, 217, 235, 255);
}
public override bool HasReference(Variable variable)
{
return variable == collection.collectionRef;
}
public override string GetSummary()
{
if (collection.Value == null)
return "Error: no collection selected";
return collection.Value.name;
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dab2b4efcfae62841b5070c4cfec8c4a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

42
Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs

@ -0,0 +1,42 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Base class for all FungusCollection commands that use an intvar
/// </summary>
[AddComponentMenu("")]
public abstract class CollectionBaseIntCommand : CollectionBaseCommand
{
[SerializeField]
protected IntegerData integer;
public override void OnEnter()
{
if (collection.Value != null)
{
OnEnterInner();
}
Continue();
}
protected abstract void OnEnterInner();
public override bool HasReference(Variable variable)
{
return variable == integer.integerRef || base.HasReference(variable);
}
public override string GetSummary()
{
if (collection.Value == null)
return "Error: no collection selected";
return integer.Value.ToString() + " on " + collection.Value.name;
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 328b7e125f24d5349be4fe583267ba1d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

50
Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs

@ -0,0 +1,50 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Base class for all FungusCollection commands that require a second collection of the same type
/// </summary>
[AddComponentMenu("")]
public abstract class CollectionBaseTwoCollectionCommand : CollectionBaseCommand
{
[SerializeField]
protected CollectionData rhsCollection;
public override void OnEnter()
{
if (collection.Value != null && rhsCollection.Value != null)
{
OnEnterInner();
}
Continue();
}
protected abstract void OnEnterInner();
public override bool HasReference(Variable variable)
{
return variable == rhsCollection.collectionRef || base.HasReference(variable);
}
public override string GetSummary()
{
if (collection.Value == null)
return "Error: no collection selected";
if (rhsCollection.Value == null)
return "Error: no variable selected";
if (collection.Value.ContainedType() != rhsCollection.Value.ContainedType())
{
return "Error: Collection types do not match. " + collection.Value.ContainedType().Name + " != " + rhsCollection.Value.ContainedType().Name;
}
return collection.Value.name + " , " + rhsCollection.Value.name;
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c4010b5577069fc4cb9480f87ed3f73e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

47
Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs

@ -0,0 +1,47 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Base class for all FungusCollection commands that require a compatible variable and an integer
/// </summary>
[AddComponentMenu("")]
public abstract class CollectionBaseVarAndIntCommand : CollectionBaseVarCommand
{
[SerializeField]
[VariableProperty(typeof(IntegerVariable))]
protected IntegerVariable integer;
public override void OnEnter()
{
if (collection.Value != null && variableToUse != null && integer != null)
{
OnEnterInner();
}
Continue();
}
public override bool HasReference(Variable variable)
{
return variable == integer || base.HasReference(variable);
}
public override string GetSummary()
{
if (collection.Value == null)
return "Error: no collection selected";
if (variableToUse == null)
return "Error: no variable selected";
if (integer == null)
return "Error: no integer selected";
return integer.Key + " on " + variableToUse.Key + " in " + collection.Value.name;
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 561b53abc515d704d8845caa3b3ee26f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

54
Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs

@ -0,0 +1,54 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Base class for all FungusCollection commands that require a compatible variable type
/// </summary>
[AddComponentMenu("")]
public abstract class CollectionBaseVarCommand : CollectionBaseCommand, ICollectionCompatible
{
[SerializeField]
[VariableProperty(compatibleVariableName = "collection")]
protected Variable variableToUse;
public override void OnEnter()
{
if (collection.Value != null && variableToUse != null)
{
OnEnterInner();
}
Continue();
}
protected abstract void OnEnterInner();
public override bool HasReference(Variable variable)
{
return variable == variableToUse || base.HasReference(variable);
}
public override string GetSummary()
{
if (collection.Value == null)
return "Error: no collection selected";
if (variableToUse == null)
return "Error: no variable selected";
return variableToUse.Key + " to " + collection.Value.name;
}
bool ICollectionCompatible.IsVarCompatibleWithCollection(Variable variable, string compatibleWith)
{
if (compatibleWith == "collection")
return collection.Value == null ? false : collection.Value.IsElementCompatible(variable);
else
return true;
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fe12b6eb87e59984cb4122f978f11e45
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

39
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs

@ -0,0 +1,39 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Add an item to a collection
/// </summary>
[CommandInfo("Collection",
"Add",
"Add an item to a collection")]
[AddComponentMenu("")]
public class CollectionCommandAdd : CollectionBaseVarCommand
{
[Tooltip("Only add if the item does not already exist in the collection")]
[SerializeField]
protected BooleanData onlyIfUnique = new BooleanData(false);
protected override void OnEnterInner()
{
if (onlyIfUnique.Value)
collection.Value.AddUnique(variableToUse);
else
collection.Value.Add(variableToUse);
}
public override bool HasReference(Variable variable)
{
return onlyIfUnique.booleanRef == variable || base.HasReference(variable);
}
public override string GetSummary()
{
return base.GetSummary() + (onlyIfUnique.Value ? " Unique" : "");
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a30a3b6902ecde54ea81d503f6a2b27e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

39
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs

@ -0,0 +1,39 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Add all items in given rhs collection to target collection
/// </summary>
[CommandInfo("Collection",
"Add All",
"Add all items in given rhs collection to target collection")]
[AddComponentMenu("")]
public class CollectionCommandAddAll : CollectionBaseTwoCollectionCommand
{
[Tooltip("Only add if the item does not already exist in the collection")]
[SerializeField]
protected BooleanData onlyIfUnique = new BooleanData(false);
protected override void OnEnterInner()
{
if (onlyIfUnique.Value)
collection.Value.AddUnique(rhsCollection);
else
collection.Value.Add(rhsCollection);
}
public override bool HasReference(Variable variable)
{
return onlyIfUnique.booleanRef == variable || base.HasReference(variable);
}
public override string GetSummary()
{
return base.GetSummary() + (onlyIfUnique.Value ? " Unique" : "");
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5688faa1580d8d147b59e18fcdd888ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

27
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs

@ -0,0 +1,27 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Clears a target collection
/// </summary>
[CommandInfo("Collection",
"Clear",
"Clears a target collection")]
[AddComponentMenu("")]
public class CollectionCommandClear : CollectionBaseCommand
{
public override void OnEnter()
{
if (collection.Value != null)
{
collection.Value.Clear();
}
Continue();
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b071472a9dcdc7469059042e2e6e50d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

37
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs

@ -0,0 +1,37 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Does the collection contain the given variable
/// </summary>
[CommandInfo("Collection",
"Contains",
"Does the collection contain the given variable")]
[AddComponentMenu("")]
public class CollectionCommandContains : CollectionBaseVarCommand
{
[VariableProperty(typeof(BooleanVariable))]
protected BooleanVariable result;
protected override void OnEnterInner()
{
if (result == null)
{
Debug.LogWarning("No result var set");
}
else
{
result.Value = collection.Value.Contains(variableToUse);
}
}
public override bool HasReference(Variable variable)
{
return result == variable || base.HasReference(variable);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6bd67ee6ac8134b4e9aea26299040034
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

53
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs

@ -0,0 +1,53 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Does target collection, contain all rhs collection items
/// </summary>
[CommandInfo("Collection",
"Contains All Of",
"Does target collection, contain all rhs collection items")]
[AddComponentMenu("")]
public class CollectionCommandContainsAll : CollectionBaseTwoCollectionCommand
{
[Tooltip("Do they have to be in the same order?")]
[SerializeField]
protected BooleanData inSameOrder = new BooleanData(false);
[VariableProperty(typeof(BooleanVariable))]
protected BooleanVariable result;
protected override void OnEnterInner()
{
if (result == null)
{
Debug.LogWarning("No result var set");
}
else
{
if (inSameOrder.Value)
{
result.Value = collection.Value.ContainsAllOfOrdered(rhsCollection.Value);
}
else
{
result.Value = collection.Value.ContainsAllOf(rhsCollection.Value);
}
}
}
public override bool HasReference(Variable variable)
{
return result == variable || inSameOrder.booleanRef == variable || base.HasReference(variable);
}
public override string GetSummary()
{
return base.GetSummary() + (inSameOrder.Value ? " Ordered" : "");
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1df2de5cf986f9d419a124bb9d834b11
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

37
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs

@ -0,0 +1,37 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Does target collection, contain any of the items in the rhs collection items
/// </summary>
[CommandInfo("Collection",
"Contains Any Of",
"Does target collection, contain any of the items in the rhs collection items")]
[AddComponentMenu("")]
public class CollectionCommandContainsAny : CollectionBaseTwoCollectionCommand
{
[VariableProperty(typeof(BooleanVariable))]
protected BooleanVariable result;
protected override void OnEnterInner()
{
if (result == null)
{
Debug.LogWarning("No result var set");
}
else
{
result.Value = collection.Value.ContainsAnyOf(rhsCollection.Value);
}
}
public override bool HasReference(Variable variable)
{
return result == variable || base.HasReference(variable);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c4e05f36271510b41a7d7889025e180e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

22
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs

@ -0,0 +1,22 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Clears target and then adds all of rhs to target.
/// </summary>
[CommandInfo("Collection",
"Copy",
"Clears target and then adds all of rhs to target.")]
[AddComponentMenu("")]
public class CollectionCommandCopy : CollectionBaseTwoCollectionCommand
{
protected override void OnEnterInner()
{
collection.Value.CopyFrom(rhsCollection.Value);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 820324be5b6a927469519df54a9bbad0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

25
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs

@ -0,0 +1,25 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Number of items in the collection
/// </summary>
[CommandInfo("Collection",
"Count",
"Number of items in the collection")]
[CommandInfo("Collection",
"Length",
"Number of items in the collection")]
[AddComponentMenu("")]
public class CollectionCommandCount : CollectionBaseIntCommand
{
protected override void OnEnterInner()
{
integer.Value = collection.Value.Count;
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 31765259d3ac50e4993fd654cd7ea78b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

53
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs

@ -0,0 +1,53 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Get or Set, an element in a collection
/// </summary>
[CommandInfo("Collection",
"Element",
"Get or Set, an element in a collection")]
[AddComponentMenu("")]
public class CollectionCommandElement : CollectionBaseVarCommand
{
public enum GetSet
{
Get,
Set,
}
[SerializeField]
protected IntegerData index;
[SerializeField]
protected GetSet getset = GetSet.Get;
protected override void OnEnterInner()
{
if (index.Value >= 0 && index.Value < collection.Value.Count)
{
if (getset == GetSet.Get)
{
collection.Value.Get(index.Value, ref variableToUse);
}
else
{
collection.Value.Set(index.Value, variableToUse);
}
}
else
{
throw new System.ArgumentOutOfRangeException();
}
}
public override string GetSummary()
{
return base.GetSummary() + " " + getset.ToString();
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bf40659a274400d40856f146223798ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

24
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs

@ -0,0 +1,24 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Remove all items from collection that are also in RHS and add all the items in RHS that are not already
/// in target. Similar to a xor
/// </summary>
[CommandInfo("Collection",
"Exclusive",
"Remove all items from collection that are also in RHS and add all the items in RHS that are not already in target. " +
"Similar to a xor")]
[AddComponentMenu("")]
public class CollectionCommandExclusive : CollectionBaseTwoCollectionCommand
{
protected override void OnEnterInner()
{
collection.Value.Exclusive(rhsCollection.Value);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 824e24d12ca84774ea135507417e94a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

41
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs

@ -0,0 +1,41 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Find an item in a collection
/// </summary>
[CommandInfo("Collection",
"Find",
"Find an item in a collection")]
[CommandInfo("Collection",
"IndexOf",
"Find an item in a collection")]
[AddComponentMenu("")]
public class CollectionCommandFind : CollectionBaseVarAndIntCommand
{
[Tooltip("If true, will find the last occurance rather than first occurance.")]
[SerializeField]
protected BooleanData lastInsteadOfFirst = new BooleanData(false);
protected override void OnEnterInner()
{
integer.Value = !lastInsteadOfFirst.Value ?
collection.Value.IndexOf(variableToUse)
: collection.Value.LastIndexOf(variableToUse);
}
public override bool HasReference(Variable variable)
{
return lastInsteadOfFirst.booleanRef == variable || base.HasReference(variable);
}
public override string GetSummary()
{
return base.GetSummary() + (lastInsteadOfFirst.Value ? " Last" : "");
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 59afe81b26e37ea4ea10dd91dfeee937
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

22
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs

@ -0,0 +1,22 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Add at a specific location in the collection
/// </summary>
[CommandInfo("Collection",
"Insert",
"Add at a specific location in the collection")]
[AddComponentMenu("")]
public class CollectionCommandInsert : CollectionBaseVarAndIntCommand
{
protected override void OnEnterInner()
{
collection.Value.Insert(integer.Value, variableToUse);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dd126ef47d8264a4d8a6aac5b4f3fb12
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

22
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs

@ -0,0 +1,22 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Remove all items from collection that aren't also in RHS, similar to an overlap.
/// </summary>
[CommandInfo("Collection",
"Intersection",
"Remove all items from collection that aren't also in RHS, similar to an overlap.")]
[AddComponentMenu("")]
public class CollectionCommandIntersection : CollectionBaseTwoCollectionCommand
{
protected override void OnEnterInner()
{
collection.Value.Intersection(rhsCollection.Value);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 586c189d813b1b045ba358c612f4a6eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

22
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs

@ -0,0 +1,22 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// How many occurrences of a given variable exist in a target collection
/// </summary>
[CommandInfo("Collection",
"Occurrences",
"How many occurrences of a given variable exist in a target collection")]
[AddComponentMenu("")]
public class CollectionCommandOccurrences : CollectionBaseVarAndIntCommand
{
protected override void OnEnterInner()
{
integer.Value = collection.Value.Occurrences(variableToUse);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 75a3711bc9cd44e429e15e10f6029fae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

39
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs

@ -0,0 +1,39 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Remove an item to a collection
/// </summary>
[CommandInfo("Collection",
"Remove",
"Remove an item to a collection")]
[AddComponentMenu("")]
public class CollectionCommandRemove : CollectionBaseVarCommand
{
[Tooltip("Should it remove ALL occurances of variable")]
[SerializeField]
protected BooleanData allOccurances = new BooleanData(false);
protected override void OnEnterInner()
{
if (allOccurances.Value)
collection.Value.RemoveAll(variableToUse);
else
collection.Value.Remove(variableToUse);
}
public override bool HasReference(Variable variable)
{
return allOccurances.booleanRef == variable || base.HasReference(variable);
}
public override string GetSummary()
{
return base.GetSummary() + (allOccurances.Value ? " ALL" : "");
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e2313a05ce56ea49bbf1922b58d793a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

22
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs

@ -0,0 +1,22 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Remove all items in given rhs collection to target collection
/// </summary>
[CommandInfo("Collection",
"Remove All Of",
"Remove all items in given rhs collection to target collection")]
[AddComponentMenu("")]
public class CollectionCommandRemoveAllOf : CollectionBaseTwoCollectionCommand
{
protected override void OnEnterInner()
{
collection.Value.RemoveAll(rhsCollection);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2bb49f43c99a0af4db604a1770b31e83
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

22
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs

@ -0,0 +1,22 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Remove item at given index
/// </summary>
[CommandInfo("Collection",
"Remove At",
"Remove item at given index")]
[AddComponentMenu("")]
public class CollectionCommandRemoveAt : CollectionBaseIntCommand
{
protected override void OnEnterInner()
{
collection.Value.RemoveAt(integer.Value);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c8ee8f64433f29a4f82b03a8e6550ae2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

22
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs

@ -0,0 +1,22 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Reserve space for given number of items in the collection
/// </summary>
[CommandInfo("Collection",
"Reserve",
"Reserve space for given number of items in the collection")]
[AddComponentMenu("")]
public class CollectionCommandReserve : CollectionBaseIntCommand
{
protected override void OnEnterInner()
{
collection.Value.Reserve(integer.Value);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4672406760fa8f340aabac4528f04c1c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

22
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs

@ -0,0 +1,22 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Resize will grow the collection to be the given size, will not remove items to shrink
/// </summary>
[CommandInfo("Collection",
"Resize",
"Resize will grow the collection to be the given size, will not remove items to shrink")]
[AddComponentMenu("")]
public class CollectionCommandResize : CollectionBaseIntCommand
{
protected override void OnEnterInner()
{
collection.Value.Resize(integer.Value);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3ce11d7cce59a3340937a8d112cd4ad5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

27
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs

@ -0,0 +1,27 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Reverse the current order of a target collection
/// </summary>
[CommandInfo("Collection",
"Reverse",
"Reverse the current order of a target collection")]
[AddComponentMenu("")]
public class CollectionCommandReverse : CollectionBaseCommand
{
public override void OnEnter()
{
if (collection.Value != null)
{
collection.Value.Reverse();
}
Continue();
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7359fcb744d14a41acae4b3a2e34b73
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

27
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs

@ -0,0 +1,27 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Randomly reorders all elements of a target collection
/// </summary>
[CommandInfo("Collection",
"Shuffle",
"Randomly reorders all elements of a target collection")]
[AddComponentMenu("")]
public class CollectionCommandShuffle : CollectionBaseCommand
{
public override void OnEnter()
{
if (collection.Value != null)
{
collection.Value.Shuffle();
}
Continue();
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a15d511e013edfe45a0a4726bda90c8f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

27
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs

@ -0,0 +1,27 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Sort a target collection
/// </summary>
[CommandInfo("Collection",
"Sort",
"Sort a target collection")]
[AddComponentMenu("")]
public class CollectionCommandSort : CollectionBaseCommand
{
public override void OnEnter()
{
if (collection.Value != null)
{
collection.Value.Sort();
}
Continue();
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 00093f39e8583954ba5935bca806f0f1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

27
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs

@ -0,0 +1,27 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Removes all duplicates.
/// </summary>
[CommandInfo("Collection",
"Unique",
"Removes all duplicates.")]
[AddComponentMenu("")]
public class CollectionCommandUnique : CollectionBaseCommand
{
public override void OnEnter()
{
if (collection.Value != null)
{
collection.Value.Unique();
}
Continue();
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 59ae026a39db9cf4d8453309fa6192db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

22
Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs

@ -0,0 +1,22 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Use the collection as a source of random selection. Picking a random item each run.
/// </summary>
[CommandInfo("Collection",
"RandomItem",
"Use the collection as a source of random selection. Picking a random item each run.")]
[AddComponentMenu("")]
public class CollectionRandom : CollectionBaseVarCommand
{
protected override void OnEnterInner()
{
collection.Value.Get(Random.Range(0, collection.Value.Count - 1), ref variableToUse);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d58ddca8952c1a149a39835e2eeac9a7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

80
Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs

@ -0,0 +1,80 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Use the collection as a source of random items and turn it into a random bag. Drawing the
/// next random item until out of items and then reshuffling them.
/// </summary>
[CommandInfo("Collection",
"RandomBag",
"Use the collection as a source of random items and turn it into a random bag. " +
"Drawing the next random item until out of items and then reshuffling them.")]
[AddComponentMenu("")]
public class CollectionRandomBag : CollectionBaseVarCommand
{
[SerializeField]
[Tooltip("Will add this many copies to the bag. If you want 5 of everything, you want 4 copies.")]
protected IntegerData duplicatesToPutInBag = new IntegerData(0);
[SerializeField]
protected IntegerData currentIndex = new IntegerData(int.MaxValue);
protected bool isInit = false;
protected override void OnEnterInner()
{
if (!isInit)
{
Init();
}
currentIndex.Value++;
if (currentIndex.Value >= collection.Value.Count)
{
Reshuffle();
}
collection.Value.Get(currentIndex.Value, ref variableToUse);
}
protected void Init()
{
var startingCount = collection.Value.Count;
for (int i = 0; i < duplicatesToPutInBag.Value; i++)
{
for (int j = 0; j < startingCount; j++)
{
collection.Value.Add(collection.Value.Get(j));
}
}
//force invalid index
currentIndex.Value = collection.Value.Count;
isInit = true;
}
protected void Reshuffle()
{
currentIndex.Value = 0;
collection.Value.Shuffle();
}
public override bool HasReference(Variable variable)
{
return base.HasReference(variable) || duplicatesToPutInBag.integerRef == variable || currentIndex.integerRef;
}
public override string GetSummary()
{
return base.GetSummary() +
(duplicatesToPutInBag.integerRef != null ? " " + duplicatesToPutInBag.integerRef.Key : "") +
(currentIndex.integerRef != null ? " " + currentIndex.integerRef.Key : ""); ;
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56176eef6b396a442b08b88220304436
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

90
Assets/Fungus/Scripts/Commands/Collection/ForEach.cs

@ -0,0 +1,90 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Loop over each element in the given collection.
/// </summary>
[CommandInfo("Collection",
"For Each",
"Loop over each element in the given collection, similar to a foreach but internally uses indicies")]
[AddComponentMenu("")]
public class ForEach : Condition, ICollectionCompatible
{
[SerializeField]
protected CollectionData collection;
[SerializeField]
[VariableProperty(compatibleVariableName = "collection")]
protected Variable item;
[SerializeField]
[Tooltip("Optional")]
protected IntegerData curIndex;
#region Public members
public override bool IsLooping { get { return true; } }
protected override void PreEvaluate()
{
//if we came from the end then we are already looping, if not this is first loop so prep
if (ParentBlock.PreviousActiveCommandIndex != endCommand.CommandIndex)
{
curIndex.Value = -1;
}
}
protected override bool EvaluateCondition()
{
var col = collection.Value;
curIndex.Value++;
if (curIndex < col.Count)
{
col.Get(curIndex, ref item);
return true;
}
return false;
}
protected override void OnFalse()
{
MoveToEnd();
}
protected override bool HasNeededProperties()
{
return collection.Value != null && item != null;
}
public override bool HasReference(Variable variable)
{
return collection.collectionRef == variable || item == variable ||
base.HasReference(variable);
}
bool ICollectionCompatible.IsVarCompatibleWithCollection(Variable variable, string compatibleWith)
{
if (compatibleWith == "collection")
return collection.Value == null ? false : collection.Value.IsElementCompatible(variable);
else
return true;
}
public override string GetSummary()
{
if (item == null)
return "Error: No item var";
if (collection.Value == null)
return "Error: No collection";
return item.Key + " in " + collection.Value.name;
}
#endregion Public members
}
}

11
Assets/Fungus/Scripts/Commands/Collection/ForEach.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1ce547d5384ce3a41b7142cab8ab41dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

51
Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs

@ -0,0 +1,51 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
[CommandInfo("GameObject",
"FindAll",
"Find all gameobjects by tag and store in a collection")]
[AddComponentMenu("")]
public class GameObjectFind : CollectionBaseCommand
{
[Tooltip("Find all gameobjects of tag")]
[SerializeField]
protected StringData tagString;
public override void OnEnter()
{
var col = collection.Value;
if (col != null)
{
var res = GameObject.FindGameObjectsWithTag(tagString.Value);
for (int i = 0; i < res.Length; i++)
{
col.Add(res[i]);
}
}
Continue();
}
public override bool HasReference(Variable variable)
{
return variable == tagString.stringRef || base.HasReference(variable);
}
public override string GetSummary()
{
if (collection.Value == null)
return "Error: no collection selected";
if (!(collection.Value is GameObjectCollection))
return "Error: collection is not GameObjectCollection";
return tagString.Value + " GOs, store in " + collection.Value.name;
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8509f58e038dd8c46b98cab78d34e06a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

162
Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs

@ -0,0 +1,162 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
[CommandInfo("Physics2D",
"Cast2D",
"Find all gameobjects hit by given physics shape overlap")]
[AddComponentMenu("")]
public class Physics2DCast : CollectionBaseCommand
{
public enum CastType
{
Box,
Capsule,
Circle,
Line,
Ray,
}
[Tooltip("")]
[SerializeField]
protected CastType castType = CastType.Ray;
[Tooltip("Starting point or centre of shape")]
[SerializeField]
protected Vector3Data position1;
[Tooltip("")]
[SerializeField]
protected Vector3Data direction;
[Tooltip("")]
[SerializeField]
protected FloatData maxDistance = new FloatData(float.PositiveInfinity);
[Tooltip("CAPSULE & Circle ONLY")]
[SerializeField]
protected FloatData radius = new FloatData(0.5f);
[Tooltip("BOX & CAPSULE ONLY")]
[SerializeField]
protected Vector3Data shapeSize = new Vector3Data(Vector3.one * 0.5f);
[Tooltip("BOX & CAPSULE ONLY")]
[SerializeField]
protected FloatData shapeAngle;
[Tooltip("LINE ONLY")]
[SerializeField]
protected Vector3Data lineEnd;
[Tooltip("")]
[SerializeField]
protected LayerMask layerMask = ~0;
[Tooltip("")]
[SerializeField]
protected FloatData minDepth = new FloatData(float.NegativeInfinity), maxDepth = new FloatData(float.PositiveInfinity);
[SerializeField]
protected CapsuleDirection2D capsuleDirection;
public override void OnEnter()
{
var col = collection.Value;
if (col != null)
{
RaycastHit2D[] resHits = null;
switch (castType)
{
case CastType.Box:
resHits = Physics2D.BoxCastAll(position1.Value, shapeSize.Value, shapeAngle.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
break;
case CastType.Capsule:
resHits = Physics2D.CapsuleCastAll(position1.Value, shapeSize.Value, capsuleDirection, shapeAngle.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
break;
case CastType.Circle:
resHits = Physics2D.CircleCastAll(position1.Value, radius.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
break;
case CastType.Line:
resHits = Physics2D.LinecastAll(position1.Value, lineEnd.Value, layerMask.value, minDepth.Value, maxDepth.Value);
break;
case CastType.Ray:
resHits = Physics2D.RaycastAll(position1.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
break;
default:
break;
}
PutCollidersIntoGameObjectCollection(resHits);
}
Continue();
}
protected void PutCollidersIntoGameObjectCollection(RaycastHit2D[] resColliders)
{
if (resColliders != null)
{
var col = collection.Value;
for (int i = 0; i < resColliders.Length; i++)
{
col.Add(resColliders[i].collider.gameObject);
}
}
}
public override bool HasReference(Variable variable)
{
return variable == position1.vector3Ref ||
variable == radius.floatRef ||
variable == shapeSize.vector3Ref ||
variable == shapeAngle.floatRef ||
variable == minDepth.floatRef ||
variable == maxDepth.floatRef ||
variable == direction.vector3Ref ||
variable == maxDistance.floatRef ||
variable == lineEnd.vector3Ref ||
base.HasReference(variable);
}
public override string GetSummary()
{
if (collection.Value == null)
return "Error: no collection selected";
//TODO we could support more than just GOs
if (!(collection.Value is GameObjectCollection))
return "Error: collection is not GameObjectCollection";
return castType.ToString() + ", store in " + collection.Value.name;
}
public override bool IsPropertyVisible(string propertyName)
{
if (castType == CastType.Capsule && propertyName == "capsulePosition2")
return true;
if (castType == CastType.Line && propertyName == "lineEnd")
return true;
if ((castType == CastType.Capsule || castType == CastType.Circle) && propertyName == "radius")
return true;
if ((castType == CastType.Capsule || castType == CastType.Box) &&
(propertyName == "shapeAngle" || propertyName == "shapeSize"))
return true;
return base.IsPropertyVisible(propertyName);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: da8de59f5960f5c4b9d61002cc912b37
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

154
Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs

@ -0,0 +1,154 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
[CommandInfo("Physics2D",
"Overlap2D",
"Find all gameobjects hit by given physics shape overlap")]
[AddComponentMenu("")]
public class Physics2DOverlap : CollectionBaseCommand
{
public enum Shape
{
Point,
Area,
Box,
Circle,
Capsule,
}
[Tooltip("")]
[SerializeField]
protected Shape shape = Shape.Box;
[Tooltip("Starting point or centre of shape")]
[SerializeField]
protected Vector3Data position1;
[Tooltip("AREA ONLY")]
[SerializeField]
protected Vector3Data areaEndPosition;
[Tooltip("CAPSULE & Circle ONLY")]
[SerializeField]
protected FloatData radius = new FloatData(0.5f);
[Tooltip("BOX & CAPSULE ONLY")]
[SerializeField]
protected Vector3Data shapeSize = new Vector3Data(Vector3.one * 0.5f);
[Tooltip("BOX & CAPSULE ONLY")]
[SerializeField]
protected FloatData shapeAngle;
[Tooltip("")]
[SerializeField]
protected LayerMask layerMask = ~0;
[Tooltip("")]
[SerializeField]
protected FloatData minDepth = new FloatData(float.NegativeInfinity), maxDepth = new FloatData(float.PositiveInfinity);
[SerializeField]
protected CapsuleDirection2D capsuleDirection;
public override void OnEnter()
{
var col = collection.Value;
if (col != null)
{
Collider2D[] resColliders = null;
switch (shape)
{
case Shape.Area:
resColliders = Physics2D.OverlapAreaAll(position1.Value, areaEndPosition.Value, layerMask.value, minDepth.Value, maxDepth.Value);
break;
case Shape.Box:
resColliders = Physics2D.OverlapBoxAll(position1.Value, shapeSize.Value, shapeAngle.Value, layerMask.value, minDepth.Value, maxDepth.Value);
break;
case Shape.Circle:
resColliders = Physics2D.OverlapCircleAll(position1.Value, radius.Value, layerMask.value, minDepth.Value, maxDepth.Value);
break;
case Shape.Capsule:
resColliders = Physics2D.OverlapCapsuleAll(position1.Value, shapeSize.Value, capsuleDirection, shapeAngle.Value, layerMask.value, minDepth.Value, maxDepth.Value);
break;
case Shape.Point:
resColliders = Physics2D.OverlapPointAll(position1.Value, layerMask.value, minDepth.Value, maxDepth.Value);
break;
default:
break;
}
PutCollidersIntoGameObjectCollection(resColliders);
}
Continue();
}
protected void PutCollidersIntoGameObjectCollection(Collider2D[] resColliders)
{
if (resColliders != null)
{
var col = collection.Value;
for (int i = 0; i < resColliders.Length; i++)
{
col.Add(resColliders[i].gameObject);
}
}
}
public override bool HasReference(Variable variable)
{
return variable == position1.vector3Ref ||
variable == areaEndPosition.vector3Ref ||
variable == radius.floatRef ||
variable == shapeSize.vector3Ref ||
variable == shapeAngle.floatRef ||
variable == minDepth.floatRef ||
variable == maxDepth.floatRef ||
base.HasReference(variable);
}
public override string GetSummary()
{
if (collection.Value == null)
return "Error: no collection selected";
//TODO we could support more than just GOs
if (!(collection.Value is GameObjectCollection))
return "Error: collection is not GameObjectCollection";
return shape.ToString() + ", store in " + collection.Value.name;
}
public override bool IsPropertyVisible(string propertyName)
{
if (shape == Shape.Capsule && propertyName == "capsulePosition2")
return true;
if (shape == Shape.Area && propertyName == "areaEndPosition")
return true;
if ((shape == Shape.Capsule || shape == Shape.Circle) && propertyName == "radius")
return true;
if ((shape == Shape.Capsule || shape == Shape.Box) && propertyName == "shapeAngle")
return true;
if (shape == Shape.Box && (propertyName == "boxHalfExtends" || propertyName == "boxOrientation"))
return true;
return base.IsPropertyVisible(propertyName);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c27aec18d802f45429190093660305e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

147
Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs

@ -0,0 +1,147 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
[CommandInfo("Physics",
"Cast",
"Find all gameobjects hit by given physics shape cast")]
[AddComponentMenu("")]
public class PhysicsCast : CollectionBaseCommand
{
public enum CastType
{
Box,
Capsule,
Ray,
Sphere,
}
[SerializeField]
protected CastType castType = CastType.Ray;
[Tooltip("Starting point/origin or centre of shape")]
[SerializeField]
protected Vector3Data position1;
[Tooltip("")]
[SerializeField]
protected Vector3Data direction;
[Tooltip("")]
[SerializeField]
protected FloatData maxDistance = new FloatData(float.PositiveInfinity);
[Tooltip("CAPSULE ONLY; end point of the capsule")]
[SerializeField]
protected Vector3Data capsulePosition2;
[Tooltip("CAPSULE & SPHERE ONLY")]
[SerializeField]
protected FloatData radius = new FloatData(0.5f);
[Tooltip("BOX ONLY")]
[SerializeField]
protected Vector3Data boxHalfExtends = new Vector3Data(Vector3.one * 0.5f);
[Tooltip("BOX ONLY")]
[SerializeField]
protected QuaternionData boxOrientation = new QuaternionData(Quaternion.identity);
[Tooltip("")]
[SerializeField]
protected LayerMask layerMask = ~0;
[Tooltip("")]
[SerializeField]
protected QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal;
public override void OnEnter()
{
var col = collection.Value;
if (col != null)
{
RaycastHit[] resHits = null;
switch (castType)
{
case CastType.Ray:
resHits = Physics.RaycastAll(position1.Value, direction.Value, maxDistance.Value, layerMask.value, queryTriggerInteraction);
break;
case CastType.Sphere:
resHits = Physics.SphereCastAll(position1.Value, radius.Value, direction.Value, maxDistance.Value, layerMask.value, queryTriggerInteraction);
break;
case CastType.Box:
resHits = Physics.BoxCastAll(position1.Value, boxHalfExtends.Value, direction.Value, boxOrientation.Value, maxDistance.Value, layerMask.value, queryTriggerInteraction);
break;
case CastType.Capsule:
resHits = Physics.CapsuleCastAll(position1.Value, capsulePosition2.Value, radius.Value, direction.Value, maxDistance.Value, layerMask.value, queryTriggerInteraction);
break;
default:
break;
}
PutCollidersIntoGameObjectCollection(resHits);
}
Continue();
}
protected void PutCollidersIntoGameObjectCollection(RaycastHit[] resHits)
{
if (resHits != null)
{
var col = collection.Value;
for (int i = 0; i < resHits.Length; i++)
{
col.Add(resHits[i].collider.gameObject);
}
}
}
public override bool HasReference(Variable variable)
{
return variable == direction.vector3Ref ||
variable == maxDistance.floatRef ||
variable == position1.vector3Ref ||
variable == capsulePosition2.vector3Ref ||
variable == radius.floatRef ||
variable == boxHalfExtends.vector3Ref ||
variable == boxOrientation.quaternionRef ||
base.HasReference(variable);
}
public override string GetSummary()
{
if (collection.Value == null)
return "Error: no collection selected";
//TODO we could support more than just GOs
if (!(collection.Value is GameObjectCollection))
return "Error: collection is not GameObjectCollection";
return castType.ToString() + ", store in " + collection.Value.name;
}
public override bool IsPropertyVisible(string propertyName)
{
if (castType == CastType.Capsule && propertyName == "capsulePosition2")
return true;
if ((castType == CastType.Capsule || castType == CastType.Sphere) && propertyName == "radius")
return true;
if (castType == CastType.Box && (propertyName == "boxHalfExtends" || propertyName == "boxOrientation"))
return true;
return base.IsPropertyVisible(propertyName);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 44a4b238cb3af004bbae4a6145089ea2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

136
Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs

@ -0,0 +1,136 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
///
/// </summary>
[CommandInfo("Physics",
"Overlap",
"Find all gameobjects hit by given physics shape overlap")]
[AddComponentMenu("")]
public class PhysicsOverlap : CollectionBaseCommand
{
public enum Shape
{
Box,
Capsule,
Sphere,
}
[Tooltip("")]
[SerializeField]
protected Shape shape = Shape.Box;
[Tooltip("Starting point or centre of shape")]
[SerializeField]
protected Vector3Data position1;
[Tooltip("CAPSULE ONLY; end point of the capsule")]
[SerializeField]
protected Vector3Data capsulePosition2;
[Tooltip("CAPSULE & SPHERE ONLY")]
[SerializeField]
protected FloatData radius = new FloatData(0.5f);
[Tooltip("BOX ONLY")]
[SerializeField]
protected Vector3Data boxHalfExtends = new Vector3Data(Vector3.one * 0.5f);
[Tooltip("BOX ONLY")]
[SerializeField]
protected QuaternionData boxOrientation = new QuaternionData(Quaternion.identity);
[Tooltip("")]
[SerializeField]
protected LayerMask layerMask = ~0;
[Tooltip("")]
[SerializeField]
protected QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal;
public override void OnEnter()
{
var col = collection.Value;
if (col != null)
{
Collider[] resColliders = null;
switch (shape)
{
case Shape.Box:
resColliders = Physics.OverlapBox(position1.Value, boxHalfExtends.Value, boxOrientation.Value, layerMask.value, queryTriggerInteraction);
break;
case Shape.Sphere:
resColliders = Physics.OverlapSphere(position1.Value, radius.Value, layerMask.value, queryTriggerInteraction);
break;
case Shape.Capsule:
resColliders = Physics.OverlapCapsule(position1.Value, capsulePosition2.Value, radius.Value, layerMask.value, queryTriggerInteraction);
break;
default:
break;
}
PutCollidersIntoGameObjectCollection(resColliders);
}
Continue();
}
protected void PutCollidersIntoGameObjectCollection(Collider[] resColliders)
{
if (resColliders != null)
{
var col = collection.Value;
for (int i = 0; i < resColliders.Length; i++)
{
col.Add(resColliders[i].gameObject);
}
}
}
public override bool HasReference(Variable variable)
{
return variable == position1.vector3Ref ||
variable == capsulePosition2.vector3Ref ||
variable == radius.floatRef ||
variable == boxHalfExtends.vector3Ref ||
variable == boxOrientation.quaternionRef ||
base.HasReference(variable);
}
public override string GetSummary()
{
if (collection.Value == null)
return "Error: no collection selected";
//TODO we could support more than just GOs
if (!(collection.Value is GameObjectCollection))
return "Error: collection is not GameObjectCollection";
return shape.ToString() + ", store in " + collection.Value.name;
}
public override bool IsPropertyVisible(string propertyName)
{
if (shape == Shape.Capsule && propertyName == "capsulePosition2")
return true;
if ((shape == Shape.Capsule || shape == Shape.Sphere) && propertyName == "radius")
return true;
if (shape == Shape.Box && (propertyName == "boxHalfExtends" || propertyName == "boxOrientation"))
return true;
return base.IsPropertyVisible(propertyName);
}
}
}

11
Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5996bc0e902a19f4fa257341b0691de3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

219
Assets/Fungus/Scripts/Commands/Condition.cs

@ -5,114 +5,165 @@ using UnityEngine;
namespace Fungus
{
/// <summary>
/// Base for all Conditional based Commands, Ifs, Loops, and so on.
/// </summary>
[AddComponentMenu("")]
public abstract class Condition : Command
{
public static string GetOperatorDescription(CompareOperator compareOperator)
{
string summary = "";
switch (compareOperator)
{
case CompareOperator.Equals:
summary += "==";
break;
case CompareOperator.NotEquals:
summary += "!=";
break;
case CompareOperator.LessThan:
summary += "<";
break;
case CompareOperator.GreaterThan:
summary += ">";
break;
case CompareOperator.LessThanOrEquals:
summary += "<=";
break;
case CompareOperator.GreaterThanOrEquals:
summary += ">=";
break;
}
return summary;
}
protected End endCommand;
#region Public members
public override void OnEnter()
{
if (ParentBlock == null)
{
return;
}
if( !HasNeededProperties() )
//if looping we need the end command in order to work
if(IsLooping && !EnsureRequiredEnd())
{
Debug.LogError(GetLocationIdentifier() + " is looping but has no matching End command");
Continue();
return;
}
if( !this.IsElseIf )
if ( !HasNeededProperties() )
{
Debug.LogError(GetLocationIdentifier() + " cannot run due to missing required properties");
Continue();
return;
}
//Ensuring we arrived at this elif honestly, not incorrectly due to fall through from a previous command
if (this.IsElseIf && !DoesPassElifSanityCheck())
{
//elif is being asked to run but didn't come from a previously failing if or elif, this isn't allowed
MoveToEnd();
return;
}
EvaluateAndContinue();
}
else
public override bool OpenBlock()
{
System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType();
var prevCmdIndent = ParentBlock.GetPreviousActiveCommandIndent();
return true;
}
//handle our matching if or else if in the chain failing and moving to us,
// need to make sure it is the same indent level
if (prevCmdIndent == IndentLevel && previousCommandType.IsSubclassOf(typeof(Condition)))
public override Color GetButtonColor()
{
// Else If behaves the same as an If command
EvaluateAndContinue();
return new Color32(253, 253, 150, 255);
}
else
public virtual bool IsLooping { get { return false; } }
/// <summary>
/// Moves execution to the closing End of the current command, attempts to locate end if not
/// already known and if no closing End exists.
/// </summary>
public virtual void MoveToEnd()
{
// Else If behaves mostly like an Else command,
// but will also jump to a following Else command.
if(endCommand == null)
{
endCommand = FindOurEndCommand();
}
// Stop if this is the last command in the list
if (CommandIndex >= ParentBlock.CommandList.Count - 1)
if (endCommand != null)
{
// Continue at next command after End
// and make the end non looping incase it gets run via index etc.
endCommand.Loop = false;
Continue(endCommand.CommandIndex + 1);
}
else
{
//nowhere to go, so we assume the block wants to stop but is missing and end, this
// is also ensures back compat
Debug.LogWarning("Condition wants to move to end but no End command found, stopping block. " + GetLocationIdentifier());
StopParentBlock();
return;
}
}
// Find the next End command at the same indent level as this Else If command
int indent = indentLevel;
for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
#endregion
protected End FindOurEndCommand()
{
var command = ParentBlock.CommandList[i];
return FindMatchingEndCommand(this);
}
/// <summary>
/// Helper to find the paired End Command for the given command.
/// </summary>
/// <param name="startCommand"></param>
/// <returns>Mathcing End Command or null if not found</returns>
public static End FindMatchingEndCommand(Command startCommand)
{
if (startCommand.ParentBlock == null)
return null;
int indent = startCommand.IndentLevel;
for (int i = startCommand.CommandIndex + 1; i < startCommand.ParentBlock.CommandList.Count; ++i)
{
var command = startCommand.ParentBlock.CommandList[i];
if (command.IndentLevel == indent)
{
System.Type type = command.GetType();
if (type == typeof(End))
if (command is End)
{
// Execute command immediately after the Else or End command
Continue(command.CommandIndex + 1);
return;
return command as End;
}
}
else if (command.IndentLevel < indent)
{
//managed to be less indent than the inner but not find and end, this shouldn't occur
// but may be user error or bad data, makes sense for completeness here
return null;
}
}
// No End command found
StopParentBlock();
return null;
}
/// <summary>
/// Helper for child classes that require an End command to function. For IsLooping commands
/// this also configures the loopback within the End command.
/// </summary>
/// <returns></returns>
protected virtual bool EnsureRequiredEnd()
{
if (endCommand == null)
{
endCommand = FindOurEndCommand();
if (endCommand == null)
{
Debug.LogError( GetLocationIdentifier() + "', could not find closing End command and thus cannot loop.");
//StopParentBlock();
return false;
}
}
public override bool OpenBlock()
if (IsLooping)
{
// Tell the following end command to loop back
endCommand.Loop = true;
endCommand.LoopBackIndex = CommandIndex;
}
return true;
}
#endregion
/// <summary>
/// Called by OnEnter when the condition is needed to evaluate and continue execution.
/// Means child classes do not have to deal with erronuous execution conditions, like fall through.
/// </summary>
protected virtual void EvaluateAndContinue()
{
PreEvaluate();
if (EvaluateCondition())
{
OnTrue();
@ -123,17 +174,23 @@ namespace Fungus
}
}
/// <summary>
/// Called when the condition is run and EvaluateCondition returns true
/// </summary>
protected virtual void OnTrue()
{
Continue();
}
/// <summary>
/// Called when the condition is run and EvaluateCondition returns false
/// </summary>
protected virtual void OnFalse()
{
// Last command in block
if (CommandIndex >= ParentBlock.CommandList.Count)
//looping constructs only care about the end
if(IsLooping)
{
StopParentBlock();
MoveToEnd();
return;
}
@ -177,7 +234,6 @@ namespace Fungus
{
// Execute the Else If command
Continue(i);
return;
}
}
@ -186,10 +242,47 @@ namespace Fungus
StopParentBlock();
}
/// <summary>
/// Sits in the if within EvaluateAndContinue, if returns true, OnTrue will run, if false, OnFalse will run.
/// </summary>
protected abstract bool EvaluateCondition();
protected abstract bool HasNeededProperties();
/// <summary>
/// Child classes are required to report if it is possible for them to be evaulated.
/// </summary>
protected virtual bool HasNeededProperties() { return true; }
/// <summary>
/// Declare if the child class is implementing an 'else if' command, which requires some special handling
/// </summary>
protected virtual bool IsElseIf { get { return false; } }
/// <summary>
/// Called before EvaluateCondition, allowing for child classes to gather required data
/// </summary>
protected virtual void PreEvaluate() { }
/// <summary>
/// Ensure that this condition didn't come from a non matching if/elif.
/// </summary>
/// <returns></returns>
protected virtual bool DoesPassElifSanityCheck()
{
System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType();
var prevCmdIndent = ParentBlock.GetPreviousActiveCommandIndent();
var prevCmd = ParentBlock.GetPreviousActiveCommand();
//handle our matching if or else if in the chain failing and moving to us,
// need to make sure it is the same indent level
if (prevCmd == null ||
prevCmdIndent != IndentLevel ||
!previousCommandType.IsSubclassOf(typeof(Condition)) ||
(prevCmd as Condition).IsLooping)
{
return false;
}
return true;
}
}
}

32
Assets/Fungus/Scripts/Commands/Else.cs

@ -18,39 +18,19 @@ namespace Fungus
public override void OnEnter()
{
if (ParentBlock == null)
{
return;
}
// Stop if this is the last command in the list
if (CommandIndex >= ParentBlock.CommandList.Count - 1)
{
StopParentBlock();
return;
}
// Find the next End command at the same indent level as this Else command
int indent = indentLevel;
for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
var command = ParentBlock.CommandList[i];
if (command.IndentLevel == indent)
{
System.Type type = command.GetType();
if (type == typeof(End))
var matchingEnd = Condition.FindMatchingEndCommand(this);
if (matchingEnd != null)
{
// Execute command immediately after the EndIf command
Continue(command.CommandIndex + 1);
return;
}
}
Continue(matchingEnd.CommandIndex + 1);
}
else
{
// No End command found
StopParentBlock();
}
}
public override bool OpenBlock()
{

10
Assets/Fungus/Scripts/Commands/ElseIf.cs

@ -18,21 +18,11 @@ namespace Fungus
#region Public members
public override bool OpenBlock()
{
return true;
}
public override bool CloseBlock()
{
return true;
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
#endregion
}
}

19
Assets/Fungus/Scripts/Commands/End.cs

@ -16,24 +16,23 @@ namespace Fungus
{
#region Public members
/// <summary>
/// Set to true by looping constructs to allow for loops to occur
/// </summary>
public virtual bool Loop { get; set; }
/// <summary>
/// Set to the index of the owning looping construct
/// </summary>
public virtual int LoopBackIndex { get; set; }
public override void OnEnter()
{
if (Loop)
{
for (int i = CommandIndex - 1; i >= 0; --i)
{
var command = ParentBlock.CommandList[i];
if (command.IndentLevel == IndentLevel &&
command.GetType() == typeof(While))
{
Continue(i);
Continue(LoopBackIndex);
return;
}
}
}
Continue();
}

8
Assets/Fungus/Scripts/Commands/If.cs

@ -14,13 +14,5 @@ namespace Fungus
[AddComponentMenu("")]
public class If : VariableCondition
{
#region Public members
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
#endregion
}
}

89
Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs

@ -0,0 +1,89 @@
using UnityEngine;
namespace Fungus
{
// <summary>
/// Store Input.mousePosition and mouse screen conversions in a variable(s)
/// </summary>
[CommandInfo("Input",
"Get Mouse Position",
"Store various interpretations of Input.mousePosition")]
[AddComponentMenu("")]
public class GetMousePosition : Command
{
[VariableProperty(typeof(Vector2Variable))]
[SerializeField]
protected Vector2Variable screenPosition;
[Tooltip("If null, Camera.main is used")]
protected Camera castCamera;
[VariableProperty(typeof(Vector2Variable))]
[SerializeField]
protected Vector2Variable viewPosition;
[VariableProperty(typeof(Vector3Variable))]
[SerializeField]
protected Vector3Variable worldPosition;
[VariableProperty(typeof(Vector3Variable))]
[SerializeField]
protected Vector3Variable worldDirection;
public override void OnEnter()
{
if (castCamera == null)
{
castCamera = Camera.main;
}
if (screenPosition != null)
{
screenPosition.Value = Input.mousePosition;
}
if (viewPosition != null)
{
viewPosition.Value = castCamera.ScreenToViewportPoint(Input.mousePosition);
}
if (worldPosition != null)
{
var screenWithZ = Input.mousePosition;
screenWithZ.z = castCamera.nearClipPlane;
worldPosition.Value = castCamera.ScreenToWorldPoint(screenWithZ);
}
if (worldDirection != null)
{
var screenWithZ = Input.mousePosition;
screenWithZ.z = castCamera.nearClipPlane;
worldDirection.Value = castCamera.ScreenPointToRay(screenWithZ).direction;
}
Continue();
}
public override string GetSummary()
{
return (screenPosition != null ? screenPosition.Key + " " : "") +
(castCamera != null ? castCamera.name + " " : "MainCam") +
(viewPosition != null ? viewPosition.Key + " " : "") +
(worldPosition != null ? worldPosition.Key + " " : "") +
(worldDirection != null ? worldDirection.Key + " " : "");
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
return (screenPosition == variable ||
viewPosition == variable ||
worldPosition == variable ||
worldDirection == variable);
}
}
}

11
Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fb32240870e5bf545a0dafba446d3990
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

84
Assets/Fungus/Scripts/Commands/LoopRange.cs

@ -0,0 +1,84 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Loop over a fixed integer range, similar to a common for loop.
/// </summary>
[CommandInfo("Flow",
"Loop Range",
"Loop over a fixed integer range, similar to a common for loop.")]
[CommandInfo("Flow",
"For",
"Loop over a fixed integer range, similar to a common for loop.")]
[AddComponentMenu("")]
public class LoopRange : Condition
{
[Tooltip("Starting value for the counter variable")]
[SerializeField]
protected IntegerData startingValue;
[Tooltip("End value for the counter variable, exclusive")]
[SerializeField]
protected IntegerData endValue;
[Tooltip("Optional int var to hold the current loop counter.")]
[SerializeField]
protected IntegerData counter;
[Tooltip("Step size for the counter, how much does it go up by each loop. Default 1")]
[SerializeField]
protected IntegerData step = new IntegerData(1);
#region Public members
public override bool IsLooping { get { return true; } }
protected override void PreEvaluate()
{
//if we came from the end then we are already looping, if not this is first loop so prep
if (ParentBlock.PreviousActiveCommandIndex != endCommand.CommandIndex)
{
counter.Value = startingValue.Value;
}
else
{
counter.Value += (startingValue.Value <= endValue.Value ? step.Value : -step.Value);
}
}
protected override bool EvaluateCondition()
{
return (startingValue.Value <= endValue.Value ?
counter.Value < endValue.Value :
counter.Value > endValue.Value);
}
protected override void OnFalse()
{
MoveToEnd();
}
public override void OnValidate()
{
// no infinite loops
if (step.Value == 0)
step.Value = 1;
//no negative steps, we do that automatically
step.Value = Mathf.Abs(step.Value);
}
public override bool HasReference(Variable variable)
{
return startingValue.integerRef == variable || endValue.integerRef == variable ||
counter.integerRef == variable || step.integerRef == variable ||
base.HasReference(variable);
}
#endregion
}
}

11
Assets/Fungus/Scripts/Commands/LoopRange.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b0eebb5bf2fc1e542a35e2e5332e60d4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

13
Assets/Fungus/Scripts/Commands/LuaCondition.cs

@ -63,7 +63,7 @@ namespace Fungus
}
// Cache a descriptive name to use in Lua error messages
friendlyName = gameObject.name + "." + ParentBlock.BlockName + "." + this.GetType().ToString() + " #" + CommandIndex.ToString();
friendlyName = GetLocationIdentifier();
Flowchart flowchart = GetFlowchart();
@ -113,17 +113,6 @@ namespace Fungus
return luaCompareString;
}
public override bool OpenBlock()
{
return true;
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
#endregion
}
}

10
Assets/Fungus/Scripts/Commands/LuaElseIf.cs

@ -18,21 +18,11 @@ namespace Fungus
#region Public members
public override bool OpenBlock()
{
return true;
}
public override bool CloseBlock()
{
return true;
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
#endregion
}
}

5
Assets/Fungus/Scripts/Commands/LuaIf.cs

@ -16,11 +16,6 @@ namespace Fungus
{
#region Public members
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
#endregion
}
}

2
Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs

@ -31,7 +31,7 @@ using UnityEngine.Serialization;
//Call this if the settings have changed
protected virtual void UpdateCache()
{
if (_SettingsString.Value != null)
if (!string.IsNullOrEmpty(_SettingsString.Value))
{
_synth.parameters.SetSettingsString(_SettingsString.Value);
_synth.CacheSound();

8
Assets/Fungus/Scripts/Commands/Property.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8a1a00144f44775449d32d39b5a7185a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

292
Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs

@ -0,0 +1,292 @@
/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
using UnityEngine;
namespace Fungus
{
// <summary>
/// Get or Set a property of a Animator component
/// </summary>
[CommandInfo("Property",
"Animator",
"Get or Set a property of a Animator component")]
[AddComponentMenu("")]
public class AnimatorProperty : BaseVariableProperty
{
//generated property
public enum Property
{
IsOptimizable,
IsHuman,
HasRootMotion,
HumanScale,
IsInitialized,
DeltaPosition,
DeltaRotation,
Velocity,
AngularVelocity,
RootPosition,
RootRotation,
ApplyRootMotion,
HasTransformHierarchy,
GravityWeight,
BodyPosition,
BodyRotation,
StabilizeFeet,
LayerCount,
ParameterCount,
FeetPivotActive,
PivotWeight,
PivotPosition,
IsMatchingTarget,
Speed,
TargetPosition,
TargetRotation,
PlaybackTime,
RecorderStartTime,
RecorderStopTime,
HasBoundPlayables,
LayersAffectMassCenter,
LeftFeetBottomHeight,
RightFeetBottomHeight,
LogWarnings,
FireEvents,
KeepAnimatorControllerStateOnDisable,
}
[SerializeField]
protected Property property;
[SerializeField]
[VariableProperty(typeof(AnimatorVariable))]
protected AnimatorVariable animatorVar;
[SerializeField]
[VariableProperty(typeof(BooleanVariable),
typeof(FloatVariable),
typeof(Vector3Variable),
typeof(QuaternionVariable),
typeof(IntegerVariable))]
protected Variable inOutVar;
public override void OnEnter()
{
var iob = inOutVar as BooleanVariable;
var iof = inOutVar as FloatVariable;
var iov = inOutVar as Vector3Variable;
var ioq = inOutVar as QuaternionVariable;
var ioi = inOutVar as IntegerVariable;
var target = animatorVar.Value;
switch (getOrSet)
{
case GetSet.Get:
switch (property)
{
case Property.IsOptimizable:
iob.Value = target.isOptimizable;
break;
case Property.IsHuman:
iob.Value = target.isHuman;
break;
case Property.HasRootMotion:
iob.Value = target.hasRootMotion;
break;
case Property.HumanScale:
iof.Value = target.humanScale;
break;
case Property.IsInitialized:
iob.Value = target.isInitialized;
break;
case Property.DeltaPosition:
iov.Value = target.deltaPosition;
break;
case Property.DeltaRotation:
ioq.Value = target.deltaRotation;
break;
case Property.Velocity:
iov.Value = target.velocity;
break;
case Property.AngularVelocity:
iov.Value = target.angularVelocity;
break;
case Property.RootPosition:
iov.Value = target.rootPosition;
break;
case Property.RootRotation:
ioq.Value = target.rootRotation;
break;
case Property.ApplyRootMotion:
iob.Value = target.applyRootMotion;
break;
case Property.HasTransformHierarchy:
iob.Value = target.hasTransformHierarchy;
break;
case Property.GravityWeight:
iof.Value = target.gravityWeight;
break;
case Property.BodyPosition:
iov.Value = target.bodyPosition;
break;
case Property.BodyRotation:
ioq.Value = target.bodyRotation;
break;
case Property.StabilizeFeet:
iob.Value = target.stabilizeFeet;
break;
case Property.LayerCount:
ioi.Value = target.layerCount;
break;
case Property.ParameterCount:
ioi.Value = target.parameterCount;
break;
case Property.FeetPivotActive:
iof.Value = target.feetPivotActive;
break;
case Property.PivotWeight:
iof.Value = target.pivotWeight;
break;
case Property.PivotPosition:
iov.Value = target.pivotPosition;
break;
case Property.IsMatchingTarget:
iob.Value = target.isMatchingTarget;
break;
case Property.Speed:
iof.Value = target.speed;
break;
case Property.TargetPosition:
iov.Value = target.targetPosition;
break;
case Property.TargetRotation:
ioq.Value = target.targetRotation;
break;
case Property.PlaybackTime:
iof.Value = target.playbackTime;
break;
case Property.RecorderStartTime:
iof.Value = target.recorderStartTime;
break;
case Property.RecorderStopTime:
iof.Value = target.recorderStopTime;
break;
case Property.HasBoundPlayables:
iob.Value = target.hasBoundPlayables;
break;
case Property.LayersAffectMassCenter:
iob.Value = target.layersAffectMassCenter;
break;
case Property.LeftFeetBottomHeight:
iof.Value = target.leftFeetBottomHeight;
break;
case Property.RightFeetBottomHeight:
iof.Value = target.rightFeetBottomHeight;
break;
case Property.LogWarnings:
iob.Value = target.logWarnings;
break;
case Property.FireEvents:
iob.Value = target.fireEvents;
break;
case Property.KeepAnimatorControllerStateOnDisable:
iob.Value = target.keepAnimatorControllerStateOnDisable;
break;
default:
Debug.Log("Unsupported get or set attempted");
break;
}
break;
case GetSet.Set:
switch (property)
{
case Property.RootPosition:
target.rootPosition = iov.Value;
break;
case Property.RootRotation:
target.rootRotation = ioq.Value;
break;
case Property.ApplyRootMotion:
target.applyRootMotion = iob.Value;
break;
case Property.BodyPosition:
target.bodyPosition = iov.Value;
break;
case Property.BodyRotation:
target.bodyRotation = ioq.Value;
break;
case Property.StabilizeFeet:
target.stabilizeFeet = iob.Value;
break;
case Property.FeetPivotActive:
target.feetPivotActive = iof.Value;
break;
case Property.Speed:
target.speed = iof.Value;
break;
case Property.PlaybackTime:
target.playbackTime = iof.Value;
break;
case Property.RecorderStartTime:
target.recorderStartTime = iof.Value;
break;
case Property.RecorderStopTime:
target.recorderStopTime = iof.Value;
break;
case Property.LayersAffectMassCenter:
target.layersAffectMassCenter = iob.Value;
break;
case Property.LogWarnings:
target.logWarnings = iob.Value;
break;
case Property.FireEvents:
target.fireEvents = iob.Value;
break;
case Property.KeepAnimatorControllerStateOnDisable:
target.keepAnimatorControllerStateOnDisable = iob.Value;
break;
default:
Debug.Log("Unsupported get or set attempted");
break;
}
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
if (animatorVar == null)
{
return "Error: no animatorVar set";
}
if (inOutVar == null)
{
return "Error: no variable set to push or pull data to or from";
}
return getOrSet.ToString() + " " + property.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (animatorVar == variable || inOutVar == variable)
return true;
return false;
}
}
}

11
Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e4616a794b2245d46970401b3acc492f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

261
Assets/Fungus/Scripts/Commands/Property/AudioSourceProperty.cs

@ -0,0 +1,261 @@
/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
using UnityEngine;
namespace Fungus
{
// <summary>
/// Get or Set a property of a AudioSource component
/// </summary>
[CommandInfo("Property",
"AudioSource",
"Get or Set a property of a AudioSource component")]
[AddComponentMenu("")]
public class AudioSourceProperty : BaseVariableProperty
{
//generated property
public enum Property
{
Volume,
Pitch,
Time,
TimeSamples,
IsPlaying,
IsVirtual,
Loop,
IgnoreListenerVolume,
PlayOnAwake,
IgnoreListenerPause,
PanStereo,
SpatialBlend,
Spatialize,
SpatializePostEffects,
ReverbZoneMix,
BypassEffects,
BypassListenerEffects,
BypassReverbZones,
DopplerLevel,
Spread,
Priority,
Mute,
MinDistance,
MaxDistance,
}
[SerializeField]
protected Property property;
[SerializeField]
[VariableProperty(typeof(AudioSourceVariable))]
protected AudioSourceVariable audioSourceVar;
[SerializeField]
[VariableProperty(typeof(FloatVariable),
typeof(IntegerVariable),
typeof(BooleanVariable))]
protected Variable inOutVar;
public override void OnEnter()
{
var iof = inOutVar as FloatVariable;
var ioi = inOutVar as IntegerVariable;
var iob = inOutVar as BooleanVariable;
var target = audioSourceVar.Value;
switch (getOrSet)
{
case GetSet.Get:
switch (property)
{
case Property.Volume:
iof.Value = target.volume;
break;
case Property.Pitch:
iof.Value = target.pitch;
break;
case Property.Time:
iof.Value = target.time;
break;
case Property.TimeSamples:
ioi.Value = target.timeSamples;
break;
case Property.IsPlaying:
iob.Value = target.isPlaying;
break;
case Property.IsVirtual:
iob.Value = target.isVirtual;
break;
case Property.Loop:
iob.Value = target.loop;
break;
case Property.IgnoreListenerVolume:
iob.Value = target.ignoreListenerVolume;
break;
case Property.PlayOnAwake:
iob.Value = target.playOnAwake;
break;
case Property.IgnoreListenerPause:
iob.Value = target.ignoreListenerPause;
break;
case Property.PanStereo:
iof.Value = target.panStereo;
break;
case Property.SpatialBlend:
iof.Value = target.spatialBlend;
break;
case Property.Spatialize:
iob.Value = target.spatialize;
break;
case Property.SpatializePostEffects:
iob.Value = target.spatializePostEffects;
break;
case Property.ReverbZoneMix:
iof.Value = target.reverbZoneMix;
break;
case Property.BypassEffects:
iob.Value = target.bypassEffects;
break;
case Property.BypassListenerEffects:
iob.Value = target.bypassListenerEffects;
break;
case Property.BypassReverbZones:
iob.Value = target.bypassReverbZones;
break;
case Property.DopplerLevel:
iof.Value = target.dopplerLevel;
break;
case Property.Spread:
iof.Value = target.spread;
break;
case Property.Priority:
ioi.Value = target.priority;
break;
case Property.Mute:
iob.Value = target.mute;
break;
case Property.MinDistance:
iof.Value = target.minDistance;
break;
case Property.MaxDistance:
iof.Value = target.maxDistance;
break;
default:
Debug.Log("Unsupported get or set attempted");
break;
}
break;
case GetSet.Set:
switch (property)
{
case Property.Volume:
target.volume = iof.Value;
break;
case Property.Pitch:
target.pitch = iof.Value;
break;
case Property.Time:
target.time = iof.Value;
break;
case Property.TimeSamples:
target.timeSamples = ioi.Value;
break;
case Property.Loop:
target.loop = iob.Value;
break;
case Property.IgnoreListenerVolume:
target.ignoreListenerVolume = iob.Value;
break;
case Property.PlayOnAwake:
target.playOnAwake = iob.Value;
break;
case Property.IgnoreListenerPause:
target.ignoreListenerPause = iob.Value;
break;
case Property.PanStereo:
target.panStereo = iof.Value;
break;
case Property.SpatialBlend:
target.spatialBlend = iof.Value;
break;
case Property.Spatialize:
target.spatialize = iob.Value;
break;
case Property.SpatializePostEffects:
target.spatializePostEffects = iob.Value;
break;
case Property.ReverbZoneMix:
target.reverbZoneMix = iof.Value;
break;
case Property.BypassEffects:
target.bypassEffects = iob.Value;
break;
case Property.BypassListenerEffects:
target.bypassListenerEffects = iob.Value;
break;
case Property.BypassReverbZones:
target.bypassReverbZones = iob.Value;
break;
case Property.DopplerLevel:
target.dopplerLevel = iof.Value;
break;
case Property.Spread:
target.spread = iof.Value;
break;
case Property.Priority:
target.priority = ioi.Value;
break;
case Property.Mute:
target.mute = iob.Value;
break;
case Property.MinDistance:
target.minDistance = iof.Value;
break;
case Property.MaxDistance:
target.maxDistance = iof.Value;
break;
default:
Debug.Log("Unsupported get or set attempted");
break;
}
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
if (audioSourceVar == null)
{
return "Error: no audioSourceVar set";
}
if (inOutVar == null)
{
return "Error: no variable set to push or pull data to or from";
}
return getOrSet.ToString() + " " + property.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (audioSourceVar == variable || inOutVar == variable)
return true;
return false;
}
}
}

11
Assets/Fungus/Scripts/Commands/Property/AudioSourceProperty.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2250cfac690a2b74f8f9dd9be91985c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

125
Assets/Fungus/Scripts/Commands/Property/CollectionProperty.cs

@ -0,0 +1,125 @@
/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
using UnityEngine;
namespace Fungus
{
// <summary>
/// Get or Set a property of a Collection component
/// </summary>
[CommandInfo("Property",
"Collection",
"Get or Set a property of a Collection component")]
[AddComponentMenu("")]
public class CollectionProperty : BaseVariableProperty
{
//generated property
public enum Property
{
Capacity,
Count,
IsFixedSize,
IsReadOnly,
IsSynchronized,
Name,
}
[SerializeField]
protected Property property;
[SerializeField]
protected CollectionData collectionData;
[SerializeField]
[VariableProperty(typeof(IntegerVariable),
typeof(BooleanVariable),
typeof(StringVariable))]
protected Variable inOutVar;
public override void OnEnter()
{
var ioi = inOutVar as IntegerVariable;
var iob = inOutVar as BooleanVariable;
var ios = inOutVar as StringVariable;
var target = collectionData.Value;
switch (getOrSet)
{
case GetSet.Get:
switch (property)
{
case Property.Capacity:
ioi.Value = target.Capacity;
break;
case Property.Count:
ioi.Value = target.Count;
break;
case Property.IsFixedSize:
iob.Value = target.IsFixedSize;
break;
case Property.IsReadOnly:
iob.Value = target.IsReadOnly;
break;
case Property.IsSynchronized:
iob.Value = target.IsSynchronized;
break;
case Property.Name:
ios.Value = target.Name;
break;
default:
Debug.Log("Unsupported get or set attempted");
break;
}
break;
case GetSet.Set:
switch (property)
{
case Property.Capacity:
target.Capacity = ioi.Value;
break;
default:
Debug.Log("Unsupported get or set attempted");
break;
}
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
if (collectionData.Value == null)
{
return "Error: no collection set";
}
if (inOutVar == null)
{
return "Error: no variable set to push or pull data to or from";
}
return getOrSet.ToString() + " " + property.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (collectionData.collectionRef == variable || inOutVar == variable)
return true;
return false;
}
}
}

11
Assets/Fungus/Scripts/Commands/Property/CollectionProperty.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6f03dcf7e7a1d2e418e5588731888b5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

153
Assets/Fungus/Scripts/Commands/Property/Collider2DProperty.cs

@ -0,0 +1,153 @@
/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
using UnityEngine;
namespace Fungus
{
// <summary>
/// Get or Set a property of a Collider2D component
/// </summary>
[CommandInfo("Property",
"Collider2D",
"Get or Set a property of a Collider2D component")]
[AddComponentMenu("")]
public class Collider2DProperty : BaseVariableProperty
{
//generated property
public enum Property
{
Density,
IsTrigger,
UsedByEffector,
UsedByComposite,
Offset,
AttachedRigidbody,
ShapeCount,
Friction,
Bounciness,
}
[SerializeField]
protected Property property;
[SerializeField]
protected Collider2DData collider2DData;
[SerializeField]
[VariableProperty(typeof(FloatVariable),
typeof(BooleanVariable),
typeof(Vector2Variable),
typeof(Rigidbody2DVariable),
typeof(IntegerVariable))]
protected Variable inOutVar;
public override void OnEnter()
{
var iof = inOutVar as FloatVariable;
var iob = inOutVar as BooleanVariable;
var iov2 = inOutVar as Vector2Variable;
var iorb2d = inOutVar as Rigidbody2DVariable;
var ioi = inOutVar as IntegerVariable;
var target = collider2DData.Value;
switch (getOrSet)
{
case GetSet.Get:
switch (property)
{
case Property.Density:
iof.Value = target.density;
break;
case Property.IsTrigger:
iob.Value = target.isTrigger;
break;
case Property.UsedByEffector:
iob.Value = target.usedByEffector;
break;
case Property.UsedByComposite:
iob.Value = target.usedByComposite;
break;
case Property.Offset:
iov2.Value = target.offset;
break;
case Property.AttachedRigidbody:
iorb2d.Value = target.attachedRigidbody;
break;
case Property.ShapeCount:
ioi.Value = target.shapeCount;
break;
case Property.Friction:
iof.Value = target.friction;
break;
case Property.Bounciness:
iof.Value = target.bounciness;
break;
default:
Debug.Log("Unsupported get or set attempted");
break;
}
break;
case GetSet.Set:
switch (property)
{
case Property.Density:
target.density = iof.Value;
break;
case Property.IsTrigger:
target.isTrigger = iob.Value;
break;
case Property.UsedByEffector:
target.usedByEffector = iob.Value;
break;
case Property.UsedByComposite:
target.usedByComposite = iob.Value;
break;
case Property.Offset:
target.offset = iov2.Value;
break;
default:
Debug.Log("Unsupported get or set attempted");
break;
}
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
if (collider2DData.Value == null)
{
return "Error: no collider2D set";
}
if (inOutVar == null)
{
return "Error: no variable set to push or pull data to or from";
}
return getOrSet.ToString() + " " + property.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (collider2DData.collider2DRef == variable || inOutVar == variable)
return true;
return false;
}
}
}

13
Assets/Fungus/Scripts/Commands/Property/Collider2DProperty.cs.meta

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: c5d345b268622414c9bb53e05f4580ed
timeCreated: 1517559095
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

123
Assets/Fungus/Scripts/Commands/Property/ColliderProperty.cs

@ -0,0 +1,123 @@
/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
using UnityEngine;
namespace Fungus
{
// <summary>
/// Get or Set a property of a Collider component
/// </summary>
[CommandInfo("Property",
"Collider",
"Get or Set a property of a Collider component")]
[AddComponentMenu("")]
public class ColliderProperty : BaseVariableProperty
{
//generated property
public enum Property
{
Enabled,
AttachedRigidbody,
IsTrigger,
ContactOffset,
}
[SerializeField]
protected Property property;
[SerializeField]
protected ColliderData colliderData;
[SerializeField]
[VariableProperty(typeof(BooleanVariable),
typeof(RigidbodyVariable),
typeof(FloatVariable))]
protected Variable inOutVar;
public override void OnEnter()
{
var iob = inOutVar as BooleanVariable;
var iorb = inOutVar as RigidbodyVariable;
var iof = inOutVar as FloatVariable;
var target = colliderData.Value;
switch (getOrSet)
{
case GetSet.Get:
switch (property)
{
case Property.Enabled:
iob.Value = target.enabled;
break;
case Property.AttachedRigidbody:
iorb.Value = target.attachedRigidbody;
break;
case Property.IsTrigger:
iob.Value = target.isTrigger;
break;
case Property.ContactOffset:
iof.Value = target.contactOffset;
break;
default:
Debug.Log("Unsupported get or set attempted");
break;
}
break;
case GetSet.Set:
switch (property)
{
case Property.Enabled:
target.enabled = iob.Value;
break;
case Property.IsTrigger:
target.isTrigger = iob.Value;
break;
case Property.ContactOffset:
target.contactOffset = iof.Value;
break;
default:
Debug.Log("Unsupported get or set attempted");
break;
}
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
if (colliderData.Value == null)
{
return "Error: no collider set";
}
if (inOutVar == null)
{
return "Error: no variable set to push or pull data to or from";
}
return getOrSet.ToString() + " " + property.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (colliderData.colliderRef == variable || inOutVar == variable)
return true;
return false;
}
}
}

13
Assets/Fungus/Scripts/Commands/Property/ColliderProperty.cs.meta

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: ca6e05b34c44a734988887ef775a1a1b
timeCreated: 1517559091
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save