Exemple #1
0
        public bool ResolveInterface <InterfaceType>(IVariableStore variables, VariableReference reference, out InterfaceType result) where InterfaceType : class
        {
            var value = reference.GetValue(variables);

            if (value.HasReference)
            {
                if (value.Reference is InterfaceType i)
                {
                    result = i;
                    return(true);
                }
                else
                {
                    result = null;
                    LogResolveWarning(value, reference, VariableType.Object, typeof(InterfaceType));
                    return(false);
                }
            }

            result = null;
            LogResolveWarning(value, reference, VariableType.Object);
            return(false);
        }
Exemple #2
0
 private void LogResolveWarning(VariableValue value, VariableReference reference, VariableType expectedType, Type resolveType = null)
 {
     if (value.IsEmpty || value.IsNull)
     {
         Debug.LogWarningFormat(this, _missingVariableWarning, reference, name);
     }
     else if (value.Type == VariableType.Enum && resolveType != null)
     {
         Debug.LogWarningFormat(this, _invalidEnumWarning, reference, name, value.EnumType.Name, resolveType.Name);
     }
     else if (value.Type == VariableType.Object && resolveType != null)
     {
         Debug.LogWarningFormat(this, _invalidObjectWarning, reference, name, value.Object.name, value.ReferenceType.Name, resolveType.Name);
     }
     else if (value.HasReference && resolveType != null)
     {
         Debug.LogWarningFormat(this, _invalidTypeWarning, reference, name, value.ReferenceType.Name, resolveType.Name);
     }
     else
     {
         Debug.LogWarningFormat(this, _invalidVariableWarning, reference, name, value.Type, expectedType);
     }
 }
Exemple #3
0
 public bool Resolve(IVariableStore variables, VariableReference reference, out VariableValue result)
 {
     result = reference.GetValue(variables);
     return(true);
 }
Exemple #4
0
 public static bool IsOutput(VariableReference variable) => variable.IsAssigned && variable.StoreName == OutputStoreName;