Exemplo n.º 1
0
        protected virtual AttributeVariableType add <T>(string variableName)
        {
            if (exist(variableName))
            {
                OLib.Console.warning(string.Format("Failed AttributeVariable add, type {0} is exist", typeof(T).Name));
                return(null);
            }

            AttributeVariableType variable = null;

            switch (typeof(T).Name)
            {
            case "Int32":   variable = new AttributeVariableInt(); break;

            case "Single":   variable = new AttributeVariableFloat(); break;

            case "Boolean":    variable = new AttributeVariableBool(); break;

            default: OLib.Console.warning(string.Format("Failed AttributeVariable add, invalid type {0}", typeof(T).Name)); break;
            }

            if (null != variable)
            {
                m_variables.Add(variableName, variable);
            }

            return(variable);
        }
Exemplo n.º 2
0
        public bool equal <T>(string variableName, T value)
        {
            AttributeVariableType variable = find(variableName);

            if (null == variable)
            {
                return(false);
            }

            return(variable.equal <T>(value));
        }
Exemplo n.º 3
0
        public T get <T>(string variableName)
        {
            AttributeVariableType variable = find(variableName);

            if (null == variable)
            {
                return(default(T));
            }

            return(variable.getValue <T>());
        }
Exemplo n.º 4
0
        public void set <T>(string variableName, T value)
        {
            AttributeVariableType variable = find(variableName);

            if (null == variable)
            {
                variable = add <T>(variableName);
                if (null == variable)
                {
                    return;
                }
            }

            variable.setValue <T>(value);
        }