예제 #1
0
 public string Take <T>(string pathRelToParent, IExposable parent)
 {
     for (int i = 0; i < this.idsRead.Count; i++)
     {
         if (this.idsRead[i].parent == parent && this.idsRead[i].pathRelToParent == pathRelToParent)
         {
             string targetLoadID = this.idsRead[i].targetLoadID;
             if (typeof(T) != this.idsRead[i].targetType)
             {
                 Log.Error(string.Concat(new object[]
                 {
                     "Trying to get load ID of object of type ",
                     typeof(T),
                     ", but it was registered as ",
                     this.idsRead[i].targetType,
                     ". pathRelToParent=",
                     pathRelToParent,
                     ", parent=",
                     parent.ToStringSafe <IExposable>()
                 }));
             }
             this.idsRead.RemoveAt(i);
             return(targetLoadID);
         }
     }
     Log.Error("Could not get load ID. We're asking for something which was never added during LoadingVars. pathRelToParent=" + pathRelToParent + ", parent=" + parent.ToStringSafe <IExposable>());
     return(null);
 }
예제 #2
0
 public string Take <T>(string pathRelToParent, IExposable parent)
 {
     for (int i = 0; i < idsRead.Count; i++)
     {
         IdRecord idRecord = idsRead[i];
         if (idRecord.parent == parent)
         {
             IdRecord idRecord2 = idsRead[i];
             if (idRecord2.pathRelToParent == pathRelToParent)
             {
                 IdRecord idRecord3      = idsRead[i];
                 string   targetLoadID   = idRecord3.targetLoadID;
                 Type     typeFromHandle = typeof(T);
                 IdRecord idRecord4      = idsRead[i];
                 if (typeFromHandle != idRecord4.targetType)
                 {
                     object[] obj = new object[8]
                     {
                         "Trying to get load ID of object of type ",
                         typeof(T),
                         ", but it was registered as ",
                         null,
                         null,
                         null,
                         null,
                         null
                     };
                     IdRecord idRecord5 = idsRead[i];
                     obj[3] = idRecord5.targetType;
                     obj[4] = ". pathRelToParent=";
                     obj[5] = pathRelToParent;
                     obj[6] = ", parent=";
                     obj[7] = parent.ToStringSafe();
                     Log.Error(string.Concat(obj));
                 }
                 idsRead.RemoveAt(i);
                 return(targetLoadID);
             }
         }
     }
     Log.Error("Could not get load ID. We're asking for something which was never added during LoadingVars. pathRelToParent=" + pathRelToParent + ", parent=" + parent.ToStringSafe());
     return(null);
 }
예제 #3
0
 public void RegisterLoadIDReadFromXml(string targetLoadID, Type targetType, string pathRelToParent, IExposable parent)
 {
     for (int i = 0; i < this.idsRead.Count; i++)
     {
         if (this.idsRead[i].parent == parent && this.idsRead[i].pathRelToParent == pathRelToParent)
         {
             Log.Error(string.Concat(new string[]
             {
                 "Tried to register the same load ID twice: ",
                 targetLoadID,
                 ", pathRelToParent=",
                 pathRelToParent,
                 ", parent=",
                 parent.ToStringSafe <IExposable>()
             }));
             return;
         }
     }
     this.idsRead.Add(new LoadIDsWantedBank.IdRecord(targetLoadID, targetType, pathRelToParent, parent));
 }
예제 #4
0
 public static void Look <T>(ref T target, bool saveDestroyedThings, string label, params object[] ctorArgs)
 {
     if (Scribe.mode == LoadSaveMode.Saving)
     {
         Thing thing = target as Thing;
         if (thing != null && thing.Destroyed)
         {
             if (!saveDestroyedThings)
             {
                 Log.Warning(string.Concat(new object[]
                 {
                     "Deep-saving destroyed thing ",
                     thing,
                     " with saveDestroyedThings==false. label=",
                     label
                 }), false);
             }
             else if (thing.Discarded)
             {
                 Log.Warning(string.Concat(new object[]
                 {
                     "Deep-saving discarded thing ",
                     thing,
                     ". This mode means that the thing is no longer managed by anything in the code and should not be deep-saved anywhere. (even with saveDestroyedThings==true) , label=",
                     label
                 }), false);
             }
         }
         IExposable exposable = target as IExposable;
         if (target != null && exposable == null)
         {
             Log.Error(string.Concat(new object[]
             {
                 "Cannot use LookDeep to save non-IExposable non-null ",
                 label,
                 " of type ",
                 typeof(T)
             }), false);
             return;
         }
         if (target == null)
         {
             if (Scribe.EnterNode(label))
             {
                 try
                 {
                     Scribe.saver.WriteAttribute("IsNull", "True");
                 }
                 finally
                 {
                     Scribe.ExitNode();
                 }
             }
         }
         else if (Scribe.EnterNode(label))
         {
             try
             {
                 if (target.GetType() != typeof(T) || typeof(T).IsGenericTypeDefinition)
                 {
                     Scribe.saver.WriteAttribute("Class", GenTypes.GetTypeNameWithoutIgnoredNamespaces(target.GetType()));
                 }
                 exposable.ExposeData();
             }
             catch (OutOfMemoryException)
             {
                 throw;
             }
             catch (Exception ex)
             {
                 Log.Error(string.Concat(new object[]
                 {
                     "Exception while saving ",
                     exposable.ToStringSafe <IExposable>(),
                     ": ",
                     ex
                 }), false);
             }
             finally
             {
                 Scribe.ExitNode();
             }
         }
         Scribe.saver.loadIDsErrorsChecker.RegisterDeepSaved(target, label);
     }
     else if (Scribe.mode == LoadSaveMode.LoadingVars)
     {
         try
         {
             target = ScribeExtractor.SaveableFromNode <T>(Scribe.loader.curXmlParent[label], ctorArgs);
         }
         catch (Exception ex2)
         {
             Log.Error(string.Concat(new object[]
             {
                 "Exception while loading ",
                 Scribe.loader.curXmlParent[label].ToStringSafe <XmlElement>(),
                 ": ",
                 ex2
             }), false);
             target = default(T);
         }
     }
 }
예제 #5
0
 public List <string> TakeList(string pathRelToParent, IExposable parent)
 {
     for (int i = 0; i < this.idListsRead.Count; i++)
     {
         if (this.idListsRead[i].parent == parent && this.idListsRead[i].pathRelToParent == pathRelToParent)
         {
             List <string> targetLoadIDs = this.idListsRead[i].targetLoadIDs;
             this.idListsRead.RemoveAt(i);
             return(targetLoadIDs);
         }
     }
     Log.Error("Could not get load IDs list. We're asking for something which was never added during LoadingVars. pathRelToParent=" + pathRelToParent + ", parent=" + parent.ToStringSafe <IExposable>());
     return(new List <string>());
 }
예제 #6
0
 public void RegisterLoadIDListReadFromXml(List <string> targetLoadIDList, string pathRelToParent, IExposable parent)
 {
     for (int i = 0; i < this.idListsRead.Count; i++)
     {
         if (this.idListsRead[i].parent == parent && this.idListsRead[i].pathRelToParent == pathRelToParent)
         {
             Log.Error("Tried to register the same list of load IDs twice. pathRelToParent=" + pathRelToParent + ", parent=" + parent.ToStringSafe <IExposable>());
             return;
         }
     }
     this.idListsRead.Add(new LoadIDsWantedBank.IdListRecord(targetLoadIDList, pathRelToParent, parent));
 }
예제 #7
0
 public void RegisterLoadIDReadFromXml(string targetLoadID, Type targetType, string pathRelToParent, IExposable parent)
 {
     for (int i = 0; i < idsRead.Count; i++)
     {
         if (idsRead[i].parent == parent && idsRead[i].pathRelToParent == pathRelToParent)
         {
             Log.Error("Tried to register the same load ID twice: " + targetLoadID + ", pathRelToParent=" + pathRelToParent + ", parent=" + parent.ToStringSafe());
             return;
         }
     }
     idsRead.Add(new IdRecord(targetLoadID, targetType, pathRelToParent, parent));
 }
예제 #8
0
 public string Take <T>(string pathRelToParent, IExposable parent)
 {
     for (int i = 0; i < idsRead.Count; i++)
     {
         if (idsRead[i].parent == parent && idsRead[i].pathRelToParent == pathRelToParent)
         {
             string targetLoadID = idsRead[i].targetLoadID;
             if (typeof(T) != idsRead[i].targetType)
             {
                 Log.Error("Trying to get load ID of object of type " + typeof(T) + ", but it was registered as " + idsRead[i].targetType + ". pathRelToParent=" + pathRelToParent + ", parent=" + parent.ToStringSafe());
             }
             idsRead.RemoveAt(i);
             return(targetLoadID);
         }
     }
     Log.Error("Could not get load ID. We're asking for something which was never added during LoadingVars. pathRelToParent=" + pathRelToParent + ", parent=" + parent.ToStringSafe());
     return(null);
 }
예제 #9
0
 public List <string> TakeList(string pathRelToParent, IExposable parent)
 {
     for (int i = 0; i < idListsRead.Count; i++)
     {
         IdListRecord idListRecord = idListsRead[i];
         if (idListRecord.parent == parent)
         {
             IdListRecord idListRecord2 = idListsRead[i];
             if (idListRecord2.pathRelToParent == pathRelToParent)
             {
                 IdListRecord  idListRecord3 = idListsRead[i];
                 List <string> targetLoadIDs = idListRecord3.targetLoadIDs;
                 idListsRead.RemoveAt(i);
                 return(targetLoadIDs);
             }
         }
     }
     Log.Error("Could not get load IDs list. We're asking for something which was never added during LoadingVars. pathRelToParent=" + pathRelToParent + ", parent=" + parent.ToStringSafe());
     return(new List <string>());
 }
예제 #10
0
 public void RegisterLoadIDListReadFromXml(List <string> targetLoadIDList, string pathRelToParent, IExposable parent)
 {
     for (int i = 0; i < idListsRead.Count; i++)
     {
         IdListRecord idListRecord = idListsRead[i];
         if (idListRecord.parent == parent)
         {
             IdListRecord idListRecord2 = idListsRead[i];
             if (idListRecord2.pathRelToParent == pathRelToParent)
             {
                 Log.Error("Tried to register the same list of load IDs twice. pathRelToParent=" + pathRelToParent + ", parent=" + parent.ToStringSafe());
                 return;
             }
         }
     }
     idListsRead.Add(new IdListRecord(targetLoadIDList, pathRelToParent, parent));
 }