示例#1
0
 public void FromNodeRow(Nodes.NodeRow nodeRow)
 {
     if (!nodeRow.IsIDNull())
     {
         ID = Convert.ToInt32(nodeRow.ID);
     }
     if (!nodeRow.IsEntityNull())
     {
         Entity = Convert.ToInt32(nodeRow.Entity);
     }
     if (!nodeRow.IsRadiusNull())
     {
         Radius = Convert.ToInt32(nodeRow.Radius);
     }
     if (!nodeRow.IsFlagNull())
     {
         Flags = Convert.ToInt32(nodeRow.Flag);
     }
     if (!nodeRow.IsGroupNull())
     {
         Group = Convert.ToInt32(nodeRow.Group);
     }
     if (!nodeRow.IsTeamNull())
     {
         Team = Convert.ToInt32(nodeRow.Team);
     }
     if (!nodeRow.IsConnection1Null())
     {
         Connect1 = Convert.ToInt32(nodeRow.Connection1);
     }
     if (!nodeRow.IsConnection2Null())
     {
         Connect2 = Convert.ToInt32(nodeRow.Connection2);
     }
     if (!nodeRow.IsConnection3Null())
     {
         Connect3 = Convert.ToInt32(nodeRow.Connection3);
     }
     if (!nodeRow.IsConnection4Null())
     {
         Connect4 = Convert.ToInt32(nodeRow.Connection4);
     }
     if (!nodeRow.IsPositionXNull())
     {
         Position = Convert.ToInt32(nodeRow.PositionX);
     }
     if (!nodeRow.IsPositionYNull())
     {
         Position = Convert.ToInt32(nodeRow.PositionY);
     }
     if (!nodeRow.IsPositionZNull())
     {
         Position = Convert.ToInt32(nodeRow.PositionZ);
     }
 }
示例#2
0
        public static void WriteNodes(string fileName, Nodes nodes)
        {
            fileName = GetNodeFile(fileName);
            StringBuilder buff     = new StringBuilder();
            StringBuilder execBuff = new StringBuilder();

            int startNode = 0;
            int endNode   = 99;
            int count     = 0;

            foreach (DataRow row in nodes.Node.Rows)
            {
                Nodes.NodeRow nodeRow = (Nodes.NodeRow)row;

                if (nodeRow.ID == null)
                {
                    continue;
                }

                buff.Append("node_resetlinks " + nodeRow.ID + ";");

                // set flags
                if (!nodeRow.IsFlagNull())
                {
                    buff.Append("node_flag " + nodeRow.ID + " " + nodeRow.Flag + ";");
                }

                // connection
                if (!nodeRow.IsConnection1Null() && nodeRow.Connection1 != "-1")
                {
                    buff.Append("node_connect " + nodeRow.ID + " " + nodeRow.Connection1 + ";");
                }

                // connection
                if (!nodeRow.IsConnection2Null() && nodeRow.Connection2 != "-1")
                {
                    buff.Append("node_connect " + nodeRow.ID + " " + nodeRow.Connection2 + ";");
                }

                // connection
                if (!nodeRow.IsConnection3Null() && nodeRow.Connection3 != "-1")
                {
                    buff.Append("node_connect " + nodeRow.ID + " " + nodeRow.Connection3 + ";");
                }

                // connection
                if (!nodeRow.IsConnection4Null() && nodeRow.Connection4 != "-1")
                {
                    buff.Append("node_connect " + nodeRow.ID + " " + nodeRow.Connection4 + ";");
                }

                // entity
                if (!nodeRow.IsEntityNull())
                {
                    buff.Append("node_ent " + nodeRow.ID + " " + nodeRow.Entity + ";");
                }

                // team
                if (!nodeRow.IsTeamNull())
                {
                    buff.Append("node_team " + nodeRow.ID + " " + nodeRow.Team + ";");
                }

                // group
                if (!nodeRow.IsGroupNull())
                {
                    buff.Append("node_group " + nodeRow.ID + " " + nodeRow.Group + ";");
                }

                // radius
                if (!nodeRow.IsRadiusNull())
                {
                    buff.Append("node_radius " + nodeRow.ID + " " + nodeRow.Radius + ";");
                }

                buff.Append("\r\n");

                count++;

                if (count > endNode)
                {
                    string subConfigFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + startNode + "_" + endNode + ".cfg";
                    WriteConfig(subConfigFileName, buff);
                    buff      = new StringBuilder();
                    startNode = endNode + 1;
                    endNode   = startNode + 99;
                    execBuff.Append("exec " + subConfigFileName + "\r\n");
                }
            }

            if (buff.Length > 0)
            {
                string subConfigFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + startNode + "_" + (count - 1) + ".cfg";
                WriteConfig(subConfigFileName, buff);
                execBuff.Append("exec " + subConfigFileName + "\r\n");
            }

            WriteConfig(fileName, execBuff);
        }