public OutputPortConfig(string _name, string _humanName, string desc, NodePortType _type, InputPortConfig[] inputPorts, OutputPortConfig[] outputPorts)
            : this()
        {
            name = _name;
            humanName = _humanName;
            description = desc;
            type = _type;

            inputs = inputPorts.Cast<object>().ToArray();
            outputs = outputPorts.Cast<object>().ToArray();
        }
Пример #2
0
        public NodeConfig(FlowNodeFilter cat, string desc, FlowNodeFlags nodeFlags, FlowNodeType nodeType, InputPortConfig[] inputPorts, OutputPortConfig[] outputPorts)
            : this()
        {
            flags = nodeFlags;
            filter = cat;
            description = desc;
            type = nodeType;

            inputs = inputPorts.Cast<object>().ToArray();
            outputs = outputPorts.Cast<object>().ToArray();
        }
Пример #3
0
        bool TryGetFlowNodeInput(PortAttribute portAttribute, MethodInfo method, out InputPortConfig inputPortConfig)
        {
            string portPrefix = null;

            object defaultVal = null;

            inputPortConfig = new InputPortConfig();

            if (method.GetParameters().Length > 0)
            {
                ParameterInfo parameter = method.GetParameters()[0];
                if (parameter.ParameterType.IsEnum)
                {
                    inputPortConfig.type = NodePortType.Int;

                    var values = Enum.GetValues(parameter.ParameterType);
                    if (values.Length <= 0)
                        return false;

                    defaultVal = values.GetValue(0);

                    inputPortConfig.uiConfig = "enum_int:";

                    for (int i = 0; i < values.Length; i++)
                    {
                        var value = values.GetValue(i);

                        if (i > 0 && i != inputPortConfig.uiConfig.Length)
                            inputPortConfig.uiConfig += ",";

                        inputPortConfig.uiConfig += Enum.GetName(parameter.ParameterType, value) + "=" + (int)value;
                    }
                }
                else
                    inputPortConfig.type = GetFlowNodePortType(parameter.ParameterType, out portPrefix, portAttribute);

                if (parameter.IsOptional && defaultVal == null)
                    defaultVal = parameter.DefaultValue;
                else if (defaultVal == null)
                {
                    switch (inputPortConfig.type)
                    {
                        case NodePortType.Bool:
                            defaultVal = false;
                            break;
                        case NodePortType.EntityId:
                            defaultVal = 0;
                            break;
                        case NodePortType.Float:
                            defaultVal = 0.0f;
                            break;
                        case NodePortType.Int:
                            defaultVal = 0;
                            break;
                        case NodePortType.String:
                            defaultVal = "";
                            break;
                        case NodePortType.Vec3:
                            defaultVal = Vec3.Zero;
                            break;
                    }
                }
            }
            else
                inputPortConfig.type = NodePortType.Void;

            string portName = (portAttribute.Name ?? method.Name);

            if (portPrefix != null)
                inputPortConfig.name = portPrefix + portName;
            else
                inputPortConfig.name = portName;

            inputPortConfig.defaultValue = defaultVal;
            inputPortConfig.description = portAttribute.Description;
            inputPortConfig.humanName = portAttribute.Name ?? method.Name;
            return true;
        }