An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.5 KiB

Collection (#787) Add concept of Collection to Fungus. Add Collection Demo, Physics Cast Demo. They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons. A number of refactorings and additions along with this to make it work more seamlessly. Variable operators defined by Variable itself Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands PlayMode Tests and Utils added Additional Variable Types, such as Quaternion, Matrix4x4 Physics casts Commands that use collections * Initial Fungus Collection work with support for int and IntegerVariable * While and Condition related changes to allow for new command Loop Range * Collection Get changes and ForEach rough * Added Collection Commands Reordered Elif logic in Condition * More collection types and commands * Variable reorg to allow for new types to be added more simply and centrally * Added more Fungus Vars for Common Unity types VariableList Adapter can delegate to the variable itself for custom drawing Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types * Many basic collection operations added Common Collection types Physics Overlap command * Custom variable drawing moved to VariableInfo.cs rather than child variable itself Added Physics cast and overlap commands * Move all Editor scripts into Editor AsmDef folder * LoopRange also registers as command name For * Condition base class commenting improved and refactored repeated looping style child class elements into base * More descriptive CollectionBase Command class names * Fungus Collection interface and comments refined * Rename ICollection to IFungusCollection Cleanup formatting * Collection example scene * Added Collection Tests * Format collection and test files Added CopyFrom to IFungusCollection * Added FungusCollection initial summaries * Added CollectionRandom commands -added simple use to CollectionLoop demo scene * Added Unique to FungusCollection -Updated tests to include unique Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects * CollectionPhysics tracks mousepos with visual Added Fungus Command to get mouse position * Variable custom draw moved to its own editor class, no longer part of typeinfo Variable generation run * Add playmode test for variable type sets Add playmode test for flow control * Update doco and formatting for Collection classes Refactor parts of Conditional classes and AnyVariable Move Property commands into Category 'Property' * Update Collection comments, formatting and Update internal to public * Add License header to added variable types
5 years ago
// 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.Assertions;
namespace Fungus.EditorUtils
{
static public class TestUtils
{
/// <summary>
/// Loads a prefab from the resources folder, optionally waiting a preset amount of time for it to complete or until says it is done.
/// </summary>
/// <param name="prefabTestName">Name of prefab in the editor resources folder to tunr, expects it to have a flowchart on in
/// that will try to execute at frame 0</param>
/// <param name="runBlocksManually">if true will run blocks in sequence until all are complete</param>
/// <param name="maxFramesToComplete">max frames for the test to be allowed to run, will assert if it runs beyond this limit</param>
/// <returns></returns>
static public System.Collections.IEnumerator RunPrefabFlowchartTests(string prefabTestName, bool runBlocksManually = true, int maxFramesToComplete = 1000)
{
var resPrefab = UnityEngine.Resources.Load<UnityEngine.GameObject>(prefabTestName);
Assert.IsNotNull(resPrefab);
var resTest = UnityEngine.Object.Instantiate(resPrefab);
//give it a few frames to kick in
yield return null;
yield return null;
yield return null;
// Use the Assert class to test conditions.
// Use yield to skip a frame.
var f = resTest.GetComponent<Flowchart>();
Assert.IsNotNull(f);
int frame = 3;
//ensure there isn't something already doing a job
while (f.HasExecutingBlocks())
{
frame++;
Assert.IsTrue(frame < maxFramesToComplete);
yield return null;
}
if (runBlocksManually)
{
var blocks = f.GetComponents<Block>();
foreach (var block in blocks)
{
block.StartExecution();
while (f.HasExecutingBlocks())
{
frame++;
Assert.IsTrue(frame < maxFramesToComplete);
yield return null;
}
}
}
UnityEngine.Object.DestroyImmediate(resTest);
Collection (#787) Add concept of Collection to Fungus. Add Collection Demo, Physics Cast Demo. They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons. A number of refactorings and additions along with this to make it work more seamlessly. Variable operators defined by Variable itself Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands PlayMode Tests and Utils added Additional Variable Types, such as Quaternion, Matrix4x4 Physics casts Commands that use collections * Initial Fungus Collection work with support for int and IntegerVariable * While and Condition related changes to allow for new command Loop Range * Collection Get changes and ForEach rough * Added Collection Commands Reordered Elif logic in Condition * More collection types and commands * Variable reorg to allow for new types to be added more simply and centrally * Added more Fungus Vars for Common Unity types VariableList Adapter can delegate to the variable itself for custom drawing Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types * Many basic collection operations added Common Collection types Physics Overlap command * Custom variable drawing moved to VariableInfo.cs rather than child variable itself Added Physics cast and overlap commands * Move all Editor scripts into Editor AsmDef folder * LoopRange also registers as command name For * Condition base class commenting improved and refactored repeated looping style child class elements into base * More descriptive CollectionBase Command class names * Fungus Collection interface and comments refined * Rename ICollection to IFungusCollection Cleanup formatting * Collection example scene * Added Collection Tests * Format collection and test files Added CopyFrom to IFungusCollection * Added FungusCollection initial summaries * Added CollectionRandom commands -added simple use to CollectionLoop demo scene * Added Unique to FungusCollection -Updated tests to include unique Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects * CollectionPhysics tracks mousepos with visual Added Fungus Command to get mouse position * Variable custom draw moved to its own editor class, no longer part of typeinfo Variable generation run * Add playmode test for variable type sets Add playmode test for flow control * Update doco and formatting for Collection classes Refactor parts of Conditional classes and AnyVariable Move Property commands into Category 'Property' * Update Collection comments, formatting and Update internal to public * Add License header to added variable types
5 years ago
}
}
}