當前位置: 首頁>>代碼示例>>C#>>正文


C# Behaviac類代碼示例

本文整理匯總了C#中Behaviac的典型用法代碼示例。如果您正苦於以下問題:C# Behaviac類的具體用法?C# Behaviac怎麽用?C# Behaviac使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Behaviac類屬於命名空間,在下文中一共展示了Behaviac類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GenerateCode

        public static string GenerateCode(Behaviac.Design.PropertyDef property, StreamWriter stream, string indent, string typename, string var, string caller)
        {
            string agentName = getGenerateAgentName(property, var, caller);
            if (property.Owner != Behaviac.Design.VariableDef.kSelf)
            {
                stream.WriteLine("{0}Agent* {1} = Agent::GetInstance(\"{2}\", pAgent->GetContextId());", indent, agentName, property.Owner);
                stream.WriteLine("{0}BEHAVIAC_ASSERT({1});", indent, agentName);
            }

            //string retStr = string.Format("(({0}*){1})->{2}", property.ClassName, agentName, property.Name);
            string propName = property.Name.Replace("::", "_");
            string nativeType = DataCppExporter.GetGeneratedNativeType(property.NativeType);
            string retStr = string.Format("(({0}*){1})->_Get_Property_<{2}PROPERTY_TYPE_{3}, {4} >()", property.ClassName, agentName, getNamespace(property.ClassName), propName, nativeType);

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

            return retStr;
        }
開發者ID:KeyleXiao,項目名稱:behaviac,代碼行數:28,代碼來源:PropertyCppExporter.cs

示例2: GenerateCode

        public static string GenerateCode(Behaviac.Design.PropertyDef property, StreamWriter stream, string indent, string typename, string var, string caller, string setValue = null)
        {
            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, agentName);

            if (setValue == null)
            {
                if (!string.IsNullOrEmpty(var))
                {
                    if (string.IsNullOrEmpty(typename))
                    {
                        stream.WriteLine("{0}{1} = {2};", indent, var, prop);
                    }
                    else
                    {
                        stream.WriteLine("{0}{1} {2} = {3};", indent, DataCsExporter.GetGeneratedNativeType(property.NativeType), var, prop);
                    }
                }
            }
            else
            {
                stream.WriteLine("{0}AgentExtra_Generated.SetProperty({1}, \"{2}\", {3});", indent, agentName, property.BasicName, setValue);
            }

            return prop;
        }
開發者ID:KeyleXiao,項目名稱:behaviac,代碼行數:33,代碼來源:PropertyCsExporter.cs

示例3: CreateNodeViewData

        public override NodeViewData CreateNodeViewData(NodeViewData parent, Behaviac.Design.Nodes.BehaviorNode rootBehavior)
        {
            NodeViewData nvd = base.CreateNodeViewData(parent, rootBehavior);
            nvd.ChangeShape(NodeShape.Rectangle);

            return nvd;
        }
開發者ID:nusus,項目名稱:behaviac,代碼行數:7,代碼來源:Noop.cs

示例4: GenerateClassConstructor

        public static void GenerateClassConstructor(Behaviac.Design.VariableDef variable, StreamWriter stream, string indent, string var)
        {
            if (variable.ValueClass == Behaviac.Design.VariableDef.kConst)
            {
                Type type = variable.Value.GetType();
                if (Plugin.IsRefType(type))
                {
                    string nativeType = DataCppExporter.GetBasicGeneratedNativeType(variable.NativeType);
                    stream.WriteLine("{0}\t\t\t{1} = NULL;", indent, var);
                }
                else if (Plugin.IsArrayType(type) || Plugin.IsCustomClassType(type) || Plugin.IsStringType(type))
                {
                    if (Plugin.IsArrayType(type))
                    {
                        string nativeType = DataCppExporter.GetGeneratedNativeType(variable.NativeType);
                        int startIndex = nativeType.IndexOf('<');
                        int endIndex = nativeType.LastIndexOf('>');
                        string itemType = nativeType.Substring(startIndex + 1, endIndex - startIndex - 1);

                        ArrayCppExporter.GenerateCode(variable.Value, stream, indent + "\t\t\t", itemType, var);
                    }
                    else if (Plugin.IsCustomClassType(type))
                    {
                        StructCppExporter.GenerateCode(variable.Value, stream, indent + "\t\t\t", var, null, "");
                    }
                    else if (Plugin.IsStringType(type))
                    {
                        string nativeType = DataCppExporter.GetBasicGeneratedNativeType(variable.NativeType);
                        string retStr = DataCppExporter.GenerateCode(variable.Value, stream, indent + "\t\t\t", nativeType, string.Empty, string.Empty);
                        stream.WriteLine("{0}\t\t\t{1} = {2};", indent, var, retStr);
                    }
                }
            }
        }
開發者ID:675492062,項目名稱:behaviac,代碼行數:34,代碼來源:VariableCppExporter.cs

示例5: PostGenerateCode

        public static void PostGenerateCode(Behaviac.Design.PropertyDef property, StreamWriter stream, string indent, string typename, string var, string caller, string setValue = null)
        {
            if (property.IsPar || property.IsCustomized)
            {
                ParInfoCppExporter.PostGenerateCode(property, stream, indent, typename, var, caller);
                return;
            }

            string agentName = GetGenerateAgentName(property, var, caller);
            string prop = setValue;
            if (setValue == null)
            {
                if (property.IsPublic)
                {
                    prop = string.Format("(({0}*){1})->{2}", property.ClassName, agentName, property.BasicName);
                }
                else
                {
                    string propName = property.Name.Replace("::", "_");
                    propName = propName.Replace("[]", "");
                    string nativeType = DataCppExporter.GetGeneratedNativeType(property.NativeType);
                    prop = string.Format("(({0}*){1})->_Get_Property_<{2}PROPERTY_TYPE_{3}, {4} >()", property.ClassName, agentName, getNamespace(property.ClassName), propName, nativeType);
                }
            }

            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);
            stream.WriteLine("{0}{1}->SetVariable(\"{2}\", {3}, {4}u);", indent, agentName, propBasicName, prop, id);
        }
開發者ID:675492062,項目名稱:behaviac,代碼行數:30,代碼來源:PropertyCppExporter.cs

示例6: GenerateCode

        public static string GenerateCode(Behaviac.Design.VariableDef variable, bool isRefParam, StreamWriter stream, string indent, string typename, string var, string caller)
        {
            string retStr = string.Empty;

            if (variable.ValueClass == Behaviac.Design.VariableDef.kConst)
            {
                bool shouldGenerate = true;
                Type type = variable.Value.GetType();
                if (Plugin.IsArrayType(type) || Plugin.IsCustomClassType(type) || Plugin.IsStringType(type))
                {
                    shouldGenerate = false;
                }

                if (shouldGenerate)
                {
                    retStr = DataCppExporter.GenerateCode(variable.Value, stream, indent, typename, var, caller);
                }
            }
            else if (variable.Property != null)
            {
                retStr = PropertyCppExporter.GenerateCode(variable.Property, variable.ArrayIndexElement, isRefParam, stream, indent, typename, var, caller);
            }

            return retStr;
        }
開發者ID:675492062,項目名稱:behaviac,代碼行數:25,代碼來源:VariableCppExporter.cs

示例7: GenerateClassMember

        public static void GenerateClassMember(Behaviac.Design.VariableDef variable, StreamWriter stream, string indent, string var)
        {
            if (variable.ValueClass == Behaviac.Design.VariableDef.kConst)
            {
                Type type = variable.Value.GetType();
                if (Plugin.IsArrayType(type) || Plugin.IsCustomClassType(type) || Plugin.IsStringType(type))
                {
                    string nativeType = DataCsExporter.GetGeneratedNativeType(variable.NativeType);

                    bool setNull = Plugin.IsArrayType(type);
                    if (!setNull && Plugin.IsCustomClassType(type))
                    {
                        Attribute[] attributes = (Attribute[])type.GetCustomAttributes(typeof(Behaviac.Design.ClassDescAttribute), false);
                        if (attributes.Length > 0)
                        {
                            Behaviac.Design.ClassDescAttribute classDesc = (Behaviac.Design.ClassDescAttribute)attributes[0];
                            if (!classDesc.IsStruct)
                                setNull = true;
                        }
                    }

                    if (setNull)
                    {
                        var += " = null";
                    }

                    stream.WriteLine("{0}\t\t{1} {2};", indent, nativeType, var);
                }
            }
        }
開發者ID:nusus,項目名稱:behaviac,代碼行數:30,代碼來源:VariableCsExporter.cs

示例8: GenerateCode

        public static string GenerateCode(Behaviac.Design.ParInfo par, StreamWriter stream, string indent, string typename, string var, string caller)
        {
            bool shouldDefineType = true;
            if (string.IsNullOrEmpty(typename))
            {
                shouldDefineType = false;
                typename = par.NativeType;
            }

            typename = DataCsExporter.GetGeneratedNativeType(typename);

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

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

            if (!string.IsNullOrEmpty(var))
            {
                if (shouldDefineType)
                    stream.WriteLine("{0}{1} {2} = {3};", indent, typename, var, retStr);
                else
                    stream.WriteLine("{0}{1} = {2};", indent, var, retStr);
            }

            return retStr;
        }
開發者ID:KeyleXiao,項目名稱:behaviac,代碼行數:26,代碼來源:ParInfoCsExporter.cs

示例9: PostGenerateCode

        public static void PostGenerateCode(Behaviac.Design.PropertyDef property, StreamWriter stream, string indent, string typename, string var, string caller, string setValue = null)
        {
            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);
            }

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

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

            stream.WriteLine("{0}{1}.SetVariable(\"{2}\", {3}, {4}u);", indent, agentName, property.BasicName, prop, id);
        }
開發者ID:KeyleXiao,項目名稱:behaviac,代碼行數:25,代碼來源:PropertyCsExporter.cs

示例10: GenerateCode

        public static string GenerateCode(Behaviac.Design.ParInfo par, StreamWriter stream, string indent, string typename, string var, string caller)
        {
            bool shouldDefineType = true;
            if (string.IsNullOrEmpty(typename))
            {
                shouldDefineType = false;
                typename = DataCppExporter.GetGeneratedNativeType(par.NativeType);
            }

            uint id = Behaviac.Design.CRC32.CalcCRC(par.Name);
            stream.WriteLine("{0}BEHAVIAC_ASSERT(behaviac::MakeVariableId(\"{1}\") == {2}u);", indent, par.Name, id);

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

            if (!string.IsNullOrEmpty(var))
            {
                if (shouldDefineType)
                    stream.WriteLine("{0}{1}& {2} = ({1}&){3};", indent, typename, var, retStr);
                else
                    stream.WriteLine("{0}{1} = {2};", indent, var, retStr);
            }

            return retStr;
        }
開發者ID:nusus,項目名稱:behaviac,代碼行數:25,代碼來源:ParInfoCppExporter.cs

示例11: GenerateCode

        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 (!property.IsReadonly)
            {
                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}AgentExtra_Generated.SetProperty({1}, \"{2}\", {3});", indent, agentName, propBasicName, setValue);
                }
            }

            return prop;
        }
開發者ID:pjkui,項目名稱:behaviac,代碼行數:35,代碼來源:PropertyCsExporter.cs

示例12: CreateNodeViewData

        public override NodeViewData CreateNodeViewData(NodeViewData parent, Behaviac.Design.Nodes.BehaviorNode rootBehavior)
        {
            NodeViewDataStyled nvd = new NodeViewDataStyled(parent, rootBehavior, this, null, __defaultBackgroundBrush, _label, _description);

            nvd.ChangeShape(NodeShape.Rectangle);

            return nvd;
        }
開發者ID:675492062,項目名稱:behaviac,代碼行數:8,代碼來源:Nop.cs

示例13: CloneProperties

        protected override void CloneProperties(Behaviac.Design.Attachments.Attachment newattach)
        {
            base.CloneProperties(newattach);

            Effector prec = (Effector)newattach;

            prec._phase = _phase;
        }
開發者ID:XyzalZhang,項目名稱:behaviac,代碼行數:8,代碼來源:Effector.cs

示例14: CloneProperties

        protected override void CloneProperties(Behaviac.Design.Attachments.Attachment newattach)
        {
            base.CloneProperties(newattach);

            StartCondition con = (StartCondition)newattach;

            con.TargetFSMNodeId = this.TargetFSMNodeId;
        }
開發者ID:XyzalZhang,項目名稱:behaviac,代碼行數:8,代碼來源:StartCondition.cs

示例15: CloneProperties

        protected override void CloneProperties(Behaviac.Design.Attachments.Attachment newattach)
        {
            base.CloneProperties(newattach);

            Precondition prec = (Precondition)newattach;

            prec._binary = _binary;
            prec._phase = _phase;
        }
開發者ID:Just4F,項目名稱:behaviac,代碼行數:9,代碼來源:Precondition.cs


注:本文中的Behaviac類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。