protected void ExportAttachments(BsonSerializer file, Node node) { //int localVars = ReferencedBehaviorLocalVars(node); int localVars = 0; if (node.Attachments.Count > 0 || localVars > 0) { file.WriteStartElement("attachments"); //this.ExportReferencedBehaviorLocalVars(node, file); foreach (Attachments.Attachment a in node.Attachments) { if (!a.Enable) { continue; } file.WriteStartElement("attachment"); Type type = a.GetType(); file.WriteString(a.ExportClass); file.WriteString(a.Id.ToString()); file.WriteBool(a.IsPrecondition); bool bIsEffector = a.IsEffector; if (a.IsTransition) { bIsEffector = false; } file.WriteBool(bIsEffector); file.WriteBool(a.IsTransition); this.ExportProperties(file, a); //this.ExportEventLocalVars(a, file); file.WriteEndElement(); } file.WriteEndElement(); } }
/// <summary> /// Exports a behaviour to the given file. /// </summary> /// <param name="file">The file we want to export to.</param> /// <param name="behavior">The behaviour we want to export.</param> protected void ExportBehavior(BsonSerializer file, BehaviorNode behavior) { file.WriteComment("EXPORTED BY TOOL, DON'T MODIFY IT!"); file.WriteComment("Source File: " + behavior.MakeRelative(behavior.FileManager.Filename)); file.WriteStartElement("behavior"); Behavior b = behavior as Behavior; Debug.Check(b != null); Debug.Check(b.Id == -1); //'\\' ->'/' string behaviorName = b.MakeRelative(b.Filename); behaviorName = behaviorName.Replace('\\', '/'); int pos = behaviorName.IndexOf(".xml"); if (pos != -1) { behaviorName = behaviorName.Remove(pos); } file.WriteString(behaviorName); file.WriteString(b.AgentType.AgentTypeName); file.WriteBool(b.IsFSM); file.WriteString(b.Version.ToString()); this.ExportProperties(file, b); this.ExportPars(file, b); if (!b.IsFSM) { this.ExportAttachments(file, b); } if (b.IsFSM) { file.WriteStartElement("node"); file.WriteString("FSM"); file.WriteString("-1"); file.WriteStartElement("properties"); file.WriteAttributeString("initialid", behavior.InitialStateId.ToString()); file.WriteEndElement(); foreach (Node child in ((Node)behavior).FSMNodes) { this.ExportNode(file, behavior, child); } file.WriteEndElement(); } else { // export the children foreach (Node child in ((Node)behavior).Children) { this.ExportNode(file, behavior, child); } } file.WriteEndElement(); }