1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

Flipped output inherited type constraints, edited comments

This commit is contained in:
Thor Brigsted 2019-11-06 11:34:09 +01:00
parent 7f009e1829
commit 36316e83b8
2 changed files with 5 additions and 5 deletions

View File

@ -45,11 +45,11 @@ namespace XNode {
public enum TypeConstraint {
/// <summary> Allow all types of input</summary>
None,
/// <summary> Allow similar and inherited types </summary>
/// <summary> Allow connections where input value type is assignable from output value type (eg. ScriptableObject --> Object)</summary>
Inherited,
/// <summary> Allow only similar types </summary>
Strict,
/// <summary> Allow similar and inherited types but checks inheritance in reverse </summary>
/// <summary> Allow connections where output value type is assignable from input value type (eg. Object --> ScriptableObject)</summary>
InheritedInverse,
}

View File

@ -261,9 +261,9 @@ namespace XNode {
if (input.typeConstraint == XNode.Node.TypeConstraint.Strict && input.ValueType != output.ValueType) return false;
if (input.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !output.ValueType.IsAssignableFrom(input.ValueType)) return false;
// Check output type constraints
if (output.typeConstraint == XNode.Node.TypeConstraint.Inherited && !output.ValueType.IsAssignableFrom(input.ValueType)) return false;
if (output.typeConstraint == XNode.Node.TypeConstraint.Strict && output.ValueType != input.ValueType) return false;
if (output.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !input.ValueType.IsAssignableFrom(output.ValueType)) return false;
if (output.typeConstraint == XNode.Node.TypeConstraint.Inherited && !input.ValueType.IsAssignableFrom(output.ValueType)) return false;
if (output.typeConstraint == XNode.Node.TypeConstraint.Strict && input.ValueType != output.ValueType) return false;
if (output.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !output.ValueType.IsAssignableFrom(input.ValueType)) return false;
// Success
return true;
}