public static void ByteArray(ref byte[] arr, string label) { if (Scribe.mode == LoadSaveMode.Saving) { if (arr != null) { byte[] array = CompressUtility.Compress(arr); if (array.Length < arr.Length) { string text = DataExposeUtility.AddLineBreaksToLongString(Convert.ToBase64String(array)); Scribe_Values.Look <string>(ref text, label + "Deflate", null, false); } else { string text2 = DataExposeUtility.AddLineBreaksToLongString(Convert.ToBase64String(arr)); Scribe_Values.Look <string>(ref text2, label, null, false); } } } if (Scribe.mode == LoadSaveMode.LoadingVars) { string text3 = null; Scribe_Values.Look <string>(ref text3, label + "Deflate", null, false); if (text3 != null) { arr = CompressUtility.Decompress(Convert.FromBase64String(DataExposeUtility.RemoveLineBreaks(text3))); } else { Scribe_Values.Look <string>(ref text3, label, null, false); if (text3 != null) { arr = Convert.FromBase64String(DataExposeUtility.RemoveLineBreaks(text3)); } else { arr = null; } } } }
public static void WriteMetaHeader() { if (Scribe.EnterNode("meta")) { try { string currentVersionStringWithRev = VersionControl.CurrentVersionStringWithRev; Scribe_Values.Look <string>(ref currentVersionStringWithRev, "gameVersion", null, false); List <string> list = (from mod in LoadedModManager.RunningMods select mod.Identifier).ToList <string>(); Scribe_Collections.Look <string>(ref list, "modIds", LookMode.Undefined, new object[0]); List <string> list2 = (from mod in LoadedModManager.RunningMods select mod.Name).ToList <string>(); Scribe_Collections.Look <string>(ref list2, "modNames", LookMode.Undefined, new object[0]); } finally { Scribe.ExitNode(); } } }
public static void LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode mode, bool logVersionConflictWarning) { ScribeMetaHeaderUtility.loadedGameVersion = "Unknown"; ScribeMetaHeaderUtility.loadedModIdsList = null; ScribeMetaHeaderUtility.loadedModNamesList = null; ScribeMetaHeaderUtility.lastMode = mode; if (Scribe.mode != LoadSaveMode.Inactive && Scribe.EnterNode("meta")) { try { Scribe_Values.Look <string>(ref ScribeMetaHeaderUtility.loadedGameVersion, "gameVersion", null, false); Scribe_Collections.Look <string>(ref ScribeMetaHeaderUtility.loadedModIdsList, "modIds", LookMode.Undefined, new object[0]); Scribe_Collections.Look <string>(ref ScribeMetaHeaderUtility.loadedModNamesList, "modNames", LookMode.Undefined, new object[0]); } finally { Scribe.ExitNode(); } } if (logVersionConflictWarning) { if (mode == ScribeMetaHeaderUtility.ScribeHeaderMode.Map || !UnityData.isEditor) { if (!ScribeMetaHeaderUtility.VersionsMatch()) { Log.Warning(string.Concat(new object[] { "Loaded file (", mode, ") is from version ", ScribeMetaHeaderUtility.loadedGameVersion, ", we are running version ", VersionControl.CurrentVersionStringWithRev, "." }), false); } } } }
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); }
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); }
public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref canChangeTerrainOnDestroyed, "canChangeTerrainOnDestroyed", defaultValue: true); }
public void ExposeData() { Scribe_Values.Look(ref uniqueID, "uniqueID", -1); Scribe_Values.Look(ref generationTick, "generationTick", 0); Scribe_Deep.Look(ref info, "mapInfo"); if (Scribe.mode == LoadSaveMode.Saving) { compressor = new MapFileCompressor(this); compressor.BuildCompressedString(); ExposeComponents(); compressor.ExposeData(); HashSet <string> hashSet = new HashSet <string>(); if (Scribe.EnterNode("things")) { try { foreach (Thing allThing in listerThings.AllThings) { try { if (allThing.def.isSaveable && !allThing.IsSaveCompressible()) { if (hashSet.Contains(allThing.ThingID)) { Log.Error("Saving Thing with already-used ID " + allThing.ThingID); } else { hashSet.Add(allThing.ThingID); } Thing target = allThing; Scribe_Deep.Look(ref target, "thing"); } } catch (OutOfMemoryException) { throw; } catch (Exception ex2) { Log.Error(string.Concat("Exception saving ", allThing, ": ", ex2)); } } } finally { Scribe.ExitNode(); } } else { Log.Error("Could not enter the things node while saving."); } compressor = null; } else { if (Scribe.mode == LoadSaveMode.LoadingVars) { ConstructComponents(); regionAndRoomUpdater.Enabled = false; compressor = new MapFileCompressor(this); } ExposeComponents(); DeepProfiler.Start("Load compressed things"); compressor.ExposeData(); DeepProfiler.End(); DeepProfiler.Start("Load non-compressed things"); Scribe_Collections.Look(ref loadedFullThings, "things", LookMode.Deep); DeepProfiler.End(); } }
public void ExposeData() { Scribe_Defs.Look <ThingDef>(ref this.thingDef, "thingDef"); Scribe_Values.Look <int>(ref this.count, "count", 1, false); }
public override void CompExposeData() { Scribe_Values.Look <int>(ref this.ticksToHeal, "ticksToHeal", 0, false); }
public virtual void ExposeData() { Scribe_Values.Look <int>(ref this.ticksAbs, "ticksAbs", 0, false); Scribe_Values.Look <int>(ref this.randSeed, "randSeed", 0, false); }
public void ExposeData() { Scribe_Values.Look(ref ticksGameInt, "ticksGame", 0); Scribe_Values.Look(ref gameStartAbsTick, "gameStartAbsTick", 0); Scribe_Values.Look(ref startingYearInt, "startingYear", 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); }
public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref sendAICoreRequestReminder, "sendAICoreRequestReminder", defaultValue: false); }
public override void ExposeData() { base.ExposeData(); Scribe_Values.Look <int>(ref this.ticksToDetonation, "ticksToDetonation", 0, false); }
public void ExposeData() { Scribe_Values.Look(ref prioritizedCell, "prioritizedCell"); Scribe_Defs.Look(ref prioritizedWorkGiver, "prioritizedWorkGiver"); Scribe_Values.Look(ref prioritizeTick, "prioritizeTick", 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; } }
public override void CompExposeData() { Scribe_Values.Look <bool>(ref this.discovered, "discovered", false, false); }
public override void PostExposeData() { Scribe_Values.Look(ref glowOnInt, "glowOn", defaultValue: false); }
public void ExposeData() { Scribe_References.Look <Thing>(ref this.thing, "thing", false); Scribe_Values.Look <int>(ref this.count, "count", 1, false); }
public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref disappearAtTick, "disappearAtTick", -1); }
public override void CompExposeData() { Scribe_Values.Look <int>(ref this.tendTick, "tendTick", -999999, false); Scribe_Values.Look <float>(ref this.tendQuality, "tendQuality", 0f, false); Scribe_Values.Look <int>(ref this.tendedCount, "tendedCount", 0, false); }
public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref targetStartedDowned, "targetStartDowned", defaultValue: false); }
public void ExposeData() { Scribe_Values.Look <int>(ref this.ticksGameInt, "ticksGame", 0, false); Scribe_Values.Look <int>(ref this.gameStartAbsTick, "gameStartAbsTick", 0, false); Scribe_Values.Look <int>(ref this.startingYearInt, "startingYear", 0, false); }
public override void CompExposeData() { Scribe_Values.Look(ref discovered, "discovered", defaultValue: false); }
public override void CompExposeData() { base.CompExposeData(); Scribe_Values.Look <float>(ref this.severityPerDayNotImmuneRandomFactor, "severityPerDayNotImmuneRandomFactor", 1f, false); }
public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref ticksToDetonation, "ticksToDetonation"); }
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 (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(); } }
public override void CompExposeData() { Scribe_Values.Look <float>(ref this.infectionChanceFactorFromTendRoom, "infectionChanceFactor", 0f, false); Scribe_Values.Look <int>(ref this.ticksUntilInfect, "ticksUntilInfect", -2, false); }