コード例 #1
0
        //return true if there is a task method loaded
        private static void load_methods(BsonDeserizer d, string agentType, BsonDeserizer.BsonTypes type)
        {
            Agent.CTagObjectDescriptor objectDesc = Agent.GetDescriptorByName(agentType);
            d.OpenDocument();
            type = d.ReadType();

            while (type == BsonDeserizer.BsonTypes.BT_MethodElement)
            {
                d.OpenDocument();

                string methodName = d.ReadString();
                //string returnTypeStr = d.ReadString();
                //returnTypeStr = returnTypeStr.Replace("::", ".");
                //string isStatic = d.ReadString();
                //string eventStr = d.ReadString();
                //bool bEvent = (eventStr == "true");
                string agentStr = d.ReadString();
                Debug.Check(!string.IsNullOrEmpty(agentStr));

                CCustomMethod customeMethod = new CTaskMethod(agentType, methodName);

                type = d.ReadType();

                while (type == BsonDeserizer.BsonTypes.BT_ParameterElement)
                {
                    d.OpenDocument();
                    string paramName = d.ReadString();
                    Debug.Check(!string.IsNullOrEmpty(paramName));
                    string paramType = d.ReadString();

                    customeMethod.AddParamType(paramType);

                    d.CloseDocument(true);
                    type = d.ReadType();
                }

                objectDesc.ms_methods.Add(customeMethod);

                d.CloseDocument(false);
                type = d.ReadType();
            }

            d.CloseDocument(false);
        }
コード例 #2
0
ファイル: Task.cs プロジェクト: wuzhen/behaviac
        protected override void load(int version, string agentType, List<property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Prototype")
                {
                    if (!string.IsNullOrEmpty(p.value))
                    {
                        CMethodBase m = Action.LoadMethod(p.value);
                        this.m_task = m as CTaskMethod;
                    }//if (p.value[0] != '\0')
                }
                else if (p.name == "IsHTN")
                {
                    if (p.value == "true")
                    {
                        this.m_bHTN = true;
                    }
                }
            }
        }
コード例 #3
0
        private static bool load_xml(byte[] pBuffer)
        {
            try
            {
                Debug.Check(pBuffer != null);
                string xml = System.Text.Encoding.UTF8.GetString(pBuffer);

                SecurityParser xmlDoc = new SecurityParser();
                xmlDoc.LoadXml(xml);

                SecurityElement rootNode = xmlDoc.ToXml();

                if (rootNode.Children == null || rootNode.Tag != "agents" && rootNode.Children.Count != 1)
                {
                    return false;
                }

                string versionStr = rootNode.Attribute("version");
                Debug.Check(!string.IsNullOrEmpty(versionStr));

                foreach(SecurityElement bbNode in rootNode.Children)
                {
                    if (bbNode.Tag == "agent" && bbNode.Children != null)
                    {
                        string agentType = bbNode.Attribute("type").Replace("::", ".");

                        AgentProperties bb = new AgentProperties(agentType);
                        agent_type_blackboards[agentType] = bb;

                        foreach(SecurityElement propertiesNode in bbNode.Children)
                        {
                            if (propertiesNode.Tag == "properties" && propertiesNode.Children != null)
                            {
                                foreach(SecurityElement propertyNode in propertiesNode.Children)
                                {
                                    if (propertyNode.Tag == "property")
                                    {
                                        string name = propertyNode.Attribute("name");
                                        string type = propertyNode.Attribute("type").Replace("::", ".");
                                        string memberStr = propertyNode.Attribute("member");
                                        bool bIsMember = false;

                                        if (!string.IsNullOrEmpty(memberStr) && memberStr == "true")
                                        {
                                            bIsMember = true;
                                        }

                                        string isStatic = propertyNode.Attribute("static");
                                        bool bIsStatic = false;

                                        if (!string.IsNullOrEmpty(isStatic) && isStatic == "true")
                                        {
                                            bIsStatic = true;
                                        }

                                        //string agentTypeMember = agentType;
                                        string agentTypeMember = null;
                                        string valueStr = null;

                                        if (!bIsMember)
                                        {
                                            valueStr = propertyNode.Attribute("defaultvalue");
                                        }
                                        else
                                        {
                                            agentTypeMember = propertyNode.Attribute("agent").Replace("::", ".");
                                        }

                                        bb.AddProperty(type, bIsStatic, name, valueStr, agentTypeMember);
                                    }
                                }
                            }
                            else if (propertiesNode.Tag == "methods" && propertiesNode.Children != null)
                            {
                                Agent.CTagObjectDescriptor objectDesc = Agent.GetDescriptorByName(agentType);
                                foreach(SecurityElement methodNode in propertiesNode.Children)
                                {
                                    if (methodNode.Tag == "method")
                                    {
                                        //string eventStr = methodNode.Attribute("isevent");
                                        //bool bEvent = (eventStr == "true");
                                        //string taskStr = methodNode.Attribute("istask");
                                        //bool bTask = (taskStr == "true");
                                        //skip those other custom method
                                        string methodName = methodNode.Attribute("name");
                                        //string type = methodNode.Attribute("returntype").Replace("::", ".");
                                        //string isStatic = methodNode.Attribute("static");
                                        //string agentTypeStr = methodNode.Attribute("agent").Replace("::", ".");
                                        CCustomMethod customeMethod = new CTaskMethod(agentType, methodName);

                                        if (methodNode.Children != null)
                                        {
                                            foreach(SecurityElement paramNode in methodNode.Children)
                                            {
                                                if (paramNode.Tag == "parameter")
                                                {
                                                    string paramName = paramNode.Attribute("name");
                                                    Debug.Check(!string.IsNullOrEmpty(paramName));

                                                    string paramType = paramNode.Attribute("type");

                                                    //string paramFullName = string.Format("{0}::{1}", paramType, paramName);

                                                    customeMethod.AddParamType(paramType);
                                                }
                                            }
                                        }

                                        objectDesc.ms_methods.Add(customeMethod);
                                    }
                                }//end of for methodNode
                            }//end of methods
                        }//end of for propertiesNode
                    }
                }//end of for bbNode

                return true;
            }
            catch (Exception e)
            {
                Debug.Check(false, e.Message);
            }

            Debug.Check(false);
            return false;
        }
コード例 #4
0
ファイル: Referencebehavior.cs プロジェクト: wuzhen/behaviac
        protected override void load(int version, string agentType, List<property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "ReferenceFilename")
                {
                    this.m_referencedBehaviorPath = p.value;

                    BehaviorTree behaviorTree = Workspace.Instance.LoadBehaviorTree(this.m_referencedBehaviorPath);
                    Debug.Check(behaviorTree != null);

                    if (behaviorTree != null)
                    {
                        this.m_bHasEvents |= behaviorTree.HasEvents();
                    }
                }
                else if (p.name == "Task")
                {
                    Debug.Check(!string.IsNullOrEmpty(p.value));
                    CMethodBase m = Action.LoadMethod(p.value);
                    Debug.Check(m is CTaskMethod);

                    this.m_taskMethod = m as CTaskMethod;
                }
                else
                {
                    //Debug.Check(0, "unrecognised property %s", p.name);
                }
            }
        }
コード例 #5
0
ファイル: AgentProperties.cs プロジェクト: ag6ag/behaviac
		static partial void load_cs()
		{
			// ---------------------------------------------------------------------
			// properties
			// ---------------------------------------------------------------------

			AgentProperties bb;

			// AgentNodeTest
			bb = new AgentProperties("AgentNodeTest");
			agent_type_blackboards["AgentNodeTest"] = bb;
			bb.AddProperty("EnumTest", false, "testColor", "EnumTest_One", "AgentNodeTest");
			bb.AddProperty("int", false, "testVar_0", "0", "AgentNodeTest");
			bb.AddProperty("int", false, "testVar_1", "0", "AgentNodeTest");
			bb.AddProperty("float", false, "testVar_2", "0", "AgentNodeTest");
			bb.AddProperty("float", false, "testVar_3", "0", "AgentNodeTest");
			bb.AddProperty("string", false, "testVar_str_0", "", "AgentNodeTest");
			bb.AddProperty("string", false, "testVar_str_1", "", "AgentNodeTest");
			bb.AddProperty("int", false, "waiting_timeout_interval", "0", "AgentNodeTest");
			bb.AddProperty("TestNS::Float2", false, "testFloat2", "{x=0;y=0;}", "AgentNodeTest");
			bb.AddProperty("int", false, "testInt", "10", "AgentNodeTest");
			bb.AddProperty("vector<int>", false, "test_int_array", "3:1|2|3", "AgentNodeTest");
			bb.AddProperty("ChildNodeTest", false, "par_child_agent_1", "null", "AgentNodeTest");
			bb.AddProperty("TestNS::Float2", false, "c_ReturnFloat2", "{x=0;y=0;}", "AgentNodeTest");
			bb.AddProperty("TestNS::Float2", false, "c_ReturnFloat2Const", "{x=0;y=0;}", "AgentNodeTest");

			// ChildNodeTest
			bb = new AgentProperties("ChildNodeTest");
			agent_type_blackboards["ChildNodeTest"] = bb;
			bb.AddProperty("TestNS::Float2", false, "testFloat2", "{x=0;y=0;}", "ChildNodeTest");
			bb.AddProperty("int", false, "testInt", "10", "ChildNodeTest");
			bb.AddProperty("vector<int>", false, "test_int_array", "3:1|2|3", "ChildNodeTest");
			bb.AddProperty("ChildNodeTest", false, "par_child_agent_1", "null", "ChildNodeTest");
			bb.AddProperty("TestNS::Float2", false, "c_ReturnFloat2", "{x=0;y=0;}", "ChildNodeTest");
			bb.AddProperty("TestNS::Float2", false, "c_ReturnFloat2Const", "{x=0;y=0;}", "ChildNodeTest");
			bb.AddProperty("EnumTest", false, "testColor", "EnumTest_One", "ChildNodeTest");
			bb.AddProperty("int", false, "testVar_0", "0", "ChildNodeTest");
			bb.AddProperty("int", false, "testVar_1", "0", "ChildNodeTest");
			bb.AddProperty("float", false, "testVar_2", "0", "ChildNodeTest");
			bb.AddProperty("float", false, "testVar_3", "0", "ChildNodeTest");
			bb.AddProperty("string", false, "testVar_str_0", "", "ChildNodeTest");
			bb.AddProperty("string", false, "testVar_str_1", "", "ChildNodeTest");
			bb.AddProperty("int", false, "waiting_timeout_interval", "0", "ChildNodeTest");

			// CustomPropertyAgent
			bb = new AgentProperties("CustomPropertyAgent");
			agent_type_blackboards["CustomPropertyAgent"] = bb;
			bb.AddProperty("bool", false, "BoolMemberReadonly", "false", "CustomPropertyAgent");
			bb.AddProperty("float", false, "FloatPropertyReadonly", "0", "CustomPropertyAgent");
			bb.AddProperty("int", true, "IntMemberConst", "0", "CustomPropertyAgent");
			bb.AddProperty("int", false, "IntProperty", "0", "CustomPropertyAgent");
			bb.AddProperty("UnityEngine::Vector3", false, "Location", "{x=0;y=0;z=0;}", "CustomPropertyAgent");
			bb.AddProperty("string", false, "StringMemberReadonly", "", "CustomPropertyAgent");
			bb.AddProperty("bool", false, "c_Bool", "false", "CustomPropertyAgent");
			bb.AddProperty("vector<int>", false, "c_IntArray", "0:", "CustomPropertyAgent");
			bb.AddProperty("string", true, "c_StaticString", "", "CustomPropertyAgent");
			bb.AddProperty("TNS::NE::NAT::eColor", false, "c_Enum", "RED", "CustomPropertyAgent");
			bb.AddProperty("UnityEngine::Vector3", false, "c_Location", "{x=0;y=0;z=0;}", "CustomPropertyAgent");

			// ParTestAgentBase
			bb = new AgentProperties("ParTestAgentBase");
			agent_type_blackboards["ParTestAgentBase"] = bb;
			bb.AddProperty("bool", true, "STV_BOOL_0", "false", "ParTestAgentBase");
			bb.AddProperty("char", true, "STV_CHAR_0", "", "ParTestAgentBase");
			bb.AddProperty("TNS::NE::NAT::eColor", true, "STV_ECOLOR_0", "RED", "ParTestAgentBase");
			bb.AddProperty("vector<bool>", true, "STV_LIST_BOOL_0", "0:", "ParTestAgentBase");
			bb.AddProperty("vector<char>", true, "STV_LIST_CHAR_0", "0:", "ParTestAgentBase");
			bb.AddProperty("vector<TNS::NE::NAT::eColor>", true, "STV_LIST_ECOLOR_0", "0:", "ParTestAgentBase");
			bb.AddProperty("vector<sbyte>", true, "STV_LIST_SBYTE_0", "0:", "ParTestAgentBase");
			bb.AddProperty("bool", false, "TV_BOOL_0", "false", "ParTestAgentBase");
			bb.AddProperty("byte", false, "TV_BYTE_0", "0", "ParTestAgentBase");
			bb.AddProperty("char", false, "TV_CHAR_0", "", "ParTestAgentBase");
			bb.AddProperty("TNS::NE::NAT::eColor", false, "TV_ECOLOR_0", "RED", "ParTestAgentBase");
			bb.AddProperty("vector<bool>", false, "TV_LIST_BOOL_0", "0:", "ParTestAgentBase");
			bb.AddProperty("vector<byte>", false, "TV_LIST_BYTE_0", "0:", "ParTestAgentBase");
			bb.AddProperty("vector<char>", false, "TV_LIST_CHAR_0", "0:", "ParTestAgentBase");
			bb.AddProperty("vector<TNS::NE::NAT::eColor>", false, "TV_LIST_ECOLOR_0", "0:", "ParTestAgentBase");
			bb.AddProperty("vector<sbyte>", false, "TV_LIST_SBYTE_0", "0:", "ParTestAgentBase");
			bb.AddProperty("sbyte", false, "TV_SBYTE_0", "0", "ParTestAgentBase");

			// ParTestAgent
			bb = new AgentProperties("ParTestAgent");
			agent_type_blackboards["ParTestAgent"] = bb;
			bb.AddProperty("int", true, "STV_INT_0", "0", "ParTestAgent");
			bb.AddProperty("TNS::ST::PER::WRK::kEmployee", true, "STV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "ParTestAgent");
			bb.AddProperty("vector<int>", true, "STV_LIST_INT_0", "0:", "ParTestAgent");
			bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", true, "STV_LIST_KEMPLOYEE_0", "0:", "ParTestAgent");
			bb.AddProperty("int", false, "TV_INT_0", "0", "ParTestAgent");
			bb.AddProperty("TNS::ST::PER::WRK::kEmployee", false, "TV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "ParTestAgent");
			bb.AddProperty("vector<int>", false, "TV_LIST_INT_0", "0:", "ParTestAgent");
			bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", false, "TV_LIST_KEMPLOYEE_0", "0:", "ParTestAgent");
			bb.AddProperty("long", false, "TV_LONG_0", "0", "ParTestAgent");
			bb.AddProperty("short", false, "TV_SHORT_0", "0", "ParTestAgent");
			bb.AddProperty("ushort", false, "TV_USHORT_0", "0", "ParTestAgent");
			bb.AddProperty("bool", true, "STV_BOOL_0", "false", "ParTestAgent");
			bb.AddProperty("char", true, "STV_CHAR_0", "", "ParTestAgent");
			bb.AddProperty("TNS::NE::NAT::eColor", true, "STV_ECOLOR_0", "RED", "ParTestAgent");
			bb.AddProperty("vector<bool>", true, "STV_LIST_BOOL_0", "0:", "ParTestAgent");
			bb.AddProperty("vector<char>", true, "STV_LIST_CHAR_0", "0:", "ParTestAgent");
			bb.AddProperty("vector<TNS::NE::NAT::eColor>", true, "STV_LIST_ECOLOR_0", "0:", "ParTestAgent");
			bb.AddProperty("vector<sbyte>", true, "STV_LIST_SBYTE_0", "0:", "ParTestAgent");
			bb.AddProperty("bool", false, "TV_BOOL_0", "false", "ParTestAgent");
			bb.AddProperty("byte", false, "TV_BYTE_0", "0", "ParTestAgent");
			bb.AddProperty("char", false, "TV_CHAR_0", "", "ParTestAgent");
			bb.AddProperty("TNS::NE::NAT::eColor", false, "TV_ECOLOR_0", "RED", "ParTestAgent");
			bb.AddProperty("vector<bool>", false, "TV_LIST_BOOL_0", "0:", "ParTestAgent");
			bb.AddProperty("vector<byte>", false, "TV_LIST_BYTE_0", "0:", "ParTestAgent");
			bb.AddProperty("vector<char>", false, "TV_LIST_CHAR_0", "0:", "ParTestAgent");
			bb.AddProperty("vector<TNS::NE::NAT::eColor>", false, "TV_LIST_ECOLOR_0", "0:", "ParTestAgent");
			bb.AddProperty("vector<sbyte>", false, "TV_LIST_SBYTE_0", "0:", "ParTestAgent");
			bb.AddProperty("sbyte", false, "TV_SBYTE_0", "0", "ParTestAgent");

			// EmployeeParTestAgent
			bb = new AgentProperties("EmployeeParTestAgent");
			agent_type_blackboards["EmployeeParTestAgent"] = bb;
			bb.AddProperty("behaviac::Agent*", true, "STV_AGENT_0", "null", "EmployeeParTestAgent");
			bb.AddProperty("float", true, "STV_F_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("vector<behaviac::Agent*>", true, "STV_LIST_AGENT_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<float>", true, "STV_LIST_F_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<string>", true, "STV_LIST_STR_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("string", true, "STV_STR_0", "", "EmployeeParTestAgent");
			bb.AddProperty("behaviac::Agent*", false, "TV_AGENT_0", "null", "EmployeeParTestAgent");
			bb.AddProperty("string", false, "TV_CSZSTR_0", "", "EmployeeParTestAgent");
			bb.AddProperty("double", false, "TV_D_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("float", false, "TV_F_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("vector<behaviac::Agent*>", false, "TV_LIST_AGENT_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<float>", false, "TV_LIST_F_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<string>", false, "TV_LIST_STR_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("long", false, "TV_LL_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("string", false, "TV_STR_0", "", "EmployeeParTestAgent");
			bb.AddProperty("uint", false, "TV_UINT_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("ulong", false, "TV_ULL_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("ulong", false, "TV_ULONG_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("int", true, "STV_INT_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("TNS::ST::PER::WRK::kEmployee", true, "STV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "EmployeeParTestAgent");
			bb.AddProperty("vector<int>", true, "STV_LIST_INT_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", true, "STV_LIST_KEMPLOYEE_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("int", false, "TV_INT_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("TNS::ST::PER::WRK::kEmployee", false, "TV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "EmployeeParTestAgent");
			bb.AddProperty("vector<int>", false, "TV_LIST_INT_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", false, "TV_LIST_KEMPLOYEE_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("long", false, "TV_LONG_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("short", false, "TV_SHORT_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("ushort", false, "TV_USHORT_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("bool", true, "STV_BOOL_0", "false", "EmployeeParTestAgent");
			bb.AddProperty("char", true, "STV_CHAR_0", "", "EmployeeParTestAgent");
			bb.AddProperty("TNS::NE::NAT::eColor", true, "STV_ECOLOR_0", "RED", "EmployeeParTestAgent");
			bb.AddProperty("vector<bool>", true, "STV_LIST_BOOL_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<char>", true, "STV_LIST_CHAR_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<TNS::NE::NAT::eColor>", true, "STV_LIST_ECOLOR_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<sbyte>", true, "STV_LIST_SBYTE_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("bool", false, "TV_BOOL_0", "false", "EmployeeParTestAgent");
			bb.AddProperty("byte", false, "TV_BYTE_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("char", false, "TV_CHAR_0", "", "EmployeeParTestAgent");
			bb.AddProperty("TNS::NE::NAT::eColor", false, "TV_ECOLOR_0", "RED", "EmployeeParTestAgent");
			bb.AddProperty("vector<bool>", false, "TV_LIST_BOOL_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<byte>", false, "TV_LIST_BYTE_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<char>", false, "TV_LIST_CHAR_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<TNS::NE::NAT::eColor>", false, "TV_LIST_ECOLOR_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("vector<sbyte>", false, "TV_LIST_SBYTE_0", "0:", "EmployeeParTestAgent");
			bb.AddProperty("sbyte", false, "TV_SBYTE_0", "0", "EmployeeParTestAgent");
			bb.AddProperty("ParTestAgent", false, "target", "null", "EmployeeParTestAgent");

			// FSMAgentTest
			bb = new AgentProperties("FSMAgentTest");
			agent_type_blackboards["FSMAgentTest"] = bb;
			bb.AddProperty("FSMAgentTest::EMessage", false, "Message", "Invalid", "FSMAgentTest");
			bb.AddProperty("int", false, "InactiveCount", "0", "FSMAgentTest");
			bb.AddProperty("uint", false, "ActiveCount", "0", "FSMAgentTest");
			bb.AddProperty("short", false, "PauseCount", "0", "FSMAgentTest");
			bb.AddProperty("long", false, "ExitCount", "0", "FSMAgentTest");
			bb.AddProperty("int", false, "FoodCount", "0", "FSMAgentTest");
			bb.AddProperty("int", false, "EnergyCount", "0", "FSMAgentTest");

			// HTNAgentHouseBase
			bb = new AgentProperties("HTNAgentHouseBase");
			agent_type_blackboards["HTNAgentHouseBase"] = bb;
			bb.AddProperty("int", false, "Money", "0", "HTNAgentHouseBase");

			// HTNAgentHouse
			bb = new AgentProperties("HTNAgentHouse");
			agent_type_blackboards["HTNAgentHouse"] = bb;
			bb.AddProperty("int", false, "Money", "0", "HTNAgentHouse");
			bb.AddProperty("bool", false, "Land", "false", "HTNAgentHouse");
			bb.AddProperty("bool", false, "GoodCredit", "true", "HTNAgentHouse");
			bb.AddProperty("bool", false, "Contract", "false", "HTNAgentHouse");
			bb.AddProperty("bool", false, "Permit", "false", "HTNAgentHouse");
			bb.AddProperty("bool", false, "HouseBuilt", "false", "HTNAgentHouse");
			bb.AddProperty("bool", false, "Mortgage", "false", "HTNAgentHouse");
			bb.AddProperty("bool", false, "House", "false", "HTNAgentHouse");

			// ParTestRegNameAgent
			bb = new AgentProperties("ParTestRegNameAgent");
			agent_type_blackboards["ParTestRegNameAgent"] = bb;
			bb.AddProperty("TNS::ST::PER::WRK::kEmployee", true, "STV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "ParTestRegNameAgent");
			bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", true, "STV_LIST_KEMPLOYEE_0", "0:", "ParTestRegNameAgent");
			bb.AddProperty("vector<sbyte>", true, "STV_LIST_SBYTE_0", "0:", "ParTestRegNameAgent");
			bb.AddProperty("behaviac::Agent*", false, "TV_AGENT_0", "null", "ParTestRegNameAgent");
			bb.AddProperty("byte", false, "TV_BYTE_0", "0", "ParTestRegNameAgent");
			bb.AddProperty("char", false, "TV_CHAR_0", "", "ParTestRegNameAgent");
			bb.AddProperty("TNS::ST::PER::WRK::kEmployee", false, "TV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "ParTestRegNameAgent");
			bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", false, "TV_LIST_KEMPLOYEE_0", "0:", "ParTestRegNameAgent");
			bb.AddProperty("sbyte", false, "TV_SBYTE_0", "0", "ParTestRegNameAgent");
			bb.AddProperty("string", false, "TV_STR_0", "", "ParTestRegNameAgent");

			// PreconEffectorAgent
			bb = new AgentProperties("PreconEffectorAgent");
			agent_type_blackboards["PreconEffectorAgent"] = bb;
			bb.AddProperty("int", false, "count_both", "0", "PreconEffectorAgent");
			bb.AddProperty("int", false, "count_failure", "0", "PreconEffectorAgent");
			bb.AddProperty("int", false, "count_success", "0", "PreconEffectorAgent");
			bb.AddProperty("int", false, "ret", "0", "PreconEffectorAgent");

			// PropertyReadonlyAgent
			bb = new AgentProperties("PropertyReadonlyAgent");
			agent_type_blackboards["PropertyReadonlyAgent"] = bb;
			bb.AddProperty("int", false, "MemberReadonly", "0", "PropertyReadonlyAgent");
			bb.AddProperty("int", false, "MemberReadonlyAs", "0", "PropertyReadonlyAgent");
			bb.AddProperty("int", false, "PropertyGetterOnly", "0", "PropertyReadonlyAgent");
			bb.AddProperty("int", false, "PropertyGetterSetter", "0", "PropertyReadonlyAgent");
			bb.AddProperty("int", false, "c_IntReadonly", "10", "PropertyReadonlyAgent");
			bb.AddProperty("int", false, "c_Int", "1", "PropertyReadonlyAgent");
			bb.AddProperty("int", true, "c_ResultStatic", "0", "PropertyReadonlyAgent");

			// StaticAgent
			bb = new AgentProperties("StaticAgent");
			agent_type_blackboards["StaticAgent"] = bb;
			bb.AddProperty("int", true, "sInt", "0", "StaticAgent");

			// TestNS.AgentArrayAccessTest
			bb = new AgentProperties("TestNS.AgentArrayAccessTest");
			agent_type_blackboards["TestNS.AgentArrayAccessTest"] = bb;
			bb.AddProperty("int", false, "Int", "0", "TestNS.AgentArrayAccessTest");
			bb.AddProperty("vector<int>", false, "ListInts", "0:", "TestNS.AgentArrayAccessTest");
			bb.AddProperty("int", false, "c_Int", "0", "TestNS.AgentArrayAccessTest");
			bb.AddProperty("vector<int>", false, "c_ListInts", "5:10|20|30|40|50", "TestNS.AgentArrayAccessTest");
			bb.AddProperty("int", false, "c_Count", "0", "TestNS.AgentArrayAccessTest");

			// ---------------------------------------------------------------------
			// tasks
			// ---------------------------------------------------------------------

			Agent.CTagObjectDescriptor objectDesc;
			CCustomMethod customeMethod;

			// AgentNodeTest
			objectDesc = Agent.GetDescriptorByName("AgentNodeTest");
			customeMethod = new CTaskMethod("AgentNodeTest", "root");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("AgentNodeTest", "event_test_int");
			customeMethod.AddParamType("int");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("AgentNodeTest", "event_test_int_bool");
			customeMethod.AddParamType("int");
			customeMethod.AddParamType("bool");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("AgentNodeTest", "event_test_int_bool_float");
			customeMethod.AddParamType("int");
			customeMethod.AddParamType("bool");
			customeMethod.AddParamType("float");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("AgentNodeTest", "event_test_void");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("AgentNodeTest", "task_test");
			customeMethod.AddParamType("int");
			customeMethod.AddParamType("float");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("AgentNodeTest", "event_test_agent");
			customeMethod.AddParamType("AgentNodeTest");
			objectDesc.ms_methods.Add(customeMethod);

			// ChildNodeTest
			objectDesc = Agent.GetDescriptorByName("ChildNodeTest");
			customeMethod = new CTaskMethod("ChildNodeTest", "root");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("ChildNodeTest", "event_test_int");
			customeMethod.AddParamType("int");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("ChildNodeTest", "event_test_int_bool");
			customeMethod.AddParamType("int");
			customeMethod.AddParamType("bool");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("ChildNodeTest", "event_test_int_bool_float");
			customeMethod.AddParamType("int");
			customeMethod.AddParamType("bool");
			customeMethod.AddParamType("float");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("ChildNodeTest", "event_test_void");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("ChildNodeTest", "task_test");
			customeMethod.AddParamType("int");
			customeMethod.AddParamType("float");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("ChildNodeTest", "event_test_agent");
			customeMethod.AddParamType("AgentNodeTest");
			objectDesc.ms_methods.Add(customeMethod);

			// HTNAgentHouse
			objectDesc = Agent.GetDescriptorByName("HTNAgentHouse");
			customeMethod = new CTaskMethod("HTNAgentHouse", "root");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("HTNAgentHouse", "root");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("HTNAgentHouse", "build_house");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("HTNAgentHouse", "construct");
			objectDesc.ms_methods.Add(customeMethod);

			// HTNAgentTravel
			objectDesc = Agent.GetDescriptorByName("HTNAgentTravel");
			customeMethod = new CTaskMethod("HTNAgentTravel", "root");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("HTNAgentTravel", "root");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("HTNAgentTravel", "travel");
			customeMethod.AddParamType("int");
			customeMethod.AddParamType("int");
			objectDesc.ms_methods.Add(customeMethod);

			customeMethod = new CTaskMethod("HTNAgentTravel", "travel_by_air");
			customeMethod.AddParamType("int");
			customeMethod.AddParamType("int");
			objectDesc.ms_methods.Add(customeMethod);
		}
コード例 #6
0
ファイル: AgentProperties.cs プロジェクト: chkob/behaviac-old
        static partial void load_cs()
        {
            // ---------------------------------------------------------------------
            // properties
            // ---------------------------------------------------------------------

            AgentProperties bb;

            // AgentArrayAccessTest
            bb = new AgentProperties("AgentArrayAccessTest");
            agent_type_blackboards["AgentArrayAccessTest"] = bb;
            bb.AddProperty("int", false, "Int", "0", "AgentArrayAccessTest");
            bb.AddProperty("vector<int>", false, "ListInts", "0:", "AgentArrayAccessTest");
            bb.AddProperty("int", false, "c_Int", "0", "AgentArrayAccessTest");
            bb.AddProperty("vector<int>", false, "c_ListInts", "5:10|20|30|40|50", "AgentArrayAccessTest");
            bb.AddProperty("int", false, "c_Count", "0", "AgentArrayAccessTest");

            // AgentNodeTest
            bb = new AgentProperties("AgentNodeTest");
            agent_type_blackboards["AgentNodeTest"] = bb;
            bb.AddProperty("int", false, "testVar_0", "0", "AgentNodeTest");
            bb.AddProperty("int", false, "testVar_1", "0", "AgentNodeTest");
            bb.AddProperty("float", false, "testVar_2", "0", "AgentNodeTest");
            bb.AddProperty("float", false, "testVar_3", "0", "AgentNodeTest");
            bb.AddProperty("string", false, "testVar_str_0", "", "AgentNodeTest");
            bb.AddProperty("string", false, "testVar_str_1", "", "AgentNodeTest");
            bb.AddProperty("int", false, "waiting_timeout_interval", "0", "AgentNodeTest");
            bb.AddProperty("TestNS::Float2", false, "testFloat2", "{x=0;y=0;}", "AgentNodeTest");

            // CustomPropertyAgent
            bb = new AgentProperties("CustomPropertyAgent");
            agent_type_blackboards["CustomPropertyAgent"] = bb;
            bb.AddProperty("bool", false, "BoolMemberReadonly", "false", "CustomPropertyAgent");
            bb.AddProperty("float", false, "FloatPropertyReadonly", "0", "CustomPropertyAgent");
            bb.AddProperty("int", true, "IntMemberConst", "0", "CustomPropertyAgent");
            bb.AddProperty("int", false, "IntProperty", "0", "CustomPropertyAgent");
            bb.AddProperty("UnityEngine::Vector3", false, "Location", "{x=0;y=0;z=0;}", "CustomPropertyAgent");
            bb.AddProperty("string", false, "StringMemberReadonly", "", "CustomPropertyAgent");
            bb.AddProperty("bool", false, "c_Bool", "false", "CustomPropertyAgent");
            bb.AddProperty("vector<int>", false, "c_IntArray", "0:", "CustomPropertyAgent");
            bb.AddProperty("string", true, "c_StaticString", "", "CustomPropertyAgent");
            bb.AddProperty("TNS::NE::NAT::eColor", false, "c_Enum", "RED", "CustomPropertyAgent");
            bb.AddProperty("UnityEngine::Vector3", false, "c_Location", "{x=0;y=0;z=0;}", "CustomPropertyAgent");

            // ParTestAgentBase
            bb = new AgentProperties("ParTestAgentBase");
            agent_type_blackboards["ParTestAgentBase"] = bb;
            bb.AddProperty("bool", true, "STV_BOOL_0", "false", "ParTestAgentBase");
            bb.AddProperty("char", true, "STV_CHAR_0", "", "ParTestAgentBase");
            bb.AddProperty("TNS::NE::NAT::eColor", true, "STV_ECOLOR_0", "RED", "ParTestAgentBase");
            bb.AddProperty("vector<bool>", true, "STV_LIST_BOOL_0", "0:", "ParTestAgentBase");
            bb.AddProperty("vector<char>", true, "STV_LIST_CHAR_0", "0:", "ParTestAgentBase");
            bb.AddProperty("vector<TNS::NE::NAT::eColor>", true, "STV_LIST_ECOLOR_0", "0:", "ParTestAgentBase");
            bb.AddProperty("vector<sbyte>", true, "STV_LIST_SBYTE_0", "0:", "ParTestAgentBase");
            bb.AddProperty("bool", false, "TV_BOOL_0", "false", "ParTestAgentBase");
            bb.AddProperty("byte", false, "TV_BYTE_0", "0", "ParTestAgentBase");
            bb.AddProperty("char", false, "TV_CHAR_0", "", "ParTestAgentBase");
            bb.AddProperty("TNS::NE::NAT::eColor", false, "TV_ECOLOR_0", "RED", "ParTestAgentBase");
            bb.AddProperty("vector<bool>", false, "TV_LIST_BOOL_0", "0:", "ParTestAgentBase");
            bb.AddProperty("vector<byte>", false, "TV_LIST_BYTE_0", "0:", "ParTestAgentBase");
            bb.AddProperty("vector<char>", false, "TV_LIST_CHAR_0", "0:", "ParTestAgentBase");
            bb.AddProperty("vector<TNS::NE::NAT::eColor>", false, "TV_LIST_ECOLOR_0", "0:", "ParTestAgentBase");
            bb.AddProperty("vector<sbyte>", false, "TV_LIST_SBYTE_0", "0:", "ParTestAgentBase");
            bb.AddProperty("sbyte", false, "TV_SBYTE_0", "0", "ParTestAgentBase");

            // ParTestAgent
            bb = new AgentProperties("ParTestAgent");
            agent_type_blackboards["ParTestAgent"] = bb;
            bb.AddProperty("int", true, "STV_INT_0", "0", "ParTestAgent");
            bb.AddProperty("TNS::ST::PER::WRK::kEmployee", true, "STV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "ParTestAgent");
            bb.AddProperty("vector<int>", true, "STV_LIST_INT_0", "0:", "ParTestAgent");
            bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", true, "STV_LIST_KEMPLOYEE_0", "0:", "ParTestAgent");
            bb.AddProperty("int", false, "TV_INT_0", "0", "ParTestAgent");
            bb.AddProperty("TNS::ST::PER::WRK::kEmployee", false, "TV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "ParTestAgent");
            bb.AddProperty("vector<int>", false, "TV_LIST_INT_0", "0:", "ParTestAgent");
            bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", false, "TV_LIST_KEMPLOYEE_0", "0:", "ParTestAgent");
            bb.AddProperty("long", false, "TV_LONG_0", "0", "ParTestAgent");
            bb.AddProperty("short", false, "TV_SHORT_0", "0", "ParTestAgent");
            bb.AddProperty("ushort", false, "TV_USHORT_0", "0", "ParTestAgent");
            bb.AddProperty("bool", true, "STV_BOOL_0", "false", "ParTestAgent");
            bb.AddProperty("char", true, "STV_CHAR_0", "", "ParTestAgent");
            bb.AddProperty("TNS::NE::NAT::eColor", true, "STV_ECOLOR_0", "RED", "ParTestAgent");
            bb.AddProperty("vector<bool>", true, "STV_LIST_BOOL_0", "0:", "ParTestAgent");
            bb.AddProperty("vector<char>", true, "STV_LIST_CHAR_0", "0:", "ParTestAgent");
            bb.AddProperty("vector<TNS::NE::NAT::eColor>", true, "STV_LIST_ECOLOR_0", "0:", "ParTestAgent");
            bb.AddProperty("vector<sbyte>", true, "STV_LIST_SBYTE_0", "0:", "ParTestAgent");
            bb.AddProperty("bool", false, "TV_BOOL_0", "false", "ParTestAgent");
            bb.AddProperty("byte", false, "TV_BYTE_0", "0", "ParTestAgent");
            bb.AddProperty("char", false, "TV_CHAR_0", "", "ParTestAgent");
            bb.AddProperty("TNS::NE::NAT::eColor", false, "TV_ECOLOR_0", "RED", "ParTestAgent");
            bb.AddProperty("vector<bool>", false, "TV_LIST_BOOL_0", "0:", "ParTestAgent");
            bb.AddProperty("vector<byte>", false, "TV_LIST_BYTE_0", "0:", "ParTestAgent");
            bb.AddProperty("vector<char>", false, "TV_LIST_CHAR_0", "0:", "ParTestAgent");
            bb.AddProperty("vector<TNS::NE::NAT::eColor>", false, "TV_LIST_ECOLOR_0", "0:", "ParTestAgent");
            bb.AddProperty("vector<sbyte>", false, "TV_LIST_SBYTE_0", "0:", "ParTestAgent");
            bb.AddProperty("sbyte", false, "TV_SBYTE_0", "0", "ParTestAgent");

            // EmployeeParTestAgent
            bb = new AgentProperties("EmployeeParTestAgent");
            agent_type_blackboards["EmployeeParTestAgent"] = bb;
            bb.AddProperty("behaviac::Agent*", true, "STV_AGENT_0", "null", "EmployeeParTestAgent");
            bb.AddProperty("float", true, "STV_F_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("vector<behaviac::Agent*>", true, "STV_LIST_AGENT_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<float>", true, "STV_LIST_F_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<string>", true, "STV_LIST_STR_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("string", true, "STV_STR_0", "", "EmployeeParTestAgent");
            bb.AddProperty("behaviac::Agent*", false, "TV_AGENT_0", "null", "EmployeeParTestAgent");
            bb.AddProperty("string", false, "TV_CSZSTR_0", "", "EmployeeParTestAgent");
            bb.AddProperty("double", false, "TV_D_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("float", false, "TV_F_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("vector<behaviac::Agent*>", false, "TV_LIST_AGENT_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<float>", false, "TV_LIST_F_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<string>", false, "TV_LIST_STR_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("long", false, "TV_LL_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("string", false, "TV_STR_0", "", "EmployeeParTestAgent");
            bb.AddProperty("uint", false, "TV_UINT_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("ulong", false, "TV_ULL_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("ulong", false, "TV_ULONG_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("int", true, "STV_INT_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("TNS::ST::PER::WRK::kEmployee", true, "STV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "EmployeeParTestAgent");
            bb.AddProperty("vector<int>", true, "STV_LIST_INT_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", true, "STV_LIST_KEMPLOYEE_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("int", false, "TV_INT_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("TNS::ST::PER::WRK::kEmployee", false, "TV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "EmployeeParTestAgent");
            bb.AddProperty("vector<int>", false, "TV_LIST_INT_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", false, "TV_LIST_KEMPLOYEE_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("long", false, "TV_LONG_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("short", false, "TV_SHORT_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("ushort", false, "TV_USHORT_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("bool", true, "STV_BOOL_0", "false", "EmployeeParTestAgent");
            bb.AddProperty("char", true, "STV_CHAR_0", "", "EmployeeParTestAgent");
            bb.AddProperty("TNS::NE::NAT::eColor", true, "STV_ECOLOR_0", "RED", "EmployeeParTestAgent");
            bb.AddProperty("vector<bool>", true, "STV_LIST_BOOL_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<char>", true, "STV_LIST_CHAR_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<TNS::NE::NAT::eColor>", true, "STV_LIST_ECOLOR_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<sbyte>", true, "STV_LIST_SBYTE_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("bool", false, "TV_BOOL_0", "false", "EmployeeParTestAgent");
            bb.AddProperty("byte", false, "TV_BYTE_0", "0", "EmployeeParTestAgent");
            bb.AddProperty("char", false, "TV_CHAR_0", "", "EmployeeParTestAgent");
            bb.AddProperty("TNS::NE::NAT::eColor", false, "TV_ECOLOR_0", "RED", "EmployeeParTestAgent");
            bb.AddProperty("vector<bool>", false, "TV_LIST_BOOL_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<byte>", false, "TV_LIST_BYTE_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<char>", false, "TV_LIST_CHAR_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<TNS::NE::NAT::eColor>", false, "TV_LIST_ECOLOR_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("vector<sbyte>", false, "TV_LIST_SBYTE_0", "0:", "EmployeeParTestAgent");
            bb.AddProperty("sbyte", false, "TV_SBYTE_0", "0", "EmployeeParTestAgent");

            // FSMAgentTest
            bb = new AgentProperties("FSMAgentTest");
            agent_type_blackboards["FSMAgentTest"] = bb;
            bb.AddProperty("FSMAgentTest::EMessage", false, "Message", "Invalid", "FSMAgentTest");
            bb.AddProperty("int", false, "InactiveCount", "0", "FSMAgentTest");
            bb.AddProperty("uint", false, "ActiveCount", "0", "FSMAgentTest");
            bb.AddProperty("short", false, "PauseCount", "0", "FSMAgentTest");
            bb.AddProperty("long", false, "ExitCount", "0", "FSMAgentTest");
            bb.AddProperty("int", false, "FoodCount", "0", "FSMAgentTest");
            bb.AddProperty("int", false, "EnergyCount", "0", "FSMAgentTest");

            // HTNAgentHouseBase
            bb = new AgentProperties("HTNAgentHouseBase");
            agent_type_blackboards["HTNAgentHouseBase"] = bb;
            bb.AddProperty("int", false, "Money", "0", "HTNAgentHouseBase");

            // HTNAgentHouse
            bb = new AgentProperties("HTNAgentHouse");
            agent_type_blackboards["HTNAgentHouse"] = bb;
            bb.AddProperty("int", false, "Money", "0", "HTNAgentHouse");
            bb.AddProperty("bool", false, "Land", "false", "HTNAgentHouse");
            bb.AddProperty("bool", false, "GoodCredit", "true", "HTNAgentHouse");
            bb.AddProperty("bool", false, "Contract", "false", "HTNAgentHouse");
            bb.AddProperty("bool", false, "Permit", "false", "HTNAgentHouse");
            bb.AddProperty("bool", false, "HouseBuilt", "false", "HTNAgentHouse");
            bb.AddProperty("bool", false, "Mortgage", "false", "HTNAgentHouse");
            bb.AddProperty("bool", false, "House", "false", "HTNAgentHouse");

            // ParTestRegNameAgent
            bb = new AgentProperties("ParTestRegNameAgent");
            agent_type_blackboards["ParTestRegNameAgent"] = bb;
            bb.AddProperty("TNS::ST::PER::WRK::kEmployee", true, "STV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "ParTestRegNameAgent");
            bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", true, "STV_LIST_KEMPLOYEE_0", "0:", "ParTestRegNameAgent");
            bb.AddProperty("vector<sbyte>", true, "STV_LIST_SBYTE_0", "0:", "ParTestRegNameAgent");
            bb.AddProperty("behaviac::Agent*", false, "TV_AGENT_0", "null", "ParTestRegNameAgent");
            bb.AddProperty("byte", false, "TV_BYTE_0", "0", "ParTestRegNameAgent");
            bb.AddProperty("char", false, "TV_CHAR_0", "", "ParTestRegNameAgent");
            bb.AddProperty("TNS::ST::PER::WRK::kEmployee", false, "TV_KEMPLOYEE_0", "{boss=null;car={brand=\"\";color=RED;price=0;};code=A;id=0;isMale=false;name=\"\";skinColor=RED;weight=0;}", "ParTestRegNameAgent");
            bb.AddProperty("vector<TNS::ST::PER::WRK::kEmployee>", false, "TV_LIST_KEMPLOYEE_0", "0:", "ParTestRegNameAgent");
            bb.AddProperty("sbyte", false, "TV_SBYTE_0", "0", "ParTestRegNameAgent");
            bb.AddProperty("string", false, "TV_STR_0", "", "ParTestRegNameAgent");

            // PreconEffectorAgent
            bb = new AgentProperties("PreconEffectorAgent");
            agent_type_blackboards["PreconEffectorAgent"] = bb;
            bb.AddProperty("int", false, "count_both", "0", "PreconEffectorAgent");
            bb.AddProperty("int", false, "count_failure", "0", "PreconEffectorAgent");
            bb.AddProperty("int", false, "count_success", "0", "PreconEffectorAgent");
            bb.AddProperty("int", false, "ret", "0", "PreconEffectorAgent");

            // PropertyReadonlyAgent
            bb = new AgentProperties("PropertyReadonlyAgent");
            agent_type_blackboards["PropertyReadonlyAgent"] = bb;
            bb.AddProperty("int", false, "MemberReadonly", "0", "PropertyReadonlyAgent");
            bb.AddProperty("int", false, "MemberReadonlyAs", "0", "PropertyReadonlyAgent");
            bb.AddProperty("int", false, "PropertyGetterOnly", "0", "PropertyReadonlyAgent");
            bb.AddProperty("int", false, "PropertyGetterSetter", "0", "PropertyReadonlyAgent");
            bb.AddProperty("int", false, "c_IntReadonly", "10", "PropertyReadonlyAgent");
            bb.AddProperty("int", false, "c_Int", "1", "PropertyReadonlyAgent");
            bb.AddProperty("int", true, "c_ResultStatic", "0", "PropertyReadonlyAgent");

            // StaticAgent
            bb = new AgentProperties("StaticAgent");
            agent_type_blackboards["StaticAgent"] = bb;
            bb.AddProperty("int", true, "sInt", "0", "StaticAgent");

            // ---------------------------------------------------------------------
            // tasks
            // ---------------------------------------------------------------------

            Agent.CTagObjectDescriptor objectDesc;
            CCustomMethod customeMethod;

            // AgentNodeTest
            objectDesc    = Agent.GetDescriptorByName("AgentNodeTest");
            customeMethod = new CTaskMethod("AgentNodeTest", "root");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("AgentNodeTest", "event_test_int");
            customeMethod.AddParamType("int");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("AgentNodeTest", "event_test_int_bool");
            customeMethod.AddParamType("int");
            customeMethod.AddParamType("bool");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("AgentNodeTest", "event_test_int_bool_float");
            customeMethod.AddParamType("int");
            customeMethod.AddParamType("bool");
            customeMethod.AddParamType("float");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("AgentNodeTest", "event_test_void");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("AgentNodeTest", "task_test");
            customeMethod.AddParamType("int");
            customeMethod.AddParamType("float");
            objectDesc.ms_methods.Add(customeMethod);

            // HTNAgentHouse
            objectDesc    = Agent.GetDescriptorByName("HTNAgentHouse");
            customeMethod = new CTaskMethod("HTNAgentHouse", "root");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("HTNAgentHouse", "root");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("HTNAgentHouse", "build_house");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("HTNAgentHouse", "construct");
            objectDesc.ms_methods.Add(customeMethod);

            // HTNAgentTravel
            objectDesc    = Agent.GetDescriptorByName("HTNAgentTravel");
            customeMethod = new CTaskMethod("HTNAgentTravel", "root");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("HTNAgentTravel", "root");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("HTNAgentTravel", "travel");
            customeMethod.AddParamType("int");
            customeMethod.AddParamType("int");
            objectDesc.ms_methods.Add(customeMethod);

            customeMethod = new CTaskMethod("HTNAgentTravel", "travel_by_air");
            customeMethod.AddParamType("int");
            customeMethod.AddParamType("int");
            objectDesc.ms_methods.Add(customeMethod);
        }
コード例 #7
0
        protected override void load(int version, string agentType, List<property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];

                if (p.name == "ReferenceBehavior")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        string typeName = null;
                        this.m_referencedBehaviorPath_var = Condition.LoadRight(p.value, ref typeName);
                    }
                    else
                    {
                        //method
                        this.m_referencedBehaviorPath_m = Action.LoadMethod(p.value);
                    }

                    string szTreePath = this.GetReferencedTree(null);

                    //conservatively make it true
                    bool bHasEvents = true;
                    if (!string.IsNullOrEmpty(szTreePath))
                    {
                        BehaviorTree behaviorTree = Workspace.Instance.LoadBehaviorTree(szTreePath);
                        Debug.Check(behaviorTree != null);

                        if (behaviorTree != null)
                        {
                            bHasEvents = behaviorTree.HasEvents();
                        }

                        this.m_bHasEvents |= bHasEvents;
                    }
                }
                else if (p.name == "Task")
                {
                    Debug.Check(!string.IsNullOrEmpty(p.value));
                    CMethodBase m = Action.LoadMethod(p.value);
                    Debug.Check(m is CTaskMethod);

                    this.m_taskMethod = m as CTaskMethod;
                }
                else
                {
                    //Debug.Check(0, "unrecognised property %s", p.name);
                }
            }
        }
コード例 #8
0
        private static bool load_xml(byte[] pBuffer)
        {
            try
            {
                Debug.Check(pBuffer != null);
                string xml = System.Text.Encoding.UTF8.GetString(pBuffer);

                SecurityParser xmlDoc = new SecurityParser();
                xmlDoc.LoadXml(xml);

                SecurityElement rootNode = xmlDoc.ToXml();

                if (rootNode.Children == null || rootNode.Tag != "agents" && rootNode.Children.Count != 1)
                {
                    return(false);
                }

                string versionStr = rootNode.Attribute("version");
                Debug.Check(!string.IsNullOrEmpty(versionStr));

                foreach (SecurityElement bbNode in rootNode.Children)
                {
                    if (bbNode.Tag == "agent" && bbNode.Children != null)
                    {
                        string agentType = bbNode.Attribute("type").Replace("::", ".");

                        AgentProperties bb = new AgentProperties(agentType);
                        agent_type_blackboards[agentType] = bb;

                        foreach (SecurityElement propertiesNode in bbNode.Children)
                        {
                            if (propertiesNode.Tag == "properties" && propertiesNode.Children != null)
                            {
                                foreach (SecurityElement propertyNode in propertiesNode.Children)
                                {
                                    if (propertyNode.Tag == "property")
                                    {
                                        string name      = propertyNode.Attribute("name");
                                        string type      = propertyNode.Attribute("type").Replace("::", ".");
                                        string memberStr = propertyNode.Attribute("member");
                                        bool   bIsMember = false;

                                        if (!string.IsNullOrEmpty(memberStr) && memberStr == "true")
                                        {
                                            bIsMember = true;
                                        }

                                        string isStatic  = propertyNode.Attribute("static");
                                        bool   bIsStatic = false;

                                        if (!string.IsNullOrEmpty(isStatic) && isStatic == "true")
                                        {
                                            bIsStatic = true;
                                        }

                                        //string agentTypeMember = agentType;
                                        string agentTypeMember = null;
                                        string valueStr        = null;

                                        if (!bIsMember)
                                        {
                                            valueStr = propertyNode.Attribute("defaultvalue");
                                        }
                                        else
                                        {
                                            agentTypeMember = propertyNode.Attribute("agent").Replace("::", ".");
                                        }

                                        bb.AddProperty(type, bIsStatic, name, valueStr, agentTypeMember);
                                    }
                                }
                            }
                            else if (propertiesNode.Tag == "methods" && propertiesNode.Children != null)
                            {
                                Agent.CTagObjectDescriptor objectDesc = Agent.GetDescriptorByName(agentType);
                                foreach (SecurityElement methodNode in propertiesNode.Children)
                                {
                                    if (methodNode.Tag == "method")
                                    {
                                        //string eventStr = methodNode.Attribute("isevent");
                                        //bool bEvent = (eventStr == "true");
                                        //string taskStr = methodNode.Attribute("istask");
                                        //bool bTask = (taskStr == "true");
                                        //skip those other custom method
                                        string methodName = methodNode.Attribute("name");
                                        //string type = methodNode.Attribute("returntype").Replace("::", ".");
                                        //string isStatic = methodNode.Attribute("static");
                                        //string agentTypeStr = methodNode.Attribute("agent").Replace("::", ".");
                                        CCustomMethod customeMethod = new CTaskMethod(agentType, methodName);

                                        if (methodNode.Children != null)
                                        {
                                            foreach (SecurityElement paramNode in methodNode.Children)
                                            {
                                                if (paramNode.Tag == "parameter")
                                                {
                                                    string paramName = paramNode.Attribute("name");
                                                    Debug.Check(!string.IsNullOrEmpty(paramName));

                                                    string paramType = paramNode.Attribute("type");

                                                    //string paramFullName = string.Format("{0}::{1}", paramType, paramName);

                                                    customeMethod.AddParamType(paramType);
                                                }
                                            }
                                        }

                                        objectDesc.ms_methods.Add(customeMethod);
                                    }
                                } //end of for methodNode
                            }     //end of methods
                        }         //end of for propertiesNode
                    }
                }                 //end of for bbNode

                return(true);
            }
            catch (Exception e)
            {
                Debug.Check(false, e.Message);
            }

            Debug.Check(false);
            return(false);
        }