private static void load_methods(BsonDeserizer d, string agentType, BsonDeserizer.BsonTypes type) { d.OpenDocument(); type = d.ReadType(); while (type == BsonDeserizer.BsonTypes.BT_MethodElement) { d.OpenDocument(); string methodName = d.ReadString(); string agentStr = d.ReadString(); Debug.Check(!string.IsNullOrEmpty(agentStr)); type = d.ReadType(); while (type == BsonDeserizer.BsonTypes.BT_ParameterElement) { d.OpenDocument(); string paramName = d.ReadString(); Debug.Check(!string.IsNullOrEmpty(paramName)); string paramType = d.ReadString(); d.CloseDocument(true); type = d.ReadType(); } d.CloseDocument(false); type = d.ReadType(); } d.CloseDocument(false); }
protected void load_properties(int version, string agentType, BsonDeserizer d) { #if !BEHAVIAC_RELEASE SetAgentType(agentType); #endif d.OpenDocument(); //load property after loading par as property might reference par List <property_t> properties = new List <property_t>(); BsonDeserizer.BsonTypes type = d.ReadType(); while (type == BsonDeserizer.BsonTypes.BT_String) { string propertyName = d.ReadString(); string propertyValue = d.ReadString(); properties.Add(new property_t(propertyName, propertyValue)); type = d.ReadType(); } if (properties.Count > 0) { this.load(version, agentType, properties); } Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); d.CloseDocument(false); }
//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); }
protected void load_children(int version, string agentType, BsonDeserizer d) { d.OpenDocument(); BehaviorNode pChildNode = this.load(agentType, d); bool bHasEvents = pChildNode.m_bHasEvents; this.AddChild(pChildNode); this.m_bHasEvents |= bHasEvents; d.CloseDocument(false); }
protected void load_attachments(int version, string agentType, BsonDeserizer d) { d.OpenDocument(); BsonDeserizer.BsonTypes type = d.ReadType(); while (type == BsonDeserizer.BsonTypes.BT_AttachmentElement) { { d.OpenDocument(); string attachClassName = d.ReadString(); BehaviorNode pAttachment = BehaviorNode.Create(attachClassName); Debug.Check(pAttachment != null, attachClassName); if (pAttachment != null) { pAttachment.SetClassNameString(attachClassName); string idString = d.ReadString(); pAttachment.SetId(Convert.ToInt32(idString)); pAttachment.load_properties_pars_attachments_children(version, agentType, d); this.Attach(pAttachment); this.m_bHasEvents |= (pAttachment is Event); } d.CloseDocument(false); } type = d.ReadType(); } Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); d.CloseDocument(false); }
private static bool load_bson(byte[] pBuffer) { try { BsonDeserizer d = new BsonDeserizer(); if (d.Init(pBuffer)) { BsonDeserizer.BsonTypes type = d.ReadType(); if (type == BsonDeserizer.BsonTypes.BT_AgentsElement) { bool bOk = d.OpenDocument(); Debug.Check(bOk); string verStr = d.ReadString(); int version = int.Parse(verStr); string signatureStr = d.ReadString(); // signature; checkSignature(signatureStr); { type = d.ReadType(); while (type != BsonDeserizer.BsonTypes.BT_None) { if (type == BsonDeserizer.BsonTypes.BT_AgentElement) { load_agent(version, d); } type = d.ReadType(); } Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); } d.CloseDocument(false); return(true); } } } catch (Exception e) { Debug.Check(false, e.Message); } Debug.Check(false); return(false); }
protected void load_pars(int version, string agentType, BsonDeserizer d) { d.OpenDocument(); BsonDeserizer.BsonTypes type = d.ReadType(); while (type == BsonDeserizer.BsonTypes.BT_ParElement) { this.load_par(version, agentType, d); type = d.ReadType(); } Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); d.CloseDocument(false); }
protected void load_par(int version, string agentType, BsonDeserizer d) { d.OpenDocument(); string name = d.ReadString(); string type = d.ReadString().Replace("::", "."); string value = d.ReadString(); string eventParam = null; if (!d.eod()) { eventParam = d.ReadString(); } this.AddPar(type, name, value, eventParam); d.CloseDocument(true); }
public bool load_bson(byte[] pBuffer) { try { BsonDeserizer d = new BsonDeserizer(); if (d.Init(pBuffer)) { BsonDeserizer.BsonTypes type = d.ReadType(); if (type == BsonDeserizer.BsonTypes.BT_BehaviorElement) { bool bOk = d.OpenDocument(); Debug.Check(bOk); this.m_name = d.ReadString(); string agentType = d.ReadString(); string versionStr = d.ReadString(); int version = Convert.ToInt32(versionStr); this.SetClassNameString("BehaviorTree"); this.SetId(-1); this.load_properties_pars_attachments_children(version, agentType, d); d.CloseDocument(false); return(true); } } } catch (Exception e) { Debug.Check(false, e.Message); } Debug.Check(false); return(false); }
protected void load_children(int version, string agentType, BsonDeserizer d) { d.OpenDocument(); BehaviorNode pChildNode = this.load(agentType, d, version); bool bHasEvents = pChildNode.m_bHasEvents; this.AddChild(pChildNode); this.m_bHasEvents |= bHasEvents; d.CloseDocument(false); }
protected void load_properties(int version, string agentType, BsonDeserizer d) { #if !BEHAVIAC_RELEASE SetAgentType(agentType); #endif d.OpenDocument(); //load property after loading par as property might reference par List<property_t> properties = new List<property_t>(); BsonDeserizer.BsonTypes type = d.ReadType(); while (type == BsonDeserizer.BsonTypes.BT_String) { string propertyName = d.ReadString(); string propertyValue = d.ReadString(); properties.Add(new property_t(propertyName, propertyValue)); type = d.ReadType(); } if (properties.Count > 0) { this.load(version, agentType, properties); } Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); d.CloseDocument(false); }
public bool load_bson(byte[] pBuffer) { try { BsonDeserizer d = new BsonDeserizer(); if (d.Init(pBuffer)) { BsonDeserizer.BsonTypes type = d.ReadType(); if (type == BsonDeserizer.BsonTypes.BT_BehaviorElement) { bool bOk = d.OpenDocument(); Debug.Check(bOk); this.m_name = d.ReadString(); string agentType = d.ReadString().Replace("::", "."); bool bFsm = d.ReadBool(); string versionStr = d.ReadString(); int version = Convert.ToInt32(versionStr); if (version != SupportedVersion) { Debug.LogError(string.Format("'{0}' Version({1}), while Version({2}) is supported, please update runtime or rexport data using the latest designer", this.m_name, version, SupportedVersion)); } this.SetClassNameString("BehaviorTree"); this.SetId(-1); this.m_bIsFSM = bFsm; this.load_properties_pars_attachments_children(version, agentType, d, false); d.CloseDocument(false); return true; } } } catch (Exception e) { Debug.Check(false, e.Message); } Debug.Check(false); return false; }
protected BehaviorNode load_node(int version, string agentType, BsonDeserizer d) { d.OpenDocument(); BsonDeserizer.BsonTypes type = d.ReadType(); Debug.Check(type == BsonDeserizer.BsonTypes.BT_NodeElement); d.OpenDocument(); BehaviorNode node = this.load(agentType, d, version); d.CloseDocument(false); type = d.ReadType(); Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); d.CloseDocument(false); return node; }
private static bool load_agent(int version, BsonDeserizer d) { try { d.OpenDocument(); string agentType = d.ReadString().Replace("::", "."); string pBaseName = d.ReadString(); Debug.Check(!string.IsNullOrEmpty(pBaseName)); AgentProperties bb = new AgentProperties(agentType); agent_type_blackboards[agentType] = bb; BsonDeserizer.BsonTypes type = d.ReadType(); while (type != BsonDeserizer.BsonTypes.BT_None) { if (type == BsonDeserizer.BsonTypes.BT_PropertiesElement) { d.OpenDocument(); type = d.ReadType(); while (type != BsonDeserizer.BsonTypes.BT_None) { if (type == BsonDeserizer.BsonTypes.BT_PropertyElement) { d.OpenDocument(); string variableName = d.ReadString(); string typeName = d.ReadString(); string memberStr = d.ReadString(); bool bIsMember = false; if (!string.IsNullOrEmpty(memberStr) && memberStr == "true") { bIsMember = true; } string isStatic = d.ReadString(); bool bIsStatic = false; if (!string.IsNullOrEmpty(isStatic) && isStatic == "true") { bIsStatic = true; } string valueStr = null; //string agentTypeMember = agentType; string agentTypeMember = null; if (!bIsMember) { valueStr = d.ReadString(); } else { agentTypeMember = d.ReadString().Replace("::", "."); } d.CloseDocument(true); bb.AddProperty(typeName, bIsStatic, variableName, valueStr, agentTypeMember); } else { Debug.Check(false); } type = d.ReadType(); }//end of while d.CloseDocument(false); } else if (type == BsonDeserizer.BsonTypes.BT_MethodsElement) { load_methods(d, agentType, type); } else { Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); } type = d.ReadType(); } d.CloseDocument(false); return true; } catch (Exception ex) { Debug.Check(false, ex.Message); } return false; }
protected void load_attachments(int version, string agentType, BsonDeserizer d, bool bIsTransition) { d.OpenDocument(); BsonDeserizer.BsonTypes type = d.ReadType(); while (type == BsonDeserizer.BsonTypes.BT_AttachmentElement) { d.OpenDocument(); if (bIsTransition) { this.m_loadAttachment = true; this.load_properties_pars_attachments_children(version, agentType, d, false); this.m_loadAttachment = false; } else { string attachClassName = d.ReadString(); BehaviorNode pAttachment = BehaviorNode.Create(attachClassName); Debug.Check(pAttachment != null, attachClassName); if (pAttachment != null) { pAttachment.SetClassNameString(attachClassName); string idString = d.ReadString(); pAttachment.SetId(Convert.ToInt32(idString)); bool bIsPrecondition = d.ReadBool(); bool bIsEffector = d.ReadBool(); bool bAttachmentIsTransition = d.ReadBool(); pAttachment.load_properties_pars_attachments_children(version, agentType, d, bAttachmentIsTransition); this.Attach(pAttachment, bIsPrecondition, bIsEffector, bAttachmentIsTransition); this.m_bHasEvents |= (pAttachment is Event); } } d.CloseDocument(false); type = d.ReadType(); } if (type != BsonDeserizer.BsonTypes.BT_None) { if (type == BsonDeserizer.BsonTypes.BT_ParsElement) { this.load_pars(version, agentType, d); } else if (type == BsonDeserizer.BsonTypes.BT_AttachmentsElement) { this.load_attachments(version, agentType, d, bIsTransition); this.m_bHasEvents |= this.HasEvents(); } else { Debug.Check(false); } type = d.ReadType(); } Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); d.CloseDocument(false); }
private static bool load_agent(int version, BsonDeserizer d) { try { d.OpenDocument(); string agentType = d.ReadString().Replace("::", "."); string pBaseName = d.ReadString(); Debug.Check(!string.IsNullOrEmpty(pBaseName)); AgentProperties bb = new AgentProperties(agentType); agent_type_blackboards[agentType] = bb; BsonDeserizer.BsonTypes type = d.ReadType(); while (type != BsonDeserizer.BsonTypes.BT_None) { if (type == BsonDeserizer.BsonTypes.BT_PropertiesElement) { d.OpenDocument(); type = d.ReadType(); while (type != BsonDeserizer.BsonTypes.BT_None) { if (type == BsonDeserizer.BsonTypes.BT_PropertyElement) { d.OpenDocument(); string variableName = d.ReadString(); string typeName = d.ReadString(); string memberStr = d.ReadString(); bool bIsMember = false; if (!string.IsNullOrEmpty(memberStr) && memberStr == "true") { bIsMember = true; } string isStatic = d.ReadString(); bool bIsStatic = false; if (!string.IsNullOrEmpty(isStatic) && isStatic == "true") { bIsStatic = true; } string valueStr = null; //string agentTypeMember = agentType; string agentTypeMember = null; if (!bIsMember) { valueStr = d.ReadString(); } else { agentTypeMember = d.ReadString(); } d.CloseDocument(true); bb.AddProperty(typeName, bIsStatic, variableName, valueStr, agentTypeMember); } else { Debug.Check(false); } type = d.ReadType(); }//end of while d.CloseDocument(false); } else if (type == BsonDeserizer.BsonTypes.BT_MethodsElement) { load_methods(d, agentType, type); } else { Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); } type = d.ReadType(); } d.CloseDocument(false); return(true); } catch (Exception ex) { Debug.Check(false, ex.Message); } return(false); }
protected void load_custom(int version, string agentType, BsonDeserizer d) { d.OpenDocument(); BsonDeserizer.BsonTypes type = d.ReadType(); Debug.Check(type == BsonDeserizer.BsonTypes.BT_NodeElement); d.OpenDocument(); BehaviorNode pChildNode = this.load(agentType, d, version); this.m_customCondition = pChildNode; d.CloseDocument(false); d.CloseDocument(false); type = d.ReadType(); Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); }
protected void load_par(int version, string agentType, BsonDeserizer d) { d.OpenDocument(); string name = d.ReadString(); string type = d.ReadString().Replace("::", "."); string value = d.ReadString(); this.AddPar(agentType, type, name, value); d.CloseDocument(true); }
public bool load_bson(byte[] pBuffer) { try { BsonDeserizer d = new BsonDeserizer(); if (d.Init(pBuffer)) { BsonDeserizer.BsonTypes type = d.ReadType(); if (type == BsonDeserizer.BsonTypes.BT_BehaviorElement) { bool bOk = d.OpenDocument(); Debug.Check(bOk); this.m_name = d.ReadString(); string agentType = d.ReadString(); string versionStr = d.ReadString(); int version = Convert.ToInt32(versionStr); this.SetClassNameString("BehaviorTree"); this.SetId(-1); this.load_properties_pars_attachments_children(version, agentType, d); d.CloseDocument(false); return true; } } } catch (Exception e) { Debug.Check(false, e.Message); } Debug.Check(false); return false; }
private static bool load_bson(byte[] pBuffer) { try { BsonDeserizer d = new BsonDeserizer(); if (d.Init(pBuffer)) { BsonDeserizer.BsonTypes type = d.ReadType(); if (type == BsonDeserizer.BsonTypes.BT_AgentsElement) { bool bOk = d.OpenDocument(); Debug.Check(bOk); string verStr = d.ReadString(); int version = int.Parse(verStr); { type = d.ReadType(); while (type != BsonDeserizer.BsonTypes.BT_None) { if (type == BsonDeserizer.BsonTypes.BT_AgentElement) { load_agent(version, d); } type = d.ReadType(); } Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); } d.CloseDocument(false); return true; } } } catch (Exception e) { Debug.Check(false, e.Message); } Debug.Check(false); return false; }
private static bool load_agent(int version, BsonDeserizer d) { try { d.OpenDocument(); string agentType = d.ReadString().Replace("::", "."); string pBaseName = d.ReadString(); Debug.Check(!string.IsNullOrEmpty(pBaseName)); uint classId = Utils.MakeVariableId(agentType); AgentMeta meta = AgentMeta.GetMeta(classId); if (meta == null) { meta = new AgentMeta(); _agentMetas[classId] = meta; } BsonDeserizer.BsonTypes type = d.ReadType(); while (type != BsonDeserizer.BsonTypes.BT_None) { if (type == BsonDeserizer.BsonTypes.BT_PropertiesElement) { d.OpenDocument(); type = d.ReadType(); while (type != BsonDeserizer.BsonTypes.BT_None) { if (type == BsonDeserizer.BsonTypes.BT_PropertyElement) { d.OpenDocument(); string propName = d.ReadString(); string propType = d.ReadString(); string memberStr = d.ReadString(); bool bIsMember = (!string.IsNullOrEmpty(memberStr) && memberStr == "true"); string isStatic = d.ReadString(); bool bIsStatic = (!string.IsNullOrEmpty(isStatic) && isStatic == "true"); string valueStr = null; string agentTypeMember = null; if (!bIsMember) { valueStr = d.ReadString(); } else { agentTypeMember = d.ReadString(); } if (!bIsMember) { registerCustomizedProperty(meta, propName, propType, valueStr, bIsStatic); } d.CloseDocument(true); } else { Debug.Check(false); } type = d.ReadType(); }//end of while d.CloseDocument(false); } else if (type == BsonDeserizer.BsonTypes.BT_MethodsElement) { load_methods(d, agentType, type); } else { Debug.Check(type == BsonDeserizer.BsonTypes.BT_None); } type = d.ReadType(); } d.CloseDocument(false); return(true); } catch (Exception ex) { Debug.Check(false, ex.Message); } return(false); }