Browse Source

Merge branch 'develop'

For v3.13.0
master
shalliwell 5 years ago
parent
commit
5e7d3e6425
  1. 1
      .gitignore
  2. 49
      Assets/Fungus/Docs/CHANGELOG.txt
  3. 434
      Assets/Fungus/Resources/Prefabs/NarrativeLog.prefab
  4. 7
      Assets/Fungus/Resources/Prefabs/NarrativeLog.prefab.meta
  5. 269
      Assets/Fungus/Resources/Prefabs/NarrativeLogEntryDisplay.prefab
  6. 7
      Assets/Fungus/Resources/Prefabs/NarrativeLogEntryDisplay.prefab.meta
  7. 70
      Assets/Fungus/Scripts/Commands/AssertCommand.cs
  8. 11
      Assets/Fungus/Scripts/Commands/AssertCommand.cs.meta
  9. 42
      Assets/Fungus/Scripts/Commands/Break.cs
  10. 2
      Assets/Fungus/Scripts/Commands/Call.cs
  11. 5
      Assets/Fungus/Scripts/Commands/Collection.meta
  12. 35
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs
  13. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs.meta
  14. 42
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs
  15. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs.meta
  16. 50
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs
  17. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs.meta
  18. 47
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs
  19. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs.meta
  20. 54
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs
  21. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs.meta
  22. 39
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs
  23. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs.meta
  24. 39
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs
  25. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs.meta
  26. 27
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs
  27. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs.meta
  28. 37
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs
  29. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs.meta
  30. 53
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs
  31. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs.meta
  32. 37
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs
  33. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs.meta
  34. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs
  35. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs.meta
  36. 25
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs
  37. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs.meta
  38. 53
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs
  39. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs.meta
  40. 24
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs
  41. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs.meta
  42. 41
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs
  43. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs.meta
  44. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs
  45. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs.meta
  46. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs
  47. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs.meta
  48. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs
  49. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs.meta
  50. 39
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs
  51. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs.meta
  52. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs
  53. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs.meta
  54. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs
  55. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs.meta
  56. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs
  57. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs.meta
  58. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs
  59. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs.meta
  60. 27
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs
  61. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs.meta
  62. 27
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs
  63. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs.meta
  64. 27
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs
  65. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs.meta
  66. 27
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs
  67. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs.meta
  68. 22
      Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs
  69. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs.meta
  70. 80
      Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs
  71. 11
      Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs.meta
  72. 90
      Assets/Fungus/Scripts/Commands/Collection/ForEach.cs
  73. 11
      Assets/Fungus/Scripts/Commands/Collection/ForEach.cs.meta
  74. 51
      Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs
  75. 11
      Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs.meta
  76. 162
      Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs
  77. 11
      Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs.meta
  78. 154
      Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs
  79. 11
      Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs.meta
  80. 147
      Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs
  81. 11
      Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs.meta
  82. 136
      Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs
  83. 11
      Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs.meta
  84. 218
      Assets/Fungus/Scripts/Commands/Condition.cs
  85. 1
      Assets/Fungus/Scripts/Commands/Conversation.cs
  86. 41
      Assets/Fungus/Scripts/Commands/DestroyOnLoad.cs
  87. 11
      Assets/Fungus/Scripts/Commands/DestroyOnLoad.cs.meta
  88. 32
      Assets/Fungus/Scripts/Commands/Else.cs
  89. 10
      Assets/Fungus/Scripts/Commands/ElseIf.cs
  90. 19
      Assets/Fungus/Scripts/Commands/End.cs
  91. 4
      Assets/Fungus/Scripts/Commands/FadeScreen.cs
  92. 7
      Assets/Fungus/Scripts/Commands/FadeToView.cs
  93. 8
      Assets/Fungus/Scripts/Commands/If.cs
  94. 89
      Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs
  95. 11
      Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs.meta
  96. 84
      Assets/Fungus/Scripts/Commands/LoopRange.cs
  97. 11
      Assets/Fungus/Scripts/Commands/LoopRange.cs.meta
  98. 13
      Assets/Fungus/Scripts/Commands/LuaCondition.cs
  99. 10
      Assets/Fungus/Scripts/Commands/LuaElseIf.cs
  100. 5
      Assets/Fungus/Scripts/Commands/LuaIf.cs
  101. Some files were not shown because too many files have changed in this diff Show More

1
.gitignore vendored

@ -17,3 +17,4 @@ UWP/*
Assets/Plugins/
Assets/Plugins.meta
Logs/*
.vscode/launch.json

49
Assets/Fungus/Docs/CHANGELOG.txt

@ -1,6 +1,55 @@
Changelog {#changelog}
=========
v3.13.0
======
## Added
- Conditional Commands now support multiple comparisons as a chain of && or ||. Thanks to preda2or, and AcademyOfF
- IWriterListener OnAllWorldsWritten fires when there are no words left to be written but writer may still have pending waits
- Entry based NarrativeLog alternate. Thanks to cg-tespy
- Option to grid snap blocks in the FlowchartWindow.
- TMPro Text animation via link text.
- Fungus Collection, varaibles, default types, and commands.
- Github Issue and PR templates.
## Fixed
- Portrait image shown as white when cycled through rapidly.
- Flowchart Window Search box steals focus
- Mushroom icon placement incorrect on some versions of Unity. Thanks to TonyJeffree
- Text and Background colour readability across Unity Versions and Pro skin. Thanks to DesperateHouseDev
- VariableData indents incorrect.
- Fix reshow of hidden portrait in Conversation. Thanks to jusw85
- FlowchartWindow search pop not showing on newer Unity versions.
- VS Solution file fix for Unity 2019.3.12
- Inspector DeleteSave button now deletes now more aware of target platform.
- Fungus VariableData single and mutliline variable drawing in more recent Unity versions.
- Possible null ref in Conversation editor during variable match check
- Block connections not drawing if origin block is not drawn.
## Changed
- Portraits are now all cached when requested under their own gameobjects and toggle active.
- Fungus Docs moved to github wiki
- JSONObject lib updated to newer version. Thanks to qrostar.
- CameraManager and View now use Tween types.
- Dragable EventHandlers now support an array of target dragables. Thanks to SarveshBajaj
- Flowchart GetVariables by type. Thanks to cg-tespy
- A null FungusVariables will now report their string value as Null instead of an empty string.
- Develop updated to Unity 2019.3.13
- Demo scenes rebuilt in minimum supported Unity version.
- Block selector now orders blocks by name.
- Block search now supports partial matches.
- Update to c#4
- Updates to Contributing, Code of Conduct.
- Menu command has a button to add a block for it to target.
- Character selector now sorts names.
- Portrait selector now sorts names.
- Update header license
- Writer uses InvariantCulture when parsing floats to avoid unexpected behaviour under changing system cultures.
v3.12.0
======

434
Assets/Fungus/Resources/Prefabs/NarrativeLog.prefab

@ -0,0 +1,434 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3892339027384508655
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3892339027384508654}
- component: {fileID: 3892339027384508652}
- component: {fileID: 3892339027384508653}
m_Layer: 5
m_Name: Background
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3892339027384508654
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339027384508655}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3892339028978780123}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3892339027384508652
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339027384508655}
m_CullTransparentMesh: 0
--- !u!114 &3892339027384508653
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339027384508655}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.2783019, g: 0.50158674, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!1 &3892339028022738724
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3892339028022738723}
- component: {fileID: 3892339028022738735}
- component: {fileID: 3892339028022738720}
- component: {fileID: 3892339028022738721}
- component: {fileID: 3892339028022738722}
m_Layer: 5
m_Name: EntryDisplayHolder
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3892339028022738723
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028022738724}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3892339028978780123}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: 0.000015258789}
m_SizeDelta: {x: 600, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!222 &3892339028022738735
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028022738724}
m_CullTransparentMesh: 0
--- !u!114 &3892339028022738720
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028022738724}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.2783019, g: 0.50158674, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &3892339028022738721
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028022738724}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 0
m_Spacing: 0
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 0
m_ChildControlWidth: 1
m_ChildControlHeight: 1
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
--- !u!114 &3892339028022738722
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028022738724}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!1 &3892339028774243865
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3892339028774243842}
- component: {fileID: 3892339028774243843}
- component: {fileID: 3892339028774243844}
- component: {fileID: 3892339028774243845}
- component: {fileID: 3892339028774243846}
- component: {fileID: 3892339028774243864}
m_Layer: 5
m_Name: NarrativeLog
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3892339028774243842
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028774243865}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 3892339028978780123}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!223 &3892339028774243843
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028774243865}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!114 &3892339028774243844
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028774243865}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!114 &3892339028774243845
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028774243865}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!225 &3892339028774243846
CanvasGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028774243865}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
--- !u!114 &3892339028774243864
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028774243865}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fde579c9edfbe7e469349e39e2a87a48, type: 3}
m_Name:
m_EditorClassIdentifier:
entryDisplayPrefab: {fileID: 2879084013005042991, guid: 243a94cf6d8dda84f8351f4289587571,
type: 3}
entryHolder: {fileID: 3892339028022738723}
--- !u!1 &3892339028978780124
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3892339028978780123}
- component: {fileID: 3892339028978780103}
- component: {fileID: 3892339028978780120}
- component: {fileID: 3892339028978780121}
- component: {fileID: 3892339028978780122}
m_Layer: 5
m_Name: MainWindow
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3892339028978780123
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028978780124}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 3892339027384508654}
- {fileID: 3892339028022738723}
m_Father: {fileID: 3892339028774243842}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 108.70001}
m_SizeDelta: {x: 600, y: 300}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3892339028978780103
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028978780124}
m_CullTransparentMesh: 0
--- !u!114 &3892339028978780120
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028978780124}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &3892339028978780121
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028978780124}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Content: {fileID: 3892339028022738723}
m_Horizontal: 0
m_Vertical: 1
m_MovementType: 2
m_Elasticity: 0.1
m_Inertia: 1
m_DecelerationRate: 0.135
m_ScrollSensitivity: 1
m_Viewport: {fileID: 0}
m_HorizontalScrollbar: {fileID: 0}
m_VerticalScrollbar: {fileID: 0}
m_HorizontalScrollbarVisibility: 0
m_VerticalScrollbarVisibility: 0
m_HorizontalScrollbarSpacing: 0
m_VerticalScrollbarSpacing: 0
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &3892339028978780122
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3892339028978780124}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ShowMaskGraphic: 1

7
Assets/Fungus/Resources/Prefabs/NarrativeLog.prefab.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bffd475e4bfb82f49810ceafe8d17b78
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

269
Assets/Fungus/Resources/Prefabs/NarrativeLogEntryDisplay.prefab

@ -0,0 +1,269 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2333275596563789949
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8885489252217067950}
- component: {fileID: 7933068750079926288}
- component: {fileID: 4379489694222926579}
m_Layer: 5
m_Name: NameText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8885489252217067950
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333275596563789949}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2481548615123137394}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7933068750079926288
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333275596563789949}
m_CullTransparentMesh: 0
--- !u!114 &4379489694222926579
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2333275596563789949}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: 64bd3e45f7a714f16b3c213f55f17fea, type: 3}
m_FontSize: 18
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 1
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Name
--- !u!1 &3511986559566215052
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3365827255933976305}
- component: {fileID: 3857872114285753493}
- component: {fileID: 19882628764411882}
m_Layer: 5
m_Name: StoryText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3365827255933976305
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3511986559566215052}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2481548615123137394}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3857872114285753493
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3511986559566215052}
m_CullTransparentMesh: 0
--- !u!114 &19882628764411882
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3511986559566215052}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: 64bd3e45f7a714f16b3c213f55f17fea, type: 3}
m_FontSize: 22
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 2
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: New Text
--- !u!1 &9061313995661533662
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2481548615123137394}
- component: {fileID: 3382758035194104851}
- component: {fileID: 819304301769093009}
- component: {fileID: 5508376540251964814}
- component: {fileID: 2879084013005042991}
m_Layer: 5
m_Name: NarrativeLogEntryDisplay
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2481548615123137394
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9061313995661533662}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 8885489252217067950}
- {fileID: 3365827255933976305}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 278}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3382758035194104851
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9061313995661533662}
m_CullTransparentMesh: 0
--- !u!114 &819304301769093009
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9061313995661533662}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!114 &5508376540251964814
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9061313995661533662}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 10
m_Right: 10
m_Top: 10
m_Bottom: 10
m_ChildAlignment: 0
m_Spacing: 0
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 1
m_ChildControlWidth: 1
m_ChildControlHeight: 1
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
--- !u!114 &2879084013005042991
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9061313995661533662}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 824b58b7741a0dd4e9b43693c47b24f7, type: 3}
m_Name:
m_EditorClassIdentifier:
nameTextField: {fileID: 4379489694222926579}
storyTextField: {fileID: 19882628764411882}

7
Assets/Fungus/Resources/Prefabs/NarrativeLogEntryDisplay.prefab.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 243a94cf6d8dda84f8351f4289587571
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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:

42
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;
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()

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

@ -53,8 +53,6 @@ namespace Fungus
public override void OnEnter()
{
var flowchart = GetFlowchart();
if (targetBlock != null)
{
// Check if calling your own parent block

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:

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

@ -5,114 +5,162 @@ 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;
}
#region Public members
protected End endCommand;
public override void OnEnter()
{
if (ParentBlock == null)
{
return;
}
//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 ( !HasNeededProperties() )
{
Debug.LogError(GetLocationIdentifier() + " cannot run due to missing required properties");
Continue();
return;
}
if( !this.IsElseIf )
//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()
{
if(endCommand == null)
{
// Else If behaves mostly like an Else command,
// but will also jump to a following Else command.
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)
protected End FindOurEndCommand()
{
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)
{
var command = ParentBlock.CommandList[i];
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 +171,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 +231,6 @@ namespace Fungus
{
// Execute the Else If command
Continue(i);
return;
}
}
@ -186,10 +239,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;
}
}
}

1
Assets/Fungus/Scripts/Commands/Conversation.cs

@ -81,6 +81,7 @@ namespace Fungus
var f = GetFlowchart();
if(!string.IsNullOrEmpty(conversationText.Value))
f.DetermineSubstituteVariables(conversationText, referencedVariables);
}
#endif

41
Assets/Fungus/Scripts/Commands/DestroyOnLoad.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>
/// Calls DontDestroyOnLoad on the target gameobject.
/// </summary>
[CommandInfo("Scripting",
"DestroyOnLoad",
"Calls DontDestroyOnLoad on the target gameobject")]
[AddComponentMenu("")]
public class DestroyOnLoad : Command
{
[SerializeField] protected GameObjectData target;
public override void OnEnter()
{
DontDestroyOnLoad(target.Value);
Continue();
}
public override string GetSummary()
{
return target.Value != null ? target.Value.name : "Error: no target set";
}
public override bool HasReference(Variable variable)
{
return variable == target.gameObjectRef;
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

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

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

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();
}

4
Assets/Fungus/Scripts/Commands/FadeScreen.cs

@ -31,6 +31,8 @@ namespace Fungus
[Tooltip("Optional texture to use when rendering the fullscreen fade effect.")]
[SerializeField] protected Texture2D fadeTexture;
[SerializeField] protected LeanTweenType fadeTweenType = LeanTweenType.easeInOutQuad;
#region Public members
public override void OnEnter()
@ -51,7 +53,7 @@ namespace Fungus
{
Continue();
}
});
}, fadeTweenType);
if (!waitUntilFinished)
{

7
Assets/Fungus/Scripts/Commands/FadeToView.cs

@ -35,6 +35,11 @@ namespace Fungus
[Tooltip("Camera to use for the fade. Will use main camera if set to none.")]
[SerializeField] protected Camera targetCamera;
[SerializeField] protected LeanTweenType fadeTweenType = LeanTweenType.easeInOutQuad;
[SerializeField] protected LeanTweenType orthoSizeTweenType = LeanTweenType.easeInOutQuad;
[SerializeField] protected LeanTweenType posTweenType = LeanTweenType.easeInOutQuad;
[SerializeField] protected LeanTweenType rotTweenType = LeanTweenType.easeInOutQuad;
protected virtual void Start()
{
AcquireCamera();
@ -87,7 +92,7 @@ namespace Fungus
{
Continue();
}
});
}, fadeTweenType, orthoSizeTweenType, posTweenType, rotTweenType);
if (!waitUntilFinished)
{

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
}
}

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

Loading…
Cancel
Save