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.

318 lines
12 KiB

// 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 System.Collections.Generic;
namespace Fungus
{
[System.Serializable]
public class conditionExpression
{
[SerializeField] protected CompareOperator compareOperator;
[SerializeField] protected AnyVariableAndDataPair anyVar;
public virtual AnyVariableAndDataPair AnyVar { get { return anyVar; } }
public virtual CompareOperator CompareOperator { get { return compareOperator; } }
public conditionExpression(){}
public conditionExpression(CompareOperator op, AnyVariableAndDataPair variablePair)
{
compareOperator = op;
anyVar = variablePair;
}
}
// anyone with a better name for this can update it
public enum AnyOrAllConditions
{
AnyOneTrue,
AllTrue
}
public abstract class VariableCondition : Condition, ISerializationCallbackReceiver
{
[Tooltip("The type of comparison to be performed")]
[SerializeField] protected AnyOrAllConditions anyOrAllConditions;
[SerializeField] protected List<conditionExpression> conditions = new List<conditionExpression>();
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
protected override bool EvaluateCondition()
{
if (conditions == null || conditions.Count == 0)
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
{
return false;
}
bool resultAny = false, resultAll = true;
foreach (conditionExpression condition in conditions)
{
bool curResult = false;
if (condition.AnyVar == null)
{
resultAll &= curResult;
resultAny |= curResult;
continue;
}
condition.AnyVar.Compare(condition.CompareOperator, ref curResult);
Debug.Log("res : " + curResult.ToString());
resultAll &= curResult;
resultAny |= curResult;
}
if (anyOrAllConditions == AnyOrAllConditions.AnyOneTrue) return resultAny;
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
return resultAll;
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
}
protected override bool HasNeededProperties()
{
if( conditions == null || conditions.Count == 0){
return false;
}
foreach (conditionExpression condition in conditions)
{
if(condition.AnyVar == null || condition.AnyVar.variable == null){
return false;
}
}
return true;
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
}
#region Public members
/// <summary>
/// The type of comparison operation to be performed.
/// </summary>
public virtual CompareOperator CompareOperator { get { return conditions[0].CompareOperator; } }
public virtual List<conditionExpression> Conditions { get { return conditions; } }
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
public override string GetSummary()
{
if (!this.HasNeededProperties())
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
{
return "Error: No variable selected";
}
string summary = "";
string connector = "";
if(anyOrAllConditions == AnyOrAllConditions.AnyOneTrue){
connector = " Or ";
}
else{
connector = " And ";
}
for(int i = 0 ; i < conditions.Count; i++)
{
summary += conditions[i].AnyVar.variable.Key + " ";
summary += VariableUtil.GetCompareOperatorDescription(conditions[i].CompareOperator) + " ";
summary += conditions[i].AnyVar.GetDataDescription();
if(i<conditions.Count-1){
summary += connector;
}
}
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
return summary;
}
public override bool HasReference(Variable variable)
{
return anyVar.HasReference(variable);
}
#endregion
#region backwards compat
[SerializeField] protected CompareOperator compareOperator;
[SerializeField] protected AnyVariableAndDataPair anyVar;
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
[Tooltip("Variable to use in expression")]
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
[VariableProperty(AllVariableTypes.VariableAny.Any)]
[SerializeField] protected Variable variable;
[Tooltip("Boolean value to compare against")]
[SerializeField] protected BooleanData booleanData;
[Tooltip("Integer value to compare against")]
[SerializeField] protected IntegerData integerData;
[Tooltip("Float value to compare against")]
[SerializeField] protected FloatData floatData;
[Tooltip("String value to compare against")]
[SerializeField] protected StringDataMulti stringData;
[Tooltip("Animator value to compare against")]
[SerializeField] protected AnimatorData animatorData;
[Tooltip("AudioSource value to compare against")]
[SerializeField] protected AudioSourceData audioSourceData;
[Tooltip("Color value to compare against")]
[SerializeField] protected ColorData colorData;
[Tooltip("GameObject value to compare against")]
[SerializeField] protected GameObjectData gameObjectData;
[Tooltip("Material value to compare against")]
[SerializeField] protected MaterialData materialData;
[Tooltip("Object value to compare against")]
[SerializeField] protected ObjectData objectData;
[Tooltip("Rigidbody2D value to compare against")]
[SerializeField] protected Rigidbody2DData rigidbody2DData;
[Tooltip("Sprite value to compare against")]
[SerializeField] protected SpriteData spriteData;
[Tooltip("Texture value to compare against")]
[SerializeField] protected TextureData textureData;
[Tooltip("Transform value to compare against")]
[SerializeField] protected TransformData transformData;
[Tooltip("Vector2 value to compare against")]
[SerializeField] protected Vector2Data vector2Data;
[Tooltip("Vector3 value to compare against")]
[SerializeField] protected Vector3Data vector3Data;
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
void ISerializationCallbackReceiver.OnBeforeSerialize()
{
}
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
void ISerializationCallbackReceiver.OnAfterDeserialize()
{
if( variable != null)
{
{
anyVar.variable = variable;
}
if (variable.GetType() == typeof(BooleanVariable) && !booleanData.Equals(new BooleanData()))
{
anyVar.data.booleanData = booleanData;
booleanData = new BooleanData();
}
else if (variable.GetType() == typeof(IntegerVariable) && !integerData.Equals(new IntegerData()))
{
anyVar.data.integerData = integerData;
integerData = new IntegerData();
}
else if (variable.GetType() == typeof(FloatVariable) && !floatData.Equals(new FloatData()))
{
anyVar.data.floatData = floatData;
floatData = new FloatData();
}
else if (variable.GetType() == typeof(StringVariable) && !stringData.Equals(new StringDataMulti()))
{
anyVar.data.stringData.stringRef = stringData.stringRef;
anyVar.data.stringData.stringVal = stringData.stringVal;
stringData = new StringDataMulti();
}
else if (variable.GetType() == typeof(AnimatorVariable) && !animatorData.Equals(new AnimatorData()))
{
anyVar.data.animatorData = animatorData;
animatorData = new AnimatorData();
}
else if (variable.GetType() == typeof(AudioSourceVariable) && !audioSourceData.Equals(new AudioSourceData()))
{
anyVar.data.audioSourceData = audioSourceData;
audioSourceData = new AudioSourceData();
}
else if (variable.GetType() == typeof(ColorVariable) && !colorData.Equals(new ColorData()))
{
anyVar.data.colorData = colorData;
colorData = new ColorData();
}
else if (variable.GetType() == typeof(GameObjectVariable) && !gameObjectData.Equals(new GameObjectData()))
{
anyVar.data.gameObjectData = gameObjectData;
gameObjectData = new GameObjectData();
}
else if (variable.GetType() == typeof(MaterialVariable) && !materialData.Equals(new MaterialData()))
{
anyVar.data.materialData = materialData;
materialData = new MaterialData();
}
else if (variable.GetType() == typeof(ObjectVariable) && !objectData.Equals(new ObjectData()))
{
anyVar.data.objectData = objectData;
objectData = new ObjectData();
}
else if (variable.GetType() == typeof(Rigidbody2DVariable) && !rigidbody2DData.Equals(new Rigidbody2DData()))
{
anyVar.data.rigidbody2DData = rigidbody2DData;
rigidbody2DData = new Rigidbody2DData();
}
else if (variable.GetType() == typeof(SpriteVariable) && !spriteData.Equals(new SpriteData()))
{
anyVar.data.spriteData = spriteData;
spriteData = new SpriteData();
}
else if (variable.GetType() == typeof(TextureVariable) && !textureData.Equals(new TextureData()))
{
anyVar.data.textureData = textureData;
textureData = new TextureData();
}
else if (variable.GetType() == typeof(TransformVariable) && !transformData.Equals(new TransformData()))
{
anyVar.data.transformData = transformData;
transformData = new TransformData();
}
else if (variable.GetType() == typeof(Vector2Variable) && !vector2Data.Equals(new Vector2Data()))
{
anyVar.data.vector2Data = vector2Data;
vector2Data = new Vector2Data();
}
else if (variable.GetType() == typeof(Vector3Variable) && !vector3Data.Equals(new Vector3Data()))
{
anyVar.data.vector3Data = vector3Data;
vector3Data = new Vector3Data();
}
//moved to new anyvar storage, clear legacy.
variable = null;
}
// just checking for anyVar != null fails here. is any var beig reintilaized somewhere?
if(anyVar != null && anyVar.variable != null){
conditionExpression c = new conditionExpression(compareOperator,anyVar);
if(!conditions.Contains(c)){
conditions.Add(c);
}
//added to list
anyVar = null;
//this is not nullabale?
//compareOperator = null;
}
}
#endregion
}
}