mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
Fixed TypeConstraint.Inherited, and added TypeConstraint.InheritedInverse (#205)
* Added TypeConstraint to check inheritance but inverted. * Flipped output inherited type constraints, edited comments
This commit is contained in:
parent
be0d452d12
commit
63c3ae2f7d
@ -45,10 +45,12 @@ 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 connections where output value type is assignable from input value type (eg. Object --> ScriptableObject)</summary>
|
||||
InheritedInverse,
|
||||
}
|
||||
|
||||
#region Obsolete
|
||||
|
||||
@ -263,9 +263,11 @@ namespace XNode {
|
||||
// Check input type constraints
|
||||
if (input.typeConstraint == XNode.Node.TypeConstraint.Inherited && !input.ValueType.IsAssignableFrom(output.ValueType)) return false;
|
||||
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.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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user