コード例 #1
0
        private string getValueType(MethodDef.Param param, string propertyName)
        {
            if (param.IsLocalVar)
            {
                Nodes.Behavior behavior = GetBehavior();
                AgentType      agent    = (behavior != null) ? behavior.AgentType : null;

                // Try to find the Agent property with the name.
                if (agent != null)
                {
                    IList <PropertyDef> properties = agent.GetProperties();
                    foreach (PropertyDef p in properties)
                    {
                        if (p.Name == propertyName
#if BEHAVIAC_NAMESPACE_FIX
                            || p.Name.EndsWith(propertyName)
#endif
                            )
                        {
                            return(VariableDef.kSelf);
                        }
                    }
                }

                // Try to find the global property with the name.
                string className = Plugin.GetClassName(propertyName);

                return(getValueType(param, className, propertyName));
            }

            return(VariableDef.kConst);
        }
コード例 #2
0
        public static string GetProperty(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent)
        {
            string retStr = string.Empty;

            if (property != null)
            {
                string typename = DataCppExporter.GetGeneratedNativeType(property.NativeType);
                if (!typename.EndsWith("*") && Plugin.IsRefType(property.Type))
                {
                    typename += "*";
                }

                if (property.IsArrayElement && !typename.StartsWith("behaviac::vector<"))
                {
                    typename = string.Format("behaviac::vector<{0} >", typename);
                }

                string propBasicName = property.BasicName.Replace("[]", "");
                uint   id            = Behaviac.Design.CRC32.CalcCRC(propBasicName);

                stream.WriteLine("{0}BEHAVIAC_ASSERT(behaviac::MakeVariableId(\"{1}\") == {2}u);", indent, propBasicName, id);
                retStr = string.Format("({0}&)pAgent->GetVariable<{0} >({1}u)", typename, id);
            }

            return(retStr);
        }
コード例 #3
0
        public override void SetParameter(MethodDef.Param param, object obj)
        {
            base.SetParameter(param, obj);

            _resetProperties = false;

            Behaviac.Design.Attachments.Attach evt      = obj as Behaviac.Design.Attachments.Attach;
            Behaviac.Design.Nodes.BaseNode     baseNode = (evt != null) ? evt.Node : obj as Behaviac.Design.Nodes.BaseNode;
            Behaviac.Design.Nodes.Behavior     behavior = (baseNode != null) ? baseNode.Behavior as Behaviac.Design.Nodes.Behavior : null;

            _agentType = (behavior != null) ? behavior.AgentType : null;
            if (!string.IsNullOrEmpty(_globalType))
            {
                _agentType = Plugin.GetInstanceAgentType(_globalType);
            }

            string      selectionName = string.Empty;
            VariableDef variable      = param.Value as VariableDef;

            if (variable != null)
            {
                selectionName = (variable.Property != null) ? variable.Property.DisplayName : variable.DisplayName;
            }
            else
            {
                RightValueDef variableRV = param.Value as RightValueDef;
                if (variableRV != null)
                {
                    selectionName = variableRV.DisplayName;
                }
            }

            setComboBox(selectionName);
        }
コード例 #4
0
        private string getValueType(MethodDef.Param param, string instanceName, string propertyName)
        {
            if (param.IsProperty)
            {
                if (instanceName == VariableDef.kSelf)
                {
                    return(VariableDef.kSelf);
                }

                Nodes.Behavior behavior = GetBehavior();
                AgentType      agent    = (behavior != null) ? behavior.AgentType : null;
                agent = Plugin.GetInstanceAgentType(instanceName, behavior, agent);

                if (agent != null)
                {
                    IList <PropertyDef> properties = agent.GetProperties();
                    foreach (PropertyDef p in properties)
                    {
                        if (p.Name == propertyName
#if BEHAVIAC_NAMESPACE_FIX
                            || p.Name.EndsWith(propertyName)
#endif
                            )
                        {
                            return(instanceName);
                        }
                    }
                }
            }

            return(VariableDef.kConst);
        }
コード例 #5
0
        private static string getProperty(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, string agentName, StreamWriter stream, string indent)
        {
            if (property.IsPar || property.IsCustomized)
            {
                return(ParInfoCppExporter.GetProperty(agentName, property, arrayIndexElement, stream, indent));
            }

            string propName   = DataCppExporter.GetPropertyBasicName(property, arrayIndexElement);
            string nativeType = DataCppExporter.GetPropertyNativeType(property, arrayIndexElement);

            if (property.IsPublic)
            {
                string className = property.ClassName;

                if (property.IsStatic)
                {
                    return(string.Format("{0}::{1}", className, propName));
                }
                else
                {
                    return(string.Format("(({0}*){1})->{2}", className, agentName, propName));
                }
            }

            propName = property.Name.Replace("::", "_");
            propName = propName.Replace("[]", "");
            return(string.Format("(({0}*){1})->_Get_Property_<{2}PROPERTY_TYPE_{3}, {4} >()", property.ClassName, agentName, getNamespace(property.ClassName), propName, nativeType));
        }
コード例 #6
0
        public static string GenerateCode(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, bool isRefParam, StreamWriter stream, string indent, string typename, string var, string caller, string setValue = null)
        {
            if (property.IsPar || property.IsCustomized)
            {
                return(ParInfoCsExporter.GenerateCode(property, isRefParam, stream, indent, typename, var, caller));
            }

            string agentName = GetGenerateAgentName(property, var, caller);
            string prop      = GetProperty(property, arrayIndexElement, stream, indent, var, caller);

            if (setValue == null)
            {
                if (!string.IsNullOrEmpty(var))
                {
                    if (string.IsNullOrEmpty(typename))
                    {
                        stream.WriteLine("{0}{1} = {2};", indent, var, prop);
                    }
                    else
                    {
                        string nativeType = DataCsExporter.GetPropertyNativeType(property, arrayIndexElement);

                        stream.WriteLine("{0}{1} {2} = {3};", indent, nativeType, var, prop);
                    }
                }
            }
            else
            {
                string propBasicName = property.BasicName.Replace("[]", "");
                stream.WriteLine("{0}AgentMetaVisitor.SetProperty({1}, \"{2}\", {3});", indent, agentName, propBasicName, setValue);
            }

            return(prop);
        }
コード例 #7
0
        private static string getProperty(PropertyDef property, MethodDef.Param arrayIndexElement, string agentName, StringWriter stream, string indent)
        {
            if (property.IsPar || property.IsCustomized)
            {
                return(ParInfoCsExporter.GetProperty(agentName, property, arrayIndexElement, stream, indent));
            }

            string propName   = DataCsExporter.GetPropertyBasicName(property, arrayIndexElement);
            string nativeType = DataCsExporter.GetPropertyNativeType(property, arrayIndexElement);

            if (property.IsPublic)
            {
                string className = property.ClassName.Replace("::", ".");

                if (property.IsStatic)
                {
                    return(string.Format("{0}.{1}", className, propName));
                }
                else
                {
                    return(string.Format("(({0}){1}).{2}", className, agentName, propName));
                }
            }

            return(string.Format("({0})AgentMetaVisitor.GetProperty({1}, \"{2}\")", nativeType, agentName, propName));
        }
コード例 #8
0
        public static void PostGenerateCode(object obj, StreamWriter stream, string indent, string var, object parent, string paramName)
        {
            Debug.Check(obj != null);

            Type type = obj.GetType();

            Debug.Check(Plugin.IsCustomClassType(type));

            MethodDef method = parent as MethodDef;
            IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(type);

            foreach (DesignerPropertyInfo property in properties)
            {
                if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                {
                    object member = property.GetValue(obj);
                    if (property.Attribute is DesignerStruct)
                    {
                        PostGenerateCode(member, stream, indent, var + "." + property.Property.Name, parent, paramName);
                    }
                    else
                    {
                        if (method != null)
                        {
                            MethodDef.Param param = method.GetParam(paramName, property);
                            if (param != null)
                            {
                                string nativeType = DataCppExporter.GetBasicGeneratedNativeType(param.NativeType);
                                ParameterCppExporter.PostGenerateCode(param, stream, indent, nativeType, var + "." + property.Property.Name, string.Empty, method);
                            }
                        }
                    }
                }
            }
        }
コード例 #9
0
        public override void SetParameter(MethodDef.Param param, object obj, bool bReadonly)
        {
            base.SetParameter(param, obj, bReadonly);

            _resetProperties = false;

            string      selectionName = string.Empty;
            VariableDef variable      = param.Value as VariableDef;

            if (variable != null)
            {
                _valueOwner   = variable.ValueClass;
                selectionName = (variable.Property != null) ? variable.Property.DisplayName : variable.DisplayName;
            }
            else
            {
                RightValueDef variableRV = param.Value as RightValueDef;

                if (variableRV != null)
                {
                    _valueOwner   = variableRV.ValueClassReal;
                    selectionName = variableRV.DisplayName;
                }
            }

            Nodes.Behavior behavior = GetBehavior();
            _agentType = (behavior != null) ? behavior.AgentType : null;
            if (_valueOwner != VariableDef.kSelf)
            {
                _agentType = Plugin.GetInstanceAgentType(_valueOwner, behavior, _agentType);
            }

            setComboBox(selectionName);
        }
コード例 #10
0
        public override void SetParameter(MethodDef.Param param, object obj)
        {
            base.SetParameter(param, obj);

            int typeIndex = -1;

            if (param.IsFromStruct)
            {
                string instance = string.Empty;
                string vt       = VariableDef.kConst;
                if (_param.Value is ParInfo)
                {
                    vt = VariableDef.kPar;
                }
                else if (_param.Value is VariableDef)
                {
                    VariableDef v = _param.Value as VariableDef;
                    vt = v.ValueClass;

                    instance = vt;
                    if (instance != VariableDef.kSelf)
                    {
                        instance = Plugin.GetInstanceNameFromClassName(instance);
                    }
                }

                typeIndex = getComboIndex(vt, instance, "");

                setPropertyEditor(createEditor(vt));
            }
            else
            {
                string[] tokens       = param.Value.ToString().Split(' ');
                string   propertyName = tokens[tokens.Length - 1];
                string   instance     = Plugin.GetInstanceName(propertyName);
                string   valueType    = string.Empty;
                if (!string.IsNullOrEmpty(instance))
                {
                    propertyName = propertyName.Substring(instance.Length + 1, propertyName.Length - instance.Length - 1);
                    valueType    = getValueType(instance, propertyName);
                }
                else
                {
                    valueType = getValueType(propertyName);
                }

                typeIndex = getComboIndex(valueType, instance, propertyName);

                setPropertyEditor(createEditor(valueType));
            }

            if (typeIndex > -1)
            {
                // Keep only one type for efficiency.
                this.typeComboBox.Items.Clear();
                this.typeComboBox.Items.Add(_types[typeIndex]);
                this.typeComboBox.SelectedIndex = 0;
            }
        }
コード例 #11
0
        public static void GenerateCode(object obj, StreamWriter stream, string indent, string var, object parent, string paramName)
        {
            Debug.Check(obj != null);

            Type type = obj.GetType();

            Debug.Check(Plugin.IsCustomClassType(type));

            MethodDef method = parent as MethodDef;
            IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(type);

            foreach (DesignerPropertyInfo property in properties)
            {
                if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                {
                    object member = property.GetValue(obj);

                    Type memberType = member.GetType();

                    if (Plugin.IsArrayType(memberType))
                    {
                        string memberNativeType = Plugin.GetNativeTypeName(memberType);
                        string nativeTypeStr    = DataCppExporter.GetGeneratedNativeType(memberNativeType);
                        int    startIndex       = nativeTypeStr.IndexOf('<');
                        int    endIndex         = nativeTypeStr.LastIndexOf('>');
                        string itemType         = nativeTypeStr.Substring(startIndex + 1, endIndex - startIndex - 1);

                        ArrayCppExporter.GenerateCode(member, stream, indent, itemType, paramName);
                    }
                    else
                    {
                        if (property.Attribute is DesignerStruct)
                        {
                            GenerateCode(member, stream, indent, var + "." + property.Property.Name, parent, paramName);
                        }
                        else
                        {
                            bool bStructProperty = false;
                            if (method != null)
                            {
                                MethodDef.Param param = method.GetParam(paramName, property);
                                if (param != null)
                                {
                                    bStructProperty = true;
                                    ParameterCppExporter.GenerateCode(param, stream, indent, string.Empty, var + "." + property.Property.Name, string.Empty);
                                }
                            }

                            if (!bStructProperty)
                            {
                                DataCppExporter.GenerateCode(member, stream, indent, string.Empty, var + "." + property.Property.Name, string.Empty);
                            }
                        }
                    }
                }
            }
        }
コード例 #12
0
        void createParamEditor(object owner, MethodDef method, bool enable, bool bReadonlyParent)
        {
            List <MethodDef.Param> parameters = method.Params;

            foreach (MethodDef.Param p in parameters)
            {
                Type   editorType    = typeof(DesignerParameterComboEnumEditor);
                string arugmentsName = "    " + p.DisplayName;
                bool   bReadonly     = bReadonlyParent | p.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnly);
                Label  label         = propertyGrid.AddProperty(arugmentsName, editorType, bReadonly);

                label.MouseEnter += new EventHandler(label_MouseEnter);

                DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag;

                if (p.Type.Name == "IList")
                {
                    lastListParam = p;
                }

                if (p.Type.Name == "System_Object" && lastListParam != null)
                {
                    p.ListParam = lastListParam;
                }

                editor.Enabled = enable;
                editor.SetParameter(p, owner, bReadonly);

                editor.ValueWasAssigned();
                editor.MouseEnter      += editor_MouseEnter;
                editor.ValueWasChanged += editor_ValueWasChanged;
                //editor.ValueType = p.Attribute.ValueType;

                MethodDef.Param arrayIndexElement = null;

                if (p.Value is VariableDef)
                {
                    VariableDef var = p.Value as VariableDef;
                    arrayIndexElement = var.ArrayIndexElement;
                }
                else if (p.Value is RightValueDef)
                {
                    RightValueDef varRV = p.Value as RightValueDef;

                    if (varRV.Var != null)
                    {
                        arrayIndexElement = varRV.Var.ArrayIndexElement;
                    }
                }

                if (arrayIndexElement != null)
                {
                    createArrayIndexEditor(owner, "        ", arrayIndexElement);
                }
            }
        }
コード例 #13
0
        public override void SetParameter(MethodDef.Param param, object obj, bool bReadonly)
        {
            base.SetParameter(param, obj, bReadonly);

            if (Plugin.IsCharType(param.Value.GetType()))
            {
                textBox.MaxLength = 1;
            }

            textBox.Text = trimQuotes(param.Value.ToString());
        }
コード例 #14
0
        public override void SetParameter(MethodDef.Param param, object obj, bool bReadonly)
        {
            base.SetParameter(param, obj, bReadonly);

            DesignerBoolean boolAtt = param.Attribute as DesignerBoolean;

            if (boolAtt != null)
            {
                checkBox.Checked = (bool)param.Value;
            }
        }
コード例 #15
0
        public override void SetParameter(MethodDef.Param param, object obj)
        {
            base.SetParameter(param, obj);

            if (param != null)
            {
                setProperty(param.Value, param.Name, false, obj);
            }
            else
            {
                update();
            }
        }
コード例 #16
0
        public override void SetParameter(MethodDef.Param param, object obj)
        {
            base.SetParameter(param, obj);

            // extract resrictions for float property
            DesignerFloat restFloatAtt = param.Attribute as DesignerFloat;

            if (restFloatAtt != null)
            {
                SetRange(restFloatAtt.Precision,
                         (decimal)restFloatAtt.Min,
                         (decimal)restFloatAtt.Max,
                         (decimal)restFloatAtt.Steps,
                         restFloatAtt.Units);
            }

            // extract restrictions for int property
            DesignerInteger restIntAtt = param.Attribute as DesignerInteger;

            if (restIntAtt != null)
            {
                SetRange(0,
                         (decimal)restIntAtt.Min,
                         (decimal)restIntAtt.Max,
                         (decimal)restIntAtt.Steps,
                         restIntAtt.Units);
            }

            // extract the value
            decimal value = 0;

            DesignerFloat floatAtt = param.Attribute as DesignerFloat;

            if (floatAtt != null)
            {
                float val = (param.Value != null) ? float.Parse(param.Value.ToString()) : 0.0f;
                value = (decimal)val;
                numericUpDown.DecimalPlaces = 2;
            }

            DesignerInteger intAtt = param.Attribute as DesignerInteger;

            if (intAtt != null)
            {
                int val = (param.Value != null) ? int.Parse(param.Value.ToString()) : 0;
                value = (decimal)val;
            }

            // assign value within limits
            numericUpDown.Value = Math.Max(numericUpDown.Minimum, Math.Min(numericUpDown.Maximum, value));
        }
コード例 #17
0
ファイル: DesignerStruct.cs プロジェクト: P79N6A/behaviac3.6
        public static bool IsPureConstDatum(object obj, object parent, string paramName)
        {
            Debug.Check(obj != null);

            if (obj != null)
            {
                Type type = obj.GetType();

                if (!Plugin.IsCustomClassType(type))
                {
                    return(false);
                }

                MethodDef method = parent as MethodDef;
                IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(type, null);

                foreach (DesignerPropertyInfo property in properties)
                {
                    if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                    {
                        object member = property.GetValue(obj);

                        if (property.Attribute is DesignerStruct)
                        {
                            if (!IsPureConstDatum(member, parent, paramName))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (method != null)
                            {
                                MethodDef.Param param = method.GetParam(paramName, property);

                                if (param != null)
                                {
                                    if (!param.IsPureConstDatum)
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }
コード例 #18
0
ファイル: ParInfoCsExporter.cs プロジェクト: yueding/behaviac
        public static void PostGenerateCode(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent, string typename, string var, string caller)
        {
            if (string.IsNullOrEmpty(typename))
            {
                typename = property.NativeType;
            }
            typename = DataCsExporter.GetGeneratedNativeType(typename);

            string propBasicName = property.BasicName.Replace("[]", "");
            uint   id            = Behaviac.Design.CRC32.CalcCRC(propBasicName);

            stream.WriteLine("{0}Debug.Check(behaviac.Utils.MakeVariableId(\"{1}\") == {2}u);", indent, propBasicName, id);
            stream.WriteLine("{0}pAgent.SetVariable<{1}>(\"{2}\", {3}u, ({1}){4});", indent, typename, property.Name, id, var);
        }
コード例 #19
0
        public static string GetProperty(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent, string var, string caller)
        {
            string agentName = GetGenerateAgentName(property, var, caller);

            if (property.Owner != Behaviac.Design.VariableDef.kSelf)
            {
                stream.WriteLine("{0}Agent* {1} = Agent::GetInstance(pAgent, \"{2}\");", indent, agentName, property.Owner);
                stream.WriteLine("{0}BEHAVIAC_ASSERT({1});", indent, agentName);
            }

            string prop = getProperty(property, arrayIndexElement, agentName, stream, indent);

            return(prop);
        }
コード例 #20
0
        private void comboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }

            e.DrawBackground();
            e.Graphics.DrawString(comboBox.Items[e.Index].ToString(), e.Font, System.Drawing.Brushes.LightGray, e.Bounds);
            e.DrawFocusRectangle();

            MethodDef.Param param = _params[e.Index];
            this.OnDescriptionChanged(this.DisplayName, param.Description);
        }
コード例 #21
0
        public static string GetProperty(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent, string var, string caller)
        {
            string agentName = GetGenerateAgentName(property, var, caller);

            if (property.Owner != Behaviac.Design.VariableDef.kSelf)
            {
                stream.WriteLine("{0}behaviac.Agent {1} = behaviac.Agent.GetInstance(\"{2}\", pAgent.GetContextId());", indent, agentName, property.Owner.Replace("::", "."));
                stream.WriteLine("{0}Debug.Check({1} != null);", indent, agentName);
            }

            string prop = getProperty(property, arrayIndexElement, agentName, stream, indent);

            return(prop);
        }
コード例 #22
0
        public static string GenerateCode(DefaultObject defaultObj, MethodDef.Param param, StreamWriter stream, string indent, string typename, string var, string caller)
        {
            Behaviac.Design.ParInfo par = param.Value as Behaviac.Design.ParInfo;
            if (par != null)
            {
                return(ParInfoCsExporter.GenerateCode(par, param.IsRef, stream, indent, typename, var, caller));
            }

            Behaviac.Design.VariableDef v = param.Value as Behaviac.Design.VariableDef;
            if (v != null)
            {
                return(VariableCsExporter.GenerateCode(defaultObj, v, param.IsRef, stream, indent, typename, var, caller));
            }

            return(DataCsExporter.GenerateCode(param.Value, defaultObj, stream, indent, typename, var, caller));
        }
コード例 #23
0
        void createArrayIndexEditor(object owner, string preBlank, MethodDef.Param arrayIndex)
        {
            Type   editorType    = typeof(DesignerParameterComboEnumEditor);
            string arugmentsName = preBlank + "Index";
            bool   bReadonly     = false;
            Label  label         = propertyGrid.AddProperty(arugmentsName, editorType, bReadonly);

            label.MouseEnter += new EventHandler(label_MouseEnter);

            DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag;

            editor.Enabled = true;
            editor.SetParameter(arrayIndex, owner, bReadonly);
            editor.ValueWasAssigned();
            editor.MouseEnter      += editor_MouseEnter;
            editor.ValueWasChanged += editor_ValueWasChanged;
        }
コード例 #24
0
        public override void SetParameter(MethodDef.Param param, object obj, bool bReadonly)
        {
            base.SetParameter(param, obj, bReadonly);

            if (param.IsFromStruct && (param.Type == typeof(VariableDef)))
            {
                VariableDef v = param.Value as VariableDef;
                FilterType = v.ValueType;
            }
            else
            {
                FilterType = param.Type;
            }

            string[] tokens = param.Value.ToString().Split(' ');
            setComboBox(tokens[tokens.Length - 1]);
        }
コード例 #25
0
        private bool ClearValueIfChanged(MethodDef.Param param)
        {
            bool bSet = true;

            if (param.ListParam != null)
            {
                Type itemType = MethodDef.Param.GetListParamItemType(param);

                if (param.Value is VariableDef)
                {
                    VariableDef var = param.Value as VariableDef;

                    if (var.ValueType != itemType)
                    {
                        //type changed, to clear the old one
                        bSet        = false;
                        param.Value = null;
                    }
                }
                else if (param.Value is PropertyDef)
                {
                    PropertyDef var = param.Value as PropertyDef;

                    if (var.Type != itemType)
                    {
                        //type changed, to clear the old one
                        bSet        = false;
                        param.Value = null;
                    }
                }
                else if (param.Value is ParInfo)
                {
                    ParInfo var = param.Value as ParInfo;

                    if (var.Type != itemType)
                    {
                        //type changed, to clear the old one
                        bSet        = false;
                        param.Value = null;
                    }
                }
            }

            return(bSet);
        }
コード例 #26
0
        public static void PostGenerateCode(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent, string typename, string var, string caller, string setValue = null)
        {
            if (property.IsPar || property.IsCustomized)
            {
                ParInfoCsExporter.PostGenerateCode(property, arrayIndexElement, stream, indent, typename, var, caller);
                return;
            }

            if (!property.IsReadonly)
            {
                string agentName = GetGenerateAgentName(property, var, caller);
                string prop      = setValue;

                if (property.Owner != Behaviac.Design.VariableDef.kSelf)
                {
                    stream.WriteLine("{0}behaviac.Agent {1} = behaviac.Agent.GetInstance(\"{2}\", pAgent.GetContextId());", indent, agentName, property.Owner.Replace("::", "."));
                    stream.WriteLine("{0}Debug.Check({1} != null);", indent, agentName);
                }

                string propBasicName = property.BasicName.Replace("[]", "");

                if (setValue != null)
                {
                    stream.WriteLine("{0}AgentExtra_Generated.SetProperty({1}, \"{2}\", {3});", indent, agentName, propBasicName, prop);
                }
                else
                {
                    prop = getProperty(property, arrayIndexElement, agentName, stream, indent);
                }

                uint id = Behaviac.Design.CRC32.CalcCRC(propBasicName);
                stream.WriteLine("{0}Debug.Check(behaviac.Utils.MakeVariableId(\"{1}\") == {2}u);", indent, propBasicName, id);

                if (string.IsNullOrEmpty(typename))
                {
                    typename = property.NativeType;
                }
                typename = DataCsExporter.GetGeneratedNativeType(typename);

                stream.WriteLine("{0}{1}.SetVariable<{2}>(\"{3}\", {4}, {5}u);", indent, agentName, typename, property.BasicName, prop, id);
            }
        }
コード例 #27
0
        public static string GetProperty(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent)
        {
            string retStr = string.Empty;

            if (property != null)
            {
                string typename = DataCppExporter.GetGeneratedNativeType(property.NativeType);
                if (property.IsArrayElement && !typename.StartsWith("behaviac::vector<"))
                {
                    typename = string.Format("behaviac::vector<{0} >", typename);
                }

                string propBasicName = property.BasicName.Replace("[]", "");
                uint   id            = Behaviac.Design.CRC32.CalcCRC(propBasicName);

                retStr = string.Format("({0})pAgent->GetVariable<{0} >({1}u)", typename, id);
            }

            return(retStr);
        }
コード例 #28
0
ファイル: ParInfoCsExporter.cs プロジェクト: yueding/behaviac
        public static string GetProperty(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent)
        {
            string retStr = string.Empty;

            if (property != null)
            {
                string typename = DataCsExporter.GetGeneratedNativeType(property.NativeType);
                if (property.IsArrayElement && !typename.StartsWith("List<"))
                {
                    typename = string.Format("List<{0}>", typename);
                }

                string propBasicName = property.BasicName.Replace("[]", "");
                uint   id            = Behaviac.Design.CRC32.CalcCRC(propBasicName);

                stream.WriteLine("{0}Debug.Check(behaviac.Utils.MakeVariableId(\"{1}\") == {2}u);", indent, propBasicName, id);
                retStr = string.Format("pAgent.GetVariable<{0}>({1}u)", typename, id);
            }

            return(retStr);
        }
コード例 #29
0
        public static string GenerateCode(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, bool isRefParam, StreamWriter stream, string indent, string typename, string var, string caller)
        {
            if (property.IsPar || property.IsCustomized)
            {
                return(ParInfoCppExporter.GenerateCode(property, isRefParam, stream, indent, typename, var, caller));
            }

            string prop = GetProperty(property, arrayIndexElement, stream, indent, var, caller);

            if (!string.IsNullOrEmpty(var))
            {
                if (string.IsNullOrEmpty(typename))
                {
                    stream.WriteLine("{0}{1} = {2};", indent, var, prop);
                }
                else
                {
                    stream.WriteLine("{0}{1} {2} = {3};", indent, DataCppExporter.GetGeneratedNativeType(property.NativeType), var, prop);
                }
            }

            return(prop);
        }
コード例 #30
0
        public override void SetParameter(MethodDef.Param param, object obj, bool bReadonly)
        {
            base.SetParameter(param, obj, bReadonly);

            _resetProperties = false;

            Behaviac.Design.Attachments.Attach evt      = obj as Behaviac.Design.Attachments.Attach;
            Behaviac.Design.Nodes.BaseNode     baseNode = (evt != null) ? evt.Node : obj as Behaviac.Design.Nodes.BaseNode;
            Behaviac.Design.Nodes.Behavior     behavior = (baseNode != null) ? baseNode.Behavior as Behaviac.Design.Nodes.Behavior : null;

            string      selectionName = string.Empty;
            VariableDef variable      = param.Value as VariableDef;

            if (variable != null)
            {
                _valueOwner   = variable.ValueClass;
                selectionName = (variable.Property != null) ? variable.Property.DisplayName : variable.DisplayName;
            }
            else
            {
                RightValueDef variableRV = param.Value as RightValueDef;

                if (variableRV != null)
                {
                    _valueOwner   = variableRV.ValueClassReal;
                    selectionName = variableRV.DisplayName;
                }
            }

            _agentType = (behavior != null) ? behavior.AgentType : null;
            if (_valueOwner != VariableDef.kSelf)
            {
                _agentType = Plugin.GetInstanceAgentType(_valueOwner);
            }

            setComboBox(selectionName);
        }
コード例 #31
0
 public virtual void SetParameter(MethodDef.Param param, object obj)
 {
     _param = param;
     _object = obj;
 }
コード例 #32
0
 public virtual void SetParameter(MethodDef.Param param, object obj, bool bReadonly)
 {
     _param = param;
     _object = obj;
     _bIsReadonly = bReadonly;
 }