Example #1
0
 public void ExposeData()
 {
     Scribe_Values.Look <int>(ref this.uniqueID, "uniqueID", -1, false);
     Scribe_Deep.Look <MapInfo>(ref this.info, "mapInfo", new object[0]);
     if (Scribe.mode == LoadSaveMode.Saving)
     {
         this.compressor = new MapFileCompressor(this);
         this.compressor.BuildCompressedString();
         this.ExposeComponents();
         this.compressor.ExposeData();
         HashSet <string> hashSet = new HashSet <string>();
         if (Scribe.EnterNode("things"))
         {
             try
             {
                 foreach (Thing current in this.listerThings.AllThings)
                 {
                     try
                     {
                         if (current.def.isSaveable && !current.IsSaveCompressible())
                         {
                             if (hashSet.Contains(current.ThingID))
                             {
                                 Log.Error("Saving Thing with already-used ID " + current.ThingID, false);
                             }
                             else
                             {
                                 hashSet.Add(current.ThingID);
                             }
                             Thing thing = current;
                             Scribe_Deep.Look <Thing>(ref thing, "thing", new object[0]);
                         }
                     }
                     catch (OutOfMemoryException)
                     {
                         throw;
                     }
                     catch (Exception ex)
                     {
                         Log.Error(string.Concat(new object[]
                         {
                             "Exception saving ",
                             current,
                             ": ",
                             ex
                         }), false);
                     }
                 }
             }
             finally
             {
                 Scribe.ExitNode();
             }
         }
         else
         {
             Log.Error("Could not enter the things node while saving.", false);
         }
         this.compressor = null;
     }
     else
     {
         if (Scribe.mode == LoadSaveMode.LoadingVars)
         {
             this.ConstructComponents();
             this.regionAndRoomUpdater.Enabled = false;
             this.compressor = new MapFileCompressor(this);
         }
         this.ExposeComponents();
         DeepProfiler.Start("Load compressed things");
         this.compressor.ExposeData();
         DeepProfiler.End();
         DeepProfiler.Start("Load non-compressed things");
         Scribe_Collections.Look <Thing>(ref this.loadedFullThings, "things", LookMode.Deep, new object[0]);
         DeepProfiler.End();
     }
 }
Example #2
0
 public override void ExposeData()
 {
     Scribe_Values.Look <string>(ref this.firstInt, "first", null, false);
     Scribe_Values.Look <string>(ref this.nickInt, "nick", null, false);
     Scribe_Values.Look <string>(ref this.lastInt, "last", null, false);
 }
Example #3
0
 public override void PostExposeData()
 {
     Scribe_Values.Look(ref glowOnInt, "glowOn", defaultValue: false);
 }
 public override void ExposeData()
 {
     base.ExposeData();
     Scribe_Values.Look(ref disappearAtTick, "disappearAtTick", -1);
 }
 public override void CompExposeData()
 {
     Scribe_Values.Look <int>(ref this.ticksToHeal, "ticksToHeal", 0, false);
 }
Example #6
0
 public void ExposeData()
 {
     Scribe_Values.Look <float>(ref this.realPlayTimeInteracting, "realPlayTimeInteracting", 0f, false);
     Scribe_Values.Look <bool>(ref this.permadeathMode, "permadeathMode", false, false);
     Scribe_Values.Look <string>(ref this.permadeathModeUniqueName, "permadeathModeUniqueName", null, false);
 }
Example #7
0
 public override void PostExposeData()
 {
     Scribe_Values.Look <bool>(ref this.glowOnInt, "glowOn", false, false);
 }
 public void ExposeData()
 {
     Scribe_Values.Look <IntVec3>(ref this.prioritizedCell, "prioritizedCell", default(IntVec3), false);
     Scribe_Defs.Look <WorkTypeDef>(ref this.prioritizedWorkType, "prioritizedWorkType");
     Scribe_Values.Look <int>(ref this.prioritizeTick, "prioritizeTick", 0, false);
 }
Example #9
0
 public override void ExposeData()
 {
     base.ExposeData();
     Scribe_Values.Look <int>(ref this.ticksToDetonation, "ticksToDetonation", 0, false);
 }
 public override void CompExposeData()
 {
     base.CompExposeData();
     Scribe_Values.Look <float>(ref this.severityPerDayNotImmuneRandomFactor, "severityPerDayNotImmuneRandomFactor", 1f, false);
 }
Example #11
0
 public override void CompExposeData()
 {
     Scribe_Values.Look(ref infectionChanceFactorFromTendRoom, "infectionChanceFactor", 0f);
     Scribe_Values.Look(ref ticksUntilInfect, "ticksUntilInfect", -2);
 }
 public static void Look <T>(ref List <T> list, bool saveDestroyedThings, string label, LookMode lookMode = LookMode.Undefined, params object[] ctorArgs)
 {
     if (lookMode == LookMode.Undefined)
     {
         if (ParseHelper.HandlesType(typeof(T)))
         {
             lookMode = LookMode.Value;
         }
         else if (typeof(T) == typeof(LocalTargetInfo))
         {
             lookMode = LookMode.LocalTargetInfo;
         }
         else if (typeof(T) == typeof(TargetInfo))
         {
             lookMode = LookMode.TargetInfo;
         }
         else if (typeof(T) == typeof(GlobalTargetInfo))
         {
             lookMode = LookMode.GlobalTargetInfo;
         }
         else if (typeof(Def).IsAssignableFrom(typeof(T)))
         {
             lookMode = LookMode.Def;
         }
         else
         {
             if (!typeof(IExposable).IsAssignableFrom(typeof(T)) || typeof(ILoadReferenceable).IsAssignableFrom(typeof(T)))
             {
                 Log.Error("LookList call with a list of " + typeof(T) + " must have lookMode set explicitly.");
                 return;
             }
             lookMode = LookMode.Deep;
         }
     }
     if (Scribe.EnterNode(label))
     {
         try
         {
             if (Scribe.mode == LoadSaveMode.Saving)
             {
                 if (list == null)
                 {
                     Scribe.saver.WriteAttribute("IsNull", "True");
                 }
                 else
                 {
                     foreach (T current in list)
                     {
                         if (lookMode == LookMode.Value)
                         {
                             T t = current;
                             Scribe_Values.Look <T>(ref t, "li", default(T), true);
                         }
                         else if (lookMode == LookMode.LocalTargetInfo)
                         {
                             LocalTargetInfo localTargetInfo = (LocalTargetInfo)((object)current);
                             Scribe_TargetInfo.Look(ref localTargetInfo, saveDestroyedThings, "li");
                         }
                         else if (lookMode == LookMode.TargetInfo)
                         {
                             TargetInfo targetInfo = (TargetInfo)((object)current);
                             Scribe_TargetInfo.Look(ref targetInfo, saveDestroyedThings, "li");
                         }
                         else if (lookMode == LookMode.GlobalTargetInfo)
                         {
                             GlobalTargetInfo globalTargetInfo = (GlobalTargetInfo)((object)current);
                             Scribe_TargetInfo.Look(ref globalTargetInfo, saveDestroyedThings, "li");
                         }
                         else if (lookMode == LookMode.Def)
                         {
                             Def def = (Def)((object)current);
                             Scribe_Defs.Look <Def>(ref def, "li");
                         }
                         else if (lookMode == LookMode.Deep)
                         {
                             T t2 = current;
                             Scribe_Deep.Look <T>(ref t2, saveDestroyedThings, "li", ctorArgs);
                         }
                         else if (lookMode == LookMode.Reference)
                         {
                             ILoadReferenceable loadReferenceable = (ILoadReferenceable)((object)current);
                             Scribe_References.Look <ILoadReferenceable>(ref loadReferenceable, "li", saveDestroyedThings);
                         }
                     }
                 }
             }
             else if (Scribe.mode == LoadSaveMode.LoadingVars)
             {
                 XmlNode      curXmlParent = Scribe.loader.curXmlParent;
                 XmlAttribute xmlAttribute = curXmlParent.Attributes["IsNull"];
                 if (xmlAttribute != null && xmlAttribute.Value.ToLower() == "true")
                 {
                     list = null;
                 }
                 else if (lookMode == LookMode.Value)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     foreach (XmlNode subNode in curXmlParent.ChildNodes)
                     {
                         T item = ScribeExtractor.ValueFromNode <T>(subNode, default(T));
                         list.Add(item);
                     }
                 }
                 else if (lookMode == LookMode.Deep)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     foreach (XmlNode subNode2 in curXmlParent.ChildNodes)
                     {
                         T item2 = ScribeExtractor.SaveableFromNode <T>(subNode2, ctorArgs);
                         list.Add(item2);
                     }
                 }
                 else if (lookMode == LookMode.Def)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     foreach (XmlNode subNode3 in curXmlParent.ChildNodes)
                     {
                         T item3 = ScribeExtractor.DefFromNodeUnsafe <T>(subNode3);
                         list.Add(item3);
                     }
                 }
                 else if (lookMode == LookMode.LocalTargetInfo)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     int num = 0;
                     foreach (XmlNode node in curXmlParent.ChildNodes)
                     {
                         LocalTargetInfo localTargetInfo2 = ScribeExtractor.LocalTargetInfoFromNode(node, num.ToString(), LocalTargetInfo.Invalid);
                         T item4 = (T)((object)localTargetInfo2);
                         list.Add(item4);
                         num++;
                     }
                 }
                 else if (lookMode == LookMode.TargetInfo)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     int num2 = 0;
                     foreach (XmlNode node2 in curXmlParent.ChildNodes)
                     {
                         TargetInfo targetInfo2 = ScribeExtractor.TargetInfoFromNode(node2, num2.ToString(), TargetInfo.Invalid);
                         T          item5       = (T)((object)targetInfo2);
                         list.Add(item5);
                         num2++;
                     }
                 }
                 else if (lookMode == LookMode.GlobalTargetInfo)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     int num3 = 0;
                     foreach (XmlNode node3 in curXmlParent.ChildNodes)
                     {
                         GlobalTargetInfo globalTargetInfo2 = ScribeExtractor.GlobalTargetInfoFromNode(node3, num3.ToString(), GlobalTargetInfo.Invalid);
                         T item6 = (T)((object)globalTargetInfo2);
                         list.Add(item6);
                         num3++;
                     }
                 }
                 else if (lookMode == LookMode.Reference)
                 {
                     List <string> list2 = new List <string>(curXmlParent.ChildNodes.Count);
                     foreach (XmlNode xmlNode in curXmlParent.ChildNodes)
                     {
                         list2.Add(xmlNode.InnerText);
                     }
                     Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(list2, string.Empty);
                 }
             }
             else if (Scribe.mode == LoadSaveMode.ResolvingCrossRefs)
             {
                 if (lookMode == LookMode.Reference)
                 {
                     list = Scribe.loader.crossRefs.TakeResolvedRefList <T>(string.Empty);
                 }
                 else if (lookMode == LookMode.LocalTargetInfo)
                 {
                     if (list != null)
                     {
                         for (int i = 0; i < list.Count; i++)
                         {
                             list[i] = (T)((object)ScribeExtractor.ResolveLocalTargetInfo((LocalTargetInfo)((object)list[i]), i.ToString()));
                         }
                     }
                 }
                 else if (lookMode == LookMode.TargetInfo)
                 {
                     if (list != null)
                     {
                         for (int j = 0; j < list.Count; j++)
                         {
                             list[j] = (T)((object)ScribeExtractor.ResolveTargetInfo((TargetInfo)((object)list[j]), j.ToString()));
                         }
                     }
                 }
                 else if (lookMode == LookMode.GlobalTargetInfo && list != null)
                 {
                     for (int k = 0; k < list.Count; k++)
                     {
                         list[k] = (T)((object)ScribeExtractor.ResolveGlobalTargetInfo((GlobalTargetInfo)((object)list[k]), k.ToString()));
                     }
                 }
             }
         }
         finally
         {
             Scribe.ExitNode();
         }
     }
     else if (Scribe.mode == LoadSaveMode.LoadingVars)
     {
         if (lookMode == LookMode.Reference)
         {
             Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(null, label);
         }
         list = null;
     }
 }
Example #13
0
 public override void ExposeData()
 {
     base.ExposeData();
     Scribe_Values.Look(ref canChangeTerrainOnDestroyed, "canChangeTerrainOnDestroyed", defaultValue: true);
 }
 public override void CompExposeData()
 {
     Scribe_Values.Look <float>(ref this.infectionChanceFactorFromTendRoom, "infectionChanceFactor", 0f, false);
     Scribe_Values.Look <int>(ref this.ticksUntilInfect, "ticksUntilInfect", -2, false);
 }
Example #15
0
 public override void CompExposeData()
 {
     Scribe_Values.Look <bool>(ref this.discovered, "discovered", false, false);
 }