clone() public method

public clone ( ) : PartValue
return PartValue
Beispiel #1
0
        public static List <PartValue> loadCraftFromFile(string fileName)
        {
            List <PartValue> loadedList = new List <PartValue>();
            PartValue        newValue   = new PartValue();
            StreamReader     stream     = new StreamReader(fileName); // exceptions handled by assembleCraft
            string           newLine    = string.Empty;
            int craftFileFormat         = 0;

            int.TryParse(stream.ReadLine(), out craftFileFormat);
            Utilities.debug.debugMessage(String.Concat("Loading crf file, format ", craftFileFormat, ", ", fileName));
            try
            {
                while (!stream.EndOfStream && !(newLine == "[EOF]"))
                {
                    newLine           = stream.ReadLine();
                    newValue.partName = newLine;
                    newValue.position = Utilities.parseVector3(stream.ReadLine());
                    newValue.rotation = Utilities.parseQuaternion(stream.ReadLine());
                    float.TryParse(stream.ReadLine(), out newValue.scale);
                    //Debug.Log("finding model " + newValue.partName);
                    newValue.model = findPartModel(newValue.partName);
                    //Debug.Log("model null? " + (newValue.model == null));
                    loadedList.Add(newValue.clone());
                }
            }
            catch (Exception e)
            {
                //Utilities.debug.debugMessage("load craft file error: " + e.ToString());
                Utilities.debug.debugMessage("Got expected exception from streamreader, part list done");
            }
            return(loadedList);
        }
 public static List<PartValue> loadCraftFromFile(string fileName)
 {
     List<PartValue> loadedList = new List<PartValue>();
     PartValue newValue = new PartValue();
     StreamReader stream = new StreamReader(fileName); // exceptions handled by assembleCraft
     string newLine = string.Empty;
     int craftFileFormat = 0;
     int.TryParse(stream.ReadLine(), out craftFileFormat);
     Utilities.debug.debugMessage(String.Concat("Loading crf file, format ", craftFileFormat, ", ", fileName));
     try
     {
         while (!stream.EndOfStream && !(newLine == "[EOF]"))
         {
             newLine = stream.ReadLine();
             newValue.partName = newLine;
             newValue.position = Utilities.parseVector3(stream.ReadLine());
             newValue.rotation = Utilities.parseQuaternion(stream.ReadLine());
             float.TryParse(stream.ReadLine(), out newValue.scale);
             //Debug.Log("finding model " + newValue.partName);
             newValue.model = findPartModel(newValue.partName);
             //Debug.Log("model null? " + (newValue.model == null));
             loadedList.Add(newValue.clone());
         }
     }
     catch (Exception e)
     {
         //Utilities.debug.debugMessage("load craft file error: " + e.ToString());
         Utilities.debug.debugMessage("Got expected exception from streamreader, part list done");
     }
     return loadedList;
 }